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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 RefPtrWillBeRawPtr<Element> body = document().body(); | 48 RefPtrWillBeRawPtr<Element> body = document().body(); |
49 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); | 49 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); |
50 | 50 |
51 IntRect boundsInDOMTree = absoluteCaretBoundsOf(createVisiblePosition(Positi
on(one.get(), 0))); | 51 IntRect boundsInDOMTree = absoluteCaretBoundsOf(createVisiblePosition(Positi
on(one.get(), 0))); |
52 IntRect boundsInComposedTree = absoluteCaretBoundsOf(createVisiblePosition(P
ositionInComposedTree(one.get(), 0))); | 52 IntRect boundsInComposedTree = absoluteCaretBoundsOf(createVisiblePosition(P
ositionInComposedTree(one.get(), 0))); |
53 | 53 |
54 EXPECT_FALSE(boundsInDOMTree.isEmpty()); | 54 EXPECT_FALSE(boundsInDOMTree.isEmpty()); |
55 EXPECT_EQ(boundsInDOMTree, boundsInComposedTree); | 55 EXPECT_EQ(boundsInDOMTree, boundsInComposedTree); |
56 } | 56 } |
57 | 57 |
| 58 TEST_F(VisibleUnitsTest, characterAfter) |
| 59 { |
| 60 const char* bodyContent = "<p id='host'><b id='one'>1</b><b id='two'>22</b><
/p><b id='three'>333</b>"; |
| 61 const char* shadowContent = "<b id='four'>4444</b><content select=#two></con
tent><content select=#one></content><b id='five'>5555</b>"; |
| 62 setBodyContent(bodyContent); |
| 63 setShadowContent(shadowContent, "host"); |
| 64 updateLayoutAndStyleForPainting(); |
| 65 |
| 66 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
| 67 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); |
| 68 |
| 69 EXPECT_EQ('2', characterAfter(createVisiblePositionInDOMTree(*one->firstChil
d(), 1))); |
| 70 EXPECT_EQ('5', characterAfter(createVisiblePositionInComposedTree(*one->firs
tChild(), 1))); |
| 71 |
| 72 EXPECT_EQ(0, characterAfter(createVisiblePositionInDOMTree(*two->firstChild(
), 2))); |
| 73 EXPECT_EQ('1', characterAfter(createVisiblePositionInComposedTree(*two->firs
tChild(), 2))); |
| 74 } |
| 75 |
58 TEST_F(VisibleUnitsTest, inSameLine) | 76 TEST_F(VisibleUnitsTest, inSameLine) |
59 { | 77 { |
60 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; | 78 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; |
61 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>"; | 79 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>"; |
62 setBodyContent(bodyContent); | 80 setBodyContent(bodyContent); |
63 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); | 81 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); |
64 updateLayoutAndStyleForPainting(); | 82 updateLayoutAndStyleForPainting(); |
65 | 83 |
66 RefPtrWillBeRawPtr<Element> body = document().body(); | 84 RefPtrWillBeRawPtr<Element> body = document().body(); |
67 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); | 85 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 setBodyContent(bodyContent); | 177 setBodyContent(bodyContent); |
160 updateLayoutAndStyleForPainting(); | 178 updateLayoutAndStyleForPainting(); |
161 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); | 179 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); |
162 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); | 180 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); |
163 | 181 |
164 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); | 182 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); |
165 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); | 183 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); |
166 } | 184 } |
167 | 185 |
168 } // namespace blink | 186 } // namespace blink |
OLD | NEW |