Changeset 91809 in webkit


Ignore:
Timestamp:
Jul 26, 2011 6:52:19 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Layering violations in gesture recognizer
https://bugs.webkit.org/show_bug.cgi?id=65044

Patch by Robert Kroeger <rjkroege@chromium.org> on 2011-07-26
Reviewed by Adam Barth.

Source/WebCore:

Divided the gesture recognizer up to correct a layering
violation by moving gesture implementation from it to
EventHandler::handleGestureEvent so that the gesture recognizer
could simply be an engine for generating gesture events from
touch events.

  • page/EventHandler.cpp:

(WebCore::EventHandler::EventHandler):
Removed construction of gesture recognizer.
(WebCore::EventHandler::handleGestureEvent):
Extended for new gesture events added in this patch.
(WebCore::EventHandler::handleTouchEvent):
Removed call into gesture recognizer.

  • page/EventHandler.h:
  • page/FrameView.cpp:

(WebCore::FrameView::reset):
Removed code to reset gesture recognizer.

  • platform/PlatformGestureEvent.h:

(WebCore::PlatformGestureEvent::PlatformGestureEvent):
(WebCore::PlatformGestureEvent::deltaX):
(WebCore::PlatformGestureEvent::deltaY):
(WebCore::PlatformGestureEvent::shiftKey):
(WebCore::PlatformGestureEvent::ctrlKey):
(WebCore::PlatformGestureEvent::altKey):
(WebCore::PlatformGestureEvent::metaKey):
Added additional gesture types and parameters.

  • platform/PlatformGestureRecognizer.h:
  • platform/chromium/FramelessScrollView.h:

Added support for displatching gesture and touch events.

  • platform/chromium/GestureRecognizerChromium.cpp:

(WebCore::InnerGestureRecognizer::InnerGestureRecognizer):
(WebCore::InnerGestureRecognizer::reset):
(WebCore::InnerGestureRecognizer::constructClickGestureEvent):
(WebCore::InnerGestureRecognizer::processTouchEventForGestures):
Removed all depedencies on EventHandler. Instead, create gesture
events from touch event stream.
(WebCore::InnerGestureRecognizer::constructScrollGesture):
(WebCore::touchDown):
(WebCore::noGesture):
(WebCore::click):
(WebCore::isClickOrScroll):
(WebCore::inScroll):
(WebCore::GestureRecognizerChromium::processTouchEventForGestures):
(WebCore::GestureRecognizerChromium::reset):

  • platform/chromium/GestureRecognizerChromium.h:
  • platform/chromium/PopupMenuChromium.cpp:

Added support to handle touch events and gesture events.
(WebCore::PopupContainer::handleTouchEvent):
(WebCore::PopupContainer::handleGestureEvent):
(WebCore::PopupListBox::handleTouchEvent):
(WebCore::PopupListBox::handleGestureEvent):

  • platform/chromium/PopupMenuChromium.h:
  • platform/mac/ScrollAnimatorMac.mm:

(WebCore::ScrollAnimatorMac::handleGestureEvent):
Ignores the newly added gesture event types.

Source/WebKit/chromium:

Moved gesture recognition higher up the event delivery code
path so that recognition of gestures is completely separated
from gesture handling.

  • features.gypi:
  • src/WebFrameImpl.cpp:

(WebKit::WebFrameImpl::createFrameView):
Added code to reset the gesture recognizer to preserve parallel
layout test execution.

  • src/WebPopupMenuImpl.cpp:

Support dispatching touch and gesture events to Popups.
(WebKit::WebPopupMenuImpl::WebPopupMenuImpl):
(WebKit::WebPopupMenuImpl::TouchEvent):
(WebKit::WebPopupMenuImpl::handleInputEvent):

  • src/WebPopupMenuImpl.h:
  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::WebViewImpl):
