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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/VisibleUnits.h" 5 #include "core/editing/VisibleUnits.h"
6 6
7 #include "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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 RawPtr<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 RawPtr<Element> body = document().body();
61 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION); 61 RawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCEPTION);
62 62
63 IntRect boundsInDOMTree = absoluteCaretBoundsOf(createVisiblePosition(Positi on(one.get(), 0))); 63 IntRect boundsInDOMTree = absoluteCaretBoundsOf(createVisiblePosition(Positi on(one.get(), 0)));
64 IntRect boundsInFlatTree = absoluteCaretBoundsOf(createVisiblePosition(Posit ionInFlatTree(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, boundsInFlatTree); 67 EXPECT_EQ(boundsInDOMTree, boundsInFlatTree);
68 } 68 }
69 69
70 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterPunctuations) 70 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterPunctuations)
71 { 71 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 LayoutTextFragment* layoutObject2 = toLayoutTextFragment(associatedLayoutObj ectOf(*text, 2)); 126 LayoutTextFragment* layoutObject2 = toLayoutTextFragment(associatedLayoutObj ectOf(*text, 2));
127 EXPECT_EQ(layoutObject1, layoutObject2); 127 EXPECT_EQ(layoutObject1, layoutObject2);
128 } 128 }
129 129
130 TEST_F(VisibleUnitsTest, caretMinOffset) 130 TEST_F(VisibleUnitsTest, caretMinOffset)
131 { 131 {
132 const char* bodyContent = "<p id=one>one</p>"; 132 const char* bodyContent = "<p id=one>one</p>";
133 setBodyContent(bodyContent); 133 setBodyContent(bodyContent);
134 134
135 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 135 RawPtr<Element> one = document().getElementById("one");
136 136
137 EXPECT_EQ(0, caretMinOffset(one->firstChild())); 137 EXPECT_EQ(0, caretMinOffset(one->firstChild()));
138 } 138 }
139 139
140 TEST_F(VisibleUnitsTest, caretMinOffsetWithFirstLetter) 140 TEST_F(VisibleUnitsTest, caretMinOffsetWithFirstLetter)
141 { 141 {
142 const char* bodyContent = "<style>#one:first-letter { font-size: 200%; }</st yle><p id=one>one</p>"; 142 const char* bodyContent = "<style>#one:first-letter { font-size: 200%; }</st yle><p id=one>one</p>";
143 setBodyContent(bodyContent); 143 setBodyContent(bodyContent);
144 144
145 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 145 RawPtr<Element> one = document().getElementById("one");
146 146
147 EXPECT_EQ(0, caretMinOffset(one->firstChild())); 147 EXPECT_EQ(0, caretMinOffset(one->firstChild()));
148 } 148 }
149 149
150 TEST_F(VisibleUnitsTest, characterAfter) 150 TEST_F(VisibleUnitsTest, characterAfter)
151 { 151 {
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 RawPtr<Element> one = document().getElementById("one");
159 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); 159 RawPtr<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(createVisiblePositionInFlatTree(*one->firstChi ld(), 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(createVisiblePositionInFlatTree(*two->firstChi ld(), 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 RawPtr<Node> one = document().querySelector("#one", ASSERT_NO_EXCEPTION);
174 RefPtrWillBeRawPtr<Node> two = document().querySelector("#two", ASSERT_NO_EX CEPTION); 174 RawPtr<Node> two = document().querySelector("#two", ASSERT_NO_EXCEPTION);
175 RefPtrWillBeRawPtr<Node> three = document().querySelector("#three", ASSERT_N O_EXCEPTION); 175 RawPtr<Node> three = document().querySelector("#three", ASSERT_NO_EXCEPTION) ;
176 RefPtrWillBeRawPtr<Node> four = document().querySelector("#four", ASSERT_NO_ EXCEPTION); 176 RawPtr<Node> four = document().querySelector("#four", ASSERT_NO_EXCEPTION);
177 RefPtrWillBeRawPtr<Element> html = document().createElement("html", ASSERT_N O_EXCEPTION); 177 RawPtr<Element> html = document().createElement("html", ASSERT_NO_EXCEPTION) ;
178 // Move two, three and four into second html element. 178 // Move two, three and four into second html element.
179 html->appendChild(two.get()); 179 html->appendChild(two.get());
180 html->appendChild(three.get()); 180 html->appendChild(three.get());
181 html->appendChild(four.get()); 181 html->appendChild(four.get());
182 one->appendChild(html.get()); 182 one->appendChild(html.get());
183 updateLayoutAndStyleForPainting(); 183 updateLayoutAndStyleForPainting();
184 184
185 EXPECT_EQ(Position(), canonicalPositionOf(Position(document().documentElemen t(), 0))); 185 EXPECT_EQ(Position(), canonicalPositionOf(Position(document().documentElemen t(), 0)));
186 186
187 EXPECT_EQ(Position(one->firstChild(), 0), canonicalPositionOf(Position(one.g et(), 0))); 187 EXPECT_EQ(Position(one->firstChild(), 0), canonicalPositionOf(Position(one.g et(), 0)));
188 EXPECT_EQ(Position(one->firstChild(), 1), canonicalPositionOf(Position(one.g et(), 1))); 188 EXPECT_EQ(Position(one->firstChild(), 1), canonicalPositionOf(Position(one.g et(), 1)));
189 189
190 EXPECT_EQ(Position(one->firstChild(), 0), canonicalPositionOf(Position(one-> firstChild(), 0))); 190 EXPECT_EQ(Position(one->firstChild(), 0), canonicalPositionOf(Position(one-> firstChild(), 0)));
191 EXPECT_EQ(Position(one->firstChild(), 1), canonicalPositionOf(Position(one-> firstChild(), 1))); 191 EXPECT_EQ(Position(one->firstChild(), 1), canonicalPositionOf(Position(one-> firstChild(), 1)));
192 192
193 EXPECT_EQ(Position(html.get(), 0), canonicalPositionOf(Position(html.get(), 0))); 193 EXPECT_EQ(Position(html.get(), 0), canonicalPositionOf(Position(html.get(), 0)));
194 EXPECT_EQ(Position(html.get(), 1), canonicalPositionOf(Position(html.get(), 1))); 194 EXPECT_EQ(Position(html.get(), 1), canonicalPositionOf(Position(html.get(), 1)));
195 EXPECT_EQ(Position(html.get(), 2), canonicalPositionOf(Position(html.get(), 2))); 195 EXPECT_EQ(Position(html.get(), 2), canonicalPositionOf(Position(html.get(), 2)));
196 196
197 EXPECT_EQ(Position(two->firstChild(), 0), canonicalPositionOf(Position(two.g et(), 0))); 197 EXPECT_EQ(Position(two->firstChild(), 0), canonicalPositionOf(Position(two.g et(), 0)));
198 EXPECT_EQ(Position(two->firstChild(), 2), canonicalPositionOf(Position(two.g et(), 1))); 198 EXPECT_EQ(Position(two->firstChild(), 2), canonicalPositionOf(Position(two.g et(), 1)));
199 } 199 }
200 200
201 TEST_F(VisibleUnitsTest, characterBefore) 201 TEST_F(VisibleUnitsTest, characterBefore)
202 { 202 {
203 const char* bodyContent = "<p id=host><b id=one>1</b><b id=two>22</b></p><b id=three>333</b>"; 203 const char* bodyContent = "<p id=host><b id=one>1</b><b id=two>22</b></p><b id=three>333</b>";
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 RawPtr<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(createVisiblePositionInFlatTree(*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(createVisiblePositionInFlatTree(*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(createVisiblePositionInFlatTree(*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(createVisiblePositionInFlatTree(*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 RawPtr<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(PositionInFlatTree(one, 0), TextAffinity: :Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*one, 0)) ); 240 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(one, 0), TextAffinity: :Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*one, 0)) );
241 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(one, 1), TextAffinity: :Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*one, 1)) ); 241 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(one, 1), TextAffinity: :Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*one, 1)) );
(...skipping 28 matching lines...) Expand all
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(PositionInFlatTree(one->firstChild(), 1), endOfDocument(createVisi blePositionInFlatTree(*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 RawPtr<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
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 EXPECT_EQ(Position(text, 6), endOfParagraph(createVisiblePositionInDOMTree(* text, 5)).deepEquivalent()); 404 EXPECT_EQ(Position(text, 6), endOfParagraph(createVisiblePositionInDOMTree(* text, 5)).deepEquivalent());
405 EXPECT_EQ(Position(text, 6), endOfParagraph(createVisiblePositionInDOMTree(* text, 6)).deepEquivalent()); 405 EXPECT_EQ(Position(text, 6), endOfParagraph(createVisiblePositionInDOMTree(* text, 6)).deepEquivalent());
406 } 406 }
407 407
408 TEST_F(VisibleUnitsTest, endOfSentence) 408 TEST_F(VisibleUnitsTest, endOfSentence)
409 { 409 {
410 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>"; 410 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>";
411 const char* shadowContent = "<p><i id=three>333</i> <content select=#two></c ontent> <content select=#one></content> <i id=four>4444</i></p>"; 411 const char* shadowContent = "<p><i id=three>333</i> <content select=#two></c ontent> <content select=#one></content> <i id=four>4444</i></p>";
412 setBodyContent(bodyContent); 412 setBodyContent(bodyContent);
413 setShadowContent(shadowContent, "host"); 413 setShadowContent(shadowContent, "host");
414 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 414 RawPtr<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(PositionInFlatTree(four, 4), endOfSentence(createVisiblePositionIn FlatTree(*one, 0)).deepEquivalent()); 423 EXPECT_EQ(PositionInFlatTree(four, 4), endOfSentence(createVisiblePositionIn FlatTree(*one, 0)).deepEquivalent());
424 424
(...skipping 11 matching lines...) Expand all
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(PositionInFlatTree(four, 4), endOfSentence(createVisiblePositionIn FlatTree(*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 RawPtr<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(PositionInFlatTree(five, 5), endOfWord(createVisiblePositionInFlat Tree(*one, 0)).deepEquivalent()); 456 EXPECT_EQ(PositionInFlatTree(five, 5), endOfWord(createVisiblePositionInFlat Tree(*one, 0)).deepEquivalent());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 508
509 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr ee(*text, 2))); 509 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr ee(*text, 2)));
510 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInFlatT ree(*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 RawPtr<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
(...skipping 20 matching lines...) Expand all
549 549
550 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*seven, 7))); 550 EXPECT_TRUE(isEndOfLine(createVisiblePositionInDOMTree(*seven, 7)));
551 EXPECT_TRUE(isEndOfLine(createVisiblePositionInFlatTree(*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 RawPtr<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
(...skipping 20 matching lines...) Expand all
590 590
591 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*seven, 7))); 591 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInDOMTree(*seven, 7)));
592 EXPECT_TRUE(isLogicalEndOfLine(createVisiblePositionInFlatTree(*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 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
601 updateLayoutAndStyleForPainting(); 601 updateLayoutAndStyleForPainting();
602 602
603 RefPtrWillBeRawPtr<Element> body = document().body(); 603 RawPtr<Element> body = document().body();
604 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION); 604 RawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCEPTION);
605 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION); 605 RawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCEPTION);
606 RefPtrWillBeRawPtr<Element> four = shadowRoot->querySelector("#s4", ASSERT_N O_EXCEPTION); 606 RawPtr<Element> four = shadowRoot->querySelector("#s4", ASSERT_NO_EXCEPTION) ;
607 RefPtrWillBeRawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_N O_EXCEPTION); 607 RawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_NO_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)));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 653
654 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInDOMTree(*three, 3))); 654 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInDOMTree(*three, 3)));
655 EXPECT_TRUE(isEndOfParagraph(createVisiblePositionInFlatTree(*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 RawPtr<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
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 723
724 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*three, 0))); 724 EXPECT_FALSE(isStartOfParagraph(createVisiblePositionInDOMTree(*three, 0)));
725 EXPECT_TRUE(isStartOfParagraph(createVisiblePositionInFlatTree(*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 RawPtr<Node> one = document().querySelector("#one", ASSERT_NO_EXCEPTION);
734 RefPtrWillBeRawPtr<Node> two = document().querySelector("#two", ASSERT_NO_EX CEPTION); 734 RawPtr<Node> two = document().querySelector("#two", ASSERT_NO_EXCEPTION);
735 RefPtrWillBeRawPtr<Node> three = document().querySelector("#three", ASSERT_N O_EXCEPTION); 735 RawPtr<Node> three = document().querySelector("#three", ASSERT_NO_EXCEPTION) ;
736 RefPtrWillBeRawPtr<Node> four = document().querySelector("#four", ASSERT_NO_ EXCEPTION); 736 RawPtr<Node> four = document().querySelector("#four", ASSERT_NO_EXCEPTION);
737 RefPtrWillBeRawPtr<Element> html = document().createElement("html", ASSERT_N O_EXCEPTION); 737 RawPtr<Element> html = document().createElement("html", ASSERT_NO_EXCEPTION) ;
738 // Move two, three and four into second html element. 738 // Move two, three and four into second html element.
739 html->appendChild(two.get()); 739 html->appendChild(two.get());
740 html->appendChild(three.get()); 740 html->appendChild(three.get());
741 html->appendChild(four.get()); 741 html->appendChild(four.get());
742 one->appendChild(html.get()); 742 one->appendChild(html.get());
743 updateLayoutAndStyleForPainting(); 743 updateLayoutAndStyleForPainting();
744 744
745 EXPECT_FALSE(isVisuallyEquivalentCandidate(Position(document().documentEleme nt(), 0))); 745 EXPECT_FALSE(isVisuallyEquivalentCandidate(Position(document().documentEleme nt(), 0)));
746 746
747 EXPECT_FALSE(isVisuallyEquivalentCandidate(Position(one.get(), 0))); 747 EXPECT_FALSE(isVisuallyEquivalentCandidate(Position(one.get(), 0)));
(...skipping 15 matching lines...) Expand all
763 updateLayoutAndStyleForPainting(); 763 updateLayoutAndStyleForPainting();
764 764
765 EXPECT_FALSE(isVisuallyEquivalentCandidate(Position(&document(), 0))); 765 EXPECT_FALSE(isVisuallyEquivalentCandidate(Position(&document(), 0)));
766 } 766 }
767 767
768 TEST_F(VisibleUnitsTest, leftPositionOf) 768 TEST_F(VisibleUnitsTest, leftPositionOf)
769 { 769 {
770 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>"; 770 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>";
771 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>55555</b>"; 771 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>55555</b>";
772 setBodyContent(bodyContent); 772 setBodyContent(bodyContent);
773 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 773 RawPtr<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(PositionInFlatTree(two->firstChild(), 1), leftPositionOf(createVis iblePosition(PositionInFlatTree(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(PositionInFlatTree(four->firstChild(), 3), leftPositionOf(createVi siblePosition(PositionInFlatTree(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(PositionInFlatTree(five->firstChild(), 5), leftPositionOf(createVi siblePosition(PositionInFlatTree(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 RawPtr<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* layoutObjectFromFlatTree; 805 LayoutObject* layoutObjectFromFlatTree;
806 LayoutRect layoutRectFromFlatTree = localCaretRectOfPosition(PositionInFlatT ree(one->firstChild(), 0), layoutObjectFromFlatTree); 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, layoutObjectFromFlatTree); 810 EXPECT_EQ(layoutObjectFromDOMTree, layoutObjectFromFlatTree);
811 EXPECT_EQ(layoutRectFromDOMTree, layoutRectFromFlatTree); 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 RawPtr<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
(...skipping 25 matching lines...) Expand all
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(PositionInFlatTree(seven, 7), logicalEndOfLine(createVisiblePositi onInFlatTree(*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 RawPtr<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
(...skipping 28 matching lines...) Expand all
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 RawPtr<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(PositionInFlatTree::lastPositionInNode(host.get()), mostForwardCar etPosition(PositionInFlatTree::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);
(...skipping 16 matching lines...) Expand all
941 941
942 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionFirstLetterSplit) 942 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionFirstLetterSplit)
943 { 943 {
944 const char* bodyContent = "<style>p:first-letter {color:red;}</style><p id=s ample>abc</p>"; 944 const char* bodyContent = "<style>p:first-letter {color:red;}</style><p id=s ample>abc</p>";
945 setBodyContent(bodyContent); 945 setBodyContent(bodyContent);
946 updateLayoutAndStyleForPainting(); 946 updateLayoutAndStyleForPainting();
947 947
948 Node* sample = document().getElementById("sample"); 948 Node* sample = document().getElementById("sample");
949 Node* firstLetter = sample->firstChild(); 949 Node* firstLetter = sample->firstChild();
950 // Split "abc" into "a" "bc" 950 // Split "abc" into "a" "bc"
951 RefPtrWillBeRawPtr<Text> remaining = toText(firstLetter)->splitText(1, ASSER T_NO_EXCEPTION); 951 RawPtr<Text> remaining = toText(firstLetter)->splitText(1, ASSERT_NO_EXCEPTI ON);
952 updateLayoutAndStyleForPainting(); 952 updateLayoutAndStyleForPainting();
953 953
954 EXPECT_EQ(Position(sample, 0), mostBackwardCaretPosition(Position(firstLette r, 0))); 954 EXPECT_EQ(Position(sample, 0), mostBackwardCaretPosition(Position(firstLette r, 0)));
955 EXPECT_EQ(Position(firstLetter, 1), mostBackwardCaretPosition(Position(first Letter, 1))); 955 EXPECT_EQ(Position(firstLetter, 1), mostBackwardCaretPosition(Position(first Letter, 1)));
956 EXPECT_EQ(Position(firstLetter, 1), mostBackwardCaretPosition(Position(remai ning, 0))); 956 EXPECT_EQ(Position(firstLetter, 1), mostBackwardCaretPosition(Position(remai ning, 0)));
957 EXPECT_EQ(Position(remaining, 1), mostBackwardCaretPosition(Position(remaini ng, 1))); 957 EXPECT_EQ(Position(remaining, 1), mostBackwardCaretPosition(Position(remaini ng, 1)));
958 EXPECT_EQ(Position(remaining, 2), mostBackwardCaretPosition(Position(remaini ng, 2))); 958 EXPECT_EQ(Position(remaining, 2), mostBackwardCaretPosition(Position(remaini ng, 2)));
959 EXPECT_EQ(Position(remaining, 2), mostBackwardCaretPosition(Position::lastPo sitionInNode(sample))); 959 EXPECT_EQ(Position(remaining, 2), mostBackwardCaretPosition(Position::lastPo sitionInNode(sample)));
960 EXPECT_EQ(Position(remaining, 2), mostBackwardCaretPosition(Position::afterN ode(sample))); 960 EXPECT_EQ(Position(remaining, 2), mostBackwardCaretPosition(Position::afterN ode(sample)));
961 } 961 }
962 962
963 TEST_F(VisibleUnitsTest, mostForwardCaretPositionAfterAnchor) 963 TEST_F(VisibleUnitsTest, mostForwardCaretPositionAfterAnchor)
964 { 964 {
965 const char* bodyContent = "<p id='host'><b id='one'>1</b></p>"; 965 const char* bodyContent = "<p id='host'><b id='one'>1</b></p>";
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 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
969 updateLayoutAndStyleForPainting(); 969 updateLayoutAndStyleForPainting();
970 970
971 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); 971 RawPtr<Element> host = document().getElementById("host");
972 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 972 RawPtr<Element> one = document().getElementById("one");
973 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three"); 973 RawPtr<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(PositionInFlatTree(three->firstChild(), 3), mostBackwardCaretPosit ion(PositionInFlatTree::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);
(...skipping 12 matching lines...) Expand all
996 EXPECT_EQ(Position(sample, 5), mostForwardCaretPosition(Position(sample, 5)) ); 996 EXPECT_EQ(Position(sample, 5), mostForwardCaretPosition(Position(sample, 5)) );
997 EXPECT_EQ(Position(sample, 7), mostForwardCaretPosition(Position(sample, 6)) ); 997 EXPECT_EQ(Position(sample, 7), mostForwardCaretPosition(Position(sample, 6)) );
998 EXPECT_EQ(Position(sample, 7), mostForwardCaretPosition(Position(sample, 7)) ); 998 EXPECT_EQ(Position(sample, 7), mostForwardCaretPosition(Position(sample, 7)) );
999 } 999 }
1000 1000
1001 TEST_F(VisibleUnitsTest, nextPositionOf) 1001 TEST_F(VisibleUnitsTest, nextPositionOf)
1002 { 1002 {
1003 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>"; 1003 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>";
1004 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>55555</b>"; 1004 const char* shadowContent = "<b id=four>4444</b><content select=#two></conte nt><content select=#one></content><b id=five>55555</b>";
1005 setBodyContent(bodyContent); 1005 setBodyContent(bodyContent);
1006 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1006 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
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(PositionInFlatTree(four->firstChild(), 0), nextPositionOf(createVi siblePosition(PositionInFlatTree(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(PositionInFlatTree(one->firstChild(), 1), nextPositionOf(createVis iblePosition(PositionInFlatTree(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(PositionInFlatTree(five->firstChild(), 1), nextPositionOf(createVi siblePosition(PositionInFlatTree(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(PositionInFlatTree(one->firstChild(), 1), nextPositionOf(createVis iblePosition(PositionInFlatTree(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 RawPtr<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());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 // |C C C C 1081 // |C C C C
1082 EXPECT_EQ(PositionWithAffinity(Position(sample, 1)), previousPositionOf(crea teVisiblePosition(Position(sample, 2))).toPositionWithAffinity()); 1082 EXPECT_EQ(PositionWithAffinity(Position(sample, 1)), previousPositionOf(crea teVisiblePosition(Position(sample, 2))).toPositionWithAffinity());
1083 EXPECT_EQ(PositionWithAffinity(Position(sample, 1)), previousPositionOf(crea teVisiblePosition(Position(sample, 2), TextAffinity::Upstream)).toPositionWithAf finity()); 1083 EXPECT_EQ(PositionWithAffinity(Position(sample, 1)), previousPositionOf(crea teVisiblePosition(Position(sample, 2), TextAffinity::Upstream)).toPositionWithAf finity());
1084 } 1084 }
1085 1085
1086 TEST_F(VisibleUnitsTest, rendersInDifferentPositionAfterAnchor) 1086 TEST_F(VisibleUnitsTest, rendersInDifferentPositionAfterAnchor)
1087 { 1087 {
1088 const char* bodyContent = "<p id='sample'>00</p>"; 1088 const char* bodyContent = "<p id='sample'>00</p>";
1089 setBodyContent(bodyContent); 1089 setBodyContent(bodyContent);
1090 updateLayoutAndStyleForPainting(); 1090 updateLayoutAndStyleForPainting();
1091 RefPtrWillBeRawPtr<Element> sample = document().getElementById("sample"); 1091 RawPtr<Element> sample = document().getElementById("sample");
1092 1092
1093 EXPECT_FALSE(rendersInDifferentPosition(Position(), Position())); 1093 EXPECT_FALSE(rendersInDifferentPosition(Position(), Position()));
1094 EXPECT_FALSE(rendersInDifferentPosition(Position(), Position::afterNode(samp le.get()))) 1094 EXPECT_FALSE(rendersInDifferentPosition(Position(), Position::afterNode(samp le.get())))
1095 << "if one of position is null, the reuslt is false."; 1095 << "if one of position is null, the reuslt is false.";
1096 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample.get()), P osition(sample.get(), 1))); 1096 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample.get()), P osition(sample.get(), 1)));
1097 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample. get()), Position(sample.get(), 1))); 1097 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample. get()), Position(sample.get(), 1)));
1098 } 1098 }
1099 1099
1100 TEST_F(VisibleUnitsTest, rendersInDifferentPositionAfterAnchorWithHidden) 1100 TEST_F(VisibleUnitsTest, rendersInDifferentPositionAfterAnchorWithHidden)
1101 { 1101 {
1102 const char* bodyContent = "<p><span id=one>11</span><span id=two style='disp lay:none'> </span></p>"; 1102 const char* bodyContent = "<p><span id=one>11</span><span id=two style='disp lay:none'> </span></p>";
1103 setBodyContent(bodyContent); 1103 setBodyContent(bodyContent);
1104 updateLayoutAndStyleForPainting(); 1104 updateLayoutAndStyleForPainting();
1105 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 1105 RawPtr<Element> one = document().getElementById("one");
1106 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); 1106 RawPtr<Element> two = document().getElementById("two");
1107 1107
1108 EXPECT_TRUE(rendersInDifferentPosition(Position::lastPositionInNode(one.get( )), Position(two.get(), 0))) 1108 EXPECT_TRUE(rendersInDifferentPosition(Position::lastPositionInNode(one.get( )), Position(two.get(), 0)))
1109 << "two doesn't have layout object"; 1109 << "two doesn't have layout object";
1110 } 1110 }
1111 1111
1112 TEST_F(VisibleUnitsTest, rendersInDifferentPositionAfterAnchorWithDifferentLayou tObjects) 1112 TEST_F(VisibleUnitsTest, rendersInDifferentPositionAfterAnchorWithDifferentLayou tObjects)
1113 { 1113 {
1114 const char* bodyContent = "<p><span id=one>11</span><span id=two> </span></ p>"; 1114 const char* bodyContent = "<p><span id=one>11</span><span id=two> </span></ p>";
1115 setBodyContent(bodyContent); 1115 setBodyContent(bodyContent);
1116 updateLayoutAndStyleForPainting(); 1116 updateLayoutAndStyleForPainting();
1117 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 1117 RawPtr<Element> one = document().getElementById("one");
1118 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); 1118 RawPtr<Element> two = document().getElementById("two");
1119 1119
1120 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(one.get ()), Position(two.get(), 0))); 1120 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(one.get ()), Position(two.get(), 0)));
1121 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(one.get ()), Position(two.get(), 1))) 1121 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(one.get ()), Position(two.get(), 1)))
1122 << "width of two is zero since contents is collapsed whitespaces"; 1122 << "width of two is zero since contents is collapsed whitespaces";
1123 } 1123 }
1124 1124
1125 TEST_F(VisibleUnitsTest, renderedOffset) 1125 TEST_F(VisibleUnitsTest, renderedOffset)
1126 { 1126 {
1127 const char* bodyContent = "<div contenteditable><span id='sample1'>1</span>< span id='sample2'>22</span></div>"; 1127 const char* bodyContent = "<div contenteditable><span id='sample1'>1</span>< span id='sample2'>22</span></div>";
1128 setBodyContent(bodyContent); 1128 setBodyContent(bodyContent);
1129 updateLayoutAndStyleForPainting(); 1129 updateLayoutAndStyleForPainting();
1130 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); 1130 RawPtr<Element> sample1 = document().getElementById("sample1");
1131 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); 1131 RawPtr<Element> sample2 = document().getElementById("sample2");
1132 1132
1133 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0))); 1133 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0)));
1134 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0))); 1134 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0)));
1135 } 1135 }
1136 1136
1137 TEST_F(VisibleUnitsTest, rightPositionOf) 1137 TEST_F(VisibleUnitsTest, rightPositionOf)
1138 { 1138 {
1139 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>"; 1139 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>";
1140 const char* shadowContent = "<p id=four>4444</p><content select=#two></conte nt><content select=#one></content><p id=five>55555</p>"; 1140 const char* shadowContent = "<p id=four>4444</p><content select=#two></conte nt><content select=#one></content><p id=five>55555</p>";
1141 setBodyContent(bodyContent); 1141 setBodyContent(bodyContent);
1142 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1142 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
1143 updateLayoutAndStyleForPainting(); 1143 updateLayoutAndStyleForPainting();
1144 1144
1145 Node* one = document().getElementById("one")->firstChild(); 1145 Node* one = document().getElementById("one")->firstChild();
1146 Node* two = document().getElementById("two")->firstChild(); 1146 Node* two = document().getElementById("two")->firstChild();
1147 Node* three = document().getElementById("three")->firstChild(); 1147 Node* three = document().getElementById("three")->firstChild();
1148 Node* four = shadowRoot->getElementById("four")->firstChild(); 1148 Node* four = shadowRoot->getElementById("four")->firstChild();
1149 Node* five = shadowRoot->getElementById("five")->firstChild(); 1149 Node* five = shadowRoot->getElementById("five")->firstChild();
1150 1150
1151 EXPECT_EQ(Position(), rightPositionOf(createVisiblePosition(Position(one, 1) )).deepEquivalent()); 1151 EXPECT_EQ(Position(), rightPositionOf(createVisiblePosition(Position(one, 1) )).deepEquivalent());
1152 EXPECT_EQ(PositionInFlatTree(five, 0), rightPositionOf(createVisiblePosition (PositionInFlatTree(one, 1))).deepEquivalent()); 1152 EXPECT_EQ(PositionInFlatTree(five, 0), rightPositionOf(createVisiblePosition (PositionInFlatTree(one, 1))).deepEquivalent());
(...skipping 24 matching lines...) Expand all
1177 1177
1178 EXPECT_EQ(Position(one, 0), startOfDocument(createVisiblePositionInDOMTree(* two, 1)).deepEquivalent()); 1178 EXPECT_EQ(Position(one, 0), startOfDocument(createVisiblePositionInDOMTree(* two, 1)).deepEquivalent());
1179 EXPECT_EQ(PositionInFlatTree(two, 0), startOfDocument(createVisiblePositionI nFlatTree(*two, 1)).deepEquivalent()); 1179 EXPECT_EQ(PositionInFlatTree(two, 0), startOfDocument(createVisiblePositionI nFlatTree(*two, 1)).deepEquivalent());
1180 } 1180 }
1181 1181
1182 TEST_F(VisibleUnitsTest, startOfLine) 1182 TEST_F(VisibleUnitsTest, startOfLine)
1183 { 1183 {
1184 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>"; 1184 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>";
1185 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>"; 1185 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>";
1186 setBodyContent(bodyContent); 1186 setBodyContent(bodyContent);
1187 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1187 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
1188 updateLayoutAndStyleForPainting(); 1188 updateLayoutAndStyleForPainting();
1189 1189
1190 Node* one = document().getElementById("one")->firstChild(); 1190 Node* one = document().getElementById("one")->firstChild();
1191 Node* two = document().getElementById("two")->firstChild(); 1191 Node* two = document().getElementById("two")->firstChild();
1192 Node* three = document().getElementById("three")->firstChild(); 1192 Node* three = document().getElementById("three")->firstChild();
1193 Node* four = document().getElementById("four")->firstChild(); 1193 Node* four = document().getElementById("four")->firstChild();
1194 Node* five = shadowRoot->getElementById("five")->firstChild(); 1194 Node* five = shadowRoot->getElementById("five")->firstChild();
1195 Node* six = shadowRoot->getElementById("six")->firstChild(); 1195 Node* six = shadowRoot->getElementById("six")->firstChild();
1196 Node* seven = shadowRoot->getElementById("seven")->firstChild(); 1196 Node* seven = shadowRoot->getElementById("seven")->firstChild();
1197 1197
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 1246
1247 // DOM version of |startOfParagraph()| doesn't take account contents in 1247 // DOM version of |startOfParagraph()| doesn't take account contents in
1248 // shadow tree. 1248 // shadow tree.
1249 EXPECT_EQ(Position(zero, 0), startOfParagraph(createVisiblePositionInDOMTree (*three, 2)).deepEquivalent()); 1249 EXPECT_EQ(Position(zero, 0), startOfParagraph(createVisiblePositionInDOMTree (*three, 2)).deepEquivalent());
1250 EXPECT_EQ(PositionInFlatTree(three, 0), startOfParagraph(createVisiblePositi onInFlatTree(*three, 2)).deepEquivalent()); 1250 EXPECT_EQ(PositionInFlatTree(three, 0), startOfParagraph(createVisiblePositi onInFlatTree(*three, 2)).deepEquivalent());
1251 1251
1252 // crbug.com/563777. startOfParagraph() unexpectedly returned a null 1252 // crbug.com/563777. startOfParagraph() unexpectedly returned a null
1253 // position with nested editable <BODY>s. 1253 // position with nested editable <BODY>s.
1254 Element* root = document().documentElement(); 1254 Element* root = document().documentElement();
1255 root->setInnerHTML("<style>* { display:inline-table; }</style><body contente ditable=true><svg><svg><foreignObject>abc<svg></svg></foreignObject></svg></svg> </body>", ASSERT_NO_EXCEPTION); 1255 root->setInnerHTML("<style>* { display:inline-table; }</style><body contente ditable=true><svg><svg><foreignObject>abc<svg></svg></foreignObject></svg></svg> </body>", ASSERT_NO_EXCEPTION);
1256 RefPtrWillBeRawPtr<Element> oldBody = document().body(); 1256 RawPtr<Element> oldBody = document().body();
1257 root->setInnerHTML("<body contenteditable=true><svg><foreignObject><style>de f</style>", ASSERT_NO_EXCEPTION); 1257 root->setInnerHTML("<body contenteditable=true><svg><foreignObject><style>de f</style>", ASSERT_NO_EXCEPTION);
1258 ASSERT(oldBody != document().body()); 1258 ASSERT(oldBody != document().body());
1259 Node* foreignObject = document().body()->firstChild()->firstChild(); 1259 Node* foreignObject = document().body()->firstChild()->firstChild();
1260 foreignObject->insertBefore(oldBody.get(), foreignObject->firstChild()); 1260 foreignObject->insertBefore(oldBody.get(), foreignObject->firstChild());
1261 Node* styleText = foreignObject->lastChild()->firstChild(); 1261 Node* styleText = foreignObject->lastChild()->firstChild();
1262 ASSERT(styleText->isTextNode()); 1262 ASSERT(styleText->isTextNode());
1263 updateLayoutAndStyleForPainting(); 1263 updateLayoutAndStyleForPainting();
1264 1264
1265 EXPECT_FALSE(startOfParagraph(createVisiblePosition(Position(styleText, 0))) .isNull()); 1265 EXPECT_FALSE(startOfParagraph(createVisiblePosition(Position(styleText, 0))) .isNull());
1266 } 1266 }
1267 1267
1268 TEST_F(VisibleUnitsTest, startOfSentence) 1268 TEST_F(VisibleUnitsTest, startOfSentence)
1269 { 1269 {
1270 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>"; 1270 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>";
1271 const char* shadowContent = "<p><i id=three>333</i> <content select=#two></c ontent> <content select=#one></content> <i id=four>4444</i></p>"; 1271 const char* shadowContent = "<p><i id=three>333</i> <content select=#two></c ontent> <content select=#one></content> <i id=four>4444</i></p>";
1272 setBodyContent(bodyContent); 1272 setBodyContent(bodyContent);
1273 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1273 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
1274 updateLayoutAndStyleForPainting(); 1274 updateLayoutAndStyleForPainting();
1275 1275
1276 Node* one = document().getElementById("one")->firstChild(); 1276 Node* one = document().getElementById("one")->firstChild();
1277 Node* two = document().getElementById("two")->firstChild(); 1277 Node* two = document().getElementById("two")->firstChild();
1278 Node* three = shadowRoot->getElementById("three")->firstChild(); 1278 Node* three = shadowRoot->getElementById("three")->firstChild();
1279 Node* four = shadowRoot->getElementById("four")->firstChild(); 1279 Node* four = shadowRoot->getElementById("four")->firstChild();
1280 1280
1281 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* one, 0)).deepEquivalent()); 1281 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(* one, 0)).deepEquivalent());
1282 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*one, 0)).deepEquivalent()); 1282 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*one, 0)).deepEquivalent());
1283 1283
(...skipping 11 matching lines...) Expand all
1295 1295
1296 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree (*four, 1)).deepEquivalent()); 1296 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree (*four, 1)).deepEquivalent());
1297 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*four, 1)).deepEquivalent()); 1297 EXPECT_EQ(PositionInFlatTree(three, 0), startOfSentence(createVisiblePositio nInFlatTree(*four, 1)).deepEquivalent());
1298 } 1298 }
1299 1299
1300 TEST_F(VisibleUnitsTest, startOfWord) 1300 TEST_F(VisibleUnitsTest, startOfWord)
1301 { 1301 {
1302 const char* bodyContent = "<a id=host><b id=one>1</b> <b id=two>22</b></a><i id=three>333</i>"; 1302 const char* bodyContent = "<a id=host><b id=one>1</b> <b id=two>22</b></a><i id=three>333</i>";
1303 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>"; 1303 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>";
1304 setBodyContent(bodyContent); 1304 setBodyContent(bodyContent);
1305 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 1305 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
1306 updateLayoutAndStyleForPainting(); 1306 updateLayoutAndStyleForPainting();
1307 1307
1308 Node* one = document().getElementById("one")->firstChild(); 1308 Node* one = document().getElementById("one")->firstChild();
1309 Node* two = document().getElementById("two")->firstChild(); 1309 Node* two = document().getElementById("two")->firstChild();
1310 Node* three = document().getElementById("three")->firstChild(); 1310 Node* three = document().getElementById("three")->firstChild();
1311 Node* four = shadowRoot->getElementById("four")->firstChild(); 1311 Node* four = shadowRoot->getElementById("four")->firstChild();
1312 Node* five = shadowRoot->getElementById("five")->firstChild(); 1312 Node* five = shadowRoot->getElementById("five")->firstChild();
1313 Node* space = shadowRoot->getElementById("space")->firstChild(); 1313 Node* space = shadowRoot->getElementById("space")->firstChild();
1314 1314
1315 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent()); 1315 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one, 0)).deepEquivalent());
(...skipping 18 matching lines...) Expand all
1334 EXPECT_EQ(PositionInFlatTree(space, 1), startOfWord(createVisiblePositionInF latTree(*five, 1)).deepEquivalent()); 1334 EXPECT_EQ(PositionInFlatTree(space, 1), startOfWord(createVisiblePositionInF latTree(*five, 1)).deepEquivalent());
1335 } 1335 }
1336 1336
1337 TEST_F(VisibleUnitsTest, endsOfNodeAreVisuallyDistinctPositionsWithInvisibleChil d) 1337 TEST_F(VisibleUnitsTest, endsOfNodeAreVisuallyDistinctPositionsWithInvisibleChil d)
1338 { 1338 {
1339 // Repro case of crbug.com/582247 1339 // Repro case of crbug.com/582247
1340 const char* bodyContent = "<button> </button><script>document.designMode = ' on'</script>"; 1340 const char* bodyContent = "<button> </button><script>document.designMode = ' on'</script>";
1341 setBodyContent(bodyContent); 1341 setBodyContent(bodyContent);
1342 updateLayoutAndStyleForPainting(); 1342 updateLayoutAndStyleForPainting();
1343 1343
1344 RefPtrWillBeRawPtr<Node> button = document().querySelector("button", ASSERT_ NO_EXCEPTION); 1344 RawPtr<Node> button = document().querySelector("button", ASSERT_NO_EXCEPTION );
1345 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button.get())); 1345 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button.get()));
1346 } 1346 }
1347 1347
1348 TEST_F(VisibleUnitsTest, endsOfNodeAreVisuallyDistinctPositionsWithEmptyLayoutCh ild) 1348 TEST_F(VisibleUnitsTest, endsOfNodeAreVisuallyDistinctPositionsWithEmptyLayoutCh ild)
1349 { 1349 {
1350 // Repro case of crbug.com/584030 1350 // Repro case of crbug.com/584030
1351 const char* bodyContent = "<button><rt><script>document.designMode = 'on'</s cript></rt></button>"; 1351 const char* bodyContent = "<button><rt><script>document.designMode = 'on'</s cript></rt></button>";
1352 setBodyContent(bodyContent); 1352 setBodyContent(bodyContent);
1353 updateLayoutAndStyleForPainting(); 1353 updateLayoutAndStyleForPainting();
1354 1354
1355 RefPtrWillBeRawPtr<Node> button = document().querySelector("button", ASSERT_ NO_EXCEPTION); 1355 RawPtr<Node> button = document().querySelector("button", ASSERT_NO_EXCEPTION );
1356 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button.get())); 1356 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button.get()));
1357 } 1357 }
1358 1358
1359 } // namespace blink 1359 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698