diff options
| author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-01 07:28:25 +0000 |
|---|---|---|
| committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-01 07:28:25 +0000 |
| commit | b75b829359b4b432d0462ab5011542f99f2021a5 (patch) | |
| tree | 564389d8698b140e97918a4cefd7ad18c7c99e7f /webkit/glue/plugins/pepper_plugin_instance.cc | |
| parent | 3ec5d92cbba6b7b13ead81ebfd9e3c202fae001d (diff) | |
| download | chromium_src-b75b829359b4b432d0462ab5011542f99f2021a5.zip chromium_src-b75b829359b4b432d0462ab5011542f99f2021a5.tar.gz chromium_src-b75b829359b4b432d0462ab5011542f99f2021a5.tar.bz2 | |
Chrome side of consolidating zoom code for pepper plugins (i.e. pdf) and the rest of Chrome. Allows plugins to have different zoom ranges, and also to update zoom on its own.
Review URL: http://codereview.chromium.org/3419023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins/pepper_plugin_instance.cc')
| -rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.cc | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc index b4ccd89..b59539d 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.cc +++ b/webkit/glue/plugins/pepper_plugin_instance.cc @@ -24,6 +24,7 @@ #include "skia/ext/platform_canvas.h" #include "third_party/ppapi/c/dev/ppb_find_dev.h" #include "third_party/ppapi/c/dev/ppb_fullscreen_dev.h" +#include "third_party/ppapi/c/dev/ppb_zoom_dev.h" #include "third_party/ppapi/c/dev/ppp_find_dev.h" #include "third_party/ppapi/c/dev/ppp_zoom_dev.h" #include "third_party/ppapi/c/pp_input_event.h" @@ -42,6 +43,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" +#include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/glue/plugins/pepper_buffer.h" #include "webkit/glue/plugins/pepper_graphics_2d.h" #include "webkit/glue/plugins/pepper_event_conversion.h" @@ -59,6 +61,7 @@ using WebKit::WebCursorInfo; using WebKit::WebFrame; using WebKit::WebInputEvent; using WebKit::WebPluginContainer; +using WebKit::WebView; namespace pepper { @@ -189,7 +192,7 @@ void NumberOfFindResultsChanged(PP_Instance instance_id, return; DCHECK_NE(instance->find_identifier(), -1); - instance->delegate()->DidChangeNumberOfFindResults( + instance->delegate()->NumberOfFindResultsChanged( instance->find_identifier(), total, final_result); } @@ -200,7 +203,7 @@ void SelectedFindResultChanged(PP_Instance instance_id, return; DCHECK_NE(instance->find_identifier(), -1); - instance->delegate()->DidChangeSelectedFindResult( + instance->delegate()->SelectedFindResultChanged( instance->find_identifier(), index); } @@ -228,6 +231,37 @@ const PPB_Fullscreen_Dev ppb_fullscreen = { &SetFullscreen, }; +void ZoomChanged(PP_Instance instance_id, double factor) { +#ifdef ZOOM_LEVEL_IS_DOUBLE + PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); + if (!instance) + return; + double zoom_level = WebView::zoomFactorToZoomLevel(factor); + instance->container()->zoomLevelChanged(zoom_level); +#endif +} + +void ZoomLimitsChanged(PP_Instance instance_id, + double minimum_factor, + double maximium_factor) { + if (minimum_factor > maximium_factor) { + NOTREACHED(); + return; + } + +#ifdef ZOOM_LEVEL_IS_DOUBLE + PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); + if (!instance) + return; + instance->delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor); +#endif +} + +const PPB_Zoom_Dev ppb_zoom = { + &ZoomChanged, + &ZoomLimitsChanged +}; + } // namespace PluginInstance::PluginInstance(PluginDelegate* delegate, @@ -282,6 +316,11 @@ const PPB_Fullscreen_Dev* PluginInstance::GetFullscreenInterface() { return &ppb_fullscreen; } +// static +const PPB_Zoom_Dev* PluginInstance::GetZoomInterface() { + return &ppb_zoom; +} + PP_Instance PluginInstance::GetPPInstance() { return reinterpret_cast<intptr_t>(this); } @@ -555,7 +594,7 @@ string16 PluginInstance::GetSelectedText(bool html) { return UTF8ToUTF16(string->value()); } -void PluginInstance::Zoom(float factor, bool text_only) { +void PluginInstance::Zoom(double factor, bool text_only) { if (!LoadZoomInterface()) return; plugin_zoom_interface_->Zoom(GetPPInstance(), factor, text_only); |
