Module: wine Branch: master Commit: 4633304cde2aeeb363b303a238ccedeb366cce5d URL: https://source.winehq.org/git/wine.git/?a=commit;h=4633304cde2aeeb363b303a23...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Jun 29 16:49:57 2020 +0200
mshtml: Add IHTMLRectCollection::item implementation.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mshtml/htmlelem.c | 30 ++++++++++++++++++++++++++++-- dlls/mshtml/tests/dom.c | 14 ++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index a594337ead..6578ee7510 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -671,8 +671,34 @@ static HRESULT WINAPI HTMLRectCollection_get__newEnum(IHTMLRectCollection *iface static HRESULT WINAPI HTMLRectCollection_item(IHTMLRectCollection *iface, VARIANT *index, VARIANT *result) { HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface); - FIXME("(%p)->(%s %p)\n", This, debugstr_variant(index), result); - return E_NOTIMPL; + nsIDOMClientRect *nsrect; + IHTMLRect *rect; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%s %p)\n", This, debugstr_variant(index), result); + + if(V_VT(index) != VT_I4 || V_I4(index) < 0) { + FIXME("Unsupported for %s index\n", debugstr_variant(index)); + return E_NOTIMPL; + } + + nsres = nsIDOMClientRectList_Item(This->rect_list, V_I4(index), &nsrect); + if(NS_FAILED(nsres)) + return map_nsresult(nsres); + if(!nsrect) { + V_VT(result) = VT_NULL; + return S_OK; + } + + hres = create_html_rect(nsrect, &rect); + nsIDOMClientRect_Release(nsrect); + if(FAILED(hres)) + return hres; + + V_VT(result) = VT_DISPATCH; + V_DISPATCH(result) = (IDispatch *)rect; + return S_OK; }
static const IHTMLRectCollectionVtbl HTMLRectCollectionVtbl = { diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 89785123c6..3aee3dfb7b 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -5144,6 +5144,7 @@ static void test_elem_bounding_client_rect(IUnknown *unk) IHTMLRectCollection *rects; IHTMLRect *rect, *rect2; IHTMLElement2 *elem2; + VARIANT v, index; LONG l; HRESULT hres;
@@ -5185,6 +5186,19 @@ static void test_elem_bounding_client_rect(IUnknown *unk)
test_disp((IUnknown*)rects, &IID_IHTMLRectCollection, NULL, L"[object]");
+ hres = IHTMLRectCollection_get_length(rects, &l); + ok(hres == S_OK, "get_length failed: %08x\n", hres); + ok(l == 1, "length = %u\n", l); + + V_VT(&index) = VT_I4; + V_I4(&index) = 0; + V_VT(&v) = VT_ERROR; + hres = IHTMLRectCollection_item(rects, &index, &v); + ok(hres == S_OK, "item failed: %08x\n", hres); + ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v)); + test_disp((IUnknown*)V_DISPATCH(&v), &IID_IHTMLRect, NULL, L"[object]"); + VariantClear(&v); + IHTMLRectCollection_Release(rects); IHTMLElement2_Release(elem2); }