mirror of
https://github.com/reactos/wine.git
synced 2024-11-28 22:20:26 +00:00
mshtml: Added support for VT_UINT name in IHTMLElementCollection::item.
This commit is contained in:
parent
e349165214
commit
cf2e8619ef
@ -236,39 +236,43 @@ static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static HRESULT get_item_idx(HTMLElementCollection *This, UINT idx, IDispatch **ret)
|
||||
{
|
||||
if(idx < This->len) {
|
||||
*ret = (IDispatch*)This->elems[idx];
|
||||
IDispatch_AddRef(*ret);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
|
||||
VARIANT name, VARIANT index, IDispatch **pdisp)
|
||||
{
|
||||
HTMLElementCollection *This = ELEMCOL_THIS(iface);
|
||||
HRESULT hres = S_OK;
|
||||
|
||||
TRACE("(%p)->(v(%d) v(%d) %p)\n", This, V_VT(&name), V_VT(&index), pdisp);
|
||||
TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&name), debugstr_variant(&index), pdisp);
|
||||
|
||||
*pdisp = NULL;
|
||||
|
||||
if(V_VT(&name) == VT_I4) {
|
||||
TRACE("name is VT_I4: %d\n", V_I4(&name));
|
||||
|
||||
switch(V_VT(&name)) {
|
||||
case VT_I4:
|
||||
if(V_I4(&name) < 0)
|
||||
return E_INVALIDARG;
|
||||
if(V_I4(&name) >= This->len)
|
||||
return S_OK;
|
||||
hres = get_item_idx(This, V_I4(&name), pdisp);
|
||||
break;
|
||||
|
||||
*pdisp = (IDispatch*)This->elems[V_I4(&name)];
|
||||
IDispatch_AddRef(*pdisp);
|
||||
TRACE("Returning pdisp=%p\n", pdisp);
|
||||
return S_OK;
|
||||
}
|
||||
case VT_UINT:
|
||||
hres = get_item_idx(This, V_UINT(&name), pdisp);
|
||||
break;
|
||||
|
||||
if(V_VT(&name) == VT_BSTR) {
|
||||
case VT_BSTR: {
|
||||
DWORD i;
|
||||
|
||||
TRACE("name is VT_BSTR: %s\n", debugstr_w(V_BSTR(&name)));
|
||||
|
||||
if(V_VT(&index) == VT_I4) {
|
||||
LONG idx = V_I4(&index);
|
||||
|
||||
TRACE("index = %d\n", idx);
|
||||
|
||||
if(idx < 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
@ -281,8 +285,6 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
|
||||
*pdisp = (IDispatch*)HTMLELEM(This->elems[i]);
|
||||
IDispatch_AddRef(*pdisp);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}else {
|
||||
elem_vector_t buf = {NULL, 0, 8};
|
||||
|
||||
@ -304,13 +306,18 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
|
||||
|
||||
heap_free(buf.buf);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
FIXME("unsupported arguments\n");
|
||||
return E_INVALIDARG;
|
||||
default:
|
||||
FIXME("Unsupported name %s\n", debugstr_variant(&name));
|
||||
hres = E_NOTIMPL;
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hres))
|
||||
TRACE("returning %p\n", *pdisp);
|
||||
return hres;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface,
|
||||
|
@ -1025,7 +1025,7 @@ static void _test_elem_collection(unsigned line, IUnknown *unk,
|
||||
LONG len;
|
||||
DWORD i;
|
||||
VARIANT name, index;
|
||||
IDispatch *disp;
|
||||
IDispatch *disp, *disp2;
|
||||
HRESULT hres;
|
||||
|
||||
hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
|
||||
@ -1041,9 +1041,9 @@ static void _test_elem_collection(unsigned line, IUnknown *unk,
|
||||
len = exlen;
|
||||
|
||||
V_VT(&index) = VT_EMPTY;
|
||||
V_VT(&name) = VT_I4;
|
||||
|
||||
for(i=0; i<len; i++) {
|
||||
V_VT(&name) = VT_I4;
|
||||
V_I4(&name) = i;
|
||||
disp = (void*)0xdeadbeef;
|
||||
hres = IHTMLElementCollection_item(col, name, index, &disp);
|
||||
@ -1053,15 +1053,29 @@ static void _test_elem_collection(unsigned line, IUnknown *unk,
|
||||
continue;
|
||||
|
||||
_test_elem_type(line, (IUnknown*)disp, elem_types[i]);
|
||||
|
||||
if(!i) {
|
||||
V_VT(&name) = VT_UINT;
|
||||
V_I4(&name) = 0;
|
||||
disp2 = (void*)0xdeadbeef;
|
||||
hres = IHTMLElementCollection_item(col, name, index, &disp2);
|
||||
ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
|
||||
ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
|
||||
if(disp2)
|
||||
IDispatch_Release(disp2);
|
||||
}
|
||||
|
||||
IDispatch_Release(disp);
|
||||
}
|
||||
|
||||
V_VT(&name) = VT_I4;
|
||||
V_I4(&name) = len;
|
||||
disp = (void*)0xdeadbeef;
|
||||
hres = IHTMLElementCollection_item(col, name, index, &disp);
|
||||
ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
|
||||
ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
|
||||
|
||||
V_VT(&name) = VT_I4;
|
||||
V_I4(&name) = -1;
|
||||
disp = (void*)0xdeadbeef;
|
||||
hres = IHTMLElementCollection_item(col, name, index, &disp);
|
||||
|
Loading…
Reference in New Issue
Block a user