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

Unified 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: Fix comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/WheelEvent.h ('k') | Source/core/html/shadow/SpinButtonElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/WheelEvent.cpp
diff --git a/Source/core/dom/WheelEvent.cpp b/Source/core/dom/WheelEvent.cpp
index 1c000eecec2146a66df376ccae29af9f69281012..6f5cade2cc1d879f30218ffe8605d8097f2bfb65 100644
--- a/Source/core/dom/WheelEvent.cpp
+++ b/Source/core/dom/WheelEvent.cpp
@@ -30,6 +30,14 @@
namespace WebCore {
+static inline double wheelTicksToPixels(double ticks)
+{
+ // Make sure we use +0 for all zeros.
+ if (!ticks)
+ return 0;
+ return -ticks * WheelEvent::TickMultiplier;
+}
+
WheelEventInit::WheelEventInit()
: deltaX(0)
, deltaY(0)
@@ -49,8 +57,8 @@ WheelEvent::WheelEvent()
WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializer)
: MouseEvent(type, initializer)
- , m_deltaX(initializer.deltaX ? initializer.deltaX : initializer.wheelDeltaX)
- , m_deltaY(initializer.deltaY ? initializer.deltaY : initializer.wheelDeltaY)
+ , m_deltaX(initializer.deltaX ? initializer.deltaX : -initializer.wheelDeltaX)
+ , m_deltaY(initializer.deltaY ? initializer.deltaY : -initializer.wheelDeltaY)
, m_deltaZ(initializer.deltaZ)
, m_deltaMode(initializer.deltaMode)
{
@@ -65,8 +73,8 @@ WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
pageLocation.x(), pageLocation.y(),
0, 0,
ctrlKey, altKey, shiftKey, metaKey, 0, 0, 0, false)
- , m_deltaX(wheelTicks.x() * TickMultiplier)
- , m_deltaY(wheelTicks.y() * TickMultiplier)
+ , m_deltaX(wheelTicksToPixels(wheelTicks.x()))
+ , m_deltaY(wheelTicksToPixels(wheelTicks.y()))
, m_deltaZ(0) // FIXME: Not supported.
, m_rawDelta(roundedIntPoint(rawDelta))
, m_deltaMode(deltaMode)
@@ -90,8 +98,8 @@ void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac
m_shiftKey = shiftKey;
m_metaKey = metaKey;
- m_deltaX = rawDeltaX * TickMultiplier;
- m_deltaY = rawDeltaY * TickMultiplier;
+ m_deltaX = wheelTicksToPixels(rawDeltaX);
+ m_deltaY = wheelTicksToPixels(rawDeltaY);
m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
m_deltaMode = DOM_DELTA_PIXEL;
m_directionInvertedFromDevice = false;
« 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