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 reserved.
6 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
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.
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.
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.
28 #include "core/CoreExport.h"
29 #include "core/events/EventDispatchMediator.h"
30 #include "core/events/MouseEvent.h"
31 #include "core/events/WheelEventInit.h"
32 #include "platform/geometry/FloatPoint.h"
36 class PlatformWheelEvent
;
38 class CORE_EXPORT WheelEvent final
: public MouseEvent
{
39 DEFINE_WRAPPERTYPEINFO();
41 enum { TickMultiplier
= 120 };
49 static PassRefPtrWillBeRawPtr
<WheelEvent
> create()
51 return adoptRefWillBeNoop(new WheelEvent
);
54 static PassRefPtrWillBeRawPtr
<WheelEvent
> create(const PlatformWheelEvent
& platformEvent
, PassRefPtrWillBeRawPtr
<AbstractView
>);
56 static PassRefPtrWillBeRawPtr
<WheelEvent
> create(const AtomicString
& type
, const WheelEventInit
& initializer
)
58 return adoptRefWillBeNoop(new WheelEvent(type
, initializer
));
61 static PassRefPtrWillBeRawPtr
<WheelEvent
> create(const FloatPoint
& wheelTicks
,
62 const FloatPoint
& rawDelta
, unsigned deltaMode
, PassRefPtrWillBeRawPtr
<AbstractView
> view
,
63 const IntPoint
& screenLocation
, const IntPoint
& windowLocation
,
64 bool ctrlKey
, bool altKey
, bool shiftKey
, bool metaKey
, unsigned short buttons
, bool canScroll
, int resendingPluginId
, bool hasPreciseScrollingDeltas
, RailsMode railsMode
)
66 return adoptRefWillBeNoop(new WheelEvent(wheelTicks
, rawDelta
, deltaMode
, view
,
67 screenLocation
, windowLocation
, ctrlKey
, altKey
, shiftKey
, metaKey
, buttons
, canScroll
, resendingPluginId
, hasPreciseScrollingDeltas
, railsMode
));
70 double deltaX() const { return m_deltaX
; } // Positive when scrolling right.
71 double deltaY() const { return m_deltaY
; } // Positive when scrolling down.
72 double deltaZ() const { return m_deltaZ
; }
73 int wheelDelta() const { return wheelDeltaY() ? wheelDeltaY() : wheelDeltaX(); } // Deprecated.
74 int wheelDeltaX() const { return m_wheelDelta
.x(); } // Deprecated, negative when scrolling right.
75 int wheelDeltaY() const { return m_wheelDelta
.y(); } // Deprecated, negative when scrolling down.
76 unsigned deltaMode() const { return m_deltaMode
; }
77 float ticksX() const { return static_cast<float>(m_wheelDelta
.x()) / TickMultiplier
; }
78 float ticksY() const { return static_cast<float>(m_wheelDelta
.y()) / TickMultiplier
; }
79 bool canScroll() const { return m_canScroll
; }
80 int resendingPluginId() const { return m_resendingPluginId
; }
81 bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas
; }
82 RailsMode
railsMode() const { return m_railsMode
; }
84 const AtomicString
& interfaceName() const override
;
85 bool isMouseEvent() const override
;
86 bool isWheelEvent() const override
;
88 PassRefPtrWillBeRawPtr
<EventDispatchMediator
> createMediator() override
;
90 DECLARE_VIRTUAL_TRACE();
94 WheelEvent(const AtomicString
&, const WheelEventInit
&);
95 WheelEvent(const FloatPoint
& wheelTicks
, const FloatPoint
& rawDelta
,
96 unsigned, PassRefPtrWillBeRawPtr
<AbstractView
>, const IntPoint
& screenLocation
, const IntPoint
& windowLocation
,
97 bool ctrlKey
, bool altKey
, bool shiftKey
, bool metaKey
, unsigned short buttons
, bool canScroll
, int resendingPluginId
, bool hasPreciseScrollingDeltas
, RailsMode
);
99 IntPoint m_wheelDelta
;
103 unsigned m_deltaMode
;
105 int m_resendingPluginId
;
106 bool m_hasPreciseScrollingDeltas
;
107 RailsMode m_railsMode
;
110 DEFINE_EVENT_TYPE_CASTS(WheelEvent
);
112 class WheelEventDispatchMediator final
: public EventDispatchMediator
{
114 static PassRefPtrWillBeRawPtr
<WheelEventDispatchMediator
> create(PassRefPtrWillBeRawPtr
<WheelEvent
>);
117 explicit WheelEventDispatchMediator(PassRefPtrWillBeRawPtr
<WheelEvent
>);
118 WheelEvent
& event() const;
119 bool dispatchEvent(EventDispatcher
&) const override
;
124 #endif // WheelEvent_h