Chromium Code Reviews| Index: Source/core/page/EventHandler.cpp |
| diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp |
| index 581c19aaae92a86def83dc537eece758ee1afc01..59e100af26780feff0049de13bdb410f93450ca6 100644 |
| --- a/Source/core/page/EventHandler.cpp |
| +++ b/Source/core/page/EventHandler.cpp |
| @@ -579,7 +579,7 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR |
| granularity = m_frame->selection().granularity(); |
| newSelection.expandUsingGranularity(m_frame->selection().granularity()); |
| } |
| - } else { |
| + } else if (m_selectionInitiationState != ExtendedSelection) { |
| newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleSelection(visiblePos)); |
| } |
| @@ -647,7 +647,6 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve |
| bool swallowEvent = false; |
| m_mousePressed = true; |
| - m_selectionInitiationState = HaveNotStartedSelection; |
| if (event.event().clickCount() == 2) |
| swallowEvent = handleMousePressEventDoubleClick(event); |
| @@ -1332,6 +1331,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; |
| HitTestResult hitTestResult = hitTestResultInFrame(m_frame, mouseEvent.position(), HitTestRequest::ReadOnly); |
| swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults(mouseEvent, hitTestResult)); |
| m_capturesDragging = !swallowEvent || mev.scrollbar(); |
| @@ -2352,6 +2355,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); |
| + m_selectionInitiationState = HaveNotStartedSelection; |
| if (!swallowMouseDownEvent) |
| swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fakeMouseDown, currentHitTest)); |
| if (!swallowMouseDownEvent) |
| @@ -3126,6 +3130,16 @@ void EventHandler::notifyElementActivated() |
| m_lastDeferredTapElement = nullptr; |
| } |
| +void EventHandler::notifySelectionChanged() |
|
yosin_UTC9
2015/04/10 02:06:09
It is better to move selection handling code in Ev
Miyoung Shin(g)
2015/04/22 15:32:37
I've tried to move the code related to the selecti
yosin_UTC9
2015/04/28 01:59:54
Yes, I'm thinking to have a SelectionHandler class
|
| +{ |
| + if (m_frame->selection().isRange()) |
| + m_selectionInitiationState = ExtendedSelection; |
|
yosin_UTC9
2015/04/10 02:06:09
|m_selectionInitiationState| is no longer represen
Miyoung Shin(g)
2015/04/22 15:32:37
I've changed |m_selectionInitiationState| to |m_se
yosin_UTC9
2015/04/28 01:59:54
I mean |PlacedCaret| and |ExtendSelection| are sta
|
| + else if (m_frame->selection().isCaret()) |
| + m_selectionInitiationState = PlacedCaret; |
| + else |
| + m_selectionInitiationState = HaveNotStartedSelection; |
| +} |
| + |
| bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) |
| { |
| // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. |