Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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(); |
| 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 Loading... | |
| 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(); | |
| 197 SelectionController& selectionController() const | |
| 198 { | |
| 199 ASSERT(m_selectionController); | |
| 200 return *m_selectionController; | |
| 201 } | |
| 200 | 202 |
| 201 private: | 203 private: |
| 202 static DragState& dragState(); | 204 static DragState& dragState(); |
| 203 | 205 |
| 204 DataTransfer* createDraggingDataTransfer() const; | 206 DataTransfer* createDraggingDataTransfer() const; |
| 205 | 207 |
| 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 ); | 208 bool handleMouseMoveOrLeaveEvent(const PlatformMouseEvent&, HitTestResult* h overedNode = nullptr, bool onlyUpdateScrollbars = false, bool forceLeave = false ); |
| 214 bool handleMousePressEvent(const MouseEventWithHitTestResults&); | 209 bool handleMousePressEvent(const MouseEventWithHitTestResults&); |
| 215 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&); | |
| 216 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&); | |
| 217 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&); | |
| 218 bool handleMouseFocus(const MouseEventWithHitTestResults&); | 210 bool handleMouseFocus(const MouseEventWithHitTestResults&); |
| 219 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&); | 211 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&); |
| 220 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&); | 212 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&); |
| 221 | 213 |
| 222 bool handlePasteGlobalSelection(const PlatformMouseEvent&); | |
| 223 | |
| 224 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::T ype); | 214 HitTestRequest::HitTestRequestType getHitTypeForGestureType(PlatformEvent::T ype); |
| 225 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); | 215 void applyTouchAdjustment(PlatformGestureEvent*, HitTestResult*); |
| 226 bool handleGestureTap(const GestureEventWithHitTestResults&); | 216 bool handleGestureTap(const GestureEventWithHitTestResults&); |
| 227 bool handleGestureLongPress(const GestureEventWithHitTestResults&); | 217 bool handleGestureLongPress(const GestureEventWithHitTestResults&); |
| 228 bool handleGestureLongTap(const GestureEventWithHitTestResults&); | 218 bool handleGestureLongTap(const GestureEventWithHitTestResults&); |
| 229 bool handleGestureScrollUpdate(const PlatformGestureEvent&); | 219 bool handleGestureScrollUpdate(const PlatformGestureEvent&); |
| 230 bool handleGestureScrollBegin(const PlatformGestureEvent&); | 220 bool handleGestureScrollBegin(const PlatformGestureEvent&); |
| 231 void clearGestureScrollNodes(); | 221 void clearGestureScrollNodes(); |
| 232 | 222 |
| 233 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; | 223 bool shouldApplyTouchAdjustment(const PlatformGestureEvent&) const; |
| 234 | 224 |
| 235 OptionalCursor selectCursor(const HitTestResult&); | 225 OptionalCursor selectCursor(const HitTestResult&); |
| 236 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); | 226 OptionalCursor selectAutoCursor(const HitTestResult&, Node*, const Cursor& i Beam); |
| 237 | 227 |
| 238 void hoverTimerFired(Timer<EventHandler>*); | 228 void hoverTimerFired(Timer<EventHandler>*); |
| 239 void cursorUpdateTimerFired(Timer<EventHandler>*); | 229 void cursorUpdateTimerFired(Timer<EventHandler>*); |
| 240 void activeIntervalTimerFired(Timer<EventHandler>*); | 230 void activeIntervalTimerFired(Timer<EventHandler>*); |
| 241 | 231 |
| 242 bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; } | |
| 243 | |
| 244 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); | 232 void fakeMouseMoveEventTimerFired(Timer<EventHandler>*); |
| 245 void cancelFakeMouseMoveEvent(); | 233 void cancelFakeMouseMoveEvent(); |
| 246 bool isCursorVisible() const; | 234 bool isCursorVisible() const; |
| 247 void updateCursor(); | 235 void updateCursor(); |
| 248 | 236 |
| 249 ScrollableArea* associatedScrollableArea(const DeprecatedPaintLayer*) const; | 237 ScrollableArea* associatedScrollableArea(const DeprecatedPaintLayer*) const; |
| 250 | 238 |
| 251 // Scrolls the elements of the DOM tree. Returns true if a node was scrolled . | 239 // 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. | 240 // 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 | 241 // 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 Loading... | |
| 296 | 284 |
| 297 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); | 285 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&); |
| 298 | 286 |
| 299 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&); | 287 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&); |
| 300 void defaultSpaceEventHandler(KeyboardEvent*); | 288 void defaultSpaceEventHandler(KeyboardEvent*); |
| 301 void defaultBackspaceEventHandler(KeyboardEvent*); | 289 void defaultBackspaceEventHandler(KeyboardEvent*); |
| 302 void defaultTabEventHandler(KeyboardEvent*); | 290 void defaultTabEventHandler(KeyboardEvent*); |
| 303 void defaultEscapeEventHandler(KeyboardEvent*); | 291 void defaultEscapeEventHandler(KeyboardEvent*); |
| 304 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); | 292 void defaultArrowEventHandler(WebFocusType, KeyboardEvent*); |
| 305 | 293 |
| 306 void updateSelectionForMouseDrag(const HitTestResult&); | |
| 307 | |
| 308 void updateLastScrollbarUnderMouse(Scrollbar*, bool); | 294 void updateLastScrollbarUnderMouse(Scrollbar*, bool); |
| 309 | 295 |
| 310 void setFrameWasScrolledByUser(); | 296 void setFrameWasScrolledByUser(); |
| 311 | 297 |
| 312 bool capturesDragging() const { return m_capturesDragging; } | 298 bool capturesDragging() const { return m_capturesDragging; } |
| 313 | 299 |
| 314 bool handleGestureShowPress(); | 300 bool handleGestureShowPress(); |
| 315 | 301 |
| 316 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); | 302 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); |
| 317 | 303 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 329 | 315 |
| 330 // NOTE: If adding a new field to this class please ensure that it is | 316 // NOTE: If adding a new field to this class please ensure that it is |
| 331 // cleared in |EventHandler::clear()|. | 317 // cleared in |EventHandler::clear()|. |
| 332 | 318 |
| 333 LocalFrame* const m_frame; | 319 LocalFrame* const m_frame; |
| 334 | 320 |
| 335 bool m_mousePressed; | 321 bool m_mousePressed; |
| 336 bool m_capturesDragging; | 322 bool m_capturesDragging; |
| 337 RefPtrWillBeMember<Node> m_mousePressNode; | 323 RefPtrWillBeMember<Node> m_mousePressNode; |
| 338 | 324 |
| 339 bool m_mouseDownMayStartSelect; | |
| 340 bool m_mouseDownMayStartDrag; | 325 bool m_mouseDownMayStartDrag; |
| 341 bool m_mouseDownWasSingleClickInSelection; | 326 OwnPtrWillBeMember<SelectionController> m_selectionController; |
|
Rick Byers
2015/05/01 13:22:09
There's a 1:1 correspondance and identical lifetim
Miyoung Shin(g)
2015/05/03 01:45:24
Oh. right. Thanks for making it simpler.
| |
| 342 enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, Extend edSelection }; | |
| 343 SelectionInitiationState m_selectionInitiationState; | |
| 344 | 327 |
| 345 LayoutPoint m_dragStartPos; | 328 LayoutPoint m_dragStartPos; |
| 346 | 329 |
| 347 Timer<EventHandler> m_hoverTimer; | 330 Timer<EventHandler> m_hoverTimer; |
| 348 Timer<EventHandler> m_cursorUpdateTimer; | 331 Timer<EventHandler> m_cursorUpdateTimer; |
| 349 | 332 |
| 350 bool m_mouseDownMayStartAutoscroll; | 333 bool m_mouseDownMayStartAutoscroll; |
| 351 | 334 |
| 352 Timer<EventHandler> m_fakeMouseMoveEventTimer; | 335 Timer<EventHandler> m_fakeMouseMoveEventTimer; |
| 353 | 336 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 // scroll sequence in this frame, or any child frames. Only used | 403 // scroll sequence in this frame, or any child frames. Only used |
| 421 // with ScrollCustomization. If some delta has been consumed, a | 404 // with ScrollCustomization. If some delta has been consumed, a |
| 422 // scroll which shouldn't propagate can't cause any element to | 405 // scroll which shouldn't propagate can't cause any element to |
| 423 // scroll other than the |m_previousGestureScrolledNode|. | 406 // scroll other than the |m_previousGestureScrolledNode|. |
| 424 bool m_deltaConsumedForScrollSequence; | 407 bool m_deltaConsumedForScrollSequence; |
| 425 }; | 408 }; |
| 426 | 409 |
| 427 } // namespace blink | 410 } // namespace blink |
| 428 | 411 |
| 429 #endif // EventHandler_h | 412 #endif // EventHandler_h |
| OLD | NEW |