mshtml: Moved document node from HTMLOuterWindow to HTMLInnerWindow.

This commit is contained in:
Jacek Caban 2012-06-25 14:05:17 +02:00 committed by Alexandre Julliard
parent 08964ede45
commit 79356c65c1
15 changed files with 151 additions and 100 deletions

View file

@ -1568,7 +1568,7 @@ static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface); HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
if(This->window) if(This->window)
update_cp_events(This->window, &This->doc_node->node.event_target, cp, This->doc_node->node.nsnode); update_cp_events(This->window->base.inner_window, &This->doc_node->node.event_target, cp, This->doc_node->node.nsnode);
} }
static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface) static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
@ -2448,7 +2448,6 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow); nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
ERR("GetContentDOMWindow failed: %08x\n", nsres); ERR("GetContentDOMWindow failed: %08x\n", nsres);
@ -2461,8 +2460,8 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
return hres; return hres;
} }
if(!doc->basedoc.doc_node && doc->basedoc.window->doc) { if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
doc->basedoc.doc_node = doc->basedoc.window->doc; doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
htmldoc_addref(&doc->basedoc.doc_node->basedoc); htmldoc_addref(&doc->basedoc.doc_node->basedoc);
} }

View file

@ -1348,7 +1348,7 @@ HRESULT detach_event(event_target_t *event_target, HTMLDocument *doc, BSTR name,
return S_OK; return S_OK;
} }
void update_cp_events(HTMLOuterWindow *window, event_target_t **event_target_ptr, cp_static_data_t *cp, nsIDOMNode *nsnode) void update_cp_events(HTMLInnerWindow *window, event_target_t **event_target_ptr, cp_static_data_t *cp, nsIDOMNode *nsnode)
{ {
event_target_t *event_target; event_target_t *event_target;
int i; int i;

View file

@ -54,7 +54,7 @@ HRESULT attach_event(event_target_t**,nsIDOMNode*,HTMLDocument*,BSTR,IDispatch*,
HRESULT detach_event(event_target_t*,HTMLDocument*,BSTR,IDispatch*) DECLSPEC_HIDDEN; HRESULT detach_event(event_target_t*,HTMLDocument*,BSTR,IDispatch*) DECLSPEC_HIDDEN;
HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*) DECLSPEC_HIDDEN; HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*) DECLSPEC_HIDDEN;
HRESULT call_fire_event(HTMLDOMNode*,eventid_t) DECLSPEC_HIDDEN; HRESULT call_fire_event(HTMLDOMNode*,eventid_t) DECLSPEC_HIDDEN;
void update_cp_events(HTMLOuterWindow*,event_target_t**,cp_static_data_t*,nsIDOMNode*) DECLSPEC_HIDDEN; void update_cp_events(HTMLInnerWindow*,event_target_t**,cp_static_data_t*,nsIDOMNode*) DECLSPEC_HIDDEN;
HRESULT doc_init_events(HTMLDocumentNode*) DECLSPEC_HIDDEN; HRESULT doc_init_events(HTMLDocumentNode*) DECLSPEC_HIDDEN;
void detach_events(HTMLDocumentNode *doc) DECLSPEC_HIDDEN; void detach_events(HTMLDocumentNode *doc) DECLSPEC_HIDDEN;

View file

@ -206,12 +206,12 @@ static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
{ {
HTMLFrameElement *This = impl_from_HTMLDOMNode(iface); HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
if(!This->framebase.content_window || !This->framebase.content_window->doc) { if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
*p = NULL; *p = NULL;
return S_OK; return S_OK;
} }
*p = (IDispatch*)&This->framebase.content_window->doc->basedoc.IHTMLDocument2_iface; *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface;
IDispatch_AddRef(*p); IDispatch_AddRef(*p);
return S_OK; return S_OK;
} }

View file

@ -461,12 +461,12 @@ static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
if(!This->content_window || !This->content_window->doc) { if(!This->content_window || !This->content_window->base.inner_window->doc) {
FIXME("no document associated\n"); FIXME("no document associated\n");
return E_FAIL; return E_FAIL;
} }
return IHTMLDocument2_get_readyState(&This->content_window->doc->basedoc.IHTMLDocument2_iface, p); return IHTMLDocument2_get_readyState(&This->content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface, p);
} }
static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v) static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)

