Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 2539283002: Remove PlatformGestureEvent in favour of using WebGestureEvent (Closed)
Patch Set: Rebase and fix comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #include "core/page/DragState.h" 80 #include "core/page/DragState.h"
81 #include "core/page/FocusController.h" 81 #include "core/page/FocusController.h"
82 #include "core/page/FrameTree.h" 82 #include "core/page/FrameTree.h"
83 #include "core/page/Page.h" 83 #include "core/page/Page.h"
84 #include "core/page/TouchAdjustment.h" 84 #include "core/page/TouchAdjustment.h"
85 #include "core/page/scrolling/ScrollState.h" 85 #include "core/page/scrolling/ScrollState.h"
86 #include "core/paint/PaintLayer.h" 86 #include "core/paint/PaintLayer.h"
87 #include "core/style/ComputedStyle.h" 87 #include "core/style/ComputedStyle.h"
88 #include "core/style/CursorData.h" 88 #include "core/style/CursorData.h"
89 #include "core/svg/SVGDocumentExtensions.h" 89 #include "core/svg/SVGDocumentExtensions.h"
90 #include "platform/PlatformGestureEvent.h"
91 #include "platform/PlatformTouchEvent.h" 90 #include "platform/PlatformTouchEvent.h"
92 #include "platform/PlatformWheelEvent.h" 91 #include "platform/PlatformWheelEvent.h"
93 #include "platform/RuntimeEnabledFeatures.h" 92 #include "platform/RuntimeEnabledFeatures.h"
94 #include "platform/WindowsKeyboardCodes.h" 93 #include "platform/WindowsKeyboardCodes.h"
95 #include "platform/geometry/FloatPoint.h" 94 #include "platform/geometry/FloatPoint.h"
96 #include "platform/graphics/Image.h" 95 #include "platform/graphics/Image.h"
97 #include "platform/heap/Handle.h" 96 #include "platform/heap/Handle.h"
98 #include "platform/scroll/ScrollAnimatorBase.h" 97 #include "platform/scroll/ScrollAnimatorBase.h"
99 #include "platform/scroll/Scrollbar.h" 98 #include "platform/scroll/Scrollbar.h"
100 #include "platform/tracing/TraceEvent.h" 99 #include "platform/tracing/TraceEvent.h"
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 WheelEvent::create(event, node->document().domWindow()); 1328 WheelEvent::create(event, node->document().domWindow());
1330 DispatchEventResult domEventResult = node->dispatchEvent(domEvent); 1329 DispatchEventResult domEventResult = node->dispatchEvent(domEvent);
1331 if (domEventResult != DispatchEventResult::NotCanceled) 1330 if (domEventResult != DispatchEventResult::NotCanceled)
1332 return EventHandlingUtil::toWebInputEventResult(domEventResult); 1331 return EventHandlingUtil::toWebInputEventResult(domEventResult);
1333 } 1332 }
1334 1333
1335 return WebInputEventResult::NotHandled; 1334 return WebInputEventResult::NotHandled;
1336 } 1335 }
1337 1336
1338 WebInputEventResult EventHandler::handleGestureEvent( 1337 WebInputEventResult EventHandler::handleGestureEvent(
1339 const PlatformGestureEvent& gestureEvent) { 1338 const WebGestureEvent& gestureEvent) {
1340 // Propagation to inner frames is handled below this function. 1339 // Propagation to inner frames is handled below this function.
1341 ASSERT(m_frame == m_frame->localFrameRoot()); 1340 ASSERT(m_frame == m_frame->localFrameRoot());
1342 1341
1343 // Scrolling-related gesture events invoke EventHandler recursively for each 1342 // Scrolling-related gesture events invoke EventHandler recursively for each
1344 // frame down the chain, doing a single-frame hit-test per frame. This matches 1343 // frame down the chain, doing a single-frame hit-test per frame. This matches
1345 // handleWheelEvent. 1344 // handleWheelEvent.
1346 // FIXME: Add a test that traverses this path, e.g. for devtools overlay. 1345 // FIXME: Add a test that traverses this path, e.g. for devtools overlay.
1347 if (gestureEvent.isScrollEvent()) 1346 if (gestureEvent.isScrollEvent())
1348 return handleGestureScrollEvent(gestureEvent); 1347 return handleGestureScrollEvent(gestureEvent);
1349 1348
(...skipping 14 matching lines...) Expand all
1364 // Propagation to inner frames is handled below this function. 1363 // Propagation to inner frames is handled below this function.
1365 ASSERT(m_frame == m_frame->localFrameRoot()); 1364 ASSERT(m_frame == m_frame->localFrameRoot());
1366 1365
1367 // Non-scrolling related gesture events do a single cross-frame hit-test and 1366 // Non-scrolling related gesture events do a single cross-frame hit-test and
1368 // jump directly to the inner most frame. This matches handleMousePressEvent 1367 // jump directly to the inner most frame. This matches handleMousePressEvent
1369 // etc. 1368 // etc.
1370 ASSERT(!targetedEvent.event().isScrollEvent()); 1369 ASSERT(!targetedEvent.event().isScrollEvent());
1371 1370
1372 // Update mouseout/leave/over/enter events before jumping directly to the 1371 // Update mouseout/leave/over/enter events before jumping directly to the
1373 // inner most frame. 1372 // inner most frame.
1374 if (targetedEvent.event().type() == PlatformEvent::GestureTap) 1373 if (targetedEvent.event().type == WebInputEvent::GestureTap)
1375 updateGestureTargetNodeForMouseEvent(targetedEvent); 1374 updateGestureTargetNodeForMouseEvent(targetedEvent);
1376 1375
1377 // Route to the correct frame. 1376 // Route to the correct frame.
1378 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) 1377 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame())
1379 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEvent); 1378 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEvent);
1380 1379
1381 // No hit test result, handle in root instance. Perhaps we should just return 1380 // No hit test result, handle in root instance. Perhaps we should just return
1382 // false instead? 1381 // false instead?
1383 return m_gestureManager->handleGestureEventInFrame(targetedEvent); 1382 return m_gestureManager->handleGestureEventInFrame(targetedEvent);
1384 } 1383 }
1385 1384
1386 WebInputEventResult EventHandler::handleGestureEventInFrame( 1385 WebInputEventResult EventHandler::handleGestureEventInFrame(
1387 const GestureEventWithHitTestResults& targetedEvent) { 1386 const GestureEventWithHitTestResults& targetedEvent) {
1388 return m_gestureManager->handleGestureEventInFrame(targetedEvent); 1387 return m_gestureManager->handleGestureEventInFrame(targetedEvent);
1389 } 1388 }
1390 1389
1391 WebInputEventResult EventHandler::handleGestureScrollEvent( 1390 WebInputEventResult EventHandler::handleGestureScrollEvent(
1392 const PlatformGestureEvent& gestureEvent) { 1391 const WebGestureEvent& gestureEvent) {
1393 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); 1392 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent");
1394 if (!m_frame->host()) 1393 if (!m_frame->host())
1395 return WebInputEventResult::NotHandled; 1394 return WebInputEventResult::NotHandled;
1396 1395
1397 return m_scrollManager->handleGestureScrollEvent(gestureEvent); 1396 return m_scrollManager->handleGestureScrollEvent(gestureEvent);
1398 } 1397 }
1399 1398
1400 WebInputEventResult EventHandler::handleGestureScrollEnd( 1399 WebInputEventResult EventHandler::handleGestureScrollEnd(
1401 const PlatformGestureEvent& gestureEvent) { 1400 const WebGestureEvent& gestureEvent) {
1402 if (!m_frame->host()) 1401 if (!m_frame->host())
1403 return WebInputEventResult::NotHandled; 1402 return WebInputEventResult::NotHandled;
1404
1405 return m_scrollManager->handleGestureScrollEnd(gestureEvent); 1403 return m_scrollManager->handleGestureScrollEnd(gestureEvent);
1406 } 1404 }
1407 1405
1408 void EventHandler::setMouseDownMayStartAutoscroll() { 1406 void EventHandler::setMouseDownMayStartAutoscroll() {
1409 m_mouseEventManager->setMouseDownMayStartAutoscroll(); 1407 m_mouseEventManager->setMouseDownMayStartAutoscroll();
1410 } 1408 }
1411 1409
1412 bool EventHandler::isScrollbarHandlingGestures() const { 1410 bool EventHandler::isScrollbarHandlingGestures() const {
1413 return m_scrollManager->isScrollbarHandlingGestures(); 1411 return m_scrollManager->isScrollbarHandlingGestures();
1414 } 1412 }
1415 1413
1416 bool EventHandler::shouldApplyTouchAdjustment( 1414 bool EventHandler::shouldApplyTouchAdjustment(
1417 const PlatformGestureEvent& event) const { 1415 const WebGestureEvent& event) const {
1418 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) 1416 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled())
1419 return false; 1417 return false;
1420 return !event.area().isEmpty(); 1418 return !event.tapAreaInRootFrame().isEmpty();
1421 } 1419 }
1422 1420
1423 bool EventHandler::bestClickableNodeForHitTestResult( 1421 bool EventHandler::bestClickableNodeForHitTestResult(
1424 const HitTestResult& result, 1422 const HitTestResult& result,
1425 IntPoint& targetPoint, 1423 IntPoint& targetPoint,
1426 Node*& targetNode) { 1424 Node*& targetNode) {
1427 // FIXME: Unify this with the other best* functions which are very similar. 1425 // FIXME: Unify this with the other best* functions which are very similar.
1428 1426
1429 TRACE_EVENT0("input", "EventHandler::bestClickableNodeForHitTestResult"); 1427 TRACE_EVENT0("input", "EventHandler::bestClickableNodeForHitTestResult");
1430 ASSERT(result.isRectBasedTest()); 1428 ASSERT(result.isRectBasedTest());
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 indexEnteredFrameChain ? enteredFrameChain[indexEnteredFrameChain - 1] 1613 indexEnteredFrameChain ? enteredFrameChain[indexEnteredFrameChain - 1]
1616 : nullptr; 1614 : nullptr;
1617 if (exitedFrameInDocument != lastEnteredFrameInDocument) 1615 if (exitedFrameInDocument != lastEnteredFrameInDocument)
1618 exitedFrameChain.append(exitedFrameInDocument); 1616 exitedFrameChain.append(exitedFrameInDocument);
1619 else if (nextExitedFrameInDocument && indexEnteredFrameChain) 1617 else if (nextExitedFrameInDocument && indexEnteredFrameChain)
1620 --indexEnteredFrameChain; 1618 --indexEnteredFrameChain;
1621 } 1619 }
1622 exitedFrameInDocument = nextExitedFrameInDocument; 1620 exitedFrameInDocument = nextExitedFrameInDocument;
1623 } 1621 }
1624 1622
1625 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 1623 const WebGestureEvent& gestureEvent = targetedEvent.event();
1626 unsigned modifiers = gestureEvent.getModifiers(); 1624 unsigned modifiers = gestureEvent.modifiers;
1627 PlatformMouseEvent fakeMouseMove( 1625 PlatformMouseEvent fakeMouseMove(
1628 gestureEvent.position(), gestureEvent.globalPosition(), 1626 gestureEvent, WebPointerProperties::Button::NoButton,
1629 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 1627 PlatformEvent::MouseMoved,
1630 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers), 1628 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers),
1631 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 1629 PlatformMouseEvent::FromTouch,
1630 TimeTicks::FromSeconds(gestureEvent.timeStampSeconds),
1632 WebPointerProperties::PointerType::Mouse); 1631 WebPointerProperties::PointerType::Mouse);
1633 1632
1634 // Update the mouseout/mouseleave event 1633 // Update the mouseout/mouseleave event
1635 size_t indexExitedFrameChain = exitedFrameChain.size(); 1634 size_t indexExitedFrameChain = exitedFrameChain.size();
1636 while (indexExitedFrameChain) { 1635 while (indexExitedFrameChain) {
1637 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain]; 1636 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain];
1638 leaveFrame->eventHandler().m_mouseEventManager->setNodeUnderMouse( 1637 leaveFrame->eventHandler().m_mouseEventManager->setNodeUnderMouse(
1639 updateMouseEventTargetNode(nullptr), fakeMouseMove); 1638 updateMouseEventTargetNode(nullptr), fakeMouseMove);
1640 } 1639 }
1641 1640
1642 // update the mouseover/mouseenter event 1641 // update the mouseover/mouseenter event
1643 while (indexEnteredFrameChain) { 1642 while (indexEnteredFrameChain) {
1644 Frame* parentFrame = 1643 Frame* parentFrame =
1645 enteredFrameChain[--indexEnteredFrameChain]->tree().parent(); 1644 enteredFrameChain[--indexEnteredFrameChain]->tree().parent();
1646 if (parentFrame && parentFrame->isLocalFrame()) 1645 if (parentFrame && parentFrame->isLocalFrame())
1647 toLocalFrame(parentFrame) 1646 toLocalFrame(parentFrame)
1648 ->eventHandler() 1647 ->eventHandler()
1649 .m_mouseEventManager->setNodeUnderMouse( 1648 .m_mouseEventManager->setNodeUnderMouse(
1650 updateMouseEventTargetNode(toHTMLFrameOwnerElement( 1649 updateMouseEventTargetNode(toHTMLFrameOwnerElement(
1651 enteredFrameChain[indexEnteredFrameChain]->owner())), 1650 enteredFrameChain[indexEnteredFrameChain]->owner())),
1652 fakeMouseMove); 1651 fakeMouseMove);
1653 } 1652 }
1654 } 1653 }
1655 1654
1656 GestureEventWithHitTestResults EventHandler::targetGestureEvent( 1655 GestureEventWithHitTestResults EventHandler::targetGestureEvent(
1657 const PlatformGestureEvent& gestureEvent, 1656 const WebGestureEvent& gestureEvent,
1658 bool readOnly) { 1657 bool readOnly) {
1659 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); 1658 TRACE_EVENT0("input", "EventHandler::targetGestureEvent");
1660 1659
1661 ASSERT(m_frame == m_frame->localFrameRoot()); 1660 ASSERT(m_frame == m_frame->localFrameRoot());
1662 // Scrolling events get hit tested per frame (like wheel events do). 1661 // Scrolling events get hit tested per frame (like wheel events do).
1663 ASSERT(!gestureEvent.isScrollEvent()); 1662 ASSERT(!gestureEvent.isScrollEvent());
1664 1663
1665 HitTestRequest::HitTestRequestType hitType = 1664 HitTestRequest::HitTestRequestType hitType =
1666 m_gestureManager->getHitTypeForGestureType(gestureEvent.type()); 1665 m_gestureManager->getHitTypeForGestureType(gestureEvent.type);
1667 TimeDelta activeInterval; 1666 TimeDelta activeInterval;
1668 bool shouldKeepActiveForMinInterval = false; 1667 bool shouldKeepActiveForMinInterval = false;
1669 if (readOnly) { 1668 if (readOnly) {
1670 hitType |= HitTestRequest::ReadOnly; 1669 hitType |= HitTestRequest::ReadOnly;
1671 } else if (gestureEvent.type() == PlatformEvent::GestureTap) { 1670 } else if (gestureEvent.type == WebInputEvent::GestureTap) {
1672 // If the Tap is received very shortly after ShowPress, we want to 1671 // If the Tap is received very shortly after ShowPress, we want to
1673 // delay clearing of the active state so that it's visible to the user 1672 // delay clearing of the active state so that it's visible to the user
1674 // for at least a couple of frames. 1673 // for at least a couple of frames.
1675 activeInterval = 1674 activeInterval =
1676 TimeTicks::Now() - m_gestureManager->getLastShowPressTimestamp(); 1675 TimeTicks::Now() - m_gestureManager->getLastShowPressTimestamp();
1677 shouldKeepActiveForMinInterval = 1676 shouldKeepActiveForMinInterval =
1678 !m_gestureManager->getLastShowPressTimestamp().isNull() && 1677 !m_gestureManager->getLastShowPressTimestamp().isNull() &&
1679 activeInterval < minimumActiveInterval; 1678 activeInterval < minimumActiveInterval;
1680 if (shouldKeepActiveForMinInterval) 1679 if (shouldKeepActiveForMinInterval)
1681 hitType |= HitTestRequest::ReadOnly; 1680 hitType |= HitTestRequest::ReadOnly;
(...skipping 12 matching lines...) Expand all
1694 eventWithHitTestResults.hitTestResult().innerElement(); 1693 eventWithHitTestResults.hitTestResult().innerElement();
1695 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. 1694 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this.
1696 m_activeIntervalTimer.startOneShot( 1695 m_activeIntervalTimer.startOneShot(
1697 (minimumActiveInterval - activeInterval).InSecondsF(), BLINK_FROM_HERE); 1696 (minimumActiveInterval - activeInterval).InSecondsF(), BLINK_FROM_HERE);
1698 } 1697 }
1699 1698
1700 return eventWithHitTestResults; 1699 return eventWithHitTestResults;
1701 } 1700 }
1702 1701
1703 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent( 1702 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(
1704 const PlatformGestureEvent& gestureEvent, 1703 const WebGestureEvent& gestureEvent,
1705 HitTestRequest::HitTestRequestType hitType) { 1704 HitTestRequest::HitTestRequestType hitType) {
1706 // Perform the rect-based hit-test (or point-based if adjustment is disabled). 1705 // Perform the rect-based hit-test (or point-based if adjustment is disabled).
1707 // Note that we don't yet apply hover/active state here because we need to 1706 // Note that we don't yet apply hover/active state here because we need to
1708 // resolve touch adjustment first so that we apply hover/active it to the 1707 // resolve touch adjustment first so that we apply hover/active it to the
1709 // final adjusted node. 1708 // final adjusted node.
1710 IntPoint hitTestPoint = 1709 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(
1711 m_frame->view()->rootFrameToContents(gestureEvent.position()); 1710 flooredIntPoint(gestureEvent.positionInRootFrame()));
1712 LayoutSize padding; 1711 LayoutSize padding;
1713 if (shouldApplyTouchAdjustment(gestureEvent)) { 1712 if (shouldApplyTouchAdjustment(gestureEvent)) {
1714 padding = LayoutSize(gestureEvent.area()); 1713 padding = LayoutSize(gestureEvent.tapAreaInRootFrame());
1715 if (!padding.isEmpty()) { 1714 if (!padding.isEmpty()) {
1716 padding.scale(1.f / 2); 1715 padding.scale(1.f / 2);
1717 hitType |= HitTestRequest::ListBased; 1716 hitType |= HitTestRequest::ListBased;
1718 } 1717 }
1719 } 1718 }
1720 HitTestResult hitTestResult = hitTestResultAtPoint( 1719 HitTestResult hitTestResult = hitTestResultAtPoint(
1721 hitTestPoint, hitType | HitTestRequest::ReadOnly, padding); 1720 hitTestPoint, hitType | HitTestRequest::ReadOnly, padding);
1722 1721
1723 // Adjust the location of the gesture to the most likely nearby node, as 1722 // Adjust the location of the gesture to the most likely nearby node, as
1724 // appropriate for the type of event. 1723 // appropriate for the type of event.
1725 PlatformGestureEvent adjustedEvent = gestureEvent; 1724 WebGestureEvent adjustedEvent = gestureEvent;
1726 applyTouchAdjustment(&adjustedEvent, &hitTestResult); 1725 applyTouchAdjustment(&adjustedEvent, &hitTestResult);
1727 1726
1728 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessary 1727 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessary
1729 // because rect-based hit testing and touch adjustment sometimes return a 1728 // because rect-based hit testing and touch adjustment sometimes return a
1730 // different node than what a point-based hit test would return for the same 1729 // different node than what a point-based hit test would return for the same
1731 // point. 1730 // point.
1732 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. 1731 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test.
1733 // http://crbug.com/398914 1732 // http://crbug.com/398914
1734 if (shouldApplyTouchAdjustment(gestureEvent)) { 1733 if (shouldApplyTouchAdjustment(gestureEvent)) {
1735 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); 1734 LocalFrame* hitFrame = hitTestResult.innerNodeFrame();
1736 if (!hitFrame) 1735 if (!hitFrame)
1737 hitFrame = m_frame; 1736 hitFrame = m_frame;
1738 hitTestResult = EventHandlingUtil::hitTestResultInFrame( 1737 hitTestResult = EventHandlingUtil::hitTestResultInFrame(
1739 hitFrame, 1738 hitFrame, hitFrame->view()->rootFrameToContents(
1740 hitFrame->view()->rootFrameToContents(adjustedEvent.position()), 1739 flooredIntPoint(adjustedEvent.positionInRootFrame())),
1741 (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased); 1740 (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased);
1742 } 1741 }
1743 1742
1744 // If we did a rect-based hit test it must be resolved to the best single node 1743 // If we did a rect-based hit test it must be resolved to the best single node
1745 // by now to ensure consumers don't accidentally use one of the other 1744 // by now to ensure consumers don't accidentally use one of the other
1746 // candidates. 1745 // candidates.
1747 ASSERT(!hitTestResult.isRectBasedTest()); 1746 ASSERT(!hitTestResult.isRectBasedTest());
1748 1747
1749 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); 1748 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult);
1750 } 1749 }
1751 1750
1752 void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, 1751 void EventHandler::applyTouchAdjustment(WebGestureEvent* gestureEvent,
1753 HitTestResult* hitTestResult) { 1752 HitTestResult* hitTestResult) {
1754 if (!shouldApplyTouchAdjustment(*gestureEvent)) 1753 if (!shouldApplyTouchAdjustment(*gestureEvent))
1755 return; 1754 return;
1756 1755
1757 Node* adjustedNode = nullptr; 1756 Node* adjustedNode = nullptr;
1758 IntPoint adjustedPoint = gestureEvent->position(); 1757 IntPoint adjustedPoint = flooredIntPoint(gestureEvent->positionInRootFrame());
1759 bool adjusted = false; 1758 bool adjusted = false;
1760 switch (gestureEvent->type()) { 1759 switch (gestureEvent->type) {
1761 case PlatformEvent::GestureTap: 1760 case WebInputEvent::GestureTap:
1762 case PlatformEvent::GestureTapUnconfirmed: 1761 case WebInputEvent::GestureTapUnconfirmed:
1763 case PlatformEvent::GestureTapDown: 1762 case WebInputEvent::GestureTapDown:
1764 case PlatformEvent::GestureShowPress: 1763 case WebInputEvent::GestureShowPress:
1765 adjusted = bestClickableNodeForHitTestResult(*hitTestResult, 1764 adjusted = bestClickableNodeForHitTestResult(*hitTestResult,
1766 adjustedPoint, adjustedNode); 1765 adjustedPoint, adjustedNode);
majidvp 2016/12/15 17:40:45 UGH! The adjustedPoint here is actually an output
dtapuska 2016/12/15 21:29:38 Acknowledged.
1767 break; 1766 break;
1768 case PlatformEvent::GestureLongPress: 1767 case WebInputEvent::GestureLongPress:
1769 case PlatformEvent::GestureLongTap: 1768 case WebInputEvent::GestureLongTap:
1770 case PlatformEvent::GestureTwoFingerTap: 1769 case WebInputEvent::GestureTwoFingerTap:
1771 adjusted = bestContextMenuNodeForHitTestResult( 1770 adjusted = bestContextMenuNodeForHitTestResult(
1772 *hitTestResult, adjustedPoint, adjustedNode); 1771 *hitTestResult, adjustedPoint, adjustedNode);
1773 break; 1772 break;
1774 default: 1773 default:
1775 ASSERT_NOT_REACHED(); 1774 ASSERT_NOT_REACHED();
1776 } 1775 }
1777 1776
1778 // Update the hit-test result to be a point-based result instead of a 1777 // Update the hit-test result to be a point-based result instead of a
1779 // rect-based result. 1778 // rect-based result.
1780 // FIXME: We should do this even when no candidate matches the node filter. 1779 // FIXME: We should do this even when no candidate matches the node filter.
1781 // crbug.com/398914 1780 // crbug.com/398914
1782 if (adjusted) { 1781 if (adjusted) {
1783 hitTestResult->resolveRectBasedTest( 1782 hitTestResult->resolveRectBasedTest(
1784 adjustedNode, m_frame->view()->rootFrameToContents(adjustedPoint)); 1783 adjustedNode, m_frame->view()->rootFrameToContents(adjustedPoint));
1785 gestureEvent->applyTouchAdjustment(adjustedPoint); 1784 gestureEvent->applyTouchAdjustment(
1785 WebFloatPoint(adjustedPoint.x(), adjustedPoint.y()));
1786 } 1786 }
1787 } 1787 }
1788 1788
1789 WebInputEventResult EventHandler::sendContextMenuEvent( 1789 WebInputEventResult EventHandler::sendContextMenuEvent(
1790 const PlatformMouseEvent& event, 1790 const PlatformMouseEvent& event,
1791 Node* overrideTargetNode) { 1791 Node* overrideTargetNode) {
1792 FrameView* v = m_frame->view(); 1792 FrameView* v = m_frame->view();
1793 if (!v) 1793 if (!v)
1794 return WebInputEventResult::NotHandled; 1794 return WebInputEventResult::NotHandled;
1795 1795
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 } 2128 }
2129 2129
2130 FrameHost* EventHandler::frameHost() const { 2130 FrameHost* EventHandler::frameHost() const {
2131 if (!m_frame->page()) 2131 if (!m_frame->page())
2132 return nullptr; 2132 return nullptr;
2133 2133
2134 return &m_frame->page()->frameHost(); 2134 return &m_frame->page()->frameHost();
2135 } 2135 }
2136 2136
2137 } // namespace blink 2137 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698