Commit f35737a0 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Initialize HTMLStyleSheet object with compat mode.

parent 51e348e9
......@@ -1733,8 +1733,8 @@ static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR
if(bstrHref && *bstrHref) {
FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
*ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
return S_OK;
return create_style_sheet(NULL, dispex_compat_mode(&This->doc_node->node.event_target.dispex),
ppnewStyleSheet);
}
hres = create_element(This->doc_node, L"style", &elem);
......
......@@ -198,10 +198,11 @@ static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface,
assert(nsres == NS_OK);
if(ss) {
This->style_sheet = HTMLStyleSheet_Create(ss);
HRESULT hres = create_style_sheet(ss, dispex_compat_mode(&This->element.node.event_target.dispex),
&This->style_sheet);
nsIDOMStyleSheet_Release(ss);
if(!This->style_sheet)
return E_OUTOFMEMORY;
if(FAILED(hres))
return hres;
}
}
......
......@@ -517,7 +517,9 @@ static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection
switch(V_VT(pvarIndex)) {
case VT_I4: {
nsIDOMStyleSheet *nsstylesheet;
IHTMLStyleSheet *stylesheet;
nsresult nsres;
HRESULT hres;
TRACE("index=%d\n", V_I4(pvarIndex));
......@@ -528,9 +530,12 @@ static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection
return E_INVALIDARG;
}
V_VT(pvarResult) = VT_DISPATCH;
V_DISPATCH(pvarResult) = (IDispatch*)HTMLStyleSheet_Create(nsstylesheet);
hres = create_style_sheet(nsstylesheet, dispex_compat_mode(&This->dispex), &stylesheet);
if(FAILED(hres))
return hres;
V_VT(pvarResult) = VT_DISPATCH;
V_DISPATCH(pvarResult) = (IDispatch*)stylesheet;
return S_OK;
}
......@@ -938,23 +943,28 @@ static dispex_static_data_t HTMLStyleSheet_dispex = {
HTMLStyleSheet_iface_tids
};
IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
HRESULT create_style_sheet(nsIDOMStyleSheet *nsstylesheet, compat_mode_t compat_mode, IHTMLStyleSheet **ret)
{
HTMLStyleSheet *ret = heap_alloc(sizeof(HTMLStyleSheet));
HTMLStyleSheet *style_sheet;
nsresult nsres;
ret->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl;
ret->ref = 1;
ret->nsstylesheet = NULL;
if(!(style_sheet = heap_alloc(sizeof(HTMLStyleSheet))))
return E_OUTOFMEMORY;
init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheet_iface, &HTMLStyleSheet_dispex);
style_sheet->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl;
style_sheet->ref = 1;
style_sheet->nsstylesheet = NULL;
init_dispex_with_compat_mode(&style_sheet->dispex, (IUnknown*)&style_sheet->IHTMLStyleSheet_iface,
&HTMLStyleSheet_dispex, compat_mode);
if(nsstylesheet) {
nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
(void**)&ret->nsstylesheet);
(void**)&style_sheet->nsstylesheet);
if(NS_FAILED(nsres))
ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
}
return &ret->IHTMLStyleSheet_iface;
*ret = &style_sheet->IHTMLStyleSheet_iface;
return S_OK;
}
......@@ -1019,7 +1019,7 @@ HRESULT get_readystate_string(READYSTATE,BSTR*) DECLSPEC_HIDDEN;
HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**) DECLSPEC_HIDDEN;
HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**) DECLSPEC_HIDDEN;
IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*) DECLSPEC_HIDDEN;
HRESULT create_style_sheet(nsIDOMStyleSheet*,compat_mode_t,IHTMLStyleSheet**) DECLSPEC_HIDDEN;
IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*) DECLSPEC_HIDDEN;
HRESULT HTMLDOMRange_Create(nsIDOMRange*,IHTMLDOMRange**) DECLSPEC_HIDDEN;
HRESULT create_markup_pointer(IMarkupPointer**) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment