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

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

Issue 2775663008: LayoutObject::absoluteBoundingBoxRectForRange() should take EphemeralRange (Closed)
Patch Set: Addressed Review comments 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(1u, quadsStartToTwo.size());
2000 EXPECT_EQ(1u, quadsStartToThree.size());
2001 EXPECT_EQ("10,8; 15,8; 15,9; 10,9", quadsStartToTwo[0].toString());
Xiaocheng 2017/03/31 18:01:19 Wait... Doesn't https://codereview.chromium.org/27
tanvir 2017/04/03 13:00:48 Based on the discussion in https://bugs.chromium.o
2002 EXPECT_EQ("15,8; 17,8; 17,9; 15,9", quadsStartToThree[0].toString());
Xiaocheng 2017/03/31 18:01:19 Same here, "15,8; 17,8; 17,9; 15,9" is the quad fo
2003 }
2004
2005 TEST_F(VisibleUnitsTest, textQuadFlatTree) {
2006 const char* bodyContent =
2007 "<b id='zero'>0</b>"
2008 "<p id='host'>"
2009 "<b id='one'>1</b>"
2010 "<b id='two'>22</b>"
2011 "</p>"
2012 "<b id='three'>333</b>";
2013 const char* shadowContent =
2014 "<p id='four'>4444</p>"
2015 "<content select=#two></content>"
2016 "<content select=#one></content>"
2017 "<p id='five'>55555</p>";
2018 setBodyContent(bodyContent);
2019 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
2020
2021 const PositionInFlatTree startPosition(document().getElementById("host"), 0);
2022 const PositionInFlatTree threePosition(document().getElementById("three"), 0);
2023 const PositionInFlatTree fivePosition(shadowRoot->getElementById("five"), 0);
2024 const EphemeralRangeInFlatTree rangeStartToThree(startPosition,
2025 threePosition);
2026 const EphemeralRangeInFlatTree rangeStartToFive(startPosition, fivePosition);
2027 Vector<FloatQuad> quadsStartToThree;
2028 Vector<FloatQuad> quadsStartToFive;
2029 textQuads(quadsStartToThree, rangeStartToThree);
2030 textQuads(quadsStartToFive, rangeStartToFive);
2031
2032 EXPECT_EQ(1u, quadsStartToThree.size());
2033 EXPECT_EQ(1u, quadsStartToFive.size());
2034 EXPECT_EQ("8,14; 13,14; 13,15; 8,15", quadsStartToThree[0].toString());
2035 EXPECT_EQ("10,12; 11,12; 11,13; 10,13", quadsStartToFive[0].toString());
2036 }
1980 } // namespace blink 2037 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698