Title: [87865] trunk/Source/WebCore
Revision
87865
Author
[email protected]
Date
2011-06-01 16:19:02 -0700 (Wed, 01 Jun 2011)

Log Message

2011-06-01  Emil A Eklund  <[email protected]>

        Reviewed by Eric Seidel.

        Switch MouseRelatedEvent to use IntPoint
        https://bugs.webkit.org/show_bug.cgi?id=61574

        Covered by existing tests.

        * dom/MouseEvent.cpp:
        (WebCore::MouseEvent::MouseEvent):
        (WebCore::MouseEvent::initMouseEvent):
        (WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
        * dom/MouseRelatedEvent.cpp:
        (WebCore::MouseRelatedEvent::MouseRelatedEvent):
        (WebCore::contentsScrollOffset):
        (WebCore::MouseRelatedEvent::initCoordinates):
        (WebCore::MouseRelatedEvent::computeRelativePosition):
        (WebCore::MouseRelatedEvent::layerX):
        (WebCore::MouseRelatedEvent::layerY):
        (WebCore::MouseRelatedEvent::offsetX):
        (WebCore::MouseRelatedEvent::offsetY):
        (WebCore::MouseRelatedEvent::pageX):
        (WebCore::MouseRelatedEvent::pageY):
        (WebCore::MouseRelatedEvent::pageLocation):
        (WebCore::MouseRelatedEvent::x):
        (WebCore::MouseRelatedEvent::y):
        * dom/MouseRelatedEvent.h:
        (WebCore::MouseRelatedEvent::screenX):
        (WebCore::MouseRelatedEvent::screenY):
        (WebCore::MouseRelatedEvent::screenLocation):
        (WebCore::MouseRelatedEvent::clientX):
        (WebCore::MouseRelatedEvent::clientY):
        (WebCore::MouseRelatedEvent::clientLocation):
        (WebCore::MouseRelatedEvent::absoluteLocation):
        * dom/TouchEvent.cpp:
        (WebCore::TouchEvent::TouchEvent):
        (WebCore::TouchEvent::initTouchEvent):
        * dom/WheelEvent.cpp:
        (WebCore::WheelEvent::WheelEvent):
        (WebCore::WheelEvent::initWheelEvent):
        (WebCore::WheelEventDispatchMediator::WheelEventDispatchMediator):
        * dom/WheelEvent.h:
        (WebCore::WheelEvent::create):
        (WebCore::WheelEvent::wheelDelta):
        (WebCore::WheelEvent::wheelDeltaX):
        (WebCore::WheelEvent::wheelDeltaY):
        (WebCore::WheelEvent::rawDeltaX):
        (WebCore::WheelEvent::rawDeltaY):
        (WebCore::WheelEvent::isHorizontal):
        * platform/graphics/IntPoint.h:
        (WebCore::IntPoint::scale):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87864 => 87865)


