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

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

Issue 2775663008: LayoutObject::absoluteBoundingBoxRectForRange() should take EphemeralRange (Closed)
Patch Set: Split Patch:1(TextQuads at VisibleUnits) 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 side-by-side diff with in-line comments
Download patch
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..24322e6174f2f3508d2267084f3f932fa4f62c7e 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;
+ textQuads(&quadsStartToTwo, rangeStartToTwo);
+ textQuads(&quadsStartToThree, 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;
+ textQuads(&quadsStartToThree, rangeStartToThree);
+ textQuads(&quadsStartToFive, 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

Powered by Google App Engine
This is Rietveld 408576698