View file

@ -184,12 +184,12 @@ static HRESULT HTMLIFrame_get_document(HTMLDOMNode *iface, IDispatch **p)
{ {
HTMLIFrame *This = impl_from_HTMLDOMNode(iface); HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
if(!This->framebase.content_window || !This->framebase.content_window->doc) { if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
*p = NULL; *p = NULL;
return S_OK; return S_OK;
} }
*p = (IDispatch*)&This->framebase.content_window->doc->basedoc.IHTMLDocument2_iface; *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface;
IDispatch_AddRef(*p); IDispatch_AddRef(*p);
return S_OK; return S_OK;
} }

View file

@ -807,6 +807,7 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i
VARIANT width, VARIANT height, IHTMLImgElement **img_elem) VARIANT width, VARIANT height, IHTMLImgElement **img_elem)
{ {
HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
HTMLDocumentNode *doc;
IHTMLImgElement *img; IHTMLImgElement *img;
HTMLElement *elem; HTMLElement *elem;
nsIDOMHTMLElement *nselem; nsIDOMHTMLElement *nselem;
@ -818,18 +819,20 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i
TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&width), TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&width),
debugstr_variant(&height), img_elem); debugstr_variant(&height), img_elem);
if(!This->window || !This->window->doc) { if(!This->window || !This->window->base.inner_window->doc) {
WARN("NULL doc\n"); WARN("NULL doc\n");
return E_UNEXPECTED; return E_UNEXPECTED;
} }
doc = This->window->base.inner_window->doc;
*img_elem = NULL; *img_elem = NULL;
hres = create_nselem(This->window->doc, imgW, &nselem); hres = create_nselem(doc, imgW, &nselem);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = HTMLElement_Create(This->window->doc, (nsIDOMNode*)nselem, FALSE, &elem); hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, FALSE, &elem);
nsIDOMHTMLElement_Release(nselem); nsIDOMHTMLElement_Release(nselem);
if(FAILED(hres)) { if(FAILED(hres)) {
ERR("HTMLElement_Create failed\n"); ERR("HTMLElement_Create failed\n");

View file

@ -468,18 +468,18 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_variant(&text), debugstr_variant(&value), TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_variant(&text), debugstr_variant(&value),
debugstr_variant(&defaultselected), debugstr_variant(&selected), optelem); debugstr_variant(&defaultselected), debugstr_variant(&selected), optelem);
if(!This->window || !This->window->doc) { if(!This->window || !This->window->base.inner_window->doc) {
WARN("NULL doc\n"); WARN("NULL doc\n");
return E_UNEXPECTED; return E_UNEXPECTED;
} }
*optelem = NULL; *optelem = NULL;
hres = create_nselem(This->window->doc, optionW, &nselem); hres = create_nselem(This->window->base.inner_window->doc, optionW, &nselem);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = get_node(This->window->doc, (nsIDOMNode*)nselem, TRUE, &node); hres = get_node(This->window->base.inner_window->doc, (nsIDOMNode*)nselem, TRUE, &node);
nsIDOMHTMLElement_Release(nselem); nsIDOMHTMLElement_Release(nselem);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View file

