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