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

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleSelection.cpp

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try running even rebaseline tests Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006 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 30 matching lines...) Expand all
41 41
42 namespace blink { 42 namespace blink {
43 43
44 template <typename Strategy> 44 template <typename Strategy>
45 VisibleSelectionTemplate<Strategy>::VisibleSelectionTemplate() 45 VisibleSelectionTemplate<Strategy>::VisibleSelectionTemplate()
46 : m_affinity(TextAffinity::Downstream), 46 : m_affinity(TextAffinity::Downstream),
47 m_selectionType(NoSelection), 47 m_selectionType(NoSelection),
48 m_baseIsFirst(true), 48 m_baseIsFirst(true),
49 m_isDirectional(false), 49 m_isDirectional(false),
50 m_granularity(CharacterGranularity), 50 m_granularity(CharacterGranularity),
51 m_hasTrailingWhitespace(false) {} 51 m_hasTrailingWhitespace(false),
52 m_isHandleVisible(false) {}
52 53
53 template <typename Strategy> 54 template <typename Strategy>
54 VisibleSelectionTemplate<Strategy>::VisibleSelectionTemplate( 55 VisibleSelectionTemplate<Strategy>::VisibleSelectionTemplate(
55 const PositionTemplate<Strategy>& base, 56 const PositionTemplate<Strategy>& base,
56 const PositionTemplate<Strategy>& extent, 57 const PositionTemplate<Strategy>& extent,
57 TextAffinity affinity, 58 TextAffinity affinity,
58 bool isDirectional) 59 bool isDirectional,
60 bool isHandleVisible)
59 : m_base(base), 61 : m_base(base),
60 m_extent(extent), 62 m_extent(extent),
61 m_affinity(affinity), 63 m_affinity(affinity),
62 m_isDirectional(isDirectional), 64 m_isDirectional(isDirectional),
63 m_granularity(CharacterGranularity), 65 m_granularity(CharacterGranularity),
64 m_hasTrailingWhitespace(false) { 66 m_hasTrailingWhitespace(false),
67 m_isHandleVisible(isHandleVisible) {
65 validate(); 68 validate();
66 } 69 }
67 70
68 template <typename Strategy> 71 template <typename Strategy>
69 VisibleSelectionTemplate<Strategy> VisibleSelectionTemplate<Strategy>::create( 72 VisibleSelectionTemplate<Strategy> VisibleSelectionTemplate<Strategy>::create(
70 const PositionTemplate<Strategy>& base, 73 const PositionTemplate<Strategy>& base,
71 const PositionTemplate<Strategy>& extent, 74 const PositionTemplate<Strategy>& extent,
72 TextAffinity affinity, 75 TextAffinity affinity,
73 bool isDirectional) { 76 bool isDirectional,
74 return VisibleSelectionTemplate(base, extent, affinity, isDirectional); 77 bool isHandleVisible) {
78 return VisibleSelectionTemplate(base, extent, affinity, isDirectional,
79 isHandleVisible);
75 } 80 }
76 81
77 VisibleSelection createVisibleSelectionDeprecated(const Position& pos, 82 VisibleSelection createVisibleSelectionDeprecated(const Position& pos,
78 TextAffinity affinity, 83 TextAffinity affinity,
79 bool isDirectional) { 84 bool isDirectional,
85 bool isHandleVisible) {
80 if (pos.isNotNull()) 86 if (pos.isNotNull())
81 pos.document()->updateStyleAndLayoutIgnorePendingStylesheets(); 87 pos.document()->updateStyleAndLayoutIgnorePendingStylesheets();
82 return VisibleSelection::create(pos, pos, affinity, isDirectional); 88 return VisibleSelection::create(pos, pos, affinity, isDirectional,
89 isHandleVisible);
83 } 90 }
84 91
85 VisibleSelection createVisibleSelectionDeprecated(const Position& base, 92 VisibleSelection createVisibleSelectionDeprecated(const Position& base,
86 const Position& extent, 93 const Position& extent,
87 TextAffinity affinity, 94 TextAffinity affinity,
88 bool isDirectional) { 95 bool isDirectional,
96 bool isHandleVisible) {
89 if (base.isNotNull()) 97 if (base.isNotNull())
90 base.document()->updateStyleAndLayoutIgnorePendingStylesheets(); 98 base.document()->updateStyleAndLayoutIgnorePendingStylesheets();
91 if (extent.isNotNull()) 99 if (extent.isNotNull())
92 extent.document()->updateStyleAndLayoutIgnorePendingStylesheets(); 100 extent.document()->updateStyleAndLayoutIgnorePendingStylesheets();
93 return VisibleSelection::create(base, extent, affinity, isDirectional); 101 return VisibleSelection::create(base, extent, affinity, isDirectional,
102 isHandleVisible);
94 } 103 }
95 104
96 VisibleSelection createVisibleSelectionDeprecated( 105 VisibleSelection createVisibleSelectionDeprecated(
97 const PositionWithAffinity& pos, 106 const PositionWithAffinity& pos,
98 bool isDirectional) { 107 bool isDirectional,
108 bool isHandleVisible) {
99 if (pos.isNotNull()) 109 if (pos.isNotNull())
100 pos.position().document()->updateStyleAndLayoutIgnorePendingStylesheets(); 110 pos.position().document()->updateStyleAndLayoutIgnorePendingStylesheets();
101 return VisibleSelection::create(pos.position(), pos.position(), 111 return VisibleSelection::create(pos.position(), pos.position(),
102 pos.affinity(), isDirectional); 112 pos.affinity(), isDirectional,
113 isHandleVisible);
103 } 114 }
104 115
105 VisibleSelection createVisibleSelectionDeprecated(const VisiblePosition& pos, 116 VisibleSelection createVisibleSelectionDeprecated(const VisiblePosition& pos,
106 bool isDirectional) { 117 bool isDirectional,
118 bool isHandleVisible) {
107 if (pos.isNotNull()) 119 if (pos.isNotNull())
108 pos.deepEquivalent() 120 pos.deepEquivalent()
109 .document() 121 .document()
110 ->updateStyleAndLayoutIgnorePendingStylesheets(); 122 ->updateStyleAndLayoutIgnorePendingStylesheets();
111 return VisibleSelection::create(pos.deepEquivalent(), pos.deepEquivalent(), 123 return VisibleSelection::create(pos.deepEquivalent(), pos.deepEquivalent(),
112 pos.affinity(), isDirectional); 124 pos.affinity(), isDirectional,
125 isHandleVisible);
113 } 126 }
114 127
115 VisibleSelection createVisibleSelectionDeprecated(const VisiblePosition& base, 128 VisibleSelection createVisibleSelectionDeprecated(const VisiblePosition& base,
116 const VisiblePosition& extent, 129 const VisiblePosition& extent,
117 bool isDirectional) { 130 bool isDirectional,
131 bool isHandleVisible) {
118 if (base.isNotNull()) 132 if (base.isNotNull())
119 base.deepEquivalent() 133 base.deepEquivalent()
120 .document() 134 .document()
121 ->updateStyleAndLayoutIgnorePendingStylesheets(); 135 ->updateStyleAndLayoutIgnorePendingStylesheets();
122 if (extent.isNotNull()) 136 if (extent.isNotNull())
123 extent.deepEquivalent() 137 extent.deepEquivalent()
124 .document() 138 .document()
125 ->updateStyleAndLayoutIgnorePendingStylesheets(); 139 ->updateStyleAndLayoutIgnorePendingStylesheets();
126 return VisibleSelection::create(base.deepEquivalent(), 140 return VisibleSelection::create(base.deepEquivalent(),
127 extent.deepEquivalent(), base.affinity(), 141 extent.deepEquivalent(), base.affinity(),
128 isDirectional); 142 isDirectional, isHandleVisible);
129 } 143 }
130 144
131 VisibleSelection createVisibleSelectionDeprecated(const EphemeralRange& range, 145 VisibleSelection createVisibleSelectionDeprecated(const EphemeralRange& range,
132 TextAffinity affinity, 146 TextAffinity affinity,
133 bool isDirectional) { 147 bool isDirectional,
148 bool isHandleVisible) {
134 if (range.isNotNull()) 149 if (range.isNotNull())
135 range.startPosition() 150 range.startPosition()
136 .document() 151 .document()
137 ->updateStyleAndLayoutIgnorePendingStylesheets(); 152 ->updateStyleAndLayoutIgnorePendingStylesheets();
138 return VisibleSelection::create(range.startPosition(), range.endPosition(), 153 return VisibleSelection::create(range.startPosition(), range.endPosition(),
139 affinity, isDirectional); 154 affinity, isDirectional, isHandleVisible);
140 } 155 }
141 156
142 VisibleSelectionInFlatTree createVisibleSelectionDeprecated( 157 VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
143 const PositionInFlatTree& pos, 158 const PositionInFlatTree& pos,
144 TextAffinity affinity, 159 TextAffinity affinity,
145 bool isDirectional) { 160 bool isDirectional,
161 bool isHandleVisible) {
146 if (pos.isNotNull()) 162 if (pos.isNotNull())
147 pos.document()->updateStyleAndLayoutIgnorePendingStylesheets(); 163 pos.document()->updateStyleAndLayoutIgnorePendingStylesheets();
148 return VisibleSelectionInFlatTree::create(pos, pos, affinity, isDirectional); 164 return VisibleSelectionInFlatTree::create(pos, pos, affinity, isDirectional,
165 isHandleVisible);
149 } 166 }
150 167
151 VisibleSelectionInFlatTree createVisibleSelectionDeprecated( 168 VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
152 const PositionInFlatTree& base, 169 const PositionInFlatTree& base,
153 const PositionInFlatTree& extent, 170 const PositionInFlatTree& extent,
154 TextAffinity affinity, 171 TextAffinity affinity,
155 bool isDirectional) { 172 bool isDirectional,
173 bool isHandleVisible) {
156 if (base.isNotNull()) 174 if (base.isNotNull())
157 base.document()->updateStyleAndLayoutIgnorePendingStylesheets(); 175 base.document()->updateStyleAndLayoutIgnorePendingStylesheets();
158 if (extent.isNotNull()) 176 if (extent.isNotNull())
159 extent.document()->updateStyleAndLayoutIgnorePendingStylesheets(); 177 extent.document()->updateStyleAndLayoutIgnorePendingStylesheets();
160 return VisibleSelectionInFlatTree::create(base, extent, affinity, 178 return VisibleSelectionInFlatTree::create(base, extent, affinity,
161 isDirectional); 179 isDirectional, isHandleVisible);
162 } 180 }
163 181
164 VisibleSelectionInFlatTree createVisibleSelectionDeprecated( 182 VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
165 const PositionInFlatTreeWithAffinity& pos, 183 const PositionInFlatTreeWithAffinity& pos,
166 bool isDirectional) { 184 bool isDirectional,
185 bool isHandleVisible) {
167 if (pos.isNotNull()) 186 if (pos.isNotNull())
168 pos.position().document()->updateStyleAndLayoutIgnorePendingStylesheets(); 187 pos.position().document()->updateStyleAndLayoutIgnorePendingStylesheets();
169 return VisibleSelectionInFlatTree::create(pos.position(), pos.position(), 188 return VisibleSelectionInFlatTree::create(pos.position(), pos.position(),
170 pos.affinity(), isDirectional); 189 pos.affinity(), isDirectional,
190 isHandleVisible);
171 } 191 }
172 192
173 VisibleSelectionInFlatTree createVisibleSelectionDeprecated( 193 VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
174 const VisiblePositionInFlatTree& pos, 194 const VisiblePositionInFlatTree& pos,
175 bool isDirectional) { 195 bool isDirectional,
196 bool isHandleVisible) {
176 if (pos.isNotNull()) 197 if (pos.isNotNull())
177 pos.deepEquivalent() 198 pos.deepEquivalent()
178 .document() 199 .document()
179 ->updateStyleAndLayoutIgnorePendingStylesheets(); 200 ->updateStyleAndLayoutIgnorePendingStylesheets();
180 return VisibleSelectionInFlatTree::create(pos.deepEquivalent(), 201 return VisibleSelectionInFlatTree::create(
181 pos.deepEquivalent(), 202 pos.deepEquivalent(), pos.deepEquivalent(), pos.affinity(), isDirectional,
182 pos.affinity(), isDirectional); 203 isHandleVisible);
183 } 204 }
184 205
185 VisibleSelectionInFlatTree createVisibleSelectionDeprecated( 206 VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
186 const VisiblePositionInFlatTree& base, 207 const VisiblePositionInFlatTree& base,
187 const VisiblePositionInFlatTree& extent, 208 const VisiblePositionInFlatTree& extent,
188 bool isDirectional) { 209 bool isDirectional,
210 bool isHandleVisible) {
189 if (base.isNotNull()) 211 if (base.isNotNull())
190 base.deepEquivalent() 212 base.deepEquivalent()
191 .document() 213 .document()
192 ->updateStyleAndLayoutIgnorePendingStylesheets(); 214 ->updateStyleAndLayoutIgnorePendingStylesheets();
193 if (extent.isNotNull()) 215 if (extent.isNotNull())
194 extent.deepEquivalent() 216 extent.deepEquivalent()
195 .document() 217 .document()
196 ->updateStyleAndLayoutIgnorePendingStylesheets(); 218 ->updateStyleAndLayoutIgnorePendingStylesheets();
197 return VisibleSelectionInFlatTree::create(base.deepEquivalent(), 219 return VisibleSelectionInFlatTree::create(
198 extent.deepEquivalent(), 220 base.deepEquivalent(), extent.deepEquivalent(), base.affinity(),
199 base.affinity(), isDirectional); 221 isDirectional, isHandleVisible);
200 } 222 }
201 223
202 VisibleSelectionInFlatTree createVisibleSelectionDeprecated( 224 VisibleSelectionInFlatTree createVisibleSelectionDeprecated(
203 const EphemeralRangeInFlatTree& range, 225 const EphemeralRangeInFlatTree& range,
204 TextAffinity affinity, 226 TextAffinity affinity,
205 bool isDirectional) { 227 bool isDirectional,
228 bool isHandleVisible) {
206 if (range.isNotNull()) 229 if (range.isNotNull())
207 range.startPosition() 230 range.startPosition()
208 .document() 231 .document()
209 ->updateStyleAndLayoutIgnorePendingStylesheets(); 232 ->updateStyleAndLayoutIgnorePendingStylesheets();
210 return VisibleSelectionInFlatTree::create( 233 return VisibleSelectionInFlatTree::create(range.startPosition(),
211 range.startPosition(), range.endPosition(), affinity, isDirectional); 234 range.endPosition(), affinity,
235 isDirectional, isHandleVisible);
212 } 236 }
213 237
214 VisibleSelection createVisibleSelection(const Position& pos, 238 VisibleSelection createVisibleSelection(const Position& pos,
215 TextAffinity affinity, 239 TextAffinity affinity,
216 bool isDirectional) { 240 bool isDirectional,
241 bool isHandleVisible) {
217 DCHECK(!needsLayoutTreeUpdate(pos)); 242 DCHECK(!needsLayoutTreeUpdate(pos));
218 return VisibleSelection::create(pos, pos, affinity, isDirectional); 243 return VisibleSelection::create(pos, pos, affinity, isDirectional,
244 isHandleVisible);
219 } 245 }
220 246
221 VisibleSelection createVisibleSelection(const Position& base, 247 VisibleSelection createVisibleSelection(const Position& base,
222 const Position& extent, 248 const Position& extent,
223 TextAffinity affinity, 249 TextAffinity affinity,
224 bool isDirectional) { 250 bool isDirectional,
251 bool isHandleVisible) {
225 DCHECK(!needsLayoutTreeUpdate(base)); 252 DCHECK(!needsLayoutTreeUpdate(base));
226 DCHECK(!needsLayoutTreeUpdate(extent)); 253 DCHECK(!needsLayoutTreeUpdate(extent));
227 // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()| 254 // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()|
228 // after all call sites have ensured that. 255 // after all call sites have ensured that.
229 return VisibleSelection::create(base, extent, affinity, isDirectional); 256 return VisibleSelection::create(base, extent, affinity, isDirectional,
257 isHandleVisible);
230 } 258 }
231 259
232 VisibleSelection createVisibleSelection(const PositionWithAffinity& pos, 260 VisibleSelection createVisibleSelection(const PositionWithAffinity& pos,
233 bool isDirectional) { 261 bool isDirectional,
262 bool isHandleVisible) {
234 DCHECK(!needsLayoutTreeUpdate(pos.position())); 263 DCHECK(!needsLayoutTreeUpdate(pos.position()));
235 return VisibleSelection::create(pos.position(), pos.position(), 264 return VisibleSelection::create(pos.position(), pos.position(),
236 pos.affinity(), isDirectional); 265 pos.affinity(), isDirectional,
266 isHandleVisible);
237 } 267 }
238 268
239 VisibleSelection createVisibleSelection(const VisiblePosition& pos, 269 VisibleSelection createVisibleSelection(const VisiblePosition& pos,
240 bool isDirectional) { 270 bool isDirectional,
271 bool isHandleVisible) {
241 DCHECK(pos.isValid()); 272 DCHECK(pos.isValid());
242 return VisibleSelection::create(pos.deepEquivalent(), pos.deepEquivalent(), 273 return VisibleSelection::create(pos.deepEquivalent(), pos.deepEquivalent(),
243 pos.affinity(), isDirectional); 274 pos.affinity(), isDirectional,
275 isHandleVisible);
244 } 276 }
245 277
246 VisibleSelection createVisibleSelection(const VisiblePosition& base, 278 VisibleSelection createVisibleSelection(const VisiblePosition& base,
247 const VisiblePosition& extent, 279 const VisiblePosition& extent,
248 bool isDirectional) { 280 bool isDirectional,
281 bool isHandleVisible) {
249 DCHECK(base.isValid()); 282 DCHECK(base.isValid());
250 DCHECK(extent.isValid()); 283 DCHECK(extent.isValid());
251 // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()| 284 // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()|
252 // after all call sites have ensured that. 285 // after all call sites have ensured that.
253 return VisibleSelection::create(base.deepEquivalent(), 286 return VisibleSelection::create(base.deepEquivalent(),
254 extent.deepEquivalent(), base.affinity(), 287 extent.deepEquivalent(), base.affinity(),
255 isDirectional); 288 isDirectional, isHandleVisible);
256 } 289 }
257 290
258 VisibleSelection createVisibleSelection(const EphemeralRange& range, 291 VisibleSelection createVisibleSelection(const EphemeralRange& range,
259 TextAffinity affinity, 292 TextAffinity affinity,
260 bool isDirectional) { 293 bool isDirectional,
294 bool isHandleVisible) {
261 DCHECK(!needsLayoutTreeUpdate(range.startPosition())); 295 DCHECK(!needsLayoutTreeUpdate(range.startPosition()));
262 DCHECK(!needsLayoutTreeUpdate(range.endPosition())); 296 DCHECK(!needsLayoutTreeUpdate(range.endPosition()));
263 return VisibleSelection::create(range.startPosition(), range.endPosition(), 297 return VisibleSelection::create(range.startPosition(), range.endPosition(),
264 affinity, isDirectional); 298 affinity, isDirectional, isHandleVisible);
265 } 299 }
266 300
267 VisibleSelectionInFlatTree createVisibleSelection(const PositionInFlatTree& pos, 301 VisibleSelectionInFlatTree createVisibleSelection(const PositionInFlatTree& pos,
268 TextAffinity affinity, 302 TextAffinity affinity,
269 bool isDirectional) { 303 bool isDirectional,
304 bool isHandleVisible) {
270 DCHECK(!needsLayoutTreeUpdate(pos)); 305 DCHECK(!needsLayoutTreeUpdate(pos));
271 return VisibleSelectionInFlatTree::create(pos, pos, affinity, isDirectional); 306 return VisibleSelectionInFlatTree::create(pos, pos, affinity, isDirectional,
307 isHandleVisible);
272 } 308 }
273 309
274 VisibleSelectionInFlatTree createVisibleSelection( 310 VisibleSelectionInFlatTree createVisibleSelection(
275 const PositionInFlatTree& base, 311 const PositionInFlatTree& base,
276 const PositionInFlatTree& extent, 312 const PositionInFlatTree& extent,
277 TextAffinity affinity, 313 TextAffinity affinity,
278 bool isDirectional) { 314 bool isDirectional,
315 bool isHandleVisible) {
279 DCHECK(!needsLayoutTreeUpdate(base)); 316 DCHECK(!needsLayoutTreeUpdate(base));
280 DCHECK(!needsLayoutTreeUpdate(extent)); 317 DCHECK(!needsLayoutTreeUpdate(extent));
281 // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()| 318 // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()|
282 // after all call sites have ensured that. 319 // after all call sites have ensured that.
283 return VisibleSelectionInFlatTree::create(base, extent, affinity, 320 return VisibleSelectionInFlatTree::create(base, extent, affinity,
284 isDirectional); 321 isDirectional, isHandleVisible);
285 } 322 }
286 323
287 VisibleSelectionInFlatTree createVisibleSelection( 324 VisibleSelectionInFlatTree createVisibleSelection(
288 const PositionInFlatTreeWithAffinity& pos, 325 const PositionInFlatTreeWithAffinity& pos,
289 bool isDirectional) { 326 bool isDirectional,
327 bool isHandleVisible) {
290 DCHECK(!needsLayoutTreeUpdate(pos.position())); 328 DCHECK(!needsLayoutTreeUpdate(pos.position()));
291 return VisibleSelectionInFlatTree::create(pos.position(), pos.position(), 329 return VisibleSelectionInFlatTree::create(pos.position(), pos.position(),
292 pos.affinity(), isDirectional); 330 pos.affinity(), isDirectional,
331 isHandleVisible);
293 } 332 }
294 333
295 VisibleSelectionInFlatTree createVisibleSelection( 334 VisibleSelectionInFlatTree createVisibleSelection(
296 const VisiblePositionInFlatTree& pos, 335 const VisiblePositionInFlatTree& pos,
297 bool isDirectional) { 336 bool isDirectional,
337 bool isHandleVisible) {
298 DCHECK(pos.isValid()); 338 DCHECK(pos.isValid());
299 return VisibleSelectionInFlatTree::create(pos.deepEquivalent(), 339 return VisibleSelectionInFlatTree::create(
300 pos.deepEquivalent(), 340 pos.deepEquivalent(), pos.deepEquivalent(), pos.affinity(), isDirectional,
301 pos.affinity(), isDirectional); 341 isHandleVisible);
302 } 342 }
303 343
304 VisibleSelectionInFlatTree createVisibleSelection( 344 VisibleSelectionInFlatTree createVisibleSelection(
305 const VisiblePositionInFlatTree& base, 345 const VisiblePositionInFlatTree& base,
306 const VisiblePositionInFlatTree& extent, 346 const VisiblePositionInFlatTree& extent,
307 bool isDirectional) { 347 bool isDirectional,
348 bool isHandleVisible) {
308 DCHECK(base.isValid()); 349 DCHECK(base.isValid());
309 DCHECK(extent.isValid()); 350 DCHECK(extent.isValid());
310 // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()| 351 // TODO(xiaochengh): We should check |base.isNotNull() || extent.isNull()|
311 // after all call sites have ensured that. 352 // after all call sites have ensured that.
312 return VisibleSelectionInFlatTree::create(base.deepEquivalent(), 353 return VisibleSelectionInFlatTree::create(
313 extent.deepEquivalent(), 354 base.deepEquivalent(), extent.deepEquivalent(), base.affinity(),
314 base.affinity(), isDirectional); 355 isDirectional, isHandleVisible);
315 } 356 }
316 357
317 VisibleSelectionInFlatTree createVisibleSelection( 358 VisibleSelectionInFlatTree createVisibleSelection(
318 const EphemeralRangeInFlatTree& range, 359 const EphemeralRangeInFlatTree& range,
319 TextAffinity affinity, 360 TextAffinity affinity,
320 bool isDirectional) { 361 bool isDirectional,
362 bool isHandleVisible) {
321 DCHECK(!needsLayoutTreeUpdate(range.startPosition())); 363 DCHECK(!needsLayoutTreeUpdate(range.startPosition()));
322 DCHECK(!needsLayoutTreeUpdate(range.endPosition())); 364 DCHECK(!needsLayoutTreeUpdate(range.endPosition()));
323 return VisibleSelectionInFlatTree::create( 365 return VisibleSelectionInFlatTree::create(range.startPosition(),
324 range.startPosition(), range.endPosition(), affinity, isDirectional); 366 range.endPosition(), affinity,
367 isDirectional, isHandleVisible);
325 } 368 }
326 369
327 template <typename Strategy> 370 template <typename Strategy>
328 static SelectionType computeSelectionType( 371 static SelectionType computeSelectionType(
329 const PositionTemplate<Strategy>& start, 372 const PositionTemplate<Strategy>& start,
330 const PositionTemplate<Strategy>& end) { 373 const PositionTemplate<Strategy>& end) {
331 if (start.isNull()) { 374 if (start.isNull()) {
332 DCHECK(end.isNull()); 375 DCHECK(end.isNull());
333 return NoSelection; 376 return NoSelection;
334 } 377 }
(...skipping 14 matching lines...) Expand all
349 const VisibleSelectionTemplate<Strategy>& other) 392 const VisibleSelectionTemplate<Strategy>& other)
350 : m_base(other.m_base), 393 : m_base(other.m_base),
351 m_extent(other.m_extent), 394 m_extent(other.m_extent),
352 m_start(other.m_start), 395 m_start(other.m_start),
353 m_end(other.m_end), 396 m_end(other.m_end),
354 m_affinity(other.m_affinity), 397 m_affinity(other.m_affinity),
355 m_selectionType(other.m_selectionType), 398 m_selectionType(other.m_selectionType),
356 m_baseIsFirst(other.m_baseIsFirst), 399 m_baseIsFirst(other.m_baseIsFirst),
357 m_isDirectional(other.m_isDirectional), 400 m_isDirectional(other.m_isDirectional),
358 m_granularity(other.m_granularity), 401 m_granularity(other.m_granularity),
359 m_hasTrailingWhitespace(other.m_hasTrailingWhitespace) {} 402 m_hasTrailingWhitespace(other.m_hasTrailingWhitespace),
403 m_isHandleVisible(other.m_isHandleVisible) {}
360 404
361 template <typename Strategy> 405 template <typename Strategy>
362 VisibleSelectionTemplate<Strategy>& VisibleSelectionTemplate<Strategy>:: 406 VisibleSelectionTemplate<Strategy>& VisibleSelectionTemplate<Strategy>::
363 operator=(const VisibleSelectionTemplate<Strategy>& other) { 407 operator=(const VisibleSelectionTemplate<Strategy>& other) {
364 m_base = other.m_base; 408 m_base = other.m_base;
365 m_extent = other.m_extent; 409 m_extent = other.m_extent;
366 m_start = other.m_start; 410 m_start = other.m_start;
367 m_end = other.m_end; 411 m_end = other.m_end;
368 m_affinity = other.m_affinity; 412 m_affinity = other.m_affinity;
369 m_selectionType = other.m_selectionType; 413 m_selectionType = other.m_selectionType;
370 m_baseIsFirst = other.m_baseIsFirst; 414 m_baseIsFirst = other.m_baseIsFirst;
371 m_isDirectional = other.m_isDirectional; 415 m_isDirectional = other.m_isDirectional;
372 m_granularity = other.m_granularity; 416 m_granularity = other.m_granularity;
373 m_hasTrailingWhitespace = other.m_hasTrailingWhitespace; 417 m_hasTrailingWhitespace = other.m_hasTrailingWhitespace;
418 m_isHandleVisible = other.m_isHandleVisible;
374 return *this; 419 return *this;
375 } 420 }
376 421
377 template <typename Strategy> 422 template <typename Strategy>
378 VisibleSelectionTemplate<Strategy> 423 VisibleSelectionTemplate<Strategy>
379 VisibleSelectionTemplate<Strategy>::selectionFromContentsOfNode(Node* node) { 424 VisibleSelectionTemplate<Strategy>::selectionFromContentsOfNode(Node* node) {
380 DCHECK(!Strategy::editingIgnoresContent(node)); 425 DCHECK(!Strategy::editingIgnoresContent(node));
381 426
382 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 427 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
383 // needs to be audited. see http://crbug.com/590369 for more details. 428 // needs to be audited. see http://crbug.com/590369 for more details.
384 node->document().updateStyleAndLayoutIgnorePendingStylesheets(); 429 node->document().updateStyleAndLayoutIgnorePendingStylesheets();
385 430
386 return VisibleSelectionTemplate::create( 431 return VisibleSelectionTemplate::create(
387 PositionTemplate<Strategy>::firstPositionInNode(node), 432 PositionTemplate<Strategy>::firstPositionInNode(node),
388 PositionTemplate<Strategy>::lastPositionInNode(node), SelDefaultAffinity, 433 PositionTemplate<Strategy>::lastPositionInNode(node), SelDefaultAffinity,
389 false); 434 false, false);
390 } 435 }
391 436
392 template <typename Strategy> 437 template <typename Strategy>
393 void VisibleSelectionTemplate<Strategy>::setBase( 438 void VisibleSelectionTemplate<Strategy>::setBase(
394 const PositionTemplate<Strategy>& position) { 439 const PositionTemplate<Strategy>& position) {
395 DCHECK(!needsLayoutTreeUpdate(position)); 440 DCHECK(!needsLayoutTreeUpdate(position));
396 m_base = position; 441 m_base = position;
397 validate(); 442 validate();
398 } 443 }
399 444
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 return; 1081 return;
1037 } 1082 }
1038 updateIfNeeded(); 1083 updateIfNeeded();
1039 } 1084 }
1040 1085
1041 template <typename Strategy> 1086 template <typename Strategy>
1042 static bool equalSelectionsAlgorithm( 1087 static bool equalSelectionsAlgorithm(
1043 const VisibleSelectionTemplate<Strategy>& selection1, 1088 const VisibleSelectionTemplate<Strategy>& selection1,
1044 const VisibleSelectionTemplate<Strategy>& selection2) { 1089 const VisibleSelectionTemplate<Strategy>& selection2) {
1045 if (selection1.affinity() != selection2.affinity() || 1090 if (selection1.affinity() != selection2.affinity() ||
1046 selection1.isDirectional() != selection2.isDirectional()) 1091 selection1.isDirectional() != selection2.isDirectional() ||
1092 selection1.isHandleVisible() != selection2.isHandleVisible())
1047 return false; 1093 return false;
1048 1094
1049 if (selection1.isNone()) 1095 if (selection1.isNone())
1050 return selection2.isNone(); 1096 return selection2.isNone();
1051 1097
1052 const VisibleSelectionTemplate<Strategy> selectionWrapper1(selection1); 1098 const VisibleSelectionTemplate<Strategy> selectionWrapper1(selection1);
1053 const VisibleSelectionTemplate<Strategy> selectionWrapper2(selection2); 1099 const VisibleSelectionTemplate<Strategy> selectionWrapper2(selection2);
1054 1100
1055 return selectionWrapper1.start() == selectionWrapper2.start() && 1101 return selectionWrapper1.start() == selectionWrapper2.start() &&
1056 selectionWrapper1.end() == selectionWrapper2.end() && 1102 selectionWrapper1.end() == selectionWrapper2.end() &&
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 1177
1132 void showTree(const blink::VisibleSelectionInFlatTree& sel) { 1178 void showTree(const blink::VisibleSelectionInFlatTree& sel) {
1133 sel.showTreeForThis(); 1179 sel.showTreeForThis();
1134 } 1180 }
1135 1181
1136 void showTree(const blink::VisibleSelectionInFlatTree* sel) { 1182 void showTree(const blink::VisibleSelectionInFlatTree* sel) {
1137 if (sel) 1183 if (sel)
1138 sel->showTreeForThis(); 1184 sel->showTreeForThis();
1139 } 1185 }
1140 #endif 1186 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698