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