--- trunk/Source/WebCore/ChangeLog	2011-06-01 23:15:58 UTC (rev 87864)
+++ trunk/Source/WebCore/ChangeLog	2011-06-01 23:19:02 UTC (rev 87865)
@@ -1,3 +1,56 @@
+2011-06-01  Emil A Eklund  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
+        Switch MouseRelatedEvent to use IntPoint
+        https://bugs.webkit.org/show_bug.cgi?id=61574
+
+        Covered by existing tests.
+
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEvent::MouseEvent):
+        (WebCore::MouseEvent::initMouseEvent):
+        (WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
+        * dom/MouseRelatedEvent.cpp:
+        (WebCore::MouseRelatedEvent::MouseRelatedEvent):
+        (WebCore::contentsScrollOffset):
+        (WebCore::MouseRelatedEvent::initCoordinates):
+        (WebCore::MouseRelatedEvent::computeRelativePosition):
+        (WebCore::MouseRelatedEvent::layerX):
+        (WebCore::MouseRelatedEvent::layerY):
+        (WebCore::MouseRelatedEvent::offsetX):
+        (WebCore::MouseRelatedEvent::offsetY):
+        (WebCore::MouseRelatedEvent::pageX):
+        (WebCore::MouseRelatedEvent::pageY):
+        (WebCore::MouseRelatedEvent::pageLocation):
+        (WebCore::MouseRelatedEvent::x):
+        (WebCore::MouseRelatedEvent::y):
+        * dom/MouseRelatedEvent.h:
+        (WebCore::MouseRelatedEvent::screenX):
+        (WebCore::MouseRelatedEvent::screenY):
+        (WebCore::MouseRelatedEvent::screenLocation):
+        (WebCore::MouseRelatedEvent::clientX):
+        (WebCore::MouseRelatedEvent::clientY):
+        (WebCore::MouseRelatedEvent::clientLocation):
+        (WebCore::MouseRelatedEvent::absoluteLocation):
+        * dom/TouchEvent.cpp:
+        (WebCore::TouchEvent::TouchEvent):
+        (WebCore::TouchEvent::initTouchEvent):
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEvent::WheelEvent):
+        (WebCore::WheelEvent::initWheelEvent):
+        (WebCore::WheelEventDispatchMediator::WheelEventDispatchMediator):
+        * dom/WheelEvent.h:
+        (WebCore::WheelEvent::create):
+        (WebCore::WheelEvent::wheelDelta):
+        (WebCore::WheelEvent::wheelDeltaX):
+        (WebCore::WheelEvent::wheelDeltaY):
+        (WebCore::WheelEvent::rawDeltaX):
+        (WebCore::WheelEvent::rawDeltaY):
+        (WebCore::WheelEvent::isHorizontal):
+        * platform/graphics/IntPoint.h:
+        (WebCore::IntPoint::scale):
+
 2011-06-01  Levi Weintraub  <[email protected]>
 
         Reviewed by Eric Seidel.

Modified: trunk/Source/WebCore/dom/MouseEvent.cpp (87864 => 87865)


--- trunk/Source/WebCore/dom/MouseEvent.cpp	2011-06-01 23:15:58 UTC (rev 87864)
+++ trunk/Source/WebCore/dom/MouseEvent.cpp	2011-06-01 23:19:02 UTC (rev 87865)
@@ -54,8 +54,8 @@
                        bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
                        unsigned short button, PassRefPtr<EventTarget> relatedTarget,
                        PassRefPtr<Clipboard> clipboard, bool isSimulated)
-    : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, screenX, screenY,
-                        pageX, pageY, ctrlKey, altKey, shiftKey, metaKey, isSimulated)
+    : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint(screenX, screenY),
+                        IntPoint(pageX, pageY), ctrlKey, altKey, shiftKey, metaKey, isSimulated)
     , m_button(button == (unsigned short)-1 ? 0 : button)
     , m_buttonDown(button != (unsigned short)-1)
     , m_relatedTarget(relatedTarget)
@@ -77,8 +77,7 @@
 
     initUIEvent(type, canBubble, cancelable, view, detail);
 
-    m_screenX = screenX;
-    m_screenY = screenY;
+    m_screenLocation = IntPoint(screenX, screenY);
     m_ctrlKey = ctrlKey;
     m_altKey = altKey;
     m_shiftKey = shiftKey;
@@ -87,7 +86,7 @@
     m_buttonDown = button != (unsigned short)-1;
     m_relatedTarget = relatedTarget;
 
-    initCoordinates(clientX, clientY);
+    initCoordinates(IntPoint(clientX, clientY));
 
     // FIXME: m_isSimulated is not set to false here.
     // FIXME: m_clipboard is not set to 0 here.
@@ -153,9 +152,8 @@
 
     if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
         MouseEvent* mouseEvent = static_cast<MouseEvent*>(this->underlyingEvent());
-        m_screenX = mouseEvent->screenX();
-        m_screenY = mouseEvent->screenY();
-        initCoordinates(mouseEvent->clientX(), mouseEvent->clientY());
+        m_screenLocation = mouseEvent->screenLocation();
+        initCoordinates(mouseEvent->clientLocation());
     }
 }
 

Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.cpp (87864 => 87865)


