From fa3ac0a3d9f01022b880b68fc003babbcd13e4a8 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sun, 1 Nov 2009 19:19:41 +0100 Subject: [PATCH] mshtml: Added HTMLFrameElement object and associate it with frame window. --- dlls/mshtml/htmlframebase.c | 46 ++++++++++++++++++++++++++++++++++++ dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/mutation.c | 16 +++++++------ 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/dlls/mshtml/htmlframebase.c b/dlls/mshtml/htmlframebase.c index b1d53e3ad93..6c0dd40a5e8 100644 --- a/dlls/mshtml/htmlframebase.c +++ b/dlls/mshtml/htmlframebase.c @@ -278,3 +278,49 @@ void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLEl } This->content_window = content_window; } + +typedef struct { + HTMLFrameBase framebase; +} HTMLFrameElement; + +#define HTMLFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLFrameElement, framebase.element.node, iface) + +static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + return HTMLFrameBase_QI(&This->framebase, riid, ppv); +} + +static void HTMLFrameElement_destructor(HTMLDOMNode *iface) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + HTMLFrameBase_destructor(&This->framebase); +} + +#undef HTMLFRAME_NODE_THIS + +static const NodeImplVtbl HTMLFrameElementImplVtbl = { + HTMLFrameElement_QI, + HTMLFrameElement_destructor +}; + +HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLWindow *content_window) +{ + nsIDOMHTMLFrameElement *nsframe; + HTMLFrameElement *ret; + nsresult nsres; + + ret = heap_alloc_zero(sizeof(HTMLFrameElement)); + + 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, content_window, NULL); + + return &ret->framebase.element; +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 570f0b11c82..a6a8396f667 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -697,6 +697,7 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL); HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*); HTMLElement *HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*); HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*); +HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*); HTMLElement *HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*); HTMLElement *HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*); HTMLElement *HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*); diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c index edcbbd7706e..f5508097fa7 100644 --- a/dlls/mshtml/mutation.c +++ b/dlls/mshtml/mutation.c @@ -259,12 +259,8 @@ static nsresult init_nsdoc_window(HTMLDocumentNode *doc, nsIDOMDocument *nsdoc, HRESULT hres; hres = HTMLWindow_Create(doc->basedoc.doc_obj, nswindow, doc->basedoc.window, &window); - if(SUCCEEDED(hres)) { - if(ret) - *ret = window; - else - IHTMLWindow2_Release(HTMLWINDOW2(window)); - } + if(SUCCEEDED(hres)) + *ret = window; } nsIDOMWindow_Release(nswindow); @@ -305,6 +301,7 @@ static nsresult init_iframe_window(HTMLDocumentNode *doc, nsISupports *nsunk) static nsresult init_frame_window(HTMLDocumentNode *doc, nsISupports *nsunk) { nsIDOMHTMLFrameElement *nsframe; + HTMLWindow *window = NULL; nsIDOMDocument *nsdoc; nsresult nsres; @@ -321,7 +318,12 @@ static nsresult init_frame_window(HTMLDocumentNode *doc, nsISupports *nsunk) return nsres; } - nsres = init_nsdoc_window(doc, nsdoc, NULL); + nsres = init_nsdoc_window(doc, nsdoc, &window); + + if(window) { + HTMLFrameElement_Create(doc, (nsIDOMHTMLElement*)nsframe, window); + IHTMLWindow2_Release(HTMLWINDOW2(window)); + } nsIDOMDocument_Release(nsdoc); return nsres;