Jacek Caban : mshtml: Initialize HTMLStyleSheetsCollection object with compat mode.

Alexandre Julliard julliard at winehq.org
Mon Mar 15 16:59:13 CDT 2021


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Mar 15 16:18:24 2021 +0100

mshtml: Initialize HTMLStyleSheetsCollection object with compat mode.

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

---

 dlls/mshtml/htmldoc.c        |  9 +++++----
 dlls/mshtml/htmlstylesheet.c | 21 +++++++++++++--------
 dlls/mshtml/mshtml_private.h |  3 ++-
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index ad3ce941002..ad326f858ee 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1647,6 +1647,7 @@ static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
     HTMLDocument *This = impl_from_IHTMLDocument2(iface);
     nsIDOMStyleSheetList *nsstylelist;
     nsresult nsres;
+    HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
 
@@ -1660,13 +1661,13 @@ static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
     nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
     if(NS_FAILED(nsres)) {
         ERR("GetStyleSheets failed: %08x\n", nsres);
-        return E_FAIL;
+        return map_nsresult(nsres);
     }
 
-    *p = HTMLStyleSheetsCollection_Create(nsstylelist);
+    hres = create_style_sheet_collection(nsstylelist,
+                                         dispex_compat_mode(&This->doc_node->node.event_target.dispex), p);
     nsIDOMStyleSheetList_Release(nsstylelist);
-
-    return S_OK;
+    return hres;
 }
 
 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c
index 8d535a657a9..b3ea09e8333 100644
--- a/dlls/mshtml/htmlstylesheet.c
+++ b/dlls/mshtml/htmlstylesheet.c
@@ -573,21 +573,26 @@ static dispex_static_data_t HTMLStyleSheetsCollection_dispex = {
     HTMLStyleSheetsCollection_iface_tids
 };
 
-IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList *nslist)
+HRESULT create_style_sheet_collection(nsIDOMStyleSheetList *nslist, compat_mode_t compat_mode,
+                                      IHTMLStyleSheetsCollection **ret)
 {
-    HTMLStyleSheetsCollection *ret = heap_alloc(sizeof(HTMLStyleSheetsCollection));
+    HTMLStyleSheetsCollection *collection;
 
-    ret->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl;
-    ret->ref = 1;
+    if(!(collection = heap_alloc(sizeof(HTMLStyleSheetsCollection))))
+        return E_OUTOFMEMORY;
+
+    collection->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl;
+    collection->ref = 1;
 
     if(nslist)
         nsIDOMStyleSheetList_AddRef(nslist);
-    ret->nslist = nslist;
+    collection->nslist = nslist;
 
-    init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheetsCollection_iface,
-            &HTMLStyleSheetsCollection_dispex);
+    init_dispex_with_compat_mode(&collection->dispex, (IUnknown*)&collection->IHTMLStyleSheetsCollection_iface,
+                                 &HTMLStyleSheetsCollection_dispex, compat_mode);
 
-    return &ret->IHTMLStyleSheetsCollection_iface;
+    *ret = &collection->IHTMLStyleSheetsCollection_iface;
+    return S_OK;
 }
 
 static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet(IHTMLStyleSheet *iface)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 735f9279b04..5fc049cf80f 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -1020,7 +1020,8 @@ HRESULT get_readystate_string(READYSTATE,BSTR*) DECLSPEC_HIDDEN;
 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**) DECLSPEC_HIDDEN;
 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**) DECLSPEC_HIDDEN;
 HRESULT create_style_sheet(nsIDOMStyleSheet*,compat_mode_t,IHTMLStyleSheet**) DECLSPEC_HIDDEN;
-IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*) DECLSPEC_HIDDEN;
+HRESULT create_style_sheet_collection(nsIDOMStyleSheetList*,compat_mode_t,
+                                      IHTMLStyleSheetsCollection**) DECLSPEC_HIDDEN;
 HRESULT HTMLDOMRange_Create(nsIDOMRange*,IHTMLDOMRange**) DECLSPEC_HIDDEN;
 HRESULT create_markup_pointer(IMarkupPointer**) DECLSPEC_HIDDEN;
 




More information about the wine-cvs mailing list