| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 "core/editing/commands/SplitTextNodeCommand.h" | 5 #include "core/editing/commands/SplitTextNodeCommand.h" |
| 6 | 6 |
| 7 #include "core/editing/EditingTestBase.h" | 7 #include "core/editing/EditingTestBase.h" |
| 8 #include "core/editing/PlainTextRange.h" | 8 #include "core/editing/PlainTextRange.h" |
| 9 #include "core/editing/commands/EditingState.h" | 9 #include "core/editing/commands/EditingState.h" |
| 10 #include "core/editing/markers/DocumentMarkerController.h" | 10 #include "core/editing/markers/DocumentMarkerController.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class SplitTextNodeCommandTest : public EditingTestBase {}; | 14 class SplitTextNodeCommandTest : public EditingTestBase {}; |
| 15 | 15 |
| 16 TEST_F(SplitTextNodeCommandTest, splitInMarkerInterior) { | 16 TEST_F(SplitTextNodeCommandTest, splitInMarkerInterior) { |
| 17 SetBodyContent("<div contenteditable>test1 test2 test3</div>"); | 17 SetBodyContent("<div contenteditable>test1 test2 test3</div>"); |
| 18 | 18 |
| 19 ContainerNode* div = ToContainerNode(GetDocument().body()->firstChild()); | 19 ContainerNode* div = ToContainerNode(GetDocument().body()->firstChild()); |
| 20 | 20 |
| 21 EphemeralRange range = PlainTextRange(0, 5).CreateRange(*div); | 21 EphemeralRange range = PlainTextRange(0, 5).CreateRange(*div); |
| 22 GetDocument().Markers().AddTextMatchMarker( | 22 GetDocument().Markers().AddTextMatchMarker( |
| 23 range, DocumentMarker::MatchStatus::kInactive); | 23 range, TextMatchMarker::MatchStatus::kInactive); |
| 24 | 24 |
| 25 range = PlainTextRange(6, 11).CreateRange(*div); | 25 range = PlainTextRange(6, 11).CreateRange(*div); |
| 26 GetDocument().Markers().AddTextMatchMarker( | 26 GetDocument().Markers().AddTextMatchMarker( |
| 27 range, DocumentMarker::MatchStatus::kInactive); | 27 range, TextMatchMarker::MatchStatus::kInactive); |
| 28 | 28 |
| 29 range = PlainTextRange(12, 17).CreateRange(*div); | 29 range = PlainTextRange(12, 17).CreateRange(*div); |
| 30 GetDocument().Markers().AddTextMatchMarker( | 30 GetDocument().Markers().AddTextMatchMarker( |
| 31 range, DocumentMarker::MatchStatus::kInactive); | 31 range, TextMatchMarker::MatchStatus::kInactive); |
| 32 | 32 |
| 33 SimpleEditCommand* command = SplitTextNodeCommand::Create( | 33 SimpleEditCommand* command = SplitTextNodeCommand::Create( |
| 34 ToText(GetDocument().body()->firstChild()->firstChild()), 8); | 34 ToText(GetDocument().body()->firstChild()->firstChild()), 8); |
| 35 | 35 |
| 36 EditingState editingState; | 36 EditingState editingState; |
| 37 command->DoApply(&editingState); | 37 command->DoApply(&editingState); |
| 38 | 38 |
| 39 Node* text1 = ToText(div->firstChild()); | 39 Node* text1 = ToText(div->firstChild()); |
| 40 Node* text2 = ToText(text1->nextSibling()); | 40 Node* text2 = ToText(text1->nextSibling()); |
| 41 | 41 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 EXPECT_EQ(6u, GetDocument().Markers().MarkersFor(text1)[1]->StartOffset()); | 88 EXPECT_EQ(6u, GetDocument().Markers().MarkersFor(text1)[1]->StartOffset()); |
| 89 EXPECT_EQ(7u, GetDocument().Markers().MarkersFor(text1)[1]->EndOffset()); | 89 EXPECT_EQ(7u, GetDocument().Markers().MarkersFor(text1)[1]->EndOffset()); |
| 90 | 90 |
| 91 EXPECT_EQ(1u, GetDocument().Markers().MarkersFor(text2).size()); | 91 EXPECT_EQ(1u, GetDocument().Markers().MarkersFor(text2).size()); |
| 92 | 92 |
| 93 EXPECT_EQ(4u, GetDocument().Markers().MarkersFor(text2)[0]->StartOffset()); | 93 EXPECT_EQ(4u, GetDocument().Markers().MarkersFor(text2)[0]->StartOffset()); |
| 94 EXPECT_EQ(9u, GetDocument().Markers().MarkersFor(text2)[0]->EndOffset()); | 94 EXPECT_EQ(9u, GetDocument().Markers().MarkersFor(text2)[0]->EndOffset()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace blink | 97 } // namespace blink |
| OLD | NEW |