Re: Resize Windowless plugin

[email protected] Tue, 14 May 2013 06:58:35 -0700 (PDT)
Newsgroups gmane.comp.mozilla.devel.plugins
Message-ID <[email protected]>
On Tuesday, May 14, 2013 3:47:02 PM UTC+2, Kevin DeKorte wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> 
> Hash: SHA1
> 
> 
> 
> On 05/14/2013 07:35 AM, [email protected] wrote:
> 
> > I have been searching for some samples of how to use NPRuntime
> 
> > however I can't find any. Are you aware of some samples?
> 
> 
> 
> Christian,
> 
> 
> 
> I've done things like this to run javascript from the plugin...
> 
> 
> 
> void postDOMEvent(NPP mInstance, const gchar * id, const gchar * event)
> 
> {
> 
>     gchar *jscript;
> 
> 
> 
>     jscript =
> 
> g_strdup_printf("javascript:obj_gmp=document.getElementById('%s');"
> 
>                               "e_gmp=document.createEvent('Events');"
> 
>                               "e_gmp.initEvent('%s',true,true);"
> 
> "obj_gmp.dispatchEvent(e_gmp);",
> 
>                               id, event);
> 
>     NPN_GetURL(mInstance, jscript, NULL);
> 
>     g_free(jscript);
> 
> }
> 
> 
> 
> 
> 
> Kevin
> 
> 
> 
> - -- 
> 
> Get my public GnuPG key from
> 
> http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7D0BD5D1
> 
> -----BEGIN PGP SIGNATURE-----
> 
> Version: GnuPG v1.4.13 (GNU/Linux)
> 
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> 
> 
> iEYEARECAAYFAlGSQFYACgkQ6w2kMH0L1dG0kQCdHgn7I7XGu/4Cb8XP9KUaWmXa
> 
> U+AAnjnRJkHA146Ze7aGms1L+juZsfnB
> 
> =NVK9
> 
> -----END PGP SIGNATURE-----

I have found that you can do:

        NPString str = { 0 };
        str.UTF8Characters = "document.getElementById('pluginId').style.height = '30px'";
        str.UTF8Length = strlen(str.UTF8Characters);

        NPObject window;
        mpBrowserFunctions->getvalue(npp, NPNVWindowNPObject, &window);

        NPVariant result;
        if(mpBrowserFunctions->evaluate(npp, &window, &str, &result))
            mpBrowserFunctions->releasevariantvalue(&result);