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/VisibleUnits.h" | 6 #include "core/editing/VisibleUnits.h" |
7 | 7 |
8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
9 #include "core/editing/VisiblePosition.h" | 9 #include "core/editing/VisiblePosition.h" |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 { | 56 { |
57 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22<
/b>"; | 57 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22<
/b>"; |
58 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten
t><b id='three'>333</b>"; | 58 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten
t><b id='three'>333</b>"; |
59 setBodyContent(bodyContent); | 59 setBodyContent(bodyContent); |
60 setShadowContent(shadowContent); | 60 setShadowContent(shadowContent); |
61 updateLayoutAndStyleForPainting(); | 61 updateLayoutAndStyleForPainting(); |
62 | 62 |
63 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | 63 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
64 | 64 |
65 LayoutObject* layoutObjectFromDOMTree; | 65 LayoutObject* layoutObjectFromDOMTree; |
66 LayoutRect layoutRectFromDOMTree = localCaretRectOfPosition(Position(one, 0)
, layoutObjectFromDOMTree); | 66 LayoutRect layoutRectFromDOMTree = localCaretRectOfPosition(Position(one->fi
rstChild(), 0), layoutObjectFromDOMTree); |
67 | 67 |
68 LayoutObject* layoutObjectFromComposedTree; | 68 LayoutObject* layoutObjectFromComposedTree; |
69 LayoutRect layoutRectFromComposedTree = localCaretRectOfPosition(PositionInC
omposedTree(one, 0), layoutObjectFromComposedTree); | 69 LayoutRect layoutRectFromComposedTree = localCaretRectOfPosition(PositionInC
omposedTree(one->firstChild(), 0), layoutObjectFromComposedTree); |
70 | 70 |
| 71 EXPECT_TRUE(layoutObjectFromDOMTree); |
| 72 EXPECT_FALSE(layoutRectFromDOMTree.isEmpty()); |
71 EXPECT_EQ(layoutObjectFromDOMTree, layoutObjectFromComposedTree); | 73 EXPECT_EQ(layoutObjectFromDOMTree, layoutObjectFromComposedTree); |
72 EXPECT_EQ(layoutRectFromDOMTree, layoutRectFromComposedTree); | 74 EXPECT_EQ(layoutRectFromDOMTree, layoutRectFromComposedTree); |
73 } | 75 } |
74 | 76 |
75 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionAfterAnchor) | 77 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionAfterAnchor) |
76 { | 78 { |
77 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22<
/b>"; | 79 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22<
/b>"; |
78 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten
t><b id='three'>333</b>"; | 80 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten
t><b id='three'>333</b>"; |
79 setBodyContent(bodyContent); | 81 setBodyContent(bodyContent); |
80 setShadowContent(shadowContent); | 82 setShadowContent(shadowContent); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 setBodyContent(bodyContent); | 121 setBodyContent(bodyContent); |
120 updateLayoutAndStyleForPainting(); | 122 updateLayoutAndStyleForPainting(); |
121 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); | 123 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); |
122 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); | 124 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); |
123 | 125 |
124 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); | 126 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); |
125 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); | 127 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); |
126 } | 128 } |
127 | 129 |
128 } // namespace blink | 130 } // namespace blink |
OLD | NEW |