<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[41746] trunk/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/41746">41746</a></dd>
<dt>Author</dt> <dd>pkasting@chromium.org</dd>
<dt>Date</dt> <dd>2009-03-16 15:19:56 -0700 (Mon, 16 Mar 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>2009-03-16  Peter Kasting  &lt;pkasting@google.com&gt;

        Reviewed by David Hyatt.

        https://bugs.webkit.org/show_bug.cgi?id=24368
        DOM scroll events should be based off the actual number of wheel
        ticks, not off the number of lines scrolled.  This matches IE.

        * dom/Node.cpp:
        (WebCore::Node::dispatchWheelEvent):
        * dom/WheelEvent.cpp:
        (WebCore::WheelEvent::WheelEvent):
        * dom/WheelEvent.h:
        (WebCore::WheelEvent::create):
        * platform/PlatformWheelEvent.h:
        (WebCore::PlatformWheelEvent::wheelTicksX):
        (WebCore::PlatformWheelEvent::wheelTicksY):
        * platform/gtk/WheelEventGtk.cpp:
        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
        * platform/mac/WheelEventMac.mm:
        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
        * platform/qt/WheelEventQt.cpp:
        * platform/win/WheelEventWin.cpp:
        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
        * platform/wx/MouseWheelEventWx.cpp:
        (WebCore::PlatformWheelEvent::PlatformWheelEvent):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoredomNodecpp">trunk/WebCore/dom/Node.cpp</a></li>
<li><a href="#trunkWebCoredomWheelEventcpp">trunk/WebCore/dom/WheelEvent.cpp</a></li>
<li><a href="#trunkWebCoredomWheelEventh">trunk/WebCore/dom/WheelEvent.h</a></li>
<li><a href="#trunkWebCoreplatformPlatformWheelEventh">trunk/WebCore/platform/PlatformWheelEvent.h</a></li>
<li><a href="#trunkWebCoreplatformgtkWheelEventGtkcpp">trunk/WebCore/platform/gtk/WheelEventGtk.cpp</a></li>
<li><a href="#trunkWebCoreplatformmacWheelEventMacmm">trunk/WebCore/platform/mac/WheelEventMac.mm</a></li>
<li><a href="#trunkWebCoreplatformqtWheelEventQtcpp">trunk/WebCore/platform/qt/WheelEventQt.cpp</a></li>
<li><a href="#trunkWebCoreplatformwinWheelEventWincpp">trunk/WebCore/platform/win/WheelEventWin.cpp</a></li>
<li><a href="#trunkWebCoreplatformwxMouseWheelEventWxcpp">trunk/WebCore/platform/wx/MouseWheelEventWx.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/ChangeLog        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2009-03-16  Peter Kasting  &lt;pkasting@google.com&gt;
+
+        Reviewed by David Hyatt.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24368
+        DOM scroll events should be based off the actual number of wheel
+        ticks, not off the number of lines scrolled.  This matches IE.
+
+        * dom/Node.cpp:
+        (WebCore::Node::dispatchWheelEvent):
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEvent::WheelEvent):
+        * dom/WheelEvent.h:
+        (WebCore::WheelEvent::create):
+        * platform/PlatformWheelEvent.h:
+        (WebCore::PlatformWheelEvent::wheelTicksX):
+        (WebCore::PlatformWheelEvent::wheelTicksY):
+        * platform/gtk/WheelEventGtk.cpp:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
+        * platform/mac/WheelEventMac.mm:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
+        * platform/qt/WheelEventQt.cpp:
+        * platform/win/WheelEventWin.cpp:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
+        * platform/wx/MouseWheelEventWx.cpp:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
+
</ins><span class="cx"> 2009-03-16  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Eric Seidel
</span></span></pre></div>
<a id="trunkWebCoredomNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Node.cpp (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Node.cpp        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/dom/Node.cpp        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -2706,19 +2706,7 @@
</span><span class="cx">     
</span><span class="cx">     IntPoint pos = view-&gt;windowToContents(e.pos());
</span><span class="cx">     
</span><del>-    // Convert the deltas from pixels to lines if we have a pixel scroll event.
-    const float cMouseWheelPixelsPerLineStep = 40.0f / 3.0f;
-    float deltaX = e.deltaX();
-    float deltaY = e.deltaY();
-    
-    // FIXME: Should we do anything with a ScrollByPageWheelEvent here?
-    // It will be treated like a line scroll of 1 right now.
-    if (e.granularity() == ScrollByPixelWheelEvent) {
-        deltaX /= cMouseWheelPixelsPerLineStep;
-        deltaY /= cMouseWheelPixelsPerLineStep;
-    }
-
-    RefPtr&lt;WheelEvent&gt; we = WheelEvent::create(e.deltaX(), e.deltaY(),
</del><ins>+    RefPtr&lt;WheelEvent&gt; we = WheelEvent::create(e.wheelTicksX(), e.wheelTicksY(),
</ins><span class="cx">         document()-&gt;defaultView(), e.globalX(), e.globalY(), pos.x(), pos.y(),
</span><span class="cx">         e.ctrlKey(), e.altKey(), e.shiftKey(), e.metaKey());
</span><span class="cx">     ExceptionCode ec = 0;
</span></span></pre></div>
<a id="trunkWebCoredomWheelEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/WheelEvent.cpp (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/WheelEvent.cpp        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/dom/WheelEvent.cpp        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -34,20 +34,15 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WheelEvent::WheelEvent(float wheelDeltaX, float wheelDeltaY, PassRefPtr&lt;AbstractView&gt; view,
</del><ins>+WheelEvent::WheelEvent(float wheelTicksX, float wheelTicksY, PassRefPtr&lt;AbstractView&gt; view,
</ins><span class="cx">                        int screenX, int screenY, int pageX, int pageY,
</span><span class="cx">                        bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
</span><span class="cx">     : MouseRelatedEvent(eventNames().mousewheelEvent,
</span><span class="cx">                         true, true, view, 0, screenX, screenY, pageX, pageY, 
</span><span class="cx">                         ctrlKey, altKey, shiftKey, metaKey)
</span><del>-    , m_wheelDeltaX(lroundf(wheelDeltaX) * 120)
-    , m_wheelDeltaY(lroundf(wheelDeltaY) * 120) // Normalize to the Windows 120 multiple
</del><ins>+    , m_wheelDeltaX(lroundf(wheelTicksX * 120))
+    , m_wheelDeltaY(lroundf(wheelTicksY * 120)) // Normalize to the Windows 120 multiple
</ins><span class="cx"> {
</span><del>-    // Rounding delta to zero makes no sense and breaks Google Maps, &lt;http://bugs.webkit.org/show_bug.cgi?id=16078&gt;.
-    if (wheelDeltaX &amp;&amp; !m_wheelDeltaX)
-        m_wheelDeltaX = (wheelDeltaX &gt; 0) ? 120 : -120;
-    if (wheelDeltaY &amp;&amp; !m_wheelDeltaY)
-        m_wheelDeltaY = (wheelDeltaY &gt; 0) ? 120 : -120;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WheelEvent::initWheelEvent(int wheelDeltaX, int wheelDeltaY, PassRefPtr&lt;AbstractView&gt; view,
</span></span></pre></div>
<a id="trunkWebCoredomWheelEventh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/WheelEvent.h (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/WheelEvent.h        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/dom/WheelEvent.h        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -35,11 +35,11 @@
</span><span class="cx">         {
</span><span class="cx">             return adoptRef(new WheelEvent);
</span><span class="cx">         }
</span><del>-        static PassRefPtr&lt;WheelEvent&gt; create(float wheelDeltaX, float wheelDeltaY, PassRefPtr&lt;AbstractView&gt; view,
</del><ins>+        static PassRefPtr&lt;WheelEvent&gt; create(float wheelTicksX, float wheelTicksY, PassRefPtr&lt;AbstractView&gt; view,
</ins><span class="cx">             int screenX, int screenY, int pageX, int pageY,
</span><span class="cx">             bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
</span><span class="cx">         {
</span><del>-            return adoptRef(new WheelEvent(wheelDeltaX, wheelDeltaY, view, screenX, screenY, pageX, pageY,
</del><ins>+            return adoptRef(new WheelEvent(wheelTicksX, wheelTicksY, view, screenX, screenY, pageX, pageY,
</ins><span class="cx">                 ctrlKey, altKey, shiftKey, metaKey));
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx"> 
</span><span class="cx">     private:
</span><span class="cx">         WheelEvent();
</span><del>-        WheelEvent(float wheelDeltaX, float wheelDeltaY, PassRefPtr&lt;AbstractView&gt;,
</del><ins>+        WheelEvent(float wheelTicksX, float wheelTicksY, PassRefPtr&lt;AbstractView&gt;,
</ins><span class="cx">                    int screenX, int screenY, int pageX, int pageY,
</span><span class="cx">                    bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCoreplatformPlatformWheelEventh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/PlatformWheelEvent.h (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/PlatformWheelEvent.h        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/platform/PlatformWheelEvent.h        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -74,6 +74,9 @@
</span><span class="cx">         float deltaX() const { return m_deltaX; }
</span><span class="cx">         float deltaY() const { return m_deltaY; }
</span><span class="cx"> 
</span><ins>+        float wheelTicksX() const { return m_wheelTicksX; }
+        float wheelTicksY() const { return m_wheelTicksY; }
+
</ins><span class="cx">         PlatformWheelEventGranularity granularity() const { return m_granularity; }
</span><span class="cx"> 
</span><span class="cx">         bool isAccepted() const { return m_isAccepted; }
</span><span class="lines">@@ -111,6 +114,8 @@
</span><span class="cx">         IntPoint m_globalPosition;
</span><span class="cx">         float m_deltaX;
</span><span class="cx">         float m_deltaY;
</span><ins>+        float m_wheelTicksX;
+        float m_wheelTicksY;
</ins><span class="cx">         PlatformWheelEventGranularity m_granularity;
</span><span class="cx">         bool m_isAccepted;
</span><span class="cx">         bool m_shiftKey;
</span></span></pre></div>
<a id="trunkWebCoreplatformgtkWheelEventGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/gtk/WheelEventGtk.cpp (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/gtk/WheelEventGtk.cpp        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/platform/gtk/WheelEventGtk.cpp        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -59,6 +59,8 @@
</span><span class="cx">             m_deltaX = -delta;
</span><span class="cx">             break;
</span><span class="cx">     }
</span><ins>+    m_wheelTicksX = m_deltaX;
+    m_wheelTicksY = m_deltaY;
</ins><span class="cx"> 
</span><span class="cx">     m_position = IntPoint(static_cast&lt;int&gt;(event-&gt;x), static_cast&lt;int&gt;(event-&gt;y));
</span><span class="cx">     m_globalPosition = IntPoint(static_cast&lt;int&gt;(event-&gt;x_root), static_cast&lt;int&gt;(event-&gt;y_root));
</span></span></pre></div>
<a id="trunkWebCoreplatformmacWheelEventMacmm"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/mac/WheelEventMac.mm (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/mac/WheelEventMac.mm        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/platform/mac/WheelEventMac.mm        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -44,7 +44,12 @@
</span><span class="cx"> {
</span><span class="cx">     BOOL continuous;
</span><span class="cx">     wkGetWheelEventDeltas(event, &amp;m_deltaX, &amp;m_deltaY, &amp;continuous);
</span><del>-    if (!continuous) {
</del><ins>+    if (continuous) {
+        m_wheelTicksX = m_deltaX / static_cast&lt;float&gt;(cScrollbarPixelsPerLineStep);
+        m_wheelTicksY = m_deltaY / static_cast&lt;float&gt;(cScrollbarPixelsPerLineStep);
+    } else {
+        m_wheelTicksX = m_deltaX;
+        m_wheelTicksY = m_deltaY;
</ins><span class="cx">         m_deltaX *= static_cast&lt;float&gt;(cScrollbarPixelsPerLineStep);
</span><span class="cx">         m_deltaY *= static_cast&lt;float&gt;(cScrollbarPixelsPerLineStep);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkWebCoreplatformqtWheelEventQtcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/qt/WheelEventQt.cpp (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/qt/WheelEventQt.cpp        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/platform/qt/WheelEventQt.cpp        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -51,6 +51,8 @@
</span><span class="cx">         m_deltaX = 0;
</span><span class="cx">         m_deltaY = (e-&gt;delta() / 120);
</span><span class="cx">     }
</span><ins>+    m_wheelTicksX = m_deltaX;
+    m_wheelTicksY = m_deltaY;
</ins><span class="cx"> 
</span><span class="cx">     // use the same single scroll step as QTextEdit (in
</span><span class="cx">     // QTextEditPrivate::init [h,v]bar-&gt;setSingleStep )
</span></span></pre></div>
<a id="trunkWebCoreplatformwinWheelEventWincpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/win/WheelEventWin.cpp (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/win/WheelEventWin.cpp        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/platform/win/WheelEventWin.cpp        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -80,8 +80,20 @@
</span><span class="cx">     // (the default scroll amount on Windows is three lines per wheel tick).
</span><span class="cx">     static const float cScrollbarPixelsPerLine = 100.0f / 3.0f;
</span><span class="cx">     float delta = GET_WHEEL_DELTA_WPARAM(wParam) / static_cast&lt;float&gt;(WHEEL_DELTA);
</span><del>-    if (isMouseHWheel)
-        delta = -delta;  // Windows is &lt;-- -/+ --&gt;, WebKit wants &lt;-- +/- --&gt;
</del><ins>+    if (isMouseHWheel) {
+        // Windows is &lt;-- -/+ --&gt;, WebKit wants &lt;-- +/- --&gt;, so we negate
+        // |delta| after saving the original value on the wheel tick member.
+        m_wheelTicksX = delta;
+        m_wheelTicksY = 0;
+        delta = -delta;
+    } else {
+        // Even though we use shift + vertical wheel to scroll horizontally in
+        // WebKit, we still note it as a vertical scroll on the wheel tick
+        // member, so that the DOM event we later construct will match the real
+        // hardware event better.
+        m_wheelTicksX = 0;
+        m_wheelTicksY = delta;
+    }
</ins><span class="cx">     if (isMouseHWheel || m_shiftKey) {
</span><span class="cx">         m_deltaX = delta * static_cast&lt;float&gt;(horizontalScrollChars()) * cScrollbarPixelsPerLine;
</span><span class="cx">         m_deltaY = 0;
</span></span></pre></div>
<a id="trunkWebCoreplatformwxMouseWheelEventWxcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/wx/MouseWheelEventWx.cpp (41745 => 41746)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/wx/MouseWheelEventWx.cpp        2009-03-16 22:07:28 UTC (rev 41745)
+++ trunk/WebCore/platform/wx/MouseWheelEventWx.cpp        2009-03-16 22:19:56 UTC (rev 41746)
</span><span class="lines">@@ -42,6 +42,8 @@
</span><span class="cx">     , m_metaKey(event.MetaDown()) // FIXME: We'll have to test other browsers
</span><span class="cx">     , m_deltaX(0) // wx doesn't support horizontal mouse wheel scrolling
</span><span class="cx">     , m_deltaY(event.GetWheelRotation() / event.GetWheelDelta())
</span><ins>+    , m_wheelTicksX(m_deltaX),
+    , m_wheelTicksY(m_deltaY),
</ins><span class="cx">     , m_isAccepted(false)
</span><span class="cx"> {
</span><span class="cx">     // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
</span></span></pre>
</div>
</div>

</body>
</html>