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 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 } | 2933 } |
2927 | 2934 |
2928 void EventHandler::notifyElementActivated() | 2935 void EventHandler::notifyElementActivated() |
2929 { | 2936 { |
2930 // Since another element has been set to active, stop current timer and clea
r reference. | 2937 // Since another element has been set to active, stop current timer and clea
r reference. |
2931 if (m_activeIntervalTimer.isActive()) | 2938 if (m_activeIntervalTimer.isActive()) |
2932 m_activeIntervalTimer.stop(); | 2939 m_activeIntervalTimer.stop(); |
2933 m_lastDeferredTapElement = nullptr; | 2940 m_lastDeferredTapElement = nullptr; |
2934 } | 2941 } |
2935 | 2942 |
| 2943 void EventHandler::notifySelectionChanged() |
| 2944 { |
| 2945 m_selectionChanged = true; |
| 2946 } |
| 2947 |
2936 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) | 2948 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) |
2937 { | 2949 { |
2938 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. | 2950 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. |
2939 // IE matches lower and upper case access keys regardless of Shift key state
- but if both upper and | 2951 // IE matches lower and upper case access keys regardless of Shift key state
- but if both upper and |
2940 // lower case variants are present in a document, the correct element is mat
ched based on Shift key state. | 2952 // lower case variants are present in a document, the correct element is mat
ched based on Shift key state. |
2941 // Firefox only matches an access key if Shift is not pressed, and does that
case-insensitively. | 2953 // Firefox only matches an access key if Shift is not pressed, and does that
case-insensitively. |
2942 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); | 2954 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); |
2943 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) | 2955 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) |
2944 return false; | 2956 return false; |
2945 String key = evt.unmodifiedText(); | 2957 String key = evt.unmodifiedText(); |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3863 unsigned EventHandler::accessKeyModifiers() | 3875 unsigned EventHandler::accessKeyModifiers() |
3864 { | 3876 { |
3865 #if OS(MACOSX) | 3877 #if OS(MACOSX) |
3866 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3878 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3867 #else | 3879 #else |
3868 return PlatformEvent::AltKey; | 3880 return PlatformEvent::AltKey; |
3869 #endif | 3881 #endif |
3870 } | 3882 } |
3871 | 3883 |
3872 } // namespace blink | 3884 } // namespace blink |
OLD | NEW |