Commit fc240a22 authored by eae@chromium.org's avatar eae@chromium.org

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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@99014 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6fc1db43
2011-11-01 Emil A Eklund <eae@chromium.org>
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.
2011-11-01 Tony Chang <tony@chromium.org>
REGRESSION: -webkit-flex() should be an invalid value
......
......@@ -53,7 +53,7 @@ static LayoutSize contentsScrollOffset(AbstractView* abstractView)
}
MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, PassRefPtr<AbstractView> abstractView,
int detail, const LayoutPoint& screenLocation, const LayoutPoint& windowLocation,
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_screenLocation(screenLocation)
......@@ -80,7 +80,7 @@ MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubb
}
}
m_clientLocation = adjustedPageLocation - toSize(scrollPosition);
m_clientLocation = adjustedPageLocation - toLayoutSize(scrollPosition);
m_pageLocation = adjustedPageLocation;
initCoordinates();
......@@ -181,7 +181,7 @@ void MouseRelatedEvent::computeRelativePosition()
if (n && (layer = n->renderer()->enclosingLayer())) {
layer->updateLayerPosition();
for (; layer; layer = layer->parent()) {
m_layerLocation -= toSize(layer->location());
m_layerLocation -= toLayoutSize(layer->location());
}
}
......
......@@ -36,7 +36,7 @@ namespace WebCore {
// exposed via DOM APIs are invariant under zooming.
int screenX() const { return m_screenLocation.x(); }
int screenY() const { return m_screenLocation.y(); }
const LayoutPoint& screenLocation() const { return m_screenLocation; }
const IntPoint& screenLocation() const { return m_screenLocation; }
int clientX() const { return m_clientLocation.x(); }
int clientY() const { return m_clientLocation.y(); }
const LayoutPoint& clientLocation() const { return m_clientLocation; }
......@@ -59,7 +59,7 @@ namespace WebCore {
protected:
MouseRelatedEvent();
MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
int detail, const LayoutPoint& screenLocation, const LayoutPoint& windowLocation,
int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated = false);
void initCoordinates();
......@@ -70,7 +70,7 @@ namespace WebCore {
void computeRelativePosition();
// Expose these so MouseEvent::initMouseEvent can set them.
LayoutPoint m_screenLocation;
IntPoint m_screenLocation;
LayoutPoint m_clientLocation;
private:
......
......@@ -269,7 +269,7 @@ static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint&
{
Frame* frame = documentUnderMouse->frame();
float zoomFactor = frame ? frame->pageZoomFactor() : 1;
IntPoint point = roundedIntPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor));
LayoutPoint point = roundedLayoutPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor));
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestResult result(point);
......
......@@ -257,7 +257,7 @@ void EventHandler::clear()
m_dragTarget = 0;
m_shouldOnlyFireDragOverEvent = false;
#endif
m_currentMousePosition = LayoutPoint();
m_currentMousePosition = IntPoint();
m_mousePressNode = 0;
m_mousePressed = false;
m_capturesDragging = false;
......@@ -1126,7 +1126,7 @@ bool EventHandler::logicalScrollRecursively(ScrollLogicalDirection direction, Sc
return frame->eventHandler()->logicalScrollRecursively(direction, granularity, m_frame->ownerElement());
}
LayoutPoint EventHandler::currentMousePosition() const
IntPoint EventHandler::currentMousePosition() const
{
return m_currentMousePosition;
}
......@@ -1334,7 +1334,7 @@ OptionalCursor EventHandler::selectCursor(const MouseEventWithHitTestResults& ev
return pointerCursor();
}
static LayoutPoint documentPointForWindowPoint(Frame* frame, const LayoutPoint& windowPoint)
static LayoutPoint documentPointForWindowPoint(Frame* frame, const IntPoint& windowPoint)
{
FrameView* view = frame->view();
// FIXME: Is it really OK to use the wrong coordinates here when view is 0?
......@@ -2406,7 +2406,7 @@ void EventHandler::fakeMouseMoveEventTimerFired(Timer<EventHandler>* timer)
bool altKey;
bool metaKey;
PlatformKeyboardEvent::getCurrentModifierState(shiftKey, ctrlKey, altKey, metaKey);
LayoutPoint globalPoint = view->contentsToScreen(LayoutRect(view->windowToContents(m_currentMousePosition), LayoutSize())).location();
IntPoint globalPoint = view->contentsToScreen(IntRect(view->windowToContents(m_currentMousePosition), IntSize())).location();
PlatformMouseEvent fakeMouseMoveEvent(m_currentMousePosition, globalPoint, NoButton, MouseEventMoved, 0, shiftKey, ctrlKey, altKey, metaKey, currentTime());
mouseMoved(fakeMouseMoveEvent);
}
......
......@@ -136,7 +136,7 @@ public:
void resizeLayerDestroyed();
LayoutPoint currentMousePosition() const;
IntPoint currentMousePosition() const;
static Frame* subframeForTargetNode(Node*);
static Frame* subframeForHitTestResult(const MouseEventWithHitTestResults&);
......@@ -400,7 +400,7 @@ private:
LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeLayer.
LayoutPoint m_currentMousePosition;
IntPoint m_currentMousePosition;
LayoutPoint m_mouseDownPos; // In our view's coords.
double m_mouseDownTimestamp;
PlatformMouseEvent m_mouseDown;
......
......@@ -26,7 +26,7 @@
#ifndef PlatformMouseEvent_h
#define PlatformMouseEvent_h
#include "LayoutTypes.h"
#include "IntPoint.h"
#if PLATFORM(GTK)
typedef struct _GdkEventButton GdkEventButton;
......@@ -83,7 +83,7 @@ namespace WebCore {
{
}
PlatformMouseEvent(const LayoutPoint& position, const LayoutPoint& globalPosition, MouseButton button, MouseEventType eventType,
PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, MouseEventType eventType,
int clickCount, bool shift, bool ctrl, bool alt, bool meta, double timestamp)
: m_position(position)
, m_globalPosition(globalPosition)
......@@ -104,11 +104,11 @@ namespace WebCore {
{
}
const LayoutPoint& pos() const { return m_position; }
LayoutUnit x() const { return m_position.x(); }
LayoutUnit y() const { return m_position.y(); }
LayoutUnit globalX() const { return m_globalPosition.x(); }
LayoutUnit globalY() const { return m_globalPosition.y(); }
const IntPoint& pos() const { return m_position; }
int x() const { return m_position.x(); }
int y() const { return m_position.y(); }
int globalX() const { return m_globalPosition.x(); }
int globalY() const { return m_globalPosition.y(); }
MouseButton button() const { return m_button; }
MouseEventType eventType() const { return m_eventType; }
int clickCount() const { return m_clickCount; }
......@@ -160,8 +160,8 @@ namespace WebCore {
#endif
protected:
LayoutPoint m_position;
LayoutPoint m_globalPosition;
IntPoint m_position;
IntPoint m_globalPosition;
MouseButton m_button;
MouseEventType m_eventType;
int m_clickCount;
......@@ -180,9 +180,9 @@ namespace WebCore {
};
#if PLATFORM(MAC) && defined(__OBJC__)
LayoutPoint globalPoint(const NSPoint& windowPoint, NSWindow *);
LayoutPoint pointForEvent(NSEvent *, NSView *windowView);
LayoutPoint globalPointForEvent(NSEvent *);
IntPoint globalPoint(const NSPoint& windowPoint, NSWindow *);
IntPoint pointForEvent(NSEvent *, NSView *windowView);
IntPoint globalPointForEvent(NSEvent *);
#endif
} // namespace WebCore
......
......@@ -68,12 +68,12 @@ static int clickCountForEvent(NSEvent *event)
}
}
LayoutPoint globalPoint(const NSPoint& windowPoint, NSWindow *window)
IntPoint globalPoint(const NSPoint& windowPoint, NSWindow *window)
{
return LayoutPoint(flipScreenPoint([window convertBaseToScreen:windowPoint], screenForWindow(window)));
return IntPoint(flipScreenPoint([window convertBaseToScreen:windowPoint], screenForWindow(window)));
}
LayoutPoint pointForEvent(NSEvent *event, NSView *windowView)
IntPoint pointForEvent(NSEvent *event, NSView *windowView)
{
switch ([event type]) {
case NSLeftMouseDown:
......@@ -92,14 +92,14 @@ LayoutPoint pointForEvent(NSEvent *event, NSView *windowView)
NSPoint location = [event locationInWindow];
if (windowView)
location = [windowView convertPoint:location fromView:nil];
return LayoutPoint(location);
return IntPoint(location);
}
default:
return LayoutPoint();
return IntPoint();
}
}
LayoutPoint globalPointForEvent(NSEvent *event)
IntPoint globalPointForEvent(NSEvent *event)
{
switch ([event type]) {
case NSLeftMouseDown:
......@@ -115,7 +115,7 @@ LayoutPoint globalPointForEvent(NSEvent *event)
case NSScrollWheel:
return globalPoint([event locationInWindow], [event window]);
default:
return LayoutPoint();
return IntPoint();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment