OLD | NEW |
---|---|
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 , m_mouseDownTimestamp(0) | 221 , m_mouseDownTimestamp(0) |
222 , m_widgetIsLatched(false) | 222 , m_widgetIsLatched(false) |
223 , m_touchPressed(false) | 223 , m_touchPressed(false) |
224 , m_scrollGestureHandlingNode(nullptr) | 224 , m_scrollGestureHandlingNode(nullptr) |
225 , m_lastGestureScrollOverWidget(false) | 225 , m_lastGestureScrollOverWidget(false) |
226 , m_maxMouseMovedDuration(0) | 226 , m_maxMouseMovedDuration(0) |
227 , m_didStartDrag(false) | 227 , m_didStartDrag(false) |
228 , m_longTapShouldInvokeContextMenu(false) | 228 , m_longTapShouldInvokeContextMenu(false) |
229 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 229 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
230 , m_lastShowPressTimestamp(0) | 230 , m_lastShowPressTimestamp(0) |
231 , m_selectionChanged(false) | |
231 { | 232 { |
232 } | 233 } |
233 | 234 |
234 EventHandler::~EventHandler() | 235 EventHandler::~EventHandler() |
235 { | 236 { |
236 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); | 237 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); |
237 } | 238 } |
238 | 239 |
239 void EventHandler::trace(Visitor* visitor) | 240 void EventHandler::trace(Visitor* visitor) |
240 { | 241 { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 m_lastGestureScrollOverWidget = false; | 296 m_lastGestureScrollOverWidget = false; |
296 m_previousGestureScrolledNode = nullptr; | 297 m_previousGestureScrolledNode = nullptr; |
297 m_scrollbarHandlingScrollGesture = nullptr; | 298 m_scrollbarHandlingScrollGesture = nullptr; |
298 m_maxMouseMovedDuration = 0; | 299 m_maxMouseMovedDuration = 0; |
299 m_didStartDrag = false; | 300 m_didStartDrag = false; |
300 m_touchPressed = false; | 301 m_touchPressed = false; |
301 m_mouseDownMayStartSelect = false; | 302 m_mouseDownMayStartSelect = false; |
302 m_mouseDownMayStartDrag = false; | 303 m_mouseDownMayStartDrag = false; |
303 m_lastShowPressTimestamp = 0; | 304 m_lastShowPressTimestamp = 0; |
304 m_lastDeferredTapElement = nullptr; | 305 m_lastDeferredTapElement = nullptr; |
306 m_selectionChanged = false; | |
305 } | 307 } |
306 | 308 |
307 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) | 309 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) |
308 { | 310 { |
309 if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) | 311 if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) |
310 return; | 312 return; |
311 if (nodeToBeRemoved.isInShadowTree()) { | 313 if (nodeToBeRemoved.isInShadowTree()) { |
312 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); | 314 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); |
313 } else { | 315 } else { |
314 // We don't dispatch click events if the mousedown node is removed | 316 // We don't dispatch click events if the mousedown node is removed |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 // the mouse is pressed again. | 770 // the mouse is pressed again. |
769 m_mousePressed = false; | 771 m_mousePressed = false; |
770 m_capturesDragging = false; | 772 m_capturesDragging = false; |
771 m_mouseDownMayStartDrag = false; | 773 m_mouseDownMayStartDrag = false; |
772 m_mouseDownMayStartSelect = false; | 774 m_mouseDownMayStartSelect = false; |
773 m_mouseDownMayStartAutoscroll = false; | 775 m_mouseDownMayStartAutoscroll = false; |
774 m_mouseDownWasInSubframe = false; | 776 m_mouseDownWasInSubframe = false; |
775 | 777 |
776 bool handled = false; | 778 bool handled = false; |
777 | 779 |
780 bool isSelectionChanged = m_selectionChanged; | |
781 m_selectionChanged = false; | |
782 | |
778 // Clear the selection if the mouse didn't move after the last mouse | 783 // Clear the selection if the mouse didn't move after the last mouse |
779 // press and it's not a context menu click. We do this so when clicking | 784 // press and it's not a context menu click and it's not set by setSelectionR ange during handling mouse event. |
780 // on the selection, the selection goes away. However, if we are | 785 // We do this so when clicking on the selection, the selection goes away. Ho wever, if we are |
781 // editing, place the caret. | 786 // editing, place the caret. |
782 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection | 787 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection |
783 && m_dragStartPos == event.event().position() | 788 && m_dragStartPos == event.event().position() |
784 && m_frame->selection().isRange() | 789 && m_frame->selection().isRange() |
785 && event.event().button() != RightButton) { | 790 && event.event().button() != RightButton |
791 && !isSelectionChanged) { | |
786 VisibleSelection newSelection; | 792 VisibleSelection newSelection; |
787 Node* node = event.targetNode(); | 793 Node* node = event.targetNode(); |
788 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled(); | 794 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled(); |
789 if (node && node->renderer() && (caretBrowsing || node->hasEditableStyle ())) { | 795 if (node && node->renderer() && (caretBrowsing || node->hasEditableStyle ())) { |
790 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP oint(event.localPoint())); | 796 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP oint(event.localPoint())); |
791 newSelection = VisibleSelection(pos); | 797 newSelection = VisibleSelection(pos); |
792 } | 798 } |
793 | 799 |
794 setSelectionIfNeeded(m_frame->selection(), newSelection); | 800 setSelectionIfNeeded(m_frame->selection(), newSelection); |
795 | 801 |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1278 m_resizeScrollableArea->setInResizeMode(true); | 1284 m_resizeScrollableArea->setInResizeMode(true); |
1279 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeC orner(p); | 1285 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeC orner(p); |
1280 invalidateClick(); | 1286 invalidateClick(); |
1281 return true; | 1287 return true; |
1282 } | 1288 } |
1283 } | 1289 } |
1284 | 1290 |
1285 m_frame->selection().setCaretBlinkingSuspended(true); | 1291 m_frame->selection().setCaretBlinkingSuspended(true); |
1286 | 1292 |
1287 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targe tNode(), m_clickCount, mouseEvent, true); | 1293 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targe tNode(), m_clickCount, mouseEvent, true); |
1294 m_selectionChanged = false; | |
1288 swallowEvent = swallowEvent || handleMouseFocus(mouseEvent); | 1295 swallowEvent = swallowEvent || handleMouseFocus(mouseEvent); |
1289 m_capturesDragging = !swallowEvent || mev.scrollbar(); | 1296 m_capturesDragging = !swallowEvent || mev.scrollbar(); |
1290 | 1297 |
1291 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults | 1298 // 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. | 1299 // in case the scrollbar widget was destroyed when the mouse event was handl ed. |
1293 if (mev.scrollbar()) { | 1300 if (mev.scrollbar()) { |
1294 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); | 1301 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); |
1295 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); | 1302 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); |
1296 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); | 1303 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); |
1297 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get ()) | 1304 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get ()) |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2944 } | 2951 } |
2945 | 2952 |
2946 void EventHandler::notifyElementActivated() | 2953 void EventHandler::notifyElementActivated() |
2947 { | 2954 { |
2948 // Since another element has been set to active, stop current timer and clea r reference. | 2955 // Since another element has been set to active, stop current timer and clea r reference. |
2949 if (m_activeIntervalTimer.isActive()) | 2956 if (m_activeIntervalTimer.isActive()) |
2950 m_activeIntervalTimer.stop(); | 2957 m_activeIntervalTimer.stop(); |
2951 m_lastDeferredTapElement = nullptr; | 2958 m_lastDeferredTapElement = nullptr; |
2952 } | 2959 } |
2953 | 2960 |
2961 void EventHandler::notifySelectionChanged() | |
2962 { | |
2963 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
| |
2964 } | |
2965 | |
2954 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) | 2966 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) |
2955 { | 2967 { |
2956 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. | 2968 // 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 | 2969 // 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. | 2970 // 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. | 2971 // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively. |
2960 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); | 2972 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); |
2961 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) | 2973 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) |
2962 return false; | 2974 return false; |
2963 String key = evt.unmodifiedText(); | 2975 String key = evt.unmodifiedText(); |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3881 unsigned EventHandler::accessKeyModifiers() | 3893 unsigned EventHandler::accessKeyModifiers() |
3882 { | 3894 { |
3883 #if OS(MACOSX) | 3895 #if OS(MACOSX) |
3884 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3896 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3885 #else | 3897 #else |
3886 return PlatformEvent::AltKey; | 3898 return PlatformEvent::AltKey; |
3887 #endif | 3899 #endif |
3888 } | 3900 } |
3889 | 3901 |
3890 } // namespace blink | 3902 } // namespace blink |
OLD | NEW |