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;