Send a message from WebViewImpl to the compositor to inform about end of flings
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 21:17:08 +0000 (21:17 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 21:17:08 +0000 (21:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104947

Patch by Yusuf Ozuysal <yusufo@google.com> 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

Source/Platform:

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

Source/WebKit/chromium:

* src/WebCompositorInputHandlerImpl.cpp:
(WebKit::WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl):
(WebKit::WebCompositorInputHandlerImpl::handleInputEventInternal):
(WebKit::WebCompositorInputHandlerImpl::handleGestureFling):
(WebKit::WebCompositorInputHandlerImpl::mainThreadHasStoppedFlinging):
(WebKit):
* src/WebCompositorInputHandlerImpl.h:
(WebCompositorInputHandlerImpl):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleGestureEvent):
(WebKit::WebViewImpl::handleKeyEvent):
(WebKit::WebViewImpl::updateAnimations):
(WebKit::WebViewImpl::didCommitLoad):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137765 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/Platform/ChangeLog
Source/Platform/chromium/public/WebInputHandler.h
Source/Platform/chromium/public/WebLayerTreeView.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp
Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h
Source/WebKit/chromium/src/WebViewImpl.cpp

index a7de4e4..ec5e6e2 100644 (file)
@@ -1,3 +1,21 @@
+2012-12-14  Yusuf Ozuysal  <yusufo@google.com>
+
+        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-12  Gavin Peters  <gavinp@chromium.org>
 
         [chromium] Add destructor to WebPrerender
index dfb23d5..dec5149 100644 (file)
@@ -33,6 +33,7 @@ public:
 
     virtual void bindToClient(WebInputHandlerClient*) = 0;
     virtual void animate(double monotonicTime) = 0;
+    virtual void mainThreadHasStoppedFlinging() = 0;
 };
 
 }
index 780ba5d..98196e8 100644 (file)
@@ -158,6 +158,9 @@ public:
     // 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
index 2fd8a0a..57c606b 100644 (file)
@@ -1,3 +1,29 @@
+2012-12-14  Yusuf Ozuysal  <yusufo@google.com>
+
+        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
+
+        * src/WebCompositorInputHandlerImpl.cpp:
+        (WebKit::WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl):
+        (WebKit::WebCompositorInputHandlerImpl::handleInputEventInternal):
+        (WebKit::WebCompositorInputHandlerImpl::handleGestureFling):
+        (WebKit::WebCompositorInputHandlerImpl::mainThreadHasStoppedFlinging):
+        (WebKit):
+        * src/WebCompositorInputHandlerImpl.h:
+        (WebCompositorInputHandlerImpl):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleGestureEvent):
+        (WebKit::WebViewImpl::handleKeyEvent):
+        (WebKit::WebViewImpl::updateAnimations):
+        (WebKit::WebViewImpl::didCommitLoad):
+
 2012-12-14  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r137570.
index a6ad412..89350ce 100644 (file)
@@ -71,6 +71,7 @@ WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl()
 #endif
     , m_gestureScrollOnImplThread(false)
     , m_gesturePinchOnImplThread(false)
+    , m_flingActiveOnMainThread(false)
 {
 }
 
@@ -198,6 +199,8 @@ WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h
     } 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 @@ WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h
     }
     case WebInputHandlerClient::ScrollStatusOnMainThread: {
         TRACE_EVENT_INSTANT0("webkit", "WebCompositorInputHandlerImpl::handleGestureFling::scrollOnMainThread");
+        m_flingActiveOnMainThread =  true;
         return DidNotHandle;
     }
     case WebInputHandlerClient::ScrollStatusIgnored: {
@@ -349,4 +353,9 @@ void WebCompositorInputHandlerImpl::scrollBy(const WebPoint& increment)
     }
 }
 
+void WebCompositorInputHandlerImpl::mainThreadHasStoppedFlinging()
+{
+    m_flingActiveOnMainThread =  false;
+}
+
 }
index 5c79add..9dfad60 100644 (file)
@@ -63,6 +63,7 @@ public:
     // 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 @@ private:
 #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;
index 41ee50a..8ffdf53 100644 (file)
@@ -707,6 +707,8 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
     case WebInputEvent::GestureFlingCancel:
         if (m_gestureAnimation) {
             m_gestureAnimation.clear();
+            if (m_layerTreeView)
+                m_layerTreeView->didStopFlinging();
             eventSwallowed = true;
         }
         break;
@@ -858,8 +860,11 @@ bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event)
         || (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 @@ void WebViewImpl::updateAnimations(double monotonicFrameBeginTime)
     if (m_gestureAnimation) {
         if (m_gestureAnimation->animate(monotonicFrameBeginTime))
             scheduleAnimation();
-        else
+        else {
             m_gestureAnimation.clear();
+            if (m_layerTreeView)
+                m_layerTreeView->didStopFlinging();
+        }
     }
 
     if (!m_page)
@@ -3646,6 +3654,8 @@ void WebViewImpl::didCommitLoad(bool* isNewNavigation, bool isNavigationWithinPa
     // Make sure link highlight from previous page is cleared.
     m_linkHighlight.clear();
     m_gestureAnimation.clear();
+    if (m_layerTreeView)
+        m_layerTreeView->didStopFlinging();
     resetSavedScrollAndScaleState();
 }