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