| 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 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 PositionWithAffinity positionWithAffinityInDOMTree(Node& anchor, int offset, EAf
finity affinity = DOWNSTREAM) | 15 PositionWithAffinity positionWithAffinityInDOMTree(Node& anchor, int offset, EAf
finity affinity = DOWNSTREAM) |
| 16 { | 16 { |
| 17 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset, Po
sition::PositionIsOffsetInAnchor)), affinity); | 17 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset)),
affinity); |
| 18 } | 18 } |
| 19 | 19 |
| 20 PositionInComposedTreeWithAffinity positionWithAffinityInComposedTree(Node& anch
or, int offset, EAffinity affinity = DOWNSTREAM) | 20 PositionInComposedTreeWithAffinity positionWithAffinityInComposedTree(Node& anch
or, int offset, EAffinity affinity = DOWNSTREAM) |
| 21 { | 21 { |
| 22 return PositionInComposedTreeWithAffinity(canonicalPositionOf(PositionInComp
osedTree(&anchor, offset, PositionInComposedTree::PositionIsOffsetInAnchor)), af
finity); | 22 return PositionInComposedTreeWithAffinity(canonicalPositionOf(PositionInComp
osedTree(&anchor, offset)), affinity); |
| 23 } | 23 } |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 class VisibleUnitsTest : public EditingTestBase { | 27 class VisibleUnitsTest : public EditingTestBase { |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 TEST_F(VisibleUnitsTest, inSameLine) | 30 TEST_F(VisibleUnitsTest, inSameLine) |
| 31 { | 31 { |
| 32 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; | 32 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0)
, positionWithAffinityInDOMTree(*five->firstChild(), 0))); | 46 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0)
, positionWithAffinityInDOMTree(*five->firstChild(), 0))); |
| 47 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*two->firstChild(), 0)
, positionWithAffinityInDOMTree(*four->firstChild(), 0))); | 47 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*two->firstChild(), 0)
, positionWithAffinityInDOMTree(*four->firstChild(), 0))); |
| 48 | 48 |
| 49 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one, 0), positio
nWithAffinityInComposedTree(*two, 0))); | 49 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one, 0), positio
nWithAffinityInComposedTree(*two, 0))); |
| 50 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild(
), 0), positionWithAffinityInComposedTree(*two->firstChild(), 0))); | 50 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild(
), 0), positionWithAffinityInComposedTree(*two->firstChild(), 0))); |
| 51 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild(
), 0), positionWithAffinityInComposedTree(*five->firstChild(), 0))); | 51 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild(
), 0), positionWithAffinityInComposedTree(*five->firstChild(), 0))); |
| 52 EXPECT_TRUE(inSameLine(positionWithAffinityInComposedTree(*two->firstChild()
, 0), positionWithAffinityInComposedTree(*four->firstChild(), 0))); | 52 EXPECT_TRUE(inSameLine(positionWithAffinityInComposedTree(*two->firstChild()
, 0), positionWithAffinityInComposedTree(*four->firstChild(), 0))); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |