Changeset 92234 in webkit


Ignore:
Timestamp:
Aug 2, 2011 2:26:02 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

Source/WebCore:

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

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.

  • dom/WheelEvent.cpp:

(WebCore::WheelEvent::WheelEvent):
(WebCore::WheelEvent::initWheelEvent):

  • dom/WheelEvent.h:

Added symbolic contstant for tick multiplier.

  • 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:

Reviewed by Adam Barth.

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

Patch by Robert Kroeger <rjkroege@chromium.org> on 2011-08-02

  • 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

    r92231 r92234  
     12011-08-02  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        * dom/WheelEvent.cpp:
     15        (WebCore::WheelEvent::WheelEvent):
     16        (WebCore::WheelEvent::initWheelEvent):
     17        * dom/WheelEvent.h:
     18        Added symbolic contstant for tick multiplier.
     19        * page/EventHandler.cpp:
     20        (WebCore::EventHandler::EventHandler):
     21        Removed construction of gesture recognizer.
     22        (WebCore::EventHandler::handleGestureEvent):
     23        Extended for new gesture events added in this patch.
     24        (WebCore::EventHandler::handleTouchEvent):
     25        Removed call into gesture recognizer.
     26        * page/EventHandler.h:
     27        * page/FrameView.cpp:
     28        (WebCore::FrameView::reset):
     29        Removed code to reset gesture recognizer.
     30        * platform/PlatformGestureEvent.h:
     31        (WebCore::PlatformGestureEvent::PlatformGestureEvent):
     32        (WebCore::PlatformGestureEvent::deltaX):
     33        (WebCore::PlatformGestureEvent::deltaY):
     34        (WebCore::PlatformGestureEvent::shiftKey):
     35        (WebCore::PlatformGestureEvent::ctrlKey):
     36        (WebCore::PlatformGestureEvent::altKey):
     37        (WebCore::PlatformGestureEvent::metaKey):
     38        Added additional gesture types and parameters.
     39        * platform/PlatformGestureRecognizer.h:
     40        * platform/chromium/FramelessScrollView.h:
     41        Added support for displatching gesture and touch events.
     42        * platform/chromium/GestureRecognizerChromium.cpp:
     43        (WebCore::InnerGestureRecognizer::InnerGestureRecognizer):
     44        (WebCore::InnerGestureRecognizer::reset):
     45        (WebCore::InnerGestureRecognizer::constructClickGestureEvent):
     46        (WebCore::InnerGestureRecognizer::processTouchEventForGestures):
     47        Removed all depedencies on EventHandler. Instead, create gesture
     48        events from touch event stream.
     49        (WebCore::InnerGestureRecognizer::constructScrollGesture):
     50        (WebCore::touchDown):
     51        (WebCore::noGesture):
     52        (WebCore::click):
     53        (WebCore::isClickOrScroll):
     54        (WebCore::inScroll):
     55        (WebCore::GestureRecognizerChromium::processTouchEventForGestures):
     56        (WebCore::GestureRecognizerChromium::reset):
     57        * platform/chromium/GestureRecognizerChromium.h:
     58        * platform/chromium/PopupMenuChromium.cpp:
     59        Added support to handle touch events and gesture events.
     60        (WebCore::PopupContainer::handleTouchEvent):
     61        (WebCore::PopupContainer::handleGestureEvent):
     62        (WebCore::PopupListBox::handleTouchEvent):
     63        (WebCore::PopupListBox::handleGestureEvent):
     64        * platform/chromium/PopupMenuChromium.h:
     65        * platform/mac/ScrollAnimatorMac.mm:
     66        (WebCore::ScrollAnimatorMac::handleGestureEvent):
     67        Ignores the newly added gesture event types.
     68
    1692011-08-01  Michael Saboff  <msaboff@apple.com>
    270
  • trunk/Source/WebCore/dom/WheelEvent.cpp

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92032 r92234  
    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;
     
    106114    virtual bool handleWheelEvent(const PlatformWheelEvent&);
    107115    virtual bool handleKeyEvent(const PlatformKeyboardEvent&);
     116#if ENABLE(TOUCH_EVENTS)
     117    virtual bool handleTouchEvent(const PlatformTouchEvent&);
     118#endif
     119#if ENABLE(GESTURE_RECOGNIZER)
     120    virtual bool handleGestureEvent(const PlatformGestureEvent&);
     121#endif
    108122
    109123    // ScrollView
     
    512526}
    513527
     528#if ENABLE(TOUCH_EVENTS)
     529bool PopupContainer::handleTouchEvent(const PlatformTouchEvent&)
     530{
     531    return false;
     532}
     533#endif
     534
     535#if ENABLE(GESTURE_RECOGNIZER)
     536// FIXME: Refactor this code to share functionality with EventHandler::handleGestureEvent.
     537bool PopupContainer::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
     538{
     539    switch (gestureEvent.type()) {
     540    case PlatformGestureEvent::TapType: {
     541        PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(), NoButton, MouseEventMoved, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
     542        PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, MouseEventPressed, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
     543        PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, MouseEventReleased, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
     544        // handleMouseMoveEvent(fakeMouseMove);
     545        handleMouseDownEvent(fakeMouseDown);
     546        handleMouseReleaseEvent(fakeMouseUp);
     547        return true;
     548    }
     549    case PlatformGestureEvent::ScrollUpdateType: {
     550        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());
     551        handleWheelEvent(syntheticWheelEvent);
     552        return true;
     553    }
     554    case PlatformGestureEvent::ScrollBeginType:
     555    case PlatformGestureEvent::ScrollEndType:
     556        break;
     557    }
     558    return false;
     559}
     560#endif
     561
    514562bool PopupContainer::handleKeyEvent(const PlatformKeyboardEvent& event)
    515563{
     
    754802    }
    755803}
     804
     805#if ENABLE(TOUCH_EVENTS)
     806bool PopupListBox::handleTouchEvent(const PlatformTouchEvent&)
     807{
     808    return false;
     809}
     810#endif
     811
     812#if ENABLE(GESTURE_RECOGNIZER)
     813bool PopupListBox::handleGestureEvent(const PlatformGestureEvent&)
     814{
     815    return false;
     816}
     817#endif
    756818
    757819static bool isCharacterTypeEvent(const PlatformKeyboardEvent& event)
  • trunk/Source/WebCore/platform/chromium/PopupMenuChromium.h

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92225 r92234  
     12011-08-02  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-08-02  Zhenyao Mo  <zmo@google.com>
    232
  • trunk/Source/WebKit/chromium/features.gypi

    r92032 r92234  
    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

    r92083 r92234  
    19891989    if (isMainFrame)
    19901990        view->setParentVisible(true);
     1991
     1992#if ENABLE(GESTURE_RECOGNIZER)
     1993    webView->resetGestureRecognizer();
     1994#endif
    19911995}
    19921996
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp

    r92032 r92234  
    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

    r92032 r92234  
    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

    r92206 r92234  
    132132#include <wtf/RefPtr.h>
    133133
     134#if ENABLE(GESTURE_EVENTS)
     135#include "PlatformGestureEvent.h"
     136#endif
     137
     138#if ENABLE(GESTURE_RECOGNIZER)
     139#include "PlatformGestureRecognizer.h"
     140#endif
     141
    134142#if USE(CG)
    135143#include <CoreGraphics/CGBitmapContext.h>
     
    343351    , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0)))
    344352    , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0)))
     353#if ENABLE(GESTURE_RECOGNIZER)
     354    , m_gestureRecognizer(WebCore::PlatformGestureRecognizer::create())
     355#endif
    345356{
    346357    // WebKit/win/WebView.cpp does the same thing, except they call the
     
    760771
    761772    PlatformTouchEventBuilder touchEventBuilder(mainFrameImpl()->frameView(), event);
    762     return mainFrameImpl()->frame()->eventHandler()->handleTouchEvent(touchEventBuilder);
     773    bool defaultPrevented = mainFrameImpl()->frame()->eventHandler()->handleTouchEvent(touchEventBuilder);
     774
     775#if ENABLE(GESTURE_RECOGNIZER)
     776    OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureEvents(m_gestureRecognizer->processTouchEventForGestures(touchEventBuilder, defaultPrevented));
     777    for (unsigned int  i = 0; i < gestureEvents->size(); i++)
     778        mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(gestureEvents->at(i));
     779#endif
     780
     781    return defaultPrevented;
    763782}
    764783#endif
     
    26712690}
    26722691
     2692#if ENABLE(GESTURE_RECOGNIZER)
     2693void WebViewImpl::resetGestureRecognizer()
     2694{
     2695    m_gestureRecognizer->reset();
     2696}
     2697#endif
     2698
     2699
    26732700} // namespace WebKit
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r92032 r92234  
    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.