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

mshtml: Use ActiveScript for JavaScript in file protocol documents.

parent 6906c2f1
...@@ -1603,6 +1603,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject) ...@@ -1603,6 +1603,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
ret->lpIDispatchExVtbl = &DocDispatchExVtbl; ret->lpIDispatchExVtbl = &DocDispatchExVtbl;
ret->ref = 0; ret->ref = 0;
ret->readystate = READYSTATE_UNINITIALIZED; ret->readystate = READYSTATE_UNINITIALIZED;
ret->scriptmode = SCRIPTMODE_GECKO;
list_init(&ret->bindings); list_init(&ret->bindings);
list_init(&ret->script_hosts); list_init(&ret->script_hosts);
......
...@@ -166,6 +166,11 @@ typedef enum { ...@@ -166,6 +166,11 @@ typedef enum {
EDITMODE EDITMODE
} USERMODE; } USERMODE;
typedef enum {
SCRIPTMODE_GECKO,
SCRIPTMODE_ACTIVESCRIPT
} SCRIPTMODE;
typedef struct { typedef struct {
const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl; const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
...@@ -255,6 +260,7 @@ struct HTMLDocument { ...@@ -255,6 +260,7 @@ struct HTMLDocument {
DOCHOSTUIINFO hostinfo; DOCHOSTUIINFO hostinfo;
USERMODE usermode; USERMODE usermode;
SCRIPTMODE scriptmode;
READYSTATE readystate; READYSTATE readystate;
BOOL in_place_active; BOOL in_place_active;
BOOL ui_active; BOOL ui_active;
...@@ -572,6 +578,7 @@ void release_script_hosts(HTMLDocument*); ...@@ -572,6 +578,7 @@ void release_script_hosts(HTMLDocument*);
void connect_scripts(HTMLDocument*); void connect_scripts(HTMLDocument*);
void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*); void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*);
IDispatch *script_parse_event(HTMLDocument*,LPCWSTR); IDispatch *script_parse_event(HTMLDocument*,LPCWSTR);
void set_script_mode(HTMLDocument*,SCRIPTMODE);
IHTMLElementCollection *create_all_collection(HTMLDOMNode*); IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument*,IUnknown*,nsIDOMNodeList*); IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument*,IUnknown*,nsIDOMNodeList*);
......
...@@ -1377,6 +1377,7 @@ interface nsIWebBrowser : nsISupports ...@@ -1377,6 +1377,7 @@ interface nsIWebBrowser : nsISupports
nsresult GetContentDOMWindow(nsIDOMWindow **aContentDOMWindow); nsresult GetContentDOMWindow(nsIDOMWindow **aContentDOMWindow);
} }
cpp_quote("#define SETUP_ALLOW_JAVASCRIPT 2")
cpp_quote("#define SETUP_IS_CHROME_WRAPPER 7") cpp_quote("#define SETUP_IS_CHROME_WRAPPER 7")
[ [
......
...@@ -158,6 +158,12 @@ static nsIInputStream *get_post_data_stream(IBindCtx *bctx) ...@@ -158,6 +158,12 @@ static nsIInputStream *get_post_data_stream(IBindCtx *bctx)
return ret; return ret;
} }
static BOOL use_gecko_script(LPCWSTR url)
{
static const WCHAR fileW[] = {'f','i','l','e',':'};
return strncmpiW(fileW, url, sizeof(fileW)/sizeof(WCHAR));
}
void set_current_mon(HTMLDocument *This, IMoniker *mon) void set_current_mon(HTMLDocument *This, IMoniker *mon)
{ {
HRESULT hres; HRESULT hres;
...@@ -181,6 +187,8 @@ void set_current_mon(HTMLDocument *This, IMoniker *mon) ...@@ -181,6 +187,8 @@ void set_current_mon(HTMLDocument *This, IMoniker *mon)
hres = IMoniker_GetDisplayName(mon, NULL, NULL, &This->url); hres = IMoniker_GetDisplayName(mon, NULL, NULL, &This->url);
if(FAILED(hres)) if(FAILED(hres))
WARN("GetDisplayName failed: %08x\n", hres); WARN("GetDisplayName failed: %08x\n", hres);
set_script_mode(This, use_gecko_script(This->url) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT);
} }
static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BOOL *bind_complete) static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BOOL *bind_complete)
......
...@@ -712,8 +712,8 @@ static ScriptHost *get_script_host(HTMLDocument *doc, const GUID *guid) ...@@ -712,8 +712,8 @@ static ScriptHost *get_script_host(HTMLDocument *doc, const GUID *guid)
{ {
ScriptHost *iter; ScriptHost *iter;
if(IsEqualGUID(&CLSID_JScript, guid)) { if(IsEqualGUID(&CLSID_JScript, &guid) && doc->scriptmode != SCRIPTMODE_ACTIVESCRIPT) {
FIXME("Ignoring JScript\n"); TRACE("Ignoring JScript\n");
return NULL; return NULL;
} }
...@@ -792,6 +792,54 @@ IDispatch *script_parse_event(HTMLDocument *doc, LPCWSTR text) ...@@ -792,6 +792,54 @@ IDispatch *script_parse_event(HTMLDocument *doc, LPCWSTR text)
return disp; return disp;
} }
static BOOL is_jscript_available(void)
{
static BOOL available, checked;
if(!checked) {
IUnknown *unk;
HRESULT hres = CoGetClassObject(&CLSID_JScript, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
if(SUCCEEDED(hres)) {
available = TRUE;
IUnknown_Release(unk);
}else {
available = FALSE;
}
checked = TRUE;
}
return available;
}
void set_script_mode(HTMLDocument *doc, SCRIPTMODE mode)
{
nsIWebBrowserSetup *setup;
nsresult nsres;
if(mode == SCRIPTMODE_ACTIVESCRIPT && !is_jscript_available()) {
TRACE("jscript.dll not available\n");
doc->scriptmode = SCRIPTMODE_GECKO;
return;
}
doc->scriptmode = mode;
if(!doc->nscontainer || !doc->nscontainer->webbrowser)
return;
nsres = nsIWebBrowser_QueryInterface(doc->nscontainer->webbrowser,
&IID_nsIWebBrowserSetup, (void**)&setup);
if(NS_SUCCEEDED(nsres)) {
nsres = nsIWebBrowserSetup_SetProperty(setup, SETUP_ALLOW_JAVASCRIPT,
doc->scriptmode == SCRIPTMODE_GECKO);
nsIWebBrowserSetup_Release(setup);
}
if(NS_FAILED(nsres))
ERR("JavaScript setup failed: %08x\n", nsres);
}
void release_script_hosts(HTMLDocument *doc) void release_script_hosts(HTMLDocument *doc)
{ {
ScriptHost *iter; ScriptHost *iter;
......
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