OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/InsertListCommand.h" | 5 #include "core/editing/commands/InsertListCommand.h" |
6 | 6 |
7 #include "core/dom/ParentNode.h" | 7 #include "core/dom/ParentNode.h" |
8 #include "core/dom/Text.h" | 8 #include "core/dom/Text.h" |
9 #include "core/editing/EditingTestBase.h" | 9 #include "core/editing/EditingTestBase.h" |
10 #include "core/editing/FrameSelection.h" | 10 #include "core/editing/FrameSelection.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // * Should have no actual children to fail the listChildNode check | 26 // * Should have no actual children to fail the listChildNode check |
27 // in InsertListCommand::doApplyForSingleParagraph. | 27 // in InsertListCommand::doApplyForSingleParagraph. |
28 // * There needs to be an extra text node to trigger its removal in | 28 // * There needs to be an extra text node to trigger its removal in |
29 // CompositeEditCommand::mergeIdenticalElements. | 29 // CompositeEditCommand::mergeIdenticalElements. |
30 // The removeNode is what updates document lifecycle to VisualUpdatePending | 30 // The removeNode is what updates document lifecycle to VisualUpdatePending |
31 // and makes FrameView::needsLayout return true. | 31 // and makes FrameView::needsLayout return true. |
32 setBodyContent("\nd\n<ol>"); | 32 setBodyContent("\nd\n<ol>"); |
33 Text* emptyText = document().createTextNode(""); | 33 Text* emptyText = document().createTextNode(""); |
34 document().body()->insertBefore(emptyText, document().body()->firstChild()); | 34 document().body()->insertBefore(emptyText, document().body()->firstChild()); |
35 updateAllLifecyclePhases(); | 35 updateAllLifecyclePhases(); |
36 document().frame()->selection().setSelection(createVisibleSelection( | 36 document().frame()->selection().setSelection( |
37 Position(document().body(), 0), Position(document().body(), 2))); | 37 SelectionInDOMTree::Builder() |
| 38 .collapse(Position(document().body(), 0)) |
| 39 .extend(Position(document().body(), 2)) |
| 40 .build()); |
38 | 41 |
39 InsertListCommand* command = | 42 InsertListCommand* command = |
40 InsertListCommand::create(document(), InsertListCommand::OrderedList); | 43 InsertListCommand::create(document(), InsertListCommand::OrderedList); |
41 // This should not DCHECK. | 44 // This should not DCHECK. |
42 EXPECT_TRUE(command->apply()) | 45 EXPECT_TRUE(command->apply()) |
43 << "The insert ordered list command should have succeeded"; | 46 << "The insert ordered list command should have succeeded"; |
44 EXPECT_EQ("<ol><li>d</li></ol>", document().body()->innerHTML()); | 47 EXPECT_EQ("<ol><li>d</li></ol>", document().body()->innerHTML()); |
45 } | 48 } |
46 } | 49 } |
OLD | NEW |