--- trunk/Source/WebCore/dom/MouseRelatedEvent.cpp	2011-06-01 23:15:58 UTC (rev 87864)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.cpp	2011-06-01 23:19:02 UTC (rev 87865)
@@ -33,57 +33,30 @@
 namespace WebCore {
 
 MouseRelatedEvent::MouseRelatedEvent()
-    : m_screenX(0)
-    , m_screenY(0)
-    , m_clientX(0)
-    , m_clientY(0)
-    , m_pageX(0)
-    , m_pageY(0)
-    , m_layerX(0)
-    , m_layerY(0)
-    , m_offsetX(0)
-    , m_offsetY(0)
-    , m_isSimulated(false)
+    : m_isSimulated(false)
     , m_hasCachedRelativePosition(false)
 {
 }
 
-static int contentsX(AbstractView* abstractView)
+static IntSize contentsScrollOffset(AbstractView* abstractView)
 {
     if (!abstractView)
-        return 0;
+        return IntSize();
     Frame* frame = abstractView->frame();
     if (!frame)
-        return 0;
+        return IntSize();
     FrameView* frameView = frame->view();
     if (!frameView)
-        return 0;
-    return frameView->scrollX() / frame->pageZoomFactor();
+        return IntSize();
+    return IntSize(frameView->scrollX() / frame->pageZoomFactor(),
+        frameView->scrollY() / frame->pageZoomFactor());
 }
 
-static int contentsY(AbstractView* abstractView)
-{
-    if (!abstractView)
-        return 0;
-    Frame* frame = abstractView->frame();
-    if (!frame)
-        return 0;
-    FrameView* frameView = frame->view();
-    if (!frameView)
-        return 0;
-    return frameView->scrollY() / frame->pageZoomFactor();
-}
-
 MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, PassRefPtr<AbstractView> abstractView,
-                                     int detail, int screenX, int screenY, int windowX, int windowY,
+                                     int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
                                      bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated)
     : UIEventWithKeyState(eventType, canBubble, cancelable, abstractView, detail, ctrlKey, altKey, shiftKey, metaKey)
-    , m_screenX(screenX)
-    , m_screenY(screenY)
-    , m_clientX(0)
-    , m_clientY(0)
-    , m_pageX(0)
-    , m_pageY(0)
+    , m_screenLocation(screenLocation)
     , m_isSimulated(isSimulated)
 {
     IntPoint adjustedPageLocation;
@@ -93,23 +66,22 @@
     if (frame && !isSimulated) {
         if (FrameView* frameView = frame->view()) {
             scrollPosition = frameView->scrollPosition();
-            adjustedPageLocation = frameView->windowToContents(IntPoint(windowX, windowY));
+            adjustedPageLocation = frameView->windowToContents(windowLocation);
             float pageZoom = frame->pageZoomFactor();
             if (pageZoom != 1.0f) {
                 // Adjust our pageX and pageY to account for the page zoom.
-                adjustedPageLocation.setX(lroundf(adjustedPageLocation.x() / pageZoom));
-                adjustedPageLocation.setY(lroundf(adjustedPageLocation.y() / pageZoom));
+                adjustedPageLocation.scale(1 / pageZoom, 1 / pageZoom);
+
+                // FIXME: Change this to use float math and proper rounding (or
+                // better yet, use IntPoint::scale).
                 scrollPosition.setX(scrollPosition.x() / pageZoom);
                 scrollPosition.setY(scrollPosition.y() / pageZoom);
             }
         }
     }
 
-    IntPoint clientLocation(adjustedPageLocation - scrollPosition);
-    m_clientX = clientLocation.x();
-    m_clientY = clientLocation.y();
-    m_pageX = adjustedPageLocation.x();
-    m_pageY = adjustedPageLocation.y();
+    m_clientLocation = adjustedPageLocation - toSize(scrollPosition);
+    m_pageLocation = adjustedPageLocation;
 
     initCoordinates();
 }
@@ -118,28 +90,23 @@
 {
     // Set up initial values for coordinates.
     // Correct values are computed lazily, see computeRelativePosition.
-    m_layerX = m_pageX;
-    m_layerY = m_pageY;
-    m_offsetX = m_pageX;
-    m_offsetY = m_pageY;
+    m_layerLocation = m_pageLocation;
+    m_offsetLocation = m_pageLocation;
 
     computePageLocation();
     m_hasCachedRelativePosition = false;
 }
 
