Commit 82a74a21 authored by Joanmarie Diggs's avatar Joanmarie Diggs Committed by Commit Bot

AXSelection: Don't explicitly check if the endpoints are detached

This is a follow-up change to http://crrev.com/c/2346329 to address a
missed comment.

AXPosition::IsValid will check if the positions are valid, so update
AXSelection to account for any triggered DOM mutations, and then call
AXSelection::IsValid, which will check the validity of the AXPosition
instances associated with the selection.

Bug: 1113650

AX-Relnotes: N/A
Change-Id: Ic7d72111b2172784bbd199b6fe7767b5badefa43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2396156
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805405}
parent b1960b37
...@@ -332,7 +332,8 @@ const SelectionInDOMTree AXSelection::AsSelection( ...@@ -332,7 +332,8 @@ const SelectionInDOMTree AXSelection::AsSelection(
void AXSelection::UpdateSelectionIfNecessary() { void AXSelection::UpdateSelectionIfNecessary() {
Document* document = base_.ContainerObject()->GetDocument(); Document* document = base_.ContainerObject()->GetDocument();
DCHECK(document); if (!document)
return;
LocalFrameView* view = document->View(); LocalFrameView* view = document->View();
if (!view || !view->LayoutPending()) if (!view || !view->LayoutPending())
...@@ -397,13 +398,9 @@ bool AXSelection::Select(const AXSelectionBehavior selection_behavior) { ...@@ -397,13 +398,9 @@ bool AXSelection::Select(const AXSelectionBehavior selection_behavior) {
return false; return false;
} }
// If the anchor or focus is removed during the "selectstart" event, do
// not proceed.
if (base_.ContainerObject()->IsDetached() ||
extent_.ContainerObject()->IsDetached())
return false;
UpdateSelectionIfNecessary(); UpdateSelectionIfNecessary();
if (!IsValid())
return false;
// Dispatching the "selectstart" event could potentially change the document // Dispatching the "selectstart" event could potentially change the document
// associated with the current frame. // associated with the current frame.
......
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