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

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

Issue 2775663008: LayoutObject::absoluteBoundingBoxRectForRange() should take EphemeralRange (Closed)
Patch Set: Y 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 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 TEST_F(VisibleUnitsTest, 2030 TEST_F(VisibleUnitsTest,
2031 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { 2031 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) {
2032 setBodyContent("<p> &#x20E3;</p>"); // Leading space is necessary 2032 setBodyContent("<p> &#x20E3;</p>"); // Leading space is necessary
2033 2033
2034 Node* paragraph = document().querySelector("p"); 2034 Node* paragraph = document().querySelector("p");
2035 Node* text = paragraph->firstChild(); 2035 Node* text = paragraph->firstChild();
2036 Position start = canonicalPositionOf(Position::beforeNode(paragraph)); 2036 Position start = canonicalPositionOf(Position::beforeNode(paragraph));
2037 EXPECT_EQ(Position(text, 2), start); 2037 EXPECT_EQ(Position(text, 2), start);
2038 } 2038 }
2039 2039
2040 TEST_F(VisibleUnitsTest, textQuadDOM) {
2041 const char* bodyContent =
2042 "<p id='host'>00"
2043 "<b id='one'>11111</b>"
2044 "<b id='two'>22</b>"
2045 "<b id='three'>33</b>"
2046 "</p>";
2047 setBodyContent(bodyContent);
2048
2049 const Position startPosition(document().getElementById("host"), 0);
2050 const Position midPosition(document().getElementById("two"), 0);
2051 const Position endPosition(document().getElementById("three"), 0);
2052 const EphemeralRange rangeStartToTwo(startPosition, midPosition);
2053 const EphemeralRange rangeStartToThree(startPosition, endPosition);
2054 Vector<FloatQuad> quadsStartToTwo;
2055 Vector<FloatQuad> quadsStartToThree;
2056 textQuad(quadsStartToTwo, rangeStartToTwo);
2057 textQuad(quadsStartToThree, rangeStartToThree);
2058
2059 EXPECT_EQ(2.0, quadsStartToTwo.size());
2060 EXPECT_EQ(3.0, quadsStartToThree.size());
2061 EXPECT_EQ(quadsStartToThree[0].toString(), quadsStartToTwo[0].toString());
Shanmuga Pandi 2017/03/28 12:02:41 toString() may not needed here
2062 EXPECT_EQ(quadsStartToThree[1].toString(), quadsStartToTwo[1].toString());
2063 EXPECT_EQ("15,8; 17,8; 17,9; 15,9", quadsStartToThree[2].toString());
2064 }
2065
2066 TEST_F(VisibleUnitsTest, textQuadFlatTree) {
2067 const char* bodyContent =
2068 "<b id='zero'>0</b>"
2069 "<p id='host'>"
2070 "<b id='one'>1</b>"
2071 "<b id='two'>22</b>"
2072 "</p>"
2073 "<b id='three'>333</b>";
2074 const char* shadowContent =
2075 "<p id='four'>4444</p>"
2076 "<content select=#two></content>"
2077 "<content select=#one></content>"
2078 "<p id='five'>55555</p>";
2079 setBodyContent(bodyContent);
2080 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
2081
2082 const PositionInFlatTree startPosition(document().getElementById("host"), 0);
2083 const PositionInFlatTree threePosition(document().getElementById("three"), 0);
2084 const PositionInFlatTree fivePosition(shadowRoot->getElementById("five"), 0);
2085 const EphemeralRangeInFlatTree rangeStartToThree(startPosition,
2086 threePosition);
2087 const EphemeralRangeInFlatTree rangeStartToFive(startPosition, fivePosition);
2088 Vector<FloatQuad> quadsStartToThree;
2089 Vector<FloatQuad> quadsStartToFive;
2090 textQuad(quadsStartToThree, rangeStartToThree);
2091 textQuad(quadsStartToFive, rangeStartToFive);
2092
2093 EXPECT_EQ(4.0, quadsStartToThree.size());
2094 EXPECT_EQ(3.0, quadsStartToFive.size());
2095 EXPECT_EQ(quadsStartToThree[0].toString(), quadsStartToFive[0].toString());
Shanmuga Pandi 2017/03/28 12:02:41 ditto
2096 EXPECT_EQ(quadsStartToThree[1].toString(), quadsStartToFive[1].toString());
2097 EXPECT_EQ("8,10; 12,10; 12,11; 8,11", quadsStartToFive[0].toString());
2098 }
2040 } // namespace blink 2099 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698