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 #include "core/html/HTMLTextFormControlElement.h" |
10 #include "core/layout/line/InlineBox.h" | 11 #include "core/layout/line/InlineBox.h" |
11 #include <ostream> // NOLINT | 12 #include <ostream> // NOLINT |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 PositionWithAffinity positionWithAffinityInDOMTree(Node& anchor, int offset, Tex
tAffinity affinity = TextAffinity::Downstream) | 18 PositionWithAffinity positionWithAffinityInDOMTree(Node& anchor, int offset, Tex
tAffinity affinity = TextAffinity::Downstream) |
18 { | 19 { |
19 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset)),
affinity); | 20 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset)),
affinity); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 Element* one = document().getElementById("one"); | 303 Element* one = document().getElementById("one"); |
303 Element* two = document().getElementById("two"); | 304 Element* two = document().getElementById("two"); |
304 | 305 |
305 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT
ree(*one->firstChild(), 1))); | 306 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT
ree(*one->firstChild(), 1))); |
306 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInCompo
sedTree(*one->firstChild(), 1))); | 307 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInCompo
sedTree(*one->firstChild(), 1))); |
307 | 308 |
308 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr
ee(*two->firstChild(), 2))); | 309 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr
ee(*two->firstChild(), 2))); |
309 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInComp
osedTree(*two->firstChild(), 2))); | 310 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInComp
osedTree(*two->firstChild(), 2))); |
310 } | 311 } |
311 | 312 |
| 313 TEST_F(VisibleUnitsTest, isEndOfEditableOrNonEditableContentWithInput) |
| 314 { |
| 315 const char* bodyContent = "<input id=sample value=ab>cde"; |
| 316 setBodyContent(bodyContent); |
| 317 updateLayoutAndStyleForPainting(); |
| 318 |
| 319 Node* text = toHTMLTextFormControlElement(document().getElementById("sample"
))->innerEditorElement()->firstChild(); |
| 320 |
| 321 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT
ree(*text, 0))); |
| 322 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInComp
osedTree(*text, 0))); |
| 323 |
| 324 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMT
ree(*text, 1))); |
| 325 EXPECT_FALSE(isEndOfEditableOrNonEditableContent(createVisiblePositionInComp
osedTree(*text, 1))); |
| 326 |
| 327 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInDOMTr
ee(*text, 2))); |
| 328 EXPECT_TRUE(isEndOfEditableOrNonEditableContent(createVisiblePositionInCompo
sedTree(*text, 2))); |
| 329 } |
| 330 |
312 TEST_F(VisibleUnitsTest, isEndOfLine) | 331 TEST_F(VisibleUnitsTest, isEndOfLine) |
313 { | 332 { |
314 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i
id=three>333</i><i id=four>4444</i><br>"; | 333 const char* bodyContent = "<a id=host><b id=one>11</b><b id=two>22</b></a><i
id=three>333</i><i id=four>4444</i><br>"; |
315 const char* shadowContent = "<div><u id=five>55555</u><content select=#two><
/content><br><u id=six>666666</u><br><content select=#one></content><u id=seven>
7777777</u></div>"; | 334 const char* shadowContent = "<div><u id=five>55555</u><content select=#two><
/content><br><u id=six>666666</u><br><content select=#one></content><u id=seven>
7777777</u></div>"; |
316 setBodyContent(bodyContent); | 335 setBodyContent(bodyContent); |
317 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); | 336 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); |
318 updateLayoutAndStyleForPainting(); | 337 updateLayoutAndStyleForPainting(); |
319 | 338 |
320 Node* one = document().getElementById("one")->firstChild(); | 339 Node* one = document().getElementById("one")->firstChild(); |
321 Node* two = document().getElementById("two")->firstChild(); | 340 Node* two = document().getElementById("two")->firstChild(); |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition
InComposedTree(*three, 1)).deepEquivalent()); | 982 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition
InComposedTree(*three, 1)).deepEquivalent()); |
964 | 983 |
965 EXPECT_EQ(Position(four, 0), startOfWord(createVisiblePositionInDOMTree(*fou
r, 1)).deepEquivalent()); | 984 EXPECT_EQ(Position(four, 0), startOfWord(createVisiblePositionInDOMTree(*fou
r, 1)).deepEquivalent()); |
966 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition
InComposedTree(*four, 1)).deepEquivalent()); | 985 EXPECT_EQ(PositionInComposedTree(four, 0), startOfWord(createVisiblePosition
InComposedTree(*four, 1)).deepEquivalent()); |
967 | 986 |
968 EXPECT_EQ(Position(space, 1), startOfWord(createVisiblePositionInDOMTree(*fi
ve, 1)).deepEquivalent()); | 987 EXPECT_EQ(Position(space, 1), startOfWord(createVisiblePositionInDOMTree(*fi
ve, 1)).deepEquivalent()); |
969 EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositio
nInComposedTree(*five, 1)).deepEquivalent()); | 988 EXPECT_EQ(PositionInComposedTree(space, 1), startOfWord(createVisiblePositio
nInComposedTree(*five, 1)).deepEquivalent()); |
970 } | 989 } |
971 | 990 |
972 } // namespace blink | 991 } // namespace blink |
OLD | NEW |