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

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

Issue 23034006: WheelEvent's deltaX/deltaY should report real amount of pixels scrolled (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo in test 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
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 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 12 matching lines...) Expand all
23 23
24 #include "config.h" 24 #include "config.h"
25 #include "core/dom/WheelEvent.h" 25 #include "core/dom/WheelEvent.h"
26 26
27 #include "core/dom/Clipboard.h" 27 #include "core/dom/Clipboard.h"
28 #include "core/dom/EventNames.h" 28 #include "core/dom/EventNames.h"
29 #include "core/platform/PlatformWheelEvent.h" 29 #include "core/platform/PlatformWheelEvent.h"
30 30
31 namespace WebCore { 31 namespace WebCore {
32 32
33 static inline double wheelTicksToPixels(double ticks)
34 {
35 // Make sure we use +0 for all zeros.
36 if (!ticks)
37 return 0;
38 return -ticks * WheelEvent::TickMultiplier;
39 }
40
41 WheelEventInit::WheelEventInit() 33 WheelEventInit::WheelEventInit()
42 : deltaX(0) 34 : deltaX(0)
43 , deltaY(0) 35 , deltaY(0)
44 , deltaZ(0) 36 , deltaZ(0)
45 , wheelDeltaX(0) 37 , wheelDeltaX(0)
46 , wheelDeltaY(0) 38 , wheelDeltaY(0)
47 , deltaMode(WheelEvent::DOM_DELTA_PIXEL) 39 , deltaMode(WheelEvent::DOM_DELTA_PIXEL)
48 { 40 {
49 } 41 }
50 42
51 WheelEvent::WheelEvent() 43 WheelEvent::WheelEvent()
52 : m_deltaX(0) 44 : m_deltaX(0)
53 , m_deltaY(0) 45 , m_deltaY(0)
54 , m_deltaZ(0) 46 , m_deltaZ(0)
55 , m_deltaMode(DOM_DELTA_PIXEL) 47 , m_deltaMode(DOM_DELTA_PIXEL)
56 , m_directionInvertedFromDevice(false) 48 , m_directionInvertedFromDevice(false)
57 { 49 {
58 ScriptWrappable::init(this); 50 ScriptWrappable::init(this);
59 } 51 }
60 52
61 WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializ er) 53 WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializ er)
62 : MouseEvent(type, initializer) 54 : MouseEvent(type, initializer)
55 , m_wheelDelta(initializer.wheelDeltaX ? initializer.wheelDeltaX : -initiali zer.deltaX, initializer.wheelDeltaY ? initializer.wheelDeltaY : -initializer.del taY)
arv (Not doing code reviews) 2013/08/22 14:15:49 Is this correct? What if initializer.wheelDeltaX w
do-not-use 2013/08/22 14:46:03 I am not sure I understand the question. If initia
do-not-use 2013/08/22 15:08:21 If the caller constructs the WheelEvent from JS an
arv (Not doing code reviews) 2013/08/22 15:25:15 My point was that if wheelDeltaX was initialized t
63 , m_deltaX(initializer.deltaX ? initializer.deltaX : -initializer.wheelDelta X) 56 , m_deltaX(initializer.deltaX ? initializer.deltaX : -initializer.wheelDelta X)
64 , m_deltaY(initializer.deltaY ? initializer.deltaY : -initializer.wheelDelta Y) 57 , m_deltaY(initializer.deltaY ? initializer.deltaY : -initializer.wheelDelta Y)
65 , m_deltaZ(initializer.deltaZ) 58 , m_deltaZ(initializer.deltaZ)
66 , m_deltaMode(initializer.deltaMode) 59 , m_deltaMode(initializer.deltaMode)
67 { 60 {
68 ScriptWrappable::init(this); 61 ScriptWrappable::init(this);
69 } 62 }
70 63
71 WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, unsigned deltaMode, 64 WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, unsigned deltaMode,
72 PassRefPtr<AbstractView> view, const IntPoint& screenLocation, const IntPoin t& pageLocation, 65 PassRefPtr<AbstractView> view, const IntPoint& screenLocation, const IntPoin t& pageLocation,
73 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvert edFromDevice) 66 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvert edFromDevice)
74 : MouseEvent(eventNames().wheelEvent, 67 : MouseEvent(eventNames().wheelEvent,
75 true, true, view, 0, screenLocation.x(), screenLocation.y(), 68 true, true, view, 0, screenLocation.x(), screenLocation.y(),
76 pageLocation.x(), pageLocation.y(), 69 pageLocation.x(), pageLocation.y(),
77 0, 0, 70 0, 0,
78 ctrlKey, altKey, shiftKey, metaKey, 0, 0, 0, false) 71 ctrlKey, altKey, shiftKey, metaKey, 0, 0, 0, false)
79 , m_deltaX(wheelTicksToPixels(wheelTicks.x())) 72 , m_wheelDelta(wheelTicks.x() * TickMultiplier, wheelTicks.y() * TickMultipl ier)
80 , m_deltaY(wheelTicksToPixels(wheelTicks.y())) 73 , m_deltaX(-rawDelta.x())
81 , m_deltaZ(0) // FIXME: Not supported. 74 , m_deltaY(-rawDelta.y())
82 , m_rawDelta(roundedIntPoint(rawDelta)) 75 , m_deltaZ(0)
83 , m_deltaMode(deltaMode) 76 , m_deltaMode(deltaMode)
84 , m_directionInvertedFromDevice(directionInvertedFromDevice) 77 , m_directionInvertedFromDevice(directionInvertedFromDevice)
85 { 78 {
86 ScriptWrappable::init(this); 79 ScriptWrappable::init(this);
87 } 80 }
88 81
89 void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac tView> view, 82 void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac tView> view,
90 int screenX, int screenY, int pageX, int pageY, 83 int screenX, int screenY, int pageX, int pageY,
91 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey) 84 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey)
92 { 85 {
93 if (dispatched()) 86 if (dispatched())
94 return; 87 return;
95 88
96 initUIEvent(eventNames().wheelEvent, true, true, view, 0); 89 initUIEvent(eventNames().wheelEvent, true, true, view, 0);
97 90
98 m_screenLocation = IntPoint(screenX, screenY); 91 m_screenLocation = IntPoint(screenX, screenY);
99 m_ctrlKey = ctrlKey; 92 m_ctrlKey = ctrlKey;
100 m_altKey = altKey; 93 m_altKey = altKey;
101 m_shiftKey = shiftKey; 94 m_shiftKey = shiftKey;
102 m_metaKey = metaKey; 95 m_metaKey = metaKey;
103 96
104 m_deltaX = wheelTicksToPixels(rawDeltaX); 97 m_wheelDelta = IntPoint(rawDeltaX * TickMultiplier, rawDeltaY * TickMultipli er);
105 m_deltaY = wheelTicksToPixels(rawDeltaY); 98 m_deltaX = -rawDeltaX;
106 m_rawDelta = IntPoint(rawDeltaX, rawDeltaY); 99 m_deltaY = -rawDeltaY;
107 m_deltaMode = DOM_DELTA_PIXEL; 100 m_deltaMode = DOM_DELTA_PIXEL;
108 m_directionInvertedFromDevice = false; 101 m_directionInvertedFromDevice = false;
109 102
110 initCoordinates(IntPoint(pageX, pageY)); 103 initCoordinates(IntPoint(pageX, pageY));
111 } 104 }
112 105
113 void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<A bstractView> view, 106 void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<A bstractView> view,
114 int screenX, int screenY, int pageX, int p ageY, 107 int screenX, int screenY, int pageX, int p ageY,
115 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) 108 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
116 { 109 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return static_cast<WheelEvent*>(EventDispatchMediator::event()); 146 return static_cast<WheelEvent*>(EventDispatchMediator::event());
154 } 147 }
155 148
156 bool WheelEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) cons t 149 bool WheelEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) cons t
157 { 150 {
158 ASSERT(event()); 151 ASSERT(event());
159 return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->default Handled(); 152 return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->default Handled();
160 } 153 }
161 154
162 } // namespace WebCore 155 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698