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

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: Created 6 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
Index: Source/core/page/EventHandler.cpp
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index 598163f112aeaebe28a8de0070b9f1312ba18d1c..a1b0943da41477502d338959de0b3de012139836 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -228,6 +228,7 @@ EventHandler::EventHandler(LocalFrame* frame)
, m_longTapShouldInvokeContextMenu(false)
, m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
, m_lastShowPressTimestamp(0)
+ , m_selectionChanged(false)
{
}
@@ -302,6 +303,7 @@ void EventHandler::clear()
m_mouseDownMayStartDrag = false;
m_lastShowPressTimestamp = 0;
m_lastDeferredTapElement = nullptr;
+ m_selectionChanged = false;
}
void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved)
@@ -775,14 +777,18 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e
bool handled = false;
+ bool isSelectionChanged = m_selectionChanged;
+ m_selectionChanged = false;
+
// Clear the selection if the mouse didn't move after the last mouse
- // press and it's not a context menu click. We do this so when clicking
- // on the selection, the selection goes away. However, if we are
+ // press and it's not a context menu click and it's not set by setSelectionRange during handling mouse event.
+ // We do this so when clicking on the selection, the selection goes away. However, if we are
// editing, place the caret.
if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != ExtendedSelection
- && m_dragStartPos == event.event().position()
- && m_frame->selection().isRange()
- && event.event().button() != RightButton) {
+ && m_dragStartPos == event.event().position()
+ && m_frame->selection().isRange()
+ && event.event().button() != RightButton
+ && !isSelectionChanged) {
VisibleSelection newSelection;
Node* node = event.targetNode();
bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
@@ -1285,6 +1291,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
m_frame->selection().setCaretBlinkingSuspended(true);
bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targetNode(), m_clickCount, mouseEvent, true);
+ m_selectionChanged = false;
swallowEvent = swallowEvent || handleMouseFocus(mouseEvent);
m_capturesDragging = !swallowEvent || mev.scrollbar();
@@ -2951,6 +2958,11 @@ void EventHandler::notifyElementActivated()
m_lastDeferredTapElement = nullptr;
}
+void EventHandler::notifySelectionChanged()
+{
+ m_selectionChanged = true;
Rick Byers 2014/08/28 18:16:41 It looks to me like m_selectionInitiationState is
Miyoung Shin(g) 2014/08/29 14:18:52 Ok, I think I can use m_selectionInitiationState
+}
+
bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt)
{
// FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do.
« LayoutTests/fast/forms/setrangetext-within-events.html ('K') | « Source/core/page/EventHandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698