-void MouseRelatedEvent::initCoordinates(int clientX, int clientY)
+void MouseRelatedEvent::initCoordinates(const IntPoint& clientLocation)
 {
     // Set up initial values for coordinates.
     // Correct values are computed lazily, see computeRelativePosition.
-    m_clientX = clientX;
-    m_clientY = clientY;
-    m_pageX = clientX + contentsX(view());
-    m_pageY = clientY + contentsY(view());
-    m_layerX = m_pageX;
-    m_layerY = m_pageY;
-    m_offsetX = m_pageX;
-    m_offsetY = m_pageY;
+    m_clientLocation = clientLocation;
+    m_pageLocation = clientLocation + contentsScrollOffset(view());
 
+    m_layerLocation = m_pageLocation;
+    m_offsetLocation = m_pageLocation;
+
     computePageLocation();
     m_hasCachedRelativePosition = false;
 }
@@ -173,25 +140,24 @@
         return;
 
     // Compute coordinates that are based on the target.
-    m_layerX = m_pageX;
-    m_layerY = m_pageY;
-    m_offsetX = m_pageX;
-    m_offsetY = m_pageY;
+    m_layerLocation = m_pageLocation;
+    m_offsetLocation = m_pageLocation;
 
     // Must have an updated render tree for this math to work correctly.
     targetNode->document()->updateStyleIfNeeded();
 
-    // Adjust offsetX/Y to be relative to the target's position.
+    // Adjust offsetLocation to be relative to the target's position.
     if (!isSimulated()) {
         if (RenderObject* r = targetNode->renderer()) {
             FloatPoint localPos = r->absoluteToLocal(absoluteLocation(), false, true);
-            float zoomFactor = pageZoomFactor(this);
-            m_offsetX = lroundf(localPos.x() / zoomFactor);
-            m_offsetY = lroundf(localPos.y() / zoomFactor);
+            m_offsetLocation = roundedIntPoint(localPos);
+            float scaleFactor = 1 / pageZoomFactor(this);
+            if (scaleFactor != 1.0f)
+                m_offsetLocation.scale(scaleFactor, scaleFactor);
         }
     }
 
-    // Adjust layerX/Y to be relative to the layer.
+    // Adjust layerLocation to be relative to the layer.
     // FIXME: We're pretty sure this is the wrong definition of "layer."
     // Our RenderLayer is a more modern concept, and layerX/Y is some
     // other notion about groups of elements (left over from the Netscape 4 days?);
@@ -204,9 +170,7 @@
     if (n && (layer = n->renderer()->enclosingLayer())) {
         layer->updateLayerPosition();
         for (; layer; layer = layer->parent()) {
-            const IntPoint& location = layer->location();
-            m_layerX -= location.x();
-            m_layerY -= location.y();
+            m_layerLocation -= toSize(layer->location());
         }
     }
 
@@ -217,52 +181,57 @@
 {
     if (!m_hasCachedRelativePosition)
         computeRelativePosition();
-    return m_layerX;
+    return m_layerLocation.x();
 }
 
 int MouseRelatedEvent::layerY()
 {
     if (!m_hasCachedRelativePosition)
         computeRelativePosition();
-    return m_layerY;
+    return m_layerLocation.y();
 }
 
 int MouseRelatedEvent::offsetX()
 {
     if (!m_hasCachedRelativePosition)
         computeRelativePosition();
-    return m_offsetX;
+    return m_offsetLocation.x();
 }
 
 int MouseRelatedEvent::offsetY()
 {
     if (!m_hasCachedRelativePosition)
         computeRelativePosition();
-    return m_offsetY;
+    return m_offsetLocation.y();
 }
 
 int MouseRelatedEvent::pageX() const
 {
-    return m_pageX;
+    return m_pageLocation.x();
 }
 
 int MouseRelatedEvent::pageY() const
 {
-    return m_pageY;
+    return m_pageLocation.y();
 }
 
