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

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
Index: Source/core/input/EventHandler.cpp
diff --git a/Source/core/input/EventHandler.cpp b/Source/core/input/EventHandler.cpp
index 3788a52df2b13812b6a69145673453db57c674ac..314c6a382d0c34a25fb4ec22f16e39bb30c9f3cb 100644
--- a/Source/core/input/EventHandler.cpp
+++ b/Source/core/input/EventHandler.cpp
@@ -362,7 +362,6 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
bool swallowEvent = false;
m_mousePressed = true;
- selectionController().initializeSelectionState();
if (event.event().clickCount() == 2)
swallowEvent = selectionController().handleMousePressEventDoubleClick(event);
@@ -950,6 +949,10 @@ 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
yosin_UTC9 2015/07/06 01:57:30 nit: Could you try to keep comments in 80 chars? I
Miyoung Shin(g) 2015/07/13 03:32:57 Done.
+ // 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();
@@ -2021,6 +2024,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)
« Source/core/editing/SelectionController.cpp ('K') | « Source/core/editing/SelectionController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698