From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlframe.c | 52 +++++++++++++++++++--------------------- dlls/mshtml/htmlwindow.c | 5 +++- 2 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/dlls/mshtml/htmlframe.c b/dlls/mshtml/htmlframe.c index 5dab4e44bc5..94b737126be 100644 --- a/dlls/mshtml/htmlframe.c +++ b/dlls/mshtml/htmlframe.c @@ -48,20 +48,19 @@ static HRESULT set_frame_doc(HTMLFrameBase *frame, nsIDOMDocument *nsdoc) return E_FAIL;
window = mozwindow_to_window(mozwindow); - if(!window && frame->element.node.doc->browser) { + if(window) + IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface); + else if(frame->element.node.doc->browser) hres = create_outer_window(frame->element.node.doc->browser, mozwindow, frame->element.node.doc->outer_window, &window);
- /* Don't hold ref to the created window; the parent keeps ref to it */ - if(SUCCEEDED(hres)) - IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface); - } mozIDOMWindowProxy_Release(mozwindow); if(FAILED(hres)) return hres;
frame->content_window = window; window->frame_element = frame; + IHTMLDOMNode_AddRef(&frame->element.node.IHTMLDOMNode_iface); return S_OK; }
@@ -710,12 +709,23 @@ static void *HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid) return HTMLElement_query_interface(&This->element.node.event_target.dispex, riid); }
-static void HTMLFrameBase_destructor(HTMLFrameBase *This) +static void HTMLFrameBase_traverse(HTMLFrameBase *This, nsCycleCollectionTraversalCallback *cb) { + HTMLDOMNode_traverse(&This->element.node.event_target.dispex, cb); + if(This->content_window) - This->content_window->frame_element = NULL; + note_cc_edge((nsISupports*)&This->content_window->base.IHTMLWindow2_iface, "content_window", cb); +} + +static void HTMLFrameBase_unlink(HTMLFrameBase *This) +{ + HTMLDOMNode_unlink(&This->element.node.event_target.dispex);
- HTMLElement_destructor(&This->element.node.event_target.dispex); + if(This->content_window) { + HTMLOuterWindow *content_window = This->content_window; + This->content_window = NULL; + IHTMLWindow2_Release(&content_window->base.IHTMLWindow2_iface); + } }
static void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMElement *nselem, @@ -944,7 +954,7 @@ static void *HTMLFrameElement_query_interface(DispatchEx *dispex, REFIID riid) static void HTMLFrameElement_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb) { HTMLFrameElement *This = frame_from_DispatchEx(dispex); - HTMLDOMNode_traverse(dispex, cb); + HTMLFrameBase_traverse(&This->framebase, cb);
if(This->framebase.nsframe) note_cc_edge((nsISupports*)This->framebase.nsframe, "nsframe", cb); @@ -953,17 +963,10 @@ static void HTMLFrameElement_traverse(DispatchEx *dispex, nsCycleCollectionTrave static void HTMLFrameElement_unlink(DispatchEx *dispex) { HTMLFrameElement *This = frame_from_DispatchEx(dispex); - HTMLDOMNode_unlink(dispex); + HTMLFrameBase_unlink(&This->framebase); unlink_ref(&This->framebase.nsframe); }
-static void HTMLFrameElement_destructor(DispatchEx *dispex) -{ - HTMLFrameElement *This = frame_from_DispatchEx(dispex); - - HTMLFrameBase_destructor(&This->framebase); -} - static HRESULT HTMLFrameElement_get_dispid(DispatchEx *dispex, BSTR name, DWORD grfdex, DISPID *dispid) { HTMLFrameElement *This = frame_from_DispatchEx(dispex); @@ -1015,7 +1018,7 @@ static const event_target_vtbl_t HTMLFrameElement_event_target_vtbl = { { HTMLELEMENT_DISPEX_VTBL_ENTRIES, .query_interface= HTMLFrameElement_query_interface, - .destructor = HTMLFrameElement_destructor, + .destructor = HTMLElement_destructor, .traverse = HTMLFrameElement_traverse, .unlink = HTMLFrameElement_unlink, .get_dispid = HTMLFrameElement_get_dispid, @@ -1534,7 +1537,7 @@ static void *HTMLIFrame_query_interface(DispatchEx *dispex, REFIID riid) static void HTMLIFrame_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb) { HTMLIFrame *This = iframe_from_DispatchEx(dispex); - HTMLDOMNode_traverse(dispex, cb); + HTMLFrameBase_traverse(&This->framebase, cb);
if(This->framebase.nsiframe) note_cc_edge((nsISupports*)This->framebase.nsiframe, "nsiframe", cb); @@ -1543,17 +1546,10 @@ static void HTMLIFrame_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCa static void HTMLIFrame_unlink(DispatchEx *dispex) { HTMLIFrame *This = iframe_from_DispatchEx(dispex); - HTMLDOMNode_unlink(dispex); + HTMLFrameBase_unlink(&This->framebase); unlink_ref(&This->framebase.nsiframe); }
-static void HTMLIFrame_destructor(DispatchEx *dispex) -{ - HTMLIFrame *This = iframe_from_DispatchEx(dispex); - - HTMLFrameBase_destructor(&This->framebase); -} - static HRESULT HTMLIFrame_get_dispid(DispatchEx *dispex, BSTR name, DWORD grfdex, DISPID *dispid) { HTMLIFrame *This = iframe_from_DispatchEx(dispex); @@ -1605,7 +1601,7 @@ static const event_target_vtbl_t HTMLIFrame_event_target_vtbl = { { HTMLELEMENT_DISPEX_VTBL_ENTRIES, .query_interface= HTMLIFrame_query_interface, - .destructor = HTMLIFrame_destructor, + .destructor = HTMLElement_destructor, .traverse = HTMLIFrame_traverse, .unlink = HTMLIFrame_unlink, .get_dispid = HTMLIFrame_get_dispid, diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 4afa434ad27..9222a349749 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -4336,6 +4336,8 @@ static nsresult NSAPI outer_window_traverse(void *ccp, void *p, nsCycleCollectio note_cc_edge((nsISupports*)&window->parent->base.IHTMLWindow2_iface, "parent", cb); if(window->location) note_cc_edge((nsISupports*)&window->location->IHTMLLocation_iface, "location", cb); + if(window->frame_element) + note_cc_edge((nsISupports*)&window->frame_element->element.node.IHTMLDOMNode_iface, "frame_element", cb); if(window->nswindow) note_cc_edge((nsISupports*)window->nswindow, "nswindow", cb); if(window->window_proxy) @@ -4374,8 +4376,9 @@ static nsresult NSAPI outer_window_unlink(void *p) IHTMLLocation_Release(&location->IHTMLLocation_iface); } if(window->frame_element) { - window->frame_element->content_window = NULL; + HTMLFrameBase *frame_element = window->frame_element; window->frame_element = NULL; + IHTMLDOMNode_Release(&frame_element->element.node.IHTMLDOMNode_iface); } unlink_ref(&window->nswindow); if(window->window_proxy) {