Jacek Caban : mshtml: Added IHTMLStyle::[get|put]_zIndex implementation.
Alexandre Julliard
julliard at winehq.org
Wed Oct 8 08:32:50 CDT 2008
Module: wine
Branch: master
Commit: 844d1cfc15f01bfb4c919fea6f0de8640f642727
URL: http://source.winehq.org/git/wine.git/?a=commit;h=844d1cfc15f01bfb4c919fea6f0de8640f642727
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Oct 7 14:45:05 2008 -0500
mshtml: Added IHTMLStyle::[get|put]_zIndex implementation.
---
dlls/mshtml/htmlstyle.c | 79 +++++++++++++++++++++++++++++++++++++++++++---
dlls/mshtml/htmlstyle.h | 3 +-
dlls/mshtml/tests/dom.c | 20 ++++++++++++
3 files changed, 95 insertions(+), 7 deletions(-)
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index 34ae105..f2b98cd 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -81,6 +81,8 @@ static const WCHAR attrVisibility[] =
{'v','i','s','i','b','i','l','i','t','y',0};
static const WCHAR attrWidth[] =
{'w','i','d','t','h',0};
+static const WCHAR attrZIndex[] =
+ {'z','-','i','n','d','e','x',0};
static const LPCWSTR style_strings[] = {
attrBackground,
@@ -107,6 +109,7 @@ static const LPCWSTR style_strings[] = {
attrVerticalAlign,
attrVisibility,
attrWidth,
+ attrZIndex
};
static const WCHAR valLineThrough[] =
@@ -172,8 +175,9 @@ static LPWSTR fix_url_value(LPCWSTR val)
return ret;
}
-#define ATTR_FIX_PX 1
-#define ATTR_FIX_URL 2
+#define ATTR_FIX_PX 1
+#define ATTR_FIX_URL 2
+#define ATTR_STR_TO_INT 4
HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCWSTR value, DWORD flags)
{
@@ -245,6 +249,57 @@ HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR
return S_OK;
}
+HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
+{
+ nsAString str_value;
+ const PRUnichar *value;
+ BOOL set = FALSE;
+
+ nsAString_Init(&str_value, NULL);
+
+ get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
+
+ nsAString_GetData(&str_value, &value);
+
+ if(flags & ATTR_STR_TO_INT) {
+ const PRUnichar *ptr = value;
+ BOOL neg = FALSE;
+ INT i = 0;
+
+ if(*ptr == '-') {
+ neg = TRUE;
+ ptr++;
+ }
+
+ while(isdigitW(*ptr))
+ i = i*10 + (*ptr++ - '0');
+
+ if(!*ptr) {
+ V_VT(p) = VT_I4;
+ V_I4(p) = neg ? -i : i;
+ set = TRUE;
+ }
+ }
+
+ if(!set) {
+ BSTR str = NULL;
+
+ if(*value) {
+ str = SysAllocString(value);
+ if(!str)
+ return E_OUTOFMEMORY;
+ }
+
+ V_VT(p) = VT_BSTR;
+ V_BSTR(p) = str;
+ }
+
+ nsAString_Finish(&str_value);
+
+ TRACE("%s -> %s\n", debugstr_w(style_strings[sid]), debugstr_variant(p));
+ return S_OK;
+}
+
static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
{
return get_nsstyle_attr(This->nsstyle, sid, p);
@@ -1581,15 +1636,27 @@ static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
{
HTMLStyle *This = HTMLSTYLE_THIS(iface);
- FIXME("(%p)->(v%d)\n", This, V_VT(&v));
- return E_NOTIMPL;
+
+ TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
+
+ switch(V_VT(&v)) {
+ case VT_BSTR:
+ return set_style_attr(This, STYLEID_Z_INDEX, V_BSTR(&v), 0);
+ default:
+ FIXME("unimplemented vt %d\n", V_VT(&v));
+ return E_NOTIMPL;
+ }
+
+ return S_OK;
}
static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
{
HTMLStyle *This = HTMLSTYLE_THIS(iface);
- FIXME("(%p)->(%p)\n", This, p);
- return E_NOTIMPL;
+
+ TRACE("(%p)->(%p)\n", This, p);
+
+ return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
}
static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
diff --git a/dlls/mshtml/htmlstyle.h b/dlls/mshtml/htmlstyle.h
index 38bfdb1..a6d1a4a 100644
--- a/dlls/mshtml/htmlstyle.h
+++ b/dlls/mshtml/htmlstyle.h
@@ -54,7 +54,8 @@ typedef enum {
STYLEID_TOP,
STYLEID_VERTICAL_ALIGN,
STYLEID_VISIBILITY,
- STYLEID_WIDTH
+ STYLEID_WIDTH,
+ STYLEID_Z_INDEX
} styleid_t;
void HTMLStyle2_Init(HTMLStyle*);
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 925d98f..973c17f 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -2250,6 +2250,26 @@ static void test_default_style(IHTMLStyle *style)
ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
+ V_VT(&v) = VT_EMPTY;
+ hres = IHTMLStyle_get_zIndex(style, &v);
+ ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
+ ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
+ ok(!V_I4(&v), "V_I4(v) != 0\n");
+ VariantClear(&v);
+
+ V_VT(&v) = VT_BSTR;
+ V_BSTR(&v) = a2bstr("1");
+ hres = IHTMLStyle_put_zIndex(style, v);
+ ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
+ VariantClear(&v);
+
+ V_VT(&v) = VT_EMPTY;
+ hres = IHTMLStyle_get_zIndex(style, &v);
+ ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
+ ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
+ ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
+ VariantClear(&v);
+
hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
if(SUCCEEDED(hres)) {
More information about the wine-cvs
mailing list