- add sources.
[platform/framework/web/crosswalk.git] / src / content / common / page_zoom.cc
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
3 // found in the LICENSE file.
4
5 #include <cmath>
6
7 #include "content/public/common/page_zoom.h"
8
9 namespace content {
10
11 const double kMinimumZoomFactor = 0.25;
12 const double kMaximumZoomFactor = 5.0;
13 const double kEpsilon = 0.001;
14 const double kTextSizeMultiplierRatio = 1.2;
15
16 bool ZoomValuesEqual(double value_a, double value_b) {
17   return (std::fabs(value_a - value_b) <= kEpsilon);
18 }
19
20 double ZoomLevelToZoomFactor(double zoom_level) {
21   return std::pow(kTextSizeMultiplierRatio, zoom_level);
22 }
23
24 double ZoomFactorToZoomLevel(double factor) {
25   return std::log(factor) / std::log(kTextSizeMultiplierRatio);
26 }
27
28 }  // namespace content