Diff
Modified: trunk/Source/WebCore/ChangeLog (99013 => 99014)
--- trunk/Source/WebCore/ChangeLog 2011-11-01 23:58:57 UTC (rev 99013)
+++ trunk/Source/WebCore/ChangeLog 2011-11-02 00:08:04 UTC (rev 99014)
@@ -1,3 +1,49 @@
+2011-11-01 Emil A Eklund <[email protected]>
+
+ 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 <[email protected]>
REGRESSION: -webkit-flex() should be an invalid value
Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.cpp (99013 => 99014)
--- trunk/Source/WebCore/dom/MouseRelatedEvent.cpp 2011-11-01 23:58:57 UTC (rev 99013)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.cpp 2011-11-02 00:08:04 UTC (rev 99014)
@@ -53,7 +53,7 @@
}
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 @@
}
}
- m_clientLocation = adjustedPageLocation - toSize(scrollPosition);
+ m_clientLocation = adjustedPageLocation - toLayoutSize(scrollPosition);
m_pageLocation = adjustedPageLocation;
initCoordinates();
@@ -181,7 +181,7 @@
if (n && (layer = n->renderer()->enclosingLayer())) {
layer->updateLayerPosition();
for (; layer; layer = layer->parent()) {
- m_layerLocation -= toSize(layer->location());
+ m_layerLocation -= toLayoutSize(layer->location());
}
}
Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.h (99013 => 99014)
--- trunk/Source/WebCore/dom/MouseRelatedEvent.h 2011-11-01 23:58:57 UTC (rev 99013)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.h 2011-11-02 00:08:04 UTC (rev 99014)
@@ -36,7 +36,7 @@
// 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 @@
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 @@
void computeRelativePosition();
// Expose these so MouseEvent::initMouseEvent can set them.
- LayoutPoint m_screenLocation;
+ IntPoint m_screenLocation;
LayoutPoint m_clientLocation;
private:
Modified: trunk/Source/WebCore/page/DragController.cpp (99013 => 99014)
--- trunk/Source/WebCore/page/DragController.cpp 2011-11-01 23:58:57 UTC (rev 99013)
+++ trunk/Source/WebCore/page/DragController.cpp 2011-11-02 00:08:04 UTC (rev 99014)
@@ -269,7 +269,7 @@
{
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);
Modified: trunk/Source/WebCore/page/EventHandler.cpp (99013 => 99014)
--- trunk/Source/WebCore/page/EventHandler.cpp 2011-11-01 23:58:57 UTC (rev 99013)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2011-11-02 00:08:04 UTC (rev 99014)
@@ -257,7 +257,7 @@
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 @@
return frame->eventHandler()->logicalScrollRecursively(direction, granularity, m_frame->ownerElement());
}
-LayoutPoint EventHandler::currentMousePosition() const
+IntPoint EventHandler::currentMousePosition() const
{
return m_currentMousePosition;
}
@@ -1334,7 +1334,7 @@
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 @@
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);
}
Modified: trunk/Source/WebCore/page/EventHandler.h (99013 => 99014)
--- trunk/Source/WebCore/page/EventHandler.h 2011-11-01 23:58:57 UTC (rev 99013)
+++ trunk/Source/WebCore/page/EventHandler.h 2011-11-02 00:08:04 UTC (rev 99014)
@@ -136,7 +136,7 @@
void resizeLayerDestroyed();
- LayoutPoint currentMousePosition() const;
+ IntPoint currentMousePosition() const;
static Frame* subframeForTargetNode(Node*);
static Frame* subframeForHitTestResult(const MouseEventWithHitTestResults&);
@@ -400,7 +400,7 @@
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;
Modified: trunk/Source/WebCore/platform/PlatformMouseEvent.h (99013 => 99014)
--- trunk/Source/WebCore/platform/PlatformMouseEvent.h 2011-11-01 23:58:57 UTC (rev 99013)
+++ trunk/Source/WebCore/platform/PlatformMouseEvent.h 2011-11-02 00:08:04 UTC (rev 99014)
@@ -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 @@
{
}
- 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 @@
{
}
- 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 @@
#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 @@
};
#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
Modified: trunk/Source/WebCore/platform/mac/PlatformMouseEventMac.mm (99013 => 99014)
--- trunk/Source/WebCore/platform/mac/PlatformMouseEventMac.mm 2011-11-01 23:58:57 UTC (rev 99013)
+++ trunk/Source/WebCore/platform/mac/PlatformMouseEventMac.mm 2011-11-02 00:08:04 UTC (rev 99014)
@@ -68,12 +68,12 @@
}
}
-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 @@
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 @@
case NSScrollWheel:
return globalPoint([event locationInWindow], [event window]);
default:
- return LayoutPoint();
+ return IntPoint();
}
}