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