Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp

Issue 2611813002: Add support for persisting CompositionUnderlines in InputMethodController (Closed)
Patch Set: Try one more time Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698