mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
6607660: java.awt.Container.getMouseEventTargetImpl should be invoked while holding the TreeLock
The body of the method has been wrapped into the synchronized (getTreeLock()) { } block. Reviewed-by: son, art
This commit is contained in:
parent
f92bcde478
commit
cdf1fcc79d
1 changed files with 44 additions and 41 deletions
|
@ -2267,53 +2267,56 @@ public class Container extends Component {
|
||||||
EventTargetFilter filter,
|
EventTargetFilter filter,
|
||||||
boolean searchHeavyweightChildren,
|
boolean searchHeavyweightChildren,
|
||||||
boolean searchHeavyweightDescendants) {
|
boolean searchHeavyweightDescendants) {
|
||||||
int ncomponents = this.ncomponents;
|
synchronized (getTreeLock()) {
|
||||||
Component component[] = this.component;
|
int ncomponents = this.ncomponents;
|
||||||
|
Component component[] = this.component;
|
||||||
|
|
||||||
for (int i = 0 ; i < ncomponents ; i++) {
|
for (int i = 0 ; i < ncomponents ; i++) {
|
||||||
Component comp = component[i];
|
Component comp = component[i];
|
||||||
if (comp != null && comp.visible &&
|
if (comp != null && comp.visible &&
|
||||||
((!searchHeavyweightChildren &&
|
((!searchHeavyweightChildren &&
|
||||||
comp.peer instanceof LightweightPeer) ||
|
comp.peer instanceof LightweightPeer) ||
|
||||||
(searchHeavyweightChildren &&
|
(searchHeavyweightChildren &&
|
||||||
!(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(
|
||||||
y - child.y,
|
x - child.x,
|
||||||
includeSelf,
|
y - child.y,
|
||||||
filter,
|
includeSelf,
|
||||||
searchHeavyweightDescendants);
|
filter,
|
||||||
if (deeper != null) {
|
searchHeavyweightDescendants);
|
||||||
return deeper;
|
if (deeper != null) {
|
||||||
}
|
return deeper;
|
||||||
} else {
|
}
|
||||||
if (filter.accept(comp)) {
|
} else {
|
||||||
// there isn't a deeper target, but this component is a
|
if (filter.accept(comp)) {
|
||||||
// target
|
// there isn't a deeper target, but this component
|
||||||
return comp;
|
// is a target
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isPeerOK;
|
||||||
|
boolean isMouseOverMe;
|
||||||
|
|
||||||
|
isPeerOK = (peer instanceof LightweightPeer) || includeSelf;
|
||||||
|
isMouseOverMe = contains(x,y);
|
||||||
|
|
||||||
|
// didn't find a child target, return this component if it's
|
||||||
|
// a possible target
|
||||||
|
if (isMouseOverMe && isPeerOK && filter.accept(this)) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
// no possible target
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isPeerOK;
|
|
||||||
boolean isMouseOverMe;
|
|
||||||
|
|
||||||
isPeerOK = (peer instanceof LightweightPeer) || includeSelf;
|
|
||||||
isMouseOverMe = contains(x,y);
|
|
||||||
|
|
||||||
// didn't find a child target, return this component if it's a possible
|
|
||||||
// target
|
|
||||||
if (isMouseOverMe && isPeerOK && filter.accept(this)) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
// no possible target
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static interface EventTargetFilter {
|
static interface EventTargetFilter {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue