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