| 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. |
| 11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
| 12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
| 13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
| 14 * | 14 * |
| 15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | |
| 28 #include "config.h" | 27 #include "config.h" |
| 29 #include "core/page/EventHandler.h" | 28 #include "core/page/EventHandler.h" |
| 30 | 29 |
| 31 #include "HTMLNames.h" | 30 #include "HTMLNames.h" |
| 32 #include "RuntimeEnabledFeatures.h" | 31 #include "RuntimeEnabledFeatures.h" |
| 33 #include "SVGNames.h" | 32 #include "SVGNames.h" |
| 34 #include "bindings/v8/ExceptionStatePlaceholder.h" | 33 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 35 #include "core/clipboard/Clipboard.h" | 34 #include "core/clipboard/Clipboard.h" |
| 36 #include "core/clipboard/DataObject.h" | 35 #include "core/clipboard/DataObject.h" |
| 37 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| (...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2107 #if OS(ANDROID) || OS(MACOSX) || OS(WIN) | 2106 #if OS(ANDROID) || OS(MACOSX) || OS(WIN) |
| 2108 return false; | 2107 return false; |
| 2109 #else | 2108 #else |
| 2110 // GTK+ must scroll horizontally if the mouse pointer is on top of the | 2109 // GTK+ must scroll horizontally if the mouse pointer is on top of the |
| 2111 // horizontal scrollbar while scrolling with the wheel. | 2110 // horizontal scrollbar while scrolling with the wheel. |
| 2112 // This code comes from gtk/EventHandlerGtk.cpp. | 2111 // This code comes from gtk/EventHandlerGtk.cpp. |
| 2113 return !event.hasPreciseScrollingDeltas() && result.scrollbar() && result.sc
rollbar()->orientation() == HorizontalScrollbar; | 2112 return !event.hasPreciseScrollingDeltas() && result.scrollbar() && result.sc
rollbar()->orientation() == HorizontalScrollbar; |
| 2114 #endif | 2113 #endif |
| 2115 } | 2114 } |
| 2116 | 2115 |
| 2117 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e) | 2116 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e, bool canRubberb
andLeft, bool canRubberbandRight) |
| 2118 { | 2117 { |
| 2119 #define RETURN_WHEEL_EVENT_HANDLED() \ | 2118 #define RETURN_WHEEL_EVENT_HANDLED() \ |
| 2120 { \ | 2119 { \ |
| 2121 setFrameWasScrolledByUser(); \ | 2120 setFrameWasScrolledByUser(); \ |
| 2122 return true; \ | 2121 return true; \ |
| 2123 } | 2122 } |
| 2124 | 2123 |
| 2125 Document* doc = m_frame->document(); | 2124 Document* doc = m_frame->document(); |
| 2126 | 2125 |
| 2127 if (!doc->renderer()) | 2126 if (!doc->renderer()) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 PlatformWheelEvent event = e; | 2170 PlatformWheelEvent event = e; |
| 2172 if (m_baseEventType == PlatformEvent::NoType && shouldTurnVerticalTicksIntoH
orizontal(result, e)) | 2171 if (m_baseEventType == PlatformEvent::NoType && shouldTurnVerticalTicksIntoH
orizontal(result, e)) |
| 2173 event = event.copyTurningVerticalTicksIntoHorizontalTicks(); | 2172 event = event.copyTurningVerticalTicksIntoHorizontalTicks(); |
| 2174 | 2173 |
| 2175 if (node) { | 2174 if (node) { |
| 2176 // Figure out which view to send the event to. | 2175 // Figure out which view to send the event to. |
| 2177 RenderObject* target = node->renderer(); | 2176 RenderObject* target = node->renderer(); |
| 2178 | 2177 |
| 2179 if (isOverWidget && target && target->isWidget()) { | 2178 if (isOverWidget && target && target->isWidget()) { |
| 2180 Widget* widget = toRenderWidget(target)->widget(); | 2179 Widget* widget = toRenderWidget(target)->widget(); |
| 2181 if (widget && passWheelEventToWidget(e, widget)) | 2180 if (widget && passWheelEventToWidget(e, widget, canRubberbandLeft, c
anRubberbandRight)) { |
| 2182 RETURN_WHEEL_EVENT_HANDLED(); | 2181 RETURN_WHEEL_EVENT_HANDLED(); |
| 2182 } |
| 2183 } | 2183 } |
| 2184 | 2184 |
| 2185 if (node && !node->dispatchWheelEvent(event)) | 2185 if (node && !node->dispatchWheelEvent(event)) |
| 2186 RETURN_WHEEL_EVENT_HANDLED(); | 2186 RETURN_WHEEL_EVENT_HANDLED(); |
| 2187 } | 2187 } |
| 2188 | 2188 |
| 2189 // Ctrl + scrollwheel is reserved for triggering zoom in/out actions in Chro
mium. | 2189 // Ctrl + scrollwheel is reserved for triggering zoom in/out actions in Chro
mium. |
| 2190 // When Ctrl is pressed and the event was not canceled by JavaScript code, | 2190 // When Ctrl is pressed and the event was not canceled by JavaScript code, |
| 2191 // return false to notify the caller that the scrollwheel event was not canc
eled. | 2191 // return false to notify the caller that the scrollwheel event was not canc
eled. |
| 2192 if (e.ctrlKey()) | 2192 if (e.ctrlKey()) |
| 2193 return false; | 2193 return false; |
| 2194 | 2194 |
| 2195 | 2195 |
| 2196 // We do another check on the frame view because the event handler can run J
S which results in the frame getting destroyed. | 2196 // We do another check on the frame view because the event handler can run J
S which results in the frame getting destroyed. |
| 2197 view = m_frame->view(); | 2197 view = m_frame->view(); |
| 2198 if (!view || !view->wheelEvent(event)) | 2198 if (!view || !view->wheelEvent(event, canRubberbandLeft, canRubberbandRight)
) |
| 2199 return false; | 2199 return false; |
| 2200 | 2200 |
| 2201 RETURN_WHEEL_EVENT_HANDLED(); | 2201 RETURN_WHEEL_EVENT_HANDLED(); |
| 2202 | 2202 |
| 2203 #undef RETURN_WHEEL_EVENT_HANDLED | 2203 #undef RETURN_WHEEL_EVENT_HANDLED |
| 2204 } | 2204 } |
| 2205 | 2205 |
| 2206 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv
ent) | 2206 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv
ent) |
| 2207 { | 2207 { |
| 2208 if (!startNode || !wheelEvent) | 2208 if (!startNode || !wheelEvent) |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2643 const float tickDivisor = static_cast<float>(WheelEvent::TickMultiplier); | 2643 const float tickDivisor = static_cast<float>(WheelEvent::TickMultiplier); |
| 2644 IntPoint point(gestureEvent.position().x(), gestureEvent.position().y()); | 2644 IntPoint point(gestureEvent.position().x(), gestureEvent.position().y()); |
| 2645 IntPoint globalPoint(gestureEvent.globalPosition().x(), gestureEvent.globalP
osition().y()); | 2645 IntPoint globalPoint(gestureEvent.globalPosition().x(), gestureEvent.globalP
osition().y()); |
| 2646 PlatformWheelEvent syntheticWheelEvent(point, globalPoint, | 2646 PlatformWheelEvent syntheticWheelEvent(point, globalPoint, |
| 2647 scaledDelta.width(), scaledDelta.height(), | 2647 scaledDelta.width(), scaledDelta.height(), |
| 2648 scaledDelta.width() / tickDivisor, scaledDelta.height() / tickDivisor, | 2648 scaledDelta.width() / tickDivisor, scaledDelta.height() / tickDivisor, |
| 2649 ScrollByPixelWheelEvent, | 2649 ScrollByPixelWheelEvent, |
| 2650 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(),
gestureEvent.metaKey()); | 2650 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(),
gestureEvent.metaKey()); |
| 2651 syntheticWheelEvent.setHasPreciseScrollingDeltas(true); | 2651 syntheticWheelEvent.setHasPreciseScrollingDeltas(true); |
| 2652 | 2652 |
| 2653 bool scrolledFrame = view->wheelEvent(syntheticWheelEvent); | 2653 bool scrolledFrame = view->wheelEvent(syntheticWheelEvent, true, true); |
| 2654 if (scrolledFrame) | 2654 if (scrolledFrame) |
| 2655 setFrameWasScrolledByUser(); | 2655 setFrameWasScrolledByUser(); |
| 2656 | 2656 |
| 2657 return scrolledFrame; | 2657 return scrolledFrame; |
| 2658 } | 2658 } |
| 2659 | 2659 |
| 2660 LocalFrame* EventHandler::getSubFrameForGestureEvent(const IntPoint& touchAdjust
edPoint, const PlatformGestureEvent& gestureEvent) | 2660 LocalFrame* EventHandler::getSubFrameForGestureEvent(const IntPoint& touchAdjust
edPoint, const PlatformGestureEvent& gestureEvent) |
| 2661 { | 2661 { |
| 2662 PlatformMouseEvent mouseDown(touchAdjustedPoint, gestureEvent.globalPosition
(), LeftButton, PlatformEvent::MousePressed, 1, | 2662 PlatformMouseEvent mouseDown(touchAdjustedPoint, gestureEvent.globalPosition
(), LeftButton, PlatformEvent::MousePressed, 1, |
| 2663 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(),
gestureEvent.metaKey(), gestureEvent.timestamp()); | 2663 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(),
gestureEvent.metaKey(), gestureEvent.timestamp()); |
| (...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3980 subframe->eventHandler().handleMouseMoveOrLeaveEvent(mev.event(), hoveredNod
e); | 3980 subframe->eventHandler().handleMouseMoveOrLeaveEvent(mev.event(), hoveredNod
e); |
| 3981 return true; | 3981 return true; |
| 3982 } | 3982 } |
| 3983 | 3983 |
| 3984 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&
mev, LocalFrame* subframe) | 3984 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&
mev, LocalFrame* subframe) |
| 3985 { | 3985 { |
| 3986 subframe->eventHandler().handleMouseReleaseEvent(mev.event()); | 3986 subframe->eventHandler().handleMouseReleaseEvent(mev.event()); |
| 3987 return true; | 3987 return true; |
| 3988 } | 3988 } |
| 3989 | 3989 |
| 3990 bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& wheelEvent,
Widget* widget) | 3990 bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& wheelEvent,
Widget* widget, bool canRubberbandLeft, bool canRubberbandRight) |
| 3991 { | 3991 { |
| 3992 // We can sometimes get a null widget! EventHandlerMac handles a null | 3992 // We can sometimes get a null widget! EventHandlerMac handles a null |
| 3993 // widget by returning false, so we do the same. | 3993 // widget by returning false, so we do the same. |
| 3994 if (!widget) | 3994 if (!widget) |
| 3995 return false; | 3995 return false; |
| 3996 | 3996 |
| 3997 // If not a FrameView, then probably a plugin widget. Those will receive | 3997 // If not a FrameView, then probably a plugin widget. Those will receive |
| 3998 // the event via an EventTargetNode dispatch when this returns false. | 3998 // the event via an EventTargetNode dispatch when this returns false. |
| 3999 if (!widget->isFrameView()) | 3999 if (!widget->isFrameView()) |
| 4000 return false; | 4000 return false; |
| 4001 | 4001 |
| 4002 return toFrameView(widget)->frame().eventHandler().handleWheelEvent(wheelEve
nt); | 4002 return toFrameView(widget)->frame().eventHandler().handleWheelEvent(wheelEve
nt, canRubberbandLeft, canRubberbandRight); |
| 4003 } | 4003 } |
| 4004 | 4004 |
| 4005 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
esults& event) | 4005 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
esults& event) |
| 4006 { | 4006 { |
| 4007 // Figure out which view to send the event to. | 4007 // Figure out which view to send the event to. |
| 4008 if (!event.targetNode() || !event.targetNode()->renderer() || !event.targetN
ode()->renderer()->isWidget()) | 4008 if (!event.targetNode() || !event.targetNode()->renderer() || !event.targetN
ode()->renderer()->isWidget()) |
| 4009 return false; | 4009 return false; |
| 4010 return false; | 4010 return false; |
| 4011 } | 4011 } |
| 4012 | 4012 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4026 unsigned EventHandler::accessKeyModifiers() | 4026 unsigned EventHandler::accessKeyModifiers() |
| 4027 { | 4027 { |
| 4028 #if OS(MACOSX) | 4028 #if OS(MACOSX) |
| 4029 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4029 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4030 #else | 4030 #else |
| 4031 return PlatformEvent::AltKey; | 4031 return PlatformEvent::AltKey; |
| 4032 #endif | 4032 #endif |
| 4033 } | 4033 } |
| 4034 | 4034 |
| 4035 } // namespace WebCore | 4035 } // namespace WebCore |
| OLD | NEW |