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 11 matching lines...) Expand all Loading... | |
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/PointerEventManager.h" | 31 #include "core/input/PointerEventManager.h" |
32 #include "core/input/ScrollManager.h" | |
32 #include "core/layout/HitTestRequest.h" | 33 #include "core/layout/HitTestRequest.h" |
33 #include "core/page/DragActions.h" | 34 #include "core/page/DragActions.h" |
34 #include "core/page/EventWithHitTestResults.h" | 35 #include "core/page/EventWithHitTestResults.h" |
35 #include "core/style/ComputedStyleConstants.h" | 36 #include "core/style/ComputedStyleConstants.h" |
36 #include "platform/Cursor.h" | 37 #include "platform/Cursor.h" |
37 #include "platform/PlatformMouseEvent.h" | 38 #include "platform/PlatformMouseEvent.h" |
38 #include "platform/PlatformTouchPoint.h" | 39 #include "platform/PlatformTouchPoint.h" |
39 #include "platform/Timer.h" | 40 #include "platform/Timer.h" |
40 #include "platform/UserGestureIndicator.h" | 41 #include "platform/UserGestureIndicator.h" |
41 #include "platform/geometry/LayoutPoint.h" | 42 #include "platform/geometry/LayoutPoint.h" |
42 #include "platform/heap/Handle.h" | 43 #include "platform/heap/Handle.h" |
43 #include "platform/scroll/ScrollTypes.h" | 44 #include "platform/scroll/ScrollTypes.h" |
44 #include "public/platform/WebFocusType.h" | 45 #include "public/platform/WebFocusType.h" |
45 #include "public/platform/WebInputEventResult.h" | 46 #include "public/platform/WebInputEventResult.h" |
46 #include "wtf/Forward.h" | 47 #include "wtf/Forward.h" |
47 #include "wtf/HashMap.h" | 48 #include "wtf/HashMap.h" |
48 #include "wtf/HashTraits.h" | 49 #include "wtf/HashTraits.h" |
49 #include "wtf/RefPtr.h" | 50 #include "wtf/RefPtr.h" |
50 #include <deque> | |
51 | 51 |
52 namespace blink { | 52 namespace blink { |
53 | 53 |
54 class AutoscrollController; | |
55 class DataTransfer; | 54 class DataTransfer; |
56 class PaintLayer; | 55 class PaintLayer; |
57 class PaintLayerScrollableArea; | |
58 class Document; | 56 class Document; |
59 class DragState; | 57 class DragState; |
60 class Element; | 58 class Element; |
61 class Event; | 59 class Event; |
62 class EventTarget; | 60 class EventTarget; |
63 template <typename EventType> | 61 template <typename EventType> |
64 class EventWithHitTestResults; | 62 class EventWithHitTestResults; |
65 class FloatPoint; | 63 class FloatPoint; |
66 class FloatQuad; | 64 class FloatQuad; |
67 class FrameHost; | 65 class FrameHost; |
68 class HTMLFrameSetElement; | 66 class HTMLFrameSetElement; |
69 class HitTestRequest; | 67 class HitTestRequest; |
70 class HitTestResult; | 68 class HitTestResult; |
71 class KeyboardEvent; | 69 class KeyboardEvent; |
72 class LayoutObject; | 70 class LayoutObject; |
73 class LocalFrame; | 71 class LocalFrame; |
74 class Node; | 72 class Node; |
75 class OptionalCursor; | 73 class OptionalCursor; |
76 class PlatformGestureEvent; | 74 class PlatformGestureEvent; |
77 class PlatformKeyboardEvent; | 75 class PlatformKeyboardEvent; |
78 class PlatformTouchEvent; | 76 class PlatformTouchEvent; |
79 class PlatformWheelEvent; | 77 class PlatformWheelEvent; |
80 class ScrollableArea; | 78 class ScrollableArea; |
81 class Scrollbar; | 79 class Scrollbar; |
82 class ScrollState; | |
83 class SelectionController; | 80 class SelectionController; |
84 class TextEvent; | 81 class TextEvent; |
85 class WheelEvent; | 82 class WheelEvent; |
86 class Widget; | 83 class Widget; |
87 | 84 |
88 enum class DragInitiator; | 85 enum class DragInitiator; |
89 | 86 |
90 class CORE_EXPORT EventHandler final : public GarbageCollectedFinalized<EventHan dler> | 87 class CORE_EXPORT EventHandler final : public GarbageCollectedFinalized<EventHan dler> |
91 , public UserGestureUtilizedCallback { | 88 , public UserGestureUtilizedCallback { |
92 | 89 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 WebInputEventResult handleMouseDraggedEvent(const MouseEventWithHitTestResul ts&); | 232 WebInputEventResult handleMouseDraggedEvent(const MouseEventWithHitTestResul ts&); |
236 WebInputEventResult handleMouseReleaseEvent(const MouseEventWithHitTestResul ts&); | 233 WebInputEventResult handleMouseReleaseEvent(const MouseEventWithHitTestResul ts&); |
237 | 234 |
238 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::E ventType); | 235 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::E ventType); |
239 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); | 236 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); |
240 WebInputEventResult handleGestureTap(const GestureEventWithHitTestResults&); | 237 WebInputEventResult handleGestureTap(const GestureEventWithHitTestResults&); |
241 WebInputEventResult handleGestureLongPress(const GestureEventWithHitTestResu lts&); | 238 WebInputEventResult handleGestureLongPress(const GestureEventWithHitTestResu lts&); |
242 WebInputEventResult handleGestureLongTap(const GestureEventWithHitTestResult s&); | 239 WebInputEventResult handleGestureLongTap(const GestureEventWithHitTestResult s&); |
243 WebInputEventResult handleGestureScrollUpdate(const PlatformGestureEvent&); | 240 WebInputEventResult handleGestureScrollUpdate(const PlatformGestureEvent&); |
244 WebInputEventResult handleGestureScrollBegin(const PlatformGestureEvent&); | 241 WebInputEventResult handleGestureScrollBegin(const PlatformGestureEvent&); |
245 void clearGestureScrollState(); | |
246 | 242 |
247 void updateGestureTargetNodeForMouseEvent(const GestureEventWithHitTestResul ts&); | 243 void updateGestureTargetNodeForMouseEvent(const GestureEventWithHitTestResul ts&); |
248 | 244 |
249 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; | 245 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; |
250 | 246 |
251 OptionalCursor selectCursor(const HitTestResult&); | 247 OptionalCursor selectCursor(const HitTestResult&); |
252 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); | 248 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); |
253 | 249 |
254 void hoverTimerFired(Timer<EventHandler>*); | 250 void hoverTimerFired(Timer<EventHandler>*); |
255 void cursorUpdateTimerFired(Timer<EventHandler>*); | 251 void cursorUpdateTimerFired(Timer<EventHandler>*); |
256 void activeIntervalTimerFired(Timer<EventHandler>*); | 252 void activeIntervalTimerFired(Timer<EventHandler>*); |
257 | 253 |
258 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); | 254 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); |
259 void cancelFakeMouseMoveEvent(); | 255 void cancelFakeMouseMoveEvent(); |
260 bool isCursorVisible() const; | 256 bool isCursorVisible() const; |
261 void updateCursor(); | 257 void updateCursor(); |
262 | 258 |
263 ScrollableArea* associatedScrollableArea(const PaintLayer*) const; | 259 ScrollableArea* associatedScrollableArea(const PaintLayer*) const; |
264 | 260 |
265 // Performs a chaining scroll, within a *single* frame, starting from a | |
266 // given node and optionally stopping on a given node. | |
267 // granularity - The units that the scroll delta parameter is in. | |
268 // delta - The delta to scroll by, in the units of the granularity param | |
269 // (e.g. pixels, lines, pages, etc.). These are in a physical | |
270 // direction. i.e. Positive is down and right. | |
271 // position - Where the scroll originated from (e.g. touch location). | |
272 // velocity - The velocity of the scroll in the case of fling gestures. | |
273 // startNode - The node to start the scroll chaining from. | |
274 // stopNode - On input, if non-null, the node at which we should stop | |
275 // chaining. On output, if provided and a node was scrolled, | |
276 // stopNode will point to that node. | |
277 // consumed - [OUT] Whether the scroll was consumed. This is different than | |
278 // ScrollResult.didScroll since we might not have scrolled but | |
279 // have reached the stopNode and thus don't want to continue | |
280 // chaining the scroll. | |
281 ScrollResult physicalScroll( | |
282 ScrollGranularity, | |
283 const FloatSize& delta, | |
284 const FloatPoint& position, | |
285 const FloatSize& velocity, | |
286 Node* startNode, | |
287 Node** stopNode, | |
288 bool* consumed); | |
289 | |
290 // Performs a chaining logical scroll, within a *single* frame, starting | |
291 // from either a provided starting node or a default based on the focused or | |
292 // most recently clicked node, falling back to the frame. | |
293 // Returns true if the scroll was consumed. | |
294 // direction - The logical direction to scroll in. This will be converted to | |
295 // a physical direction for each LayoutBox we try to scroll | |
296 // based on that box's writing mode. | |
297 // granularity - The units that the scroll delta parameter is in. | |
298 // startNode - Optional. If provided, start chaining from the given node. | |
299 // If not, use the current focus or last clicked node. | |
300 bool logicalScroll(ScrollDirection, ScrollGranularity, Node* startNode = nul lptr); | |
301 | |
302 ScrollResult scrollBox( | |
303 LayoutBox*, | |
304 ScrollGranularity, | |
305 const FloatSize& delta, | |
306 const FloatPoint& position, | |
307 const FloatSize& velocity, | |
308 bool* wasRootScroller); | |
309 | |
310 bool isRootScroller(const Node&) const; | |
311 void customizedScroll(const Node& startNode, ScrollState&); | |
312 | |
313 void invalidateClick(); | 261 void invalidateClick(); |
314 | 262 |
315 Node* updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); | 263 Node* updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); |
316 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent &, bool isFrameBoundaryTransition = false); | 264 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent &, bool isFrameBoundaryTransition = false); |
317 | 265 |
318 | 266 |
319 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&); | 267 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&); |
320 | 268 |
321 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node* target, int clickCount, const PlatformMouseEvent&); | 269 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node* target, int clickCount, const PlatformMouseEvent&); |
322 | 270 |
(...skipping 24 matching lines...) Expand all Loading... | |
347 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); | 295 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); |
348 | 296 |
349 void defaultSpaceEventHandler(KeyboardEvent*); | 297 void defaultSpaceEventHandler(KeyboardEvent*); |
350 void defaultBackspaceEventHandler(KeyboardEvent*); | 298 void defaultBackspaceEventHandler(KeyboardEvent*); |
351 void defaultTabEventHandler(KeyboardEvent*); | 299 void defaultTabEventHandler(KeyboardEvent*); |
352 void defaultEscapeEventHandler(KeyboardEvent*); | 300 void defaultEscapeEventHandler(KeyboardEvent*); |
353 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); | 301 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); |
354 | 302 |
355 void updateLastScrollbarUnderMouse(Scrollbar*, bool); | 303 void updateLastScrollbarUnderMouse(Scrollbar*, bool); |
356 | 304 |
357 void setFrameWasScrolledByUser(); | |
358 | |
359 bool capturesDragging() const { return m_capturesDragging; } | 305 bool capturesDragging() const { return m_capturesDragging; } |
360 | 306 |
361 WebInputEventResult handleGestureShowPress(); | 307 WebInputEventResult handleGestureShowPress(); |
362 | 308 |
363 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); | |
364 | |
365 WebInputEventResult passScrollGestureEventToWidget(const PlatformGestureEven t&, LayoutObject*); | |
366 | |
367 AutoscrollController* autoscrollController() const; | |
368 bool panScrollInProgress() const; | |
369 void setLastKnownMousePosition(const PlatformMouseEvent&); | 309 void setLastKnownMousePosition(const PlatformMouseEvent&); |
370 | 310 |
371 bool shouldTopControlsConsumeScroll(FloatSize) const; | 311 bool shouldTopControlsConsumeScroll(FloatSize) const; |
372 | 312 |
373 // If the given element is a shadow host and its root has delegatesFocus=fal se flag, | 313 // If the given element is a shadow host and its root has delegatesFocus=fal se flag, |
374 // slide focus to its inner element. Returns true if the resulting focus is different from | 314 // slide focus to its inner element. Returns true if the resulting focus is different from |
375 // the given element. | 315 // the given element. |
376 bool slideFocusOnShadowHostIfNecessary(const Element&); | 316 bool slideFocusOnShadowHostIfNecessary(const Element&); |
377 | 317 |
378 FrameHost* frameHost() const; | 318 FrameHost* frameHost() const; |
(...skipping 20 matching lines...) Expand all Loading... | |
399 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide state | 339 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide state |
400 // should move out of EventHandler to a new PageEventHandler class. crbug.co m/449649 | 340 // should move out of EventHandler to a new PageEventHandler class. crbug.co m/449649 |
401 Timer<EventHandler> m_cursorUpdateTimer; | 341 Timer<EventHandler> m_cursorUpdateTimer; |
402 | 342 |
403 bool m_mouseDownMayStartAutoscroll; | 343 bool m_mouseDownMayStartAutoscroll; |
404 | 344 |
405 Timer<EventHandler> m_fakeMouseMoveEventTimer; | 345 Timer<EventHandler> m_fakeMouseMoveEventTimer; |
406 | 346 |
407 bool m_svgPan; | 347 bool m_svgPan; |
408 | 348 |
409 Member<PaintLayerScrollableArea> m_resizeScrollableArea; | |
410 | |
411 Member<Node> m_capturingMouseEventsNode; | 349 Member<Node> m_capturingMouseEventsNode; |
dtapuska
2016/05/27 14:12:23
Can we remove HandleGestureScrollUpdate/End/Begin
Navid Zolghadr
2016/05/30 20:15:46
Done with Update and Begin. But End one is being u
| |
412 bool m_eventHandlerWillResetCapturingMouseEventsNode; | 350 bool m_eventHandlerWillResetCapturingMouseEventsNode; |
413 | 351 |
414 // Note the difference of this and m_nodeUnderPointer in PointerEventManager | 352 // Note the difference of this and m_nodeUnderPointer in PointerEventManager |
415 Member<Node> m_nodeUnderMouse; | 353 Member<Node> m_nodeUnderMouse; |
416 | 354 |
417 Member<LocalFrame> m_lastMouseMoveEventSubframe; | 355 Member<LocalFrame> m_lastMouseMoveEventSubframe; |
418 Member<Scrollbar> m_lastScrollbarUnderMouse; | 356 Member<Scrollbar> m_lastScrollbarUnderMouse; |
419 | 357 |
420 int m_clickCount; | 358 int m_clickCount; |
421 Member<Node> m_clickNode; | 359 Member<Node> m_clickNode; |
422 | 360 |
423 Member<Node> m_dragTarget; | 361 Member<Node> m_dragTarget; |
424 bool m_shouldOnlyFireDragOverEvent; | 362 bool m_shouldOnlyFireDragOverEvent; |
425 | 363 |
426 Member<HTMLFrameSetElement> m_frameSetBeingResized; | 364 Member<HTMLFrameSetElement> m_frameSetBeingResized; |
427 | 365 |
428 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA rea. | |
429 | |
430 bool m_mousePositionIsUnknown; | 366 bool m_mousePositionIsUnknown; |
431 // The last mouse movement position this frame has seen in root frame coordi nates. | 367 // The last mouse movement position this frame has seen in root frame coordi nates. |
432 IntPoint m_lastKnownMousePosition; | 368 IntPoint m_lastKnownMousePosition; |
433 IntPoint m_lastKnownMouseGlobalPosition; | 369 IntPoint m_lastKnownMouseGlobalPosition; |
434 IntPoint m_mouseDownPos; // In our view's coords. | 370 IntPoint m_mouseDownPos; // In our view's coords. |
435 double m_mouseDownTimestamp; | 371 double m_mouseDownTimestamp; |
436 PlatformMouseEvent m_mouseDown; | 372 PlatformMouseEvent m_mouseDown; |
437 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; | 373 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; |
438 | 374 |
439 PointerEventManager m_pointerEventManager; | 375 PointerEventManager m_pointerEventManager; |
440 | 376 ScrollManager m_scrollManager; |
441 Member<Node> m_scrollGestureHandlingNode; | |
442 bool m_lastGestureScrollOverWidget; | |
443 // The most recent element to scroll natively during this scroll | |
444 // sequence. Null if no native element has scrolled this scroll | |
445 // sequence, or if the most recent element to scroll used scroll | |
446 // customization. | |
447 Member<Node> m_previousGestureScrolledNode; | |
448 Member<Scrollbar> m_scrollbarHandlingScrollGesture; | |
449 | 377 |
450 double m_maxMouseMovedDuration; | 378 double m_maxMouseMovedDuration; |
451 | 379 |
452 bool m_longTapShouldInvokeContextMenu; | 380 bool m_longTapShouldInvokeContextMenu; |
453 | 381 |
454 Timer<EventHandler> m_activeIntervalTimer; | 382 Timer<EventHandler> m_activeIntervalTimer; |
455 double m_lastShowPressTimestamp; | 383 double m_lastShowPressTimestamp; |
456 Member<Element> m_lastDeferredTapElement; | 384 Member<Element> m_lastDeferredTapElement; |
457 | |
458 // Only used with the ScrollCustomization runtime enabled feature. | |
459 std::deque<int> m_currentScrollChain; | |
460 // True iff some of the delta has been consumed for the current | |
461 // scroll sequence in this frame, or any child frames. Only used | |
462 // with ScrollCustomization. If some delta has been consumed, a | |
463 // scroll which shouldn't propagate can't cause any element to | |
464 // scroll other than the |m_previousGestureScrolledNode|. | |
465 bool m_deltaConsumedForScrollSequence; | |
466 }; | 385 }; |
467 | 386 |
468 } // namespace blink | 387 } // namespace blink |
469 | 388 |
470 #endif // EventHandler_h | 389 #endif // EventHandler_h |
OLD | NEW |