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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 , m_svgPan(false) | 282 , m_svgPan(false) |
283 , m_resizeScrollableArea(0) | 283 , m_resizeScrollableArea(0) |
284 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 284 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
285 , m_clickCount(0) | 285 , m_clickCount(0) |
286 , m_shouldOnlyFireDragOverEvent(false) | 286 , m_shouldOnlyFireDragOverEvent(false) |
287 , m_mousePositionIsUnknown(true) | 287 , m_mousePositionIsUnknown(true) |
288 , m_mouseDownTimestamp(0) | 288 , m_mouseDownTimestamp(0) |
289 , m_widgetIsLatched(false) | 289 , m_widgetIsLatched(false) |
290 , m_originatingTouchPointTargetKey(0) | 290 , m_originatingTouchPointTargetKey(0) |
291 , m_touchPressed(false) | 291 , m_touchPressed(false) |
292 , m_scrollGestureHandlingNode(0) | 292 , m_scrollGestureHandlingNode(nullptr) |
293 , m_lastHitTestResultOverWidget(false) | 293 , m_lastHitTestResultOverWidget(false) |
294 , m_maxMouseMovedDuration(0) | 294 , m_maxMouseMovedDuration(0) |
295 , m_baseEventType(PlatformEvent::NoType) | 295 , m_baseEventType(PlatformEvent::NoType) |
296 , m_didStartDrag(false) | 296 , m_didStartDrag(false) |
297 , m_longTapShouldInvokeContextMenu(false) | 297 , m_longTapShouldInvokeContextMenu(false) |
298 , m_syntheticPageScaleFactor(0) | 298 , m_syntheticPageScaleFactor(0) |
299 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 299 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
300 , m_lastShowPressTimestamp(0) | 300 , m_lastShowPressTimestamp(0) |
301 { | 301 { |
302 } | 302 } |
303 | 303 |
304 EventHandler::~EventHandler() | 304 EventHandler::~EventHandler() |
305 { | 305 { |
306 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); | 306 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); |
307 } | 307 } |
308 | 308 |
309 DragState& EventHandler::dragState() | 309 DragState& EventHandler::dragState() |
310 { | 310 { |
311 DEFINE_STATIC_LOCAL(DragState, state, ()); | 311 DEFINE_STATIC_LOCAL(DragState, state, ()); |
312 return state; | 312 return state; |
313 } | 313 } |
314 | 314 |
315 void EventHandler::clear() | 315 void EventHandler::clear() |
316 { | 316 { |
317 m_hoverTimer.stop(); | 317 m_hoverTimer.stop(); |
318 m_cursorUpdateTimer.stop(); | 318 m_cursorUpdateTimer.stop(); |
319 m_fakeMouseMoveEventTimer.stop(); | 319 m_fakeMouseMoveEventTimer.stop(); |
320 m_activeIntervalTimer.stop(); | 320 m_activeIntervalTimer.stop(); |
321 m_resizeScrollableArea = 0; | 321 m_resizeScrollableArea = 0; |
322 m_nodeUnderMouse = 0; | 322 m_nodeUnderMouse = nullptr; |
323 m_lastNodeUnderMouse = 0; | 323 m_lastNodeUnderMouse = nullptr; |
324 m_instanceUnderMouse = 0; | 324 m_instanceUnderMouse = nullptr; |
325 m_lastInstanceUnderMouse = 0; | 325 m_lastInstanceUnderMouse = nullptr; |
326 m_lastMouseMoveEventSubframe = 0; | 326 m_lastMouseMoveEventSubframe = nullptr; |
327 m_lastScrollbarUnderMouse = 0; | 327 m_lastScrollbarUnderMouse = nullptr; |
328 m_clickCount = 0; | 328 m_clickCount = 0; |
329 m_clickNode = 0; | 329 m_clickNode = nullptr; |
330 m_frameSetBeingResized = 0; | 330 m_frameSetBeingResized = nullptr; |
331 m_dragTarget = 0; | 331 m_dragTarget = nullptr; |
332 m_shouldOnlyFireDragOverEvent = false; | 332 m_shouldOnlyFireDragOverEvent = false; |
333 m_mousePositionIsUnknown = true; | 333 m_mousePositionIsUnknown = true; |
334 m_lastKnownMousePosition = IntPoint(); | 334 m_lastKnownMousePosition = IntPoint(); |
335 m_lastKnownMouseGlobalPosition = IntPoint(); | 335 m_lastKnownMouseGlobalPosition = IntPoint(); |
336 m_lastMouseDownUserGestureToken.clear(); | 336 m_lastMouseDownUserGestureToken.clear(); |
337 m_mousePressNode = 0; | 337 m_mousePressNode = nullptr; |
338 m_mousePressed = false; | 338 m_mousePressed = false; |
339 m_capturesDragging = false; | 339 m_capturesDragging = false; |
340 m_capturingMouseEventsNode = 0; | 340 m_capturingMouseEventsNode = nullptr; |
341 m_latchedWheelEventNode = 0; | 341 m_latchedWheelEventNode = nullptr; |
342 m_previousWheelScrolledNode = 0; | 342 m_previousWheelScrolledNode = nullptr; |
343 m_originatingTouchPointTargets.clear(); | 343 m_originatingTouchPointTargets.clear(); |
344 m_originatingTouchPointDocument.clear(); | 344 m_originatingTouchPointDocument.clear(); |
345 m_originatingTouchPointTargetKey = 0; | 345 m_originatingTouchPointTargetKey = 0; |
346 m_scrollGestureHandlingNode = 0; | 346 m_scrollGestureHandlingNode = nullptr; |
347 m_lastHitTestResultOverWidget = false; | 347 m_lastHitTestResultOverWidget = false; |
348 m_previousGestureScrolledNode = 0; | 348 m_previousGestureScrolledNode = nullptr; |
349 m_scrollbarHandlingScrollGesture = 0; | 349 m_scrollbarHandlingScrollGesture = nullptr; |
350 m_maxMouseMovedDuration = 0; | 350 m_maxMouseMovedDuration = 0; |
351 m_baseEventType = PlatformEvent::NoType; | 351 m_baseEventType = PlatformEvent::NoType; |
352 m_didStartDrag = false; | 352 m_didStartDrag = false; |
353 m_touchPressed = false; | 353 m_touchPressed = false; |
354 m_mouseDownMayStartSelect = false; | 354 m_mouseDownMayStartSelect = false; |
355 m_mouseDownMayStartDrag = false; | 355 m_mouseDownMayStartDrag = false; |
356 m_lastShowPressTimestamp = 0; | 356 m_lastShowPressTimestamp = 0; |
357 m_lastDeferredTapElement = 0; | 357 m_lastDeferredTapElement = nullptr; |
358 } | 358 } |
359 | 359 |
360 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) | 360 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) |
361 { | 361 { |
362 if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) | 362 if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) |
363 return; | 363 return; |
364 if (nodeToBeRemoved.isInShadowTree()) { | 364 if (nodeToBeRemoved.isInShadowTree()) { |
365 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); | 365 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); |
366 } else { | 366 } else { |
367 // We don't dispatch click events if the mousedown node is removed | 367 // We don't dispatch click events if the mousedown node is removed |
368 // before a mouseup event. It is compatible with IE and Firefox. | 368 // before a mouseup event. It is compatible with IE and Firefox. |
369 m_clickNode = 0; | 369 m_clickNode = nullptr; |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 static void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelecti
on& newSelection) | 373 static void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelecti
on& newSelection) |
374 { | 374 { |
375 if (selection.selection() != newSelection) | 375 if (selection.selection() != newSelection) |
376 selection.setSelection(newSelection); | 376 selection.setSelection(newSelection); |
377 } | 377 } |
378 | 378 |
379 static inline bool dispatchSelectStart(Node* node) | 379 static inline bool dispatchSelectStart(Node* node) |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 | 607 |
608 if (!node->canStartSelection()) | 608 if (!node->canStartSelection()) |
609 return false; | 609 return false; |
610 | 610 |
611 return true; | 611 return true; |
612 } | 612 } |
613 | 613 |
614 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
nt) | 614 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
nt) |
615 { | 615 { |
616 // Reset drag state. | 616 // Reset drag state. |
617 dragState().m_dragSrc = 0; | 617 dragState().m_dragSrc = nullptr; |
618 | 618 |
619 cancelFakeMouseMoveEvent(); | 619 cancelFakeMouseMoveEvent(); |
620 | 620 |
621 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 621 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
622 | 622 |
623 if (ScrollView* scrollView = m_frame->view()) { | 623 if (ScrollView* scrollView = m_frame->view()) { |
624 if (scrollView->isPointInScrollbarCorner(event.event().position())) | 624 if (scrollView->isPointInScrollbarCorner(event.event().position())) |
625 return false; | 625 return false; |
626 } | 626 } |
627 | 627 |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 | 1281 |
1282 bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(mouseEvent); | 1282 bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(mouseEvent); |
1283 if (defaultPrevented) | 1283 if (defaultPrevented) |
1284 return true; | 1284 return true; |
1285 | 1285 |
1286 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 1286 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
1287 m_frame->tree().top()->eventHandler().m_lastMouseDownUserGestureToken = gest
ureIndicator.currentToken(); | 1287 m_frame->tree().top()->eventHandler().m_lastMouseDownUserGestureToken = gest
ureIndicator.currentToken(); |
1288 | 1288 |
1289 cancelFakeMouseMoveEvent(); | 1289 cancelFakeMouseMoveEvent(); |
1290 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 1290 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
1291 m_capturingMouseEventsNode = 0; | 1291 m_capturingMouseEventsNode = nullptr; |
1292 m_mousePressed = true; | 1292 m_mousePressed = true; |
1293 m_capturesDragging = true; | 1293 m_capturesDragging = true; |
1294 setLastKnownMousePosition(mouseEvent); | 1294 setLastKnownMousePosition(mouseEvent); |
1295 m_mouseDownTimestamp = mouseEvent.timestamp(); | 1295 m_mouseDownTimestamp = mouseEvent.timestamp(); |
1296 m_mouseDownMayStartDrag = false; | 1296 m_mouseDownMayStartDrag = false; |
1297 m_mouseDownMayStartSelect = false; | 1297 m_mouseDownMayStartSelect = false; |
1298 m_mouseDownMayStartAutoscroll = false; | 1298 m_mouseDownMayStartAutoscroll = false; |
1299 if (FrameView* view = m_frame->view()) | 1299 if (FrameView* view = m_frame->view()) |
1300 m_mouseDownPos = view->windowToContents(mouseEvent.position()); | 1300 m_mouseDownPos = view->windowToContents(mouseEvent.position()); |
1301 else { | 1301 else { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targe
tNode(), true, m_clickCount, mouseEvent, true); | 1366 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targe
tNode(), true, m_clickCount, mouseEvent, true); |
1367 m_capturesDragging = !swallowEvent || mev.scrollbar(); | 1367 m_capturesDragging = !swallowEvent || mev.scrollbar(); |
1368 | 1368 |
1369 // If the hit testing originally determined the event was in a scrollbar, re
fetch the MouseEventWithHitTestResults | 1369 // If the hit testing originally determined the event was in a scrollbar, re
fetch the MouseEventWithHitTestResults |
1370 // in case the scrollbar widget was destroyed when the mouse event was handl
ed. | 1370 // in case the scrollbar widget was destroyed when the mouse event was handl
ed. |
1371 if (mev.scrollbar()) { | 1371 if (mev.scrollbar()) { |
1372 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou
se.get(); | 1372 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou
se.get(); |
1373 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active
| HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent); | 1373 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active
| HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent); |
1374 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou
seEvent); | 1374 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou
seEvent); |
1375 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get
()) | 1375 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get
()) |
1376 m_lastScrollbarUnderMouse = 0; | 1376 m_lastScrollbarUnderMouse = nullptr; |
1377 } | 1377 } |
1378 | 1378 |
1379 if (swallowEvent) { | 1379 if (swallowEvent) { |
1380 // scrollbars should get events anyway, even disabled controls might be
scrollable | 1380 // scrollbars should get events anyway, even disabled controls might be
scrollable |
1381 Scrollbar* scrollbar = mev.scrollbar(); | 1381 Scrollbar* scrollbar = mev.scrollbar(); |
1382 | 1382 |
1383 updateLastScrollbarUnderMouse(scrollbar, true); | 1383 updateLastScrollbarUnderMouse(scrollbar, true); |
1384 | 1384 |
1385 if (scrollbar) | 1385 if (scrollbar) |
1386 passMousePressEventToScrollbar(mev, scrollbar); | 1386 passMousePressEventToScrollbar(mev, scrollbar); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 swallowEvent = !dispatchMouseEvent(EventTypeNames::mousemove, mev.targetNode
(), false, 0, mouseEvent, true); | 1582 swallowEvent = !dispatchMouseEvent(EventTypeNames::mousemove, mev.targetNode
(), false, 0, mouseEvent, true); |
1583 if (!swallowEvent) | 1583 if (!swallowEvent) |
1584 swallowEvent = handleMouseDraggedEvent(mev); | 1584 swallowEvent = handleMouseDraggedEvent(mev); |
1585 | 1585 |
1586 return swallowEvent; | 1586 return swallowEvent; |
1587 } | 1587 } |
1588 | 1588 |
1589 void EventHandler::invalidateClick() | 1589 void EventHandler::invalidateClick() |
1590 { | 1590 { |
1591 m_clickCount = 0; | 1591 m_clickCount = 0; |
1592 m_clickNode = 0; | 1592 m_clickNode = nullptr; |
1593 } | 1593 } |
1594 | 1594 |
1595 static Node* parentForClickEvent(const Node& node) | 1595 static Node* parentForClickEvent(const Node& node) |
1596 { | 1596 { |
1597 // IE doesn't dispatch click events for mousedown/mouseup events across form | 1597 // IE doesn't dispatch click events for mousedown/mouseup events across form |
1598 // controls. | 1598 // controls. |
1599 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent()) | 1599 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent()) |
1600 return 0; | 1600 return 0; |
1601 return node.parentOrShadowHostNode(); | 1601 return node.parentOrShadowHostNode(); |
1602 } | 1602 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 return !dispatchMouseEvent(EventTypeNames::mouseup, m_lastNodeUnderMouse
.get(), cancelable, m_clickCount, mouseEvent, setUnder); | 1643 return !dispatchMouseEvent(EventTypeNames::mouseup, m_lastNodeUnderMouse
.get(), cancelable, m_clickCount, mouseEvent, setUnder); |
1644 } | 1644 } |
1645 | 1645 |
1646 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release | HitTe
stRequest::ConfusingAndOftenMisusedDisallowShadowContent; | 1646 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release | HitTe
stRequest::ConfusingAndOftenMisusedDisallowShadowContent; |
1647 if (mouseEvent.fromTouch()) | 1647 if (mouseEvent.fromTouch()) |
1648 hitType |= HitTestRequest::ReadOnly; | 1648 hitType |= HitTestRequest::ReadOnly; |
1649 HitTestRequest request(hitType); | 1649 HitTestRequest request(hitType); |
1650 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); | 1650 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); |
1651 Frame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetNode(m
_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); | 1651 Frame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetNode(m
_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); |
1652 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 1652 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
1653 m_capturingMouseEventsNode = 0; | 1653 m_capturingMouseEventsNode = nullptr; |
1654 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) | 1654 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) |
1655 return true; | 1655 return true; |
1656 | 1656 |
1657 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.
targetNode(), true, m_clickCount, mouseEvent, false); | 1657 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.
targetNode(), true, m_clickCount, mouseEvent, false); |
1658 | 1658 |
1659 bool contextMenuEvent = mouseEvent.button() == RightButton; | 1659 bool contextMenuEvent = mouseEvent.button() == RightButton; |
1660 #if OS(MACOSX) | 1660 #if OS(MACOSX) |
1661 // FIXME: The Mac port achieves the same behavior by checking whether the co
ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl
ementations. | 1661 // FIXME: The Mac port achieves the same behavior by checking whether the co
ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl
ementations. |
1662 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv
ent::CtrlKey) | 1662 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv
ent::CtrlKey) |
1663 contextMenuEvent = true; | 1663 contextMenuEvent = true; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1721 | 1721 |
1722 // FIXME: We might want to dispatch a dragleave even if the view is gone. | 1722 // FIXME: We might want to dispatch a dragleave even if the view is gone. |
1723 if (!view) | 1723 if (!view) |
1724 return false; | 1724 return false; |
1725 | 1725 |
1726 RefPtr<MouseEvent> me = MouseEvent::create(eventType, | 1726 RefPtr<MouseEvent> me = MouseEvent::create(eventType, |
1727 true, true, m_frame->document()->domWindow(), | 1727 true, true, m_frame->document()->domWindow(), |
1728 0, event.globalPosition().x(), event.globalPosition().y(), event.positio
n().x(), event.position().y(), | 1728 0, event.globalPosition().x(), event.globalPosition().y(), event.positio
n().x(), event.position().y(), |
1729 event.movementDelta().x(), event.movementDelta().y(), | 1729 event.movementDelta().x(), event.movementDelta().y(), |
1730 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), | 1730 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), |
1731 0, 0, clipboard); | 1731 0, nullptr, clipboard); |
1732 | 1732 |
1733 dragTarget->dispatchEvent(me.get(), IGNORE_EXCEPTION); | 1733 dragTarget->dispatchEvent(me.get(), IGNORE_EXCEPTION); |
1734 return me->defaultPrevented(); | 1734 return me->defaultPrevented(); |
1735 } | 1735 } |
1736 | 1736 |
1737 static bool targetIsFrame(Node* target, Frame*& frame) | 1737 static bool targetIsFrame(Node* target, Frame*& frame) |
1738 { | 1738 { |
1739 if (!target) | 1739 if (!target) |
1740 return false; | 1740 return false; |
1741 | 1741 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 preventedDefault = targetFrame->eventHandler().performDragAndDrop(ev
ent, clipboard); | 1877 preventedDefault = targetFrame->eventHandler().performDragAndDrop(ev
ent, clipboard); |
1878 } else if (m_dragTarget.get()) | 1878 } else if (m_dragTarget.get()) |
1879 preventedDefault = dispatchDragEvent(EventTypeNames::drop, m_dragTarget.
get(), event, clipboard); | 1879 preventedDefault = dispatchDragEvent(EventTypeNames::drop, m_dragTarget.
get(), event, clipboard); |
1880 clearDragState(); | 1880 clearDragState(); |
1881 return preventedDefault; | 1881 return preventedDefault; |
1882 } | 1882 } |
1883 | 1883 |
1884 void EventHandler::clearDragState() | 1884 void EventHandler::clearDragState() |
1885 { | 1885 { |
1886 stopAutoscroll(); | 1886 stopAutoscroll(); |
1887 m_dragTarget = 0; | 1887 m_dragTarget = nullptr; |
1888 m_capturingMouseEventsNode = 0; | 1888 m_capturingMouseEventsNode = nullptr; |
1889 m_shouldOnlyFireDragOverEvent = false; | 1889 m_shouldOnlyFireDragOverEvent = false; |
1890 } | 1890 } |
1891 | 1891 |
1892 void EventHandler::setCapturingMouseEventsNode(PassRefPtr<Node> n) | 1892 void EventHandler::setCapturingMouseEventsNode(PassRefPtr<Node> n) |
1893 { | 1893 { |
1894 m_capturingMouseEventsNode = n; | 1894 m_capturingMouseEventsNode = n; |
1895 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 1895 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
1896 } | 1896 } |
1897 | 1897 |
1898 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
t& request, const PlatformMouseEvent& mev) | 1898 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
t& request, const PlatformMouseEvent& mev) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 if (FrameView* frameView = frame->view()) | 1989 if (FrameView* frameView = frame->view()) |
1990 frameView->mouseEnteredContentArea(); | 1990 frameView->mouseEnteredContentArea(); |
1991 } | 1991 } |
1992 } else if (page && (layerForNodeUnderMouse && (!layerForLastNode || laye
rForNodeUnderMouse != layerForLastNode))) { | 1992 } else if (page && (layerForNodeUnderMouse && (!layerForLastNode || laye
rForNodeUnderMouse != layerForLastNode))) { |
1993 // The mouse has moved between layers. | 1993 // The mouse has moved between layers. |
1994 if (ScrollableArea* scrollableAreaForNodeUnderMouse = associatedScro
llableArea(layerForNodeUnderMouse)) | 1994 if (ScrollableArea* scrollableAreaForNodeUnderMouse = associatedScro
llableArea(layerForNodeUnderMouse)) |
1995 scrollableAreaForNodeUnderMouse->mouseEnteredContentArea(); | 1995 scrollableAreaForNodeUnderMouse->mouseEnteredContentArea(); |
1996 } | 1996 } |
1997 | 1997 |
1998 if (m_lastNodeUnderMouse && m_lastNodeUnderMouse->document() != m_frame-
>document()) { | 1998 if (m_lastNodeUnderMouse && m_lastNodeUnderMouse->document() != m_frame-
>document()) { |
1999 m_lastNodeUnderMouse = 0; | 1999 m_lastNodeUnderMouse = nullptr; |
2000 m_lastScrollbarUnderMouse = 0; | 2000 m_lastScrollbarUnderMouse = nullptr; |
2001 m_lastInstanceUnderMouse = 0; | 2001 m_lastInstanceUnderMouse = nullptr; |
2002 } | 2002 } |
2003 | 2003 |
2004 if (m_lastNodeUnderMouse != m_nodeUnderMouse) { | 2004 if (m_lastNodeUnderMouse != m_nodeUnderMouse) { |
2005 // send mouseout event to the old node | 2005 // send mouseout event to the old node |
2006 if (m_lastNodeUnderMouse) | 2006 if (m_lastNodeUnderMouse) |
2007 m_lastNodeUnderMouse->dispatchMouseEvent(mouseEvent, EventTypeNa
mes::mouseout, 0, m_nodeUnderMouse.get()); | 2007 m_lastNodeUnderMouse->dispatchMouseEvent(mouseEvent, EventTypeNa
mes::mouseout, 0, m_nodeUnderMouse.get()); |
2008 // send mouseover event to the new node | 2008 // send mouseover event to the new node |
2009 if (m_nodeUnderMouse) | 2009 if (m_nodeUnderMouse) |
2010 m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, EventTypeNames:
:mouseover, 0, m_lastNodeUnderMouse.get()); | 2010 m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, EventTypeNames:
:mouseover, 0, m_lastNodeUnderMouse.get()); |
2011 } | 2011 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2143 if (e.useLatchedEventNode()) { | 2143 if (e.useLatchedEventNode()) { |
2144 if (!m_latchedWheelEventNode) { | 2144 if (!m_latchedWheelEventNode) { |
2145 m_latchedWheelEventNode = node; | 2145 m_latchedWheelEventNode = node; |
2146 m_widgetIsLatched = result.isOverWidget(); | 2146 m_widgetIsLatched = result.isOverWidget(); |
2147 } else | 2147 } else |
2148 node = m_latchedWheelEventNode.get(); | 2148 node = m_latchedWheelEventNode.get(); |
2149 | 2149 |
2150 isOverWidget = m_widgetIsLatched; | 2150 isOverWidget = m_widgetIsLatched; |
2151 } else { | 2151 } else { |
2152 if (m_latchedWheelEventNode) | 2152 if (m_latchedWheelEventNode) |
2153 m_latchedWheelEventNode = 0; | 2153 m_latchedWheelEventNode = nullptr; |
2154 if (m_previousWheelScrolledNode) | 2154 if (m_previousWheelScrolledNode) |
2155 m_previousWheelScrolledNode = 0; | 2155 m_previousWheelScrolledNode = nullptr; |
2156 | 2156 |
2157 isOverWidget = result.isOverWidget(); | 2157 isOverWidget = result.isOverWidget(); |
2158 } | 2158 } |
2159 | 2159 |
2160 // FIXME: It should not be necessary to do this mutation here. | 2160 // FIXME: It should not be necessary to do this mutation here. |
2161 // Instead, the handlers should know convert vertical scrolls | 2161 // Instead, the handlers should know convert vertical scrolls |
2162 // appropriately. | 2162 // appropriately. |
2163 PlatformWheelEvent event = e; | 2163 PlatformWheelEvent event = e; |
2164 if (m_baseEventType == PlatformEvent::NoType && shouldTurnVerticalTicksIntoH
orizontal(result, e)) | 2164 if (m_baseEventType == PlatformEvent::NoType && shouldTurnVerticalTicksIntoH
orizontal(result, e)) |
2165 event = event.copyTurningVerticalTicksIntoHorizontalTicks(); | 2165 event = event.copyTurningVerticalTicksIntoHorizontalTicks(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 ScrollAnimator* animator = sa->scrollAnimator(); | 2232 ScrollAnimator* animator = sa->scrollAnimator(); |
2233 if (animator) | 2233 if (animator) |
2234 animator->cancelAnimations(); | 2234 animator->cancelAnimations(); |
2235 } | 2235 } |
2236 return false; | 2236 return false; |
2237 } | 2237 } |
2238 | 2238 |
2239 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) | 2239 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) |
2240 { | 2240 { |
2241 IntPoint adjustedPoint = gestureEvent.position(); | 2241 IntPoint adjustedPoint = gestureEvent.position(); |
2242 RefPtr<Frame> subframe = 0; | 2242 RefPtr<Frame> subframe = nullptr; |
2243 switch (gestureEvent.type()) { | 2243 switch (gestureEvent.type()) { |
2244 case PlatformEvent::GestureScrollBegin: | 2244 case PlatformEvent::GestureScrollBegin: |
2245 case PlatformEvent::GestureScrollUpdate: | 2245 case PlatformEvent::GestureScrollUpdate: |
2246 case PlatformEvent::GestureScrollUpdateWithoutPropagation: | 2246 case PlatformEvent::GestureScrollUpdateWithoutPropagation: |
2247 case PlatformEvent::GestureScrollEnd: | 2247 case PlatformEvent::GestureScrollEnd: |
2248 case PlatformEvent::GestureFlingStart: | 2248 case PlatformEvent::GestureFlingStart: |
2249 // Handle directly in main frame | 2249 // Handle directly in main frame |
2250 break; | 2250 break; |
2251 | 2251 |
2252 case PlatformEvent::GestureTap: | 2252 case PlatformEvent::GestureTap: |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 scrollbar = result.scrollbar(); | 2321 scrollbar = result.scrollbar(); |
2322 } | 2322 } |
2323 | 2323 |
2324 if (scrollbar) { | 2324 if (scrollbar) { |
2325 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); | 2325 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); |
2326 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow
ed) { | 2326 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow
ed) { |
2327 m_scrollbarHandlingScrollGesture = scrollbar; | 2327 m_scrollbarHandlingScrollGesture = scrollbar; |
2328 } else if (gestureEvent.type() == PlatformEvent::GestureScrollEnd | 2328 } else if (gestureEvent.type() == PlatformEvent::GestureScrollEnd |
2329 || gestureEvent.type() == PlatformEvent::GestureFlingStart | 2329 || gestureEvent.type() == PlatformEvent::GestureFlingStart |
2330 || !eventSwallowed) { | 2330 || !eventSwallowed) { |
2331 m_scrollbarHandlingScrollGesture = 0; | 2331 m_scrollbarHandlingScrollGesture = nullptr; |
2332 } | 2332 } |
2333 | 2333 |
2334 if (eventSwallowed) | 2334 if (eventSwallowed) |
2335 return true; | 2335 return true; |
2336 } | 2336 } |
2337 | 2337 |
2338 if (eventTarget) { | 2338 if (eventTarget) { |
2339 bool eventSwallowed = false; | 2339 bool eventSwallowed = false; |
2340 if (handleScrollGestureOnResizer(eventTarget, gestureEvent)) | 2340 if (handleScrollGestureOnResizer(eventTarget, gestureEvent)) |
2341 eventSwallowed = true; | 2341 eventSwallowed = true; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MousePressed, 1, | 2428 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MousePressed, 1, |
2429 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey
(), gestureEvent.metaKey(), WTF::currentTime()); | 2429 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey
(), gestureEvent.metaKey(), WTF::currentTime()); |
2430 m_mouseDown = mouseDownEvent; | 2430 m_mouseDown = mouseDownEvent; |
2431 | 2431 |
2432 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MouseMoved, 1, | 2432 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MouseMoved, 1, |
2433 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey
(), gestureEvent.metaKey(), WTF::currentTime()); | 2433 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey
(), gestureEvent.metaKey(), WTF::currentTime()); |
2434 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Confus
ingAndOftenMisusedDisallowShadowContent); | 2434 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Confus
ingAndOftenMisusedDisallowShadowContent); |
2435 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE
vent); | 2435 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE
vent); |
2436 m_didStartDrag = false; | 2436 m_didStartDrag = false; |
2437 m_mouseDownMayStartDrag = true; | 2437 m_mouseDownMayStartDrag = true; |
2438 dragState().m_dragSrc = 0; | 2438 dragState().m_dragSrc = nullptr; |
2439 m_mouseDownPos = m_frame->view()->windowToContents(mouseDragEvent.positi
on()); | 2439 m_mouseDownPos = m_frame->view()->windowToContents(mouseDragEvent.positi
on()); |
2440 RefPtr<FrameView> protector(m_frame->view()); | 2440 RefPtr<FrameView> protector(m_frame->view()); |
2441 handleDrag(mev, DontCheckDragHysteresis); | 2441 handleDrag(mev, DontCheckDragHysteresis); |
2442 if (m_didStartDrag) { | 2442 if (m_didStartDrag) { |
2443 m_longTapShouldInvokeContextMenu = true; | 2443 m_longTapShouldInvokeContextMenu = true; |
2444 return true; | 2444 return true; |
2445 } | 2445 } |
2446 } | 2446 } |
2447 #if OS(ANDROID) | 2447 #if OS(ANDROID) |
2448 bool shouldLongPressSelectWord = true; | 2448 bool shouldLongPressSelectWord = true; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2549 if (!view) | 2549 if (!view) |
2550 return false; | 2550 return false; |
2551 | 2551 |
2552 LayoutPoint viewPoint = view->windowToContents(gestureEvent.position()); | 2552 LayoutPoint viewPoint = view->windowToContents(gestureEvent.position()); |
2553 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::ConfusingA
ndOftenMisusedDisallowShadowContent); | 2553 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::ConfusingA
ndOftenMisusedDisallowShadowContent); |
2554 HitTestResult result(viewPoint); | 2554 HitTestResult result(viewPoint); |
2555 document->renderView()->hitTest(request, result); | 2555 document->renderView()->hitTest(request, result); |
2556 | 2556 |
2557 m_lastHitTestResultOverWidget = result.isOverWidget(); | 2557 m_lastHitTestResultOverWidget = result.isOverWidget(); |
2558 m_scrollGestureHandlingNode = result.innerNode(); | 2558 m_scrollGestureHandlingNode = result.innerNode(); |
2559 m_previousGestureScrolledNode = 0; | 2559 m_previousGestureScrolledNode = nullptr; |
2560 | 2560 |
2561 // If there's no renderer on the node, send the event to the nearest ancesto
r with a renderer. | 2561 // If there's no renderer on the node, send the event to the nearest ancesto
r with a renderer. |
2562 // Needed for <option> and <optgroup> elements so we can touch scroll <selec
t>s | 2562 // Needed for <option> and <optgroup> elements so we can touch scroll <selec
t>s |
2563 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->renderer
()) | 2563 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->renderer
()) |
2564 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado
wHostNode(); | 2564 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado
wHostNode(); |
2565 | 2565 |
2566 if (!m_scrollGestureHandlingNode) | 2566 if (!m_scrollGestureHandlingNode) |
2567 return false; | 2567 return false; |
2568 | 2568 |
2569 passGestureEventToWidgetIfPossible(gestureEvent, m_scrollGestureHandlingNode
->renderer()); | 2569 passGestureEventToWidgetIfPossible(gestureEvent, m_scrollGestureHandlingNode
->renderer()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2649 { | 2649 { |
2650 PlatformMouseEvent mouseDown(touchAdjustedPoint, gestureEvent.globalPosition
(), LeftButton, PlatformEvent::MousePressed, 1, | 2650 PlatformMouseEvent mouseDown(touchAdjustedPoint, gestureEvent.globalPosition
(), LeftButton, PlatformEvent::MousePressed, 1, |
2651 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(),
gestureEvent.metaKey(), gestureEvent.timestamp()); | 2651 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(),
gestureEvent.metaKey(), gestureEvent.timestamp()); |
2652 HitTestRequest request(HitTestRequest::ReadOnly); | 2652 HitTestRequest request(HitTestRequest::ReadOnly); |
2653 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown); | 2653 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown); |
2654 return subframeForHitTestResult(mev); | 2654 return subframeForHitTestResult(mev); |
2655 } | 2655 } |
2656 | 2656 |
2657 void EventHandler::clearGestureScrollNodes() | 2657 void EventHandler::clearGestureScrollNodes() |
2658 { | 2658 { |
2659 m_scrollGestureHandlingNode = 0; | 2659 m_scrollGestureHandlingNode = nullptr; |
2660 m_previousGestureScrolledNode = 0; | 2660 m_previousGestureScrolledNode = nullptr; |
2661 } | 2661 } |
2662 | 2662 |
2663 bool EventHandler::isScrollbarHandlingGestures() const | 2663 bool EventHandler::isScrollbarHandlingGestures() const |
2664 { | 2664 { |
2665 return m_scrollbarHandlingScrollGesture.get(); | 2665 return m_scrollbarHandlingScrollGesture.get(); |
2666 } | 2666 } |
2667 | 2667 |
2668 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const | 2668 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const |
2669 { | 2669 { |
2670 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) | 2670 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2999 m_activeIntervalTimer.stop(); | 2999 m_activeIntervalTimer.stop(); |
3000 | 3000 |
3001 if (m_frame | 3001 if (m_frame |
3002 && m_frame->document() | 3002 && m_frame->document() |
3003 && m_lastDeferredTapElement) { | 3003 && m_lastDeferredTapElement) { |
3004 // FIXME: Enable condition when http://crbug.com/226842 lands | 3004 // FIXME: Enable condition when http://crbug.com/226842 lands |
3005 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement(
) | 3005 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement(
) |
3006 HitTestRequest request(HitTestRequest::TouchEvent | HitTestRequest::Rele
ase); | 3006 HitTestRequest request(HitTestRequest::TouchEvent | HitTestRequest::Rele
ase); |
3007 m_frame->document()->updateHoverActiveState(request, m_lastDeferredTapEl
ement.get()); | 3007 m_frame->document()->updateHoverActiveState(request, m_lastDeferredTapEl
ement.get()); |
3008 } | 3008 } |
3009 m_lastDeferredTapElement = 0; | 3009 m_lastDeferredTapElement = nullptr; |
3010 } | 3010 } |
3011 | 3011 |
3012 void EventHandler::notifyElementActivated() | 3012 void EventHandler::notifyElementActivated() |
3013 { | 3013 { |
3014 // Since another element has been set to active, stop current timer and clea
r reference. | 3014 // Since another element has been set to active, stop current timer and clea
r reference. |
3015 if (m_activeIntervalTimer.isActive()) | 3015 if (m_activeIntervalTimer.isActive()) |
3016 m_activeIntervalTimer.stop(); | 3016 m_activeIntervalTimer.stop(); |
3017 m_lastDeferredTapElement = 0; | 3017 m_lastDeferredTapElement = nullptr; |
3018 } | 3018 } |
3019 | 3019 |
3020 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) | 3020 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) |
3021 { | 3021 { |
3022 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. | 3022 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. |
3023 // IE matches lower and upper case access keys regardless of Shift key state
- but if both upper and | 3023 // IE matches lower and upper case access keys regardless of Shift key state
- but if both upper and |
3024 // lower case variants are present in a document, the correct element is mat
ched based on Shift key state. | 3024 // lower case variants are present in a document, the correct element is mat
ched based on Shift key state. |
3025 // Firefox only matches an access key if Shift is not pressed, and does that
case-insensitively. | 3025 // Firefox only matches an access key if Shift is not pressed, and does that
case-insensitively. |
3026 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); | 3026 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); |
3027 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) | 3027 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3232 // Send a hit test request so that RenderLayer gets a chance to update the :
hover and :active pseudoclasses. | 3232 // Send a hit test request so that RenderLayer gets a chance to update the :
hover and :active pseudoclasses. |
3233 HitTestRequest request(HitTestRequest::Release | HitTestRequest::ConfusingAn
dOftenMisusedDisallowShadowContent); | 3233 HitTestRequest request(HitTestRequest::Release | HitTestRequest::ConfusingAn
dOftenMisusedDisallowShadowContent); |
3234 prepareMouseEvent(request, event); | 3234 prepareMouseEvent(request, event); |
3235 | 3235 |
3236 if (dragState().m_dragSrc) { | 3236 if (dragState().m_dragSrc) { |
3237 dragState().m_dragClipboard->setDestinationOperation(operation); | 3237 dragState().m_dragClipboard->setDestinationOperation(operation); |
3238 // for now we don't care if event handler cancels default behavior, sinc
e there is none | 3238 // for now we don't care if event handler cancels default behavior, sinc
e there is none |
3239 dispatchDragSrcEvent(EventTypeNames::dragend, event); | 3239 dispatchDragSrcEvent(EventTypeNames::dragend, event); |
3240 } | 3240 } |
3241 freeClipboard(); | 3241 freeClipboard(); |
3242 dragState().m_dragSrc = 0; | 3242 dragState().m_dragSrc = nullptr; |
3243 // In case the drag was ended due to an escape key press we need to ensure | 3243 // In case the drag was ended due to an escape key press we need to ensure |
3244 // that consecutive mousemove events don't reinitiate the drag and drop. | 3244 // that consecutive mousemove events don't reinitiate the drag and drop. |
3245 m_mouseDownMayStartDrag = false; | 3245 m_mouseDownMayStartDrag = false; |
3246 } | 3246 } |
3247 | 3247 |
3248 void EventHandler::updateDragStateAfterEditDragIfNeeded(Element* rootEditableEle
ment) | 3248 void EventHandler::updateDragStateAfterEditDragIfNeeded(Element* rootEditableEle
ment) |
3249 { | 3249 { |
3250 // If inserting the dragged contents removed the drag source, we still want
to fire dragend at the root editble element. | 3250 // If inserting the dragged contents removed the drag source, we still want
to fire dragend at the root editble element. |
3251 if (dragState().m_dragSrc && !dragState().m_dragSrc->inDocument()) | 3251 if (dragState().m_dragSrc && !dragState().m_dragSrc->inDocument()) |
3252 dragState().m_dragSrc = rootEditableElement; | 3252 dragState().m_dragSrc = rootEditableElement; |
(...skipping 28 matching lines...) Expand all Loading... |
3281 HitTestRequest request(HitTestRequest::ReadOnly); | 3281 HitTestRequest request(HitTestRequest::ReadOnly); |
3282 HitTestResult result(m_mouseDownPos); | 3282 HitTestResult result(m_mouseDownPos); |
3283 m_frame->contentRenderer()->hitTest(request, result); | 3283 m_frame->contentRenderer()->hitTest(request, result); |
3284 Node* node = result.innerNode(); | 3284 Node* node = result.innerNode(); |
3285 if (node) { | 3285 if (node) { |
3286 DragController::SelectionDragPolicy selectionDragPolicy = event.even
t().timestamp() - m_mouseDownTimestamp < TextDragDelay | 3286 DragController::SelectionDragPolicy selectionDragPolicy = event.even
t().timestamp() - m_mouseDownTimestamp < TextDragDelay |
3287 ? DragController::DelayedSelectionDragResolution | 3287 ? DragController::DelayedSelectionDragResolution |
3288 : DragController::ImmediateSelectionDragResolution; | 3288 : DragController::ImmediateSelectionDragResolution; |
3289 dragState().m_dragSrc = m_frame->page()->dragController().draggableN
ode(m_frame, node, m_mouseDownPos, selectionDragPolicy, dragState().m_dragType); | 3289 dragState().m_dragSrc = m_frame->page()->dragController().draggableN
ode(m_frame, node, m_mouseDownPos, selectionDragPolicy, dragState().m_dragType); |
3290 } else { | 3290 } else { |
3291 dragState().m_dragSrc = 0; | 3291 dragState().m_dragSrc = nullptr; |
3292 } | 3292 } |
3293 | 3293 |
3294 if (!dragState().m_dragSrc) | 3294 if (!dragState().m_dragSrc) |
3295 m_mouseDownMayStartDrag = false; // no element is draggable | 3295 m_mouseDownMayStartDrag = false; // no element is draggable |
3296 } | 3296 } |
3297 | 3297 |
3298 if (!m_mouseDownMayStartDrag) | 3298 if (!m_mouseDownMayStartDrag) |
3299 return !mouseDownMayStartSelect() && !m_mouseDownMayStartAutoscroll; | 3299 return !mouseDownMayStartSelect() && !m_mouseDownMayStartAutoscroll; |
3300 | 3300 |
3301 // We are starting a text/image/url drag, so the cursor should be an arrow | 3301 // We are starting a text/image/url drag, so the cursor should be an arrow |
3302 // FIXME <rdar://7577595>: Custom cursors aren't supported during drag and d
rop (default to pointer). | 3302 // FIXME <rdar://7577595>: Custom cursors aren't supported during drag and d
rop (default to pointer). |
3303 m_frame->view()->setCursor(pointerCursor()); | 3303 m_frame->view()->setCursor(pointerCursor()); |
3304 | 3304 |
3305 if (checkDragHysteresis == ShouldCheckDragHysteresis && !dragHysteresisExcee
ded(event.event().position())) | 3305 if (checkDragHysteresis == ShouldCheckDragHysteresis && !dragHysteresisExcee
ded(event.event().position())) |
3306 return true; | 3306 return true; |
3307 | 3307 |
3308 // Once we're past the hysteresis point, we don't want to treat this gesture
as a click | 3308 // Once we're past the hysteresis point, we don't want to treat this gesture
as a click |
3309 invalidateClick(); | 3309 invalidateClick(); |
3310 | 3310 |
3311 if (!tryStartDrag(event)) { | 3311 if (!tryStartDrag(event)) { |
3312 // Something failed to start the drag, clean up. | 3312 // Something failed to start the drag, clean up. |
3313 freeClipboard(); | 3313 freeClipboard(); |
3314 dragState().m_dragSrc = 0; | 3314 dragState().m_dragSrc = nullptr; |
3315 } | 3315 } |
3316 | 3316 |
3317 m_mouseDownMayStartDrag = false; | 3317 m_mouseDownMayStartDrag = false; |
3318 // Whether or not the drag actually started, no more default handling (like
selection). | 3318 // Whether or not the drag actually started, no more default handling (like
selection). |
3319 return true; | 3319 return true; |
3320 } | 3320 } |
3321 | 3321 |
3322 bool EventHandler::tryStartDrag(const MouseEventWithHitTestResults& event) | 3322 bool EventHandler::tryStartDrag(const MouseEventWithHitTestResults& event) |
3323 { | 3323 { |
3324 freeClipboard(); // would only happen if we missed a dragEnd. Do it anyway,
just | 3324 freeClipboard(); // would only happen if we missed a dragEnd. Do it anyway,
just |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4009 unsigned EventHandler::accessKeyModifiers() | 4009 unsigned EventHandler::accessKeyModifiers() |
4010 { | 4010 { |
4011 #if OS(MACOSX) | 4011 #if OS(MACOSX) |
4012 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4012 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
4013 #else | 4013 #else |
4014 return PlatformEvent::AltKey; | 4014 return PlatformEvent::AltKey; |
4015 #endif | 4015 #endif |
4016 } | 4016 } |
4017 | 4017 |
4018 } // namespace WebCore | 4018 } // namespace WebCore |
OLD | NEW |