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/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_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 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 &IsFullscreen, | 243 &IsFullscreen, |
244 &SetFullscreen, | 244 &SetFullscreen, |
245 }; | 245 }; |
246 | 246 |
247 void ZoomChanged(PP_Instance instance_id, double factor) { | 247 void ZoomChanged(PP_Instance instance_id, double factor) { |
248 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 248 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
249 if (!instance) | 249 if (!instance) |
250 return; | 250 return; |
251 | 251 |
252 // We only want to tell the page to change its zoom if the whole page is the | 252 // We only want to tell the page to change its zoom if the whole page is the |
253 // PDF. If we're in an iframe, then don't do anything. | 253 // PDF. If we're in an iframe, then don't do anything. |
brettw
2011/01/21 21:42:30
Can you remove the reference to PDF in this commen
| |
254 WebFrame* frame = instance->container()->element().document().frame(); | 254 if (!instance->IsFullPagePlugin()) |
255 if (!frame->view()->mainFrame()->document().isPluginDocument()) | |
256 return; | 255 return; |
257 | 256 |
258 double zoom_level = WebView::zoomFactorToZoomLevel(factor); | 257 double zoom_level = WebView::zoomFactorToZoomLevel(factor); |
259 // The conversino from zoom level to factor, and back, can introduce rounding | 258 // The conversino from zoom level to factor, and back, can introduce rounding |
260 // errors. i.e. WebKit originally tells us 3.0, but by the time we tell the | 259 // errors. i.e. WebKit originally tells us 3.0, but by the time we tell the |
261 // plugin and it tells us back, the level becomes 3.000000000004. Need to | 260 // plugin and it tells us back, the level becomes 3.000000000004. Need to |
262 // round or else otherwise if the user zooms out, it will go to 3.0 instead of | 261 // round or else otherwise if the user zooms out, it will go to 3.0 instead of |
263 // 2.0. | 262 // 2.0. |
264 int rounded = | 263 int rounded = |
265 static_cast<int>(zoom_level + (zoom_level > 0 ? 0.001 : -0.001)); | 264 static_cast<int>(zoom_level + (zoom_level > 0 ? 0.001 : -0.001)); |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1224 } | 1223 } |
1225 | 1224 |
1226 ObjectVar* PluginInstance::ObjectVarForNPObject(NPObject* np_object) const { | 1225 ObjectVar* PluginInstance::ObjectVarForNPObject(NPObject* np_object) const { |
1227 NPObjectToObjectVarMap::const_iterator found = | 1226 NPObjectToObjectVarMap::const_iterator found = |
1228 np_object_to_object_var_.find(np_object); | 1227 np_object_to_object_var_.find(np_object); |
1229 if (found == np_object_to_object_var_.end()) | 1228 if (found == np_object_to_object_var_.end()) |
1230 return NULL; | 1229 return NULL; |
1231 return found->second; | 1230 return found->second; |
1232 } | 1231 } |
1233 | 1232 |
1233 bool PluginInstance::IsFullPagePlugin() const { | |
1234 WebFrame* frame = container()->element().document().frame(); | |
1235 return frame->view()->mainFrame()->document().isPluginDocument(); | |
1236 } | |
1237 | |
1234 } // namespace ppapi | 1238 } // namespace ppapi |
1235 } // namespace webkit | 1239 } // namespace webkit |
OLD | NEW |