mshtml: Store ns[i]frame reference in HTMLFrameBase.

This commit is contained in:
Andrew Eikum 2009-12-07 16:28:04 -06:00 committed by Alexandre Julliard
parent 662653c8ff
commit 6e3e7c9f4c
3 changed files with 20 additions and 26 deletions

View File

@ -443,16 +443,31 @@ void HTMLFrameBase_destructor(HTMLFrameBase *This)
if(This->content_window) if(This->content_window)
This->content_window->frame_element = NULL; This->content_window->frame_element = NULL;
if(This->nsframe)
nsIDOMHTMLFrameElement_Release(This->nsframe);
if(This->nsiframe)
nsIDOMHTMLIFrameElement_Release(This->nsiframe);
HTMLElement_destructor(&This->element.node); HTMLElement_destructor(&This->element.node);
} }
void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
dispex_static_data_t *dispex_data) dispex_static_data_t *dispex_data)
{ {
nsresult nsres;
This->lpIHTMLFrameBaseVtbl = &HTMLFrameBaseVtbl; This->lpIHTMLFrameBaseVtbl = &HTMLFrameBaseVtbl;
This->lpIHTMLFrameBase2Vtbl = &HTMLFrameBase2Vtbl; This->lpIHTMLFrameBase2Vtbl = &HTMLFrameBase2Vtbl;
HTMLElement_Init(&This->element, doc, nselem, dispex_data); HTMLElement_Init(&This->element, doc, nselem, dispex_data);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
if(NS_FAILED(nsres)) {
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
if(NS_FAILED(nsres))
ERR("Could not get nsIDOMHTML[I]Frame interface\n");
}else
This->nsiframe = NULL;
} }
typedef struct { typedef struct {
@ -492,17 +507,11 @@ static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface) static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface)
{ {
HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
nsIDOMHTMLFrameElement *nsframe;
nsIDOMDocument *nsdoc; nsIDOMDocument *nsdoc;
nsresult nsres; nsresult nsres;
HRESULT hres; HRESULT hres;
nsres = nsIDOMHTMLElement_QueryInterface(This->framebase.element.nselem, &IID_nsIDOMHTMLFrameElement, (void**)&nsframe); nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc);
if(NS_FAILED(nsres))
return E_FAIL;
nsres = nsIDOMHTMLFrameElement_GetContentDocument(nsframe, &nsdoc);
nsIDOMHTMLFrameElement_Release(nsframe);
if(NS_FAILED(nsres) || !nsdoc) { if(NS_FAILED(nsres) || !nsdoc) {
ERR("GetContentDocument failed: %08x\n", nsres); ERR("GetContentDocument failed: %08x\n", nsres);
return E_FAIL; return E_FAIL;
@ -531,18 +540,12 @@ static const NodeImplVtbl HTMLFrameElementImplVtbl = {
HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{ {
nsIDOMHTMLFrameElement *nsframe;
HTMLFrameElement *ret; HTMLFrameElement *ret;
nsresult nsres;
ret = heap_alloc_zero(sizeof(HTMLFrameElement)); ret = heap_alloc_zero(sizeof(HTMLFrameElement));
ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl; ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl;
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&nsframe);
if(NS_FAILED(nsres))
ERR("Could not get nsIDOMHTMLFrameElement iface: %08x\n", nsres);
HTMLFrameBase_Init(&ret->framebase, doc, nselem, NULL); HTMLFrameBase_Init(&ret->framebase, doc, nselem, NULL);
return &ret->framebase.element; return &ret->framebase.element;

View File

@ -33,10 +33,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
typedef struct { typedef struct {
HTMLFrameBase framebase; HTMLFrameBase framebase;
LONG ref;
nsIDOMHTMLIFrameElement *nsiframe;
} HTMLIFrame; } HTMLIFrame;
#define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface) #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface)
@ -52,9 +48,6 @@ static void HTMLIFrame_destructor(HTMLDOMNode *iface)
{ {
HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface); HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
if(This->nsiframe)
nsIDOMHTMLIFrameElement_Release(This->nsiframe);
HTMLFrameBase_destructor(&This->framebase); HTMLFrameBase_destructor(&This->framebase);
} }
@ -86,7 +79,7 @@ static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface)
nsresult nsres; nsresult nsres;
HRESULT hres; HRESULT hres;
nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->nsiframe, &nsdoc); nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc);
if(NS_FAILED(nsres) || !nsdoc) { if(NS_FAILED(nsres) || !nsdoc) {
ERR("GetContentDocument failed: %08x\n", nsres); ERR("GetContentDocument failed: %08x\n", nsres);
return E_FAIL; return E_FAIL;
@ -134,16 +127,11 @@ static dispex_static_data_t HTMLIFrame_dispex = {
HTMLElement *HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) HTMLElement *HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{ {
HTMLIFrame *ret; HTMLIFrame *ret;
nsresult nsres;
ret = heap_alloc_zero(sizeof(HTMLIFrame)); ret = heap_alloc_zero(sizeof(HTMLIFrame));
ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl; ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&ret->nsiframe);
if(NS_FAILED(nsres))
ERR("Could not get nsIDOMHTMLIFrameElement iface: %08x\n", nsres);
HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex); HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
return &ret->framebase.element; return &ret->framebase.element;

View File

@ -504,6 +504,9 @@ struct HTMLFrameBase {
const IHTMLFrameBase2Vtbl *lpIHTMLFrameBase2Vtbl; const IHTMLFrameBase2Vtbl *lpIHTMLFrameBase2Vtbl;
HTMLWindow *content_window; HTMLWindow *content_window;
nsIDOMHTMLFrameElement *nsframe;
nsIDOMHTMLIFrameElement *nsiframe;
}; };
typedef struct _mutation_queue_t { typedef struct _mutation_queue_t {