| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 Element* two = document().getElementById("two"); | 86 Element* two = document().getElementById("two"); |
| 87 Element* three = document().getElementById("three"); | 87 Element* three = document().getElementById("three"); |
| 88 | 88 |
| 89 EXPECT_EQ(Position(three->firstChild(), 3), endOfParagraph(createVisiblePosi
tionInDOMTree(*one->firstChild(), 1)).deepEquivalent()); | 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()); | 90 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 1), endOfParagraph(creat
eVisiblePositionInComposedTree(*one->firstChild(), 1)).deepEquivalent()); |
| 91 | 91 |
| 92 EXPECT_EQ(Position(three->firstChild(), 3), endOfParagraph(createVisiblePosi
tionInDOMTree(*two->firstChild(), 2)).deepEquivalent()); | 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()); | 93 EXPECT_EQ(PositionInComposedTree(two->firstChild(), 2), endOfParagraph(creat
eVisiblePositionInComposedTree(*two->firstChild(), 2)).deepEquivalent()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 TEST_F(VisibleUnitsTest, isEndOfEditableOrNonEditableContent) |
| 97 { |
| 98 const char* bodyContent = "<a id=host><b id=one contenteditable>1</b><b id=t
wo>22</b></a>"; |
| 99 const char* shadowContent = "<content select=#two></content></p><p><content
select=#one></content>"; |
| 100 setBodyContent(bodyContent); |
| 101 setShadowContent(shadowContent, "host"); |
| 102 updateLayoutAndStyleForPainting(); |
| 103 |
| 104 Element* one = document().getElementById("one"); |
| 105 Element* two = document().getElementById("two"); |
| 106 |
| 107 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT
ree(*one->firstChild(), 1))); |
| 108 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInCompo
sedTree(*one->firstChild(), 1))); |
| 109 |
| 110 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr
ee(*two->firstChild(), 2))); |
| 111 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInComp
osedTree(*two->firstChild(), 2))); |
| 112 } |
| 113 |
| 96 TEST_F(VisibleUnitsTest, inSameLine) | 114 TEST_F(VisibleUnitsTest, inSameLine) |
| 97 { | 115 { |
| 98 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; | 116 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; |
| 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>"; | 117 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>"; |
| 100 setBodyContent(bodyContent); | 118 setBodyContent(bodyContent); |
| 101 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); | 119 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); |
| 102 updateLayoutAndStyleForPainting(); | 120 updateLayoutAndStyleForPainting(); |
| 103 | 121 |
| 104 RefPtrWillBeRawPtr<Element> body = document().body(); | 122 RefPtrWillBeRawPtr<Element> body = document().body(); |
| 105 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); | 123 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 setBodyContent(bodyContent); | 243 setBodyContent(bodyContent); |
| 226 updateLayoutAndStyleForPainting(); | 244 updateLayoutAndStyleForPainting(); |
| 227 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); | 245 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); |
| 228 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); | 246 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); |
| 229 | 247 |
| 230 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); | 248 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); |
| 231 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); | 249 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); |
| 232 } | 250 } |
| 233 | 251 |
| 234 } // namespace blink | 252 } // namespace blink |
| OLD | NEW |