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

Unified Diff: Source/core/input/EventHandler.cpp

Issue 1049233003: Keep the selection of the text field when changed by JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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 | « Source/core/editing/SelectionController.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/input/EventHandler.cpp
diff --git a/Source/core/input/EventHandler.cpp b/Source/core/input/EventHandler.cpp
index 9e1072c47e5fbfb6e410e44f5368e2cf7c25f900..39bcfff68e989a25bd1278d9d6a646bc206ec421 100644
--- a/Source/core/input/EventHandler.cpp
+++ b/Source/core/input/EventHandler.cpp
@@ -368,7 +368,6 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
bool swallowEvent = false;
m_mousePressed = true;
- selectionController().initializeSelectionState();
if (event.event().clickCount() == 2)
swallowEvent = selectionController().handleMousePressEventDoubleClick(event);
@@ -956,6 +955,12 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
m_frame->selection().setCaretBlinkingSuspended(true);
bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.innerNode(), m_clickCount, mouseEvent, true);
+ // m_selectionInitiationState is initialized after dispatching mousedown
+ // event in order not to keep the selection by DOM APIs Because we can't
+ // give the user the chance to handle the selection by user action like
+ // dragging if we keep the selection in case of mousedown. FireFox also has
+ // the same behavior and it's more compatible with other browsers.
+ selectionController().initializeSelectionState();
HitTestResult hitTestResult = hitTestResultInFrame(m_frame, mouseEvent.position(), HitTestRequest::ReadOnly);
swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults(mouseEvent, hitTestResult));
m_capturesDragging = !swallowEvent || mev.scrollbar();
@@ -2032,6 +2037,7 @@ bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftButtonDown),
PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true);
+ selectionController().initializeSelectionState();
if (!swallowMouseDownEvent)
swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fakeMouseDown, currentHitTest));
if (!swallowMouseDownEvent)
« no previous file with comments | « Source/core/editing/SelectionController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698