+const IntPoint& MouseRelatedEvent::pageLocation() const
+{
+    return m_pageLocation;
+}
+
 int MouseRelatedEvent::x() const
 {
     // FIXME: This is not correct.
     // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events.html>.
-    return m_clientX;
+    return m_clientLocation.x();
 }
 
 int MouseRelatedEvent::y() const
 {
     // FIXME: This is not correct.
     // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events.html>.
-    return m_clientY;
+    return m_clientLocation.y();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.h (87864 => 87865)


--- trunk/Source/WebCore/dom/MouseRelatedEvent.h	2011-06-01 23:15:58 UTC (rev 87864)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.h	2011-06-01 23:19:02 UTC (rev 87865)
@@ -34,10 +34,12 @@
     public:
         // Note that these values are adjusted to counter the effects of zoom, so that values
         // exposed via DOM APIs are invariant under zooming.
-        int screenX() const { return m_screenX; }
-        int screenY() const { return m_screenY; }
-        int clientX() const { return m_clientX; }
-        int clientY() const { return m_clientY; }
+        int screenX() const { return m_screenLocation.x(); }
+        int screenY() const { return m_screenLocation.y(); }
+        const IntPoint& screenLocation() const { return m_screenLocation; }
+        int clientX() const { return m_clientLocation.x(); }
+        int clientY() const { return m_clientLocation.y(); }
+        const IntPoint& clientLocation() const { return m_clientLocation; }
         int layerX();
         int layerY();
         int offsetX();
@@ -45,40 +47,36 @@
         bool isSimulated() const { return m_isSimulated; }
         virtual int pageX() const;
         virtual int pageY() const;
+        virtual const IntPoint& pageLocation() const;
         int x() const;
         int y() const;
 
         // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords,
         // usable with RenderObject::absoluteToLocal).
-        IntPoint absoluteLocation() const { return m_absoluteLocation; }
+        const IntPoint& absoluteLocation() const { return m_absoluteLocation; }
         void setAbsoluteLocation(const IntPoint& p) { m_absoluteLocation = p; }
     
     protected:
         MouseRelatedEvent();
         MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
-                          int detail, int screenX, int screenY, int pageX, int pageY,
+                          int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
                           bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated = false);
 
         void initCoordinates();
-        void initCoordinates(int clientX, int clientY);
+        void initCoordinates(const IntPoint& clientLocation);
         virtual void receivedTarget();
 
         void computePageLocation();
         void computeRelativePosition();
         
         // Expose these so MouseEvent::initMouseEvent can set them.
-        int m_screenX;
-        int m_screenY;
-        int m_clientX;
-        int m_clientY;
+        IntPoint m_screenLocation;
+        IntPoint m_clientLocation;
 
     private:
-        int m_pageX;
-        int m_pageY;
-        int m_layerX;
-        int m_layerY;
-        int m_offsetX;
-        int m_offsetY;
+        IntPoint m_pageLocation;
+        IntPoint m_layerLocation;
+        IntPoint m_offsetLocation;
         IntPoint m_absoluteLocation;
         bool m_isSimulated;
         bool m_hasCachedRelativePosition;

Modified: trunk/Source/WebCore/dom/TouchEvent.cpp (87864 => 87865)


--- trunk/Source/WebCore/dom/TouchEvent.cpp	2011-06-01 23:15:58 UTC (rev 87864)
+++ trunk/Source/WebCore/dom/TouchEvent.cpp	2011-06-01 23:19:02 UTC (rev 87865)
@@ -40,8 +40,8 @@
         TouchList* changedTouches, const AtomicString& type, 
         PassRefPtr<AbstractView> view, int screenX, int screenY, int pageX, int pageY,
         bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
-    : MouseRelatedEvent(type, true, true, view, 0, screenX, screenY, pageX, pageY,
-                        ctrlKey, altKey, shiftKey, metaKey)
+    : MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY),
+                        IntPoint(pageX, pageY), ctrlKey, altKey, shiftKey, metaKey)
     , m_touches(touches)
     , m_targetTouches(targetTouches)
     , m_changedTouches(changedTouches)
@@ -65,13 +65,12 @@
     m_touches = touches;
     m_targetTouches = targetTouches;
     m_changedTouches = changedTouches;
-    m_screenX = screenX;
-    m_screenY = screenY;
+    m_screenLocation = IntPoint(screenX, screenY);
     m_ctrlKey = ctrlKey;
     m_altKey = altKey;
     m_shiftKey = shiftKey;
     m_metaKey = metaKey;
