Commit 2a726222 authored by thestig@chromium.org's avatar thestig@chromium.org

Declare some zoom constants in the headers so we don't have to duplicate the values in plugins.

BUG=107063
TEST=none

Review URL: http://codereview.chromium.org/8926001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114586 0039d316-1c4b-4281-b951-d872f2087c98
parent 71e0babe
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <algorithm>
#include <cmath>
#include "chrome/browser/chrome_page_zoom.h"
......@@ -18,6 +19,7 @@ enum PageZoomValueType {
const double kPresetZoomFactors[] = { 0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0,
1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0,
5.0 };
const size_t kPresetZoomFactorsSize = arraysize(kPresetZoomFactors);
std::vector<double> PresetZoomValues(PageZoomValueType value_type,
double custom_value) {
......@@ -26,7 +28,7 @@ std::vector<double> PresetZoomValues(PageZoomValueType value_type,
// sorted order.
std::vector<double> zoom_values;
bool found_custom = false;
for (size_t i = 0; i < arraysize(kPresetZoomFactors); i++) {
for (size_t i = 0; i < kPresetZoomFactorsSize; i++) {
double zoom_value = kPresetZoomFactors[i];
if (value_type == PAGE_ZOOM_VALUE_TYPE_LEVEL)
zoom_value = WebKit::WebView::zoomFactorToZoomLevel(zoom_value);
......
......@@ -10,6 +10,12 @@
namespace chrome_page_zoom {
// Zoom factors supported by the browser.
extern const double kPresetZoomFactors[];
// Size of |kPresetZoomFactors|.
extern const size_t kPresetZoomFactorsSize;
// Return a sorted vector of zoom factors. The vector will consist of preset
// values along with a custom value (if the custom value is not already
// represented.)
......
......@@ -10,16 +10,10 @@ namespace content {
const double kMinimumZoomFactor = 0.25;
const double kMaximumZoomFactor = 5.0;
const double kEpsilon = 0.001;
bool ZoomValuesEqual(double value_a, double value_b) {
// Epsilon value for comparing two floating-point zoom values. We don't use
// std::numeric_limits<> because it is too precise for zoom values. Zoom
// values lose precision due to factor/level conversions. A value of 0.001
// is precise enough for zoom value comparisons.
const double epsilon = 0.001;
return (std::fabs(value_a - value_b) <= epsilon);
return (std::fabs(value_a - value_b) <= kEpsilon);
}
} // namespace content
......@@ -26,6 +26,12 @@ CONTENT_EXPORT extern const double kMinimumZoomFactor;
// WebView::maxTextSizeMultiplier.
CONTENT_EXPORT extern const double kMaximumZoomFactor;
// Epsilon value for comparing two floating-point zoom values. We don't use
// std::numeric_limits<> because it is too precise for zoom values. Zoom
// values lose precision due to factor/level conversions. A value of 0.001
// is precise enough for zoom value comparisons.
CONTENT_EXPORT extern const double kEpsilon;
// Test if two zoom values (either zoom factors or zoom levels) should be
// considered equal.
CONTENT_EXPORT bool ZoomValuesEqual(double value_a, double value_b);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment