Commit 8b0868c1 authored by Evan Tang's avatar Evan Tang Committed by Alexandre Julliard

mshtml: Implement IHTMLRect2 for HTMLRect.

parent 8870d51d
...@@ -529,6 +529,7 @@ HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **re ...@@ -529,6 +529,7 @@ HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **re
typedef struct { typedef struct {
DispatchEx dispex; DispatchEx dispex;
IHTMLRect IHTMLRect_iface; IHTMLRect IHTMLRect_iface;
IHTMLRect2 IHTMLRect2_iface;
LONG ref; LONG ref;
...@@ -550,6 +551,8 @@ static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, voi ...@@ -550,6 +551,8 @@ static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, voi
*ppv = &This->IHTMLRect_iface; *ppv = &This->IHTMLRect_iface;
}else if(IsEqualGUID(&IID_IHTMLRect, riid)) { }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
*ppv = &This->IHTMLRect_iface; *ppv = &This->IHTMLRect_iface;
}else if (IsEqualGUID(&IID_IHTMLRect2, riid)) {
*ppv = &This->IHTMLRect2_iface;
}else if(dispex_query_interface(&This->dispex, riid, ppv)) { }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
return *ppv ? S_OK : E_NOINTERFACE; return *ppv ? S_OK : E_NOINTERFACE;
}else { }else {
...@@ -723,6 +726,91 @@ static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p) ...@@ -723,6 +726,91 @@ static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
return S_OK; return S_OK;
} }
static inline HTMLRect *impl_from_IHTMLRect2(IHTMLRect2 *iface)
{
return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect2_iface);
}
static HRESULT WINAPI HTMLRect2_QueryInterface(IHTMLRect2 *iface, REFIID riid, void **ppv)
{
HTMLRect *This = impl_from_IHTMLRect2(iface);
return IHTMLRect_QueryInterface(&This->IHTMLRect_iface, riid, ppv);
}
static ULONG WINAPI HTMLRect2_AddRef(IHTMLRect2 *iface)
{
HTMLRect *This = impl_from_IHTMLRect2(iface);
return IHTMLRect_AddRef(&This->IHTMLRect_iface);
}
static ULONG WINAPI HTMLRect2_Release(IHTMLRect2 *iface)
{
HTMLRect *This = impl_from_IHTMLRect2(iface);
return IHTMLRect_Release(&This->IHTMLRect_iface);
}
static HRESULT WINAPI HTMLRect2_GetTypeInfoCount(IHTMLRect2 *iface, UINT *pctinfo)
{
HTMLRect *This = impl_from_IHTMLRect2(iface);
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
}
static HRESULT WINAPI HTMLRect2_GetTypeInfo(IHTMLRect2 *iface, UINT iTInfo,
LCID lcid, ITypeInfo **ppTInfo)
{
HTMLRect *This = impl_from_IHTMLRect2(iface);
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
}
static HRESULT WINAPI HTMLRect2_GetIDsOfNames(IHTMLRect2 *iface, REFIID riid,
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
HTMLRect *This = impl_from_IHTMLRect2(iface);
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
lcid, rgDispId);
}
static HRESULT WINAPI HTMLRect2_Invoke(IHTMLRect2 *iface, DISPID dispIdMember,
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
HTMLRect *This = impl_from_IHTMLRect2(iface);
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
}
static HRESULT WINAPI HTMLRect2_get_width(IHTMLRect2 *iface, FLOAT *p)
{
HTMLRect *This = impl_from_IHTMLRect2(iface);
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsres = nsIDOMClientRect_GetWidth(This->nsrect, p);
if (NS_FAILED(nsres)) {
ERR("GetWidth failed: %08lx\n", nsres);
return E_FAIL;
}
return S_OK;
}
static HRESULT WINAPI HTMLRect2_get_height(IHTMLRect2 *iface, FLOAT *p)
{
HTMLRect *This = impl_from_IHTMLRect2(iface);
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsres = nsIDOMClientRect_GetHeight(This->nsrect, p);
if (NS_FAILED(nsres)) {
ERR("GetHeight failed: %08lx\n", nsres);
return E_FAIL;
}
return S_OK;
}
static const IHTMLRectVtbl HTMLRectVtbl = { static const IHTMLRectVtbl HTMLRectVtbl = {
HTMLRect_QueryInterface, HTMLRect_QueryInterface,
HTMLRect_AddRef, HTMLRect_AddRef,
...@@ -741,6 +829,24 @@ static const IHTMLRectVtbl HTMLRectVtbl = { ...@@ -741,6 +829,24 @@ static const IHTMLRectVtbl HTMLRectVtbl = {
HTMLRect_get_bottom HTMLRect_get_bottom
}; };
static const IHTMLRect2Vtbl HTMLRect2Vtbl = {
HTMLRect2_QueryInterface,
HTMLRect2_AddRef,
HTMLRect2_Release,
HTMLRect2_GetTypeInfoCount,
HTMLRect2_GetTypeInfo,
HTMLRect2_GetIDsOfNames,
HTMLRect2_Invoke,
HTMLRect2_get_width,
HTMLRect2_get_height,
};
void HTMLRect_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
{
if (mode >= COMPAT_MODE_IE9)
dispex_info_add_interface(info, IHTMLRect2_tid, NULL);
}
static const tid_t HTMLRect_iface_tids[] = { static const tid_t HTMLRect_iface_tids[] = {
IHTMLRect_tid, IHTMLRect_tid,
0 0
...@@ -749,7 +855,8 @@ static dispex_static_data_t HTMLRect_dispex = { ...@@ -749,7 +855,8 @@ static dispex_static_data_t HTMLRect_dispex = {
L"ClientRect", L"ClientRect",
NULL, NULL,
IHTMLRect_tid, IHTMLRect_tid,
HTMLRect_iface_tids HTMLRect_iface_tids,
HTMLRect_init_dispex_info
}; };
static HRESULT create_html_rect(nsIDOMClientRect *nsrect, compat_mode_t compat_mode, IHTMLRect **ret) static HRESULT create_html_rect(nsIDOMClientRect *nsrect, compat_mode_t compat_mode, IHTMLRect **ret)
...@@ -761,6 +868,7 @@ static HRESULT create_html_rect(nsIDOMClientRect *nsrect, compat_mode_t compat_m ...@@ -761,6 +868,7 @@ static HRESULT create_html_rect(nsIDOMClientRect *nsrect, compat_mode_t compat_m
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl; rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
rect->IHTMLRect2_iface.lpVtbl = &HTMLRect2Vtbl;
rect->ref = 1; rect->ref = 1;
init_dispatch(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex, compat_mode); init_dispatch(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex, compat_mode);
......
...@@ -237,6 +237,7 @@ typedef struct EventTarget EventTarget; ...@@ -237,6 +237,7 @@ typedef struct EventTarget EventTarget;
XIID(IHTMLPerformanceTiming) \ XIID(IHTMLPerformanceTiming) \
XIID(IHTMLPluginsCollection) \ XIID(IHTMLPluginsCollection) \
XIID(IHTMLRect) \ XIID(IHTMLRect) \
XIID(IHTMLRect2) \
XIID(IHTMLRectCollection) \ XIID(IHTMLRectCollection) \
XIID(IHTMLScreen) \ XIID(IHTMLScreen) \
XIID(IHTMLScriptElement) \ XIID(IHTMLScriptElement) \
......
...@@ -557,6 +557,23 @@ sync_test("stylesheet_props", function() { ...@@ -557,6 +557,23 @@ sync_test("stylesheet_props", function() {
test_exposed("rules", true); test_exposed("rules", true);
}); });
sync_test("rect_props", function() {
document.body.innerHTML = '<div>test</div>';
var elem = document.body.firstChild;
var rect = elem.getBoundingClientRect();
function test_exposed(prop, expect) {
if(expect)
ok(prop in rect, prop + " not found in rect object.");
else
ok(!(prop in rect), prop + " found in rect object.");
}
var v = document.documentMode;
test_exposed("width", v >= 9);
test_exposed("height", v >= 9);
});
sync_test("xhr open", function() { sync_test("xhr open", function() {
var e = false; var e = false;
try { try {
......
...@@ -293,6 +293,8 @@ sync_test("rects", function() { ...@@ -293,6 +293,8 @@ sync_test("rects", function() {
ok(rects.length === 1, "rect.length = " + rects.length); ok(rects.length === 1, "rect.length = " + rects.length);
ok(rects[0].top === rect.top, "rects[0].top = " + rects[0].top + " rect.top = " + rect.top); ok(rects[0].top === rect.top, "rects[0].top = " + rects[0].top + " rect.top = " + rect.top);
ok(rects[0].bottom === rect.bottom, "rects[0].bottom = " + rects[0].bottom + " rect.bottom = " + rect.bottom); ok(rects[0].bottom === rect.bottom, "rects[0].bottom = " + rects[0].bottom + " rect.bottom = " + rect.bottom);
ok(rect.height === rect.bottom - rect.top, "rect.height = " + rect.height + " rect.bottom = " + rect.bottom + " rect.top = " + rect.top);
ok(rect.width === rect.right - rect.left, "rect.width = " + rect.width + " rect.right = " + rect.right + " rect.left = " + rect.left);
elem = document.createElement("style"); elem = document.createElement("style");
rects = elem.getClientRects(); rects = elem.getClientRects();
......
...@@ -4135,6 +4135,10 @@ ...@@ -4135,6 +4135,10 @@
#define DISPID_IHTMLRECT_RIGHT DISPID_OMRECT+3 #define DISPID_IHTMLRECT_RIGHT DISPID_OMRECT+3
#define DISPID_IHTMLRECT_BOTTOM DISPID_OMRECT+4 #define DISPID_IHTMLRECT_BOTTOM DISPID_OMRECT+4
/* IHTMLRect2 */
#define DISPID_IHTMLRECT2_WIDTH DISPID_OMRECT+5
#define DISPID_IHTMLRECT2_HEIGHT DISPID_OMRECT+6
/* IHTMLRectCollection */ /* IHTMLRectCollection */
#define DISPID_IHTMLRECTCOLLECTION_LENGTH DISPID_COLLECTION #define DISPID_IHTMLRECTCOLLECTION_LENGTH DISPID_COLLECTION
#define DISPID_IHTMLRECTCOLLECTION__NEWENUM DISPID_NEWENUM #define DISPID_IHTMLRECTCOLLECTION__NEWENUM DISPID_NEWENUM
......
...@@ -7938,6 +7938,24 @@ interface IHTMLRect : IDispatch ...@@ -7938,6 +7938,24 @@ interface IHTMLRect : IDispatch
} }
/***************************************************************************** /*****************************************************************************
* IHTMLRect2 interface
*/
[
odl,
oleautomation,
dual,
uuid(3051076c-98b5-11cf-bb82-00aa00bdce0b)
]
interface IHTMLRect2 : IDispatch
{
[propget, id(DISPID_IHTMLRECT2_WIDTH)]
HRESULT width([retval, out] FLOAT *p);
[propget, id(DISPID_IHTMLRECT2_HEIGHT)]
HRESULT height([retval, out] FLOAT *p);
}
/*****************************************************************************
* IHTMLRectCollection interface * IHTMLRectCollection interface
*/ */
[ [
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