Changeset 87865 in webkit


Ignore:
Timestamp:
Jun 1, 2011, 4:19:02 PM (14 years ago)
Author:
eae@chromium.org
Message:

2011-06-01 Emil A Eklund <eae@chromium.org>

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):
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87864 r87865  
     12011-06-01  Emil A Eklund  <eae@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Switch MouseRelatedEvent to use IntPoint
     6        https://bugs.webkit.org/show_bug.cgi?id=61574
     7
     8        Covered by existing tests.
     9
     10        * dom/MouseEvent.cpp:
     11        (WebCore::MouseEvent::MouseEvent):
     12        (WebCore::MouseEvent::initMouseEvent):
     13        (WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
     14        * dom/MouseRelatedEvent.cpp:
     15        (WebCore::MouseRelatedEvent::MouseRelatedEvent):
     16        (WebCore::contentsScrollOffset):
     17        (WebCore::MouseRelatedEvent::initCoordinates):
     18        (WebCore::MouseRelatedEvent::computeRelativePosition):
     19        (WebCore::MouseRelatedEvent::layerX):
     20        (WebCore::MouseRelatedEvent::layerY):
     21        (WebCore::MouseRelatedEvent::offsetX):
     22        (WebCore::MouseRelatedEvent::offsetY):
     23        (WebCore::MouseRelatedEvent::pageX):
     24        (WebCore::MouseRelatedEvent::pageY):
     25        (WebCore::MouseRelatedEvent::pageLocation):
     26        (WebCore::MouseRelatedEvent::x):
     27        (WebCore::MouseRelatedEvent::y):
     28        * dom/MouseRelatedEvent.h:
     29        (WebCore::MouseRelatedEvent::screenX):
     30        (WebCore::MouseRelatedEvent::screenY):
     31        (WebCore::MouseRelatedEvent::screenLocation):
     32        (WebCore::MouseRelatedEvent::clientX):
     33        (WebCore::MouseRelatedEvent::clientY):
     34        (WebCore::MouseRelatedEvent::clientLocation):
     35        (WebCore::MouseRelatedEvent::absoluteLocation):
     36        * dom/TouchEvent.cpp:
     37        (WebCore::TouchEvent::TouchEvent):
     38        (WebCore::TouchEvent::initTouchEvent):
     39        * dom/WheelEvent.cpp:
     40        (WebCore::WheelEvent::WheelEvent):
     41        (WebCore::WheelEvent::initWheelEvent):
     42        (WebCore::WheelEventDispatchMediator::WheelEventDispatchMediator):
     43        * dom/WheelEvent.h:
     44        (WebCore::WheelEvent::create):
     45        (WebCore::WheelEvent::wheelDelta):
     46        (WebCore::WheelEvent::wheelDeltaX):
     47        (WebCore::WheelEvent::wheelDeltaY):
     48        (WebCore::WheelEvent::rawDeltaX):
     49        (WebCore::WheelEvent::rawDeltaY):
     50        (WebCore::WheelEvent::isHorizontal):
     51        * platform/graphics/IntPoint.h:
     52        (WebCore::IntPoint::scale):
     53
    1542011-06-01  Levi Weintraub  <leviw@chromium.org>
    255
  • trunk/Source/WebCore/dom/MouseEvent.cpp

    r86776 r87865  
    5555                       unsigned short button, PassRefPtr<EventTarget> relatedTarget,
    5656                       PassRefPtr<Clipboard> clipboard, bool isSimulated)
    57     : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, screenX, screenY,
    58                         pageX, pageY, ctrlKey, altKey, shiftKey, metaKey, isSimulated)
     57    : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint(screenX, screenY),
     58                        IntPoint(pageX, pageY), ctrlKey, altKey, shiftKey, metaKey, isSimulated)
    5959    , m_button(button == (unsigned short)-1 ? 0 : button)
    6060    , m_buttonDown(button != (unsigned short)-1)
     
    7878    initUIEvent(type, canBubble, cancelable, view, detail);
    7979
    80     m_screenX = screenX;
    81     m_screenY = screenY;
     80    m_screenLocation = IntPoint(screenX, screenY);
    8281    m_ctrlKey = ctrlKey;
    8382    m_altKey = altKey;
     
    8887    m_relatedTarget = relatedTarget;
    8988
    90     initCoordinates(clientX, clientY);
     89    initCoordinates(IntPoint(clientX, clientY));
    9190
    9291    // FIXME: m_isSimulated is not set to false here.
     
    154153    if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
    155154        MouseEvent* mouseEvent = static_cast<MouseEvent*>(this->underlyingEvent());
    156         m_screenX = mouseEvent->screenX();
    157         m_screenY = mouseEvent->screenY();
    158         initCoordinates(mouseEvent->clientX(), mouseEvent->clientY());
     155        m_screenLocation = mouseEvent->screenLocation();
     156        initCoordinates(mouseEvent->clientLocation());
    159157    }
    160158}
  • trunk/Source/WebCore/dom/MouseRelatedEvent.cpp

    r87467 r87865  
    3434
    3535MouseRelatedEvent::MouseRelatedEvent()
    36     : m_screenX(0)
    37     , m_screenY(0)
    38     , m_clientX(0)
    39     , m_clientY(0)
    40     , m_pageX(0)
    41     , m_pageY(0)
    42     , m_layerX(0)
    43     , m_layerY(0)
    44     , m_offsetX(0)
    45     , m_offsetY(0)
    46     , m_isSimulated(false)
     36    : m_isSimulated(false)
    4737    , m_hasCachedRelativePosition(false)
    4838{
    4939}
    5040
    51 static int contentsX(AbstractView* abstractView)
     41static IntSize contentsScrollOffset(AbstractView* abstractView)
    5242{
    5343    if (!abstractView)
    54         return 0;
     44        return IntSize();
    5545    Frame* frame = abstractView->frame();
    5646    if (!frame)
    57         return 0;
     47        return IntSize();
    5848    FrameView* frameView = frame->view();
    5949    if (!frameView)
    60         return 0;
    61     return frameView->scrollX() / frame->pageZoomFactor();
    62 }
    63 
    64 static int contentsY(AbstractView* abstractView)
    65 {
    66     if (!abstractView)
    67         return 0;
    68     Frame* frame = abstractView->frame();
    69     if (!frame)
    70         return 0;
    71     FrameView* frameView = frame->view();
    72     if (!frameView)
    73         return 0;
    74     return frameView->scrollY() / frame->pageZoomFactor();
     50        return IntSize();
     51    return IntSize(frameView->scrollX() / frame->pageZoomFactor(),
     52        frameView->scrollY() / frame->pageZoomFactor());
    7553}
    7654
    7755MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, PassRefPtr<AbstractView> abstractView,
    78                                      int detail, int screenX, int screenY, int windowX, int windowY,
     56                                     int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
    7957                                     bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated)
    8058    : UIEventWithKeyState(eventType, canBubble, cancelable, abstractView, detail, ctrlKey, altKey, shiftKey, metaKey)
    81     , m_screenX(screenX)
    82     , m_screenY(screenY)
    83     , m_clientX(0)
    84     , m_clientY(0)
    85     , m_pageX(0)
    86     , m_pageY(0)
     59    , m_screenLocation(screenLocation)
    8760    , m_isSimulated(isSimulated)
    8861{
     
    9467        if (FrameView* frameView = frame->view()) {
    9568            scrollPosition = frameView->scrollPosition();
    96             adjustedPageLocation = frameView->windowToContents(IntPoint(windowX, windowY));
     69            adjustedPageLocation = frameView->windowToContents(windowLocation);
    9770            float pageZoom = frame->pageZoomFactor();
    9871            if (pageZoom != 1.0f) {
    9972                // Adjust our pageX and pageY to account for the page zoom.
    100                 adjustedPageLocation.setX(lroundf(adjustedPageLocation.x() / pageZoom));
    101                 adjustedPageLocation.setY(lroundf(adjustedPageLocation.y() / pageZoom));
     73                adjustedPageLocation.scale(1 / pageZoom, 1 / pageZoom);
     74
     75                // FIXME: Change this to use float math and proper rounding (or
     76                // better yet, use IntPoint::scale).
    10277                scrollPosition.setX(scrollPosition.x() / pageZoom);
    10378                scrollPosition.setY(scrollPosition.y() / pageZoom);
     
    10681    }
    10782
    108     IntPoint clientLocation(adjustedPageLocation - scrollPosition);
    109     m_clientX = clientLocation.x();
    110     m_clientY = clientLocation.y();
    111     m_pageX = adjustedPageLocation.x();
    112     m_pageY = adjustedPageLocation.y();
     83    m_clientLocation = adjustedPageLocation - toSize(scrollPosition);
     84    m_pageLocation = adjustedPageLocation;
    11385
    11486    initCoordinates();
     
    11991    // Set up initial values for coordinates.
    12092    // Correct values are computed lazily, see computeRelativePosition.
    121     m_layerX = m_pageX;
    122     m_layerY = m_pageY;
    123     m_offsetX = m_pageX;
    124     m_offsetY = m_pageY;
     93    m_layerLocation = m_pageLocation;
     94    m_offsetLocation = m_pageLocation;
    12595
    12696    computePageLocation();
     
    12898}
    12999
    130 void MouseRelatedEvent::initCoordinates(int clientX, int clientY)
     100void MouseRelatedEvent::initCoordinates(const IntPoint& clientLocation)
    131101{
    132102    // Set up initial values for coordinates.
    133103    // Correct values are computed lazily, see computeRelativePosition.
    134     m_clientX = clientX;
    135     m_clientY = clientY;
    136     m_pageX = clientX + contentsX(view());
    137     m_pageY = clientY + contentsY(view());
    138     m_layerX = m_pageX;
    139     m_layerY = m_pageY;
    140     m_offsetX = m_pageX;
    141     m_offsetY = m_pageY;
     104    m_clientLocation = clientLocation;
     105    m_pageLocation = clientLocation + contentsScrollOffset(view());
     106
     107    m_layerLocation = m_pageLocation;
     108    m_offsetLocation = m_pageLocation;
    142109
    143110    computePageLocation();
     
    174141
    175142    // Compute coordinates that are based on the target.
    176     m_layerX = m_pageX;
    177     m_layerY = m_pageY;
    178     m_offsetX = m_pageX;
    179     m_offsetY = m_pageY;
     143    m_layerLocation = m_pageLocation;
     144    m_offsetLocation = m_pageLocation;
    180145
    181146    // Must have an updated render tree for this math to work correctly.
    182147    targetNode->document()->updateStyleIfNeeded();
    183148
    184     // Adjust offsetX/Y to be relative to the target's position.
     149    // Adjust offsetLocation to be relative to the target's position.
    185150    if (!isSimulated()) {
    186151        if (RenderObject* r = targetNode->renderer()) {
    187152            FloatPoint localPos = r->absoluteToLocal(absoluteLocation(), false, true);
    188             float zoomFactor = pageZoomFactor(this);
    189             m_offsetX = lroundf(localPos.x() / zoomFactor);
    190             m_offsetY = lroundf(localPos.y() / zoomFactor);
     153            m_offsetLocation = roundedIntPoint(localPos);
     154            float scaleFactor = 1 / pageZoomFactor(this);
     155            if (scaleFactor != 1.0f)
     156                m_offsetLocation.scale(scaleFactor, scaleFactor);
    191157        }
    192158    }
    193159
    194     // Adjust layerX/Y to be relative to the layer.
     160    // Adjust layerLocation to be relative to the layer.
    195161    // FIXME: We're pretty sure this is the wrong definition of "layer."
    196162    // Our RenderLayer is a more modern concept, and layerX/Y is some
     
    205171        layer->updateLayerPosition();
    206172        for (; layer; layer = layer->parent()) {
    207             const IntPoint& location = layer->location();
    208             m_layerX -= location.x();
    209             m_layerY -= location.y();
     173            m_layerLocation -= toSize(layer->location());
    210174        }
    211175    }
     
    218182    if (!m_hasCachedRelativePosition)
    219183        computeRelativePosition();
    220     return m_layerX;
     184    return m_layerLocation.x();
    221185}
    222186
     
    225189    if (!m_hasCachedRelativePosition)
    226190        computeRelativePosition();
    227     return m_layerY;
     191    return m_layerLocation.y();
    228192}
    229193
     
    232196    if (!m_hasCachedRelativePosition)
    233197        computeRelativePosition();
    234     return m_offsetX;
     198    return m_offsetLocation.x();
    235199}
    236200
     
    239203    if (!m_hasCachedRelativePosition)
    240204        computeRelativePosition();
    241     return m_offsetY;
     205    return m_offsetLocation.y();
    242206}
    243207
    244208int MouseRelatedEvent::pageX() const
    245209{
    246     return m_pageX;
     210    return m_pageLocation.x();
    247211}
    248212
    249213int MouseRelatedEvent::pageY() const
    250214{
    251     return m_pageY;
     215    return m_pageLocation.y();
     216}
     217
     218const IntPoint& MouseRelatedEvent::pageLocation() const
     219{
     220    return m_pageLocation;
    252221}
    253222
     
    256225    // FIXME: This is not correct.
    257226    // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events.html>.
    258     return m_clientX;
     227    return m_clientLocation.x();
    259228}
    260229
     
    263232    // FIXME: This is not correct.
    264233    // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events.html>.
    265     return m_clientY;
     234    return m_clientLocation.y();
    266235}
    267236
  • trunk/Source/WebCore/dom/MouseRelatedEvent.h

    r82225 r87865  
    3535        // Note that these values are adjusted to counter the effects of zoom, so that values
    3636        // exposed via DOM APIs are invariant under zooming.
    37         int screenX() const { return m_screenX; }
    38         int screenY() const { return m_screenY; }
    39         int clientX() const { return m_clientX; }
    40         int clientY() const { return m_clientY; }
     37        int screenX() const { return m_screenLocation.x(); }
     38        int screenY() const { return m_screenLocation.y(); }
     39        const IntPoint& screenLocation() const { return m_screenLocation; }
     40        int clientX() const { return m_clientLocation.x(); }
     41        int clientY() const { return m_clientLocation.y(); }
     42        const IntPoint& clientLocation() const { return m_clientLocation; }
    4143        int layerX();
    4244        int layerY();
     
    4648        virtual int pageX() const;
    4749        virtual int pageY() const;
     50        virtual const IntPoint& pageLocation() const;
    4851        int x() const;
    4952        int y() const;
     
    5154        // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords,
    5255        // usable with RenderObject::absoluteToLocal).
    53         IntPoint absoluteLocation() const { return m_absoluteLocation; }
     56        const IntPoint& absoluteLocation() const { return m_absoluteLocation; }
    5457        void setAbsoluteLocation(const IntPoint& p) { m_absoluteLocation = p; }
    5558   
     
    5760        MouseRelatedEvent();
    5861        MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
    59                           int detail, int screenX, int screenY, int pageX, int pageY,
     62                          int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
    6063                          bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated = false);
    6164
    6265        void initCoordinates();
    63         void initCoordinates(int clientX, int clientY);
     66        void initCoordinates(const IntPoint& clientLocation);
    6467        virtual void receivedTarget();
    6568
     
    6871       
    6972        // Expose these so MouseEvent::initMouseEvent can set them.
    70         int m_screenX;
    71         int m_screenY;
    72         int m_clientX;
    73         int m_clientY;
     73        IntPoint m_screenLocation;
     74        IntPoint m_clientLocation;
    7475
    7576    private:
    76         int m_pageX;
    77         int m_pageY;
    78         int m_layerX;
    79         int m_layerY;
    80         int m_offsetX;
    81         int m_offsetY;
     77        IntPoint m_pageLocation;
     78        IntPoint m_layerLocation;
     79        IntPoint m_offsetLocation;
    8280        IntPoint m_absoluteLocation;
    8381        bool m_isSimulated;
  • trunk/Source/WebCore/dom/TouchEvent.cpp

    r86135 r87865  
    4141        PassRefPtr<AbstractView> view, int screenX, int screenY, int pageX, int pageY,
    4242        bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
    43     : MouseRelatedEvent(type, true, true, view, 0, screenX, screenY, pageX, pageY,
    44                         ctrlKey, altKey, shiftKey, metaKey)
     43    : MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY),
     44                        IntPoint(pageX, pageY), ctrlKey, altKey, shiftKey, metaKey)
    4545    , m_touches(touches)
    4646    , m_targetTouches(targetTouches)
     
    6666    m_targetTouches = targetTouches;
    6767    m_changedTouches = changedTouches;
    68     m_screenX = screenX;
    69     m_screenY = screenY;
     68    m_screenLocation = IntPoint(screenX, screenY);
    7069    m_ctrlKey = ctrlKey;
    7170    m_altKey = altKey;
    7271    m_shiftKey = shiftKey;
    7372    m_metaKey = metaKey;
    74     initCoordinates(clientX, clientY);
     73    initCoordinates(IntPoint(clientX, clientY));
    7574}
    7675
  • trunk/Source/WebCore/dom/WheelEvent.cpp

    r83298 r87865  
    3333
    3434WheelEvent::WheelEvent()
    35     : m_wheelDeltaX(0)
    36     , m_wheelDeltaY(0)
    37     , m_rawDeltaX(0)
    38     , m_rawDeltaY(0)
    39     , m_granularity(Pixel)
     35    : m_granularity(Pixel)
    4036{
    4137}
    4238
    43 WheelEvent::WheelEvent(float wheelTicksX, float wheelTicksY, float rawDeltaX, float rawDeltaY,
     39WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
    4440                       Granularity granularity, PassRefPtr<AbstractView> view,
    45                        int screenX, int screenY, int pageX, int pageY,
     41                       const IntPoint& screenLocation, const IntPoint& pageLocation,
    4642                       bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
    4743    : MouseRelatedEvent(eventNames().mousewheelEvent,
    48                         true, true, view, 0, screenX, screenY, pageX, pageY,
     44                        true, true, view, 0, screenLocation, pageLocation,
    4945                        ctrlKey, altKey, shiftKey, metaKey)
    50     , m_wheelDeltaX(lroundf(wheelTicksX * 120))
    51     , m_wheelDeltaY(lroundf(wheelTicksY * 120)) // Normalize to the Windows 120 multiple
    52     , m_rawDeltaX(rawDeltaX)
    53     , m_rawDeltaY(rawDeltaY)
     46    , m_wheelDelta(IntPoint(static_cast<int>(wheelTicks.x() * 120), static_cast<int>(wheelTicks.y() * 120)))
     47    , m_rawDelta(roundedIntPoint(rawDelta))
    5448    , m_granularity(granularity)
    5549{
     
    6559    initUIEvent(eventNames().mousewheelEvent, true, true, view, 0);
    6660   
    67     m_screenX = screenX;
    68     m_screenY = screenY;
     61    m_screenLocation = IntPoint(screenX, screenY);
    6962    m_ctrlKey = ctrlKey;
    7063    m_altKey = altKey;
     
    7366   
    7467    // Normalize to the Windows 120 multiple
    75     m_wheelDeltaX = rawDeltaX * 120;
    76     m_wheelDeltaY = rawDeltaY * 120;
     68    m_wheelDelta = IntPoint(rawDeltaX * 120, rawDeltaY * 120);
    7769   
    78     m_rawDeltaX = rawDeltaX;
    79     m_rawDeltaY = rawDeltaY;
     70    m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
    8071    m_granularity = Pixel;
    8172   
    82     initCoordinates(pageX, pageY);
     73    initCoordinates(IntPoint(pageX, pageY));
    8374}
    8475
     
    10697        return;
    10798
    108     setEvent(WheelEvent::create(event.wheelTicksX(), event.wheelTicksY(), event.deltaX(), event.deltaY(), granularity(event),
    109         view, event.globalX(), event.globalY(), event.x(), event.y(), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()));
     99    setEvent(WheelEvent::create(FloatPoint(event.wheelTicksX(), event.wheelTicksY()), FloatPoint(event.deltaX(), event.deltaY()), granularity(event),
     100        view, IntPoint(event.globalX(), event.globalY()), IntPoint(event.x(), event.y()), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()));
    110101
    111102}
  • trunk/Source/WebCore/dom/WheelEvent.h

    r83298 r87865  
    2525#define WheelEvent_h
    2626
     27#include "FloatPoint.h"
    2728#include "MouseRelatedEvent.h"
    2829
     
    3839            return adoptRef(new WheelEvent);
    3940        }
    40         static PassRefPtr<WheelEvent> create(float wheelTicksX, float wheelTicksY,
    41             float rawDeltaX, float rawDeltaY, Granularity granularity, PassRefPtr<AbstractView> view,
    42             int screenX, int screenY, int pageX, int pageY,
     41        static PassRefPtr<WheelEvent> create(const FloatPoint& wheelTicks,
     42            const FloatPoint& rawDelta, Granularity granularity, PassRefPtr<AbstractView> view,
     43            const IntPoint& screenLocation, const IntPoint& pageLocation,
    4344            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
    4445        {
    45             return adoptRef(new WheelEvent(wheelTicksX, wheelTicksY, rawDeltaX, rawDeltaY,
    46                 granularity, view, screenX, screenY, pageX, pageY,
    47                 ctrlKey, altKey, shiftKey, metaKey));
     46            return adoptRef(new WheelEvent(wheelTicks, rawDelta, granularity, view,
     47                screenLocation, pageLocation, ctrlKey, altKey, shiftKey, metaKey));
    4848        }
    4949
     
    5656                                  bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
    5757
    58         int wheelDelta() const { if (m_wheelDeltaY == 0) return m_wheelDeltaX; return m_wheelDeltaY; }
    59         int wheelDeltaX() const { return m_wheelDeltaX; }
    60         int wheelDeltaY() const { return m_wheelDeltaY; }
    61         int rawDeltaX() const { return m_rawDeltaX; }
    62         int rawDeltaY() const { return m_rawDeltaY; }
     58        int wheelDelta() const { return m_wheelDelta.y() ? m_wheelDelta.y() : m_wheelDelta.x(); }
     59        int wheelDeltaX() const { return m_wheelDelta.x(); }
     60        int wheelDeltaY() const { return m_wheelDelta.y(); }
     61        int rawDeltaX() const { return m_rawDelta.x(); }
     62        int rawDeltaY() const { return m_rawDelta.y(); }
    6363        Granularity granularity() const { return m_granularity; }
    6464
    6565        // Needed for Objective-C legacy support
    66         bool isHorizontal() const { return m_wheelDeltaX; }
     66        bool isHorizontal() const { return m_wheelDelta.x(); }
    6767
    6868    private:
    6969        WheelEvent();
    70         WheelEvent(float wheelTicksX, float wheelTicksY, float rawDeltaX, float rawDeltaY,
     70        WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
    7171                   Granularity granularity, PassRefPtr<AbstractView>,
    72                    int screenX, int screenY, int pageX, int pageY,
     72                   const IntPoint& screenLocation, const IntPoint& pageLocation,
    7373                   bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
    7474
    7575        virtual bool isWheelEvent() const;
    76        
    77         int m_wheelDeltaX;
    78         int m_wheelDeltaY;
    7976
    80         int m_rawDeltaX;
    81         int m_rawDeltaY;
     77        IntPoint m_wheelDelta;
     78        IntPoint m_rawDelta;
    8279        Granularity m_granularity;
    8380    };
  • trunk/Source/WebCore/platform/graphics/IntPoint.h

    r87303 r87865  
    2828
    2929#include "IntSize.h"
     30#include <wtf/MathExtras.h>
    3031
    3132#if PLATFORM(QT)
     
    9394    void move(const IntPoint& offset) { move(offset.x(), offset.y()); }
    9495    void move(int dx, int dy) { m_x += dx; m_y += dy; }
     96    void scale(float sx, float sy)
     97    {
     98        m_x = lroundf(static_cast<float>(m_x * sx));
     99        m_y = lroundf(static_cast<float>(m_y * sy));
     100    }
    95101   
    96102    IntPoint expandedTo(const IntPoint& other) const
Note: See TracChangeset for help on using the changeset viewer.