dmloader: Don't claim partial success when loading fails.
[wine] / dlls / mshtml / htmlstyle.c
1 /*
2  * Copyright 2006 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include <stdarg.h>
20 #include <math.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28 #include "mshtmdid.h"
29
30 #include "mshtml_private.h"
31 #include "htmlstyle.h"
32
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 static const WCHAR attrBackground[] =
38     {'b','a','c','k','g','r','o','u','n','d',0};
39 static const WCHAR attrBackgroundColor[] =
40     {'b','a','c','k','g','r','o','u','n','d','-','c','o','l','o','r',0};
41 static const WCHAR attrBackgroundImage[] =
42     {'b','a','c','k','g','r','o','u','n','d','-','i','m','a','g','e',0};
43 static const WCHAR attrBackgroundPosition[] =
44     {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n',0};
45 static const WCHAR attrBackgroundPositionX[] =
46     {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','x',0};
47 static const WCHAR attrBackgroundPositionY[] =
48     {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','y',0};
49 static const WCHAR attrBackgroundRepeat[] =
50     {'b','a','c','k','g','r','o','u','n','d','-','r','e','p','e','a','t',0};
51 static const WCHAR attrBorder[] =
52     {'b','o','r','d','e','r',0};
53 static const WCHAR attrBorderBottom[] =
54     {'b','o','r','d','e','r','-','b','o','t','t','o','m',0};
55 static const WCHAR attrBorderBottomColor[] =
56     {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','c','o','l','o','r',0};
57 static const WCHAR attrBorderBottomStyle[] =
58     {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','s','t','y','l','e',0};
59 static const WCHAR attrBorderBottomWidth[] =
60     {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','w','i','d','t','h',0};
61 static const WCHAR attrBorderColor[] =
62     {'b','o','r','d','e','r','-','c','o','l','o','r',0};
63 static const WCHAR attrBorderLeft[] =
64     {'b','o','r','d','e','r','-','l','e','f','t',0};
65 static const WCHAR attrBorderLeftColor[] =
66     {'b','o','r','d','e','r','-','l','e','f','t','-','c','o','l','o','r',0};
67 static const WCHAR attrBorderLeftStyle[] =
68     {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0};
69 static const WCHAR attrBorderLeftWidth[] =
70     {'b','o','r','d','e','r','-','l','e','f','t','-','w','i','d','t','h',0};
71 static const WCHAR attrBorderRight[] =
72     {'b','o','r','d','e','r','-','r','i','g','h','t',0};
73 static const WCHAR attrBorderRightColor[] =
74     {'b','o','r','d','e','r','-','r','i','g','h','t','-','c','o','l','o','r',0};
75 static const WCHAR attrBorderRightStyle[] =
76     {'b','o','r','d','e','r','-','r','i','g','h','t','-','s','t','y','l','e',0};
77 static const WCHAR attrBorderRightWidth[] =
78     {'b','o','r','d','e','r','-','r','i','g','h','t','-','w','i','d','t','h',0};
79 static const WCHAR attrBorderTop[] =
80     {'b','o','r','d','e','r','-','t','o','p',0};
81 static const WCHAR attrBorderTopColor[] =
82     {'b','o','r','d','e','r','-','t','o','p','-','c','o','l','o','r',0};
83 static const WCHAR attrBorderStyle[] =
84     {'b','o','r','d','e','r','-','s','t','y','l','e',0};
85 static const WCHAR attrBorderTopStyle[] =
86     {'b','o','r','d','e','r','-','t','o','p','-','s','t','y','l','e',0};
87 static const WCHAR attrBorderTopWidth[] =
88     {'b','o','r','d','e','r','-','t','o','p','-','w','i','d','t','h',0};
89 static const WCHAR attrBorderWidth[] =
90     {'b','o','r','d','e','r','-','w','i','d','t','h',0};
91 static const WCHAR attrBottom[] =
92     {'b','o','t','t','o','m',0};
93 static const WCHAR attrClip[] =
94     {'c','l','i','p',0};
95 static const WCHAR attrColor[] =
96     {'c','o','l','o','r',0};
97 static const WCHAR attrCursor[] =
98     {'c','u','r','s','o','r',0};
99 static const WCHAR attrDirection[] =
100     {'d','i','r','e','c','t','i','o','n',0};
101 static const WCHAR attrDisplay[] =
102     {'d','i','s','p','l','a','y',0};
103 static const WCHAR attrFilter[] =
104     {'f','i','l','e','t','e','r',0};
105 static const WCHAR attrFontFamily[] =
106     {'f','o','n','t','-','f','a','m','i','l','y',0};
107 static const WCHAR attrFontSize[] =
108     {'f','o','n','t','-','s','i','z','e',0};
109 static const WCHAR attrFontStyle[] =
110     {'f','o','n','t','-','s','t','y','l','e',0};
111 static const WCHAR attrFontVariant[] =
112     {'f','o','n','t','-','v','a','r','i','a','n','t',0};
113 static const WCHAR attrFontWeight[] =
114     {'f','o','n','t','-','w','e','i','g','h','t',0};
115 static const WCHAR attrHeight[] =
116     {'h','e','i','g','h','t',0};
117 static const WCHAR attrLeft[] =
118     {'l','e','f','t',0};
119 static const WCHAR attrLetterSpacing[] =
120     {'l','e','t','t','e','r','-','s','p','a','c','i','n','g',0};
121 static const WCHAR attrLineHeight[] =
122     {'l','i','n','e','-','h','e','i','g','h','t',0};
123 static const WCHAR attrMargin[] =
124     {'m','a','r','g','i','n',0};
125 static const WCHAR attrMarginBottom[] =
126     {'m','a','r','g','i','n','-','b','o','t','t','o','m',0};
127 static const WCHAR attrMarginLeft[] =
128     {'m','a','r','g','i','n','-','l','e','f','t',0};
129 static const WCHAR attrMarginRight[] =
130     {'m','a','r','g','i','n','-','r','i','g','h','t',0};
131 static const WCHAR attrMarginTop[] =
132     {'m','a','r','g','i','n','-','t','o','p',0};
133 static const WCHAR attrMinHeight[] =
134     {'m','i','n','-','h','e','i','g','h','t',0};
135 static const WCHAR attrOverflow[] =
136     {'o','v','e','r','f','l','o','w',0};
137 static const WCHAR attrPadding[] =
138     {'p','a','d','d','i','n','g',0};
139 static const WCHAR attrPaddingBottom[] =
140     {'p','a','d','d','i','n','g','-','b','o','t','t','o','m',0};
141 static const WCHAR attrPaddingLeft[] =
142     {'p','a','d','d','i','n','g','-','l','e','f','t',0};
143 static const WCHAR attrPaddingRight[] =
144     {'p','a','d','d','i','n','g','-','r','i','g','h','t',0};
145 static const WCHAR attrPaddingTop[] =
146     {'p','a','d','d','i','n','g','-','t','o','p',0};
147 static const WCHAR attrPageBreakAfter[] =
148     {'p','a','g','e','-','b','r','e','a','k','-','a','f','t','e','r',0};
149 static const WCHAR attrPageBreakBefore[] =
150     {'p','a','g','e','-','b','r','e','a','k','-','b','e','f','o','r','e',0};
151 static const WCHAR attrPosition[] =
152     {'p','o','s','i','t','i','o','n',0};
153 static const WCHAR attrRight[] =
154     {'r','i','g','h','t',0};
155 static const WCHAR attrTextAlign[] =
156     {'t','e','x','t','-','a','l','i','g','n',0};
157 static const WCHAR attrTextDecoration[] =
158     {'t','e','x','t','-','d','e','c','o','r','a','t','i','o','n',0};
159 static const WCHAR attrTextIndent[] =
160     {'t','e','x','t','-','i','n','d','e','n','t',0};
161 static const WCHAR attrTop[] =
162     {'t','o','p',0};
163 static const WCHAR attrVerticalAlign[] =
164     {'v','e','r','t','i','c','a','l','-','a','l','i','g','n',0};
165 static const WCHAR attrVisibility[] =
166     {'v','i','s','i','b','i','l','i','t','y',0};
167 static const WCHAR attrWidth[] =
168     {'w','i','d','t','h',0};
169 static const WCHAR attrWordSpacing[] =
170     {'w','o','r','d','-','s','p','a','c','i','n','g',0};
171 static const WCHAR attrWordWrap[] =
172     {'w','o','r','d','-','w','r','a','p',0};
173 static const WCHAR attrZIndex[] =
174     {'z','-','i','n','d','e','x',0};
175
176 static const struct{
177     const WCHAR *name;
178     DISPID dispid;
179 } style_tbl[] = {
180     {attrBackground,           DISPID_IHTMLSTYLE_BACKGROUND},
181     {attrBackgroundColor,      DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
182     {attrBackgroundImage,      DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
183     {attrBackgroundPosition,   DISPID_IHTMLSTYLE_BACKGROUNDPOSITION},
184     {attrBackgroundPositionX,  DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONX},
185     {attrBackgroundPositionY,  DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
186     {attrBackgroundRepeat,     DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
187     {attrBorder,               DISPID_IHTMLSTYLE_BORDER},
188     {attrBorderBottom,         DISPID_IHTMLSTYLE_BORDERBOTTOM},
189     {attrBorderBottomColor,    DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR},
190     {attrBorderBottomStyle,    DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
191     {attrBorderBottomWidth,    DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
192     {attrBorderColor,          DISPID_IHTMLSTYLE_BORDERCOLOR},
193     {attrBorderLeft,           DISPID_IHTMLSTYLE_BORDERLEFT},
194     {attrBorderLeftColor,      DISPID_IHTMLSTYLE_BORDERLEFTCOLOR},
195     {attrBorderLeftStyle,      DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
196     {attrBorderLeftWidth,      DISPID_IHTMLSTYLE_BORDERLEFTWIDTH},
197     {attrBorderRight,          DISPID_IHTMLSTYLE_BORDERRIGHT},
198     {attrBorderRightColor,     DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR},
199     {attrBorderRightStyle,     DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
200     {attrBorderRightWidth,     DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
201     {attrBorderStyle,          DISPID_IHTMLSTYLE_BORDERSTYLE},
202     {attrBorderTop,            DISPID_IHTMLSTYLE_BORDERTOP},
203     {attrBorderTopColor,       DISPID_IHTMLSTYLE_BORDERTOPCOLOR},
204     {attrBorderTopStyle,       DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
205     {attrBorderTopWidth,       DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
206     {attrBorderWidth,          DISPID_IHTMLSTYLE_BORDERWIDTH},
207     {attrBottom,               DISPID_IHTMLSTYLE2_BOTTOM},
208     {attrClip,                 DISPID_IHTMLSTYLE_CLIP},
209     {attrColor,                DISPID_IHTMLSTYLE_COLOR},
210     {attrCursor,               DISPID_IHTMLSTYLE_CURSOR},
211     {attrDirection,            DISPID_IHTMLSTYLE2_DIRECTION},
212     {attrDisplay,              DISPID_IHTMLSTYLE_DISPLAY},
213     {attrFilter,               DISPID_IHTMLSTYLE_FILTER},
214     {attrFontFamily,           DISPID_IHTMLSTYLE_FONTFAMILY},
215     {attrFontSize,             DISPID_IHTMLSTYLE_FONTSIZE},
216     {attrFontStyle,            DISPID_IHTMLSTYLE_FONTSTYLE},
217     {attrFontVariant,          DISPID_IHTMLSTYLE_FONTVARIANT},
218     {attrFontWeight,           DISPID_IHTMLSTYLE_FONTWEIGHT},
219     {attrHeight,               DISPID_IHTMLSTYLE_HEIGHT},
220     {attrLeft,                 DISPID_IHTMLSTYLE_LEFT},
221     {attrLetterSpacing,        DISPID_IHTMLSTYLE_LETTERSPACING},
222     {attrLineHeight,           DISPID_IHTMLSTYLE_LINEHEIGHT},
223     {attrMargin,               DISPID_IHTMLSTYLE_MARGIN},
224     {attrMarginBottom,         DISPID_IHTMLSTYLE_MARGINBOTTOM},
225     {attrMarginLeft,           DISPID_IHTMLSTYLE_MARGINLEFT},
226     {attrMarginRight,          DISPID_IHTMLSTYLE_MARGINRIGHT},
227     {attrMarginTop,            DISPID_IHTMLSTYLE_MARGINTOP},
228     {attrMinHeight,            DISPID_IHTMLSTYLE4_MINHEIGHT},
229     {attrOverflow,             DISPID_IHTMLSTYLE_OVERFLOW},
230     {attrPadding,              DISPID_IHTMLSTYLE_PADDING},
231     {attrPaddingBottom,        DISPID_IHTMLSTYLE_PADDINGBOTTOM},
232     {attrPaddingLeft,          DISPID_IHTMLSTYLE_PADDINGLEFT},
233     {attrPaddingRight,         DISPID_IHTMLSTYLE_PADDINGRIGHT},
234     {attrPaddingTop,           DISPID_IHTMLSTYLE_PADDINGTOP},
235     {attrPageBreakAfter,       DISPID_IHTMLSTYLE_PAGEBREAKAFTER},
236     {attrPageBreakBefore,      DISPID_IHTMLSTYLE_PAGEBREAKBEFORE},
237     {attrPosition,             DISPID_IHTMLSTYLE2_POSITION},
238     {attrRight,                DISPID_IHTMLSTYLE2_RIGHT},
239     {attrTextAlign,            DISPID_IHTMLSTYLE_TEXTALIGN},
240     {attrTextDecoration,       DISPID_IHTMLSTYLE_TEXTDECORATION},
241     {attrTextIndent,           DISPID_IHTMLSTYLE_TEXTINDENT},
242     {attrTop,                  DISPID_IHTMLSTYLE_TOP},
243     {attrVerticalAlign,        DISPID_IHTMLSTYLE_VERTICALALIGN},
244     {attrVisibility,           DISPID_IHTMLSTYLE_VISIBILITY},
245     {attrWidth,                DISPID_IHTMLSTYLE_WIDTH},
246     {attrWordSpacing,          DISPID_IHTMLSTYLE_WORDSPACING},
247     {attrWordWrap,             DISPID_IHTMLSTYLE3_WORDWRAP},
248     {attrZIndex,               DISPID_IHTMLSTYLE_ZINDEX}
249 };
250
251 static const WCHAR valLineThrough[] =
252     {'l','i','n','e','-','t','h','r','o','u','g','h',0};
253 static const WCHAR valUnderline[] =
254     {'u','n','d','e','r','l','i','n','e',0};
255 static const WCHAR szNormal[] =
256     {'n','o','r','m','a','l',0};
257 static const WCHAR styleNone[] =
258     {'n','o','n','e',0};
259 static const WCHAR valOverline[] =
260     {'o','v','e','r','l','i','n','e',0};
261 static const WCHAR valBlink[] =
262     {'b','l','i','n','k',0};
263
264 static const WCHAR px_formatW[] = {'%','d','p','x',0};
265 static const WCHAR emptyW[] = {0};
266
267 static LPWSTR fix_px_value(LPCWSTR val)
268 {
269     LPCWSTR ptr = val;
270
271     while(*ptr) {
272         while(*ptr && isspaceW(*ptr))
273             ptr++;
274         if(!*ptr)
275             break;
276
277         while(*ptr && isdigitW(*ptr))
278             ptr++;
279
280         if(!*ptr || isspaceW(*ptr)) {
281             LPWSTR ret, p;
282             int len = strlenW(val)+1;
283
284             ret = heap_alloc((len+2)*sizeof(WCHAR));
285             memcpy(ret, val, (ptr-val)*sizeof(WCHAR));
286             p = ret + (ptr-val);
287             *p++ = 'p';
288             *p++ = 'x';
289             strcpyW(p, ptr);
290
291             TRACE("fixed %s -> %s\n", debugstr_w(val), debugstr_w(ret));
292
293             return ret;
294         }
295
296         while(*ptr && !isspaceW(*ptr))
297             ptr++;
298     }
299
300     return NULL;
301 }
302
303 static LPWSTR fix_url_value(LPCWSTR val)
304 {
305     WCHAR *ret, *ptr;
306
307     static const WCHAR urlW[] = {'u','r','l','('};
308
309     if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
310         return NULL;
311
312     ret = heap_strdupW(val);
313
314     for(ptr = ret; *ptr; ptr++) {
315         if(*ptr == '\\')
316             *ptr = '/';
317     }
318
319     return ret;
320 }
321
322 HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCWSTR value, DWORD flags)
323 {
324     nsAString str_name, str_value, str_empty;
325     LPWSTR val = NULL;
326     nsresult nsres;
327
328     if(flags & ATTR_FIX_PX)
329         val = fix_px_value(value);
330     if(flags & ATTR_FIX_URL)
331         val = fix_url_value(value);
332
333     nsAString_InitDepend(&str_name, style_tbl[sid].name);
334     nsAString_InitDepend(&str_value, val ? val : value);
335     nsAString_InitDepend(&str_empty, emptyW);
336
337     nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
338     if(NS_FAILED(nsres))
339         ERR("SetProperty failed: %08x\n", nsres);
340
341     nsAString_Finish(&str_name);
342     nsAString_Finish(&str_value);
343     nsAString_Finish(&str_empty);
344     heap_free(val);
345
346     return S_OK;
347 }
348
349 static HRESULT var_to_styleval(const VARIANT *v, WCHAR *buf, DWORD flags, const WCHAR **ret)
350 {
351     switch(V_VT(v)) {
352     case VT_NULL:
353         *ret = emptyW;
354         return S_OK;
355
356     case VT_BSTR:
357         *ret = V_BSTR(v);
358         return S_OK;
359
360     case VT_BSTR|VT_BYREF:
361         *ret = *V_BSTRREF(v);
362         return S_OK;
363
364     case VT_I4: {
365         static const WCHAR formatW[] = {'%','d',0};
366         static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
367
368         if(flags & ATTR_HEX_INT)
369             wsprintfW(buf, hex_formatW, V_I4(v));
370         else if(flags & ATTR_FIX_PX)
371             wsprintfW(buf, px_formatW, V_I4(v));
372         else
373             wsprintfW(buf, formatW, V_I4(v));
374
375         *ret = buf;
376         return S_OK;
377     }
378     default:
379         FIXME("not implemented vt %d\n", V_VT(v));
380         return E_NOTIMPL;
381
382     }
383 }
384
385 HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *value, DWORD flags)
386 {
387     const WCHAR *val;
388     WCHAR buf[14];
389     HRESULT hres;
390
391     hres = var_to_styleval(value, buf, flags, &val);
392     if(FAILED(hres))
393         return hres;
394
395     return set_nsstyle_attr(nsstyle, sid, val, flags);
396 }
397
398 static inline HRESULT set_style_attr(HTMLStyle *This, styleid_t sid, LPCWSTR value, DWORD flags)
399 {
400     return set_nsstyle_attr(This->nsstyle, sid, value, flags);
401 }
402
403 static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, nsAString *value)
404 {
405     nsAString str_name;
406     nsresult nsres;
407
408     nsAString_InitDepend(&str_name, style_tbl[sid].name);
409
410     nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
411     if(NS_FAILED(nsres)) {
412         ERR("SetProperty failed: %08x\n", nsres);
413         return E_FAIL;
414     }
415
416     nsAString_Finish(&str_name);
417
418     return NS_OK;
419 }
420
421 static HRESULT nsstyle_to_bstr(const WCHAR *val, DWORD flags, BSTR *p)
422 {
423     BSTR ret;
424     DWORD len;
425
426     if(!*val) {
427         *p = NULL;
428         return S_OK;
429     }
430
431     ret = SysAllocString(val);
432     if(!ret)
433         return E_OUTOFMEMORY;
434
435     len = SysStringLen(ret);
436
437     if(flags & ATTR_REMOVE_COMMA) {
438         DWORD new_len = len;
439         WCHAR *ptr, *ptr2;
440
441         for(ptr = ret; (ptr = strchrW(ptr, ',')); ptr++)
442             new_len--;
443
444         if(new_len != len) {
445             BSTR new_ret;
446
447             new_ret = SysAllocStringLen(NULL, new_len);
448             if(!new_ret) {
449                 SysFreeString(ret);
450                 return E_OUTOFMEMORY;
451             }
452
453             for(ptr2 = new_ret, ptr = ret; *ptr; ptr++) {
454                 if(*ptr != ',')
455                     *ptr2++ = *ptr;
456             }
457
458             SysFreeString(ret);
459             ret = new_ret;
460         }
461     }
462
463     *p = ret;
464     return S_OK;
465 }
466
467 HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR *p, DWORD flags)
468 {
469     nsAString str_value;
470     const PRUnichar *value;
471     HRESULT hres;
472
473     nsAString_Init(&str_value, NULL);
474
475     get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
476
477     nsAString_GetData(&str_value, &value);
478     hres = nsstyle_to_bstr(value, flags, p);
479     nsAString_Finish(&str_value);
480
481     TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_w(*p));
482     return hres;
483 }
484
485 HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
486 {
487     nsAString str_value;
488     const PRUnichar *value;
489     BOOL set = FALSE;
490     HRESULT hres = S_OK;
491
492     nsAString_Init(&str_value, NULL);
493
494     get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
495
496     nsAString_GetData(&str_value, &value);
497
498     if(flags & ATTR_STR_TO_INT) {
499         const PRUnichar *ptr = value;
500         BOOL neg = FALSE;
501         INT i = 0;
502
503         if(*ptr == '-') {
504             neg = TRUE;
505             ptr++;
506         }
507
508         while(isdigitW(*ptr))
509             i = i*10 + (*ptr++ - '0');
510
511         if(!*ptr) {
512             V_VT(p) = VT_I4;
513             V_I4(p) = neg ? -i : i;
514             set = TRUE;
515         }
516     }
517
518     if(!set) {
519         BSTR str;
520
521         hres = nsstyle_to_bstr(value, flags, &str);
522         if(SUCCEEDED(hres)) {
523             V_VT(p) = VT_BSTR;
524             V_BSTR(p) = str;
525         }
526     }
527
528     nsAString_Finish(&str_value);
529
530     TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_variant(p));
531     return S_OK;
532 }
533
534 static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
535 {
536     return get_nsstyle_attr(This->nsstyle, sid, p, 0);
537 }
538
539 static HRESULT check_style_attr_value(HTMLStyle *This, styleid_t sid, LPCWSTR exval, VARIANT_BOOL *p)
540 {
541     nsAString str_value;
542     const PRUnichar *value;
543
544     nsAString_Init(&str_value, NULL);
545
546     get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
547
548     nsAString_GetData(&str_value, &value);
549     *p = strcmpW(value, exval) ? VARIANT_FALSE : VARIANT_TRUE;
550     nsAString_Finish(&str_value);
551
552     TRACE("%s -> %x\n", debugstr_w(style_tbl[sid].name), *p);
553     return S_OK;
554 }
555
556 static inline HRESULT set_style_pos(HTMLStyle *This, styleid_t sid, float value)
557 {
558     WCHAR szValue[25];
559     WCHAR szFormat[] = {'%','.','0','f','p','x',0};
560
561     value = floor(value);
562
563     sprintfW(szValue, szFormat, value);
564
565     return set_style_attr(This, sid, szValue, 0);
566 }
567
568 static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p)
569 {
570     nsAString str_value;
571     HRESULT hres;
572     WCHAR pxW[] = {'p','x',0};
573
574     TRACE("%p %d %p\n", This, sid, p);
575
576     *p = 0.0f;
577
578     nsAString_Init(&str_value, NULL);
579
580     hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
581     if(hres == S_OK)
582     {
583         WCHAR *ptr;
584         const PRUnichar *value;
585
586         nsAString_GetData(&str_value, &value);
587         if(value)
588         {
589             *p = strtolW(value, &ptr, 10);
590
591             if(*ptr && strcmpW(ptr, pxW))
592             {
593                 nsAString_Finish(&str_value);
594                 FIXME("only px values are currently supported\n");
595                 return E_FAIL;
596             }
597         }
598     }
599
600     TRACE("ret %f\n", *p);
601
602     nsAString_Finish(&str_value);
603
604     return hres;
605 }
606
607 static BOOL is_valid_border_style(BSTR v)
608 {
609     static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0};
610     static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0};
611     static const WCHAR styleSolid[]  = {'s','o','l','i','d',0};
612     static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0};
613     static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0};
614     static const WCHAR styleRidge[]  = {'r','i','d','g','e',0};
615     static const WCHAR styleInset[]  = {'i','n','s','e','t',0};
616     static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0};
617
618     TRACE("%s\n", debugstr_w(v));
619
620     if(!v || strcmpiW(v, styleNone)   == 0 || strcmpiW(v, styleDotted) == 0 ||
621              strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid)  == 0 ||
622              strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 ||
623              strcmpiW(v, styleRidge)  == 0 || strcmpiW(v, styleInset)  == 0 ||
624              strcmpiW(v, styleOutset) == 0 )
625     {
626         return TRUE;
627     }
628
629     return FALSE;
630 }
631
632 static inline HTMLStyle *impl_from_IHTMLStyle(IHTMLStyle *iface)
633 {
634     return CONTAINING_RECORD(iface, HTMLStyle, IHTMLStyle_iface);
635 }
636
637 static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv)
638 {
639     HTMLStyle *This = impl_from_IHTMLStyle(iface);
640
641     *ppv = NULL;
642
643     if(IsEqualGUID(&IID_IUnknown, riid)) {
644         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
645         *ppv = &This->IHTMLStyle_iface;
646     }else if(IsEqualGUID(&IID_IHTMLStyle, riid)) {
647         TRACE("(%p)->(IID_IHTMLStyle %p)\n", This, ppv);
648         *ppv = &This->IHTMLStyle_iface;
649     }else if(IsEqualGUID(&IID_IHTMLStyle2, riid)) {
650         TRACE("(%p)->(IID_IHTMLStyle2 %p)\n", This, ppv);
651         *ppv = &This->IHTMLStyle2_iface;
652     }else if(IsEqualGUID(&IID_IHTMLStyle3, riid)) {
653         TRACE("(%p)->(IID_IHTMLStyle3 %p)\n", This, ppv);
654         *ppv = &This->IHTMLStyle3_iface;
655     }else if(IsEqualGUID(&IID_IHTMLStyle4, riid)) {
656         TRACE("(%p)->(IID_IHTMLStyle4 %p)\n", This, ppv);
657         *ppv = &This->IHTMLStyle4_iface;
658     }else if(IsEqualGUID(&IID_IHTMLStyle5, riid)) {
659         TRACE("(%p)->(IID_IHTMLStyle5 %p)\n", This, ppv);
660         *ppv = &This->IHTMLStyle5_iface;
661     }else if(IsEqualGUID(&IID_IHTMLStyle6, riid)) {
662         TRACE("(%p)->(IID_IHTMLStyle6 %p)\n", This, ppv);
663         *ppv = &This->IHTMLStyle6_iface;
664     }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
665         return *ppv ? S_OK : E_NOINTERFACE;
666     }
667
668     if(*ppv) {
669         IUnknown_AddRef((IUnknown*)*ppv);
670         return S_OK;
671     }
672
673     WARN("unsupported %s\n", debugstr_guid(riid));
674     return E_NOINTERFACE;
675 }
676
677 static ULONG WINAPI HTMLStyle_AddRef(IHTMLStyle *iface)
678 {
679     HTMLStyle *This = impl_from_IHTMLStyle(iface);
680     LONG ref = InterlockedIncrement(&This->ref);
681
682     TRACE("(%p) ref=%d\n", This, ref);
683
684     return ref;
685 }
686
687 static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
688 {
689     HTMLStyle *This = impl_from_IHTMLStyle(iface);
690     LONG ref = InterlockedDecrement(&This->ref);
691
692     TRACE("(%p) ref=%d\n", This, ref);
693
694     if(!ref) {
695         if(This->nsstyle)
696             nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
697         release_dispex(&This->dispex);
698         heap_free(This);
699     }
700
701     return ref;
702 }
703
704 static HRESULT WINAPI HTMLStyle_GetTypeInfoCount(IHTMLStyle *iface, UINT *pctinfo)
705 {
706     HTMLStyle *This = impl_from_IHTMLStyle(iface);
707     return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
708 }
709
710 static HRESULT WINAPI HTMLStyle_GetTypeInfo(IHTMLStyle *iface, UINT iTInfo,
711                                               LCID lcid, ITypeInfo **ppTInfo)
712 {
713     HTMLStyle *This = impl_from_IHTMLStyle(iface);
714     return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
715 }
716
717 static HRESULT WINAPI HTMLStyle_GetIDsOfNames(IHTMLStyle *iface, REFIID riid,
718                                                 LPOLESTR *rgszNames, UINT cNames,
719                                                 LCID lcid, DISPID *rgDispId)
720 {
721     HTMLStyle *This = impl_from_IHTMLStyle(iface);
722     return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
723             lcid, rgDispId);
724 }
725
726 static HRESULT WINAPI HTMLStyle_Invoke(IHTMLStyle *iface, DISPID dispIdMember,
727                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
728                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
729 {
730     HTMLStyle *This = impl_from_IHTMLStyle(iface);
731     return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
732             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
733 }
734
735 static HRESULT WINAPI HTMLStyle_put_fontFamily(IHTMLStyle *iface, BSTR v)
736 {
737     HTMLStyle *This = impl_from_IHTMLStyle(iface);
738
739     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
740
741     return set_style_attr(This, STYLEID_FONT_FAMILY, v, 0);
742 }
743
744 static HRESULT WINAPI HTMLStyle_get_fontFamily(IHTMLStyle *iface, BSTR *p)
745 {
746     HTMLStyle *This = impl_from_IHTMLStyle(iface);
747
748     TRACE("(%p)->(%p)\n", This, p);
749
750     return get_style_attr(This, STYLEID_FONT_FAMILY, p);
751 }
752
753 static HRESULT WINAPI HTMLStyle_put_fontStyle(IHTMLStyle *iface, BSTR v)
754 {
755     HTMLStyle *This = impl_from_IHTMLStyle(iface);
756     static const WCHAR szItalic[]  = {'i','t','a','l','i','c',0};
757     static const WCHAR szOblique[]  = {'o','b','l','i','q','u','e',0};
758
759     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
760
761     /* fontStyle can only be one of the follow values. */
762     if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szItalic, v) == 0 ||
763              strcmpiW(szOblique, v) == 0)
764     {
765         return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, v, 0);
766     }
767
768     return E_INVALIDARG;
769 }
770
771 static HRESULT WINAPI HTMLStyle_get_fontStyle(IHTMLStyle *iface, BSTR *p)
772 {
773     HTMLStyle *This = impl_from_IHTMLStyle(iface);
774
775     TRACE("(%p)->(%p)\n", This, p);
776
777     return get_style_attr(This, STYLEID_FONT_STYLE, p);
778 }
779
780 static HRESULT WINAPI HTMLStyle_put_fontVariant(IHTMLStyle *iface, BSTR v)
781 {
782     HTMLStyle *This = impl_from_IHTMLStyle(iface);
783     static const WCHAR szCaps[]  = {'s','m','a','l','l','-','c','a','p','s',0};
784
785     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
786
787     /* fontVariant can only be one of the follow values. */
788     if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szCaps, v) == 0)
789     {
790         return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, v, 0);
791     }
792
793     return E_INVALIDARG;
794 }
795
796 static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p)
797 {
798     HTMLStyle *This = impl_from_IHTMLStyle(iface);
799     TRACE("(%p)->(%p)\n", This, p);
800
801     if(!p)
802        return E_INVALIDARG;
803
804     return get_style_attr(This, STYLEID_FONT_VARIANT, p);
805 }
806
807 static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v)
808 {
809     HTMLStyle *This = impl_from_IHTMLStyle(iface);
810     static const WCHAR styleBold[] = {'b','o','l','d',0};
811     static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0};
812     static const WCHAR styleLighter[]  = {'l','i','g','h','t','e','r',0};
813     static const WCHAR style100[] = {'1','0','0',0};
814     static const WCHAR style200[] = {'2','0','0',0};
815     static const WCHAR style300[] = {'3','0','0',0};
816     static const WCHAR style400[] = {'4','0','0',0};
817     static const WCHAR style500[] = {'5','0','0',0};
818     static const WCHAR style600[] = {'6','0','0',0};
819     static const WCHAR style700[] = {'7','0','0',0};
820     static const WCHAR style800[] = {'8','0','0',0};
821     static const WCHAR style900[] = {'9','0','0',0};
822
823     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
824
825     /* fontWeight can only be one of the following */
826     if(!v || strcmpiW(szNormal, v) == 0    || strcmpiW(styleBold, v) == 0    ||
827              strcmpiW(styleBolder, v) == 0 || strcmpiW(styleLighter, v) == 0 ||
828              strcmpiW(style100, v) == 0    || strcmpiW(style200, v) == 0     ||
829              strcmpiW(style300, v) == 0    || strcmpiW(style400, v) == 0     ||
830              strcmpiW(style500, v) == 0    || strcmpiW(style600, v) == 0     ||
831              strcmpiW(style700, v) == 0    || strcmpiW(style800, v) == 0     ||
832              strcmpiW(style900, v) == 0
833              )
834     {
835         return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0);
836     }
837
838     return E_INVALIDARG;
839 }
840
841 static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p)
842 {
843     HTMLStyle *This = impl_from_IHTMLStyle(iface);
844
845     TRACE("(%p)->(%p)\n", This, p);
846
847     return get_style_attr(This, STYLEID_FONT_WEIGHT, p);
848 }
849
850 static HRESULT WINAPI HTMLStyle_put_fontSize(IHTMLStyle *iface, VARIANT v)
851 {
852     HTMLStyle *This = impl_from_IHTMLStyle(iface);
853
854     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
855
856     switch(V_VT(&v)) {
857     case VT_BSTR:
858         return set_style_attr(This, STYLEID_FONT_SIZE, V_BSTR(&v), 0);
859     default:
860         FIXME("not supported vt %d\n", V_VT(&v));
861     }
862
863     return S_OK;
864 }
865
866 static HRESULT WINAPI HTMLStyle_get_fontSize(IHTMLStyle *iface, VARIANT *p)
867 {
868     HTMLStyle *This = impl_from_IHTMLStyle(iface);
869
870     TRACE("(%p)->(%p)\n", This, p);
871
872     V_VT(p) = VT_BSTR;
873     return get_style_attr(This, STYLEID_FONT_SIZE, &V_BSTR(p));
874 }
875
876 static HRESULT WINAPI HTMLStyle_put_font(IHTMLStyle *iface, BSTR v)
877 {
878     HTMLStyle *This = impl_from_IHTMLStyle(iface);
879     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
880     return E_NOTIMPL;
881 }
882
883 static HRESULT WINAPI HTMLStyle_get_font(IHTMLStyle *iface, BSTR *p)
884 {
885     HTMLStyle *This = impl_from_IHTMLStyle(iface);
886     FIXME("(%p)->(%p)\n", This, p);
887     return E_NOTIMPL;
888 }
889
890 static HRESULT WINAPI HTMLStyle_put_color(IHTMLStyle *iface, VARIANT v)
891 {
892     HTMLStyle *This = impl_from_IHTMLStyle(iface);
893
894     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
895
896     switch(V_VT(&v)) {
897     case VT_BSTR:
898         TRACE("%s\n", debugstr_w(V_BSTR(&v)));
899         return set_style_attr(This, STYLEID_COLOR, V_BSTR(&v), 0);
900
901     default:
902         FIXME("unsupported vt=%d\n", V_VT(&v));
903     }
904
905     return E_NOTIMPL;
906 }
907
908 static HRESULT WINAPI HTMLStyle_get_color(IHTMLStyle *iface, VARIANT *p)
909 {
910     HTMLStyle *This = impl_from_IHTMLStyle(iface);
911
912     TRACE("(%p)->(%p)\n", This, p);
913
914     V_VT(p) = VT_BSTR;
915     return get_style_attr(This, STYLEID_COLOR, &V_BSTR(p));
916 }
917
918 static HRESULT WINAPI HTMLStyle_put_background(IHTMLStyle *iface, BSTR v)
919 {
920     HTMLStyle *This = impl_from_IHTMLStyle(iface);
921
922     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
923
924     return set_style_attr(This, STYLEID_BACKGROUND, v, 0);
925 }
926
927 static HRESULT WINAPI HTMLStyle_get_background(IHTMLStyle *iface, BSTR *p)
928 {
929     HTMLStyle *This = impl_from_IHTMLStyle(iface);
930
931     TRACE("(%p)->(%p)\n", This, p);
932
933     return get_style_attr(This, STYLEID_BACKGROUND, p);
934 }
935
936 static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v)
937 {
938     HTMLStyle *This = impl_from_IHTMLStyle(iface);
939
940     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
941
942     switch(V_VT(&v)) {
943     case VT_BSTR:
944         return set_style_attr(This, STYLEID_BACKGROUND_COLOR, V_BSTR(&v), 0);
945     case VT_I4: {
946         WCHAR value[10];
947         static const WCHAR format[] = {'#','%','0','6','x',0};
948
949         wsprintfW(value, format, V_I4(&v));
950         return set_style_attr(This, STYLEID_BACKGROUND_COLOR, value, 0);
951     }
952     default:
953         FIXME("unsupported vt %d\n", V_VT(&v));
954     }
955
956     return S_OK;
957 }
958
959 static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
960 {
961     HTMLStyle *This = impl_from_IHTMLStyle(iface);
962     TRACE("(%p)->(%p)\n", This, p);
963
964     V_VT(p) = VT_BSTR;
965     return get_style_attr(This, STYLEID_BACKGROUND_COLOR, &V_BSTR(p));
966 }
967
968 static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
969 {
970     HTMLStyle *This = impl_from_IHTMLStyle(iface);
971
972     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
973
974     return set_style_attr(This, STYLEID_BACKGROUND_IMAGE, v, ATTR_FIX_URL);
975 }
976
977 static HRESULT WINAPI HTMLStyle_get_backgroundImage(IHTMLStyle *iface, BSTR *p)
978 {
979     HTMLStyle *This = impl_from_IHTMLStyle(iface);
980
981     TRACE("(%p)->(%p)\n", This, p);
982
983     return get_style_attr(This, STYLEID_BACKGROUND_IMAGE, p);
984 }
985
986 static HRESULT WINAPI HTMLStyle_put_backgroundRepeat(IHTMLStyle *iface, BSTR v)
987 {
988     HTMLStyle *This = impl_from_IHTMLStyle(iface);
989     static const WCHAR styleRepeat[]   = {'r','e','p','e','a','t',0};
990     static const WCHAR styleNoRepeat[] = {'n','o','-','r','e','p','e','a','t',0};
991     static const WCHAR styleRepeatX[]  = {'r','e','p','e','a','t','-','x',0};
992     static const WCHAR styleRepeatY[]  = {'r','e','p','e','a','t','-','y',0};
993
994     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
995
996     /* fontWeight can only be one of the following */
997     if(!v || strcmpiW(styleRepeat, v) == 0    || strcmpiW(styleNoRepeat, v) == 0    ||
998              strcmpiW(styleRepeatX, v) == 0 || strcmpiW(styleRepeatY, v) == 0 )
999     {
1000         return set_style_attr(This, STYLEID_BACKGROUND_REPEAT , v, 0);
1001     }
1002
1003     return E_INVALIDARG;
1004 }
1005
1006 static HRESULT WINAPI HTMLStyle_get_backgroundRepeat(IHTMLStyle *iface, BSTR *p)
1007 {
1008     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1009
1010     TRACE("(%p)->(%p)\n", This, p);
1011
1012     return get_style_attr(This, STYLEID_BACKGROUND_REPEAT, p);
1013 }
1014
1015 static HRESULT WINAPI HTMLStyle_put_backgroundAttachment(IHTMLStyle *iface, BSTR v)
1016 {
1017     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1018     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1019     return E_NOTIMPL;
1020 }
1021
1022 static HRESULT WINAPI HTMLStyle_get_backgroundAttachment(IHTMLStyle *iface, BSTR *p)
1023 {
1024     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1025     FIXME("(%p)->(%p)\n", This, p);
1026     return E_NOTIMPL;
1027 }
1028
1029 static HRESULT WINAPI HTMLStyle_put_backgroundPosition(IHTMLStyle *iface, BSTR v)
1030 {
1031     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1032
1033     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1034
1035     return set_style_attr(This, STYLEID_BACKGROUND_POSITION, v, 0);
1036 }
1037
1038 static HRESULT WINAPI HTMLStyle_get_backgroundPosition(IHTMLStyle *iface, BSTR *p)
1039 {
1040     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1041
1042     TRACE("(%p)->(%p)\n", This, p);
1043
1044     return get_style_attr(This, STYLEID_BACKGROUND_POSITION, p);
1045 }
1046
1047 static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIANT v)
1048 {
1049     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1050     WCHAR buf[14], *pos_val;
1051     nsAString pos_str;
1052     const WCHAR *val;
1053     DWORD val_len;
1054     HRESULT hres;
1055
1056     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1057
1058     hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1059     if(FAILED(hres))
1060         return hres;
1061
1062     val_len = val ? strlenW(val) : 0;
1063
1064     nsAString_Init(&pos_str, NULL);
1065     hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1066     if(SUCCEEDED(hres)) {
1067         const PRUnichar *pos, *posy;
1068         DWORD posy_len;
1069
1070         nsAString_GetData(&pos_str, &pos);
1071         posy = strchrW(pos, ' ');
1072         if(!posy) {
1073             static const WCHAR zero_pxW[] = {' ','0','p','x',0};
1074
1075             TRACE("no space in %s\n", debugstr_w(pos));
1076             posy = zero_pxW;
1077         }
1078
1079         posy_len = strlenW(posy);
1080         pos_val = heap_alloc((val_len+posy_len+1)*sizeof(WCHAR));
1081         if(pos_val) {
1082             if(val_len)
1083                 memcpy(pos_val, val, val_len*sizeof(WCHAR));
1084             if(posy_len)
1085                 memcpy(pos_val+val_len, posy, posy_len*sizeof(WCHAR));
1086             pos_val[val_len+posy_len] = 0;
1087         }else {
1088             hres = E_OUTOFMEMORY;
1089         }
1090     }
1091     nsAString_Finish(&pos_str);
1092     if(FAILED(hres))
1093         return hres;
1094
1095     TRACE("setting position to %s\n", debugstr_w(pos_val));
1096     hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1097     heap_free(pos_val);
1098     return hres;
1099 }
1100
1101 static HRESULT WINAPI HTMLStyle_get_backgroundPositionX(IHTMLStyle *iface, VARIANT *p)
1102 {
1103     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1104     nsAString pos_str;
1105     BSTR ret;
1106     HRESULT hres;
1107
1108     TRACE("(%p)->(%p)\n", This, p);
1109
1110     nsAString_Init(&pos_str, NULL);
1111     hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1112     if(SUCCEEDED(hres)) {
1113         const PRUnichar *pos, *space;
1114
1115         nsAString_GetData(&pos_str, &pos);
1116         space = strchrW(pos, ' ');
1117         if(!space) {
1118             WARN("no space in %s\n", debugstr_w(pos));
1119             space = pos + strlenW(pos);
1120         }
1121
1122         if(space != pos) {
1123             ret = SysAllocStringLen(pos, space-pos);
1124             if(!ret)
1125                 hres = E_OUTOFMEMORY;
1126         }else {
1127             ret = NULL;
1128         }
1129     }
1130     nsAString_Finish(&pos_str);
1131     if(FAILED(hres))
1132         return hres;
1133
1134     TRACE("returning %s\n", debugstr_w(ret));
1135     V_VT(p) = VT_BSTR;
1136     V_BSTR(p) = ret;
1137     return S_OK;
1138 }
1139
1140 static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIANT v)
1141 {
1142     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1143     WCHAR buf[14], *pos_val;
1144     nsAString pos_str;
1145     const WCHAR *val;
1146     DWORD val_len;
1147     HRESULT hres;
1148
1149     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1150
1151     hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1152     if(FAILED(hres))
1153         return hres;
1154
1155     val_len = val ? strlenW(val) : 0;
1156
1157     nsAString_Init(&pos_str, NULL);
1158     hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1159     if(SUCCEEDED(hres)) {
1160         const PRUnichar *pos, *space;
1161         DWORD posx_len;
1162
1163         nsAString_GetData(&pos_str, &pos);
1164         space = strchrW(pos, ' ');
1165         if(space) {
1166             space++;
1167         }else {
1168             static const WCHAR zero_pxW[] = {'0','p','x',' ',0};
1169
1170             TRACE("no space in %s\n", debugstr_w(pos));
1171             pos = zero_pxW;
1172             space = pos + sizeof(zero_pxW)/sizeof(WCHAR)-1;
1173         }
1174
1175         posx_len = space-pos;
1176
1177         pos_val = heap_alloc((posx_len+val_len+1)*sizeof(WCHAR));
1178         if(pos_val) {
1179             memcpy(pos_val, pos, posx_len*sizeof(WCHAR));
1180             if(val_len)
1181                 memcpy(pos_val+posx_len, val, val_len*sizeof(WCHAR));
1182             pos_val[posx_len+val_len] = 0;
1183         }else {
1184             hres = E_OUTOFMEMORY;
1185         }
1186     }
1187     nsAString_Finish(&pos_str);
1188     if(FAILED(hres))
1189         return hres;
1190
1191     TRACE("setting position to %s\n", debugstr_w(pos_val));
1192     hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1193     heap_free(pos_val);
1194     return hres;
1195 }
1196
1197 static HRESULT WINAPI HTMLStyle_get_backgroundPositionY(IHTMLStyle *iface, VARIANT *p)
1198 {
1199     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1200     nsAString pos_str;
1201     BSTR ret;
1202     HRESULT hres;
1203
1204     TRACE("(%p)->(%p)\n", This, p);
1205
1206     nsAString_Init(&pos_str, NULL);
1207     hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1208     if(SUCCEEDED(hres)) {
1209         const PRUnichar *pos, *posy;
1210
1211         nsAString_GetData(&pos_str, &pos);
1212         posy = strchrW(pos, ' ');
1213         if(posy) {
1214             ret = SysAllocString(posy+1);
1215             if(!ret)
1216                 hres = E_OUTOFMEMORY;
1217         }else {
1218             ret = NULL;
1219         }
1220     }
1221     nsAString_Finish(&pos_str);
1222     if(FAILED(hres))
1223         return hres;
1224
1225     TRACE("returning %s\n", debugstr_w(ret));
1226     V_VT(p) = VT_BSTR;
1227     V_BSTR(p) = ret;
1228     return S_OK;
1229 }
1230
1231 static HRESULT WINAPI HTMLStyle_put_wordSpacing(IHTMLStyle *iface, VARIANT v)
1232 {
1233     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1234     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1235     return set_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, &v, 0);
1236 }
1237
1238 static HRESULT WINAPI HTMLStyle_get_wordSpacing(IHTMLStyle *iface, VARIANT *p)
1239 {
1240     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1241     TRACE("(%p)->(%p)\n", This, p);
1242     return get_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, p, 0);
1243 }
1244
1245 static HRESULT WINAPI HTMLStyle_put_letterSpacing(IHTMLStyle *iface, VARIANT v)
1246 {
1247     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1248     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1249     return set_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, &v, 0);
1250 }
1251
1252 static HRESULT WINAPI HTMLStyle_get_letterSpacing(IHTMLStyle *iface, VARIANT *p)
1253 {
1254     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1255     TRACE("(%p)->(%p)\n", This, p);
1256     return get_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, p, 0);
1257 }
1258
1259 static HRESULT WINAPI HTMLStyle_put_textDecoration(IHTMLStyle *iface, BSTR v)
1260 {
1261     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1262
1263     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1264
1265     /* textDecoration can only be one of the following */
1266     if(!v || strcmpiW(styleNone, v)   == 0 || strcmpiW(valUnderline, v)   == 0 ||
1267              strcmpiW(valOverline, v) == 0 || strcmpiW(valLineThrough, v) == 0 ||
1268              strcmpiW(valBlink, v)    == 0)
1269     {
1270         return set_style_attr(This, STYLEID_TEXT_DECORATION , v, 0);
1271     }
1272
1273     return E_INVALIDARG;
1274 }
1275
1276 static HRESULT WINAPI HTMLStyle_get_textDecoration(IHTMLStyle *iface, BSTR *p)
1277 {
1278     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1279
1280     TRACE("(%p)->(%p)\n", This, p);
1281
1282     return get_style_attr(This, STYLEID_TEXT_DECORATION, p);
1283 }
1284
1285 static HRESULT WINAPI HTMLStyle_put_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL v)
1286 {
1287     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1288
1289     TRACE("(%p)->(%x)\n", This, v);
1290
1291     return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? styleNone : emptyW, 0);
1292 }
1293
1294 static HRESULT WINAPI HTMLStyle_get_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL *p)
1295 {
1296     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1297
1298     TRACE("(%p)->(%p)\n", This, p);
1299
1300     return check_style_attr_value(This, STYLEID_TEXT_DECORATION, styleNone, p);
1301 }
1302
1303 static HRESULT WINAPI HTMLStyle_put_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL v)
1304 {
1305     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1306
1307     TRACE("(%p)->(%x)\n", This, v);
1308
1309     return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valUnderline : emptyW, 0);
1310 }
1311
1312 static HRESULT WINAPI HTMLStyle_get_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL *p)
1313 {
1314     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1315
1316     TRACE("(%p)->(%p)\n", This, p);
1317
1318     return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valUnderline, p);
1319 }
1320
1321 static HRESULT WINAPI HTMLStyle_put_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL v)
1322 {
1323     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1324
1325     TRACE("(%p)->(%x)\n", This, v);
1326
1327     return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valOverline : emptyW, 0);
1328 }
1329
1330 static HRESULT WINAPI HTMLStyle_get_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL *p)
1331 {
1332     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1333
1334     TRACE("(%p)->(%p)\n", This, p);
1335
1336     return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valOverline, p);
1337 }
1338
1339 static HRESULT WINAPI HTMLStyle_put_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL v)
1340 {
1341     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1342
1343     TRACE("(%p)->(%x)\n", This, v);
1344
1345     return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valLineThrough : emptyW, 0);
1346 }
1347
1348 static HRESULT WINAPI HTMLStyle_get_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL *p)
1349 {
1350     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1351
1352     TRACE("(%p)->(%p)\n", This, p);
1353
1354     return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valLineThrough, p);
1355 }
1356
1357 static HRESULT WINAPI HTMLStyle_put_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL v)
1358 {
1359     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1360
1361     TRACE("(%p)->(%x)\n", This, v);
1362
1363     return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valBlink : emptyW, 0);
1364 }
1365
1366 static HRESULT WINAPI HTMLStyle_get_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL *p)
1367 {
1368     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1369
1370     TRACE("(%p)->(%p)\n", This, p);
1371
1372     return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valBlink, p);
1373 }
1374
1375 static HRESULT WINAPI HTMLStyle_put_verticalAlign(IHTMLStyle *iface, VARIANT v)
1376 {
1377     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1378
1379     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1380
1381     switch(V_VT(&v)) {
1382     case VT_BSTR:
1383         return set_style_attr(This, STYLEID_VERTICAL_ALIGN, V_BSTR(&v), 0);
1384     default:
1385         FIXME("not implemented vt %d\n", V_VT(&v));
1386         return E_NOTIMPL;
1387     }
1388
1389     return S_OK;
1390 }
1391
1392 static HRESULT WINAPI HTMLStyle_get_verticalAlign(IHTMLStyle *iface, VARIANT *p)
1393 {
1394     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1395     BSTR ret;
1396     HRESULT hres;
1397
1398     TRACE("(%p)->(%p)\n", This, p);
1399
1400     hres = get_style_attr(This, STYLEID_VERTICAL_ALIGN, &ret);
1401     if(FAILED(hres))
1402         return hres;
1403
1404     V_VT(p) = VT_BSTR;
1405     V_BSTR(p) = ret;
1406     return S_OK;
1407 }
1408
1409 static HRESULT WINAPI HTMLStyle_put_textTransform(IHTMLStyle *iface, BSTR v)
1410 {
1411     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1412     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1413     return E_NOTIMPL;
1414 }
1415
1416 static HRESULT WINAPI HTMLStyle_get_textTransform(IHTMLStyle *iface, BSTR *p)
1417 {
1418     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1419     FIXME("(%p)->(%p)\n", This, p);
1420     return E_NOTIMPL;
1421 }
1422
1423 static HRESULT WINAPI HTMLStyle_put_textAlign(IHTMLStyle *iface, BSTR v)
1424 {
1425     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1426
1427     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1428
1429     return set_style_attr(This, STYLEID_TEXT_ALIGN, v, 0);
1430 }
1431
1432 static HRESULT WINAPI HTMLStyle_get_textAlign(IHTMLStyle *iface, BSTR *p)
1433 {
1434     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1435
1436     TRACE("(%p)->(%p)\n", This, p);
1437
1438     return get_style_attr(This, STYLEID_TEXT_ALIGN, p);
1439 }
1440
1441 static HRESULT WINAPI HTMLStyle_put_textIndent(IHTMLStyle *iface, VARIANT v)
1442 {
1443     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1444     FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1445     return E_NOTIMPL;
1446 }
1447
1448 static HRESULT WINAPI HTMLStyle_get_textIndent(IHTMLStyle *iface, VARIANT *p)
1449 {
1450     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1451     FIXME("(%p)->(%p)\n", This, p);
1452     return E_NOTIMPL;
1453 }
1454
1455 static HRESULT WINAPI HTMLStyle_put_lineHeight(IHTMLStyle *iface, VARIANT v)
1456 {
1457     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1458     FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1459     return E_NOTIMPL;
1460 }
1461
1462 static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
1463 {
1464     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1465     FIXME("(%p)->(%p)\n", This, p);
1466     return E_NOTIMPL;
1467 }
1468
1469 static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
1470 {
1471     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1472
1473     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1474
1475     return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, &v, ATTR_FIX_PX);
1476 }
1477
1478 static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
1479 {
1480     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1481
1482     TRACE("(%p)->(%p)\n", This, p);
1483
1484     return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
1485 }
1486
1487 static HRESULT WINAPI HTMLStyle_put_marginRight(IHTMLStyle *iface, VARIANT v)
1488 {
1489     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1490
1491     TRACE("(%p)->(v(%d))\n", This, V_VT(&v));
1492
1493     return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, &v, ATTR_FIX_PX);
1494 }
1495
1496 static HRESULT WINAPI HTMLStyle_get_marginRight(IHTMLStyle *iface, VARIANT *p)
1497 {
1498     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1499     TRACE("(%p)->(%p)\n", This, p);
1500     return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
1501 }
1502
1503 static HRESULT WINAPI HTMLStyle_put_marginBottom(IHTMLStyle *iface, VARIANT v)
1504 {
1505     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1506
1507     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1508
1509     return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, &v, ATTR_FIX_PX);
1510 }
1511
1512 static HRESULT WINAPI HTMLStyle_get_marginBottom(IHTMLStyle *iface, VARIANT *p)
1513 {
1514     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1515
1516     TRACE("(%p)->(%p)\n", This, p);
1517
1518     return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, p, 0);
1519 }
1520
1521 static HRESULT WINAPI HTMLStyle_put_marginLeft(IHTMLStyle *iface, VARIANT v)
1522 {
1523     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1524
1525     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1526
1527     return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, &v, ATTR_FIX_PX);
1528 }
1529
1530 static HRESULT WINAPI HTMLStyle_put_margin(IHTMLStyle *iface, BSTR v)
1531 {
1532     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1533
1534     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1535
1536     return set_style_attr(This, STYLEID_MARGIN, v, 0);
1537 }
1538
1539 static HRESULT WINAPI HTMLStyle_get_margin(IHTMLStyle *iface, BSTR *p)
1540 {
1541     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1542
1543     TRACE("(%p)->(%p)\n", This, p);
1544
1545     return get_style_attr(This, STYLEID_MARGIN, p);
1546 }
1547
1548 static HRESULT WINAPI HTMLStyle_get_marginLeft(IHTMLStyle *iface, VARIANT *p)
1549 {
1550     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1551     TRACE("(%p)->(%p)\n", This, p);
1552     return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
1553 }
1554
1555 static HRESULT WINAPI HTMLStyle_put_paddingTop(IHTMLStyle *iface, VARIANT v)
1556 {
1557     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1558
1559     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1560
1561     return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, &v, ATTR_FIX_PX);
1562 }
1563
1564 static HRESULT WINAPI HTMLStyle_get_paddingTop(IHTMLStyle *iface, VARIANT *p)
1565 {
1566     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1567
1568     TRACE("(%p)->(%p)\n", This, p);
1569
1570     return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, p, 0);
1571 }
1572
1573 static HRESULT WINAPI HTMLStyle_put_paddingRight(IHTMLStyle *iface, VARIANT v)
1574 {
1575     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1576
1577     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1578
1579     return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, &v, ATTR_FIX_PX);
1580 }
1581
1582 static HRESULT WINAPI HTMLStyle_get_paddingRight(IHTMLStyle *iface, VARIANT *p)
1583 {
1584     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1585
1586     TRACE("(%p)->(%p)\n", This, p);
1587
1588     return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, p, 0);
1589 }
1590
1591 static HRESULT WINAPI HTMLStyle_put_paddingBottom(IHTMLStyle *iface, VARIANT v)
1592 {
1593     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1594
1595     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1596
1597     return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, &v, ATTR_FIX_PX);
1598 }
1599
1600 static HRESULT WINAPI HTMLStyle_get_paddingBottom(IHTMLStyle *iface, VARIANT *p)
1601 {
1602     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1603
1604     TRACE("(%p)->(%p)\n", This, p);
1605
1606     return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, p, 0);
1607 }
1608
1609 static HRESULT WINAPI HTMLStyle_put_paddingLeft(IHTMLStyle *iface, VARIANT v)
1610 {
1611     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1612
1613     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1614
1615     return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, &v, ATTR_FIX_PX);
1616 }
1617
1618 static HRESULT WINAPI HTMLStyle_get_paddingLeft(IHTMLStyle *iface, VARIANT *p)
1619 {
1620     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1621
1622     TRACE("(%p)->(%p)\n", This, p);
1623
1624     return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, p, 0);
1625 }
1626
1627 static HRESULT WINAPI HTMLStyle_put_padding(IHTMLStyle *iface, BSTR v)
1628 {
1629     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1630
1631     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1632
1633     return set_style_attr(This, STYLEID_PADDING, v, 0);
1634 }
1635
1636 static HRESULT WINAPI HTMLStyle_get_padding(IHTMLStyle *iface, BSTR *p)
1637 {
1638     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1639
1640     TRACE("(%p)->(%p)\n", This, p);
1641
1642     return get_style_attr(This, STYLEID_PADDING, p);
1643 }
1644
1645 static HRESULT WINAPI HTMLStyle_put_border(IHTMLStyle *iface, BSTR v)
1646 {
1647     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1648
1649     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1650
1651     return set_style_attr(This, STYLEID_BORDER, v, 0);
1652 }
1653
1654 static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
1655 {
1656     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1657
1658     TRACE("(%p)->(%p)\n", This, p);
1659
1660     return get_style_attr(This, STYLEID_BORDER, p);
1661 }
1662
1663 static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
1664 {
1665     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1666     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1667     return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX);
1668 }
1669
1670 static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
1671 {
1672     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1673     TRACE("(%p)->(%p)\n", This, p);
1674     return get_style_attr(This, STYLEID_BORDER_TOP, p);
1675 }
1676
1677 static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
1678 {
1679     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1680     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1681     return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX);
1682 }
1683
1684 static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
1685 {
1686     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1687     TRACE("(%p)->(%p)\n", This, p);
1688     return get_style_attr(This, STYLEID_BORDER_RIGHT, p);
1689 }
1690
1691 static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
1692 {
1693     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1694     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1695     return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX);
1696 }
1697
1698 static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
1699 {
1700     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1701     TRACE("(%p)->(%p)\n", This, p);
1702     return get_style_attr(This, STYLEID_BORDER_BOTTOM, p);
1703 }
1704
1705 static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
1706 {
1707     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1708
1709     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1710
1711     return set_style_attr(This, STYLEID_BORDER_LEFT, v, ATTR_FIX_PX);
1712 }
1713
1714 static HRESULT WINAPI HTMLStyle_get_borderLeft(IHTMLStyle *iface, BSTR *p)
1715 {
1716     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1717
1718     TRACE("(%p)->(%p)\n", This, p);
1719
1720     return get_style_attr(This, STYLEID_BORDER_LEFT, p);
1721 }
1722
1723 static HRESULT WINAPI HTMLStyle_put_borderColor(IHTMLStyle *iface, BSTR v)
1724 {
1725     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1726
1727     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1728
1729     return set_style_attr(This, STYLEID_BORDER_COLOR, v, 0);
1730 }
1731
1732 static HRESULT WINAPI HTMLStyle_get_borderColor(IHTMLStyle *iface, BSTR *p)
1733 {
1734     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1735
1736     TRACE("(%p)->(%p)\n", This, p);
1737
1738     return get_style_attr(This, STYLEID_BORDER_COLOR, p);
1739 }
1740
1741 static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v)
1742 {
1743     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1744
1745     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1746
1747     return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, &v, ATTR_HEX_INT);
1748 }
1749
1750 static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p)
1751 {
1752     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1753
1754     TRACE("(%p)->(%p)\n", This, p);
1755
1756     return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0);
1757 }
1758
1759 static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v)
1760 {
1761     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1762
1763     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1764
1765     return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, &v, ATTR_HEX_INT);
1766 }
1767
1768 static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p)
1769 {
1770     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1771
1772     TRACE("(%p)->(%p)\n", This, p);
1773
1774     return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0);
1775 }
1776
1777 static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v)
1778 {
1779     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1780
1781     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1782
1783     return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, &v, ATTR_HEX_INT);
1784 }
1785
1786 static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p)
1787 {
1788     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1789
1790     TRACE("(%p)->(%p)\n", This, p);
1791
1792     return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0);
1793 }
1794
1795 static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v)
1796 {
1797     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1798
1799     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1800
1801     return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, &v, ATTR_HEX_INT);
1802 }
1803
1804 static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p)
1805 {
1806     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1807
1808     TRACE("(%p)->(%p)\n", This, p);
1809
1810     return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0);
1811 }
1812
1813 static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v)
1814 {
1815     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1816     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1817     return set_style_attr(This, STYLEID_BORDER_WIDTH, v, ATTR_FIX_PX);
1818 }
1819
1820 static HRESULT WINAPI HTMLStyle_get_borderWidth(IHTMLStyle *iface, BSTR *p)
1821 {
1822     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1823     TRACE("(%p)->(%p)\n", This, p);
1824     return get_style_attr(This, STYLEID_BORDER_WIDTH, p);
1825 }
1826
1827 static HRESULT WINAPI HTMLStyle_put_borderTopWidth(IHTMLStyle *iface, VARIANT v)
1828 {
1829     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1830     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1831     return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, &v, 0);
1832 }
1833
1834 static HRESULT WINAPI HTMLStyle_get_borderTopWidth(IHTMLStyle *iface, VARIANT *p)
1835 {
1836     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1837
1838     TRACE("(%p)->(%p)\n", This, p);
1839
1840     return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, p, 0);
1841 }
1842
1843 static HRESULT WINAPI HTMLStyle_put_borderRightWidth(IHTMLStyle *iface, VARIANT v)
1844 {
1845     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1846     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1847     return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, &v, 0);
1848 }
1849
1850 static HRESULT WINAPI HTMLStyle_get_borderRightWidth(IHTMLStyle *iface, VARIANT *p)
1851 {
1852     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1853     TRACE("(%p)->(%p)\n", This, p);
1854     return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, p, 0);
1855 }
1856
1857 static HRESULT WINAPI HTMLStyle_put_borderBottomWidth(IHTMLStyle *iface, VARIANT v)
1858 {
1859     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1860
1861     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1862     return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, &v, 0);
1863 }
1864
1865 static HRESULT WINAPI HTMLStyle_get_borderBottomWidth(IHTMLStyle *iface, VARIANT *p)
1866 {
1867     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1868     TRACE("(%p)->(%p)\n", This, p);
1869     return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, p, 0);
1870 }
1871
1872 static HRESULT WINAPI HTMLStyle_put_borderLeftWidth(IHTMLStyle *iface, VARIANT v)
1873 {
1874     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1875     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1876     return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, &v, 0);
1877 }
1878
1879 static HRESULT WINAPI HTMLStyle_get_borderLeftWidth(IHTMLStyle *iface, VARIANT *p)
1880 {
1881     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1882     TRACE("(%p)->(%p)\n", This, p);
1883     return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, p, 0);
1884 }
1885
1886 static HRESULT WINAPI HTMLStyle_put_borderStyle(IHTMLStyle *iface, BSTR v)
1887 {
1888     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1889     static const WCHAR styleWindowInset[]  = {'w','i','n','d','o','w','-','i','n','s','e','t',0};
1890     HRESULT hres = S_OK;
1891     BSTR pstyle;
1892     int i=0;
1893     int last = 0;
1894
1895     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1896
1897     while(v[i] && hres == S_OK)
1898     {
1899         if(v[i] == (WCHAR)' ')
1900         {
1901             pstyle = SysAllocStringLen(&v[last], (i-last));
1902             if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1903             {
1904                 TRACE("1. Invalid style (%s)\n", debugstr_w(pstyle));
1905                 hres = E_INVALIDARG;
1906             }
1907             SysFreeString(pstyle);
1908             last = i+1;
1909         }
1910         i++;
1911     }
1912
1913     if(hres == S_OK)
1914     {
1915         pstyle = SysAllocStringLen(&v[last], i-last);
1916         if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1917         {
1918             TRACE("2. Invalid style (%s)\n", debugstr_w(pstyle));
1919             hres = E_INVALIDARG;
1920         }
1921         SysFreeString(pstyle);
1922     }
1923
1924     if(hres == S_OK)
1925         hres = set_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, v, 0);
1926
1927     return hres;
1928 }
1929
1930 static HRESULT WINAPI HTMLStyle_get_borderStyle(IHTMLStyle *iface, BSTR *p)
1931 {
1932     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1933     TRACE("(%p)->(%p)\n", This, p);
1934     return get_style_attr(This, STYLEID_BORDER_STYLE, p);
1935 }
1936
1937 static HRESULT WINAPI HTMLStyle_put_borderTopStyle(IHTMLStyle *iface, BSTR v)
1938 {
1939     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1940     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1941
1942     if(!is_valid_border_style(v))
1943         return E_INVALIDARG;
1944
1945     return set_style_attr(This, STYLEID_BORDER_TOP_STYLE, v, 0);
1946 }
1947
1948 static HRESULT WINAPI HTMLStyle_get_borderTopStyle(IHTMLStyle *iface, BSTR *p)
1949 {
1950     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1951     TRACE("(%p)->(%p)\n", This, p);
1952     return get_style_attr(This, STYLEID_BORDER_TOP_STYLE, p);
1953 }
1954
1955 static HRESULT WINAPI HTMLStyle_put_borderRightStyle(IHTMLStyle *iface, BSTR v)
1956 {
1957     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1958     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1959
1960     if(!is_valid_border_style(v))
1961         return E_INVALIDARG;
1962
1963     return set_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, v, 0);
1964 }
1965
1966 static HRESULT WINAPI HTMLStyle_get_borderRightStyle(IHTMLStyle *iface, BSTR *p)
1967 {
1968     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1969     TRACE("(%p)->(%p)\n", This, p);
1970     return get_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, p);
1971 }
1972
1973 static HRESULT WINAPI HTMLStyle_put_borderBottomStyle(IHTMLStyle *iface, BSTR v)
1974 {
1975     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1976     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1977
1978     if(!is_valid_border_style(v))
1979         return E_INVALIDARG;
1980
1981     return set_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, v, 0);
1982 }
1983
1984 static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p)
1985 {
1986     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1987     TRACE("(%p)->(%p)\n", This, p);
1988     return get_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, p);
1989 }
1990
1991 static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v)
1992 {
1993     HTMLStyle *This = impl_from_IHTMLStyle(iface);
1994     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1995
1996     if(!is_valid_border_style(v))
1997         return E_INVALIDARG;
1998
1999     return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0);
2000 }
2001
2002 static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p)
2003 {
2004     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2005     TRACE("(%p)->(%p)\n", This, p);
2006     return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p);
2007 }
2008
2009 static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
2010 {
2011     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2012
2013     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
2014
2015     return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX);
2016 }
2017
2018 static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
2019 {
2020     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2021
2022     TRACE("(%p)->(%p)\n", This, p);
2023
2024     V_VT(p) = VT_BSTR;
2025     return get_style_attr(This, STYLEID_WIDTH, &V_BSTR(p));
2026 }
2027
2028 static HRESULT WINAPI HTMLStyle_put_height(IHTMLStyle *iface, VARIANT v)
2029 {
2030     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2031
2032     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2033
2034     return set_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, &v, ATTR_FIX_PX);
2035 }
2036
2037 static HRESULT WINAPI HTMLStyle_get_height(IHTMLStyle *iface, VARIANT *p)
2038 {
2039     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2040     BSTR ret;
2041     HRESULT hres;
2042
2043     TRACE("(%p)->(%p)\n", This, p);
2044
2045     hres = get_style_attr(This, STYLEID_HEIGHT, &ret);
2046     if(FAILED(hres))
2047         return hres;
2048
2049     V_VT(p) = VT_BSTR;
2050     V_BSTR(p) = ret;
2051     return S_OK;
2052 }
2053
2054 static HRESULT WINAPI HTMLStyle_put_styleFloat(IHTMLStyle *iface, BSTR v)
2055 {
2056     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2057     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2058     return E_NOTIMPL;
2059 }
2060
2061 static HRESULT WINAPI HTMLStyle_get_styleFloat(IHTMLStyle *iface, BSTR *p)
2062 {
2063     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2064     FIXME("(%p)->(%p)\n", This, p);
2065     return E_NOTIMPL;
2066 }
2067
2068 static HRESULT WINAPI HTMLStyle_put_clear(IHTMLStyle *iface, BSTR v)
2069 {
2070     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2071     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2072     return E_NOTIMPL;
2073 }
2074
2075 static HRESULT WINAPI HTMLStyle_get_clear(IHTMLStyle *iface, BSTR *p)
2076 {
2077     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2078     FIXME("(%p)->(%p)\n", This, p);
2079     return E_NOTIMPL;
2080 }
2081
2082 static HRESULT WINAPI HTMLStyle_put_display(IHTMLStyle *iface, BSTR v)
2083 {
2084     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2085
2086     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2087
2088     return set_style_attr(This, STYLEID_DISPLAY, v, 0);
2089 }
2090
2091 static HRESULT WINAPI HTMLStyle_get_display(IHTMLStyle *iface, BSTR *p)
2092 {
2093     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2094
2095     TRACE("(%p)->(%p)\n", This, p);
2096
2097     return get_style_attr(This, STYLEID_DISPLAY, p);
2098 }
2099
2100 static HRESULT WINAPI HTMLStyle_put_visibility(IHTMLStyle *iface, BSTR v)
2101 {
2102     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2103
2104     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2105
2106     return set_style_attr(This, STYLEID_VISIBILITY, v, 0);
2107 }
2108
2109 static HRESULT WINAPI HTMLStyle_get_visibility(IHTMLStyle *iface, BSTR *p)
2110 {
2111     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2112
2113     TRACE("(%p)->(%p)\n", This, p);
2114
2115     return get_style_attr(This, STYLEID_VISIBILITY, p);
2116 }
2117
2118 static HRESULT WINAPI HTMLStyle_put_listStyleType(IHTMLStyle *iface, BSTR v)
2119 {
2120     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2121     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2122     return E_NOTIMPL;
2123 }
2124
2125 static HRESULT WINAPI HTMLStyle_get_listStyleType(IHTMLStyle *iface, BSTR *p)
2126 {
2127     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2128     FIXME("(%p)->(%p)\n", This, p);
2129     return E_NOTIMPL;
2130 }
2131
2132 static HRESULT WINAPI HTMLStyle_put_listStylePosition(IHTMLStyle *iface, BSTR v)
2133 {
2134     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2135     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2136     return E_NOTIMPL;
2137 }
2138
2139 static HRESULT WINAPI HTMLStyle_get_listStylePosition(IHTMLStyle *iface, BSTR *p)
2140 {
2141     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2142     FIXME("(%p)->(%p)\n", This, p);
2143     return E_NOTIMPL;
2144 }
2145
2146 static HRESULT WINAPI HTMLStyle_put_listStyleImage(IHTMLStyle *iface, BSTR v)
2147 {
2148     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2149     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2150     return E_NOTIMPL;
2151 }
2152
2153 static HRESULT WINAPI HTMLStyle_get_listStyleImage(IHTMLStyle *iface, BSTR *p)
2154 {
2155     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2156     FIXME("(%p)->(%p)\n", This, p);
2157     return E_NOTIMPL;
2158 }
2159
2160 static HRESULT WINAPI HTMLStyle_put_listStyle(IHTMLStyle *iface, BSTR v)
2161 {
2162     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2163     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2164     return E_NOTIMPL;
2165 }
2166
2167 static HRESULT WINAPI HTMLStyle_get_listStyle(IHTMLStyle *iface, BSTR *p)
2168 {
2169     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2170     FIXME("(%p)->(%p)\n", This, p);
2171     return E_NOTIMPL;
2172 }
2173
2174 static HRESULT WINAPI HTMLStyle_put_whiteSpace(IHTMLStyle *iface, BSTR v)
2175 {
2176     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2177     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2178     return E_NOTIMPL;
2179 }
2180
2181 static HRESULT WINAPI HTMLStyle_get_whiteSpace(IHTMLStyle *iface, BSTR *p)
2182 {
2183     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2184     FIXME("(%p)->(%p)\n", This, p);
2185     return E_NOTIMPL;
2186 }
2187
2188 static HRESULT WINAPI HTMLStyle_put_top(IHTMLStyle *iface, VARIANT v)
2189 {
2190     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2191
2192     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2193
2194     return set_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, &v, 0);
2195 }
2196
2197 static HRESULT WINAPI HTMLStyle_get_top(IHTMLStyle *iface, VARIANT *p)
2198 {
2199     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2200     BSTR ret;
2201     HRESULT hres;
2202
2203     TRACE("(%p)->(%p)\n", This, p);
2204
2205     hres = get_style_attr(This, STYLEID_TOP, &ret);
2206     if(FAILED(hres))
2207         return hres;
2208
2209     V_VT(p) = VT_BSTR;
2210     V_BSTR(p) = ret;
2211     return S_OK;
2212 }
2213
2214 static HRESULT WINAPI HTMLStyle_put_left(IHTMLStyle *iface, VARIANT v)
2215 {
2216     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2217
2218     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2219
2220     return set_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, &v, 0);
2221 }
2222
2223 static HRESULT WINAPI HTMLStyle_get_left(IHTMLStyle *iface, VARIANT *p)
2224 {
2225     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2226     BSTR ret;
2227     HRESULT hres;
2228
2229     TRACE("(%p)->(%p)\n", This, p);
2230
2231     hres = get_style_attr(This, STYLEID_LEFT, &ret);
2232     if(FAILED(hres))
2233         return hres;
2234
2235     V_VT(p) = VT_BSTR;
2236     V_BSTR(p) = ret;
2237     return S_OK;
2238 }
2239
2240 static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
2241 {
2242     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2243     TRACE("(%p)->(%p)\n", This, p);
2244     return IHTMLStyle2_get_position(&This->IHTMLStyle2_iface, p);
2245 }
2246
2247 static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
2248 {
2249     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2250
2251     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2252
2253     switch(V_VT(&v)) {
2254     case VT_BSTR:
2255         return set_style_attr(This, STYLEID_Z_INDEX, V_BSTR(&v), 0);
2256     case VT_I4: {
2257         WCHAR value[14];
2258         static const WCHAR format[] = {'%','d',0};
2259
2260         wsprintfW(value, format, V_I4(&v));
2261         return set_style_attr(This, STYLEID_Z_INDEX, value, 0);
2262     }
2263     default:
2264         FIXME("unimplemented vt %d\n", V_VT(&v));
2265         return E_NOTIMPL;
2266     }
2267
2268     return S_OK;
2269 }
2270
2271 static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
2272 {
2273     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2274
2275     TRACE("(%p)->(%p)\n", This, p);
2276
2277     return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
2278 }
2279
2280 static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
2281 {
2282     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2283     static const WCHAR szVisible[] = {'v','i','s','i','b','l','e',0};
2284     static const WCHAR szScroll[]  = {'s','c','r','o','l','l',0};
2285     static const WCHAR szHidden[]  = {'h','i','d','d','e','n',0};
2286     static const WCHAR szAuto[]    = {'a','u','t','o',0};
2287
2288     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2289
2290     /* overflow can only be one of the follow values. */
2291     if(!v || !*v || strcmpiW(szVisible, v) == 0 || strcmpiW(szScroll, v) == 0 ||
2292              strcmpiW(szHidden, v) == 0  || strcmpiW(szAuto, v) == 0)
2293     {
2294         return set_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, v, 0);
2295     }
2296
2297     return E_INVALIDARG;
2298 }
2299
2300
2301 static HRESULT WINAPI HTMLStyle_get_overflow(IHTMLStyle *iface, BSTR *p)
2302 {
2303     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2304
2305     TRACE("(%p)->(%p)\n", This, p);
2306
2307     if(!p)
2308        return E_INVALIDARG;
2309
2310     return get_style_attr(This, STYLEID_OVERFLOW, p);
2311 }
2312
2313 static HRESULT WINAPI HTMLStyle_put_pageBreakBefore(IHTMLStyle *iface, BSTR v)
2314 {
2315     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2316
2317     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2318
2319     return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, v, 0);
2320 }
2321
2322 static HRESULT WINAPI HTMLStyle_get_pageBreakBefore(IHTMLStyle *iface, BSTR *p)
2323 {
2324     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2325
2326     TRACE("(%p)->(%p)\n", This, p);
2327
2328     return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, p, 0);
2329 }
2330
2331 static HRESULT WINAPI HTMLStyle_put_pageBreakAfter(IHTMLStyle *iface, BSTR v)
2332 {
2333     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2334
2335     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2336
2337     return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, v, 0);
2338 }
2339
2340 static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p)
2341 {
2342     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2343
2344     TRACE("(%p)->(%p)\n", This, p);
2345
2346     return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, p, 0);
2347 }
2348
2349 static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
2350 {
2351     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2352     nsAString text_str;
2353     nsresult nsres;
2354
2355     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2356
2357     nsAString_InitDepend(&text_str, v);
2358     nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str);
2359     nsAString_Finish(&text_str);
2360     if(NS_FAILED(nsres)) {
2361         FIXME("SetCssStyle failed: %08x\n", nsres);
2362         return E_FAIL;
2363     }
2364
2365     return S_OK;
2366 }
2367
2368 static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p)
2369 {
2370     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2371     nsAString text_str;
2372     nsresult nsres;
2373
2374     TRACE("(%p)->(%p)\n", This, p);
2375
2376     /* FIXME: Gecko style formatting is different than IE (uppercase). */
2377     nsAString_Init(&text_str, NULL);
2378     nsres = nsIDOMCSSStyleDeclaration_GetCssText(This->nsstyle, &text_str);
2379     if(NS_SUCCEEDED(nsres)) {
2380         const PRUnichar *text;
2381
2382         nsAString_GetData(&text_str, &text);
2383         *p = *text ? SysAllocString(text) : NULL;
2384     }else {
2385         FIXME("GetCssStyle failed: %08x\n", nsres);
2386         *p = NULL;
2387     }
2388
2389     nsAString_Finish(&text_str);
2390     return S_OK;
2391 }
2392
2393 static HRESULT WINAPI HTMLStyle_put_pixelTop(IHTMLStyle *iface, LONG v)
2394 {
2395     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2396     FIXME("(%p)->()\n", This);
2397     return E_NOTIMPL;
2398 }
2399
2400 static HRESULT WINAPI HTMLStyle_get_pixelTop(IHTMLStyle *iface, LONG *p)
2401 {
2402     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2403     FIXME("(%p)->()\n", This);
2404     return E_NOTIMPL;
2405 }
2406
2407 static HRESULT WINAPI HTMLStyle_put_pixelLeft(IHTMLStyle *iface, LONG v)
2408 {
2409     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2410     FIXME("(%p)->()\n", This);
2411     return E_NOTIMPL;
2412 }
2413
2414 static HRESULT WINAPI HTMLStyle_get_pixelLeft(IHTMLStyle *iface, LONG *p)
2415 {
2416     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2417     FIXME("(%p)->()\n", This);
2418     return E_NOTIMPL;
2419 }
2420
2421 static HRESULT WINAPI HTMLStyle_put_pixelWidth(IHTMLStyle *iface, LONG v)
2422 {
2423     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2424     FIXME("(%p)->()\n", This);
2425     return E_NOTIMPL;
2426 }
2427
2428 static HRESULT WINAPI HTMLStyle_get_pixelWidth(IHTMLStyle *iface, LONG *p)
2429 {
2430     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2431     FIXME("(%p)->()\n", This);
2432     return E_NOTIMPL;
2433 }
2434
2435 static HRESULT WINAPI HTMLStyle_put_pixelHeight(IHTMLStyle *iface, LONG v)
2436 {
2437     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2438     FIXME("(%p)->()\n", This);
2439     return E_NOTIMPL;
2440 }
2441
2442 static HRESULT WINAPI HTMLStyle_get_pixelHeight(IHTMLStyle *iface, LONG *p)
2443 {
2444     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2445     FIXME("(%p)->()\n", This);
2446     return E_NOTIMPL;
2447 }
2448
2449 static HRESULT WINAPI HTMLStyle_put_posTop(IHTMLStyle *iface, float v)
2450 {
2451     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2452
2453     TRACE("(%p)->(%f)\n", This, v);
2454
2455     return set_style_pos(This, STYLEID_TOP, v);
2456 }
2457
2458 static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
2459 {
2460     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2461
2462     TRACE("(%p)->(%p)\n", This, p);
2463
2464     if(!p)
2465         return E_POINTER;
2466
2467     return get_nsstyle_pos(This, STYLEID_TOP, p);
2468 }
2469
2470 static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
2471 {
2472     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2473
2474     TRACE("(%p)->(%f)\n", This, v);
2475
2476     return set_style_pos(This, STYLEID_LEFT, v);
2477 }
2478
2479 static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
2480 {
2481     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2482
2483     TRACE("(%p)->(%p)\n", This, p);
2484
2485     if(!p)
2486         return E_POINTER;
2487
2488     return get_nsstyle_pos(This, STYLEID_LEFT, p);
2489 }
2490
2491 static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
2492 {
2493     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2494
2495     TRACE("(%p)->(%f)\n", This, v);
2496
2497     return set_style_pos(This, STYLEID_WIDTH, v);
2498 }
2499
2500 static HRESULT WINAPI HTMLStyle_get_posWidth(IHTMLStyle *iface, float *p)
2501 {
2502     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2503
2504     TRACE("(%p)->(%p)\n", This, p);
2505
2506     if(!p)
2507         return E_POINTER;
2508
2509     if(get_nsstyle_pos(This, STYLEID_WIDTH, p) != S_OK)
2510         *p = 0.0f;
2511
2512     return S_OK;
2513 }
2514
2515 static HRESULT WINAPI HTMLStyle_put_posHeight(IHTMLStyle *iface, float v)
2516 {
2517     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2518
2519     TRACE("(%p)->(%f)\n", This, v);
2520
2521     return set_style_pos(This, STYLEID_HEIGHT, v);
2522 }
2523
2524 static HRESULT WINAPI HTMLStyle_get_posHeight(IHTMLStyle *iface, float *p)
2525 {
2526     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2527
2528     TRACE("(%p)->(%p)\n", This, p);
2529
2530     if(!p)
2531         return E_POINTER;
2532
2533     if(get_nsstyle_pos(This, STYLEID_HEIGHT, p) != S_OK)
2534         *p = 0.0f;
2535
2536     return S_OK;
2537 }
2538
2539 static HRESULT WINAPI HTMLStyle_put_cursor(IHTMLStyle *iface, BSTR v)
2540 {
2541     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2542
2543     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2544
2545     return set_style_attr(This, STYLEID_CURSOR, v, 0);
2546 }
2547
2548 static HRESULT WINAPI HTMLStyle_get_cursor(IHTMLStyle *iface, BSTR *p)
2549 {
2550     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2551
2552     TRACE("(%p)->(%p)\n", This, p);
2553
2554     return get_style_attr(This, STYLEID_CURSOR, p);
2555 }
2556
2557 static HRESULT WINAPI HTMLStyle_put_clip(IHTMLStyle *iface, BSTR v)
2558 {
2559     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2560
2561     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2562
2563     return set_style_attr(This, STYLEID_CLIP, v, 0);
2564 }
2565
2566 static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
2567 {
2568     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2569
2570     TRACE("(%p)->(%p)\n", This, p);
2571
2572     return get_nsstyle_attr(This->nsstyle, STYLEID_CLIP, p, ATTR_REMOVE_COMMA);
2573 }
2574
2575 static void set_opacity(HTMLStyle *This, const WCHAR *val)
2576 {
2577     nsAString name_str, val_str, empty_str;
2578     nsresult nsres;
2579
2580     static const WCHAR opacityW[] = {'o','p','a','c','i','t','y',0};
2581
2582     TRACE("%s\n", debugstr_w(val));
2583
2584     nsAString_InitDepend(&name_str, opacityW);
2585     nsAString_InitDepend(&val_str, val);
2586     nsAString_InitDepend(&empty_str, emptyW);
2587
2588     nsres = nsIDOMCSSStyleDeclaration_SetProperty(This->nsstyle, &name_str, &val_str, &empty_str);
2589     if(NS_FAILED(nsres))
2590         ERR("SetProperty failed: %08x\n", nsres);
2591
2592     nsAString_Finish(&name_str);
2593     nsAString_Finish(&val_str);
2594     nsAString_Finish(&empty_str);
2595 }
2596
2597 static void update_filter(HTMLStyle *This)
2598 {
2599     const WCHAR *ptr = This->elem->filter, *ptr2;
2600
2601     static const WCHAR alphaW[] = {'a','l','p','h','a'};
2602
2603     if(!ptr) {
2604         set_opacity(This, emptyW);
2605         return;
2606     }
2607
2608     while(1) {
2609         while(isspaceW(*ptr))
2610             ptr++;
2611         if(!*ptr)
2612             break;
2613
2614         ptr2 = ptr;
2615         while(isalnumW(*ptr))
2616             ptr++;
2617         if(ptr == ptr2) {
2618             WARN("unexpected char '%c'\n", *ptr);
2619             break;
2620         }
2621         if(*ptr != '(') {
2622             WARN("expected '('\n");
2623             continue;
2624         }
2625
2626         if(ptr2 + sizeof(alphaW)/sizeof(WCHAR) == ptr && !memcmp(ptr2, alphaW, sizeof(alphaW))) {
2627             static const WCHAR formatW[] = {'%','f',0};
2628             static const WCHAR opacityW[] = {'o','p','a','c','i','t','y','='};
2629
2630             ptr++;
2631             do {
2632                 while(isspaceW(*ptr))
2633                     ptr++;
2634
2635                 ptr2 = ptr;
2636                 while(*ptr && *ptr != ',' && *ptr != ')')
2637                     ptr++;
2638                 if(!*ptr) {
2639                     WARN("unexpected end of string\n");
2640                     break;
2641                 }
2642
2643                 if(ptr-ptr2 > sizeof(opacityW)/sizeof(WCHAR) && !memcmp(ptr2, opacityW, sizeof(opacityW))) {
2644                     float fval = 0.0f, e = 0.1f;
2645                     WCHAR buf[32];
2646
2647                     ptr2 += sizeof(opacityW)/sizeof(WCHAR);
2648
2649                     while(isdigitW(*ptr2))
2650                         fval = fval*10.0f + (float)(*ptr2++ - '0');
2651
2652                     if(*ptr2 == '.') {
2653                         while(isdigitW(*++ptr2)) {
2654                             fval += e * (float)(*ptr2++ - '0');
2655                             e *= 0.1f;
2656                         }
2657                     }
2658
2659                     sprintfW(buf, formatW, fval * 0.01f);
2660                     set_opacity(This, buf);
2661                 }else {
2662                     FIXME("unknown param %s\n", debugstr_wn(ptr2, ptr-ptr2));
2663                 }
2664
2665                 if(*ptr == ',')
2666                     ptr++;
2667             }while(*ptr != ')');
2668         }else {
2669             FIXME("unknown filter %s\n", debugstr_wn(ptr2, ptr-ptr2));
2670             ptr = strchrW(ptr, ')');
2671             if(!ptr)
2672                 break;
2673             ptr++;
2674         }
2675     }
2676 }
2677
2678 static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
2679 {
2680     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2681     WCHAR *new_filter = NULL;
2682
2683     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2684
2685     if(!This->elem) {
2686         FIXME("Element already destroyed\n");
2687         return E_UNEXPECTED;
2688     }
2689
2690     if(v) {
2691         new_filter = heap_strdupW(v);
2692         if(!new_filter)
2693             return E_OUTOFMEMORY;
2694     }
2695
2696     heap_free(This->elem->filter);
2697     This->elem->filter = new_filter;
2698
2699     update_filter(This);
2700     return S_OK;
2701 }
2702
2703 static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
2704 {
2705     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2706
2707     TRACE("(%p)->(%p)\n", This, p);
2708
2709     if(!This->elem) {
2710         FIXME("Element already destroyed\n");
2711         return E_UNEXPECTED;
2712     }
2713
2714     if(This->elem->filter) {
2715         *p = SysAllocString(This->elem->filter);
2716         if(!*p)
2717             return E_OUTOFMEMORY;
2718     }else {
2719         *p = NULL;
2720     }
2721
2722     return S_OK;
2723 }
2724
2725 static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2726         VARIANT AttributeValue, LONG lFlags)
2727 {
2728     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2729     HRESULT hres;
2730     DISPID dispid;
2731
2732     TRACE("(%p)->(%s v%d %08x)\n", This, debugstr_w(strAttributeName),
2733            V_VT(&AttributeValue), lFlags);
2734
2735     if(!strAttributeName)
2736         return E_INVALIDARG;
2737
2738     if(lFlags == 1)
2739         FIXME("Parameter lFlags ignored\n");
2740
2741     hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2742                         LOCALE_USER_DEFAULT, &dispid);
2743     if(hres == S_OK)
2744     {
2745         VARIANT ret;
2746         DISPID dispidNamed = DISPID_PROPERTYPUT;
2747         DISPPARAMS params;
2748
2749         params.cArgs = 1;
2750         params.rgvarg = &AttributeValue;
2751         params.cNamedArgs = 1;
2752         params.rgdispidNamedArgs = &dispidNamed;
2753
2754         hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2755             DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2756     }
2757     else
2758     {
2759         FIXME("Custom attributes not supported.\n");
2760     }
2761
2762     TRACE("ret: %08x\n", hres);
2763
2764     return hres;
2765 }
2766
2767 static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2768         LONG lFlags, VARIANT *AttributeValue)
2769 {
2770     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2771     HRESULT hres;
2772     DISPID dispid;
2773
2774     TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName),
2775           AttributeValue, lFlags);
2776
2777     if(!AttributeValue || !strAttributeName)
2778         return E_INVALIDARG;
2779
2780     if(lFlags == 1)
2781         FIXME("Parameter lFlags ignored\n");
2782
2783     hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2784                         LOCALE_USER_DEFAULT, &dispid);
2785     if(hres == S_OK)
2786     {
2787         DISPPARAMS params = {NULL, NULL, 0, 0 };
2788
2789         hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2790             DISPATCH_PROPERTYGET, &params, AttributeValue, NULL, NULL);
2791     }
2792     else
2793     {
2794         FIXME("Custom attributes not supported.\n");
2795     }
2796
2797     return hres;
2798 }
2799
2800 static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2801                                                 LONG lFlags, VARIANT_BOOL *pfSuccess)
2802 {
2803     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2804     FIXME("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName),
2805          lFlags, pfSuccess);
2806     return E_NOTIMPL;
2807 }
2808
2809 static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
2810 {
2811     HTMLStyle *This = impl_from_IHTMLStyle(iface);
2812     FIXME("(%p)->(%p)\n", This, String);
2813     return E_NOTIMPL;
2814 }
2815
2816 static const IHTMLStyleVtbl HTMLStyleVtbl = {
2817     HTMLStyle_QueryInterface,
2818     HTMLStyle_AddRef,
2819     HTMLStyle_Release,
2820     HTMLStyle_GetTypeInfoCount,
2821     HTMLStyle_GetTypeInfo,
2822     HTMLStyle_GetIDsOfNames,
2823     HTMLStyle_Invoke,
2824     HTMLStyle_put_fontFamily,
2825     HTMLStyle_get_fontFamily,
2826     HTMLStyle_put_fontStyle,
2827     HTMLStyle_get_fontStyle,
2828     HTMLStyle_put_fontVariant,
2829     HTMLStyle_get_fontVariant,
2830     HTMLStyle_put_fontWeight,
2831     HTMLStyle_get_fontWeight,
2832     HTMLStyle_put_fontSize,
2833     HTMLStyle_get_fontSize,
2834     HTMLStyle_put_font,
2835     HTMLStyle_get_font,
2836     HTMLStyle_put_color,
2837     HTMLStyle_get_color,
2838     HTMLStyle_put_background,
2839     HTMLStyle_get_background,
2840     HTMLStyle_put_backgroundColor,
2841     HTMLStyle_get_backgroundColor,
2842     HTMLStyle_put_backgroundImage,
2843     HTMLStyle_get_backgroundImage,
2844     HTMLStyle_put_backgroundRepeat,
2845     HTMLStyle_get_backgroundRepeat,
2846     HTMLStyle_put_backgroundAttachment,
2847     HTMLStyle_get_backgroundAttachment,
2848     HTMLStyle_put_backgroundPosition,
2849     HTMLStyle_get_backgroundPosition,
2850     HTMLStyle_put_backgroundPositionX,
2851     HTMLStyle_get_backgroundPositionX,
2852     HTMLStyle_put_backgroundPositionY,
2853     HTMLStyle_get_backgroundPositionY,
2854     HTMLStyle_put_wordSpacing,
2855     HTMLStyle_get_wordSpacing,
2856     HTMLStyle_put_letterSpacing,
2857     HTMLStyle_get_letterSpacing,
2858     HTMLStyle_put_textDecoration,
2859     HTMLStyle_get_textDecoration,
2860     HTMLStyle_put_textDecorationNone,
2861     HTMLStyle_get_textDecorationNone,
2862     HTMLStyle_put_textDecorationUnderline,
2863     HTMLStyle_get_textDecorationUnderline,
2864     HTMLStyle_put_textDecorationOverline,
2865     HTMLStyle_get_textDecorationOverline,
2866     HTMLStyle_put_textDecorationLineThrough,
2867     HTMLStyle_get_textDecorationLineThrough,
2868     HTMLStyle_put_textDecorationBlink,
2869     HTMLStyle_get_textDecorationBlink,
2870     HTMLStyle_put_verticalAlign,
2871     HTMLStyle_get_verticalAlign,
2872     HTMLStyle_put_textTransform,
2873     HTMLStyle_get_textTransform,
2874     HTMLStyle_put_textAlign,
2875     HTMLStyle_get_textAlign,
2876     HTMLStyle_put_textIndent,
2877     HTMLStyle_get_textIndent,
2878     HTMLStyle_put_lineHeight,
2879     HTMLStyle_get_lineHeight,
2880     HTMLStyle_put_marginTop,
2881     HTMLStyle_get_marginTop,
2882     HTMLStyle_put_marginRight,
2883     HTMLStyle_get_marginRight,
2884     HTMLStyle_put_marginBottom,
2885     HTMLStyle_get_marginBottom,
2886     HTMLStyle_put_marginLeft,
2887     HTMLStyle_get_marginLeft,
2888     HTMLStyle_put_margin,
2889     HTMLStyle_get_margin,
2890     HTMLStyle_put_paddingTop,
2891     HTMLStyle_get_paddingTop,
2892     HTMLStyle_put_paddingRight,
2893     HTMLStyle_get_paddingRight,
2894     HTMLStyle_put_paddingBottom,
2895     HTMLStyle_get_paddingBottom,
2896     HTMLStyle_put_paddingLeft,
2897     HTMLStyle_get_paddingLeft,
2898     HTMLStyle_put_padding,
2899     HTMLStyle_get_padding,
2900     HTMLStyle_put_border,
2901     HTMLStyle_get_border,
2902     HTMLStyle_put_borderTop,
2903     HTMLStyle_get_borderTop,
2904     HTMLStyle_put_borderRight,
2905     HTMLStyle_get_borderRight,
2906     HTMLStyle_put_borderBottom,
2907     HTMLStyle_get_borderBottom,
2908     HTMLStyle_put_borderLeft,
2909     HTMLStyle_get_borderLeft,
2910     HTMLStyle_put_borderColor,
2911     HTMLStyle_get_borderColor,
2912     HTMLStyle_put_borderTopColor,
2913     HTMLStyle_get_borderTopColor,
2914     HTMLStyle_put_borderRightColor,
2915     HTMLStyle_get_borderRightColor,
2916     HTMLStyle_put_borderBottomColor,
2917     HTMLStyle_get_borderBottomColor,
2918     HTMLStyle_put_borderLeftColor,
2919     HTMLStyle_get_borderLeftColor,
2920     HTMLStyle_put_borderWidth,
2921     HTMLStyle_get_borderWidth,
2922     HTMLStyle_put_borderTopWidth,
2923     HTMLStyle_get_borderTopWidth,
2924     HTMLStyle_put_borderRightWidth,
2925     HTMLStyle_get_borderRightWidth,
2926     HTMLStyle_put_borderBottomWidth,
2927     HTMLStyle_get_borderBottomWidth,
2928     HTMLStyle_put_borderLeftWidth,
2929     HTMLStyle_get_borderLeftWidth,
2930     HTMLStyle_put_borderStyle,
2931     HTMLStyle_get_borderStyle,
2932     HTMLStyle_put_borderTopStyle,
2933     HTMLStyle_get_borderTopStyle,
2934     HTMLStyle_put_borderRightStyle,
2935     HTMLStyle_get_borderRightStyle,
2936     HTMLStyle_put_borderBottomStyle,
2937     HTMLStyle_get_borderBottomStyle,
2938     HTMLStyle_put_borderLeftStyle,
2939     HTMLStyle_get_borderLeftStyle,
2940     HTMLStyle_put_width,
2941     HTMLStyle_get_width,
2942     HTMLStyle_put_height,
2943     HTMLStyle_get_height,
2944     HTMLStyle_put_styleFloat,
2945     HTMLStyle_get_styleFloat,
2946     HTMLStyle_put_clear,
2947     HTMLStyle_get_clear,
2948     HTMLStyle_put_display,
2949     HTMLStyle_get_display,
2950     HTMLStyle_put_visibility,
2951     HTMLStyle_get_visibility,
2952     HTMLStyle_put_listStyleType,
2953     HTMLStyle_get_listStyleType,
2954     HTMLStyle_put_listStylePosition,
2955     HTMLStyle_get_listStylePosition,
2956     HTMLStyle_put_listStyleImage,
2957     HTMLStyle_get_listStyleImage,
2958     HTMLStyle_put_listStyle,
2959     HTMLStyle_get_listStyle,
2960     HTMLStyle_put_whiteSpace,
2961     HTMLStyle_get_whiteSpace,
2962     HTMLStyle_put_top,
2963     HTMLStyle_get_top,
2964     HTMLStyle_put_left,
2965     HTMLStyle_get_left,
2966     HTMLStyle_get_position,
2967     HTMLStyle_put_zIndex,
2968     HTMLStyle_get_zIndex,
2969     HTMLStyle_put_overflow,
2970     HTMLStyle_get_overflow,
2971     HTMLStyle_put_pageBreakBefore,
2972     HTMLStyle_get_pageBreakBefore,
2973     HTMLStyle_put_pageBreakAfter,
2974     HTMLStyle_get_pageBreakAfter,
2975     HTMLStyle_put_cssText,
2976     HTMLStyle_get_cssText,
2977     HTMLStyle_put_pixelTop,
2978     HTMLStyle_get_pixelTop,
2979     HTMLStyle_put_pixelLeft,
2980     HTMLStyle_get_pixelLeft,
2981     HTMLStyle_put_pixelWidth,
2982     HTMLStyle_get_pixelWidth,
2983     HTMLStyle_put_pixelHeight,
2984     HTMLStyle_get_pixelHeight,
2985     HTMLStyle_put_posTop,
2986     HTMLStyle_get_posTop,
2987     HTMLStyle_put_posLeft,
2988     HTMLStyle_get_posLeft,
2989     HTMLStyle_put_posWidth,
2990     HTMLStyle_get_posWidth,
2991     HTMLStyle_put_posHeight,
2992     HTMLStyle_get_posHeight,
2993     HTMLStyle_put_cursor,
2994     HTMLStyle_get_cursor,
2995     HTMLStyle_put_clip,
2996     HTMLStyle_get_clip,
2997     HTMLStyle_put_filter,
2998     HTMLStyle_get_filter,
2999     HTMLStyle_setAttribute,
3000     HTMLStyle_getAttribute,
3001     HTMLStyle_removeAttribute,
3002     HTMLStyle_toString
3003 };
3004
3005 static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
3006 {
3007     int c, i, min=0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
3008
3009     while(min <= max) {
3010         i = (min+max)/2;
3011
3012         c = strcmpW(style_tbl[i].name, name);
3013         if(!c) {
3014             *dispid = style_tbl[i].dispid;
3015             return S_OK;
3016         }
3017
3018         if(c > 0)
3019             max = i-1;
3020         else
3021             min = i+1;
3022     }
3023
3024     return DISP_E_UNKNOWNNAME;
3025 }
3026
3027 static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
3028     NULL,
3029     HTMLStyle_get_dispid,
3030     NULL,
3031     NULL
3032 };
3033
3034 static const tid_t HTMLStyle_iface_tids[] = {
3035     IHTMLStyle_tid,
3036     IHTMLStyle2_tid,
3037     IHTMLStyle3_tid,
3038     IHTMLStyle4_tid,
3039     IHTMLStyle5_tid,
3040     IHTMLStyle6_tid,
3041     0
3042 };
3043 static dispex_static_data_t HTMLStyle_dispex = {
3044     &HTMLStyle_dispex_vtbl,
3045     DispHTMLStyle_tid,
3046     NULL,
3047     HTMLStyle_iface_tids
3048 };
3049
3050 HRESULT HTMLStyle_Create(HTMLElement *elem, nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
3051 {
3052     HTMLStyle *style;
3053
3054     style = heap_alloc_zero(sizeof(HTMLStyle));
3055     if(!style)
3056         return E_OUTOFMEMORY;
3057
3058     style->IHTMLStyle_iface.lpVtbl = &HTMLStyleVtbl;
3059     style->ref = 1;
3060     style->nsstyle = nsstyle;
3061     style->elem = elem;
3062     HTMLStyle2_Init(style);
3063     HTMLStyle3_Init(style);
3064
3065     nsIDOMCSSStyleDeclaration_AddRef(nsstyle);
3066
3067     init_dispex(&style->dispex, (IUnknown*)&style->IHTMLStyle_iface, &HTMLStyle_dispex);
3068
3069     *ret = style;
3070     return S_OK;
3071 }