OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004 Apple Computer, 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 |
(...skipping 21 matching lines...) Expand all Loading... | |
32 | 32 |
33 namespace WebCore { | 33 namespace WebCore { |
34 | 34 |
35 class LayoutPoint; | 35 class LayoutPoint; |
36 class Position; | 36 class Position; |
37 | 37 |
38 const EAffinity SEL_DEFAULT_AFFINITY = DOWNSTREAM; | 38 const EAffinity SEL_DEFAULT_AFFINITY = DOWNSTREAM; |
39 enum SelectionDirection { DirectionForward, DirectionBackward, DirectionRight, D irectionLeft }; | 39 enum SelectionDirection { DirectionForward, DirectionBackward, DirectionRight, D irectionLeft }; |
40 | 40 |
41 class VisibleSelection { | 41 class VisibleSelection { |
42 DISALLOW_ALLOCATION(); | |
42 public: | 43 public: |
43 VisibleSelection(); | 44 VisibleSelection(); |
44 | 45 |
45 VisibleSelection(const Position&, EAffinity, bool isDirectional = false); | 46 VisibleSelection(const Position&, EAffinity, bool isDirectional = false); |
46 VisibleSelection(const Position&, const Position&, EAffinity = SEL_DEFAULT_A FFINITY, bool isDirectional = false); | 47 VisibleSelection(const Position&, const Position&, EAffinity = SEL_DEFAULT_A FFINITY, bool isDirectional = false); |
47 | 48 |
48 explicit VisibleSelection(const Range*, EAffinity = SEL_DEFAULT_AFFINITY, bo ol isDirectional = false); | 49 explicit VisibleSelection(const Range*, EAffinity = SEL_DEFAULT_AFFINITY, bo ol isDirectional = false); |
49 | 50 |
50 explicit VisibleSelection(const VisiblePosition&, bool isDirectional = false ); | 51 explicit VisibleSelection(const VisiblePosition&, bool isDirectional = false ); |
51 VisibleSelection(const VisiblePosition&, const VisiblePosition&, bool isDire ctional = false); | 52 VisibleSelection(const VisiblePosition&, const VisiblePosition&, bool isDire ctional = false); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 public: | 122 public: |
122 ChangeObserver(); | 123 ChangeObserver(); |
123 virtual ~ChangeObserver(); | 124 virtual ~ChangeObserver(); |
124 virtual void didChangeVisibleSelection() = 0; | 125 virtual void didChangeVisibleSelection() = 0; |
125 }; | 126 }; |
126 | 127 |
127 void setChangeObserver(ChangeObserver&); | 128 void setChangeObserver(ChangeObserver&); |
128 void clearChangeObserver(); | 129 void clearChangeObserver(); |
129 void didChange(); // Fire the change observer, if any. | 130 void didChange(); // Fire the change observer, if any. |
130 | 131 |
132 void trace(Visitor*); | |
133 | |
131 #ifndef NDEBUG | 134 #ifndef NDEBUG |
132 void debugPosition() const; | 135 void debugPosition() const; |
133 void formatForDebugger(char* buffer, unsigned length) const; | 136 void formatForDebugger(char* buffer, unsigned length) const; |
134 void showTreeForThis() const; | 137 void showTreeForThis() const; |
135 #endif | 138 #endif |
136 | 139 |
137 private: | 140 private: |
138 void validate(TextGranularity = CharacterGranularity); | 141 void validate(TextGranularity = CharacterGranularity); |
139 | 142 |
140 // Support methods for validate() | 143 // Support methods for validate() |
141 void setBaseAndExtentToDeepEquivalents(); | 144 void setBaseAndExtentToDeepEquivalents(); |
142 void setStartAndEndFromBaseAndExtentRespectingGranularity(TextGranularity); | 145 void setStartAndEndFromBaseAndExtentRespectingGranularity(TextGranularity); |
143 void adjustSelectionToAvoidCrossingShadowBoundaries(); | 146 void adjustSelectionToAvoidCrossingShadowBoundaries(); |
144 void adjustSelectionToAvoidCrossingEditingBoundaries(); | 147 void adjustSelectionToAvoidCrossingEditingBoundaries(); |
145 void updateSelectionType(); | 148 void updateSelectionType(); |
146 | 149 |
147 // We need to store these as Positions because VisibleSelection is | 150 // We need to store these as Positions because VisibleSelection is |
148 // used to store values in editing commands for use when | 151 // used to store values in editing commands for use when |
149 // undoing the command. We need to be able to create a selection that, while currently | 152 // undoing the command. We need to be able to create a selection that, while currently |
150 // invalid, will be valid once the changes are undone. | 153 // invalid, will be valid once the changes are undone. |
151 | 154 |
152 Position m_base; // Where the first click happened | 155 Position m_base; // Where the first click happened |
153 Position m_extent; // Where the end click happened | 156 Position m_extent; // Where the end click happened |
154 Position m_start; // Leftmost position when expanded to respect granularity | 157 Position m_start; // Leftmost position when expanded to respect granularity |
155 Position m_end; // Rightmost position when expanded to respect granularit y | 158 Position m_end; // Rightmost position when expanded to respect granularit y |
156 | 159 |
157 EAffinity m_affinity; // the upstream/downstream affinity of the c aret | 160 EAffinity m_affinity; // the upstream/downstream affinity of the c aret |
158 | 161 |
162 // Oilpan: this reference has a lifetime that is at least as long | |
163 // as this object. | |
159 ChangeObserver* m_changeObserver; | 164 ChangeObserver* m_changeObserver; |
haraken
2014/05/29 01:14:15
I agree that no weak processing is needed for the
sof
2014/05/29 10:03:53
Done, made ChangeObserver a GC mixin.
| |
160 | 165 |
161 // these are cached, can be recalculated by validate() | 166 // these are cached, can be recalculated by validate() |
162 SelectionType m_selectionType; // None, Caret, Range | 167 SelectionType m_selectionType; // None, Caret, Range |
163 bool m_baseIsFirst : 1; // True if base is before the extent | 168 bool m_baseIsFirst : 1; // True if base is before the extent |
164 bool m_isDirectional : 1; // Non-directional ignores m_baseIsFirst and selec tion always extends on shift + arrow key. | 169 bool m_isDirectional : 1; // Non-directional ignores m_baseIsFirst and selec tion always extends on shift + arrow key. |
165 }; | 170 }; |
166 | 171 |
167 inline bool operator==(const VisibleSelection& a, const VisibleSelection& b) | 172 inline bool operator==(const VisibleSelection& a, const VisibleSelection& b) |
168 { | 173 { |
169 return a.start() == b.start() && a.end() == b.end() && a.affinity() == b.aff inity() && a.isBaseFirst() == b.isBaseFirst() | 174 return a.start() == b.start() && a.end() == b.end() && a.affinity() == b.aff inity() && a.isBaseFirst() == b.isBaseFirst() |
170 && a.isDirectional() == b.isDirectional(); | 175 && a.isDirectional() == b.isDirectional(); |
171 } | 176 } |
172 | 177 |
173 inline bool operator!=(const VisibleSelection& a, const VisibleSelection& b) | 178 inline bool operator!=(const VisibleSelection& a, const VisibleSelection& b) |
174 { | 179 { |
175 return !(a == b); | 180 return !(a == b); |
176 } | 181 } |
177 | 182 |
178 } // namespace WebCore | 183 } // namespace WebCore |
179 | 184 |
180 #ifndef NDEBUG | 185 #ifndef NDEBUG |
181 // Outside the WebCore namespace for ease of invocation from gdb. | 186 // Outside the WebCore namespace for ease of invocation from gdb. |
182 void showTree(const WebCore::VisibleSelection&); | 187 void showTree(const WebCore::VisibleSelection&); |
183 void showTree(const WebCore::VisibleSelection*); | 188 void showTree(const WebCore::VisibleSelection*); |
184 #endif | 189 #endif |
185 | 190 |
186 #endif // VisibleSelection_h | 191 #endif // VisibleSelection_h |
OLD | NEW |