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

mshtml: Added IHTMLRect::get_top implementation.

parent 489320b9
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <math.h>
#define COBJMACROS #define COBJMACROS
...@@ -36,7 +37,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); ...@@ -36,7 +37,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
typedef struct { typedef struct {
DispatchEx dispex; DispatchEx dispex;
const IHTMLRectVtbl *lpIHTMLRectVtbl; const IHTMLRectVtbl *lpIHTMLRectVtbl;
LONG ref; LONG ref;
nsIDOMClientRect *nsrect;
} HTMLRect; } HTMLRect;
#define HTMLRECT(x) ((IHTMLRect*) &(x)->lpIHTMLRectVtbl) #define HTMLRECT(x) ((IHTMLRect*) &(x)->lpIHTMLRectVtbl)
...@@ -82,8 +86,11 @@ static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface) ...@@ -82,8 +86,11 @@ static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
if(!ref) if(!ref) {
if(This->nsrect)
nsIDOMClientRect_Release(This->nsrect);
heap_free(This); heap_free(This);
}
return ref; return ref;
} }
...@@ -145,8 +152,19 @@ static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v) ...@@ -145,8 +152,19 @@ static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p) static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
{ {
HTMLRect *This = HTMLRECT_THIS(iface); HTMLRect *This = HTMLRECT_THIS(iface);
FIXME("(%p)->(%p)\n", This, p); float top;
return E_NOTIMPL; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
if(NS_FAILED(nsres)) {
ERR("GetTop failed: %08x\n", nsres);
return E_FAIL;
}
*p = floor(top+0.5);
return S_OK;
} }
static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v) static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
...@@ -208,7 +226,7 @@ static dispex_static_data_t HTMLRect_dispex = { ...@@ -208,7 +226,7 @@ static dispex_static_data_t HTMLRect_dispex = {
HTMLRect_iface_tids HTMLRect_iface_tids
}; };
static HRESULT create_html_rect(IHTMLRect **ret) static HRESULT create_html_rect(nsIDOMClientRect *nsrect, IHTMLRect **ret)
{ {
HTMLRect *rect; HTMLRect *rect;
...@@ -221,6 +239,9 @@ static HRESULT create_html_rect(IHTMLRect **ret) ...@@ -221,6 +239,9 @@ static HRESULT create_html_rect(IHTMLRect **ret)
init_dispex(&rect->dispex, (IUnknown*)HTMLRECT(rect), &HTMLRect_dispex); init_dispex(&rect->dispex, (IUnknown*)HTMLRECT(rect), &HTMLRect_dispex);
nsIDOMClientRect_AddRef(nsrect);
rect->nsrect = nsrect;
*ret = HTMLRECT(rect); *ret = HTMLRECT(rect);
return S_OK; return S_OK;
} }
...@@ -556,10 +577,31 @@ static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRec ...@@ -556,10 +577,31 @@ static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRec
static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect) static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
{ {
HTMLElement *This = HTMLELEM2_THIS(iface); HTMLElement *This = HTMLELEM2_THIS(iface);
nsIDOMNSElement *nselem;
nsIDOMClientRect *nsrect;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, pRect); TRACE("(%p)->(%p)\n", This, pRect);
return create_html_rect(pRect); nsres = nsIDOMHTMLElement_QueryInterface(This->node.nsnode, &IID_nsIDOMNSElement,
(void**)&nselem);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMNSElement iface: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIDOMNSElement_GetBoundingClientRect(nselem, &nsrect);
nsIDOMNSElement_Release(nselem);
if(NS_FAILED(nsres) || !nsrect) {
ERR("GetBoindingClientRect failed: %08x\n", nsres);
return E_FAIL;
}
hres = create_html_rect(nsrect, pRect);
nsIDOMClientRect_Release(nsrect);
return hres;
} }
static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname, static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
......
...@@ -131,7 +131,6 @@ typedef nsISupports nsIDOMMediaList; ...@@ -131,7 +131,6 @@ typedef nsISupports nsIDOMMediaList;
typedef nsISupports nsIDOMHTMLTableCaptionElement; typedef nsISupports nsIDOMHTMLTableCaptionElement;
typedef nsISupports nsIDOMHTMLTableSectionElement; typedef nsISupports nsIDOMHTMLTableSectionElement;
typedef nsISupports nsIDOMClientRectList; typedef nsISupports nsIDOMClientRectList;
typedef nsISupports nsIDOMClientRect;
typedef nsISupports nsIDOMLocation; typedef nsISupports nsIDOMLocation;
typedef nsISupports nsIDocument; typedef nsISupports nsIDocument;
typedef nsISupports nsIContent; typedef nsISupports nsIContent;
...@@ -734,6 +733,22 @@ interface nsIDOMElementCSSInlineStyle : nsISupports ...@@ -734,6 +733,22 @@ interface nsIDOMElementCSSInlineStyle : nsISupports
[ [
object, object,
uuid(b2f824c4-d9d3-499b-8d3b-45c8245497c6),
local
/* NOT_FROZEN */
]
interface nsIDOMClientRect : nsISupports
{
nsresult GetLeft(float *aLeft);
nsresult GetTop(float *aTop);
nsresult GetRight(float *aRight);
nsresult GetBottom(float *aBottom);
nsresult GetWidth(float *aWidth);
nsresult GetHeight(float *aHeight);
}
[
object,
uuid(f0aef489-18c5-4de6-99d5-58b3758b098c), uuid(f0aef489-18c5-4de6-99d5-58b3758b098c),
local local
/* NOT_FROZEN */ /* NOT_FROZEN */
......
...@@ -2854,18 +2854,27 @@ static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char ...@@ -2854,18 +2854,27 @@ static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char
static void test_elem_bounding_client_rect(IUnknown *unk) static void test_elem_bounding_client_rect(IUnknown *unk)
{ {
IHTMLRect *rect, *rect2;
IHTMLElement2 *elem2; IHTMLElement2 *elem2;
IHTMLRect *rect; LONG l;
HRESULT hres; HRESULT hres;
elem2 = get_elem2_iface(unk); elem2 = get_elem2_iface(unk);
hres = IHTMLElement2_getBoundingClientRect(elem2, &rect); hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
IHTMLElement2_Release(elem2); IHTMLElement2_Release(elem2);
ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres); ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
ok(rect != NULL, "rect == NULL\n"); ok(rect != NULL, "rect == NULL\n");
ok(rect != rect2, "rect == rect2\n");
IHTMLRect_Release(rect2);
test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]"); test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]");
l = 0xdeadbeef;
hres = IHTMLRect_get_top(rect, &l);
ok(hres == S_OK, "get_top failed: %08x\n", hres);
ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
IHTMLRect_Release(rect); IHTMLRect_Release(rect);
} }
......
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