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) |