Index: Source/core/editing/SelectionController.cpp |
diff --git a/Source/core/editing/SelectionController.cpp b/Source/core/editing/SelectionController.cpp |
index 4a33683f5f9ca2480d52ae270d9d6335df2db73f..9ba2fe78d3e42e7a914b73efaa6cc41e4d3b1d96 100644 |
--- a/Source/core/editing/SelectionController.cpp |
+++ b/Source/core/editing/SelectionController.cpp |
@@ -238,6 +238,10 @@ void SelectionController::updateSelectionForMouseDragAlgorithm(const HitTestResu |
if (m_selectionState == SelectionState::HaveNotStartedSelection && !dispatchSelectStart(target)) |
return; |
+ // TODO(yosin) We should check |mousePressNode|, |targetPosition|, and |
+ // |newSelection| are valid for |m_frame->document()|. |
+ // |dispatchSelectStart()| can change them by "selectstart" event handler. |
+ |
if (m_selectionState != SelectionState::ExtendedSelection) { |
// Always extend selection here because it's caused by a mouse drag |
m_selectionState = SelectionState::ExtendedSelection; |
@@ -285,6 +289,9 @@ bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(Node |
if (!dispatchSelectStart(targetNode)) |
return false; |
+ if (!selection.isValidFor(*m_frame->document())) |
+ return false; |
+ |
if (selection.isRange()) { |
m_selectionState = SelectionState::ExtendedSelection; |
} else { |