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 14 matching lines...) Expand all Loading... | |
25 EXPECT_EQ(RTL, directionOfEnclosingBlock(PositionInComposedTree(one, 0))); | 25 EXPECT_EQ(RTL, directionOfEnclosingBlock(PositionInComposedTree(one, 0))); |
26 } | 26 } |
27 | 27 |
28 TEST_F(EditingUtilitiesTest, firstEditablePositionAfterPositionInRoot) | 28 TEST_F(EditingUtilitiesTest, firstEditablePositionAfterPositionInRoot) |
29 { | 29 { |
30 const char* bodyContent = "<p id='host' contenteditable><b id='one'></b><b i d='two'>22</b></p>"; | 30 const char* bodyContent = "<p id='host' contenteditable><b id='one'></b><b i d='two'>22</b></p>"; |
31 const char* shadowContent = "<content select=#two></content><content select= #one></content><b id='three'>333</b>"; | 31 const char* shadowContent = "<content select=#two></content><content select= #one></content><b id='three'>333</b>"; |
32 setBodyContent(bodyContent); | 32 setBodyContent(bodyContent); |
33 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); | 33 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); |
34 updateLayoutAndStyleForPainting(); | 34 updateLayoutAndStyleForPainting(); |
35 Node* host = document().getElementById("host"); | 35 Element* host = document().getElementById("host"); |
36 Node* one = document().getElementById("one"); | 36 Node* one = document().getElementById("one"); |
37 Node* two = document().getElementById("two"); | |
37 Node* three = shadowRoot->getElementById("three"); | 38 Node* three = shadowRoot->getElementById("three"); |
38 | 39 |
39 EXPECT_EQ(Position(one, 0), firstEditablePositionAfterPositionInRoot(Positio n(one, 0), host)); | 40 EXPECT_EQ(Position(one, 0), firstEditablePositionAfterPositionInRoot(Positio n(one, 0), host)); |
41 EXPECT_EQ(Position(two->firstChild(), 0), firstEditableVisiblePositionAfterP ositionInRoot(Position(one, 0), host).deepEquivalent()); | |
40 | 42 |
41 EXPECT_EQ(PositionInComposedTree(one, 0), firstEditablePositionAfterPosition InRoot(PositionInComposedTree(one, 0), host)); | 43 EXPECT_EQ(PositionInComposedTree(one, 0), firstEditablePositionAfterPosition InRoot(PositionInComposedTree(one, 0), host)); |
44 EXPECT_EQ(PositionInComposedTree(two->firstChild(), 2), firstEditableVisible PositionAfterPositionInRoot(PositionInComposedTree(one, 0), host).deepEquivalent ()); | |
yoichio
2015/09/08 01:34:28
PositionInComposedTree(one, 0) seems not in a DOM
yoichio
2015/09/08 01:43:04
Plus, why after |PositionInComposedTree(one, 0)| i
yosin_UTC9
2015/09/08 02:04:32
Since, canonicalized position of PosICT(one, 0) is
| |
42 | 45 |
43 EXPECT_EQ(Position::firstPositionInNode(host), firstEditablePositionAfterPos itionInRoot(Position(three, 0), host)); | 46 EXPECT_EQ(Position::firstPositionInNode(host), firstEditablePositionAfterPos itionInRoot(Position(three, 0), host)); |
47 EXPECT_EQ(Position(two->firstChild(), 0), firstEditableVisiblePositionAfterP ositionInRoot(Position(three, 0), host).deepEquivalent()); | |
44 EXPECT_EQ(PositionInComposedTree::afterNode(host), firstEditablePositionAfte rPositionInRoot(PositionInComposedTree(three, 0), host)); | 48 EXPECT_EQ(PositionInComposedTree::afterNode(host), firstEditablePositionAfte rPositionInRoot(PositionInComposedTree(three, 0), host)); |
49 EXPECT_EQ(PositionInComposedTree::lastPositionInNode(host), firstEditableVis iblePositionAfterPositionInRoot(PositionInComposedTree(three, 0), host).deepEqui valent()); | |
45 } | 50 } |
46 | 51 |
47 TEST_F(EditingUtilitiesTest, enclosingBlock) | 52 TEST_F(EditingUtilitiesTest, enclosingBlock) |
48 { | 53 { |
49 const char* bodyContent = "<p id='host'><b id='one'>11</b></p>"; | 54 const char* bodyContent = "<p id='host'><b id='one'>11</b></p>"; |
50 const char* shadowContent = "<content select=#two></content><div id='three'> <content select=#one></content></div>"; | 55 const char* shadowContent = "<content select=#two></content><div id='three'> <content select=#one></content></div>"; |
51 setBodyContent(bodyContent); | 56 setBodyContent(bodyContent); |
52 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); | 57 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); |
53 updateLayoutAndStyleForPainting(); | 58 updateLayoutAndStyleForPainting(); |
54 Node* host = document().getElementById("host"); | 59 Node* host = document().getElementById("host"); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 updateLayoutAndStyleForPainting(); | 101 updateLayoutAndStyleForPainting(); |
97 Node* one = document().getElementById("one"); | 102 Node* one = document().getElementById("one"); |
98 Node* two = document().getElementById("two"); | 103 Node* two = document().getElementById("two"); |
99 Node* three = document().getElementById("three"); | 104 Node* three = document().getElementById("three"); |
100 | 105 |
101 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi tion(one, 1))); | 106 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi tion(one, 1))); |
102 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin ctCandidate(PositionInComposedTree(one, 1))); | 107 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin ctCandidate(PositionInComposedTree(one, 1))); |
103 } | 108 } |
104 | 109 |
105 } // namespace blink | 110 } // namespace blink |
OLD | NEW |