| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/VisibleSelection.h" | 5 #include "core/editing/VisibleSelection.h" |
| 6 | 6 |
| 7 #include "core/dom/Range.h" | 7 #include "core/dom/Range.h" |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 | 9 |
| 10 #define LOREM_IPSUM \ | 10 #define LOREM_IPSUM \ |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 VisibleSelection selection(Position::firstPositionInNode(one.get()), Positio
n::lastPositionInNode(shadowRoot.get())); | 181 VisibleSelection selection(Position::firstPositionInNode(one.get()), Positio
n::lastPositionInNode(shadowRoot.get())); |
| 182 VisibleSelectionInComposedTree selectionInComposedTree(PositionInComposedTre
e::firstPositionInNode(one.get()), PositionInComposedTree::lastPositionInNode(ho
st.get())); | 182 VisibleSelectionInComposedTree selectionInComposedTree(PositionInComposedTre
e::firstPositionInNode(one.get()), PositionInComposedTree::lastPositionInNode(ho
st.get())); |
| 183 | 183 |
| 184 EXPECT_EQ(Position(host.get(), PositionAnchorType::BeforeAnchor), selection.
start()); | 184 EXPECT_EQ(Position(host.get(), PositionAnchorType::BeforeAnchor), selection.
start()); |
| 185 EXPECT_EQ(Position(one->firstChild(), 0), selection.end()); | 185 EXPECT_EQ(Position(one->firstChild(), 0), selection.end()); |
| 186 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 0), selectionInComposedT
ree.start()); | 186 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 0), selectionInComposedT
ree.start()); |
| 187 EXPECT_EQ(PositionInComposedTree(six->firstChild(), 2), selectionInComposedT
ree.end()); | 187 EXPECT_EQ(PositionInComposedTree(six->firstChild(), 2), selectionInComposedT
ree.end()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 TEST_F(VisibleSelectionTest, ShadowDistributedNodes) | 190 TEST_F(VisibleSelectionTest, ShadowV0DistributedNodes) |
| 191 { | 191 { |
| 192 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; | 192 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; |
| 193 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two>
</content><span id='s5'>55</span><content select=#one></content><span id='s6'>66
</span></a>"; | 193 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two>
</content><span id='s5'>55</span><content select=#one></content><span id='s6'>66
</span></a>"; |
| 194 setBodyContent(bodyContent); | 194 setBodyContent(bodyContent); |
| 195 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); | 195 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); |
| 196 | 196 |
| 197 RefPtrWillBeRawPtr<Element> body = document().body(); | 197 RefPtrWillBeRawPtr<Element> body = document().body(); |
| 198 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); | 198 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); |
| 199 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE
PTION); | 199 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE
PTION); |
| 200 RefPtrWillBeRawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_N
O_EXCEPTION); | 200 RefPtrWillBeRawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_N
O_EXCEPTION); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 345 |
| 346 RefPtrWillBeRawPtr<Range> range = firstRangeOf(selection); | 346 RefPtrWillBeRawPtr<Range> range = firstRangeOf(selection); |
| 347 EXPECT_EQ(0, range->startOffset()); | 347 EXPECT_EQ(0, range->startOffset()); |
| 348 EXPECT_EQ(11, range->endOffset()); | 348 EXPECT_EQ(11, range->endOffset()); |
| 349 EXPECT_EQ("Lorem ipsum", range->text()); | 349 EXPECT_EQ("Lorem ipsum", range->text()); |
| 350 testComposedTreePositionsToEqualToDOMTreePositions(selection, selectionI
nComposedTree); | 350 testComposedTreePositionsToEqualToDOMTreePositions(selection, selectionI
nComposedTree); |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| 354 } // namespace blink | 354 } // namespace blink |
| OLD | NEW |