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

mshtml: Added support for VT_UINT name in IHTMLElementCollection::item.

parent e3491652
...@@ -236,39 +236,43 @@ static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name) ...@@ -236,39 +236,43 @@ static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name)
return ret; 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, static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
VARIANT name, VARIANT index, IDispatch **pdisp) VARIANT name, VARIANT index, IDispatch **pdisp)
{ {
HTMLElementCollection *This = ELEMCOL_THIS(iface); 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; *pdisp = NULL;
if(V_VT(&name) == VT_I4) { switch(V_VT(&name)) {
TRACE("name is VT_I4: %d\n", V_I4(&name)); case VT_I4:
if(V_I4(&name) < 0) if(V_I4(&name) < 0)
return E_INVALIDARG; return E_INVALIDARG;
if(V_I4(&name) >= This->len) hres = get_item_idx(This, V_I4(&name), pdisp);
return S_OK; break;
*pdisp = (IDispatch*)This->elems[V_I4(&name)]; case VT_UINT:
IDispatch_AddRef(*pdisp); hres = get_item_idx(This, V_UINT(&name), pdisp);
TRACE("Returning pdisp=%p\n", pdisp); break;
return S_OK;
}
if(V_VT(&name) == VT_BSTR) { case VT_BSTR: {
DWORD i; DWORD i;
TRACE("name is VT_BSTR: %s\n", debugstr_w(V_BSTR(&name)));
if(V_VT(&index) == VT_I4) { if(V_VT(&index) == VT_I4) {
LONG idx = V_I4(&index); LONG idx = V_I4(&index);
TRACE("index = %d\n", idx);
if(idx < 0) if(idx < 0)
return E_INVALIDARG; return E_INVALIDARG;
...@@ -281,8 +285,6 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface, ...@@ -281,8 +285,6 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
*pdisp = (IDispatch*)HTMLELEM(This->elems[i]); *pdisp = (IDispatch*)HTMLELEM(This->elems[i]);
IDispatch_AddRef(*pdisp); IDispatch_AddRef(*pdisp);
} }
return S_OK;
}else { }else {
elem_vector_t buf = {NULL, 0, 8}; elem_vector_t buf = {NULL, 0, 8};
...@@ -304,13 +306,18 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface, ...@@ -304,13 +306,18 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
heap_free(buf.buf); heap_free(buf.buf);
} }
return S_OK;
} }
break;
} }
FIXME("unsupported arguments\n"); default:
return E_INVALIDARG; 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, static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface,
......
...@@ -1025,7 +1025,7 @@ static void _test_elem_collection(unsigned line, IUnknown *unk, ...@@ -1025,7 +1025,7 @@ static void _test_elem_collection(unsigned line, IUnknown *unk,
LONG len; LONG len;
DWORD i; DWORD i;
VARIANT name, index; VARIANT name, index;
IDispatch *disp; IDispatch *disp, *disp2;
HRESULT hres; HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col); hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
...@@ -1041,9 +1041,9 @@ static void _test_elem_collection(unsigned line, IUnknown *unk, ...@@ -1041,9 +1041,9 @@ static void _test_elem_collection(unsigned line, IUnknown *unk,
len = exlen; len = exlen;
V_VT(&index) = VT_EMPTY; V_VT(&index) = VT_EMPTY;
V_VT(&name) = VT_I4;
for(i=0; i<len; i++) { for(i=0; i<len; i++) {
V_VT(&name) = VT_I4;
V_I4(&name) = i; V_I4(&name) = i;
disp = (void*)0xdeadbeef; disp = (void*)0xdeadbeef;
hres = IHTMLElementCollection_item(col, name, index, &disp); hres = IHTMLElementCollection_item(col, name, index, &disp);
...@@ -1053,15 +1053,29 @@ static void _test_elem_collection(unsigned line, IUnknown *unk, ...@@ -1053,15 +1053,29 @@ static void _test_elem_collection(unsigned line, IUnknown *unk,
continue; continue;
_test_elem_type(line, (IUnknown*)disp, elem_types[i]); _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); IDispatch_Release(disp);
} }
V_VT(&name) = VT_I4;
V_I4(&name) = len; V_I4(&name) = len;
disp = (void*)0xdeadbeef; disp = (void*)0xdeadbeef;
hres = IHTMLElementCollection_item(col, name, index, &disp); hres = IHTMLElementCollection_item(col, name, index, &disp);
ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres); ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
ok_(__FILE__,line) (disp == NULL, "disp != NULL\n"); ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
V_VT(&name) = VT_I4;
V_I4(&name) = -1; V_I4(&name) = -1;
disp = (void*)0xdeadbeef; disp = (void*)0xdeadbeef;
hres = IHTMLElementCollection_item(col, name, index, &disp); hres = IHTMLElementCollection_item(col, name, index, &disp);
......
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