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

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

Issue 2747333002: Make makeSearchRange() in VisibleSelection to handle BeforeAnchor and AfterAnchor position type (Closed)
Patch Set: 2017-03-15T14:33:19 Update a comment in test Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleSelection.cpp ('k') | no next file » | 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/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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 VisibleSelectionTemplate<Strategy> expandUsingGranularity( 63 VisibleSelectionTemplate<Strategy> expandUsingGranularity(
64 const VisibleSelectionTemplate<Strategy>& selection, 64 const VisibleSelectionTemplate<Strategy>& selection,
65 TextGranularity granularity) { 65 TextGranularity granularity) {
66 return createVisibleSelection( 66 return createVisibleSelection(
67 typename SelectionTemplate<Strategy>::Builder() 67 typename SelectionTemplate<Strategy>::Builder()
68 .setBaseAndExtent(selection.base(), selection.extent()) 68 .setBaseAndExtent(selection.base(), selection.extent())
69 .setGranularity(granularity) 69 .setGranularity(granularity)
70 .build()); 70 .build());
71 } 71 }
72 72
73 // For http://crbug.com/700368
74 TEST_F(VisibleSelectionTest, appendTrailingWhitespaceWithAfterAnchor) {
75 setBodyContent(
76 "<input type=checkbox>"
77 "<div style='user-select:none'>abc</div>");
78 Element* const input = document().querySelector("input");
79
80 // Simulate double-clicking "abc".
81 // TODO(editing-dev): We should remove above comment once we fix [1].
82 // [1] http://crbug.com/701657 double-click on user-select:none should not
83 // compute selection.
84 VisibleSelection selection =
85 createVisibleSelection(SelectionInDOMTree::Builder()
86 .collapse(Position::beforeNode(input))
87 .extend(Position::afterNode(input))
88 .setGranularity(WordGranularity)
89 .build());
90 selection.appendTrailingWhitespace();
91
92 EXPECT_EQ(Position::beforeNode(input), selection.start());
93 EXPECT_EQ(Position::afterNode(input), selection.end());
94 }
95
73 TEST_F(VisibleSelectionTest, expandUsingGranularity) { 96 TEST_F(VisibleSelectionTest, expandUsingGranularity) {
74 const char* bodyContent = 97 const char* bodyContent =
75 "<span id=host><a id=one>1</a><a id=two>22</a></span>"; 98 "<span id=host><a id=one>1</a><a id=two>22</a></span>";
76 const char* shadowContent = 99 const char* shadowContent =
77 "<p><b id=three>333</b><content select=#two></content><b " 100 "<p><b id=three>333</b><content select=#two></content><b "
78 "id=four>4444</b><span id=space> </span><content " 101 "id=four>4444</b><span id=space> </span><content "
79 "select=#one></content><b id=five>55555</b></p>"; 102 "select=#one></content><b id=five>55555</b></p>";
80 setBodyContent(bodyContent); 103 setBodyContent(bodyContent);
81 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); 104 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
82 105
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 Element* host = document().getElementById("host"); 531 Element* host = document().getElementById("host");
509 host->appendChild(sample); 532 host->appendChild(sample);
510 document().updateStyleAndLayout(); 533 document().updateStyleAndLayout();
511 534
512 // Simulates to restore selection from undo stack. 535 // Simulates to restore selection from undo stack.
513 selection = createVisibleSelection(selection.asSelection()); 536 selection = createVisibleSelection(selection.asSelection());
514 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start()); 537 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start());
515 } 538 }
516 539
517 } // namespace blink 540 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698