44 import java.util.Arrays; |
44 import java.util.Arrays; |
45 import java.util.EventListener; |
45 import java.util.EventListener; |
46 import java.util.HashSet; |
46 import java.util.HashSet; |
47 import java.util.Set; |
47 import java.util.Set; |
48 |
48 |
49 import java.util.logging.*; |
|
50 |
|
51 import javax.accessibility.*; |
49 import javax.accessibility.*; |
|
50 |
|
51 import sun.util.logging.PlatformLogger; |
52 |
52 |
53 import sun.awt.AppContext; |
53 import sun.awt.AppContext; |
54 import sun.awt.CausedFocusEvent; |
54 import sun.awt.CausedFocusEvent; |
55 import sun.awt.PeerEvent; |
55 import sun.awt.PeerEvent; |
56 import sun.awt.SunToolkit; |
56 import sun.awt.SunToolkit; |
199 * all descendant containers). |
199 * all descendant containers). |
200 */ |
200 */ |
201 private transient int numOfHWComponents = 0; |
201 private transient int numOfHWComponents = 0; |
202 private transient int numOfLWComponents = 0; |
202 private transient int numOfLWComponents = 0; |
203 |
203 |
204 private static final Logger mixingLog = Logger.getLogger("java.awt.mixing.Container"); |
204 private static final PlatformLogger mixingLog = PlatformLogger.getLogger("java.awt.mixing.Container"); |
205 |
205 |
206 /** |
206 /** |
207 * @serialField ncomponents int |
207 * @serialField ncomponents int |
208 * The number of components in this container. |
208 * The number of components in this container. |
209 * This value can be null. |
209 * This value can be null. |
1285 // Should only be called while holding tree lock |
1285 // Should only be called while holding tree lock |
1286 int numListening(long mask) { |
1286 int numListening(long mask) { |
1287 int superListening = super.numListening(mask); |
1287 int superListening = super.numListening(mask); |
1288 |
1288 |
1289 if (mask == AWTEvent.HIERARCHY_EVENT_MASK) { |
1289 if (mask == AWTEvent.HIERARCHY_EVENT_MASK) { |
1290 if (eventLog.isLoggable(Level.FINE)) { |
1290 if (eventLog.isLoggable(PlatformLogger.FINE)) { |
1291 // Verify listeningChildren is correct |
1291 // Verify listeningChildren is correct |
1292 int sum = 0; |
1292 int sum = 0; |
1293 for (Component comp : component) { |
1293 for (Component comp : component) { |
1294 sum += comp.numListening(mask); |
1294 sum += comp.numListening(mask); |
1295 } |
1295 } |
1296 if (listeningChildren != sum) { |
1296 if (listeningChildren != sum) { |
1297 eventLog.log(Level.FINE, "Assertion (listeningChildren == sum) failed"); |
1297 eventLog.fine("Assertion (listeningChildren == sum) failed"); |
1298 } |
1298 } |
1299 } |
1299 } |
1300 return listeningChildren + superListening; |
1300 return listeningChildren + superListening; |
1301 } else if (mask == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) { |
1301 } else if (mask == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) { |
1302 if (eventLog.isLoggable(Level.FINE)) { |
1302 if (eventLog.isLoggable(PlatformLogger.FINE)) { |
1303 // Verify listeningBoundsChildren is correct |
1303 // Verify listeningBoundsChildren is correct |
1304 int sum = 0; |
1304 int sum = 0; |
1305 for (Component comp : component) { |
1305 for (Component comp : component) { |
1306 sum += comp.numListening(mask); |
1306 sum += comp.numListening(mask); |
1307 } |
1307 } |
1308 if (listeningBoundsChildren != sum) { |
1308 if (listeningBoundsChildren != sum) { |
1309 eventLog.log(Level.FINE, "Assertion (listeningBoundsChildren == sum) failed"); |
1309 eventLog.fine("Assertion (listeningBoundsChildren == sum) failed"); |
1310 } |
1310 } |
1311 } |
1311 } |
1312 return listeningBoundsChildren + superListening; |
1312 return listeningBoundsChildren + superListening; |
1313 } else { |
1313 } else { |
1314 // assert false; |
1314 // assert false; |
1315 if (eventLog.isLoggable(Level.FINE)) { |
1315 if (eventLog.isLoggable(PlatformLogger.FINE)) { |
1316 eventLog.log(Level.FINE, "This code must never be reached"); |
1316 eventLog.fine("This code must never be reached"); |
1317 } |
1317 } |
1318 return superListening; |
1318 return superListening; |
1319 } |
1319 } |
1320 } |
1320 } |
1321 |
1321 |
1322 // Should only be called while holding tree lock |
1322 // Should only be called while holding tree lock |
1323 void adjustListeningChildren(long mask, int num) { |
1323 void adjustListeningChildren(long mask, int num) { |
1324 if (eventLog.isLoggable(Level.FINE)) { |
1324 if (eventLog.isLoggable(PlatformLogger.FINE)) { |
1325 boolean toAssert = (mask == AWTEvent.HIERARCHY_EVENT_MASK || |
1325 boolean toAssert = (mask == AWTEvent.HIERARCHY_EVENT_MASK || |
1326 mask == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK || |
1326 mask == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK || |
1327 mask == (AWTEvent.HIERARCHY_EVENT_MASK | |
1327 mask == (AWTEvent.HIERARCHY_EVENT_MASK | |
1328 AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)); |
1328 AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)); |
1329 if (!toAssert) { |
1329 if (!toAssert) { |
1330 eventLog.log(Level.FINE, "Assertion failed"); |
1330 eventLog.fine("Assertion failed"); |
1331 } |
1331 } |
1332 } |
1332 } |
1333 |
1333 |
1334 if (num == 0) |
1334 if (num == 0) |
1335 return; |
1335 return; |
1360 } |
1360 } |
1361 } |
1361 } |
1362 |
1362 |
1363 // Should only be called while holding tree lock |
1363 // Should only be called while holding tree lock |
1364 int countHierarchyMembers() { |
1364 int countHierarchyMembers() { |
1365 if (log.isLoggable(Level.FINE)) { |
1365 if (log.isLoggable(PlatformLogger.FINE)) { |
1366 // Verify descendantsCount is correct |
1366 // Verify descendantsCount is correct |
1367 int sum = 0; |
1367 int sum = 0; |
1368 for (Component comp : component) { |
1368 for (Component comp : component) { |
1369 sum += comp.countHierarchyMembers(); |
1369 sum += comp.countHierarchyMembers(); |
1370 } |
1370 } |
1371 if (descendantsCount != sum) { |
1371 if (descendantsCount != sum) { |
1372 log.log(Level.FINE, "Assertion (descendantsCount == sum) failed"); |
1372 log.fine("Assertion (descendantsCount == sum) failed"); |
1373 } |
1373 } |
1374 } |
1374 } |
1375 return descendantsCount + 1; |
1375 return descendantsCount + 1; |
1376 } |
1376 } |
1377 |
1377 |
3922 recursiveSubtractAndApplyShape(shape, fromZorder, getBottommostComponentIndex()); |
3922 recursiveSubtractAndApplyShape(shape, fromZorder, getBottommostComponentIndex()); |
3923 } |
3923 } |
3924 |
3924 |
3925 final void recursiveSubtractAndApplyShape(Region shape, int fromZorder, int toZorder) { |
3925 final void recursiveSubtractAndApplyShape(Region shape, int fromZorder, int toZorder) { |
3926 checkTreeLock(); |
3926 checkTreeLock(); |
3927 if (mixingLog.isLoggable(Level.FINE)) { |
3927 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
3928 mixingLog.fine("this = " + this + |
3928 mixingLog.fine("this = " + this + |
3929 "; shape=" + shape + "; fromZ=" + fromZorder + "; toZ=" + toZorder); |
3929 "; shape=" + shape + "; fromZ=" + fromZorder + "; toZ=" + toZorder); |
3930 } |
3930 } |
3931 if (fromZorder == -1) { |
3931 if (fromZorder == -1) { |
3932 return; |
3932 return; |
3959 recursiveApplyCurrentShape(fromZorder, getBottommostComponentIndex()); |
3959 recursiveApplyCurrentShape(fromZorder, getBottommostComponentIndex()); |
3960 } |
3960 } |
3961 |
3961 |
3962 final void recursiveApplyCurrentShape(int fromZorder, int toZorder) { |
3962 final void recursiveApplyCurrentShape(int fromZorder, int toZorder) { |
3963 checkTreeLock(); |
3963 checkTreeLock(); |
3964 if (mixingLog.isLoggable(Level.FINE)) { |
3964 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
3965 mixingLog.fine("this = " + this + |
3965 mixingLog.fine("this = " + this + |
3966 "; fromZ=" + fromZorder + "; toZ=" + toZorder); |
3966 "; fromZ=" + fromZorder + "; toZ=" + toZorder); |
3967 } |
3967 } |
3968 if (fromZorder == -1) { |
3968 if (fromZorder == -1) { |
3969 return; |
3969 return; |
4088 } |
4088 } |
4089 |
4089 |
4090 @Override |
4090 @Override |
4091 void mixOnHiding(boolean isLightweight) { |
4091 void mixOnHiding(boolean isLightweight) { |
4092 synchronized (getTreeLock()) { |
4092 synchronized (getTreeLock()) { |
4093 if (mixingLog.isLoggable(Level.FINE)) { |
4093 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
4094 mixingLog.fine("this = " + this + |
4094 mixingLog.fine("this = " + this + |
4095 "; isLightweight=" + isLightweight); |
4095 "; isLightweight=" + isLightweight); |
4096 } |
4096 } |
4097 if (isLightweight) { |
4097 if (isLightweight) { |
4098 recursiveHideHeavyweightChildren(); |
4098 recursiveHideHeavyweightChildren(); |
4204 * Our own mouse event for when we're dragged over from another hw |
4204 * Our own mouse event for when we're dragged over from another hw |
4205 * container |
4205 * container |
4206 */ |
4206 */ |
4207 private static final int LWD_MOUSE_DRAGGED_OVER = 1500; |
4207 private static final int LWD_MOUSE_DRAGGED_OVER = 1500; |
4208 |
4208 |
4209 private static final Logger eventLog = Logger.getLogger("java.awt.event.LightweightDispatcher"); |
4209 private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.LightweightDispatcher"); |
4210 |
4210 |
4211 LightweightDispatcher(Container nativeContainer) { |
4211 LightweightDispatcher(Container nativeContainer) { |
4212 this.nativeContainer = nativeContainer; |
4212 this.nativeContainer = nativeContainer; |
4213 mouseEventTarget = null; |
4213 mouseEventTarget = null; |
4214 eventMask = 0; |
4214 eventMask = 0; |
4346 break; |
4346 break; |
4347 case MouseEvent.MOUSE_WHEEL: |
4347 case MouseEvent.MOUSE_WHEEL: |
4348 // This may send it somewhere that doesn't have MouseWheelEvents |
4348 // This may send it somewhere that doesn't have MouseWheelEvents |
4349 // enabled. In this case, Component.dispatchEventImpl() will |
4349 // enabled. In this case, Component.dispatchEventImpl() will |
4350 // retarget the event to a parent that DOES have the events enabled. |
4350 // retarget the event to a parent that DOES have the events enabled. |
4351 if (eventLog.isLoggable(Level.FINEST) && (mouseOver != null)) { |
4351 if (eventLog.isLoggable(PlatformLogger.FINEST) && (mouseOver != null)) { |
4352 eventLog.log(Level.FINEST, "retargeting mouse wheel to " + |
4352 eventLog.finest("retargeting mouse wheel to " + |
4353 mouseOver.getName() + ", " + |
4353 mouseOver.getName() + ", " + |
4354 mouseOver.getClass()); |
4354 mouseOver.getClass()); |
4355 } |
4355 } |
4356 retargetMouseEvent(mouseOver, id, e); |
4356 retargetMouseEvent(mouseOver, id, e); |
4357 break; |
4357 break; |
4358 } |
4358 } |
4359 e.consume(); |
4359 e.consume(); |