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

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

Issue 2542693002: Use WTF::TimeTicks to represent timestamp in Platform/Core event types (Closed)
Patch Set: rebase 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 static const int maximumCursorSize = 128; 133 static const int maximumCursorSize = 128;
134 134
135 // It's pretty unlikely that a scale of less than one would ever be used. But 135 // It's pretty unlikely that a scale of less than one would ever be used. But
136 // all we really need to ensure here is that the scale isn't so small that 136 // all we really need to ensure here is that the scale isn't so small that
137 // integer overflow can occur when dividing cursor sizes (limited above) by the 137 // integer overflow can occur when dividing cursor sizes (limited above) by the
138 // scale. 138 // scale.
139 static const double minimumCursorScale = 0.001; 139 static const double minimumCursorScale = 0.001;
140 140
141 // The minimum amount of time an element stays active after a ShowPress 141 // The minimum amount of time an element stays active after a ShowPress
142 // This is roughly 9 frames, which should be long enough to be noticeable. 142 // This is roughly 9 frames, which should be long enough to be noticeable.
143 static const double minimumActiveInterval = 0.15; 143 static const TimeDelta minimumActiveInterval = TimeDelta::FromSecondsD(0.15);
144 144
145 enum NoCursorChangeType { NoCursorChange }; 145 enum NoCursorChangeType { NoCursorChange };
146 146
147 class OptionalCursor { 147 class OptionalCursor {
148 public: 148 public:
149 OptionalCursor(NoCursorChangeType) : m_isCursorChange(false) {} 149 OptionalCursor(NoCursorChangeType) : m_isCursorChange(false) {}
150 OptionalCursor(const Cursor& cursor) 150 OptionalCursor(const Cursor& cursor)
151 : m_isCursorChange(true), m_cursor(cursor) {} 151 : m_isCursorChange(true), m_cursor(cursor) {}
152 152
153 bool isCursorChange() const { return m_isCursorChange; } 153 bool isCursorChange() const { return m_isCursorChange; }
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 const PlatformGestureEvent& gestureEvent, 1657 const PlatformGestureEvent& 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 double activeInterval = 0; 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() == PlatformEvent::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 = WTF::monotonicallyIncreasingTime() - 1675 activeInterval =
1676 m_gestureManager->getLastShowPressTimestamp(); 1676 TimeTicks::Now() - m_gestureManager->getLastShowPressTimestamp();
1677 shouldKeepActiveForMinInterval = 1677 shouldKeepActiveForMinInterval =
1678 m_gestureManager->getLastShowPressTimestamp() && 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;
1682 } 1682 }
1683 1683
1684 GestureEventWithHitTestResults eventWithHitTestResults = 1684 GestureEventWithHitTestResults eventWithHitTestResults =
1685 hitTestResultForGestureEvent(gestureEvent, hitType); 1685 hitTestResultForGestureEvent(gestureEvent, hitType);
1686 // Now apply hover/active state to the final target. 1686 // Now apply hover/active state to the final target.
1687 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); 1687 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent);
1688 if (!request.readOnly()) 1688 if (!request.readOnly())
1689 updateGestureHoverActiveState( 1689 updateGestureHoverActiveState(
1690 request, eventWithHitTestResults.hitTestResult().innerElement()); 1690 request, eventWithHitTestResults.hitTestResult().innerElement());
1691 1691
1692 if (shouldKeepActiveForMinInterval) { 1692 if (shouldKeepActiveForMinInterval) {
1693 m_lastDeferredTapElement = 1693 m_lastDeferredTapElement =
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(minimumActiveInterval - activeInterval, 1696 m_activeIntervalTimer.startOneShot(
1697 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 PlatformGestureEvent& 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
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 // The contextmenu event is a mouse event even when invoked using the 1889 // The contextmenu event is a mouse event even when invoked using the
1890 // keyboard. This is required for web compatibility. 1890 // keyboard. This is required for web compatibility.
1891 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; 1891 PlatformEvent::EventType eventType = PlatformEvent::MousePressed;
1892 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) 1892 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp())
1893 eventType = PlatformEvent::MouseReleased; 1893 eventType = PlatformEvent::MouseReleased;
1894 1894
1895 PlatformMouseEvent mouseEvent( 1895 PlatformMouseEvent mouseEvent(
1896 locationInRootFrame, globalPosition, 1896 locationInRootFrame, globalPosition,
1897 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0, 1897 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0,
1898 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, 1898 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable,
1899 WTF::monotonicallyIncreasingTime(), 1899 TimeTicks::Now(), WebPointerProperties::PointerType::Mouse);
1900 WebPointerProperties::PointerType::Mouse);
1901 1900
1902 return sendContextMenuEvent(mouseEvent, overrideTargetElement); 1901 return sendContextMenuEvent(mouseEvent, overrideTargetElement);
1903 } 1902 }
1904 1903
1905 void EventHandler::scheduleHoverStateUpdate() { 1904 void EventHandler::scheduleHoverStateUpdate() {
1906 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. 1905 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this.
1907 if (!m_hoverTimer.isActive()) 1906 if (!m_hoverTimer.isActive())
1908 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE); 1907 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE);
1909 } 1908 }
1910 1909
(...skipping 218 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
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/TypeAhead.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