[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    [PATCH 2/6] mshtml: Implement IHTMLTextContainer interface directly in HTMLBodyElement object.
From:       Jacek Caban <jacek () codeweavers ! com>
Date:       2018-02-28 15:31:33
Message-ID: 68291d8e-a358-11c4-d818-43c545f9e8ea () codeweavers ! com
[Download RAW message or body]

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
---
 dlls/mshtml/htmlbody.c | 113
+++++++++++++++++++++----------------------------
 1 file changed, 49 insertions(+), 64 deletions(-)



["0002-mshtml-Implement-IHTMLTextContainer-interface-directl.diff" (text/x-patch)]

diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c
index 1d3ff9cab5..4913c45995 100644
--- a/dlls/mshtml/htmlbody.c
+++ b/dlls/mshtml/htmlbody.c
@@ -18,6 +18,7 @@
 
 #include <stdarg.h>
 #include <stdio.h>
+#include <assert.h>
 
 #define COBJMACROS
 
@@ -38,13 +39,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 typedef struct {
     HTMLElement element;
 
-    IHTMLTextContainer IHTMLTextContainer_iface;
-} HTMLTextContainer;
-
-typedef struct {
-    HTMLTextContainer textcont;
-
     IHTMLBodyElement IHTMLBodyElement_iface;
+    IHTMLTextContainer IHTMLTextContainer_iface;
 
     nsIDOMHTMLBodyElement *nsbody;
 } HTMLBodyElement;
@@ -225,27 +221,27 @@ static HRESULT WINAPI \
HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,  {
     HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
 
-    return IHTMLDOMNode_QueryInterface(&This->textcont.element.node.IHTMLDOMNode_iface, \
riid, ppv); +    return \
IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);  }
 
 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
 {
     HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
 
-    return IHTMLDOMNode_AddRef(&This->textcont.element.node.IHTMLDOMNode_iface);
+    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
 }
 
 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
 {
     HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
 
-    return IHTMLDOMNode_Release(&This->textcont.element.node.IHTMLDOMNode_iface);
+    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
 }
 
 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT \
*pctinfo)  {
     HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
-    return IDispatchEx_GetTypeInfoCount(&This->textcont.element.node.event_target.dispex.IDispatchEx_iface,
 +    return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface,
  pctinfo);
 }
 
@@ -253,7 +249,7 @@ static HRESULT WINAPI \
                HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT
                                               LCID lcid, ITypeInfo **ppTInfo)
 {
     HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
-    return IDispatchEx_GetTypeInfo(&This->textcont.element.node.event_target.dispex.IDispatchEx_iface, \
iTInfo, +    return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, \
iTInfo,  lcid, ppTInfo);
 }
 
@@ -262,7 +258,7 @@ static HRESULT WINAPI \
                HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REF
                                                 LCID lcid, DISPID *rgDispId)
 {
     HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
-    return IDispatchEx_GetIDsOfNames(&This->textcont.element.node.event_target.dispex.IDispatchEx_iface, \
riid, +    return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, \
riid,  rgszNames, cNames, lcid, rgDispId);
 }
 
@@ -271,7 +267,7 @@ static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement \
                *iface, DISPID dis
                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT \
*puArgErr)  {
     HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
-    return IDispatchEx_Invoke(&This->textcont.element.node.event_target.dispex.IDispatchEx_iface, \
dispIdMember, +    return \
IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, \
                dispIdMember,
             riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
 }
 
@@ -584,7 +580,7 @@ static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement \
*iface, VARIAN  
     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
 
-    return set_node_event(&This->textcont.element.node, EVENTID_LOAD, &v);
+    return set_node_event(&This->element.node, EVENTID_LOAD, &v);
 }
 
 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT \
*p) @@ -593,7 +589,7 @@ static HRESULT WINAPI \
HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIAN  
     TRACE("(%p)->(%p)\n", This, p);
 
-    return get_node_event(&This->textcont.element.node, EVENTID_LOAD, p);
+    return get_node_event(&This->element.node, EVENTID_LOAD, p);
 }
 
 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT \
v) @@ -636,7 +632,7 @@ static HRESULT WINAPI \
HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v  return E_INVALIDARG;
     }
 
-    return set_elem_style(&This->textcont.element, STYLEID_OVERFLOW, val);
+    return set_elem_style(&This->element, STYLEID_OVERFLOW, val);
 }
 
 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
@@ -649,7 +645,7 @@ static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement \
*iface, BSTR *  TRACE("(%p)->(%p)\n", This, p);
 
     /* Emulate with CSS visibility attribute */
-    hres = get_elem_style(&This->textcont.element, STYLEID_OVERFLOW, &overflow);
+    hres = get_elem_style(&This->element, STYLEID_OVERFLOW, &overflow);
     if(FAILED(hres))
         return hres;
 
@@ -714,21 +710,21 @@ static HRESULT WINAPI \
HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, I  
     TRACE("(%p)->(%p)\n", This, range);
 
