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

Unified Diff: Source/web/WebInputEventConversion.cpp

Issue 298133003: Expose fractional TouchEvent coordinates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merge with trunk 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
Index: Source/web/WebInputEventConversion.cpp
diff --git a/Source/web/WebInputEventConversion.cpp b/Source/web/WebInputEventConversion.cpp
index 4a2ed1acdd795d95c3e8b8957a256157e22e7fcf..f19a91f7dfdaedf570ece8b87a39e30583763b79 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)
@@ -745,7 +751,7 @@ 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.position = convertAbsoluteLocationForRenderObjectFloat(touch->absoluteLocation(), *renderObject);
point.radiusX = touch->webkitRadiusX();
point.radiusY = touch->webkitRadiusY();
point.rotationAngle = touch->webkitRotationAngle();

Powered by Google App Engine
This is Rietveld 408576698