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

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

Issue 1113323002: [Reland] Refactor the selection code in EventHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
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/editing/TextGranularity.h"
31 #include "core/events/TextEventInputType.h" 30 #include "core/events/TextEventInputType.h"
32 #include "core/layout/HitTestRequest.h" 31 #include "core/layout/HitTestRequest.h"
33 #include "core/style/ComputedStyleConstants.h" 32 #include "core/style/ComputedStyleConstants.h"
34 #include "core/page/DragActions.h" 33 #include "core/page/DragActions.h"
35 #include "core/page/EventWithHitTestResults.h" 34 #include "core/page/EventWithHitTestResults.h"
36 #include "platform/Cursor.h" 35 #include "platform/Cursor.h"
37 #include "platform/PlatformMouseEvent.h" 36 #include "platform/PlatformMouseEvent.h"
38 #include "platform/Timer.h" 37 #include "platform/Timer.h"
39 #include "platform/UserGestureIndicator.h" 38 #include "platform/UserGestureIndicator.h"
40 #include "platform/geometry/LayoutPoint.h" 39 #include "platform/geometry/LayoutPoint.h"
(...skipping 28 matching lines...) Expand all
69 class Node; 68 class Node;
70 class OptionalCursor; 69 class OptionalCursor;
71 class PlatformGestureEvent; 70 class PlatformGestureEvent;
72 class PlatformKeyboardEvent; 71 class PlatformKeyboardEvent;
73 class PlatformTouchEvent; 72 class PlatformTouchEvent;
74 class PlatformWheelEvent; 73 class PlatformWheelEvent;
75 class LayoutObject; 74 class LayoutObject;
76 class ScrollableArea; 75 class ScrollableArea;
77 class Scrollbar; 76 class Scrollbar;
78 class ScrollState; 77 class ScrollState;
78 class SelectionController;
79 class TextEvent; 79 class TextEvent;
80 class VisibleSelection;
81 class WheelEvent; 80 class WheelEvent;
82 class Widget; 81 class Widget;
83 82
84 enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTraili ngWhitespace };
85 enum class DragInitiator; 83 enum class DragInitiator;
86 84
87 class CORE_EXPORT EventHandler : public NoBaseWillBeGarbageCollectedFinalized<Ev entHandler> { 85 class CORE_EXPORT EventHandler : public NoBaseWillBeGarbageCollectedFinalized<Ev entHandler> {
88 WTF_MAKE_NONCOPYABLE(EventHandler); 86 WTF_MAKE_NONCOPYABLE(EventHandler);
89 public: 87 public:
90 explicit EventHandler(LocalFrame*); 88 explicit EventHandler(LocalFrame*);
91 ~EventHandler(); 89 ~EventHandler();
92 DECLARE_TRACE(); 90 DECLARE_TRACE();
93 91
94 void clear(); 92 void clear();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 189
192 bool handleTouchEvent(const PlatformTouchEvent&); 190 bool handleTouchEvent(const PlatformTouchEvent&);
193 191
194 bool useHandCursor(Node*, bool isOverLink); 192 bool useHandCursor(Node*, bool isOverLink);
195 193
196 void notifyElementActivated(); 194 void notifyElementActivated();
197 195
198 PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_last MouseDownUserGestureToken.release(); } 196 PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_last MouseDownUserGestureToken.release(); }
199 197
200 int clickCount() { return m_clickCount; } 198 int clickCount() { return m_clickCount; }
201 bool mouseDownWasSingleClickInSelection() { return m_mouseDownWasSingleClick InSelection; } 199
200 SelectionController& selectionController() const { return *m_selectionContro ller; }
202 201
203 private: 202 private:
204 static DragState& dragState(); 203 static DragState& dragState();
205 204
206 DataTransfer* createDraggingDataTransfer() const; 205 DataTransfer* createDraggingDataTransfer() const;
207 206
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 ); 207 bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* h overedNode = nullptr, bool onlyUpdateScrollbars = false, bool forceLeave = false );
216 bool handleMousePressEvent(const MouseEventWithHitTestResults&); 208 bool handleMousePressEvent(const MouseEventWithHitTestResults&);
217 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
218 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
219 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
220 bool handleMouseFocus(const MouseEventWithHitTestResults&); 209 bool handleMouseFocus(const MouseEventWithHitTestResults&);
221 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&); 210 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&);
222 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&); 211 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
223 212
224 bool handlePasteGlobalSelection(const PlatformMouseEvent&);
225
226 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::T ype); 213 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::T ype);
227 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); 214 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*);
228 bool handleGestureTap(const GestureEventWithHitTestResults&); 215 bool handleGestureTap(const GestureEventWithHitTestResults&);
229 bool handleGestureLongPress(const GestureEventWithHitTestResults&); 216 bool handleGestureLongPress(const GestureEventWithHitTestResults&);
230 bool handleGestureLongTap(const GestureEventWithHitTestResults&); 217 bool handleGestureLongTap(const GestureEventWithHitTestResults&);
231 bool handleGestureScrollUpdate(const PlatformGestureEvent&); 218 bool handleGestureScrollUpdate(const PlatformGestureEvent&);
232 bool handleGestureScrollBegin(const PlatformGestureEvent&); 219 bool handleGestureScrollBegin(const PlatformGestureEvent&);
233 void clearGestureScrollNodes(); 220 void clearGestureScrollNodes();
234 221
235 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; 222 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const;
236 223
237 OptionalCursor selectCursor(const HitTestResult&); 224 OptionalCursor selectCursor(const HitTestResult&);
238 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); 225 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam);
239 226
240 void hoverTimerFired(Timer<EventHandler>*); 227 void hoverTimerFired(Timer<EventHandler>*);
241 void cursorUpdateTimerFired(Timer<EventHandler>*); 228 void cursorUpdateTimerFired(Timer<EventHandler>*);
242 void activeIntervalTimerFired(Timer<EventHandler>*); 229 void activeIntervalTimerFired(Timer<EventHandler>*);
243 230
244 bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
245
246 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); 231 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*);
247 void cancelFakeMouseMoveEvent(); 232 void cancelFakeMouseMoveEvent();
248 bool isCursorVisible() const; 233 bool isCursorVisible() const;
249 void updateCursor(); 234 void updateCursor();
250 235
251 ScrollableArea* associatedScrollableArea(const DeprecatedPaintLayer*) const; 236 ScrollableArea* associatedScrollableArea(const DeprecatedPaintLayer*) const;
252 237
253 // Scrolls the elements of the DOM tree. Returns true if a node was scrolled . 238 // 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. 239 // 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 240 // direction - The direction to scroll in. If this is a logical direction, i t will be
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 283
299 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); 284 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&);
300 285
301 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&); 286 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&);
302 void defaultSpaceEventHandler(KeyboardEvent*); 287 void defaultSpaceEventHandler(KeyboardEvent*);
303 void defaultBackspaceEventHandler(KeyboardEvent*); 288 void defaultBackspaceEventHandler(KeyboardEvent*);
304 void defaultTabEventHandler(KeyboardEvent*); 289 void defaultTabEventHandler(KeyboardEvent*);
305 void defaultEscapeEventHandler(KeyboardEvent*); 290 void defaultEscapeEventHandler(KeyboardEvent*);
306 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); 291 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*);
307 292
308 void updateSelectionForMouseDrag(const HitTestResult&);
309
310 void updateLastScrollbarUnderMouse(Scrollbar*, bool); 293 void updateLastScrollbarUnderMouse(Scrollbar*, bool);
311 294
312 void setFrameWasScrolledByUser(); 295 void setFrameWasScrolledByUser();
313 296
314 bool capturesDragging() const { return m_capturesDragging; } 297 bool capturesDragging() const { return m_capturesDragging; }
315 298
316 bool handleGestureShowPress(); 299 bool handleGestureShowPress();
317 300
318 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); 301 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&);
319 302
(...skipping 11 matching lines...) Expand all
331 314
332 // NOTE: If adding a new field to this class please ensure that it is 315 // NOTE: If adding a new field to this class please ensure that it is
333 // cleared in |EventHandler::clear()|. 316 // cleared in |EventHandler::clear()|.
334 317
335 LocalFrame* const m_frame; 318 LocalFrame* const m_frame;
336 319
337 bool m_mousePressed; 320 bool m_mousePressed;
338 bool m_capturesDragging; 321 bool m_capturesDragging;
339 RefPtrWillBeMember<Node> m_mousePressNode; 322 RefPtrWillBeMember<Node> m_mousePressNode;
340 323
341 bool m_mouseDownMayStartSelect;
342 bool m_mouseDownMayStartDrag; 324 bool m_mouseDownMayStartDrag;
343 bool m_mouseDownWasSingleClickInSelection; 325 const OwnPtr<SelectionController> m_selectionController;
tkent 2015/05/20 23:57:40 OwnPtr -> OwnPtrWillBeMember
Miyoung Shin(g) 2015/05/21 22:49:38 Done.
344 enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, Extend edSelection };
345 SelectionInitiationState m_selectionInitiationState;
346 326
347 LayoutPoint m_dragStartPos; 327 LayoutPoint m_dragStartPos;
348 328
349 Timer<EventHandler> m_hoverTimer; 329 Timer<EventHandler> m_hoverTimer;
350 330
351 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide state 331 // 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 332 // should move out of EventHandler to a new PageEventHandler class. crbug.co m/449649
353 Timer<EventHandler> m_cursorUpdateTimer; 333 Timer<EventHandler> m_cursorUpdateTimer;
354 334
355 bool m_mouseDownMayStartAutoscroll; 335 bool m_mouseDownMayStartAutoscroll;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // scroll sequence in this frame, or any child frames. Only used 405 // scroll sequence in this frame, or any child frames. Only used
426 // with ScrollCustomization. If some delta has been consumed, a 406 // with ScrollCustomization. If some delta has been consumed, a
427 // scroll which shouldn't propagate can't cause any element to 407 // scroll which shouldn't propagate can't cause any element to
428 // scroll other than the |m_previousGestureScrolledNode|. 408 // scroll other than the |m_previousGestureScrolledNode|.
429 bool m_deltaConsumedForScrollSequence; 409 bool m_deltaConsumedForScrollSequence;
430 }; 410 };
431 411
432 } // namespace blink 412 } // namespace blink
433 413
434 #endif // EventHandler_h 414 #endif // EventHandler_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698