-    if(!This->textcont.element.node.doc->nsdoc) {
+    if(!This->element.node.doc->nsdoc) {
         WARN("No nsdoc\n");
         return E_UNEXPECTED;
     }
 
-    nsres = nsIDOMHTMLDocument_CreateRange(This->textcont.element.node.doc->nsdoc, \
&nsrange); +    nsres = nsIDOMHTMLDocument_CreateRange(This->element.node.doc->nsdoc, \
&nsrange);  if(NS_SUCCEEDED(nsres)) {
-        nsres = nsIDOMRange_SelectNodeContents(nsrange, \
This->textcont.element.node.nsnode); +        nsres = \
nsIDOMRange_SelectNodeContents(nsrange, This->element.node.nsnode);  \
if(NS_FAILED(nsres))  ERR("SelectNodeContents failed: %08x\n", nsres);
     }else {
         ERR("CreateRange failed: %08x\n", nsres);
     }
 
-    hres = HTMLTxtRange_Create(This->textcont.element.node.doc->basedoc.doc_node, \
nsrange, range); +    hres = \
HTMLTxtRange_Create(This->element.node.doc->basedoc.doc_node, nsrange, range);  
     nsIDOMRange_Release(nsrange);
     return hres;
@@ -779,40 +775,40 @@ static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
     HTMLBodyElement_createTextRange
 };
 
-static inline HTMLTextContainer *impl_from_IHTMLTextContainer(IHTMLTextContainer \
*iface) +static inline HTMLBodyElement \
*impl_from_IHTMLTextContainer(IHTMLTextContainer *iface)  {
-    return CONTAINING_RECORD(iface, HTMLTextContainer, IHTMLTextContainer_iface);
+    return CONTAINING_RECORD(iface, HTMLBodyElement, IHTMLTextContainer_iface);
 }
 
 static HRESULT WINAPI HTMLTextContainer_QueryInterface(IHTMLTextContainer *iface,
                                                        REFIID riid, void **ppv)
 {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     return IHTMLElement_QueryInterface(&This->element.IHTMLElement_iface, riid, \
ppv);  }
 
 static ULONG WINAPI HTMLTextContainer_AddRef(IHTMLTextContainer *iface)
 {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     return IHTMLElement_AddRef(&This->element.IHTMLElement_iface);
 }
 
 static ULONG WINAPI HTMLTextContainer_Release(IHTMLTextContainer *iface)
 {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     return IHTMLElement_Release(&This->element.IHTMLElement_iface);
 }
 
 static HRESULT WINAPI HTMLTextContainer_GetTypeInfoCount(IHTMLTextContainer *iface, \
UINT *pctinfo)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, \
pctinfo);  }
 
 static HRESULT WINAPI HTMLTextContainer_GetTypeInfo(IHTMLTextContainer *iface, UINT \
                iTInfo,
                                               LCID lcid, ITypeInfo **ppTInfo)
 {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, \
iTInfo, lcid,  ppTInfo);
 }
@@ -821,7 +817,7 @@ static HRESULT WINAPI \
                HTMLTextContainer_GetIDsOfNames(IHTMLTextContainer *iface,
                                                 LPOLESTR *rgszNames, UINT cNames,
                                                 LCID lcid, DISPID *rgDispId)
 {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, \
riid, rgszNames,  cNames, lcid, rgDispId);
 }
@@ -830,7 +826,7 @@ static HRESULT WINAPI HTMLTextContainer_Invoke(IHTMLTextContainer \
                *iface, DISPID
                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS \
                *pDispParams,
                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT \
*puArgErr)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, \
dispIdMember, riid,  lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
 }
