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

Side by Side 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, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/VisibleUnits.h" 5 #include "core/editing/VisibleUnits.h"
6 6
7 #include <ostream> // NOLINT 7 #include <ostream> // NOLINT
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "core/dom/Text.h" 9 #include "core/dom/Text.h"
10 #include "core/editing/EditingTestBase.h" 10 #include "core/editing/EditingTestBase.h"
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 TEST_F(VisibleUnitsTest, 1970 TEST_F(VisibleUnitsTest,
1971 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { 1971 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) {
1972 setBodyContent("<p> &#x20E3;</p>"); // Leading space is necessary 1972 setBodyContent("<p> &#x20E3;</p>"); // Leading space is necessary
1973 1973
1974 Node* paragraph = document().querySelector("p"); 1974 Node* paragraph = document().querySelector("p");
1975 Node* text = paragraph->firstChild(); 1975 Node* text = paragraph->firstChild();
1976 Position start = canonicalPositionOf(Position::beforeNode(paragraph)); 1976 Position start = canonicalPositionOf(Position::beforeNode(paragraph));
1977 EXPECT_EQ(Position(text, 2), start); 1977 EXPECT_EQ(Position(text, 2), start);
1978 } 1978 }
1979 1979
1980 TEST_F(VisibleUnitsTest, textQuadDOM) {
1981 const char* bodyContent =
1982 "<p id='host'>00"
1983 "<b id='one'>11111</b>"
1984 "<b id='two'>22</b>"
1985 "<b id='three'>33</b>"
1986 "</p>";
1987 setBodyContent(bodyContent);
1988
1989 const Position startPosition(document().getElementById("host"), 0);
1990 const Position midPosition(document().getElementById("two"), 0);
1991 const Position endPosition(document().getElementById("three"), 0);
1992 const EphemeralRange rangeStartToTwo(startPosition, midPosition);
1993 const EphemeralRange rangeStartToThree(startPosition, endPosition);
1994 Vector<FloatQuad> quadsStartToTwo;
1995 Vector<FloatQuad> quadsStartToThree;
1996 textQuads(&quadsStartToTwo, rangeStartToTwo);
1997 textQuads(&quadsStartToThree, rangeStartToThree);
1998
1999 EXPECT_EQ(2u, quadsStartToTwo.size());
2000 EXPECT_EQ(3u, quadsStartToThree.size());
2001 EXPECT_EQ(quadsStartToThree[0], quadsStartToTwo[0]);
2002 EXPECT_EQ(quadsStartToThree[1], quadsStartToTwo[1]);
2003 EXPECT_EQ("8,8; 10,8; 10,9; 8,9", quadsStartToTwo[0].toString());
2004 EXPECT_EQ("10,8; 15,8; 15,9; 10,9", quadsStartToTwo[1].toString());
2005 EXPECT_EQ("8,8; 10,8; 10,9; 8,9", quadsStartToThree[0].toString());
2006 EXPECT_EQ("10,8; 15,8; 15,9; 10,9", quadsStartToThree[1].toString());
2007 EXPECT_EQ("15,8; 17,8; 17,9; 15,9", quadsStartToThree[2].toString());
2008 }
2009
2010 TEST_F(VisibleUnitsTest, textQuadFlatTree) {
2011 const char* bodyContent =
2012 "<b id='zero'>0</b>"
2013 "<p id='host'>"
2014 "<b id='one'>1</b>"
2015 "<b id='two'>22</b>"
2016 "</p>"
2017 "<b id='three'>333</b>";
2018 const char* shadowContent =
2019 "<p id='four'>4444</p>"
2020 "<content select=#two></content>"
2021 "<content select=#one></content>"
2022 "<p id='five'>55555</p>";
2023 setBodyContent(bodyContent);
2024 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
2025
2026 const PositionInFlatTree startPosition(document().getElementById("host"), 0);
2027 const PositionInFlatTree threePosition(document().getElementById("three"), 0);
2028 const PositionInFlatTree fivePosition(shadowRoot->getElementById("five"), 0);
2029 const EphemeralRangeInFlatTree rangeStartToThree(startPosition,
2030 threePosition);
2031 const EphemeralRangeInFlatTree rangeStartToFive(startPosition, fivePosition);
2032 Vector<FloatQuad> quadsStartToThree;
2033 Vector<FloatQuad> quadsStartToFive;
2034 textQuads(&quadsStartToThree, rangeStartToThree);
2035 textQuads(&quadsStartToFive, rangeStartToFive);
2036
2037 EXPECT_EQ(4u, quadsStartToThree.size());
2038 EXPECT_EQ(3u, quadsStartToFive.size());
2039 EXPECT_EQ(quadsStartToThree[0], quadsStartToFive[0]);
2040 EXPECT_EQ(quadsStartToThree[1], quadsStartToFive[1]);
2041 EXPECT_EQ("8,10; 12,10; 12,11; 8,11", quadsStartToThree[0].toString());
2042 EXPECT_EQ("8,12; 10,12; 10,13; 8,13", quadsStartToThree[1].toString());
2043 EXPECT_EQ("10,12; 11,12; 11,13; 10,13", quadsStartToThree[2].toString());
2044 EXPECT_EQ("8,14; 13,14; 13,15; 8,15", quadsStartToThree[3].toString());
2045 EXPECT_EQ("8,10; 12,10; 12,11; 8,11", quadsStartToFive[0].toString());
2046 EXPECT_EQ("8,12; 10,12; 10,13; 8,13", quadsStartToFive[1].toString());
2047 EXPECT_EQ("10,12; 11,12; 11,13; 10,13", quadsStartToFive[2].toString());
2048 }
1980 } // namespace blink 2049 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698