[PATCH 01/10] mshtml: COM cleanup for the IHTMLElement iface.

Michael Stefaniuc mstefani at redhat.de
Wed Dec 29 18:24:59 CST 2010


---
 dlls/mshtml/htmlcomment.c    |    2 +-
 dlls/mshtml/htmldoc.c        |    4 +-
 dlls/mshtml/htmlelem.c       |  215 +++++++++++++++++++++---------------------
 dlls/mshtml/htmlelem2.c      |   11 +-
 dlls/mshtml/htmlelem3.c      |    6 +-
 dlls/mshtml/htmlelemcol.c    |   10 +-
 dlls/mshtml/htmlimg.c        |    3 +-
 dlls/mshtml/htmltextcont.c   |    6 +-
 dlls/mshtml/htmlwindow.c     |    2 +-
 dlls/mshtml/mshtml_private.h |    3 +-
 10 files changed, 133 insertions(+), 129 deletions(-)

diff --git a/dlls/mshtml/htmlcomment.c b/dlls/mshtml/htmlcomment.c
index 82a0188..b04a6a2 100644
--- a/dlls/mshtml/htmlcomment.c
+++ b/dlls/mshtml/htmlcomment.c
@@ -106,7 +106,7 @@ static HRESULT WINAPI HTMLCommentElement_get_text(IHTMLCommentElement *iface, BS
 
     TRACE("(%p)->(%p)\n", This, p);
 
-    return IHTMLElement_get_outerHTML(HTMLELEM(&This->element), p);
+    return IHTMLElement_get_outerHTML(&This->element.IHTMLElement_iface, p);
 }
 
 static HRESULT WINAPI HTMLCommentElement_put_atomic(IHTMLCommentElement *iface, LONG v)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 0ad676f..451dae9 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1005,8 +1005,8 @@ static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTa
     if(FAILED(hres))
         return hres;
 
-    *newElem = HTMLELEM(elem);
-    IHTMLElement_AddRef(HTMLELEM(elem));
+    *newElem = &elem->IHTMLElement_iface;
+    IHTMLElement_AddRef(&elem->IHTMLElement_iface);
     return S_OK;
 }
 
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 1d7c59c..73a5ee2 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -113,7 +113,10 @@ IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
 
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
-#define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
+static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
+{
+    return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
+}
 
 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
 {
@@ -147,35 +150,35 @@ HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement
 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
                                                  REFIID riid, void **ppv)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->node), riid, ppv);
 }
 
 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->node));
 }
 
 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     return IHTMLDOMNode_Release(HTMLDOMNODE(&This->node));
 }
 
 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->node.dispex), pctinfo);
 }
 
 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
                                               LCID lcid, ITypeInfo **ppTInfo)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->node.dispex), iTInfo, lcid, ppTInfo);
 }
 
@@ -183,7 +186,7 @@ static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid
                                                 LPOLESTR *rgszNames, UINT cNames,
                                                 LCID lcid, DISPID *rgDispId)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
 }
 
@@ -191,7 +194,7 @@ static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMembe
                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     return IDispatchEx_Invoke(DISPATCHEX(&This->node.dispex), dispIdMember, riid, lcid,
             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
 }
@@ -199,7 +202,7 @@ static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMembe
 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
                                                VARIANT AttributeValue, LONG lFlags)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     HRESULT hres;
     DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
     DISPPARAMS dispParams;
@@ -226,7 +229,7 @@ static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttr
 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
                                                LONG lFlags, VARIANT *AttributeValue)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     DISPID dispid;
     HRESULT hres;
     DISPPARAMS dispParams = {NULL, NULL, 0, 0};
@@ -256,7 +259,7 @@ static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttr
 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
                                                   LONG lFlags, VARIANT_BOOL *pfSuccess)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
 
@@ -265,7 +268,7 @@ static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strA
 
 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsAString classname_str;
     nsresult nsres;
 
