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