Jacek Caban : mshtml: Add IHTMLStyleElement2 implementation.

Alexandre Julliard julliard at winehq.org
Mon Apr 5 16:28:25 CDT 2021


Module: wine
Branch: master
Commit: 5962a0ea263fbe1860d824c5dde536df263fb51b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5962a0ea263fbe1860d824c5dde536df263fb51b

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Apr  5 16:05:01 2021 +0200

mshtml: Add IHTMLStyleElement2 implementation.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/htmlstyleelem.c  | 81 ++++++++++++++++++++++++++++++++++++++++++++
 dlls/mshtml/mshtml_private.h |  1 +
 dlls/mshtml/tests/dom.c      | 11 ++++++
 3 files changed, 93 insertions(+)

diff --git a/dlls/mshtml/htmlstyleelem.c b/dlls/mshtml/htmlstyleelem.c
index d3fb71dae72..9108cc4ca8b 100644
--- a/dlls/mshtml/htmlstyleelem.c
+++ b/dlls/mshtml/htmlstyleelem.c
@@ -37,6 +37,7 @@ struct HTMLStyleElement {
     HTMLElement element;
 
     IHTMLStyleElement IHTMLStyleElement_iface;
+    IHTMLStyleElement2 IHTMLStyleElement2_iface;
 
     nsIDOMHTMLStyleElement *nsstyle;
     IHTMLStyleSheet *style_sheet;
@@ -282,6 +283,82 @@ static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
     HTMLStyleElement_get_media
 };
 
+static inline HTMLStyleElement *impl_from_IHTMLStyleElement2(IHTMLStyleElement2 *iface)
+{
+    return CONTAINING_RECORD(iface, HTMLStyleElement, IHTMLStyleElement2_iface);
+}
+
+static HRESULT WINAPI HTMLStyleElement2_QueryInterface(IHTMLStyleElement2 *iface,
+                                                       REFIID riid, void **ppv)
+{
+    HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
+
+    return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
+}
+
+static ULONG WINAPI HTMLStyleElement2_AddRef(IHTMLStyleElement2 *iface)
+{
+    HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
+
+    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
+}
+
+static ULONG WINAPI HTMLStyleElement2_Release(IHTMLStyleElement2 *iface)
+{
+    HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
+
+    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
+}
+
+static HRESULT WINAPI HTMLStyleElement2_GetTypeInfoCount(IHTMLStyleElement2 *iface, UINT *pctinfo)
+{
+    HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
+    return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
+}
+
+static HRESULT WINAPI HTMLStyleElement2_GetTypeInfo(IHTMLStyleElement2 *iface, UINT iTInfo,
+                                                    LCID lcid, ITypeInfo **ppTInfo)
+{
+    HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
+    return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
+                                   ppTInfo);
+}
+
+static HRESULT WINAPI HTMLStyleElement2_GetIDsOfNames(IHTMLStyleElement2 *iface, REFIID riid,
+        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
+{
+    HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
+    return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
+                                     cNames, lcid, rgDispId);
+}
+
+static HRESULT WINAPI HTMLStyleElement2_Invoke(IHTMLStyleElement2 *iface, DISPID dispIdMember,
+        REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
+        VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
+{
+    HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
+    return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
+                              lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+}
+
+static HRESULT WINAPI HTMLStyleElement2_get_sheet(IHTMLStyleElement2 *iface, IHTMLStyleSheet **p)
+{
+    HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
+    TRACE("(%p)->(%p)\n", This, p);
+    return IHTMLStyleElement_get_styleSheet(&This->IHTMLStyleElement_iface, p);
+}
+
+static const IHTMLStyleElement2Vtbl HTMLStyleElement2Vtbl = {
+    HTMLStyleElement2_QueryInterface,
+    HTMLStyleElement2_AddRef,
+    HTMLStyleElement2_Release,
+    HTMLStyleElement2_GetTypeInfoCount,
+    HTMLStyleElement2_GetTypeInfo,
+    HTMLStyleElement2_GetIDsOfNames,
+    HTMLStyleElement2_Invoke,
+    HTMLStyleElement2_get_sheet
+};
+
 static inline HTMLStyleElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
 {
     return CONTAINING_RECORD(iface, HTMLStyleElement, element.node);
@@ -300,6 +377,9 @@ static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
     }else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
         TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
         *ppv = &This->IHTMLStyleElement_iface;
+    }else if(IsEqualGUID(&IID_IHTMLStyleElement2, riid)) {
+        TRACE("(%p)->(IID_IHTMLStyleElement2 %p)\n", This, ppv);
+        *ppv = &This->IHTMLStyleElement2_iface;
     }else {
         return HTMLElement_QI(&This->element.node, riid, ppv);
     }
@@ -382,6 +462,7 @@ HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HT
         return E_OUTOFMEMORY;
 
     ret->IHTMLStyleElement_iface.lpVtbl = &HTMLStyleElementVtbl;
+    ret->IHTMLStyleElement2_iface.lpVtbl = &HTMLStyleElement2Vtbl;
     ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
 
     HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 2a269df5e4e..d6b71b0521b 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -236,6 +236,7 @@ typedef struct EventTarget EventTarget;
     XIID(IHTMLStyle5) \
     XIID(IHTMLStyle6) \
     XIID(IHTMLStyleElement) \
+    XIID(IHTMLStyleElement2) \
     XIID(IHTMLStyleSheet) \
     XIID(IHTMLStyleSheetRule) \
     XIID(IHTMLStyleSheetRulesCollection) \
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 1253e9cdea8..67d79780907 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -10100,6 +10100,7 @@ static void test_null_write(IHTMLDocument2 *doc)
 static void test_create_stylesheet(IHTMLDocument2 *doc)
 {
     IHTMLStyleSheet *stylesheet, *stylesheet2;
+    IHTMLStyleElement2 *style_elem2;
     IHTMLStyleElement *style_elem;
     IHTMLElement *doc_elem, *elem;
     HRESULT hres;
@@ -10142,8 +10143,18 @@ static void test_create_stylesheet(IHTMLDocument2 *doc)
     ok(hres == S_OK, "get_styleSheet failed: %08x\n", hres);
     ok(stylesheet2 != NULL, "stylesheet2 == NULL\n");
     ok(iface_cmp((IUnknown*)stylesheet, (IUnknown*)stylesheet2), "stylesheet != stylesheet2\n");
+    IHTMLStyleSheet_Release(stylesheet2);
+
+    hres = IHTMLStyleElement_QueryInterface(style_elem, &IID_IHTMLStyleElement2, (void**)&style_elem2);
+    ok(hres == S_OK, "Could not get IHTMLStyleElement2: %08x\n", hres);
 
+    hres = IHTMLStyleElement2_get_sheet(style_elem2, &stylesheet2);
+    ok(hres == S_OK, "get_styleSheet failed: %08x\n", hres);
+    ok(stylesheet2 != NULL, "stylesheet2 == NULL\n");
+    ok(iface_cmp((IUnknown*)stylesheet, (IUnknown*)stylesheet2), "stylesheet != stylesheet2\n");
     IHTMLStyleSheet_Release(stylesheet2);
+
+    IHTMLStyleElement2_Release(style_elem2);
     IHTMLStyleSheet_Release(stylesheet);
 
     IHTMLStyleElement_Release(style_elem);




More information about the wine-cvs mailing list