summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 23:13:11 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 23:13:11 +0000
commit5bd1c88a74cefc0d924be9ba6b6f0eb23972f00c (patch)
tree524fd45727d48e3d4fa7d28d4a0ffd4fef6d72da /webkit
parent6ab26caac00cd93071ae27f66d3f22be010cdc5c (diff)
downloadchromium_src-5bd1c88a74cefc0d924be9ba6b6f0eb23972f00c.zip
chromium_src-5bd1c88a74cefc0d924be9ba6b6f0eb23972f00c.tar.gz
chromium_src-5bd1c88a74cefc0d924be9ba6b6f0eb23972f00c.tar.bz2
Fix rounding errors when converting between zoom factor and zoom level.
BUG=60640 Review URL: http://codereview.chromium.org/4117002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63971 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/pepper_plugin_instance.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc
index 54a1f42..bc40240 100644
--- a/webkit/glue/plugins/pepper_plugin_instance.cc
+++ b/webkit/glue/plugins/pepper_plugin_instance.cc
@@ -238,6 +238,15 @@ void ZoomChanged(PP_Instance instance_id, double factor) {
if (!instance)
return;
double zoom_level = WebView::zoomFactorToZoomLevel(factor);
+ // The conversino from zoom level to factor, and back, can introduce rounding
+ // errors. i.e. WebKit originally tells us 3.0, but by the time we tell the
+ // plugin and it tells us back, the level becomes 3.000000000004. Need to
+ // round or else otherwise if the user zooms out, it will go to 3.0 instead of
+ // 2.0.
+ int rounded =
+ static_cast<int>(zoom_level + (zoom_level > 0 ? 0.001 : -0.001));
+ if (abs(rounded - zoom_level) < 0.001)
+ zoom_level = rounded;
instance->container()->zoomLevelChanged(zoom_level);
}