Title: [156219] trunk/Source
Revision
156219
Author
[email protected]
Date
2013-09-20 20:23:22 -0700 (Fri, 20 Sep 2013)

Log Message

Handle panning gestures messages properly on Windows.
https://bugs.webkit.org/show_bug.cgi?id=121711.

Reviewed by Brent Fulgham.

This fixes a number of issues with panning gestures on Windows.
1. Two finger panning in one direction can sometimes cause some unexpected scrolling 
in the other direction when the gesture first begins (directions meaning horizontal and vertical)
2. Single finger horizontal panning should only be disabled when attempting to select text.
3. Scrolling via panning should be clamped, other wise we can scroll contents completely out of the scrollview.
4. Horizontal overpan should work.
5. Overpan should occur whenever we scroll to the extents of whichever scroll view we're currently scrolling.

* WebView.cpp:
(WebView::gestureNotify):
(WebView::gesture):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollByRecursively):
* rendering/RenderLayer.h: 
Added an argument to keep track of which scrollview was actually scrolled
This is needed by the Windows port to keep track to determine whether or not
we need to overpan.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (156218 => 156219)


--- trunk/Source/WebCore/ChangeLog	2013-09-21 01:25:51 UTC (rev 156218)
+++ trunk/Source/WebCore/ChangeLog	2013-09-21 03:23:22 UTC (rev 156219)
@@ -1,3 +1,20 @@
+2013-09-20  Roger Fong  <[email protected]>
+
+        Handle panning gestures messages properly on Windows.
+        https://bugs.webkit.org/show_bug.cgi?id=121711.
+
+        Reviewed by Brent Fulgham.
+
+        This is needed by the Windows port to keep track to determine whether or not
+        we need to overpan.
+
+        No new functionality added.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollByRecursively):
+        * rendering/RenderLayer.h: 
+        Added an argument to keep track of which scrollview was actually scrolled
+
 2013-09-20  Alexandru Chiculita  <[email protected]>
 
         Web Inspector: [CSS Regions] Display CSS Regions chain when highlighting a CSS Region node

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (156218 => 156219)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2013-09-21 01:25:51 UTC (rev 156218)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2013-09-21 03:23:22 UTC (rev 156219)
@@ -2166,7 +2166,7 @@
     scrollByRecursively(adjustedScrollDelta(delta), ScrollOffsetClamped);
 }
 
