Jacek Caban : mshtml: Use ActiveScript for JavaScript in file protocol documents.
Alexandre Julliard
julliard at winehq.org
Thu Sep 25 07:13:29 CDT 2008
Module: wine
Branch: master
Commit: c3bdda810243ed6c8d6b9960d1df3b534653b438
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c3bdda810243ed6c8d6b9960d1df3b534653b438
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Sep 24 18:19:46 2008 +0200
mshtml: Use ActiveScript for JavaScript in file protocol documents.
---
dlls/mshtml/htmldoc.c | 1 +
dlls/mshtml/mshtml_private.h | 7 +++++
dlls/mshtml/nsiface.idl | 1 +
dlls/mshtml/persist.c | 8 ++++++
dlls/mshtml/script.c | 52 ++++++++++++++++++++++++++++++++++++++++-
5 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index e5870d8..dd989ff 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1603,6 +1603,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
ret->lpIDispatchExVtbl = &DocDispatchExVtbl;
ret->ref = 0;
ret->readystate = READYSTATE_UNINITIALIZED;
+ ret->scriptmode = SCRIPTMODE_GECKO;
list_init(&ret->bindings);
list_init(&ret->script_hosts);
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 5a9f533..5211d2f 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -166,6 +166,11 @@ typedef enum {
EDITMODE
} USERMODE;
+typedef enum {
+ SCRIPTMODE_GECKO,
+ SCRIPTMODE_ACTIVESCRIPT
+} SCRIPTMODE;
+
typedef struct {
const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
@@ -255,6 +260,7 @@ struct HTMLDocument {
DOCHOSTUIINFO hostinfo;
USERMODE usermode;
+ SCRIPTMODE scriptmode;
READYSTATE readystate;
BOOL in_place_active;
BOOL ui_active;
@@ -572,6 +578,7 @@ void release_script_hosts(HTMLDocument*);
void connect_scripts(HTMLDocument*);
void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*);
IDispatch *script_parse_event(HTMLDocument*,LPCWSTR);
+void set_script_mode(HTMLDocument*,SCRIPTMODE);
IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument*,IUnknown*,nsIDOMNodeList*);
diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl
index 42e6eb0..44b426c 100644
--- a/dlls/mshtml/nsiface.idl
+++ b/dlls/mshtml/nsiface.idl
@@ -1377,6 +1377,7 @@ interface nsIWebBrowser : nsISupports
nsresult GetContentDOMWindow(nsIDOMWindow **aContentDOMWindow);
}
+cpp_quote("#define SETUP_ALLOW_JAVASCRIPT 2")
cpp_quote("#define SETUP_IS_CHROME_WRAPPER 7")
[
diff --git a/dlls/mshtml/persist.c b/dlls/mshtml/persist.c
index 78a5d6b..e673f9c 100644
--- a/dlls/mshtml/persist.c
+++ b/dlls/mshtml/persist.c
@@ -158,6 +158,12 @@ static nsIInputStream *get_post_data_stream(IBindCtx *bctx)
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)
{
HRESULT hres;
@@ -181,6 +187,8 @@ void set_current_mon(HTMLDocument *This, IMoniker *mon)
hres = IMoniker_GetDisplayName(mon, NULL, NULL, &This->url);
if(FAILED(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)
diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c
index de76062..5df0616 100644
--- a/dlls/mshtml/script.c
+++ b/dlls/mshtml/script.c
@@ -712,8 +712,8 @@ static ScriptHost *get_script_host(HTMLDocument *doc, const GUID *guid)
{
ScriptHost *iter;
- if(IsEqualGUID(&CLSID_JScript, guid)) {
- FIXME("Ignoring JScript\n");
+ if(IsEqualGUID(&CLSID_JScript, &guid) && doc->scriptmode != SCRIPTMODE_ACTIVESCRIPT) {
+ TRACE("Ignoring JScript\n");
return NULL;
}
@@ -792,6 +792,54 @@ IDispatch *script_parse_event(HTMLDocument *doc, LPCWSTR text)
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)
{
ScriptHost *iter;
More information about the wine-cvs
mailing list