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

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

Issue 2428363004: Get rid of createVisibleSelection() taking PositionWithAffinity (Closed)
Patch Set: 2016-10-20T14:00:21 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 // 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 418
419 // This is for crbug.com/627783, simulating restoring selection 419 // This is for crbug.com/627783, simulating restoring selection
420 // in undo stack. 420 // in undo stack.
421 TEST_F(VisibleSelectionTest, updateIfNeededWithShadowHost) { 421 TEST_F(VisibleSelectionTest, updateIfNeededWithShadowHost) {
422 setBodyContent("<div id=host></div><div id=sample>foo</div>"); 422 setBodyContent("<div id=host></div><div id=sample>foo</div>");
423 setShadowContent("<content>", "host"); 423 setShadowContent("<content>", "host");
424 Element* sample = document().getElementById("sample"); 424 Element* sample = document().getElementById("sample");
425 425
426 // Simulates saving selection in undo stack. 426 // Simulates saving selection in undo stack.
427 VisibleSelection selection = 427 VisibleSelection selection =
428 createVisibleSelection(Position(sample->firstChild(), 0)); 428 createVisibleSelection(SelectionInDOMTree::Builder()
429 .collapse(Position(sample->firstChild(), 0))
430 .build());
429 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start()); 431 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start());
430 432
431 // Simulates modifying DOM tree to invalidate distribution. 433 // Simulates modifying DOM tree to invalidate distribution.
432 Element* host = document().getElementById("host"); 434 Element* host = document().getElementById("host");
433 host->appendChild(sample); 435 host->appendChild(sample);
434 document().updateStyleAndLayout(); 436 document().updateStyleAndLayout();
435 437
436 // Simulates to restore selection from undo stack. 438 // Simulates to restore selection from undo stack.
437 selection.updateIfNeeded(); 439 selection.updateIfNeeded();
438 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start()); 440 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start());
439 441
440 VisibleSelectionInFlatTree selectionInFlatTree; 442 VisibleSelectionInFlatTree selectionInFlatTree;
441 SelectionAdjuster::adjustSelectionInFlatTree(&selectionInFlatTree, selection); 443 SelectionAdjuster::adjustSelectionInFlatTree(&selectionInFlatTree, selection);
442 EXPECT_EQ(PositionInFlatTree(sample->firstChild(), 0), 444 EXPECT_EQ(PositionInFlatTree(sample->firstChild(), 0),
443 selectionInFlatTree.start()); 445 selectionInFlatTree.start());
444 } 446 }
445 447
446 } // namespace blink 448 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698