Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef EventHandler_h | 26 #ifndef EventHandler_h |
| 27 #define EventHandler_h | 27 #define EventHandler_h |
| 28 | 28 |
| 29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
| 30 #include "core/events/TextEventInputType.h" | 30 #include "core/events/TextEventInputType.h" |
| 31 #include "core/input/GestureManager.h" | |
| 31 #include "core/input/KeyboardEventManager.h" | 32 #include "core/input/KeyboardEventManager.h" |
| 32 #include "core/input/PointerEventManager.h" | 33 #include "core/input/PointerEventManager.h" |
| 33 #include "core/input/ScrollManager.h" | 34 #include "core/input/ScrollManager.h" |
| 34 #include "core/layout/HitTestRequest.h" | 35 #include "core/layout/HitTestRequest.h" |
| 35 #include "core/page/DragActions.h" | 36 #include "core/page/DragActions.h" |
| 36 #include "core/page/EventWithHitTestResults.h" | 37 #include "core/page/EventWithHitTestResults.h" |
| 37 #include "core/style/ComputedStyleConstants.h" | 38 #include "core/style/ComputedStyleConstants.h" |
| 38 #include "platform/Cursor.h" | 39 #include "platform/Cursor.h" |
| 39 #include "platform/PlatformMouseEvent.h" | 40 #include "platform/PlatformMouseEvent.h" |
| 40 #include "platform/PlatformTouchPoint.h" | 41 #include "platform/PlatformTouchPoint.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 // most recently clicked node, falling back to the frame. | 227 // most recently clicked node, falling back to the frame. |
| 227 // Returns true if the scroll was consumed. | 228 // Returns true if the scroll was consumed. |
| 228 // direction - The logical direction to scroll in. This will be converted to | 229 // direction - The logical direction to scroll in. This will be converted to |
| 229 // a physical direction for each LayoutBox we try to scroll | 230 // a physical direction for each LayoutBox we try to scroll |
| 230 // based on that box's writing mode. | 231 // based on that box's writing mode. |
| 231 // granularity - The units that the scroll delta parameter is in. | 232 // granularity - The units that the scroll delta parameter is in. |
| 232 // startNode - Optional. If provided, start chaining from the given node. | 233 // startNode - Optional. If provided, start chaining from the given node. |
| 233 // If not, use the current focus or last clicked node. | 234 // If not, use the current focus or last clicked node. |
| 234 bool logicalScroll(ScrollDirection, ScrollGranularity, Node* startNode = nul lptr); | 235 bool logicalScroll(ScrollDirection, ScrollGranularity, Node* startNode = nul lptr); |
| 235 | 236 |
| 237 // Only called by GestureManager until further refactoring. | |
|
mustaq
2016/07/11 18:01:35
I think you meant to comment on the whole block of
Navid Zolghadr
2016/07/11 18:24:32
I thought having all the following lines together
| |
| 238 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node* target, int clickCount, const PlatformMouseEvent&); | |
| 239 WebInputEventResult handleMousePressEvent(const MouseEventWithHitTestResults &); | |
|
dtapuska
2016/07/11 17:53:15
This is kind of a weird design where the event han
Navid Zolghadr
2016/07/11 18:24:32
They should be inside MouseEventManager. That chan
| |
| 240 WebInputEventResult handleMouseReleaseEvent(const MouseEventWithHitTestResul ts&); | |
| 241 WebInputEventResult handleMouseFocus(const MouseEventWithHitTestResults&, In putDeviceCapabilities* sourceCapabilities); | |
| 242 void setClickNode(Node*); | |
| 243 static ContainerNode* parentForClickEvent(const Node&); | |
| 244 bool handleDragDropIfPossible(const GestureEventWithHitTestResults&); | |
| 245 // Resets the state that indicates the next events could cause a drag. It is called when | |
| 246 // we realize the next events should not cause drag based on the drag heuris tics. | |
| 247 void clearDragHeuristicState(); | |
| 248 | |
| 249 | |
| 236 private: | 250 private: |
| 237 static DragState& dragState(); | 251 static DragState& dragState(); |
| 238 | 252 |
| 239 DataTransfer* createDraggingDataTransfer() const; | 253 DataTransfer* createDraggingDataTransfer() const; |
| 240 | 254 |
| 241 WebInputEventResult handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, H itTestResult* hoveredNode = nullptr, bool onlyUpdateScrollbars = false, bool for ceLeave = false); | 255 WebInputEventResult handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, H itTestResult* hoveredNode = nullptr, bool onlyUpdateScrollbars = false, bool for ceLeave = false); |
| 242 WebInputEventResult handleMousePressEvent(const MouseEventWithHitTestResults &); | |
| 243 WebInputEventResult handleMouseFocus(const MouseEventWithHitTestResults&, In putDeviceCapabilities* sourceCapabilities); | |
| 244 WebInputEventResult handleMouseDraggedEvent(const MouseEventWithHitTestResul ts&); | 256 WebInputEventResult handleMouseDraggedEvent(const MouseEventWithHitTestResul ts&); |
| 245 WebInputEventResult handleMouseReleaseEvent(const MouseEventWithHitTestResul ts&); | |
| 246 | 257 |
| 247 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::E ventType); | |
| 248 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); | 258 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); |
| 249 WebInputEventResult handleGestureTapDown(const GestureEventWithHitTestResult s&); | |
| 250 WebInputEventResult handleGestureTap(const GestureEventWithHitTestResults&); | |
| 251 WebInputEventResult handleGestureLongPress(const GestureEventWithHitTestResu lts&); | |
| 252 WebInputEventResult handleGestureLongTap(const GestureEventWithHitTestResult s&); | |
| 253 | 259 |
| 254 void updateGestureTargetNodeForMouseEvent(const GestureEventWithHitTestResul ts&); | 260 void updateGestureTargetNodeForMouseEvent(const GestureEventWithHitTestResul ts&); |
| 255 | 261 |
| 256 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; | 262 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; |
| 257 | 263 |
| 258 OptionalCursor selectCursor(const HitTestResult&); | 264 OptionalCursor selectCursor(const HitTestResult&); |
| 259 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); | 265 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); |
| 260 | 266 |
| 261 void hoverTimerFired(Timer<EventHandler>*); | 267 void hoverTimerFired(Timer<EventHandler>*); |
| 262 void cursorUpdateTimerFired(Timer<EventHandler>*); | 268 void cursorUpdateTimerFired(Timer<EventHandler>*); |
| 263 void activeIntervalTimerFired(Timer<EventHandler>*); | 269 void activeIntervalTimerFired(Timer<EventHandler>*); |
| 264 | 270 |
| 265 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); | 271 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); |
| 266 void cancelFakeMouseMoveEvent(); | 272 void cancelFakeMouseMoveEvent(); |
| 267 bool isCursorVisible() const; | 273 bool isCursorVisible() const; |
| 268 void updateCursor(); | 274 void updateCursor(); |
| 269 | 275 |
| 270 ScrollableArea* associatedScrollableArea(const PaintLayer*) const; | 276 ScrollableArea* associatedScrollableArea(const PaintLayer*) const; |
| 271 | 277 |
| 272 void invalidateClick(); | 278 void invalidateClick(); |
| 273 | 279 |
| 274 Node* updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); | 280 Node* updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); |
| 275 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent &, bool isFrameBoundaryTransition = false); | 281 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent &, bool isFrameBoundaryTransition = false); |
| 276 | 282 |
| 277 | 283 |
| 278 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&); | 284 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&); |
| 279 | 285 |
| 280 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node* target, int clickCount, const PlatformMouseEvent&); | |
| 281 | |
| 282 // Dispatches ME after corresponding PE provided the PE has not been cancele d. The eventType arg | 286 // Dispatches ME after corresponding PE provided the PE has not been cancele d. The eventType arg |
| 283 // must be a mouse event that can be gated though a preventDefaulted pointer down (i.e., one of | 287 // must be a mouse event that can be gated though a preventDefaulted pointer down (i.e., one of |
| 284 // {mousedown, mousemove, mouseup}). | 288 // {mousedown, mousemove, mouseup}). |
| 285 // TODO(mustaq): Can we avoid the clickCount param, instead use PlatformMous eEvent's count? | 289 // TODO(mustaq): Can we avoid the clickCount param, instead use PlatformMous eEvent's count? |
| 286 // Same applied to dispatchMouseEvent() above. | 290 // Same applied to dispatchMouseEvent() above. |
| 287 WebInputEventResult updatePointerTargetAndDispatchEvents(const AtomicString& mouseEventType, Node* target, | 291 WebInputEventResult updatePointerTargetAndDispatchEvents(const AtomicString& mouseEventType, Node* target, |
| 288 int clickCount, const PlatformMouseEvent&); | 292 int clickCount, const PlatformMouseEvent&); |
| 289 | 293 |
| 290 WebInputEventResult dispatchDragEvent(const AtomicString& eventType, Node* t arget, const PlatformMouseEvent&, DataTransfer*); | 294 WebInputEventResult dispatchDragEvent(const AtomicString& eventType, Node* t arget, const PlatformMouseEvent&, DataTransfer*); |
| 291 | 295 |
| 292 void clearDragDataTransfer(); | 296 void clearDragDataTransfer(); |
| 293 | 297 |
| 294 bool handleDrag(const MouseEventWithHitTestResults&, DragInitiator); | 298 bool handleDrag(const MouseEventWithHitTestResults&, DragInitiator); |
| 295 bool tryStartDrag(const MouseEventWithHitTestResults&); | 299 bool tryStartDrag(const MouseEventWithHitTestResults&); |
| 296 | 300 |
| 297 // Clears drag target and related states. It is called when drag is done or canceled. | 301 // Clears drag target and related states. It is called when drag is done or canceled. |
| 298 void clearDragState(); | 302 void clearDragState(); |
| 299 | 303 |
| 300 // Resets the state that indicates the next events could cause a drag. It is called when | |
| 301 // we realize the next events should not cause drag based on the drag heuris tics. | |
| 302 void clearDragHeuristicState(); | |
| 303 | |
| 304 WebInputEventResult dispatchDragSrcEvent(const AtomicString& eventType, cons t PlatformMouseEvent&); | 304 WebInputEventResult dispatchDragSrcEvent(const AtomicString& eventType, cons t PlatformMouseEvent&); |
| 305 | 305 |
| 306 bool dragHysteresisExceeded(const IntPoint&) const; | 306 bool dragHysteresisExceeded(const IntPoint&) const; |
| 307 | 307 |
| 308 WebInputEventResult passMousePressEventToSubframe(MouseEventWithHitTestResul ts&, LocalFrame* subframe); | 308 WebInputEventResult passMousePressEventToSubframe(MouseEventWithHitTestResul ts&, LocalFrame* subframe); |
| 309 WebInputEventResult passMouseMoveEventToSubframe(MouseEventWithHitTestResult s&, LocalFrame* subframe, HitTestResult* hoveredNode = nullptr); | 309 WebInputEventResult passMouseMoveEventToSubframe(MouseEventWithHitTestResult s&, LocalFrame* subframe, HitTestResult* hoveredNode = nullptr); |
| 310 WebInputEventResult passMouseReleaseEventToSubframe(MouseEventWithHitTestRes ults&, LocalFrame* subframe); | 310 WebInputEventResult passMouseReleaseEventToSubframe(MouseEventWithHitTestRes ults&, LocalFrame* subframe); |
| 311 | 311 |
| 312 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); | 312 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); |
| 313 | 313 |
| 314 void defaultSpaceEventHandler(KeyboardEvent*); | 314 void defaultSpaceEventHandler(KeyboardEvent*); |
| 315 void defaultBackspaceEventHandler(KeyboardEvent*); | 315 void defaultBackspaceEventHandler(KeyboardEvent*); |
| 316 void defaultTabEventHandler(KeyboardEvent*); | 316 void defaultTabEventHandler(KeyboardEvent*); |
| 317 void defaultEscapeEventHandler(KeyboardEvent*); | 317 void defaultEscapeEventHandler(KeyboardEvent*); |
| 318 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); | 318 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); |
| 319 | 319 |
| 320 void updateLastScrollbarUnderMouse(Scrollbar*, bool); | 320 void updateLastScrollbarUnderMouse(Scrollbar*, bool); |
| 321 | 321 |
| 322 bool capturesDragging() const { return m_capturesDragging; } | 322 bool capturesDragging() const { return m_capturesDragging; } |
| 323 | 323 |
| 324 WebInputEventResult handleGestureShowPress(); | |
| 325 | |
| 326 void setLastKnownMousePosition(const PlatformMouseEvent&); | 324 void setLastKnownMousePosition(const PlatformMouseEvent&); |
| 327 | 325 |
| 328 bool shouldTopControlsConsumeScroll(FloatSize) const; | 326 bool shouldTopControlsConsumeScroll(FloatSize) const; |
| 329 | 327 |
| 330 // If the given element is a shadow host and its root has delegatesFocus=fal se flag, | 328 // If the given element is a shadow host and its root has delegatesFocus=fal se flag, |
| 331 // slide focus to its inner element. Returns true if the resulting focus is different from | 329 // slide focus to its inner element. Returns true if the resulting focus is different from |
| 332 // the given element. | 330 // the given element. |
| 333 bool slideFocusOnShadowHostIfNecessary(const Element&); | 331 bool slideFocusOnShadowHostIfNecessary(const Element&); |
| 334 | 332 |
| 335 FrameHost* frameHost() const; | 333 FrameHost* frameHost() const; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 IntPoint m_lastKnownMousePosition; | 383 IntPoint m_lastKnownMousePosition; |
| 386 IntPoint m_lastKnownMouseGlobalPosition; | 384 IntPoint m_lastKnownMouseGlobalPosition; |
| 387 IntPoint m_mouseDownPos; // In our view's coords. | 385 IntPoint m_mouseDownPos; // In our view's coords. |
| 388 double m_mouseDownTimestamp; | 386 double m_mouseDownTimestamp; |
| 389 PlatformMouseEvent m_mouseDown; | 387 PlatformMouseEvent m_mouseDown; |
| 390 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; | 388 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; |
| 391 | 389 |
| 392 PointerEventManager m_pointerEventManager; | 390 PointerEventManager m_pointerEventManager; |
| 393 ScrollManager m_scrollManager; | 391 ScrollManager m_scrollManager; |
| 394 KeyboardEventManager m_keyboardEventManager; | 392 KeyboardEventManager m_keyboardEventManager; |
| 393 GestureManager m_gestureManager; | |
| 395 | 394 |
| 396 double m_maxMouseMovedDuration; | 395 double m_maxMouseMovedDuration; |
| 397 | 396 |
| 398 bool m_longTapShouldInvokeContextMenu; | |
| 399 | |
| 400 Timer<EventHandler> m_activeIntervalTimer; | 397 Timer<EventHandler> m_activeIntervalTimer; |
| 401 double m_lastShowPressTimestamp; | |
| 402 Member<Element> m_lastDeferredTapElement; | 398 Member<Element> m_lastDeferredTapElement; |
| 403 | 399 |
| 404 // Set on GestureTapDown if the |pointerdown| event corresponding to the | |
| 405 // triggering |touchstart| event was canceled. This suppresses mouse event | |
| 406 // firing for the current gesture sequence (i.e. until next GestureTapDown). | |
| 407 bool m_suppressMouseEventsFromGestures; | |
| 408 }; | 400 }; |
| 409 | 401 |
| 410 } // namespace blink | 402 } // namespace blink |
| 411 | 403 |
| 412 #endif // EventHandler_h | 404 #endif // EventHandler_h |
| OLD | NEW |