| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 class VisibleUnitsTest : public EditingTestBase { | 37 class VisibleUnitsTest : public EditingTestBase { |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 TEST_F(VisibleUnitsTest, absoluteCaretBoundsOf) | 40 TEST_F(VisibleUnitsTest, absoluteCaretBoundsOf) |
| 41 { | 41 { |
| 42 const char* bodyContent = "<p id='host'><b id='one'>11</b><b id='two'>22</b>
</p>"; | 42 const char* bodyContent = "<p id='host'><b id='one'>11</b><b id='two'>22</b>
</p>"; |
| 43 const char* shadowContent = "<div><content select=#two></content><content se
lect=#one></content></div>"; | 43 const char* shadowContent = "<div><content select=#two></content><content se
lect=#one></content></div>"; |
| 44 setBodyContent(bodyContent); | 44 setBodyContent(bodyContent); |
| 45 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); | 45 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); |
| 46 ASSERT_UNUSED(shadowRoot, shadowRoot); |
| 46 updateLayoutAndStyleForPainting(); | 47 updateLayoutAndStyleForPainting(); |
| 47 | 48 |
| 48 RefPtrWillBeRawPtr<Element> body = document().body(); | 49 RefPtrWillBeRawPtr<Element> body = document().body(); |
| 49 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); | 50 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE
PTION); |
| 50 | 51 |
| 51 IntRect boundsInDOMTree = absoluteCaretBoundsOf(createVisiblePosition(Positi
on(one.get(), 0))); | 52 IntRect boundsInDOMTree = absoluteCaretBoundsOf(createVisiblePosition(Positi
on(one.get(), 0))); |
| 52 IntRect boundsInComposedTree = absoluteCaretBoundsOf(createVisiblePosition(P
ositionInComposedTree(one.get(), 0))); | 53 IntRect boundsInComposedTree = absoluteCaretBoundsOf(createVisiblePosition(P
ositionInComposedTree(one.get(), 0))); |
| 53 | 54 |
| 54 EXPECT_FALSE(boundsInDOMTree.isEmpty()); | 55 EXPECT_FALSE(boundsInDOMTree.isEmpty()); |
| 55 EXPECT_EQ(boundsInDOMTree, boundsInComposedTree); | 56 EXPECT_EQ(boundsInDOMTree, boundsInComposedTree); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 setBodyContent(bodyContent); | 160 setBodyContent(bodyContent); |
| 160 updateLayoutAndStyleForPainting(); | 161 updateLayoutAndStyleForPainting(); |
| 161 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); | 162 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); |
| 162 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); | 163 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); |
| 163 | 164 |
| 164 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); | 165 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); |
| 165 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); | 166 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); |
| 166 } | 167 } |
| 167 | 168 |
| 168 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |