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 * Copyright (C) 2015 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 21 matching lines...) Expand all Loading... | |
32 #include "core/editing/VisibleSelection.h" | 32 #include "core/editing/VisibleSelection.h" |
33 #include "core/page/EventWithHitTestResults.h" | 33 #include "core/page/EventWithHitTestResults.h" |
34 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 class FrameSelection; | 38 class FrameSelection; |
39 class HitTestResult; | 39 class HitTestResult; |
40 class LocalFrame; | 40 class LocalFrame; |
41 | 41 |
42 class SelectionController final : public GarbageCollected<SelectionController> { | 42 class CORE_EXPORT SelectionController final |
43 : public GarbageCollectedFinalized<SelectionController> { | |
Xiaocheng
2016/10/24 03:53:11
What's the difference between GarbageCollected and
yosin_UTC9
2016/10/24 07:12:12
Member variable |m_originalBaseInFlatTree| require
| |
43 WTF_MAKE_NONCOPYABLE(SelectionController); | 44 WTF_MAKE_NONCOPYABLE(SelectionController); |
44 | 45 |
45 public: | 46 public: |
46 static SelectionController* create(LocalFrame&); | 47 static SelectionController* create(LocalFrame&); |
47 DECLARE_TRACE(); | 48 DECLARE_VIRTUAL_TRACE(); |
48 | 49 |
50 void documentDetached(); | |
49 void handleMousePressEvent(const MouseEventWithHitTestResults&); | 51 void handleMousePressEvent(const MouseEventWithHitTestResults&); |
50 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&); | 52 bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&); |
51 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&); | 53 bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&); |
52 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&); | 54 bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&); |
53 void handleMouseDraggedEvent(const MouseEventWithHitTestResults&, | 55 void handleMouseDraggedEvent(const MouseEventWithHitTestResults&, |
54 const IntPoint&, | 56 const IntPoint&, |
55 const LayoutPoint&, | 57 const LayoutPoint&, |
56 Node*, | 58 Node*, |
57 const IntPoint&); | 59 const IntPoint&); |
58 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&, | 60 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&, |
(...skipping 14 matching lines...) Expand all Loading... | |
73 void initializeSelectionState(); | 75 void initializeSelectionState(); |
74 void setMouseDownMayStartSelect(bool); | 76 void setMouseDownMayStartSelect(bool); |
75 bool mouseDownMayStartSelect() const; | 77 bool mouseDownMayStartSelect() const; |
76 bool mouseDownWasSingleClickInSelection() const; | 78 bool mouseDownWasSingleClickInSelection() const; |
77 void notifySelectionChanged(); | 79 void notifySelectionChanged(); |
78 bool hasExtendedSelection() const { | 80 bool hasExtendedSelection() const { |
79 return m_selectionState == SelectionState::ExtendedSelection; | 81 return m_selectionState == SelectionState::ExtendedSelection; |
80 } | 82 } |
81 | 83 |
82 private: | 84 private: |
85 friend class SelectionControllerTest; | |
86 | |
83 explicit SelectionController(LocalFrame&); | 87 explicit SelectionController(LocalFrame&); |
84 | 88 |
85 enum class AppendTrailingWhitespace { ShouldAppend, DontAppend }; | 89 enum class AppendTrailingWhitespace { ShouldAppend, DontAppend }; |
86 enum class SelectInputEventType { Touch, Mouse }; | 90 enum class SelectInputEventType { Touch, Mouse }; |
91 enum EndPointsAdjustmentMode { | |
92 AdjustEndpointsAtBidiBoundary, | |
93 DoNotAdjustEndpoints | |
94 }; | |
95 | |
96 Document& document() const; | |
87 | 97 |
88 void selectClosestWordFromHitTestResult(const HitTestResult&, | 98 void selectClosestWordFromHitTestResult(const HitTestResult&, |
89 AppendTrailingWhitespace, | 99 AppendTrailingWhitespace, |
90 SelectInputEventType); | 100 SelectInputEventType); |
91 void selectClosestMisspellingFromHitTestResult(const HitTestResult&, | 101 void selectClosestMisspellingFromHitTestResult(const HitTestResult&, |
92 AppendTrailingWhitespace); | 102 AppendTrailingWhitespace); |
93 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&); | 103 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&); |
94 void selectClosestMisspellingFromMouseEvent( | 104 void selectClosestMisspellingFromMouseEvent( |
95 const MouseEventWithHitTestResults&); | 105 const MouseEventWithHitTestResults&); |
96 void selectClosestWordOrLinkFromMouseEvent( | 106 void selectClosestWordOrLinkFromMouseEvent( |
97 const MouseEventWithHitTestResults&); | 107 const MouseEventWithHitTestResults&); |
108 void setNonDirectionalSelectionIfNeeded(const VisibleSelectionInFlatTree&, | |
109 TextGranularity, | |
110 EndPointsAdjustmentMode); | |
98 bool updateSelectionForMouseDownDispatchingSelectStart( | 111 bool updateSelectionForMouseDownDispatchingSelectStart( |
99 Node*, | 112 Node*, |
100 const VisibleSelectionInFlatTree&, | 113 const VisibleSelectionInFlatTree&, |
101 TextGranularity); | 114 TextGranularity); |
102 | 115 |
103 FrameSelection& selection() const; | 116 FrameSelection& selection() const; |
104 | 117 |
105 Member<LocalFrame> const m_frame; | 118 Member<LocalFrame> const m_frame; |
119 // Used to store base before the adjustment at bidi boundary | |
120 VisiblePositionInFlatTree m_originalBaseInFlatTree; | |
Xiaocheng
2016/10/24 03:53:11
It's a bad pattern to store a VP on heap, as it's
yosin_UTC9
2016/10/24 07:12:12
Done.
| |
106 bool m_mouseDownMayStartSelect; | 121 bool m_mouseDownMayStartSelect; |
107 bool m_mouseDownWasSingleClickInSelection; | 122 bool m_mouseDownWasSingleClickInSelection; |
108 bool m_mouseDownAllowsMultiClick; | 123 bool m_mouseDownAllowsMultiClick; |
109 enum class SelectionState { | 124 enum class SelectionState { |
110 HaveNotStartedSelection, | 125 HaveNotStartedSelection, |
111 PlacedCaret, | 126 PlacedCaret, |
112 ExtendedSelection | 127 ExtendedSelection |
113 }; | 128 }; |
114 SelectionState m_selectionState; | 129 SelectionState m_selectionState; |
115 }; | 130 }; |
116 | 131 |
117 bool isLinkSelection(const MouseEventWithHitTestResults&); | 132 bool isLinkSelection(const MouseEventWithHitTestResults&); |
118 bool isExtendingSelection(const MouseEventWithHitTestResults&); | 133 bool isExtendingSelection(const MouseEventWithHitTestResults&); |
119 | 134 |
120 } // namespace blink | 135 } // namespace blink |
121 | 136 |
122 #endif // SelectionController_h | 137 #endif // SelectionController_h |
OLD | NEW |