Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1541)

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.h

Issue 2010133003: Add ScrollManager class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding TODOs Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
93 public: 90 public:
94 explicit EventHandler(LocalFrame*); 91 explicit EventHandler(LocalFrame*);
95 ~EventHandler(); 92 ~EventHandler();
96 DECLARE_TRACE(); 93 DECLARE_TRACE();
97 94
98 void clear(); 95 void clear();
99 void nodeWillBeRemoved(Node&); 96 void nodeWillBeRemoved(Node&);
100 97
101 void updateSelectionForMouseDrag(); 98 void updateSelectionForMouseDrag();
102 99
103 #if OS(WIN) 100 #if OS(WIN)
104 void startPanScrolling(LayoutObject*); 101 void startPanScrolling(LayoutObject*);
105 #endif 102 #endif
106 103
104 // TODO(nzolghadr): Some of the APIs in this class only forward the action
105 // to the corresponding Manager class. We need to investigate whether it is
106 // better to expose the manager instance itself later or can the access to
107 // those APIs be more limited or removed.
108
107 void stopAutoscroll(); 109 void stopAutoscroll();
108 110
109 void dispatchFakeMouseMoveEventSoon(); 111 void dispatchFakeMouseMoveEventSoon();
110 void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&); 112 void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
111 113
112 static HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, H itTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRe quest::Active); 114 static HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, H itTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRe quest::Active);
113 115
114 HitTestResult hitTestResultAtPoint(const LayoutPoint&, 116 HitTestResult hitTestResultAtPoint(const LayoutPoint&,
115 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active, 117 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active,
116 const LayoutSize& padding = LayoutSize()); 118 const LayoutSize& padding = LayoutSize());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 WebInputEventResult handleMousePressEvent(const MouseEventWithHitTestResults &); 230 WebInputEventResult handleMousePressEvent(const MouseEventWithHitTestResults &);
229 WebInputEventResult handleMouseFocus(const MouseEventWithHitTestResults&, In putDeviceCapabilities* sourceCapabilities); 231 WebInputEventResult handleMouseFocus(const MouseEventWithHitTestResults&, In putDeviceCapabilities* sourceCapabilities);
230 WebInputEventResult handleMouseDraggedEvent(const MouseEventWithHitTestResul ts&); 232 WebInputEventResult handleMouseDraggedEvent(const MouseEventWithHitTestResul ts&);
231 WebInputEventResult handleMouseReleaseEvent(const MouseEventWithHitTestResul ts&); 233 WebInputEventResult handleMouseReleaseEvent(const MouseEventWithHitTestResul ts&);
232 234
233 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::E ventType); 235 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::E ventType);
234 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); 236 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*);
235 WebInputEventResult handleGestureTap(const GestureEventWithHitTestResults&); 237 WebInputEventResult handleGestureTap(const GestureEventWithHitTestResults&);
236 WebInputEventResult handleGestureLongPress(const GestureEventWithHitTestResu lts&); 238 WebInputEventResult handleGestureLongPress(const GestureEventWithHitTestResu lts&);
237 WebInputEventResult handleGestureLongTap(const GestureEventWithHitTestResult s&); 239 WebInputEventResult handleGestureLongTap(const GestureEventWithHitTestResult s&);
238 WebInputEventResult handleGestureScrollUpdate(const PlatformGestureEvent&);
239 WebInputEventResult handleGestureScrollBegin(const PlatformGestureEvent&);
240 void clearGestureScrollState();
241 240
242 void updateGestureTargetNodeForMouseEvent(const GestureEventWithHitTestResul ts&); 241 void updateGestureTargetNodeForMouseEvent(const GestureEventWithHitTestResul ts&);
243 242
244 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; 243 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const;
245 244
246 OptionalCursor selectCursor(const HitTestResult&); 245 OptionalCursor selectCursor(const HitTestResult&);
247 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); 246 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam);
248 247
249 void hoverTimerFired(Timer<EventHandler>*); 248 void hoverTimerFired(Timer<EventHandler>*);
250 void cursorUpdateTimerFired(Timer<EventHandler>*); 249 void cursorUpdateTimerFired(Timer<EventHandler>*);
251 void activeIntervalTimerFired(Timer<EventHandler>*); 250 void activeIntervalTimerFired(Timer<EventHandler>*);
252 251
253 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); 252 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*);
254 void cancelFakeMouseMoveEvent(); 253 void cancelFakeMouseMoveEvent();
255 bool isCursorVisible() const; 254 bool isCursorVisible() const;
256 void updateCursor(); 255 void updateCursor();
257 256
258 ScrollableArea* associatedScrollableArea(const PaintLayer*) const; 257 ScrollableArea* associatedScrollableArea(const PaintLayer*) const;
259 258
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(); 259 void invalidateClick();
309 260
310 Node* updateMouseEventTargetNode(Node*, const PlatformMouseEvent&); 261 Node* updateMouseEventTargetNode(Node*, const PlatformMouseEvent&);
311 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent &, bool isFrameBoundaryTransition = false); 262 void updateMouseEventTargetNodeAndSendEvents(Node*, const PlatformMouseEvent &, bool isFrameBoundaryTransition = false);
312 263
313 264
314 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&); 265 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&);
315 266
316 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node* target, int clickCount, const PlatformMouseEvent&); 267 WebInputEventResult dispatchMouseEvent(const AtomicString& eventType, Node* target, int clickCount, const PlatformMouseEvent&);
317 268
(...skipping 24 matching lines...) Expand all
342 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); 293 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&);
343 294
344 void defaultSpaceEventHandler(KeyboardEvent*); 295 void defaultSpaceEventHandler(KeyboardEvent*);
345 void defaultBackspaceEventHandler(KeyboardEvent*); 296 void defaultBackspaceEventHandler(KeyboardEvent*);
346 void defaultTabEventHandler(KeyboardEvent*); 297 void defaultTabEventHandler(KeyboardEvent*);
347 void defaultEscapeEventHandler(KeyboardEvent*); 298 void defaultEscapeEventHandler(KeyboardEvent*);
348 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); 299 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*);
349 300
350 void updateLastScrollbarUnderMouse(Scrollbar*, bool); 301 void updateLastScrollbarUnderMouse(Scrollbar*, bool);
351 302
352 void setFrameWasScrolledByUser();
353
354 bool capturesDragging() const { return m_capturesDragging; } 303 bool capturesDragging() const { return m_capturesDragging; }
355 304
356 WebInputEventResult handleGestureShowPress(); 305 WebInputEventResult handleGestureShowPress();
357 306
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&); 307 void setLastKnownMousePosition(const PlatformMouseEvent&);
365 308
366 bool shouldTopControlsConsumeScroll(FloatSize) const; 309 bool shouldTopControlsConsumeScroll(FloatSize) const;
367 310
368 // If the given element is a shadow host and its root has delegatesFocus=fal se flag, 311 // 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 312 // slide focus to its inner element. Returns true if the resulting focus is different from
370 // the given element. 313 // the given element.
371 bool slideFocusOnShadowHostIfNecessary(const Element&); 314 bool slideFocusOnShadowHostIfNecessary(const Element&);
372 315
373 FrameHost* frameHost() const; 316 FrameHost* frameHost() const;
(...skipping 20 matching lines...) Expand all
394 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide state 337 // 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 338 // should move out of EventHandler to a new PageEventHandler class. crbug.co m/449649
396 Timer<EventHandler> m_cursorUpdateTimer; 339 Timer<EventHandler> m_cursorUpdateTimer;
397 340
398 bool m_mouseDownMayStartAutoscroll; 341 bool m_mouseDownMayStartAutoscroll;
399 342
400 Timer<EventHandler> m_fakeMouseMoveEventTimer; 343 Timer<EventHandler> m_fakeMouseMoveEventTimer;
401 344
402 bool m_svgPan; 345 bool m_svgPan;
403 346
404 Member<PaintLayerScrollableArea> m_resizeScrollableArea;
405
406 Member<Node> m_capturingMouseEventsNode; 347 Member<Node> m_capturingMouseEventsNode;
407 bool m_eventHandlerWillResetCapturingMouseEventsNode; 348 bool m_eventHandlerWillResetCapturingMouseEventsNode;
408 349
409 // Note the difference of this and m_nodeUnderPointer in PointerEventManager 350 // Note the difference of this and m_nodeUnderPointer in PointerEventManager
410 Member<Node> m_nodeUnderMouse; 351 Member<Node> m_nodeUnderMouse;
411 352
412 Member<LocalFrame> m_lastMouseMoveEventSubframe; 353 Member<LocalFrame> m_lastMouseMoveEventSubframe;
413 Member<Scrollbar> m_lastScrollbarUnderMouse; 354 Member<Scrollbar> m_lastScrollbarUnderMouse;
414 355
415 int m_clickCount; 356 int m_clickCount;
416 Member<Node> m_clickNode; 357 Member<Node> m_clickNode;
417 358
418 Member<Node> m_dragTarget; 359 Member<Node> m_dragTarget;
419 bool m_shouldOnlyFireDragOverEvent; 360 bool m_shouldOnlyFireDragOverEvent;
420 361
421 Member<HTMLFrameSetElement> m_frameSetBeingResized; 362 Member<HTMLFrameSetElement> m_frameSetBeingResized;
422 363
423 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA rea.
424
425 bool m_mousePositionIsUnknown; 364 bool m_mousePositionIsUnknown;
426 // The last mouse movement position this frame has seen in root frame coordi nates. 365 // The last mouse movement position this frame has seen in root frame coordi nates.
427 IntPoint m_lastKnownMousePosition; 366 IntPoint m_lastKnownMousePosition;
428 IntPoint m_lastKnownMouseGlobalPosition; 367 IntPoint m_lastKnownMouseGlobalPosition;
429 IntPoint m_mouseDownPos; // In our view's coords. 368 IntPoint m_mouseDownPos; // In our view's coords.
430 double m_mouseDownTimestamp; 369 double m_mouseDownTimestamp;
431 PlatformMouseEvent m_mouseDown; 370 PlatformMouseEvent m_mouseDown;
432 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken; 371 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken;
433 372
434 PointerEventManager m_pointerEventManager; 373 PointerEventManager m_pointerEventManager;
435 374 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 375
445 double m_maxMouseMovedDuration; 376 double m_maxMouseMovedDuration;
446 377
447 bool m_longTapShouldInvokeContextMenu; 378 bool m_longTapShouldInvokeContextMenu;
448 379
449 Timer<EventHandler> m_activeIntervalTimer; 380 Timer<EventHandler> m_activeIntervalTimer;
450 double m_lastShowPressTimestamp; 381 double m_lastShowPressTimestamp;
451 Member<Element> m_lastDeferredTapElement; 382 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 }; 383 };
462 384
463 } // namespace blink 385 } // namespace blink
464 386
465 #endif // EventHandler_h 387 #endif // EventHandler_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/input/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698