Partially revert 104427, change WebWidgetClient::didHandleGestureEvent semantics.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 22:31:21 +0000 (22:31 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 22:31:21 +0000 (22:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107605

Patch by Tien-Ren Chen <trchen@chromium.org> on 2013-01-23
Reviewed by Darin Fisher.

Per discussion in https://codereview.chromium.org/11473027/ we decided
not to introduce an enum to WebWidgetClient::didHandleGestureEvent().
Instead, change the semantics of the bool flag to indicate whether the
gesture event is cancelled for disambiguation.

* public/WebWidgetClient.h:
(WebKit::WebWidgetClient::didHandleGestureEvent):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleGestureEvent):
* tests/WebViewTest.cpp:

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

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebWidgetClient.h
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/tests/WebViewTest.cpp

index 35474c244f0597e57532d82040fa77ea7c62475e..0754365d214e2e6971d94d3a94b13451fcf5ec1f 100644 (file)
@@ -1,3 +1,21 @@
+2013-01-23  Tien-Ren Chen  <trchen@chromium.org>
+
+        Partially revert 104427, change WebWidgetClient::didHandleGestureEvent semantics.
+        https://bugs.webkit.org/show_bug.cgi?id=107605
+
+        Reviewed by Darin Fisher.
+
+        Per discussion in https://codereview.chromium.org/11473027/ we decided
+        not to introduce an enum to WebWidgetClient::didHandleGestureEvent().
+        Instead, change the semantics of the bool flag to indicate whether the
+        gesture event is cancelled for disambiguation.
+
+        * public/WebWidgetClient.h:
+        (WebKit::WebWidgetClient::didHandleGestureEvent):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleGestureEvent):
+        * tests/WebViewTest.cpp:
+
 2013-01-23  Mark Pilgrim  <pilgrim@chromium.org>
 
         [Chromium] Remove WebArrayBufferView and WebSerializedScriptValue from chromium/public/platform/
index 47191d757994e062bf4c2576a9f06a259e2a2ccc..10e173067619b60c3f63a7979a6fcbaa6ac4eb9b 100644 (file)
@@ -168,13 +168,7 @@ public:
     virtual bool isPointerLocked() { return false; }
 
     // Called when a gesture event is handled.
-    enum EventStatus {
-        EventStatusUnprocessed,
-        EventStatusProcessed,
-        EventStatusCancelled
-    };
-    virtual void didHandleGestureEvent(const WebGestureEvent& event, EventStatus) { }
-    virtual void didHandleGestureEvent(const WebGestureEvent& event, bool eventSwallowed) { } // deprecated
+    virtual void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled) { }
 
 protected:
     ~WebWidgetClient() { }
index ad86885b57f50cf949a5737d6ed9249ab0f25954..95e9d954e3ac31ca5c898be9fad82cce79a45d0a 100644 (file)
@@ -695,7 +695,8 @@ void WebViewImpl::scrollBy(const WebPoint& delta)
 #if ENABLE(GESTURE_EVENTS)
 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
 {
-    WebWidgetClient::EventStatus eventStatus = WebWidgetClient::EventStatusUnprocessed;
+    bool eventSwallowed = false;
+    bool eventCancelled = false; // for disambiguation
 
     // Handle link highlighting outside the main switch to avoid getting lost in the
     // complicated set of cases handled below.
@@ -729,7 +730,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
         OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY), WebSize()));
         m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(flingCurve.release(), this);
         scheduleAnimation();
-        eventStatus = WebWidgetClient::EventStatusProcessed;
+        eventSwallowed = true;
         break;
     }
     case WebInputEvent::GestureFlingCancel:
@@ -737,13 +738,13 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
             m_gestureAnimation.clear();
             if (m_layerTreeView)
                 m_layerTreeView->didStopFlinging();
-            eventStatus = WebWidgetClient::EventStatusProcessed;
+            eventSwallowed = true;
         }
         break;
     case WebInputEvent::GestureTap: {
         m_client->cancelScheduledContentIntents();
         if (detectContentOnTouch(WebPoint(event.x, event.y))) {
-            eventStatus = WebWidgetClient::EventStatusProcessed;
+            eventSwallowed = true;
             break;
         }
 
@@ -759,13 +760,14 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
             // FIXME: replace touch adjustment code when numberOfGoodTargets == 1?
             // Single candidate case is currently handled by: https://bugs.webkit.org/show_bug.cgi?id=85101
             if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(event, goodTargets)) {
-                eventStatus = WebWidgetClient::EventStatusCancelled;
+                eventSwallowed = true;
+                eventCancelled = true;
                 break;
             }
         }
 
         PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
-        eventStatus = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent) ? WebWidgetClient::EventStatusProcessed : WebWidgetClient::EventStatusUnprocessed;
+        eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
 
         if (m_selectPopup && m_selectPopup == selectPopup) {
             // That tap triggered a select popup which is the same as the one that
@@ -787,7 +789,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
         m_page->contextMenuController()->clearContextMenu();
         m_contextMenuAllowed = true;
         PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
-        eventStatus = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent) ? WebWidgetClient::EventStatusProcessed : WebWidgetClient::EventStatusUnprocessed;
+        eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
         m_contextMenuAllowed = false;
 
         break;
@@ -795,14 +797,14 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
     case WebInputEvent::GestureTapDown: {
         m_client->cancelScheduledContentIntents();
         PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
-        eventStatus = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent) ? WebWidgetClient::EventStatusProcessed : WebWidgetClient::EventStatusUnprocessed;
+        eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
         break;
     }
     case WebInputEvent::GestureDoubleTap:
         if (m_webSettings->doubleTapToZoomEnabled() && m_minimumPageScaleFactor != m_maximumPageScaleFactor) {
             m_client->cancelScheduledContentIntents();
             animateZoomAroundPoint(WebPoint(event.x, event.y), DoubleTap);
-            eventStatus = WebWidgetClient::EventStatusProcessed;
+            eventSwallowed = true;
             break;
         }
     case WebInputEvent::GestureScrollBegin:
@@ -814,14 +816,14 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
     case WebInputEvent::GesturePinchEnd:
     case WebInputEvent::GesturePinchUpdate: {
         PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
-        eventStatus = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent) ? WebWidgetClient::EventStatusProcessed : WebWidgetClient::EventStatusUnprocessed;
+        eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
         break;
     }
     default:
         ASSERT_NOT_REACHED();
     }
-    m_client->didHandleGestureEvent(event, eventStatus);
-    return eventStatus != WebWidgetClient::EventStatusUnprocessed;
+    m_client->didHandleGestureEvent(event, eventCancelled);
+    return eventSwallowed;
 }
 
 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters& parameters)
index ccc47c4991f33406e5ddff25f3e99a4389cbca0c..5f78a444236eba6256ce272e13fb2be9de6e2145 100644 (file)
@@ -123,7 +123,7 @@ private:
 class TapHandlingWebViewClient : public WebViewClient {
 public:
     // WebViewClient methods
-    virtual void didHandleGestureEvent(const WebGestureEvent& event, EventStatus eventStatus)
+    virtual void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled)
     {
         if (event.type == WebInputEvent::GestureTap) {
             m_tapX = event.x;