Module: wine Branch: master Commit: 1597967417caa123153bec5b307f31ed7fd5fa18 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1597967417caa123153bec5b30...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Apr 29 01:38:41 2008 +0200
mshtml: Added indexed access to HTMLElementCollection object support.
---
dlls/mshtml/htmlelem.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 51 insertions(+), 1 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index faf888c..f9b416a 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1651,6 +1651,51 @@ static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface, return S_OK; }
+#define DISPID_ELEMCOL_0 MSHTML_DISPID_CUSTOM_MIN + +static HRESULT HTMLElementCollection_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid) +{ + HTMLElementCollection *This = ELEMCOL_THIS(iface); + WCHAR *ptr; + DWORD idx=0; + + for(ptr = name; *ptr && isdigitW(*ptr); ptr++) + idx = idx*10 + (*ptr-'0'); + + if(*ptr || idx >= This->len) + return DISP_E_UNKNOWNNAME; + + *dispid = DISPID_ELEMCOL_0 + idx; + TRACE("ret %x\n", *dispid); + return S_OK; +} + +static HRESULT HTMLElementCollection_invoke(IUnknown *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, + VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) +{ + HTMLElementCollection *This = ELEMCOL_THIS(iface); + DWORD idx; + + TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller); + + idx = id - DISPID_ELEMCOL_0; + if(idx >= This->len) + return DISP_E_UNKNOWNNAME; + + switch(flags) { + case INVOKE_PROPERTYGET: + V_VT(res) = VT_DISPATCH; + V_DISPATCH(res) = (IDispatch*)HTMLELEM(This->elems[idx]); + IHTMLElement_AddRef(HTMLELEM(This->elems[idx])); + break; + default: + FIXME("unimplemented flags %x\n", flags); + return E_NOTIMPL; + } + + return S_OK; +} + #undef ELEMCOL_THIS
static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl = { @@ -1669,8 +1714,13 @@ static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl = { HTMLElementCollection_tags };
+static const dispex_static_data_vtbl_t HTMLElementColection_dispex_vtbl = { + HTMLElementCollection_get_dispid, + HTMLElementCollection_invoke +}; + static dispex_static_data_t HTMLElementCollection_dispex = { - NULL, + &HTMLElementColection_dispex_vtbl, DispHTMLElementCollection_tid, NULL, {