mshtml: Merge parse_extern_script and bind_script.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2016-07-19 18:40:04 +02:00 committed by Alexandre Julliard
parent f73f884884
commit eeb075dd0e
1 changed files with 20 additions and 20 deletions

View File

@ -997,12 +997,30 @@ static const BSCallbackVtbl ScriptBSCVtbl = {
}; };
static HRESULT bind_script(HTMLInnerWindow *window, IUri *uri, HTMLScriptElement *script_elem) static HRESULT load_script(HTMLScriptElement *script_elem, const WCHAR *src)
{ {
HTMLInnerWindow *window;
ScriptBSC *bsc; ScriptBSC *bsc;
IMoniker *mon; IMoniker *mon;
IUri *uri;
HRESULT hres; HRESULT hres;
static const WCHAR wine_schemaW[] = {'w','i','n','e',':'};
if(strlenW(src) > sizeof(wine_schemaW)/sizeof(WCHAR) && !memcmp(src, wine_schemaW, sizeof(wine_schemaW)))
src += sizeof(wine_schemaW)/sizeof(WCHAR);
TRACE("(%p %s)\n", script_elem, debugstr_w(src));
if(!script_elem->element.node.doc || !(window = script_elem->element.node.doc->window)) {
ERR("no window\n");
return E_UNEXPECTED;
}
hres = create_uri(src, 0, &uri);
if(FAILED(hres))
return hres;
hres = CreateURLMonikerEx2(NULL, uri, &mon, URL_MK_UNIFORM); hres = CreateURLMonikerEx2(NULL, uri, &mon, URL_MK_UNIFORM);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1029,24 +1047,6 @@ static HRESULT bind_script(HTMLInnerWindow *window, IUri *uri, HTMLScriptElement
return hres; return hres;
} }
static void parse_extern_script(ScriptHost *script_host, HTMLScriptElement *script_elem, LPCWSTR src)
{
IUri *uri;
HRESULT hres;
static const WCHAR wine_schemaW[] = {'w','i','n','e',':'};
if(strlenW(src) > sizeof(wine_schemaW)/sizeof(WCHAR) && !memcmp(src, wine_schemaW, sizeof(wine_schemaW)))
src += sizeof(wine_schemaW)/sizeof(WCHAR);
hres = create_uri(src, 0, &uri);
if(FAILED(hres))
return;
hres = bind_script(script_host->window, uri, script_elem);
IUri_Release(uri);
}
static void parse_inline_script(ScriptHost *script_host, HTMLScriptElement *script_elem) static void parse_inline_script(ScriptHost *script_host, HTMLScriptElement *script_elem)
{ {
const PRUnichar *text; const PRUnichar *text;
@ -1095,7 +1095,7 @@ static void parse_script_elem(ScriptHost *script_host, HTMLScriptElement *script
if(NS_FAILED(nsres)) { if(NS_FAILED(nsres)) {
ERR("GetSrc failed: %08x\n", nsres); ERR("GetSrc failed: %08x\n", nsres);
}else if(*src) { }else if(*src) {
parse_extern_script(script_host, script_elem, src); load_script(script_elem, src);
}else { }else {
parse_inline_script(script_host, script_elem); parse_inline_script(script_host, script_elem);
} }