@@ -287,7 +290,7 @@ static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
 
 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsAString class_str;
     nsresult nsres;
     HRESULT hres = S_OK;
@@ -319,7 +322,7 @@ static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
 
 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsAString id_str;
     nsresult nsres;
 
@@ -341,7 +344,7 @@ static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
 
 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     const PRUnichar *id;
     nsAString id_str;
     nsresult nsres;
@@ -368,7 +371,7 @@ static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
 
 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     const PRUnichar *tag;
     nsAString tag_str;
     nsresult nsres;
@@ -400,7 +403,7 @@ static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
 
 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     IHTMLDOMNode *node;
     HRESULT hres;
 
@@ -420,7 +423,7 @@ static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLEl
 
 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMElementCSSInlineStyle *nselemstyle;
     nsIDOMCSSStyleDeclaration *nsstyle;
     nsresult nsres;
@@ -455,21 +458,21 @@ static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
 
 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->()\n", This);
 
@@ -478,7 +481,7 @@ static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
 
 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -487,7 +490,7 @@ static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
 
 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
 
@@ -496,7 +499,7 @@ static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
 
 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -505,7 +508,7 @@ static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p
 
 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
 
@@ -514,7 +517,7 @@ static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
 
 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -523,7 +526,7 @@ static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
 
 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->()\n", This);
 
@@ -532,28 +535,28 @@ static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
 
 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
 
@@ -562,7 +565,7 @@ static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
 
 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -571,7 +574,7 @@ static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p
 
 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->()\n", This);
 
@@ -580,7 +583,7 @@ static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v
 
 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -589,21 +592,21 @@ static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *
 
 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->()\n", This);
 
@@ -612,7 +615,7 @@ static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v
 
 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -621,7 +624,7 @@ static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *
 
 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
 
@@ -630,7 +633,7 @@ static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
 
 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -639,7 +642,7 @@ static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
 
 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -658,7 +661,7 @@ static const WCHAR titleW[] = {'t','i','t','l','e',0};
 
 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsAString title_str;
     nsresult nsres;
 
@@ -689,7 +692,7 @@ static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
 
 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsAString title_str;
     nsresult nsres;
 
@@ -729,21 +732,21 @@ static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
 
 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
 
@@ -752,7 +755,7 @@ static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT
 
 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -761,7 +764,7 @@ static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT
 
 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
@@ -769,49 +772,49 @@ static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT va
 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
                                            VARIANT_BOOL *pfResult)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMNSHTMLElement *nselem;
     PRInt32 top = 0;
     nsresult nsres;
@@ -837,7 +840,7 @@ static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
 
 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMNSHTMLElement *nselem;
     PRInt32 offset = 0;
     nsresult nsres;
@@ -863,7 +866,7 @@ static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
 
 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMNSHTMLElement *nselem;
     PRInt32 offset = 0;
     nsresult nsres;
@@ -889,14 +892,14 @@ static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
 
 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMNSHTMLElement *nselem;
     nsAString html_str;
     nsresult nsres;
@@ -928,7 +931,7 @@ static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
 
 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMNSHTMLElement *nselem;
     nsAString html_str;
     nsresult nsres;
@@ -964,7 +967,7 @@ static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
 
 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMNode *nschild, *tmp;
     nsIDOMText *text_node;
     nsAString text_str;
@@ -1010,7 +1013,7 @@ static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
 
 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -1019,7 +1022,7 @@ static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
 
 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMDocumentFragment *nsfragment;
     nsIDOMDocumentRange *nsdocrange;
     nsIDOMNSRange *nsrange;
@@ -1081,7 +1084,7 @@ static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
 
 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsAString html_str;
     HRESULT hres;
 
@@ -1106,14 +1109,14 @@ static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
 
 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
@@ -1185,7 +1188,7 @@ static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsI
 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
                                                      BSTR html)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMDocumentRange *nsdocrange;
     nsIDOMRange *range;
     nsIDOMNSRange *nsrange;
