diff options
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_delegate.h | 12 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.cc | 45 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.h | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_module.cc | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_webplugin_impl.cc | 14 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_webplugin_impl.h | 2 |
6 files changed, 69 insertions, 11 deletions
diff --git a/webkit/glue/plugins/pepper_plugin_delegate.h b/webkit/glue/plugins/pepper_plugin_delegate.h index 1bb4bed..318c70a 100644 --- a/webkit/glue/plugins/pepper_plugin_delegate.h +++ b/webkit/glue/plugins/pepper_plugin_delegate.h @@ -156,12 +156,12 @@ class PluginDelegate { PlatformAudio::Client* client) = 0; // Notifies that the number of find results has changed. - virtual void DidChangeNumberOfFindResults(int identifier, - int total, - bool final_result) = 0; + virtual void NumberOfFindResultsChanged(int identifier, + int total, + bool final_result) = 0; // Notifies that the index of the currently selected item has been updated. - virtual void DidChangeSelectedFindResult(int identifier, int index) = 0; + virtual void SelectedFindResultChanged(int identifier, int index) = 0; // Runs a file chooser. virtual bool RunFileChooser( @@ -202,6 +202,10 @@ class PluginDelegate { // Returns a string with the name of the default 8-bit char encoding. virtual std::string GetDefaultEncoding() = 0; + + // Sets the mininum and maximium zoom factors. + virtual void ZoomLimitsChanged(double minimum_factor, + double maximum_factor) = 0; }; } // namespace pepper 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); diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/glue/plugins/pepper_plugin_instance.h index 4eb956f..97e026e 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.h +++ b/webkit/glue/plugins/pepper_plugin_instance.h @@ -25,6 +25,7 @@ struct PP_Var; struct PPB_Instance; struct PPB_Find_Dev; struct PPB_Fullscreen_Dev; +struct PPB_Zoom_Dev; struct PPP_Find_Dev; struct PPP_Instance; struct PPP_Zoom_Dev; @@ -67,6 +68,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> { // exposed to the plugin. static const PPB_Find_Dev* GetFindInterface(); static const PPB_Fullscreen_Dev* GetFullscreenInterface(); + static const PPB_Zoom_Dev* GetZoomInterface(); PluginDelegate* delegate() const { return delegate_; } PluginModule* module() const { return module_.get(); } @@ -134,7 +136,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> { gfx::Rect* clip); string16 GetSelectedText(bool html); - void Zoom(float factor, bool text_only); + void Zoom(double factor, bool text_only); bool StartFind(const string16& search_text, bool case_sensitive, int identifier); diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc index 251023f..0845479 100644 --- a/webkit/glue/plugins/pepper_plugin_module.cc +++ b/webkit/glue/plugins/pepper_plugin_module.cc @@ -34,6 +34,7 @@ #include "third_party/ppapi/c/dev/ppb_url_util_dev.h" #include "third_party/ppapi/c/dev/ppb_video_decoder_dev.h" #include "third_party/ppapi/c/dev/ppb_widget_dev.h" +#include "third_party/ppapi/c/dev/ppb_zoom_dev.h" #include "third_party/ppapi/c/trusted/ppb_image_data_trusted.h" #include "third_party/ppapi/c/pp_module.h" #include "third_party/ppapi/c/pp_resource.h" @@ -272,6 +273,8 @@ const void* GetInterface(const char* name) { return CharSet::GetInterface(); if (strcmp(name, PPB_CURSOR_CONTROL_DEV_INTERFACE) == 0) return GetCursorControlInterface(); + if (strcmp(name, PPB_ZOOM_DEV_INTERFACE) == 0) + return PluginInstance::GetZoomInterface(); // Only support the testing interface when the command line switch is // specified. This allows us to prevent people from (ab)using this interface diff --git a/webkit/glue/plugins/pepper_webplugin_impl.cc b/webkit/glue/plugins/pepper_webplugin_impl.cc index 32903b0..0cea7219 100644 --- a/webkit/glue/plugins/pepper_webplugin_impl.cc +++ b/webkit/glue/plugins/pepper_webplugin_impl.cc @@ -4,10 +4,13 @@ #include "webkit/glue/plugins/pepper_webplugin_impl.h" +#include <cmath> + #include "base/message_loop.h" #include "third_party/ppapi/c/pp_var.h" #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" +#include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_plugin_module.h" #include "webkit/glue/plugins/pepper_url_loader.h" @@ -19,6 +22,7 @@ using WebKit::WebPluginParams; using WebKit::WebRect; using WebKit::WebString; using WebKit::WebVector; +using WebKit::WebView; namespace pepper { @@ -165,8 +169,14 @@ WebKit::WebString WebPluginImpl::selectionAsMarkup() const { return instance_->GetSelectedText(true); } -void WebPluginImpl::setZoomFactor(float scale, bool text_only) { - instance_->Zoom(scale, text_only); +void WebPluginImpl::setZoomLevel(double level, bool text_only) { +#ifdef ZOOM_LEVEL_IS_DOUBLE + double factor = WebView::zoomLevelToZoomFactor(level); +#else + double factor = std::pow(1.2, level); +#endif + + instance_->Zoom(factor, text_only); } bool WebPluginImpl::startFind(const WebKit::WebString& search_text, diff --git a/webkit/glue/plugins/pepper_webplugin_impl.h b/webkit/glue/plugins/pepper_webplugin_impl.h index 9d2f313..17ce979 100644 --- a/webkit/glue/plugins/pepper_webplugin_impl.h +++ b/webkit/glue/plugins/pepper_webplugin_impl.h @@ -63,7 +63,7 @@ class WebPluginImpl : public WebKit::WebPlugin { virtual bool hasSelection() const; virtual WebKit::WebString selectionAsText() const; virtual WebKit::WebString selectionAsMarkup() const; - virtual void setZoomFactor(float scale, bool text_only); + virtual void setZoomLevel(double level, bool text_only); virtual bool startFind(const WebKit::WebString& search_text, bool case_sensitive, int identifier); |