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

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

Issue 2465803002: Get rid of VisibleSelection::expandUsingGranularity() (Closed)
Patch Set: 2016-10-31T17:16:07 Created 4 years, 1 month 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/VisibleSelection.h" 5 #include "core/editing/VisibleSelection.h"
6 6
7 #include "core/dom/Range.h" 7 #include "core/dom/Range.h"
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 #include "core/editing/SelectionAdjuster.h" 9 #include "core/editing/SelectionAdjuster.h"
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // shadow root, not distributed node, we map a position in flat tree 49 // shadow root, not distributed node, we map a position in flat tree
50 // to DOM tree position. 50 // to DOM tree position.
51 EXPECT_EQ(selection.start(), 51 EXPECT_EQ(selection.start(),
52 toPositionInDOMTree(selectionInFlatTree.start())); 52 toPositionInDOMTree(selectionInFlatTree.start()));
53 EXPECT_EQ(selection.end(), toPositionInDOMTree(selectionInFlatTree.end())); 53 EXPECT_EQ(selection.end(), toPositionInDOMTree(selectionInFlatTree.end()));
54 EXPECT_EQ(selection.base(), toPositionInDOMTree(selectionInFlatTree.base())); 54 EXPECT_EQ(selection.base(), toPositionInDOMTree(selectionInFlatTree.base()));
55 EXPECT_EQ(selection.extent(), 55 EXPECT_EQ(selection.extent(),
56 toPositionInDOMTree(selectionInFlatTree.extent())); 56 toPositionInDOMTree(selectionInFlatTree.extent()));
57 } 57 }
58 58
59 template <typename Strategy>
60 VisibleSelectionTemplate<Strategy> expandUsingGranularity(
61 const VisibleSelectionTemplate<Strategy>& selection,
62 TextGranularity granularity) {
63 return createVisibleSelection(
64 typename SelectionTemplate<Strategy>::Builder()
65 .setBaseAndExtent(selection.base(), selection.extent())
66 .setGranularity(granularity)
67 .build());
68 }
69
59 TEST_F(VisibleSelectionTest, expandUsingGranularity) { 70 TEST_F(VisibleSelectionTest, expandUsingGranularity) {
60 const char* bodyContent = 71 const char* bodyContent =
61 "<span id=host><a id=one>1</a><a id=two>22</a></span>"; 72 "<span id=host><a id=one>1</a><a id=two>22</a></span>";
62 const char* shadowContent = 73 const char* shadowContent =
63 "<p><b id=three>333</b><content select=#two></content><b " 74 "<p><b id=three>333</b><content select=#two></content><b "
64 "id=four>4444</b><span id=space> </span><content " 75 "id=four>4444</b><span id=space> </span><content "
65 "select=#one></content><b id=five>55555</b></p>"; 76 "select=#one></content><b id=five>55555</b></p>";
66 setBodyContent(bodyContent); 77 setBodyContent(bodyContent);
67 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); 78 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
68 79
69 Node* one = document().getElementById("one")->firstChild(); 80 Node* one = document().getElementById("one")->firstChild();
70 Node* two = document().getElementById("two")->firstChild(); 81 Node* two = document().getElementById("two")->firstChild();
71 Node* three = shadowRoot->getElementById("three")->firstChild(); 82 Node* three = shadowRoot->getElementById("three")->firstChild();
72 Node* four = shadowRoot->getElementById("four")->firstChild(); 83 Node* four = shadowRoot->getElementById("four")->firstChild();
73 Node* five = shadowRoot->getElementById("five")->firstChild(); 84 Node* five = shadowRoot->getElementById("five")->firstChild();
74 85
75 VisibleSelection selection; 86 VisibleSelection selection;
76 VisibleSelectionInFlatTree selectionInFlatTree; 87 VisibleSelectionInFlatTree selectionInFlatTree;
77 88
78 // From a position at distributed node 89 // From a position at distributed node
79 selection = createVisibleSelection( 90 selection = createVisibleSelection(
80 SelectionInDOMTree::Builder().collapse(Position(one, 1)).build()); 91 SelectionInDOMTree::Builder().collapse(Position(one, 1)).build());
81 selection.expandUsingGranularity(WordGranularity); 92 selection = expandUsingGranularity(selection, WordGranularity);
82 selectionInFlatTree = 93 selectionInFlatTree =
83 createVisibleSelection(SelectionInFlatTree::Builder() 94 createVisibleSelection(SelectionInFlatTree::Builder()
84 .collapse(PositionInFlatTree(one, 1)) 95 .collapse(PositionInFlatTree(one, 1))
85 .build()); 96 .build());
86 selectionInFlatTree.expandUsingGranularity(WordGranularity); 97 selectionInFlatTree =
98 expandUsingGranularity(selectionInFlatTree, WordGranularity);
87 99
88 EXPECT_EQ(Position(one, 1), selection.base()); 100 EXPECT_EQ(Position(one, 1), selection.base());
89 EXPECT_EQ(Position(one, 1), selection.extent()); 101 EXPECT_EQ(Position(one, 1), selection.extent());
90 EXPECT_EQ(Position(one, 0), selection.start()); 102 EXPECT_EQ(Position(one, 0), selection.start());
91 EXPECT_EQ(Position(two, 2), selection.end()); 103 EXPECT_EQ(Position(two, 2), selection.end());
92 104
93 EXPECT_EQ(PositionInFlatTree(one, 1), selectionInFlatTree.base()); 105 EXPECT_EQ(PositionInFlatTree(one, 1), selectionInFlatTree.base());
94 EXPECT_EQ(PositionInFlatTree(one, 1), selectionInFlatTree.extent()); 106 EXPECT_EQ(PositionInFlatTree(one, 1), selectionInFlatTree.extent());
95 EXPECT_EQ(PositionInFlatTree(one, 0), selectionInFlatTree.start()); 107 EXPECT_EQ(PositionInFlatTree(one, 0), selectionInFlatTree.start());
96 EXPECT_EQ(PositionInFlatTree(five, 5), selectionInFlatTree.end()); 108 EXPECT_EQ(PositionInFlatTree(five, 5), selectionInFlatTree.end());
97 109
98 // From a position at distributed node 110 // From a position at distributed node
99 selection = createVisibleSelection( 111 selection = createVisibleSelection(
100 SelectionInDOMTree::Builder().collapse(Position(two, 1)).build()); 112 SelectionInDOMTree::Builder().collapse(Position(two, 1)).build());
101 selection.expandUsingGranularity(WordGranularity); 113 selection = expandUsingGranularity(selection, WordGranularity);
102 selectionInFlatTree = 114 selectionInFlatTree =
103 createVisibleSelection(SelectionInFlatTree::Builder() 115 createVisibleSelection(SelectionInFlatTree::Builder()
104 .collapse(PositionInFlatTree(two, 1)) 116 .collapse(PositionInFlatTree(two, 1))
105 .build()); 117 .build());
106 selectionInFlatTree.expandUsingGranularity(WordGranularity); 118 selectionInFlatTree =
119 expandUsingGranularity(selectionInFlatTree, WordGranularity);
107 120
108 EXPECT_EQ(Position(two, 1), selection.base()); 121 EXPECT_EQ(Position(two, 1), selection.base());
109 EXPECT_EQ(Position(two, 1), selection.extent()); 122 EXPECT_EQ(Position(two, 1), selection.extent());
110 EXPECT_EQ(Position(one, 0), selection.start()); 123 EXPECT_EQ(Position(one, 0), selection.start());
111 EXPECT_EQ(Position(two, 2), selection.end()); 124 EXPECT_EQ(Position(two, 2), selection.end());
112 125
113 EXPECT_EQ(PositionInFlatTree(two, 1), selectionInFlatTree.base()); 126 EXPECT_EQ(PositionInFlatTree(two, 1), selectionInFlatTree.base());
114 EXPECT_EQ(PositionInFlatTree(two, 1), selectionInFlatTree.extent()); 127 EXPECT_EQ(PositionInFlatTree(two, 1), selectionInFlatTree.extent());
115 EXPECT_EQ(PositionInFlatTree(three, 0), selectionInFlatTree.start()); 128 EXPECT_EQ(PositionInFlatTree(three, 0), selectionInFlatTree.start());
116 EXPECT_EQ(PositionInFlatTree(four, 4), selectionInFlatTree.end()); 129 EXPECT_EQ(PositionInFlatTree(four, 4), selectionInFlatTree.end());
117 130
118 // From a position at node in shadow tree 131 // From a position at node in shadow tree
119 selection = createVisibleSelection( 132 selection = createVisibleSelection(
120 SelectionInDOMTree::Builder().collapse(Position(three, 1)).build()); 133 SelectionInDOMTree::Builder().collapse(Position(three, 1)).build());
121 selection.expandUsingGranularity(WordGranularity); 134 selection = expandUsingGranularity(selection, WordGranularity);
122 selectionInFlatTree = 135 selectionInFlatTree =
123 createVisibleSelection(SelectionInFlatTree::Builder() 136 createVisibleSelection(SelectionInFlatTree::Builder()
124 .collapse(PositionInFlatTree(three, 1)) 137 .collapse(PositionInFlatTree(three, 1))
125 .build()); 138 .build());
126 selectionInFlatTree.expandUsingGranularity(WordGranularity); 139 selectionInFlatTree =
140 expandUsingGranularity(selectionInFlatTree, WordGranularity);
127 141
128 EXPECT_EQ(Position(three, 1), selection.base()); 142 EXPECT_EQ(Position(three, 1), selection.base());
129 EXPECT_EQ(Position(three, 1), selection.extent()); 143 EXPECT_EQ(Position(three, 1), selection.extent());
130 EXPECT_EQ(Position(three, 0), selection.start()); 144 EXPECT_EQ(Position(three, 0), selection.start());
131 EXPECT_EQ(Position(four, 4), selection.end()); 145 EXPECT_EQ(Position(four, 4), selection.end());
132 146
133 EXPECT_EQ(PositionInFlatTree(three, 1), selectionInFlatTree.base()); 147 EXPECT_EQ(PositionInFlatTree(three, 1), selectionInFlatTree.base());
134 EXPECT_EQ(PositionInFlatTree(three, 1), selectionInFlatTree.extent()); 148 EXPECT_EQ(PositionInFlatTree(three, 1), selectionInFlatTree.extent());
135 EXPECT_EQ(PositionInFlatTree(three, 0), selectionInFlatTree.start()); 149 EXPECT_EQ(PositionInFlatTree(three, 0), selectionInFlatTree.start());
136 EXPECT_EQ(PositionInFlatTree(four, 4), selectionInFlatTree.end()); 150 EXPECT_EQ(PositionInFlatTree(four, 4), selectionInFlatTree.end());
137 151
138 // From a position at node in shadow tree 152 // From a position at node in shadow tree
139 selection = createVisibleSelection( 153 selection = createVisibleSelection(
140 SelectionInDOMTree::Builder().collapse(Position(four, 1)).build()); 154 SelectionInDOMTree::Builder().collapse(Position(four, 1)).build());
141 selection.expandUsingGranularity(WordGranularity); 155 selection = expandUsingGranularity(selection, WordGranularity);
142 selectionInFlatTree = 156 selectionInFlatTree =
143 createVisibleSelection(SelectionInFlatTree::Builder() 157 createVisibleSelection(SelectionInFlatTree::Builder()
144 .collapse(PositionInFlatTree(four, 1)) 158 .collapse(PositionInFlatTree(four, 1))
145 .build()); 159 .build());
146 selectionInFlatTree.expandUsingGranularity(WordGranularity); 160 selectionInFlatTree =
161 expandUsingGranularity(selectionInFlatTree, WordGranularity);
147 162
148 EXPECT_EQ(Position(four, 1), selection.base()); 163 EXPECT_EQ(Position(four, 1), selection.base());
149 EXPECT_EQ(Position(four, 1), selection.extent()); 164 EXPECT_EQ(Position(four, 1), selection.extent());
150 EXPECT_EQ(Position(three, 0), selection.start()); 165 EXPECT_EQ(Position(three, 0), selection.start());
151 EXPECT_EQ(Position(four, 4), selection.end()); 166 EXPECT_EQ(Position(four, 4), selection.end());
152 167
153 EXPECT_EQ(PositionInFlatTree(four, 1), selectionInFlatTree.base()); 168 EXPECT_EQ(PositionInFlatTree(four, 1), selectionInFlatTree.base());
154 EXPECT_EQ(PositionInFlatTree(four, 1), selectionInFlatTree.extent()); 169 EXPECT_EQ(PositionInFlatTree(four, 1), selectionInFlatTree.extent());
155 EXPECT_EQ(PositionInFlatTree(three, 0), selectionInFlatTree.start()); 170 EXPECT_EQ(PositionInFlatTree(three, 0), selectionInFlatTree.start());
156 EXPECT_EQ(PositionInFlatTree(four, 4), selectionInFlatTree.end()); 171 EXPECT_EQ(PositionInFlatTree(four, 4), selectionInFlatTree.end());
157 172
158 // From a position at node in shadow tree 173 // From a position at node in shadow tree
159 selection = createVisibleSelection( 174 selection = createVisibleSelection(
160 SelectionInDOMTree::Builder().collapse(Position(five, 1)).build()); 175 SelectionInDOMTree::Builder().collapse(Position(five, 1)).build());
161 selection.expandUsingGranularity(WordGranularity); 176 selection = expandUsingGranularity(selection, WordGranularity);
162 selectionInFlatTree = 177 selectionInFlatTree =
163 createVisibleSelection(SelectionInFlatTree::Builder() 178 createVisibleSelection(SelectionInFlatTree::Builder()
164 .collapse(PositionInFlatTree(five, 1)) 179 .collapse(PositionInFlatTree(five, 1))
165 .build()); 180 .build());
166 selectionInFlatTree.expandUsingGranularity(WordGranularity); 181 selectionInFlatTree =
182 expandUsingGranularity(selectionInFlatTree, WordGranularity);
167 183
168 EXPECT_EQ(Position(five, 1), selection.base()); 184 EXPECT_EQ(Position(five, 1), selection.base());
169 EXPECT_EQ(Position(five, 1), selection.extent()); 185 EXPECT_EQ(Position(five, 1), selection.extent());
170 EXPECT_EQ(Position(five, 0), selection.start()); 186 EXPECT_EQ(Position(five, 0), selection.start());
171 EXPECT_EQ(Position(five, 5), selection.end()); 187 EXPECT_EQ(Position(five, 5), selection.end());
172 188
173 EXPECT_EQ(PositionInFlatTree(five, 1), selectionInFlatTree.base()); 189 EXPECT_EQ(PositionInFlatTree(five, 1), selectionInFlatTree.base());
174 EXPECT_EQ(PositionInFlatTree(five, 1), selectionInFlatTree.extent()); 190 EXPECT_EQ(PositionInFlatTree(five, 1), selectionInFlatTree.extent());
175 EXPECT_EQ(PositionInFlatTree(one, 0), selectionInFlatTree.start()); 191 EXPECT_EQ(PositionInFlatTree(one, 0), selectionInFlatTree.start());
176 EXPECT_EQ(PositionInFlatTree(five, 5), selectionInFlatTree.end()); 192 EXPECT_EQ(PositionInFlatTree(five, 5), selectionInFlatTree.end());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 TEST_F(VisibleSelectionTest, WordGranularity) { 332 TEST_F(VisibleSelectionTest, WordGranularity) {
317 setBodyContent(LOREM_IPSUM); 333 setBodyContent(LOREM_IPSUM);
318 334
319 VisibleSelection selection; 335 VisibleSelection selection;
320 VisibleSelectionInFlatTree selectionInFlatTree; 336 VisibleSelectionInFlatTree selectionInFlatTree;
321 337
322 // Beginning of a word. 338 // Beginning of a word.
323 { 339 {
324 setSelection(selection, 0); 340 setSelection(selection, 0);
325 setSelection(selectionInFlatTree, 0); 341 setSelection(selectionInFlatTree, 0);
326 selection.expandUsingGranularity(WordGranularity); 342 selection = expandUsingGranularity(selection, WordGranularity);
327 selectionInFlatTree.expandUsingGranularity(WordGranularity); 343 selectionInFlatTree =
344 expandUsingGranularity(selectionInFlatTree, WordGranularity);
328 345
329 Range* range = firstRangeOf(selection); 346 Range* range = firstRangeOf(selection);
330 EXPECT_EQ(0, range->startOffset()); 347 EXPECT_EQ(0, range->startOffset());
331 EXPECT_EQ(5, range->endOffset()); 348 EXPECT_EQ(5, range->endOffset());
332 EXPECT_EQ("Lorem", range->text()); 349 EXPECT_EQ("Lorem", range->text());
333 testFlatTreePositionsToEqualToDOMTreePositions(selection, 350 testFlatTreePositionsToEqualToDOMTreePositions(selection,
334 selectionInFlatTree); 351 selectionInFlatTree);
335 } 352 }
336 353
337 // Middle of a word. 354 // Middle of a word.
338 { 355 {
339 setSelection(selection, 8); 356 setSelection(selection, 8);
340 setSelection(selectionInFlatTree, 8); 357 setSelection(selectionInFlatTree, 8);
341 selection.expandUsingGranularity(WordGranularity); 358 selection = expandUsingGranularity(selection, WordGranularity);
342 selectionInFlatTree.expandUsingGranularity(WordGranularity); 359 selectionInFlatTree =
360 expandUsingGranularity(selectionInFlatTree, WordGranularity);
343 361
344 Range* range = firstRangeOf(selection); 362 Range* range = firstRangeOf(selection);
345 EXPECT_EQ(6, range->startOffset()); 363 EXPECT_EQ(6, range->startOffset());
346 EXPECT_EQ(11, range->endOffset()); 364 EXPECT_EQ(11, range->endOffset());
347 EXPECT_EQ("ipsum", range->text()); 365 EXPECT_EQ("ipsum", range->text());
348 testFlatTreePositionsToEqualToDOMTreePositions(selection, 366 testFlatTreePositionsToEqualToDOMTreePositions(selection,
349 selectionInFlatTree); 367 selectionInFlatTree);
350 } 368 }
351 369
352 // End of a word. 370 // End of a word.
353 // FIXME: that sounds buggy, we might want to select the word _before_ instead 371 // FIXME: that sounds buggy, we might want to select the word _before_ instead
354 // of the space... 372 // of the space...
355 { 373 {
356 setSelection(selection, 5); 374 setSelection(selection, 5);
357 setSelection(selectionInFlatTree, 5); 375 setSelection(selectionInFlatTree, 5);
358 selection.expandUsingGranularity(WordGranularity); 376 selection = expandUsingGranularity(selection, WordGranularity);
359 selectionInFlatTree.expandUsingGranularity(WordGranularity); 377 selectionInFlatTree =
378 expandUsingGranularity(selectionInFlatTree, WordGranularity);
360 379
361 Range* range = firstRangeOf(selection); 380 Range* range = firstRangeOf(selection);
362 EXPECT_EQ(5, range->startOffset()); 381 EXPECT_EQ(5, range->startOffset());
363 EXPECT_EQ(6, range->endOffset()); 382 EXPECT_EQ(6, range->endOffset());
364 EXPECT_EQ(" ", range->text()); 383 EXPECT_EQ(" ", range->text());
365 testFlatTreePositionsToEqualToDOMTreePositions(selection, 384 testFlatTreePositionsToEqualToDOMTreePositions(selection,
366 selectionInFlatTree); 385 selectionInFlatTree);
367 } 386 }
368 387
369 // Before comma. 388 // Before comma.
370 // FIXME: that sounds buggy, we might want to select the word _before_ instead 389 // FIXME: that sounds buggy, we might want to select the word _before_ instead
371 // of the comma. 390 // of the comma.
372 { 391 {
373 setSelection(selection, 26); 392 setSelection(selection, 26);
374 setSelection(selectionInFlatTree, 26); 393 setSelection(selectionInFlatTree, 26);
375 selection.expandUsingGranularity(WordGranularity); 394 selection = expandUsingGranularity(selection, WordGranularity);
376 selectionInFlatTree.expandUsingGranularity(WordGranularity); 395 selectionInFlatTree =
396 expandUsingGranularity(selectionInFlatTree, WordGranularity);
377 397
378 Range* range = firstRangeOf(selection); 398 Range* range = firstRangeOf(selection);
379 EXPECT_EQ(26, range->startOffset()); 399 EXPECT_EQ(26, range->startOffset());
380 EXPECT_EQ(27, range->endOffset()); 400 EXPECT_EQ(27, range->endOffset());
381 EXPECT_EQ(",", range->text()); 401 EXPECT_EQ(",", range->text());
382 testFlatTreePositionsToEqualToDOMTreePositions(selection, 402 testFlatTreePositionsToEqualToDOMTreePositions(selection,
383 selectionInFlatTree); 403 selectionInFlatTree);
384 } 404 }
385 405
386 // After comma. 406 // After comma.
387 { 407 {
388 setSelection(selection, 27); 408 setSelection(selection, 27);
389 setSelection(selectionInFlatTree, 27); 409 setSelection(selectionInFlatTree, 27);
390 selection.expandUsingGranularity(WordGranularity); 410 selection = expandUsingGranularity(selection, WordGranularity);
391 selectionInFlatTree.expandUsingGranularity(WordGranularity); 411 selectionInFlatTree =
412 expandUsingGranularity(selectionInFlatTree, WordGranularity);
392 413
393 Range* range = firstRangeOf(selection); 414 Range* range = firstRangeOf(selection);
394 EXPECT_EQ(27, range->startOffset()); 415 EXPECT_EQ(27, range->startOffset());
395 EXPECT_EQ(28, range->endOffset()); 416 EXPECT_EQ(28, range->endOffset());
396 EXPECT_EQ(" ", range->text()); 417 EXPECT_EQ(" ", range->text());
397 testFlatTreePositionsToEqualToDOMTreePositions(selection, 418 testFlatTreePositionsToEqualToDOMTreePositions(selection,
398 selectionInFlatTree); 419 selectionInFlatTree);
399 } 420 }
400 421
401 // When selecting part of a word. 422 // When selecting part of a word.
402 { 423 {
403 setSelection(selection, 0, 1); 424 setSelection(selection, 0, 1);
404 setSelection(selectionInFlatTree, 0, 1); 425 setSelection(selectionInFlatTree, 0, 1);
405 selection.expandUsingGranularity(WordGranularity); 426 selection = expandUsingGranularity(selection, WordGranularity);
406 selectionInFlatTree.expandUsingGranularity(WordGranularity); 427 selectionInFlatTree =
428 expandUsingGranularity(selectionInFlatTree, WordGranularity);
407 429
408 Range* range = firstRangeOf(selection); 430 Range* range = firstRangeOf(selection);
409 EXPECT_EQ(0, range->startOffset()); 431 EXPECT_EQ(0, range->startOffset());
410 EXPECT_EQ(5, range->endOffset()); 432 EXPECT_EQ(5, range->endOffset());
411 EXPECT_EQ("Lorem", range->text()); 433 EXPECT_EQ("Lorem", range->text());
412 testFlatTreePositionsToEqualToDOMTreePositions(selection, 434 testFlatTreePositionsToEqualToDOMTreePositions(selection,
413 selectionInFlatTree); 435 selectionInFlatTree);
414 } 436 }
415 437
416 // When selecting part of two words. 438 // When selecting part of two words.
417 { 439 {
418 setSelection(selection, 2, 8); 440 setSelection(selection, 2, 8);
419 setSelection(selectionInFlatTree, 2, 8); 441 setSelection(selectionInFlatTree, 2, 8);
420 selection.expandUsingGranularity(WordGranularity); 442 selection = expandUsingGranularity(selection, WordGranularity);
421 selectionInFlatTree.expandUsingGranularity(WordGranularity); 443 selectionInFlatTree =
444 expandUsingGranularity(selectionInFlatTree, WordGranularity);
422 445
423 Range* range = firstRangeOf(selection); 446 Range* range = firstRangeOf(selection);
424 EXPECT_EQ(0, range->startOffset()); 447 EXPECT_EQ(0, range->startOffset());
425 EXPECT_EQ(11, range->endOffset()); 448 EXPECT_EQ(11, range->endOffset());
426 EXPECT_EQ("Lorem ipsum", range->text()); 449 EXPECT_EQ("Lorem ipsum", range->text());
427 testFlatTreePositionsToEqualToDOMTreePositions(selection, 450 testFlatTreePositionsToEqualToDOMTreePositions(selection,
428 selectionInFlatTree); 451 selectionInFlatTree);
429 } 452 }
430 } 453 }
431 454
(...skipping 20 matching lines...) Expand all
452 selection.updateIfNeeded(); 475 selection.updateIfNeeded();
453 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start()); 476 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start());
454 477
455 VisibleSelectionInFlatTree selectionInFlatTree; 478 VisibleSelectionInFlatTree selectionInFlatTree;
456 SelectionAdjuster::adjustSelectionInFlatTree(&selectionInFlatTree, selection); 479 SelectionAdjuster::adjustSelectionInFlatTree(&selectionInFlatTree, selection);
457 EXPECT_EQ(PositionInFlatTree(sample->firstChild(), 0), 480 EXPECT_EQ(PositionInFlatTree(sample->firstChild(), 0),
458 selectionInFlatTree.start()); 481 selectionInFlatTree.start());
459 } 482 }
460 483
461 } // namespace blink 484 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698