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