Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: Source/core/dom/WheelEvent.cpp

Issue 22859012: Add support for DOM Level 3 WheelEvent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename prefixedType() to legacyType() Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/WheelEvent.h ('k') | Source/core/dom/WheelEvent.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
6 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
6 * 7 *
7 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
11 * 12 *
12 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 16 * Library General Public License for more details.
16 * 17 *
17 * You should have received a copy of the GNU Library General Public License 18 * 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 * 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 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
21 */ 22 */
22 23
23 #include "config.h" 24 #include "config.h"
24 #include "core/dom/WheelEvent.h" 25 #include "core/dom/WheelEvent.h"
25 26
26 #include "core/dom/Clipboard.h" 27 #include "core/dom/Clipboard.h"
27 #include "core/dom/EventNames.h" 28 #include "core/dom/EventNames.h"
28 #include "core/platform/PlatformWheelEvent.h" 29 #include "core/platform/PlatformWheelEvent.h"
29 30
30 namespace WebCore { 31 namespace WebCore {
31 32
32 WheelEventInit::WheelEventInit() 33 WheelEventInit::WheelEventInit()
33 : wheelDeltaX(0) 34 : deltaX(0)
35 , deltaY(0)
36 , deltaZ(0)
37 , wheelDeltaX(0)
34 , wheelDeltaY(0) 38 , wheelDeltaY(0)
35 , deltaMode(WheelEvent::DOM_DELTA_PIXEL) 39 , deltaMode(WheelEvent::DOM_DELTA_PIXEL)
36 { 40 {
37 } 41 }
38 42
39 WheelEvent::WheelEvent() 43 WheelEvent::WheelEvent()
40 : m_deltaMode(DOM_DELTA_PIXEL) 44 : m_deltaMode(DOM_DELTA_PIXEL)
41 , m_directionInvertedFromDevice(false) 45 , m_directionInvertedFromDevice(false)
42 { 46 {
43 ScriptWrappable::init(this); 47 ScriptWrappable::init(this);
44 } 48 }
45 49
46 WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializ er) 50 WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializ er)
47 : MouseEvent(type, initializer) 51 : MouseEvent(type, initializer)
48 , m_wheelDelta(IntPoint(initializer.wheelDeltaX, initializer.wheelDeltaY)) 52 , m_deltaX(initializer.deltaX ? initializer.deltaX : initializer.wheelDeltaX )
53 , m_deltaY(initializer.deltaY ? initializer.deltaY : initializer.wheelDeltaY )
54 , m_deltaZ(initializer.deltaZ)
49 , m_deltaMode(initializer.deltaMode) 55 , m_deltaMode(initializer.deltaMode)
50 { 56 {
51 ScriptWrappable::init(this); 57 ScriptWrappable::init(this);
52 } 58 }
53 59
54 WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, unsigned deltaMode, 60 WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, unsigned deltaMode,
55 PassRefPtr<AbstractView> view, const IntPoint& screenLocation, const IntPoin t& pageLocation, 61 PassRefPtr<AbstractView> view, const IntPoint& screenLocation, const IntPoin t& pageLocation,
56 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvert edFromDevice) 62 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvert edFromDevice)
57 : MouseEvent(eventNames().mousewheelEvent, 63 : MouseEvent(eventNames().wheelEvent,
58 true, true, view, 0, screenLocation.x(), screenLocation.y(), 64 true, true, view, 0, screenLocation.x(), screenLocation.y(),
59 pageLocation.x(), pageLocation.y(), 65 pageLocation.x(), pageLocation.y(),
60 0, 0, 66 0, 0,
61 ctrlKey, altKey, shiftKey, metaKey, 0, 0, 0, false) 67 ctrlKey, altKey, shiftKey, metaKey, 0, 0, 0, false)
62 , m_wheelDelta(IntPoint(static_cast<int>(wheelTicks.x() * TickMultiplier), s tatic_cast<int>(wheelTicks.y() * TickMultiplier))) 68 , m_deltaX(wheelTicks.x() * TickMultiplier)
69 , m_deltaY(wheelTicks.y() * TickMultiplier)
70 , m_deltaZ(0) // FIXME: Not supported.
63 , m_rawDelta(roundedIntPoint(rawDelta)) 71 , m_rawDelta(roundedIntPoint(rawDelta))
64 , m_deltaMode(deltaMode) 72 , m_deltaMode(deltaMode)
65 , m_directionInvertedFromDevice(directionInvertedFromDevice) 73 , m_directionInvertedFromDevice(directionInvertedFromDevice)
66 { 74 {
67 ScriptWrappable::init(this); 75 ScriptWrappable::init(this);
68 } 76 }
69 77
70 void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac tView> view, 78 void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac tView> view,
71 int screenX, int screenY, int pageX, int pageY, 79 int screenX, int screenY, int pageX, int pageY,
72 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey) 80 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey)
73 { 81 {
74 if (dispatched()) 82 if (dispatched())
75 return; 83 return;
76 84
77 initUIEvent(eventNames().mousewheelEvent, true, true, view, 0); 85 initUIEvent(eventNames().wheelEvent, true, true, view, 0);
78 86
79 m_screenLocation = IntPoint(screenX, screenY); 87 m_screenLocation = IntPoint(screenX, screenY);
80 m_ctrlKey = ctrlKey; 88 m_ctrlKey = ctrlKey;
81 m_altKey = altKey; 89 m_altKey = altKey;
82 m_shiftKey = shiftKey; 90 m_shiftKey = shiftKey;
83 m_metaKey = metaKey; 91 m_metaKey = metaKey;
84 92
85 // Normalize to the Windows 120 multiple 93 m_deltaX = rawDeltaX * TickMultiplier;
86 m_wheelDelta = IntPoint(rawDeltaX * TickMultiplier, rawDeltaY * TickMultipli er); 94 m_deltaY = rawDeltaY * TickMultiplier;
87
88 m_rawDelta = IntPoint(rawDeltaX, rawDeltaY); 95 m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
89 m_deltaMode = DOM_DELTA_PIXEL; 96 m_deltaMode = DOM_DELTA_PIXEL;
90 m_directionInvertedFromDevice = false; 97 m_directionInvertedFromDevice = false;
91 98
92 initCoordinates(IntPoint(pageX, pageY)); 99 initCoordinates(IntPoint(pageX, pageY));
93 } 100 }
94 101
95 void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<A bstractView> view, 102 void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<A bstractView> view,
96 int screenX, int screenY, int pageX, int p ageY, 103 int screenX, int screenY, int pageX, int p ageY,
97 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) 104 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return static_cast<WheelEvent*>(EventDispatchMediator::event()); 142 return static_cast<WheelEvent*>(EventDispatchMediator::event());
136 } 143 }
137 144
138 bool WheelEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) cons t 145 bool WheelEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) cons t
139 { 146 {
140 ASSERT(event()); 147 ASSERT(event());
141 return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->default Handled(); 148 return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->default Handled();
142 } 149 }
143 150
144 } // namespace WebCore 151 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/WheelEvent.h ('k') | Source/core/dom/WheelEvent.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698