Re: FW: How to Read DOm for FF 3.0.8
taxilian <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <3fb01ba2-9dc8-47d9-83f8-0211d01078fc@r31g2000prh.googlegroups.com> |
Well, if you aren't too attached to the XPCOM interfaces, the NPAPI
ones are pretty easy to do this with (and cross-platform, compatible
with other browsers like safari and chrome, to boot)
here are a few helper functions that I use:
void NpapiScriptableObject::getWindowNPObject(MNVariant &window)
{
NPObject *sWindowObj = NULL;
NPError err = NPN_GetValue(mInstance, NPNVWindowNPObject,
&sWindowObj);
window.setNPObject(sWindowObj, NPN_RetainObject,
NPN_ReleaseObject);
}
void NpapiScriptableObject::getPluginNPObject(MNVariant &plugin)
{
NPObject *sPluginObj = NULL;
NPError err = NPN_GetValue(mInstance, NPNVPluginElementNPObject,
&sPluginObj);
plugin.setNPObject(sPluginObj, NPN_RetainObject,
NPN_ReleaseObject);
}
void NpapiScriptableObject::getValueFromNPObject(MNVariant &result,
NPObject *target, const char *propertyName)
{
NPVariant var;
bool b = NPN_GetProperty(mInstance, target, NPN_GetStringIdentifier
(propertyName), &var);
if (b)
{
NPVariantToMNVariant(var, result);
NPN_ReleaseVariantValue(&var);
}
else
{
result.setVoid();
}
}
MNVariant is just a class that I wrote that can handle multiple data
types (it's part of a cross-browser plugin framework that I'm
developing); in this case, its primary function is to call
NPN_RetainObject on any NPObjects that are assigned to it and
NPN_ReleaseObject when it goes out of scope.
Basically, you get the window, and then you get a property on the
window, like, say, "document"... and then you can call methods on it,
etc.
I'm not sure how well it works to mix the nsI interfaces with the
npapi/npruntime interfaces, however.
But then, by and large I don't understand why so many people are still
even using XPCOM when it only works on firefox; I guess my needs are
just more general. If it helps, great, if not, maybe someone else can
help you with the XPCOM stuff.
Richard
On Apr 8, 10:50 pm, "Tarun Sharma" <[email protected]> wrote:
> Hi,
>
> In my C++ MFC Based application I was reading the Dom for Firefox 3.0.2 by
> using ISimpleDOMDocument and ISimpleDOMNode interfaces.
>
> But these interfaces doesn't work for FF 3.0.8. Can anyone tell me what has
> changed and now how can I read the Dom.
>
> Tarun Sharma.