| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | |
| 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | |
| 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserv
ed. | |
| 6 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | |
| 7 * | |
| 8 * This library is free software; you can redistribute it and/or | |
| 9 * modify it under the terms of the GNU Library General Public | |
| 10 * License as published by the Free Software Foundation; either | |
| 11 * version 2 of the License, or (at your option) any later version. | |
| 12 * | |
| 13 * This library is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 * Library General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU Library General Public License | |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 21 * Boston, MA 02110-1301, USA. | |
| 22 * | |
| 23 */ | |
| 24 | |
| 25 #ifndef WheelEvent_h | |
| 26 #define WheelEvent_h | |
| 27 | |
| 28 #include "core/events/EventDispatchMediator.h" | |
| 29 #include "core/events/MouseEvent.h" | |
| 30 #include "core/platform/graphics/FloatPoint.h" | |
| 31 | |
| 32 namespace WebCore { | |
| 33 | |
| 34 class PlatformWheelEvent; | |
| 35 | |
| 36 struct WheelEventInit : public MouseEventInit { | |
| 37 WheelEventInit(); | |
| 38 | |
| 39 double deltaX; | |
| 40 double deltaY; | |
| 41 double deltaZ; | |
| 42 int wheelDeltaX; // Deprecated. | |
| 43 int wheelDeltaY; // Deprecated. | |
| 44 unsigned deltaMode; | |
| 45 }; | |
| 46 | |
| 47 class WheelEvent : public MouseEvent { | |
| 48 public: | |
| 49 enum { TickMultiplier = 120 }; | |
| 50 | |
| 51 enum DeltaMode { | |
| 52 DOM_DELTA_PIXEL = 0, | |
| 53 DOM_DELTA_LINE, | |
| 54 DOM_DELTA_PAGE | |
| 55 }; | |
| 56 | |
| 57 static PassRefPtr<WheelEvent> create() | |
| 58 { | |
| 59 return adoptRef(new WheelEvent); | |
| 60 } | |
| 61 | |
| 62 static PassRefPtr<WheelEvent> create(const AtomicString& type, const WheelEv
entInit& initializer) | |
| 63 { | |
| 64 return adoptRef(new WheelEvent(type, initializer)); | |
| 65 } | |
| 66 | |
| 67 static PassRefPtr<WheelEvent> create(const FloatPoint& wheelTicks, | |
| 68 const FloatPoint& rawDelta, unsigned deltaMode, PassRefPtr<AbstractView>
view, | |
| 69 const IntPoint& screenLocation, const IntPoint& pageLocation, | |
| 70 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionIn
vertedFromDevice) | |
| 71 { | |
| 72 return adoptRef(new WheelEvent(wheelTicks, rawDelta, deltaMode, view, | |
| 73 screenLocation, pageLocation, ctrlKey, altKey, shiftKey, metaKey, direct
ionInvertedFromDevice)); | |
| 74 } | |
| 75 | |
| 76 void initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView>, | |
| 77 int screenX, int screenY, int pageX, int pageY, | |
| 78 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); | |
| 79 | |
| 80 void initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractV
iew>, | |
| 81 int screenX, int screenY, int pageX, int pageY, | |
| 82 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); | |
| 83 | |
| 84 double deltaX() const { return m_deltaX; } // Positive when scrolling right. | |
| 85 double deltaY() const { return m_deltaY; } // Positive when scrolling down. | |
| 86 double deltaZ() const { return m_deltaZ; } | |
| 87 int wheelDelta() const { return wheelDeltaY() ? wheelDeltaY() : wheelDeltaX(
); } // Deprecated. | |
| 88 int wheelDeltaX() const { return m_wheelDelta.x(); } // Deprecated, negative
when scrolling right. | |
| 89 int wheelDeltaY() const { return m_wheelDelta.y(); } // Deprecated, negative
when scrolling down. | |
| 90 unsigned deltaMode() const { return m_deltaMode; } | |
| 91 float ticksX() const { return static_cast<float>(m_wheelDelta.x()) / TickMul
tiplier; } | |
| 92 float ticksY() const { return static_cast<float>(m_wheelDelta.y()) / TickMul
tiplier; } | |
| 93 | |
| 94 bool webkitDirectionInvertedFromDevice() const { return m_directionInvertedF
romDevice; } | |
| 95 | |
| 96 virtual const AtomicString& interfaceName() const; | |
| 97 virtual bool isMouseEvent() const; | |
| 98 | |
| 99 private: | |
| 100 WheelEvent(); | |
| 101 WheelEvent(const AtomicString&, const WheelEventInit&); | |
| 102 WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, | |
| 103 unsigned, PassRefPtr<AbstractView>, const IntPoint& screenLocation, cons
t IntPoint& pageLocation, | |
| 104 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionIn
vertedFromDevice); | |
| 105 | |
| 106 IntPoint m_wheelDelta; | |
| 107 double m_deltaX; | |
| 108 double m_deltaY; | |
| 109 double m_deltaZ; | |
| 110 unsigned m_deltaMode; | |
| 111 bool m_directionInvertedFromDevice; | |
| 112 }; | |
| 113 | |
| 114 class WheelEventDispatchMediator : public EventDispatchMediator { | |
| 115 public: | |
| 116 static PassRefPtr<WheelEventDispatchMediator> create(const PlatformWheelEven
t&, PassRefPtr<AbstractView>); | |
| 117 private: | |
| 118 WheelEventDispatchMediator(const PlatformWheelEvent&, PassRefPtr<AbstractVie
w>); | |
| 119 WheelEvent* event() const; | |
| 120 virtual bool dispatchEvent(EventDispatcher*) const OVERRIDE; | |
| 121 }; | |
| 122 | |
| 123 } // namespace WebCore | |
| 124 | |
| 125 #endif // WheelEvent_h | |
| OLD | NEW |