Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp |
| index 866d02dfe99734e203c106c3f9c8b144b4f294f3..6541e8cf97bb436d33b789e162f5becffa63ad5c 100644 |
| --- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp |
| +++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp |
| @@ -644,13 +644,16 @@ void CompositeEditCommand::replaceTextInNode(Text* node, |
| const String& replacementText) { |
| // DeleteFromTextNodeCommand and InsertIntoTextNodeCommand are never |
| // aborted. |
| - applyCommandToComposite( |
| - DeleteFromTextNodeCommand::create(node, offset, count), |
| - ASSERT_NO_EDITING_ABORT); |
| + |
| + // Insert must happen before delete to preserve markers correctly |
|
rlanday
2017/01/03 21:07:03
This is something that came up when I added a test
|
| + // See algorithm in https://dom.spec.whatwg.org/#concept-cd-replace |
| if (!replacementText.isEmpty()) |
| applyCommandToComposite( |
| InsertIntoTextNodeCommand::create(node, offset, replacementText), |
| ASSERT_NO_EDITING_ABORT); |
| + applyCommandToComposite(DeleteFromTextNodeCommand::create( |
| + node, offset + replacementText.length(), count), |
| + ASSERT_NO_EDITING_ABORT); |
| } |
| Position CompositeEditCommand::replaceSelectedTextInNode(const String& text) { |