OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/editing/VisibleUnits.h" | 6 #include "core/editing/VisibleUnits.h" |
7 | 7 |
8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
9 #include "core/editing/VisiblePosition.h" | 9 #include "core/editing/VisiblePosition.h" |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | 67 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
68 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); | 68 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); |
69 | 69 |
70 EXPECT_EQ('2', characterAfter(createVisiblePositionInDOMTree(*one->firstChil
d(), 1))); | 70 EXPECT_EQ('2', characterAfter(createVisiblePositionInDOMTree(*one->firstChil
d(), 1))); |
71 EXPECT_EQ('5', characterAfter(createVisiblePositionInComposedTree(*one->firs
tChild(), 1))); | 71 EXPECT_EQ('5', characterAfter(createVisiblePositionInComposedTree(*one->firs
tChild(), 1))); |
72 | 72 |
73 EXPECT_EQ(0, characterAfter(createVisiblePositionInDOMTree(*two->firstChild(
), 2))); | 73 EXPECT_EQ(0, characterAfter(createVisiblePositionInDOMTree(*two->firstChild(
), 2))); |
74 EXPECT_EQ('1', characterAfter(createVisiblePositionInComposedTree(*two->firs
tChild(), 2))); | 74 EXPECT_EQ('1', characterAfter(createVisiblePositionInComposedTree(*two->firs
tChild(), 2))); |
75 } | 75 } |
76 | 76 |
| 77 TEST_F(VisibleUnitsTest, endOfParagraph) |
| 78 { |
| 79 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a><b
id=three>333</b>"; |
| 80 const char* shadowContent = "<p><content select=#two></content></p><p><conte
nt select=#one></content></p>"; |
| 81 setBodyContent(bodyContent); |
| 82 setShadowContent(shadowContent, "host"); |
| 83 updateLayoutAndStyleForPainting(); |
| 84 |
| 85 Element* one = document().getElementById("one"); |
| 86 Element* two = document().getElementById("two"); |
| 87 Element* three = document().getElementById("three"); |
| 88 |
| 89 EXPECT_EQ(Position(three->firstChild(), 3), endOfParagraph(createVisiblePosi
tionInDOMTree(*one->firstChild(), 1)).deepEquivalent()); |
| 90 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 1), endOfParagraph(creat
eVisiblePositionInComposedTree(*one->firstChild(), 1)).deepEquivalent()); |
| 91 |
| 92 EXPECT_EQ(Position(three->firstChild(), 3), endOfParagraph(createVisiblePosi
tionInDOMTree(*two->firstChild(), 2)).deepEquivalent()); |
| 93 EXPECT_EQ(PositionInComposedTree(two->firstChild(), 2), endOfParagraph(creat
eVisiblePositionInComposedTree(*two->firstChild(), 2)).deepEquivalent()); |
| 94 } |
| 95 |
77 TEST_F(VisibleUnitsTest, inSameLine) | 96 TEST_F(VisibleUnitsTest, inSameLine) |
78 { | 97 { |
79 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; | 98 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; |
80 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>"; | 99 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>"; |
81 setBodyContent(bodyContent); | 100 setBodyContent(bodyContent); |
82 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); | 101 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); |
83 updateLayoutAndStyleForPainting(); | 102 updateLayoutAndStyleForPainting(); |
84 | 103 |
85 RefPtrWillBeRawPtr<Element> body = document().body(); | 104 RefPtrWillBeRawPtr<Element> body = document().body(); |
86 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); | 105 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 setBodyContent(bodyContent); | 197 setBodyContent(bodyContent); |
179 updateLayoutAndStyleForPainting(); | 198 updateLayoutAndStyleForPainting(); |
180 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); | 199 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); |
181 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); | 200 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); |
182 | 201 |
183 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); | 202 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); |
184 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); | 203 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); |
185 } | 204 } |
186 | 205 |
187 } // namespace blink | 206 } // namespace blink |
OLD | NEW |