| 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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(*
two, 1)).deepEquivalent()); | 808 EXPECT_EQ(Position(one, 0), startOfSentence(createVisiblePositionInDOMTree(*
two, 1)).deepEquivalent()); |
| 809 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos
itionInComposedTree(*two, 1)).deepEquivalent()); | 809 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos
itionInComposedTree(*two, 1)).deepEquivalent()); |
| 810 | 810 |
| 811 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree
(*three, 1)).deepEquivalent()); | 811 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree
(*three, 1)).deepEquivalent()); |
| 812 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos
itionInComposedTree(*three, 1)).deepEquivalent()); | 812 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos
itionInComposedTree(*three, 1)).deepEquivalent()); |
| 813 | 813 |
| 814 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree
(*four, 1)).deepEquivalent()); | 814 EXPECT_EQ(Position(three, 0), startOfSentence(createVisiblePositionInDOMTree
(*four, 1)).deepEquivalent()); |
| 815 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos
itionInComposedTree(*four, 1)).deepEquivalent()); | 815 EXPECT_EQ(PositionInComposedTree(three, 0), startOfSentence(createVisiblePos
itionInComposedTree(*four, 1)).deepEquivalent()); |
| 816 } | 816 } |
| 817 | 817 |
| 818 TEST_F(VisibleUnitsTest, startOfWord) |
| 819 { |
| 820 const char* bodyContent = "<a id=host><b id=one>1</b> <b id=two>22</b></a><i
id=three>333</i>"; |
| 821 const char* shadowContent = "<p><u id=four>44444</u><content select=#two></c
ontent><span id=space> </span><content select=#one></content><u id=five>55555</u
></p>"; |
| 822 setBodyContent(bodyContent); |
| 823 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); |
| 824 updateLayoutAndStyleForPainting(); |
| 825 |
| 826 Node* one = document().getElementById("one")->firstChild(); |
| 827 Node* two = document().getElementById("two")->firstChild(); |
| 828 Node* three = document().getElementById("three")->firstChild(); |
| 829 Node* four = shadowRoot->getElementById("four")->firstChild(); |
| 830 Node* five = shadowRoot->getElementById("five")->firstChild(); |
| 831 Node* space = shadowRoot->getElementById("space")->firstChild(); |
| 832 |
| 833 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one,
0)).deepEquivalent()); |
| 834 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition
InComposedTree(*one, 0)).deepEquivalent()); |
| 835 |
| 836 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*one,
1)).deepEquivalent()); |
| 837 EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositio
nInComposedTree(*one, 1)).deepEquivalent()); |
| 838 |
| 839 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*two,
0)).deepEquivalent()); |
| 840 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition
InComposedTree(*two, 0)).deepEquivalent()); |
| 841 |
| 842 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*two,
1)).deepEquivalent()); |
| 843 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition
InComposedTree(*two, 1)).deepEquivalent()); |
| 844 |
| 845 EXPECT_EQ(Position(one, 0), startOfWord(createVisiblePositionInDOMTree(*thre
e, 1)).deepEquivalent()); |
| 846 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition
InComposedTree(*three, 1)).deepEquivalent()); |
| 847 |
| 848 EXPECT_EQ(Position(four, 0), startOfWord(createVisiblePositionInDOMTree(*fou
r, 1)).deepEquivalent()); |
| 849 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition
InComposedTree(*four, 1)).deepEquivalent()); |
| 850 |
| 851 EXPECT_EQ(Position(space, 1), startOfWord(createVisiblePositionInDOMTree(*fi
ve, 1)).deepEquivalent()); |
| 852 EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositio
nInComposedTree(*five, 1)).deepEquivalent()); |
| 853 } |
| 854 |
| 818 } // namespace blink | 855 } // namespace blink |
| OLD | NEW |