| 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/dom/Position.h" | 6 #include "core/dom/Position.h" |
| 7 | 7 |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 EXPECT_EQ(t2, Position::inParentAfterNode(*n2).nodeAsRangeLastNode()); | 95 EXPECT_EQ(t2, Position::inParentAfterNode(*n2).nodeAsRangeLastNode()); |
| 96 EXPECT_EQ(t3, Position::afterNode(host).nodeAsRangeLastNode()); | 96 EXPECT_EQ(t3, Position::afterNode(host).nodeAsRangeLastNode()); |
| 97 | 97 |
| 98 EXPECT_EQ(t2, PositionInComposedTree::inParentBeforeNode(*n1).nodeAsRangeLas
tNode()); | 98 EXPECT_EQ(t2, PositionInComposedTree::inParentBeforeNode(*n1).nodeAsRangeLas
tNode()); |
| 99 EXPECT_EQ(a, PositionInComposedTree::inParentBeforeNode(*n2).nodeAsRangeLast
Node()); | 99 EXPECT_EQ(a, PositionInComposedTree::inParentBeforeNode(*n2).nodeAsRangeLast
Node()); |
| 100 EXPECT_EQ(t1, PositionInComposedTree::inParentAfterNode(*n1).nodeAsRangeLast
Node()); | 100 EXPECT_EQ(t1, PositionInComposedTree::inParentAfterNode(*n1).nodeAsRangeLast
Node()); |
| 101 EXPECT_EQ(t2, PositionInComposedTree::inParentAfterNode(*n2).nodeAsRangeLast
Node()); | 101 EXPECT_EQ(t2, PositionInComposedTree::inParentAfterNode(*n2).nodeAsRangeLast
Node()); |
| 102 EXPECT_EQ(t1, PositionInComposedTree::afterNode(host).nodeAsRangeLastNode())
; | 102 EXPECT_EQ(t1, PositionInComposedTree::afterNode(host).nodeAsRangeLastNode())
; |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST_F(PositionTest, rendersInDifferentPositionAfterAnchor) |
| 106 { |
| 107 const char* bodyContent = "<p id='sample'>00</p>"; |
| 108 setBodyContent(bodyContent); |
| 109 updateLayoutAndStyleForPainting(); |
| 110 RefPtrWillBeRawPtr<Element> sample = document().getElementById("sample"); |
| 111 |
| 112 EXPECT_FALSE(Position::afterNode(sample.get()).rendersInDifferentPosition(Po
sition(sample.get(), 1))); |
| 113 EXPECT_FALSE(Position::lastPositionInNode(sample.get()).rendersInDifferentPo
sition(Position(sample.get(), 1))); |
| 114 } |
| 115 |
| 105 TEST_F(PositionTest, ToPositionInComposedTreeWithActiveInsertionPoint) | 116 TEST_F(PositionTest, ToPositionInComposedTreeWithActiveInsertionPoint) |
| 106 { | 117 { |
| 107 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; | 118 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
| 108 const char* shadowContent = "<a id='a'><content select=#one id='content'></c
ontent><content></content></a>"; | 119 const char* shadowContent = "<a id='a'><content select=#one id='content'></c
ontent><content></content></a>"; |
| 109 setBodyContent(bodyContent); | 120 setBodyContent(bodyContent); |
| 110 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); | 121 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); |
| 111 RefPtrWillBeRawPtr<Element> anchor = shadowRoot->getElementById("a"); | 122 RefPtrWillBeRawPtr<Element> anchor = shadowRoot->getElementById("a"); |
| 112 | 123 |
| 113 EXPECT_EQ(PositionInComposedTree(anchor.get(), 0), toPositionInComposedTree(
Position(anchor.get(), 0))); | 124 EXPECT_EQ(PositionInComposedTree(anchor.get(), 0), toPositionInComposedTree(
Position(anchor.get(), 0))); |
| 114 EXPECT_EQ(PositionInComposedTree(anchor.get(), 1), toPositionInComposedTree(
Position(anchor.get(), 1))); | 125 EXPECT_EQ(PositionInComposedTree(anchor.get(), 1), toPositionInComposedTree(
Position(anchor.get(), 1))); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 181 |
| 171 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 182 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
| 172 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | 183 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
| 173 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three"); | 184 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three"); |
| 174 | 185 |
| 175 EXPECT_EQ(Position(one->firstChild(), 1), Position::afterNode(host.get()).up
stream()); | 186 EXPECT_EQ(Position(one->firstChild(), 1), Position::afterNode(host.get()).up
stream()); |
| 176 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 3), PositionInComposed
Tree::afterNode(host.get()).upstream()); | 187 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 3), PositionInComposed
Tree::afterNode(host.get()).upstream()); |
| 177 } | 188 } |
| 178 | 189 |
| 179 } // namespace blink | 190 } // namespace blink |
| OLD | NEW |