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

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

Issue 2539283002: Remove PlatformGestureEvent in favour of using WebGestureEvent (Closed)
Patch Set: Add missing copyright on new file 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());
1341 DCHECK_NE(0, gestureEvent.frameScale());
1342 1342
1343 // Scrolling-related gesture events invoke EventHandler recursively for each 1343 // Scrolling-related gesture events invoke EventHandler recursively for each
1344 // frame down the chain, doing a single-frame hit-test per frame. This matches 1344 // frame down the chain, doing a single-frame hit-test per frame. This matches
1345 // handleWheelEvent. 1345 // handleWheelEvent.
1346 // FIXME: Add a test that traverses this path, e.g. for devtools overlay. 1346 // FIXME: Add a test that traverses this path, e.g. for devtools overlay.
1347 if (gestureEvent.isScrollEvent()) 1347 if (gestureEvent.isScrollEvent())
1348 return handleGestureScrollEvent(gestureEvent); 1348 return handleGestureScrollEvent(gestureEvent);
1349 1349
1350 // Hit test across all frames and do touch adjustment as necessary for the 1350 // Hit test across all frames and do touch adjustment as necessary for the
1351 // event type. 1351 // event type.
(...skipping 12 matching lines...) Expand all
1364 // Propagation to inner frames is handled below this function. 1364 // Propagation to inner frames is handled below this function.
1365 ASSERT(m_frame == m_frame->localFrameRoot()); 1365 ASSERT(m_frame == m_frame->localFrameRoot());
1366 1366
1367 // Non-scrolling related gesture events do a single cross-frame hit-test and 1367 // Non-scrolling related gesture events do a single cross-frame hit-test and
1368 // jump directly to the inner most frame. This matches handleMousePressEvent 1368 // jump directly to the inner most frame. This matches handleMousePressEvent
1369 // etc. 1369 // etc.
1370 ASSERT(!targetedEvent.event().isScrollEvent()); 1370 ASSERT(!targetedEvent.event().isScrollEvent());
1371 1371
1372 // Update mouseout/leave/over/enter events before jumping directly to the 1372 // Update mouseout/leave/over/enter events before jumping directly to the
1373 // inner most frame. 1373 // inner most frame.
1374 if (targetedEvent.event().type() == PlatformEvent::GestureTap) 1374 if (targetedEvent.event().type == WebInputEvent::GestureTap)
1375 updateGestureTargetNodeForMouseEvent(targetedEvent); 1375 updateGestureTargetNodeForMouseEvent(targetedEvent);
1376 1376
1377 // Route to the correct frame. 1377 // Route to the correct frame.
1378 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) 1378 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame())
1379 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEvent); 1379 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEvent);
1380 1380
1381 // No hit test result, handle in root instance. Perhaps we should just return 1381 // No hit test result, handle in root instance. Perhaps we should just return
1382 // false instead? 1382 // false instead?
1383 return m_gestureManager->handleGestureEventInFrame(targetedEvent); 1383 return m_gestureManager->handleGestureEventInFrame(targetedEvent);
1384 } 1384 }
1385 1385
1386 WebInputEventResult EventHandler::handleGestureEventInFrame( 1386 WebInputEventResult EventHandler::handleGestureEventInFrame(
1387 const GestureEventWithHitTestResults& targetedEvent) { 1387 const GestureEventWithHitTestResults& targetedEvent) {
1388 return m_gestureManager->handleGestureEventInFrame(targetedEvent); 1388 return m_gestureManager->handleGestureEventInFrame(targetedEvent);
1389 } 1389 }
1390 1390
1391 WebInputEventResult EventHandler::handleGestureScrollEvent( 1391 WebInputEventResult EventHandler::handleGestureScrollEvent(
1392 const PlatformGestureEvent& gestureEvent) { 1392 const WebGestureEvent& gestureEvent) {
1393 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); 1393 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent");
1394 if (!m_frame->host()) 1394 if (!m_frame->host())
1395 return WebInputEventResult::NotHandled; 1395 return WebInputEventResult::NotHandled;
1396 1396
1397 return m_scrollManager->handleGestureScrollEvent(gestureEvent); 1397 return m_scrollManager->handleGestureScrollEvent(gestureEvent);
1398 } 1398 }
1399 1399
1400 WebInputEventResult EventHandler::handleGestureScrollEnd( 1400 WebInputEventResult EventHandler::handleGestureScrollEnd(
1401 const PlatformGestureEvent& gestureEvent) { 1401 const WebGestureEvent& gestureEvent) {
1402 if (!m_frame->host()) 1402 if (!m_frame->host())
1403 return WebInputEventResult::NotHandled; 1403 return WebInputEventResult::NotHandled;
1404
1405 return m_scrollManager->handleGestureScrollEnd(gestureEvent); 1404 return m_scrollManager->handleGestureScrollEnd(gestureEvent);
1406 } 1405 }
1407 1406
1408 void EventHandler::setMouseDownMayStartAutoscroll() { 1407 void EventHandler::setMouseDownMayStartAutoscroll() {
1409 m_mouseEventManager->setMouseDownMayStartAutoscroll(); 1408 m_mouseEventManager->setMouseDownMayStartAutoscroll();
1410 } 1409 }
1411 1410
1412 bool EventHandler::isScrollbarHandlingGestures() const { 1411 bool EventHandler::isScrollbarHandlingGestures() const {
1413 return m_scrollManager->isScrollbarHandlingGestures(); 1412 return m_scrollManager->isScrollbarHandlingGestures();
1414 } 1413 }
1415 1414
1416 bool EventHandler::shouldApplyTouchAdjustment( 1415 bool EventHandler::shouldApplyTouchAdjustment(
1417 const PlatformGestureEvent& event) const { 1416 const WebGestureEvent& event) const {
1418 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) 1417 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled())
1419 return false; 1418 return false;
1420 return !event.area().isEmpty(); 1419 return !event.tapAreaInRootFrame().isEmpty();
1421 } 1420 }
1422 1421
1423 bool EventHandler::bestClickableNodeForHitTestResult( 1422 bool EventHandler::bestClickableNodeForHitTestResult(
1424 const HitTestResult& result, 1423 const HitTestResult& result,
1425 IntPoint& targetPoint, 1424 IntPoint& targetPoint,
1426 Node*& targetNode) { 1425 Node*& targetNode) {
1427 // FIXME: Unify this with the other best* functions which are very similar. 1426 // FIXME: Unify this with the other best* functions which are very similar.
1428 1427
1429 TRACE_EVENT0("input", "EventHandler::bestClickableNodeForHitTestResult"); 1428 TRACE_EVENT0("input", "EventHandler::bestClickableNodeForHitTestResult");
1430 ASSERT(result.isRectBasedTest()); 1429 ASSERT(result.isRectBasedTest());
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 indexEnteredFrameChain ? enteredFrameChain[indexEnteredFrameChain - 1] 1614 indexEnteredFrameChain ? enteredFrameChain[indexEnteredFrameChain - 1]
1616 : nullptr; 1615 : nullptr;
1617 if (exitedFrameInDocument != lastEnteredFrameInDocument) 1616 if (exitedFrameInDocument != lastEnteredFrameInDocument)
1618 exitedFrameChain.append(exitedFrameInDocument); 1617 exitedFrameChain.append(exitedFrameInDocument);
1619 else if (nextExitedFrameInDocument && indexEnteredFrameChain) 1618 else if (nextExitedFrameInDocument && indexEnteredFrameChain)
1620 --indexEnteredFrameChain; 1619 --indexEnteredFrameChain;
1621 } 1620 }
1622 exitedFrameInDocument = nextExitedFrameInDocument; 1621 exitedFrameInDocument = nextExitedFrameInDocument;
1623 } 1622 }
1624 1623
1625 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 1624 const WebGestureEvent& gestureEvent = targetedEvent.event();
1626 unsigned modifiers = gestureEvent.getModifiers(); 1625 unsigned modifiers = gestureEvent.modifiers;
1627 PlatformMouseEvent fakeMouseMove( 1626 PlatformMouseEvent fakeMouseMove(
1628 gestureEvent.position(), gestureEvent.globalPosition(), 1627 gestureEvent, WebPointerProperties::Button::NoButton,
1629 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 1628 PlatformEvent::MouseMoved,
1630 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers), 1629 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers),
1631 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 1630 PlatformMouseEvent::FromTouch,
1631 TimeTicks::FromSeconds(gestureEvent.timeStampSeconds),
1632 WebPointerProperties::PointerType::Mouse); 1632 WebPointerProperties::PointerType::Mouse);
1633 1633
1634 // Update the mouseout/mouseleave event 1634 // Update the mouseout/mouseleave event
1635 size_t indexExitedFrameChain = exitedFrameChain.size(); 1635 size_t indexExitedFrameChain = exitedFrameChain.size();
1636 while (indexExitedFrameChain) { 1636 while (indexExitedFrameChain) {
1637 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain]; 1637 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain];
1638 leaveFrame->eventHandler().m_mouseEventManager->setNodeUnderMouse( 1638 leaveFrame->eventHandler().m_mouseEventManager->setNodeUnderMouse(
1639 updateMouseEventTargetNode(nullptr), fakeMouseMove); 1639 updateMouseEventTargetNode(nullptr), fakeMouseMove);
1640 } 1640 }
1641 1641
1642 // update the mouseover/mouseenter event 1642 // update the mouseover/mouseenter event
1643 while (indexEnteredFrameChain) { 1643 while (indexEnteredFrameChain) {
1644 Frame* parentFrame = 1644 Frame* parentFrame =
1645 enteredFrameChain[--indexEnteredFrameChain]->tree().parent(); 1645 enteredFrameChain[--indexEnteredFrameChain]->tree().parent();
1646 if (parentFrame && parentFrame->isLocalFrame()) 1646 if (parentFrame && parentFrame->isLocalFrame())
1647 toLocalFrame(parentFrame) 1647 toLocalFrame(parentFrame)
1648 ->eventHandler() 1648 ->eventHandler()
1649 .m_mouseEventManager->setNodeUnderMouse( 1649 .m_mouseEventManager->setNodeUnderMouse(
1650 updateMouseEventTargetNode(toHTMLFrameOwnerElement( 1650 updateMouseEventTargetNode(toHTMLFrameOwnerElement(
1651 enteredFrameChain[indexEnteredFrameChain]->owner())), 1651 enteredFrameChain[indexEnteredFrameChain]->owner())),
1652 fakeMouseMove); 1652 fakeMouseMove);
1653 } 1653 }
1654 } 1654 }
1655 1655
1656 GestureEventWithHitTestResults EventHandler::targetGestureEvent( 1656 GestureEventWithHitTestResults EventHandler::targetGestureEvent(
1657 const PlatformGestureEvent& gestureEvent, 1657 const WebGestureEvent& gestureEvent,
1658 bool readOnly) { 1658 bool readOnly) {
1659 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); 1659 TRACE_EVENT0("input", "EventHandler::targetGestureEvent");
1660 1660
1661 ASSERT(m_frame == m_frame->localFrameRoot()); 1661 ASSERT(m_frame == m_frame->localFrameRoot());
1662 // Scrolling events get hit tested per frame (like wheel events do). 1662 // Scrolling events get hit tested per frame (like wheel events do).
1663 ASSERT(!gestureEvent.isScrollEvent()); 1663 ASSERT(!gestureEvent.isScrollEvent());
1664 1664
1665 HitTestRequest::HitTestRequestType hitType = 1665 HitTestRequest::HitTestRequestType hitType =
1666 m_gestureManager->getHitTypeForGestureType(gestureEvent.type()); 1666 m_gestureManager->getHitTypeForGestureType(gestureEvent.type);
1667 TimeDelta activeInterval; 1667 TimeDelta activeInterval;
1668 bool shouldKeepActiveForMinInterval = false; 1668 bool shouldKeepActiveForMinInterval = false;
1669 if (readOnly) { 1669 if (readOnly) {
1670 hitType |= HitTestRequest::ReadOnly; 1670 hitType |= HitTestRequest::ReadOnly;
1671 } else if (gestureEvent.type() == PlatformEvent::GestureTap) { 1671 } else if (gestureEvent.type == WebInputEvent::GestureTap) {
1672 // If the Tap is received very shortly after ShowPress, we want to 1672 // 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 1673 // delay clearing of the active state so that it's visible to the user
1674 // for at least a couple of frames. 1674 // for at least a couple of frames.
1675 activeInterval = 1675 activeInterval =
1676 TimeTicks::Now() - m_gestureManager->getLastShowPressTimestamp(); 1676 TimeTicks::Now() - m_gestureManager->getLastShowPressTimestamp();
1677 shouldKeepActiveForMinInterval = 1677 shouldKeepActiveForMinInterval =
1678 !m_gestureManager->getLastShowPressTimestamp().isNull() && 1678 !m_gestureManager->getLastShowPressTimestamp().isNull() &&
1679 activeInterval < minimumActiveInterval; 1679 activeInterval < minimumActiveInterval;
1680 if (shouldKeepActiveForMinInterval) 1680 if (shouldKeepActiveForMinInterval)
1681 hitType |= HitTestRequest::ReadOnly; 1681 hitType |= HitTestRequest::ReadOnly;
(...skipping 12 matching lines...) Expand all
1694 eventWithHitTestResults.hitTestResult().innerElement(); 1694 eventWithHitTestResults.hitTestResult().innerElement();
1695 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. 1695 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this.
1696 m_activeIntervalTimer.startOneShot( 1696 m_activeIntervalTimer.startOneShot(
1697 (minimumActiveInterval - activeInterval).InSecondsF(), BLINK_FROM_HERE); 1697 (minimumActiveInterval - activeInterval).InSecondsF(), BLINK_FROM_HERE);
1698 } 1698 }
1699 1699
1700 return eventWithHitTestResults; 1700 return eventWithHitTestResults;
1701 } 1701 }
1702 1702
1703 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent( 1703 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(
1704 const PlatformGestureEvent& gestureEvent, 1704 const WebGestureEvent& gestureEvent,
1705 HitTestRequest::HitTestRequestType hitType) { 1705 HitTestRequest::HitTestRequestType hitType) {
1706 // Perform the rect-based hit-test (or point-based if adjustment is disabled). 1706 // 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 1707 // 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 1708 // resolve touch adjustment first so that we apply hover/active it to the
1709 // final adjusted node. 1709 // final adjusted node.
1710 IntPoint hitTestPoint = 1710 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(
1711 m_frame->view()->rootFrameToContents(gestureEvent.position()); 1711 flooredIntPoint(gestureEvent.positionInRootFrame()));
1712 LayoutSize padding; 1712 LayoutSize padding;
1713 if (shouldApplyTouchAdjustment(gestureEvent)) { 1713 if (shouldApplyTouchAdjustment(gestureEvent)) {
1714 padding = LayoutSize(gestureEvent.area()); 1714 padding = LayoutSize(gestureEvent.tapAreaInRootFrame());
1715 if (!padding.isEmpty()) { 1715 if (!padding.isEmpty()) {
1716 padding.scale(1.f / 2); 1716 padding.scale(1.f / 2);
1717 hitType |= HitTestRequest::ListBased; 1717 hitType |= HitTestRequest::ListBased;
1718 } 1718 }
1719 } 1719 }
1720 HitTestResult hitTestResult = hitTestResultAtPoint( 1720 HitTestResult hitTestResult = hitTestResultAtPoint(
1721 hitTestPoint, hitType | HitTestRequest::ReadOnly, padding); 1721 hitTestPoint, hitType | HitTestRequest::ReadOnly, padding);
1722 1722
1723 // Adjust the location of the gesture to the most likely nearby node, as 1723 // Adjust the location of the gesture to the most likely nearby node, as
1724 // appropriate for the type of event. 1724 // appropriate for the type of event.
1725 PlatformGestureEvent adjustedEvent = gestureEvent; 1725 WebGestureEvent adjustedEvent = gestureEvent;
1726 applyTouchAdjustment(&adjustedEvent, &hitTestResult); 1726 applyTouchAdjustment(&adjustedEvent, &hitTestResult);
1727 1727
1728 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessary 1728 // 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 1729 // 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 1730 // different node than what a point-based hit test would return for the same
1731 // point. 1731 // point.
1732 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. 1732 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test.
1733 // http://crbug.com/398914 1733 // http://crbug.com/398914
1734 if (shouldApplyTouchAdjustment(gestureEvent)) { 1734 if (shouldApplyTouchAdjustment(gestureEvent)) {
1735 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); 1735 LocalFrame* hitFrame = hitTestResult.innerNodeFrame();
1736 if (!hitFrame) 1736 if (!hitFrame)
1737 hitFrame = m_frame; 1737 hitFrame = m_frame;
1738 hitTestResult = EventHandlingUtil::hitTestResultInFrame( 1738 hitTestResult = EventHandlingUtil::hitTestResultInFrame(
1739 hitFrame, 1739 hitFrame, hitFrame->view()->rootFrameToContents(
1740 hitFrame->view()->rootFrameToContents(adjustedEvent.position()), 1740 flooredIntPoint(adjustedEvent.positionInRootFrame())),
1741 (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased); 1741 (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased);
1742 } 1742 }
1743 1743
1744 // If we did a rect-based hit test it must be resolved to the best single node 1744 // 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 1745 // by now to ensure consumers don't accidentally use one of the other
1746 // candidates. 1746 // candidates.
1747 ASSERT(!hitTestResult.isRectBasedTest()); 1747 ASSERT(!hitTestResult.isRectBasedTest());
1748 1748
1749 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); 1749 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult);
1750 } 1750 }
1751 1751
1752 void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, 1752 void EventHandler::applyTouchAdjustment(WebGestureEvent* gestureEvent,
1753 HitTestResult* hitTestResult) { 1753 HitTestResult* hitTestResult) {
1754 if (!shouldApplyTouchAdjustment(*gestureEvent)) 1754 if (!shouldApplyTouchAdjustment(*gestureEvent))
1755 return; 1755 return;
1756 1756
1757 Node* adjustedNode = nullptr; 1757 Node* adjustedNode = nullptr;
1758 IntPoint adjustedPoint = gestureEvent->position(); 1758 IntPoint adjustedPoint = flooredIntPoint(gestureEvent->positionInRootFrame());
1759 bool adjusted = false; 1759 bool adjusted = false;
1760 switch (gestureEvent->type()) { 1760 switch (gestureEvent->type) {
1761 case PlatformEvent::GestureTap: 1761 case WebInputEvent::GestureTap:
1762 case PlatformEvent::GestureTapUnconfirmed: 1762 case WebInputEvent::GestureTapUnconfirmed:
1763 case PlatformEvent::GestureTapDown: 1763 case WebInputEvent::GestureTapDown:
1764 case PlatformEvent::GestureShowPress: 1764 case WebInputEvent::GestureShowPress:
1765 adjusted = bestClickableNodeForHitTestResult(*hitTestResult, 1765 adjusted = bestClickableNodeForHitTestResult(*hitTestResult,
1766 adjustedPoint, adjustedNode); 1766 adjustedPoint, adjustedNode);
1767 break; 1767 break;
1768 case PlatformEvent::GestureLongPress: 1768 case WebInputEvent::GestureLongPress:
1769 case PlatformEvent::GestureLongTap: 1769 case WebInputEvent::GestureLongTap:
1770 case PlatformEvent::GestureTwoFingerTap: 1770 case WebInputEvent::GestureTwoFingerTap:
1771 adjusted = bestContextMenuNodeForHitTestResult( 1771 adjusted = bestContextMenuNodeForHitTestResult(
1772 *hitTestResult, adjustedPoint, adjustedNode); 1772 *hitTestResult, adjustedPoint, adjustedNode);
1773 break; 1773 break;
1774 default: 1774 default:
1775 ASSERT_NOT_REACHED(); 1775 ASSERT_NOT_REACHED();
1776 } 1776 }
1777 1777
1778 // Update the hit-test result to be a point-based result instead of a 1778 // Update the hit-test result to be a point-based result instead of a
1779 // rect-based result. 1779 // rect-based result.
1780 // FIXME: We should do this even when no candidate matches the node filter. 1780 // FIXME: We should do this even when no candidate matches the node filter.
1781 // crbug.com/398914 1781 // crbug.com/398914
1782 if (adjusted) { 1782 if (adjusted) {
1783 hitTestResult->resolveRectBasedTest( 1783 hitTestResult->resolveRectBasedTest(
1784 adjustedNode, m_frame->view()->rootFrameToContents(adjustedPoint)); 1784 adjustedNode, m_frame->view()->rootFrameToContents(adjustedPoint));
1785 gestureEvent->applyTouchAdjustment(adjustedPoint); 1785 gestureEvent->applyTouchAdjustment(
1786 WebFloatPoint(adjustedPoint.x(), adjustedPoint.y()));
1786 } 1787 }
1787 } 1788 }
1788 1789
1789 WebInputEventResult EventHandler::sendContextMenuEvent( 1790 WebInputEventResult EventHandler::sendContextMenuEvent(
1790 const PlatformMouseEvent& event, 1791 const PlatformMouseEvent& event,
1791 Node* overrideTargetNode) { 1792 Node* overrideTargetNode) {
1792 FrameView* v = m_frame->view(); 1793 FrameView* v = m_frame->view();
1793 if (!v) 1794 if (!v)
1794 return WebInputEventResult::NotHandled; 1795 return WebInputEventResult::NotHandled;
1795 1796
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 } 2129 }
2129 2130
2130 FrameHost* EventHandler::frameHost() const { 2131 FrameHost* EventHandler::frameHost() const {
2131 if (!m_frame->page()) 2132 if (!m_frame->page())
2132 return nullptr; 2133 return nullptr;
2133 2134
2134 return &m_frame->page()->frameHost(); 2135 return &m_frame->page()->frameHost();
2135 } 2136 }
2136 2137
2137 } // namespace blink 2138 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | third_party/WebKit/Source/core/input/EventHandlerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698