-    initCoordinates(clientX, clientY);
+    initCoordinates(IntPoint(clientX, clientY));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/WheelEvent.cpp (87864 => 87865)


--- trunk/Source/WebCore/dom/WheelEvent.cpp	2011-06-01 23:15:58 UTC (rev 87864)
+++ trunk/Source/WebCore/dom/WheelEvent.cpp	2011-06-01 23:19:02 UTC (rev 87865)
@@ -32,25 +32,19 @@
 namespace WebCore {
 
 WheelEvent::WheelEvent()
-    : m_wheelDeltaX(0)
-    , m_wheelDeltaY(0)
-    , m_rawDeltaX(0)
-    , m_rawDeltaY(0)
-    , m_granularity(Pixel)
+    : m_granularity(Pixel)
 {
 }
 
-WheelEvent::WheelEvent(float wheelTicksX, float wheelTicksY, float rawDeltaX, float rawDeltaY,
+WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
                        Granularity granularity, PassRefPtr<AbstractView> view,
-                       int screenX, int screenY, int pageX, int pageY,
+                       const IntPoint& screenLocation, const IntPoint& pageLocation,
                        bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
     : MouseRelatedEvent(eventNames().mousewheelEvent,
-                        true, true, view, 0, screenX, screenY, pageX, pageY,
+                        true, true, view, 0, screenLocation, pageLocation,
                         ctrlKey, altKey, shiftKey, metaKey)
-    , m_wheelDeltaX(lroundf(wheelTicksX * 120))
-    , m_wheelDeltaY(lroundf(wheelTicksY * 120)) // Normalize to the Windows 120 multiple
-    , m_rawDeltaX(rawDeltaX)
-    , m_rawDeltaY(rawDeltaY)
+    , m_wheelDelta(IntPoint(static_cast<int>(wheelTicks.x() * 120), static_cast<int>(wheelTicks.y() * 120)))
+    , m_rawDelta(roundedIntPoint(rawDelta))
     , m_granularity(granularity)
 {
 }
@@ -64,22 +58,19 @@
     
     initUIEvent(eventNames().mousewheelEvent, true, true, view, 0);
     
-    m_screenX = screenX;
-    m_screenY = screenY;
+    m_screenLocation = IntPoint(screenX, screenY);
     m_ctrlKey = ctrlKey;
     m_altKey = altKey;
     m_shiftKey = shiftKey;
     m_metaKey = metaKey;
     
     // Normalize to the Windows 120 multiple
-    m_wheelDeltaX = rawDeltaX * 120;
-    m_wheelDeltaY = rawDeltaY * 120;
+    m_wheelDelta = IntPoint(rawDeltaX * 120, rawDeltaY * 120);
     
-    m_rawDeltaX = rawDeltaX;
-    m_rawDeltaY = rawDeltaY;
+    m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
     m_granularity = Pixel;
     
-    initCoordinates(pageX, pageY);
+    initCoordinates(IntPoint(pageX, pageY));
 }
 
 void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView> view,
@@ -105,8 +96,8 @@
     if (!(event.deltaX() || event.deltaY()))
         return;
 
-    setEvent(WheelEvent::create(event.wheelTicksX(), event.wheelTicksY(), event.deltaX(), event.deltaY(), granularity(event),
-        view, event.globalX(), event.globalY(), event.x(), event.y(), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()));
+    setEvent(WheelEvent::create(FloatPoint(event.wheelTicksX(), event.wheelTicksY()), FloatPoint(event.deltaX(), event.deltaY()), granularity(event),
+        view, IntPoint(event.globalX(), event.globalY()), IntPoint(event.x(), event.y()), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()));
 
 }
 

Modified: trunk/Source/WebCore/dom/WheelEvent.h (87864 => 87865)


--- trunk/Source/WebCore/dom/WheelEvent.h	2011-06-01 23:15:58 UTC (rev 87864)
+++ trunk/Source/WebCore/dom/WheelEvent.h	2011-06-01 23:19:02 UTC (rev 87865)
@@ -24,6 +24,7 @@
 #ifndef WheelEvent_h
 #define WheelEvent_h
 