Added gesture recognition creation.
(WebKit::WebViewImpl::touchEvent):
Added recognition of gestures and dispatch of gesture events.
(WebKit::WebViewImpl::resetGestureRecognizer):

  • src/WebViewImpl.h:
Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r91808 r91809  
     12011-07-26  Robert Kroeger  <rjkroege@chromium.org>
     2
     3        [chromium] Layering violations in gesture recognizer
     4        https://bugs.webkit.org/show_bug.cgi?id=65044
     5
     6        Reviewed by Adam Barth.
     7
     8        Divided the gesture recognizer up to correct a layering
     9        violation by moving gesture implementation from it to
     10        EventHandler::handleGestureEvent so that the gesture recognizer
     11        could simply be an engine for generating gesture events from
     12        touch events.
     13
     14        * page/EventHandler.cpp:
     15        (WebCore::EventHandler::EventHandler):
     16        Removed construction of gesture recognizer.
     17        (WebCore::EventHandler::handleGestureEvent):
     18        Extended for new gesture events added in this patch.
     19        (WebCore::EventHandler::handleTouchEvent):
     20        Removed call into gesture recognizer.
     21        * page/EventHandler.h:
     22        * page/FrameView.cpp:
     23        (WebCore::FrameView::reset):
     24        Removed code to reset gesture recognizer.
     25        * platform/PlatformGestureEvent.h:
     26        (WebCore::PlatformGestureEvent::PlatformGestureEvent):
     27        (WebCore::PlatformGestureEvent::deltaX):
     28        (WebCore::PlatformGestureEvent::deltaY):
     29        (WebCore::PlatformGestureEvent::shiftKey):
     30        (WebCore::PlatformGestureEvent::ctrlKey):
     31        (WebCore::PlatformGestureEvent::altKey):
     32        (WebCore::PlatformGestureEvent::metaKey):
     33        Added additional gesture types and parameters.
     34        * platform/PlatformGestureRecognizer.h:
     35        * platform/chromium/FramelessScrollView.h:
     36        Added support for displatching gesture and touch events.
     37        * platform/chromium/GestureRecognizerChromium.cpp:
     38        (WebCore::InnerGestureRecognizer::InnerGestureRecognizer):
     39        (WebCore::InnerGestureRecognizer::reset):
     40        (WebCore::InnerGestureRecognizer::constructClickGestureEvent):
     41        (WebCore::InnerGestureRecognizer::processTouchEventForGestures):
     42        Removed all depedencies on EventHandler. Instead, create gesture
     43        events from touch event stream.
     44        (WebCore::InnerGestureRecognizer::constructScrollGesture):
     45        (WebCore::touchDown):
     46        (WebCore::noGesture):
     47        (WebCore::click):
     48        (WebCore::isClickOrScroll):
     49        (WebCore::inScroll):
     50        (WebCore::GestureRecognizerChromium::processTouchEventForGestures):
     51        (WebCore::GestureRecognizerChromium::reset):
     52        * platform/chromium/GestureRecognizerChromium.h:
     53        * platform/chromium/PopupMenuChromium.cpp:
     54        Added support to handle touch events and gesture events.
     55        (WebCore::PopupContainer::handleTouchEvent):
     56        (WebCore::PopupContainer::handleGestureEvent):
     57        (WebCore::PopupListBox::handleTouchEvent):
     58        (WebCore::PopupListBox::handleGestureEvent):
     59        * platform/chromium/PopupMenuChromium.h:
     60        * platform/mac/ScrollAnimatorMac.mm:
     61        (WebCore::ScrollAnimatorMac::handleGestureEvent):
     62        Ignores the newly added gesture event types.
     63
    1642011-07-26  Joseph Pecoraro  <joepeck@webkit.org>
    265
  • trunk/Source/WebCore/dom/WheelEvent.cpp

    r87865 r91809  
    4444                        true, true, view, 0, screenLocation, pageLocation,
    4545                        ctrlKey, altKey, shiftKey, metaKey)
    46     , m_wheelDelta(IntPoint(static_cast<int>(wheelTicks.x() * 120), static_cast<int>(wheelTicks.y() * 120)))
     46    , m_wheelDelta(IntPoint(static_cast<int>(wheelTicks.x() * tickMultiplier), static_cast<int>(wheelTicks.y() * tickMultiplier)))
    4747    , m_rawDelta(roundedIntPoint(rawDelta))
    4848    , m_granularity(granularity)
     
    6666   
    6767    // Normalize to the Windows 120 multiple
    68     m_wheelDelta = IntPoint(rawDeltaX * 120, rawDeltaY * 120);
     68    m_wheelDelta = IntPoint(rawDeltaX * tickMultiplier, rawDeltaY * tickMultiplier);
    6969   
    7070    m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
  • trunk/Source/WebCore/dom/WheelEvent.h

    r87865 r91809  
    3333    class WheelEvent : public MouseRelatedEvent {
    3434    public:
     35        enum { tickMultiplier = 120 };
     36
    3537        enum Granularity { Pixel, Line, Page };
    3638
  • trunk/Source/WebCore/page/EventHandler.cpp

    r91003 r91809  
    101101#endif
    102102
    103 #if ENABLE(GESTURE_RECOGNIZER)
    104 #include "PlatformGestureRecognizer.h"
    105 #endif
    106 
    107103namespace WebCore {
    108104
     
    210206#if ENABLE(TOUCH_EVENTS)
    211207    , m_touchPressed(false)
    212 #endif
    213 #if ENABLE(GESTURE_RECOGNIZER)
    214     , m_gestureRecognizer(PlatformGestureRecognizer::create())
    215208#endif
    216209{
     
    22282221    // end gesture as well.
    22292222
    2230     FrameView* view = m_frame->view();
    2231     if (!view)
    2232         return false;
    2233 
    2234     view->handleGestureEvent(gestureEvent);
     2223    switch (gestureEvent.type()) {
     2224    case PlatformGestureEvent::TapType: {
     2225        // FIXME: Refactor this code to not hit test multiple times once hit testing has been corrected as suggested above.
     2226        PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(), NoButton, MouseEventMoved, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
     2227        PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, MouseEventPressed, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
     2228        PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, MouseEventReleased, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
     2229        mouseMoved(fakeMouseMove);
     2230        handleMousePressEvent(fakeMouseDown);
     2231        handleMouseReleaseEvent(fakeMouseUp);
     2232        return true;
     2233    }
     2234    case PlatformGestureEvent::ScrollUpdateType: {
     2235        const float tickDivisor = (float)WheelEvent::tickMultiplier;
     2236        // FIXME: Replace this interim implementation once the above fixme has been addressed.
     2237        PlatformWheelEvent syntheticWheelEvent(gestureEvent.position(), gestureEvent.globalPosition(), gestureEvent.deltaX(), gestureEvent.deltaY(), gestureEvent.deltaX() / tickDivisor, gestureEvent.deltaY() / tickDivisor, ScrollByPixelWheelEvent, /* isAccepted */ false, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey());
     2238        handleWheelEvent(syntheticWheelEvent);
     2239        return true;
     2240    }
     2241    case PlatformGestureEvent::ScrollBeginType:
     2242    case PlatformGestureEvent::ScrollEndType:
     2243        FrameView* view = m_frame->view();
     2244        if (!view)
     2245            return false;
     2246
     2247        view->handleGestureEvent(gestureEvent);
     2248        return true;
     2249    }
    22352250    return true;
    22362251}
     
    32873302    }
    32883303
    3289 #if ENABLE(GESTURE_RECOGNIZER)
    3290     if (m_gestureRecognizer)
    3291         m_gestureRecognizer->processTouchEventForGesture(event, this, defaultPrevented);
    3292 #endif
    3293 
    32943304    return defaultPrevented;
    32953305}
    32963306
    3297 #if ENABLE(GESTURE_RECOGNIZER)
    3298 void EventHandler::resetGestureRecognizer()
    3299 {
    3300     if (m_gestureRecognizer)
    3301         m_gestureRecognizer->reset();
    3302 }
    3303 #endif
    3304 
    3305 
    3306 #endif
    3307 
    3308 }
     3307
     3308
     3309#endif
     3310
     3311}
  • trunk/Source/WebCore/page/EventHandler.h

    r88307 r91809  
    8181#endif
    8282
    83 #if ENABLE(GESTURE_RECOGNIZER)
    84 class PlatformGestureRecognizer;
    85 #endif
    86 
    8783#if ENABLE(DRAG_SUPPORT)
    8884extern const int LinkDragHysteresis;
     
    165161#if ENABLE(GESTURE_EVENTS)
    166162    bool handleGestureEvent(const PlatformGestureEvent&);
    167 #endif
    168 
    169 #if ENABLE(GESTURE_RECOGNIZER)
    170     void resetGestureRecognizer();
    171163#endif
    172164
     
    430422    bool m_touchPressed;
    431423#endif
    432 #if ENABLE(GESTURE_RECOGNIZER)
    433     OwnPtr<PlatformGestureRecognizer> m_gestureRecognizer;
    434 #endif
    435424};
    436425
  • trunk/Source/WebCore/page/FrameView.cpp

    r91808 r91809  
    233233    m_firstVisuallyNonEmptyLayoutCallbackPending = true;
    234234    m_maintainScrollPositionAnchor = 0;
    235 
    236 #if ENABLE(GESTURE_RECOGNIZER)
    237     frame()->eventHandler()->resetGestureRecognizer();
    238 #endif
    239235}
    240236
  • trunk/Source/WebCore/platform/PlatformGestureEvent.h

    r76745 r91809  
    3838        ScrollBeginType,
    3939        ScrollEndType,
     40        ScrollUpdateType,
     41        TapType
    4042    };
    4143
     
    4345        : m_type(ScrollBeginType)
    4446        , m_timestamp(0)
     47    {
     48    }
     49
     50    PlatformGestureEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const double timestamp, const float deltaX, const float deltaY, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey)
     51        : m_type(type)
     52        , m_position(position)
     53        , m_globalPosition(globalPosition)
     54        , m_timestamp(timestamp)
     55        , m_deltaX(deltaX)
     56        , m_deltaY(deltaY)
     57        , m_shiftKey(shiftKey)
     58        , m_ctrlKey(ctrlKey)
     59        , m_altKey(altKey)
     60        , m_metaKey(metaKey)
    4561    {
    4662    }
     
    5369    double timestamp() const { return m_timestamp; }
    5470
     71    float deltaX() const { return m_deltaX; }
     72    float deltaY() const { return m_deltaY; }
     73    bool shiftKey() const { return m_shiftKey; }
     74    bool ctrlKey() const { return m_ctrlKey; }
     75    bool altKey() const { return m_altKey; }
     76    bool metaKey() const { return m_metaKey; }
     77
    5578protected:
    5679    Type m_type;
     
    5881    IntPoint m_globalPosition;
    5982    double m_timestamp;
     83    float m_deltaX;
     84    float m_deltaY;
     85    bool m_shiftKey;
     86    bool m_ctrlKey;
     87    bool m_altKey;
     88    bool m_metaKey;
    6089};
    6190
  • trunk/Source/WebCore/platform/PlatformGestureRecognizer.h

    r88307 r91809  
    3232#define PlatformGestureRecognizer_h
    3333
     34#include "PlatformGestureEvent.h"
    3435#include <wtf/PassOwnPtr.h>
     36#include <wtf/Vector.h>
    3537
    3638namespace WebCore {
    3739
    3840class EventHandler;
    39 class PlatformGestureRecognizer;
    4041class PlatformTouchEvent;
    4142
    42 // A GestureRecognizer detects gestures occurring in the touch event.
    43 // In response to a given touch event, the GestureRecognizer, updates
    44 // its internal state and optionally dispatches synthetic events to the
    45 // invoking EventHandler instance.
    4643class PlatformGestureRecognizer {
    4744protected:
     
    5249    virtual ~PlatformGestureRecognizer();
    5350
    54     // Invoked for each touch event that could contribute to the current gesture.
    55     // Takes a PlatformTouchEvent and the EventHandler that originated it and which will also
    56     // be the target of any generated synthetic event. Finally, |handled|
    57     // specifies if the |event| was actually handled by |source| (by the JavaScript)
    58     // Returns true if the event resulted in firing a synthetic event.
    59     virtual bool processTouchEventForGesture(const PlatformTouchEvent&, EventHandler*, bool handled) = 0;
     51    typedef PassOwnPtr<Vector<PlatformGestureEvent> > PassGestures;
     52
     53    // Invoked for each touch event and returns 0 or more resulting gestures.
     54    virtual PassGestures processTouchEventForGestures(const PlatformTouchEvent&, bool defaultPrevented) = 0;
    6055
    6156    // Clears the GestureRecognizer to its initial state.
  • trunk/Source/WebCore/platform/chromium/FramelessScrollView.h

    r90152 r91809  
    3737
    3838    class FramelessScrollViewClient;
     39#if ENABLE(GESTURE_RECOGNIZER)
     40    class PlatformGestureEvent;
     41#endif
    3942    class PlatformKeyboardEvent;
    4043    class PlatformMouseEvent;
     44#if ENABLE(TOUCH_EVENTS)
     45    class PlatformTouchEvent;
     46#endif
    4147    class PlatformWheelEvent;
    4248
     
    6167        virtual bool handleWheelEvent(const PlatformWheelEvent&) = 0;
    6268        virtual bool handleKeyEvent(const PlatformKeyboardEvent&) = 0;
     69#if ENABLE(TOUCH_EVENTS)
     70        virtual bool handleTouchEvent(const PlatformTouchEvent&) = 0;
     71#endif
     72#if ENABLE(GESTURE_RECOGNIZER)
     73        virtual bool handleGestureEvent(const PlatformGestureEvent&) = 0;
     74#endif
    6375
    6476        // ScrollableArea public methods:
  • trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp

    r88307 r91809  
    3232#include "GestureRecognizerChromium.h"
    3333
    34 #include "EventHandler.h"
    3534#include "PlatformMouseEvent.h"
    3635#include "PlatformWheelEvent.h"
     
    3837namespace WebCore {
    3938
    40 static bool click(InnerGestureRecognizer*, const PlatformTouchPoint&);
    41 static bool isClickOrScroll(InnerGestureRecognizer*, const PlatformTouchPoint&);
    42 static bool inScroll(InnerGestureRecognizer*, const PlatformTouchPoint&);
    43 static bool noGesture(InnerGestureRecognizer*, const PlatformTouchPoint&);
    44 static bool touchDown(InnerGestureRecognizer*, const PlatformTouchPoint&);
     39// FIXME: Convert to methods.
     40static bool click(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
     41static bool isClickOrScroll(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
     42static bool inScroll(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
     43static bool noGesture(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
     44static bool touchDown(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
    4545
    4646// FIXME: Make these configurable programmatically.
     
    5353    , m_state(InnerGestureRecognizer::NoGesture)
    5454    , m_lastTouchTime(0.0)
    55     , m_eventHandler(0)
    5655    , m_ctrlKey(false)
    5756    , m_altKey(false)
     
    8180    m_state = InnerGestureRecognizer::NoGesture;
    8281    m_lastTouchTime = 0.0;
    83     m_eventHandler = 0;
    8482}
    8583
     
    105103}
    106104
    107 void InnerGestureRecognizer::dispatchSyntheticClick(const PlatformTouchPoint& point)
    108 {
    109     PlatformMouseEvent fakeMouseMove(point.pos(), point.screenPos(), NoButton, MouseEventMoved, /* clickCount */ 1, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey, m_lastTouchTime);
    110     PlatformMouseEvent fakeMouseDown(point.pos(), point.screenPos(), LeftButton, MouseEventPressed, /* clickCount */ 1, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey, m_lastTouchTime);
    111     PlatformMouseEvent fakeMouseUp(point.pos(), point.screenPos(), LeftButton, MouseEventReleased, /* clickCount */ 1, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey, m_lastTouchTime);
    112 
    113     m_eventHandler->mouseMoved(fakeMouseMove);
    114     m_eventHandler->handleMousePressEvent(fakeMouseDown);
    115     m_eventHandler->handleMouseReleaseEvent(fakeMouseUp);
    116 }
    117 
    118 bool InnerGestureRecognizer::processTouchEventForGesture(const PlatformTouchEvent& event, EventHandler* eventHandler, bool handled)
    119 {
    120     m_eventHandler = eventHandler;
     105void InnerGestureRecognizer::appendClickGestureEvent(const PlatformTouchPoint& touchPoint, InnerGestureRecognizer::Gestures gestures)
     106{
     107    gestures->append(PlatformGestureEvent(PlatformGestureEvent::TapType, touchPoint.pos(), touchPoint.screenPos(), m_lastTouchTime, 0.0f, 0.0f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));
     108}
     109
     110PlatformGestureRecognizer::PassGestures InnerGestureRecognizer::processTouchEventForGestures(const PlatformTouchEvent& event, bool defaultPrevented)
     111{
    121112    m_ctrlKey = event.ctrlKey();
    122113    m_altKey = event.altKey();
     
    124115    m_metaKey = event.metaKey();
    125116
     117    OwnPtr<Vector<PlatformGestureEvent> > gestures = adoptPtr(new Vector<PlatformGestureEvent>());
    126118    const Vector<PlatformTouchPoint>& points = event.touchPoints();
    127119    for (unsigned i = 0; i < points.size(); i++) {
     
    129121        updateValues(event.timestamp(), p);
    130122
    131         if (GestureTransitionFunction ef = m_edgeFunctions.get(signature(m_state, p.id(), p.state(), handled)))
    132             handled = (*ef)(this, p);
    133     }
    134     return handled;
    135 }
    136 
    137 void InnerGestureRecognizer::scrollViaTouchMotion(const PlatformTouchPoint& touchPoint)
     123        if (GestureTransitionFunction ef = m_edgeFunctions.get(signature(m_state, p.id(), p.state(), defaultPrevented)))
     124            (*ef)(this, p, gestures.get());
     125    }
     126    return gestures.release();
     127}
     128
     129void InnerGestureRecognizer::appendScrollGesture(const PlatformTouchPoint& touchPoint, Gestures gestures)
    138130{
    139131    float deltaX(touchPoint.pos().x() - m_firstTouchPosition.x());
    140132    float deltaY(touchPoint.pos().y() - m_firstTouchPosition.y());
    141133
    142     // FIXME: Convert to gesture events when they handle subframes.
    143     PlatformWheelEvent syntheticWheelEvent(touchPoint.pos(), touchPoint.screenPos(), deltaX, deltaY, deltaX / static_cast<float>(120), deltaY / static_cast<float>(120), ScrollByPixelWheelEvent, /* isAccepted */ false, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey);
    144     m_eventHandler->handleWheelEvent(syntheticWheelEvent);
     134    gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollUpdateType, touchPoint.pos(), touchPoint.screenPos(), m_lastTouchTime, deltaX, deltaY, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));
    145135    m_firstTouchPosition = touchPoint.pos();
    146136}
     
    167157}
    168158
    169 static bool touchDown(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint&)
     159static bool touchDown(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures gestures)
    170160{
    171161    gestureRecognizer->setState(InnerGestureRecognizer::PendingSyntheticClick);
     
    173163}
    174164
    175 bool noGesture(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint&)
     165static bool noGesture(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures gestures)
    176166{
    177167    gestureRecognizer->reset();
     
    179169}
    180170
    181 static bool click(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point)
     171static bool click(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures)
    182172{
    183173    if (gestureRecognizer->isInClickTimeWindow() && gestureRecognizer->isInsideManhattanSquare(point)) {
    184174        gestureRecognizer->setState(InnerGestureRecognizer::NoGesture);
    185         gestureRecognizer->dispatchSyntheticClick(point);
     175        gestureRecognizer->appendClickGestureEvent(point, gestures);
    186176        return true;
    187177    }
    188     return noGesture(gestureRecognizer, point);
    189 }
    190 
    191 static bool isClickOrScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point)
     178    return noGesture(gestureRecognizer, point, gestures);
     179}
     180
     181static bool isClickOrScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures)
    192182{
    193183    if (gestureRecognizer->isInClickTimeWindow() && gestureRecognizer->isInsideManhattanSquare(point)) {
     
    197187
    198188    if (point.state() == PlatformTouchPoint::TouchMoved && !gestureRecognizer->isInsideManhattanSquare(point)) {
    199         gestureRecognizer->scrollViaTouchMotion(point);
     189        gestureRecognizer->appendScrollGesture(point, gestures);
    200190        gestureRecognizer->setState(InnerGestureRecognizer::Scroll);
    201191        return true;
     
    204194}
    205195
    206 static bool inScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point)
    207 {
    208     gestureRecognizer->scrollViaTouchMotion(point);
     196static bool inScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures)
     197{
     198    gestureRecognizer->appendScrollGesture(point, gestures);
    209199    return true;
    210200}
     
    233223}
    234224
     225PlatformGestureRecognizer::PassGestures GestureRecognizerChromium::processTouchEventForGestures(const PlatformTouchEvent& touchEvent, bool defaultPrevented)
     226{
     227    return m_innerGestureRecognizer.processTouchEventForGestures(touchEvent, defaultPrevented);
     228}
     229
     230void GestureRecognizerChromium::reset()
     231{
     232    m_innerGestureRecognizer.reset();
     233}
     234
    235235} // namespace WebCore
  • trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h

    r88307 r91809  
    4040namespace WebCore {
    4141
     42class PlatformGestureEvent;
     43
    4244class InnerGestureRecognizer {
    4345public:
     
    4850    };
    4951
    50     typedef bool (*GestureTransitionFunction)(InnerGestureRecognizer*, const PlatformTouchPoint&);
     52    typedef Vector<PlatformGestureEvent>* Gestures;
     53    typedef bool (*GestureTransitionFunction)(InnerGestureRecognizer*, const PlatformTouchPoint&, Gestures);
    5154
    5255    ~InnerGestureRecognizer();
    5356
    54     void dispatchSyntheticClick(const PlatformTouchPoint&);
     57    void appendClickGestureEvent(const PlatformTouchPoint&, Gestures);
    5558    virtual void reset();
    5659    bool isInClickTimeWindow();
    5760    bool isInsideManhattanSquare(const PlatformTouchPoint&);
    58     virtual bool processTouchEventForGesture(const PlatformTouchEvent&, EventHandler*, bool handled);
    59     void scrollViaTouchMotion(const PlatformTouchPoint&);
     61    virtual PlatformGestureRecognizer::PassGestures  processTouchEventForGestures(const PlatformTouchEvent&, bool defaultPrevented);
     62    void appendScrollGesture(const PlatformTouchPoint&, Gestures);
    6063    void setState(State value) { m_state = value; }
    6164    State state() { return m_state; }
     
    7376    State m_state;
    7477    double m_lastTouchTime;
    75     EventHandler* m_eventHandler;
    7678
    7779    bool m_ctrlKey;
     
    8789    virtual ~GestureRecognizerChromium();
    8890
    89     virtual void reset()
    90     {
    91         m_innerGestureRecognizer.reset();
    92     };
     91    virtual void reset();
    9392 
    94     virtual bool processTouchEventForGesture(const PlatformTouchEvent& touchEvent, EventHandler* eventHandler, bool handled)
    95     {
    96         return m_innerGestureRecognizer.processTouchEventForGesture(touchEvent, eventHandler, handled);
    97     }
     93    virtual PlatformGestureRecognizer::PassGestures  processTouchEventForGestures(const PlatformTouchEvent&, bool defaultPrevented);
    9894private:
    9995    InnerGestureRecognizer m_innerGestureRecognizer;
  • trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp

    r90769 r91809  
    5959#include <wtf/unicode/CharacterNames.h>
    6060
     61#if ENABLE(GESTURE_EVENTS)
     62#include "PlatformGestureEvent.h"
     63#endif
     64
     65#if ENABLE(TOUCH_EVENTS)
     66#include "PlatformTouchEvent.h"
     67#endif
     68
    6169using namespace std;
    6270using namespace WTF;
     
    104112    virtual bool handleWheelEvent(const PlatformWheelEvent&);
    105113    virtual bool handleKeyEvent(const PlatformKeyboardEvent&);
     114#if ENABLE(TOUCH_EVENTS)
     115    virtual bool handleTouchEvent(const PlatformTouchEvent&);
     116#endif
     117#if ENABLE(GESTURE_RECOGNIZER)
     118    virtual bool handleGestureEvent(const PlatformGestureEvent&);
     119#endif
    106120
    107121    // ScrollView
     
    510524}
    511525
     526#if ENABLE(TOUCH_EVENTS)
     527bool PopupContainer::handleTouchEvent(const PlatformTouchEvent&)
     528{
     529    return false;
     530}
     531#endif
     532
     533#if ENABLE(GESTURE_RECOGNIZER)
     534// FIXME: Refactor this code to share functionality with EventHandler::handleGestureEvent.
     535bool PopupContainer::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
     536{
     537    switch (gestureEvent.type()) {
     538    case PlatformGestureEvent::TapType: {
     539        PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(), NoButton, MouseEventMoved, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
     540        PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, MouseEventPressed, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
     541        PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, MouseEventReleased, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
     542        // handleMouseMoveEvent(fakeMouseMove);
     543        handleMouseDownEvent(fakeMouseDown);
     544        handleMouseReleaseEvent(fakeMouseUp);
     545        return true;
     546    }
     547    case PlatformGestureEvent::ScrollUpdateType: {
     548        PlatformWheelEvent syntheticWheelEvent(gestureEvent.position(), gestureEvent.globalPosition(), gestureEvent.deltaX(), gestureEvent.deltaY(), gestureEvent.deltaX() / 120.0f, gestureEvent.deltaY() / 120.0f, ScrollByPixelWheelEvent, /* isAccepted */ false, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey());
     549        handleWheelEvent(syntheticWheelEvent);
     550        return true;
     551    }
     552    case PlatformGestureEvent::ScrollBeginType:
     553    case PlatformGestureEvent::ScrollEndType:
     554        break;
     555    }
     556    return false;
     557}
     558#endif
     559
    512560bool PopupContainer::handleKeyEvent(const PlatformKeyboardEvent& event)
    513561{
     
    752800    }
    753801}
     802
     803#if ENABLE(TOUCH_EVENTS)
     804bool PopupListBox::handleTouchEvent(const PlatformTouchEvent&)
     805{
     806    return false;
     807}
     808#endif
     809
     810#if ENABLE(GESTURE_RECOGNIZER)
     811bool PopupListBox::handleGestureEvent(const PlatformGestureEvent&)
     812{
     813    return false;
     814}
     815#endif
    754816
    755817static bool isCharacterTypeEvent(const PlatformKeyboardEvent& event)
  • trunk/Source/WebCore/platform/chromium/PopupMenuChromium.h

    r89916 r91809  
    123123    virtual bool handleWheelEvent(const PlatformWheelEvent&);
    124124    virtual bool handleKeyEvent(const PlatformKeyboardEvent&);
     125#if ENABLE(TOUCH_EVENTS)
     126    virtual bool handleTouchEvent(const PlatformTouchEvent&);
     127#endif
     128#if ENABLE(GESTURE_RECOGNIZER)
     129    virtual bool handleGestureEvent(const PlatformGestureEvent&);
     130#endif
    125131
    126132    // PopupContainer methods
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r88982 r91809  
    860860    if (gestureEvent.type() == PlatformGestureEvent::ScrollBeginType)
    861861        beginScrollGesture();
    862     else
     862    else if (gestureEvent.type() == PlatformGestureEvent::ScrollEndType)
    863863        endScrollGesture();
    864864}
  • trunk/Source/WebKit/chromium/ChangeLog

    r91797 r91809  
     12011-07-26  Robert Kroeger  <rjkroege@chromium.org>
     2
     3        [chromium] Layering violations in gesture recognizer
     4        https://bugs.webkit.org/show_bug.cgi?id=65044
     5
     6        Reviewed by Adam Barth.
     7
     8        Moved gesture recognition higher up the event delivery code
     9        path so that recognition of gestures is completely separated
     10        from gesture handling.
     11
     12        * features.gypi:
     13        * src/WebFrameImpl.cpp:
     14        (WebKit::WebFrameImpl::createFrameView):
     15        Added code to reset the gesture recognizer to preserve parallel
     16        layout test execution.
     17        * src/WebPopupMenuImpl.cpp:
     18        Support dispatching touch and gesture events to Popups.
     19        (WebKit::WebPopupMenuImpl::WebPopupMenuImpl):
     20        (WebKit::WebPopupMenuImpl::TouchEvent):
     21        (WebKit::WebPopupMenuImpl::handleInputEvent):
     22        * src/WebPopupMenuImpl.h:
     23        * src/WebViewImpl.cpp:
     24        (WebKit::WebViewImpl::WebViewImpl):
     25        Added gesture recognition creation.
     26        (WebKit::WebViewImpl::touchEvent):
     27        Added recognition of gestures and dispatch of gesture events.
     28        (WebKit::WebViewImpl::resetGestureRecognizer):
     29        * src/WebViewImpl.h:
     30
    1312011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
    232
  • trunk/Source/WebKit/chromium/features.gypi

    r91797 r91809  
    5151      'ENABLE_FILTERS=1',
    5252      'ENABLE_GEOLOCATION=1',
     53      'ENABLE_GESTURE_EVENTS=1',
    5354      'ENABLE_GESTURE_RECOGNIZER=1',
    5455      'ENABLE_ICONDATABASE=0',
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r90641 r91809  
    19951995    if (isMainFrame)
    19961996        view->setParentVisible(true);
     1997
     1998#if ENABLE(GESTURE_RECOGNIZER)
     1999    webView->resetGestureRecognizer();
     2000#endif
    19972001}
    19982002
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp

    r91107 r91809  
    5353#include <skia/ext/platform_canvas.h>
    5454
     55#if ENABLE(GESTURE_RECOGNIZER)
     56#include "PlatformGestureEvent.h"
     57#include "PlatformGestureRecognizer.h"
     58#endif
     59
    5560using namespace WebCore;
    5661
     
    7075    : m_client(client)
    7176    , m_widget(0)
     77#if ENABLE(GESTURE_RECOGNIZER)
     78    , m_gestureRecognizer(WebCore::PlatformGestureRecognizer::create())
     79#endif
    7280{
    7381    // set to impossible point so we always get the first mouse pos
     
    125133    m_widget->handleWheelEvent(PlatformWheelEventBuilder(m_widget, event));
    126134}
     135
     136#if ENABLE(TOUCH_EVENTS)
     137bool WebPopupMenuImpl::TouchEvent(const WebTouchEvent& event)
     138{
     139
     140    PlatformTouchEventBuilder touchEventBuilder(m_widget, event);
     141    bool defaultPrevented(m_widget->handleTouchEvent(touchEventBuilder));
     142#if ENABLE(GESTURE_RECOGNIZER)
     143    OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureEvents(m_gestureRecognizer->processTouchEventForGestures(touchEventBuilder, defaultPrevented));
     144    for (unsigned int  i = 0; i < gestureEvents->size(); i++)
     145        m_widget->handleGestureEvent((*gestureEvents)[i]);
     146#endif
     147    return defaultPrevented;
     148}
     149#endif
    127150
    128151bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event)
     
    238261        return KeyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
    239262
    240     default:
    241         break;
     263    case WebInputEvent::TouchStart:
     264    case WebInputEvent::TouchMove:
     265    case WebInputEvent::TouchEnd:
     266    case WebInputEvent::TouchCancel:
     267        return TouchEvent(*static_cast<const WebTouchEvent*>(&inputEvent));
     268
     269    case WebInputEvent::Undefined:
     270    case WebInputEvent::MouseEnter:
     271    case WebInputEvent::ContextMenu:
     272        return false;
    242273    }
    243274    return false;
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h

    r91107 r91809  
    3636#include "WebPopupMenu.h"
    3737#include "WebSize.h"
     38#include <wtf/OwnPtr.h>
    3839#include <wtf/RefCounted.h>
    3940
     
    4344class KeyboardEvent;
    4445class Page;
     46#if ENABLE(GESTURE_RECOGNIZER)
     47class PlatformGestureRecognizer;
     48#endif
    4549class PlatformKeyboardEvent;
    4650class Range;
     
    5458class WebRange;
    5559struct WebRect;
     60class WebTouchEvent;
    5661
    5762class WebPopupMenuImpl : public WebPopupMenu,
     
    100105    void MouseDoubleClick(const WebMouseEvent&);
    101106    void MouseWheel(const WebMouseWheelEvent&);
     107    bool TouchEvent(const WebTouchEvent&);
    102108    bool KeyEvent(const WebKeyboardEvent&);
    103109
     
    137143    // before it is destroyed.
    138144    WebCore::FramelessScrollView* m_widget;
     145
     146#if ENABLE(GESTURE_RECOGNIZER)
     147    OwnPtr<WebCore::PlatformGestureRecognizer> m_gestureRecognizer;
     148#endif
    139149};
    140150
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r91621 r91809  
    130130#include <wtf/RefPtr.h>
    131131
     132#if ENABLE(GESTURE_EVENTS)
     133#include "PlatformGestureEvent.h"
     134#endif
     135
     136#if ENABLE(GESTURE_RECOGNIZER)
     137#include "PlatformGestureRecognizer.h"
     138#endif
     139
    132140#if USE(CG)
    133141#include <CoreGraphics/CGBitmapContext.h>
     
    341349    , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0)))
    342350    , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0)))
     351#if ENABLE(GESTURE_RECOGNIZER)
     352    , m_gestureRecognizer(WebCore::PlatformGestureRecognizer::create())
     353#endif
    343354{
    344355    // WebKit/win/WebView.cpp does the same thing, except they call the
     
    758769
    759770    PlatformTouchEventBuilder touchEventBuilder(mainFrameImpl()->frameView(), event);
    760     return mainFrameImpl()->frame()->eventHandler()->handleTouchEvent(touchEventBuilder);
     771    bool defaultPrevented = mainFrameImpl()->frame()->eventHandler()->handleTouchEvent(touchEventBuilder);
     772
     773#if ENABLE(GESTURE_RECOGNIZER)
     774    OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureEvents(m_gestureRecognizer->processTouchEventForGestures(touchEventBuilder, defaultPrevented));
     775    for (unsigned int  i = 0; i < gestureEvents->size(); i++)
     776        mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(gestureEvents->at(i));
     777#endif
     778
     779    return defaultPrevented;
    761780}
    762781#endif
     
    26592678}
    26602679
     2680#if ENABLE(GESTURE_RECOGNIZER)
     2681void WebViewImpl::resetGestureRecognizer()
     2682{
     2683    m_gestureRecognizer->reset();
     2684}
     2685#endif
     2686
     2687
    26612688} // namespace WebKit
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r91621 r91809  
    6868class RenderTheme;
    6969class Widget;
     70#if ENABLE(GESTURE_RECOGNIZER)
     71class PlatformGestureRecognizer;
     72#endif
    7073}
    7174
     
    386389    void fullFramePluginZoomLevelChanged(double zoomLevel);
    387390
     391#if ENABLE(GESTURE_RECOGNIZER)
     392    void resetGestureRecognizer();
     393#endif
     394
    388395private:
    389396    friend class WebView;  // So WebView::Create can call our constructor
     
    566573    OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy;
    567574    OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
     575
     576#if ENABLE(GESTURE_RECOGNIZER)
     577    OwnPtr<WebCore::PlatformGestureRecognizer> m_gestureRecognizer;
     578#endif
    568579};
    569580
Note: See TracChangeset for help on using the changeset viewer.