changeset 2409:43b8a8bc8208

6920842: Wheel events do not bubbling to the browser if they was not treated in applet. Reviewed-by: art, anthony, peterz
author uta
date Wed, 14 Apr 2010 15:28:37 +0400
parents 2cafbbe9825e
children ba8ecdbf0b88
files src/share/classes/java/awt/Component.java src/share/classes/java/awt/Container.java src/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java
diffstat 3 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/Component.java	Thu Mar 18 13:53:00 2010 -0700
+++ b/src/share/classes/java/awt/Component.java	Wed Apr 14 15:28:37 2010 +0400
@@ -4941,9 +4941,13 @@
                 // If we dispatch the event to toplevel ancestor,
                 // this could encolse the loop: 6480024.
                 anc.dispatchEventToSelf(newMWE);
-            }
-        }
-        return true;
+                if (newMWE.isConsumed()) {
+                    e.consume();
+                }
+                return true;
+            }
+        }
+        return false;
     }
 
     boolean checkWindowClosingException() {
--- a/src/share/classes/java/awt/Container.java	Thu Mar 18 13:53:00 2010 -0700
+++ b/src/share/classes/java/awt/Container.java	Wed Apr 14 15:28:37 2010 +0400
@@ -4492,7 +4492,10 @@
             retargetMouseEvent(mouseOver, id, e);
         break;
             }
-            e.consume();
+            //Consuming of wheel events is implemented in "retargetMouseEvent".
+            if (id != MouseEvent.MOUSE_WHEEL) {
+                e.consume();
+            }
     }
     return e.isConsumed();
     }
@@ -4800,6 +4803,12 @@
                     target.dispatchEvent(retargeted);
                 }
             }
+            if (id == MouseEvent.MOUSE_WHEEL && retargeted.isConsumed()) {
+                //An exception for wheel bubbling to the native system.
+                //In "processMouseEvent" total event consuming for wheel events is skipped.
+                //Protection from bubbling of Java-accepted wheel events.
+                e.consume();
+            }
         }
     }
 
--- a/src/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java	Thu Mar 18 13:53:00 2010 -0700
+++ b/src/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java	Wed Apr 14 15:28:37 2010 +0400
@@ -870,6 +870,8 @@
                     orientation = SwingConstants.HORIZONTAL;
                 }
 
+                e.consume();
+
                 if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                     JViewport vp = scrollpane.getViewport();
                     if (vp == null) { return; }