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

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

Issue 2539283002: Remove PlatformGestureEvent in favour of using WebGestureEvent (Closed)
Patch Set: 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, gestureEvent.timeStampSeconds,
1632 WebPointerProperties::PointerType::Mouse); 1630 WebPointerProperties::PointerType::Mouse);
1633 1631
1634 // Update the mouseout/mouseleave event 1632 // Update the mouseout/mouseleave event
1635 size_t indexExitedFrameChain = exitedFrameChain.size(); 1633 size_t indexExitedFrameChain = exitedFrameChain.size();
1636 while (indexExitedFrameChain) { 1634 while (indexExitedFrameChain) {
1637 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain]; 1635 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain];
1638 leaveFrame->eventHandler().m_mouseEventManager->setNodeUnderMouse( 1636 leaveFrame->eventHandler().m_mouseEventManager->setNodeUnderMouse(
1639 updateMouseEventTargetNode(nullptr), fakeMouseMove); 1637 updateMouseEventTargetNode(nullptr), fakeMouseMove);
1640 } 1638 }
1641 1639
1642 // update the mouseover/mouseenter event 1640 // update the mouseover/mouseenter event
1643 while (indexEnteredFrameChain) { 1641 while (indexEnteredFrameChain) {
1644 Frame* parentFrame = 1642 Frame* parentFrame =
1645 enteredFrameChain[--indexEnteredFrameChain]->tree().parent(); 1643 enteredFrameChain[--indexEnteredFrameChain]->tree().parent();
1646 if (parentFrame && parentFrame->isLocalFrame()) 1644 if (parentFrame && parentFrame->isLocalFrame())
1647 toLocalFrame(parentFrame) 1645 toLocalFrame(parentFrame)
1648 ->eventHandler() 1646 ->eventHandler()
1649 .m_mouseEventManager->setNodeUnderMouse( 1647 .m_mouseEventManager->setNodeUnderMouse(
1650 updateMouseEventTargetNode(toHTMLFrameOwnerElement( 1648 updateMouseEventTargetNode(toHTMLFrameOwnerElement(
1651 enteredFrameChain[indexEnteredFrameChain]->owner())), 1649 enteredFrameChain[indexEnteredFrameChain]->owner())),
1652 fakeMouseMove); 1650 fakeMouseMove);
1653 } 1651 }
1654 } 1652 }
1655 1653
1656 GestureEventWithHitTestResults EventHandler::targetGestureEvent( 1654 GestureEventWithHitTestResults EventHandler::targetGestureEvent(
1657 const PlatformGestureEvent& gestureEvent, 1655 const WebGestureEvent& gestureEvent,
1658 bool readOnly) { 1656 bool readOnly) {
1659 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); 1657 TRACE_EVENT0("input", "EventHandler::targetGestureEvent");
1660 1658
1661 ASSERT(m_frame == m_frame->localFrameRoot()); 1659 ASSERT(m_frame == m_frame->localFrameRoot());
1662 // Scrolling events get hit tested per frame (like wheel events do). 1660 // Scrolling events get hit tested per frame (like wheel events do).
1663 ASSERT(!gestureEvent.isScrollEvent()); 1661 ASSERT(!gestureEvent.isScrollEvent());
1664 1662
1665 HitTestRequest::HitTestRequestType hitType = 1663 HitTestRequest::HitTestRequestType hitType =
1666 m_gestureManager->getHitTypeForGestureType(gestureEvent.type()); 1664 m_gestureManager->getHitTypeForGestureType(gestureEvent.type);
1667 double activeInterval = 0; 1665 double activeInterval = 0;
1668 bool shouldKeepActiveForMinInterval = false; 1666 bool shouldKeepActiveForMinInterval = false;
1669 if (readOnly) { 1667 if (readOnly) {
1670 hitType |= HitTestRequest::ReadOnly; 1668 hitType |= HitTestRequest::ReadOnly;
1671 } else if (gestureEvent.type() == PlatformEvent::GestureTap) { 1669 } else if (gestureEvent.type == WebInputEvent::GestureTap) {
1672 // If the Tap is received very shortly after ShowPress, we want to 1670 // 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 1671 // delay clearing of the active state so that it's visible to the user
1674 // for at least a couple of frames. 1672 // for at least a couple of frames.
1675 activeInterval = WTF::monotonicallyIncreasingTime() - 1673 activeInterval = WTF::monotonicallyIncreasingTime() -
1676 m_gestureManager->getLastShowPressTimestamp(); 1674 m_gestureManager->getLastShowPressTimestamp();
1677 shouldKeepActiveForMinInterval = 1675 shouldKeepActiveForMinInterval =
1678 m_gestureManager->getLastShowPressTimestamp() && 1676 m_gestureManager->getLastShowPressTimestamp() &&
1679 activeInterval < minimumActiveInterval; 1677 activeInterval < minimumActiveInterval;
1680 if (shouldKeepActiveForMinInterval) 1678 if (shouldKeepActiveForMinInterval)
1681 hitType |= HitTestRequest::ReadOnly; 1679 hitType |= HitTestRequest::ReadOnly;
(...skipping 12 matching lines...) Expand all
1694 eventWithHitTestResults.hitTestResult().innerElement(); 1692 eventWithHitTestResults.hitTestResult().innerElement();
1695 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. 1693 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this.
1696 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterval, 1694 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterval,
1697 BLINK_FROM_HERE); 1695 BLINK_FROM_HERE);
1698 } 1696 }
1699 1697
1700 return eventWithHitTestResults; 1698 return eventWithHitTestResults;
1701 } 1699 }
1702 1700
1703 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent( 1701 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(
1704 const PlatformGestureEvent& gestureEvent, 1702 const WebGestureEvent& gestureEvent,
1705 HitTestRequest::HitTestRequestType hitType) { 1703 HitTestRequest::HitTestRequestType hitType) {
1706 // Perform the rect-based hit-test (or point-based if adjustment is disabled). 1704 // 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 1705 // 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 1706 // resolve touch adjustment first so that we apply hover/active it to the
1709 // final adjusted node. 1707 // final adjusted node.
1710 IntPoint hitTestPoint = 1708 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(
1711 m_frame->view()->rootFrameToContents(gestureEvent.position()); 1709 flooredIntPoint(gestureEvent.positionInRootFrame()));
1712 LayoutSize padding; 1710 LayoutSize padding;
1713 if (shouldApplyTouchAdjustment(gestureEvent)) { 1711 if (shouldApplyTouchAdjustment(gestureEvent)) {
1714 padding = LayoutSize(gestureEvent.area()); 1712 padding = LayoutSize(gestureEvent.tapAreaInRootFrame());
1715 if (!padding.isEmpty()) { 1713 if (!padding.isEmpty()) {
1716 padding.scale(1.f / 2); 1714 padding.scale(1.f / 2);
1717 hitType |= HitTestRequest::ListBased; 1715 hitType |= HitTestRequest::ListBased;
1718 } 1716 }
1719 } 1717 }
1720 HitTestResult hitTestResult = hitTestResultAtPoint( 1718 HitTestResult hitTestResult = hitTestResultAtPoint(
1721 hitTestPoint, hitType | HitTestRequest::ReadOnly, padding); 1719 hitTestPoint, hitType | HitTestRequest::ReadOnly, padding);
1722 1720
1723 // Adjust the location of the gesture to the most likely nearby node, as 1721 // Adjust the location of the gesture to the most likely nearby node, as
1724 // appropriate for the type of event. 1722 // appropriate for the type of event.
1725 PlatformGestureEvent adjustedEvent = gestureEvent; 1723 WebGestureEvent adjustedEvent = gestureEvent;
1726 applyTouchAdjustment(&adjustedEvent, &hitTestResult); 1724 applyTouchAdjustment(&adjustedEvent, &hitTestResult);
1727 1725
1728 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessary 1726 // 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 1727 // 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 1728 // different node than what a point-based hit test would return for the same
1731 // point. 1729 // point.
1732 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. 1730 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test.
1733 // http://crbug.com/398914 1731 // http://crbug.com/398914
1734 if (shouldApplyTouchAdjustment(gestureEvent)) { 1732 if (shouldApplyTouchAdjustment(gestureEvent)) {
1735 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); 1733 LocalFrame* hitFrame = hitTestResult.innerNodeFrame();
1736 if (!hitFrame) 1734 if (!hitFrame)
1737 hitFrame = m_frame; 1735 hitFrame = m_frame;
1738 hitTestResult = EventHandlingUtil::hitTestResultInFrame( 1736 hitTestResult = EventHandlingUtil::hitTestResultInFrame(
1739 hitFrame, 1737 hitFrame, hitFrame->view()->rootFrameToContents(
1740 hitFrame->view()->rootFrameToContents(adjustedEvent.position()), 1738 flooredIntPoint(adjustedEvent.positionInRootFrame())),
1741 (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased); 1739 (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased);
1742 } 1740 }
1743 1741
1744 // If we did a rect-based hit test it must be resolved to the best single node 1742 // 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 1743 // by now to ensure consumers don't accidentally use one of the other
1746 // candidates. 1744 // candidates.
1747 ASSERT(!hitTestResult.isRectBasedTest()); 1745 ASSERT(!hitTestResult.isRectBasedTest());
1748 1746
1749 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); 1747 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult);
1750 } 1748 }
1751 1749
1752 void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, 1750 void EventHandler::applyTouchAdjustment(WebGestureEvent* gestureEvent,
1753 HitTestResult* hitTestResult) { 1751 HitTestResult* hitTestResult) {
1754 if (!shouldApplyTouchAdjustment(*gestureEvent)) 1752 if (!shouldApplyTouchAdjustment(*gestureEvent))
1755 return; 1753 return;
1756 1754
1757 Node* adjustedNode = nullptr; 1755 Node* adjustedNode = nullptr;
1758 IntPoint adjustedPoint = gestureEvent->position(); 1756 IntPoint adjustedPoint = flooredIntPoint(gestureEvent->positionInRootFrame());
1759 bool adjusted = false; 1757 bool adjusted = false;
1760 switch (gestureEvent->type()) { 1758 switch (gestureEvent->type) {
1761 case PlatformEvent::GestureTap: 1759 case WebInputEvent::GestureTap:
1762 case PlatformEvent::GestureTapUnconfirmed: 1760 case WebInputEvent::GestureTapUnconfirmed:
1763 case PlatformEvent::GestureTapDown: 1761 case WebInputEvent::GestureTapDown:
1764 case PlatformEvent::GestureShowPress: 1762 case WebInputEvent::GestureShowPress:
1765 adjusted = bestClickableNodeForHitTestResult(*hitTestResult, 1763 adjusted = bestClickableNodeForHitTestResult(*hitTestResult,
1766 adjustedPoint, adjustedNode); 1764 adjustedPoint, adjustedNode);
1767 break; 1765 break;
1768 case PlatformEvent::GestureLongPress: 1766 case WebInputEvent::GestureLongPress:
1769 case PlatformEvent::GestureLongTap: 1767 case WebInputEvent::GestureLongTap:
1770 case PlatformEvent::GestureTwoFingerTap: 1768 case WebInputEvent::GestureTwoFingerTap:
1771 adjusted = bestContextMenuNodeForHitTestResult( 1769 adjusted = bestContextMenuNodeForHitTestResult(
1772 *hitTestResult, adjustedPoint, adjustedNode); 1770 *hitTestResult, adjustedPoint, adjustedNode);
1773 break; 1771 break;
1774 default: 1772 default:
1775 ASSERT_NOT_REACHED(); 1773 ASSERT_NOT_REACHED();
1776 } 1774 }
1777 1775
1778 // Update the hit-test result to be a point-based result instead of a 1776 // Update the hit-test result to be a point-based result instead of a
1779 // rect-based result. 1777 // rect-based result.
1780 // FIXME: We should do this even when no candidate matches the node filter. 1778 // FIXME: We should do this even when no candidate matches the node filter.
1781 // crbug.com/398914 1779 // crbug.com/398914
1782 if (adjusted) { 1780 if (adjusted) {
1783 hitTestResult->resolveRectBasedTest( 1781 hitTestResult->resolveRectBasedTest(
1784 adjustedNode, m_frame->view()->rootFrameToContents(adjustedPoint)); 1782 adjustedNode, m_frame->view()->rootFrameToContents(adjustedPoint));
1785 gestureEvent->applyTouchAdjustment(adjustedPoint); 1783 gestureEvent->applyTouchAdjustment(
1784 WebFloatPoint(adjustedPoint.x(), adjustedPoint.y()));
1786 } 1785 }
1787 } 1786 }
1788 1787
1789 WebInputEventResult EventHandler::sendContextMenuEvent( 1788 WebInputEventResult EventHandler::sendContextMenuEvent(
1790 const PlatformMouseEvent& event, 1789 const PlatformMouseEvent& event,
1791 Node* overrideTargetNode) { 1790 Node* overrideTargetNode) {
1792 FrameView* v = m_frame->view(); 1791 FrameView* v = m_frame->view();
1793 if (!v) 1792 if (!v)
1794 return WebInputEventResult::NotHandled; 1793 return WebInputEventResult::NotHandled;
1795 1794
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 } 2128 }
2130 2129
2131 FrameHost* EventHandler::frameHost() const { 2130 FrameHost* EventHandler::frameHost() const {
2132 if (!m_frame->page()) 2131 if (!m_frame->page())
2133 return nullptr; 2132 return nullptr;
2134 2133
2135 return &m_frame->page()->frameHost(); 2134 return &m_frame->page()->frameHost();
2136 } 2135 }
2137 2136
2138 } // namespace blink 2137 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698