@@ -1246,7 +1249,7 @@ static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR w
 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
                                                      BSTR text)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMNode *nsnode;
     nsAString ns_text;
     nsresult nsres;
@@ -1278,21 +1281,21 @@ static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR w
 
 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)\n", This);
 
@@ -1302,7 +1305,7 @@ static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
                                               IHTMLFiltersCollection **p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     TRACE("(%p)->(%p)\n", This, p);
 
     if(!p)
@@ -1315,154 +1318,154 @@ static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
 
 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, String);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
     nsIDOMNodeList *nsnode_list;
     nsresult nsres;
 
@@ -1474,7 +1477,8 @@ static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **
         return E_FAIL;
     }
 
-    *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nsnode_list);
+    *p = (IDispatch*)create_collection_from_nodelist(This->node.doc,
+            (IUnknown*)&This->IHTMLElement_iface, nsnode_list);
 
     nsIDOMNodeList_Release(nsnode_list);
     return S_OK;
@@ -1482,7 +1486,7 @@ static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **
 
 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
 {
-    HTMLElement *This = HTMLELEM_THIS(iface);
+    HTMLElement *This = impl_from_IHTMLElement(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -1490,8 +1494,6 @@ static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
     return S_OK;
 }
 
-#undef HTMLELEM_THIS
-
 static const IHTMLElementVtbl HTMLElementVtbl = {
     HTMLElement_QueryInterface,
     HTMLElement_AddRef,
@@ -1602,13 +1604,13 @@ HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
 
     if(IsEqualGUID(&IID_IUnknown, riid)) {
         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
-        *ppv = HTMLELEM(This);
+        *ppv = &This->IHTMLElement_iface;
     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
-        *ppv = HTMLELEM(This);
+        *ppv = &This->IHTMLElement_iface;
     }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
         TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
-        *ppv = HTMLELEM(This);
+        *ppv = &This->IHTMLElement_iface;
     }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
         TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
         *ppv = HTMLELEM2(This);
@@ -1621,7 +1623,7 @@ HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
     }
 
     if(*ppv) {
-        IHTMLElement_AddRef(HTMLELEM(This));
+        IHTMLElement_AddRef(&This->IHTMLElement_iface);
         return S_OK;
     }
 
@@ -1650,7 +1652,7 @@ HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **
     if(FAILED(hres))
         return hres;
 
-    IHTMLElement_AddRef(HTMLELEM(new_elem));
+    IHTMLElement_AddRef(&new_elem->IHTMLElement_iface);
     *ret = &new_elem->node;
     return S_OK;
 }
@@ -1711,14 +1713,15 @@ static dispex_static_data_t HTMLElement_dispex = {
 
 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
 {
-    This->lpHTMLElementVtbl = &HTMLElementVtbl;
+    This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
 
     HTMLElement2_Init(This);
     HTMLElement3_Init(This);
 
     if(dispex_data && !dispex_data->vtbl)
         dispex_data->vtbl = &HTMLElement_dispex_vtbl;
-    init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), dispex_data ? dispex_data : &HTMLElement_dispex);
+    init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
+            dispex_data ? dispex_data : &HTMLElement_dispex);
 
     if(nselem)
         nsIDOMHTMLElement_AddRef(nselem);
@@ -1726,7 +1729,7 @@ void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElemen
 
     HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
 
-    ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
+    ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
 }
 
 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
diff --git a/dlls/mshtml/htmlelem2.c b/dlls/mshtml/htmlelem2.c
index f6d7bfc..1e39977 100644
--- a/dlls/mshtml/htmlelem2.c
+++ b/dlls/mshtml/htmlelem2.c
@@ -284,19 +284,19 @@ static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
                                                   REFIID riid, void **ppv)
 {
     HTMLElement *This = HTMLELEM2_THIS(iface);
-    return IHTMLElement_QueryInterface(HTMLELEM(This), riid, ppv);
+    return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
 }
 
 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
 {
     HTMLElement *This = HTMLELEM2_THIS(iface);
-    return IHTMLElement_AddRef(HTMLELEM(This));
+    return IHTMLElement_AddRef(&This->IHTMLElement_iface);
 }
 
 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
 {
     HTMLElement *This = HTMLELEM2_THIS(iface);
-    return IHTMLElement_Release(HTMLELEM(This));
+    return IHTMLElement_Release(&This->IHTMLElement_iface);
 }
 
 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
