Jacek Caban : mshtml: Added IHTMLRect::get_top implementation.
Alexandre Julliard
julliard at winehq.org
Mon Jul 19 11:05:30 CDT 2010
Module: wine
Branch: master
Commit: bbaefeb3b5154d1646820527728169e8fd291cbf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bbaefeb3b5154d1646820527728169e8fd291cbf
Author: Jacek Caban <jacek at codeweavers.com>
Date: Sat Jul 17 13:30:43 2010 +0200
mshtml: Added IHTMLRect::get_top implementation.
---
dlls/mshtml/htmlelem2.c | 52 ++++++++++++++++++++++++++++++++++++++++++----
dlls/mshtml/nsiface.idl | 17 ++++++++++++++-
dlls/mshtml/tests/dom.c | 11 +++++++++-
3 files changed, 73 insertions(+), 7 deletions(-)
diff --git a/dlls/mshtml/htmlelem2.c b/dlls/mshtml/htmlelem2.c
index b6030b8..251763f 100644
--- a/dlls/mshtml/htmlelem2.c
+++ b/dlls/mshtml/htmlelem2.c
@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
+#include <math.h>
#define COBJMACROS
@@ -36,7 +37,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
typedef struct {
DispatchEx dispex;
const IHTMLRectVtbl *lpIHTMLRectVtbl;
+
LONG ref;
+
+ nsIDOMClientRect *nsrect;
} HTMLRect;
#define HTMLRECT(x) ((IHTMLRect*) &(x)->lpIHTMLRectVtbl)
@@ -82,8 +86,11 @@ static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
TRACE("(%p) ref=%d\n", This, ref);
- if(!ref)
+ if(!ref) {
+ if(This->nsrect)
+ nsIDOMClientRect_Release(This->nsrect);
heap_free(This);
+ }
return ref;
}
@@ -145,8 +152,19 @@ static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
{
HTMLRect *This = HTMLRECT_THIS(iface);
- FIXME("(%p)->(%p)\n", This, p);
- return E_NOTIMPL;
+ float top;
+ 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)
@@ -208,7 +226,7 @@ static dispex_static_data_t HTMLRect_dispex = {
HTMLRect_iface_tids
};
-static HRESULT create_html_rect(IHTMLRect **ret)
+static HRESULT create_html_rect(nsIDOMClientRect *nsrect, IHTMLRect **ret)
{
HTMLRect *rect;
@@ -221,6 +239,9 @@ static HRESULT create_html_rect(IHTMLRect **ret)
init_dispex(&rect->dispex, (IUnknown*)HTMLRECT(rect), &HTMLRect_dispex);
+ nsIDOMClientRect_AddRef(nsrect);
+ rect->nsrect = nsrect;
+
*ret = HTMLRECT(rect);
return S_OK;
}
@@ -556,10 +577,31 @@ static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRec
static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
{
HTMLElement *This = HTMLELEM2_THIS(iface);
+ nsIDOMNSElement *nselem;
+ nsIDOMClientRect *nsrect;
+ nsresult nsres;
+ HRESULT hres;
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,
diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl
index 4ccc64a..b62c7b2 100644
--- a/dlls/mshtml/nsiface.idl
+++ b/dlls/mshtml/nsiface.idl
@@ -131,7 +131,6 @@ typedef nsISupports nsIDOMMediaList;
typedef nsISupports nsIDOMHTMLTableCaptionElement;
typedef nsISupports nsIDOMHTMLTableSectionElement;
typedef nsISupports nsIDOMClientRectList;
-typedef nsISupports nsIDOMClientRect;
typedef nsISupports nsIDOMLocation;
typedef nsISupports nsIDocument;
typedef nsISupports nsIContent;
@@ -734,6 +733,22 @@ interface nsIDOMElementCSSInlineStyle : nsISupports
[
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),
local
/* NOT_FROZEN */
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index c877b96..fa3763c 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -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)
{
+ IHTMLRect *rect, *rect2;
IHTMLElement2 *elem2;
- IHTMLRect *rect;
+ LONG l;
HRESULT hres;
elem2 = get_elem2_iface(unk);
hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
+ hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
IHTMLElement2_Release(elem2);
ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
ok(rect != NULL, "rect == NULL\n");
+ ok(rect != rect2, "rect == rect2\n");
+ IHTMLRect_Release(rect2);
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);
}
More information about the wine-cvs
mailing list