diff --git a/dlls/mshtml/htmlelem2.c b/dlls/mshtml/htmlelem2.c index 80854425486..a1df1d67249 100644 --- a/dlls/mshtml/htmlelem2.c +++ b/dlls/mshtml/htmlelem2.c @@ -738,8 +738,26 @@ static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, long * static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, long *p) { HTMLElement *This = HTMLELEM2_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsIDOMNSHTMLElement *nselem; + PRInt32 width = 0; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem); + if(NS_SUCCEEDED(nsres)) { + nsres = nsIDOMNSHTMLElement_GetScrollWidth(nselem, &width); + nsIDOMNSHTMLElement_Release(nselem); + if(NS_FAILED(nsres)) + ERR("GetScrollWidth failed: %08x\n", nsres); + }else { + ERR("Could not get nsIDOMNSHTMLElement interface: %08x\n", nsres); + } + + *p = width; + TRACE("*p = %ld\n", *p); + + return S_OK; } static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, long v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 18b229038c9..3a06d6ad352 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -991,6 +991,29 @@ static long _elem_get_scroll_height(unsigned line, IUnknown *unk) return l; } +#define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u) +static long _elem_get_scroll_width(unsigned line, IUnknown *unk) +{ + IHTMLElement2 *elem = _get_elem2_iface(line, unk); + IHTMLTextContainer *txtcont; + long l = -1, l2 = -1; + HRESULT hres; + + hres = IHTMLElement2_get_scrollWidth(elem, &l); + ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres); + IHTMLElement2_Release(elem); + + hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont); + ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres); + + hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2); + IHTMLTextContainer_Release(txtcont); + ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %ld\n", l2); + ok_(__FILE__,line) (l == l2, "unexpected width %ld, expected %ld\n", l2, l); + + return l; +} + #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s) static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src) { @@ -1967,6 +1990,8 @@ static void test_default_body(IHTMLBodyElement *body) l = elem_get_scroll_height((IUnknown*)body); ok(l != -1, "scrollHeight == -1\n"); + l = elem_get_scroll_width((IUnknown*)body); + ok(l != -1, "scrollWidth == -1\n"); } static void test_window(IHTMLDocument2 *doc)