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 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( |
|
rlanday
2017/01/31 19:50:21
Again, hope this doesn't break anything...
rlanday
2017/01/31 22:33:45
I have a test case that requires this fix to work
esprehn
2017/01/31 22:41:34
What did the code do before and what's different?
rlanday
2017/01/31 22:58:43
Actually this doesn't break any of the webkit_unit
|
| + node, offset + replacementText.length(), count), |
| + ASSERT_NO_EDITING_ABORT); |
| } |
| Position CompositeEditCommand::replaceSelectedTextInNode(const String& text) { |