@@ -739,7 +739,7 @@ static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
 
     V_VT(&var) = VT_BSTR;
     V_BSTR(&var) = v;
-    return IHTMLElement_setAttribute(HTMLELEM(This), accessKeyW, var, 0);
+    return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
 }
 
 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
@@ -1365,7 +1365,8 @@ static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BS
         return E_FAIL;
     }
 
-    *pelColl = create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nslist);
+    *pelColl = create_collection_from_nodelist(This->node.doc,
+            (IUnknown*)&This->IHTMLElement_iface, nslist);
     nsIDOMNodeList_Release(nslist);
     return S_OK;
 }
diff --git a/dlls/mshtml/htmlelem3.c b/dlls/mshtml/htmlelem3.c
index 30c8546..686c730 100644
--- a/dlls/mshtml/htmlelem3.c
+++ b/dlls/mshtml/htmlelem3.c
@@ -39,19 +39,19 @@ static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
                                                   REFIID riid, void **ppv)
 {
     HTMLElement *This = HTMLELEM3_THIS(iface);
-    return IHTMLElement_QueryInterface(HTMLELEM(This), riid, ppv);
+    return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
 }
 
 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
 {
     HTMLElement *This = HTMLELEM3_THIS(iface);
-    return IHTMLElement_AddRef(HTMLELEM(This));
+    return IHTMLElement_AddRef(&This->IHTMLElement_iface);
 }
 
 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
 {
     HTMLElement *This = HTMLELEM3_THIS(iface);
-    return IHTMLElement_Release(HTMLELEM(This));
+    return IHTMLElement_Release(&This->IHTMLElement_iface);
 }
 
 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c
index daef670..b82a441 100644
--- a/dlls/mshtml/htmlelemcol.c
+++ b/dlls/mshtml/htmlelemcol.c
@@ -215,7 +215,7 @@ static BOOL is_elem_id(HTMLElement *elem, LPCWSTR name)
     BSTR elem_id;
     HRESULT hres;
 