-void RenderLayer::scrollByRecursively(const IntSize& delta, ScrollOffsetClamping clamp)
+void RenderLayer::scrollByRecursively(const IntSize& delta, ScrollOffsetClamping clamp, ScrollView** scrolledView)
 {
     if (delta.isZero())
         return;
@@ -2178,12 +2178,13 @@
     if (renderer().hasOverflowClip() && !restrictedByLineClamp) {
         IntSize newScrollOffset = scrollOffset() + delta;
         scrollToOffset(newScrollOffset, clamp);
+        *scrolledView = &renderer().view().frameView();
 
         // If this layer can't do the scroll we ask the next layer up that can scroll to try
         IntSize remainingScrollOffset = newScrollOffset - scrollOffset();
         if (!remainingScrollOffset.isZero() && renderer().parent()) {
             if (RenderLayer* scrollableLayer = enclosingScrollableLayer())
-                scrollableLayer->scrollByRecursively(remainingScrollOffset);
+                scrollableLayer->scrollByRecursively(remainingScrollOffset, clamp, scrolledView);
 
             renderer().frame().eventHandler().updateAutoscrollRenderer();
         }
@@ -2191,6 +2192,7 @@
         // If we are here, we were called on a renderer that can be programmatically scrolled, but doesn't
         // have an overflow clip. Which means that it is a document node that can be scrolled.
         renderer().view().frameView().scrollBy(delta);
+        *scrolledView = &renderer().view().frameView();
 
         // FIXME: If we didn't scroll the whole way, do we want to try looking at the frames ownerElement? 
         // https://bugs.webkit.org/show_bug.cgi?id=28237

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (156218 => 156219)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2013-09-21 01:25:51 UTC (rev 156218)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2013-09-21 03:23:22 UTC (rev 156219)
@@ -386,7 +386,7 @@
     };
 
     // Scrolling methods for layers that can scroll their overflow.
-    void scrollByRecursively(const IntSize&, ScrollOffsetClamping = ScrollOffsetUnclamped);
+    void scrollByRecursively(const IntSize&, ScrollOffsetClamping = ScrollOffsetUnclamped, ScrollView** scrolledView = 0);
     void scrollToOffset(const IntSize&, ScrollOffsetClamping = ScrollOffsetUnclamped);
     void scrollToXOffset(int x, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(IntSize(x, scrollYOffset()), clamp); }
     void scrollToYOffset(int y, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(IntSize(scrollXOffset(), y), clamp); }

Modified: trunk/Source/WebKit/win/ChangeLog (156218 => 156219)


--- trunk/Source/WebKit/win/ChangeLog	2013-09-21 01:25:51 UTC (rev 156218)
+++ trunk/Source/WebKit/win/ChangeLog	2013-09-21 03:23:22 UTC (rev 156219)
@@ -1,3 +1,22 @@
+2013-09-20  Roger Fong  <[email protected]>
+
+        Handle panning gestures messages properly on Windows.
+        https://bugs.webkit.org/show_bug.cgi?id=121711.
+
+        Reviewed by Brent Fulgham.
+
+        This fixes a number of issues with panning gestures on Windows.
+        1. Two finger panning in one direction can sometimes cause some unexpected scrolling 
+        in the other direction when the gesture first begins (directions meaning horizontal and vertical)
+        2. Single finger horizontal panning should only be disabled when attempting to select text.
+        3. Scrolling via panning should be clamped, other wise we can scroll contents completely out of the scrollview.
+        4. Horizontal overpan should work.
+        5. Overpan should occur whenever we scroll to the extents of whichever scroll view we're currently scrolling.
+
+        * WebView.cpp:
+        (WebView::gestureNotify):
+        (WebView::gesture):
+
 2013-09-20  Patrick Gansterer  <[email protected]>
 
         Fix MIDL files for Visual Studio 2012

Modified: trunk/Source/WebKit/win/WebView.cpp (156218 => 156219)


--- trunk/Source/WebKit/win/WebView.cpp	2013-09-21 01:25:51 UTC (rev 156218)
+++ trunk/Source/WebKit/win/WebView.cpp	2013-09-21 03:23:22 UTC (rev 156219)
@@ -1607,7 +1607,8 @@
         // The hit testing above won't detect if we've hit the main frame's vertical scrollbar. Check that manually now.
         RECT webViewRect;
         GetWindowRect(m_viewWindow, &webViewRect);
-        hitScrollbar = view->verticalScrollbar() && (gestureBeginPoint.x > (webViewRect.right - view->verticalScrollbar()->theme()->scrollbarThickness()));  
+        hitScrollbar = (view->verticalScrollbar() && (gestureBeginPoint.x > (webViewRect.right - view->verticalScrollbar()->theme()->scrollbarThickness()))) 
+            || (view->horizontalScrollbar() && (gestureBeginPoint.y > (webViewRect.bottom - view->horizontalScrollbar()->theme()->scrollbarThickness())));  
     }
 
     bool canBeScrolled = false;
@@ -1623,20 +1624,24 @@
     // We always allow two-fingered panning with inertia and a gutter (which limits movement to one
     // direction in most cases).
     DWORD dwPanWant = GC_PAN | GC_PAN_WITH_INERTIA | GC_PAN_WITH_GUTTER;
-    // We never allow single-fingered horizontal panning. That gesture is reserved for creating text
-    // selections. This matches IE.
-    DWORD dwPanBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
+    DWORD dwPanBlock = 0;
 
     if (hitScrollbar || !canBeScrolled) {
         // The part of the page under the gesture can't be scrolled, or the gesture is on a scrollbar.
-        // Disallow single-fingered vertical panning in this case, too, so we'll fall back to the default
+        // Disallow single-fingered panning in this case so we'll fall back to the default
         // behavior (which allows the scrollbar thumb to be dragged, text selections to be made, etc.).
-        dwPanBlock |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
+        dwPanBlock = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY | GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
     } else {
         // The part of the page the gesture is under can be scrolled, and we're not under a scrollbar.
         // Allow single-fingered vertical panning in this case, so the user will be able to pan the page
         // with one or two fingers.
         dwPanWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
+
+        // Disable single-fingered horizontal panning only if the target node is text.
+        if (m_gestureTargetNode && m_gestureTargetNode->isTextNode())
+            dwPanBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
+        else
+            dwPanWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
     }
 
     GESTURECONFIG gc = { GID_PAN, dwPanWant, dwPanBlock };