+#include "FloatPoint.h"
 #include "MouseRelatedEvent.h"
 
 namespace WebCore {
@@ -37,14 +38,13 @@
         {
             return adoptRef(new WheelEvent);
         }
-        static PassRefPtr<WheelEvent> create(float wheelTicksX, float wheelTicksY,
-            float rawDeltaX, float rawDeltaY, Granularity granularity, PassRefPtr<AbstractView> view,
-            int screenX, int screenY, int pageX, int pageY,
+        static PassRefPtr<WheelEvent> create(const FloatPoint& wheelTicks,
+            const FloatPoint& rawDelta, Granularity granularity, PassRefPtr<AbstractView> view,
+            const IntPoint& screenLocation, const IntPoint& pageLocation,
             bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
         {
-            return adoptRef(new WheelEvent(wheelTicksX, wheelTicksY, rawDeltaX, rawDeltaY,
-                granularity, view, screenX, screenY, pageX, pageY,
-                ctrlKey, altKey, shiftKey, metaKey));
+            return adoptRef(new WheelEvent(wheelTicks, rawDelta, granularity, view,
+                screenLocation, pageLocation, ctrlKey, altKey, shiftKey, metaKey));
         }
 
         void initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView>,
@@ -55,30 +55,27 @@
                                   int screenX, int screenY, int pageX, int pageY,
                                   bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
 
-        int wheelDelta() const { if (m_wheelDeltaY == 0) return m_wheelDeltaX; return m_wheelDeltaY; }
-        int wheelDeltaX() const { return m_wheelDeltaX; }
-        int wheelDeltaY() const { return m_wheelDeltaY; }
-        int rawDeltaX() const { return m_rawDeltaX; }
-        int rawDeltaY() const { return m_rawDeltaY; }
+        int wheelDelta() const { return m_wheelDelta.y() ? m_wheelDelta.y() : m_wheelDelta.x(); }
+        int wheelDeltaX() const { return m_wheelDelta.x(); }
+        int wheelDeltaY() const { return m_wheelDelta.y(); }
+        int rawDeltaX() const { return m_rawDelta.x(); }
+        int rawDeltaY() const { return m_rawDelta.y(); }
         Granularity granularity() const { return m_granularity; }
 
         // Needed for Objective-C legacy support
-        bool isHorizontal() const { return m_wheelDeltaX; }
+        bool isHorizontal() const { return m_wheelDelta.x(); }
 
     private:
         WheelEvent();
-        WheelEvent(float wheelTicksX, float wheelTicksY, float rawDeltaX, float rawDeltaY,
+        WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
                    Granularity granularity, PassRefPtr<AbstractView>,
-                   int screenX, int screenY, int pageX, int pageY,
+                   const IntPoint& screenLocation, const IntPoint& pageLocation,
                    bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
 
         virtual bool isWheelEvent() const;
-        
-        int m_wheelDeltaX;
-        int m_wheelDeltaY;
 
-        int m_rawDeltaX;
-        int m_rawDeltaY;
+        IntPoint m_wheelDelta;
+        IntPoint m_rawDelta;
         Granularity m_granularity;
     };
 

Modified: trunk/Source/WebCore/platform/graphics/IntPoint.h (87864 => 87865)


--- trunk/Source/WebCore/platform/graphics/IntPoint.h	2011-06-01 23:15:58 UTC (rev 87864)
+++ trunk/Source/WebCore/platform/graphics/IntPoint.h	2011-06-01 23:19:02 UTC (rev 87865)
@@ -27,6 +27,7 @@
 #define IntPoint_h
 
 #include "IntSize.h"
+#include <wtf/MathExtras.h>
 
 #if PLATFORM(QT)
 #include <QDataStream>
@@ -92,6 +93,11 @@
     void move(const IntSize& s) { move(s.width(), s.height()); } 
     void move(const IntPoint& offset) { move(offset.x(), offset.y()); }
     void move(int dx, int dy) { m_x += dx; m_y += dy; }
+    void scale(float sx, float sy)
+    {
+        m_x = lroundf(static_cast<float>(m_x * sx));
+        m_y = lroundf(static_cast<float>(m_y * sy));
+    }
     
     IntPoint expandedTo(const IntPoint& other) const
     {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to