OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 ~MaximumDurationTracker() | 165 ~MaximumDurationTracker() |
166 { | 166 { |
167 *m_maxDuration = max(*m_maxDuration, monotonicallyIncreasingTime() - m_s
tart); | 167 *m_maxDuration = max(*m_maxDuration, monotonicallyIncreasingTime() - m_s
tart); |
168 } | 168 } |
169 | 169 |
170 private: | 170 private: |
171 double* m_maxDuration; | 171 double* m_maxDuration; |
172 double m_start; | 172 double m_start; |
173 }; | 173 }; |
174 | 174 |
175 static inline ScrollGranularity wheelGranularityToScrollGranularity(unsigned del
taMode) | 175 static inline ScrollGranularity wheelGranularityToScrollGranularity(WheelEvent*
event) |
176 { | 176 { |
177 switch (deltaMode) { | 177 unsigned deltaMode = event->deltaMode(); |
178 case WheelEvent::DOM_DELTA_PAGE: | 178 if (deltaMode == WheelEvent::DOM_DELTA_PAGE) |
179 return ScrollByPage; | 179 return ScrollByPage; |
180 case WheelEvent::DOM_DELTA_LINE: | 180 if (deltaMode == WheelEvent::DOM_DELTA_LINE) |
181 return ScrollByLine; | 181 return ScrollByLine; |
182 case WheelEvent::DOM_DELTA_PIXEL: | 182 ASSERT(deltaMode == WheelEvent::DOM_DELTA_PIXEL); |
183 return ScrollByPixel; | 183 return event->hasPreciseScrollingDeltas() ? ScrollByPrecisePixel : ScrollByP
ixel; |
184 default: | |
185 return ScrollByPixel; | |
186 } | |
187 } | 184 } |
188 | 185 |
189 // Refetch the event target node if it is removed or currently is the shadow nod
e inside an <input> element. | 186 // Refetch the event target node if it is removed or currently is the shadow nod
e inside an <input> element. |
190 // If a mouse event handler changes the input element type to one that has a wid
get associated, | 187 // If a mouse event handler changes the input element type to one that has a wid
get associated, |
191 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid
get and thus the | 188 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid
get and thus the |
192 // event target node can't still be the shadow node. | 189 // event target node can't still be the shadow node. |
193 static inline bool shouldRefetchEventTarget(const MouseEventWithHitTestResults&
mev) | 190 static inline bool shouldRefetchEventTarget(const MouseEventWithHitTestResults&
mev) |
194 { | 191 { |
195 Node* targetNode = mev.innerNode(); | 192 Node* targetNode = mev.innerNode(); |
196 if (!targetNode || !targetNode->parentNode()) | 193 if (!targetNode || !targetNode->parentNode()) |
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv
ent) | 2034 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv
ent) |
2038 { | 2035 { |
2039 if (!startNode || !wheelEvent) | 2036 if (!startNode || !wheelEvent) |
2040 return; | 2037 return; |
2041 | 2038 |
2042 // Ctrl + scrollwheel is reserved for triggering zoom in/out actions in Chro
mium. | 2039 // Ctrl + scrollwheel is reserved for triggering zoom in/out actions in Chro
mium. |
2043 if (wheelEvent->ctrlKey()) | 2040 if (wheelEvent->ctrlKey()) |
2044 return; | 2041 return; |
2045 | 2042 |
2046 Node* stopNode = m_previousWheelScrolledNode.get(); | 2043 Node* stopNode = m_previousWheelScrolledNode.get(); |
2047 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve
nt->deltaMode()); | 2044 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve
nt); |
2048 | 2045 |
2049 // Break up into two scrolls if we need to. Diagonal movement on | 2046 // Break up into two scrolls if we need to. Diagonal movement on |
2050 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b
oth deltaX and deltaY can be set). | 2047 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b
oth deltaX and deltaY can be set). |
2051 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta
X(), roundedIntPoint(wheelEvent->absoluteLocation()))) | 2048 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta
X(), roundedIntPoint(wheelEvent->absoluteLocation()))) |
2052 wheelEvent->setDefaultHandled(); | 2049 wheelEvent->setDefaultHandled(); |
2053 | 2050 |
2054 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY
(), roundedIntPoint(wheelEvent->absoluteLocation()))) | 2051 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY
(), roundedIntPoint(wheelEvent->absoluteLocation()))) |
2055 wheelEvent->setDefaultHandled(); | 2052 wheelEvent->setDefaultHandled(); |
2056 | 2053 |
2057 if (!m_latchedWheelEventNode) | 2054 if (!m_latchedWheelEventNode) |
(...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3884 unsigned EventHandler::accessKeyModifiers() | 3881 unsigned EventHandler::accessKeyModifiers() |
3885 { | 3882 { |
3886 #if OS(MACOSX) | 3883 #if OS(MACOSX) |
3887 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3884 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3888 #else | 3885 #else |
3889 return PlatformEvent::AltKey; | 3886 return PlatformEvent::AltKey; |
3890 #endif | 3887 #endif |
3891 } | 3888 } |
3892 | 3889 |
3893 } // namespace blink | 3890 } // namespace blink |
OLD | NEW |