@@ -1667,6 +1672,10 @@
         m_gestureTargetNode = 0;
         break;
     case GID_PAN: {
+        if (gi.dwFlags & GF_BEGIN) {
+            m_lastPanX = gi.ptsLocation.x;
+            m_lastPanY = gi.ptsLocation.y;
+        }
         // Where are the fingers currently?
         long currentX = gi.ptsLocation.x;
         long currentY = gi.ptsLocation.y;
@@ -1686,44 +1695,51 @@
             return false;
         }
 
-        if (!m_gestureTargetNode || !m_gestureTargetNode->renderer())
-            return false;
+        ScrollView* scrolledView = 0;
 
-        // We negate here since panning up moves the content up, but moves the scrollbar down.
-        m_gestureTargetNode->renderer()->enclosingLayer()->scrollByRecursively(IntSize(-deltaX, -deltaY));
-           
+        if (!m_gestureTargetNode || !m_gestureTargetNode->renderer()) {
+            // We might directly hit the document without hitting any nodes
+            coreFrame->view()->scrollBy(IntSize(-deltaX, -deltaY));
+            scrolledView = coreFrame->view();
+        } else
+            m_gestureTargetNode->renderer()->enclosingLayer()->scrollByRecursively(IntSize(-deltaX, -deltaY), WebCore::RenderLayer::ScrollOffsetClamped, &scrolledView);
+
         if (!(UpdatePanningFeedbackPtr() && BeginPanningFeedbackPtr() && EndPanningFeedbackPtr())) {
             CloseGestureInfoHandlePtr()(gestureHandle);
             return true;
         }
 
+        // Handle overpanning
         if (gi.dwFlags & GF_BEGIN) {
             BeginPanningFeedbackPtr()(m_viewWindow);
             m_yOverpan = 0;
+            m_xOverpan = 0;
         } else if (gi.dwFlags & GF_END) {
             EndPanningFeedbackPtr()(m_viewWindow, true);
             m_yOverpan = 0;
+            m_xOverpan = 0;
         }
 
-        ScrollView* view = coreFrame->view();
-        if (!view) {
+        if (!scrolledView) {
             CloseGestureInfoHandlePtr()(gestureHandle);
             return true;
         }
-        Scrollbar* vertScrollbar = view->verticalScrollbar();
-        if (!vertScrollbar) {
-            CloseGestureInfoHandlePtr()(gestureHandle);
-            return true;
-        }
 
-        // FIXME: Support Horizontal Window Bounce. <https://webkit.org/b/28500>.
-        // FIXME: If the user starts panning down after a window bounce has started, the window doesn't bounce back 
-        // until they release their finger. <https://webkit.org/b/28501>.
-        if (vertScrollbar->currentPos() == 0)
-            UpdatePanningFeedbackPtr()(m_viewWindow, 0, m_yOverpan, gi.dwFlags & GF_INERTIA);
-        else if (vertScrollbar->currentPos() >= vertScrollbar->maximum())
-            UpdatePanningFeedbackPtr()(m_viewWindow, 0, m_yOverpan, gi.dwFlags & GF_INERTIA);
+        Scrollbar* vertScrollbar = scrolledView->verticalScrollbar();
 
+        int ypan = 0;
+        int xpan = 0;
+
+        if (vertScrollbar && (!vertScrollbar->currentPos() || vertScrollbar->currentPos() >= vertScrollbar->maximum()))
+            ypan = m_yOverpan;
+
+        Scrollbar* horiScrollbar = scrolledView->horizontalScrollbar();
+
+        if (horiScrollbar && (!horiScrollbar->currentPos() || horiScrollbar->currentPos() >= horiScrollbar->maximum()))
+            xpan = m_xOverpan;
+
+        UpdatePanningFeedbackPtr()(m_viewWindow, xpan, ypan, gi.dwFlags & GF_INERTIA);
+
         CloseGestureInfoHandlePtr()(gestureHandle);
         return true;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to