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

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

Issue 22888005: WheelEvent's deltaX/deltaY sign is wrong (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Avoid negative zero value 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/html/shadow/SpinButtonElement.cpp » ('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 * 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 if (!ticks)
36 return 0;
arv (Not doing code reviews) 2013/08/21 14:19:23 Is it worth special casing 0? Are you concerned ab
do-not-use 2013/08/21 14:31:10 I had an issue with a test failing because a shoul
arv (Not doing code reviews) 2013/08/21 14:52:30 Makes sense. I think we should normalize -0 here.
do-not-use 2013/08/21 15:00:36 Done.
arv (Not doing code reviews) 2013/08/21 15:02:53 That comment is not very nice. How about: // Make
37 return -ticks * WheelEvent::TickMultiplier;
38 }
39
33 WheelEventInit::WheelEventInit() 40 WheelEventInit::WheelEventInit()
34 : deltaX(0) 41 : deltaX(0)
35 , deltaY(0) 42 , deltaY(0)
36 , deltaZ(0) 43 , deltaZ(0)
37 , wheelDeltaX(0) 44 , wheelDeltaX(0)
38 , wheelDeltaY(0) 45 , wheelDeltaY(0)
39 , deltaMode(WheelEvent::DOM_DELTA_PIXEL) 46 , deltaMode(WheelEvent::DOM_DELTA_PIXEL)
40 { 47 {
41 } 48 }
42 49
43 WheelEvent::WheelEvent() 50 WheelEvent::WheelEvent()
44 : m_deltaMode(DOM_DELTA_PIXEL) 51 : m_deltaMode(DOM_DELTA_PIXEL)
45 , m_directionInvertedFromDevice(false) 52 , m_directionInvertedFromDevice(false)
46 { 53 {
47 ScriptWrappable::init(this); 54 ScriptWrappable::init(this);
48 } 55 }
49 56
50 WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializ er) 57 WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializ er)
51 : MouseEvent(type, initializer) 58 : MouseEvent(type, initializer)
52 , m_deltaX(initializer.deltaX ? initializer.deltaX : initializer.wheelDeltaX ) 59 , m_deltaX(initializer.deltaX ? initializer.deltaX : -initializer.wheelDelta X)
53 , m_deltaY(initializer.deltaY ? initializer.deltaY : initializer.wheelDeltaY ) 60 , m_deltaY(initializer.deltaY ? initializer.deltaY : -initializer.wheelDelta Y)
54 , m_deltaZ(initializer.deltaZ) 61 , m_deltaZ(initializer.deltaZ)
55 , m_deltaMode(initializer.deltaMode) 62 , m_deltaMode(initializer.deltaMode)
56 { 63 {
57 ScriptWrappable::init(this); 64 ScriptWrappable::init(this);
58 } 65 }
59 66
60 WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, unsigned deltaMode, 67 WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, unsigned deltaMode,
61 PassRefPtr<AbstractView> view, const IntPoint& screenLocation, const IntPoin t& pageLocation, 68 PassRefPtr<AbstractView> view, const IntPoint& screenLocation, const IntPoin t& pageLocation,
62 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvert edFromDevice) 69 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvert edFromDevice)
63 : MouseEvent(eventNames().wheelEvent, 70 : MouseEvent(eventNames().wheelEvent,
64 true, true, view, 0, screenLocation.x(), screenLocation.y(), 71 true, true, view, 0, screenLocation.x(), screenLocation.y(),
65 pageLocation.x(), pageLocation.y(), 72 pageLocation.x(), pageLocation.y(),
66 0, 0, 73 0, 0,
67 ctrlKey, altKey, shiftKey, metaKey, 0, 0, 0, false) 74 ctrlKey, altKey, shiftKey, metaKey, 0, 0, 0, false)
68 , m_deltaX(wheelTicks.x() * TickMultiplier) 75 , m_deltaX(wheelTicksToPixels(wheelTicks.x()))
69 , m_deltaY(wheelTicks.y() * TickMultiplier) 76 , m_deltaY(wheelTicksToPixels(wheelTicks.y()))
70 , m_deltaZ(0) // FIXME: Not supported. 77 , m_deltaZ(0) // FIXME: Not supported.
71 , m_rawDelta(roundedIntPoint(rawDelta)) 78 , m_rawDelta(roundedIntPoint(rawDelta))
72 , m_deltaMode(deltaMode) 79 , m_deltaMode(deltaMode)
73 , m_directionInvertedFromDevice(directionInvertedFromDevice) 80 , m_directionInvertedFromDevice(directionInvertedFromDevice)
74 { 81 {
75 ScriptWrappable::init(this); 82 ScriptWrappable::init(this);
76 } 83 }
77 84
78 void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac tView> view, 85 void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac tView> view,
79 int screenX, int screenY, int pageX, int pageY, 86 int screenX, int screenY, int pageX, int pageY,
80 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey) 87 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey)
81 { 88 {
82 if (dispatched()) 89 if (dispatched())
83 return; 90 return;
84 91
85 initUIEvent(eventNames().wheelEvent, true, true, view, 0); 92 initUIEvent(eventNames().wheelEvent, true, true, view, 0);
86 93
87 m_screenLocation = IntPoint(screenX, screenY); 94 m_screenLocation = IntPoint(screenX, screenY);
88 m_ctrlKey = ctrlKey; 95 m_ctrlKey = ctrlKey;
89 m_altKey = altKey; 96 m_altKey = altKey;
90 m_shiftKey = shiftKey; 97 m_shiftKey = shiftKey;
91 m_metaKey = metaKey; 98 m_metaKey = metaKey;
92 99
93 m_deltaX = rawDeltaX * TickMultiplier; 100 m_deltaX = wheelTicksToPixels(rawDeltaX);
94 m_deltaY = rawDeltaY * TickMultiplier; 101 m_deltaY = wheelTicksToPixels(rawDeltaY);
95 m_rawDelta = IntPoint(rawDeltaX, rawDeltaY); 102 m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
96 m_deltaMode = DOM_DELTA_PIXEL; 103 m_deltaMode = DOM_DELTA_PIXEL;
97 m_directionInvertedFromDevice = false; 104 m_directionInvertedFromDevice = false;
98 105
99 initCoordinates(IntPoint(pageX, pageY)); 106 initCoordinates(IntPoint(pageX, pageY));
100 } 107 }
101 108
102 void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<A bstractView> view, 109 void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<A bstractView> view,
103 int screenX, int screenY, int pageX, int p ageY, 110 int screenX, int screenY, int pageX, int p ageY,
104 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) 111 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return static_cast<WheelEvent*>(EventDispatchMediator::event()); 149 return static_cast<WheelEvent*>(EventDispatchMediator::event());
143 } 150 }
144 151
145 bool WheelEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) cons t 152 bool WheelEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) cons t
146 { 153 {
147 ASSERT(event()); 154 ASSERT(event());
148 return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->default Handled(); 155 return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->default Handled();
149 } 156 }
150 157
151 } // namespace WebCore 158 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/WheelEvent.h ('k') | Source/core/html/shadow/SpinButtonElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698