Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/browser-plugin/scriptable.cpp
diff options
context:
space:
mode:
authorTommi Komulainen <tko@litl.com>2009-08-25 15:05:32 (GMT)
committer Marco Pesenti Gritti <marcopg@litl.com>2010-07-27 22:04:22 (GMT)
commitaded6eb5272ccb4f9b90ee529bdb014ffaa59031 (patch)
treedde7bd63762ca9fbcf17805809ebbd7c13284ea1 /browser-plugin/scriptable.cpp
parent60cc60c16e52601993c77076dab3eeb9d1f0ab1a (diff)
browser-plugin: add zoom property
Example: plugin.zoom = plugin.zoom * 1.5;
Diffstat (limited to 'browser-plugin/scriptable.cpp')
-rw-r--r--browser-plugin/scriptable.cpp18
1 files changed, 18 insertions, 0 deletions
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;