Title: [137793] trunk/Source
Revision
137793
Author
[email protected]
Date
2012-12-14 18:28:55 -0800 (Fri, 14 Dec 2012)

Log Message

Send a message from WebViewImpl to the compositor to inform about end of flings
https://bugs.webkit.org/show_bug.cgi?id=104947

Patch by Yusuf Ozuysal <[email protected]> on 2012-12-14
Reviewed by James Robinson.

Whenever we have a fling animation finished on cancelled on main thread this sends
a message that will be relayed to the compositor input handler. Then the input handler
keeps track of main thread fling with a boolean and doesn't send flingCancels
unnecessarily

* chromium/public/WebInputHandler.h:
(WebInputHandler):
* chromium/public/WebLayerTreeView.h:
(WebLayerTreeView):
(WebKit::WebLayerTreeView::mainThreadHasStoppedFlinging):

Modified Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (137792 => 137793)


--- trunk/Source/Platform/ChangeLog	2012-12-15 01:21:25 UTC (rev 137792)
+++ trunk/Source/Platform/ChangeLog	2012-12-15 02:28:55 UTC (rev 137793)
@@ -1,3 +1,21 @@
+2012-12-14  Yusuf Ozuysal  <[email protected]>
+
+        Send a message from WebViewImpl to the compositor to inform about end of flings
+        https://bugs.webkit.org/show_bug.cgi?id=104947
+
+        Reviewed by James Robinson.
+
+        Whenever we have a fling animation finished on cancelled on main thread this sends
+        a message that will be relayed to the compositor input handler. Then the input handler
+        keeps track of main thread fling with a boolean and doesn't send flingCancels
+        unnecessarily
+
+        * chromium/public/WebInputHandler.h:
+        (WebInputHandler):
+        * chromium/public/WebLayerTreeView.h:
+        (WebLayerTreeView):
+        (WebKit::WebLayerTreeView::mainThreadHasStoppedFlinging):
+
 2012-12-14  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r137765.

Modified: trunk/Source/Platform/chromium/public/WebInputHandler.h (137792 => 137793)


--- trunk/Source/Platform/chromium/public/WebInputHandler.h	2012-12-15 01:21:25 UTC (rev 137792)
+++ trunk/Source/Platform/chromium/public/WebInputHandler.h	2012-12-15 02:28:55 UTC (rev 137793)
@@ -33,6 +33,7 @@
 
     virtual void bindToClient(WebInputHandlerClient*) = 0;
     virtual void animate(double monotonicTime) = 0;
+    virtual void mainThreadHasStoppedFlinging() = 0;
 };
 
 }

Modified: trunk/Source/Platform/chromium/public/WebLayerTreeView.h (137792 => 137793)


--- trunk/Source/Platform/chromium/public/WebLayerTreeView.h	2012-12-15 01:21:25 UTC (rev 137792)
+++ trunk/Source/Platform/chromium/public/WebLayerTreeView.h	2012-12-15 02:28:55 UTC (rev 137793)
@@ -158,6 +158,9 @@
     // mode.
     virtual void updateAnimations(double frameBeginTime) = 0;
 
+    // Relays the end of a fling animation.
+    virtual void didStopFlinging() { }
+
     // Composites and attempts to read back the result into the provided
     // buffer. If it wasn't possible, e.g. due to context lost, will return
     // false. Pixel format is 32bit (RGBA), and the provided buffer must be

Modified: trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp (137792 => 137793)


--- trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp	2012-12-15 01:21:25 UTC (rev 137792)
+++ trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp	2012-12-15 02:28:55 UTC (rev 137793)
@@ -71,6 +71,7 @@
 #endif
     , m_gestureScrollOnImplThread(false)
     , m_gesturePinchOnImplThread(false)
+    , m_flingActiveOnMainThread(false)
 {
 }
 
@@ -198,6 +199,8 @@
     } else if (event.type == WebInputEvent::GestureFlingCancel) {
         if (cancelCurrentFling())
             return DidHandle;
+        else if (!m_flingActiveOnMainThread)
+            return DropEvent;
 #if ENABLE(TOUCH_EVENT_TRACKING)
     } else if (event.type == WebInputEvent::TouchStart) {
         const WebTouchEvent& touchEvent = *static_cast<const WebTouchEvent*>(&event);
@@ -230,6 +233,7 @@
     }
     case WebInputHandlerClient::ScrollStatusOnMainThread: {
         TRACE_EVENT_INSTANT0("webkit", "WebCompositorInputHandlerImpl::handleGestureFling::scrollOnMainThread");
+        m_flingActiveOnMainThread =  true;
         return DidNotHandle;
     }
     case WebInputHandlerClient::ScrollStatusIgnored: {
@@ -318,6 +322,7 @@
         // scroll on the thread if the fling starts outside the subarea but then is flung "under" the
         // pointer.
         m_client->transferActiveWheelFlingAnimation(m_flingParameters);
+        m_flingActiveOnMainThread = true;
         cancelCurrentFling();
         break;
     }
@@ -349,4 +354,9 @@
     }
 }
 
+void WebCompositorInputHandlerImpl::mainThreadHasStoppedFlinging()
+{
+    m_flingActiveOnMainThread =  false;
 }
