mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
mshtml: Store document node in window.
This commit is contained in:
parent
1d2020795a
commit
62ccef389f
@ -1949,7 +1949,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
|
||||
ERR("GetContentDOMWindow failed: %08x\n", nsres);
|
||||
}
|
||||
|
||||
hres = HTMLWindow_Create(nswindow, &doc->basedoc.window);
|
||||
hres = HTMLWindow_Create(doc, nswindow, &doc->basedoc.window);
|
||||
if(nswindow)
|
||||
nsIDOMWindow_Release(nswindow);
|
||||
if(FAILED(hres)) {
|
||||
@ -1958,7 +1958,6 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
|
||||
}
|
||||
|
||||
update_nsdocument(doc);
|
||||
doc->basedoc.window->doc = &doc->basedoc;
|
||||
get_thread_hwnd();
|
||||
|
||||
return S_OK;
|
||||
|
@ -961,7 +961,7 @@ void check_event_attr(HTMLDocument *doc, nsIDOMElement *nselem)
|
||||
|
||||
TRACE("%p.%s = %s\n", nselem, debugstr_w(event_info[i].attr_name), debugstr_w(attr_value));
|
||||
|
||||
disp = script_parse_event(doc, attr_value);
|
||||
disp = script_parse_event(doc->window, attr_value);
|
||||
if(disp) {
|
||||
node = get_node(doc, (nsIDOMNode*)nselem, TRUE);
|
||||
set_event_handler_disp(get_node_event_target(node), node->doc, i, disp);
|
||||
|
@ -73,7 +73,7 @@ static inline HRESULT get_doc_event(HTMLDocument *doc, eventid_t eid, VARIANT *v
|
||||
|
||||
static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
|
||||
{
|
||||
return set_event_handler(&window->event_target, window->doc, eid, var);
|
||||
return set_event_handler(&window->event_target, &window->doc_obj->basedoc, eid, var);
|
||||
}
|
||||
|
||||
static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
|
||||
|
@ -129,7 +129,7 @@ static HRESULT WINAPI HTMLIFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface,
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
hres = HTMLWindow_Create(NULL, &window);
|
||||
hres = HTMLWindow_Create(This->element.node.doc->doc_obj, NULL, &window);
|
||||
if(FAILED(hres)) {
|
||||
nsIDOMDocument_Release(nsdoc);
|
||||
return hres;
|
||||
@ -137,7 +137,7 @@ static HRESULT WINAPI HTMLIFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface,
|
||||
|
||||
hres = create_doc_from_nsdoc(nshtmldoc, This->element.node.doc->doc_obj, window, &This->content_doc);
|
||||
if(SUCCEEDED(hres))
|
||||
window->doc = &This->content_doc->basedoc;
|
||||
window->doc = This->content_doc;
|
||||
IHTMLWindow2_Release(HTMLWINDOW2(window));
|
||||
nsIDOMHTMLDocument_Release(nshtmldoc);
|
||||
if(FAILED(hres))
|
||||
|
@ -37,12 +37,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
||||
|
||||
static HRESULT get_url(HTMLLocation *This, const WCHAR **ret)
|
||||
{
|
||||
if(!This->window || !This->window->doc || !This->window->doc->url) {
|
||||
if(!This->window || !This->window->doc_obj || !This->window->doc_obj->basedoc.url) {
|
||||
FIXME("No current URL\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
*ret = This->window->doc->url;
|
||||
*ret = This->window->doc_obj->basedoc.url;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
|
||||
TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_variant(&text), debugstr_variant(&value),
|
||||
debugstr_variant(&defaultselected), debugstr_variant(&selected), optelem);
|
||||
|
||||
if(!This->window || !This->window->doc || !This->window->doc->nsdoc) {
|
||||
if(!This->window || !This->window->doc || !This->window->doc->basedoc.nsdoc) {
|
||||
WARN("NULL nsdoc\n");
|
||||
return E_UNEXPECTED;
|
||||
}
|
||||
@ -467,14 +467,14 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
|
||||
*optelem = NULL;
|
||||
|
||||
nsAString_Init(&option_str, optionW);
|
||||
nsres = nsIDOMHTMLDocument_CreateElement(This->window->doc->nsdoc, &option_str, &nselem);
|
||||
nsres = nsIDOMHTMLDocument_CreateElement(This->window->doc->basedoc.nsdoc, &option_str, &nselem);
|
||||
nsAString_Finish(&option_str);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("CreateElement failed: %08x\n", nsres);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(get_node(This->window->doc, (nsIDOMNode*)nselem, TRUE)),
|
||||
hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(get_node(&This->window->doc_obj->basedoc, (nsIDOMNode*)nselem, TRUE)),
|
||||
&IID_IHTMLOptionElement, (void**)optelem);
|
||||
nsIDOMElement_Release(nselem);
|
||||
|
||||
|
@ -223,7 +223,7 @@ static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID
|
||||
|
||||
TRACE("(%p)->(%d)\n", This, timerID);
|
||||
|
||||
return clear_task_timer(This->doc, FALSE, timerID);
|
||||
return clear_task_timer(&This->doc->basedoc, FALSE, timerID);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
|
||||
@ -239,7 +239,7 @@ static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
MessageBoxW(This->doc->hwnd, message, wszTitle, MB_ICONWARNING);
|
||||
MessageBoxW(This->doc_obj->basedoc.hwnd, message, wszTitle, MB_ICONWARNING);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if(MessageBoxW(This->doc->hwnd, message, wszTitle,
|
||||
if(MessageBoxW(This->doc_obj->basedoc.hwnd, message, wszTitle,
|
||||
MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
|
||||
*confirmed = VARIANT_TRUE;
|
||||
else *confirmed = VARIANT_FALSE;
|
||||
@ -353,7 +353,7 @@ static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
|
||||
arg.textdata = textdata;
|
||||
|
||||
DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
|
||||
This->doc->hwnd, prompt_dlgproc, (LPARAM)&arg);
|
||||
This->doc_obj->basedoc.hwnd, prompt_dlgproc, (LPARAM)&arg);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -632,7 +632,7 @@ static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocumen
|
||||
|
||||
if(This->doc) {
|
||||
/* FIXME: We should return a wrapper object here */
|
||||
*p = HTMLDOC(This->doc);
|
||||
*p = HTMLDOC(&This->doc->basedoc);
|
||||
IHTMLDocument2_AddRef(*p);
|
||||
}else {
|
||||
*p = NULL;
|
||||
@ -752,7 +752,7 @@ static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerI
|
||||
|
||||
TRACE("(%p)->(%d)\n", This, timerID);
|
||||
|
||||
return clear_task_timer(This->doc, TRUE, timerID);
|
||||
return clear_task_timer(&This->doc->basedoc, TRUE, timerID);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
|
||||
@ -856,10 +856,10 @@ static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **
|
||||
|
||||
*p = NULL;
|
||||
|
||||
if(!This->doc->hostui)
|
||||
if(!This->doc_obj->basedoc.hostui)
|
||||
return S_OK;
|
||||
|
||||
return IDocHostUIHandler_GetExternal(This->doc->hostui, p);
|
||||
return IDocHostUIHandler_GetExternal(This->doc_obj->basedoc.hostui, p);
|
||||
}
|
||||
|
||||
static HRESULT HTMLWindow_invoke(IUnknown *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
|
||||
@ -1055,7 +1055,7 @@ static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, I
|
||||
|
||||
TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
|
||||
|
||||
return attach_event(&This->event_target, This->doc, event, pDisp, pfResult);
|
||||
return attach_event(&This->event_target, &This->doc_obj->basedoc, event, pDisp, pfResult);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
|
||||
@ -1077,7 +1077,7 @@ static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, LONG msec, VARI
|
||||
break;
|
||||
|
||||
case VT_BSTR:
|
||||
disp = script_parse_event(This->doc, V_BSTR(expr));
|
||||
disp = script_parse_event(This, V_BSTR(expr));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1088,7 +1088,7 @@ static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, LONG msec, VARI
|
||||
if(!disp)
|
||||
return E_FAIL;
|
||||
|
||||
*timer_id = set_task_timer(This->doc, msec, interval, disp);
|
||||
*timer_id = set_task_timer(&This->doc->basedoc, msec, interval, disp);
|
||||
IDispatch_Release(disp);
|
||||
|
||||
return S_OK;
|
||||
@ -1413,7 +1413,7 @@ static dispex_static_data_t HTMLWindow_dispex = {
|
||||
HTMLWindow_iface_tids
|
||||
};
|
||||
|
||||
HRESULT HTMLWindow_Create(nsIDOMWindow *nswindow, HTMLWindow **ret)
|
||||
HRESULT HTMLWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTMLWindow **ret)
|
||||
{
|
||||
HTMLWindow *window;
|
||||
|
||||
@ -1425,6 +1425,7 @@ HRESULT HTMLWindow_Create(nsIDOMWindow *nswindow, HTMLWindow **ret)
|
||||
window->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
|
||||
window->lpIDispatchExVtbl = &WindowDispExVtbl;
|
||||
window->ref = 1;
|
||||
window->doc_obj = doc_obj;
|
||||
|
||||
init_dispex(&window->dispex, (IUnknown*)HTMLWINDOW2(window), &HTMLWindow_dispex);
|
||||
|
||||
|
@ -154,6 +154,8 @@ BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
|
||||
HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
|
||||
|
||||
typedef struct HTMLWindow HTMLWindow;
|
||||
typedef struct HTMLDocumentNode HTMLDocumentNode;
|
||||
typedef struct HTMLDocumentObj HTMLDocumentObj;
|
||||
|
||||
typedef enum {
|
||||
SCRIPTMODE_GECKO,
|
||||
@ -193,7 +195,8 @@ struct HTMLWindow {
|
||||
|
||||
LONG ref;
|
||||
|
||||
HTMLDocument *doc;
|
||||
HTMLDocumentNode *doc;
|
||||
HTMLDocumentObj *doc_obj;
|
||||
nsIDOMWindow *nswindow;
|
||||
|
||||
event_target_t *event_target;
|
||||
@ -249,9 +252,6 @@ typedef struct {
|
||||
ULONG (*release)(HTMLDocument*);
|
||||
} htmldoc_vtbl_t;
|
||||
|
||||
typedef struct HTMLDocumentNode HTMLDocumentNode;
|
||||
typedef struct HTMLDocumentObj HTMLDocumentObj;
|
||||
|
||||
struct HTMLDocument {
|
||||
DispatchEx dispex;
|
||||
const htmldoc_vtbl_t *vtbl;
|
||||
@ -548,7 +548,7 @@ HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
|
||||
HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
|
||||
HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
|
||||
|
||||
HRESULT HTMLWindow_Create(nsIDOMWindow*,HTMLWindow**);
|
||||
HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow**);
|
||||
HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
|
||||
HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
|
||||
HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
|
||||
@ -678,7 +678,7 @@ void release_nodes(HTMLDocument*);
|
||||
void release_script_hosts(HTMLWindow*);
|
||||
void connect_scripts(HTMLWindow*);
|
||||
void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*);
|
||||
IDispatch *script_parse_event(HTMLDocument*,LPCWSTR);
|
||||
IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
|
||||
void set_script_mode(HTMLWindow*,SCRIPTMODE);
|
||||
BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
|
||||
IDispatch *get_script_disp(ScriptHost*);
|
||||
|
@ -844,6 +844,8 @@ void update_nsdocument(HTMLDocumentObj *doc)
|
||||
doc_node->basedoc.doc_obj = NULL;
|
||||
IHTMLDocument2_Release(HTMLDOC(&doc_node->basedoc));
|
||||
doc->basedoc.doc_node = NULL;
|
||||
|
||||
doc->basedoc.window->doc = NULL;
|
||||
}
|
||||
|
||||
doc->basedoc.nsdoc = nsdoc;
|
||||
@ -859,6 +861,7 @@ void update_nsdocument(HTMLDocumentObj *doc)
|
||||
}
|
||||
|
||||
doc->basedoc.doc_node = doc_node;
|
||||
doc->basedoc.window->doc = doc_node;
|
||||
}
|
||||
|
||||
void close_gecko(void)
|
||||
|
@ -246,7 +246,7 @@ void add_nsevent_listener(HTMLWindow *window, LPCWSTR type)
|
||||
return;
|
||||
}
|
||||
|
||||
init_event(target, type, NSEVENTLIST(&window->doc->nscontainer->htmlevent_listener), TRUE);
|
||||
init_event(target, type, NSEVENTLIST(&window->doc_obj->basedoc.nscontainer->htmlevent_listener), TRUE);
|
||||
nsIDOMEventTarget_Release(target);
|
||||
}
|
||||
|
||||
|
@ -593,7 +593,7 @@ static void parse_extern_script(ScriptHost *script_host, LPCWSTR src)
|
||||
if(FAILED(hres))
|
||||
return;
|
||||
|
||||
hres = bind_mon_to_buffer(script_host->window->doc, mon, (void**)&buf, &size);
|
||||
hres = bind_mon_to_buffer(&script_host->window->doc_obj->basedoc, mon, (void**)&buf, &size);
|
||||
IMoniker_Release(mon);
|
||||
if(FAILED(hres))
|
||||
return;
|
||||
@ -762,7 +762,7 @@ void doc_insert_script(HTMLDocument *doc, nsIDOMHTMLScriptElement *nsscript)
|
||||
parse_script_elem(script_host, nsscript);
|
||||
}
|
||||
|
||||
IDispatch *script_parse_event(HTMLDocument *doc, LPCWSTR text)
|
||||
IDispatch *script_parse_event(HTMLWindow *window, LPCWSTR text)
|
||||
{
|
||||
ScriptHost *script_host;
|
||||
GUID guid = CLSID_JScript;
|
||||
@ -795,7 +795,7 @@ IDispatch *script_parse_event(HTMLDocument *doc, LPCWSTR text)
|
||||
ptr = text;
|
||||
}
|
||||
|
||||
script_host = get_script_host(doc->window, &guid);
|
||||
script_host = get_script_host(window, &guid);
|
||||
if(!script_host || !script_host->parse_proc)
|
||||
return NULL;
|
||||
|
||||
@ -890,10 +890,10 @@ void set_script_mode(HTMLWindow *window, SCRIPTMODE mode)
|
||||
|
||||
window->scriptmode = mode;
|
||||
|
||||
if(!window->doc->nscontainer || !window->doc->nscontainer->webbrowser)
|
||||
if(!window->doc_obj->basedoc.nscontainer || !window->doc_obj->basedoc.nscontainer->webbrowser)
|
||||
return;
|
||||
|
||||
nsres = nsIWebBrowser_QueryInterface(window->doc->nscontainer->webbrowser,
|
||||
nsres = nsIWebBrowser_QueryInterface(window->doc_obj->basedoc.nscontainer->webbrowser,
|
||||
&IID_nsIWebBrowserSetup, (void**)&setup);
|
||||
if(NS_SUCCEEDED(nsres)) {
|
||||
nsres = nsIWebBrowserSetup_SetProperty(setup, SETUP_ALLOW_JAVASCRIPT,
|
||||
|
Loading…
Reference in New Issue
Block a user