提交 a7c51f9c 编写于 作者: A anthony

6607660: java.awt.Container.getMouseEventTargetImpl should be invoked while holding the TreeLock

Summary: The body of the method has been wrapped into the synchronized (getTreeLock()) { } block.
Reviewed-by: son, art
上级 11b1ddf8
...@@ -2267,6 +2267,7 @@ public class Container extends Component { ...@@ -2267,6 +2267,7 @@ public class Container extends Component {
EventTargetFilter filter, EventTargetFilter filter,
boolean searchHeavyweightChildren, boolean searchHeavyweightChildren,
boolean searchHeavyweightDescendants) { boolean searchHeavyweightDescendants) {
synchronized (getTreeLock()) {
int ncomponents = this.ncomponents; int ncomponents = this.ncomponents;
Component component[] = this.component; Component component[] = this.component;
...@@ -2279,11 +2280,12 @@ public class Container extends Component { ...@@ -2279,11 +2280,12 @@ public class Container extends Component {
!(comp.peer instanceof LightweightPeer))) && !(comp.peer instanceof LightweightPeer))) &&
comp.contains(x - comp.x, y - comp.y)) { comp.contains(x - comp.x, y - comp.y)) {
// found a component that intersects the point, see if there is // found a component that intersects the point, see if there
// a deeper possibility. // is a deeper possibility.
if (comp instanceof Container) { if (comp instanceof Container) {
Container child = (Container) comp; Container child = (Container) comp;
Component deeper = child.getMouseEventTarget(x - child.x, Component deeper = child.getMouseEventTarget(
x - child.x,
y - child.y, y - child.y,
includeSelf, includeSelf,
filter, filter,
...@@ -2293,8 +2295,8 @@ public class Container extends Component { ...@@ -2293,8 +2295,8 @@ public class Container extends Component {
} }
} else { } else {
if (filter.accept(comp)) { if (filter.accept(comp)) {
// there isn't a deeper target, but this component is a // there isn't a deeper target, but this component
// target // is a target
return comp; return comp;
} }
} }
...@@ -2307,14 +2309,15 @@ public class Container extends Component { ...@@ -2307,14 +2309,15 @@ public class Container extends Component {
isPeerOK = (peer instanceof LightweightPeer) || includeSelf; isPeerOK = (peer instanceof LightweightPeer) || includeSelf;
isMouseOverMe = contains(x,y); isMouseOverMe = contains(x,y);
// didn't find a child target, return this component if it's a possible // didn't find a child target, return this component if it's
// target // a possible target
if (isMouseOverMe && isPeerOK && filter.accept(this)) { if (isMouseOverMe && isPeerOK && filter.accept(this)) {
return this; return this;
} }
// no possible target // no possible target
return null; return null;
} }
}
static interface EventTargetFilter { static interface EventTargetFilter {
boolean accept(final Component comp); boolean accept(final Component comp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册