@ -43,48 +43,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
static struct list window_list = LIST_INIT(window_list); static struct list window_list = LIST_INIT(window_list);
static HRESULT window_set_docnode(HTMLOuterWindow*,HTMLDocumentNode*);
static inline BOOL is_outer_window(HTMLWindow *window) static inline BOOL is_outer_window(HTMLWindow *window)
{ {
return &window->outer_window->base == window; return &window->outer_window->base == window;
} }
static void window_set_docnode(HTMLOuterWindow *window, HTMLDocumentNode *doc_node)
{
if(window->doc) {
if(window->doc_obj && window == window->doc_obj->basedoc.window)
window->doc->basedoc.cp_container.forward_container = NULL;
detach_events(window->doc);
abort_document_bindings(window->doc);
release_script_hosts(window);
window->doc->basedoc.window = NULL;
htmldoc_release(&window->doc->basedoc);
}
window->doc = doc_node;
if(doc_node)
htmldoc_addref(&doc_node->basedoc);
if(window->doc_obj && window->doc_obj->basedoc.window == window) {
if(window->doc_obj->basedoc.doc_node)
htmldoc_release(&window->doc_obj->basedoc.doc_node->basedoc);
window->doc_obj->basedoc.doc_node = doc_node;
if(doc_node)
htmldoc_addref(&doc_node->basedoc);
}
if(doc_node && window->doc_obj && window->doc_obj->usermode == EDITMODE) {
nsAString mode_str;
nsresult nsres;
static const PRUnichar onW[] = {'o','n',0};
nsAString_Init(&mode_str, onW);
nsres = nsIDOMHTMLDocument_SetDesignMode(doc_node->nsdoc, &mode_str);
nsAString_Finish(&mode_str);
if(NS_FAILED(nsres))
ERR("SetDesignMode failed: %08x\n", nsres);
}
}
static void release_children(HTMLOuterWindow *This) static void release_children(HTMLOuterWindow *This)
{ {
HTMLOuterWindow *child; HTMLOuterWindow *child;
@ -124,22 +89,22 @@ void get_top_window(HTMLOuterWindow *window, HTMLOuterWindow **ret)
static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var) static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
{ {
if(!window->outer_window->doc) { if(!window->inner_window->doc) {
FIXME("No document\n"); FIXME("No document\n");
return E_FAIL; return E_FAIL;
} }
return set_event_handler(&window->outer_window->doc->body_event_target, NULL, window->outer_window->doc, eid, var); return set_event_handler(&window->inner_window->doc->body_event_target, NULL, window->inner_window->doc, eid, var);
} }
static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var) static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
{ {
if(!window->outer_window->doc) { if(!window->inner_window->doc) {
FIXME("No document\n"); FIXME("No document\n");
return E_FAIL; return E_FAIL;
} }
return get_event_handler(&window->outer_window->doc->body_event_target, eid, var); return get_event_handler(&window->inner_window->doc->body_event_target, eid, var);
} }
static inline HTMLWindow *impl_from_IHTMLWindow2(IHTMLWindow2 *iface) static inline HTMLWindow *impl_from_IHTMLWindow2(IHTMLWindow2 *iface)
@ -266,6 +231,7 @@ static void release_outer_window(HTMLOuterWindow *This)
static void release_inner_window(HTMLInnerWindow *This) static void release_inner_window(HTMLInnerWindow *This)
{ {
htmldoc_release(&This->doc->basedoc);
heap_free(This); heap_free(This);
} }
@ -529,7 +495,7 @@ static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID
TRACE("(%p)->(%d)\n", This, timerID); TRACE("(%p)->(%d)\n", This, timerID);
return clear_task_timer(&This->outer_window->doc->basedoc, FALSE, timerID); return clear_task_timer(&This->inner_window->doc->basedoc, FALSE, timerID);
} }
#define MAX_MESSAGE_LEN 2000 #define MAX_MESSAGE_LEN 2000
@ -1046,9 +1012,9 @@ static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocumen
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
if(This->outer_window->doc) { if(This->inner_window->doc) {
/* FIXME: We should return a wrapper object here */ /* FIXME: We should return a wrapper object here */
*p = &This->outer_window->doc->basedoc.IHTMLDocument2_iface; *p = &This->inner_window->doc->basedoc.IHTMLDocument2_iface;
IHTMLDocument2_AddRef(*p); IHTMLDocument2_AddRef(*p);
}else { }else {
*p = NULL; *p = NULL;
@ -1187,7 +1153,7 @@ static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerI
TRACE("(%p)->(%d)\n", This, timerID); TRACE("(%p)->(%d)\n", This, timerID);
return clear_task_timer(&This->outer_window->doc->basedoc, TRUE, timerID); return clear_task_timer(&This->inner_window->doc->basedoc, TRUE, timerID);
} }
static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v) static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
@ -1457,7 +1423,7 @@ static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult) static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
{ {
HTMLWindow *This = impl_from_IHTMLWindow3(iface); HTMLWindow *This = impl_from_IHTMLWindow3(iface);
HTMLOuterWindow *window = This->outer_window; HTMLInnerWindow *window = This->inner_window;
TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult); TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
@ -1472,7 +1438,7 @@ static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, I
static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp) static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
{ {
HTMLWindow *This = impl_from_IHTMLWindow3(iface); HTMLWindow *This = impl_from_IHTMLWindow3(iface);
HTMLOuterWindow *window = This->outer_window; HTMLInnerWindow *window = This->inner_window;
TRACE("(%p)->()\n", This); TRACE("(%p)->()\n", This);
@ -1484,7 +1450,7 @@ static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, I
return detach_event(window->doc->body_event_target, &window->doc->basedoc, event, pDisp); return detach_event(window->doc->body_event_target, &window->doc->basedoc, event, pDisp);
} }
static HRESULT window_set_timer(HTMLOuterWindow *This, VARIANT *expr, LONG msec, VARIANT *language, static HRESULT window_set_timer(HTMLInnerWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
BOOL interval, LONG *timer_id) BOOL interval, LONG *timer_id)
{ {
IDispatch *disp = NULL; IDispatch *disp = NULL;
@ -1496,7 +1462,7 @@ static HRESULT window_set_timer(HTMLOuterWindow *This, VARIANT *expr, LONG msec,
break; break;
case VT_BSTR: case VT_BSTR:
disp = script_parse_event(This, V_BSTR(expr)); disp = script_parse_event(This->base.outer_window, V_BSTR(expr));
break; break;
default: default:
@ -1520,7 +1486,7 @@ static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expre
TRACE("(%p)->(%s %d %s %p)\n", This, debugstr_variant(expression), msec, debugstr_variant(language), timerID); TRACE("(%p)->(%s %d %s %p)\n", This, debugstr_variant(expression), msec, debugstr_variant(language), timerID);
return window_set_timer(This->outer_window, expression, msec, language, FALSE, timerID); return window_set_timer(This->inner_window, expression, msec, language, FALSE, timerID);
} }
static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec, static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
@ -1530,7 +1496,7 @@ static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expr
TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID); TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
return window_set_timer(This->outer_window, expression, msec, language, TRUE, timerID); return window_set_timer(This->inner_window, expression, msec, language, TRUE, timerID);
} }
static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface) static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
@ -2299,11 +2265,11 @@ static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName,
if(hres != DISP_E_UNKNOWNNAME) if(hres != DISP_E_UNKNOWNNAME)
return hres; return hres;
if(window->doc) { if(window->base.inner_window->doc) {
global_prop_t *prop; global_prop_t *prop;
IHTMLElement *elem; IHTMLElement *elem;
hres = IHTMLDocument3_getElementById(&window->doc->basedoc.IHTMLDocument3_iface, hres = IHTMLDocument3_getElementById(&window->base.inner_window->doc->basedoc.IHTMLDocument3_iface,
bstrName, &elem); bstrName, &elem);
if(SUCCEEDED(hres) && elem) { if(SUCCEEDED(hres) && elem) {
IHTMLElement_Release(elem); IHTMLElement_Release(elem);
@ -2518,7 +2484,7 @@ static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD
case DISPATCH_PROPERTYGET: { case DISPATCH_PROPERTYGET: {
IHTMLElement *elem; IHTMLElement *elem;
hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface, hres = IHTMLDocument3_getElementById(&This->base.inner_window->doc->basedoc.IHTMLDocument3_iface,
prop->name, &elem); prop->name, &elem);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -2600,7 +2566,26 @@ static void *alloc_window(size_t size)
return window; return window;
} }
HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTMLOuterWindow *parent, HTMLOuterWindow **ret) static HRESULT create_inner_window(HTMLOuterWindow *outer_window, HTMLDocumentNode *doc_node, HTMLInnerWindow **ret)
{
HTMLInnerWindow *window;
window = alloc_window(sizeof(HTMLInnerWindow));
if(!window)
return E_OUTOFMEMORY;
window->base.outer_window = outer_window;
window->base.inner_window = window;
htmldoc_addref(&doc_node->basedoc);
window->doc = doc_node;
*ret = window;
return S_OK;
}
HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
HTMLOuterWindow *parent, HTMLOuterWindow **ret)
{ {
HTMLOuterWindow *window; HTMLOuterWindow *window;
HRESULT hres; HRESULT hres;
@ -2634,6 +2619,12 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
window->readystate = READYSTATE_UNINITIALIZED; window->readystate = READYSTATE_UNINITIALIZED;
list_init(&window->script_hosts); list_init(&window->script_hosts);
hres = update_window_doc(window);
if(FAILED(hres)) {
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
return hres;
}
hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0); hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
if(FAILED(hres)) { if(FAILED(hres)) {
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface); IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
@ -2641,7 +2632,6 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
} }
window->task_magic = get_task_target_magic(); window->task_magic = get_task_target_magic();
update_window_doc(window);
list_init(&window->children); list_init(&window->children);
list_add_head(&window_list, &window->entry); list_add_head(&window_list, &window->entry);
@ -2657,39 +2647,97 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
return S_OK; return S_OK;
} }
void update_window_doc(HTMLOuterWindow *window) static HRESULT window_set_docnode(HTMLOuterWindow *window, HTMLDocumentNode *doc_node)
{
HTMLInnerWindow *inner_window;
HRESULT hres;
if(window->base.inner_window) {
if(window->doc_obj && window == window->doc_obj->basedoc.window)
window->base.inner_window->doc->basedoc.cp_container.forward_container = NULL;
detach_events(window->base.inner_window->doc);
abort_document_bindings(window->base.inner_window->doc);
release_script_hosts(window);
}
if(doc_node) {
hres = create_inner_window(window, doc_node, &inner_window);
if(FAILED(hres))
return hres;
}else {
inner_window = NULL;
}
if(window->base.inner_window) {
window->base.inner_window->doc->basedoc.window = NULL;
window->base.inner_window->base.outer_window = NULL;
IHTMLWindow2_Release(&window->base.inner_window->base.IHTMLWindow2_iface);
}
window->base.inner_window = inner_window;
if(!doc_node)
return S_OK;
if(window->doc_obj && window->doc_obj->basedoc.window == window) {
if(window->doc_obj->basedoc.doc_node)
htmldoc_release(&window->doc_obj->basedoc.doc_node->basedoc);
window->doc_obj->basedoc.doc_node = doc_node;
if(doc_node)
htmldoc_addref(&doc_node->basedoc);
}
if(doc_node && window->doc_obj && window->doc_obj->usermode == EDITMODE) {
nsAString mode_str;
nsresult nsres;
static const PRUnichar onW[] = {'o','n',0};
nsAString_Init(&mode_str, onW);
nsres = nsIDOMHTMLDocument_SetDesignMode(doc_node->nsdoc, &mode_str);
nsAString_Finish(&mode_str);
if(NS_FAILED(nsres))
ERR("SetDesignMode failed: %08x\n", nsres);
}
return S_OK;
}
HRESULT update_window_doc(HTMLOuterWindow *window)
{ {
nsIDOMHTMLDocument *nshtmldoc; nsIDOMHTMLDocument *nshtmldoc;
nsIDOMDocument *nsdoc; nsIDOMDocument *nsdoc;
nsresult nsres; nsresult nsres;
HRESULT hres;
nsres = nsIDOMWindow_GetDocument(window->nswindow, &nsdoc); nsres = nsIDOMWindow_GetDocument(window->nswindow, &nsdoc);
if(NS_FAILED(nsres) || !nsdoc) { if(NS_FAILED(nsres) || !nsdoc) {
ERR("GetDocument failed: %08x\n", nsres); ERR("GetDocument failed: %08x\n", nsres);
return; return E_FAIL;
} }
nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc); nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
nsIDOMDocument_Release(nsdoc); nsIDOMDocument_Release(nsdoc);
if(NS_FAILED(nsres)) { if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres); ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
return; return E_FAIL;
} }
if(!window->doc || window->doc->nsdoc != nshtmldoc) { if(!window->base.inner_window || window->base.inner_window->doc->nsdoc != nshtmldoc) {
HTMLDocumentNode *doc; HTMLDocumentNode *doc;
HRESULT hres;
hres = create_doc_from_nsdoc(nshtmldoc, window->doc_obj, window, &doc); hres = create_doc_from_nsdoc(nshtmldoc, window->doc_obj, window, &doc);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
window_set_docnode(window, doc); hres = window_set_docnode(window, doc);
htmldoc_release(&doc->basedoc); htmldoc_release(&doc->basedoc);
}else { }else {
ERR("create_doc_from_nsdoc failed: %08x\n", hres); ERR("create_doc_from_nsdoc failed: %08x\n", hres);
} }
}else {
hres = S_OK;
} }
nsIDOMHTMLDocument_Release(nshtmldoc); nsIDOMHTMLDocument_Release(nshtmldoc);
return hres;
} }
HTMLOuterWindow *nswindow_to_window(const nsIDOMWindow *nswindow) HTMLOuterWindow *nswindow_to_window(const nsIDOMWindow *nswindow)

