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

Unified Diff: Source/core/editing/VisibleUnitsTest.cpp

Issue 1338953002: Introduce composed tree version of startOfWord() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-14T11:03:14 Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/VisibleUnitsTest.cpp
diff --git a/Source/core/editing/VisibleUnitsTest.cpp b/Source/core/editing/VisibleUnitsTest.cpp
index e0047ca8603ab4d77dac0a16763fa625bc1abdc0..9c2109ccc17c7f70cab988bd316d220fe4102de6 100644
--- a/Source/core/editing/VisibleUnitsTest.cpp
+++ b/Source/core/editing/VisibleUnitsTest.cpp
@@ -815,4 +815,41 @@ TEST_F(VisibleUnitsTest, startOfSentence)
EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePositionInComposedTree(*four, 1)).deepEquivalent());
}
+TEST_F(VisibleUnitsTest, startOfWord)
+{
+ const char* bodyContent = "<a id=host><b id=one>1</b> <b id=two>22</b></a><i id=three>333</i>";
+ const char* shadowContent = "<p><u id=four>44444</u><content select=#two></content><span id=space> </span><content select=#one></content><u id=five>55555</u></p>";
+ setBodyContent(bodyContent);
+ RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
+ updateLayoutAndStyleForPainting();
+
+ Node* one = document().getElementById("one")->firstChild();
+ Node* two = document().getElementById("two")->firstChild();
+ Node* three = document().getElementById("three")->firstChild();
+ Node* four = shadowRoot->getElementById("four")->firstChild();
+ Node* five = shadowRoot->getElementById("five")->firstChild();
+ Node* space = shadowRoot->getElementById("space")->firstChild();
+
+ EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent());
+ EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePositionInComposedTree(*one, 0)).deepEquivalent());
+
+ EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one, 1)).deepEquivalent());
+ EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositionInComposedTree(*one, 1)).deepEquivalent());
+
+ EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*two, 0)).deepEquivalent());
+ EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePositionInComposedTree(*two, 0)).deepEquivalent());
+
+ EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*two, 1)).deepEquivalent());
+ EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePositionInComposedTree(*two, 1)).deepEquivalent());
+
+ EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*three, 1)).deepEquivalent());
+ EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePositionInComposedTree(*three, 1)).deepEquivalent());
+
+ EXPECT_EQ(Position(four, 0), startOfWord(createVisiblePositionInDOMTree(*four, 1)).deepEquivalent());
+ EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePositionInComposedTree(*four, 1)).deepEquivalent());
+
+ EXPECT_EQ(Position(space, 1), startOfWord(createVisiblePositionInDOMTree(*five, 1)).deepEquivalent());
+ EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositionInComposedTree(*five, 1)).deepEquivalent());
+}
+
} // namespace blink
« no previous file with comments | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698