Index: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
index e2141461cfec85ff973897674e6afc3caae0ea83..ef5daa681aec935c002e414b18eed39926e3712b 100644 |
--- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
@@ -1859,12 +1859,21 @@ void ReplaceSelectionCommand::completeHTMLReplacement( |
document().updateStyleAndLayoutIgnorePendingStylesheets(); |
- if (m_selectReplacement) |
+ if (m_selectReplacement) { |
setEndingSelection(createVisibleSelection( |
start, end, SelDefaultAffinity, endingSelection().isDirectional())); |
- else |
+ return; |
+ } |
+ |
+ if (end.isNotNull()) { |
setEndingSelection(createVisibleSelection( |
- end, SelDefaultAffinity, endingSelection().isDirectional())); |
+ SelectionInDOMTree::Builder() |
+ .collapse(end) |
+ .setIsDirectional(endingSelection().isDirectional()) |
+ .build())); |
+ return; |
+ } |
+ setEndingSelection(createVisibleSelection(SelectionInDOMTree())); |
} |
void ReplaceSelectionCommand::mergeTextNodesAroundPosition( |