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

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

Issue 1326313002: Introduce composed tree version of leftPositionOf() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-09T12:49:11 Add a comment about DOM version of leftPositoin() for composed tree Created 5 years, 3 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
« no previous file with comments | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "core/editing/VisibleUnits.h" 6 #include "core/editing/VisibleUnits.h"
7 7
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 #include "core/editing/VisiblePosition.h" 9 #include "core/editing/VisiblePosition.h"
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*two->firstChild(), 0))); 121 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*two->firstChild(), 0)));
122 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*five->firstChild(), 0))); 122 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*five->firstChild(), 0)));
123 EXPECT_TRUE(inSameLine(positionWithAffinityInComposedTree(*two->firstChild() , 0), positionWithAffinityInComposedTree(*four->firstChild(), 0))); 123 EXPECT_TRUE(inSameLine(positionWithAffinityInComposedTree(*two->firstChild() , 0), positionWithAffinityInComposedTree(*four->firstChild(), 0)));
124 124
125 EXPECT_FALSE(inSameLine(createVisiblePositionInComposedTree(*one, 0), create VisiblePositionInComposedTree(*two, 0))); 125 EXPECT_FALSE(inSameLine(createVisiblePositionInComposedTree(*one, 0), create VisiblePositionInComposedTree(*two, 0)));
126 EXPECT_FALSE(inSameLine(createVisiblePositionInComposedTree(*one->firstChild (), 0), createVisiblePositionInComposedTree(*two->firstChild(), 0))); 126 EXPECT_FALSE(inSameLine(createVisiblePositionInComposedTree(*one->firstChild (), 0), createVisiblePositionInComposedTree(*two->firstChild(), 0)));
127 EXPECT_FALSE(inSameLine(createVisiblePositionInComposedTree(*one->firstChild (), 0), createVisiblePositionInComposedTree(*five->firstChild(), 0))); 127 EXPECT_FALSE(inSameLine(createVisiblePositionInComposedTree(*one->firstChild (), 0), createVisiblePositionInComposedTree(*five->firstChild(), 0)));
128 EXPECT_TRUE(inSameLine(createVisiblePositionInComposedTree(*two->firstChild( ), 0), createVisiblePositionInComposedTree(*four->firstChild(), 0))); 128 EXPECT_TRUE(inSameLine(createVisiblePositionInComposedTree(*two->firstChild( ), 0), createVisiblePositionInComposedTree(*four->firstChild(), 0)));
129 } 129 }
130 130
131 TEST_F(VisibleUnitsTest, leftPositionOf)
132 {
133 const char* bodyContent = "<b id=zero>0</b><p id=host><b id=one>1</b><b id=t wo>22</b></p><b id=three>333</b>";
134 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>55555</b>";
135 setBodyContent(bodyContent);
136 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
137 updateLayoutAndStyleForPainting();
138
139 Element* one = document().getElementById("one");
140 Element* two = document().getElementById("two");
141 Element* three = document().getElementById("three");
142 Element* four = shadowRoot->getElementById("four");
143 Element* five = shadowRoot->getElementById("five");
144
145 EXPECT_EQ(Position(two->firstChild(), 1), leftPositionOf(createVisiblePositi on(Position(one, 0))).deepEquivalent());
146 EXPECT_EQ(PositionInComposedTree(two->firstChild(), 1), leftPositionOf(creat eVisiblePosition(PositionInComposedTree(one, 0))).deepEquivalent());
147
148 EXPECT_EQ(Position(one->firstChild(), 0), leftPositionOf(createVisiblePositi on(Position(two, 0))).deepEquivalent());
149 EXPECT_EQ(PositionInComposedTree(four->firstChild(), 3), leftPositionOf(crea teVisiblePosition(PositionInComposedTree(two, 0))).deepEquivalent());
150
151 EXPECT_EQ(Position(two->firstChild(), 2), leftPositionOf(createVisiblePositi on(Position(three, 0))).deepEquivalent());
152 EXPECT_EQ(PositionInComposedTree(five->firstChild(), 5), leftPositionOf(crea teVisiblePosition(PositionInComposedTree(three, 0))).deepEquivalent());
153 }
154
131 TEST_F(VisibleUnitsTest, localCaretRectOfPosition) 155 TEST_F(VisibleUnitsTest, localCaretRectOfPosition)
132 { 156 {
133 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>"; 157 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>";
134 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; 158 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>";
135 setBodyContent(bodyContent); 159 setBodyContent(bodyContent);
136 setShadowContent(shadowContent, "host"); 160 setShadowContent(shadowContent, "host");
137 updateLayoutAndStyleForPainting(); 161 updateLayoutAndStyleForPainting();
138 162
139 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 163 RefPtrWillBeRawPtr<Element> one = document().getElementById("one");
140 164
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 setBodyContent(bodyContent); 249 setBodyContent(bodyContent);
226 updateLayoutAndStyleForPainting(); 250 updateLayoutAndStyleForPainting();
227 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); 251 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1");
228 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); 252 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2");
229 253
230 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0))); 254 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0)));
231 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0))); 255 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0)));
232 } 256 }
233 257
234 } // namespace blink 258 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698