Commit c052c5a0 authored by tanvir.rizvi's avatar tanvir.rizvi Committed by Commit Bot

Use IsValidFor instead of IsConnected in DeleteSelectionCommand

IsConnected checks if the anchor node is connected in DOM/FLAT
tree, while IsValidFor check if the position is in the same
document.
HandleGeneralDelete can cause DOM mutation and hence
can move out of the document. Therefore we should use
IsValidFor.
This CL changes IsConnected to IsValidFor to cover
all the scenarios.

Bug: 794282
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I72268bfe1e275e40768aaf7f8e875e20b99f6460
Reviewed-on: https://chromium-review.googlesource.com/c/1286242Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Tanvir Rizvi <tanvir.rizvi@samsung.com>
Cr-Commit-Position: refs/heads/master@{#600672}
parent 315b30a5
...@@ -1189,7 +1189,7 @@ void DeleteSelectionCommand::DoApply(EditingState* editing_state) { ...@@ -1189,7 +1189,7 @@ void DeleteSelectionCommand::DoApply(EditingState* editing_state) {
} }
// HandleGeneralDelete cause DOM mutation events so |ending_position_| // HandleGeneralDelete cause DOM mutation events so |ending_position_|
// can be out of document. // can be out of document.
if (ending_position_.IsConnected()) { if (ending_position_.IsValidFor(GetDocument())) {
InsertNodeAt(placeholder, ending_position_, editing_state); InsertNodeAt(placeholder, ending_position_, editing_state);
if (editing_state->IsAborted()) if (editing_state->IsAborted())
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment