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

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

Issue 2432383002: Get rid of flat tree version of createVisibleSelection() taking two PositionInFlatTree (Closed)
Patch Set: 2016-10-20T15:59:37 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/SelectionAdjusterTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/FrameSelection.h" 5 #include "core/editing/FrameSelection.h"
6 6
7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/Text.h" 10 #include "core/dom/Text.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 const char* shadowContent = "<span id=bottom>bottom</span>"; 283 const char* shadowContent = "<span id=bottom>bottom</span>";
284 setBodyContent(bodyContent); 284 setBodyContent(bodyContent);
285 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); 285 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
286 286
287 Node* top = document().getElementById("top")->firstChild(); 287 Node* top = document().getElementById("top")->firstChild();
288 Node* bottom = shadowRoot->getElementById("bottom")->firstChild(); 288 Node* bottom = shadowRoot->getElementById("bottom")->firstChild();
289 Node* host = document().getElementById("host"); 289 Node* host = document().getElementById("host");
290 290
291 // top to bottom 291 // top to bottom
292 selection().setNonDirectionalSelectionIfNeeded( 292 selection().setNonDirectionalSelectionIfNeeded(
293 createVisibleSelection(PositionInFlatTree(top, 1), 293 createVisibleSelection(SelectionInFlatTree::Builder()
294 PositionInFlatTree(bottom, 3)), 294 .collapse(PositionInFlatTree(top, 1))
295 .extend(PositionInFlatTree(bottom, 3))
296 .build()),
295 CharacterGranularity); 297 CharacterGranularity);
296 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().base()); 298 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().base());
297 EXPECT_EQ(Position::beforeNode(host), visibleSelectionInDOMTree().extent()); 299 EXPECT_EQ(Position::beforeNode(host), visibleSelectionInDOMTree().extent());
298 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().start()); 300 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().start());
299 EXPECT_EQ(Position(top, 3), visibleSelectionInDOMTree().end()); 301 EXPECT_EQ(Position(top, 3), visibleSelectionInDOMTree().end());
300 302
301 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().base()); 303 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().base());
302 EXPECT_EQ(PositionInFlatTree(bottom, 3), 304 EXPECT_EQ(PositionInFlatTree(bottom, 3),
303 visibleSelectionInFlatTree().extent()); 305 visibleSelectionInFlatTree().extent());
304 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().start()); 306 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().start());
305 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().end()); 307 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().end());
306 308
307 // bottom to top 309 // bottom to top
308 selection().setNonDirectionalSelectionIfNeeded( 310 selection().setNonDirectionalSelectionIfNeeded(
309 createVisibleSelection(PositionInFlatTree(bottom, 3), 311 createVisibleSelection(SelectionInFlatTree::Builder()
310 PositionInFlatTree(top, 1)), 312 .collapse(PositionInFlatTree(bottom, 3))
313 .extend(PositionInFlatTree(top, 1))
314 .build()),
311 CharacterGranularity); 315 CharacterGranularity);
312 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().base()); 316 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().base());
313 EXPECT_EQ(Position::beforeNode(bottom->parentNode()), 317 EXPECT_EQ(Position::beforeNode(bottom->parentNode()),
314 visibleSelectionInDOMTree().extent()); 318 visibleSelectionInDOMTree().extent());
315 EXPECT_EQ(Position(bottom, 0), visibleSelectionInDOMTree().start()); 319 EXPECT_EQ(Position(bottom, 0), visibleSelectionInDOMTree().start());
316 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().end()); 320 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().end());
317 321
318 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().base()); 322 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().base());
319 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().extent()); 323 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().extent());
320 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().start()); 324 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().start());
(...skipping 27 matching lines...) Expand all
348 selection().updateIfNeeded(); 352 selection().updateIfNeeded();
349 353
350 // TODO(yosin): Once lazy canonicalization implemented, selection.start 354 // TODO(yosin): Once lazy canonicalization implemented, selection.start
351 // should be Position(HTML, 0). 355 // should be Position(HTML, 0).
352 EXPECT_EQ(Position(), selection().start()) 356 EXPECT_EQ(Position(), selection().start())
353 << "updateIfNeeded() makes selection to null."; 357 << "updateIfNeeded() makes selection to null.";
354 EXPECT_EQ(selection().start(), caretPosition().position()); 358 EXPECT_EQ(selection().start(), caretPosition().position());
355 } 359 }
356 360
357 } // namespace blink 361 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/SelectionAdjusterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698