OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_plugin_instance.h" | 5 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #if defined(OS_MACOSX) | 9 #if defined(OS_MACOSX) |
10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 const PPB_Fullscreen_Dev ppb_fullscreen = { | 238 const PPB_Fullscreen_Dev ppb_fullscreen = { |
239 &IsFullscreen, | 239 &IsFullscreen, |
240 &SetFullscreen, | 240 &SetFullscreen, |
241 }; | 241 }; |
242 | 242 |
243 void ZoomChanged(PP_Instance instance_id, double factor) { | 243 void ZoomChanged(PP_Instance instance_id, double factor) { |
244 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 244 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
245 if (!instance) | 245 if (!instance) |
246 return; | 246 return; |
| 247 |
| 248 // We only want to tell the page to change its zoom if the whole page is the |
| 249 // PDF. If we're in an iframe, then don't do anything. |
| 250 WebFrame* frame = instance->container()->element().document().frame(); |
| 251 if (!frame->view()->mainFrame()->document().isPluginDocument()) |
| 252 return; |
| 253 |
247 double zoom_level = WebView::zoomFactorToZoomLevel(factor); | 254 double zoom_level = WebView::zoomFactorToZoomLevel(factor); |
248 // The conversino from zoom level to factor, and back, can introduce rounding | 255 // The conversino from zoom level to factor, and back, can introduce rounding |
249 // errors. i.e. WebKit originally tells us 3.0, but by the time we tell the | 256 // errors. i.e. WebKit originally tells us 3.0, but by the time we tell the |
250 // plugin and it tells us back, the level becomes 3.000000000004. Need to | 257 // plugin and it tells us back, the level becomes 3.000000000004. Need to |
251 // round or else otherwise if the user zooms out, it will go to 3.0 instead of | 258 // round or else otherwise if the user zooms out, it will go to 3.0 instead of |
252 // 2.0. | 259 // 2.0. |
253 int rounded = | 260 int rounded = |
254 static_cast<int>(zoom_level + (zoom_level > 0 ? 0.001 : -0.001)); | 261 static_cast<int>(zoom_level + (zoom_level > 0 ? 0.001 : -0.001)); |
255 if (abs(rounded - zoom_level) < 0.001) | 262 if (abs(rounded - zoom_level) < 0.001) |
256 zoom_level = rounded; | 263 zoom_level = rounded; |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 } | 1170 } |
1164 | 1171 |
1165 Graphics3D* PluginInstance::bound_graphics_3d() const { | 1172 Graphics3D* PluginInstance::bound_graphics_3d() const { |
1166 if (bound_graphics_.get() == NULL) | 1173 if (bound_graphics_.get() == NULL) |
1167 return NULL; | 1174 return NULL; |
1168 | 1175 |
1169 return bound_graphics_->Cast<Graphics3D>(); | 1176 return bound_graphics_->Cast<Graphics3D>(); |
1170 } | 1177 } |
1171 | 1178 |
1172 } // namespace pepper | 1179 } // namespace pepper |
OLD | NEW |