Chromium Code Reviews| 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/EditingUtilities.h" | 6 #include "core/editing/EditingUtilities.h" |
| 7 | 7 |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); | 72 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); |
| 73 updateLayoutAndStyleForPainting(); | 73 updateLayoutAndStyleForPainting(); |
| 74 Node* host = document().getElementById("host"); | 74 Node* host = document().getElementById("host"); |
| 75 Node* one = document().getElementById("one"); | 75 Node* one = document().getElementById("one"); |
| 76 Node* three = shadowRoot->getElementById("three"); | 76 Node* three = shadowRoot->getElementById("three"); |
| 77 | 77 |
| 78 EXPECT_EQ(host, enclosingNodeOfType(Position(one, 0), isEnclosingBlock)); | 78 EXPECT_EQ(host, enclosingNodeOfType(Position(one, 0), isEnclosingBlock)); |
| 79 EXPECT_EQ(three, enclosingNodeOfType(PositionInComposedTree(one, 0), isEnclo singBlock)); | 79 EXPECT_EQ(three, enclosingNodeOfType(PositionInComposedTree(one, 0), isEnclo singBlock)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 TEST_F(EditingUtilitiesTest, lastEditablePositionBeforePositionInRoot) | |
| 83 { | |
| 84 const char* bodyContent = "<p id='host' contenteditable><b id='one'>1</b><b id='two'>22</b></p>"; | |
| 85 const char* shadowContent = "<content select=#two></content><content select= #one></content><b id='three'>333</b>"; | |
| 86 setBodyContent(bodyContent); | |
| 87 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); | |
| 88 updateLayoutAndStyleForPainting(); | |
| 89 Element* host = document().getElementById("host"); | |
| 90 Node* one = document().getElementById("one"); | |
| 91 Node* two = document().getElementById("two"); | |
| 92 Node* three = shadowRoot->getElementById("three"); | |
| 93 | |
| 94 EXPECT_EQ(Position(one, 0), lastEditablePositionBeforePositionInRoot(Positio n(one, 0), host)); | |
| 95 EXPECT_EQ(Position(one->firstChild(), 0), lastEditableVisiblePositionBeforeP ositionInRoot(Position(one, 0), host).deepEquivalent()); | |
|
yoichio
2015/09/08 08:22:07
(one->firstChild(), 0) is after (one, 0).
Ditto to
| |
| 96 | |
| 97 EXPECT_EQ(PositionInComposedTree(one, 0), lastEditablePositionBeforePosition InRoot(PositionInComposedTree(one, 0), host)); | |
| 98 EXPECT_EQ(PositionInComposedTree(two->firstChild(), 2), lastEditableVisibleP ositionBeforePositionInRoot(PositionInComposedTree(one, 0), host).deepEquivalent ()); | |
| 99 | |
| 100 EXPECT_EQ(Position::firstPositionInNode(host), lastEditablePositionBeforePos itionInRoot(Position(three, 0), host)); | |
| 101 EXPECT_EQ(Position(one->firstChild(), 0), lastEditableVisiblePositionBeforeP ositionInRoot(Position(three, 0), host).deepEquivalent()); | |
| 102 EXPECT_EQ(PositionInComposedTree::firstPositionInNode(host), lastEditablePos itionBeforePositionInRoot(PositionInComposedTree(three, 0), host)); | |
| 103 EXPECT_EQ(PositionInComposedTree(two->firstChild(), 0), lastEditableVisibleP ositionBeforePositionInRoot(PositionInComposedTree(three, 0), host).deepEquivale nt()); | |
| 104 } | |
| 105 | |
| 82 TEST_F(EditingUtilitiesTest, NextNodeIndex) | 106 TEST_F(EditingUtilitiesTest, NextNodeIndex) |
| 83 { | 107 { |
| 84 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>"; | 108 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>"; |
| 85 const char* shadowContent = "<content select=#two></content><content select= #one></content>"; | 109 const char* shadowContent = "<content select=#two></content><content select= #one></content>"; |
| 86 setBodyContent(bodyContent); | 110 setBodyContent(bodyContent); |
| 87 setShadowContent(shadowContent, "host"); | 111 setShadowContent(shadowContent, "host"); |
| 88 Node* host = document().getElementById("host"); | 112 Node* host = document().getElementById("host"); |
| 89 Node* two = document().getElementById("two"); | 113 Node* two = document().getElementById("two"); |
| 90 | 114 |
| 91 EXPECT_EQ(Position(host, 3), nextPositionOf(Position(two, 2), PositionMoveTy pe::CodePoint)); | 115 EXPECT_EQ(Position(host, 3), nextPositionOf(Position(two, 2), PositionMoveTy pe::CodePoint)); |
| 92 EXPECT_EQ(PositionInComposedTree(host, 1), nextPositionOf(PositionInComposed Tree(two, 2), PositionMoveType::CodePoint)); | 116 EXPECT_EQ(PositionInComposedTree(host, 1), nextPositionOf(PositionInComposed Tree(two, 2), PositionMoveType::CodePoint)); |
| 93 } | 117 } |
| 94 | 118 |
| 95 TEST_F(EditingUtilitiesTest, NextVisuallyDistinctCandidate) | 119 TEST_F(EditingUtilitiesTest, NextVisuallyDistinctCandidate) |
| 96 { | 120 { |
| 97 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b><b id='three'>33</b></p>"; | 121 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b><b id='three'>33</b></p>"; |
| 98 const char* shadowContent = "<content select=#two></content><content select= #one></content><content select=#three></content>"; | 122 const char* shadowContent = "<content select=#two></content><content select= #one></content><content select=#three></content>"; |
| 99 setBodyContent(bodyContent); | 123 setBodyContent(bodyContent); |
| 100 setShadowContent(shadowContent, "host"); | 124 setShadowContent(shadowContent, "host"); |
| 101 updateLayoutAndStyleForPainting(); | 125 updateLayoutAndStyleForPainting(); |
| 102 Node* one = document().getElementById("one"); | 126 Node* one = document().getElementById("one"); |
| 103 Node* two = document().getElementById("two"); | 127 Node* two = document().getElementById("two"); |
| 104 Node* three = document().getElementById("three"); | 128 Node* three = document().getElementById("three"); |
| 105 | 129 |
| 106 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi tion(one, 1))); | 130 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi tion(one, 1))); |
| 107 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin ctCandidate(PositionInComposedTree(one, 1))); | 131 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin ctCandidate(PositionInComposedTree(one, 1))); |
| 108 } | 132 } |
| 109 | 133 |
| 110 } // namespace blink | 134 } // namespace blink |
| OLD | NEW |