View file

@ -321,7 +321,6 @@ struct HTMLOuterWindow {
windowref_t *window_ref; windowref_t *window_ref;
LONG task_magic; LONG task_magic;
HTMLDocumentNode *doc;
HTMLDocumentObj *doc_obj; HTMLDocumentObj *doc_obj;
nsIDOMWindow *nswindow; nsIDOMWindow *nswindow;
HTMLOuterWindow *parent; HTMLOuterWindow *parent;
@ -357,6 +356,8 @@ struct HTMLOuterWindow {
struct HTMLInnerWindow { struct HTMLInnerWindow {
HTMLWindow base; HTMLWindow base;
HTMLDocumentNode *doc;
}; };
typedef enum { typedef enum {
@ -656,7 +657,7 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLOuterWind
HRESULT create_document_fragment(nsIDOMNode*,HTMLDocumentNode*,HTMLDocumentNode**) DECLSPEC_HIDDEN; HRESULT create_document_fragment(nsIDOMNode*,HTMLDocumentNode*,HTMLDocumentNode**) DECLSPEC_HIDDEN;
HRESULT HTMLOuterWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLOuterWindow*,HTMLOuterWindow**) DECLSPEC_HIDDEN; HRESULT HTMLOuterWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLOuterWindow*,HTMLOuterWindow**) DECLSPEC_HIDDEN;
void update_window_doc(HTMLOuterWindow*) DECLSPEC_HIDDEN; HRESULT update_window_doc(HTMLOuterWindow*) DECLSPEC_HIDDEN;
HTMLOuterWindow *nswindow_to_window(const nsIDOMWindow*) DECLSPEC_HIDDEN; HTMLOuterWindow *nswindow_to_window(const nsIDOMWindow*) DECLSPEC_HIDDEN;
void get_top_window(HTMLOuterWindow*,HTMLOuterWindow**) DECLSPEC_HIDDEN; void get_top_window(HTMLOuterWindow*,HTMLOuterWindow**) DECLSPEC_HIDDEN;
HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLOuterWindow*) DECLSPEC_HIDDEN; HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLOuterWindow*) DECLSPEC_HIDDEN;

