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

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

Issue 1675163002: Rename ComposedTree to FlatTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 4 years, 10 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 "core/dom/Text.h" 7 #include "core/dom/Text.h"
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 #include "core/html/HTMLTextFormControlElement.h" 10 #include "core/html/HTMLTextFormControlElement.h"
11 #include "core/layout/LayoutTextFragment.h" 11 #include "core/layout/LayoutTextFragment.h"
12 #include "core/layout/line/InlineBox.h" 12 #include "core/layout/line/InlineBox.h"
13 #include <ostream> // NOLINT 13 #include <ostream> // NOLINT
14 14
15 namespace blink { 15 namespace blink {
16 16
17 namespace { 17 namespace {
18 18
19 PositionWithAffinity positionWithAffinityInDOMTree(Node& anchor, int offset, Tex tAffinity affinity = TextAffinity::Downstream) 19 PositionWithAffinity positionWithAffinityInDOMTree(Node& anchor, int offset, Tex tAffinity affinity = TextAffinity::Downstream)
20 { 20 {
21 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset)), affinity); 21 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset)), affinity);
22 } 22 }
23 23
24 VisiblePosition createVisiblePositionInDOMTree(Node& anchor, int offset, TextAff inity affinity = TextAffinity::Downstream) 24 VisiblePosition createVisiblePositionInDOMTree(Node& anchor, int offset, TextAff inity affinity = TextAffinity::Downstream)
25 { 25 {
26 return createVisiblePosition(Position(&anchor, offset), affinity); 26 return createVisiblePosition(Position(&anchor, offset), affinity);
27 } 27 }
28 28
29 PositionInComposedTreeWithAffinity positionWithAffinityInComposedTree(Node& anch or, int offset, TextAffinity affinity = TextAffinity::Downstream) 29 PositionInFlatTreeWithAffinity positionWithAffinityInFlatTree(Node& anchor, int offset, TextAffinity affinity = TextAffinity::Downstream)
30 { 30 {
31 return PositionInComposedTreeWithAffinity(canonicalPositionOf(PositionInComp osedTree(&anchor, offset)), affinity); 31 return PositionInFlatTreeWithAffinity(canonicalPositionOf(PositionInFlatTree (&anchor, offset)), affinity);
32 } 32 }
33 33
34 VisiblePositionInComposedTree createVisiblePositionInComposedTree(Node& anchor, int offset, TextAffinity affinity = TextAffinity::Downstream) 34 VisiblePositionInFlatTree createVisiblePositionInFlatTree(Node& anchor, int offs et, TextAffinity affinity = TextAffinity::Downstream)
35 { 35 {
36 return createVisiblePosition(PositionInComposedTree(&anchor, offset), affini ty); 36 return createVisiblePosition(PositionInFlatTree(&anchor, offset), affinity);
37 } 37 }
38 38
39 } // namespace 39 } // namespace
40 40
41 std::ostream& operator<<(std::ostream& ostream, const InlineBoxPosition& inlineB oxPosition) 41 std::ostream& operator<<(std::ostream& ostream, const InlineBoxPosition& inlineB oxPosition)
42 { 42 {
43 if (!inlineBoxPosition.inlineBox) 43 if (!inlineBoxPosition.inlineBox)
44 return ostream << "null"; 44 return ostream << "null";
45 return ostream << inlineBoxPosition.inlineBox->lineLayoutItem().node() << "@ " << inlineBoxPosition.offsetInBox; 45 return ostream << inlineBoxPosition.inlineBox->lineLayoutItem().node() << "@ " << inlineBoxPosition.offsetInBox;
46 } 46 }
47 47
48 class VisibleUnitsTest : public EditingTestBase { 48 class VisibleUnitsTest : public EditingTestBase {
49 }; 49 };
50 50
51 TEST_F(VisibleUnitsTest, absoluteCaretBoundsOf) 51 TEST_F(VisibleUnitsTest, absoluteCaretBoundsOf)
52 { 52 {
53 const char* bodyContent = "<p id='host'><b id='one'>11</b><b id='two'>22</b> </p>"; 53 const char* bodyContent = "<p id='host'><b id='one'>11</b><b id='two'>22</b> </p>";
54 const char* shadowContent = "<div><content select=#two></content><content se lect=#one></content></div>"; 54 const char* shadowContent = "<div><content select=#two></content><content se lect=#one></content></div>";
55 setBodyContent(bodyContent); 55 setBodyContent(bodyContent);
56 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 56 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
57 ASSERT_UNUSED(shadowRoot, shadowRoot); 57 ASSERT_UNUSED(shadowRoot, shadowRoot);
58 updateLayoutAndStyleForPainting(); 58 updateLayoutAndStyleForPainting();
59 59
60 RefPtrWillBeRawPtr<Element> body = document().body(); 60 RefPtrWillBeRawPtr<Element> body = document().body();
61 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION); 61 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION);
62 62
63 IntRect boundsInDOMTree = absoluteCaretBoundsOf(createVisiblePosition(Positi on(one.get(), 0))); 63 IntRect boundsInDOMTree = absoluteCaretBoundsOf(createVisiblePosition(Positi on(one.get(), 0)));
64 IntRect boundsInComposedTree = absoluteCaretBoundsOf(createVisiblePosition(P ositionInComposedTree(one.get(), 0))); 64 IntRect boundsInFlatTree = absoluteCaretBoundsOf(createVisiblePosition(Posit ionInFlatTree(one.get(), 0)));
65 65
66 EXPECT_FALSE(boundsInDOMTree.isEmpty()); 66 EXPECT_FALSE(boundsInDOMTree.isEmpty());
67 EXPECT_EQ(boundsInDOMTree, boundsInComposedTree); 67 EXPECT_EQ(boundsInDOMTree, boundsInFlatTree);
68 } 68 }
69 69
70 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterPunctuations) 70 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterPunctuations)
71 { 71 {
72 const char* bodyContent = "<style>p:first-letter {color:red;}</style><p id=s ample>(a)bc</p>"; 72 const char* bodyContent = "<style>p:first-letter {color:red;}</style><p id=s ample>(a)bc</p>";
73 setBodyContent(bodyContent); 73 setBodyContent(bodyContent);
74 updateLayoutAndStyleForPainting(); 74 updateLayoutAndStyleForPainting();
75 75
76 Node* sample = document().getElementById("sample"); 76 Node* sample = document().getElementById("sample");
77 Node* text = sample->firstChild(); 77 Node* text = sample->firstChild();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 const char* bodyContent = "<p id='host'><b id='one'>1</b><b id='two'>22</b>< /p><b id='three'>333</b>"; 152 const char* bodyContent = "<p id='host'><b id='one'>1</b><b id='two'>22</b>< /p><b id='three'>333</b>";
153 const char* shadowContent = "<b id='four'>4444</b><content select=#two></con tent><content select=#one></content><b id='five'>5555</b>"; 153 const char* shadowContent = "<b id='four'>4444</b><content select=#two></con tent><content select=#one></content><b id='five'>5555</b>";
154 setBodyContent(bodyContent); 154 setBodyContent(bodyContent);
155 setShadowContent(shadowContent, "host"); 155 setShadowContent(shadowContent, "host");
156 updateLayoutAndStyleForPainting(); 156 updateLayoutAndStyleForPainting();
157 157
158 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 158 RefPtrWillBeRawPtr<Element> one = document().getElementById("one");
159 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); 159 RefPtrWillBeRawPtr<Element> two = document().getElementById("two");
160 160
161 EXPECT_EQ('2', characterAfter(createVisiblePositionInDOMTree(*one->firstChil d(), 1))); 161 EXPECT_EQ('2', characterAfter(createVisiblePositionInDOMTree(*one->firstChil d(), 1)));
162 EXPECT_EQ('5', characterAfter(createVisiblePositionInComposedTree(*one->firs tChild(), 1))); 162 EXPECT_EQ('5', characterAfter(createVisiblePositionInFlatTree(*one->firstChi ld(), 1)));
163 163
164 EXPECT_EQ(0, characterAfter(createVisiblePositionInDOMTree(*two->firstChild( ), 2))); 164 EXPECT_EQ(0, characterAfter(createVisiblePositionInDOMTree(*two->firstChild( ), 2)));
165 EXPECT_EQ('1', characterAfter(createVisiblePositionInComposedTree(*two->firs tChild(), 2))); 165 EXPECT_EQ('1', characterAfter(createVisiblePositionInFlatTree(*two->firstChi ld(), 2)));
166 } 166 }
167 167
168 TEST_F(VisibleUnitsTest, canonicalPositionOfWithHTMLHtmlElement) 168 TEST_F(VisibleUnitsTest, canonicalPositionOfWithHTMLHtmlElement)
169 { 169 {
170 const char* bodyContent = "<html><div id=one contenteditable>1</div><span id =two contenteditable=false>22</span><span id=three contenteditable=false>333</sp an><span id=four contenteditable=false>333</span></html>"; 170 const char* bodyContent = "<html><div id=one contenteditable>1</div><span id =two contenteditable=false>22</span><span id=three contenteditable=false>333</sp an><span id=four contenteditable=false>333</span></html>";
171 setBodyContent(bodyContent); 171 setBodyContent(bodyContent);
172 172
173 RefPtrWillBeRawPtr<Node> one = document().querySelector("#one", ASSERT_NO_EX CEPTION); 173 RefPtrWillBeRawPtr<Node> one = document().querySelector("#one", ASSERT_NO_EX CEPTION);
174 RefPtrWillBeRawPtr<Node> two = document().querySelector("#two", ASSERT_NO_EX CEPTION); 174 RefPtrWillBeRawPtr<Node> two = document().querySelector("#two", ASSERT_NO_EX CEPTION);
175 RefPtrWillBeRawPtr<Node> three = document().querySelector("#three", ASSERT_N O_EXCEPTION); 175 RefPtrWillBeRawPtr<Node> three = document().querySelector("#three", ASSERT_N O_EXCEPTION);
(...skipping 28 matching lines...) Expand all
204 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>5555</b>"; 204 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>5555</b>";
205 setBodyContent(bodyContent); 205 setBodyContent(bodyContent);
206 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 206 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
207 updateLayoutAndStyleForPainting(); 207 updateLayoutAndStyleForPainting();
208 208
209 Node* one = document().getElementById("one")->firstChild(); 209 Node* one = document().getElementById("one")->firstChild();
210 Node* two = document().getElementById("two")->firstChild(); 210 Node* two = document().getElementById("two")->firstChild();
211 Node* five = shadowRoot->getElementById("five")->firstChild(); 211 Node* five = shadowRoot->getElementById("five")->firstChild();
212 212
213 EXPECT_EQ(0, characterBefore(createVisiblePositionInDOMTree(*one, 0))); 213 EXPECT_EQ(0, characterBefore(createVisiblePositionInDOMTree(*one, 0)));
214 EXPECT_EQ('2', characterBefore(createVisiblePositionInComposedTree(*one, 0)) ); 214 EXPECT_EQ('2', characterBefore(createVisiblePositionInFlatTree(*one, 0)));
215 215
216 EXPECT_EQ('1', characterBefore(createVisiblePositionInDOMTree(*one, 1))); 216 EXPECT_EQ('1', characterBefore(createVisiblePositionInDOMTree(*one, 1)));
217 EXPECT_EQ('1', characterBefore(createVisiblePositionInComposedTree(*one, 1)) ); 217 EXPECT_EQ('1', characterBefore(createVisiblePositionInFlatTree(*one, 1)));
218 218
219 EXPECT_EQ('1', characterBefore(createVisiblePositionInDOMTree(*two, 0))); 219 EXPECT_EQ('1', characterBefore(createVisiblePositionInDOMTree(*two, 0)));
220 EXPECT_EQ('4', characterBefore(createVisiblePositionInComposedTree(*two, 0)) ); 220 EXPECT_EQ('4', characterBefore(createVisiblePositionInFlatTree(*two, 0)));
221 221
222 EXPECT_EQ('4', characterBefore(createVisiblePositionInDOMTree(*five, 0))); 222 EXPECT_EQ('4', characterBefore(createVisiblePositionInDOMTree(*five, 0)));
223 EXPECT_EQ('1', characterBefore(createVisiblePositionInComposedTree(*five, 0) )); 223 EXPECT_EQ('1', characterBefore(createVisiblePositionInFlatTree(*five, 0)));
224 } 224 }
225 225
226 TEST_F(VisibleUnitsTest, computeInlineBoxPosition) 226 TEST_F(VisibleUnitsTest, computeInlineBoxPosition)
227 { 227 {
228 const char* bodyContent = "<p id=host><b id=one>1</b><b id=two>22</b></p><b id=three>333</b>"; 228 const char* bodyContent = "<p id=host><b id=one>1</b><b id=two>22</b></p><b id=three>333</b>";
229 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>5555</b>"; 229 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>5555</b>";
230 setBodyContent(bodyContent); 230 setBodyContent(bodyContent);
231 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 231 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
232 updateLayoutAndStyleForPainting(); 232 updateLayoutAndStyleForPainting();
233 233
234 Node* one = document().getElementById("one")->firstChild(); 234 Node* one = document().getElementById("one")->firstChild();
235 Node* two = document().getElementById("two")->firstChild(); 235 Node* two = document().getElementById("two")->firstChild();
236 Node* three = document().getElementById("three")->firstChild(); 236 Node* three = document().getElementById("three")->firstChild();
237 Node* four = shadowRoot->getElementById("four")->firstChild(); 237 Node* four = shadowRoot->getElementById("four")->firstChild();
238 Node* five = shadowRoot->getElementById("five")->firstChild(); 238 Node* five = shadowRoot->getElementById("five")->firstChild();
239 239
240 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(one, 0), TextAffin ity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree(* one, 0))); 240 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(one, 0), TextAffinity: :Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*one, 0)) );
241 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(one, 1), TextAffin ity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree(* one, 1))); 241 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(one, 1), TextAffinity: :Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*one, 1)) );
242 242
243 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(two, 0), TextAffin ity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree(* two, 0))); 243 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(two, 0), TextAffinity: :Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*two, 0)) );
244 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(two, 1), TextAffin ity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree(* two, 1))); 244 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(two, 1), TextAffinity: :Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*two, 1)) );
245 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(two, 2), TextAffin ity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree(* two, 2))); 245 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(two, 2), TextAffinity: :Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*two, 2)) );
246 246
247 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(three, 0), TextAff inity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree (*three, 0))); 247 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(three, 0), TextAffinit y::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*three, 0)));
248 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(three, 1), TextAff inity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree (*three, 1))); 248 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(three, 1), TextAffinit y::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*three, 1)));
249 249
250 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(four, 0), TextAffi nity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree( *four, 0))); 250 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(four, 0), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*four, 0 )));
251 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(four, 1), TextAffi nity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree( *four, 1))); 251 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(four, 1), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*four, 1 )));
252 252
253 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(five, 0), TextAffi nity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree( *five, 0))); 253 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(five, 0), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*five, 0 )));
254 EXPECT_EQ(computeInlineBoxPosition(PositionInComposedTree(five, 1), TextAffi nity::Downstream), computeInlineBoxPosition(createVisiblePositionInComposedTree( *five, 1))); 254 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(five, 1), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*five, 1 )));
255 } 255 }
256 256
257 TEST_F(VisibleUnitsTest, endOfDocument) 257 TEST_F(VisibleUnitsTest, endOfDocument)
258 { 258 {
259 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>"; 259 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>";
260 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>"; 260 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>";
261 setBodyContent(bodyContent); 261 setBodyContent(bodyContent);
262 setShadowContent(shadowContent, "host"); 262 setShadowContent(shadowContent, "host");
263 updateLayoutAndStyleForPainting(); 263 updateLayoutAndStyleForPainting();
264 264
265 Element* one = document().getElementById("one"); 265 Element* one = document().getElementById("one");
266 Element* two = document().getElementById("two"); 266 Element* two = document().getElementById("two");
267 267
268 EXPECT_EQ(Position(two->firstChild(), 2), endOfDocument(createVisiblePositio nInDOMTree(*one->firstChild(), 0)).deepEquivalent()); 268 EXPECT_EQ(Position(two->firstChild(), 2), endOfDocument(createVisiblePositio nInDOMTree(*one->firstChild(), 0)).deepEquivalent());
269 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 1), endOfDocument(create VisiblePositionInComposedTree(*one->firstChild(), 0)).deepEquivalent()); 269 EXPECT_EQ(PositionInFlatTree(one->firstChild(), 1), endOfDocument(createVisi blePositionInFlatTree(*one->firstChild(), 0)).deepEquivalent());
270 270
271 EXPECT_EQ(Position(two->firstChild(), 2), endOfDocument(createVisiblePositio nInDOMTree(*two->firstChild(), 1)).deepEquivalent()); 271 EXPECT_EQ(Position(two->firstChild(), 2), endOfDocument(createVisiblePositio nInDOMTree(*two->firstChild(), 1)).deepEquivalent());
272 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 1), endOfDocument(create VisiblePositionInComposedTree(*two->firstChild(), 1)).deepEquivalent()); 272 EXPECT_EQ(PositionInFlatTree(one->firstChild(), 1), endOfDocument(createVisi blePositionInFlatTree(*two->firstChild(), 1)).deepEquivalent());
273 } 273 }
274 274
275 TEST_F(VisibleUnitsTest, endOfLine) 275 TEST_F(VisibleUnitsTest, endOfLine)
276 { 276 {
277 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>"; 277 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>";
278 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>"; 278 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>";
279 setBodyContent(bodyContent); 279 setBodyContent(bodyContent);
280 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 280 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
281 updateLayoutAndStyleForPainting(); 281 updateLayoutAndStyleForPainting();
282 282
283 Node* one = document().getElementById("one")->firstChild(); 283 Node* one = document().getElementById("one")->firstChild();
284 Node* two = document().getElementById("two")->firstChild(); 284 Node* two = document().getElementById("two")->firstChild();
285 Node* three = document().getElementById("three")->firstChild(); 285 Node* three = document().getElementById("three")->firstChild();
286 Node* four = document().getElementById("four")->firstChild(); 286 Node* four = document().getElementById("four")->firstChild();
287 Node* five = shadowRoot->getElementById("five")->firstChild(); 287 Node* five = shadowRoot->getElementById("five")->firstChild();
288 Node* six = shadowRoot->getElementById("six")->firstChild(); 288 Node* six = shadowRoot->getElementById("six")->firstChild();
289 Node* seven = shadowRoot->getElementById("seven")->firstChild(); 289 Node* seven = shadowRoot->getElementById("seven")->firstChild();
290 290
291 EXPECT_EQ(Position(seven, 7), endOfLine(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent()); 291 EXPECT_EQ(Position(seven, 7), endOfLine(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent());
292 EXPECT_EQ(PositionInComposedTree(seven, 7), endOfLine(createVisiblePositionI nComposedTree(*one, 0)).deepEquivalent()); 292 EXPECT_EQ(PositionInFlatTree(seven, 7), endOfLine(createVisiblePositionInFla tTree(*one, 0)).deepEquivalent());
293 293
294 EXPECT_EQ(Position(seven, 7), endOfLine(createVisiblePositionInDOMTree(*one, 1)).deepEquivalent()); 294 EXPECT_EQ(Position(seven, 7), endOfLine(createVisiblePositionInDOMTree(*one, 1)).deepEquivalent());
295 EXPECT_EQ(PositionInComposedTree(seven, 7), endOfLine(createVisiblePositionI nComposedTree(*one, 1)).deepEquivalent()); 295 EXPECT_EQ(PositionInFlatTree(seven, 7), endOfLine(createVisiblePositionInFla tTree(*one, 1)).deepEquivalent());
296 296
297 EXPECT_EQ(Position(seven, 7), endOfLine(createVisiblePositionInDOMTree(*two, 0)).deepEquivalent()); 297 EXPECT_EQ(Position(seven, 7), endOfLine(createVisiblePositionInDOMTree(*two, 0)).deepEquivalent());
298 EXPECT_EQ(PositionInComposedTree(two, 2), endOfLine(createVisiblePositionInC omposedTree(*two, 0)).deepEquivalent()); 298 EXPECT_EQ(PositionInFlatTree(two, 2), endOfLine(createVisiblePositionInFlatT ree(*two, 0)).deepEquivalent());
299 299
300 // TODO(yosin) endOfLine(two, 1) -> (five, 5) is a broken result. We keep 300 // TODO(yosin) endOfLine(two, 1) -> (five, 5) is a broken result. We keep
301 // it as a marker for future change. 301 // it as a marker for future change.
302 EXPECT_EQ(Position(five, 5), endOfLine(createVisiblePositionInDOMTree(*two, 1)).deepEquivalent()); 302 EXPECT_EQ(Position(five, 5), endOfLine(createVisiblePositionInDOMTree(*two, 1)).deepEquivalent());
303 EXPECT_EQ(PositionInComposedTree(two, 2), endOfLine(createVisiblePositionInC omposedTree(*two, 1)).deepEquivalent()); 303 EXPECT_EQ(PositionInFlatTree(two, 2), endOfLine(createVisiblePositionInFlatT ree(*two, 1)).deepEquivalent());
304 304
305 EXPECT_EQ(Position(five, 5), endOfLine(createVisiblePositionInDOMTree(*three , 0)).deepEquivalent()); 305 EXPECT_EQ(Position(five, 5), endOfLine(createVisiblePositionInDOMTree(*three , 0)).deepEquivalent());
306 EXPECT_EQ(PositionInComposedTree(four, 4), endOfLine(createVisiblePositionIn ComposedTree(*three, 1)).deepEquivalent()); 306 EXPECT_EQ(PositionInFlatTree(four, 4), endOfLine(createVisiblePositionInFlat Tree(*three, 1)).deepEquivalent());
307 307
308 EXPECT_EQ(Position(four, 4), endOfLine(createVisiblePositionInDOMTree(*four, 1)).deepEquivalent()); 308 EXPECT_EQ(Position(four, 4), endOfLine(createVisiblePositionInDOMTree(*four, 1)).deepEquivalent());
309 EXPECT_EQ(PositionInComposedTree(four, 4), endOfLine(createVisiblePositionIn ComposedTree(*four, 1)).deepEquivalent()); 309 EXPECT_EQ(PositionInFlatTree(four, 4), endOfLine(createVisiblePositionInFlat Tree(*four, 1)).deepEquivalent());
310 310
311 EXPECT_EQ(Position(five, 5), endOfLine(createVisiblePositionInDOMTree(*five, 1)).deepEquivalent()); 311 EXPECT_EQ(Position(five, 5), endOfLine(createVisiblePositionInDOMTree(*five, 1)).deepEquivalent());
312 EXPECT_EQ(PositionInComposedTree(two, 2), endOfLine(createVisiblePositionInC omposedTree(*five, 1)).deepEquivalent()); 312 EXPECT_EQ(PositionInFlatTree(two, 2), endOfLine(createVisiblePositionInFlatT ree(*five, 1)).deepEquivalent());
313 313
314 EXPECT_EQ(Position(six, 6), endOfLine(createVisiblePositionInDOMTree(*six, 1 )).deepEquivalent()); 314 EXPECT_EQ(Position(six, 6), endOfLine(createVisiblePositionInDOMTree(*six, 1 )).deepEquivalent());
315 EXPECT_EQ(PositionInComposedTree(six, 6), endOfLine(createVisiblePositionInC omposedTree(*six, 1)).deepEquivalent()); 315 EXPECT_EQ(PositionInFlatTree(six, 6), endOfLine(createVisiblePositionInFlatT ree(*six, 1)).deepEquivalent());
316 316
317 EXPECT_EQ(Position(seven, 7), endOfLine(createVisiblePositionInDOMTree(*seve n, 1)).deepEquivalent()); 317 EXPECT_EQ(Position(seven, 7), endOfLine(createVisiblePositionInDOMTree(*seve n, 1)).deepEquivalent());
318 EXPECT_EQ(PositionInComposedTree(seven, 7), endOfLine(createVisiblePositionI nComposedTree(*seven, 1)).deepEquivalent()); 318 EXPECT_EQ(PositionInFlatTree(seven, 7), endOfLine(createVisiblePositionInFla tTree(*seven, 1)).deepEquivalent());
319 } 319 }
320 320
321 TEST_F(VisibleUnitsTest, endOfParagraphFirstLetter) 321 TEST_F(VisibleUnitsTest, endOfParagraphFirstLetter)
322 { 322 {
323 setBodyContent("<style>div::first-letter { color: red }</style><div id=sampl e>1ab\nde</div>"); 323 setBodyContent("<style>div::first-letter { color: red }</style><div id=sampl e>1ab\nde</div>");
324 updateLayoutAndStyleForPainting(); 324 updateLayoutAndStyleForPainting();
325 325
326 Node* sample = document().getElementById("sample"); 326 Node* sample = document().getElementById("sample");
327 Node* text = sample->firstChild(); 327 Node* text = sample->firstChild();
328 328
(...skipping 29 matching lines...) Expand all
358 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>"; 358 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>";
359 setBodyContent(bodyContent); 359 setBodyContent(bodyContent);
360 setShadowContent(shadowContent, "host"); 360 setShadowContent(shadowContent, "host");
361 updateLayoutAndStyleForPainting(); 361 updateLayoutAndStyleForPainting();
362 362
363 Element* one = document().getElementById("one"); 363 Element* one = document().getElementById("one");
364 Element* two = document().getElementById("two"); 364 Element* two = document().getElementById("two");
365 Element* three = document().getElementById("three"); 365 Element* three = document().getElementById("three");
366 366
367 EXPECT_EQ(Position(three->firstChild(), 3), endOfParagraph(createVisiblePosi tionInDOMTree(*one->firstChild(), 1)).deepEquivalent()); 367 EXPECT_EQ(Position(three->firstChild(), 3), endOfParagraph(createVisiblePosi tionInDOMTree(*one->firstChild(), 1)).deepEquivalent());
368 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 1), endOfParagraph(creat eVisiblePositionInComposedTree(*one->firstChild(), 1)).deepEquivalent()); 368 EXPECT_EQ(PositionInFlatTree(one->firstChild(), 1), endOfParagraph(createVis iblePositionInFlatTree(*one->firstChild(), 1)).deepEquivalent());
369 369
370 EXPECT_EQ(Position(three->firstChild(), 3), endOfParagraph(createVisiblePosi tionInDOMTree(*two->firstChild(), 2)).deepEquivalent()); 370 EXPECT_EQ(Position(three->firstChild(), 3), endOfParagraph(createVisiblePosi tionInDOMTree(*two->firstChild(), 2)).deepEquivalent());
371 EXPECT_EQ(PositionInComposedTree(two->firstChild(), 2), endOfParagraph(creat eVisiblePositionInComposedTree(*two->firstChild(), 2)).deepEquivalent()); 371 EXPECT_EQ(PositionInFlatTree(two->firstChild(), 2), endOfParagraph(createVis iblePositionInFlatTree(*two->firstChild(), 2)).deepEquivalent());
372 } 372 }
373 373
374 TEST_F(VisibleUnitsTest, endOfParagraphSimple) 374 TEST_F(VisibleUnitsTest, endOfParagraphSimple)
375 { 375 {
376 setBodyContent("<div id=sample>1ab\nde</div>"); 376 setBodyContent("<div id=sample>1ab\nde</div>");
377 updateLayoutAndStyleForPainting(); 377 updateLayoutAndStyleForPainting();
378 378
379 Node* sample = document().getElementById("sample"); 379 Node* sample = document().getElementById("sample");
380 Node* text = sample->firstChild(); 380 Node* text = sample->firstChild();
381 381
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 setShadowContent(shadowContent, "host"); 413 setShadowContent(shadowContent, "host");
414 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 414 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
415 updateLayoutAndStyleForPainting(); 415 updateLayoutAndStyleForPainting();
416 416
417 Node* one = document().getElementById("one")->firstChild(); 417 Node* one = document().getElementById("one")->firstChild();
418 Node* two = document().getElementById("two")->firstChild(); 418 Node* two = document().getElementById("two")->firstChild();
419 Node* three = shadowRoot->getElementById("three")->firstChild(); 419 Node* three = shadowRoot->getElementById("three")->firstChild();
420 Node* four = shadowRoot->getElementById("four")->firstChild(); 420 Node* four = shadowRoot->getElementById("four")->firstChild();
421 421
422 EXPECT_EQ(Position(two, 2), endOfSentence(createVisiblePositionInDOMTree(*on e, 0)).deepEquivalent()); 422 EXPECT_EQ(Position(two, 2), endOfSentence(createVisiblePositionInDOMTree(*on e, 0)).deepEquivalent());
423 EXPECT_EQ(PositionInComposedTree(four, 4), endOfSentence(createVisiblePositi onInComposedTree(*one, 0)).deepEquivalent()); 423 EXPECT_EQ(PositionInFlatTree(four, 4), endOfSentence(createVisiblePositionIn FlatTree(*one, 0)).deepEquivalent());
424 424
425 EXPECT_EQ(Position(two, 2), endOfSentence(createVisiblePositionInDOMTree(*on e, 1)).deepEquivalent()); 425 EXPECT_EQ(Position(two, 2), endOfSentence(createVisiblePositionInDOMTree(*on e, 1)).deepEquivalent());
426 EXPECT_EQ(PositionInComposedTree(four, 4), endOfSentence(createVisiblePositi onInComposedTree(*one, 1)).deepEquivalent()); 426 EXPECT_EQ(PositionInFlatTree(four, 4), endOfSentence(createVisiblePositionIn FlatTree(*one, 1)).deepEquivalent());
427 427
428 EXPECT_EQ(Position(two, 2), endOfSentence(createVisiblePositionInDOMTree(*tw o, 0)).deepEquivalent()); 428 EXPECT_EQ(Position(two, 2), endOfSentence(createVisiblePositionInDOMTree(*tw o, 0)).deepEquivalent());
429 EXPECT_EQ(PositionInComposedTree(four, 4), endOfSentence(createVisiblePositi onInComposedTree(*two, 0)).deepEquivalent()); 429 EXPECT_EQ(PositionInFlatTree(four, 4), endOfSentence(createVisiblePositionIn FlatTree(*two, 0)).deepEquivalent());
430 430
431 EXPECT_EQ(Position(two, 2), endOfSentence(createVisiblePositionInDOMTree(*tw o, 1)).deepEquivalent()); 431 EXPECT_EQ(Position(two, 2), endOfSentence(createVisiblePositionInDOMTree(*tw o, 1)).deepEquivalent());
432 EXPECT_EQ(PositionInComposedTree(four, 4), endOfSentence(createVisiblePositi onInComposedTree(*two, 1)).deepEquivalent()); 432 EXPECT_EQ(PositionInFlatTree(four, 4), endOfSentence(createVisiblePositionIn FlatTree(*two, 1)).deepEquivalent());
433 433
434 EXPECT_EQ(Position(four, 4), endOfSentence(createVisiblePositionInDOMTree(*t hree, 1)).deepEquivalent()); 434 EXPECT_EQ(Position(four, 4), endOfSentence(createVisiblePositionInDOMTree(*t hree, 1)).deepEquivalent());
435 EXPECT_EQ(PositionInComposedTree(four, 4), endOfSentence(createVisiblePositi onInComposedTree(*three, 1)).deepEquivalent()); 435 EXPECT_EQ(PositionInFlatTree(four, 4), endOfSentence(createVisiblePositionIn FlatTree(*three, 1)).deepEquivalent());
436 436
437 EXPECT_EQ(Position(four, 4), endOfSentence(createVisiblePositionInDOMTree(*f our, 1)).deepEquivalent()); 437 EXPECT_EQ(Position(four, 4), endOfSentence(createVisiblePositionInDOMTree(*f our, 1)).deepEquivalent());
438 EXPECT_EQ(PositionInComposedTree(four, 4), endOfSentence(createVisiblePositi onInComposedTree(*four, 1)).deepEquivalent()); 438 EXPECT_EQ(PositionInFlatTree(four, 4), endOfSentence(createVisiblePositionIn FlatTree(*four, 1)).deepEquivalent());
439 } 439 }
440 440
441 TEST_F(VisibleUnitsTest, endOfWord) 441 TEST_F(VisibleUnitsTest, endOfWord)
442 { 442 {
443 const char* bodyContent = "<a id=host><b id=one>1</b> <b id=two>22</b></a><i id=three>333</i>"; 443 const char* bodyContent = "<a id=host><b id=one>1</b> <b id=two>22</b></a><i id=three>333</i>";
444 const char* shadowContent = "<p><u id=four>44444</u><content select=#two></c ontent><span id=space> </span><content select=#one></content><u id=five>55555</u ></p>"; 444 const char* shadowContent = "<p><u id=four>44444</u><content select=#two></c ontent><span id=space> </span><content select=#one></content><u id=five>55555</u ></p>";
445 setBodyContent(bodyContent); 445 setBodyContent(bodyContent);
446 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 446 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
447 updateLayoutAndStyleForPainting(); 447 updateLayoutAndStyleForPainting();
448 448
449 Node* one = document().getElementById("one")->firstChild(); 449 Node* one = document().getElementById("one")->firstChild();
450 Node* two = document().getElementById("two")->firstChild(); 450 Node* two = document().getElementById("two")->firstChild();
451 Node* three = document().getElementById("three")->firstChild(); 451 Node* three = document().getElementById("three")->firstChild();
452 Node* four = shadowRoot->getElementById("four")->firstChild(); 452 Node* four = shadowRoot->getElementById("four")->firstChild();
453 Node* five = shadowRoot->getElementById("five")->firstChild(); 453 Node* five = shadowRoot->getElementById("five")->firstChild();
454 454
455 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent()); 455 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent());
456 EXPECT_EQ(PositionInComposedTree(five, 5), endOfWord(createVisiblePositionIn ComposedTree(*one, 0)).deepEquivalent()); 456 EXPECT_EQ(PositionInFlatTree(five, 5), endOfWord(createVisiblePositionInFlat Tree(*one, 0)).deepEquivalent());
457 457
458 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*one, 1)).deepEquivalent()); 458 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*one, 1)).deepEquivalent());
459 EXPECT_EQ(PositionInComposedTree(five, 5), endOfWord(createVisiblePositionIn ComposedTree(*one, 1)).deepEquivalent()); 459 EXPECT_EQ(PositionInFlatTree(five, 5), endOfWord(createVisiblePositionInFlat Tree(*one, 1)).deepEquivalent());
460 460
461 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*two, 0)).deepEquivalent()); 461 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*two, 0)).deepEquivalent());
462 EXPECT_EQ(PositionInComposedTree(two, 2), endOfWord(createVisiblePositionInC omposedTree(*two, 0)).deepEquivalent()); 462 EXPECT_EQ(PositionInFlatTree(two, 2), endOfWord(createVisiblePositionInFlatT ree(*two, 0)).deepEquivalent());
463 463
464 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*two, 1)).deepEquivalent()); 464 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*two, 1)).deepEquivalent());
465 EXPECT_EQ(PositionInComposedTree(two, 2), endOfWord(createVisiblePositionInC omposedTree(*two, 1)).deepEquivalent()); 465 EXPECT_EQ(PositionInFlatTree(two, 2), endOfWord(createVisiblePositionInFlatT ree(*two, 1)).deepEquivalent());
466 466
467 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*thre e, 1)).deepEquivalent()); 467 EXPECT_EQ(Position(three, 3), endOfWord(createVisiblePositionInDOMTree(*thre e, 1)).deepEquivalent());
468 EXPECT_EQ(PositionInComposedTree(three, 3), endOfWord(createVisiblePositionI nComposedTree(*three, 1)).deepEquivalent()); 468 EXPECT_EQ(PositionInFlatTree(three, 3), endOfWord(createVisiblePositionInFla tTree(*three, 1)).deepEquivalent());
469 469
470 EXPECT_EQ(Position(four, 5), endOfWord(createVisiblePositionInDOMTree(*four, 1)).deepEquivalent()); 470 EXPECT_EQ(Position(four, 5), endOfWord(createVisiblePositionInDOMTree(*four, 1)).deepEquivalent());
471 EXPECT_EQ(PositionInComposedTree(two, 2), endOfWord(createVisiblePositionInC omposedTree(*four, 1)).deepEquivalent()); 471 EXPECT_EQ(PositionInFlatTree(two, 2), endOfWord(createVisiblePositionInFlatT ree(*four, 1)).deepEquivalent());
472 472
473 EXPECT_EQ(Position(five, 5), endOfWord(createVisiblePositionInDOMTree(*five, 1)).deepEquivalent()); 473 EXPECT_EQ(Position(five, 5), endOfWord(createVisiblePositionInDOMTree(*five, 1)).deepEquivalent());
474 EXPECT_EQ(PositionInComposedTree(five, 5), endOfWord(createVisiblePositionIn ComposedTree(*five, 1)).deepEquivalent()); 474 EXPECT_EQ(PositionInFlatTree(five, 5), endOfWord(createVisiblePositionInFlat Tree(*five, 1)).deepEquivalent());
475 } 475 }
476 476
477 TEST_F(VisibleUnitsTest, isEndOfEditableOrNonEditableContent) 477 TEST_F(VisibleUnitsTest, isEndOfEditableOrNonEditableContent)
478 { 478 {
479 const char* bodyContent = "<a id=host><b id=one contenteditable>1</b><b id=t wo>22</b></a>"; 479 const char* bodyContent = "<a id=host><b id=one contenteditable>1</b><b id=t wo>22</b></a>";
480 const char* shadowContent = "<content select=#two></content></p><p><content select=#one></content>"; 480 const char* shadowContent = "<content select=#two></content></p><p><content select=#one></content>";
481 setBodyContent(bodyContent); 481 setBodyContent(bodyContent);
482 setShadowContent(shadowContent, "host"); 482 setShadowContent(shadowContent, "host");
483 updateLayoutAndStyleForPainting(); 483 updateLayoutAndStyleForPainting();
484 484
485 Element* one = document().getElementById("one"); 485 Element* one = document().getElementById("one");
486 Element* two = document().getElementById("two"); 486 Element* two = document().getElementById("two");
487 487
488 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT ree(*one->firstChild(), 1))); 488 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT ree(*one->firstChild(), 1)));
489 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInCompo sedTree(*one->firstChild(), 1))); 489 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInFlatT ree(*one->firstChild(), 1)));
490 490
491 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr ee(*two->firstChild(), 2))); 491 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr ee(*two->firstChild(), 2)));
492 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInComp osedTree(*two->firstChild(), 2))); 492 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInFlat Tree(*two->firstChild(), 2)));
493 } 493 }
494 494
495 TEST_F(VisibleUnitsTest, isEndOfEditableOrNonEditableContentWithInput) 495 TEST_F(VisibleUnitsTest, isEndOfEditableOrNonEditableContentWithInput)
496 { 496 {
497 const char* bodyContent = "<input id=sample value=ab>cde"; 497 const char* bodyContent = "<input id=sample value=ab>cde";
498 setBodyContent(bodyContent); 498 setBodyContent(bodyContent);
499 updateLayoutAndStyleForPainting(); 499 updateLayoutAndStyleForPainting();
500 500
501 Node* text = toHTMLTextFormControlElement(document().getElementById("sample" ))->innerEditorElement()->firstChild(); 501 Node* text = toHTMLTextFormControlElement(document().getElementById("sample" ))->innerEditorElement()->firstChild();
502 502
503 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT ree(*text, 0))); 503 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT ree(*text, 0)));
504 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInComp osedTree(*text, 0))); 504 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInFlat Tree(*text, 0)));
505 505
506 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT ree(*text, 1))); 506 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT ree(*text, 1)));
507 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInComp osedTree(*text, 1))); 507 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInFlat Tree(*text, 1)));
508 508
509 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr ee(*text, 2))); 509 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr ee(*text, 2)));
510 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInCompo sedTree(*text, 2))); 510 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInFlatT ree(*text, 2)));
511 } 511 }
512 512
513 TEST_F(VisibleUnitsTest, isEndOfLine) 513 TEST_F(VisibleUnitsTest, isEndOfLine)
514 { 514 {
515 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>"; 515 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>";
516 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>"; 516 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>";
517 setBodyContent(bodyContent); 517 setBodyContent(bodyContent);
518 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 518 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
519 updateLayoutAndStyleForPainting(); 519 updateLayoutAndStyleForPainting();
520 520
521 Node* one = document().getElementById("one")->firstChild(); 521 Node* one = document().getElementById("one")->firstChild();
522 Node* two = document().getElementById("two")->firstChild(); 522 Node* two = document().getElementById("two")->firstChild();
523 Node* three = document().getElementById("three")->firstChild(); 523 Node* three = document().getElementById("three")->firstChild();
524 Node* four = document().getElementById("four")->firstChild(); 524 Node* four = document().getElementById("four")->firstChild();
525 Node* five = shadowRoot->getElementById("five")->firstChild(); 525 Node* five = shadowRoot->getElementById("five")->firstChild();
526 Node* six = shadowRoot->getElementById("six")->firstChild(); 526 Node* six = shadowRoot->getElementById("six")->firstChild();
527 Node* seven = shadowRoot->getElementById("seven")->firstChild(); 527 Node* seven = shadowRoot->getElementById("seven")->firstChild();
528 528
529 EXPECT_FALSE(isEndOfLine(createVisiblePositionInDOMTree(*one, 0))); 529 EXPECT_FALSE(isEndOfLine(createVisiblePositionInDOMTree(*one, 0)));
530 EXPECT_FALSE(isEndOfLine(createVisiblePositionInComposedTree(*one, 0))); 530 EXPECT_FALSE(isEndOfLine(createVisiblePositionInFlatTree(*one, 0)));
531 531
532 EXPECT_FALSE(isEndOfLine(createVisiblePositionInDOMTree(*one, 1))); 532 EXPECT_FALSE(isEndOfLine(createVisiblePositionInDOMTree(*one, 1)));
533 EXPECT_FALSE(isEndOfLine(createVisiblePositionInComposedTree(*one, 1))); 533 EXPECT_FALSE(isEndOfLine(createVisiblePositionInFlatTree(*one, 1)));
534 534
535 EXPECT_FALSE(isEndOfLine(createVisiblePositionInDOMTree(*two, 2))); 535 EXPECT_FALSE(isEndOfLine(createVisiblePositionInDOMTree(*two, 2)));
536 EXPECT_TRUE(isEndOfLine(createVisiblePositionInComposedTree(*two, 2))); 536 EXPECT_TRUE(isEndOfLine(createVisiblePositionInFlatTree(*two, 2)));
537 537
538 EXPECT_FALSE(isEndOfLine(createVisiblePositionInDOMTree(*three, 3))); 538 EXPECT_FALSE(isEndOfLine(createVisiblePositionInDOMTree(*three, 3)));
539 EXPECT_FALSE(isEndOfLine(createVisiblePositionInComposedTree(*three, 3))); 539 EXPECT_FALSE(isEndOfLine(createVisiblePositionInFlatTree(*three, 3)));
540 540
541 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*four, 4))); 541 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*four, 4)));
542 EXPECT_TRUE(isEndOfLine(createVisiblePositionInComposedTree(*four, 4))); 542 EXPECT_TRUE(isEndOfLine(createVisiblePositionInFlatTree(*four, 4)));
543 543
544 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*five, 5))); 544 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*five, 5)));
545 EXPECT_FALSE(isEndOfLine(createVisiblePositionInComposedTree(*five, 5))); 545 EXPECT_FALSE(isEndOfLine(createVisiblePositionInFlatTree(*five, 5)));
546 546
547 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*six, 6))); 547 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*six, 6)));
548 EXPECT_TRUE(isEndOfLine(createVisiblePositionInComposedTree(*six, 6))); 548 EXPECT_TRUE(isEndOfLine(createVisiblePositionInFlatTree(*six, 6)));
549 549
550 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*seven, 7))); 550 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*seven, 7)));
551 EXPECT_TRUE(isEndOfLine(createVisiblePositionInComposedTree(*seven, 7))); 551 EXPECT_TRUE(isEndOfLine(createVisiblePositionInFlatTree(*seven, 7)));
552 } 552 }
553 553
554 TEST_F(VisibleUnitsTest, isLogicalEndOfLine) 554 TEST_F(VisibleUnitsTest, isLogicalEndOfLine)
555 { 555 {
556 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>"; 556 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>";
557 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>"; 557 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>";
558 setBodyContent(bodyContent); 558 setBodyContent(bodyContent);
559 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 559 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
560 updateLayoutAndStyleForPainting(); 560 updateLayoutAndStyleForPainting();
561 561
562 Node* one = document().getElementById("one")->firstChild(); 562 Node* one = document().getElementById("one")->firstChild();
563 Node* two = document().getElementById("two")->firstChild(); 563 Node* two = document().getElementById("two")->firstChild();
564 Node* three = document().getElementById("three")->firstChild(); 564 Node* three = document().getElementById("three")->firstChild();
565 Node* four = document().getElementById("four")->firstChild(); 565 Node* four = document().getElementById("four")->firstChild();
566 Node* five = shadowRoot->getElementById("five")->firstChild(); 566 Node* five = shadowRoot->getElementById("five")->firstChild();
567 Node* six = shadowRoot->getElementById("six")->firstChild(); 567 Node* six = shadowRoot->getElementById("six")->firstChild();
568 Node* seven = shadowRoot->getElementById("seven")->firstChild(); 568 Node* seven = shadowRoot->getElementById("seven")->firstChild();
569 569
570 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*one, 0))); 570 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*one, 0)));
571 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInComposedTree(*one, 0) )); 571 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInFlatTree(*one, 0)));
572 572
573 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*one, 1))); 573 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*one, 1)));
574 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInComposedTree(*one, 1) )); 574 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInFlatTree(*one, 1)));
575 575
576 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*two, 2))); 576 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*two, 2)));
577 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInComposedTree(*two, 2)) ); 577 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInFlatTree(*two, 2)));
578 578
579 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*three, 3))); 579 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*three, 3)));
580 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInComposedTree(*three, 3))); 580 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInFlatTree(*three, 3))) ;
581 581
582 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*four, 4))); 582 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*four, 4)));
583 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInComposedTree(*four, 4) )); 583 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInFlatTree(*four, 4)));
584 584
585 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*five, 5))); 585 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*five, 5)));
586 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInComposedTree(*five, 5 ))); 586 EXPECT_FALSE(isLogicalEndOfLine(createVisiblePositionInFlatTree(*five, 5)));
587 587
588 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*six, 6))); 588 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*six, 6)));
589 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInComposedTree(*six, 6)) ); 589 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInFlatTree(*six, 6)));
590 590
591 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*seven, 7))); 591 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*seven, 7)));
592 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInComposedTree(*seven, 7 ))); 592 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInFlatTree(*seven, 7)));
593 } 593 }
594 594
595 TEST_F(VisibleUnitsTest, inSameLine) 595 TEST_F(VisibleUnitsTest, inSameLine)
596 { 596 {
597 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>"; 597 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>";
598 const char* shadowContent = "<div><span id='s4'>44</span><content select=#tw o></content><br><span id='s5'>55</span><br><content select=#one></content><span id='s6'>66</span></div>"; 598 const char* shadowContent = "<div><span id='s4'>44</span><content select=#tw o></content><br><span id='s5'>55</span><br><content select=#one></content><span id='s6'>66</span></div>";
599 setBodyContent(bodyContent); 599 setBodyContent(bodyContent);
600 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 600 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
601 updateLayoutAndStyleForPainting(); 601 updateLayoutAndStyleForPainting();
602 602
603 RefPtrWillBeRawPtr<Element> body = document().body(); 603 RefPtrWillBeRawPtr<Element> body = document().body();
604 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION); 604 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION);
605 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION); 605 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION);
606 RefPtrWillBeRawPtr<Element> four = shadowRoot->querySelector("#s4", ASSERT_N O_EXCEPTION); 606 RefPtrWillBeRawPtr<Element> four = shadowRoot->querySelector("#s4", ASSERT_N O_EXCEPTION);
607 RefPtrWillBeRawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_N O_EXCEPTION); 607 RefPtrWillBeRawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_N O_EXCEPTION);
608 608
609 EXPECT_TRUE(inSameLine(positionWithAffinityInDOMTree(*one, 0), positionWithA ffinityInDOMTree(*two, 0))); 609 EXPECT_TRUE(inSameLine(positionWithAffinityInDOMTree(*one, 0), positionWithA ffinityInDOMTree(*two, 0)));
610 EXPECT_TRUE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0), positionWithAffinityInDOMTree(*two->firstChild(), 0))); 610 EXPECT_TRUE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0), positionWithAffinityInDOMTree(*two->firstChild(), 0)));
611 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0) , positionWithAffinityInDOMTree(*five->firstChild(), 0))); 611 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0) , positionWithAffinityInDOMTree(*five->firstChild(), 0)));
612 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*two->firstChild(), 0) , positionWithAffinityInDOMTree(*four->firstChild(), 0))); 612 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*two->firstChild(), 0) , positionWithAffinityInDOMTree(*four->firstChild(), 0)));
613 613
614 EXPECT_TRUE(inSameLine(createVisiblePositionInDOMTree(*one, 0), createVisibl ePositionInDOMTree(*two, 0))); 614 EXPECT_TRUE(inSameLine(createVisiblePositionInDOMTree(*one, 0), createVisibl ePositionInDOMTree(*two, 0)));
615 EXPECT_TRUE(inSameLine(createVisiblePositionInDOMTree(*one->firstChild(), 0) , createVisiblePositionInDOMTree(*two->firstChild(), 0))); 615 EXPECT_TRUE(inSameLine(createVisiblePositionInDOMTree(*one->firstChild(), 0) , createVisiblePositionInDOMTree(*two->firstChild(), 0)));
616 EXPECT_FALSE(inSameLine(createVisiblePositionInDOMTree(*one->firstChild(), 0 ), createVisiblePositionInDOMTree(*five->firstChild(), 0))); 616 EXPECT_FALSE(inSameLine(createVisiblePositionInDOMTree(*one->firstChild(), 0 ), createVisiblePositionInDOMTree(*five->firstChild(), 0)));
617 EXPECT_FALSE(inSameLine(createVisiblePositionInDOMTree(*two->firstChild(), 0 ), createVisiblePositionInDOMTree(*four->firstChild(), 0))); 617 EXPECT_FALSE(inSameLine(createVisiblePositionInDOMTree(*two->firstChild(), 0 ), createVisiblePositionInDOMTree(*four->firstChild(), 0)));
618 618
619 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one, 0), positio nWithAffinityInComposedTree(*two, 0))); 619 EXPECT_FALSE(inSameLine(positionWithAffinityInFlatTree(*one, 0), positionWit hAffinityInFlatTree(*two, 0)));
620 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*two->firstChild(), 0))); 620 EXPECT_FALSE(inSameLine(positionWithAffinityInFlatTree(*one->firstChild(), 0 ), positionWithAffinityInFlatTree(*two->firstChild(), 0)));
621 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*five->firstChild(), 0))); 621 EXPECT_FALSE(inSameLine(positionWithAffinityInFlatTree(*one->firstChild(), 0 ), positionWithAffinityInFlatTree(*five->firstChild(), 0)));
622 EXPECT_TRUE(inSameLine(positionWithAffinityInComposedTree(*two->firstChild() , 0), positionWithAffinityInComposedTree(*four->firstChild(), 0))); 622 EXPECT_TRUE(inSameLine(positionWithAffinityInFlatTree(*two->firstChild(), 0) , positionWithAffinityInFlatTree(*four->firstChild(), 0)));
623 623
624 EXPECT_FALSE(inSameLine(createVisiblePositionInComposedTree(*one, 0), create VisiblePositionInComposedTree(*two, 0))); 624 EXPECT_FALSE(inSameLine(createVisiblePositionInFlatTree(*one, 0), createVisi blePositionInFlatTree(*two, 0)));
625 EXPECT_FALSE(inSameLine(createVisiblePositionInComposedTree(*one->firstChild (), 0), createVisiblePositionInComposedTree(*two->firstChild(), 0))); 625 EXPECT_FALSE(inSameLine(createVisiblePositionInFlatTree(*one->firstChild(), 0), createVisiblePositionInFlatTree(*two->firstChild(), 0)));
626 EXPECT_FALSE(inSameLine(createVisiblePositionInComposedTree(*one->firstChild (), 0), createVisiblePositionInComposedTree(*five->firstChild(), 0))); 626 EXPECT_FALSE(inSameLine(createVisiblePositionInFlatTree(*one->firstChild(), 0), createVisiblePositionInFlatTree(*five->firstChild(), 0)));
627 EXPECT_TRUE(inSameLine(createVisiblePositionInComposedTree(*two->firstChild( ), 0), createVisiblePositionInComposedTree(*four->firstChild(), 0))); 627 EXPECT_TRUE(inSameLine(createVisiblePositionInFlatTree(*two->firstChild(), 0 ), createVisiblePositionInFlatTree(*four->firstChild(), 0)));
628 } 628 }
629 629
630 TEST_F(VisibleUnitsTest, isEndOfParagraph) 630 TEST_F(VisibleUnitsTest, isEndOfParagraph)
631 { 631 {
632 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a><b id=three>333</b>"; 632 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a><b id=three>333</b>";
633 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>"; 633 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>";
634 setBodyContent(bodyContent); 634 setBodyContent(bodyContent);
635 setShadowContent(shadowContent, "host"); 635 setShadowContent(shadowContent, "host");
636 updateLayoutAndStyleForPainting(); 636 updateLayoutAndStyleForPainting();
637 637
638 Node* one = document().getElementById("one")->firstChild(); 638 Node* one = document().getElementById("one")->firstChild();
639 Node* two = document().getElementById("two")->firstChild(); 639 Node* two = document().getElementById("two")->firstChild();
640 Node* three = document().getElementById("three")->firstChild(); 640 Node* three = document().getElementById("three")->firstChild();
641 641
642 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInDOMTree(*one, 0))); 642 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInDOMTree(*one, 0)));
643 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInComposedTree(*one, 0))) ; 643 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInFlatTree(*one, 0)));
644 644
645 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInDOMTree(*one, 1))); 645 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInDOMTree(*one, 1)));
646 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInComposedTree(*one, 1))); 646 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInFlatTree(*one, 1)));
647 647
648 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInDOMTree(*two, 2))); 648 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInDOMTree(*two, 2)));
649 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInComposedTree(*two, 2))); 649 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInFlatTree(*two, 2)));
650 650
651 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInDOMTree(*three, 0))); 651 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInDOMTree(*three, 0)));
652 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInComposedTree(*three, 0) )); 652 EXPECT_FALSE(isEndOfParagraph(createVisiblePositionInFlatTree(*three, 0)));
653 653
654 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInDOMTree(*three, 3))); 654 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInDOMTree(*three, 3)));
655 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInComposedTree(*three, 3)) ); 655 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInFlatTree(*three, 3)));
656 } 656 }
657 657
658 TEST_F(VisibleUnitsTest, isStartOfLine) 658 TEST_F(VisibleUnitsTest, isStartOfLine)
659 { 659 {
660 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>"; 660 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>";
661 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>"; 661 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>";
662 setBodyContent(bodyContent); 662 setBodyContent(bodyContent);
663 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 663 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
664 updateLayoutAndStyleForPainting(); 664 updateLayoutAndStyleForPainting();
665 665
666 Node* one = document().getElementById("one")->firstChild(); 666 Node* one = document().getElementById("one")->firstChild();
667 Node* two = document().getElementById("two")->firstChild(); 667 Node* two = document().getElementById("two")->firstChild();
668 Node* three = document().getElementById("three")->firstChild(); 668 Node* three = document().getElementById("three")->firstChild();
669 Node* four = document().getElementById("four")->firstChild(); 669 Node* four = document().getElementById("four")->firstChild();
670 Node* five = shadowRoot->getElementById("five")->firstChild(); 670 Node* five = shadowRoot->getElementById("five")->firstChild();
671 Node* six = shadowRoot->getElementById("six")->firstChild(); 671 Node* six = shadowRoot->getElementById("six")->firstChild();
672 Node* seven = shadowRoot->getElementById("seven")->firstChild(); 672 Node* seven = shadowRoot->getElementById("seven")->firstChild();
673 673
674 EXPECT_TRUE(isStartOfLine(createVisiblePositionInDOMTree(*one, 0))); 674 EXPECT_TRUE(isStartOfLine(createVisiblePositionInDOMTree(*one, 0)));
675 EXPECT_TRUE(isStartOfLine(createVisiblePositionInComposedTree(*one, 0))); 675 EXPECT_TRUE(isStartOfLine(createVisiblePositionInFlatTree(*one, 0)));
676 676
677 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*one, 1))); 677 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*one, 1)));
678 EXPECT_FALSE(isStartOfLine(createVisiblePositionInComposedTree(*one, 1))); 678 EXPECT_FALSE(isStartOfLine(createVisiblePositionInFlatTree(*one, 1)));
679 679
680 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*two, 0))); 680 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*two, 0)));
681 EXPECT_FALSE(isStartOfLine(createVisiblePositionInComposedTree(*two, 0))); 681 EXPECT_FALSE(isStartOfLine(createVisiblePositionInFlatTree(*two, 0)));
682 682
683 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*three, 0))); 683 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*three, 0)));
684 EXPECT_TRUE(isStartOfLine(createVisiblePositionInComposedTree(*three, 0))); 684 EXPECT_TRUE(isStartOfLine(createVisiblePositionInFlatTree(*three, 0)));
685 685
686 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*four, 0))); 686 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*four, 0)));
687 EXPECT_FALSE(isStartOfLine(createVisiblePositionInComposedTree(*four, 0))); 687 EXPECT_FALSE(isStartOfLine(createVisiblePositionInFlatTree(*four, 0)));
688 688
689 EXPECT_TRUE(isStartOfLine(createVisiblePositionInDOMTree(*five, 0))); 689 EXPECT_TRUE(isStartOfLine(createVisiblePositionInDOMTree(*five, 0)));
690 EXPECT_TRUE(isStartOfLine(createVisiblePositionInComposedTree(*five, 0))); 690 EXPECT_TRUE(isStartOfLine(createVisiblePositionInFlatTree(*five, 0)));
691 691
692 EXPECT_TRUE(isStartOfLine(createVisiblePositionInDOMTree(*six, 0))); 692 EXPECT_TRUE(isStartOfLine(createVisiblePositionInDOMTree(*six, 0)));
693 EXPECT_TRUE(isStartOfLine(createVisiblePositionInComposedTree(*six, 0))); 693 EXPECT_TRUE(isStartOfLine(createVisiblePositionInFlatTree(*six, 0)));
694 694
695 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*seven, 0))); 695 EXPECT_FALSE(isStartOfLine(createVisiblePositionInDOMTree(*seven, 0)));
696 EXPECT_FALSE(isStartOfLine(createVisiblePositionInComposedTree(*seven, 0))); 696 EXPECT_FALSE(isStartOfLine(createVisiblePositionInFlatTree(*seven, 0)));
697 } 697 }
698 698
699 TEST_F(VisibleUnitsTest, isStartOfParagraph) 699 TEST_F(VisibleUnitsTest, isStartOfParagraph)
700 { 700 {
701 const char* bodyContent = "<b id=zero>0</b><a id=host><b id=one>1</b><b id=t wo>22</b></a><b id=three>333</b>"; 701 const char* bodyContent = "<b id=zero>0</b><a id=host><b id=one>1</b><b id=t wo>22</b></a><b id=three>333</b>";
702 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>"; 702 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>";
703 setBodyContent(bodyContent); 703 setBodyContent(bodyContent);
704 setShadowContent(shadowContent, "host"); 704 setShadowContent(shadowContent, "host");
705 updateLayoutAndStyleForPainting(); 705 updateLayoutAndStyleForPainting();
706 706
707 Node* zero = document().getElementById("zero")->firstChild(); 707 Node* zero = document().getElementById("zero")->firstChild();
708 Node* one = document().getElementById("one")->firstChild(); 708 Node* one = document().getElementById("one")->firstChild();
709 Node* two = document().getElementById("two")->firstChild(); 709 Node* two = document().getElementById("two")->firstChild();
710 Node* three = document().getElementById("three")->firstChild(); 710 Node* three = document().getElementById("three")->firstChild();
711 711
712 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInDOMTree(*zero, 0))); 712 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInDOMTree(*zero, 0)));
713 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInComposedTree(*zero, 0) )); 713 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInFlatTree(*zero, 0)));
714 714
715 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*one, 0))); 715 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*one, 0)));
716 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInComposedTree(*one, 0)) ); 716 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInFlatTree(*one, 0)));
717 717
718 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*one, 1))); 718 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*one, 1)));
719 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInComposedTree(*one, 1) )); 719 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInFlatTree(*one, 1)));
720 720
721 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*two, 0))); 721 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*two, 0)));
722 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInComposedTree(*two, 0)) ); 722 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInFlatTree(*two, 0)));
723 723
724 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*three, 0))); 724 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*three, 0)));
725 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInComposedTree(*three, 0 ))); 725 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInFlatTree(*three, 0)));
726 } 726 }
727 727
728 TEST_F(VisibleUnitsTest, isVisuallyEquivalentCandidateWithHTMLHtmlElement) 728 TEST_F(VisibleUnitsTest, isVisuallyEquivalentCandidateWithHTMLHtmlElement)
729 { 729 {
730 const char* bodyContent = "<html><div id=one contenteditable>1</div><span id =two contenteditable=false>22</span><span id=three contenteditable=false>333</sp an><span id=four contenteditable=false>333</span></html>"; 730 const char* bodyContent = "<html><div id=one contenteditable>1</div><span id =two contenteditable=false>22</span><span id=three contenteditable=false>333</sp an><span id=four contenteditable=false>333</span></html>";
731 setBodyContent(bodyContent); 731 setBodyContent(bodyContent);
732 732
733 RefPtrWillBeRawPtr<Node> one = document().querySelector("#one", ASSERT_NO_EX CEPTION); 733 RefPtrWillBeRawPtr<Node> one = document().querySelector("#one", ASSERT_NO_EX CEPTION);
734 RefPtrWillBeRawPtr<Node> two = document().querySelector("#two", ASSERT_NO_EX CEPTION); 734 RefPtrWillBeRawPtr<Node> two = document().querySelector("#two", ASSERT_NO_EX CEPTION);
735 RefPtrWillBeRawPtr<Node> three = document().querySelector("#three", ASSERT_N O_EXCEPTION); 735 RefPtrWillBeRawPtr<Node> three = document().querySelector("#three", ASSERT_N O_EXCEPTION);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 773 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
774 updateLayoutAndStyleForPainting(); 774 updateLayoutAndStyleForPainting();
775 775
776 Element* one = document().getElementById("one"); 776 Element* one = document().getElementById("one");
777 Element* two = document().getElementById("two"); 777 Element* two = document().getElementById("two");
778 Element* three = document().getElementById("three"); 778 Element* three = document().getElementById("three");
779 Element* four = shadowRoot->getElementById("four"); 779 Element* four = shadowRoot->getElementById("four");
780 Element* five = shadowRoot->getElementById("five"); 780 Element* five = shadowRoot->getElementById("five");
781 781
782 EXPECT_EQ(Position(two->firstChild(), 1), leftPositionOf(createVisiblePositi on(Position(one, 0))).deepEquivalent()); 782 EXPECT_EQ(Position(two->firstChild(), 1), leftPositionOf(createVisiblePositi on(Position(one, 0))).deepEquivalent());
783 EXPECT_EQ(PositionInComposedTree(two->firstChild(), 1), leftPositionOf(creat eVisiblePosition(PositionInComposedTree(one, 0))).deepEquivalent()); 783 EXPECT_EQ(PositionInFlatTree(two->firstChild(), 1), leftPositionOf(createVis iblePosition(PositionInFlatTree(one, 0))).deepEquivalent());
784 784
785 EXPECT_EQ(Position(one->firstChild(), 0), leftPositionOf(createVisiblePositi on(Position(two, 0))).deepEquivalent()); 785 EXPECT_EQ(Position(one->firstChild(), 0), leftPositionOf(createVisiblePositi on(Position(two, 0))).deepEquivalent());
786 EXPECT_EQ(PositionInComposedTree(four->firstChild(), 3), leftPositionOf(crea teVisiblePosition(PositionInComposedTree(two, 0))).deepEquivalent()); 786 EXPECT_EQ(PositionInFlatTree(four->firstChild(), 3), leftPositionOf(createVi siblePosition(PositionInFlatTree(two, 0))).deepEquivalent());
787 787
788 EXPECT_EQ(Position(two->firstChild(), 2), leftPositionOf(createVisiblePositi on(Position(three, 0))).deepEquivalent()); 788 EXPECT_EQ(Position(two->firstChild(), 2), leftPositionOf(createVisiblePositi on(Position(three, 0))).deepEquivalent());
789 EXPECT_EQ(PositionInComposedTree(five->firstChild(), 5), leftPositionOf(crea teVisiblePosition(PositionInComposedTree(three, 0))).deepEquivalent()); 789 EXPECT_EQ(PositionInFlatTree(five->firstChild(), 5), leftPositionOf(createVi siblePosition(PositionInFlatTree(three, 0))).deepEquivalent());
790 } 790 }
791 791
792 TEST_F(VisibleUnitsTest, localCaretRectOfPosition) 792 TEST_F(VisibleUnitsTest, localCaretRectOfPosition)
793 { 793 {
794 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>"; 794 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>";
795 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; 795 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>";
796 setBodyContent(bodyContent); 796 setBodyContent(bodyContent);
797 setShadowContent(shadowContent, "host"); 797 setShadowContent(shadowContent, "host");
798 updateLayoutAndStyleForPainting(); 798 updateLayoutAndStyleForPainting();
799 799
800 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 800 RefPtrWillBeRawPtr<Element> one = document().getElementById("one");
801 801
802 LayoutObject* layoutObjectFromDOMTree; 802 LayoutObject* layoutObjectFromDOMTree;
803 LayoutRect layoutRectFromDOMTree = localCaretRectOfPosition(Position(one->fi rstChild(), 0), layoutObjectFromDOMTree); 803 LayoutRect layoutRectFromDOMTree = localCaretRectOfPosition(Position(one->fi rstChild(), 0), layoutObjectFromDOMTree);
804 804
805 LayoutObject* layoutObjectFromComposedTree; 805 LayoutObject* layoutObjectFromFlatTree;
806 LayoutRect layoutRectFromComposedTree = localCaretRectOfPosition(PositionInC omposedTree(one->firstChild(), 0), layoutObjectFromComposedTree); 806 LayoutRect layoutRectFromFlatTree = localCaretRectOfPosition(PositionInFlatT ree(one->firstChild(), 0), layoutObjectFromFlatTree);
807 807
808 EXPECT_TRUE(layoutObjectFromDOMTree); 808 EXPECT_TRUE(layoutObjectFromDOMTree);
809 EXPECT_FALSE(layoutRectFromDOMTree.isEmpty()); 809 EXPECT_FALSE(layoutRectFromDOMTree.isEmpty());
810 EXPECT_EQ(layoutObjectFromDOMTree, layoutObjectFromComposedTree); 810 EXPECT_EQ(layoutObjectFromDOMTree, layoutObjectFromFlatTree);
811 EXPECT_EQ(layoutRectFromDOMTree, layoutRectFromComposedTree); 811 EXPECT_EQ(layoutRectFromDOMTree, layoutRectFromFlatTree);
812 } 812 }
813 813
814 TEST_F(VisibleUnitsTest, logicalEndOfLine) 814 TEST_F(VisibleUnitsTest, logicalEndOfLine)
815 { 815 {
816 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>"; 816 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>";
817 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>"; 817 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>";
818 setBodyContent(bodyContent); 818 setBodyContent(bodyContent);
819 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 819 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
820 updateLayoutAndStyleForPainting(); 820 updateLayoutAndStyleForPainting();
821 821
822 Node* one = document().getElementById("one")->firstChild(); 822 Node* one = document().getElementById("one")->firstChild();
823 Node* two = document().getElementById("two")->firstChild(); 823 Node* two = document().getElementById("two")->firstChild();
824 Node* three = document().getElementById("three")->firstChild(); 824 Node* three = document().getElementById("three")->firstChild();
825 Node* four = document().getElementById("four")->firstChild(); 825 Node* four = document().getElementById("four")->firstChild();
826 Node* five = shadowRoot->getElementById("five")->firstChild(); 826 Node* five = shadowRoot->getElementById("five")->firstChild();
827 Node* six = shadowRoot->getElementById("six")->firstChild(); 827 Node* six = shadowRoot->getElementById("six")->firstChild();
828 Node* seven = shadowRoot->getElementById("seven")->firstChild(); 828 Node* seven = shadowRoot->getElementById("seven")->firstChild();
829 829
830 EXPECT_EQ(Position(seven, 7), logicalEndOfLine(createVisiblePositionInDOMTre e(*one, 0)).deepEquivalent()); 830 EXPECT_EQ(Position(seven, 7), logicalEndOfLine(createVisiblePositionInDOMTre e(*one, 0)).deepEquivalent());
831 EXPECT_EQ(PositionInComposedTree(seven, 7), logicalEndOfLine(createVisiblePo sitionInComposedTree(*one, 0)).deepEquivalent()); 831 EXPECT_EQ(PositionInFlatTree(seven, 7), logicalEndOfLine(createVisiblePositi onInFlatTree(*one, 0)).deepEquivalent());
832 832
833 EXPECT_EQ(Position(seven, 7), logicalEndOfLine(createVisiblePositionInDOMTre e(*one, 1)).deepEquivalent()); 833 EXPECT_EQ(Position(seven, 7), logicalEndOfLine(createVisiblePositionInDOMTre e(*one, 1)).deepEquivalent());
834 EXPECT_EQ(PositionInComposedTree(seven, 7), logicalEndOfLine(createVisiblePo sitionInComposedTree(*one, 1)).deepEquivalent()); 834 EXPECT_EQ(PositionInFlatTree(seven, 7), logicalEndOfLine(createVisiblePositi onInFlatTree(*one, 1)).deepEquivalent());
835 835
836 EXPECT_EQ(Position(seven, 7), logicalEndOfLine(createVisiblePositionInDOMTre e(*two, 0)).deepEquivalent()); 836 EXPECT_EQ(Position(seven, 7), logicalEndOfLine(createVisiblePositionInDOMTre e(*two, 0)).deepEquivalent());
837 EXPECT_EQ(PositionInComposedTree(two, 2), logicalEndOfLine(createVisiblePosi tionInComposedTree(*two, 0)).deepEquivalent()); 837 EXPECT_EQ(PositionInFlatTree(two, 2), logicalEndOfLine(createVisiblePosition InFlatTree(*two, 0)).deepEquivalent());
838 838
839 // TODO(yosin) logicalEndOfLine(two, 1) -> (five, 5) is a broken result. We keep 839 // TODO(yosin) logicalEndOfLine(two, 1) -> (five, 5) is a broken result. We keep
840 // it as a marker for future change. 840 // it as a marker for future change.
841 EXPECT_EQ(Position(five, 5), logicalEndOfLine(createVisiblePositionInDOMTree (*two, 1)).deepEquivalent()); 841 EXPECT_EQ(Position(five, 5), logicalEndOfLine(createVisiblePositionInDOMTree (*two, 1)).deepEquivalent());
842 EXPECT_EQ(PositionInComposedTree(two, 2), logicalEndOfLine(createVisiblePosi tionInComposedTree(*two, 1)).deepEquivalent()); 842 EXPECT_EQ(PositionInFlatTree(two, 2), logicalEndOfLine(createVisiblePosition InFlatTree(*two, 1)).deepEquivalent());
843 843
844 EXPECT_EQ(Position(five, 5), logicalEndOfLine(createVisiblePositionInDOMTree (*three, 0)).deepEquivalent()); 844 EXPECT_EQ(Position(five, 5), logicalEndOfLine(createVisiblePositionInDOMTree (*three, 0)).deepEquivalent());
845 EXPECT_EQ(PositionInComposedTree(four, 4), logicalEndOfLine(createVisiblePos itionInComposedTree(*three, 1)).deepEquivalent()); 845 EXPECT_EQ(PositionInFlatTree(four, 4), logicalEndOfLine(createVisiblePositio nInFlatTree(*three, 1)).deepEquivalent());
846 846
847 EXPECT_EQ(Position(four, 4), logicalEndOfLine(createVisiblePositionInDOMTree (*four, 1)).deepEquivalent()); 847 EXPECT_EQ(Position(four, 4), logicalEndOfLine(createVisiblePositionInDOMTree (*four, 1)).deepEquivalent());
848 EXPECT_EQ(PositionInComposedTree(four, 4), logicalEndOfLine(createVisiblePos itionInComposedTree(*four, 1)).deepEquivalent()); 848 EXPECT_EQ(PositionInFlatTree(four, 4), logicalEndOfLine(createVisiblePositio nInFlatTree(*four, 1)).deepEquivalent());
849 849
850 EXPECT_EQ(Position(five, 5), logicalEndOfLine(createVisiblePositionInDOMTree (*five, 1)).deepEquivalent()); 850 EXPECT_EQ(Position(five, 5), logicalEndOfLine(createVisiblePositionInDOMTree (*five, 1)).deepEquivalent());
851 EXPECT_EQ(PositionInComposedTree(two, 2), logicalEndOfLine(createVisiblePosi tionInComposedTree(*five, 1)).deepEquivalent()); 851 EXPECT_EQ(PositionInFlatTree(two, 2), logicalEndOfLine(createVisiblePosition InFlatTree(*five, 1)).deepEquivalent());
852 852
853 EXPECT_EQ(Position(six, 6), logicalEndOfLine(createVisiblePositionInDOMTree( *six, 1)).deepEquivalent()); 853 EXPECT_EQ(Position(six, 6), logicalEndOfLine(createVisiblePositionInDOMTree( *six, 1)).deepEquivalent());
854 EXPECT_EQ(PositionInComposedTree(six, 6), logicalEndOfLine(createVisiblePosi tionInComposedTree(*six, 1)).deepEquivalent()); 854 EXPECT_EQ(PositionInFlatTree(six, 6), logicalEndOfLine(createVisiblePosition InFlatTree(*six, 1)).deepEquivalent());
855 855
856 EXPECT_EQ(Position(seven, 7), logicalEndOfLine(createVisiblePositionInDOMTre e(*seven, 1)).deepEquivalent()); 856 EXPECT_EQ(Position(seven, 7), logicalEndOfLine(createVisiblePositionInDOMTre e(*seven, 1)).deepEquivalent());
857 EXPECT_EQ(PositionInComposedTree(seven, 7), logicalEndOfLine(createVisiblePo sitionInComposedTree(*seven, 1)).deepEquivalent()); 857 EXPECT_EQ(PositionInFlatTree(seven, 7), logicalEndOfLine(createVisiblePositi onInFlatTree(*seven, 1)).deepEquivalent());
858 } 858 }
859 859
860 TEST_F(VisibleUnitsTest, logicalStartOfLine) 860 TEST_F(VisibleUnitsTest, logicalStartOfLine)
861 { 861 {
862 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>"; 862 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>";
863 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>"; 863 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>";
864 setBodyContent(bodyContent); 864 setBodyContent(bodyContent);
865 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 865 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
866 updateLayoutAndStyleForPainting(); 866 updateLayoutAndStyleForPainting();
867 867
868 Node* one = document().getElementById("one")->firstChild(); 868 Node* one = document().getElementById("one")->firstChild();
869 Node* two = document().getElementById("two")->firstChild(); 869 Node* two = document().getElementById("two")->firstChild();
870 Node* three = document().getElementById("three")->firstChild(); 870 Node* three = document().getElementById("three")->firstChild();
871 Node* four = document().getElementById("four")->firstChild(); 871 Node* four = document().getElementById("four")->firstChild();
872 Node* five = shadowRoot->getElementById("five")->firstChild(); 872 Node* five = shadowRoot->getElementById("five")->firstChild();
873 Node* six = shadowRoot->getElementById("six")->firstChild(); 873 Node* six = shadowRoot->getElementById("six")->firstChild();
874 Node* seven = shadowRoot->getElementById("seven")->firstChild(); 874 Node* seven = shadowRoot->getElementById("seven")->firstChild();
875 875
876 EXPECT_EQ(Position(one, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*one, 0)).deepEquivalent()); 876 EXPECT_EQ(Position(one, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*one, 0)).deepEquivalent());
877 EXPECT_EQ(PositionInComposedTree(one, 0), logicalStartOfLine(createVisiblePo sitionInComposedTree(*one, 0)).deepEquivalent()); 877 EXPECT_EQ(PositionInFlatTree(one, 0), logicalStartOfLine(createVisiblePositi onInFlatTree(*one, 0)).deepEquivalent());
878 878
879 EXPECT_EQ(Position(one, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*one, 1)).deepEquivalent()); 879 EXPECT_EQ(Position(one, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*one, 1)).deepEquivalent());
880 EXPECT_EQ(PositionInComposedTree(one, 0), logicalStartOfLine(createVisiblePo sitionInComposedTree(*one, 1)).deepEquivalent()); 880 EXPECT_EQ(PositionInFlatTree(one, 0), logicalStartOfLine(createVisiblePositi onInFlatTree(*one, 1)).deepEquivalent());
881 881
882 EXPECT_EQ(Position(one, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*two, 0)).deepEquivalent()); 882 EXPECT_EQ(Position(one, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*two, 0)).deepEquivalent());
883 EXPECT_EQ(PositionInComposedTree(five, 0), logicalStartOfLine(createVisibleP ositionInComposedTree(*two, 0)).deepEquivalent()); 883 EXPECT_EQ(PositionInFlatTree(five, 0), logicalStartOfLine(createVisiblePosit ionInFlatTree(*two, 0)).deepEquivalent());
884 884
885 EXPECT_EQ(Position(five, 0), logicalStartOfLine(createVisiblePositionInDOMTr ee(*two, 1)).deepEquivalent()); 885 EXPECT_EQ(Position(five, 0), logicalStartOfLine(createVisiblePositionInDOMTr ee(*two, 1)).deepEquivalent());
886 EXPECT_EQ(PositionInComposedTree(five, 0), logicalStartOfLine(createVisibleP ositionInComposedTree(*two, 1)).deepEquivalent()); 886 EXPECT_EQ(PositionInFlatTree(five, 0), logicalStartOfLine(createVisiblePosit ionInFlatTree(*two, 1)).deepEquivalent());
887 887
888 EXPECT_EQ(Position(five, 0), logicalStartOfLine(createVisiblePositionInDOMTr ee(*three, 0)).deepEquivalent()); 888 EXPECT_EQ(Position(five, 0), logicalStartOfLine(createVisiblePositionInDOMTr ee(*three, 0)).deepEquivalent());
889 EXPECT_EQ(PositionInComposedTree(three, 0), logicalStartOfLine(createVisible PositionInComposedTree(*three, 1)).deepEquivalent()); 889 EXPECT_EQ(PositionInFlatTree(three, 0), logicalStartOfLine(createVisiblePosi tionInFlatTree(*three, 1)).deepEquivalent());
890 890
891 // TODO(yosin) logicalStartOfLine(four, 1) -> (two, 2) is a broken result. 891 // TODO(yosin) logicalStartOfLine(four, 1) -> (two, 2) is a broken result.
892 // We keep it as a marker for future change. 892 // We keep it as a marker for future change.
893 EXPECT_EQ(Position(two, 2), logicalStartOfLine(createVisiblePositionInDOMTre e(*four, 1)).deepEquivalent()); 893 EXPECT_EQ(Position(two, 2), logicalStartOfLine(createVisiblePositionInDOMTre e(*four, 1)).deepEquivalent());
894 EXPECT_EQ(PositionInComposedTree(three, 0), logicalStartOfLine(createVisible PositionInComposedTree(*four, 1)).deepEquivalent()); 894 EXPECT_EQ(PositionInFlatTree(three, 0), logicalStartOfLine(createVisiblePosi tionInFlatTree(*four, 1)).deepEquivalent());
895 895
896 EXPECT_EQ(Position(five, 0), logicalStartOfLine(createVisiblePositionInDOMTr ee(*five, 1)).deepEquivalent()); 896 EXPECT_EQ(Position(five, 0), logicalStartOfLine(createVisiblePositionInDOMTr ee(*five, 1)).deepEquivalent());
897 EXPECT_EQ(PositionInComposedTree(five, 0), logicalStartOfLine(createVisibleP ositionInComposedTree(*five, 1)).deepEquivalent()); 897 EXPECT_EQ(PositionInFlatTree(five, 0), logicalStartOfLine(createVisiblePosit ionInFlatTree(*five, 1)).deepEquivalent());
898 898
899 EXPECT_EQ(Position(six, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*six, 1)).deepEquivalent()); 899 EXPECT_EQ(Position(six, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*six, 1)).deepEquivalent());
900 EXPECT_EQ(PositionInComposedTree(six, 0), logicalStartOfLine(createVisiblePo sitionInComposedTree(*six, 1)).deepEquivalent()); 900 EXPECT_EQ(PositionInFlatTree(six, 0), logicalStartOfLine(createVisiblePositi onInFlatTree(*six, 1)).deepEquivalent());
901 901
902 EXPECT_EQ(Position(one, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*seven, 1)).deepEquivalent()); 902 EXPECT_EQ(Position(one, 0), logicalStartOfLine(createVisiblePositionInDOMTre e(*seven, 1)).deepEquivalent());
903 EXPECT_EQ(PositionInComposedTree(one, 0), logicalStartOfLine(createVisiblePo sitionInComposedTree(*seven, 1)).deepEquivalent()); 903 EXPECT_EQ(PositionInFlatTree(one, 0), logicalStartOfLine(createVisiblePositi onInFlatTree(*seven, 1)).deepEquivalent());
904 } 904 }
905 905
906 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionAfterAnchor) 906 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionAfterAnchor)
907 { 907 {
908 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>"; 908 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>";
909 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; 909 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>";
910 setBodyContent(bodyContent); 910 setBodyContent(bodyContent);
911 setShadowContent(shadowContent, "host"); 911 setShadowContent(shadowContent, "host");
912 updateLayoutAndStyleForPainting(); 912 updateLayoutAndStyleForPainting();
913 913
914 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); 914 RefPtrWillBeRawPtr<Element> host = document().getElementById("host");
915 915
916 EXPECT_EQ(Position::lastPositionInNode(host.get()), mostForwardCaretPosition (Position::afterNode(host.get()))); 916 EXPECT_EQ(Position::lastPositionInNode(host.get()), mostForwardCaretPosition (Position::afterNode(host.get())));
917 EXPECT_EQ(PositionInComposedTree::lastPositionInNode(host.get()), mostForwar dCaretPosition(PositionInComposedTree::afterNode(host.get()))); 917 EXPECT_EQ(PositionInFlatTree::lastPositionInNode(host.get()), mostForwardCar etPosition(PositionInFlatTree::afterNode(host.get())));
918 } 918 }
919 919
920 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionFirstLetter) 920 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionFirstLetter)
921 { 921 {
922 // Note: first-letter pseudo element contains letter and punctuations. 922 // Note: first-letter pseudo element contains letter and punctuations.
923 const char* bodyContent = "<style>p:first-letter {color:red;}</style><p id=s ample> (2)45 </p>"; 923 const char* bodyContent = "<style>p:first-letter {color:red;}</style><p id=s ample> (2)45 </p>";
924 setBodyContent(bodyContent); 924 setBodyContent(bodyContent);
925 updateLayoutAndStyleForPainting(); 925 updateLayoutAndStyleForPainting();
926 926
927 Node* sample = document().getElementById("sample")->firstChild(); 927 Node* sample = document().getElementById("sample")->firstChild();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; 966 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>";
967 setBodyContent(bodyContent); 967 setBodyContent(bodyContent);
968 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 968 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
969 updateLayoutAndStyleForPainting(); 969 updateLayoutAndStyleForPainting();
970 970
971 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); 971 RefPtrWillBeRawPtr<Element> host = document().getElementById("host");
972 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 972 RefPtrWillBeRawPtr<Element> one = document().getElementById("one");
973 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three"); 973 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three");
974 974
975 EXPECT_EQ(Position(one->firstChild(), 1), mostBackwardCaretPosition(Position ::afterNode(host.get()))); 975 EXPECT_EQ(Position(one->firstChild(), 1), mostBackwardCaretPosition(Position ::afterNode(host.get())));
976 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 3), mostBackwardCaretP osition(PositionInComposedTree::afterNode(host.get()))); 976 EXPECT_EQ(PositionInFlatTree(three->firstChild(), 3), mostBackwardCaretPosit ion(PositionInFlatTree::afterNode(host.get())));
977 } 977 }
978 978
979 TEST_F(VisibleUnitsTest, mostForwardCaretPositionFirstLetter) 979 TEST_F(VisibleUnitsTest, mostForwardCaretPositionFirstLetter)
980 { 980 {
981 // Note: first-letter pseudo element contains letter and punctuations. 981 // Note: first-letter pseudo element contains letter and punctuations.
982 const char* bodyContent = "<style>p:first-letter {color:red;}</style><p id=s ample> (2)45 </p>"; 982 const char* bodyContent = "<style>p:first-letter {color:red;}</style><p id=s ample> (2)45 </p>";
983 setBodyContent(bodyContent); 983 setBodyContent(bodyContent);
984 updateLayoutAndStyleForPainting(); 984 updateLayoutAndStyleForPainting();
985 985
986 Node* sample = document().getElementById("sample")->firstChild(); 986 Node* sample = document().getElementById("sample")->firstChild();
(...skipping 20 matching lines...) Expand all
1007 updateLayoutAndStyleForPainting(); 1007 updateLayoutAndStyleForPainting();
1008 1008
1009 Element* zero = document().getElementById("zero"); 1009 Element* zero = document().getElementById("zero");
1010 Element* one = document().getElementById("one"); 1010 Element* one = document().getElementById("one");
1011 Element* two = document().getElementById("two"); 1011 Element* two = document().getElementById("two");
1012 Element* three = document().getElementById("three"); 1012 Element* three = document().getElementById("three");
1013 Element* four = shadowRoot->getElementById("four"); 1013 Element* four = shadowRoot->getElementById("four");
1014 Element* five = shadowRoot->getElementById("five"); 1014 Element* five = shadowRoot->getElementById("five");
1015 1015
1016 EXPECT_EQ(Position(one->firstChild(), 0), nextPositionOf(createVisiblePositi on(Position(zero, 1))).deepEquivalent()); 1016 EXPECT_EQ(Position(one->firstChild(), 0), nextPositionOf(createVisiblePositi on(Position(zero, 1))).deepEquivalent());
1017 EXPECT_EQ(PositionInComposedTree(four->firstChild(), 0), nextPositionOf(crea teVisiblePosition(PositionInComposedTree(zero, 1))).deepEquivalent()); 1017 EXPECT_EQ(PositionInFlatTree(four->firstChild(), 0), nextPositionOf(createVi siblePosition(PositionInFlatTree(zero, 1))).deepEquivalent());
1018 1018
1019 EXPECT_EQ(Position(one->firstChild(), 1), nextPositionOf(createVisiblePositi on(Position(one, 0))).deepEquivalent()); 1019 EXPECT_EQ(Position(one->firstChild(), 1), nextPositionOf(createVisiblePositi on(Position(one, 0))).deepEquivalent());
1020 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 1), nextPositionOf(creat eVisiblePosition(PositionInComposedTree(one, 0))).deepEquivalent()); 1020 EXPECT_EQ(PositionInFlatTree(one->firstChild(), 1), nextPositionOf(createVis iblePosition(PositionInFlatTree(one, 0))).deepEquivalent());
1021 1021
1022 EXPECT_EQ(Position(two->firstChild(), 1), nextPositionOf(createVisiblePositi on(Position(one, 1))).deepEquivalent()); 1022 EXPECT_EQ(Position(two->firstChild(), 1), nextPositionOf(createVisiblePositi on(Position(one, 1))).deepEquivalent());
1023 EXPECT_EQ(PositionInComposedTree(five->firstChild(), 1), nextPositionOf(crea teVisiblePosition(PositionInComposedTree(one, 1))).deepEquivalent()); 1023 EXPECT_EQ(PositionInFlatTree(five->firstChild(), 1), nextPositionOf(createVi siblePosition(PositionInFlatTree(one, 1))).deepEquivalent());
1024 1024
1025 EXPECT_EQ(Position(three->firstChild(), 0), nextPositionOf(createVisiblePosi tion(Position(two, 2))).deepEquivalent()); 1025 EXPECT_EQ(Position(three->firstChild(), 0), nextPositionOf(createVisiblePosi tion(Position(two, 2))).deepEquivalent());
1026 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 1), nextPositionOf(creat eVisiblePosition(PositionInComposedTree(two, 2))).deepEquivalent()); 1026 EXPECT_EQ(PositionInFlatTree(one->firstChild(), 1), nextPositionOf(createVis iblePosition(PositionInFlatTree(two, 2))).deepEquivalent());
1027 } 1027 }
1028 1028
1029 TEST_F(VisibleUnitsTest, previousPositionOf) 1029 TEST_F(VisibleUnitsTest, previousPositionOf)
1030 { 1030 {
1031 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>"; 1031 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>";
1032 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>55555</b>"; 1032 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>55555</b>";
1033 setBodyContent(bodyContent); 1033 setBodyContent(bodyContent);
1034 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1034 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
1035 updateLayoutAndStyleForPainting(); 1035 updateLayoutAndStyleForPainting();
1036 1036
1037 Node* zero = document().getElementById("zero")->firstChild(); 1037 Node* zero = document().getElementById("zero")->firstChild();
1038 Node* one = document().getElementById("one")->firstChild(); 1038 Node* one = document().getElementById("one")->firstChild();
1039 Node* two = document().getElementById("two")->firstChild(); 1039 Node* two = document().getElementById("two")->firstChild();
1040 Node* three = document().getElementById("three")->firstChild(); 1040 Node* three = document().getElementById("three")->firstChild();
1041 Node* four = shadowRoot->getElementById("four")->firstChild(); 1041 Node* four = shadowRoot->getElementById("four")->firstChild();
1042 Node* five = shadowRoot->getElementById("five")->firstChild(); 1042 Node* five = shadowRoot->getElementById("five")->firstChild();
1043 1043
1044 EXPECT_EQ(Position(zero, 0), previousPositionOf(createVisiblePosition(Positi on(zero, 1))).deepEquivalent()); 1044 EXPECT_EQ(Position(zero, 0), previousPositionOf(createVisiblePosition(Positi on(zero, 1))).deepEquivalent());
1045 EXPECT_EQ(PositionInComposedTree(zero, 0), previousPositionOf(createVisibleP osition(PositionInComposedTree(zero, 1))).deepEquivalent()); 1045 EXPECT_EQ(PositionInFlatTree(zero, 0), previousPositionOf(createVisiblePosit ion(PositionInFlatTree(zero, 1))).deepEquivalent());
1046 1046
1047 EXPECT_EQ(Position(zero, 1), previousPositionOf(createVisiblePosition(Positi on(one, 0))).deepEquivalent()); 1047 EXPECT_EQ(Position(zero, 1), previousPositionOf(createVisiblePosition(Positi on(one, 0))).deepEquivalent());
1048 EXPECT_EQ(PositionInComposedTree(two, 1), previousPositionOf(createVisiblePo sition(PositionInComposedTree(one, 0))).deepEquivalent()); 1048 EXPECT_EQ(PositionInFlatTree(two, 1), previousPositionOf(createVisiblePositi on(PositionInFlatTree(one, 0))).deepEquivalent());
1049 1049
1050 EXPECT_EQ(Position(one, 0), previousPositionOf(createVisiblePosition(Positio n(one, 1))).deepEquivalent()); 1050 EXPECT_EQ(Position(one, 0), previousPositionOf(createVisiblePosition(Positio n(one, 1))).deepEquivalent());
1051 EXPECT_EQ(PositionInComposedTree(two, 2), previousPositionOf(createVisiblePo sition(PositionInComposedTree(one, 1))).deepEquivalent()); 1051 EXPECT_EQ(PositionInFlatTree(two, 2), previousPositionOf(createVisiblePositi on(PositionInFlatTree(one, 1))).deepEquivalent());
1052 1052
1053 EXPECT_EQ(Position(one, 0), previousPositionOf(createVisiblePosition(Positio n(two, 0))).deepEquivalent()); 1053 EXPECT_EQ(Position(one, 0), previousPositionOf(createVisiblePosition(Positio n(two, 0))).deepEquivalent());
1054 EXPECT_EQ(PositionInComposedTree(four, 3), previousPositionOf(createVisibleP osition(PositionInComposedTree(two, 0))).deepEquivalent()); 1054 EXPECT_EQ(PositionInFlatTree(four, 3), previousPositionOf(createVisiblePosit ion(PositionInFlatTree(two, 0))).deepEquivalent());
1055 1055
1056 // DOM tree to shadow tree 1056 // DOM tree to shadow tree
1057 EXPECT_EQ(Position(two, 2), previousPositionOf(createVisiblePosition(Positio n(three, 0))).deepEquivalent()); 1057 EXPECT_EQ(Position(two, 2), previousPositionOf(createVisiblePosition(Positio n(three, 0))).deepEquivalent());
1058 EXPECT_EQ(PositionInComposedTree(five, 5), previousPositionOf(createVisibleP osition(PositionInComposedTree(three, 0))).deepEquivalent()); 1058 EXPECT_EQ(PositionInFlatTree(five, 5), previousPositionOf(createVisiblePosit ion(PositionInFlatTree(three, 0))).deepEquivalent());
1059 1059
1060 // Shadow tree to DOM tree 1060 // Shadow tree to DOM tree
1061 EXPECT_EQ(Position(), previousPositionOf(createVisiblePosition(Position(four , 0))).deepEquivalent()); 1061 EXPECT_EQ(Position(), previousPositionOf(createVisiblePosition(Position(four , 0))).deepEquivalent());
1062 EXPECT_EQ(PositionInComposedTree(zero, 1), previousPositionOf(createVisibleP osition(PositionInComposedTree(four, 0))).deepEquivalent()); 1062 EXPECT_EQ(PositionInFlatTree(zero, 1), previousPositionOf(createVisiblePosit ion(PositionInFlatTree(four, 0))).deepEquivalent());
1063 1063
1064 // Note: Canonicalization maps (five, 0) to (four, 4) in DOM tree and 1064 // Note: Canonicalization maps (five, 0) to (four, 4) in DOM tree and
1065 // (one, 1) in composed tree. 1065 // (one, 1) in flat tree.
1066 EXPECT_EQ(Position(four, 4), previousPositionOf(createVisiblePosition(Positi on(five, 1))).deepEquivalent()); 1066 EXPECT_EQ(Position(four, 4), previousPositionOf(createVisiblePosition(Positi on(five, 1))).deepEquivalent());
1067 EXPECT_EQ(PositionInComposedTree(one, 1), previousPositionOf(createVisiblePo sition(PositionInComposedTree(five, 1))).deepEquivalent()); 1067 EXPECT_EQ(PositionInFlatTree(one, 1), previousPositionOf(createVisiblePositi on(PositionInFlatTree(five, 1))).deepEquivalent());
1068 } 1068 }
1069 1069
1070 TEST_F(VisibleUnitsTest, previousPositionOfOneCharPerLine) 1070 TEST_F(VisibleUnitsTest, previousPositionOfOneCharPerLine)
1071 { 1071 {
1072 const char* bodyContent = "<div id=sample style='font-size: 500px'>A&#x714a; &#xfa67;</div>"; 1072 const char* bodyContent = "<div id=sample style='font-size: 500px'>A&#x714a; &#xfa67;</div>";
1073 setBodyContent(bodyContent); 1073 setBodyContent(bodyContent);
1074 1074
1075 Node* sample = document().getElementById("sample")->firstChild(); 1075 Node* sample = document().getElementById("sample")->firstChild();
1076 1076
1077 // In case of each line has one character, VisiblePosition are: 1077 // In case of each line has one character, VisiblePosition are:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1114 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
1115 updateLayoutAndStyleForPainting(); 1115 updateLayoutAndStyleForPainting();
1116 1116
1117 Node* one = document().getElementById("one")->firstChild(); 1117 Node* one = document().getElementById("one")->firstChild();
1118 Node* two = document().getElementById("two")->firstChild(); 1118 Node* two = document().getElementById("two")->firstChild();
1119 Node* three = document().getElementById("three")->firstChild(); 1119 Node* three = document().getElementById("three")->firstChild();
1120 Node* four = shadowRoot->getElementById("four")->firstChild(); 1120 Node* four = shadowRoot->getElementById("four")->firstChild();
1121 Node* five = shadowRoot->getElementById("five")->firstChild(); 1121 Node* five = shadowRoot->getElementById("five")->firstChild();
1122 1122
1123 EXPECT_EQ(Position(), rightPositionOf(createVisiblePosition(Position(one, 1) )).deepEquivalent()); 1123 EXPECT_EQ(Position(), rightPositionOf(createVisiblePosition(Position(one, 1) )).deepEquivalent());
1124 EXPECT_EQ(PositionInComposedTree(five, 0), rightPositionOf(createVisiblePosi tion(PositionInComposedTree(one, 1))).deepEquivalent()); 1124 EXPECT_EQ(PositionInFlatTree(five, 0), rightPositionOf(createVisiblePosition (PositionInFlatTree(one, 1))).deepEquivalent());
1125 1125
1126 EXPECT_EQ(Position(one, 1), rightPositionOf(createVisiblePosition(Position(t wo, 2))).deepEquivalent()); 1126 EXPECT_EQ(Position(one, 1), rightPositionOf(createVisiblePosition(Position(t wo, 2))).deepEquivalent());
1127 EXPECT_EQ(PositionInComposedTree(one, 1), rightPositionOf(createVisiblePosit ion(PositionInComposedTree(two, 2))).deepEquivalent()); 1127 EXPECT_EQ(PositionInFlatTree(one, 1), rightPositionOf(createVisiblePosition( PositionInFlatTree(two, 2))).deepEquivalent());
1128 1128
1129 EXPECT_EQ(Position(five, 0), rightPositionOf(createVisiblePosition(Position( four, 4))).deepEquivalent()); 1129 EXPECT_EQ(Position(five, 0), rightPositionOf(createVisiblePosition(Position( four, 4))).deepEquivalent());
1130 EXPECT_EQ(PositionInComposedTree(two, 0), rightPositionOf(createVisiblePosit ion(PositionInComposedTree(four, 4))).deepEquivalent()); 1130 EXPECT_EQ(PositionInFlatTree(two, 0), rightPositionOf(createVisiblePosition( PositionInFlatTree(four, 4))).deepEquivalent());
1131 1131
1132 EXPECT_EQ(Position(), rightPositionOf(createVisiblePosition(Position(five, 5 ))).deepEquivalent()); 1132 EXPECT_EQ(Position(), rightPositionOf(createVisiblePosition(Position(five, 5 ))).deepEquivalent());
1133 EXPECT_EQ(PositionInComposedTree(three, 0), rightPositionOf(createVisiblePos ition(PositionInComposedTree(five, 5))).deepEquivalent()); 1133 EXPECT_EQ(PositionInFlatTree(three, 0), rightPositionOf(createVisiblePositio n(PositionInFlatTree(five, 5))).deepEquivalent());
1134 } 1134 }
1135 1135
1136 TEST_F(VisibleUnitsTest, startOfDocument) 1136 TEST_F(VisibleUnitsTest, startOfDocument)
1137 { 1137 {
1138 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>"; 1138 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>";
1139 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>"; 1139 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>";
1140 setBodyContent(bodyContent); 1140 setBodyContent(bodyContent);
1141 setShadowContent(shadowContent, "host"); 1141 setShadowContent(shadowContent, "host");
1142 updateLayoutAndStyleForPainting(); 1142 updateLayoutAndStyleForPainting();
1143 1143
1144 Node* one = document().getElementById("one")->firstChild(); 1144 Node* one = document().getElementById("one")->firstChild();
1145 Node* two = document().getElementById("two")->firstChild(); 1145 Node* two = document().getElementById("two")->firstChild();
1146 1146
1147 EXPECT_EQ(Position(one, 0), startOfDocument(createVisiblePositionInDOMTree(* one, 0)).deepEquivalent()); 1147 EXPECT_EQ(Position(one, 0), startOfDocument(createVisiblePositionInDOMTree(* one, 0)).deepEquivalent());
1148 EXPECT_EQ(PositionInComposedTree(two, 0), startOfDocument(createVisiblePosit ionInComposedTree(*one, 0)).deepEquivalent()); 1148 EXPECT_EQ(PositionInFlatTree(two, 0), startOfDocument(createVisiblePositionI nFlatTree(*one, 0)).deepEquivalent());
1149 1149
1150 EXPECT_EQ(Position(one, 0), startOfDocument(createVisiblePositionInDOMTree(* two, 1)).deepEquivalent()); 1150 EXPECT_EQ(Position(one, 0), startOfDocument(createVisiblePositionInDOMTree(* two, 1)).deepEquivalent());
1151 EXPECT_EQ(PositionInComposedTree(two, 0), startOfDocument(createVisiblePosit ionInComposedTree(*two, 1)).deepEquivalent()); 1151 EXPECT_EQ(PositionInFlatTree(two, 0), startOfDocument(createVisiblePositionI nFlatTree(*two, 1)).deepEquivalent());
1152 } 1152 }
1153 1153
1154 TEST_F(VisibleUnitsTest, startOfLine) 1154 TEST_F(VisibleUnitsTest, startOfLine)
1155 { 1155 {
1156 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>"; 1156 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i id=four>4444</i><br>";
1157 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>"; 1157 const char* shadowContent = "<div><u id=five>55555</u><content select=#two>< /content><br><u id=six>666666</u><br><content select=#one></content><u id=seven> 7777777</u></div>";
1158 setBodyContent(bodyContent); 1158 setBodyContent(bodyContent);
1159 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1159 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
1160 updateLayoutAndStyleForPainting(); 1160 updateLayoutAndStyleForPainting();
1161 1161
1162 Node* one = document().getElementById("one")->firstChild(); 1162 Node* one = document().getElementById("one")->firstChild();
1163 Node* two = document().getElementById("two")->firstChild(); 1163 Node* two = document().getElementById("two")->firstChild();
1164 Node* three = document().getElementById("three")->firstChild(); 1164 Node* three = document().getElementById("three")->firstChild();
1165 Node* four = document().getElementById("four")->firstChild(); 1165 Node* four = document().getElementById("four")->firstChild();
1166 Node* five = shadowRoot->getElementById("five")->firstChild(); 1166 Node* five = shadowRoot->getElementById("five")->firstChild();
1167 Node* six = shadowRoot->getElementById("six")->firstChild(); 1167 Node* six = shadowRoot->getElementById("six")->firstChild();
1168 Node* seven = shadowRoot->getElementById("seven")->firstChild(); 1168 Node* seven = shadowRoot->getElementById("seven")->firstChild();
1169 1169
1170 EXPECT_EQ(Position(one, 0), startOfLine(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent()); 1170 EXPECT_EQ(Position(one, 0), startOfLine(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent());
1171 EXPECT_EQ(PositionInComposedTree(one, 0), startOfLine(createVisiblePositionI nComposedTree(*one, 0)).deepEquivalent()); 1171 EXPECT_EQ(PositionInFlatTree(one, 0), startOfLine(createVisiblePositionInFla tTree(*one, 0)).deepEquivalent());
1172 1172
1173 EXPECT_EQ(Position(one, 0), startOfLine(createVisiblePositionInDOMTree(*one, 1)).deepEquivalent()); 1173 EXPECT_EQ(Position(one, 0), startOfLine(createVisiblePositionInDOMTree(*one, 1)).deepEquivalent());
1174 EXPECT_EQ(PositionInComposedTree(one, 0), startOfLine(createVisiblePositionI nComposedTree(*one, 1)).deepEquivalent()); 1174 EXPECT_EQ(PositionInFlatTree(one, 0), startOfLine(createVisiblePositionInFla tTree(*one, 1)).deepEquivalent());
1175 1175
1176 EXPECT_EQ(Position(one, 0), startOfLine(createVisiblePositionInDOMTree(*two, 0)).deepEquivalent()); 1176 EXPECT_EQ(Position(one, 0), startOfLine(createVisiblePositionInDOMTree(*two, 0)).deepEquivalent());
1177 EXPECT_EQ(PositionInComposedTree(five, 0), startOfLine(createVisiblePosition InComposedTree(*two, 0)).deepEquivalent()); 1177 EXPECT_EQ(PositionInFlatTree(five, 0), startOfLine(createVisiblePositionInFl atTree(*two, 0)).deepEquivalent());
1178 1178
1179 EXPECT_EQ(Position(five, 0), startOfLine(createVisiblePositionInDOMTree(*two , 1)).deepEquivalent()); 1179 EXPECT_EQ(Position(five, 0), startOfLine(createVisiblePositionInDOMTree(*two , 1)).deepEquivalent());
1180 EXPECT_EQ(PositionInComposedTree(five, 0), startOfLine(createVisiblePosition InComposedTree(*two, 1)).deepEquivalent()); 1180 EXPECT_EQ(PositionInFlatTree(five, 0), startOfLine(createVisiblePositionInFl atTree(*two, 1)).deepEquivalent());
1181 1181
1182 EXPECT_EQ(Position(five, 0), startOfLine(createVisiblePositionInDOMTree(*thr ee, 0)).deepEquivalent()); 1182 EXPECT_EQ(Position(five, 0), startOfLine(createVisiblePositionInDOMTree(*thr ee, 0)).deepEquivalent());
1183 EXPECT_EQ(PositionInComposedTree(three, 0), startOfLine(createVisiblePositio nInComposedTree(*three, 1)).deepEquivalent()); 1183 EXPECT_EQ(PositionInFlatTree(three, 0), startOfLine(createVisiblePositionInF latTree(*three, 1)).deepEquivalent());
1184 1184
1185 // TODO(yosin) startOfLine(four, 1) -> (two, 2) is a broken result. We keep 1185 // TODO(yosin) startOfLine(four, 1) -> (two, 2) is a broken result. We keep
1186 // it as a marker for future change. 1186 // it as a marker for future change.
1187 EXPECT_EQ(Position(two, 2), startOfLine(createVisiblePositionInDOMTree(*four , 1)).deepEquivalent()); 1187 EXPECT_EQ(Position(two, 2), startOfLine(createVisiblePositionInDOMTree(*four , 1)).deepEquivalent());
1188 EXPECT_EQ(PositionInComposedTree(three, 0), startOfLine(createVisiblePositio nInComposedTree(*four, 1)).deepEquivalent()); 1188 EXPECT_EQ(PositionInFlatTree(three, 0), startOfLine(createVisiblePositionInF latTree(*four, 1)).deepEquivalent());
1189 1189
1190 EXPECT_EQ(Position(five, 0), startOfLine(createVisiblePositionInDOMTree(*fiv e, 1)).deepEquivalent()); 1190 EXPECT_EQ(Position(five, 0), startOfLine(createVisiblePositionInDOMTree(*fiv e, 1)).deepEquivalent());
1191 EXPECT_EQ(PositionInComposedTree(five, 0), startOfLine(createVisiblePosition InComposedTree(*five, 1)).deepEquivalent()); 1191 EXPECT_EQ(PositionInFlatTree(five, 0), startOfLine(createVisiblePositionInFl atTree(*five, 1)).deepEquivalent());
1192 1192
1193 EXPECT_EQ(Position(six, 0), startOfLine(createVisiblePositionInDOMTree(*six, 1)).deepEquivalent()); 1193 EXPECT_EQ(Position(six, 0), startOfLine(createVisiblePositionInDOMTree(*six, 1)).deepEquivalent());
1194 EXPECT_EQ(PositionInComposedTree(six, 0), startOfLine(createVisiblePositionI nComposedTree(*six, 1)).deepEquivalent()); 1194 EXPECT_EQ(PositionInFlatTree(six, 0), startOfLine(createVisiblePositionInFla tTree(*six, 1)).deepEquivalent());
1195 1195
1196 EXPECT_EQ(Position(one, 0), startOfLine(createVisiblePositionInDOMTree(*seve n, 1)).deepEquivalent()); 1196 EXPECT_EQ(Position(one, 0), startOfLine(createVisiblePositionInDOMTree(*seve n, 1)).deepEquivalent());
1197 EXPECT_EQ(PositionInComposedTree(one, 0), startOfLine(createVisiblePositionI nComposedTree(*seven, 1)).deepEquivalent()); 1197 EXPECT_EQ(PositionInFlatTree(one, 0), startOfLine(createVisiblePositionInFla tTree(*seven, 1)).deepEquivalent());
1198 } 1198 }
1199 1199
1200 TEST_F(VisibleUnitsTest, startOfParagraph) 1200 TEST_F(VisibleUnitsTest, startOfParagraph)
1201 { 1201 {
1202 const char* bodyContent = "<b id=zero>0</b><a id=host><b id=one>1</b><b id=t wo>22</b></a><b id=three>333</b>"; 1202 const char* bodyContent = "<b id=zero>0</b><a id=host><b id=one>1</b><b id=t wo>22</b></a><b id=three>333</b>";
1203 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>"; 1203 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>";
1204 setBodyContent(bodyContent); 1204 setBodyContent(bodyContent);
1205 setShadowContent(shadowContent, "host"); 1205 setShadowContent(shadowContent, "host");
1206 updateLayoutAndStyleForPainting(); 1206 updateLayoutAndStyleForPainting();
1207 1207
1208 Node* zero = document().getElementById("zero")->firstChild(); 1208 Node* zero = document().getElementById("zero")->firstChild();
1209 Node* one = document().getElementById("one")->firstChild(); 1209 Node* one = document().getElementById("one")->firstChild();
1210 Node* two = document().getElementById("two")->firstChild(); 1210 Node* two = document().getElementById("two")->firstChild();
1211 Node* three = document().getElementById("three")->firstChild(); 1211 Node* three = document().getElementById("three")->firstChild();
1212 1212
1213 EXPECT_EQ(Position(zero, 0), startOfParagraph(createVisiblePositionInDOMTree (*one, 1)).deepEquivalent()); 1213 EXPECT_EQ(Position(zero, 0), startOfParagraph(createVisiblePositionInDOMTree (*one, 1)).deepEquivalent());
1214 EXPECT_EQ(PositionInComposedTree(one, 0), startOfParagraph(createVisiblePosi tionInComposedTree(*one, 1)).deepEquivalent()); 1214 EXPECT_EQ(PositionInFlatTree(one, 0), startOfParagraph(createVisiblePosition InFlatTree(*one, 1)).deepEquivalent());
1215 1215
1216 EXPECT_EQ(Position(zero, 0), startOfParagraph(createVisiblePositionInDOMTree (*two, 2)).deepEquivalent()); 1216 EXPECT_EQ(Position(zero, 0), startOfParagraph(createVisiblePositionInDOMTree (*two, 2)).deepEquivalent());
1217 EXPECT_EQ(PositionInComposedTree(two, 0), startOfParagraph(createVisiblePosi tionInComposedTree(*two, 2)).deepEquivalent()); 1217 EXPECT_EQ(PositionInFlatTree(two, 0), startOfParagraph(createVisiblePosition InFlatTree(*two, 2)).deepEquivalent());
1218 1218
1219 // DOM version of |startOfParagraph()| doesn't take account contents in 1219 // DOM version of |startOfParagraph()| doesn't take account contents in
1220 // shadow tree. 1220 // shadow tree.
1221 EXPECT_EQ(Position(zero, 0), startOfParagraph(createVisiblePositionInDOMTree (*three, 2)).deepEquivalent()); 1221 EXPECT_EQ(Position(zero, 0), startOfParagraph(createVisiblePositionInDOMTree (*three, 2)).deepEquivalent());
1222 EXPECT_EQ(PositionInComposedTree(three, 0), startOfParagraph(createVisiblePo sitionInComposedTree(*three, 2)).deepEquivalent()); 1222 EXPECT_EQ(PositionInFlatTree(three, 0), startOfParagraph(createVisiblePositi onInFlatTree(*three, 2)).deepEquivalent());
1223 1223
1224 // crbug.com/563777. startOfParagraph() unexpectedly returned a null 1224 // crbug.com/563777. startOfParagraph() unexpectedly returned a null
1225 // position with nested editable <BODY>s. 1225 // position with nested editable <BODY>s.
1226 Element* root = document().documentElement(); 1226 Element* root = document().documentElement();
1227 root->setInnerHTML("<style>* { display:inline-table; }</style><body contente ditable=true><svg><svg><foreignObject>abc<svg></svg></foreignObject></svg></svg> </body>", ASSERT_NO_EXCEPTION); 1227 root->setInnerHTML("<style>* { display:inline-table; }</style><body contente ditable=true><svg><svg><foreignObject>abc<svg></svg></foreignObject></svg></svg> </body>", ASSERT_NO_EXCEPTION);
1228 RefPtrWillBeRawPtr<Element> oldBody = document().body(); 1228 RefPtrWillBeRawPtr<Element> oldBody = document().body();
1229 root->setInnerHTML("<body contenteditable=true><svg><foreignObject><style>de f</style>", ASSERT_NO_EXCEPTION); 1229 root->setInnerHTML("<body contenteditable=true><svg><foreignObject><style>de f</style>", ASSERT_NO_EXCEPTION);
1230 ASSERT(oldBody != document().body()); 1230 ASSERT(oldBody != document().body());
1231 Node* foreignObject = document().body()->firstChild()->firstChild(); 1231 Node* foreignObject = document().body()->firstChild()->firstChild();
1232 foreignObject->insertBefore(oldBody.get(), foreignObject->firstChild()); 1232 foreignObject->insertBefore(oldBody.get(), foreignObject->firstChild());
(...skipping 11 matching lines...) Expand all
1244 setBodyContent(bodyContent); 1244 setBodyContent(bodyContent);
1245 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1245 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
1246 updateLayoutAndStyleForPainting(); 1246 updateLayoutAndStyleForPainting();
1247 1247
1248 Node* one = document().getElementById("one")->firstChild(); 1248 Node* one = document().getElementById("one")->firstChild();
1249 Node* two = document().getElementById("two")->firstChild(); 1249 Node* two = document().getElementById("two")->firstChild();
1250 Node* three = shadowRoot->getElementById("three")->firstChild(); 1250 Node* three = shadowRoot->getElementById("three")->firstChild();
1251 Node* four = shadowRoot->getElementById("four")->firstChild(); 1251 Node* four = shadowRoot->getElementById("four")->firstChild();
1252 1252
1253 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* one, 0)).deepEquivalent()); 1253 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* one, 0)).deepEquivalent());
1254 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos itionInComposedTree(*one, 0)).deepEquivalent()); 1254 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*one, 0)).deepEquivalent());
1255 1255
1256 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* one, 1)).deepEquivalent()); 1256 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* one, 1)).deepEquivalent());
1257 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos itionInComposedTree(*one, 1)).deepEquivalent()); 1257 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*one, 1)).deepEquivalent());
1258 1258
1259 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* two, 0)).deepEquivalent()); 1259 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* two, 0)).deepEquivalent());
1260 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos itionInComposedTree(*two, 0)).deepEquivalent()); 1260 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*two, 0)).deepEquivalent());
1261 1261
1262 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* two, 1)).deepEquivalent()); 1262 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* two, 1)).deepEquivalent());
1263 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos itionInComposedTree(*two, 1)).deepEquivalent()); 1263 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*two, 1)).deepEquivalent());
1264 1264
1265 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree (*three, 1)).deepEquivalent()); 1265 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree (*three, 1)).deepEquivalent());
1266 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos itionInComposedTree(*three, 1)).deepEquivalent()); 1266 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*three, 1)).deepEquivalent());
1267 1267
1268 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree (*four, 1)).deepEquivalent()); 1268 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree (*four, 1)).deepEquivalent());
1269 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos itionInComposedTree(*four, 1)).deepEquivalent()); 1269 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*four, 1)).deepEquivalent());
1270 } 1270 }
1271 1271
1272 TEST_F(VisibleUnitsTest, startOfWord) 1272 TEST_F(VisibleUnitsTest, startOfWord)
1273 { 1273 {
1274 const char* bodyContent = "<a id=host><b id=one>1</b> <b id=two>22</b></a><i id=three>333</i>"; 1274 const char* bodyContent = "<a id=host><b id=one>1</b> <b id=two>22</b></a><i id=three>333</i>";
1275 const char* shadowContent = "<p><u id=four>44444</u><content select=#two></c ontent><span id=space> </span><content select=#one></content><u id=five>55555</u ></p>"; 1275 const char* shadowContent = "<p><u id=four>44444</u><content select=#two></c ontent><span id=space> </span><content select=#one></content><u id=five>55555</u ></p>";
1276 setBodyContent(bodyContent); 1276 setBodyContent(bodyContent);
1277 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1277 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
1278 updateLayoutAndStyleForPainting(); 1278 updateLayoutAndStyleForPainting();
1279 1279
1280 Node* one = document().getElementById("one")->firstChild(); 1280 Node* one = document().getElementById("one")->firstChild();
1281 Node* two = document().getElementById("two")->firstChild(); 1281 Node* two = document().getElementById("two")->firstChild();
1282 Node* three = document().getElementById("three")->firstChild(); 1282 Node* three = document().getElementById("three")->firstChild();
1283 Node* four = shadowRoot->getElementById("four")->firstChild(); 1283 Node* four = shadowRoot->getElementById("four")->firstChild();
1284 Node* five = shadowRoot->getElementById("five")->firstChild(); 1284 Node* five = shadowRoot->getElementById("five")->firstChild();
1285 Node* space = shadowRoot->getElementById("space")->firstChild(); 1285 Node* space = shadowRoot->getElementById("space")->firstChild();
1286 1286
1287 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent()); 1287 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent());
1288 EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositio nInComposedTree(*one, 0)).deepEquivalent()); 1288 EXPECT_EQ(PositionInFlatTree(space, 1), startOfWord(createVisiblePositionInF latTree(*one, 0)).deepEquivalent());
1289 1289
1290 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one, 1)).deepEquivalent()); 1290 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one, 1)).deepEquivalent());
1291 EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositio nInComposedTree(*one, 1)).deepEquivalent()); 1291 EXPECT_EQ(PositionInFlatTree(space, 1), startOfWord(createVisiblePositionInF latTree(*one, 1)).deepEquivalent());
1292 1292
1293 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*two, 0)).deepEquivalent()); 1293 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*two, 0)).deepEquivalent());
1294 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition InComposedTree(*two, 0)).deepEquivalent()); 1294 EXPECT_EQ(PositionInFlatTree(four, 0), startOfWord(createVisiblePositionInFl atTree(*two, 0)).deepEquivalent());
1295 1295
1296 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*two, 1)).deepEquivalent()); 1296 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*two, 1)).deepEquivalent());
1297 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition InComposedTree(*two, 1)).deepEquivalent()); 1297 EXPECT_EQ(PositionInFlatTree(four, 0), startOfWord(createVisiblePositionInFl atTree(*two, 1)).deepEquivalent());
1298 1298
1299 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*thre e, 1)).deepEquivalent()); 1299 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*thre e, 1)).deepEquivalent());
1300 EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositio nInComposedTree(*three, 1)).deepEquivalent()); 1300 EXPECT_EQ(PositionInFlatTree(space, 1), startOfWord(createVisiblePositionInF latTree(*three, 1)).deepEquivalent());
1301 1301
1302 EXPECT_EQ(Position(four, 0), startOfWord(createVisiblePositionInDOMTree(*fou r, 1)).deepEquivalent()); 1302 EXPECT_EQ(Position(four, 0), startOfWord(createVisiblePositionInDOMTree(*fou r, 1)).deepEquivalent());
1303 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition InComposedTree(*four, 1)).deepEquivalent()); 1303 EXPECT_EQ(PositionInFlatTree(four, 0), startOfWord(createVisiblePositionInFl atTree(*four, 1)).deepEquivalent());
1304 1304
1305 EXPECT_EQ(Position(space, 1), startOfWord(createVisiblePositionInDOMTree(*fi ve, 1)).deepEquivalent()); 1305 EXPECT_EQ(Position(space, 1), startOfWord(createVisiblePositionInDOMTree(*fi ve, 1)).deepEquivalent());
1306 EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositio nInComposedTree(*five, 1)).deepEquivalent()); 1306 EXPECT_EQ(PositionInFlatTree(space, 1), startOfWord(createVisiblePositionInF latTree(*five, 1)).deepEquivalent());
1307 } 1307 }
1308 1308
1309 } // namespace blink 1309 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698