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

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

Issue 1157833002: Revert of 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
« no previous file with comments | « Source/core/html/HTMLLabelElement.cpp ('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
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/events/TextEventInputType.h" 31 #include "core/events/TextEventInputType.h"
31 #include "core/layout/HitTestRequest.h" 32 #include "core/layout/HitTestRequest.h"
32 #include "core/style/ComputedStyleConstants.h" 33 #include "core/style/ComputedStyleConstants.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 "platform/Cursor.h" 36 #include "platform/Cursor.h"
36 #include "platform/PlatformMouseEvent.h" 37 #include "platform/PlatformMouseEvent.h"
37 #include "platform/Timer.h" 38 #include "platform/Timer.h"
38 #include "platform/UserGestureIndicator.h" 39 #include "platform/UserGestureIndicator.h"
39 #include "platform/geometry/LayoutPoint.h" 40 #include "platform/geometry/LayoutPoint.h"
(...skipping 28 matching lines...) Expand all
68 class Node; 69 class Node;
69 class OptionalCursor; 70 class OptionalCursor;
70 class PlatformGestureEvent; 71 class PlatformGestureEvent;
71 class PlatformKeyboardEvent; 72 class PlatformKeyboardEvent;
72 class PlatformTouchEvent; 73 class PlatformTouchEvent;
73 class PlatformWheelEvent; 74 class PlatformWheelEvent;
74 class LayoutObject; 75 class LayoutObject;
75 class ScrollableArea; 76 class ScrollableArea;
76 class Scrollbar; 77 class Scrollbar;
77 class ScrollState; 78 class ScrollState;
78 class SelectionController;
79 class TextEvent; 79 class TextEvent;
80 class VisibleSelection;
80 class WheelEvent; 81 class WheelEvent;
81 class Widget; 82 class Widget;
82 83
84 enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTraili ngWhitespace };
83 enum class DragInitiator; 85 enum class DragInitiator;
84 86
85 class CORE_EXPORT EventHandler : public NoBaseWillBeGarbageCollectedFinalized<Ev entHandler> { 87 class CORE_EXPORT EventHandler : public NoBaseWillBeGarbageCollectedFinalized<Ev entHandler> {
86 WTF_MAKE_NONCOPYABLE(EventHandler); 88 WTF_MAKE_NONCOPYABLE(EventHandler);
87 public: 89 public:
88 explicit EventHandler(LocalFrame*); 90 explicit EventHandler(LocalFrame*);
89 ~EventHandler(); 91 ~EventHandler();
90 DECLARE_TRACE(); 92 DECLARE_TRACE();
91 93
92 void clear(); 94 void clear();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 191
190 bool handleTouchEvent(const PlatformTouchEvent&); 192 bool handleTouchEvent(const PlatformTouchEvent&);
191 193
192 bool useHandCursor(Node*, bool isOverLink); 194 bool useHandCursor(Node*, bool isOverLink);
193 195
194 void notifyElementActivated(); 196 void notifyElementActivated();
195 197
196 PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_last MouseDownUserGestureToken.release(); } 198 PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_last MouseDownUserGestureToken.release(); }
197 199
198 int clickCount() { return m_clickCount; } 200 int clickCount() { return m_clickCount; }
199 201 bool mouseDownWasSingleClickInSelection() { return m_mouseDownWasSingleClick InSelection; }
200 SelectionController& selectionController() const { return *m_selectionContro ller; }
201 202
202 private: 203 private:
203 static DragState& dragState(); 204 static DragState& dragState();
204 205
205 DataTransfer* createDraggingDataTransfer() const; 206 DataTransfer* createDraggingDataTransfer() const;
206 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
207 bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* h overedNode = nullptr, bool onlyUpdateScrollbars = false, bool forceLeave = false ); 215 bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* h overedNode = nullptr, bool onlyUpdateScrollbars = false, bool forceLeave = false );
208 bool handleMousePressEvent(const MouseEventWithHitTestResults&); 216 bool handleMousePressEvent(const MouseEventWithHitTestResults&);
217 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
218 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
219 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
209 bool handleMouseFocus(const MouseEventWithHitTestResults&); 220 bool handleMouseFocus(const MouseEventWithHitTestResults&);
210 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&); 221 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&);
211 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&); 222 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
212 223
224 bool handlePasteGlobalSelection(const PlatformMouseEvent&);
225
213 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::T ype); 226 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::T ype);
214 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); 227 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*);
215 bool handleGestureTap(const GestureEventWithHitTestResults&); 228 bool handleGestureTap(const GestureEventWithHitTestResults&);
216 bool handleGestureLongPress(const GestureEventWithHitTestResults&); 229 bool handleGestureLongPress(const GestureEventWithHitTestResults&);
217 bool handleGestureLongTap(const GestureEventWithHitTestResults&); 230 bool handleGestureLongTap(const GestureEventWithHitTestResults&);
218 bool handleGestureScrollUpdate(const PlatformGestureEvent&); 231 bool handleGestureScrollUpdate(const PlatformGestureEvent&);
219 bool handleGestureScrollBegin(const PlatformGestureEvent&); 232 bool handleGestureScrollBegin(const PlatformGestureEvent&);
220 void clearGestureScrollNodes(); 233 void clearGestureScrollNodes();
221 234
222 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; 235 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const;
223 236
224 OptionalCursor selectCursor(const HitTestResult&); 237 OptionalCursor selectCursor(const HitTestResult&);
225 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); 238 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam);
226 239
227 void hoverTimerFired(Timer<EventHandler>*); 240 void hoverTimerFired(Timer<EventHandler>*);
228 void cursorUpdateTimerFired(Timer<EventHandler>*); 241 void cursorUpdateTimerFired(Timer<EventHandler>*);
229 void activeIntervalTimerFired(Timer<EventHandler>*); 242 void activeIntervalTimerFired(Timer<EventHandler>*);
230 243
244 bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
245
231 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); 246 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*);
232 void cancelFakeMouseMoveEvent(); 247 void cancelFakeMouseMoveEvent();
233 bool isCursorVisible() const; 248 bool isCursorVisible() const;
234 void updateCursor(); 249 void updateCursor();
235 250
236 ScrollableArea* associatedScrollableArea(const DeprecatedPaintLayer*) const; 251 ScrollableArea* associatedScrollableArea(const DeprecatedPaintLayer*) const;
237 252
238 // Scrolls the elements of the DOM tree. Returns true if a node was scrolled . 253 // Scrolls the elements of the DOM tree. Returns true if a node was scrolled .
239 // False if we reached the root and couldn't scroll anything. 254 // False if we reached the root and couldn't scroll anything.
240 // direction - The direction to scroll in. If this is a logical direction, i t will be 255 // 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
283 298
284 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); 299 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&);
285 300
286 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&); 301 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&);
287 void defaultSpaceEventHandler(KeyboardEvent*); 302 void defaultSpaceEventHandler(KeyboardEvent*);
288 void defaultBackspaceEventHandler(KeyboardEvent*); 303 void defaultBackspaceEventHandler(KeyboardEvent*);
289 void defaultTabEventHandler(KeyboardEvent*); 304 void defaultTabEventHandler(KeyboardEvent*);
290 void defaultEscapeEventHandler(KeyboardEvent*); 305 void defaultEscapeEventHandler(KeyboardEvent*);
291 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); 306 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*);
292 307
308 void updateSelectionForMouseDrag(const HitTestResult&);
309
293 void updateLastScrollbarUnderMouse(Scrollbar*, bool); 310 void updateLastScrollbarUnderMouse(Scrollbar*, bool);
294 311
295 void setFrameWasScrolledByUser(); 312 void setFrameWasScrolledByUser();
296 313
297 bool capturesDragging() const { return m_capturesDragging; } 314 bool capturesDragging() const { return m_capturesDragging; }
298 315
299 bool handleGestureShowPress(); 316 bool handleGestureShowPress();
300 317
301 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); 318 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&);
302 319
(...skipping 11 matching lines...) Expand all
314 331
315 // NOTE: If adding a new field to this class please ensure that it is 332 // NOTE: If adding a new field to this class please ensure that it is
316 // cleared in |EventHandler::clear()|. 333 // cleared in |EventHandler::clear()|.
317 334
318 LocalFrame* const m_frame; 335 LocalFrame* const m_frame;
319 336
320 bool m_mousePressed; 337 bool m_mousePressed;
321 bool m_capturesDragging; 338 bool m_capturesDragging;
322 RefPtrWillBeMember<Node> m_mousePressNode; 339 RefPtrWillBeMember<Node> m_mousePressNode;
323 340
341 bool m_mouseDownMayStartSelect;
324 bool m_mouseDownMayStartDrag; 342 bool m_mouseDownMayStartDrag;
325 const OwnPtrWillBeMember<SelectionController> m_selectionController; 343 bool m_mouseDownWasSingleClickInSelection;
344 enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, Extend edSelection };
345 SelectionInitiationState m_selectionInitiationState;
326 346
327 LayoutPoint m_dragStartPos; 347 LayoutPoint m_dragStartPos;
328 348
329 Timer<EventHandler> m_hoverTimer; 349 Timer<EventHandler> m_hoverTimer;
330 350
331 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide state 351 // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide state
332 // should move out of EventHandler to a new PageEventHandler class. crbug.co m/449649 352 // should move out of EventHandler to a new PageEventHandler class. crbug.co m/449649
333 Timer<EventHandler> m_cursorUpdateTimer; 353 Timer<EventHandler> m_cursorUpdateTimer;
334 354
335 bool m_mouseDownMayStartAutoscroll; 355 bool m_mouseDownMayStartAutoscroll;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // scroll sequence in this frame, or any child frames. Only used 425 // scroll sequence in this frame, or any child frames. Only used
406 // with ScrollCustomization. If some delta has been consumed, a 426 // with ScrollCustomization. If some delta has been consumed, a
407 // scroll which shouldn't propagate can't cause any element to 427 // scroll which shouldn't propagate can't cause any element to
408 // scroll other than the |m_previousGestureScrolledNode|. 428 // scroll other than the |m_previousGestureScrolledNode|.
409 bool m_deltaConsumedForScrollSequence; 429 bool m_deltaConsumedForScrollSequence;
410 }; 430 };
411 431
412 } // namespace blink 432 } // namespace blink
413 433
414 #endif // EventHandler_h 434 #endif // EventHandler_h
OLDNEW
« no previous file with comments | « Source/core/html/HTMLLabelElement.cpp ('k') | Source/core/page/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698