Changeset 91809 in webkit
- Timestamp:
- Jul 26, 2011 6:52:19 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r91808 r91809 1 2011-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 1 64 2011-07-26 Joseph Pecoraro <joepeck@webkit.org> 2 65 -
trunk/Source/WebCore/dom/WheelEvent.cpp
r87865 r91809 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
r87865 r91809 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
r91003 r91809 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
r88307 r91809 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
r91808 r91809 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
r76745 r91809 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
r88307 r91809 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
r90152 r91809 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
r88307 r91809 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
r88307 r91809 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
r90769 r91809 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; … … 104 112 virtual bool handleWheelEvent(const PlatformWheelEvent&); 105 113 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 106 120 107 121 // ScrollView … … 510 524 } 511 525 526 #if ENABLE(TOUCH_EVENTS) 527 bool 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. 535 bool 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 512 560 bool PopupContainer::handleKeyEvent(const PlatformKeyboardEvent& event) 513 561 { … … 752 800 } 753 801 } 802 803 #if ENABLE(TOUCH_EVENTS) 804 bool PopupListBox::handleTouchEvent(const PlatformTouchEvent&) 805 { 806 return false; 807 } 808 #endif 809 810 #if ENABLE(GESTURE_RECOGNIZER) 811 bool PopupListBox::handleGestureEvent(const PlatformGestureEvent&) 812 { 813 return false; 814 } 815 #endif 754 816 755 817 static bool isCharacterTypeEvent(const PlatformKeyboardEvent& event) -
trunk/Source/WebCore/platform/chromium/PopupMenuChromium.h
r89916 r91809 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
r88982 r91809 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
r91797 r91809 1 2011-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 1 31 2011-07-26 Sadrul Habib Chowdhury <sadrul@chromium.org> 2 32 -
trunk/Source/WebKit/chromium/features.gypi
r91797 r91809 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
r90641 r91809 1995 1995 if (isMainFrame) 1996 1996 view->setParentVisible(true); 1997 1998 #if ENABLE(GESTURE_RECOGNIZER) 1999 webView->resetGestureRecognizer(); 2000 #endif 1997 2001 } 1998 2002 -
trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
r91107 r91809 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
r91107 r91809 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
r91621 r91809 130 130 #include <wtf/RefPtr.h> 131 131 132 #if ENABLE(GESTURE_EVENTS) 133 #include "PlatformGestureEvent.h" 134 #endif 135 136 #if ENABLE(GESTURE_RECOGNIZER) 137 #include "PlatformGestureRecognizer.h" 138 #endif 139 132 140 #if USE(CG) 133 141 #include <CoreGraphics/CGBitmapContext.h> … … 341 349 , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0))) 342 350 , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0))) 351 #if ENABLE(GESTURE_RECOGNIZER) 352 , m_gestureRecognizer(WebCore::PlatformGestureRecognizer::create()) 353 #endif 343 354 { 344 355 // WebKit/win/WebView.cpp does the same thing, except they call the … … 758 769 759 770 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; 761 780 } 762 781 #endif … … 2659 2678 } 2660 2679 2680 #if ENABLE(GESTURE_RECOGNIZER) 2681 void WebViewImpl::resetGestureRecognizer() 2682 { 2683 m_gestureRecognizer->reset(); 2684 } 2685 #endif 2686 2687 2661 2688 } // namespace WebKit -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r91621 r91809 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.