Bug 737758: Part 2 V2: Address Windows abnormality (identify _faked_ pixel scrolls). r=roc a=akeybl
authorAvi Halachmi (:avih)
Mon, 26 Mar 2012 13:34:10 +0200
changeset 92002 5096a64c4c3993ac45c486487a4ca2330d53bcb6
parent 92001 993e301d9bdb47c323b193748ff74a305c8814a5
child 92003 4e89e0ae835499519d46dbb3a7f74af7a36d701f
push idunknown
push userunknown
push dateunknown
reviewersroc, akeybl
bugs737758
milestone13.0a2
Bug 737758: Part 2 V2: Address Windows abnormality (identify _faked_ pixel scrolls). r=roc a=akeybl
content/events/src/nsEventStateManager.cpp
widget/nsGUIEvent.h
widget/windows/WinMouseScrollHandler.cpp
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -3218,18 +3218,21 @@ nsEventStateManager::PostHandleEvent(nsP
           break;
 
         case MOUSE_SCROLL_PAGE:
           DoScrollText(aTargetFrame, msEvent, nsIScrollableFrame::PAGES,
                        false);
           break;
 
         case MOUSE_SCROLL_PIXELS:
-          DoScrollText(aTargetFrame, msEvent, nsIScrollableFrame::DEVICE_PIXELS,
-                       false);
+          {
+            bool fromLines = msEvent->scrollFlags & nsMouseScrollEvent::kFromLines;
+            DoScrollText(aTargetFrame, msEvent, nsIScrollableFrame::DEVICE_PIXELS,
+                         false, nsnull, (fromLines ? nsGkAtoms::mouseWheel : nsnull));
+          }
           break;
 
         case MOUSE_SCROLL_HISTORY:
           DoScrollHistory(msEvent->delta);
           break;
 
         case MOUSE_SCROLL_ZOOM:
           DoScrollZoom(aTargetFrame, msEvent->delta);
--- a/widget/nsGUIEvent.h
+++ b/widget/nsGUIEvent.h
@@ -1279,19 +1279,24 @@ public:
                             // will compute the appropriate height/width based on
                             // view lineHeight and generate line scroll events
                             // as needed.
     kNoDefer =      1 << 5, // For scrollable views, indicates scroll should not
                             // occur asynchronously.
     kIsMomentum =   1 << 6, // Marks scroll events that aren't controlled by the
                             // user but fire automatically as the result of a
                             // "momentum" scroll.
-    kAllowSmoothScroll = 1 << 7 // Allow smooth scroll for the pixel scroll
-                                // event.
-  };
+    kAllowSmoothScroll = 1 << 7, // Allow smooth scroll for the pixel scroll
+                                 // event.
+    kFromLines =    1 << 8  // For a pixels scroll event, indicates that it
+                            // originated from a lines scroll event.
+                            // (Only used on windows which generates "faked"
+                            // pixel scroll events even for simple mouse wheel
+                            // scroll)
+};
 
   nsMouseScrollEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
     : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
       scrollFlags(0), delta(0), scrollOverflow(0)
   {
   }
 
   PRInt32               scrollFlags;
--- a/widget/windows/WinMouseScrollHandler.cpp
+++ b/widget/windows/WinMouseScrollHandler.cpp
@@ -560,22 +560,24 @@ MouseScrollHandler::HandleMouseWheelMess
   // Before dispatching line scroll event, we should get the current scroll
   // event target information for pixel scroll.
   ScrollTargetInfo scrollTargetInfo =
     GetScrollTargetInfo(aWindow, eventInfo, modKeyState);
 
   // Grab the widget, it might be destroyed by a DOM event handler.
   nsRefPtr<nsWindow> kungFuDethGrip(aWindow);
 
+  bool fromLines = false;
   nsMouseScrollEvent scrollEvent(true, NS_MOUSE_SCROLL, aWindow);
   if (mLastEventInfo.InitMouseScrollEvent(aWindow, scrollEvent,
                                           scrollTargetInfo, modKeyState)) {
     PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
       ("MouseScroll::HandleMouseWheelMessage: dispatching "
        "NS_MOUSE_SCROLL event"));
+    fromLines = true;
     DispatchEvent(aWindow, scrollEvent);
     if (aWindow->Destroyed()) {
       PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
         ("MouseScroll::HandleMouseWheelMessage: The window was destroyed "
          "by NS_MOUSE_SCROLL event"));
       mLastEventInfo.ResetTransaction();
       return;
     }
@@ -589,16 +591,17 @@ MouseScrollHandler::HandleMouseWheelMess
 #endif
 
   nsMouseScrollEvent pixelEvent(true, NS_MOUSE_PIXEL_SCROLL, aWindow);
   if (mLastEventInfo.InitMousePixelScrollEvent(aWindow, pixelEvent,
                                                scrollTargetInfo, modKeyState)) {
     PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
       ("MouseScroll::HandleMouseWheelMessage: dispatching "
        "NS_MOUSE_PIXEL_SCROLL event"));
+    pixelEvent.scrollFlags |= fromLines ? nsMouseScrollEvent::kFromLines : 0;
     DispatchEvent(aWindow, pixelEvent);
     if (aWindow->Destroyed()) {
       PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
         ("MouseScroll::HandleMouseWheelMessage: The window was destroyed "
          "by NS_MOUSE_PIXEL_SCROLL event"));
       mLastEventInfo.ResetTransaction();
       return;
     }