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