⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 107125 in webkit


Ignore:
Timestamp:
Feb 8, 2012, 1:12:58 PM (15 years ago)
Author:
commit-queue@webkit.org
Message:

Add support for pinch gesture processing in the MT compositor.
https://bugs.webkit.org/show_bug.cgi?id=77804

Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> 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:
Location:
trunk/Source/WebKit/chromium
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r107117 r107125  
     12012-02-08  Sadrul Habib Chowdhury  <sadrul@chromium.org>
     2
     3        Add support for pinch gesture processing in the MT compositor.
     4        https://bugs.webkit.org/show_bug.cgi?id=77804
     5
     6        Reviewed by James Robinson.
     7
     8        * public/WebInputEvent.h:
     9        * src/WebCompositorInputHandlerImpl.cpp:
     10        (WebKit::WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl):
     11        (WebKit::WebCompositorInputHandlerImpl::handleInputEvent):
     12        * src/WebCompositorInputHandlerImpl.h:
     13        (WebCompositorInputHandlerImpl):
     14        * src/WebInputEventConversion.cpp:
     15        (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
     16        * src/WebPopupMenuImpl.cpp:
     17        (WebKit::WebPopupMenuImpl::handleInputEvent):
     18        * src/WebViewImpl.cpp:
     19        (WebKit::WebViewImpl::handleInputEvent):
     20        * tests/WebCompositorInputHandlerImplTest.cpp:
     21
    1222012-02-08  Nico Weber  <nicolasweber@gmx.de>
    223
  • trunk/Source/WebKit/chromium/public/WebInputEvent.h

    r106214 r107125  
    110110        GestureTapDown,
    111111        GestureDoubleTap,
     112        GesturePinchBegin,
     113        GesturePinchEnd,
     114        GesturePinchUpdate,
    112115
    113116        // WebTouchEvent
     
    352355    int globalX;
    353356    int globalY;
     357
     358    // NOTE: |deltaX| and |deltaY| represents the amount to scroll for Scroll gesture events. For Pinch gesture events, |deltaX| represents the scaling/magnification factor.
    354359    float deltaX;
    355360    float deltaY;
  • trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp

    r106987 r107125  
    8484#ifndef NDEBUG
    8585    , m_expectScrollUpdateEnd(false)
     86    , m_expectPinchUpdateEnd(false)
    8687#endif
    8788    , m_scrollStarted(false)
     
    174175            return;
    175176        }
     177    } else if (event.type == WebInputEvent::GesturePinchBegin) {
     178        ASSERT(!m_expectPinchUpdateEnd);
     179#ifndef NDEBUG
     180        m_expectPinchUpdateEnd = true;
     181#endif
     182        m_inputHandlerClient->pinchGestureBegin();
     183        m_client->didHandleInputEvent();
     184        return;
     185    } else if (event.type == WebInputEvent::GesturePinchEnd) {
     186        ASSERT(m_expectPinchUpdateEnd);
     187#ifndef NDEBUG
     188        m_expectPinchUpdateEnd = false;
     189#endif
     190        m_inputHandlerClient->pinchGestureEnd();
     191        m_client->didHandleInputEvent();
     192        return;
     193    } else if (event.type == WebInputEvent::GesturePinchUpdate) {
     194        ASSERT(m_expectPinchUpdateEnd);
     195        const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event);
     196        m_inputHandlerClient->pinchGestureUpdate(gestureEvent.deltaX, IntPoint(gestureEvent.x, gestureEvent.y));
     197        m_client->didHandleInputEvent();
     198        return;
    176199    }
    177200    m_client->didNotHandleInputEvent(true /* sendToWidget */);
  • trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h

    r106987 r107125  
    7373#ifndef NDEBUG
    7474    bool m_expectScrollUpdateEnd;
     75    bool m_expectPinchUpdateEnd;
    7576#endif
    7677    bool m_scrollStarted;
  • trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp

    r106063 r107125  
    156156        m_type = PlatformEvent::GestureDoubleTap;
    157157        break;
     158    case WebInputEvent::GesturePinchBegin:
     159    case WebInputEvent::GesturePinchEnd:
     160    case WebInputEvent::GesturePinchUpdate:
     161        // FIXME: Once PlatformGestureEvent is updated to support pinch, this should set m_type to appropriate PlatformEvent type.
     162        ASSERT_NOT_REACHED();
    158163    default:
    159164        ASSERT_NOT_REACHED();
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp

    r107036 r107125  
    276276    case WebInputEvent::ContextMenu:
    277277        return false;
     278
     279    case WebInputEvent::GesturePinchBegin:
     280    case WebInputEvent::GesturePinchEnd:
     281    case WebInputEvent::GesturePinchUpdate:
     282        // FIXME: Once PlatformGestureEvent is updated to support pinch, this should call handleGestureEvent, just like it currently does for gesture scroll.
     283        return false;
    278284    }
    279285    return false;
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r107036 r107125  
    14171417#endif
    14181418
     1419#if ENABLE(GESTURE_EVENTS)
     1420    case WebInputEvent::GesturePinchBegin:
     1421    case WebInputEvent::GesturePinchEnd:
     1422    case WebInputEvent::GesturePinchUpdate:
     1423        // FIXME: Once PlatformGestureEvent is updated to support pinch, this should call handleGestureEvent, just like it currently does for gesture scroll.
     1424        handled = false;
     1425        break;
     1426#endif
     1427
    14191428    default:
    14201429        handled = false;
  • trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp

    r106987 r107125  
    4747    MockInputHandlerClient()
    4848        : m_scrollStatus(ScrollStarted)
     49        , m_pinchStarted(false)
     50        , m_pinchEnded(false)
     51        , m_pinchMagnification(0)
    4952    {
    5053    }
     
    5255
    5356    void setScrollStatus(ScrollStatus status) { m_scrollStatus = status; }
     57
     58    bool pinchStarted() const { return m_pinchStarted; }
     59    bool pinchEnded() const { return m_pinchEnded; }
     60    float pinchMaginifcation() const { return m_pinchMagnification; }
     61
     62    void resetPinch()
     63    {
     64        m_pinchStarted = m_pinchStarted = false;
     65        m_pinchMagnification = 0;
     66    }
    5467
    5568private:
     
    6376
    6477    virtual bool haveWheelEventHandlers() OVERRIDE { return false; }
    65     virtual void pinchGestureBegin() OVERRIDE { }
    66     virtual void pinchGestureUpdate(float magnifyDelta, const WebCore::IntPoint& anchor) OVERRIDE { }
    67     virtual void pinchGestureEnd() OVERRIDE { }
     78    virtual void pinchGestureBegin() OVERRIDE
     79    {
     80        m_pinchStarted = true;
     81    }
     82    virtual void pinchGestureUpdate(float magnifyDelta, const WebCore::IntPoint& anchor) OVERRIDE
     83    {
     84        m_pinchMagnification = magnifyDelta;
     85    }
     86    virtual void pinchGestureEnd() OVERRIDE
     87    {
     88        m_pinchEnded = true;
     89    }
    6890    virtual void startPageScaleAnimation(const WebCore::IntSize& targetPosition,
    6991                                         bool anchorPoint,
     
    7395
    7496    ScrollStatus m_scrollStatus;
     97    bool m_pinchStarted;
     98    bool m_pinchEnded;
     99    float m_pinchMagnification;
    75100};
    76101
     
    201226}
    202227
    203 }
     228TEST(WebCompositorInputHandlerImpl, gesturePinch)
     229{
     230    WebKit::WebCompositor::initialize(0);
     231#ifndef NDEBUG
     232    // WebCompositorInputHandler APIs can only be called from the compositor thread.
     233    WebCore::DebugScopedSetImplThread alwaysImplThread;
     234#endif
     235
     236    MockInputHandlerClient mockInputHandler;
     237    OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputHandlerImpl::create(&mockInputHandler);
     238    MockWebCompositorInputHandlerClient mockClient;
     239    inputHandler->setClient(&mockClient);
     240
     241    WebKit::WebGestureEvent gesture;
     242
     243    gesture.type = WebKit::WebInputEvent::GesturePinchBegin;
     244    inputHandler->handleInputEvent(gesture);
     245    EXPECT_TRUE(mockClient.handled());
     246    EXPECT_FALSE(mockClient.sendToWidget());
     247    EXPECT_TRUE(mockInputHandler.pinchStarted());
     248    mockClient.reset();
     249    mockInputHandler.resetPinch();
     250
     251    gesture.type = WebKit::WebInputEvent::GesturePinchUpdate;
     252    gesture.deltaX = 1.5;
     253    inputHandler->handleInputEvent(gesture);
     254    EXPECT_TRUE(mockClient.handled());
     255    EXPECT_FALSE(mockClient.sendToWidget());
     256    EXPECT_FALSE(mockInputHandler.pinchEnded());
     257    EXPECT_EQ(1.5, mockInputHandler.pinchMaginifcation());
     258    mockClient.reset();
     259    mockInputHandler.resetPinch();
     260
     261    gesture.type = WebKit::WebInputEvent::GesturePinchUpdate;
     262    gesture.deltaX = 0.5;
     263    inputHandler->handleInputEvent(gesture);
     264    EXPECT_TRUE(mockClient.handled());
     265    EXPECT_FALSE(mockClient.sendToWidget());
     266    EXPECT_FALSE(mockInputHandler.pinchEnded());
     267    EXPECT_EQ(0.5, mockInputHandler.pinchMaginifcation());
     268    mockClient.reset();
     269    mockInputHandler.resetPinch();
     270
     271    gesture.type = WebKit::WebInputEvent::GesturePinchEnd;
     272    inputHandler->handleInputEvent(gesture);
     273    EXPECT_TRUE(mockClient.handled());
     274    EXPECT_FALSE(mockClient.sendToWidget());
     275    EXPECT_TRUE(mockInputHandler.pinchEnded());
     276    mockClient.reset();
     277    mockInputHandler.resetPinch();
     278
     279    inputHandler->setClient(0);
     280
     281    WebKit::WebCompositor::shutdown();
     282}
     283
     284}
Note: See TracChangeset for help on using the changeset viewer.