提交 8b04346f 编写于 作者: S serb

7166296:...

7166296: closed/java/awt/Frame/DisabledParentOfToplevel/DisabledParentOfToplevel.html failed since 1.8.0b36
Reviewed-by: anthony, art
上级 ec8f21d4
......@@ -87,18 +87,22 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
private final T target;
// Container peer. It may not be the peer of the target's direct
// parent, for example, in the case of hw/lw mixing. However,
// let's skip this scenario for the time being. We also assume
// the container peer is not null, which might also be false if
// addNotify() is called for a component outside of the hierarchy.
// The exception is LWWindowPeers: their parents are always null
private LWContainerPeer containerPeer;
// Handy reference to the top-level window peer. Window peer is
// borrowed from the containerPeer in constructor, and should also
// be updated when the component is reparented to another container
private LWWindowPeer windowPeer;
/**
* Container peer. It may not be the peer of the target's direct parent, for
* example, in the case of hw/lw mixing. However, let's skip this scenario
* for the time being. We also assume the container peer is not null, which
* might also be false if addNotify() is called for a component outside of
* the hierarchy. The exception is LWWindowPeers: their containers are
* always null
*/
private final LWContainerPeer containerPeer;
/**
* Handy reference to the top-level window peer. Window peer is borrowed
* from the containerPeer in constructor, and should also be updated when
* the component is reparented to another container
*/
private final LWWindowPeer windowPeer;
private final AtomicBoolean disposed = new AtomicBoolean(false);
......@@ -183,13 +187,13 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
this.target = target;
this.platformComponent = platformComponent;
initializeContainerPeer();
// Container peer is always null for LWWindowPeers, so
// windowPeer is always null for them as well. On the other
// hand, LWWindowPeer shouldn't use windowPeer at all
if (containerPeer != null) {
windowPeer = containerPeer.getWindowPeerOrSelf();
}
final Container container = SunToolkit.getNativeContainer(target);
containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
: null;
// don't bother about z-order here as updateZOrder()
// will be called from addNotify() later anyway
if (containerPeer != null) {
......@@ -356,15 +360,6 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
return containerPeer;
}
// Just a helper method
// Overridden in LWWindowPeer to skip containerPeer initialization
protected void initializeContainerPeer() {
Container parent = LWToolkit.getNativeContainer(target);
if (parent != null) {
containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(parent);
}
}
public PlatformWindow getPlatformWindow() {
LWWindowPeer windowPeer = getWindowPeer();
return windowPeer.getPlatformWindow();
......
......@@ -201,11 +201,6 @@ public class LWWindowPeer
return this;
}
@Override
protected void initializeContainerPeer() {
// No-op as LWWindowPeer doesn't have any containerPeer
}
// ---- PEER METHODS ---- //
@Override
......
......@@ -1051,11 +1051,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
return parent;
}
// This method is overriden in the Window class to return null,
// This method is overridden in the Window class to return null,
// because the parent field of the Window object contains
// the owner of the window, not its parent.
Container getContainer() {
return getParent();
return getParent_NoClientCode();
}
/**
......@@ -8194,10 +8194,10 @@ public abstract class Component implements ImageObserver, MenuContainer,
* Fetches the native container somewhere higher up in the component
* tree that contains this component.
*/
Container getNativeContainer() {
Container p = parent;
final Container getNativeContainer() {
Container p = getContainer();
while (p != null && p.peer instanceof LightweightPeer) {
p = p.getParent_NoClientCode();
p = p.getContainer();
}
return p;
}
......
......@@ -3914,7 +3914,7 @@ public class Window extends Container implements Accessible {
// ************************** MIXING CODE *******************************
// A window has a parent, but it does NOT have a container
// A window has an owner, but it does NOT have a container
@Override
final Container getContainer() {
return null;
......
......@@ -759,9 +759,7 @@ public abstract class WComponentPeer extends WObjectPeer
WComponentPeer(Component target) {
this.target = target;
this.paintArea = new RepaintArea();
Container parent = WToolkit.getNativeContainer(target);
WComponentPeer parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent);
create(parentPeer);
create(getNativeParent());
// fix for 5088782: check if window object is created successfully
checkCreation();
......@@ -771,6 +769,17 @@ public abstract class WComponentPeer extends WObjectPeer
}
abstract void create(WComponentPeer parent);
/**
* Gets the native parent of this peer. We use the term "parent" explicitly,
* because we override the method in top-level window peer implementations.
*
* @return the parent container/owner of this peer.
*/
WComponentPeer getNativeParent() {
Container parent = SunToolkit.getNativeContainer((Component) target);
return (WComponentPeer) WToolkit.targetToPeer(parent);
}
protected void checkCreation()
{
if ((hwnd == 0) || (pData == 0))
......
......@@ -215,6 +215,12 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
createAwtWindow(parent);
}
@Override
final WComponentPeer getNativeParent() {
final Container owner = ((Window) target).getOwner();
return (WComponentPeer) WToolkit.targetToPeer(owner);
}
// should be overriden in WDialogPeer
protected void realShow() {
super.show();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册