Commit 12ad9b0c authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Implement index access for HTMLStyleSheetRulesCollection.

parent d750a6b3
...@@ -375,13 +375,84 @@ static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtb ...@@ -375,13 +375,84 @@ static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtb
HTMLStyleSheetRulesCollection_item HTMLStyleSheetRulesCollection_item
}; };
static inline HTMLStyleSheetRulesCollection *HTMLStyleSheetRulesCollection_from_DispatchEx(DispatchEx *iface)
{
return CONTAINING_RECORD(iface, HTMLStyleSheetRulesCollection, dispex);
}
static HRESULT HTMLStyleSheetRulesCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
{
HTMLStyleSheetRulesCollection *This = HTMLStyleSheetRulesCollection_from_DispatchEx(dispex);
UINT32 len = 0;
DWORD idx = 0;
WCHAR *ptr;
for(ptr = name; *ptr && is_digit(*ptr); ptr++)
idx = idx*10 + (*ptr-'0');
if(*ptr)
return DISP_E_UNKNOWNNAME;
nsIDOMCSSRuleList_GetLength(This->nslist, &len);
if(idx >= len)
return DISP_E_UNKNOWNNAME;
*dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
TRACE("ret %x\n", *dispid);
return S_OK;
}
static HRESULT HTMLStyleSheetRulesCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
{
HTMLStyleSheetRulesCollection *This = HTMLStyleSheetRulesCollection_from_DispatchEx(dispex);
TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
switch(flags) {
case DISPATCH_PROPERTYGET: {
IHTMLStyleSheetRule *stylesheetrule;
nsIDOMCSSRule *nsstylesheetrule;
nsresult nsres;
HRESULT hres;
nsres = nsIDOMCSSRuleList_Item(This->nslist, id - MSHTML_DISPID_CUSTOM_MIN, &nsstylesheetrule);
if(NS_FAILED(nsres))
return DISP_E_MEMBERNOTFOUND;
if(!nsstylesheetrule) {
V_VT(res) = VT_EMPTY;
return S_OK;
}
hres = create_style_sheet_rule(nsstylesheetrule, dispex_compat_mode(&This->dispex), &stylesheetrule);
nsIDOMCSSRule_Release(nsstylesheetrule);
if(FAILED(hres))
return hres;
V_VT(res) = VT_DISPATCH;
V_DISPATCH(res) = (IDispatch*)stylesheetrule;
break;
}
default:
FIXME("unimplemented flags %x\n", flags);
return E_NOTIMPL;
}
return S_OK;
}
static const dispex_static_data_vtbl_t HTMLStyleSheetRulesCollection_dispex_vtbl = {
NULL,
HTMLStyleSheetRulesCollection_get_dispid,
HTMLStyleSheetRulesCollection_invoke
};
static const tid_t HTMLStyleSheetRulesCollection_iface_tids[] = { static const tid_t HTMLStyleSheetRulesCollection_iface_tids[] = {
IHTMLStyleSheetRulesCollection_tid, IHTMLStyleSheetRulesCollection_tid,
0 0
}; };
static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex = { static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex = {
L"MSCSSRuleList", L"MSCSSRuleList",
NULL, &HTMLStyleSheetRulesCollection_dispex_vtbl,
DispHTMLStyleSheetRulesCollection_tid, DispHTMLStyleSheetRulesCollection_tid,
HTMLStyleSheetRulesCollection_iface_tids HTMLStyleSheetRulesCollection_iface_tids
}; };
......
...@@ -226,7 +226,7 @@ sync_test("builtin_toString", function() { ...@@ -226,7 +226,7 @@ sync_test("builtin_toString", function() {
test("sessionStorage", window.sessionStorage, "Storage"); test("sessionStorage", window.sessionStorage, "Storage");
test("style", document.body.style, "MSStyleCSSProperties"); test("style", document.body.style, "MSStyleCSSProperties");
test("styleSheet", sheet, "CSSStyleSheet"); test("styleSheet", sheet, "CSSStyleSheet");
test("styleSheetRule", sheet.rules.item(0), "CSSStyleRule"); test("styleSheetRule", sheet.rules[0], "CSSStyleRule");
test("styleSheetRules", sheet.rules, "MSCSSRuleList"); test("styleSheetRules", sheet.rules, "MSCSSRuleList");
test("styleSheets", document.styleSheets, "StyleSheetList"); test("styleSheets", document.styleSheets, "StyleSheetList");
test("textNode", document.createTextNode("testNode"), "Text", v < 9 ? "testNode" : null); test("textNode", document.createTextNode("testNode"), "Text", v < 9 ? "testNode" : null);
......
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