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 | 88 |
92 WTF_MAKE_NONCOPYABLE(EventHandler); | 89 WTF_MAKE_NONCOPYABLE(EventHandler); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 WebInputEventResult handleMousePressEvent(const MouseEventWithHitTestResults
&); | 225 WebInputEventResult handleMousePressEvent(const MouseEventWithHitTestResults
&); |
229 WebInputEventResult handleMouseFocus(const MouseEventWithHitTestResults&, In
putDeviceCapabilities* sourceCapabilities); | 226 WebInputEventResult handleMouseFocus(const MouseEventWithHitTestResults&, In
putDeviceCapabilities* sourceCapabilities); |
230 WebInputEventResult handleMouseDraggedEvent(const MouseEventWithHitTestResul
ts&); | 227 WebInputEventResult handleMouseDraggedEvent(const MouseEventWithHitTestResul
ts&); |
231 WebInputEventResult handleMouseReleaseEvent(const MouseEventWithHitTestResul
ts&); | 228 WebInputEventResult handleMouseReleaseEvent(const MouseEventWithHitTestResul
ts&); |
232 | 229 |
233 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::E
ventType); | 230 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::E
ventType); |
234 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); | 231 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); |
235 WebInputEventResult handleGestureTap(const GestureEventWithHitTestResults&); | 232 WebInputEventResult handleGestureTap(const GestureEventWithHitTestResults&); |
236 WebInputEventResult handleGestureLongPress(const GestureEventWithHitTestResu
lts&); | 233 WebInputEventResult handleGestureLongPress(const GestureEventWithHitTestResu
lts&); |
237 WebInputEventResult handleGestureLongTap(const GestureEventWithHitTestResult
s&); | 234 WebInputEventResult handleGestureLongTap(const GestureEventWithHitTestResult
s&); |
238 WebInputEventResult handleGestureScrollUpdate(const PlatformGestureEvent&); | |
239 WebInputEventResult handleGestureScrollBegin(const PlatformGestureEvent&); | |
240 void clearGestureScrollState(); | |
241 | 235 |
242 void updateGestureTargetNodeForMouseEvent(const GestureEventWithHitTestResul
ts&); | 236 void updateGestureTargetNodeForMouseEvent(const GestureEventWithHitTestResul
ts&); |
243 | 237 |
244 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; | 238 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; |
245 | 239 |
246 OptionalCursor selectCursor(const HitTestResult&); | 240 OptionalCursor selectCursor(const HitTestResult&); |
247 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i
Beam); | 241 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i
Beam); |
248 | 242 |
249 void hoverTimerFired(Timer<EventHandler>*); | 243 void hoverTimerFired(Timer<EventHandler>*); |
250 void cursorUpdateTimerFired(Timer<EventHandler>*); | 244 void cursorUpdateTimerFired(Timer<EventHandler>*); |
251 void activeIntervalTimerFired(Timer<EventHandler>*); | 245 void activeIntervalTimerFired(Timer<EventHandler>*); |
252 | 246 |
253 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); | 247 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); |
254 void cancelFakeMouseMoveEvent(); | 248 void cancelFakeMouseMoveEvent(); |
255 bool isCursorVisible() const; | 249 bool isCursorVisible() const; |
256 void updateCursor(); | 250 void updateCursor(); |
257 | 251 |
258 ScrollableArea* associatedScrollableArea(const PaintLayer*) const; | 252 ScrollableArea* associatedScrollableArea(const PaintLayer*) const; |
259 | 253 |
260 // Performs a chaining scroll, within a *single* frame, starting from a | |
261 // given node and optionally stopping on a given node. | |
262 // granularity - The units that the scroll delta parameter is in. | |
263 // delta - The delta to scroll by, in the units of the granularity param | |
264 // (e.g. pixels, lines, pages, etc.). These are in a physical | |
265 // direction. i.e. Positive is down and right. | |
266 // position - Where the scroll originated from (e.g. touch location). | |
267 // velocity - The velocity of the scroll in the case of fling gestures. | |
268 // startNode - The node to start the scroll chaining from. | |
269 // stopNode - On input, if non-null, the node at which we should stop | |
270 // chaining. On output, if provided and a node was scrolled, | |
271 // stopNode will point to that node. | |
272 // consumed - [OUT] Whether the scroll was consumed. This is different than | |
273 // ScrollResult.didScroll since we might not have scrolled but | |
274 // have reached the stopNode and thus don't want to continue | |
275 // chaining the scroll. | |
276 ScrollResult physicalScroll( | |
277 ScrollGranularity, | |
278 const FloatSize& delta, | |
279 const FloatPoint& position, | |
280 const FloatSize& velocity, | |
281 Node* startNode, | |
282 Node** stopNode, | |
283 bool* consumed); | |
284 | |
285 // Performs a chaining logical scroll, within a *single* frame, starting | |
286 // from either a provided starting node or a default based on the focused or | |
287 // most recently clicked node, falling back to the frame. | |
288 // Returns true if the scroll was consumed. | |
289 // direction - The logical direction to scroll in. This will be converted to | |
290 // a physical direction for each LayoutBox we try to scroll | |
291 // based on that box's writing mode. | |
292 // granularity - The units that the scroll delta parameter is in. | |
293 // startNode - Optional. If provided, start chaining from the given node. | |
294 // If not, use the current focus or last clicked node. | |
295 bool logicalScroll(ScrollDirection, ScrollGranularity, Node* startNode = nul
lptr); | |
296 | |
297 ScrollResult scrollBox( | |
298 LayoutBox*, | |
299 ScrollGranularity, | |
300 const FloatSize& delta, | |
301 const FloatPoint& position, | |
302 const FloatSize& velocity, | |
303 bool* wasRootScroller); | |
304 | |
305 bool isRootScroller(const Node&) const; | |
306 void customizedScroll(const Node& startNode, ScrollState&); | |
307 | |
308 void invalidateClick(); | 254 void invalidateClick(); |
309 | 255 |
310 Node* updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); | 256 Node* updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); |
311 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent
&, bool isFrameBoundaryTransition = false); | 257 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent
&, bool isFrameBoundaryTransition = false); |
312 | 258 |
313 | 259 |
314 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const
PlatformMouseEvent&); | 260 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const
PlatformMouseEvent&); |
315 | 261 |
316 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node*
target, int clickCount, const PlatformMouseEvent&); | 262 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node*
target, int clickCount, const PlatformMouseEvent&); |
317 | 263 |
(...skipping 24 matching lines...) Expand all Loading... |
342 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); | 288 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); |
343 | 289 |
344 void defaultSpaceEventHandler(KeyboardEvent*); | 290 void defaultSpaceEventHandler(KeyboardEvent*); |
345 void defaultBackspaceEventHandler(KeyboardEvent*); | 291 void defaultBackspaceEventHandler(KeyboardEvent*); |
346 void defaultTabEventHandler(KeyboardEvent*); | 292 void defaultTabEventHandler(KeyboardEvent*); |
347 void defaultEscapeEventHandler(KeyboardEvent*); | 293 void defaultEscapeEventHandler(KeyboardEvent*); |
348 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); | 294 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); |
349 | 295 |
350 void updateLastScrollbarUnderMouse(Scrollbar*, bool); | 296 void updateLastScrollbarUnderMouse(Scrollbar*, bool); |
351 | 297 |
352 void setFrameWasScrolledByUser(); | |
353 | |
354 bool capturesDragging() const { return m_capturesDragging; } | 298 bool capturesDragging() const { return m_capturesDragging; } |
355 | 299 |
356 WebInputEventResult handleGestureShowPress(); | 300 WebInputEventResult handleGestureShowPress(); |
357 | 301 |
358 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); | |
359 | |
360 WebInputEventResult passScrollGestureEventToWidget(const PlatformGestureEven
t&, LayoutObject*); | |
361 | |
362 AutoscrollController* autoscrollController() const; | |
363 bool panScrollInProgress() const; | |
364 void setLastKnownMousePosition(const PlatformMouseEvent&); | 302 void setLastKnownMousePosition(const PlatformMouseEvent&); |
365 | 303 |
366 bool shouldTopControlsConsumeScroll(FloatSize) const; | 304 bool shouldTopControlsConsumeScroll(FloatSize) const; |
367 | 305 |
368 // If the given element is a shadow host and its root has delegatesFocus=fal
se flag, | 306 // If the given element is a shadow host and its root has delegatesFocus=fal
se flag, |
369 // slide focus to its inner element. Returns true if the resulting focus is
different from | 307 // slide focus to its inner element. Returns true if the resulting focus is
different from |
370 // the given element. | 308 // the given element. |
371 bool slideFocusOnShadowHostIfNecessary(const Element&); | 309 bool slideFocusOnShadowHostIfNecessary(const Element&); |
372 | 310 |
373 FrameHost* frameHost() const; | 311 FrameHost* frameHost() const; |
(...skipping 20 matching lines...) Expand all Loading... |
394 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide
state | 332 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide
state |
395 // should move out of EventHandler to a new PageEventHandler class. crbug.co
m/449649 | 333 // should move out of EventHandler to a new PageEventHandler class. crbug.co
m/449649 |
396 Timer<EventHandler> m_cursorUpdateTimer; | 334 Timer<EventHandler> m_cursorUpdateTimer; |
397 | 335 |
398 bool m_mouseDownMayStartAutoscroll; | 336 bool m_mouseDownMayStartAutoscroll; |
399 | 337 |
400 Timer<EventHandler> m_fakeMouseMoveEventTimer; | 338 Timer<EventHandler> m_fakeMouseMoveEventTimer; |
401 | 339 |
402 bool m_svgPan; | 340 bool m_svgPan; |
403 | 341 |
404 Member<PaintLayerScrollableArea> m_resizeScrollableArea; | |
405 | |
406 Member<Node> m_capturingMouseEventsNode; | 342 Member<Node> m_capturingMouseEventsNode; |
407 bool m_eventHandlerWillResetCapturingMouseEventsNode; | 343 bool m_eventHandlerWillResetCapturingMouseEventsNode; |
408 | 344 |
409 // Note the difference of this and m_nodeUnderPointer in PointerEventManager | 345 // Note the difference of this and m_nodeUnderPointer in PointerEventManager |
410 Member<Node> m_nodeUnderMouse; | 346 Member<Node> m_nodeUnderMouse; |
411 | 347 |
412 Member<LocalFrame> m_lastMouseMoveEventSubframe; | 348 Member<LocalFrame> m_lastMouseMoveEventSubframe; |
413 Member<Scrollbar> m_lastScrollbarUnderMouse; | 349 Member<Scrollbar> m_lastScrollbarUnderMouse; |
414 | 350 |
415 int m_clickCount; | 351 int m_clickCount; |
416 Member<Node> m_clickNode; | 352 Member<Node> m_clickNode; |
417 | 353 |
418 Member<Node> m_dragTarget; | 354 Member<Node> m_dragTarget; |
419 bool m_shouldOnlyFireDragOverEvent; | 355 bool m_shouldOnlyFireDragOverEvent; |
420 | 356 |
421 Member<HTMLFrameSetElement> m_frameSetBeingResized; | 357 Member<HTMLFrameSetElement> m_frameSetBeingResized; |
422 | 358 |
423 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA
rea. | |
424 | |
425 bool m_mousePositionIsUnknown; | 359 bool m_mousePositionIsUnknown; |
426 // The last mouse movement position this frame has seen in root frame coordi
nates. | 360 // The last mouse movement position this frame has seen in root frame coordi
nates. |
427 IntPoint m_lastKnownMousePosition; | 361 IntPoint m_lastKnownMousePosition; |
428 IntPoint m_lastKnownMouseGlobalPosition; | 362 IntPoint m_lastKnownMouseGlobalPosition; |
429 IntPoint m_mouseDownPos; // In our view's coords. | 363 IntPoint m_mouseDownPos; // In our view's coords. |
430 double m_mouseDownTimestamp; | 364 double m_mouseDownTimestamp; |
431 PlatformMouseEvent m_mouseDown; | 365 PlatformMouseEvent m_mouseDown; |
432 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; | 366 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; |
433 | 367 |
434 PointerEventManager m_pointerEventManager; | 368 PointerEventManager m_pointerEventManager; |
435 | 369 ScrollManager m_scrollManager; |
436 Member<Node> m_scrollGestureHandlingNode; | |
437 bool m_lastGestureScrollOverWidget; | |
438 // The most recent element to scroll natively during this scroll | |
439 // sequence. Null if no native element has scrolled this scroll | |
440 // sequence, or if the most recent element to scroll used scroll | |
441 // customization. | |
442 Member<Node> m_previousGestureScrolledNode; | |
443 Member<Scrollbar> m_scrollbarHandlingScrollGesture; | |
444 | 370 |
445 double m_maxMouseMovedDuration; | 371 double m_maxMouseMovedDuration; |
446 | 372 |
447 bool m_longTapShouldInvokeContextMenu; | 373 bool m_longTapShouldInvokeContextMenu; |
448 | 374 |
449 Timer<EventHandler> m_activeIntervalTimer; | 375 Timer<EventHandler> m_activeIntervalTimer; |
450 double m_lastShowPressTimestamp; | 376 double m_lastShowPressTimestamp; |
451 Member<Element> m_lastDeferredTapElement; | 377 Member<Element> m_lastDeferredTapElement; |
452 | |
453 // Only used with the ScrollCustomization runtime enabled feature. | |
454 std::deque<int> m_currentScrollChain; | |
455 // True iff some of the delta has been consumed for the current | |
456 // scroll sequence in this frame, or any child frames. Only used | |
457 // with ScrollCustomization. If some delta has been consumed, a | |
458 // scroll which shouldn't propagate can't cause any element to | |
459 // scroll other than the |m_previousGestureScrolledNode|. | |
460 bool m_deltaConsumedForScrollSequence; | |
461 }; | 378 }; |
462 | 379 |
463 } // namespace blink | 380 } // namespace blink |
464 | 381 |
465 #endif // EventHandler_h | 382 #endif // EventHandler_h |
OLD | NEW |