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

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

Issue 507533002: Fix to keep the selection of the text field in input element after setSelectionRange is called by d… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 3 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/page/EventHandler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/EventHandler.cpp
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index 5350361f2990e7d48ef8b5cbd82ca2afb1fb8ab0..21ed824b1a70e8a6b4251948d86f695876461802 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -620,7 +620,6 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
bool swallowEvent = false;
m_mousePressed = true;
- m_selectionInitiationState = HaveNotStartedSelection;
if (event.event().clickCount() == 2)
swallowEvent = handleMousePressEventDoubleClick(event);
@@ -1283,6 +1282,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
+ // 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.
+ m_selectionInitiationState = HaveNotStartedSelection;
swallowEvent = swallowEvent || handleMouseFocus(mouseEvent);
m_capturesDragging = !swallowEvent || mev.scrollbar();
@@ -2937,6 +2940,11 @@ void EventHandler::notifyElementActivated()
m_lastDeferredTapElement = nullptr;
}
+void EventHandler::notifySelectionChanged()
+{
+ m_selectionInitiationState = ExtendedSelection;
+}
+
bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt)
{
// FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do.
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698