Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(791)

Unified Diff: Source/core/editing/SelectionController.cpp

Issue 1288883002: Make SelectionController not to set invalid selection by mouse down (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-13T18:48:09 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/editing/selection/selectstart-event-crash.html ('k') | Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « LayoutTests/editing/selection/selectstart-event-crash.html ('k') | Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698