| 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 Node* innerNode = event.innerNode(); | 508 Node* innerNode = event.innerNode(); |
| 509 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) | 509 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) |
| 510 return false; | 510 return false; |
| 511 | 511 |
| 512 // Extend the selection if the Shift key is down, unless the click is in a l
ink. | 512 // Extend the selection if the Shift key is down, unless the click is in a l
ink. |
| 513 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); | 513 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); |
| 514 | 514 |
| 515 // Don't restart the selection when the mouse is pressed on an | 515 // Don't restart the selection when the mouse is pressed on an |
| 516 // existing selection so we can allow for text dragging. | 516 // existing selection so we can allow for text dragging. |
| 517 if (FrameView* view = m_frame->view()) { | 517 if (FrameView* view = m_frame->view()) { |
| 518 LayoutPoint vPoint = view->windowToContents(event.event().position()); | 518 LayoutPoint vPoint = view->rootFrameToContents(event.event().position())
; |
| 519 if (!extendSelection && m_frame->selection().contains(vPoint)) { | 519 if (!extendSelection && m_frame->selection().contains(vPoint)) { |
| 520 m_mouseDownWasSingleClickInSelection = true; | 520 m_mouseDownWasSingleClickInSelection = true; |
| 521 return false; | 521 return false; |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 | 524 |
| 525 VisiblePosition visiblePos(innerNode->layoutObject()->positionForPoint(event
.localPoint())); | 525 VisiblePosition visiblePos(innerNode->layoutObject()->positionForPoint(event
.localPoint())); |
| 526 if (visiblePos.isNull()) | 526 if (visiblePos.isNull()) |
| 527 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW
NSTREAM); | 527 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW
NSTREAM); |
| 528 Position pos = visiblePos.deepEquivalent(); | 528 Position pos = visiblePos.deepEquivalent(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 | 603 |
| 604 m_mouseDownMayStartDrag = singleClick; | 604 m_mouseDownMayStartDrag = singleClick; |
| 605 | 605 |
| 606 m_mouseDownWasSingleClickInSelection = false; | 606 m_mouseDownWasSingleClickInSelection = false; |
| 607 | 607 |
| 608 m_mouseDown = event.event(); | 608 m_mouseDown = event.event(); |
| 609 | 609 |
| 610 if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGEx
tensions().zoomAndPanEnabled()) { | 610 if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGEx
tensions().zoomAndPanEnabled()) { |
| 611 if (event.event().shiftKey() && singleClick) { | 611 if (event.event().shiftKey() && singleClick) { |
| 612 m_svgPan = true; | 612 m_svgPan = true; |
| 613 m_frame->document()->accessSVGExtensions().startPan(m_frame->view()-
>windowToContents(event.event().position())); | 613 m_frame->document()->accessSVGExtensions().startPan(m_frame->view()-
>rootFrameToContents(event.event().position())); |
| 614 return true; | 614 return true; |
| 615 } | 615 } |
| 616 } | 616 } |
| 617 | 617 |
| 618 // We don't do this at the start of mouse down handling, | 618 // We don't do this at the start of mouse down handling, |
| 619 // because we don't want to do it until we know we didn't hit a widget. | 619 // because we don't want to do it until we know we didn't hit a widget. |
| 620 if (singleClick) | 620 if (singleClick) |
| 621 focusDocumentView(); | 621 focusDocumentView(); |
| 622 | 622 |
| 623 Node* innerNode = event.innerNode(); | 623 Node* innerNode = event.innerNode(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 void EventHandler::updateSelectionForMouseDrag() | 707 void EventHandler::updateSelectionForMouseDrag() |
| 708 { | 708 { |
| 709 FrameView* view = m_frame->view(); | 709 FrameView* view = m_frame->view(); |
| 710 if (!view) | 710 if (!view) |
| 711 return; | 711 return; |
| 712 LayoutView* renderer = m_frame->contentRenderer(); | 712 LayoutView* renderer = m_frame->contentRenderer(); |
| 713 if (!renderer) | 713 if (!renderer) |
| 714 return; | 714 return; |
| 715 | 715 |
| 716 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move); | 716 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move); |
| 717 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); | 717 HitTestResult result(view->rootFrameToContents(m_lastKnownMousePosition)); |
| 718 renderer->hitTest(request, result); | 718 renderer->hitTest(request, result); |
| 719 updateSelectionForMouseDrag(result); | 719 updateSelectionForMouseDrag(result); |
| 720 } | 720 } |
| 721 | 721 |
| 722 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) | 722 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) |
| 723 { | 723 { |
| 724 if (!m_mouseDownMayStartSelect) | 724 if (!m_mouseDownMayStartSelect) |
| 725 return; | 725 return; |
| 726 | 726 |
| 727 Node* target = hitTestResult.innerNode(); | 727 Node* target = hitTestResult.innerNode(); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 if (!view || !view->shouldSetCursor()) | 1021 if (!view || !view->shouldSetCursor()) |
| 1022 return; | 1022 return; |
| 1023 | 1023 |
| 1024 LayoutView* layoutView = view->layoutView(); | 1024 LayoutView* layoutView = view->layoutView(); |
| 1025 if (!layoutView) | 1025 if (!layoutView) |
| 1026 return; | 1026 return; |
| 1027 | 1027 |
| 1028 m_frame->document()->updateLayout(); | 1028 m_frame->document()->updateLayout(); |
| 1029 | 1029 |
| 1030 HitTestRequest request(HitTestRequest::ReadOnly); | 1030 HitTestRequest request(HitTestRequest::ReadOnly); |
| 1031 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); | 1031 HitTestResult result(view->rootFrameToContents(m_lastKnownMousePosition)); |
| 1032 layoutView->hitTest(request, result); | 1032 layoutView->hitTest(request, result); |
| 1033 | 1033 |
| 1034 OptionalCursor optionalCursor = selectCursor(result); | 1034 OptionalCursor optionalCursor = selectCursor(result); |
| 1035 if (optionalCursor.isCursorChange()) { | 1035 if (optionalCursor.isCursorChange()) { |
| 1036 m_currentMouseCursor = optionalCursor.cursor(); | 1036 m_currentMouseCursor = optionalCursor.cursor(); |
| 1037 view->setCursor(m_currentMouseCursor); | 1037 view->setCursor(m_currentMouseCursor); |
| 1038 } | 1038 } |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) | 1041 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 && m_frame->selection().isCaretOrRange() | 1202 && m_frame->selection().isCaretOrRange() |
| 1203 && !m_capturingMouseEventsNode) { | 1203 && !m_capturingMouseEventsNode) { |
| 1204 return iBeam; | 1204 return iBeam; |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 if ((editable || (renderer && renderer->isText() && node->canStartSelection(
))) && !inResizer && !result.scrollbar()) | 1207 if ((editable || (renderer && renderer->isText() && node->canStartSelection(
))) && !inResizer && !result.scrollbar()) |
| 1208 return iBeam; | 1208 return iBeam; |
| 1209 return pointerCursor(); | 1209 return pointerCursor(); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 static LayoutPoint documentPointForWindowPoint(LocalFrame* frame, const IntPoint
& windowPoint) | 1212 static LayoutPoint contentPointFromRootFrame(LocalFrame* frame, const IntPoint&
pointInRootFrame) |
| 1213 { | 1213 { |
| 1214 FrameView* view = frame->view(); | 1214 FrameView* view = frame->view(); |
| 1215 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? | 1215 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? |
| 1216 // Historically the code would just crash; this is clearly no worse than tha
t. | 1216 // Historically the code would just crash; this is clearly no worse than tha
t. |
| 1217 return view ? view->windowToContents(windowPoint) : windowPoint; | 1217 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame
; |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) | 1220 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) |
| 1221 { | 1221 { |
| 1222 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 1222 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
| 1223 | 1223 |
| 1224 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 1224 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
| 1225 | 1225 |
| 1226 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 1226 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
| 1227 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken =
gestureIndicator.currentToken(); | 1227 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken =
gestureIndicator.currentToken(); |
| 1228 | 1228 |
| 1229 cancelFakeMouseMoveEvent(); | 1229 cancelFakeMouseMoveEvent(); |
| 1230 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 1230 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
| 1231 m_capturingMouseEventsNode = nullptr; | 1231 m_capturingMouseEventsNode = nullptr; |
| 1232 m_mousePressed = true; | 1232 m_mousePressed = true; |
| 1233 m_capturesDragging = true; | 1233 m_capturesDragging = true; |
| 1234 setLastKnownMousePosition(mouseEvent); | 1234 setLastKnownMousePosition(mouseEvent); |
| 1235 m_mouseDownTimestamp = mouseEvent.timestamp(); | 1235 m_mouseDownTimestamp = mouseEvent.timestamp(); |
| 1236 m_mouseDownMayStartDrag = false; | 1236 m_mouseDownMayStartDrag = false; |
| 1237 m_mouseDownMayStartSelect = false; | 1237 m_mouseDownMayStartSelect = false; |
| 1238 m_mouseDownMayStartAutoscroll = false; | 1238 m_mouseDownMayStartAutoscroll = false; |
| 1239 if (FrameView* view = m_frame->view()) | 1239 if (FrameView* view = m_frame->view()) |
| 1240 m_mouseDownPos = view->windowToContents(mouseEvent.position()); | 1240 m_mouseDownPos = view->rootFrameToContents(mouseEvent.position()); |
| 1241 else { | 1241 else { |
| 1242 invalidateClick(); | 1242 invalidateClick(); |
| 1243 return false; | 1243 return false; |
| 1244 } | 1244 } |
| 1245 | 1245 |
| 1246 HitTestRequest request(HitTestRequest::Active); | 1246 HitTestRequest request(HitTestRequest::Active); |
| 1247 // Save the document point we generate in case the window coordinate is inva
lidated by what happens | 1247 // Save the document point we generate in case the window coordinate is inva
lidated by what happens |
| 1248 // when we dispatch the event. | 1248 // when we dispatch the event. |
| 1249 LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.
position()); | 1249 LayoutPoint documentPoint = contentPointFromRootFrame(m_frame, mouseEvent.po
sition()); |
| 1250 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); | 1250 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); |
| 1251 | 1251 |
| 1252 if (!mev.innerNode()) { | 1252 if (!mev.innerNode()) { |
| 1253 invalidateClick(); | 1253 invalidateClick(); |
| 1254 return false; | 1254 return false; |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 m_mousePressNode = mev.innerNode(); | 1257 m_mousePressNode = mev.innerNode(); |
| 1258 | 1258 |
| 1259 RefPtrWillBeRawPtr<LocalFrame> subframe = subframeForHitTestResult(mev); | 1259 RefPtrWillBeRawPtr<LocalFrame> subframe = subframeForHitTestResult(mev); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1280 invalidateClick(); | 1280 invalidateClick(); |
| 1281 return true; | 1281 return true; |
| 1282 } | 1282 } |
| 1283 #endif | 1283 #endif |
| 1284 | 1284 |
| 1285 m_clickCount = mouseEvent.clickCount(); | 1285 m_clickCount = mouseEvent.clickCount(); |
| 1286 m_clickNode = mev.innerNode()->isTextNode() ? NodeRenderingTraversal::paren
t(*mev.innerNode()) : mev.innerNode(); | 1286 m_clickNode = mev.innerNode()->isTextNode() ? NodeRenderingTraversal::paren
t(*mev.innerNode()) : mev.innerNode(); |
| 1287 | 1287 |
| 1288 if (FrameView* view = m_frame->view()) { | 1288 if (FrameView* view = m_frame->view()) { |
| 1289 DeprecatedPaintLayer* layer = mev.innerNode()->layoutObject() ? mev.inne
rNode()->layoutObject()->enclosingLayer() : nullptr; | 1289 DeprecatedPaintLayer* layer = mev.innerNode()->layoutObject() ? mev.inne
rNode()->layoutObject()->enclosingLayer() : nullptr; |
| 1290 IntPoint p = view->windowToContents(mouseEvent.position()); | 1290 IntPoint p = view->rootFrameToContents(mouseEvent.position()); |
| 1291 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForPointer)) { | 1291 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForPointer)) { |
| 1292 m_resizeScrollableArea = layer->scrollableArea(); | 1292 m_resizeScrollableArea = layer->scrollableArea(); |
| 1293 m_resizeScrollableArea->setInResizeMode(true); | 1293 m_resizeScrollableArea->setInResizeMode(true); |
| 1294 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); | 1294 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); |
| 1295 invalidateClick(); | 1295 invalidateClick(); |
| 1296 return true; | 1296 return true; |
| 1297 } | 1297 } |
| 1298 } | 1298 } |
| 1299 | 1299 |
| 1300 m_frame->selection().setCaretBlinkingSuspended(true); | 1300 m_frame->selection().setCaretBlinkingSuspended(true); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 setLastKnownMousePosition(mouseEvent); | 1403 setLastKnownMousePosition(mouseEvent); |
| 1404 | 1404 |
| 1405 if (m_hoverTimer.isActive()) | 1405 if (m_hoverTimer.isActive()) |
| 1406 m_hoverTimer.stop(); | 1406 m_hoverTimer.stop(); |
| 1407 | 1407 |
| 1408 m_cursorUpdateTimer.stop(); | 1408 m_cursorUpdateTimer.stop(); |
| 1409 | 1409 |
| 1410 cancelFakeMouseMoveEvent(); | 1410 cancelFakeMouseMoveEvent(); |
| 1411 | 1411 |
| 1412 if (m_svgPan) { | 1412 if (m_svgPan) { |
| 1413 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->wi
ndowToContents(m_lastKnownMousePosition)); | 1413 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro
otFrameToContents(m_lastKnownMousePosition)); |
| 1414 return true; | 1414 return true; |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 if (m_frameSetBeingResized) | 1417 if (m_frameSetBeingResized) |
| 1418 return !dispatchMouseEvent(EventTypeNames::mousemove, m_frameSetBeingRes
ized.get(), 0, mouseEvent, false); | 1418 return !dispatchMouseEvent(EventTypeNames::mousemove, m_frameSetBeingRes
ized.get(), 0, mouseEvent, false); |
| 1419 | 1419 |
| 1420 // Send events right to a scrollbar if the mouse is pressed. | 1420 // Send events right to a scrollbar if the mouse is pressed. |
| 1421 if (m_lastScrollbarUnderMouse && m_mousePressed) { | 1421 if (m_lastScrollbarUnderMouse && m_mousePressed) { |
| 1422 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent); | 1422 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent); |
| 1423 return true; | 1423 return true; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 #if OS(WIN) | 1539 #if OS(WIN) |
| 1540 if (Page* page = m_frame->page()) | 1540 if (Page* page = m_frame->page()) |
| 1541 page->autoscrollController().handleMouseReleaseForPanScrolling(m_frame,
mouseEvent); | 1541 page->autoscrollController().handleMouseReleaseForPanScrolling(m_frame,
mouseEvent); |
| 1542 #endif | 1542 #endif |
| 1543 | 1543 |
| 1544 m_mousePressed = false; | 1544 m_mousePressed = false; |
| 1545 setLastKnownMousePosition(mouseEvent); | 1545 setLastKnownMousePosition(mouseEvent); |
| 1546 | 1546 |
| 1547 if (m_svgPan) { | 1547 if (m_svgPan) { |
| 1548 m_svgPan = false; | 1548 m_svgPan = false; |
| 1549 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->wi
ndowToContents(m_lastKnownMousePosition)); | 1549 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro
otFrameToContents(m_lastKnownMousePosition)); |
| 1550 return true; | 1550 return true; |
| 1551 } | 1551 } |
| 1552 | 1552 |
| 1553 if (m_frameSetBeingResized) | 1553 if (m_frameSetBeingResized) |
| 1554 return !dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResiz
ed.get(), m_clickCount, mouseEvent, false); | 1554 return !dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResiz
ed.get(), m_clickCount, mouseEvent, false); |
| 1555 | 1555 |
| 1556 if (m_lastScrollbarUnderMouse) { | 1556 if (m_lastScrollbarUnderMouse) { |
| 1557 invalidateClick(); | 1557 invalidateClick(); |
| 1558 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); | 1558 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); |
| 1559 bool setUnder = false; | 1559 bool setUnder = false; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 { | 1823 { |
| 1824 m_capturingMouseEventsNode = n; | 1824 m_capturingMouseEventsNode = n; |
| 1825 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 1825 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
| 1826 } | 1826 } |
| 1827 | 1827 |
| 1828 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
t& request, const PlatformMouseEvent& mev) | 1828 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
t& request, const PlatformMouseEvent& mev) |
| 1829 { | 1829 { |
| 1830 ASSERT(m_frame); | 1830 ASSERT(m_frame); |
| 1831 ASSERT(m_frame->document()); | 1831 ASSERT(m_frame->document()); |
| 1832 | 1832 |
| 1833 return m_frame->document()->prepareMouseEvent(request, documentPointForWindo
wPoint(m_frame, mev.position()), mev); | 1833 return m_frame->document()->prepareMouseEvent(request, contentPointFromRootF
rame(m_frame, mev.position()), mev); |
| 1834 } | 1834 } |
| 1835 | 1835 |
| 1836 void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
useEvent& mouseEvent, bool fireMouseOverOut) | 1836 void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
useEvent& mouseEvent, bool fireMouseOverOut) |
| 1837 { | 1837 { |
| 1838 Node* result = targetNode; | 1838 Node* result = targetNode; |
| 1839 | 1839 |
| 1840 // If we're capturing, we always go right to that node. | 1840 // If we're capturing, we always go right to that node. |
| 1841 if (m_capturingMouseEventsNode) | 1841 if (m_capturingMouseEventsNode) |
| 1842 result = m_capturingMouseEventsNode.get(); | 1842 result = m_capturingMouseEventsNode.get(); |
| 1843 else { | 1843 else { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent,
eventType, clickCount); | 1901 return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent,
eventType, clickCount); |
| 1902 } | 1902 } |
| 1903 | 1903 |
| 1904 // The return value means 'swallow event' (was handled), as for other handle* fu
nctions. | 1904 // The return value means 'swallow event' (was handled), as for other handle* fu
nctions. |
| 1905 bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted
Event) | 1905 bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted
Event) |
| 1906 { | 1906 { |
| 1907 const PlatformMouseEvent& mouseEvent = targetedEvent.event(); | 1907 const PlatformMouseEvent& mouseEvent = targetedEvent.event(); |
| 1908 | 1908 |
| 1909 // If clicking on a frame scrollbar, do not mess up with content focus. | 1909 // If clicking on a frame scrollbar, do not mess up with content focus. |
| 1910 if (FrameView* view = m_frame->view()) { | 1910 if (FrameView* view = m_frame->view()) { |
| 1911 if (view->scrollbarAtWindowPoint(mouseEvent.position())) | 1911 if (view->scrollbarAtRootFramePoint(mouseEvent.position())) |
| 1912 return false; | 1912 return false; |
| 1913 } | 1913 } |
| 1914 | 1914 |
| 1915 // The layout needs to be up to date to determine if an element is focusable
. | 1915 // The layout needs to be up to date to determine if an element is focusable
. |
| 1916 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1916 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 1917 | 1917 |
| 1918 Element* element = nullptr; | 1918 Element* element = nullptr; |
| 1919 if (m_nodeUnderMouse) | 1919 if (m_nodeUnderMouse) |
| 1920 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse
) : m_nodeUnderMouse->parentOrShadowHostElement(); | 1920 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse
) : m_nodeUnderMouse->parentOrShadowHostElement(); |
| 1921 for (; element; element = element->parentOrShadowHostElement()) { | 1921 for (; element; element = element->parentOrShadowHostElement()) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 | 2001 |
| 2002 if (!doc->layoutView()) | 2002 if (!doc->layoutView()) |
| 2003 return false; | 2003 return false; |
| 2004 | 2004 |
| 2005 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 2005 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
| 2006 | 2006 |
| 2007 FrameView* view = m_frame->view(); | 2007 FrameView* view = m_frame->view(); |
| 2008 if (!view) | 2008 if (!view) |
| 2009 return false; | 2009 return false; |
| 2010 | 2010 |
| 2011 LayoutPoint vPoint = view->windowToContents(event.position()); | 2011 LayoutPoint vPoint = view->rootFrameToContents(event.position()); |
| 2012 | 2012 |
| 2013 HitTestRequest request(HitTestRequest::ReadOnly); | 2013 HitTestRequest request(HitTestRequest::ReadOnly); |
| 2014 HitTestResult result(vPoint); | 2014 HitTestResult result(vPoint); |
| 2015 doc->layoutView()->hitTest(request, result); | 2015 doc->layoutView()->hitTest(request, result); |
| 2016 | 2016 |
| 2017 Node* node = result.innerNode(); | 2017 Node* node = result.innerNode(); |
| 2018 // Wheel events should not dispatch to text nodes. | 2018 // Wheel events should not dispatch to text nodes. |
| 2019 if (node && node->isTextNode()) | 2019 if (node && node->isTextNode()) |
| 2020 node = NodeRenderingTraversal::parent(*node); | 2020 node = NodeRenderingTraversal::parent(*node); |
| 2021 | 2021 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 scrollbar = m_scrollbarHandlingScrollGesture.get(); | 2205 scrollbar = m_scrollbarHandlingScrollGesture.get(); |
| 2206 eventTarget = m_scrollGestureHandlingNode.get(); | 2206 eventTarget = m_scrollGestureHandlingNode.get(); |
| 2207 } | 2207 } |
| 2208 | 2208 |
| 2209 if (!eventTarget) { | 2209 if (!eventTarget) { |
| 2210 Document* document = m_frame->document(); | 2210 Document* document = m_frame->document(); |
| 2211 if (!document->layoutView()) | 2211 if (!document->layoutView()) |
| 2212 return false; | 2212 return false; |
| 2213 | 2213 |
| 2214 FrameView* view = m_frame->view(); | 2214 FrameView* view = m_frame->view(); |
| 2215 LayoutPoint viewPoint = view->windowToContents(gestureEvent.position()); | 2215 LayoutPoint viewPoint = view->rootFrameToContents(gestureEvent.position(
)); |
| 2216 HitTestRequest request(HitTestRequest::ReadOnly); | 2216 HitTestRequest request(HitTestRequest::ReadOnly); |
| 2217 HitTestResult result(viewPoint); | 2217 HitTestResult result(viewPoint); |
| 2218 document->layoutView()->hitTest(request, result); | 2218 document->layoutView()->hitTest(request, result); |
| 2219 | 2219 |
| 2220 eventTarget = result.innerNode(); | 2220 eventTarget = result.innerNode(); |
| 2221 | 2221 |
| 2222 m_lastGestureScrollOverWidget = result.isOverWidget(); | 2222 m_lastGestureScrollOverWidget = result.isOverWidget(); |
| 2223 m_scrollGestureHandlingNode = eventTarget; | 2223 m_scrollGestureHandlingNode = eventTarget; |
| 2224 m_previousGestureScrolledNode = nullptr; | 2224 m_previousGestureScrolledNode = nullptr; |
| 2225 | 2225 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2271 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur
eEvent.type()); | 2271 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur
eEvent.type()); |
| 2272 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); | 2272 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); |
| 2273 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); | 2273 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); |
| 2274 | 2274 |
| 2275 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 2275 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
| 2276 | 2276 |
| 2277 HitTestResult currentHitTest = targetedEvent.hitTestResult(); | 2277 HitTestResult currentHitTest = targetedEvent.hitTestResult(); |
| 2278 | 2278 |
| 2279 // We use the adjusted position so the application isn't surprised to see a
event with | 2279 // We use the adjusted position so the application isn't surprised to see a
event with |
| 2280 // co-ordinates outside the target's bounds. | 2280 // co-ordinates outside the target's bounds. |
| 2281 IntPoint adjustedPoint = frameView->windowToContents(gestureEvent.position()
); | 2281 IntPoint adjustedPoint = frameView->rootFrameToContents(gestureEvent.positio
n()); |
| 2282 | 2282 |
| 2283 unsigned modifiers = gestureEvent.modifiers(); | 2283 unsigned modifiers = gestureEvent.modifiers(); |
| 2284 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa
lPosition(), | 2284 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa
lPosition(), |
| 2285 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | 2285 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, |
| 2286 static_cast<PlatformEvent::Modifiers>(modifiers), | 2286 static_cast<PlatformEvent::Modifiers>(modifiers), |
| 2287 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2287 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
| 2288 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0,
fakeMouseMove, true); | 2288 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0,
fakeMouseMove, true); |
| 2289 | 2289 |
| 2290 // Do a new hit-test in case the mousemove event changed the DOM. | 2290 // Do a new hit-test in case the mousemove event changed the DOM. |
| 2291 // Note that if the original hit test wasn't over an element (eg. was over a
scrollbar) we | 2291 // Note that if the original hit test wasn't over an element (eg. was over a
scrollbar) we |
| 2292 // don't want to re-hit-test because it may be in the wrong frame (and there
's no way the page | 2292 // don't want to re-hit-test because it may be in the wrong frame (and there
's no way the page |
| 2293 // could have seen the event anyway). | 2293 // could have seen the event anyway). |
| 2294 // Also note that the position of the frame may have changed, so we need to
recompute the content | 2294 // Also note that the position of the frame may have changed, so we need to
recompute the content |
| 2295 // co-ordinates (updating layout/style as hitTestResultAtPoint normally woul
d). | 2295 // co-ordinates (updating layout/style as hitTestResultAtPoint normally woul
d). |
| 2296 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 | 2296 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 |
| 2297 if (currentHitTest.innerNode()) { | 2297 if (currentHitTest.innerNode()) { |
| 2298 LocalFrame* mainFrame = m_frame->localFrameRoot(); | 2298 LocalFrame* mainFrame = m_frame->localFrameRoot(); |
| 2299 if (mainFrame && mainFrame->view()) | 2299 if (mainFrame && mainFrame->view()) |
| 2300 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); | 2300 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); |
| 2301 adjustedPoint = frameView->windowToContents(gestureEvent.position()); | 2301 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); |
| 2302 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); | 2302 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); |
| 2303 } | 2303 } |
| 2304 m_clickNode = currentHitTest.innerNode(); | 2304 m_clickNode = currentHitTest.innerNode(); |
| 2305 | 2305 |
| 2306 // Capture data for showUnhandledTapUIIfNeeded. | 2306 // Capture data for showUnhandledTapUIIfNeeded. |
| 2307 RefPtrWillBeRawPtr<Node> tappedNode = m_clickNode; | 2307 RefPtrWillBeRawPtr<Node> tappedNode = m_clickNode; |
| 2308 IntPoint tappedPosition = gestureEvent.position(); | 2308 IntPoint tappedPosition = gestureEvent.position(); |
| 2309 | 2309 |
| 2310 if (m_clickNode && m_clickNode->isTextNode()) | 2310 if (m_clickNode && m_clickNode->isTextNode()) |
| 2311 m_clickNode = NodeRenderingTraversal::parent(*m_clickNode); | 2311 m_clickNode = NodeRenderingTraversal::parent(*m_clickNode); |
| 2312 | 2312 |
| 2313 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa
lPosition(), | 2313 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa
lPosition(), |
| 2314 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), | 2314 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), |
| 2315 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut
tonDown), | 2315 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut
tonDown), |
| 2316 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2316 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
| 2317 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown,
currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true); | 2317 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown,
currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true); |
| 2318 if (!swallowMouseDownEvent) | 2318 if (!swallowMouseDownEvent) |
| 2319 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa
keMouseDown, currentHitTest)); | 2319 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa
keMouseDown, currentHitTest)); |
| 2320 if (!swallowMouseDownEvent) | 2320 if (!swallowMouseDownEvent) |
| 2321 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul
ts(fakeMouseDown, currentHitTest)); | 2321 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul
ts(fakeMouseDown, currentHitTest)); |
| 2322 | 2322 |
| 2323 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 | 2323 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 |
| 2324 if (currentHitTest.innerNode()) { | 2324 if (currentHitTest.innerNode()) { |
| 2325 LocalFrame* mainFrame = m_frame->localFrameRoot(); | 2325 LocalFrame* mainFrame = m_frame->localFrameRoot(); |
| 2326 if (mainFrame && mainFrame->view()) | 2326 if (mainFrame && mainFrame->view()) |
| 2327 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); | 2327 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); |
| 2328 adjustedPoint = frameView->windowToContents(gestureEvent.position()); | 2328 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); |
| 2329 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); | 2329 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); |
| 2330 } | 2330 } |
| 2331 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP
osition(), | 2331 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP
osition(), |
| 2332 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), | 2332 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), |
| 2333 static_cast<PlatformEvent::Modifiers>(modifiers), | 2333 static_cast<PlatformEvent::Modifiers>(modifiers), |
| 2334 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2334 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
| 2335 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, curr
entHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp, false); | 2335 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, curr
entHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp, false); |
| 2336 | 2336 |
| 2337 bool swallowClickEvent = false; | 2337 bool swallowClickEvent = false; |
| 2338 if (m_clickNode) { | 2338 if (m_clickNode) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2350 } | 2350 } |
| 2351 | 2351 |
| 2352 if (!swallowMouseUpEvent) | 2352 if (!swallowMouseUpEvent) |
| 2353 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul
ts(fakeMouseUp, currentHitTest)); | 2353 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul
ts(fakeMouseUp, currentHitTest)); |
| 2354 | 2354 |
| 2355 bool swallowed = swallowMouseDownEvent | swallowMouseUpEvent | swallowClickE
vent; | 2355 bool swallowed = swallowMouseDownEvent | swallowMouseUpEvent | swallowClickE
vent; |
| 2356 if (!swallowed && tappedNode && m_frame->page()) { | 2356 if (!swallowed && tappedNode && m_frame->page()) { |
| 2357 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()->
domTreeVersion(); | 2357 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()->
domTreeVersion(); |
| 2358 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl
eVersion(); | 2358 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl
eVersion(); |
| 2359 | 2359 |
| 2360 // FIXME: This will be replaced with a standard conversion method once c
rbug.com/371902 lands. | 2360 IntPoint tappedPositionInViewport = m_frame->page()->frameHost().pinchVi
ewport().rootFrameToViewport(tappedPosition); |
| 2361 PinchViewport& pinchViewport = m_frame->page()->frameHost().pinchViewpor
t(); | |
| 2362 IntPoint tappedPositionInViewport = tappedPosition; | |
| 2363 tappedPositionInViewport.moveBy(-flooredIntPoint(pinchViewport.location(
))); | |
| 2364 tappedPositionInViewport.scale(pinchViewport.scale(), pinchViewport.scal
e()); | |
| 2365 | |
| 2366 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp
ort, tappedNode.get(), domTreeChanged || styleChanged); | 2361 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp
ort, tappedNode.get(), domTreeChanged || styleChanged); |
| 2367 } | 2362 } |
| 2368 return swallowed; | 2363 return swallowed; |
| 2369 } | 2364 } |
| 2370 | 2365 |
| 2371 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
targetedEvent) | 2366 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
targetedEvent) |
| 2372 { | 2367 { |
| 2373 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2368 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
| 2374 IntPoint adjustedPoint = gestureEvent.position(); | 2369 IntPoint adjustedPoint = gestureEvent.position(); |
| 2375 | 2370 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2386 PlatformMouseEvent::FromTouch, WTF::currentTime()); | 2381 PlatformMouseEvent::FromTouch, WTF::currentTime()); |
| 2387 m_mouseDown = mouseDownEvent; | 2382 m_mouseDown = mouseDownEvent; |
| 2388 | 2383 |
| 2389 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MouseMoved, 1, | 2384 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MouseMoved, 1, |
| 2390 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef
tButtonDown), | 2385 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef
tButtonDown), |
| 2391 PlatformMouseEvent::FromTouch, WTF::currentTime()); | 2386 PlatformMouseEvent::FromTouch, WTF::currentTime()); |
| 2392 HitTestRequest request(HitTestRequest::ReadOnly); | 2387 HitTestRequest request(HitTestRequest::ReadOnly); |
| 2393 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE
vent); | 2388 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE
vent); |
| 2394 m_mouseDownMayStartDrag = true; | 2389 m_mouseDownMayStartDrag = true; |
| 2395 dragState().m_dragSrc = nullptr; | 2390 dragState().m_dragSrc = nullptr; |
| 2396 m_mouseDownPos = m_frame->view()->windowToContents(mouseDragEvent.positi
on()); | 2391 m_mouseDownPos = m_frame->view()->rootFrameToContents(mouseDragEvent.pos
ition()); |
| 2397 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 2392 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
| 2398 if (handleDrag(mev, DragInitiator::Touch)) { | 2393 if (handleDrag(mev, DragInitiator::Touch)) { |
| 2399 m_longTapShouldInvokeContextMenu = true; | 2394 m_longTapShouldInvokeContextMenu = true; |
| 2400 return true; | 2395 return true; |
| 2401 } | 2396 } |
| 2402 } | 2397 } |
| 2403 #if OS(ANDROID) | 2398 #if OS(ANDROID) |
| 2404 bool shouldLongPressSelectWord = true; | 2399 bool shouldLongPressSelectWord = true; |
| 2405 #else | 2400 #else |
| 2406 bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()-
>touchEditingEnabled(); | 2401 bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()-
>touchEditingEnabled(); |
| 2407 #endif | 2402 #endif |
| 2408 if (shouldLongPressSelectWord) { | 2403 if (shouldLongPressSelectWord) { |
| 2409 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.p
osition()); | 2404 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEven
t.position()); |
| 2410 HitTestResult result = hitTestResultAtPoint(hitTestPoint); | 2405 HitTestResult result = hitTestResultAtPoint(hitTestPoint); |
| 2411 Node* innerNode = result.innerNode(); | 2406 Node* innerNode = result.innerNode(); |
| 2412 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable()
|| innerNode->isTextNode() | 2407 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable()
|| innerNode->isTextNode() |
| 2413 #if OS(ANDROID) | 2408 #if OS(ANDROID) |
| 2414 || innerNode->canStartSelection() | 2409 || innerNode->canStartSelection() |
| 2415 #endif | 2410 #endif |
| 2416 )) { | 2411 )) { |
| 2417 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitesp
ace); | 2412 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitesp
ace); |
| 2418 if (m_frame->selection().isRange()) { | 2413 if (m_frame->selection().isRange()) { |
| 2419 focusDocumentView(); | 2414 focusDocumentView(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2431 m_longTapShouldInvokeContextMenu = false; | 2426 m_longTapShouldInvokeContextMenu = false; |
| 2432 return sendContextMenuEventForGesture(targetedEvent); | 2427 return sendContextMenuEventForGesture(targetedEvent); |
| 2433 } | 2428 } |
| 2434 #endif | 2429 #endif |
| 2435 return false; | 2430 return false; |
| 2436 } | 2431 } |
| 2437 | 2432 |
| 2438 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor
mGestureEvent& gestureEvent) { | 2433 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor
mGestureEvent& gestureEvent) { |
| 2439 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { | 2434 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { |
| 2440 DeprecatedPaintLayer* layer = eventTarget->layoutObject() ? eventTarget-
>layoutObject()->enclosingLayer() : nullptr; | 2435 DeprecatedPaintLayer* layer = eventTarget->layoutObject() ? eventTarget-
>layoutObject()->enclosingLayer() : nullptr; |
| 2441 IntPoint p = m_frame->view()->windowToContents(gestureEvent.position()); | 2436 IntPoint p = m_frame->view()->rootFrameToContents(gestureEvent.position(
)); |
| 2442 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForTouch)) { | 2437 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForTouch)) { |
| 2443 m_resizeScrollableArea = layer->scrollableArea(); | 2438 m_resizeScrollableArea = layer->scrollableArea(); |
| 2444 m_resizeScrollableArea->setInResizeMode(true); | 2439 m_resizeScrollableArea->setInResizeMode(true); |
| 2445 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); | 2440 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); |
| 2446 return true; | 2441 return true; |
| 2447 } | 2442 } |
| 2448 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) { | 2443 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) { |
| 2449 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | 2444 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { |
| 2450 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne
r); | 2445 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne
r); |
| 2451 return true; | 2446 return true; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 ASSERT(result.isRectBasedTest()); | 2621 ASSERT(result.isRectBasedTest()); |
| 2627 | 2622 |
| 2628 // If the touch is over a scrollbar, don't adjust the touch point since touc
h adjustment only takes into account | 2623 // If the touch is over a scrollbar, don't adjust the touch point since touc
h adjustment only takes into account |
| 2629 // DOM nodes so a touch over a scrollbar will be adjusted towards nearby nod
es. This leads to things like textarea | 2624 // DOM nodes so a touch over a scrollbar will be adjusted towards nearby nod
es. This leads to things like textarea |
| 2630 // scrollbars being untouchable. | 2625 // scrollbars being untouchable. |
| 2631 if (result.scrollbar()) { | 2626 if (result.scrollbar()) { |
| 2632 targetNode = 0; | 2627 targetNode = 0; |
| 2633 return false; | 2628 return false; |
| 2634 } | 2629 } |
| 2635 | 2630 |
| 2636 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint
InMainFrame()); | 2631 IntPoint touchCenter = m_frame->view()->contentsToRootFrame(result.roundedPo
intInMainFrame()); |
| 2637 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation
().boundingBox()); | 2632 IntRect touchRect = m_frame->view()->contentsToRootFrame(result.hitTestLocat
ion().boundingBox()); |
| 2638 | 2633 |
| 2639 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2634 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2640 copyToVector(result.listBasedTestResult(), nodes); | 2635 copyToVector(result.listBasedTestResult(), nodes); |
| 2641 | 2636 |
| 2642 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2637 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
| 2643 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc
hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); | 2638 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc
hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); |
| 2644 } | 2639 } |
| 2645 | 2640 |
| 2646 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu
lt, IntPoint& targetPoint, Node*& targetNode) | 2641 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu
lt, IntPoint& targetPoint, Node*& targetNode) |
| 2647 { | 2642 { |
| 2648 ASSERT(result.isRectBasedTest()); | 2643 ASSERT(result.isRectBasedTest()); |
| 2649 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint
InMainFrame()); | 2644 IntPoint touchCenter = m_frame->view()->contentsToRootFrame(result.roundedPo
intInMainFrame()); |
| 2650 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation
().boundingBox()); | 2645 IntRect touchRect = m_frame->view()->contentsToRootFrame(result.hitTestLocat
ion().boundingBox()); |
| 2651 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2646 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2652 copyToVector(result.listBasedTestResult(), nodes); | 2647 copyToVector(result.listBasedTestResult(), nodes); |
| 2653 | 2648 |
| 2654 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2649 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
| 2655 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to
uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2650 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to
uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
| 2656 } | 2651 } |
| 2657 | 2652 |
| 2658 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co
nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) | 2653 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co
nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) |
| 2659 { | 2654 { |
| 2660 if (touchRadius.isEmpty()) | 2655 if (touchRadius.isEmpty()) |
| 2661 return false; | 2656 return false; |
| 2662 | 2657 |
| 2663 IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); | 2658 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(touchCenter); |
| 2664 | 2659 |
| 2665 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | HitTestRequest::ListBased; | 2660 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | HitTestRequest::ListBased; |
| 2666 HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType, LayoutSiz
e(touchRadius)); | 2661 HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType, LayoutSiz
e(touchRadius)); |
| 2667 | 2662 |
| 2668 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); | 2663 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); |
| 2669 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2664 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2670 copyToVector(result.listBasedTestResult(), nodes); | 2665 copyToVector(result.listBasedTestResult(), nodes); |
| 2671 | 2666 |
| 2672 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2667 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
| 2673 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect,
WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2668 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect,
WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 } | 2705 } |
| 2711 | 2706 |
| 2712 return eventWithHitTestResults; | 2707 return eventWithHitTestResults; |
| 2713 } | 2708 } |
| 2714 | 2709 |
| 2715 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const
PlatformGestureEvent& gestureEvent, HitTestRequest::HitTestRequestType hitType) | 2710 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const
PlatformGestureEvent& gestureEvent, HitTestRequest::HitTestRequestType hitType) |
| 2716 { | 2711 { |
| 2717 // Perform the rect-based hit-test (or point-based if adjustment is disabled
). Note that | 2712 // Perform the rect-based hit-test (or point-based if adjustment is disabled
). Note that |
| 2718 // we don't yet apply hover/active state here because we need to resolve tou
ch adjustment | 2713 // we don't yet apply hover/active state here because we need to resolve tou
ch adjustment |
| 2719 // first so that we apply hover/active it to the final adjusted node. | 2714 // first so that we apply hover/active it to the final adjusted node. |
| 2720 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit
ion()); | 2715 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEvent.po
sition()); |
| 2721 LayoutSize padding; | 2716 LayoutSize padding; |
| 2722 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2717 if (shouldApplyTouchAdjustment(gestureEvent)) { |
| 2723 padding = LayoutSize(gestureEvent.area()); | 2718 padding = LayoutSize(gestureEvent.area()); |
| 2724 if (!padding.isEmpty()) { | 2719 if (!padding.isEmpty()) { |
| 2725 padding.scale(1.f / 2); | 2720 padding.scale(1.f / 2); |
| 2726 hitType |= HitTestRequest::ListBased; | 2721 hitType |= HitTestRequest::ListBased; |
| 2727 } | 2722 } |
| 2728 } | 2723 } |
| 2729 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, padding); | 2724 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, padding); |
| 2730 | 2725 |
| 2731 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the | 2726 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the |
| 2732 // type of event. | 2727 // type of event. |
| 2733 PlatformGestureEvent adjustedEvent = gestureEvent; | 2728 PlatformGestureEvent adjustedEvent = gestureEvent; |
| 2734 applyTouchAdjustment(&adjustedEvent, &hitTestResult); | 2729 applyTouchAdjustment(&adjustedEvent, &hitTestResult); |
| 2735 | 2730 |
| 2736 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because | 2731 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because |
| 2737 // rect-based hit testing and touch adjustment sometimes return a different
node than | 2732 // rect-based hit testing and touch adjustment sometimes return a different
node than |
| 2738 // what a point-based hit test would return for the same point. | 2733 // what a point-based hit test would return for the same point. |
| 2739 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 | 2734 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 |
| 2740 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2735 if (shouldApplyTouchAdjustment(gestureEvent)) { |
| 2741 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); | 2736 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); |
| 2742 if (!hitFrame) | 2737 if (!hitFrame) |
| 2743 hitFrame = m_frame; | 2738 hitFrame = m_frame; |
| 2744 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT
oContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~Hit
TestRequest::ListBased); | 2739 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->rootFra
meToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~
HitTestRequest::ListBased); |
| 2745 } | 2740 } |
| 2746 | 2741 |
| 2747 // If we did a rect-based hit test it must be resolved to the best single no
de by now to | 2742 // If we did a rect-based hit test it must be resolved to the best single no
de by now to |
| 2748 // ensure consumers don't accidentally use one of the other candidates. | 2743 // ensure consumers don't accidentally use one of the other candidates. |
| 2749 ASSERT(!hitTestResult.isRectBasedTest()); | 2744 ASSERT(!hitTestResult.isRectBasedTest()); |
| 2750 | 2745 |
| 2751 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); | 2746 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); |
| 2752 } | 2747 } |
| 2753 | 2748 |
| 2754 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo
rmEvent::Type type) | 2749 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo
rmEvent::Type type) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2799 case PlatformEvent::GestureTwoFingerTap: | 2794 case PlatformEvent::GestureTwoFingerTap: |
| 2800 adjusted = bestContextMenuNodeForHitTestResult(*hitTestResult, adjustedP
oint, adjustedNode); | 2795 adjusted = bestContextMenuNodeForHitTestResult(*hitTestResult, adjustedP
oint, adjustedNode); |
| 2801 break; | 2796 break; |
| 2802 default: | 2797 default: |
| 2803 ASSERT_NOT_REACHED(); | 2798 ASSERT_NOT_REACHED(); |
| 2804 } | 2799 } |
| 2805 | 2800 |
| 2806 // Update the hit-test result to be a point-based result instead of a rect-b
ased result. | 2801 // Update the hit-test result to be a point-based result instead of a rect-b
ased result. |
| 2807 // FIXME: We should do this even when no candidate matches the node filter.
crbug.com/398914 | 2802 // FIXME: We should do this even when no candidate matches the node filter.
crbug.com/398914 |
| 2808 if (adjusted) { | 2803 if (adjusted) { |
| 2809 hitTestResult->resolveRectBasedTest(adjustedNode, m_frame->view()->windo
wToContents(adjustedPoint)); | 2804 hitTestResult->resolveRectBasedTest(adjustedNode, m_frame->view()->rootF
rameToContents(adjustedPoint)); |
| 2810 gestureEvent->applyTouchAdjustment(adjustedPoint); | 2805 gestureEvent->applyTouchAdjustment(adjustedPoint); |
| 2811 } | 2806 } |
| 2812 } | 2807 } |
| 2813 | 2808 |
| 2814 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event) | 2809 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event) |
| 2815 { | 2810 { |
| 2816 Document* doc = m_frame->document(); | 2811 Document* doc = m_frame->document(); |
| 2817 FrameView* v = m_frame->view(); | 2812 FrameView* v = m_frame->view(); |
| 2818 if (!v) | 2813 if (!v) |
| 2819 return false; | 2814 return false; |
| 2820 | 2815 |
| 2821 // Clear mouse press state to avoid initiating a drag while context menu is
up. | 2816 // Clear mouse press state to avoid initiating a drag while context menu is
up. |
| 2822 m_mousePressed = false; | 2817 m_mousePressed = false; |
| 2823 LayoutPoint viewportPos = v->windowToContents(event.position()); | 2818 LayoutPoint viewportPos = v->rootFrameToContents(event.position()); |
| 2824 HitTestRequest request(HitTestRequest::Active); | 2819 HitTestRequest request(HitTestRequest::Active); |
| 2825 MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportP
os, event); | 2820 MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportP
os, event); |
| 2826 | 2821 |
| 2827 if (!m_frame->selection().contains(viewportPos) | 2822 if (!m_frame->selection().contains(viewportPos) |
| 2828 && !mev.scrollbar() | 2823 && !mev.scrollbar() |
| 2829 // FIXME: In the editable case, word selection sometimes selects content
that isn't underneath the mouse. | 2824 // FIXME: In the editable case, word selection sometimes selects content
that isn't underneath the mouse. |
| 2830 // If the selection is non-editable, we do word selection to make it eas
ier to use the contextual menu items | 2825 // If the selection is non-editable, we do word selection to make it eas
ier to use the contextual menu items |
| 2831 // available for text selections. But only if we're above text. | 2826 // available for text selections. But only if we're above text. |
| 2832 && (m_frame->selection().isContentEditable() || (mev.innerNode() && mev.
innerNode()->isTextNode()))) { | 2827 && (m_frame->selection().isContentEditable() || (mev.innerNode() && mev.
innerNode()->isTextNode()))) { |
| 2833 m_mouseDownMayStartSelect = true; // context menu events are always allo
wed to perform a selection | 2828 m_mouseDownMayStartSelect = true; // context menu events are always allo
wed to perform a selection |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2854 // Clear mouse press state to avoid initiating a drag while context menu is
up. | 2849 // Clear mouse press state to avoid initiating a drag while context menu is
up. |
| 2855 m_mousePressed = false; | 2850 m_mousePressed = false; |
| 2856 | 2851 |
| 2857 static const int kContextMenuMargin = 1; | 2852 static const int kContextMenuMargin = 1; |
| 2858 | 2853 |
| 2859 #if OS(WIN) | 2854 #if OS(WIN) |
| 2860 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); | 2855 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); |
| 2861 #else | 2856 #else |
| 2862 int rightAligned = 0; | 2857 int rightAligned = 0; |
| 2863 #endif | 2858 #endif |
| 2864 IntPoint locationInViewport; | 2859 IntPoint locationInRootFrame; |
| 2865 Element* focusedElement = doc->focusedElement(); | 2860 Element* focusedElement = doc->focusedElement(); |
| 2866 FrameSelection& selection = m_frame->selection(); | 2861 FrameSelection& selection = m_frame->selection(); |
| 2867 Position start = selection.selection().start(); | 2862 Position start = selection.selection().start(); |
| 2863 PinchViewport& pinchViewport = m_frame->page()->frameHost().pinchViewport(); |
| 2868 | 2864 |
| 2869 if (start.deprecatedNode() && (selection.rootEditableElement() || selection.
isRange())) { | 2865 if (start.deprecatedNode() && (selection.rootEditableElement() || selection.
isRange())) { |
| 2870 RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange()
; | 2866 RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange()
; |
| 2871 IntRect firstRect = m_frame->editor().firstRectForRange(selectionRange.g
et()); | 2867 IntRect firstRect = m_frame->editor().firstRectForRange(selectionRange.g
et()); |
| 2872 | 2868 |
| 2873 int x = rightAligned ? firstRect.maxX() : firstRect.x(); | 2869 int x = rightAligned ? firstRect.maxX() : firstRect.x(); |
| 2874 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. | 2870 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. |
| 2875 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; | 2871 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; |
| 2876 locationInViewport = view->contentsToWindow(IntPoint(x, y)); | 2872 locationInRootFrame = view->contentsToRootFrame(IntPoint(x, y)); |
| 2877 } else if (focusedElement) { | 2873 } else if (focusedElement) { |
| 2878 IntRect clippedRect = focusedElement->boundsInViewportSpace(); | 2874 IntRect clippedRect = focusedElement->boundsInViewportSpace(); |
| 2879 locationInViewport = IntPoint(clippedRect.center()); | 2875 // FIXME: boundsInViewportSpace is actually in the weird scaled but untr
anslated coordinate space of |
| 2876 // the old-style pinch viewport. crbug.com/459591. |
| 2877 locationInRootFrame = flooredIntPoint(pinchViewport.viewportCSSPixelsToR
ootFrame(clippedRect.center())); |
| 2880 } else { | 2878 } else { |
| 2881 // FIXME - Almost certainly wrong, this is not in viewport space. crbug.
com/458682. | 2879 locationInRootFrame = IntPoint( |
| 2882 locationInViewport = IntPoint( | 2880 rightAligned ? pinchViewport.visibleRect().maxX() - kContextMenuMarg
in : kContextMenuMargin, |
| 2883 rightAligned ? view->contentsWidth() - kContextMenuMargin : kContext
MenuMargin, | |
| 2884 kContextMenuMargin); | 2881 kContextMenuMargin); |
| 2885 } | 2882 } |
| 2886 | 2883 |
| 2887 m_frame->view()->setCursor(pointerCursor()); | 2884 m_frame->view()->setCursor(pointerCursor()); |
| 2885 IntPoint locationInViewport = pinchViewport.rootFrameToViewport(locationInRo
otFrame); |
| 2888 IntPoint globalPosition = view->hostWindow()->viewportToScreen(IntRect(locat
ionInViewport, IntSize())).location(); | 2886 IntPoint globalPosition = view->hostWindow()->viewportToScreen(IntRect(locat
ionInViewport, IntSize())).location(); |
| 2889 | 2887 |
| 2890 Node* targetNode = doc->focusedElement(); | 2888 Node* targetNode = doc->focusedElement(); |
| 2891 if (!targetNode) | 2889 if (!targetNode) |
| 2892 targetNode = doc; | 2890 targetNode = doc; |
| 2893 | 2891 |
| 2894 // Use the focused node as the target for hover and active. | 2892 // Use the focused node as the target for hover and active. |
| 2895 HitTestResult result(locationInViewport); | 2893 HitTestResult result(locationInRootFrame); |
| 2896 result.setInnerNode(targetNode); | 2894 result.setInnerNode(targetNode); |
| 2897 doc->updateHoverActiveState(HitTestRequest::Active, result.innerElement()); | 2895 doc->updateHoverActiveState(HitTestRequest::Active, result.innerElement()); |
| 2898 | 2896 |
| 2899 // The contextmenu event is a mouse event even when invoked using the keyboa
rd. | 2897 // The contextmenu event is a mouse event even when invoked using the keyboa
rd. |
| 2900 // This is required for web compatibility. | 2898 // This is required for web compatibility. |
| 2901 PlatformEvent::Type eventType = PlatformEvent::MousePressed; | 2899 PlatformEvent::Type eventType = PlatformEvent::MousePressed; |
| 2902 if (m_frame->settings()->showContextMenuOnMouseUp()) | 2900 if (m_frame->settings()->showContextMenuOnMouseUp()) |
| 2903 eventType = PlatformEvent::MouseReleased; | 2901 eventType = PlatformEvent::MouseReleased; |
| 2904 | 2902 |
| 2905 PlatformMouseEvent mouseEvent(locationInViewport, globalPosition, RightButto
n, eventType, 1, false, false, false, false, PlatformMouseEvent::RealOrIndisting
uishable, WTF::currentTime()); | 2903 PlatformMouseEvent mouseEvent(locationInRootFrame, globalPosition, RightButt
on, eventType, 1, false, false, false, false, PlatformMouseEvent::RealOrIndistin
guishable, WTF::currentTime()); |
| 2906 | 2904 |
| 2907 handleMousePressEvent(mouseEvent); | 2905 handleMousePressEvent(mouseEvent); |
| 2908 return sendContextMenuEvent(mouseEvent); | 2906 return sendContextMenuEvent(mouseEvent); |
| 2909 } | 2907 } |
| 2910 | 2908 |
| 2911 bool EventHandler::sendContextMenuEventForGesture(const GestureEventWithHitTestR
esults& targetedEvent) | 2909 bool EventHandler::sendContextMenuEventForGesture(const GestureEventWithHitTestR
esults& targetedEvent) |
| 2912 { | 2910 { |
| 2913 unsigned modifiers = targetedEvent.event().modifiers(); | 2911 unsigned modifiers = targetedEvent.event().modifiers(); |
| 2914 PlatformEvent::Type eventType = PlatformEvent::MousePressed; | 2912 PlatformEvent::Type eventType = PlatformEvent::MousePressed; |
| 2915 | 2913 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2967 m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveShortInterval, F
ROM_HERE); | 2965 m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveShortInterval, F
ROM_HERE); |
| 2968 } | 2966 } |
| 2969 } | 2967 } |
| 2970 | 2968 |
| 2971 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) | 2969 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) |
| 2972 { | 2970 { |
| 2973 FrameView* view = m_frame->view(); | 2971 FrameView* view = m_frame->view(); |
| 2974 if (!view) | 2972 if (!view) |
| 2975 return; | 2973 return; |
| 2976 | 2974 |
| 2977 if (!quad.containsPoint(view->windowToContents(m_lastKnownMousePosition))) | 2975 if (!quad.containsPoint(view->rootFrameToContents(m_lastKnownMousePosition))
) |
| 2978 return; | 2976 return; |
| 2979 | 2977 |
| 2980 dispatchFakeMouseMoveEventSoon(); | 2978 dispatchFakeMouseMoveEventSoon(); |
| 2981 } | 2979 } |
| 2982 | 2980 |
| 2983 void EventHandler::fakeMouseMoveEventTimerFired(Timer<EventHandler>* timer) | 2981 void EventHandler::fakeMouseMoveEventTimerFired(Timer<EventHandler>* timer) |
| 2984 { | 2982 { |
| 2985 ASSERT_UNUSED(timer, timer == &m_fakeMouseMoveEventTimer); | 2983 ASSERT_UNUSED(timer, timer == &m_fakeMouseMoveEventTimer); |
| 2986 ASSERT(!m_mousePressed); | 2984 ASSERT(!m_mousePressed); |
| 2987 | 2985 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3033 void EventHandler::hoverTimerFired(Timer<EventHandler>*) | 3031 void EventHandler::hoverTimerFired(Timer<EventHandler>*) |
| 3034 { | 3032 { |
| 3035 m_hoverTimer.stop(); | 3033 m_hoverTimer.stop(); |
| 3036 | 3034 |
| 3037 ASSERT(m_frame); | 3035 ASSERT(m_frame); |
| 3038 ASSERT(m_frame->document()); | 3036 ASSERT(m_frame->document()); |
| 3039 | 3037 |
| 3040 if (LayoutView* renderer = m_frame->contentRenderer()) { | 3038 if (LayoutView* renderer = m_frame->contentRenderer()) { |
| 3041 if (FrameView* view = m_frame->view()) { | 3039 if (FrameView* view = m_frame->view()) { |
| 3042 HitTestRequest request(HitTestRequest::Move); | 3040 HitTestRequest request(HitTestRequest::Move); |
| 3043 HitTestResult result(view->windowToContents(m_lastKnownMousePosition
)); | 3041 HitTestResult result(view->rootFrameToContents(m_lastKnownMousePosit
ion)); |
| 3044 renderer->hitTest(request, result); | 3042 renderer->hitTest(request, result); |
| 3045 m_frame->document()->updateHoverActiveState(request, result.innerEle
ment()); | 3043 m_frame->document()->updateHoverActiveState(request, result.innerEle
ment()); |
| 3046 } | 3044 } |
| 3047 } | 3045 } |
| 3048 } | 3046 } |
| 3049 | 3047 |
| 3050 void EventHandler::activeIntervalTimerFired(Timer<EventHandler>*) | 3048 void EventHandler::activeIntervalTimerFired(Timer<EventHandler>*) |
| 3051 { | 3049 { |
| 3052 m_activeIntervalTimer.stop(); | 3050 m_activeIntervalTimer.stop(); |
| 3053 | 3051 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3213 } | 3211 } |
| 3214 if (event->type() == EventTypeNames::keypress) { | 3212 if (event->type() == EventTypeNames::keypress) { |
| 3215 m_frame->editor().handleKeyboardEvent(event); | 3213 m_frame->editor().handleKeyboardEvent(event); |
| 3216 if (event->defaultHandled()) | 3214 if (event->defaultHandled()) |
| 3217 return; | 3215 return; |
| 3218 if (event->charCode() == ' ') | 3216 if (event->charCode() == ' ') |
| 3219 defaultSpaceEventHandler(event); | 3217 defaultSpaceEventHandler(event); |
| 3220 } | 3218 } |
| 3221 } | 3219 } |
| 3222 | 3220 |
| 3223 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation)
const | 3221 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragLocationInRootFram
e) const |
| 3224 { | 3222 { |
| 3225 FrameView* view = m_frame->view(); | 3223 FrameView* view = m_frame->view(); |
| 3226 if (!view) | 3224 if (!view) |
| 3227 return false; | 3225 return false; |
| 3228 IntPoint dragLocation = view->windowToContents(dragViewportLocation); | 3226 IntPoint dragLocation = view->rootFrameToContents(dragLocationInRootFrame); |
| 3229 IntSize delta = dragLocation - m_mouseDownPos; | 3227 IntSize delta = dragLocation - m_mouseDownPos; |
| 3230 | 3228 |
| 3231 int threshold = GeneralDragHysteresis; | 3229 int threshold = GeneralDragHysteresis; |
| 3232 switch (dragState().m_dragType) { | 3230 switch (dragState().m_dragType) { |
| 3233 case DragSourceActionSelection: | 3231 case DragSourceActionSelection: |
| 3234 threshold = TextDragHysteresis; | 3232 threshold = TextDragHysteresis; |
| 3235 break; | 3233 break; |
| 3236 case DragSourceActionImage: | 3234 case DragSourceActionImage: |
| 3237 threshold = ImageDragHysteresis; | 3235 threshold = ImageDragHysteresis; |
| 3238 break; | 3236 break; |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3637 | 3635 |
| 3638 // First do hit tests for any new touch points. | 3636 // First do hit tests for any new touch points. |
| 3639 for (i = 0; i < points.size(); ++i) { | 3637 for (i = 0; i < points.size(); ++i) { |
| 3640 const PlatformTouchPoint& point = points[i]; | 3638 const PlatformTouchPoint& point = points[i]; |
| 3641 | 3639 |
| 3642 // Touch events implicitly capture to the touched node, and don't change | 3640 // Touch events implicitly capture to the touched node, and don't change |
| 3643 // active/hover states themselves (Gesture events do). So we only need | 3641 // active/hover states themselves (Gesture events do). So we only need |
| 3644 // to hit-test on touchstart, and it can be read-only. | 3642 // to hit-test on touchstart, and it can be read-only. |
| 3645 if (point.state() == PlatformTouchPoint::TouchPressed) { | 3643 if (point.state() == PlatformTouchPoint::TouchPressed) { |
| 3646 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; | 3644 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; |
| 3647 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->windowTo
Contents(point.pos())); | 3645 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->rootFram
eToContents(point.pos())); |
| 3648 HitTestResult result; | 3646 HitTestResult result; |
| 3649 if (!m_touchSequenceDocument) { | 3647 if (!m_touchSequenceDocument) { |
| 3650 result = hitTestResultAtPoint(pagePoint, hitType); | 3648 result = hitTestResultAtPoint(pagePoint, hitType); |
| 3651 } else if (m_touchSequenceDocument->frame()) { | 3649 } else if (m_touchSequenceDocument->frame()) { |
| 3652 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum
ent->frame()->view()->windowToContents(point.pos())); | 3650 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum
ent->frame()->view()->rootFrameToContents(point.pos())); |
| 3653 result = hitTestResultInFrame(m_touchSequenceDocument->frame(),
framePoint, hitType); | 3651 result = hitTestResultInFrame(m_touchSequenceDocument->frame(),
framePoint, hitType); |
| 3654 } else | 3652 } else |
| 3655 continue; | 3653 continue; |
| 3656 | 3654 |
| 3657 Node* node = result.innerNode(); | 3655 Node* node = result.innerNode(); |
| 3658 if (!node) | 3656 if (!node) |
| 3659 continue; | 3657 continue; |
| 3660 | 3658 |
| 3661 // Touch events should not go to text nodes | 3659 // Touch events should not go to text nodes |
| 3662 if (node->isTextNode()) | 3660 if (node->isTextNode()) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3760 // Document so that there's some valid node here. Perhaps this | 3758 // Document so that there's some valid node here. Perhaps this |
| 3761 // should really be LocalDOMWindow, but in all other cases the targe
t of | 3759 // should really be LocalDOMWindow, but in all other cases the targe
t of |
| 3762 // a Touch is a Node so using the window could be a breaking change. | 3760 // a Touch is a Node so using the window could be a breaking change. |
| 3763 // Since we know there was no handler invoked, the specific target | 3761 // Since we know there was no handler invoked, the specific target |
| 3764 // should be completely irrelevant to the application. | 3762 // should be completely irrelevant to the application. |
| 3765 touchTarget = m_touchSequenceDocument; | 3763 touchTarget = m_touchSequenceDocument; |
| 3766 targetFrame = m_touchSequenceDocument->frame(); | 3764 targetFrame = m_touchSequenceDocument->frame(); |
| 3767 } | 3765 } |
| 3768 ASSERT(targetFrame); | 3766 ASSERT(targetFrame); |
| 3769 | 3767 |
| 3770 // pagePoint should always be relative to the target elements | 3768 // pagePoint should always be in the target element's document coordinat
es. |
| 3771 // containing frame. | 3769 FloatPoint pagePoint = targetFrame->view()->rootFrameToContents(point.po
s()); |
| 3772 FloatPoint pagePoint = targetFrame->view()->windowToContents(point.pos()
); | |
| 3773 | 3770 |
| 3774 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); | 3771 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); |
| 3775 | 3772 |
| 3776 FloatPoint adjustedPagePoint = pagePoint.scaledBy(scaleFactor); | 3773 FloatPoint adjustedPagePoint = pagePoint.scaledBy(scaleFactor); |
| 3777 FloatSize adjustedRadius = point.radius().scaledBy(scaleFactor); | 3774 FloatSize adjustedRadius = point.radius().scaledBy(scaleFactor); |
| 3778 | 3775 |
| 3779 RefPtrWillBeRawPtr<Touch> touch = Touch::create( | 3776 RefPtrWillBeRawPtr<Touch> touch = Touch::create( |
| 3780 targetFrame, touchTarget.get(), point.id(), point.screenPos(), adjus
tedPagePoint, adjustedRadius, point.rotationAngle(), point.force()); | 3777 targetFrame, touchTarget.get(), point.id(), point.screenPos(), adjus
tedPagePoint, adjustedRadius, point.rotationAngle(), point.force()); |
| 3781 | 3778 |
| 3782 // Ensure this target's touch list exists, even if it ends up empty, so | 3779 // Ensure this target's touch list exists, even if it ends up empty, so |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3879 m_lastKnownMousePosition = event.position(); | 3876 m_lastKnownMousePosition = event.position(); |
| 3880 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 3877 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
| 3881 } | 3878 } |
| 3882 | 3879 |
| 3883 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, LocalFrame* subframe) | 3880 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, LocalFrame* subframe) |
| 3884 { | 3881 { |
| 3885 // If we're clicking into a frame that is selected, the frame will appear | 3882 // If we're clicking into a frame that is selected, the frame will appear |
| 3886 // greyed out even though we're clicking on the selection. This looks | 3883 // greyed out even though we're clicking on the selection. This looks |
| 3887 // really strange (having the whole frame be greyed out), so we deselect the | 3884 // really strange (having the whole frame be greyed out), so we deselect the |
| 3888 // selection. | 3885 // selection. |
| 3889 IntPoint p = m_frame->view()->windowToContents(mev.event().position()); | 3886 IntPoint p = m_frame->view()->rootFrameToContents(mev.event().position()); |
| 3890 if (m_frame->selection().contains(p)) { | 3887 if (m_frame->selection().contains(p)) { |
| 3891 VisiblePosition visiblePos( | 3888 VisiblePosition visiblePos( |
| 3892 mev.innerNode()->layoutObject()->positionForPoint(mev.localPoint()))
; | 3889 mev.innerNode()->layoutObject()->positionForPoint(mev.localPoint()))
; |
| 3893 VisibleSelection newSelection(visiblePos); | 3890 VisibleSelection newSelection(visiblePos); |
| 3894 m_frame->selection().setSelection(newSelection); | 3891 m_frame->selection().setSelection(newSelection); |
| 3895 } | 3892 } |
| 3896 | 3893 |
| 3897 subframe->eventHandler().handleMousePressEvent(mev.event()); | 3894 subframe->eventHandler().handleMousePressEvent(mev.event()); |
| 3898 return true; | 3895 return true; |
| 3899 } | 3896 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3952 | 3949 |
| 3953 // If it's in the direction to hide the top controls, only consume when the
frame can also scroll. | 3950 // If it's in the direction to hide the top controls, only consume when the
frame can also scroll. |
| 3954 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo
sition().y()) | 3951 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo
sition().y()) |
| 3955 return true; | 3952 return true; |
| 3956 | 3953 |
| 3957 return false; | 3954 return false; |
| 3958 } | 3955 } |
| 3959 | 3956 |
| 3960 | 3957 |
| 3961 } // namespace blink | 3958 } // namespace blink |
| OLD | NEW |