Commit a0c2d641 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use get_elem_attr_value helper in npplugin.c.

parent 75a2e8c4
...@@ -211,10 +211,11 @@ typedef struct _NPPluginFuncs { ...@@ -211,10 +211,11 @@ typedef struct _NPPluginFuncs {
NPP_LostFocusPtr lostfocus; NPP_LostFocusPtr lostfocus;
} NPPluginFuncs; } NPPluginFuncs;
static nsIDOMElement *get_dom_element(NPP instance) static nsIDOMHTMLElement *get_dom_element(NPP instance)
{ {
nsISupports *instance_unk = (nsISupports*)instance->ndata; nsISupports *instance_unk = (nsISupports*)instance->ndata;
nsIPluginInstance *plugin_instance; nsIPluginInstance *plugin_instance;
nsIDOMHTMLElement *html_elem;
nsIDOMElement *elem; nsIDOMElement *elem;
nsresult nsres; nsresult nsres;
...@@ -231,17 +232,24 @@ static nsIDOMElement *get_dom_element(NPP instance) ...@@ -231,17 +232,24 @@ static nsIDOMElement *get_dom_element(NPP instance)
return NULL; return NULL;
} }
return elem; nsres = nsIDOMElement_QueryInterface(elem, &IID_nsIDOMHTMLElement, (void**)&html_elem);
nsIDOMElement_Release(elem);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
return NULL;
}
return html_elem;
} }
static HTMLInnerWindow *get_elem_window(nsIDOMElement *elem) static HTMLInnerWindow *get_elem_window(nsIDOMHTMLElement *elem)
{ {
nsIDOMWindow *nswindow; nsIDOMWindow *nswindow;
nsIDOMDocument *nsdoc; nsIDOMDocument *nsdoc;
HTMLOuterWindow *window; HTMLOuterWindow *window;
nsresult nsres; nsresult nsres;
nsres = nsIDOMElement_GetOwnerDocument(elem, &nsdoc); nsres = nsIDOMHTMLElement_GetOwnerDocument(elem, &nsdoc);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
return NULL; return NULL;
...@@ -287,29 +295,22 @@ static BOOL parse_classid(const PRUnichar *classid, CLSID *clsid) ...@@ -287,29 +295,22 @@ static BOOL parse_classid(const PRUnichar *classid, CLSID *clsid)
return SUCCEEDED(hres); return SUCCEEDED(hres);
} }
static BOOL get_elem_clsid(nsIDOMElement *elem, CLSID *clsid) static BOOL get_elem_clsid(nsIDOMHTMLElement *elem, CLSID *clsid)
{ {
nsAString attr_str, val_str; const PRUnichar *val;
nsAString val_str;
nsresult nsres; nsresult nsres;
BOOL ret = FALSE; BOOL ret = FALSE;
static const PRUnichar classidW[] = {'c','l','a','s','s','i','d',0}; static const PRUnichar classidW[] = {'c','l','a','s','s','i','d',0};
nsAString_InitDepend(&attr_str, classidW); nsres = get_elem_attr_value(elem, classidW, &val_str, &val);
nsAString_Init(&val_str, NULL);
nsres = nsIDOMElement_GetAttribute(elem, &attr_str, &val_str);
nsAString_Finish(&attr_str);
if(NS_SUCCEEDED(nsres)) { if(NS_SUCCEEDED(nsres)) {
const PRUnichar *val;
nsAString_GetData(&val_str, &val);
if(*val) if(*val)
ret = parse_classid(val, clsid); ret = parse_classid(val, clsid);
}else { nsAString_Finish(&val_str);
ERR("GetAttribute failed: %08x\n", nsres);
} }
nsAString_Finish(&val_str);
return ret; return ret;
} }
...@@ -529,35 +530,28 @@ static void install_codebase(const WCHAR *url) ...@@ -529,35 +530,28 @@ static void install_codebase(const WCHAR *url)
WARN("FAILED: %08x\n", hres); WARN("FAILED: %08x\n", hres);
} }
static void check_codebase(HTMLInnerWindow *window, nsIDOMElement *nselem) static void check_codebase(HTMLInnerWindow *window, nsIDOMHTMLElement *nselem)
{ {
nsAString attr_str, val_str;
BOOL is_on_list = FALSE; BOOL is_on_list = FALSE;
install_entry_t *iter; install_entry_t *iter;
const PRUnichar *val;
nsAString val_str;
IUri *uri = NULL; IUri *uri = NULL;
nsresult nsres; nsresult nsres;
HRESULT hres; HRESULT hres;
static const PRUnichar codebaseW[] = {'c','o','d','e','b','a','s','e',0}; static const PRUnichar codebaseW[] = {'c','o','d','e','b','a','s','e',0};
nsAString_InitDepend(&attr_str, codebaseW); nsres = get_elem_attr_value(nselem, codebaseW, &val_str, &val);
nsAString_Init(&val_str, NULL);
nsres = nsIDOMElement_GetAttribute(nselem, &attr_str, &val_str);
nsAString_Finish(&attr_str);
if(NS_SUCCEEDED(nsres)) { if(NS_SUCCEEDED(nsres)) {
const PRUnichar *val;
nsAString_GetData(&val_str, &val);
if(*val) { if(*val) {
hres = CoInternetCombineUrlEx(window->base.outer_window->uri, val, 0, &uri, 0); hres = CoInternetCombineUrlEx(window->base.outer_window->uri, val, 0, &uri, 0);
if(FAILED(hres)) if(FAILED(hres))
uri = NULL; uri = NULL;
} }
}else { nsAString_Finish(&val_str);
ERR("GetAttribute failed: %08x\n", nsres);
} }
nsAString_Finish(&val_str);
if(!uri) if(!uri)
return; return;
...@@ -599,7 +593,7 @@ static void check_codebase(HTMLInnerWindow *window, nsIDOMElement *nselem) ...@@ -599,7 +593,7 @@ static void check_codebase(HTMLInnerWindow *window, nsIDOMElement *nselem)
IUri_Release(uri); IUri_Release(uri);
} }
static IUnknown *create_activex_object(HTMLInnerWindow *window, nsIDOMElement *nselem, CLSID *clsid) static IUnknown *create_activex_object(HTMLInnerWindow *window, nsIDOMHTMLElement *nselem, CLSID *clsid)
{ {
IClassFactoryEx *cfex; IClassFactoryEx *cfex;
IClassFactory *cf; IClassFactory *cf;
...@@ -645,7 +639,7 @@ static IUnknown *create_activex_object(HTMLInnerWindow *window, nsIDOMElement *n ...@@ -645,7 +639,7 @@ static IUnknown *create_activex_object(HTMLInnerWindow *window, nsIDOMElement *n
static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, INT16 argc, char **argn, static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, INT16 argc, char **argn,
char **argv, NPSavedData *saved) char **argv, NPSavedData *saved)
{ {
nsIDOMElement *nselem; nsIDOMHTMLElement *nselem;
HTMLInnerWindow *window; HTMLInnerWindow *window;
IUnknown *obj; IUnknown *obj;
CLSID clsid; CLSID clsid;
...@@ -662,7 +656,7 @@ static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, I ...@@ -662,7 +656,7 @@ static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, I
window = get_elem_window(nselem); window = get_elem_window(nselem);
if(!window) { if(!window) {
ERR("Could not get element's window object\n"); ERR("Could not get element's window object\n");
nsIDOMElement_Release(nselem); nsIDOMHTMLElement_Release(nselem);
return NPERR_GENERIC_ERROR; return NPERR_GENERIC_ERROR;
} }
...@@ -671,7 +665,7 @@ static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, I ...@@ -671,7 +665,7 @@ static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, I
PluginHost *host; PluginHost *host;
HRESULT hres; HRESULT hres;
hres = create_plugin_host(window->doc, nselem, obj, &clsid, &host); hres = create_plugin_host(window->doc, (nsIDOMElement*)nselem, obj, &clsid, &host);
IUnknown_Release(obj); IUnknown_Release(obj);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
instance->pdata = host; instance->pdata = host;
...@@ -681,7 +675,7 @@ static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, I ...@@ -681,7 +675,7 @@ static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, I
err = NPERR_GENERIC_ERROR; err = NPERR_GENERIC_ERROR;
} }
nsIDOMElement_Release(nselem); nsIDOMHTMLElement_Release(nselem);
return err; return err;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment