Changeset 92234 in webkit
- Timestamp:
- Aug 2, 2011 2:26:02 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r92231 r92234 1 2011-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 1 69 2011-08-01 Michael Saboff <msaboff@apple.com> 2 70 -
trunk/Source/WebCore/dom/WheelEvent.cpp
r92032 r92234 44 44 true, true, view, 0, screenLocation, pageLocation, 45 45 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))) 47 47 , m_rawDelta(roundedIntPoint(rawDelta)) 48 48 , m_granularity(granularity) … … 66 66 67 67 // Normalize to the Windows 120 multiple 68 m_wheelDelta = IntPoint(rawDeltaX * 120, rawDeltaY * 120);68 m_wheelDelta = IntPoint(rawDeltaX * tickMultiplier, rawDeltaY * tickMultiplier); 69 69 70 70 m_rawDelta = IntPoint(rawDeltaX, rawDeltaY); -
trunk/Source/WebCore/dom/WheelEvent.h
r92032 r92234 33 33 class WheelEvent : public MouseRelatedEvent { 34 34 public: 35 enum { tickMultiplier = 120 }; 36 35 37 enum Granularity { Pixel, Line, Page }; 36 38 -
trunk/Source/WebCore/page/EventHandler.cpp
r92032 r92234 101 101 #endif 102 102 103 #if ENABLE(GESTURE_RECOGNIZER)104 #include "PlatformGestureRecognizer.h"105 #endif106 107 103 namespace WebCore { 108 104 … … 210 206 #if ENABLE(TOUCH_EVENTS) 211 207 , m_touchPressed(false) 212 #endif213 #if ENABLE(GESTURE_RECOGNIZER)214 , m_gestureRecognizer(PlatformGestureRecognizer::create())215 208 #endif 216 209 { … … 2228 2221 // end gesture as well. 2229 2222 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 } 2235 2250 return true; 2236 2251 } … … 3287 3302 } 3288 3303 3289 #if ENABLE(GESTURE_RECOGNIZER)3290 if (m_gestureRecognizer)3291 m_gestureRecognizer->processTouchEventForGesture(event, this, defaultPrevented);3292 #endif3293 3294 3304 return defaultPrevented; 3295 3305 } 3296 3306 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 81 81 #endif 82 82 83 #if ENABLE(GESTURE_RECOGNIZER)84 class PlatformGestureRecognizer;85 #endif86 87 83 #if ENABLE(DRAG_SUPPORT) 88 84 extern const int LinkDragHysteresis; … … 165 161 #if ENABLE(GESTURE_EVENTS) 166 162 bool handleGestureEvent(const PlatformGestureEvent&); 167 #endif168 169 #if ENABLE(GESTURE_RECOGNIZER)170 void resetGestureRecognizer();171 163 #endif 172 164 … … 430 422 bool m_touchPressed; 431 423 #endif 432 #if ENABLE(GESTURE_RECOGNIZER)433 OwnPtr<PlatformGestureRecognizer> m_gestureRecognizer;434 #endif435 424 }; 436 425 -
trunk/Source/WebCore/page/FrameView.cpp
r92032 r92234 233 233 m_firstVisuallyNonEmptyLayoutCallbackPending = true; 234 234 m_maintainScrollPositionAnchor = 0; 235 236 #if ENABLE(GESTURE_RECOGNIZER)237 frame()->eventHandler()->resetGestureRecognizer();238 #endif239 235 } 240 236 -
trunk/Source/WebCore/platform/PlatformGestureEvent.h
r92032 r92234 38 38 ScrollBeginType, 39 39 ScrollEndType, 40 ScrollUpdateType, 41 TapType 40 42 }; 41 43 … … 43 45 : m_type(ScrollBeginType) 44 46 , 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) 45 61 { 46 62 } … … 53 69 double timestamp() const { return m_timestamp; } 54 70 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 55 78 protected: 56 79 Type m_type; … … 58 81 IntPoint m_globalPosition; 59 82 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; 60 89 }; 61 90 -
trunk/Source/WebCore/platform/PlatformGestureRecognizer.h
r92032 r92234 32 32 #define PlatformGestureRecognizer_h 33 33 34 #include "PlatformGestureEvent.h" 34 35 #include <wtf/PassOwnPtr.h> 36 #include <wtf/Vector.h> 35 37 36 38 namespace WebCore { 37 39 38 40 class EventHandler; 39 class PlatformGestureRecognizer;40 41 class PlatformTouchEvent; 41 42 42 // A GestureRecognizer detects gestures occurring in the touch event.43 // In response to a given touch event, the GestureRecognizer, updates44 // its internal state and optionally dispatches synthetic events to the45 // invoking EventHandler instance.46 43 class PlatformGestureRecognizer { 47 44 protected: … … 52 49 virtual ~PlatformGestureRecognizer(); 53 50 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; 60 55 61 56 // Clears the GestureRecognizer to its initial state. -
trunk/Source/WebCore/platform/chromium/FramelessScrollView.h
r92032 r92234 37 37 38 38 class FramelessScrollViewClient; 39 #if ENABLE(GESTURE_RECOGNIZER) 40 class PlatformGestureEvent; 41 #endif 39 42 class PlatformKeyboardEvent; 40 43 class PlatformMouseEvent; 44 #if ENABLE(TOUCH_EVENTS) 45 class PlatformTouchEvent; 46 #endif 41 47 class PlatformWheelEvent; 42 48 … … 61 67 virtual bool handleWheelEvent(const PlatformWheelEvent&) = 0; 62 68 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 63 75 64 76 // ScrollableArea public methods: -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp
r92032 r92234 32 32 #include "GestureRecognizerChromium.h" 33 33 34 #include "EventHandler.h"35 34 #include "PlatformMouseEvent.h" 36 35 #include "PlatformWheelEvent.h" … … 38 37 namespace WebCore { 39 38 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. 40 static bool click(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); 41 static bool isClickOrScroll(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); 42 static bool inScroll(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); 43 static bool noGesture(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); 44 static bool touchDown(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); 45 45 46 46 // FIXME: Make these configurable programmatically. … … 53 53 , m_state(InnerGestureRecognizer::NoGesture) 54 54 , m_lastTouchTime(0.0) 55 , m_eventHandler(0)56 55 , m_ctrlKey(false) 57 56 , m_altKey(false) … … 81 80 m_state = InnerGestureRecognizer::NoGesture; 82 81 m_lastTouchTime = 0.0; 83 m_eventHandler = 0;84 82 } 85 83 … … 105 103 } 106 104 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; 105 void 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 110 PlatformGestureRecognizer::PassGestures InnerGestureRecognizer::processTouchEventForGestures(const PlatformTouchEvent& event, bool defaultPrevented) 111 { 121 112 m_ctrlKey = event.ctrlKey(); 122 113 m_altKey = event.altKey(); … … 124 115 m_metaKey = event.metaKey(); 125 116 117 OwnPtr<Vector<PlatformGestureEvent> > gestures = adoptPtr(new Vector<PlatformGestureEvent>()); 126 118 const Vector<PlatformTouchPoint>& points = event.touchPoints(); 127 119 for (unsigned i = 0; i < points.size(); i++) { … … 129 121 updateValues(event.timestamp(), p); 130 122 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 129 void InnerGestureRecognizer::appendScrollGesture(const PlatformTouchPoint& touchPoint, Gestures gestures) 138 130 { 139 131 float deltaX(touchPoint.pos().x() - m_firstTouchPosition.x()); 140 132 float deltaY(touchPoint.pos().y() - m_firstTouchPosition.y()); 141 133 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)); 145 135 m_firstTouchPosition = touchPoint.pos(); 146 136 } … … 167 157 } 168 158 169 static bool touchDown(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& )159 static bool touchDown(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures gestures) 170 160 { 171 161 gestureRecognizer->setState(InnerGestureRecognizer::PendingSyntheticClick); … … 173 163 } 174 164 175 bool noGesture(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint&)165 static bool noGesture(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures gestures) 176 166 { 177 167 gestureRecognizer->reset(); … … 179 169 } 180 170 181 static bool click(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point )171 static bool click(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures) 182 172 { 183 173 if (gestureRecognizer->isInClickTimeWindow() && gestureRecognizer->isInsideManhattanSquare(point)) { 184 174 gestureRecognizer->setState(InnerGestureRecognizer::NoGesture); 185 gestureRecognizer-> dispatchSyntheticClick(point);175 gestureRecognizer->appendClickGestureEvent(point, gestures); 186 176 return true; 187 177 } 188 return noGesture(gestureRecognizer, point );189 } 190 191 static bool isClickOrScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point )178 return noGesture(gestureRecognizer, point, gestures); 179 } 180 181 static bool isClickOrScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures) 192 182 { 193 183 if (gestureRecognizer->isInClickTimeWindow() && gestureRecognizer->isInsideManhattanSquare(point)) { … … 197 187 198 188 if (point.state() == PlatformTouchPoint::TouchMoved && !gestureRecognizer->isInsideManhattanSquare(point)) { 199 gestureRecognizer-> scrollViaTouchMotion(point);189 gestureRecognizer->appendScrollGesture(point, gestures); 200 190 gestureRecognizer->setState(InnerGestureRecognizer::Scroll); 201 191 return true; … … 204 194 } 205 195 206 static bool inScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point )207 { 208 gestureRecognizer-> scrollViaTouchMotion(point);196 static bool inScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures) 197 { 198 gestureRecognizer->appendScrollGesture(point, gestures); 209 199 return true; 210 200 } … … 233 223 } 234 224 225 PlatformGestureRecognizer::PassGestures GestureRecognizerChromium::processTouchEventForGestures(const PlatformTouchEvent& touchEvent, bool defaultPrevented) 226 { 227 return m_innerGestureRecognizer.processTouchEventForGestures(touchEvent, defaultPrevented); 228 } 229 230 void GestureRecognizerChromium::reset() 231 { 232 m_innerGestureRecognizer.reset(); 233 } 234 235 235 } // namespace WebCore -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h
r92032 r92234 40 40 namespace WebCore { 41 41 42 class PlatformGestureEvent; 43 42 44 class InnerGestureRecognizer { 43 45 public: … … 48 50 }; 49 51 50 typedef bool (*GestureTransitionFunction)(InnerGestureRecognizer*, const PlatformTouchPoint&); 52 typedef Vector<PlatformGestureEvent>* Gestures; 53 typedef bool (*GestureTransitionFunction)(InnerGestureRecognizer*, const PlatformTouchPoint&, Gestures); 51 54 52 55 ~InnerGestureRecognizer(); 53 56 54 void dispatchSyntheticClick(const PlatformTouchPoint&);57 void appendClickGestureEvent(const PlatformTouchPoint&, Gestures); 55 58 virtual void reset(); 56 59 bool isInClickTimeWindow(); 57 60 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); 60 63 void setState(State value) { m_state = value; } 61 64 State state() { return m_state; } … … 73 76 State m_state; 74 77 double m_lastTouchTime; 75 EventHandler* m_eventHandler;76 78 77 79 bool m_ctrlKey; … … 87 89 virtual ~GestureRecognizerChromium(); 88 90 89 virtual void reset() 90 { 91 m_innerGestureRecognizer.reset(); 92 }; 91 virtual void reset(); 93 92 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); 98 94 private: 99 95 InnerGestureRecognizer m_innerGestureRecognizer; -
trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp
r92032 r92234 59 59 #include <wtf/unicode/CharacterNames.h> 60 60 61 #if ENABLE(GESTURE_EVENTS) 62 #include "PlatformGestureEvent.h" 63 #endif 64 65 #if ENABLE(TOUCH_EVENTS) 66 #include "PlatformTouchEvent.h" 67 #endif 68 61 69 using namespace std; 62 70 using namespace WTF; … … 106 114 virtual bool handleWheelEvent(const PlatformWheelEvent&); 107 115 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 108 122 109 123 // ScrollView … … 512 526 } 513 527 528 #if ENABLE(TOUCH_EVENTS) 529 bool 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. 537 bool 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 514 562 bool PopupContainer::handleKeyEvent(const PlatformKeyboardEvent& event) 515 563 { … … 754 802 } 755 803 } 804 805 #if ENABLE(TOUCH_EVENTS) 806 bool PopupListBox::handleTouchEvent(const PlatformTouchEvent&) 807 { 808 return false; 809 } 810 #endif 811 812 #if ENABLE(GESTURE_RECOGNIZER) 813 bool PopupListBox::handleGestureEvent(const PlatformGestureEvent&) 814 { 815 return false; 816 } 817 #endif 756 818 757 819 static bool isCharacterTypeEvent(const PlatformKeyboardEvent& event) -
trunk/Source/WebCore/platform/chromium/PopupMenuChromium.h
r92032 r92234 123 123 virtual bool handleWheelEvent(const PlatformWheelEvent&); 124 124 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 125 131 126 132 // PopupContainer methods -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm
r92032 r92234 860 860 if (gestureEvent.type() == PlatformGestureEvent::ScrollBeginType) 861 861 beginScrollGesture(); 862 else 862 else if (gestureEvent.type() == PlatformGestureEvent::ScrollEndType) 863 863 endScrollGesture(); 864 864 } -
trunk/Source/WebKit/chromium/ChangeLog
r92225 r92234 1 2011-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 1 31 2011-08-02 Zhenyao Mo <zmo@google.com> 2 32 -
trunk/Source/WebKit/chromium/features.gypi
r92032 r92234 51 51 'ENABLE_FILTERS=1', 52 52 'ENABLE_GEOLOCATION=1', 53 'ENABLE_GESTURE_EVENTS=1', 53 54 'ENABLE_GESTURE_RECOGNIZER=1', 54 55 'ENABLE_ICONDATABASE=0', -
trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp
r92083 r92234 1989 1989 if (isMainFrame) 1990 1990 view->setParentVisible(true); 1991 1992 #if ENABLE(GESTURE_RECOGNIZER) 1993 webView->resetGestureRecognizer(); 1994 #endif 1991 1995 } 1992 1996 -
trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
r92032 r92234 53 53 #include <skia/ext/platform_canvas.h> 54 54 55 #if ENABLE(GESTURE_RECOGNIZER) 56 #include "PlatformGestureEvent.h" 57 #include "PlatformGestureRecognizer.h" 58 #endif 59 55 60 using namespace WebCore; 56 61 … … 70 75 : m_client(client) 71 76 , m_widget(0) 77 #if ENABLE(GESTURE_RECOGNIZER) 78 , m_gestureRecognizer(WebCore::PlatformGestureRecognizer::create()) 79 #endif 72 80 { 73 81 // set to impossible point so we always get the first mouse pos … … 125 133 m_widget->handleWheelEvent(PlatformWheelEventBuilder(m_widget, event)); 126 134 } 135 136 #if ENABLE(TOUCH_EVENTS) 137 bool 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 127 150 128 151 bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event) … … 238 261 return KeyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent)); 239 262 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; 242 273 } 243 274 return false; -
trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h
r92032 r92234 36 36 #include "WebPopupMenu.h" 37 37 #include "WebSize.h" 38 #include <wtf/OwnPtr.h> 38 39 #include <wtf/RefCounted.h> 39 40 … … 43 44 class KeyboardEvent; 44 45 class Page; 46 #if ENABLE(GESTURE_RECOGNIZER) 47 class PlatformGestureRecognizer; 48 #endif 45 49 class PlatformKeyboardEvent; 46 50 class Range; … … 54 58 class WebRange; 55 59 struct WebRect; 60 class WebTouchEvent; 56 61 57 62 class WebPopupMenuImpl : public WebPopupMenu, … … 100 105 void MouseDoubleClick(const WebMouseEvent&); 101 106 void MouseWheel(const WebMouseWheelEvent&); 107 bool TouchEvent(const WebTouchEvent&); 102 108 bool KeyEvent(const WebKeyboardEvent&); 103 109 … … 137 143 // before it is destroyed. 138 144 WebCore::FramelessScrollView* m_widget; 145 146 #if ENABLE(GESTURE_RECOGNIZER) 147 OwnPtr<WebCore::PlatformGestureRecognizer> m_gestureRecognizer; 148 #endif 139 149 }; 140 150 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r92206 r92234 132 132 #include <wtf/RefPtr.h> 133 133 134 #if ENABLE(GESTURE_EVENTS) 135 #include "PlatformGestureEvent.h" 136 #endif 137 138 #if ENABLE(GESTURE_RECOGNIZER) 139 #include "PlatformGestureRecognizer.h" 140 #endif 141 134 142 #if USE(CG) 135 143 #include <CoreGraphics/CGBitmapContext.h> … … 343 351 , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0))) 344 352 , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0))) 353 #if ENABLE(GESTURE_RECOGNIZER) 354 , m_gestureRecognizer(WebCore::PlatformGestureRecognizer::create()) 355 #endif 345 356 { 346 357 // WebKit/win/WebView.cpp does the same thing, except they call the … … 760 771 761 772 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; 763 782 } 764 783 #endif … … 2671 2690 } 2672 2691 2692 #if ENABLE(GESTURE_RECOGNIZER) 2693 void WebViewImpl::resetGestureRecognizer() 2694 { 2695 m_gestureRecognizer->reset(); 2696 } 2697 #endif 2698 2699 2673 2700 } // namespace WebKit -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r92032 r92234 68 68 class RenderTheme; 69 69 class Widget; 70 #if ENABLE(GESTURE_RECOGNIZER) 71 class PlatformGestureRecognizer; 72 #endif 70 73 } 71 74 … … 386 389 void fullFramePluginZoomLevelChanged(double zoomLevel); 387 390 391 #if ENABLE(GESTURE_RECOGNIZER) 392 void resetGestureRecognizer(); 393 #endif 394 388 395 private: 389 396 friend class WebView; // So WebView::Create can call our constructor … … 566 573 OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy; 567 574 OwnPtr<GeolocationClientProxy> m_geolocationClientProxy; 575 576 #if ENABLE(GESTURE_RECOGNIZER) 577 OwnPtr<WebCore::PlatformGestureRecognizer> m_gestureRecognizer; 578 #endif 568 579 }; 569 580
Note: See TracChangeset
for help on using the changeset viewer.