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

Side by Side Diff: Source/core/page/EventHandler.h

Issue 1153723010: Remove page/EventHandler.* and fix core.gypi (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/page/EventHandler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
24 */
25
26 #ifndef EventHandler_h
27 #define EventHandler_h
28
29 #include "core/CoreExport.h"
30 #include "core/editing/TextGranularity.h"
31 #include "core/events/TextEventInputType.h"
32 #include "core/layout/HitTestRequest.h"
33 #include "core/style/ComputedStyleConstants.h"
34 #include "core/page/DragActions.h"
35 #include "core/page/EventWithHitTestResults.h"
36 #include "platform/Cursor.h"
37 #include "platform/PlatformMouseEvent.h"
38 #include "platform/Timer.h"
39 #include "platform/UserGestureIndicator.h"
40 #include "platform/geometry/LayoutPoint.h"
41 #include "platform/heap/Handle.h"
42 #include "platform/scroll/ScrollTypes.h"
43 #include "public/platform/WebFocusType.h"
44 #include "wtf/Forward.h"
45 #include "wtf/HashMap.h"
46 #include "wtf/HashTraits.h"
47 #include "wtf/RefPtr.h"
48
49 namespace blink {
50
51 class AutoscrollController;
52 class DataTransfer;
53 class DeprecatedPaintLayer;
54 class DeprecatedPaintLayerScrollableArea;
55 class Document;
56 class DragState;
57 class Element;
58 class Event;
59 class EventTarget;
60 template <typename EventType>
61 class EventWithHitTestResults;
62 class FloatPoint;
63 class FloatQuad;
64 class HTMLFrameSetElement;
65 class HitTestRequest;
66 class HitTestResult;
67 class KeyboardEvent;
68 class LocalFrame;
69 class Node;
70 class OptionalCursor;
71 class PlatformGestureEvent;
72 class PlatformKeyboardEvent;
73 class PlatformTouchEvent;
74 class PlatformWheelEvent;
75 class LayoutObject;
76 class ScrollableArea;
77 class Scrollbar;
78 class ScrollState;
79 class TextEvent;
80 class VisibleSelection;
81 class WheelEvent;
82 class Widget;
83
84 enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTraili ngWhitespace };
85 enum class DragInitiator;
86
87 class CORE_EXPORT EventHandler : public NoBaseWillBeGarbageCollectedFinalized<Ev entHandler> {
88 WTF_MAKE_NONCOPYABLE(EventHandler);
89 public:
90 explicit EventHandler(LocalFrame*);
91 ~EventHandler();
92 DECLARE_TRACE();
93
94 void clear();
95 void nodeWillBeRemoved(Node&);
96
97 void updateSelectionForMouseDrag();
98
99 #if OS(WIN)
100 void startPanScrolling(LayoutObject*);
101 #endif
102
103 void stopAutoscroll();
104
105 void dispatchFakeMouseMoveEventSoon();
106 void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
107
108 HitTestResult hitTestResultAtPoint(const LayoutPoint&,
109 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active,
110 const LayoutSize& padding = LayoutSize());
111
112 bool mousePressed() const { return m_mousePressed; }
113
114 void setCapturingMouseEventsNode(PassRefPtrWillBeRawPtr<Node>); // A caller is responsible for resetting capturing node to 0.
115
116 bool updateDragAndDrop(const PlatformMouseEvent&, DataTransfer*);
117 void cancelDragAndDrop(const PlatformMouseEvent&, DataTransfer*);
118 bool performDragAndDrop(const PlatformMouseEvent&, DataTransfer*);
119 void updateDragStateAfterEditDragIfNeeded(Element* rootEditableElement);
120
121 void scheduleHoverStateUpdate();
122 void scheduleCursorUpdate();
123
124 // Return whether a mouse cursor update is currently pending. Used for test ing.
125 bool cursorUpdatePending();
126
127 void setResizingFrameSet(HTMLFrameSetElement*);
128
129 void resizeScrollableAreaDestroyed();
130
131 IntPoint lastKnownMousePosition() const;
132
133 // Attempts to scroll the DOM tree. If that fails, scrolls the view.
134 // If the view can't be scrolled either, recursively bubble to the parent fr ame.
135 bool bubblingScroll(ScrollDirection, ScrollGranularity, Node* startingNode = nullptr);
136
137 bool handleMouseMoveEvent(const PlatformMouseEvent&);
138 void handleMouseLeaveEvent(const PlatformMouseEvent&);
139
140 bool handleMousePressEvent(const PlatformMouseEvent&);
141 bool handleMouseReleaseEvent(const PlatformMouseEvent&);
142 bool handleWheelEvent(const PlatformWheelEvent&);
143 void defaultWheelEventHandler(Node*, WheelEvent*);
144
145 // Called on the local root frame exactly once per gesture event.
146 bool handleGestureEvent(const PlatformGestureEvent&);
147 bool handleGestureEvent(const GestureEventWithHitTestResults&);
148
149 // Clear the old hover/active state within frames before moving the hover st ate to the another frame
150 void updateGestureHoverActiveState(const HitTestRequest&, Element*);
151
152 // Hit-test the provided (non-scroll) gesture event, applying touch-adjustme nt and updating
153 // hover/active state across all frames if necessary. This should be called at most once
154 // per gesture event, and called on the local root frame.
155 // Note: This is similar to (the less clearly named) prepareMouseEvent.
156 // FIXME: Remove readOnly param when there is only ever a single call to thi s.
157 GestureEventWithHitTestResults targetGestureEvent(const PlatformGestureEvent &, bool readOnly = false);
158 GestureEventWithHitTestResults hitTestResultForGestureEvent(const PlatformGe stureEvent&, HitTestRequest::HitTestRequestType);
159 // Handle the provided non-scroll gesture event. Should be called only on th e inner frame.
160 bool handleGestureEventInFrame(const GestureEventWithHitTestResults&);
161
162 // Handle the provided scroll gesture event, propagating down to child frame s as necessary.
163 bool handleGestureScrollEvent(const PlatformGestureEvent&);
164 bool handleGestureScrollEnd(const PlatformGestureEvent&);
165 bool isScrollbarHandlingGestures() const;
166
167 bool bestClickableNodeForHitTestResult(const HitTestResult&, IntPoint& targe tPoint, Node*& targetNode);
168 bool bestContextMenuNodeForHitTestResult(const HitTestResult&, IntPoint& tar getPoint, Node*& targetNode);
169 // FIXME: This doesn't appear to be used outside tests anymore, what path ar e we using now and is it tested?
170 bool bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSiz e& touchRadius, IntRect& targetArea, Node*& targetNode);
171
172 bool sendContextMenuEvent(const PlatformMouseEvent&, Node* overrideTargetNod e = nullptr);
173 bool sendContextMenuEventForKey(Element* overrideTargetElement = nullptr);
174 bool sendContextMenuEventForGesture(const GestureEventWithHitTestResults&);
175
176 void setMouseDownMayStartAutoscroll() { m_mouseDownMayStartAutoscroll = true ; }
177
178 static unsigned accessKeyModifiers();
179 bool handleAccessKey(const PlatformKeyboardEvent&);
180 bool keyEvent(const PlatformKeyboardEvent&);
181 void defaultKeyboardEventHandler(KeyboardEvent*);
182
183 bool handleTextInputEvent(const String& text, Event* underlyingEvent = nullp tr, TextEventInputType = TextEventInputKeyboard);
184 void defaultTextInputEventHandler(TextEvent*);
185
186 void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation);
187
188 void focusDocumentView();
189
190 void capsLockStateMayHaveChanged(); // Only called by FrameSelection
191
192 bool handleTouchEvent(const PlatformTouchEvent&);
193
194 bool useHandCursor(Node*, bool isOverLink);
195
196 void notifyElementActivated();
197
198 PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_last MouseDownUserGestureToken.release(); }
199
200 int clickCount() { return m_clickCount; }
201 bool mouseDownWasSingleClickInSelection() { return m_mouseDownWasSingleClick InSelection; }
202
203 private:
204 static DragState& dragState();
205
206 DataTransfer* createDraggingDataTransfer() const;
207
208 bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleS election&, TextGranularity);
209 void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailing Whitespace);
210 void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendT railingWhitespace);
211 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&);
212 void selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResul ts&);
213 void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResult s&);
214
215 bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* h overedNode = nullptr, bool onlyUpdateScrollbars = false, bool forceLeave = false );
216 bool handleMousePressEvent(const MouseEventWithHitTestResults&);
217 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
218 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
219 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
220 bool handleMouseFocus(const MouseEventWithHitTestResults&);
221 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&);
222 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
223
224 bool handlePasteGlobalSelection(const PlatformMouseEvent&);
225
226 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::T ype);
227 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*);
228 bool handleGestureTap(const GestureEventWithHitTestResults&);
229 bool handleGestureLongPress(const GestureEventWithHitTestResults&);
230 bool handleGestureLongTap(const GestureEventWithHitTestResults&);
231 bool handleGestureScrollUpdate(const PlatformGestureEvent&);
232 bool handleGestureScrollBegin(const PlatformGestureEvent&);
233 void clearGestureScrollNodes();
234
235 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const;
236
237 OptionalCursor selectCursor(const HitTestResult&);
238 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam);
239
240 void hoverTimerFired(Timer<EventHandler>*);
241 void cursorUpdateTimerFired(Timer<EventHandler>*);
242 void activeIntervalTimerFired(Timer<EventHandler>*);
243
244 bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
245
246 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*);
247 void cancelFakeMouseMoveEvent();
248 bool isCursorVisible() const;
249 void updateCursor();
250
251 ScrollableArea* associatedScrollableArea(const DeprecatedPaintLayer*) const;
252
253 // Scrolls the elements of the DOM tree. Returns true if a node was scrolled .
254 // False if we reached the root and couldn't scroll anything.
255 // direction - The direction to scroll in. If this is a logical direction, i t will be
256 // converted to the physical direction based on a node's writing mode.
257 // granularity - The units that the scroll delta parameter is in.
258 // startNode - The node to start bubbling the scroll from. If a node can't s croll,
259 // the scroll bubbles up to the containing block.
260 // stopNode - On input, if provided and non-null, the node at which we shoul d stop bubbling on input.
261 // On output, if provided and a node was scrolled stopNode will p oint to that node.
262 // delta - The delta to scroll by, in the units of the granularity parameter . (e.g. pixels, lines, pages, etc.)
263 // absolutePoint - For wheel scrolls - the location, in absolute coordinates , where the event occured.
264 bool scroll(ScrollDirection, ScrollGranularity, Node* startNode = nullptr, N ode** stopNode = nullptr, float delta = 1.0f, IntPoint absolutePoint = IntPoint( ));
265
266 void customizedScroll(const Node& startNode, ScrollState&);
267
268 TouchAction intersectTouchAction(const TouchAction, const TouchAction);
269 TouchAction computeEffectiveTouchAction(const Node&);
270
271 HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestR equest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest:: Active);
272
273 void invalidateClick();
274
275 void updateMouseEventTargetNode(Node*, const PlatformMouseEvent&, bool);
276
277 /* Dispatches mouseover, mouseout, mouseenter and mouseleave events to appro priate nodes when the mouse pointer moves from one node to another. */
278 void sendMouseEventsForNodeTransition(Node*, Node*, const PlatformMouseEvent &);
279
280 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&);
281
282 bool dispatchMouseEvent(const AtomicString& eventType, Node* target, int cli ckCount, const PlatformMouseEvent&, bool setUnder);
283 bool dispatchDragEvent(const AtomicString& eventType, Node* target, const Pl atformMouseEvent&, DataTransfer*);
284
285 void clearDragDataTransfer();
286
287 bool handleDrag(const MouseEventWithHitTestResults&, DragInitiator);
288 bool tryStartDrag(const MouseEventWithHitTestResults&);
289 void clearDragState();
290
291 bool dispatchDragSrcEvent(const AtomicString& eventType, const PlatformMouse Event&);
292
293 bool dragHysteresisExceeded(const IntPoint&) const;
294
295 bool passMousePressEventToSubframe(MouseEventWithHitTestResults&, LocalFrame * subframe);
296 bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, LocalFrame* subframe, HitTestResult* hoveredNode = nullptr);
297 bool passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&, LocalFra me* subframe);
298
299 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&);
300
301 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&);
302 void defaultSpaceEventHandler(KeyboardEvent*);
303 void defaultBackspaceEventHandler(KeyboardEvent*);
304 void defaultTabEventHandler(KeyboardEvent*);
305 void defaultEscapeEventHandler(KeyboardEvent*);
306 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*);
307
308 void updateSelectionForMouseDrag(const HitTestResult&);
309
310 void updateLastScrollbarUnderMouse(Scrollbar*, bool);
311
312 void setFrameWasScrolledByUser();
313
314 bool capturesDragging() const { return m_capturesDragging; }
315
316 bool handleGestureShowPress();
317
318 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&);
319
320 bool passScrollGestureEventToWidget(const PlatformGestureEvent&, LayoutObjec t*);
321
322 AutoscrollController* autoscrollController() const;
323 bool panScrollInProgress() const;
324 void setLastKnownMousePosition(const PlatformMouseEvent&);
325
326 bool shouldTopControlsConsumeScroll(FloatSize) const;
327
328 // If the given element is a shadow host with tabStop = false, slide focus t o its inner
329 // element. Returns true if the resulting focus is different from the given element.
330 bool slideFocusOnShadowHostIfNecessary(const Element&);
331
332 // NOTE: If adding a new field to this class please ensure that it is
333 // cleared in |EventHandler::clear()|.
334
335 LocalFrame* const m_frame;
336
337 bool m_mousePressed;
338 bool m_capturesDragging;
339 RefPtrWillBeMember<Node> m_mousePressNode;
340
341 bool m_mouseDownMayStartSelect;
342 bool m_mouseDownMayStartDrag;
343 bool m_mouseDownWasSingleClickInSelection;
344 enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, Extend edSelection };
345 SelectionInitiationState m_selectionInitiationState;
346
347 LayoutPoint m_dragStartPos;
348
349 Timer<EventHandler> m_hoverTimer;
350
351 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide state
352 // should move out of EventHandler to a new PageEventHandler class. crbug.co m/449649
353 Timer<EventHandler> m_cursorUpdateTimer;
354
355 bool m_mouseDownMayStartAutoscroll;
356
357 Timer<EventHandler> m_fakeMouseMoveEventTimer;
358
359 bool m_svgPan;
360
361 DeprecatedPaintLayerScrollableArea* m_resizeScrollableArea;
362
363 RefPtrWillBeMember<Node> m_capturingMouseEventsNode;
364 bool m_eventHandlerWillResetCapturingMouseEventsNode;
365
366 RefPtrWillBeMember<Node> m_nodeUnderMouse;
367 RefPtrWillBeMember<Node> m_lastNodeUnderMouse;
368 RefPtrWillBeMember<LocalFrame> m_lastMouseMoveEventSubframe;
369 RefPtrWillBeMember<Scrollbar> m_lastScrollbarUnderMouse;
370
371 int m_clickCount;
372 RefPtrWillBeMember<Node> m_clickNode;
373
374 RefPtrWillBeMember<Node> m_dragTarget;
375 bool m_shouldOnlyFireDragOverEvent;
376
377 RefPtrWillBeMember<HTMLFrameSetElement> m_frameSetBeingResized;
378
379 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA rea.
380
381 bool m_mousePositionIsUnknown;
382 // The last mouse movement position this frame has seen in root frame coordi nates.
383 IntPoint m_lastKnownMousePosition;
384 IntPoint m_lastKnownMouseGlobalPosition;
385 IntPoint m_mouseDownPos; // In our view's coords.
386 double m_mouseDownTimestamp;
387 PlatformMouseEvent m_mouseDown;
388 RefPtr<UserGestureToken> m_lastMouseDownUserGestureToken;
389
390 RefPtrWillBeMember<Node> m_latchedWheelEventNode;
391 bool m_widgetIsLatched;
392
393 RefPtrWillBeMember<Node> m_previousWheelScrolledNode;
394
395 // The target of each active touch point indexed by the touch ID.
396 using TouchTargetMap = WillBeHeapHashMap<unsigned, RefPtrWillBeMember<EventT arget>, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned >>;
397 TouchTargetMap m_targetForTouchID;
398
399 // If set, the document of the active touch sequence. Unset if no touch sequ ence active.
400 RefPtrWillBeMember<Document> m_touchSequenceDocument;
401 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken;
402
403 bool m_touchPressed;
404
405 RefPtrWillBeMember<Node> m_scrollGestureHandlingNode;
406 bool m_lastGestureScrollOverWidget;
407 // The most recent element to scroll natively during this scroll
408 // sequence. Null if no native element has scrolled this scroll
409 // sequence, or if the most recent element to scroll used scroll
410 // customization.
411 RefPtrWillBeMember<Node> m_previousGestureScrolledNode;
412 RefPtrWillBeMember<Scrollbar> m_scrollbarHandlingScrollGesture;
413
414 double m_maxMouseMovedDuration;
415
416 bool m_longTapShouldInvokeContextMenu;
417
418 Timer<EventHandler> m_activeIntervalTimer;
419 double m_lastShowPressTimestamp;
420 RefPtrWillBeMember<Element> m_lastDeferredTapElement;
421
422 // Only used with the ScrollCustomization runtime enabled feature.
423 WillBeHeapDeque<RefPtrWillBeMember<Element>> m_currentScrollChain;
424 // True iff some of the delta has been consumed for the current
425 // scroll sequence in this frame, or any child frames. Only used
426 // with ScrollCustomization. If some delta has been consumed, a
427 // scroll which shouldn't propagate can't cause any element to
428 // scroll other than the |m_previousGestureScrolledNode|.
429 bool m_deltaConsumedForScrollSequence;
430 };
431
432 } // namespace blink
433
434 #endif // EventHandler_h
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/page/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698