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

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" 30 #include "core/editing/SelectionController.h"
yosin_UTC9 2015/05/18 08:53:47 Let's use |OwnPtr<ScrollController| to avoid inclu
Miyoung Shin(g) 2015/05/19 09:01:43 Done.
31 #include "core/events/TextEventInputType.h" 31 #include "core/events/TextEventInputType.h"
32 #include "core/layout/HitTestRequest.h" 32 #include "core/layout/HitTestRequest.h"
33 #include "core/style/ComputedStyleConstants.h" 33 #include "core/style/ComputedStyleConstants.h"
34 #include "core/page/DragActions.h" 34 #include "core/page/DragActions.h"
35 #include "core/page/EventWithHitTestResults.h" 35 #include "core/page/EventWithHitTestResults.h"
36 #include "platform/Cursor.h" 36 #include "platform/Cursor.h"
37 #include "platform/PlatformMouseEvent.h" 37 #include "platform/PlatformMouseEvent.h"
38 #include "platform/Timer.h" 38 #include "platform/Timer.h"
39 #include "platform/UserGestureIndicator.h" 39 #include "platform/UserGestureIndicator.h"
40 #include "platform/geometry/LayoutPoint.h" 40 #include "platform/geometry/LayoutPoint.h"
(...skipping 29 matching lines...) Expand all
70 class OptionalCursor; 70 class OptionalCursor;
71 class PlatformGestureEvent; 71 class PlatformGestureEvent;
72 class PlatformKeyboardEvent; 72 class PlatformKeyboardEvent;
73 class PlatformTouchEvent; 73 class PlatformTouchEvent;
74 class PlatformWheelEvent; 74 class PlatformWheelEvent;
75 class LayoutObject; 75 class LayoutObject;
76 class ScrollableArea; 76 class ScrollableArea;
77 class Scrollbar; 77 class Scrollbar;
78 class ScrollState; 78 class ScrollState;
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();
95 void nodeWillBeRemoved(Node&); 93 void nodeWillBeRemoved(Node&);
96 94
97 void updateSelectionForMouseDrag();
98
99 #if OS(WIN) 95 #if OS(WIN)
100 void startPanScrolling(LayoutObject*); 96 void startPanScrolling(LayoutObject*);
101 #endif 97 #endif
102 98
103 void stopAutoscroll(); 99 void stopAutoscroll();
104 100
105 void dispatchFakeMouseMoveEventSoon(); 101 void dispatchFakeMouseMoveEventSoon();
106 void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&); 102 void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
107 103
108 HitTestResult hitTestResultAtPoint(const LayoutPoint&, 104 HitTestResult hitTestResultAtPoint(const LayoutPoint&,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 185
190 bool handleTouchEvent(const PlatformTouchEvent&); 186 bool handleTouchEvent(const PlatformTouchEvent&);
191 187
192 bool useHandCursor(Node*, bool isOverLink); 188 bool useHandCursor(Node*, bool isOverLink);
193 189
194 void notifyElementActivated(); 190 void notifyElementActivated();
195 191
196 PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_last MouseDownUserGestureToken.release(); } 192 PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_last MouseDownUserGestureToken.release(); }
197 193
198 int clickCount() { return m_clickCount; } 194 int clickCount() { return m_clickCount; }
199 bool mouseDownWasSingleClickInSelection() { return m_mouseDownWasSingleClick InSelection; } 195
196 void updateSelectionForMouseDrag();
yosin_UTC9 2015/05/18 08:53:47 nit: Please move this to original position, e.g. L
Miyoung Shin(g) 2015/05/19 09:01:43 Done.
197 SelectionController& selectionController() { return m_selectionController; }
200 198
201 private: 199 private:
202 static DragState& dragState(); 200 static DragState& dragState();
203 201
204 DataTransfer* createDraggingDataTransfer() const; 202 DataTransfer* createDraggingDataTransfer() const;
205 203
206 bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleS election&, TextGranularity);
207 void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailing Whitespace);
208 void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendT railingWhitespace);
209 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&);
210 void selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResul ts&);
211 void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResult s&);
212
213 bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* h overedNode = nullptr, bool onlyUpdateScrollbars = false, bool forceLeave = false ); 204 bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* h overedNode = nullptr, bool onlyUpdateScrollbars = false, bool forceLeave = false );
214 bool handleMousePressEvent(const MouseEventWithHitTestResults&); 205 bool handleMousePressEvent(const MouseEventWithHitTestResults&);
215 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
216 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
217 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
218 bool handleMouseFocus(const MouseEventWithHitTestResults&); 206 bool handleMouseFocus(const MouseEventWithHitTestResults&);
219 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&); 207 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&);
220 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&); 208 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
221 209
222 bool handlePasteGlobalSelection(const PlatformMouseEvent&);
223
224 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::T ype); 210 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::T ype);
225 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); 211 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*);
226 bool handleGestureTap(const GestureEventWithHitTestResults&); 212 bool handleGestureTap(const GestureEventWithHitTestResults&);
227 bool handleGestureLongPress(const GestureEventWithHitTestResults&); 213 bool handleGestureLongPress(const GestureEventWithHitTestResults&);
228 bool handleGestureLongTap(const GestureEventWithHitTestResults&); 214 bool handleGestureLongTap(const GestureEventWithHitTestResults&);
229 bool handleGestureScrollUpdate(const PlatformGestureEvent&); 215 bool handleGestureScrollUpdate(const PlatformGestureEvent&);
230 bool handleGestureScrollBegin(const PlatformGestureEvent&); 216 bool handleGestureScrollBegin(const PlatformGestureEvent&);
231 void clearGestureScrollNodes(); 217 void clearGestureScrollNodes();
232 218
233 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; 219 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const;
234 220
235 OptionalCursor selectCursor(const HitTestResult&); 221 OptionalCursor selectCursor(const HitTestResult&);
236 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); 222 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam);
237 223
238 void hoverTimerFired(Timer<EventHandler>*); 224 void hoverTimerFired(Timer<EventHandler>*);
239 void cursorUpdateTimerFired(Timer<EventHandler>*); 225 void cursorUpdateTimerFired(Timer<EventHandler>*);
240 void activeIntervalTimerFired(Timer<EventHandler>*); 226 void activeIntervalTimerFired(Timer<EventHandler>*);
241 227
242 bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
243
244 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); 228 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*);
245 void cancelFakeMouseMoveEvent(); 229 void cancelFakeMouseMoveEvent();
246 bool isCursorVisible() const; 230 bool isCursorVisible() const;
247 void updateCursor(); 231 void updateCursor();
248 232
249 ScrollableArea* associatedScrollableArea(const DeprecatedPaintLayer*) const; 233 ScrollableArea* associatedScrollableArea(const DeprecatedPaintLayer*) const;
250 234
251 // Scrolls the elements of the DOM tree. Returns true if a node was scrolled . 235 // Scrolls the elements of the DOM tree. Returns true if a node was scrolled .
252 // False if we reached the root and couldn't scroll anything. 236 // False if we reached the root and couldn't scroll anything.
253 // direction - The direction to scroll in. If this is a logical direction, i t will be 237 // 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
296 280
297 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); 281 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&);
298 282
299 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&); 283 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&);
300 void defaultSpaceEventHandler(KeyboardEvent*); 284 void defaultSpaceEventHandler(KeyboardEvent*);
301 void defaultBackspaceEventHandler(KeyboardEvent*); 285 void defaultBackspaceEventHandler(KeyboardEvent*);
302 void defaultTabEventHandler(KeyboardEvent*); 286 void defaultTabEventHandler(KeyboardEvent*);
303 void defaultEscapeEventHandler(KeyboardEvent*); 287 void defaultEscapeEventHandler(KeyboardEvent*);
304 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); 288 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*);
305 289
306 void updateSelectionForMouseDrag(const HitTestResult&);
307
308 void updateLastScrollbarUnderMouse(Scrollbar*, bool); 290 void updateLastScrollbarUnderMouse(Scrollbar*, bool);
309 291
310 void setFrameWasScrolledByUser(); 292 void setFrameWasScrolledByUser();
311 293
312 bool capturesDragging() const { return m_capturesDragging; } 294 bool capturesDragging() const { return m_capturesDragging; }
313 295
314 bool handleGestureShowPress(); 296 bool handleGestureShowPress();
315 297
316 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); 298 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&);
317 299
(...skipping 11 matching lines...) Expand all
329 311
330 // NOTE: If adding a new field to this class please ensure that it is 312 // NOTE: If adding a new field to this class please ensure that it is
331 // cleared in |EventHandler::clear()|. 313 // cleared in |EventHandler::clear()|.
332 314
333 LocalFrame* const m_frame; 315 LocalFrame* const m_frame;
334 316
335 bool m_mousePressed; 317 bool m_mousePressed;
336 bool m_capturesDragging; 318 bool m_capturesDragging;
337 RefPtrWillBeMember<Node> m_mousePressNode; 319 RefPtrWillBeMember<Node> m_mousePressNode;
338 320
339 bool m_mouseDownMayStartSelect;
340 bool m_mouseDownMayStartDrag; 321 bool m_mouseDownMayStartDrag;
341 bool m_mouseDownWasSingleClickInSelection; 322 SelectionController m_selectionController;
yosin_UTC9 2015/05/18 08:53:47 Let's use |const OwnPtr<SelectionController>|.
Miyoung Shin(g) 2015/05/19 09:01:43 Done.
342 enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, Extend edSelection };
343 SelectionInitiationState m_selectionInitiationState;
344 323
345 LayoutPoint m_dragStartPos; 324 LayoutPoint m_dragStartPos;
346 325
347 Timer<EventHandler> m_hoverTimer; 326 Timer<EventHandler> m_hoverTimer;
348 Timer<EventHandler> m_cursorUpdateTimer; 327 Timer<EventHandler> m_cursorUpdateTimer;
349 328
350 bool m_mouseDownMayStartAutoscroll; 329 bool m_mouseDownMayStartAutoscroll;
351 330
352 Timer<EventHandler> m_fakeMouseMoveEventTimer; 331 Timer<EventHandler> m_fakeMouseMoveEventTimer;
353 332
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // scroll sequence in this frame, or any child frames. Only used 399 // scroll sequence in this frame, or any child frames. Only used
421 // with ScrollCustomization. If some delta has been consumed, a 400 // with ScrollCustomization. If some delta has been consumed, a
422 // scroll which shouldn't propagate can't cause any element to 401 // scroll which shouldn't propagate can't cause any element to
423 // scroll other than the |m_previousGestureScrolledNode|. 402 // scroll other than the |m_previousGestureScrolledNode|.
424 bool m_deltaConsumedForScrollSequence; 403 bool m_deltaConsumedForScrollSequence;
425 }; 404 };
426 405
427 } // namespace blink 406 } // namespace blink
428 407
429 #endif // EventHandler_h 408 #endif // EventHandler_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698