OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/disambiguation_popup_helper.h" | 5 #include "content/renderer/disambiguation_popup_helper.h" |
6 | 6 |
7 #include "third_party/WebKit/public/platform/WebRect.h" | 7 #include "third_party/WebKit/public/platform/WebRect.h" |
8 #include "ui/gfx/geometry/size_conversions.h" | 8 #include "ui/gfx/geometry/size_conversions.h" |
9 | 9 |
10 using blink::WebRect; | 10 using blink::WebRect; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 // Ensure the disambiguation popup fits inside the screen, | 62 // Ensure the disambiguation popup fits inside the screen, |
63 // clip the edges farthest to the touch point if needed. | 63 // clip the edges farthest to the touch point if needed. |
64 gfx::Rect CropZoomArea(const gfx::Rect& zoom_rect, | 64 gfx::Rect CropZoomArea(const gfx::Rect& zoom_rect, |
65 const gfx::Size& viewport_size, | 65 const gfx::Size& viewport_size, |
66 const gfx::Point& touch_point, | 66 const gfx::Point& touch_point, |
67 float scale) { | 67 float scale) { |
68 gfx::Size max_size = viewport_size; | 68 gfx::Size max_size = viewport_size; |
69 max_size.Enlarge(-2 * kDisambiguationPopupBoundsMargin, | 69 max_size.Enlarge(-2 * kDisambiguationPopupBoundsMargin, |
70 -2 * kDisambiguationPopupBoundsMargin); | 70 -2 * kDisambiguationPopupBoundsMargin); |
71 max_size = ToCeiledSize(ScaleSize(max_size, 1.0 / scale)); | 71 max_size = gfx::ScaleToCeiledSize(max_size, 1.0 / scale); |
72 | 72 |
73 int left = touch_point.x() - zoom_rect.x(); | 73 int left = touch_point.x() - zoom_rect.x(); |
74 int right = zoom_rect.right() - touch_point.x(); | 74 int right = zoom_rect.right() - touch_point.x(); |
75 int top = touch_point.y() - zoom_rect.y(); | 75 int top = touch_point.y() - zoom_rect.y(); |
76 int bottom = zoom_rect.bottom() - touch_point.y(); | 76 int bottom = zoom_rect.bottom() - touch_point.y(); |
77 TrimEdges(&left, &right, max_size.width()); | 77 TrimEdges(&left, &right, max_size.width()); |
78 TrimEdges(&top, &bottom, max_size.height()); | 78 TrimEdges(&top, &bottom, max_size.height()); |
79 | 79 |
80 return gfx::Rect(touch_point.x() - left, | 80 return gfx::Rect(touch_point.x() - left, |
81 touch_point.y() - top, | 81 touch_point.y() - top, |
(...skipping 21 matching lines...) Expand all Loading... |
103 | 103 |
104 float new_total_scale = | 104 float new_total_scale = |
105 FindOptimalScaleFactor(target_rects, total_scale); | 105 FindOptimalScaleFactor(target_rects, total_scale); |
106 *zoom_rect = CropZoomArea( | 106 *zoom_rect = CropZoomArea( |
107 *zoom_rect, screen_size, tap_rect.CenterPoint(), new_total_scale); | 107 *zoom_rect, screen_size, tap_rect.CenterPoint(), new_total_scale); |
108 | 108 |
109 return new_total_scale; | 109 return new_total_scale; |
110 } | 110 } |
111 | 111 |
112 } // namespace content | 112 } // namespace content |
OLD | NEW |