+
+}

Modified: trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h (137792 => 137793)


--- trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h	2012-12-15 01:21:25 UTC (rev 137792)
+++ trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h	2012-12-15 02:28:55 UTC (rev 137793)
@@ -63,6 +63,7 @@
     // WebInputHandler implementation.
     virtual void bindToClient(WebInputHandlerClient*);
     virtual void animate(double monotonicTime);
+    virtual void mainThreadHasStoppedFlinging();
 
     // WebGestureCurveTarget implementation.
     virtual void scrollBy(const WebPoint&);
@@ -98,6 +99,9 @@
 #endif
     bool m_gestureScrollOnImplThread;
     bool m_gesturePinchOnImplThread;
+    // This is always false when there are no flings on the main thread, but conservative in the
+    // sense that we might not be actually flinging when it is true.
+    bool m_flingActiveOnMainThread;
 
     static int s_nextAvailableIdentifier;
     static HashSet<WebCompositorInputHandlerImpl*>* s_compositors;

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (137792 => 137793)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-12-15 01:21:25 UTC (rev 137792)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-12-15 02:28:55 UTC (rev 137793)
@@ -707,6 +707,8 @@
     case WebInputEvent::GestureFlingCancel:
         if (m_gestureAnimation) {
             m_gestureAnimation.clear();
+            if (m_layerTreeView)
+                m_layerTreeView->didStopFlinging();
             eventSwallowed = true;
         }
         break;
@@ -858,8 +860,11 @@
         || (event.type == WebInputEvent::KeyUp));
 
     // Halt an in-progress fling on a key event.
-    if (m_gestureAnimation)
+    if (m_gestureAnimation) {
         m_gestureAnimation.clear();
+        if (m_layerTreeView)
+            m_layerTreeView->didStopFlinging();
+    }
 
     // Please refer to the comments explaining the m_suppressNextKeypressEvent
     // member.
@@ -1765,8 +1770,11 @@
     if (m_gestureAnimation) {
         if (m_gestureAnimation->animate(monotonicFrameBeginTime))
             scheduleAnimation();
-        else
+        else {
             m_gestureAnimation.clear();
+            if (m_layerTreeView)
+                m_layerTreeView->didStopFlinging();
+        }
     }
 
     if (!m_page)
@@ -3650,6 +3658,8 @@
     // Make sure link highlight from previous page is cleared.
     m_linkHighlight.clear();
     m_gestureAnimation.clear();
+    if (m_layerTreeView)
+        m_layerTreeView->didStopFlinging();
     resetSavedScrollAndScaleState();
 }
 

Modified: trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp (137792 => 137793)


--- trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp	2012-12-15 01:21:25 UTC (rev 137792)
+++ trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp	2012-12-15 02:28:55 UTC (rev 137793)
@@ -389,9 +389,10 @@
     gesture.data.flingStart.sourceDevice = WebGestureEvent::Touchpad;
     m_inputHandler->handleInputEvent(gesture);
 
+    m_expectedDisposition = DropEvent;
     VERIFY_AND_RESET_MOCKS();
 
-    // Even if we didn't start a fling ourselves, we still need to send the cancel event to the widget.
+    // Since the previous fling was ignored, we should also be dropping the next flingCancel.
     gesture.type = WebInputEvent::GestureFlingCancel;
     gesture.data.flingStart.sourceDevice = WebGestureEvent::Touchpad;
     m_inputHandler->handleInputEvent(gesture);
@@ -454,7 +455,6 @@
         .WillOnce(testing::Return(WebInputHandlerClient::ScrollStatusOnMainThread));
     EXPECT_CALL(m_mockInputHandlerClient, scrollByIfPossible(testing::_, testing::_)).Times(0);
     EXPECT_CALL(m_mockInputHandlerClient, scrollEnd()).Times(0);
-
     // Expected wheel fling animation parameters:
     // *) flingDelta and flingPoint should match the original GestureFlingStart event
     // *) startTime should be 10 to match the time parameter of the first animate() call after the GestureFlingStart
@@ -572,6 +572,7 @@
     m_inputHandler->handleInputEvent(gesture);
 
     VERIFY_AND_RESET_MOCKS();
+    m_inputHandler->mainThreadHasStoppedFlinging();
 
     // Start a second gesture fling, this time in the +Y direction with no X.
     gesture.type = WebInputEvent::GestureFlingStart;
@@ -690,7 +691,6 @@
     gesture.data.flingStart.sourceDevice = WebGestureEvent::Touchscreen;
     m_inputHandler->handleInputEvent(gesture);
 
-    m_expectedDisposition = DidNotHandle;
     VERIFY_AND_RESET_MOCKS();
 
     // Even if we didn't start a fling ourselves, we still need to send the cancel event to the widget.
@@ -751,7 +751,7 @@
 
 TEST_F(WebCompositorInputHandlerImplTest, lastInputEventForVSync)
 {
-    m_expectedDisposition = DidNotHandle;
+    m_expectedDisposition = DropEvent;
     VERIFY_AND_RESET_MOCKS();
 
     gesture.type = WebInputEvent::GestureFlingCancel;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to