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

Side by Side Diff: chrome/browser/chrome_page_zoom.cc

Issue 8926001: Move some zoom constants into the headers so we don't have to duplicate the values in plugins. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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
« no previous file with comments | « chrome/browser/chrome_page_zoom.h ('k') | content/common/page_zoom.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm>
5 #include <cmath> 6 #include <cmath>
6 7
7 #include "chrome/browser/chrome_page_zoom.h" 8 #include "chrome/browser/chrome_page_zoom.h"
8 #include "content/public/common/page_zoom.h" 9 #include "content/public/common/page_zoom.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
10 11
11 namespace chrome_page_zoom { 12 namespace chrome_page_zoom {
12 13
13 enum PageZoomValueType { 14 enum PageZoomValueType {
14 PAGE_ZOOM_VALUE_TYPE_FACTOR, 15 PAGE_ZOOM_VALUE_TYPE_FACTOR,
15 PAGE_ZOOM_VALUE_TYPE_LEVEL, 16 PAGE_ZOOM_VALUE_TYPE_LEVEL,
16 }; 17 };
17 18
18 const double kPresetZoomFactors[] = { 0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0, 19 const double kPresetZoomFactors[] = { 0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0,
19 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 20 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0,
20 5.0 }; 21 5.0 };
22 const size_t kPresetZoomFactorsSize = arraysize(kPresetZoomFactors);
21 23
22 std::vector<double> PresetZoomValues(PageZoomValueType value_type, 24 std::vector<double> PresetZoomValues(PageZoomValueType value_type,
23 double custom_value) { 25 double custom_value) {
24 // Generate a vector of zoom values from an array of known preset 26 // Generate a vector of zoom values from an array of known preset
25 // factors. The values in content::kPresetZoomFactors will already be in 27 // factors. The values in content::kPresetZoomFactors will already be in
26 // sorted order. 28 // sorted order.
27 std::vector<double> zoom_values; 29 std::vector<double> zoom_values;
28 bool found_custom = false; 30 bool found_custom = false;
29 for (size_t i = 0; i < arraysize(kPresetZoomFactors); i++) { 31 for (size_t i = 0; i < kPresetZoomFactorsSize; i++) {
30 double zoom_value = kPresetZoomFactors[i]; 32 double zoom_value = kPresetZoomFactors[i];
31 if (value_type == PAGE_ZOOM_VALUE_TYPE_LEVEL) 33 if (value_type == PAGE_ZOOM_VALUE_TYPE_LEVEL)
32 zoom_value = WebKit::WebView::zoomFactorToZoomLevel(zoom_value); 34 zoom_value = WebKit::WebView::zoomFactorToZoomLevel(zoom_value);
33 if (content::ZoomValuesEqual(zoom_value, custom_value)) 35 if (content::ZoomValuesEqual(zoom_value, custom_value))
34 found_custom = true; 36 found_custom = true;
35 zoom_values.push_back(zoom_value); 37 zoom_values.push_back(zoom_value);
36 } 38 }
37 // If the preset array did not contain the custom value, append it to the 39 // If the preset array did not contain the custom value, append it to the
38 // vector and then sort. 40 // vector and then sort.
39 double min = value_type == PAGE_ZOOM_VALUE_TYPE_LEVEL ? 41 double min = value_type == PAGE_ZOOM_VALUE_TYPE_LEVEL ?
(...skipping 11 matching lines...) Expand all
51 53
52 std::vector<double> PresetZoomFactors(double custom_factor) { 54 std::vector<double> PresetZoomFactors(double custom_factor) {
53 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_FACTOR, custom_factor); 55 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_FACTOR, custom_factor);
54 } 56 }
55 57
56 std::vector<double> PresetZoomLevels(double custom_level) { 58 std::vector<double> PresetZoomLevels(double custom_level) {
57 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_LEVEL, custom_level); 59 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_LEVEL, custom_level);
58 } 60 }
59 61
60 } // namespace chrome_page_zoom 62 } // namespace chrome_page_zoom
OLDNEW
« no previous file with comments | « chrome/browser/chrome_page_zoom.h ('k') | content/common/page_zoom.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698