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

Unified Diff: Source/platform/Widget.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/Widget.h ('k') | Source/platform/geometry/FloatPoint.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/Widget.cpp
diff --git a/Source/platform/Widget.cpp b/Source/platform/Widget.cpp
index 41aba1ee7be423e40da69e9b68ff06388468c205..0f15bfc5844f65913c905637650f1e71a34aa6d3 100644
--- a/Source/platform/Widget.cpp
+++ b/Source/platform/Widget.cpp
@@ -127,6 +127,25 @@ IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const
return windowPoint;
}
+FloatPoint Widget::convertFromContainingWindow(const FloatPoint& windowPoint) const
+{
+ // Widgets / windows are required to be IntPoint aligned, but we may need to convert
+ // FloatPoint values within them (eg. for event co-ordinates).
+ IntPoint flooredPoint = flooredIntPoint(windowPoint);
+ FloatPoint parentPoint = this->convertFromContainingWindow(flooredPoint);
+ FloatSize windowFraction = windowPoint - flooredPoint;
+ // Use linear interpolation handle any fractional value (eg. for iframes subject to a transform
+ // beyond just a simple translation).
+ // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
+ if (!windowFraction.isEmpty()) {
+ const int kFactor = 1000;
+ IntPoint parentLineEnd = this->convertFromContainingWindow(flooredPoint + roundedIntSize(windowFraction.scaledBy(kFactor)));
+ FloatSize parentFraction = (parentLineEnd - parentPoint).scaledBy(1.0f / kFactor);
+ parentPoint.move(parentFraction);
+ }
+ return parentPoint;
+}
+
IntPoint Widget::convertToContainingWindow(const IntPoint& localPoint) const
{
if (const Widget* parentWidget = parent()) {
« no previous file with comments | « Source/platform/Widget.h ('k') | Source/platform/geometry/FloatPoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698