View file

@ -726,7 +726,7 @@ HRESULT start_binding(HTMLOuterWindow *window, HTMLDocumentNode *doc, BSCallback
bscallback->doc = doc; bscallback->doc = doc;
if(!doc && window) if(!doc && window)
bscallback->doc = window->doc; bscallback->doc = window->base.inner_window->doc;
/* NOTE: IE7 calls IsSystemMoniker here*/ /* NOTE: IE7 calls IsSystemMoniker here*/
@ -998,10 +998,10 @@ static HRESULT on_start_nsrequest(nsChannelBSC *This)
list_remove(&This->bsc.entry); list_remove(&This->bsc.entry);
list_init(&This->bsc.entry); list_init(&This->bsc.entry);
update_window_doc(This->window); update_window_doc(This->window);
if(This->window->doc != This->bsc.doc) { if(This->window->base.inner_window->doc != This->bsc.doc) {
if(This->bsc.doc) if(This->bsc.doc)
list_remove(&This->bsc.entry); list_remove(&This->bsc.entry);
This->bsc.doc = This->window->doc; This->bsc.doc = This->window->base.inner_window->doc;
} }
list_add_head(&This->bsc.doc->bindings, &This->bsc.entry); list_add_head(&This->bsc.doc->bindings, &This->bsc.entry);
if(This->window->readystate != READYSTATE_LOADING) if(This->window->readystate != READYSTATE_LOADING)
@ -1276,7 +1276,7 @@ static HRESULT nsChannelBSC_start_binding(BSCallback *bsc)
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc); nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
if(This->window) if(This->window)
This->window->doc->skip_mutation_notif = FALSE; This->window->base.inner_window->doc->skip_mutation_notif = FALSE;
return S_OK; return S_OK;
} }
@ -1668,7 +1668,7 @@ void set_window_bscallback(HTMLOuterWindow *window, nsChannelBSC *callback)
if(callback) { if(callback) {
callback->window = window; callback->window = window;
IBindStatusCallback_AddRef(&callback->bsc.IBindStatusCallback_iface); IBindStatusCallback_AddRef(&callback->bsc.IBindStatusCallback_iface);
callback->bsc.doc = window->doc; callback->bsc.doc = window->base.inner_window->doc;
} }
} }
@ -2150,7 +2150,7 @@ HRESULT navigate_url(HTMLOuterWindow *window, const WCHAR *new_url, const WCHAR
if(window->doc_obj && window == window->doc_obj->basedoc.window) { if(window->doc_obj && window == window->doc_obj->basedoc.window) {
BOOL cancel; BOOL cancel;
hres = hlink_frame_navigate(&window->doc->basedoc, url, NULL, 0, &cancel); hres = hlink_frame_navigate(&window->base.inner_window->doc->basedoc, url, NULL, 0, &cancel);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View file

@ -234,7 +234,7 @@ static nsIDOMElement *get_dom_element(NPP instance)
return elem; return elem;
} }
static HTMLOuterWindow *get_elem_window(nsIDOMElement *elem) static HTMLInnerWindow *get_elem_window(nsIDOMElement *elem)
{ {
nsIDOMWindow *nswindow; nsIDOMWindow *nswindow;
nsIDOMDocument *nsdoc; nsIDOMDocument *nsdoc;
@ -253,7 +253,7 @@ static HTMLOuterWindow *get_elem_window(nsIDOMElement *elem)
window = nswindow_to_window(nswindow); window = nswindow_to_window(nswindow);
nsIDOMWindow_Release(nswindow); nsIDOMWindow_Release(nswindow);
return window; return window->base.inner_window;
} }
static BOOL parse_classid(const PRUnichar *classid, CLSID *clsid) static BOOL parse_classid(const PRUnichar *classid, CLSID *clsid)
@ -313,7 +313,7 @@ static BOOL get_elem_clsid(nsIDOMElement *elem, CLSID *clsid)
return ret; return ret;
} }
static IUnknown *create_activex_object(HTMLOuterWindow *window, nsIDOMElement *nselem, CLSID *clsid) static IUnknown *create_activex_object(HTMLInnerWindow *window, nsIDOMElement *nselem, CLSID *clsid)
{ {
IClassFactoryEx *cfex; IClassFactoryEx *cfex;
IClassFactory *cf; IClassFactory *cf;
@ -357,7 +357,7 @@ static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, I
char **argv, NPSavedData *saved) char **argv, NPSavedData *saved)
{ {
nsIDOMElement *nselem; nsIDOMElement *nselem;
HTMLOuterWindow *window; HTMLInnerWindow *window;
IUnknown *obj; IUnknown *obj;
CLSID clsid; CLSID clsid;
NPError err = NPERR_NO_ERROR; NPError err = NPERR_NO_ERROR;

View file

@ -285,10 +285,10 @@ HRESULT load_nsuri(HTMLOuterWindow *window, nsWineURI *uri, nsChannelBSC *channe
} }
uri->channel_bsc = channelbsc; uri->channel_bsc = channelbsc;
doc = window->doc; doc = window->base.inner_window->doc;
doc->skip_mutation_notif = TRUE; doc->skip_mutation_notif = TRUE;
nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)&uri->nsIURL_iface, NULL, flags, FALSE); nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)&uri->nsIURL_iface, NULL, flags, FALSE);
if(doc == window->doc) if(doc == window->base.inner_window->doc)
doc->skip_mutation_notif = FALSE; doc->skip_mutation_notif = FALSE;
uri->channel_bsc = NULL; uri->channel_bsc = NULL;
nsIDocShell_Release(doc_shell); nsIDocShell_Release(doc_shell);
@ -1022,9 +1022,9 @@ static nsresult async_open(nsChannel *This, HTMLOuterWindow *window, BOOL is_doc
}else { }else {
start_binding_task_t *task = heap_alloc(sizeof(start_binding_task_t)); start_binding_task_t *task = heap_alloc(sizeof(start_binding_task_t));
task->doc = window->doc; task->doc = window->base.inner_window->doc;
task->bscallback = bscallback; task->bscallback = bscallback;
push_task(&task->header, start_binding_proc, start_binding_task_destr, window->doc->basedoc.task_magic); push_task(&task->header, start_binding_proc, start_binding_task_destr, window->base.inner_window->doc->basedoc.task_magic);
} }
return NS_OK; return NS_OK;

