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