-    hres = IHTMLElement_get_id(HTMLELEM(elem), &elem_id);
+    hres = IHTMLElement_get_id(&elem->IHTMLElement_iface, &elem_id);
     if(FAILED(hres)){
         WARN("IHTMLElement_get_id failed: 0x%08x\n", hres);
         return FALSE;
@@ -308,7 +308,7 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
             }
 
             if(i != This->len) {
-                *pdisp = (IDispatch*)HTMLELEM(This->elems[i]);
+                *pdisp = (IDispatch*)&This->elems[i]->IHTMLElement_iface;
                 IDispatch_AddRef(*pdisp);
             }
         }else {
@@ -326,7 +326,7 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
                 *pdisp = (IDispatch*)HTMLElementCollection_Create(This->ref_unk, buf.buf, buf.len);
             }else {
                 if(buf.len == 1) {
-                    *pdisp = (IDispatch*)HTMLELEM(buf.buf[0]);
+                    *pdisp = (IDispatch*)&buf.buf[0]->IHTMLElement_iface;
                     IDispatch_AddRef(*pdisp);
                 }
 
@@ -456,8 +456,8 @@ static HRESULT HTMLElementCollection_invoke(DispatchEx *dispex, DISPID id, LCID
     switch(flags) {
     case DISPATCH_PROPERTYGET:
         V_VT(res) = VT_DISPATCH;
-        V_DISPATCH(res) = (IDispatch*)HTMLELEM(This->elems[idx]);
-        IHTMLElement_AddRef(HTMLELEM(This->elems[idx]));
+        V_DISPATCH(res) = (IDispatch*)&This->elems[idx]->IHTMLElement_iface;
+        IHTMLElement_AddRef(&This->elems[idx]->IHTMLElement_iface);
         break;
     default:
         FIXME("unimplemented flags %x\n", flags);
diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c
index 7bf3794..a0d66e7 100644
--- a/dlls/mshtml/htmlimg.c
+++ b/dlls/mshtml/htmlimg.c
@@ -835,7 +835,8 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i
         return hres;
     }
 
-    hres = IHTMLElement_QueryInterface(HTMLELEM(elem), &IID_IHTMLImgElement, (void**)&img);
+    hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLImgElement,
+            (void**)&img);
     if(FAILED(hres)) {
         ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres);
         return hres;
diff --git a/dlls/mshtml/htmltextcont.c b/dlls/mshtml/htmltextcont.c
index 46b5d87..10a2360 100644
--- a/dlls/mshtml/htmltextcont.c
+++ b/dlls/mshtml/htmltextcont.c
@@ -40,19 +40,19 @@ static HRESULT WINAPI HTMLTextContainer_QueryInterface(IHTMLTextContainer *iface
                                                        REFIID riid, void **ppv)
 {
     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
-    return IHTMLElement_QueryInterface(HTMLELEM(&This->element), riid, ppv);
+    return IHTMLElement_QueryInterface(&This->element.IHTMLElement_iface, riid, ppv);
 }
 
 static ULONG WINAPI HTMLTextContainer_AddRef(IHTMLTextContainer *iface)
 {
     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
-    return IHTMLElement_AddRef(HTMLELEM(&This->element));
+    return IHTMLElement_AddRef(&This->element.IHTMLElement_iface);
 }
 
 static ULONG WINAPI HTMLTextContainer_Release(IHTMLTextContainer *iface)
 {
     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
-    return IHTMLElement_Release(HTMLELEM(&This->element));
+    return IHTMLElement_Release(&This->element.IHTMLElement_iface);
 }
 
 static HRESULT WINAPI HTMLTextContainer_GetTypeInfoCount(IHTMLTextContainer *iface, UINT *pctinfo)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index c98eb1d..29ddb23 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -394,7 +394,7 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex,
 
             nsIDOMWindow_Release(nsWindow);
 
-            hres = IHTMLElement_get_id(HTMLELEM(&cur_window->frame_element->element), &id);
+            hres = IHTMLElement_get_id(&cur_window->frame_element->element.IHTMLElement_iface, &id);
             if(FAILED(hres)) {
                 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
                 goto cleanup;
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 5ffebd3..6adb14a 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -549,7 +549,7 @@ typedef struct {
     HTMLDOMNode node;
     ConnectionPointContainer cp_container;
 
-    const IHTMLElementVtbl   *lpHTMLElementVtbl;
+    IHTMLElement  IHTMLElement_iface;
     const IHTMLElement2Vtbl  *lpHTMLElement2Vtbl;
     const IHTMLElement3Vtbl  *lpHTMLElement3Vtbl;
 
@@ -642,7 +642,6 @@ struct HTMLDocumentNode {
 #define STATUSCLB(x)     ((IBindStatusCallback*)          &(x)->lpBindStatusCallbackVtbl)
 #define BINDINFO(x)      ((IInternetBindInfo*)            &(x)->lpInternetBindInfoVtbl);
 
-#define HTMLELEM(x)      ((IHTMLElement*)                 &(x)->lpHTMLElementVtbl)
 #define HTMLELEM2(x)     ((IHTMLElement2*)                &(x)->lpHTMLElement2Vtbl)
 #define HTMLELEM3(x)     ((IHTMLElement3*)                &(x)->lpHTMLElement3Vtbl)
 #define HTMLDOMNODE(x)   ((IHTMLDOMNode*)                 &(x)->lpHTMLDOMNodeVtbl)
-- 
1.7.3.4



More information about the wine-patches mailing list