View file

@ -406,7 +406,7 @@ void set_ready_state(HTMLOuterWindow *window, READYSTATE readystate)
if(window->doc_obj && window->doc_obj->basedoc.window == window) if(window->doc_obj && window->doc_obj->basedoc.window == window)
call_property_onchanged(&window->doc_obj->basedoc.cp_propnotif, DISPID_READYSTATE); call_property_onchanged(&window->doc_obj->basedoc.cp_propnotif, DISPID_READYSTATE);
fire_event(window->doc, EVENTID_READYSTATECHANGE, FALSE, window->doc->node.nsnode, NULL); fire_event(window->base.inner_window->doc, EVENTID_READYSTATECHANGE, FALSE, window->base.inner_window->doc->node.nsnode, NULL);
if(window->frame_element) if(window->frame_element)
fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE, fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE,

View file

@ -573,10 +573,10 @@ static HRESULT WINAPI ASServiceProvider_QueryService(IServiceProvider *iface, RE
if(IsEqualGUID(&SID_SInternetHostSecurityManager, guidService)) { if(IsEqualGUID(&SID_SInternetHostSecurityManager, guidService)) {
TRACE("(%p)->(SID_SInternetHostSecurityManager)\n", This); TRACE("(%p)->(SID_SInternetHostSecurityManager)\n", This);
if(!This->window || !This->window->doc) if(!This->window || !This->window->base.inner_window->doc)
return E_NOINTERFACE; return E_NOINTERFACE;
return IInternetHostSecurityManager_QueryInterface(&This->window->doc->IInternetHostSecurityManager_iface, return IInternetHostSecurityManager_QueryInterface(&This->window->base.inner_window->doc->IInternetHostSecurityManager_iface,
riid, ppv); riid, ppv);
} }
@ -659,7 +659,7 @@ static void parse_extern_script(ScriptHost *script_host, LPCWSTR src)
if(FAILED(hres)) if(FAILED(hres))
return; return;
hres = bind_mon_to_buffer(script_host->window->doc, mon, (void**)&buf, &size); hres = bind_mon_to_buffer(script_host->window->base.inner_window->doc, mon, (void**)&buf, &size);
IMoniker_Release(mon); IMoniker_Release(mon);
if(FAILED(hres)) if(FAILED(hres))
return; return;