| 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 0c7fb5795e80adc76d9cb1cd2c79949553efcf3d..f238e95ebd8aa2edbb24d7dbd9d1ad2d74d0e01d 100644
|
| --- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
|
| @@ -532,13 +532,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
|
| + // 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) {
|
|
|