Index: third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp |
diff --git a/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp |
index 35896331fcbb1286c3761f16dcdd8b571467f10e..d6d22b9620a4743d0c3a3bf3903a6d80eae35d20 100644 |
--- a/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp |
+++ b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp |
@@ -195,10 +195,19 @@ void DeleteSelectionCommand::setStartingSelectionOnSmartDelete( |
document().lifecycle()); |
bool isBaseFirst = startingSelection().isBaseFirst(); |
+ // TODO(yosin): We should not call |createVisiblePosition()| here and use |
+ // |start| and |end| as base/extent since |VisibleSelection| also calls |
+ // |createVisiblePosition()| during construction. |
+ // Because of |newBase.affinity()| can be |Upstream|, we can't simply |
+ // use |start| and |end| here. |
VisiblePosition newBase = createVisiblePosition(isBaseFirst ? start : end); |
VisiblePosition newExtent = createVisiblePosition(isBaseFirst ? end : start); |
- setStartingSelection(createVisibleSelection( |
- newBase, newExtent, startingSelection().isDirectional())); |
+ SelectionInDOMTree::Builder builder; |
+ builder.setAffinity(newBase.affinity()) |
+ .setBaseAndExtentDeprecated(newBase.deepEquivalent(), |
+ newExtent.deepEquivalent()) |
+ .setIsDirectional(startingSelection().isDirectional()); |
+ setStartingSelection(createVisibleSelection(builder.build())); |
} |
void DeleteSelectionCommand::initializePositionData( |