| Index: third_party/WebKit/Source/core/editing/FrameSelection.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
|
| index 22fe9fbd89ee7dfd71d6c9b437dac1f27085536b..ea53a274dc77431adeca7186a1d67e0e64253aca 100644
|
| --- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
|
| @@ -858,8 +858,13 @@ void FrameSelection::selectAll()
|
| if (!root || editingIgnoresContent(root.get()))
|
| return;
|
|
|
| - if (selectStartTarget && selectStartTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNames::selectstart)) != DispatchEventResult::NotCanceled)
|
| - return;
|
| + if (selectStartTarget) {
|
| + if (selectStartTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNames::selectstart)) != DispatchEventResult::NotCanceled)
|
| + return;
|
| + // |root| may be detached due to selectstart event.
|
| + if (!root->inDocument() || root->document() != document)
|
| + return;
|
| + }
|
|
|
| VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode(root.get()));
|
| setSelection(newSelection);
|
|
|