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 "core/editing/EditingUtilities.h" | 5 #include "core/editing/EditingUtilities.h" |
6 | 6 |
7 #include "core/dom/StaticNodeList.h" | 7 #include "core/dom/StaticNodeList.h" |
8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 EXPECT_EQ( | 57 EXPECT_EQ( |
58 Position::FirstPositionInNode(*host), | 58 Position::FirstPositionInNode(*host), |
59 FirstEditablePositionAfterPositionInRoot(Position(three, 0), *host)); | 59 FirstEditablePositionAfterPositionInRoot(Position(three, 0), *host)); |
60 EXPECT_EQ( | 60 EXPECT_EQ( |
61 Position(one->firstChild(), 0), | 61 Position(one->firstChild(), 0), |
62 FirstEditableVisiblePositionAfterPositionInRoot(Position(three, 0), *host) | 62 FirstEditableVisiblePositionAfterPositionInRoot(Position(three, 0), *host) |
63 .DeepEquivalent()); | 63 .DeepEquivalent()); |
64 EXPECT_EQ(PositionInFlatTree::AfterNode(*host), | 64 EXPECT_EQ(PositionInFlatTree::AfterNode(*host), |
65 FirstEditablePositionAfterPositionInRoot( | 65 FirstEditablePositionAfterPositionInRoot( |
66 PositionInFlatTree(three, 0), *host)); | 66 PositionInFlatTree(three, 0), *host)); |
67 EXPECT_EQ(PositionInFlatTree::LastPositionInNode(host), | 67 EXPECT_EQ(PositionInFlatTree::LastPositionInNode(*host), |
68 FirstEditableVisiblePositionAfterPositionInRoot( | 68 FirstEditableVisiblePositionAfterPositionInRoot( |
69 PositionInFlatTree(three, 0), *host) | 69 PositionInFlatTree(three, 0), *host) |
70 .DeepEquivalent()); | 70 .DeepEquivalent()); |
71 } | 71 } |
72 | 72 |
73 TEST_F(EditingUtilitiesTest, enclosingBlock) { | 73 TEST_F(EditingUtilitiesTest, enclosingBlock) { |
74 const char* body_content = "<p id='host'><b id='one'>11</b></p>"; | 74 const char* body_content = "<p id='host'><b id='one'>11</b></p>"; |
75 const char* shadow_content = | 75 const char* shadow_content = |
76 "<content select=#two></content><div id='three'><content " | 76 "<content select=#two></content><div id='three'><content " |
77 "select=#one></content></div>"; | 77 "select=#one></content></div>"; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 Node* host = GetDocument().getElementById("host"); | 131 Node* host = GetDocument().getElementById("host"); |
132 Node* table = GetDocument().getElementById("table"); | 132 Node* table = GetDocument().getElementById("table"); |
133 | 133 |
134 EXPECT_EQ(table, TableElementJustBefore(VisiblePosition::AfterNode(*table))); | 134 EXPECT_EQ(table, TableElementJustBefore(VisiblePosition::AfterNode(*table))); |
135 EXPECT_EQ(table, TableElementJustBefore( | 135 EXPECT_EQ(table, TableElementJustBefore( |
136 VisiblePositionInFlatTree::AfterNode(*table))); | 136 VisiblePositionInFlatTree::AfterNode(*table))); |
137 | 137 |
138 EXPECT_EQ(table, | 138 EXPECT_EQ(table, |
139 TableElementJustBefore(VisiblePosition::LastPositionInNode(table))); | 139 TableElementJustBefore(VisiblePosition::LastPositionInNode(table))); |
140 EXPECT_EQ(table, TableElementJustBefore(CreateVisiblePosition( | 140 EXPECT_EQ(table, TableElementJustBefore(CreateVisiblePosition( |
141 PositionInFlatTree::LastPositionInNode(table)))); | 141 PositionInFlatTree::LastPositionInNode(*table)))); |
142 | 142 |
143 EXPECT_EQ(nullptr, | 143 EXPECT_EQ(nullptr, |
144 TableElementJustBefore(CreateVisiblePosition(Position(host, 2)))); | 144 TableElementJustBefore(CreateVisiblePosition(Position(host, 2)))); |
145 EXPECT_EQ(table, TableElementJustBefore( | 145 EXPECT_EQ(table, TableElementJustBefore( |
146 CreateVisiblePosition(PositionInFlatTree(host, 2)))); | 146 CreateVisiblePosition(PositionInFlatTree(host, 2)))); |
147 | 147 |
148 EXPECT_EQ(nullptr, TableElementJustBefore(VisiblePosition::AfterNode(*host))); | 148 EXPECT_EQ(nullptr, TableElementJustBefore(VisiblePosition::AfterNode(*host))); |
149 EXPECT_EQ(nullptr, TableElementJustBefore( | 149 EXPECT_EQ(nullptr, TableElementJustBefore( |
150 VisiblePositionInFlatTree::AfterNode(*host))); | 150 VisiblePositionInFlatTree::AfterNode(*host))); |
151 | 151 |
152 EXPECT_EQ(nullptr, | 152 EXPECT_EQ(nullptr, |
153 TableElementJustBefore(VisiblePosition::LastPositionInNode(host))); | 153 TableElementJustBefore(VisiblePosition::LastPositionInNode(host))); |
154 EXPECT_EQ(table, TableElementJustBefore(CreateVisiblePosition( | 154 EXPECT_EQ(table, TableElementJustBefore(CreateVisiblePosition( |
155 PositionInFlatTree::LastPositionInNode(host)))); | 155 PositionInFlatTree::LastPositionInNode(*host)))); |
156 } | 156 } |
157 | 157 |
158 TEST_F(EditingUtilitiesTest, lastEditablePositionBeforePositionInRoot) { | 158 TEST_F(EditingUtilitiesTest, lastEditablePositionBeforePositionInRoot) { |
159 const char* body_content = | 159 const char* body_content = |
160 "<p id='host' contenteditable><b id='one'>1</b><b id='two'>22</b></p>"; | 160 "<p id='host' contenteditable><b id='one'>1</b><b id='two'>22</b></p>"; |
161 const char* shadow_content = | 161 const char* shadow_content = |
162 "<content select=#two></content><content select=#one></content><b " | 162 "<content select=#two></content><content select=#one></content><b " |
163 "id='three'>333</b>"; | 163 "id='three'>333</b>"; |
164 SetBodyContent(body_content); | 164 SetBodyContent(body_content); |
165 ShadowRoot* shadow_root = SetShadowContent(shadow_content, "host"); | 165 ShadowRoot* shadow_root = SetShadowContent(shadow_content, "host"); |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 PositionMoveType::kBackwardDeletion)); | 899 PositionMoveType::kBackwardDeletion)); |
900 EXPECT_EQ(Position(node, 2), | 900 EXPECT_EQ(Position(node, 2), |
901 PreviousPositionOf(Position(node, 3), | 901 PreviousPositionOf(Position(node, 3), |
902 PositionMoveType::kBackwardDeletion)); | 902 PositionMoveType::kBackwardDeletion)); |
903 EXPECT_EQ(Position(node, 0), | 903 EXPECT_EQ(Position(node, 0), |
904 PreviousPositionOf(Position(node, 1), | 904 PreviousPositionOf(Position(node, 1), |
905 PositionMoveType::kBackwardDeletion)); | 905 PositionMoveType::kBackwardDeletion)); |
906 } | 906 } |
907 | 907 |
908 } // namespace blink | 908 } // namespace blink |
OLD | NEW |