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/Source/WebKit/chromium/public/platform/WebRect.h" | 7 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
8 #include "ui/gfx/size_conversions.h" | 8 #include "ui/gfx/size_conversions.h" |
9 | 9 |
10 using WebKit::WebRect; | 10 using WebKit::WebRect; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 // Ensure the disambiguation popup fits inside the screen, | 60 // Ensure the disambiguation popup fits inside the screen, |
61 // clip the edges farthest to the touch point if needed. | 61 // clip the edges farthest to the touch point if needed. |
62 gfx::Rect CropZoomArea(const gfx::Rect& zoom_rect, | 62 gfx::Rect CropZoomArea(const gfx::Rect& zoom_rect, |
63 const gfx::Size& viewport_size, | 63 const gfx::Size& viewport_size, |
64 const gfx::Point& touch_point, | 64 const gfx::Point& touch_point, |
65 float scale) { | 65 float scale) { |
66 gfx::Size max_size = viewport_size; | 66 gfx::Size max_size = viewport_size; |
67 max_size.Enlarge(-2 * kDisambiguationPopupBoundsMargin, | 67 max_size.Enlarge(-2 * kDisambiguationPopupBoundsMargin, |
68 -2 * kDisambiguationPopupBoundsMargin); | 68 -2 * kDisambiguationPopupBoundsMargin); |
69 max_size = ToCeiledSize(max_size.Scale(1.0 / scale)); | 69 max_size = ToCeiledSize(ScaleSize(max_size, 1.0 / scale)); |
70 | 70 |
71 int left = touch_point.x() - zoom_rect.x(); | 71 int left = touch_point.x() - zoom_rect.x(); |
72 int right = zoom_rect.right() - touch_point.x(); | 72 int right = zoom_rect.right() - touch_point.x(); |
73 int top = touch_point.y() - zoom_rect.y(); | 73 int top = touch_point.y() - zoom_rect.y(); |
74 int bottom = zoom_rect.bottom() - touch_point.y(); | 74 int bottom = zoom_rect.bottom() - touch_point.y(); |
75 TrimEdges(&left, &right, max_size.width()); | 75 TrimEdges(&left, &right, max_size.width()); |
76 TrimEdges(&top, &bottom, max_size.height()); | 76 TrimEdges(&top, &bottom, max_size.height()); |
77 | 77 |
78 return gfx::Rect(touch_point.x() - left, | 78 return gfx::Rect(touch_point.x() - left, |
79 touch_point.y() - top, | 79 touch_point.y() - top, |
(...skipping 17 matching lines...) Expand all Loading... |
97 zoom_rect->Intersect(gfx::Rect(viewport_size)); | 97 zoom_rect->Intersect(gfx::Rect(viewport_size)); |
98 | 98 |
99 float scale = FindOptimalScaleFactor(target_rects); | 99 float scale = FindOptimalScaleFactor(target_rects); |
100 *zoom_rect = CropZoomArea( | 100 *zoom_rect = CropZoomArea( |
101 *zoom_rect, viewport_size, tap_rect.CenterPoint(), scale); | 101 *zoom_rect, viewport_size, tap_rect.CenterPoint(), scale); |
102 | 102 |
103 return scale; | 103 return scale; |
104 } | 104 } |
105 | 105 |
106 } // namespace content | 106 } // namespace content |
OLD | NEW |