Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1472)

Unified Diff: Source/web/WebInputEventConversion.cpp

Issue 298133003: Expose fractional TouchEvent coordinates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make layout test output stable across platforms Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/scroll/ScrollView.cpp ('k') | Source/web/tests/WebInputEventConversionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebInputEventConversion.cpp
diff --git a/Source/web/WebInputEventConversion.cpp b/Source/web/WebInputEventConversion.cpp
index 4a2ed1acdd795d95c3e8b8957a256157e22e7fcf..96a1b5e9d7314e9e3f6f901933fd96a305539576 100644
--- a/Source/web/WebInputEventConversion.cpp
+++ b/Source/web/WebInputEventConversion.cpp
@@ -424,17 +424,18 @@ inline WebTouchPoint::State toWebTouchPointState(const AtomicString& type)
PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTouchPoint& point)
{
- float scale = widgetInputEventsScaleFactor(widget);
+ float scale = 1.0f / widgetInputEventsScaleFactor(widget);
IntSize offset = widgetInputEventsOffset(widget);
IntPoint pinchViewport = pinchViewportOffset(widget);
m_id = point.id;
m_state = toPlatformTouchPointState(point.state);
- m_pos = widget->convertFromContainingWindow(IntPoint(
- (point.position.x - offset.width()) / scale + pinchViewport.x(),
- (point.position.y - offset.height()) / scale + pinchViewport.y()));
- m_screenPos = IntPoint(point.screenPosition.x, point.screenPosition.y);
- m_radiusY = point.radiusY / scale;
- m_radiusX = point.radiusX / scale;
+ FloatPoint pos = (point.position - offset).scaledBy(scale);
+ pos.moveBy(pinchViewport);
+ IntPoint flooredPoint = flooredIntPoint(pos);
+ // This assumes convertFromContainingWindow does only translations, not scales.
+ m_pos = widget->convertFromContainingWindow(flooredPoint) + (pos - flooredPoint);
+ m_screenPos = FloatPoint(point.screenPosition.x, point.screenPosition.y);
+ m_radius = FloatSize(point.radiusX, point.radiusY).scaledBy(scale);
m_rotationAngle = point.rotationAngle;
m_force = point.force;
}
@@ -475,9 +476,14 @@ static int getWebInputModifiers(const UIEventWithKeyState& event)
return modifiers;
}
+static FloatPoint convertAbsoluteLocationForRenderObjectFloat(const LayoutPoint& location, const WebCore::RenderObject& renderObject)
+{
+ return renderObject.absoluteToLocal(location, UseTransforms);
+}
+
static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& location, const WebCore::RenderObject& renderObject)
{
- return roundedIntPoint(renderObject.absoluteToLocal(location, UseTransforms));
+ return roundedIntPoint(convertAbsoluteLocationForRenderObjectFloat(location, renderObject));
}
static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& event, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEvent& webEvent)
@@ -576,11 +582,12 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::
// The mouse event co-ordinates should be generated from the co-ordinates of the touch point.
ScrollView* view = toScrollView(widget->parent());
- IntPoint windowPoint = IntPoint(touch->absoluteLocation().x(), touch->absoluteLocation().y());
+ IntPoint windowPoint = roundedIntPoint(touch->absoluteLocation());
if (view)
windowPoint = view->contentsToWindow(windowPoint);
- globalX = touch->screenX();
- globalY = touch->screenY();
+ IntPoint screenPoint = roundedIntPoint(touch->screenLocation());
+ globalX = screenPoint.x();
+ globalY = screenPoint.y();
windowX = windowPoint.x();
windowY = windowPoint.y();
@@ -744,8 +751,8 @@ static void addTouchPoints(const Widget* widget, const AtomicString& touchType,
WebTouchPoint point;
point.id = touch->identifier();
- point.screenPosition = WebFloatPoint(touch->screenX(), touch->screenY());
- point.position = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject);
+ point.screenPosition = touch->screenLocation();
+ point.position = convertAbsoluteLocationForRenderObjectFloat(touch->absoluteLocation(), *renderObject);
point.radiusX = touch->webkitRadiusX();
point.radiusY = touch->webkitRadiusY();
point.rotationAngle = touch->webkitRotationAngle();
« no previous file with comments | « Source/platform/scroll/ScrollView.cpp ('k') | Source/web/tests/WebInputEventConversionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698