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

Side by Side Diff: content/renderer/disambiguation_popup_helper.cc

Issue 11740038: Cleanup: Fix some lint errors in content/. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 14 matching lines...) Expand all
25 // make all targets touchable. 25 // make all targets touchable.
26 const int kDisambiguationPopupMinimumTouchSize = 40; 26 const int kDisambiguationPopupMinimumTouchSize = 40;
27 const float kDisambiguationPopupMaxScale = 5.0; 27 const float kDisambiguationPopupMaxScale = 5.0;
28 const float kDisambiguationPopupMinScale = 2.0; 28 const float kDisambiguationPopupMinScale = 2.0;
29 29
30 // Compute the scaling factor to ensure the smallest touch candidate reaches 30 // Compute the scaling factor to ensure the smallest touch candidate reaches
31 // a certain clickable size after zooming 31 // a certain clickable size after zooming
32 float FindOptimalScaleFactor(const WebVector<WebRect>& target_rects) { 32 float FindOptimalScaleFactor(const WebVector<WebRect>& target_rects) {
33 using std::min; 33 using std::min;
34 using std::max; 34 using std::max;
35 if (!target_rects.size()) // shall never reach 35 if (!target_rects.size()) // shall never reach
36 return kDisambiguationPopupMinScale; 36 return kDisambiguationPopupMinScale;
37 int smallest_target = min(target_rects[0].width, target_rects[0].height); 37 int smallest_target = min(target_rects[0].width, target_rects[0].height);
38 for (size_t i = 1; i < target_rects.size(); i++) { 38 for (size_t i = 1; i < target_rects.size(); i++) {
39 smallest_target = min(smallest_target, target_rects[i].width); 39 smallest_target = min(smallest_target, target_rects[i].width);
40 smallest_target = min(smallest_target, target_rects[i].height); 40 smallest_target = min(smallest_target, target_rects[i].height);
41 } 41 }
42 smallest_target = max(smallest_target, 1); 42 smallest_target = max(smallest_target, 1);
43 return min(kDisambiguationPopupMaxScale, max(kDisambiguationPopupMinScale, 43 return min(kDisambiguationPopupMaxScale, max(kDisambiguationPopupMinScale,
44 static_cast<float>(kDisambiguationPopupMinimumTouchSize) 44 static_cast<float>(kDisambiguationPopupMinimumTouchSize)
45 / smallest_target)); 45 / smallest_target));
(...skipping 28 matching lines...) Expand all
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,
80 left + right, 80 left + right,
81 top + bottom); 81 top + bottom);
82 } 82 }
83 83
84 } // unnamed namespace 84 } // namespace
85 85
86 namespace content { 86 namespace content {
87 87
88 float DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( 88 float DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
89 const gfx::Rect& tap_rect, 89 const gfx::Rect& tap_rect,
90 const WebVector<WebRect>& target_rects, 90 const WebVector<WebRect>& target_rects,
91 const gfx::Size& viewport_size, 91 const gfx::Size& viewport_size,
92 gfx::Rect* zoom_rect) { 92 gfx::Rect* zoom_rect) {
93 *zoom_rect = tap_rect; 93 *zoom_rect = tap_rect;
94 for (size_t i = 0; i < target_rects.size(); i++) 94 for (size_t i = 0; i < target_rects.size(); i++)
95 zoom_rect->Union(gfx::Rect(target_rects[i])); 95 zoom_rect->Union(gfx::Rect(target_rects[i]));
96 zoom_rect->Inset(-kDisambiguationPopupPadding, -kDisambiguationPopupPadding); 96 zoom_rect->Inset(-kDisambiguationPopupPadding, -kDisambiguationPopupPadding);
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
OLDNEW
« no previous file with comments | « content/renderer/disambiguation_popup_helper.h ('k') | content/renderer/disambiguation_popup_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698