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