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