@@ -838,14 +834,14 @@ static HRESULT WINAPI \
HTMLTextContainer_Invoke(IHTMLTextContainer *iface, DISPID  static HRESULT WINAPI \
                HTMLTextContainer_createControlRange(IHTMLTextContainer *iface,
                                                            IDispatch **range)
 {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     FIXME("(%p)->(%p)\n", This, range);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLTextContainer_get_scrollHeight(IHTMLTextContainer *iface, \
LONG *p)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -854,7 +850,7 @@ static HRESULT WINAPI \
HTMLTextContainer_get_scrollHeight(IHTMLTextContainer *ifa  
 static HRESULT WINAPI HTMLTextContainer_get_scrollWidth(IHTMLTextContainer *iface, \
LONG *p)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -863,7 +859,7 @@ static HRESULT WINAPI \
HTMLTextContainer_get_scrollWidth(IHTMLTextContainer *ifac  
 static HRESULT WINAPI HTMLTextContainer_put_scrollTop(IHTMLTextContainer *iface, \
LONG v)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
 
     TRACE("(%p)->(%d)\n", This, v);
 
@@ -872,7 +868,7 @@ static HRESULT WINAPI \
HTMLTextContainer_put_scrollTop(IHTMLTextContainer *iface,  
 static HRESULT WINAPI HTMLTextContainer_get_scrollTop(IHTMLTextContainer *iface, \
LONG *p)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -881,7 +877,7 @@ static HRESULT WINAPI \
HTMLTextContainer_get_scrollTop(IHTMLTextContainer *iface,  
 static HRESULT WINAPI HTMLTextContainer_put_scrollLeft(IHTMLTextContainer *iface, \
LONG v)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
 
     TRACE("(%p)->(%d)\n", This, v);
 
@@ -890,7 +886,7 @@ static HRESULT WINAPI \
HTMLTextContainer_put_scrollLeft(IHTMLTextContainer *iface  
 static HRESULT WINAPI HTMLTextContainer_get_scrollLeft(IHTMLTextContainer *iface, \
LONG *p)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -899,14 +895,14 @@ static HRESULT WINAPI \
HTMLTextContainer_get_scrollLeft(IHTMLTextContainer *iface  
 static HRESULT WINAPI HTMLTextContainer_put_onscroll(IHTMLTextContainer *iface, \
VARIANT v)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     FIXME("(%p)->()\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI HTMLTextContainer_get_onscroll(IHTMLTextContainer *iface, \
VARIANT *p)  {
-    HTMLTextContainer *This = impl_from_IHTMLTextContainer(iface);
+    HTMLBodyElement *This = impl_from_IHTMLTextContainer(iface);
     FIXME("(%p)->(%p)\n", This, p);
     return E_NOTIMPL;
 }
@@ -930,17 +926,9 @@ static const IHTMLTextContainerVtbl HTMLTextContainerVtbl = {
     HTMLTextContainer_get_onscroll
 };
 
-static void HTMLTextContainer_Init(HTMLTextContainer *This, HTMLDocumentNode *doc, \
                nsIDOMElement *nselem,
-        dispex_static_data_t *dispex_data)
-{
-    This->IHTMLTextContainer_iface.lpVtbl = &HTMLTextContainerVtbl;
-
-    HTMLElement_Init(&This->element, doc, nselem, dispex_data);
-}
-
 static inline HTMLBodyElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
 {
-    return CONTAINING_RECORD(iface, HTMLBodyElement, textcont.element.node);
+    return CONTAINING_RECORD(iface, HTMLBodyElement, element.node);
 }
 
 static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
@@ -959,8 +947,8 @@ static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID \
riid, void **ppv)  TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
         *ppv = &This->IHTMLBodyElement_iface;
     }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
-        TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
-        *ppv = &This->textcont.IHTMLTextContainer_iface;
+        TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", This, ppv);
+        *ppv = &This->IHTMLTextContainer_iface;
     }
 
     if(*ppv) {
@@ -968,7 +956,7 @@ static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID \
riid, void **ppv)  return S_OK;
     }
 
-    return HTMLElement_QI(&This->textcont.element.node, riid, ppv);
+    return HTMLElement_QI(&This->element.node, riid, ppv);
 }
 
 static void HTMLBodyElement_traverse(HTMLDOMNode *iface, \
nsCycleCollectionTraversalCallback *cb) @@ -1000,11 +988,11 @@ static EventTarget \
*HTMLBodyElement_get_event_prop_target(HTMLDOMNode *iface, in  case EVENTID_FOCUS:
     case EVENTID_LOAD:
     case EVENTID_SCROLL:
-        return This->textcont.element.node.doc && \
                This->textcont.element.node.doc->window
-            ? &This->textcont.element.node.doc->window->event_target
-            : &This->textcont.element.node.event_target;
+        return This->element.node.doc && This->element.node.doc->window
+            ? &This->element.node.doc->window->event_target
+            : &This->element.node.event_target;
     default:
-        return &This->textcont.element.node.event_target;
+        return &This->element.node.event_target;
     }
 }
 
@@ -1077,17 +1065,14 @@ HRESULT HTMLBodyElement_Create(HTMLDocumentNode *doc, \
nsIDOMElement *nselem, HTM  return E_OUTOFMEMORY;
 
     ret->IHTMLBodyElement_iface.lpVtbl = &HTMLBodyElementVtbl;
-    ret->textcont.element.node.vtbl = &HTMLBodyElementImplVtbl;
+    ret->IHTMLTextContainer_iface.lpVtbl = &HTMLTextContainerVtbl;
+    ret->element.node.vtbl = &HTMLBodyElementImplVtbl;
 
-    nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement, \
                (void**)&ret->nsbody);
-    if(NS_FAILED(nsres)) {
-        ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
-        heap_free(ret);
-        return E_OUTOFMEMORY;
-    }
+    HTMLElement_Init(&ret->element, doc, nselem, &HTMLBodyElement_dispex);
 
-    HTMLTextContainer_Init(&ret->textcont, doc, nselem, &HTMLBodyElement_dispex);
+    nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement, \
(void**)&ret->nsbody); +    assert(nsres == NS_OK);
 
-    *elem = &ret->textcont.element;
+    *elem = &ret->element;
     return S_OK;
 }


[Attachment #4 (text/plain)]




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic