Changeset 99014 in webkit


Ignore:
Timestamp:
Nov 1, 2011 5:08:04 PM (12 years ago)
Author:
eae@chromium.org
Message:

Use IntPoint for screen coordinates in MouseEvent
https://bugs.webkit.org/show_bug.cgi?id=71327

Reviewed by Darin Adler.

Change mouse events to use int/IntPoint for screen/window coordinates and
LayoutUnit/LayoutPoint for coordinates adjusted for zooming.

No new tests.

  • dom/MouseRelatedEvent.cpp:

(WebCore::MouseRelatedEvent::MouseRelatedEvent):
(WebCore::MouseRelatedEvent::computeRelativePosition):

  • dom/MouseRelatedEvent.h:

(WebCore::MouseRelatedEvent::screenLocation):
Revert screenLocation and windowLocation back to int.

  • page/DragController.cpp:

(WebCore::elementUnderMouse):
Change elementUnderMouse to use a LayoutPoint for hit testing.

  • page/EventHandler.cpp:

(WebCore::EventHandler::clear):
(WebCore::EventHandler::currentMousePosition):
(WebCore::documentPointForWindowPoint):
(WebCore::EventHandler::fakeMouseMoveEventTimerFired):

  • page/EventHandler.h:

Revert m_currentMousePosition to IntPoint as it represents a
screen coordinate.

  • platform/PlatformMouseEvent.h:

(WebCore::PlatformMouseEvent::PlatformMouseEvent):
(WebCore::PlatformMouseEvent::pos):
(WebCore::PlatformMouseEvent::x):
(WebCore::PlatformMouseEvent::y):
(WebCore::PlatformMouseEvent::globalX):
(WebCore::PlatformMouseEvent::globalY):

  • platform/mac/PlatformMouseEventMac.mm:

(WebCore::globalPoint):
(WebCore::pointForEvent):
(WebCore::globalPointForEvent):
Revert PlatformMouseEvent to int/IntPoint as it represents a screen
coordinate.

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r99013 r99014  
     12011-11-01  Emil A Eklund  <eae@chromium.org>
     2
     3        Use IntPoint for screen coordinates in MouseEvent
     4        https://bugs.webkit.org/show_bug.cgi?id=71327
     5
     6        Reviewed by Darin Adler.
     7
     8        Change mouse events to use int/IntPoint for screen/window coordinates and
     9        LayoutUnit/LayoutPoint for coordinates adjusted for zooming.
     10
     11        No new tests.
     12
     13        * dom/MouseRelatedEvent.cpp:
     14        (WebCore::MouseRelatedEvent::MouseRelatedEvent):
     15        (WebCore::MouseRelatedEvent::computeRelativePosition):
     16        * dom/MouseRelatedEvent.h:
     17        (WebCore::MouseRelatedEvent::screenLocation):
     18        Revert screenLocation and windowLocation back to int.
     19
     20        * page/DragController.cpp:
     21        (WebCore::elementUnderMouse):
     22        Change elementUnderMouse to use a LayoutPoint for hit testing.
     23
     24        * page/EventHandler.cpp:
     25        (WebCore::EventHandler::clear):
     26        (WebCore::EventHandler::currentMousePosition):
     27        (WebCore::documentPointForWindowPoint):
     28        (WebCore::EventHandler::fakeMouseMoveEventTimerFired):
     29        * page/EventHandler.h:
     30        Revert m_currentMousePosition to IntPoint as it represents a
     31        screen coordinate.
     32
     33        * platform/PlatformMouseEvent.h:
     34        (WebCore::PlatformMouseEvent::PlatformMouseEvent):
     35        (WebCore::PlatformMouseEvent::pos):
     36        (WebCore::PlatformMouseEvent::x):
     37        (WebCore::PlatformMouseEvent::y):
     38        (WebCore::PlatformMouseEvent::globalX):
     39        (WebCore::PlatformMouseEvent::globalY):
     40        * platform/mac/PlatformMouseEventMac.mm:
     41        (WebCore::globalPoint):
     42        (WebCore::pointForEvent):
     43        (WebCore::globalPointForEvent):
     44        Revert PlatformMouseEvent to int/IntPoint as it represents a screen
     45        coordinate.
     46
    1472011-11-01  Tony Chang  <tony@chromium.org>
    248
  • trunk/Source/WebCore/dom/MouseRelatedEvent.cpp

    r97380 r99014  
    5454
    5555MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, PassRefPtr<AbstractView> abstractView,
    56                                      int detail, const LayoutPoint& screenLocation, const LayoutPoint& windowLocation,
     56                                     int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
    5757                                     bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated)
    5858    : UIEventWithKeyState(eventType, canBubble, cancelable, abstractView, detail, ctrlKey, altKey, shiftKey, metaKey)
     
    8181    }
    8282
    83     m_clientLocation = adjustedPageLocation - toSize(scrollPosition);
     83    m_clientLocation = adjustedPageLocation - toLayoutSize(scrollPosition);
    8484    m_pageLocation = adjustedPageLocation;
    8585
     
    182182        layer->updateLayerPosition();
    183183        for (; layer; layer = layer->parent()) {
    184             m_layerLocation -= toSize(layer->location());
     184            m_layerLocation -= toLayoutSize(layer->location());
    185185        }
    186186    }
  • trunk/Source/WebCore/dom/MouseRelatedEvent.h

    r93053 r99014  
    3737        int screenX() const { return m_screenLocation.x(); }
    3838        int screenY() const { return m_screenLocation.y(); }
    39         const LayoutPoint& screenLocation() const { return m_screenLocation; }
     39        const IntPoint& screenLocation() const { return m_screenLocation; }
    4040        int clientX() const { return m_clientLocation.x(); }
    4141        int clientY() const { return m_clientLocation.y(); }
     
    6060        MouseRelatedEvent();
    6161        MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
    62                           int detail, const LayoutPoint& screenLocation, const LayoutPoint& windowLocation,
     62                          int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
    6363                          bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated = false);
    6464
     
    7171       
    7272        // Expose these so MouseEvent::initMouseEvent can set them.
    73         LayoutPoint m_screenLocation;
     73        IntPoint m_screenLocation;
    7474        LayoutPoint m_clientLocation;
    7575
  • trunk/Source/WebCore/page/DragController.cpp

    r97878 r99014  
    270270    Frame* frame = documentUnderMouse->frame();
    271271    float zoomFactor = frame ? frame->pageZoomFactor() : 1;
    272     IntPoint point = roundedIntPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor));
     272    LayoutPoint point = roundedLayoutPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor));
    273273
    274274    HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
  • trunk/Source/WebCore/page/EventHandler.cpp

    r98788 r99014  
    258258    m_shouldOnlyFireDragOverEvent = false;
    259259#endif
    260     m_currentMousePosition = LayoutPoint();
     260    m_currentMousePosition = IntPoint();
    261261    m_mousePressNode = 0;
    262262    m_mousePressed = false;
     
    11271127}
    11281128
    1129 LayoutPoint EventHandler::currentMousePosition() const
     1129IntPoint EventHandler::currentMousePosition() const
    11301130{
    11311131    return m_currentMousePosition;
     
    13351335}
    13361336   
    1337 static LayoutPoint documentPointForWindowPoint(Frame* frame, const LayoutPoint& windowPoint)
     1337static LayoutPoint documentPointForWindowPoint(Frame* frame, const IntPoint& windowPoint)
    13381338{
    13391339    FrameView* view = frame->view();
     
    24072407    bool metaKey;
    24082408    PlatformKeyboardEvent::getCurrentModifierState(shiftKey, ctrlKey, altKey, metaKey);
    2409     LayoutPoint globalPoint = view->contentsToScreen(LayoutRect(view->windowToContents(m_currentMousePosition), LayoutSize())).location();
     2409    IntPoint globalPoint = view->contentsToScreen(IntRect(view->windowToContents(m_currentMousePosition), IntSize())).location();
    24102410    PlatformMouseEvent fakeMouseMoveEvent(m_currentMousePosition, globalPoint, NoButton, MouseEventMoved, 0, shiftKey, ctrlKey, altKey, metaKey, currentTime());
    24112411    mouseMoved(fakeMouseMoveEvent);
  • trunk/Source/WebCore/page/EventHandler.h

    r96566 r99014  
    137137    void resizeLayerDestroyed();
    138138
    139     LayoutPoint currentMousePosition() const;
     139    IntPoint currentMousePosition() const;
    140140
    141141    static Frame* subframeForTargetNode(Node*);
     
    401401    LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeLayer.
    402402   
    403     LayoutPoint m_currentMousePosition;
     403    IntPoint m_currentMousePosition;
    404404    LayoutPoint m_mouseDownPos; // In our view's coords.
    405405    double m_mouseDownTimestamp;
  • trunk/Source/WebCore/platform/PlatformMouseEvent.h

    r95922 r99014  
    2727#define PlatformMouseEvent_h
    2828
    29 #include "LayoutTypes.h"
     29#include "IntPoint.h"
    3030
    3131#if PLATFORM(GTK)
     
    8484        }
    8585
    86         PlatformMouseEvent(const LayoutPoint& position, const LayoutPoint& globalPosition, MouseButton button, MouseEventType eventType,
     86        PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, MouseEventType eventType,
    8787                           int clickCount, bool shift, bool ctrl, bool alt, bool meta, double timestamp)
    8888            : m_position(position)
     
    105105        }
    106106
    107         const LayoutPoint& pos() const { return m_position; }
    108         LayoutUnit x() const { return m_position.x(); }
    109         LayoutUnit y() const { return m_position.y(); }
    110         LayoutUnit globalX() const { return m_globalPosition.x(); }
    111         LayoutUnit globalY() const { return m_globalPosition.y(); }
     107        const IntPoint& pos() const { return m_position; }
     108        int x() const { return m_position.x(); }
     109        int y() const { return m_position.y(); }
     110        int globalX() const { return m_globalPosition.x(); }
     111        int globalY() const { return m_globalPosition.y(); }
    112112        MouseButton button() const { return m_button; }
    113113        MouseEventType eventType() const { return m_eventType; }
     
    161161
    162162    protected:
    163         LayoutPoint m_position;
    164         LayoutPoint m_globalPosition;
     163        IntPoint m_position;
     164        IntPoint m_globalPosition;
    165165        MouseButton m_button;
    166166        MouseEventType m_eventType;
     
    181181
    182182#if PLATFORM(MAC) && defined(__OBJC__)
    183     LayoutPoint globalPoint(const NSPoint& windowPoint, NSWindow *);
    184     LayoutPoint pointForEvent(NSEvent *, NSView *windowView);
    185     LayoutPoint globalPointForEvent(NSEvent *);
     183    IntPoint globalPoint(const NSPoint& windowPoint, NSWindow *);
     184    IntPoint pointForEvent(NSEvent *, NSView *windowView);
     185    IntPoint globalPointForEvent(NSEvent *);
    186186#endif
    187187
  • trunk/Source/WebCore/platform/mac/PlatformMouseEventMac.mm

    r93053 r99014  
    6969}
    7070
    71 LayoutPoint globalPoint(const NSPoint& windowPoint, NSWindow *window)
     71IntPoint globalPoint(const NSPoint& windowPoint, NSWindow *window)
    7272{
    73     return LayoutPoint(flipScreenPoint([window convertBaseToScreen:windowPoint], screenForWindow(window)));
     73    return IntPoint(flipScreenPoint([window convertBaseToScreen:windowPoint], screenForWindow(window)));
    7474}
    7575
    76 LayoutPoint pointForEvent(NSEvent *event, NSView *windowView)
     76IntPoint pointForEvent(NSEvent *event, NSView *windowView)
    7777{
    7878    switch ([event type]) {
     
    9393            if (windowView)
    9494                location = [windowView convertPoint:location fromView:nil];
    95             return LayoutPoint(location);
     95            return IntPoint(location);
    9696        }
    9797        default:
    98             return LayoutPoint();
     98            return IntPoint();
    9999    }
    100100}
    101101
    102 LayoutPoint globalPointForEvent(NSEvent *event)
     102IntPoint globalPointForEvent(NSEvent *event)
    103103{
    104104    switch ([event type]) {
     
    116116            return globalPoint([event locationInWindow], [event window]);
    117117        default:
    118             return LayoutPoint();
     118            return IntPoint();
    119119    }
    120120}
Note: See TracChangeset for help on using the changeset viewer.