From aded6eb5272ccb4f9b90ee529bdb014ffaa59031 Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Tue, 25 Aug 2009 15:05:32 +0000 Subject: browser-plugin: add zoom property Example: plugin.zoom = plugin.zoom * 1.5; --- (limited to 'browser-plugin/scriptable.cpp') diff --git a/browser-plugin/scriptable.cpp b/browser-plugin/scriptable.cpp index 6272c7d..e8fbcb2 100644 --- a/browser-plugin/scriptable.cpp +++ b/browser-plugin/scriptable.cpp @@ -197,6 +197,7 @@ ScriptablePluginObject::ScriptablePluginObject (NPP npp) : mMagicWrapper(0) { mTitleID = NPN_GetStringIdentifier ("title"); + mZoomID = NPN_GetStringIdentifier ("zoom"); mMagicWrapperID = NPN_GetStringIdentifier ("magicWrapper"); mZoomInID = NPN_GetStringIdentifier ("zoomIn"); @@ -229,6 +230,7 @@ ScriptablePluginObject::HasProperty (NPIdentifier name) { NPIdentifier properties[] = { mTitleID, + mZoomID, mMagicWrapperID }; @@ -256,6 +258,9 @@ ScriptablePluginObject::GetProperty (NPIdentifier name, NPVariant *result) } return true; + } else if (name == mZoomID) { + DOUBLE_TO_NPVARIANT (plugin->GetZoom(), *result); + return true; } return false; @@ -292,6 +297,19 @@ ScriptablePluginObject::SetProperty (NPIdentifier name, const NPVariant *value) } return true; + } else if (name == mZoomID) { + double zoom; + if (NPVARIANT_IS_DOUBLE (*value)) { + zoom = NPVARIANT_TO_DOUBLE (*value); + } else if (NPVARIANT_IS_INT32 (*value)) { + zoom = NPVARIANT_TO_INT32 (*value); + } else { + NPN_SetException (this, "Invalid type for zoom, expected a number"); + return false; + } + + plugin->SetZoom (zoom); + return true; } return false; -- cgit v0.9.1