From: commit-queue@webkit.org Date: Wed, 8 Feb 2012 21:12:58 +0000 (+0000) Subject: Add support for pinch gesture processing in the MT compositor. X-Git-Tag: 070512121124~13420 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e355faecf69b782c9a0df52aa56ec4f7c9aec21;p=profile%2Fivi%2Fwebkit-efl.git Add support for pinch gesture processing in the MT compositor. https://bugs.webkit.org/show_bug.cgi?id=77804 Patch by Sadrul Habib Chowdhury on 2012-02-08 Reviewed by James Robinson. * public/WebInputEvent.h: * src/WebCompositorInputHandlerImpl.cpp: (WebKit::WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl): (WebKit::WebCompositorInputHandlerImpl::handleInputEvent): * src/WebCompositorInputHandlerImpl.h: (WebCompositorInputHandlerImpl): * src/WebInputEventConversion.cpp: (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder): * src/WebPopupMenuImpl.cpp: (WebKit::WebPopupMenuImpl::handleInputEvent): * src/WebViewImpl.cpp: (WebKit::WebViewImpl::handleInputEvent): * tests/WebCompositorInputHandlerImplTest.cpp: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107125 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 0a7d28d..bf2acbc 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,24 @@ +2012-02-08 Sadrul Habib Chowdhury + + Add support for pinch gesture processing in the MT compositor. + https://bugs.webkit.org/show_bug.cgi?id=77804 + + Reviewed by James Robinson. + + * public/WebInputEvent.h: + * src/WebCompositorInputHandlerImpl.cpp: + (WebKit::WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl): + (WebKit::WebCompositorInputHandlerImpl::handleInputEvent): + * src/WebCompositorInputHandlerImpl.h: + (WebCompositorInputHandlerImpl): + * src/WebInputEventConversion.cpp: + (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder): + * src/WebPopupMenuImpl.cpp: + (WebKit::WebPopupMenuImpl::handleInputEvent): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::handleInputEvent): + * tests/WebCompositorInputHandlerImplTest.cpp: + 2012-02-08 Nico Weber [chromium] Make dependency on Accelerate.framework explicit. diff --git a/Source/WebKit/chromium/public/WebInputEvent.h b/Source/WebKit/chromium/public/WebInputEvent.h index 57b1f4b..e42e451 100644 --- a/Source/WebKit/chromium/public/WebInputEvent.h +++ b/Source/WebKit/chromium/public/WebInputEvent.h @@ -109,6 +109,9 @@ public: GestureTap, GestureTapDown, GestureDoubleTap, + GesturePinchBegin, + GesturePinchEnd, + GesturePinchUpdate, // WebTouchEvent TouchStart, @@ -351,6 +354,8 @@ public: int y; int globalX; int globalY; + + // NOTE: |deltaX| and |deltaY| represents the amount to scroll for Scroll gesture events. For Pinch gesture events, |deltaX| represents the scaling/magnification factor. float deltaX; float deltaY; diff --git a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp index 367bc3e..40c151d 100644 --- a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp +++ b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp @@ -83,6 +83,7 @@ WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl(CCInputHandlerClien , m_inputHandlerClient(inputHandlerClient) #ifndef NDEBUG , m_expectScrollUpdateEnd(false) + , m_expectPinchUpdateEnd(false) #endif , m_scrollStarted(false) { @@ -173,6 +174,28 @@ void WebCompositorInputHandlerImpl::handleInputEvent(const WebInputEvent& event) m_scrollStarted = false; return; } + } else if (event.type == WebInputEvent::GesturePinchBegin) { + ASSERT(!m_expectPinchUpdateEnd); +#ifndef NDEBUG + m_expectPinchUpdateEnd = true; +#endif + m_inputHandlerClient->pinchGestureBegin(); + m_client->didHandleInputEvent(); + return; + } else if (event.type == WebInputEvent::GesturePinchEnd) { + ASSERT(m_expectPinchUpdateEnd); +#ifndef NDEBUG + m_expectPinchUpdateEnd = false; +#endif + m_inputHandlerClient->pinchGestureEnd(); + m_client->didHandleInputEvent(); + return; + } else if (event.type == WebInputEvent::GesturePinchUpdate) { + ASSERT(m_expectPinchUpdateEnd); + const WebGestureEvent& gestureEvent = *static_cast(&event); + m_inputHandlerClient->pinchGestureUpdate(gestureEvent.deltaX, IntPoint(gestureEvent.x, gestureEvent.y)); + m_client->didHandleInputEvent(); + return; } m_client->didNotHandleInputEvent(true /* sendToWidget */); } diff --git a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h index 7a63268..a2f1302 100644 --- a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h +++ b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h @@ -72,6 +72,7 @@ private: #ifndef NDEBUG bool m_expectScrollUpdateEnd; + bool m_expectPinchUpdateEnd; #endif bool m_scrollStarted; diff --git a/Source/WebKit/chromium/src/WebInputEventConversion.cpp b/Source/WebKit/chromium/src/WebInputEventConversion.cpp index ddd4736..64ba311 100644 --- a/Source/WebKit/chromium/src/WebInputEventConversion.cpp +++ b/Source/WebKit/chromium/src/WebInputEventConversion.cpp @@ -155,6 +155,11 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W case WebInputEvent::GestureDoubleTap: m_type = PlatformEvent::GestureDoubleTap; break; + case WebInputEvent::GesturePinchBegin: + case WebInputEvent::GesturePinchEnd: + case WebInputEvent::GesturePinchUpdate: + // FIXME: Once PlatformGestureEvent is updated to support pinch, this should set m_type to appropriate PlatformEvent type. + ASSERT_NOT_REACHED(); default: ASSERT_NOT_REACHED(); } diff --git a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp index 03f31d8..3f328f5 100644 --- a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp +++ b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp @@ -275,6 +275,12 @@ bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent) case WebInputEvent::MouseEnter: case WebInputEvent::ContextMenu: return false; + + case WebInputEvent::GesturePinchBegin: + case WebInputEvent::GesturePinchEnd: + case WebInputEvent::GesturePinchUpdate: + // FIXME: Once PlatformGestureEvent is updated to support pinch, this should call handleGestureEvent, just like it currently does for gesture scroll. + return false; } return false; } diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index 8269a1d..a05e989 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -1416,6 +1416,15 @@ bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) break; #endif +#if ENABLE(GESTURE_EVENTS) + case WebInputEvent::GesturePinchBegin: + case WebInputEvent::GesturePinchEnd: + case WebInputEvent::GesturePinchUpdate: + // FIXME: Once PlatformGestureEvent is updated to support pinch, this should call handleGestureEvent, just like it currently does for gesture scroll. + handled = false; + break; +#endif + default: handled = false; } diff --git a/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp b/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp index cc8359f..9df969e 100644 --- a/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp +++ b/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp @@ -46,12 +46,25 @@ class MockInputHandlerClient : public WebCore::CCInputHandlerClient { public: MockInputHandlerClient() : m_scrollStatus(ScrollStarted) + , m_pinchStarted(false) + , m_pinchEnded(false) + , m_pinchMagnification(0) { } virtual ~MockInputHandlerClient() { } void setScrollStatus(ScrollStatus status) { m_scrollStatus = status; } + bool pinchStarted() const { return m_pinchStarted; } + bool pinchEnded() const { return m_pinchEnded; } + float pinchMaginifcation() const { return m_pinchMagnification; } + + void resetPinch() + { + m_pinchStarted = m_pinchStarted = false; + m_pinchMagnification = 0; + } + private: virtual void setNeedsRedraw() OVERRIDE { } virtual ScrollStatus scrollBegin(const WebCore::IntPoint&) OVERRIDE @@ -62,9 +75,18 @@ private: virtual void scrollEnd() OVERRIDE { } virtual bool haveWheelEventHandlers() OVERRIDE { return false; } - virtual void pinchGestureBegin() OVERRIDE { } - virtual void pinchGestureUpdate(float magnifyDelta, const WebCore::IntPoint& anchor) OVERRIDE { } - virtual void pinchGestureEnd() OVERRIDE { } + virtual void pinchGestureBegin() OVERRIDE + { + m_pinchStarted = true; + } + virtual void pinchGestureUpdate(float magnifyDelta, const WebCore::IntPoint& anchor) OVERRIDE + { + m_pinchMagnification = magnifyDelta; + } + virtual void pinchGestureEnd() OVERRIDE + { + m_pinchEnded = true; + } virtual void startPageScaleAnimation(const WebCore::IntSize& targetPosition, bool anchorPoint, float pageScale, @@ -72,6 +94,9 @@ private: double durationMs) OVERRIDE { } ScrollStatus m_scrollStatus; + bool m_pinchStarted; + bool m_pinchEnded; + float m_pinchMagnification; }; class MockWebCompositorInputHandlerClient : public WebKit::WebCompositorInputHandlerClient { @@ -200,4 +225,60 @@ TEST(WebCompositorInputHandlerImpl, gestureScroll) WebKit::WebCompositor::shutdown(); } +TEST(WebCompositorInputHandlerImpl, gesturePinch) +{ + WebKit::WebCompositor::initialize(0); +#ifndef NDEBUG + // WebCompositorInputHandler APIs can only be called from the compositor thread. + WebCore::DebugScopedSetImplThread alwaysImplThread; +#endif + + MockInputHandlerClient mockInputHandler; + OwnPtr inputHandler = WebCompositorInputHandlerImpl::create(&mockInputHandler); + MockWebCompositorInputHandlerClient mockClient; + inputHandler->setClient(&mockClient); + + WebKit::WebGestureEvent gesture; + + gesture.type = WebKit::WebInputEvent::GesturePinchBegin; + inputHandler->handleInputEvent(gesture); + EXPECT_TRUE(mockClient.handled()); + EXPECT_FALSE(mockClient.sendToWidget()); + EXPECT_TRUE(mockInputHandler.pinchStarted()); + mockClient.reset(); + mockInputHandler.resetPinch(); + + gesture.type = WebKit::WebInputEvent::GesturePinchUpdate; + gesture.deltaX = 1.5; + inputHandler->handleInputEvent(gesture); + EXPECT_TRUE(mockClient.handled()); + EXPECT_FALSE(mockClient.sendToWidget()); + EXPECT_FALSE(mockInputHandler.pinchEnded()); + EXPECT_EQ(1.5, mockInputHandler.pinchMaginifcation()); + mockClient.reset(); + mockInputHandler.resetPinch(); + + gesture.type = WebKit::WebInputEvent::GesturePinchUpdate; + gesture.deltaX = 0.5; + inputHandler->handleInputEvent(gesture); + EXPECT_TRUE(mockClient.handled()); + EXPECT_FALSE(mockClient.sendToWidget()); + EXPECT_FALSE(mockInputHandler.pinchEnded()); + EXPECT_EQ(0.5, mockInputHandler.pinchMaginifcation()); + mockClient.reset(); + mockInputHandler.resetPinch(); + + gesture.type = WebKit::WebInputEvent::GesturePinchEnd; + inputHandler->handleInputEvent(gesture); + EXPECT_TRUE(mockClient.handled()); + EXPECT_FALSE(mockClient.sendToWidget()); + EXPECT_TRUE(mockInputHandler.pinchEnded()); + mockClient.reset(); + mockInputHandler.resetPinch(); + + inputHandler->setClient(0); + + WebKit::WebCompositor::shutdown(); +} + }