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

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

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 months 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 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 // Propagation to inner frames is handled below this function. 1359 // Propagation to inner frames is handled below this function.
1360 ASSERT(m_frame == m_frame->localFrameRoot()); 1360 ASSERT(m_frame == m_frame->localFrameRoot());
1361 1361
1362 // Non-scrolling related gesture events do a single cross-frame hit-test and 1362 // Non-scrolling related gesture events do a single cross-frame hit-test and
1363 // jump directly to the inner most frame. This matches handleMousePressEvent 1363 // jump directly to the inner most frame. This matches handleMousePressEvent
1364 // etc. 1364 // etc.
1365 ASSERT(!targetedEvent.event().isScrollEvent()); 1365 ASSERT(!targetedEvent.event().isScrollEvent());
1366 1366
1367 // Update mouseout/leave/over/enter events before jumping directly to the 1367 // Update mouseout/leave/over/enter events before jumping directly to the
1368 // inner most frame. 1368 // inner most frame.
1369 if (targetedEvent.event().type == WebInputEvent::GestureTap) 1369 if (targetedEvent.event().type() == WebInputEvent::GestureTap)
1370 updateGestureTargetNodeForMouseEvent(targetedEvent); 1370 updateGestureTargetNodeForMouseEvent(targetedEvent);
1371 1371
1372 // Route to the correct frame. 1372 // Route to the correct frame.
1373 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) 1373 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame())
1374 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEvent); 1374 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEvent);
1375 1375
1376 // No hit test result, handle in root instance. Perhaps we should just return 1376 // No hit test result, handle in root instance. Perhaps we should just return
1377 // false instead? 1377 // false instead?
1378 return m_gestureManager->handleGestureEventInFrame(targetedEvent); 1378 return m_gestureManager->handleGestureEventInFrame(targetedEvent);
1379 } 1379 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 : nullptr; 1610 : nullptr;
1611 if (exitedFrameInDocument != lastEnteredFrameInDocument) 1611 if (exitedFrameInDocument != lastEnteredFrameInDocument)
1612 exitedFrameChain.push_back(exitedFrameInDocument); 1612 exitedFrameChain.push_back(exitedFrameInDocument);
1613 else if (nextExitedFrameInDocument && indexEnteredFrameChain) 1613 else if (nextExitedFrameInDocument && indexEnteredFrameChain)
1614 --indexEnteredFrameChain; 1614 --indexEnteredFrameChain;
1615 } 1615 }
1616 exitedFrameInDocument = nextExitedFrameInDocument; 1616 exitedFrameInDocument = nextExitedFrameInDocument;
1617 } 1617 }
1618 1618
1619 const WebGestureEvent& gestureEvent = targetedEvent.event(); 1619 const WebGestureEvent& gestureEvent = targetedEvent.event();
1620 unsigned modifiers = gestureEvent.modifiers; 1620 unsigned modifiers = gestureEvent.modifiers();
1621 PlatformMouseEvent fakeMouseMove( 1621 PlatformMouseEvent fakeMouseMove(
1622 gestureEvent, WebPointerProperties::Button::NoButton, 1622 gestureEvent, WebPointerProperties::Button::NoButton,
1623 PlatformEvent::MouseMoved, 1623 PlatformEvent::MouseMoved,
1624 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers), 1624 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers),
1625 PlatformMouseEvent::FromTouch, 1625 PlatformMouseEvent::FromTouch,
1626 TimeTicks::FromSeconds(gestureEvent.timeStampSeconds), 1626 TimeTicks::FromSeconds(gestureEvent.timeStampSeconds()),
1627 WebPointerProperties::PointerType::Mouse); 1627 WebPointerProperties::PointerType::Mouse);
1628 1628
1629 // Update the mouseout/mouseleave event 1629 // Update the mouseout/mouseleave event
1630 size_t indexExitedFrameChain = exitedFrameChain.size(); 1630 size_t indexExitedFrameChain = exitedFrameChain.size();
1631 while (indexExitedFrameChain) { 1631 while (indexExitedFrameChain) {
1632 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain]; 1632 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain];
1633 leaveFrame->eventHandler().m_mouseEventManager->setNodeUnderMouse( 1633 leaveFrame->eventHandler().m_mouseEventManager->setNodeUnderMouse(
1634 updateMouseEventTargetNode(nullptr), fakeMouseMove); 1634 updateMouseEventTargetNode(nullptr), fakeMouseMove);
1635 } 1635 }
1636 1636
(...skipping 14 matching lines...) Expand all
1651 GestureEventWithHitTestResults EventHandler::targetGestureEvent( 1651 GestureEventWithHitTestResults EventHandler::targetGestureEvent(
1652 const WebGestureEvent& gestureEvent, 1652 const WebGestureEvent& gestureEvent,
1653 bool readOnly) { 1653 bool readOnly) {
1654 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); 1654 TRACE_EVENT0("input", "EventHandler::targetGestureEvent");
1655 1655
1656 ASSERT(m_frame == m_frame->localFrameRoot()); 1656 ASSERT(m_frame == m_frame->localFrameRoot());
1657 // Scrolling events get hit tested per frame (like wheel events do). 1657 // Scrolling events get hit tested per frame (like wheel events do).
1658 ASSERT(!gestureEvent.isScrollEvent()); 1658 ASSERT(!gestureEvent.isScrollEvent());
1659 1659
1660 HitTestRequest::HitTestRequestType hitType = 1660 HitTestRequest::HitTestRequestType hitType =
1661 m_gestureManager->getHitTypeForGestureType(gestureEvent.type); 1661 m_gestureManager->getHitTypeForGestureType(gestureEvent.type());
1662 TimeDelta activeInterval; 1662 TimeDelta activeInterval;
1663 bool shouldKeepActiveForMinInterval = false; 1663 bool shouldKeepActiveForMinInterval = false;
1664 if (readOnly) { 1664 if (readOnly) {
1665 hitType |= HitTestRequest::ReadOnly; 1665 hitType |= HitTestRequest::ReadOnly;
1666 } else if (gestureEvent.type == WebInputEvent::GestureTap) { 1666 } else if (gestureEvent.type() == WebInputEvent::GestureTap) {
1667 // If the Tap is received very shortly after ShowPress, we want to 1667 // If the Tap is received very shortly after ShowPress, we want to
1668 // delay clearing of the active state so that it's visible to the user 1668 // delay clearing of the active state so that it's visible to the user
1669 // for at least a couple of frames. 1669 // for at least a couple of frames.
1670 activeInterval = 1670 activeInterval =
1671 TimeTicks::Now() - m_gestureManager->getLastShowPressTimestamp(); 1671 TimeTicks::Now() - m_gestureManager->getLastShowPressTimestamp();
1672 shouldKeepActiveForMinInterval = 1672 shouldKeepActiveForMinInterval =
1673 !m_gestureManager->getLastShowPressTimestamp().isNull() && 1673 !m_gestureManager->getLastShowPressTimestamp().isNull() &&
1674 activeInterval < minimumActiveInterval; 1674 activeInterval < minimumActiveInterval;
1675 if (shouldKeepActiveForMinInterval) 1675 if (shouldKeepActiveForMinInterval)
1676 hitType |= HitTestRequest::ReadOnly; 1676 hitType |= HitTestRequest::ReadOnly;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 } 1745 }
1746 1746
1747 void EventHandler::applyTouchAdjustment(WebGestureEvent* gestureEvent, 1747 void EventHandler::applyTouchAdjustment(WebGestureEvent* gestureEvent,
1748 HitTestResult* hitTestResult) { 1748 HitTestResult* hitTestResult) {
1749 if (!shouldApplyTouchAdjustment(*gestureEvent)) 1749 if (!shouldApplyTouchAdjustment(*gestureEvent))
1750 return; 1750 return;
1751 1751
1752 Node* adjustedNode = nullptr; 1752 Node* adjustedNode = nullptr;
1753 IntPoint adjustedPoint = flooredIntPoint(gestureEvent->positionInRootFrame()); 1753 IntPoint adjustedPoint = flooredIntPoint(gestureEvent->positionInRootFrame());
1754 bool adjusted = false; 1754 bool adjusted = false;
1755 switch (gestureEvent->type) { 1755 switch (gestureEvent->type()) {
1756 case WebInputEvent::GestureTap: 1756 case WebInputEvent::GestureTap:
1757 case WebInputEvent::GestureTapUnconfirmed: 1757 case WebInputEvent::GestureTapUnconfirmed:
1758 case WebInputEvent::GestureTapDown: 1758 case WebInputEvent::GestureTapDown:
1759 case WebInputEvent::GestureShowPress: 1759 case WebInputEvent::GestureShowPress:
1760 adjusted = bestClickableNodeForHitTestResult(*hitTestResult, 1760 adjusted = bestClickableNodeForHitTestResult(*hitTestResult,
1761 adjustedPoint, adjustedNode); 1761 adjustedPoint, adjustedNode);
1762 break; 1762 break;
1763 case WebInputEvent::GestureLongPress: 1763 case WebInputEvent::GestureLongPress:
1764 case WebInputEvent::GestureLongTap: 1764 case WebInputEvent::GestureLongTap:
1765 case WebInputEvent::GestureTwoFingerTap: 1765 case WebInputEvent::GestureTwoFingerTap:
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 } 2125 }
2126 2126
2127 FrameHost* EventHandler::frameHost() const { 2127 FrameHost* EventHandler::frameHost() const {
2128 if (!m_frame->page()) 2128 if (!m_frame->page())
2129 return nullptr; 2129 return nullptr;
2130 2130
2131 return &m_frame->page()->frameHost(); 2131 return &m_frame->page()->frameHost();
2132 } 2132 }
2133 2133
2134 } // namespace blink 2134 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/MouseEvent.cpp ('k') | third_party/WebKit/Source/core/input/EventHandlerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698