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

Side by Side 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, 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 unified diff | Download patch
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 if (singleClick) 612 if (singleClick)
613 focusDocumentView(); 613 focusDocumentView();
614 614
615 Node* innerNode = event.targetNode(); 615 Node* innerNode = event.targetNode();
616 616
617 m_mousePressNode = innerNode; 617 m_mousePressNode = innerNode;
618 m_dragStartPos = event.event().position(); 618 m_dragStartPos = event.event().position();
619 619
620 bool swallowEvent = false; 620 bool swallowEvent = false;
621 m_mousePressed = true; 621 m_mousePressed = true;
622 m_selectionInitiationState = HaveNotStartedSelection;
623 622
624 if (event.event().clickCount() == 2) 623 if (event.event().clickCount() == 2)
625 swallowEvent = handleMousePressEventDoubleClick(event); 624 swallowEvent = handleMousePressEventDoubleClick(event);
626 else if (event.event().clickCount() >= 3) 625 else if (event.event().clickCount() >= 3)
627 swallowEvent = handleMousePressEventTripleClick(event); 626 swallowEvent = handleMousePressEventTripleClick(event);
628 else 627 else
629 swallowEvent = handleMousePressEventSingleClick(event); 628 swallowEvent = handleMousePressEventSingleClick(event);
630 629
631 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect 630 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect
632 || (m_mousePressNode && m_mousePressNode->renderBox() && m_mousePressNod e->renderBox()->canBeProgramaticallyScrolled()); 631 || (m_mousePressNode && m_mousePressNode->renderBox() && m_mousePressNod e->renderBox()->canBeProgramaticallyScrolled());
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 m_resizeScrollableArea->setInResizeMode(true); 1277 m_resizeScrollableArea->setInResizeMode(true);
1279 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeC orner(p); 1278 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeC orner(p);
1280 invalidateClick(); 1279 invalidateClick();
1281 return true; 1280 return true;
1282 } 1281 }
1283 } 1282 }
1284 1283
1285 m_frame->selection().setCaretBlinkingSuspended(true); 1284 m_frame->selection().setCaretBlinkingSuspended(true);
1286 1285
1287 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targe tNode(), m_clickCount, mouseEvent, true); 1286 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targe tNode(), m_clickCount, mouseEvent, true);
1287 m_selectionInitiationState = HaveNotStartedSelection;
Rick Byers 2014/09/02 15:39:20 Please add a comment here saying why we don't cons
1288 swallowEvent = swallowEvent || handleMouseFocus(mouseEvent); 1288 swallowEvent = swallowEvent || handleMouseFocus(mouseEvent);
1289 m_capturesDragging = !swallowEvent || mev.scrollbar(); 1289 m_capturesDragging = !swallowEvent || mev.scrollbar();
1290 1290
1291 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults 1291 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults
1292 // in case the scrollbar widget was destroyed when the mouse event was handl ed. 1292 // in case the scrollbar widget was destroyed when the mouse event was handl ed.
1293 if (mev.scrollbar()) { 1293 if (mev.scrollbar()) {
1294 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); 1294 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get();
1295 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); 1295 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active );
1296 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); 1296 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent);
1297 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get ()) 1297 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get ())
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
2944 } 2944 }
2945 2945
2946 void EventHandler::notifyElementActivated() 2946 void EventHandler::notifyElementActivated()
2947 { 2947 {
2948 // Since another element has been set to active, stop current timer and clea r reference. 2948 // Since another element has been set to active, stop current timer and clea r reference.
2949 if (m_activeIntervalTimer.isActive()) 2949 if (m_activeIntervalTimer.isActive())
2950 m_activeIntervalTimer.stop(); 2950 m_activeIntervalTimer.stop();
2951 m_lastDeferredTapElement = nullptr; 2951 m_lastDeferredTapElement = nullptr;
2952 } 2952 }
2953 2953
2954 void EventHandler::notifySelectionChanged()
2955 {
2956 m_selectionInitiationState = ExtendedSelection;
2957 }
2958
2954 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) 2959 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt)
2955 { 2960 {
2956 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. 2961 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do.
2957 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and 2962 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and
2958 // lower case variants are present in a document, the correct element is mat ched based on Shift key state. 2963 // lower case variants are present in a document, the correct element is mat ched based on Shift key state.
2959 // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively. 2964 // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively.
2960 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); 2965 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey));
2961 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) 2966 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers())
2962 return false; 2967 return false;
2963 String key = evt.unmodifiedText(); 2968 String key = evt.unmodifiedText();
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
3881 unsigned EventHandler::accessKeyModifiers() 3886 unsigned EventHandler::accessKeyModifiers()
3882 { 3887 {
3883 #if OS(MACOSX) 3888 #if OS(MACOSX)
3884 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3889 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3885 #else 3890 #else
3886 return PlatformEvent::AltKey; 3891 return PlatformEvent::AltKey;
3887 #endif 3892 #endif
3888 } 3893 }
3889 3894
3890 } // namespace blink 3895 } // namespace blink
OLDNEW
« 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