| 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 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 3 * | 4 * |
| 4 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 6 * are met: | 7 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 12 * | 13 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (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 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 25 */ |
| 25 | 26 |
| 26 #ifndef AutoscrollController_h | 27 #ifndef SelectionController_h |
| 27 #define AutoscrollController_h | 28 #define SelectionController_h |
| 28 | 29 |
| 29 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
| 30 #include "platform/geometry/IntPoint.h" | 31 #include "core/editing/TextGranularity.h" |
| 31 #include "wtf/PassOwnPtr.h" | 32 #include "core/page/EventWithHitTestResults.h" |
| 33 #include "platform/heap/Handle.h" |
| 32 | 34 |
| 33 namespace blink { | 35 namespace blink { |
| 34 | 36 |
| 37 class FrameSelection; |
| 38 class HitTestResult; |
| 35 class LocalFrame; | 39 class LocalFrame; |
| 36 class FrameView; | 40 class VisibleSelection; |
| 37 class Node; | |
| 38 class Page; | |
| 39 class PlatformMouseEvent; | |
| 40 class LayoutBox; | |
| 41 class LayoutObject; | |
| 42 | 41 |
| 43 enum AutoscrollType { | 42 class SelectionController final : public NoBaseWillBeGarbageCollected<SelectionC
ontroller> { |
| 44 NoAutoscroll, | 43 WTF_MAKE_NONCOPYABLE(SelectionController); |
| 45 AutoscrollForDragAndDrop, | 44 public: |
| 46 AutoscrollForSelection, | 45 static PassOwnPtrWillBeRawPtr<SelectionController> create(LocalFrame&); |
| 47 #if OS(WIN) | 46 DECLARE_TRACE(); |
| 48 AutoscrollForPanCanStop, | |
| 49 AutoscrollForPan, | |
| 50 #endif | |
| 51 }; | |
| 52 | 47 |
| 53 // AutscrollController handels autoscroll and pan scroll for EventHandler. | 48 bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleS
election&, TextGranularity); |
| 54 class CORE_EXPORT AutoscrollController { | 49 void handleMousePressEvent(const MouseEventWithHitTestResults&); |
| 55 public: | 50 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&); |
| 56 static PassOwnPtr<AutoscrollController> create(Page&); | 51 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&); |
| 52 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&); |
| 53 void handleMouseDraggedEvent(const MouseEventWithHitTestResults&, const IntP
oint&, const LayoutPoint&, Node*, const IntPoint&); |
| 54 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&, const Layo
utPoint&); |
| 55 bool handlePasteGlobalSelection(const PlatformMouseEvent&); |
| 56 bool handleGestureLongPress(const PlatformGestureEvent&, const HitTestResult
&); |
| 57 | 57 |
| 58 void animate(double monotonicFrameBeginTime); | 58 void updateSelectionForMouseDrag(Node*, const LayoutPoint&, const IntPoint&)
; |
| 59 bool autoscrollInProgress() const; | 59 void updateSelectionForMouseDrag(const HitTestResult&, Node*, const LayoutPo
int&, const IntPoint&); |
| 60 bool autoscrollInProgress(const LayoutBox*) const; | 60 void prepareForContextMenu(const MouseEventWithHitTestResults&, const Layout
Point&); |
| 61 bool panScrollInProgress() const; | 61 void preparePassMousePressEventToSubframe(MouseEventWithHitTestResults&); |
| 62 void startAutoscrollForSelection(LayoutObject*); | 62 |
| 63 void stopAutoscroll(); | 63 void initializeSelectionState(); |
| 64 void stopAutoscrollIfNeeded(LayoutObject*); | 64 void setMouseDownMayStartSelect(bool); |
| 65 void updateAutoscrollLayoutObject(); | 65 bool mouseDownMayStartSelect() const; |
| 66 void updateDragAndDrop(Node* targetNode, const IntPoint& eventPosition, doub
le eventTime); | 66 bool mouseDownWasSingleClickInSelection() const; |
| 67 #if OS(WIN) | |
| 68 void handleMouseReleaseForPanScrolling(LocalFrame*, const PlatformMouseEvent
&); | |
| 69 void startPanScrolling(LayoutBox*, const IntPoint&); | |
| 70 #endif | |
| 71 | 67 |
| 72 private: | 68 private: |
| 73 explicit AutoscrollController(Page&); | 69 explicit SelectionController(LocalFrame&); |
| 74 | 70 |
| 75 void startAutoscroll(); | 71 enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTr
ailingWhitespace }; |
| 72 void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailing
Whitespace); |
| 73 void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendT
railingWhitespace); |
| 74 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&); |
| 75 void selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResul
ts&); |
| 76 void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResult
s&); |
| 76 | 77 |
| 77 #if OS(WIN) | |
| 78 void updatePanScrollState(FrameView*, const IntPoint& lastKnownMousePosition
); | |
| 79 #endif | |
| 80 | 78 |
| 81 Page& m_page; | 79 RawPtrWillBeMember<LocalFrame> const m_frame; |
| 82 LayoutBox* m_autoscrollLayoutObject; | 80 bool m_mouseDownMayStartSelect; |
| 83 AutoscrollType m_autoscrollType; | 81 bool m_mouseDownWasSingleClickInSelection; |
| 84 IntPoint m_dragAndDropAutoscrollReferencePosition; | 82 enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, Extend
edSelection }; |
| 85 double m_dragAndDropAutoscrollStartTime; | 83 SelectionInitiationState m_selectionInitiationState; |
| 86 #if OS(WIN) | |
| 87 IntPoint m_panScrollStartPos; | |
| 88 #endif | |
| 89 }; | 84 }; |
| 90 | 85 |
| 91 } // namespace blink | 86 } // namespace blink |
| 92 | 87 #endif // SelectionController_h |
| 93 #endif // AutoscrollController_h | |
| OLD | NEW |