| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 const char* shadowContent = "<content select=#two></content><content select=
#table></content>"; | 99 const char* shadowContent = "<content select=#two></content><content select=
#table></content>"; |
| 100 setBodyContent(bodyContent); | 100 setBodyContent(bodyContent); |
| 101 setShadowContent(shadowContent, "host"); | 101 setShadowContent(shadowContent, "host"); |
| 102 Node* host = document().getElementById("host"); | 102 Node* host = document().getElementById("host"); |
| 103 Node* table = document().getElementById("table"); | 103 Node* table = document().getElementById("table"); |
| 104 | 104 |
| 105 EXPECT_EQ(table, tableElementJustBefore(VisiblePosition::afterNode(table))); | 105 EXPECT_EQ(table, tableElementJustBefore(VisiblePosition::afterNode(table))); |
| 106 EXPECT_EQ(table, tableElementJustBefore(VisiblePositionInFlatTree::afterNode
(table))); | 106 EXPECT_EQ(table, tableElementJustBefore(VisiblePositionInFlatTree::afterNode
(table))); |
| 107 | 107 |
| 108 EXPECT_EQ(table, tableElementJustBefore(VisiblePosition::lastPositionInNode(
table))); | 108 EXPECT_EQ(table, tableElementJustBefore(VisiblePosition::lastPositionInNode(
table))); |
| 109 EXPECT_EQ(table, tableElementJustBefore(createVisiblePositionDeprecated(Posi
tionInFlatTree::lastPositionInNode(table)))); | 109 EXPECT_EQ(table, tableElementJustBefore(createVisiblePosition(PositionInFlat
Tree::lastPositionInNode(table)))); |
| 110 | 110 |
| 111 EXPECT_EQ(nullptr, tableElementJustBefore(createVisiblePositionDeprecated(Po
sition(host, 2)))); | 111 EXPECT_EQ(nullptr, tableElementJustBefore(createVisiblePosition(Position(hos
t, 2)))); |
| 112 EXPECT_EQ(table, tableElementJustBefore(createVisiblePositionDeprecated(Posi
tionInFlatTree(host, 2)))); | 112 EXPECT_EQ(table, tableElementJustBefore(createVisiblePosition(PositionInFlat
Tree(host, 2)))); |
| 113 | 113 |
| 114 EXPECT_EQ(nullptr, tableElementJustBefore(VisiblePosition::afterNode(host)))
; | 114 EXPECT_EQ(nullptr, tableElementJustBefore(VisiblePosition::afterNode(host)))
; |
| 115 EXPECT_EQ(nullptr, tableElementJustBefore(VisiblePositionInFlatTree::afterNo
de(host))); | 115 EXPECT_EQ(nullptr, tableElementJustBefore(VisiblePositionInFlatTree::afterNo
de(host))); |
| 116 | 116 |
| 117 EXPECT_EQ(nullptr, tableElementJustBefore(VisiblePosition::lastPositionInNod
e(host))); | 117 EXPECT_EQ(nullptr, tableElementJustBefore(VisiblePosition::lastPositionInNod
e(host))); |
| 118 EXPECT_EQ(table, tableElementJustBefore(createVisiblePositionDeprecated(Posi
tionInFlatTree::lastPositionInNode(host)))); | 118 EXPECT_EQ(table, tableElementJustBefore(createVisiblePosition(PositionInFlat
Tree::lastPositionInNode(host)))); |
| 119 } | 119 } |
| 120 | 120 |
| 121 TEST_F(EditingUtilitiesTest, lastEditablePositionBeforePositionInRoot) | 121 TEST_F(EditingUtilitiesTest, lastEditablePositionBeforePositionInRoot) |
| 122 { | 122 { |
| 123 const char* bodyContent = "<p id='host' contenteditable><b id='one'>1</b><b
id='two'>22</b></p>"; | 123 const char* bodyContent = "<p id='host' contenteditable><b id='one'>1</b><b
id='two'>22</b></p>"; |
| 124 const char* shadowContent = "<content select=#two></content><content select=
#one></content><b id='three'>333</b>"; | 124 const char* shadowContent = "<content select=#two></content><content select=
#one></content><b id='three'>333</b>"; |
| 125 setBodyContent(bodyContent); | 125 setBodyContent(bodyContent); |
| 126 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); | 126 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
| 127 Element* host = document().getElementById("host"); | 127 Element* host = document().getElementById("host"); |
| 128 Node* one = document().getElementById("one"); | 128 Node* one = document().getElementById("one"); |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 | 725 |
| 726 // Edge case: specify middle of surrogate pairs. | 726 // Edge case: specify middle of surrogate pairs. |
| 727 setBodyContent("<p id='target'>👁👁👁</p>"); | 727 setBodyContent("<p id='target'>👁👁👁</p>"); |
| 728 node = document().getElementById("target")->firstChild(); | 728 node = document().getElementById("target")->firstChild(); |
| 729 EXPECT_EQ(Position(node, 4), previousPositionOf(Position(node, 5), PositionM
oveType::BackwardDeletion)); | 729 EXPECT_EQ(Position(node, 4), previousPositionOf(Position(node, 5), PositionM
oveType::BackwardDeletion)); |
| 730 EXPECT_EQ(Position(node, 2), previousPositionOf(Position(node, 3), PositionM
oveType::BackwardDeletion)); | 730 EXPECT_EQ(Position(node, 2), previousPositionOf(Position(node, 3), PositionM
oveType::BackwardDeletion)); |
| 731 EXPECT_EQ(Position(node, 0), previousPositionOf(Position(node, 1), PositionM
oveType::BackwardDeletion)); | 731 EXPECT_EQ(Position(node, 0), previousPositionOf(Position(node, 1), PositionM
oveType::BackwardDeletion)); |
| 732 } | 732 } |
| 733 | 733 |
| 734 } // namespace blink | 734 } // namespace blink |
| OLD | NEW |