Index: third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp |
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp b/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp |
index c4d76ac5dca6b6645be5214ea354509a89591a3f..7ff103a9957ac3e291d1dab2f8650bd06b4acc32 100644 |
--- a/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp |
+++ b/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp |
@@ -1977,4 +1977,73 @@ TEST_F(VisibleUnitsTest, |
EXPECT_EQ(Position(text, 2), start); |
} |
+TEST_F(VisibleUnitsTest, textQuadDOM) { |
+ const char* bodyContent = |
+ "<p id='host'>00" |
+ "<b id='one'>11111</b>" |
+ "<b id='two'>22</b>" |
+ "<b id='three'>33</b>" |
+ "</p>"; |
+ setBodyContent(bodyContent); |
+ |
+ const Position startPosition(document().getElementById("host"), 0); |
+ const Position midPosition(document().getElementById("two"), 0); |
+ const Position endPosition(document().getElementById("three"), 0); |
+ const EphemeralRange rangeStartToTwo(startPosition, midPosition); |
+ const EphemeralRange rangeStartToThree(startPosition, endPosition); |
+ Vector<FloatQuad> quadsStartToTwo; |
+ Vector<FloatQuad> quadsStartToThree; |
+ quadsStartToTwo = textQuad(rangeStartToTwo); |
+ quadsStartToThree = textQuad(rangeStartToThree); |
+ |
+ EXPECT_EQ(2u, quadsStartToTwo.size()); |
+ EXPECT_EQ(3u, quadsStartToThree.size()); |
+ EXPECT_EQ(quadsStartToThree[0], quadsStartToTwo[0]); |
+ EXPECT_EQ(quadsStartToThree[1], quadsStartToTwo[1]); |
+ EXPECT_EQ("8,8; 10,8; 10,9; 8,9", quadsStartToTwo[0].toString()); |
+ EXPECT_EQ("10,8; 15,8; 15,9; 10,9", quadsStartToTwo[1].toString()); |
+ EXPECT_EQ("8,8; 10,8; 10,9; 8,9", quadsStartToThree[0].toString()); |
+ EXPECT_EQ("10,8; 15,8; 15,9; 10,9", quadsStartToThree[1].toString()); |
+ EXPECT_EQ("15,8; 17,8; 17,9; 15,9", quadsStartToThree[2].toString()); |
+} |
+ |
+TEST_F(VisibleUnitsTest, textQuadFlatTree) { |
+ const char* bodyContent = |
+ "<b id='zero'>0</b>" |
+ "<p id='host'>" |
+ "<b id='one'>1</b>" |
+ "<b id='two'>22</b>" |
+ "</p>" |
+ "<b id='three'>333</b>"; |
+ const char* shadowContent = |
+ "<p id='four'>4444</p>" |
+ "<content select=#two></content>" |
+ "<content select=#one></content>" |
+ "<p id='five'>55555</p>"; |
+ setBodyContent(bodyContent); |
+ ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
+ |
+ const PositionInFlatTree startPosition(document().getElementById("host"), 0); |
+ const PositionInFlatTree threePosition(document().getElementById("three"), 0); |
+ const PositionInFlatTree fivePosition(shadowRoot->getElementById("five"), 0); |
+ const EphemeralRangeInFlatTree rangeStartToThree(startPosition, |
+ threePosition); |
+ const EphemeralRangeInFlatTree rangeStartToFive(startPosition, fivePosition); |
+ Vector<FloatQuad> quadsStartToThree; |
+ Vector<FloatQuad> quadsStartToFive; |
+ quadsStartToThree = textQuad(rangeStartToThree); |
+ quadsStartToFive = textQuad(rangeStartToFive); |
+ |
+ EXPECT_EQ(4u, quadsStartToThree.size()); |
+ EXPECT_EQ(3u, quadsStartToFive.size()); |
+ EXPECT_EQ(quadsStartToThree[0], quadsStartToFive[0]); |
+ EXPECT_EQ(quadsStartToThree[1], quadsStartToFive[1]); |
+ EXPECT_EQ("8,10; 12,10; 12,11; 8,11", quadsStartToThree[0].toString()); |
+ EXPECT_EQ("8,12; 10,12; 10,13; 8,13", quadsStartToThree[1].toString()); |
+ EXPECT_EQ("10,12; 11,12; 11,13; 10,13", quadsStartToThree[2].toString()); |
+ EXPECT_EQ("8,14; 13,14; 13,15; 8,15", quadsStartToThree[3].toString()); |
+ EXPECT_EQ("8,10; 12,10; 12,11; 8,11", quadsStartToFive[0].toString()); |
+ EXPECT_EQ("8,12; 10,12; 10,13; 8,13", quadsStartToFive[1].toString()); |
+ EXPECT_EQ("10,12; 11,12; 11,13; 10,13", quadsStartToFive[2].toString()); |
+} |
} // namespace blink |