| 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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 Node* innerNode = event.innerNode(); | 507 Node* innerNode = event.innerNode(); |
| 508 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) | 508 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) |
| 509 return false; | 509 return false; |
| 510 | 510 |
| 511 // Extend the selection if the Shift key is down, unless the click is in a l
ink. | 511 // Extend the selection if the Shift key is down, unless the click is in a l
ink. |
| 512 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); | 512 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); |
| 513 | 513 |
| 514 // Don't restart the selection when the mouse is pressed on an | 514 // Don't restart the selection when the mouse is pressed on an |
| 515 // existing selection so we can allow for text dragging. | 515 // existing selection so we can allow for text dragging. |
| 516 if (FrameView* view = m_frame->view()) { | 516 if (FrameView* view = m_frame->view()) { |
| 517 LayoutPoint vPoint = view->windowToContents(event.event().position()); | 517 LayoutPoint vPoint = view->rootFrameToContents(event.event().position())
; |
| 518 if (!extendSelection && m_frame->selection().contains(vPoint)) { | 518 if (!extendSelection && m_frame->selection().contains(vPoint)) { |
| 519 m_mouseDownWasSingleClickInSelection = true; | 519 m_mouseDownWasSingleClickInSelection = true; |
| 520 return false; | 520 return false; |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 VisiblePosition visiblePos(innerNode->renderer()->positionForPoint(event.loc
alPoint())); | 524 VisiblePosition visiblePos(innerNode->renderer()->positionForPoint(event.loc
alPoint())); |
| 525 if (visiblePos.isNull()) | 525 if (visiblePos.isNull()) |
| 526 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW
NSTREAM); | 526 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW
NSTREAM); |
| 527 Position pos = visiblePos.deepEquivalent(); | 527 Position pos = visiblePos.deepEquivalent(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 | 602 |
| 603 m_mouseDownMayStartDrag = singleClick; | 603 m_mouseDownMayStartDrag = singleClick; |
| 604 | 604 |
| 605 m_mouseDownWasSingleClickInSelection = false; | 605 m_mouseDownWasSingleClickInSelection = false; |
| 606 | 606 |
| 607 m_mouseDown = event.event(); | 607 m_mouseDown = event.event(); |
| 608 | 608 |
| 609 if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGEx
tensions().zoomAndPanEnabled()) { | 609 if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGEx
tensions().zoomAndPanEnabled()) { |
| 610 if (event.event().shiftKey() && singleClick) { | 610 if (event.event().shiftKey() && singleClick) { |
| 611 m_svgPan = true; | 611 m_svgPan = true; |
| 612 m_frame->document()->accessSVGExtensions().startPan(m_frame->view()-
>windowToContents(event.event().position())); | 612 m_frame->document()->accessSVGExtensions().startPan(m_frame->view()-
>rootFrameToContents(event.event().position())); |
| 613 return true; | 613 return true; |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 | 616 |
| 617 // We don't do this at the start of mouse down handling, | 617 // We don't do this at the start of mouse down handling, |
| 618 // because we don't want to do it until we know we didn't hit a widget. | 618 // because we don't want to do it until we know we didn't hit a widget. |
| 619 if (singleClick) | 619 if (singleClick) |
| 620 focusDocumentView(); | 620 focusDocumentView(); |
| 621 | 621 |
| 622 Node* innerNode = event.innerNode(); | 622 Node* innerNode = event.innerNode(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 void EventHandler::updateSelectionForMouseDrag() | 706 void EventHandler::updateSelectionForMouseDrag() |
| 707 { | 707 { |
| 708 FrameView* view = m_frame->view(); | 708 FrameView* view = m_frame->view(); |
| 709 if (!view) | 709 if (!view) |
| 710 return; | 710 return; |
| 711 LayoutView* renderer = m_frame->contentRenderer(); | 711 LayoutView* renderer = m_frame->contentRenderer(); |
| 712 if (!renderer) | 712 if (!renderer) |
| 713 return; | 713 return; |
| 714 | 714 |
| 715 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move); | 715 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move); |
| 716 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); | 716 HitTestResult result(view->rootFrameToContents(m_lastKnownMousePosition)); |
| 717 renderer->hitTest(request, result); | 717 renderer->hitTest(request, result); |
| 718 updateSelectionForMouseDrag(result); | 718 updateSelectionForMouseDrag(result); |
| 719 } | 719 } |
| 720 | 720 |
| 721 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) | 721 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) |
| 722 { | 722 { |
| 723 if (!m_mouseDownMayStartSelect) | 723 if (!m_mouseDownMayStartSelect) |
| 724 return; | 724 return; |
| 725 | 725 |
| 726 Node* target = hitTestResult.innerNode(); | 726 Node* target = hitTestResult.innerNode(); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 if (!view || !view->shouldSetCursor()) | 1020 if (!view || !view->shouldSetCursor()) |
| 1021 return; | 1021 return; |
| 1022 | 1022 |
| 1023 LayoutView* layoutView = view->layoutView(); | 1023 LayoutView* layoutView = view->layoutView(); |
| 1024 if (!layoutView) | 1024 if (!layoutView) |
| 1025 return; | 1025 return; |
| 1026 | 1026 |
| 1027 m_frame->document()->updateLayout(); | 1027 m_frame->document()->updateLayout(); |
| 1028 | 1028 |
| 1029 HitTestRequest request(HitTestRequest::ReadOnly); | 1029 HitTestRequest request(HitTestRequest::ReadOnly); |
| 1030 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); | 1030 HitTestResult result(view->rootFrameToContents(m_lastKnownMousePosition)); |
| 1031 layoutView->hitTest(request, result); | 1031 layoutView->hitTest(request, result); |
| 1032 | 1032 |
| 1033 OptionalCursor optionalCursor = selectCursor(result); | 1033 OptionalCursor optionalCursor = selectCursor(result); |
| 1034 if (optionalCursor.isCursorChange()) { | 1034 if (optionalCursor.isCursorChange()) { |
| 1035 m_currentMouseCursor = optionalCursor.cursor(); | 1035 m_currentMouseCursor = optionalCursor.cursor(); |
| 1036 view->setCursor(m_currentMouseCursor); | 1036 view->setCursor(m_currentMouseCursor); |
| 1037 } | 1037 } |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) | 1040 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 && m_frame->selection().isCaretOrRange() | 1201 && m_frame->selection().isCaretOrRange() |
| 1202 && !m_capturingMouseEventsNode) { | 1202 && !m_capturingMouseEventsNode) { |
| 1203 return iBeam; | 1203 return iBeam; |
| 1204 } | 1204 } |
| 1205 | 1205 |
| 1206 if ((editable || (renderer && renderer->isText() && node->canStartSelection(
))) && !inResizer && !result.scrollbar()) | 1206 if ((editable || (renderer && renderer->isText() && node->canStartSelection(
))) && !inResizer && !result.scrollbar()) |
| 1207 return iBeam; | 1207 return iBeam; |
| 1208 return pointerCursor(); | 1208 return pointerCursor(); |
| 1209 } | 1209 } |
| 1210 | 1210 |
| 1211 static LayoutPoint documentPointForWindowPoint(LocalFrame* frame, const IntPoint
& windowPoint) | 1211 static LayoutPoint contentPointFromRootFrame(LocalFrame* frame, const IntPoint&
pointInRootFrame) |
| 1212 { | 1212 { |
| 1213 FrameView* view = frame->view(); | 1213 FrameView* view = frame->view(); |
| 1214 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? | 1214 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? |
| 1215 // Historically the code would just crash; this is clearly no worse than tha
t. | 1215 // Historically the code would just crash; this is clearly no worse than tha
t. |
| 1216 return view ? view->windowToContents(windowPoint) : windowPoint; | 1216 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame
; |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) | 1219 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) |
| 1220 { | 1220 { |
| 1221 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 1221 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
| 1222 | 1222 |
| 1223 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 1223 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
| 1224 | 1224 |
| 1225 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 1225 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
| 1226 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken =
gestureIndicator.currentToken(); | 1226 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken =
gestureIndicator.currentToken(); |
| 1227 | 1227 |
| 1228 cancelFakeMouseMoveEvent(); | 1228 cancelFakeMouseMoveEvent(); |
| 1229 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 1229 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
| 1230 m_capturingMouseEventsNode = nullptr; | 1230 m_capturingMouseEventsNode = nullptr; |
| 1231 m_mousePressed = true; | 1231 m_mousePressed = true; |
| 1232 m_capturesDragging = true; | 1232 m_capturesDragging = true; |
| 1233 setLastKnownMousePosition(mouseEvent); | 1233 setLastKnownMousePosition(mouseEvent); |
| 1234 m_mouseDownTimestamp = mouseEvent.timestamp(); | 1234 m_mouseDownTimestamp = mouseEvent.timestamp(); |
| 1235 m_mouseDownMayStartDrag = false; | 1235 m_mouseDownMayStartDrag = false; |
| 1236 m_mouseDownMayStartSelect = false; | 1236 m_mouseDownMayStartSelect = false; |
| 1237 m_mouseDownMayStartAutoscroll = false; | 1237 m_mouseDownMayStartAutoscroll = false; |
| 1238 if (FrameView* view = m_frame->view()) | 1238 if (FrameView* view = m_frame->view()) |
| 1239 m_mouseDownPos = view->windowToContents(mouseEvent.position()); | 1239 m_mouseDownPos = view->rootFrameToContents(mouseEvent.position()); |
| 1240 else { | 1240 else { |
| 1241 invalidateClick(); | 1241 invalidateClick(); |
| 1242 return false; | 1242 return false; |
| 1243 } | 1243 } |
| 1244 | 1244 |
| 1245 HitTestRequest request(HitTestRequest::Active); | 1245 HitTestRequest request(HitTestRequest::Active); |
| 1246 // Save the document point we generate in case the window coordinate is inva
lidated by what happens | 1246 // Save the document point we generate in case the window coordinate is inva
lidated by what happens |
| 1247 // when we dispatch the event. | 1247 // when we dispatch the event. |
| 1248 LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.
position()); | 1248 LayoutPoint documentPoint = contentPointFromRootFrame(m_frame, mouseEvent.po
sition()); |
| 1249 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); | 1249 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); |
| 1250 | 1250 |
| 1251 if (!mev.innerNode()) { | 1251 if (!mev.innerNode()) { |
| 1252 invalidateClick(); | 1252 invalidateClick(); |
| 1253 return false; | 1253 return false; |
| 1254 } | 1254 } |
| 1255 | 1255 |
| 1256 m_mousePressNode = mev.innerNode(); | 1256 m_mousePressNode = mev.innerNode(); |
| 1257 | 1257 |
| 1258 RefPtrWillBeRawPtr<LocalFrame> subframe = subframeForHitTestResult(mev); | 1258 RefPtrWillBeRawPtr<LocalFrame> subframe = subframeForHitTestResult(mev); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1279 invalidateClick(); | 1279 invalidateClick(); |
| 1280 return true; | 1280 return true; |
| 1281 } | 1281 } |
| 1282 #endif | 1282 #endif |
| 1283 | 1283 |
| 1284 m_clickCount = mouseEvent.clickCount(); | 1284 m_clickCount = mouseEvent.clickCount(); |
| 1285 m_clickNode = mev.innerNode()->isTextNode() ? NodeRenderingTraversal::paren
t(*mev.innerNode()) : mev.innerNode(); | 1285 m_clickNode = mev.innerNode()->isTextNode() ? NodeRenderingTraversal::paren
t(*mev.innerNode()) : mev.innerNode(); |
| 1286 | 1286 |
| 1287 if (FrameView* view = m_frame->view()) { | 1287 if (FrameView* view = m_frame->view()) { |
| 1288 Layer* layer = mev.innerNode()->renderer() ? mev.innerNode()->renderer()
->enclosingLayer() : nullptr; | 1288 Layer* layer = mev.innerNode()->renderer() ? mev.innerNode()->renderer()
->enclosingLayer() : nullptr; |
| 1289 IntPoint p = view->windowToContents(mouseEvent.position()); | 1289 IntPoint p = view->rootFrameToContents(mouseEvent.position()); |
| 1290 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForPointer)) { | 1290 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForPointer)) { |
| 1291 m_resizeScrollableArea = layer->scrollableArea(); | 1291 m_resizeScrollableArea = layer->scrollableArea(); |
| 1292 m_resizeScrollableArea->setInResizeMode(true); | 1292 m_resizeScrollableArea->setInResizeMode(true); |
| 1293 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); | 1293 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); |
| 1294 invalidateClick(); | 1294 invalidateClick(); |
| 1295 return true; | 1295 return true; |
| 1296 } | 1296 } |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 m_frame->selection().setCaretBlinkingSuspended(true); | 1299 m_frame->selection().setCaretBlinkingSuspended(true); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 setLastKnownMousePosition(mouseEvent); | 1402 setLastKnownMousePosition(mouseEvent); |
| 1403 | 1403 |
| 1404 if (m_hoverTimer.isActive()) | 1404 if (m_hoverTimer.isActive()) |
| 1405 m_hoverTimer.stop(); | 1405 m_hoverTimer.stop(); |
| 1406 | 1406 |
| 1407 m_cursorUpdateTimer.stop(); | 1407 m_cursorUpdateTimer.stop(); |
| 1408 | 1408 |
| 1409 cancelFakeMouseMoveEvent(); | 1409 cancelFakeMouseMoveEvent(); |
| 1410 | 1410 |
| 1411 if (m_svgPan) { | 1411 if (m_svgPan) { |
| 1412 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->wi
ndowToContents(m_lastKnownMousePosition)); | 1412 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro
otFrameToContents(m_lastKnownMousePosition)); |
| 1413 return true; | 1413 return true; |
| 1414 } | 1414 } |
| 1415 | 1415 |
| 1416 if (m_frameSetBeingResized) | 1416 if (m_frameSetBeingResized) |
| 1417 return !dispatchMouseEvent(EventTypeNames::mousemove, m_frameSetBeingRes
ized.get(), 0, mouseEvent, false); | 1417 return !dispatchMouseEvent(EventTypeNames::mousemove, m_frameSetBeingRes
ized.get(), 0, mouseEvent, false); |
| 1418 | 1418 |
| 1419 // Send events right to a scrollbar if the mouse is pressed. | 1419 // Send events right to a scrollbar if the mouse is pressed. |
| 1420 if (m_lastScrollbarUnderMouse && m_mousePressed) { | 1420 if (m_lastScrollbarUnderMouse && m_mousePressed) { |
| 1421 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent); | 1421 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent); |
| 1422 return true; | 1422 return true; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 #if OS(WIN) | 1538 #if OS(WIN) |
| 1539 if (Page* page = m_frame->page()) | 1539 if (Page* page = m_frame->page()) |
| 1540 page->autoscrollController().handleMouseReleaseForPanScrolling(m_frame,
mouseEvent); | 1540 page->autoscrollController().handleMouseReleaseForPanScrolling(m_frame,
mouseEvent); |
| 1541 #endif | 1541 #endif |
| 1542 | 1542 |
| 1543 m_mousePressed = false; | 1543 m_mousePressed = false; |
| 1544 setLastKnownMousePosition(mouseEvent); | 1544 setLastKnownMousePosition(mouseEvent); |
| 1545 | 1545 |
| 1546 if (m_svgPan) { | 1546 if (m_svgPan) { |
| 1547 m_svgPan = false; | 1547 m_svgPan = false; |
| 1548 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->wi
ndowToContents(m_lastKnownMousePosition)); | 1548 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro
otFrameToContents(m_lastKnownMousePosition)); |
| 1549 return true; | 1549 return true; |
| 1550 } | 1550 } |
| 1551 | 1551 |
| 1552 if (m_frameSetBeingResized) | 1552 if (m_frameSetBeingResized) |
| 1553 return !dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResiz
ed.get(), m_clickCount, mouseEvent, false); | 1553 return !dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResiz
ed.get(), m_clickCount, mouseEvent, false); |
| 1554 | 1554 |
| 1555 if (m_lastScrollbarUnderMouse) { | 1555 if (m_lastScrollbarUnderMouse) { |
| 1556 invalidateClick(); | 1556 invalidateClick(); |
| 1557 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); | 1557 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); |
| 1558 bool setUnder = false; | 1558 bool setUnder = false; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 { | 1824 { |
| 1825 m_capturingMouseEventsNode = n; | 1825 m_capturingMouseEventsNode = n; |
| 1826 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 1826 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
| 1827 } | 1827 } |
| 1828 | 1828 |
| 1829 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
t& request, const PlatformMouseEvent& mev) | 1829 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
t& request, const PlatformMouseEvent& mev) |
| 1830 { | 1830 { |
| 1831 ASSERT(m_frame); | 1831 ASSERT(m_frame); |
| 1832 ASSERT(m_frame->document()); | 1832 ASSERT(m_frame->document()); |
| 1833 | 1833 |
| 1834 return m_frame->document()->prepareMouseEvent(request, documentPointForWindo
wPoint(m_frame, mev.position()), mev); | 1834 return m_frame->document()->prepareMouseEvent(request, contentPointFromRootF
rame(m_frame, mev.position()), mev); |
| 1835 } | 1835 } |
| 1836 | 1836 |
| 1837 void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
useEvent& mouseEvent, bool fireMouseOverOut) | 1837 void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
useEvent& mouseEvent, bool fireMouseOverOut) |
| 1838 { | 1838 { |
| 1839 Node* result = targetNode; | 1839 Node* result = targetNode; |
| 1840 | 1840 |
| 1841 // If we're capturing, we always go right to that node. | 1841 // If we're capturing, we always go right to that node. |
| 1842 if (m_capturingMouseEventsNode) | 1842 if (m_capturingMouseEventsNode) |
| 1843 result = m_capturingMouseEventsNode.get(); | 1843 result = m_capturingMouseEventsNode.get(); |
| 1844 else { | 1844 else { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent,
eventType, clickCount); | 1902 return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent,
eventType, clickCount); |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 // The return value means 'swallow event' (was handled), as for other handle* fu
nctions. | 1905 // The return value means 'swallow event' (was handled), as for other handle* fu
nctions. |
| 1906 bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted
Event) | 1906 bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted
Event) |
| 1907 { | 1907 { |
| 1908 const PlatformMouseEvent& mouseEvent = targetedEvent.event(); | 1908 const PlatformMouseEvent& mouseEvent = targetedEvent.event(); |
| 1909 | 1909 |
| 1910 // If clicking on a frame scrollbar, do not mess up with content focus. | 1910 // If clicking on a frame scrollbar, do not mess up with content focus. |
| 1911 if (FrameView* view = m_frame->view()) { | 1911 if (FrameView* view = m_frame->view()) { |
| 1912 if (view->scrollbarAtWindowPoint(mouseEvent.position())) | 1912 if (view->scrollbarAtRootFramePoint(mouseEvent.position())) |
| 1913 return false; | 1913 return false; |
| 1914 } | 1914 } |
| 1915 | 1915 |
| 1916 // The layout needs to be up to date to determine if an element is focusable
. | 1916 // The layout needs to be up to date to determine if an element is focusable
. |
| 1917 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1917 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 1918 | 1918 |
| 1919 Element* element = nullptr; | 1919 Element* element = nullptr; |
| 1920 if (m_nodeUnderMouse) | 1920 if (m_nodeUnderMouse) |
| 1921 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse
) : m_nodeUnderMouse->parentOrShadowHostElement(); | 1921 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse
) : m_nodeUnderMouse->parentOrShadowHostElement(); |
| 1922 for (; element; element = element->parentOrShadowHostElement()) { | 1922 for (; element; element = element->parentOrShadowHostElement()) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 | 1975 |
| 1976 if (!doc->layoutView()) | 1976 if (!doc->layoutView()) |
| 1977 return false; | 1977 return false; |
| 1978 | 1978 |
| 1979 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 1979 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
| 1980 | 1980 |
| 1981 FrameView* view = m_frame->view(); | 1981 FrameView* view = m_frame->view(); |
| 1982 if (!view) | 1982 if (!view) |
| 1983 return false; | 1983 return false; |
| 1984 | 1984 |
| 1985 LayoutPoint vPoint = view->windowToContents(event.position()); | 1985 LayoutPoint vPoint = view->rootFrameToContents(event.position()); |
| 1986 | 1986 |
| 1987 HitTestRequest request(HitTestRequest::ReadOnly); | 1987 HitTestRequest request(HitTestRequest::ReadOnly); |
| 1988 HitTestResult result(vPoint); | 1988 HitTestResult result(vPoint); |
| 1989 doc->layoutView()->hitTest(request, result); | 1989 doc->layoutView()->hitTest(request, result); |
| 1990 | 1990 |
| 1991 Node* node = result.innerNode(); | 1991 Node* node = result.innerNode(); |
| 1992 // Wheel events should not dispatch to text nodes. | 1992 // Wheel events should not dispatch to text nodes. |
| 1993 if (node && node->isTextNode()) | 1993 if (node && node->isTextNode()) |
| 1994 node = NodeRenderingTraversal::parent(*node); | 1994 node = NodeRenderingTraversal::parent(*node); |
| 1995 | 1995 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 scrollbar = m_scrollbarHandlingScrollGesture.get(); | 2179 scrollbar = m_scrollbarHandlingScrollGesture.get(); |
| 2180 eventTarget = m_scrollGestureHandlingNode.get(); | 2180 eventTarget = m_scrollGestureHandlingNode.get(); |
| 2181 } | 2181 } |
| 2182 | 2182 |
| 2183 if (!eventTarget) { | 2183 if (!eventTarget) { |
| 2184 Document* document = m_frame->document(); | 2184 Document* document = m_frame->document(); |
| 2185 if (!document->layoutView()) | 2185 if (!document->layoutView()) |
| 2186 return false; | 2186 return false; |
| 2187 | 2187 |
| 2188 FrameView* view = m_frame->view(); | 2188 FrameView* view = m_frame->view(); |
| 2189 LayoutPoint viewPoint = view->windowToContents(gestureEvent.position()); | 2189 LayoutPoint viewPoint = view->rootFrameToContents(gestureEvent.position(
)); |
| 2190 HitTestRequest request(HitTestRequest::ReadOnly); | 2190 HitTestRequest request(HitTestRequest::ReadOnly); |
| 2191 HitTestResult result(viewPoint); | 2191 HitTestResult result(viewPoint); |
| 2192 document->layoutView()->hitTest(request, result); | 2192 document->layoutView()->hitTest(request, result); |
| 2193 | 2193 |
| 2194 eventTarget = result.innerNode(); | 2194 eventTarget = result.innerNode(); |
| 2195 | 2195 |
| 2196 m_lastGestureScrollOverWidget = result.isOverWidget(); | 2196 m_lastGestureScrollOverWidget = result.isOverWidget(); |
| 2197 m_scrollGestureHandlingNode = eventTarget; | 2197 m_scrollGestureHandlingNode = eventTarget; |
| 2198 m_previousGestureScrolledNode = nullptr; | 2198 m_previousGestureScrolledNode = nullptr; |
| 2199 | 2199 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2245 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur
eEvent.type()); | 2245 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur
eEvent.type()); |
| 2246 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); | 2246 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); |
| 2247 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); | 2247 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); |
| 2248 | 2248 |
| 2249 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 2249 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
| 2250 | 2250 |
| 2251 HitTestResult currentHitTest = targetedEvent.hitTestResult(); | 2251 HitTestResult currentHitTest = targetedEvent.hitTestResult(); |
| 2252 | 2252 |
| 2253 // We use the adjusted position so the application isn't surprised to see a
event with | 2253 // We use the adjusted position so the application isn't surprised to see a
event with |
| 2254 // co-ordinates outside the target's bounds. | 2254 // co-ordinates outside the target's bounds. |
| 2255 IntPoint adjustedPoint = frameView->windowToContents(gestureEvent.position()
); | 2255 IntPoint adjustedPoint = frameView->rootFrameToContents(gestureEvent.positio
n()); |
| 2256 | 2256 |
| 2257 unsigned modifiers = gestureEvent.modifiers(); | 2257 unsigned modifiers = gestureEvent.modifiers(); |
| 2258 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa
lPosition(), | 2258 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa
lPosition(), |
| 2259 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | 2259 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, |
| 2260 static_cast<PlatformEvent::Modifiers>(modifiers), | 2260 static_cast<PlatformEvent::Modifiers>(modifiers), |
| 2261 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2261 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
| 2262 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0,
fakeMouseMove, true); | 2262 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0,
fakeMouseMove, true); |
| 2263 | 2263 |
| 2264 // Do a new hit-test in case the mousemove event changed the DOM. | 2264 // Do a new hit-test in case the mousemove event changed the DOM. |
| 2265 // Note that if the original hit test wasn't over an element (eg. was over a
scrollbar) we | 2265 // Note that if the original hit test wasn't over an element (eg. was over a
scrollbar) we |
| 2266 // don't want to re-hit-test because it may be in the wrong frame (and there
's no way the page | 2266 // don't want to re-hit-test because it may be in the wrong frame (and there
's no way the page |
| 2267 // could have seen the event anyway). | 2267 // could have seen the event anyway). |
| 2268 // Also note that the position of the frame may have changed, so we need to
recompute the content | 2268 // Also note that the position of the frame may have changed, so we need to
recompute the content |
| 2269 // co-ordinates (updating layout/style as hitTestResultAtPoint normally woul
d). | 2269 // co-ordinates (updating layout/style as hitTestResultAtPoint normally woul
d). |
| 2270 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 | 2270 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 |
| 2271 if (currentHitTest.innerNode()) { | 2271 if (currentHitTest.innerNode()) { |
| 2272 LocalFrame* mainFrame = m_frame->localFrameRoot(); | 2272 LocalFrame* mainFrame = m_frame->localFrameRoot(); |
| 2273 if (mainFrame && mainFrame->view()) | 2273 if (mainFrame && mainFrame->view()) |
| 2274 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); | 2274 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); |
| 2275 adjustedPoint = frameView->windowToContents(gestureEvent.position()); | 2275 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); |
| 2276 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); | 2276 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); |
| 2277 } | 2277 } |
| 2278 m_clickNode = currentHitTest.innerNode(); | 2278 m_clickNode = currentHitTest.innerNode(); |
| 2279 | 2279 |
| 2280 // Capture data for showUnhandledTapUIIfNeeded. | 2280 // Capture data for showUnhandledTapUIIfNeeded. |
| 2281 RefPtrWillBeRawPtr<Node> tappedNode = m_clickNode; | 2281 RefPtrWillBeRawPtr<Node> tappedNode = m_clickNode; |
| 2282 IntPoint tappedPosition = gestureEvent.position(); | 2282 IntPoint tappedPosition = gestureEvent.position(); |
| 2283 | 2283 |
| 2284 if (m_clickNode && m_clickNode->isTextNode()) | 2284 if (m_clickNode && m_clickNode->isTextNode()) |
| 2285 m_clickNode = NodeRenderingTraversal::parent(*m_clickNode); | 2285 m_clickNode = NodeRenderingTraversal::parent(*m_clickNode); |
| 2286 | 2286 |
| 2287 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa
lPosition(), | 2287 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa
lPosition(), |
| 2288 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), | 2288 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), |
| 2289 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut
tonDown), | 2289 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut
tonDown), |
| 2290 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2290 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
| 2291 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown,
currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true); | 2291 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown,
currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true); |
| 2292 if (!swallowMouseDownEvent) | 2292 if (!swallowMouseDownEvent) |
| 2293 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa
keMouseDown, currentHitTest)); | 2293 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa
keMouseDown, currentHitTest)); |
| 2294 if (!swallowMouseDownEvent) | 2294 if (!swallowMouseDownEvent) |
| 2295 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul
ts(fakeMouseDown, currentHitTest)); | 2295 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul
ts(fakeMouseDown, currentHitTest)); |
| 2296 | 2296 |
| 2297 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 | 2297 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 |
| 2298 if (currentHitTest.innerNode()) { | 2298 if (currentHitTest.innerNode()) { |
| 2299 LocalFrame* mainFrame = m_frame->localFrameRoot(); | 2299 LocalFrame* mainFrame = m_frame->localFrameRoot(); |
| 2300 if (mainFrame && mainFrame->view()) | 2300 if (mainFrame && mainFrame->view()) |
| 2301 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); | 2301 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); |
| 2302 adjustedPoint = frameView->windowToContents(gestureEvent.position()); | 2302 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); |
| 2303 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); | 2303 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); |
| 2304 } | 2304 } |
| 2305 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP
osition(), | 2305 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP
osition(), |
| 2306 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), | 2306 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), |
| 2307 static_cast<PlatformEvent::Modifiers>(modifiers), | 2307 static_cast<PlatformEvent::Modifiers>(modifiers), |
| 2308 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2308 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
| 2309 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, curr
entHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp, false); | 2309 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, curr
entHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp, false); |
| 2310 | 2310 |
| 2311 bool swallowClickEvent = false; | 2311 bool swallowClickEvent = false; |
| 2312 if (m_clickNode) { | 2312 if (m_clickNode) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2323 m_clickNode = nullptr; | 2323 m_clickNode = nullptr; |
| 2324 } | 2324 } |
| 2325 | 2325 |
| 2326 if (!swallowMouseUpEvent) | 2326 if (!swallowMouseUpEvent) |
| 2327 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul
ts(fakeMouseUp, currentHitTest)); | 2327 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul
ts(fakeMouseUp, currentHitTest)); |
| 2328 | 2328 |
| 2329 bool swallowed = swallowMouseDownEvent | swallowMouseUpEvent | swallowClickE
vent; | 2329 bool swallowed = swallowMouseDownEvent | swallowMouseUpEvent | swallowClickE
vent; |
| 2330 if (!swallowed && tappedNode) { | 2330 if (!swallowed && tappedNode) { |
| 2331 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()->
domTreeVersion(); | 2331 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()->
domTreeVersion(); |
| 2332 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl
eVersion(); | 2332 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl
eVersion(); |
| 2333 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPosition, tappe
dNode.get(), domTreeChanged || styleChanged); | 2333 IntPoint tappedPositionInViewport = m_frame->page()->frameHost().pinchVi
ewport().rootFrameToViewport(tappedPosition); |
| 2334 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp
ort, tappedNode.get(), domTreeChanged || styleChanged); |
| 2334 } | 2335 } |
| 2335 return swallowed; | 2336 return swallowed; |
| 2336 } | 2337 } |
| 2337 | 2338 |
| 2338 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
targetedEvent) | 2339 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
targetedEvent) |
| 2339 { | 2340 { |
| 2340 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2341 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
| 2341 IntPoint adjustedPoint = gestureEvent.position(); | 2342 IntPoint adjustedPoint = gestureEvent.position(); |
| 2342 | 2343 |
| 2343 unsigned modifiers = gestureEvent.modifiers(); | 2344 unsigned modifiers = gestureEvent.modifiers(); |
| 2344 | 2345 |
| 2345 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests
here (re-using the | 2346 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests
here (re-using the |
| 2346 // supplied HitTestResult), but that will require some overhaul of the touch
drag-and-drop code | 2347 // supplied HitTestResult), but that will require some overhaul of the touch
drag-and-drop code |
| 2347 // and LongPress is such a special scenario that it's unlikely to matter muc
h in practice. | 2348 // and LongPress is such a special scenario that it's unlikely to matter muc
h in practice. |
| 2348 | 2349 |
| 2349 m_longTapShouldInvokeContextMenu = false; | 2350 m_longTapShouldInvokeContextMenu = false; |
| 2350 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_
frame->view()) { | 2351 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_
frame->view()) { |
| 2351 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MousePressed, 1, | 2352 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MousePressed, 1, |
| 2352 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef
tButtonDown), | 2353 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef
tButtonDown), |
| 2353 PlatformMouseEvent::FromTouch, WTF::currentTime()); | 2354 PlatformMouseEvent::FromTouch, WTF::currentTime()); |
| 2354 m_mouseDown = mouseDownEvent; | 2355 m_mouseDown = mouseDownEvent; |
| 2355 | 2356 |
| 2356 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MouseMoved, 1, | 2357 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi
tion(), LeftButton, PlatformEvent::MouseMoved, 1, |
| 2357 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef
tButtonDown), | 2358 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef
tButtonDown), |
| 2358 PlatformMouseEvent::FromTouch, WTF::currentTime()); | 2359 PlatformMouseEvent::FromTouch, WTF::currentTime()); |
| 2359 HitTestRequest request(HitTestRequest::ReadOnly); | 2360 HitTestRequest request(HitTestRequest::ReadOnly); |
| 2360 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE
vent); | 2361 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE
vent); |
| 2361 m_mouseDownMayStartDrag = true; | 2362 m_mouseDownMayStartDrag = true; |
| 2362 dragState().m_dragSrc = nullptr; | 2363 dragState().m_dragSrc = nullptr; |
| 2363 m_mouseDownPos = m_frame->view()->windowToContents(mouseDragEvent.positi
on()); | 2364 m_mouseDownPos = m_frame->view()->rootFrameToContents(mouseDragEvent.pos
ition()); |
| 2364 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 2365 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
| 2365 if (handleDrag(mev, DragInitiator::Touch)) { | 2366 if (handleDrag(mev, DragInitiator::Touch)) { |
| 2366 m_longTapShouldInvokeContextMenu = true; | 2367 m_longTapShouldInvokeContextMenu = true; |
| 2367 return true; | 2368 return true; |
| 2368 } | 2369 } |
| 2369 } | 2370 } |
| 2370 #if OS(ANDROID) | 2371 #if OS(ANDROID) |
| 2371 bool shouldLongPressSelectWord = true; | 2372 bool shouldLongPressSelectWord = true; |
| 2372 #else | 2373 #else |
| 2373 bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()-
>touchEditingEnabled(); | 2374 bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()-
>touchEditingEnabled(); |
| 2374 #endif | 2375 #endif |
| 2375 if (shouldLongPressSelectWord) { | 2376 if (shouldLongPressSelectWord) { |
| 2376 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.p
osition()); | 2377 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEven
t.position()); |
| 2377 HitTestResult result = hitTestResultAtPoint(hitTestPoint); | 2378 HitTestResult result = hitTestResultAtPoint(hitTestPoint); |
| 2378 Node* innerNode = result.innerNode(); | 2379 Node* innerNode = result.innerNode(); |
| 2379 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable()
|| innerNode->isTextNode() | 2380 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable()
|| innerNode->isTextNode() |
| 2380 #if OS(ANDROID) | 2381 #if OS(ANDROID) |
| 2381 || innerNode->canStartSelection() | 2382 || innerNode->canStartSelection() |
| 2382 #endif | 2383 #endif |
| 2383 )) { | 2384 )) { |
| 2384 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitesp
ace); | 2385 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitesp
ace); |
| 2385 if (m_frame->selection().isRange()) { | 2386 if (m_frame->selection().isRange()) { |
| 2386 focusDocumentView(); | 2387 focusDocumentView(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2398 m_longTapShouldInvokeContextMenu = false; | 2399 m_longTapShouldInvokeContextMenu = false; |
| 2399 return sendContextMenuEventForGesture(targetedEvent); | 2400 return sendContextMenuEventForGesture(targetedEvent); |
| 2400 } | 2401 } |
| 2401 #endif | 2402 #endif |
| 2402 return false; | 2403 return false; |
| 2403 } | 2404 } |
| 2404 | 2405 |
| 2405 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor
mGestureEvent& gestureEvent) { | 2406 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor
mGestureEvent& gestureEvent) { |
| 2406 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { | 2407 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { |
| 2407 Layer* layer = eventTarget->renderer() ? eventTarget->renderer()->enclos
ingLayer() : nullptr; | 2408 Layer* layer = eventTarget->renderer() ? eventTarget->renderer()->enclos
ingLayer() : nullptr; |
| 2408 IntPoint p = m_frame->view()->windowToContents(gestureEvent.position()); | 2409 IntPoint p = m_frame->view()->rootFrameToContents(gestureEvent.position(
)); |
| 2409 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForTouch)) { | 2410 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForTouch)) { |
| 2410 m_resizeScrollableArea = layer->scrollableArea(); | 2411 m_resizeScrollableArea = layer->scrollableArea(); |
| 2411 m_resizeScrollableArea->setInResizeMode(true); | 2412 m_resizeScrollableArea->setInResizeMode(true); |
| 2412 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); | 2413 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); |
| 2413 return true; | 2414 return true; |
| 2414 } | 2415 } |
| 2415 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) { | 2416 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) { |
| 2416 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | 2417 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { |
| 2417 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne
r); | 2418 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne
r); |
| 2418 return true; | 2419 return true; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2593 ASSERT(result.isRectBasedTest()); | 2594 ASSERT(result.isRectBasedTest()); |
| 2594 | 2595 |
| 2595 // If the touch is over a scrollbar, don't adjust the touch point since touc
h adjustment only takes into account | 2596 // If the touch is over a scrollbar, don't adjust the touch point since touc
h adjustment only takes into account |
| 2596 // DOM nodes so a touch over a scrollbar will be adjusted towards nearby nod
es. This leads to things like textarea | 2597 // DOM nodes so a touch over a scrollbar will be adjusted towards nearby nod
es. This leads to things like textarea |
| 2597 // scrollbars being untouchable. | 2598 // scrollbars being untouchable. |
| 2598 if (result.scrollbar()) { | 2599 if (result.scrollbar()) { |
| 2599 targetNode = 0; | 2600 targetNode = 0; |
| 2600 return false; | 2601 return false; |
| 2601 } | 2602 } |
| 2602 | 2603 |
| 2603 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint
InMainFrame()); | 2604 IntPoint touchCenter = m_frame->view()->contentsToRootFrame(result.roundedPo
intInMainFrame()); |
| 2604 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation
().boundingBox()); | 2605 IntRect touchRect = m_frame->view()->contentsToRootFrame(result.hitTestLocat
ion().boundingBox()); |
| 2605 | 2606 |
| 2606 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2607 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2607 copyToVector(result.listBasedTestResult(), nodes); | 2608 copyToVector(result.listBasedTestResult(), nodes); |
| 2608 | 2609 |
| 2609 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2610 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
| 2610 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc
hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); | 2611 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc
hRect, WillBeHeapVector<RefPtrWillBeMember<Node>> (nodes)); |
| 2611 } | 2612 } |
| 2612 | 2613 |
| 2613 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu
lt, IntPoint& targetPoint, Node*& targetNode) | 2614 bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& resu
lt, IntPoint& targetPoint, Node*& targetNode) |
| 2614 { | 2615 { |
| 2615 ASSERT(result.isRectBasedTest()); | 2616 ASSERT(result.isRectBasedTest()); |
| 2616 IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPoint
InMainFrame()); | 2617 IntPoint touchCenter = m_frame->view()->contentsToRootFrame(result.roundedPo
intInMainFrame()); |
| 2617 IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation
().boundingBox()); | 2618 IntRect touchRect = m_frame->view()->contentsToRootFrame(result.hitTestLocat
ion().boundingBox()); |
| 2618 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2619 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2619 copyToVector(result.listBasedTestResult(), nodes); | 2620 copyToVector(result.listBasedTestResult(), nodes); |
| 2620 | 2621 |
| 2621 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2622 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
| 2622 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to
uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2623 return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, to
uchRect, WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
| 2623 } | 2624 } |
| 2624 | 2625 |
| 2625 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co
nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) | 2626 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co
nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) |
| 2626 { | 2627 { |
| 2627 if (touchRadius.isEmpty()) | 2628 if (touchRadius.isEmpty()) |
| 2628 return false; | 2629 return false; |
| 2629 | 2630 |
| 2630 IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); | 2631 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(touchCenter); |
| 2631 | 2632 |
| 2632 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | HitTestRequest::ListBased; | 2633 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | HitTestRequest::ListBased; |
| 2633 HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType, LayoutSiz
e(touchRadius)); | 2634 HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType, LayoutSiz
e(touchRadius)); |
| 2634 | 2635 |
| 2635 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); | 2636 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); |
| 2636 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2637 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
| 2637 copyToVector(result.listBasedTestResult(), nodes); | 2638 copyToVector(result.listBasedTestResult(), nodes); |
| 2638 | 2639 |
| 2639 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2640 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
| 2640 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect,
WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); | 2641 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect,
WillBeHeapVector<RefPtrWillBeMember<Node>>(nodes)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2677 } | 2678 } |
| 2678 | 2679 |
| 2679 return eventWithHitTestResults; | 2680 return eventWithHitTestResults; |
| 2680 } | 2681 } |
| 2681 | 2682 |
| 2682 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const
PlatformGestureEvent& gestureEvent, HitTestRequest::HitTestRequestType hitType) | 2683 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const
PlatformGestureEvent& gestureEvent, HitTestRequest::HitTestRequestType hitType) |
| 2683 { | 2684 { |
| 2684 // Perform the rect-based hit-test (or point-based if adjustment is disabled
). Note that | 2685 // Perform the rect-based hit-test (or point-based if adjustment is disabled
). Note that |
| 2685 // we don't yet apply hover/active state here because we need to resolve tou
ch adjustment | 2686 // we don't yet apply hover/active state here because we need to resolve tou
ch adjustment |
| 2686 // first so that we apply hover/active it to the final adjusted node. | 2687 // first so that we apply hover/active it to the final adjusted node. |
| 2687 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit
ion()); | 2688 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEvent.po
sition()); |
| 2688 LayoutSize padding; | 2689 LayoutSize padding; |
| 2689 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2690 if (shouldApplyTouchAdjustment(gestureEvent)) { |
| 2690 padding = LayoutSize(gestureEvent.area()); | 2691 padding = LayoutSize(gestureEvent.area()); |
| 2691 if (!padding.isEmpty()) { | 2692 if (!padding.isEmpty()) { |
| 2692 padding.scale(1.f / 2); | 2693 padding.scale(1.f / 2); |
| 2693 hitType |= HitTestRequest::ListBased; | 2694 hitType |= HitTestRequest::ListBased; |
| 2694 } | 2695 } |
| 2695 } | 2696 } |
| 2696 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, padding); | 2697 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, padding); |
| 2697 | 2698 |
| 2698 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the | 2699 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the |
| 2699 // type of event. | 2700 // type of event. |
| 2700 PlatformGestureEvent adjustedEvent = gestureEvent; | 2701 PlatformGestureEvent adjustedEvent = gestureEvent; |
| 2701 applyTouchAdjustment(&adjustedEvent, &hitTestResult); | 2702 applyTouchAdjustment(&adjustedEvent, &hitTestResult); |
| 2702 | 2703 |
| 2703 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because | 2704 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because |
| 2704 // rect-based hit testing and touch adjustment sometimes return a different
node than | 2705 // rect-based hit testing and touch adjustment sometimes return a different
node than |
| 2705 // what a point-based hit test would return for the same point. | 2706 // what a point-based hit test would return for the same point. |
| 2706 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 | 2707 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 |
| 2707 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2708 if (shouldApplyTouchAdjustment(gestureEvent)) { |
| 2708 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); | 2709 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); |
| 2709 if (!hitFrame) | 2710 if (!hitFrame) |
| 2710 hitFrame = m_frame; | 2711 hitFrame = m_frame; |
| 2711 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT
oContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~Hit
TestRequest::ListBased); | 2712 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->rootFra
meToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~
HitTestRequest::ListBased); |
| 2712 } | 2713 } |
| 2713 | 2714 |
| 2714 // If we did a rect-based hit test it must be resolved to the best single no
de by now to | 2715 // If we did a rect-based hit test it must be resolved to the best single no
de by now to |
| 2715 // ensure consumers don't accidentally use one of the other candidates. | 2716 // ensure consumers don't accidentally use one of the other candidates. |
| 2716 ASSERT(!hitTestResult.isRectBasedTest()); | 2717 ASSERT(!hitTestResult.isRectBasedTest()); |
| 2717 | 2718 |
| 2718 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); | 2719 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); |
| 2719 } | 2720 } |
| 2720 | 2721 |
| 2721 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo
rmEvent::Type type) | 2722 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo
rmEvent::Type type) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2766 case PlatformEvent::GestureTwoFingerTap: | 2767 case PlatformEvent::GestureTwoFingerTap: |
| 2767 adjusted = bestContextMenuNodeForHitTestResult(*hitTestResult, adjustedP
oint, adjustedNode); | 2768 adjusted = bestContextMenuNodeForHitTestResult(*hitTestResult, adjustedP
oint, adjustedNode); |
| 2768 break; | 2769 break; |
| 2769 default: | 2770 default: |
| 2770 ASSERT_NOT_REACHED(); | 2771 ASSERT_NOT_REACHED(); |
| 2771 } | 2772 } |
| 2772 | 2773 |
| 2773 // Update the hit-test result to be a point-based result instead of a rect-b
ased result. | 2774 // Update the hit-test result to be a point-based result instead of a rect-b
ased result. |
| 2774 // FIXME: We should do this even when no candidate matches the node filter.
crbug.com/398914 | 2775 // FIXME: We should do this even when no candidate matches the node filter.
crbug.com/398914 |
| 2775 if (adjusted) { | 2776 if (adjusted) { |
| 2776 hitTestResult->resolveRectBasedTest(adjustedNode, m_frame->view()->windo
wToContents(adjustedPoint)); | 2777 hitTestResult->resolveRectBasedTest(adjustedNode, m_frame->view()->rootF
rameToContents(adjustedPoint)); |
| 2777 gestureEvent->applyTouchAdjustment(adjustedPoint); | 2778 gestureEvent->applyTouchAdjustment(adjustedPoint); |
| 2778 } | 2779 } |
| 2779 } | 2780 } |
| 2780 | 2781 |
| 2781 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event) | 2782 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event) |
| 2782 { | 2783 { |
| 2783 Document* doc = m_frame->document(); | 2784 Document* doc = m_frame->document(); |
| 2784 FrameView* v = m_frame->view(); | 2785 FrameView* v = m_frame->view(); |
| 2785 if (!v) | 2786 if (!v) |
| 2786 return false; | 2787 return false; |
| 2787 | 2788 |
| 2788 // Clear mouse press state to avoid initiating a drag while context menu is
up. | 2789 // Clear mouse press state to avoid initiating a drag while context menu is
up. |
| 2789 m_mousePressed = false; | 2790 m_mousePressed = false; |
| 2790 LayoutPoint viewportPos = v->windowToContents(event.position()); | 2791 LayoutPoint viewportPos = v->rootFrameToContents(event.position()); |
| 2791 HitTestRequest request(HitTestRequest::Active); | 2792 HitTestRequest request(HitTestRequest::Active); |
| 2792 MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportP
os, event); | 2793 MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportP
os, event); |
| 2793 | 2794 |
| 2794 if (!m_frame->selection().contains(viewportPos) | 2795 if (!m_frame->selection().contains(viewportPos) |
| 2795 && !mev.scrollbar() | 2796 && !mev.scrollbar() |
| 2796 // FIXME: In the editable case, word selection sometimes selects content
that isn't underneath the mouse. | 2797 // FIXME: In the editable case, word selection sometimes selects content
that isn't underneath the mouse. |
| 2797 // If the selection is non-editable, we do word selection to make it eas
ier to use the contextual menu items | 2798 // If the selection is non-editable, we do word selection to make it eas
ier to use the contextual menu items |
| 2798 // available for text selections. But only if we're above text. | 2799 // available for text selections. But only if we're above text. |
| 2799 && (m_frame->selection().isContentEditable() || (mev.innerNode() && mev.
innerNode()->isTextNode()))) { | 2800 && (m_frame->selection().isContentEditable() || (mev.innerNode() && mev.
innerNode()->isTextNode()))) { |
| 2800 m_mouseDownMayStartSelect = true; // context menu events are always allo
wed to perform a selection | 2801 m_mouseDownMayStartSelect = true; // context menu events are always allo
wed to perform a selection |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2833 FrameSelection& selection = m_frame->selection(); | 2834 FrameSelection& selection = m_frame->selection(); |
| 2834 Position start = selection.selection().start(); | 2835 Position start = selection.selection().start(); |
| 2835 | 2836 |
| 2836 if (start.deprecatedNode() && (selection.rootEditableElement() || selection.
isRange())) { | 2837 if (start.deprecatedNode() && (selection.rootEditableElement() || selection.
isRange())) { |
| 2837 RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange()
; | 2838 RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange()
; |
| 2838 IntRect firstRect = m_frame->editor().firstRectForRange(selectionRange.g
et()); | 2839 IntRect firstRect = m_frame->editor().firstRectForRange(selectionRange.g
et()); |
| 2839 | 2840 |
| 2840 int x = rightAligned ? firstRect.maxX() : firstRect.x(); | 2841 int x = rightAligned ? firstRect.maxX() : firstRect.x(); |
| 2841 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. | 2842 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. |
| 2842 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; | 2843 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; |
| 2843 locationInViewport = view->contentsToWindow(IntPoint(x, y)); | 2844 locationInViewport = view->contentsToViewport(IntPoint(x, y)); |
| 2844 } else if (focusedElement) { | 2845 } else if (focusedElement) { |
| 2845 IntRect clippedRect = focusedElement->boundsInViewportSpace(); | 2846 IntRect clippedRect = focusedElement->boundsInViewportSpace(); |
| 2846 locationInViewport = IntPoint(clippedRect.center()); | 2847 locationInViewport = IntPoint(clippedRect.center()); |
| 2847 } else { | 2848 } else { |
| 2848 // FIXME - Almost certainly wrong, this is not in viewport space. crbug.
com/458682. | 2849 // FIXME - Almost certainly wrong, this is not in viewport space. crbug.
com/458602. |
| 2849 locationInViewport = IntPoint( | 2850 locationInViewport = IntPoint( |
| 2850 rightAligned ? view->contentsWidth() - kContextMenuMargin : kContext
MenuMargin, | 2851 rightAligned ? view->contentsWidth() - kContextMenuMargin : kContext
MenuMargin, |
| 2851 kContextMenuMargin); | 2852 kContextMenuMargin); |
| 2852 } | 2853 } |
| 2853 | 2854 |
| 2854 m_frame->view()->setCursor(pointerCursor()); | 2855 m_frame->view()->setCursor(pointerCursor()); |
| 2855 IntPoint globalPosition = view->hostWindow()->viewportToScreen(IntRect(locat
ionInViewport, IntSize())).location(); | 2856 IntPoint globalPosition = view->hostWindow()->viewportToScreen(IntRect(locat
ionInViewport, IntSize())).location(); |
| 2856 | 2857 |
| 2857 Node* targetNode = doc->focusedElement(); | 2858 Node* targetNode = doc->focusedElement(); |
| 2858 if (!targetNode) | 2859 if (!targetNode) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2934 m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveShortInterval, F
ROM_HERE); | 2935 m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveShortInterval, F
ROM_HERE); |
| 2935 } | 2936 } |
| 2936 } | 2937 } |
| 2937 | 2938 |
| 2938 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) | 2939 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) |
| 2939 { | 2940 { |
| 2940 FrameView* view = m_frame->view(); | 2941 FrameView* view = m_frame->view(); |
| 2941 if (!view) | 2942 if (!view) |
| 2942 return; | 2943 return; |
| 2943 | 2944 |
| 2944 if (!quad.containsPoint(view->windowToContents(m_lastKnownMousePosition))) | 2945 if (!quad.containsPoint(view->rootFrameToContents(m_lastKnownMousePosition))
) |
| 2945 return; | 2946 return; |
| 2946 | 2947 |
| 2947 dispatchFakeMouseMoveEventSoon(); | 2948 dispatchFakeMouseMoveEventSoon(); |
| 2948 } | 2949 } |
| 2949 | 2950 |
| 2950 void EventHandler::fakeMouseMoveEventTimerFired(Timer<EventHandler>* timer) | 2951 void EventHandler::fakeMouseMoveEventTimerFired(Timer<EventHandler>* timer) |
| 2951 { | 2952 { |
| 2952 ASSERT_UNUSED(timer, timer == &m_fakeMouseMoveEventTimer); | 2953 ASSERT_UNUSED(timer, timer == &m_fakeMouseMoveEventTimer); |
| 2953 ASSERT(!m_mousePressed); | 2954 ASSERT(!m_mousePressed); |
| 2954 | 2955 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3000 void EventHandler::hoverTimerFired(Timer<EventHandler>*) | 3001 void EventHandler::hoverTimerFired(Timer<EventHandler>*) |
| 3001 { | 3002 { |
| 3002 m_hoverTimer.stop(); | 3003 m_hoverTimer.stop(); |
| 3003 | 3004 |
| 3004 ASSERT(m_frame); | 3005 ASSERT(m_frame); |
| 3005 ASSERT(m_frame->document()); | 3006 ASSERT(m_frame->document()); |
| 3006 | 3007 |
| 3007 if (LayoutView* renderer = m_frame->contentRenderer()) { | 3008 if (LayoutView* renderer = m_frame->contentRenderer()) { |
| 3008 if (FrameView* view = m_frame->view()) { | 3009 if (FrameView* view = m_frame->view()) { |
| 3009 HitTestRequest request(HitTestRequest::Move); | 3010 HitTestRequest request(HitTestRequest::Move); |
| 3010 HitTestResult result(view->windowToContents(m_lastKnownMousePosition
)); | 3011 HitTestResult result(view->rootFrameToContents(m_lastKnownMousePosit
ion)); |
| 3011 renderer->hitTest(request, result); | 3012 renderer->hitTest(request, result); |
| 3012 m_frame->document()->updateHoverActiveState(request, result.innerEle
ment()); | 3013 m_frame->document()->updateHoverActiveState(request, result.innerEle
ment()); |
| 3013 } | 3014 } |
| 3014 } | 3015 } |
| 3015 } | 3016 } |
| 3016 | 3017 |
| 3017 void EventHandler::activeIntervalTimerFired(Timer<EventHandler>*) | 3018 void EventHandler::activeIntervalTimerFired(Timer<EventHandler>*) |
| 3018 { | 3019 { |
| 3019 m_activeIntervalTimer.stop(); | 3020 m_activeIntervalTimer.stop(); |
| 3020 | 3021 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3180 } | 3181 } |
| 3181 if (event->type() == EventTypeNames::keypress) { | 3182 if (event->type() == EventTypeNames::keypress) { |
| 3182 m_frame->editor().handleKeyboardEvent(event); | 3183 m_frame->editor().handleKeyboardEvent(event); |
| 3183 if (event->defaultHandled()) | 3184 if (event->defaultHandled()) |
| 3184 return; | 3185 return; |
| 3185 if (event->charCode() == ' ') | 3186 if (event->charCode() == ' ') |
| 3186 defaultSpaceEventHandler(event); | 3187 defaultSpaceEventHandler(event); |
| 3187 } | 3188 } |
| 3188 } | 3189 } |
| 3189 | 3190 |
| 3190 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation)
const | 3191 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragLocationInRootFram
e) const |
| 3191 { | 3192 { |
| 3192 FrameView* view = m_frame->view(); | 3193 FrameView* view = m_frame->view(); |
| 3193 if (!view) | 3194 if (!view) |
| 3194 return false; | 3195 return false; |
| 3195 IntPoint dragLocation = view->windowToContents(dragViewportLocation); | 3196 IntPoint dragLocation = view->rootFrameToContents(dragLocationInRootFrame); |
| 3196 IntSize delta = dragLocation - m_mouseDownPos; | 3197 IntSize delta = dragLocation - m_mouseDownPos; |
| 3197 | 3198 |
| 3198 int threshold = GeneralDragHysteresis; | 3199 int threshold = GeneralDragHysteresis; |
| 3199 switch (dragState().m_dragType) { | 3200 switch (dragState().m_dragType) { |
| 3200 case DragSourceActionSelection: | 3201 case DragSourceActionSelection: |
| 3201 threshold = TextDragHysteresis; | 3202 threshold = TextDragHysteresis; |
| 3202 break; | 3203 break; |
| 3203 case DragSourceActionImage: | 3204 case DragSourceActionImage: |
| 3204 threshold = ImageDragHysteresis; | 3205 threshold = ImageDragHysteresis; |
| 3205 break; | 3206 break; |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3604 | 3605 |
| 3605 // First do hit tests for any new touch points. | 3606 // First do hit tests for any new touch points. |
| 3606 for (i = 0; i < points.size(); ++i) { | 3607 for (i = 0; i < points.size(); ++i) { |
| 3607 const PlatformTouchPoint& point = points[i]; | 3608 const PlatformTouchPoint& point = points[i]; |
| 3608 | 3609 |
| 3609 // Touch events implicitly capture to the touched node, and don't change | 3610 // Touch events implicitly capture to the touched node, and don't change |
| 3610 // active/hover states themselves (Gesture events do). So we only need | 3611 // active/hover states themselves (Gesture events do). So we only need |
| 3611 // to hit-test on touchstart, and it can be read-only. | 3612 // to hit-test on touchstart, and it can be read-only. |
| 3612 if (point.state() == PlatformTouchPoint::TouchPressed) { | 3613 if (point.state() == PlatformTouchPoint::TouchPressed) { |
| 3613 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; | 3614 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; |
| 3614 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->windowTo
Contents(point.pos())); | 3615 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->rootFram
eToContents(point.pos())); |
| 3615 HitTestResult result; | 3616 HitTestResult result; |
| 3616 if (!m_touchSequenceDocument) { | 3617 if (!m_touchSequenceDocument) { |
| 3617 result = hitTestResultAtPoint(pagePoint, hitType); | 3618 result = hitTestResultAtPoint(pagePoint, hitType); |
| 3618 } else if (m_touchSequenceDocument->frame()) { | 3619 } else if (m_touchSequenceDocument->frame()) { |
| 3619 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum
ent->frame()->view()->windowToContents(point.pos())); | 3620 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum
ent->frame()->view()->rootFrameToContents(point.pos())); |
| 3620 result = hitTestResultInFrame(m_touchSequenceDocument->frame(),
framePoint, hitType); | 3621 result = hitTestResultInFrame(m_touchSequenceDocument->frame(),
framePoint, hitType); |
| 3621 } else | 3622 } else |
| 3622 continue; | 3623 continue; |
| 3623 | 3624 |
| 3624 Node* node = result.innerNode(); | 3625 Node* node = result.innerNode(); |
| 3625 if (!node) | 3626 if (!node) |
| 3626 continue; | 3627 continue; |
| 3627 | 3628 |
| 3628 // Touch events should not go to text nodes | 3629 // Touch events should not go to text nodes |
| 3629 if (node->isTextNode()) | 3630 if (node->isTextNode()) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3727 // Document so that there's some valid node here. Perhaps this | 3728 // Document so that there's some valid node here. Perhaps this |
| 3728 // should really be LocalDOMWindow, but in all other cases the targe
t of | 3729 // should really be LocalDOMWindow, but in all other cases the targe
t of |
| 3729 // a Touch is a Node so using the window could be a breaking change. | 3730 // a Touch is a Node so using the window could be a breaking change. |
| 3730 // Since we know there was no handler invoked, the specific target | 3731 // Since we know there was no handler invoked, the specific target |
| 3731 // should be completely irrelevant to the application. | 3732 // should be completely irrelevant to the application. |
| 3732 touchTarget = m_touchSequenceDocument; | 3733 touchTarget = m_touchSequenceDocument; |
| 3733 targetFrame = m_touchSequenceDocument->frame(); | 3734 targetFrame = m_touchSequenceDocument->frame(); |
| 3734 } | 3735 } |
| 3735 ASSERT(targetFrame); | 3736 ASSERT(targetFrame); |
| 3736 | 3737 |
| 3737 // pagePoint should always be relative to the target elements | 3738 // pagePoint should always be in the target element's document coordinat
es. |
| 3738 // containing frame. | 3739 FloatPoint pagePoint = targetFrame->view()->rootFrameToContents(point.po
s()); |
| 3739 FloatPoint pagePoint = targetFrame->view()->windowToContents(point.pos()
); | |
| 3740 | 3740 |
| 3741 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); | 3741 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); |
| 3742 | 3742 |
| 3743 FloatPoint adjustedPagePoint = pagePoint.scaledBy(scaleFactor); | 3743 FloatPoint adjustedPagePoint = pagePoint.scaledBy(scaleFactor); |
| 3744 FloatSize adjustedRadius = point.radius().scaledBy(scaleFactor); | 3744 FloatSize adjustedRadius = point.radius().scaledBy(scaleFactor); |
| 3745 | 3745 |
| 3746 RefPtrWillBeRawPtr<Touch> touch = Touch::create( | 3746 RefPtrWillBeRawPtr<Touch> touch = Touch::create( |
| 3747 targetFrame, touchTarget.get(), point.id(), point.screenPos(), adjus
tedPagePoint, adjustedRadius, point.rotationAngle(), point.force()); | 3747 targetFrame, touchTarget.get(), point.id(), point.screenPos(), adjus
tedPagePoint, adjustedRadius, point.rotationAngle(), point.force()); |
| 3748 | 3748 |
| 3749 // Ensure this target's touch list exists, even if it ends up empty, so | 3749 // 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... |
| 3846 m_lastKnownMousePosition = event.position(); | 3846 m_lastKnownMousePosition = event.position(); |
| 3847 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 3847 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
| 3848 } | 3848 } |
| 3849 | 3849 |
| 3850 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, LocalFrame* subframe) | 3850 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, LocalFrame* subframe) |
| 3851 { | 3851 { |
| 3852 // If we're clicking into a frame that is selected, the frame will appear | 3852 // If we're clicking into a frame that is selected, the frame will appear |
| 3853 // greyed out even though we're clicking on the selection. This looks | 3853 // greyed out even though we're clicking on the selection. This looks |
| 3854 // really strange (having the whole frame be greyed out), so we deselect the | 3854 // really strange (having the whole frame be greyed out), so we deselect the |
| 3855 // selection. | 3855 // selection. |
| 3856 IntPoint p = m_frame->view()->windowToContents(mev.event().position()); | 3856 IntPoint p = m_frame->view()->rootFrameToContents(mev.event().position()); |
| 3857 if (m_frame->selection().contains(p)) { | 3857 if (m_frame->selection().contains(p)) { |
| 3858 VisiblePosition visiblePos( | 3858 VisiblePosition visiblePos( |
| 3859 mev.innerNode()->renderer()->positionForPoint(mev.localPoint())); | 3859 mev.innerNode()->renderer()->positionForPoint(mev.localPoint())); |
| 3860 VisibleSelection newSelection(visiblePos); | 3860 VisibleSelection newSelection(visiblePos); |
| 3861 m_frame->selection().setSelection(newSelection); | 3861 m_frame->selection().setSelection(newSelection); |
| 3862 } | 3862 } |
| 3863 | 3863 |
| 3864 subframe->eventHandler().handleMousePressEvent(mev.event()); | 3864 subframe->eventHandler().handleMousePressEvent(mev.event()); |
| 3865 return true; | 3865 return true; |
| 3866 } | 3866 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3919 | 3919 |
| 3920 // If it's in the direction to hide the top controls, only consume when the
frame can also scroll. | 3920 // If it's in the direction to hide the top controls, only consume when the
frame can also scroll. |
| 3921 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo
sition().y()) | 3921 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo
sition().y()) |
| 3922 return true; | 3922 return true; |
| 3923 | 3923 |
| 3924 return false; | 3924 return false; |
| 3925 } | 3925 } |
| 3926 | 3926 |
| 3927 | 3927 |
| 3928 } // namespace blink | 3928 } // namespace blink |
| OLD | NEW |