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, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23 #include "config.h"
24 #include "WheelEvent.h"
25
26 #include "EventNames.h"
27 #include <wtf/MathExtras.h>
28
29 namespace WebCore {
30
WheelEvent()31 WheelEvent::WheelEvent()
32 : m_wheelDeltaX(0)
33 , m_wheelDeltaY(0)
34 {
35 }
36
WheelEvent(float wheelTicksX,float wheelTicksY,PassRefPtr<AbstractView> view,int screenX,int screenY,int pageX,int pageY,bool ctrlKey,bool altKey,bool shiftKey,bool metaKey)37 WheelEvent::WheelEvent(float wheelTicksX, float wheelTicksY, PassRefPtr<AbstractView> view,
38 int screenX, int screenY, int pageX, int pageY,
39 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
40 : MouseRelatedEvent(eventNames().mousewheelEvent,
41 true, true, view, 0, screenX, screenY, pageX, pageY,
42 ctrlKey, altKey, shiftKey, metaKey)
43 , m_wheelDeltaX(lroundf(wheelTicksX * 120))
44 , m_wheelDeltaY(lroundf(wheelTicksY * 120)) // Normalize to the Windows 120 multiple
45 {
46 }
47
initWheelEvent(int wheelDeltaX,int wheelDeltaY,PassRefPtr<AbstractView> view,int screenX,int screenY,int pageX,int pageY,bool ctrlKey,bool altKey,bool shiftKey,bool metaKey)48 void WheelEvent::initWheelEvent(int wheelDeltaX, int wheelDeltaY, PassRefPtr<AbstractView> view,
49 int screenX, int screenY, int pageX, int pageY,
50 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
51 {
52 if (dispatched())
53 return;
54
55 initUIEvent(eventNames().mousewheelEvent, true, true, view, 0);
56
57 m_screenX = screenX;
58 m_screenY = screenY;
59 m_ctrlKey = ctrlKey;
60 m_altKey = altKey;
61 m_shiftKey = shiftKey;
62 m_metaKey = metaKey;
63 m_wheelDeltaX = wheelDeltaX;
64 m_wheelDeltaY = wheelDeltaY;
65
66 initCoordinates(pageX, pageY);
67 }
68
69
isWheelEvent() const70 bool WheelEvent::isWheelEvent() const
71 {
72 return true;
73 }
74
75 } // namespace WebCore
76