| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/mus/view_coordinate_conversions.h" | 5 #include "components/mus/view_coordinate_conversions.h" |
| 6 | 6 |
| 7 #include "components/mus/server_view.h" | 7 #include "components/mus/server_view.h" |
| 8 #include "ui/gfx/geometry/point.h" | 8 #include "ui/gfx/geometry/point.h" |
| 9 #include "ui/gfx/geometry/point_conversions.h" | 9 #include "ui/gfx/geometry/point_conversions.h" |
| 10 #include "ui/gfx/geometry/point_f.h" | 10 #include "ui/gfx/geometry/point_f.h" |
| 11 #include "ui/gfx/geometry/rect.h" | 11 #include "ui/gfx/geometry/rect.h" |
| 12 #include "ui/gfx/geometry/vector2d.h" | 12 #include "ui/gfx/geometry/vector2d.h" |
| 13 #include "ui/gfx/geometry/vector2d_f.h" | 13 #include "ui/gfx/geometry/vector2d_f.h" |
| 14 | 14 |
| 15 namespace view_manager { | 15 namespace mus { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 gfx::Vector2dF CalculateOffsetToAncestor(const ServerView* view, | 19 gfx::Vector2dF CalculateOffsetToAncestor(const ServerView* view, |
| 20 const ServerView* ancestor) { | 20 const ServerView* ancestor) { |
| 21 DCHECK(ancestor->Contains(view)); | 21 DCHECK(ancestor->Contains(view)); |
| 22 gfx::Vector2d result; | 22 gfx::Vector2d result; |
| 23 for (const ServerView* v = view; v != ancestor; v = v->parent()) | 23 for (const ServerView* v = view; v != ancestor; v = v->parent()) |
| 24 result += v->bounds().OffsetFromOrigin(); | 24 result += v->bounds().OffsetFromOrigin(); |
| 25 return gfx::Vector2dF(result.x(), result.y()); | 25 return gfx::Vector2dF(result.x(), result.y()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 if (from == to) | 59 if (from == to) |
| 60 return rect; | 60 return rect; |
| 61 | 61 |
| 62 const gfx::Point top_left(ConvertPointBetweenViews(from, to, rect.origin())); | 62 const gfx::Point top_left(ConvertPointBetweenViews(from, to, rect.origin())); |
| 63 const gfx::Point bottom_right(gfx::ToCeiledPoint(ConvertPointFBetweenViews( | 63 const gfx::Point bottom_right(gfx::ToCeiledPoint(ConvertPointFBetweenViews( |
| 64 from, to, gfx::PointF(rect.right(), rect.bottom())))); | 64 from, to, gfx::PointF(rect.right(), rect.bottom())))); |
| 65 return gfx::Rect(top_left.x(), top_left.y(), bottom_right.x() - top_left.x(), | 65 return gfx::Rect(top_left.x(), top_left.y(), bottom_right.x() - top_left.x(), |
| 66 bottom_right.y() - top_left.y()); | 66 bottom_right.y() - top_left.y()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace view_manager | 69 } // namespace mus |
| OLD | NEW |