From f68e24a6dc8ec3eb1101a37bc025177c163efa7e Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sat, 15 Sep 2007 16:04:57 +0200 Subject: [PATCH] mshtml: Store HTMLElement struct instead of pointer in HTMLAnchorElement. --- dlls/mshtml/htmlanchor.c | 19 +++++++------- dlls/mshtml/htmlelem.c | 51 ++++++++++++++++++++---------------- dlls/mshtml/mshtml_private.h | 2 +- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c index 1b01f42a33c..3bd08fc8d47 100644 --- a/dlls/mshtml/htmlanchor.c +++ b/dlls/mshtml/htmlanchor.c @@ -36,9 +36,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); typedef struct { - const IHTMLAnchorElementVtbl *lpHTMLAnchorElementVtbl; + HTMLElement element; - HTMLElement *element; + const IHTMLAnchorElementVtbl *lpHTMLAnchorElementVtbl; } HTMLAnchorElement; #define HTMLANCHOR(x) ((IHTMLAnchorElement*) &(x)->lpHTMLAnchorElementVtbl) @@ -69,7 +69,7 @@ static HRESULT WINAPI HTMLAnchorElement_QueryInterface(IHTMLAnchorElement *iface return S_OK; } - hres = HTMLElement_QI(This->element, riid, ppv); + hres = HTMLElement_QI(&This->element, riid, ppv); if(FAILED(hres)) WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); @@ -82,7 +82,7 @@ static ULONG WINAPI HTMLAnchorElement_AddRef(IHTMLAnchorElement *iface) TRACE("(%p)\n", This); - return IHTMLDocument2_AddRef(HTMLDOC(This->element->node.doc)); + return IHTMLDocument2_AddRef(HTMLDOC(This->element.node.doc)); } static ULONG WINAPI HTMLAnchorElement_Release(IHTMLAnchorElement *iface) @@ -91,7 +91,7 @@ static ULONG WINAPI HTMLAnchorElement_Release(IHTMLAnchorElement *iface) TRACE("(%p)\n", This); - return IHTMLDocument2_Release(HTMLDOC(This->element->node.doc)); + return IHTMLDocument2_Release(HTMLDOC(This->element.node.doc)); } static HRESULT WINAPI HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement *iface, UINT *pctinfo) @@ -473,13 +473,14 @@ static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl = { HTMLAnchorElement_blur }; -void HTMLAnchorElement_Create(HTMLElement *element) +HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement *nselem) { HTMLAnchorElement *ret = mshtml_alloc(sizeof(HTMLAnchorElement)); ret->lpHTMLAnchorElementVtbl = &HTMLAnchorElementVtbl; - ret->element = element; - element->impl = (IUnknown*)HTMLANCHOR(ret); - element->destructor = HTMLAnchorElement_destructor; + ret->element.impl = (IUnknown*)HTMLANCHOR(ret); + ret->element.destructor = HTMLAnchorElement_destructor; + + return &ret->element; } diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index a1df0d4b588..9b4d47d13cf 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1273,6 +1273,7 @@ HRESULT HTMLElement_QI(HTMLElement *This, REFIID riid, void **ppv) HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode) { + nsIDOMHTMLElement *nselem; HTMLElement *ret; nsAString class_name_str; const PRUnichar *class_name; @@ -1284,39 +1285,45 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode) static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0}; static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0}; - ret = mshtml_alloc(sizeof(HTMLElement)); - ret->lpHTMLElementVtbl = &HTMLElementVtbl; - ret->impl = NULL; - ret->destructor = NULL; - - ret->node.node_type = NT_HTMLELEM; - ret->node.impl.elem = HTMLELEM(ret); - ret->node.destructor = HTMLElement_destructor; - - HTMLElement2_Init(ret); - - nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&ret->nselem); + nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem); if(NS_FAILED(nsres)) return NULL; nsAString_Init(&class_name_str, NULL); - nsIDOMHTMLElement_GetTagName(ret->nselem, &class_name_str); + nsIDOMHTMLElement_GetTagName(nselem, &class_name_str); nsAString_GetData(&class_name_str, &class_name, NULL); if(!strcmpW(class_name, wszA)) - HTMLAnchorElement_Create(ret); - else if(!strcmpW(class_name, wszBODY)) - HTMLBodyElement_Create(ret); - else if(!strcmpW(class_name, wszINPUT)) - HTMLInputElement_Create(ret); - else if(!strcmpW(class_name, wszSELECT)) - HTMLSelectElement_Create(ret); - else if(!strcmpW(class_name, wszTEXTAREA)) - HTMLTextAreaElement_Create(ret); + ret = HTMLAnchorElement_Create(nselem); + else { + ret = mshtml_alloc(sizeof(HTMLElement)); + + ret->impl = NULL; + ret->destructor = NULL; + ret->nselem = nselem; + + if(!strcmpW(class_name, wszBODY)) + HTMLBodyElement_Create(ret); + else if(!strcmpW(class_name, wszINPUT)) + HTMLInputElement_Create(ret); + else if(!strcmpW(class_name, wszSELECT)) + HTMLSelectElement_Create(ret); + else if(!strcmpW(class_name, wszTEXTAREA)) + HTMLTextAreaElement_Create(ret); + } nsAString_Finish(&class_name_str); + ret->lpHTMLElementVtbl = &HTMLElementVtbl; + ret->nselem = nselem; + + HTMLElement2_Init(ret); + + ret->node.node_type = NT_HTMLELEM; + ret->node.impl.elem = HTMLELEM(ret); + ret->node.destructor = HTMLElement_destructor; + return ret; } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 5ef90d6eb79..ecfbbc9a3e6 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -416,7 +416,7 @@ void detach_selection(HTMLDocument*); void detach_ranges(HTMLDocument*); HTMLElement *HTMLElement_Create(nsIDOMNode*); -void HTMLAnchorElement_Create(HTMLElement*); +HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*); void HTMLBodyElement_Create(HTMLElement*); void HTMLInputElement_Create(HTMLElement*); void HTMLSelectElement_Create(HTMLElement*);