[PATCH] Implement IHTMLStyle get/put posLeft
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Tue Oct 14 04:11:25 CDT 2008
---
dlls/mshtml/htmlstyle.c | 43 ++++++++++++++++++++++++++++++++++++++-----
dlls/mshtml/tests/dom.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 5 deletions(-)
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index e90d723..e4d10c9 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
+#include <math.h>
#define COBJMACROS
@@ -1804,18 +1805,50 @@ static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
return E_NOTIMPL;
}
-static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
+static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float f)
{
HTMLStyle *This = HTMLSTYLE_THIS(iface);
- FIXME("(%p)->()\n", This);
- return E_NOTIMPL;
+ VARIANT v;
+
+ TRACE("(%p)->(%f)\n", This, f);
+
+ V_VT(&v) = VT_I4;
+ V_I4(&v) = floor(f);
+
+ if(VariantChangeType(&v, &v, 0, VT_BSTR) == S_OK)
+ {
+ HRESULT hres = set_style_attr(This, STYLEID_LEFT, V_BSTR(&v), ATTR_FIX_PX);
+ VariantClear(&v);
+ return hres;
+ }
+
+ return E_FAIL;
}
static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
{
HTMLStyle *This = HTMLSTYLE_THIS(iface);
- FIXME("(%p)->()\n", This);
- return E_NOTIMPL;
+ BSTR ret;
+ HRESULT hres;
+ VARIANT v;
+
+ TRACE("(%p)->(%p)\n", This, p);
+
+ if(!p)
+ return E_POINTER;
+
+ *p = 0.0f;
+
+ hres = get_style_attr(This, STYLEID_LEFT, &ret);
+ if(SUCCEEDED(hres))
+ {
+ if(ret)
+ *p = atoiW(ret);
+ }
+
+ TRACE("ret %f\n", *p);
+
+ return S_OK;
}
static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 75538fe..9323627 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -2237,6 +2237,7 @@ static void test_default_style(IHTMLStyle *style)
VARIANT v;
BSTR str;
HRESULT hres;
+ float f;
test_disp((IUnknown*)style, &DIID_DispHTMLStyle);
test_ifaces((IUnknown*)style, style_iids);
@@ -2338,12 +2339,41 @@ static void test_default_style(IHTMLStyle *style)
ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
VariantClear(&v);
+ /* Test posLeft */
+ hres = IHTMLStyle_get_posLeft(style, NULL);
+ ok(hres == E_POINTER, "get_left failed: %08x\n", hres);
+
+ f = 1.0f;
+ hres = IHTMLStyle_get_posLeft(style, &f);
+ ok(hres == S_OK, "get_left failed: %08x\n", hres);
+ ok(f == 0.0, "expected 0.0 got %f\n", f);
+
+ hres = IHTMLStyle_put_posLeft(style, 4.9f);
+ ok(hres == S_OK, "get_left failed: %08x\n", hres);
+
+ hres = IHTMLStyle_get_posLeft(style, &f);
+ ok(hres == S_OK, "get_left failed: %08x\n", hres);
+ ok(f == 4.0, "expected 4.0 got %f\n", f);
+
+ /* Ensure left is updated correctly. */
+ V_VT(&v) = VT_EMPTY;
+ hres = IHTMLStyle_get_left(style, &v);
+ ok(hres == S_OK, "get_left failed: %08x\n", hres);
+ ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
+ ok(!strcmp_wa(V_BSTR(&v), "4px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
+ VariantClear(&v);
+
+ /* Test left */
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = a2bstr("3px");
hres = IHTMLStyle_put_left(style, v);
ok(hres == S_OK, "put_left failed: %08x\n", hres);
VariantClear(&v);
+ hres = IHTMLStyle_get_posLeft(style, &f);
+ ok(hres == S_OK, "get_left failed: %08x\n", hres);
+ ok(f == 3.0, "expected 3.0 got %f\n", f);
+
V_VT(&v) = VT_EMPTY;
hres = IHTMLStyle_get_left(style, &v);
ok(hres == S_OK, "get_left failed: %08x\n", hres);
--
1.5.4.3
--------------000209080500050608070008--
More information about the wine-patches
mailing list