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

Unified Diff: ui/views/view.cc

Issue 2648583003: Handle floating point coordinates from ozone to exosphere (Closed)
Patch Set: Handle floating point coordinates from ozone to exosphere Created 3 years, 11 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
« ui/aura/window.cc ('K') | « ui/views/view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index d65f4bc25926d324ee7ea48ed5732ec678c93523..f1258cc3e5e15fdce1e0b8907a0dd97d6ac29698 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -708,6 +708,15 @@ View* View::GetSelectedViewForGroup(int group) {
void View::ConvertPointToTarget(const View* source,
const View* target,
gfx::Point* point) {
+ gfx::PointF point_f(*point);
+ ConvertPointToTargetF(source, target, &point_f);
+ *point = gfx::ToFlooredPoint(point_f);
+}
+
+// static
+void View::ConvertPointToTargetF(const View* source,
+ const View* target,
+ gfx::PointF* point) {
DCHECK(source);
DCHECK(target);
if (source == target)
@@ -717,10 +726,10 @@ void View::ConvertPointToTarget(const View* source,
CHECK_EQ(GetHierarchyRoot(source), root);
if (source != root)
- source->ConvertPointForAncestor(root, point);
+ source->ConvertPointForAncestorF(root, point);
if (target != root)
- target->ConvertPointFromAncestor(root, point);
+ target->ConvertPointFromAncestorF(root, point);
}
// static
@@ -2146,22 +2155,38 @@ bool View::GetTransformRelativeTo(const View* ancestor,
bool View::ConvertPointForAncestor(const View* ancestor,
gfx::Point* point) const {
+ gfx::PointF point_f(*point);
+ bool result = ConvertPointForAncestorF(ancestor, &point_f);
+ *point = gfx::ToFlooredPoint(point_f);
+ return result;
+}
+
+bool View::ConvertPointForAncestorF(const View* ancestor,
+ gfx::PointF* point) const {
gfx::Transform trans;
// TODO(sad): Have some way of caching the transformation results.
bool result = GetTransformRelativeTo(ancestor, &trans);
- auto p = gfx::Point3F(gfx::PointF(*point));
+ auto p = gfx::Point3F(*point);
trans.TransformPoint(&p);
- *point = gfx::ToFlooredPoint(p.AsPointF());
+ *point = p.AsPointF();
return result;
}
bool View::ConvertPointFromAncestor(const View* ancestor,
gfx::Point* point) const {
+ gfx::PointF point_f(*point);
+ bool result = ConvertPointFromAncestorF(ancestor, &point_f);
+ *point = gfx::ToFlooredPoint(point_f);
+ return result;
+}
+
+bool View::ConvertPointFromAncestorF(const View* ancestor,
+ gfx::PointF* point) const {
gfx::Transform trans;
bool result = GetTransformRelativeTo(ancestor, &trans);
- auto p = gfx::Point3F(gfx::PointF(*point));
+ auto p = gfx::Point3F(*point);
trans.TransformPointReverse(&p);
- *point = gfx::ToFlooredPoint(p.AsPointF());
+ *point = p.AsPointF();
return result;
}
« ui/aura/window.cc ('K') | « ui/views/view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698