mshtml: Moved style_tbl lookup to separated function.
[wine.git] / dlls / mshtml / htmlstyle.c
blob1f8947c5d23b559ab33ab8457346957418734fa9
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <stdarg.h>
20 #include <math.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28 #include "mshtmdid.h"
30 #include "mshtml_private.h"
31 #include "htmlstyle.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 static const WCHAR attrBackground[] =
38 {'b','a','c','k','g','r','o','u','n','d',0};
39 static const WCHAR attrBackgroundColor[] =
40 {'b','a','c','k','g','r','o','u','n','d','-','c','o','l','o','r',0};
41 static const WCHAR attrBackgroundImage[] =
42 {'b','a','c','k','g','r','o','u','n','d','-','i','m','a','g','e',0};
43 static const WCHAR attrBackgroundPosition[] =
44 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n',0};
45 static const WCHAR attrBackgroundPositionX[] =
46 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','x',0};
47 static const WCHAR attrBackgroundPositionY[] =
48 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','y',0};
49 static const WCHAR attrBackgroundRepeat[] =
50 {'b','a','c','k','g','r','o','u','n','d','-','r','e','p','e','a','t',0};
51 static const WCHAR attrBorder[] =
52 {'b','o','r','d','e','r',0};
53 static const WCHAR attrBorderBottom[] =
54 {'b','o','r','d','e','r','-','b','o','t','t','o','m',0};
55 static const WCHAR attrBorderBottomColor[] =
56 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','c','o','l','o','r',0};
57 static const WCHAR attrBorderBottomStyle[] =
58 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','s','t','y','l','e',0};
59 static const WCHAR attrBorderBottomWidth[] =
60 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','w','i','d','t','h',0};
61 static const WCHAR attrBorderColor[] =
62 {'b','o','r','d','e','r','-','c','o','l','o','r',0};
63 static const WCHAR attrBorderLeft[] =
64 {'b','o','r','d','e','r','-','l','e','f','t',0};
65 static const WCHAR attrBorderLeftColor[] =
66 {'b','o','r','d','e','r','-','l','e','f','t','-','c','o','l','o','r',0};
67 static const WCHAR attrBorderLeftStyle[] =
68 {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0};
69 static const WCHAR attrBorderLeftWidth[] =
70 {'b','o','r','d','e','r','-','l','e','f','t','-','w','i','d','t','h',0};
71 static const WCHAR attrBorderRight[] =
72 {'b','o','r','d','e','r','-','r','i','g','h','t',0};
73 static const WCHAR attrBorderRightColor[] =
74 {'b','o','r','d','e','r','-','r','i','g','h','t','-','c','o','l','o','r',0};
75 static const WCHAR attrBorderRightStyle[] =
76 {'b','o','r','d','e','r','-','r','i','g','h','t','-','s','t','y','l','e',0};
77 static const WCHAR attrBorderRightWidth[] =
78 {'b','o','r','d','e','r','-','r','i','g','h','t','-','w','i','d','t','h',0};
79 static const WCHAR attrBorderTop[] =
80 {'b','o','r','d','e','r','-','t','o','p',0};
81 static const WCHAR attrBorderTopColor[] =
82 {'b','o','r','d','e','r','-','t','o','p','-','c','o','l','o','r',0};
83 static const WCHAR attrBorderStyle[] =
84 {'b','o','r','d','e','r','-','s','t','y','l','e',0};
85 static const WCHAR attrBorderTopStyle[] =
86 {'b','o','r','d','e','r','-','t','o','p','-','s','t','y','l','e',0};
87 static const WCHAR attrBorderTopWidth[] =
88 {'b','o','r','d','e','r','-','t','o','p','-','w','i','d','t','h',0};
89 static const WCHAR attrBorderWidth[] =
90 {'b','o','r','d','e','r','-','w','i','d','t','h',0};
91 static const WCHAR attrBottom[] =
92 {'b','o','t','t','o','m',0};
93 static const WCHAR attrClip[] =
94 {'c','l','i','p',0};
95 static const WCHAR attrColor[] =
96 {'c','o','l','o','r',0};
97 static const WCHAR attrCursor[] =
98 {'c','u','r','s','o','r',0};
99 static const WCHAR attrDirection[] =
100 {'d','i','r','e','c','t','i','o','n',0};
101 static const WCHAR attrDisplay[] =
102 {'d','i','s','p','l','a','y',0};
103 static const WCHAR attrFilter[] =
104 {'f','i','l','e','t','e','r',0};
105 static const WCHAR attrFontFamily[] =
106 {'f','o','n','t','-','f','a','m','i','l','y',0};
107 static const WCHAR attrFontSize[] =
108 {'f','o','n','t','-','s','i','z','e',0};
109 static const WCHAR attrFontStyle[] =
110 {'f','o','n','t','-','s','t','y','l','e',0};
111 static const WCHAR attrFontVariant[] =
112 {'f','o','n','t','-','v','a','r','i','a','n','t',0};
113 static const WCHAR attrFontWeight[] =
114 {'f','o','n','t','-','w','e','i','g','h','t',0};
115 static const WCHAR attrHeight[] =
116 {'h','e','i','g','h','t',0};
117 static const WCHAR attrLeft[] =
118 {'l','e','f','t',0};
119 static const WCHAR attrLetterSpacing[] =
120 {'l','e','t','t','e','r','-','s','p','a','c','i','n','g',0};
121 static const WCHAR attrLineHeight[] =
122 {'l','i','n','e','-','h','e','i','g','h','t',0};
123 static const WCHAR attrMargin[] =
124 {'m','a','r','g','i','n',0};
125 static const WCHAR attrMarginBottom[] =
126 {'m','a','r','g','i','n','-','b','o','t','t','o','m',0};
127 static const WCHAR attrMarginLeft[] =
128 {'m','a','r','g','i','n','-','l','e','f','t',0};
129 static const WCHAR attrMarginRight[] =
130 {'m','a','r','g','i','n','-','r','i','g','h','t',0};
131 static const WCHAR attrMarginTop[] =
132 {'m','a','r','g','i','n','-','t','o','p',0};
133 static const WCHAR attrMinHeight[] =
134 {'m','i','n','-','h','e','i','g','h','t',0};
135 static const WCHAR attrOverflow[] =
136 {'o','v','e','r','f','l','o','w',0};
137 static const WCHAR attrPadding[] =
138 {'p','a','d','d','i','n','g',0};
139 static const WCHAR attrPaddingBottom[] =
140 {'p','a','d','d','i','n','g','-','b','o','t','t','o','m',0};
141 static const WCHAR attrPaddingLeft[] =
142 {'p','a','d','d','i','n','g','-','l','e','f','t',0};
143 static const WCHAR attrPaddingRight[] =
144 {'p','a','d','d','i','n','g','-','r','i','g','h','t',0};
145 static const WCHAR attrPaddingTop[] =
146 {'p','a','d','d','i','n','g','-','t','o','p',0};
147 static const WCHAR attrPageBreakAfter[] =
148 {'p','a','g','e','-','b','r','e','a','k','-','a','f','t','e','r',0};
149 static const WCHAR attrPageBreakBefore[] =
150 {'p','a','g','e','-','b','r','e','a','k','-','b','e','f','o','r','e',0};
151 static const WCHAR attrPosition[] =
152 {'p','o','s','i','t','i','o','n',0};
153 static const WCHAR attrRight[] =
154 {'r','i','g','h','t',0};
155 static const WCHAR attrTextAlign[] =
156 {'t','e','x','t','-','a','l','i','g','n',0};
157 static const WCHAR attrTextDecoration[] =
158 {'t','e','x','t','-','d','e','c','o','r','a','t','i','o','n',0};
159 static const WCHAR attrTextIndent[] =
160 {'t','e','x','t','-','i','n','d','e','n','t',0};
161 static const WCHAR attrTop[] =
162 {'t','o','p',0};
163 static const WCHAR attrVerticalAlign[] =
164 {'v','e','r','t','i','c','a','l','-','a','l','i','g','n',0};
165 static const WCHAR attrVisibility[] =
166 {'v','i','s','i','b','i','l','i','t','y',0};
167 static const WCHAR attrWidth[] =
168 {'w','i','d','t','h',0};
169 static const WCHAR attrWordSpacing[] =
170 {'w','o','r','d','-','s','p','a','c','i','n','g',0};
171 static const WCHAR attrWordWrap[] =
172 {'w','o','r','d','-','w','r','a','p',0};
173 static const WCHAR attrZIndex[] =
174 {'z','-','i','n','d','e','x',0};
176 typedef struct {
177 const WCHAR *name;
178 DISPID dispid;
179 } style_tbl_entry_t;
181 static const style_tbl_entry_t style_tbl[] = {
182 {attrBackground, DISPID_IHTMLSTYLE_BACKGROUND},
183 {attrBackgroundColor, DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
184 {attrBackgroundImage, DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
185 {attrBackgroundPosition, DISPID_IHTMLSTYLE_BACKGROUNDPOSITION},
186 {attrBackgroundPositionX, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONX},
187 {attrBackgroundPositionY, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
188 {attrBackgroundRepeat, DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
189 {attrBorder, DISPID_IHTMLSTYLE_BORDER},
190 {attrBorderBottom, DISPID_IHTMLSTYLE_BORDERBOTTOM},
191 {attrBorderBottomColor, DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR},
192 {attrBorderBottomStyle, DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
193 {attrBorderBottomWidth, DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
194 {attrBorderColor, DISPID_IHTMLSTYLE_BORDERCOLOR},
195 {attrBorderLeft, DISPID_IHTMLSTYLE_BORDERLEFT},
196 {attrBorderLeftColor, DISPID_IHTMLSTYLE_BORDERLEFTCOLOR},
197 {attrBorderLeftStyle, DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
198 {attrBorderLeftWidth, DISPID_IHTMLSTYLE_BORDERLEFTWIDTH},
199 {attrBorderRight, DISPID_IHTMLSTYLE_BORDERRIGHT},
200 {attrBorderRightColor, DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR},
201 {attrBorderRightStyle, DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
202 {attrBorderRightWidth, DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
203 {attrBorderStyle, DISPID_IHTMLSTYLE_BORDERSTYLE},
204 {attrBorderTop, DISPID_IHTMLSTYLE_BORDERTOP},
205 {attrBorderTopColor, DISPID_IHTMLSTYLE_BORDERTOPCOLOR},
206 {attrBorderTopStyle, DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
207 {attrBorderTopWidth, DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
208 {attrBorderWidth, DISPID_IHTMLSTYLE_BORDERWIDTH},
209 {attrBottom, DISPID_IHTMLSTYLE2_BOTTOM},
210 {attrClip, DISPID_IHTMLSTYLE_CLIP},
211 {attrColor, DISPID_IHTMLSTYLE_COLOR},
212 {attrCursor, DISPID_IHTMLSTYLE_CURSOR},
213 {attrDirection, DISPID_IHTMLSTYLE2_DIRECTION},
214 {attrDisplay, DISPID_IHTMLSTYLE_DISPLAY},
215 {attrFilter, DISPID_IHTMLSTYLE_FILTER},
216 {attrFontFamily, DISPID_IHTMLSTYLE_FONTFAMILY},
217 {attrFontSize, DISPID_IHTMLSTYLE_FONTSIZE},
218 {attrFontStyle, DISPID_IHTMLSTYLE_FONTSTYLE},
219 {attrFontVariant, DISPID_IHTMLSTYLE_FONTVARIANT},
220 {attrFontWeight, DISPID_IHTMLSTYLE_FONTWEIGHT},
221 {attrHeight, DISPID_IHTMLSTYLE_HEIGHT},
222 {attrLeft, DISPID_IHTMLSTYLE_LEFT},
223 {attrLetterSpacing, DISPID_IHTMLSTYLE_LETTERSPACING},
224 {attrLineHeight, DISPID_IHTMLSTYLE_LINEHEIGHT},
225 {attrMargin, DISPID_IHTMLSTYLE_MARGIN},
226 {attrMarginBottom, DISPID_IHTMLSTYLE_MARGINBOTTOM},
227 {attrMarginLeft, DISPID_IHTMLSTYLE_MARGINLEFT},
228 {attrMarginRight, DISPID_IHTMLSTYLE_MARGINRIGHT},
229 {attrMarginTop, DISPID_IHTMLSTYLE_MARGINTOP},
230 {attrMinHeight, DISPID_IHTMLSTYLE4_MINHEIGHT},
231 {attrOverflow, DISPID_IHTMLSTYLE_OVERFLOW},
232 {attrPadding, DISPID_IHTMLSTYLE_PADDING},
233 {attrPaddingBottom, DISPID_IHTMLSTYLE_PADDINGBOTTOM},
234 {attrPaddingLeft, DISPID_IHTMLSTYLE_PADDINGLEFT},
235 {attrPaddingRight, DISPID_IHTMLSTYLE_PADDINGRIGHT},
236 {attrPaddingTop, DISPID_IHTMLSTYLE_PADDINGTOP},
237 {attrPageBreakAfter, DISPID_IHTMLSTYLE_PAGEBREAKAFTER},
238 {attrPageBreakBefore, DISPID_IHTMLSTYLE_PAGEBREAKBEFORE},
239 {attrPosition, DISPID_IHTMLSTYLE2_POSITION},
240 {attrRight, DISPID_IHTMLSTYLE2_RIGHT},
241 {attrTextAlign, DISPID_IHTMLSTYLE_TEXTALIGN},
242 {attrTextDecoration, DISPID_IHTMLSTYLE_TEXTDECORATION},
243 {attrTextIndent, DISPID_IHTMLSTYLE_TEXTINDENT},
244 {attrTop, DISPID_IHTMLSTYLE_TOP},
245 {attrVerticalAlign, DISPID_IHTMLSTYLE_VERTICALALIGN},
246 {attrVisibility, DISPID_IHTMLSTYLE_VISIBILITY},
247 {attrWidth, DISPID_IHTMLSTYLE_WIDTH},
248 {attrWordSpacing, DISPID_IHTMLSTYLE_WORDSPACING},
249 {attrWordWrap, DISPID_IHTMLSTYLE3_WORDWRAP},
250 {attrZIndex, DISPID_IHTMLSTYLE_ZINDEX}
253 static const WCHAR valLineThrough[] =
254 {'l','i','n','e','-','t','h','r','o','u','g','h',0};
255 static const WCHAR valUnderline[] =
256 {'u','n','d','e','r','l','i','n','e',0};
257 static const WCHAR szNormal[] =
258 {'n','o','r','m','a','l',0};
259 static const WCHAR styleNone[] =
260 {'n','o','n','e',0};
261 static const WCHAR valOverline[] =
262 {'o','v','e','r','l','i','n','e',0};
263 static const WCHAR valBlink[] =
264 {'b','l','i','n','k',0};
266 static const WCHAR px_formatW[] = {'%','d','p','x',0};
267 static const WCHAR emptyW[] = {0};
269 static const style_tbl_entry_t *lookup_style_tbl(const WCHAR *name)
271 int c, i, min = 0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
273 while(min <= max) {
274 i = (min+max)/2;
276 c = strcmpW(style_tbl[i].name, name);
277 if(!c)
278 return style_tbl+i;
280 if(c > 0)
281 max = i-1;
282 else
283 min = i+1;
286 return NULL;
289 static LPWSTR fix_px_value(LPCWSTR val)
291 LPCWSTR ptr = val;
293 while(*ptr) {
294 while(*ptr && isspaceW(*ptr))
295 ptr++;
296 if(!*ptr)
297 break;
299 while(*ptr && isdigitW(*ptr))
300 ptr++;
302 if(!*ptr || isspaceW(*ptr)) {
303 LPWSTR ret, p;
304 int len = strlenW(val)+1;
306 ret = heap_alloc((len+2)*sizeof(WCHAR));
307 memcpy(ret, val, (ptr-val)*sizeof(WCHAR));
308 p = ret + (ptr-val);
309 *p++ = 'p';
310 *p++ = 'x';
311 strcpyW(p, ptr);
313 TRACE("fixed %s -> %s\n", debugstr_w(val), debugstr_w(ret));
315 return ret;
318 while(*ptr && !isspaceW(*ptr))
319 ptr++;
322 return NULL;
325 static LPWSTR fix_url_value(LPCWSTR val)
327 WCHAR *ret, *ptr;
329 static const WCHAR urlW[] = {'u','r','l','('};
331 if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
332 return NULL;
334 ret = heap_strdupW(val);
336 for(ptr = ret; *ptr; ptr++) {
337 if(*ptr == '\\')
338 *ptr = '/';
341 return ret;
344 HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCWSTR value, DWORD flags)
346 nsAString str_name, str_value, str_empty;
347 LPWSTR val = NULL;
348 nsresult nsres;
350 if(flags & ATTR_FIX_PX)
351 val = fix_px_value(value);
352 if(flags & ATTR_FIX_URL)
353 val = fix_url_value(value);
355 nsAString_InitDepend(&str_name, style_tbl[sid].name);
356 nsAString_InitDepend(&str_value, val ? val : value);
357 nsAString_InitDepend(&str_empty, emptyW);
359 nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
360 if(NS_FAILED(nsres))
361 ERR("SetProperty failed: %08x\n", nsres);
363 nsAString_Finish(&str_name);
364 nsAString_Finish(&str_value);
365 nsAString_Finish(&str_empty);
366 heap_free(val);
368 return S_OK;
371 static HRESULT var_to_styleval(const VARIANT *v, WCHAR *buf, DWORD flags, const WCHAR **ret)
373 switch(V_VT(v)) {
374 case VT_NULL:
375 *ret = emptyW;
376 return S_OK;
378 case VT_BSTR:
379 *ret = V_BSTR(v);
380 return S_OK;
382 case VT_BSTR|VT_BYREF:
383 *ret = *V_BSTRREF(v);
384 return S_OK;
386 case VT_I4: {
387 static const WCHAR formatW[] = {'%','d',0};
388 static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
390 if(flags & ATTR_HEX_INT)
391 wsprintfW(buf, hex_formatW, V_I4(v));
392 else if(flags & ATTR_FIX_PX)
393 wsprintfW(buf, px_formatW, V_I4(v));
394 else
395 wsprintfW(buf, formatW, V_I4(v));
397 *ret = buf;
398 return S_OK;
400 default:
401 FIXME("not implemented for %s\n", debugstr_variant(v));
402 return E_NOTIMPL;
407 HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *value, DWORD flags)
409 const WCHAR *val;
410 WCHAR buf[14];
411 HRESULT hres;
413 hres = var_to_styleval(value, buf, flags, &val);
414 if(FAILED(hres))
415 return hres;
417 return set_nsstyle_attr(nsstyle, sid, val, flags);
420 static inline HRESULT set_style_attr(HTMLStyle *This, styleid_t sid, LPCWSTR value, DWORD flags)
422 return set_nsstyle_attr(This->nsstyle, sid, value, flags);
425 static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, nsAString *value)
427 nsAString str_name;
428 nsresult nsres;
430 nsAString_InitDepend(&str_name, style_tbl[sid].name);
432 nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
433 if(NS_FAILED(nsres)) {
434 ERR("SetProperty failed: %08x\n", nsres);
435 return E_FAIL;
438 nsAString_Finish(&str_name);
440 return NS_OK;
443 static HRESULT nsstyle_to_bstr(const WCHAR *val, DWORD flags, BSTR *p)
445 BSTR ret;
446 DWORD len;
448 if(!*val) {
449 *p = NULL;
450 return S_OK;
453 ret = SysAllocString(val);
454 if(!ret)
455 return E_OUTOFMEMORY;
457 len = SysStringLen(ret);
459 if(flags & ATTR_REMOVE_COMMA) {
460 DWORD new_len = len;
461 WCHAR *ptr, *ptr2;
463 for(ptr = ret; (ptr = strchrW(ptr, ',')); ptr++)
464 new_len--;
466 if(new_len != len) {
467 BSTR new_ret;
469 new_ret = SysAllocStringLen(NULL, new_len);
470 if(!new_ret) {
471 SysFreeString(ret);
472 return E_OUTOFMEMORY;
475 for(ptr2 = new_ret, ptr = ret; *ptr; ptr++) {
476 if(*ptr != ',')
477 *ptr2++ = *ptr;
480 SysFreeString(ret);
481 ret = new_ret;
485 *p = ret;
486 return S_OK;
489 HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR *p, DWORD flags)
491 nsAString str_value;
492 const PRUnichar *value;
493 HRESULT hres;
495 nsAString_Init(&str_value, NULL);
497 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
499 nsAString_GetData(&str_value, &value);
500 hres = nsstyle_to_bstr(value, flags, p);
501 nsAString_Finish(&str_value);
503 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_w(*p));
504 return hres;
507 HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
509 nsAString str_value;
510 const PRUnichar *value;
511 BOOL set = FALSE;
512 HRESULT hres = S_OK;
514 nsAString_Init(&str_value, NULL);
516 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
518 nsAString_GetData(&str_value, &value);
520 if(flags & ATTR_STR_TO_INT) {
521 const PRUnichar *ptr = value;
522 BOOL neg = FALSE;
523 INT i = 0;
525 if(*ptr == '-') {
526 neg = TRUE;
527 ptr++;
530 while(isdigitW(*ptr))
531 i = i*10 + (*ptr++ - '0');
533 if(!*ptr) {
534 V_VT(p) = VT_I4;
535 V_I4(p) = neg ? -i : i;
536 set = TRUE;
540 if(!set) {
541 BSTR str;
543 hres = nsstyle_to_bstr(value, flags, &str);
544 if(SUCCEEDED(hres)) {
545 V_VT(p) = VT_BSTR;
546 V_BSTR(p) = str;
550 nsAString_Finish(&str_value);
552 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_variant(p));
553 return S_OK;
556 static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
558 return get_nsstyle_attr(This->nsstyle, sid, p, 0);
561 static HRESULT check_style_attr_value(HTMLStyle *This, styleid_t sid, LPCWSTR exval, VARIANT_BOOL *p)
563 nsAString str_value;
564 const PRUnichar *value;
566 nsAString_Init(&str_value, NULL);
568 get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
570 nsAString_GetData(&str_value, &value);
571 *p = strcmpW(value, exval) ? VARIANT_FALSE : VARIANT_TRUE;
572 nsAString_Finish(&str_value);
574 TRACE("%s -> %x\n", debugstr_w(style_tbl[sid].name), *p);
575 return S_OK;
578 static inline HRESULT set_style_pos(HTMLStyle *This, styleid_t sid, float value)
580 WCHAR szValue[25];
581 WCHAR szFormat[] = {'%','.','0','f','p','x',0};
583 value = floor(value);
585 sprintfW(szValue, szFormat, value);
587 return set_style_attr(This, sid, szValue, 0);
590 static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p)
592 nsAString str_value;
593 HRESULT hres;
594 WCHAR pxW[] = {'p','x',0};
596 TRACE("%p %d %p\n", This, sid, p);
598 *p = 0.0f;
600 nsAString_Init(&str_value, NULL);
602 hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
603 if(hres == S_OK)
605 WCHAR *ptr;
606 const PRUnichar *value;
608 nsAString_GetData(&str_value, &value);
609 if(value)
611 *p = strtolW(value, &ptr, 10);
613 if(*ptr && strcmpW(ptr, pxW))
615 nsAString_Finish(&str_value);
616 FIXME("only px values are currently supported\n");
617 return E_FAIL;
622 TRACE("ret %f\n", *p);
624 nsAString_Finish(&str_value);
626 return hres;
629 static BOOL is_valid_border_style(BSTR v)
631 static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0};
632 static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0};
633 static const WCHAR styleSolid[] = {'s','o','l','i','d',0};
634 static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0};
635 static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0};
636 static const WCHAR styleRidge[] = {'r','i','d','g','e',0};
637 static const WCHAR styleInset[] = {'i','n','s','e','t',0};
638 static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0};
640 TRACE("%s\n", debugstr_w(v));
642 if(!v || strcmpiW(v, styleNone) == 0 || strcmpiW(v, styleDotted) == 0 ||
643 strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid) == 0 ||
644 strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 ||
645 strcmpiW(v, styleRidge) == 0 || strcmpiW(v, styleInset) == 0 ||
646 strcmpiW(v, styleOutset) == 0 )
648 return TRUE;
651 return FALSE;
654 static inline HTMLStyle *impl_from_IHTMLStyle(IHTMLStyle *iface)
656 return CONTAINING_RECORD(iface, HTMLStyle, IHTMLStyle_iface);
659 static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv)
661 HTMLStyle *This = impl_from_IHTMLStyle(iface);
663 *ppv = NULL;
665 if(IsEqualGUID(&IID_IUnknown, riid)) {
666 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
667 *ppv = &This->IHTMLStyle_iface;
668 }else if(IsEqualGUID(&IID_IHTMLStyle, riid)) {
669 TRACE("(%p)->(IID_IHTMLStyle %p)\n", This, ppv);
670 *ppv = &This->IHTMLStyle_iface;
671 }else if(IsEqualGUID(&IID_IHTMLStyle2, riid)) {
672 TRACE("(%p)->(IID_IHTMLStyle2 %p)\n", This, ppv);
673 *ppv = &This->IHTMLStyle2_iface;
674 }else if(IsEqualGUID(&IID_IHTMLStyle3, riid)) {
675 TRACE("(%p)->(IID_IHTMLStyle3 %p)\n", This, ppv);
676 *ppv = &This->IHTMLStyle3_iface;
677 }else if(IsEqualGUID(&IID_IHTMLStyle4, riid)) {
678 TRACE("(%p)->(IID_IHTMLStyle4 %p)\n", This, ppv);
679 *ppv = &This->IHTMLStyle4_iface;
680 }else if(IsEqualGUID(&IID_IHTMLStyle5, riid)) {
681 TRACE("(%p)->(IID_IHTMLStyle5 %p)\n", This, ppv);
682 *ppv = &This->IHTMLStyle5_iface;
683 }else if(IsEqualGUID(&IID_IHTMLStyle6, riid)) {
684 TRACE("(%p)->(IID_IHTMLStyle6 %p)\n", This, ppv);
685 *ppv = &This->IHTMLStyle6_iface;
686 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
687 return *ppv ? S_OK : E_NOINTERFACE;
690 if(*ppv) {
691 IUnknown_AddRef((IUnknown*)*ppv);
692 return S_OK;
695 WARN("unsupported %s\n", debugstr_guid(riid));
696 return E_NOINTERFACE;
699 static ULONG WINAPI HTMLStyle_AddRef(IHTMLStyle *iface)
701 HTMLStyle *This = impl_from_IHTMLStyle(iface);
702 LONG ref = InterlockedIncrement(&This->ref);
704 TRACE("(%p) ref=%d\n", This, ref);
706 return ref;
709 static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
711 HTMLStyle *This = impl_from_IHTMLStyle(iface);
712 LONG ref = InterlockedDecrement(&This->ref);
714 TRACE("(%p) ref=%d\n", This, ref);
716 if(!ref) {
717 if(This->nsstyle)
718 nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
719 release_dispex(&This->dispex);
720 heap_free(This);
723 return ref;
726 static HRESULT WINAPI HTMLStyle_GetTypeInfoCount(IHTMLStyle *iface, UINT *pctinfo)
728 HTMLStyle *This = impl_from_IHTMLStyle(iface);
729 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
732 static HRESULT WINAPI HTMLStyle_GetTypeInfo(IHTMLStyle *iface, UINT iTInfo,
733 LCID lcid, ITypeInfo **ppTInfo)
735 HTMLStyle *This = impl_from_IHTMLStyle(iface);
736 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
739 static HRESULT WINAPI HTMLStyle_GetIDsOfNames(IHTMLStyle *iface, REFIID riid,
740 LPOLESTR *rgszNames, UINT cNames,
741 LCID lcid, DISPID *rgDispId)
743 HTMLStyle *This = impl_from_IHTMLStyle(iface);
744 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
745 lcid, rgDispId);
748 static HRESULT WINAPI HTMLStyle_Invoke(IHTMLStyle *iface, DISPID dispIdMember,
749 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
750 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
752 HTMLStyle *This = impl_from_IHTMLStyle(iface);
753 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
754 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
757 static HRESULT WINAPI HTMLStyle_put_fontFamily(IHTMLStyle *iface, BSTR v)
759 HTMLStyle *This = impl_from_IHTMLStyle(iface);
761 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
763 return set_style_attr(This, STYLEID_FONT_FAMILY, v, 0);
766 static HRESULT WINAPI HTMLStyle_get_fontFamily(IHTMLStyle *iface, BSTR *p)
768 HTMLStyle *This = impl_from_IHTMLStyle(iface);
770 TRACE("(%p)->(%p)\n", This, p);
772 return get_style_attr(This, STYLEID_FONT_FAMILY, p);
775 static HRESULT WINAPI HTMLStyle_put_fontStyle(IHTMLStyle *iface, BSTR v)
777 HTMLStyle *This = impl_from_IHTMLStyle(iface);
778 static const WCHAR szItalic[] = {'i','t','a','l','i','c',0};
779 static const WCHAR szOblique[] = {'o','b','l','i','q','u','e',0};
781 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
783 /* fontStyle can only be one of the follow values. */
784 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szItalic, v) == 0 ||
785 strcmpiW(szOblique, v) == 0)
787 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, v, 0);
790 return E_INVALIDARG;
793 static HRESULT WINAPI HTMLStyle_get_fontStyle(IHTMLStyle *iface, BSTR *p)
795 HTMLStyle *This = impl_from_IHTMLStyle(iface);
797 TRACE("(%p)->(%p)\n", This, p);
799 return get_style_attr(This, STYLEID_FONT_STYLE, p);
802 static HRESULT WINAPI HTMLStyle_put_fontVariant(IHTMLStyle *iface, BSTR v)
804 HTMLStyle *This = impl_from_IHTMLStyle(iface);
805 static const WCHAR szCaps[] = {'s','m','a','l','l','-','c','a','p','s',0};
807 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
809 /* fontVariant can only be one of the follow values. */
810 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szCaps, v) == 0)
812 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, v, 0);
815 return E_INVALIDARG;
818 static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p)
820 HTMLStyle *This = impl_from_IHTMLStyle(iface);
821 TRACE("(%p)->(%p)\n", This, p);
823 if(!p)
824 return E_INVALIDARG;
826 return get_style_attr(This, STYLEID_FONT_VARIANT, p);
829 static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v)
831 HTMLStyle *This = impl_from_IHTMLStyle(iface);
832 static const WCHAR styleBold[] = {'b','o','l','d',0};
833 static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0};
834 static const WCHAR styleLighter[] = {'l','i','g','h','t','e','r',0};
835 static const WCHAR style100[] = {'1','0','0',0};
836 static const WCHAR style200[] = {'2','0','0',0};
837 static const WCHAR style300[] = {'3','0','0',0};
838 static const WCHAR style400[] = {'4','0','0',0};
839 static const WCHAR style500[] = {'5','0','0',0};
840 static const WCHAR style600[] = {'6','0','0',0};
841 static const WCHAR style700[] = {'7','0','0',0};
842 static const WCHAR style800[] = {'8','0','0',0};
843 static const WCHAR style900[] = {'9','0','0',0};
845 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
847 /* fontWeight can only be one of the following */
848 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(styleBold, v) == 0 ||
849 strcmpiW(styleBolder, v) == 0 || strcmpiW(styleLighter, v) == 0 ||
850 strcmpiW(style100, v) == 0 || strcmpiW(style200, v) == 0 ||
851 strcmpiW(style300, v) == 0 || strcmpiW(style400, v) == 0 ||
852 strcmpiW(style500, v) == 0 || strcmpiW(style600, v) == 0 ||
853 strcmpiW(style700, v) == 0 || strcmpiW(style800, v) == 0 ||
854 strcmpiW(style900, v) == 0
857 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0);
860 return E_INVALIDARG;
863 static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p)
865 HTMLStyle *This = impl_from_IHTMLStyle(iface);
867 TRACE("(%p)->(%p)\n", This, p);
869 return get_style_attr(This, STYLEID_FONT_WEIGHT, p);
872 static HRESULT WINAPI HTMLStyle_put_fontSize(IHTMLStyle *iface, VARIANT v)
874 HTMLStyle *This = impl_from_IHTMLStyle(iface);
876 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
878 return set_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, &v, ATTR_FIX_PX);
881 static HRESULT WINAPI HTMLStyle_get_fontSize(IHTMLStyle *iface, VARIANT *p)
883 HTMLStyle *This = impl_from_IHTMLStyle(iface);
885 TRACE("(%p)->(%p)\n", This, p);
887 return get_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, p, 0);
890 static HRESULT WINAPI HTMLStyle_put_font(IHTMLStyle *iface, BSTR v)
892 HTMLStyle *This = impl_from_IHTMLStyle(iface);
893 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
894 return E_NOTIMPL;
897 static HRESULT WINAPI HTMLStyle_get_font(IHTMLStyle *iface, BSTR *p)
899 HTMLStyle *This = impl_from_IHTMLStyle(iface);
900 FIXME("(%p)->(%p)\n", This, p);
901 return E_NOTIMPL;
904 static HRESULT WINAPI HTMLStyle_put_color(IHTMLStyle *iface, VARIANT v)
906 HTMLStyle *This = impl_from_IHTMLStyle(iface);
908 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
910 return set_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, &v, ATTR_HEX_INT);
913 static HRESULT WINAPI HTMLStyle_get_color(IHTMLStyle *iface, VARIANT *p)
915 HTMLStyle *This = impl_from_IHTMLStyle(iface);
917 TRACE("(%p)->(%p)\n", This, p);
919 return get_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, p, 0);
922 static HRESULT WINAPI HTMLStyle_put_background(IHTMLStyle *iface, BSTR v)
924 HTMLStyle *This = impl_from_IHTMLStyle(iface);
926 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
928 return set_style_attr(This, STYLEID_BACKGROUND, v, 0);
931 static HRESULT WINAPI HTMLStyle_get_background(IHTMLStyle *iface, BSTR *p)
933 HTMLStyle *This = impl_from_IHTMLStyle(iface);
935 TRACE("(%p)->(%p)\n", This, p);
937 return get_style_attr(This, STYLEID_BACKGROUND, p);
940 static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v)
942 HTMLStyle *This = impl_from_IHTMLStyle(iface);
944 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
946 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, &v, ATTR_HEX_INT);
949 static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
951 HTMLStyle *This = impl_from_IHTMLStyle(iface);
953 TRACE("(%p)->(%p)\n", This, p);
955 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, p, 0);
958 static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
960 HTMLStyle *This = impl_from_IHTMLStyle(iface);
962 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
964 return set_style_attr(This, STYLEID_BACKGROUND_IMAGE, v, ATTR_FIX_URL);
967 static HRESULT WINAPI HTMLStyle_get_backgroundImage(IHTMLStyle *iface, BSTR *p)
969 HTMLStyle *This = impl_from_IHTMLStyle(iface);
971 TRACE("(%p)->(%p)\n", This, p);
973 return get_style_attr(This, STYLEID_BACKGROUND_IMAGE, p);
976 static HRESULT WINAPI HTMLStyle_put_backgroundRepeat(IHTMLStyle *iface, BSTR v)
978 HTMLStyle *This = impl_from_IHTMLStyle(iface);
979 static const WCHAR styleRepeat[] = {'r','e','p','e','a','t',0};
980 static const WCHAR styleNoRepeat[] = {'n','o','-','r','e','p','e','a','t',0};
981 static const WCHAR styleRepeatX[] = {'r','e','p','e','a','t','-','x',0};
982 static const WCHAR styleRepeatY[] = {'r','e','p','e','a','t','-','y',0};
984 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
986 /* fontWeight can only be one of the following */
987 if(!v || strcmpiW(styleRepeat, v) == 0 || strcmpiW(styleNoRepeat, v) == 0 ||
988 strcmpiW(styleRepeatX, v) == 0 || strcmpiW(styleRepeatY, v) == 0 )
990 return set_style_attr(This, STYLEID_BACKGROUND_REPEAT , v, 0);
993 return E_INVALIDARG;
996 static HRESULT WINAPI HTMLStyle_get_backgroundRepeat(IHTMLStyle *iface, BSTR *p)
998 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1000 TRACE("(%p)->(%p)\n", This, p);
1002 return get_style_attr(This, STYLEID_BACKGROUND_REPEAT, p);
1005 static HRESULT WINAPI HTMLStyle_put_backgroundAttachment(IHTMLStyle *iface, BSTR v)
1007 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1008 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1009 return E_NOTIMPL;
1012 static HRESULT WINAPI HTMLStyle_get_backgroundAttachment(IHTMLStyle *iface, BSTR *p)
1014 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1015 FIXME("(%p)->(%p)\n", This, p);
1016 return E_NOTIMPL;
1019 static HRESULT WINAPI HTMLStyle_put_backgroundPosition(IHTMLStyle *iface, BSTR v)
1021 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1023 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1025 return set_style_attr(This, STYLEID_BACKGROUND_POSITION, v, 0);
1028 static HRESULT WINAPI HTMLStyle_get_backgroundPosition(IHTMLStyle *iface, BSTR *p)
1030 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1032 TRACE("(%p)->(%p)\n", This, p);
1034 return get_style_attr(This, STYLEID_BACKGROUND_POSITION, p);
1037 static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIANT v)
1039 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1040 WCHAR buf[14], *pos_val;
1041 nsAString pos_str;
1042 const WCHAR *val;
1043 DWORD val_len;
1044 HRESULT hres;
1046 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1048 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1049 if(FAILED(hres))
1050 return hres;
1052 val_len = val ? strlenW(val) : 0;
1054 nsAString_Init(&pos_str, NULL);
1055 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1056 if(SUCCEEDED(hres)) {
1057 const PRUnichar *pos, *posy;
1058 DWORD posy_len;
1060 nsAString_GetData(&pos_str, &pos);
1061 posy = strchrW(pos, ' ');
1062 if(!posy) {
1063 static const WCHAR zero_pxW[] = {' ','0','p','x',0};
1065 TRACE("no space in %s\n", debugstr_w(pos));
1066 posy = zero_pxW;
1069 posy_len = strlenW(posy);
1070 pos_val = heap_alloc((val_len+posy_len+1)*sizeof(WCHAR));
1071 if(pos_val) {
1072 if(val_len)
1073 memcpy(pos_val, val, val_len*sizeof(WCHAR));
1074 if(posy_len)
1075 memcpy(pos_val+val_len, posy, posy_len*sizeof(WCHAR));
1076 pos_val[val_len+posy_len] = 0;
1077 }else {
1078 hres = E_OUTOFMEMORY;
1081 nsAString_Finish(&pos_str);
1082 if(FAILED(hres))
1083 return hres;
1085 TRACE("setting position to %s\n", debugstr_w(pos_val));
1086 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1087 heap_free(pos_val);
1088 return hres;
1091 static HRESULT WINAPI HTMLStyle_get_backgroundPositionX(IHTMLStyle *iface, VARIANT *p)
1093 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1094 nsAString pos_str;
1095 BSTR ret;
1096 HRESULT hres;
1098 TRACE("(%p)->(%p)\n", This, p);
1100 nsAString_Init(&pos_str, NULL);
1101 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1102 if(SUCCEEDED(hres)) {
1103 const PRUnichar *pos, *space;
1105 nsAString_GetData(&pos_str, &pos);
1106 space = strchrW(pos, ' ');
1107 if(!space) {
1108 WARN("no space in %s\n", debugstr_w(pos));
1109 space = pos + strlenW(pos);
1112 if(space != pos) {
1113 ret = SysAllocStringLen(pos, space-pos);
1114 if(!ret)
1115 hres = E_OUTOFMEMORY;
1116 }else {
1117 ret = NULL;
1120 nsAString_Finish(&pos_str);
1121 if(FAILED(hres))
1122 return hres;
1124 TRACE("returning %s\n", debugstr_w(ret));
1125 V_VT(p) = VT_BSTR;
1126 V_BSTR(p) = ret;
1127 return S_OK;
1130 static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIANT v)
1132 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1133 WCHAR buf[14], *pos_val;
1134 nsAString pos_str;
1135 const WCHAR *val;
1136 DWORD val_len;
1137 HRESULT hres;
1139 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1141 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1142 if(FAILED(hres))
1143 return hres;
1145 val_len = val ? strlenW(val) : 0;
1147 nsAString_Init(&pos_str, NULL);
1148 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1149 if(SUCCEEDED(hres)) {
1150 const PRUnichar *pos, *space;
1151 DWORD posx_len;
1153 nsAString_GetData(&pos_str, &pos);
1154 space = strchrW(pos, ' ');
1155 if(space) {
1156 space++;
1157 }else {
1158 static const WCHAR zero_pxW[] = {'0','p','x',' ',0};
1160 TRACE("no space in %s\n", debugstr_w(pos));
1161 pos = zero_pxW;
1162 space = pos + sizeof(zero_pxW)/sizeof(WCHAR)-1;
1165 posx_len = space-pos;
1167 pos_val = heap_alloc((posx_len+val_len+1)*sizeof(WCHAR));
1168 if(pos_val) {
1169 memcpy(pos_val, pos, posx_len*sizeof(WCHAR));
1170 if(val_len)
1171 memcpy(pos_val+posx_len, val, val_len*sizeof(WCHAR));
1172 pos_val[posx_len+val_len] = 0;
1173 }else {
1174 hres = E_OUTOFMEMORY;
1177 nsAString_Finish(&pos_str);
1178 if(FAILED(hres))
1179 return hres;
1181 TRACE("setting position to %s\n", debugstr_w(pos_val));
1182 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1183 heap_free(pos_val);
1184 return hres;
1187 static HRESULT WINAPI HTMLStyle_get_backgroundPositionY(IHTMLStyle *iface, VARIANT *p)
1189 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1190 nsAString pos_str;
1191 BSTR ret;
1192 HRESULT hres;
1194 TRACE("(%p)->(%p)\n", This, p);
1196 nsAString_Init(&pos_str, NULL);
1197 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1198 if(SUCCEEDED(hres)) {
1199 const PRUnichar *pos, *posy;
1201 nsAString_GetData(&pos_str, &pos);
1202 posy = strchrW(pos, ' ');
1203 if(posy) {
1204 ret = SysAllocString(posy+1);
1205 if(!ret)
1206 hres = E_OUTOFMEMORY;
1207 }else {
1208 ret = NULL;
1211 nsAString_Finish(&pos_str);
1212 if(FAILED(hres))
1213 return hres;
1215 TRACE("returning %s\n", debugstr_w(ret));
1216 V_VT(p) = VT_BSTR;
1217 V_BSTR(p) = ret;
1218 return S_OK;
1221 static HRESULT WINAPI HTMLStyle_put_wordSpacing(IHTMLStyle *iface, VARIANT v)
1223 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1225 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1227 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, &v, 0);
1230 static HRESULT WINAPI HTMLStyle_get_wordSpacing(IHTMLStyle *iface, VARIANT *p)
1232 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1233 TRACE("(%p)->(%p)\n", This, p);
1234 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, p, 0);
1237 static HRESULT WINAPI HTMLStyle_put_letterSpacing(IHTMLStyle *iface, VARIANT v)
1239 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1241 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1243 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, &v, 0);
1246 static HRESULT WINAPI HTMLStyle_get_letterSpacing(IHTMLStyle *iface, VARIANT *p)
1248 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1249 TRACE("(%p)->(%p)\n", This, p);
1250 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, p, 0);
1253 static HRESULT WINAPI HTMLStyle_put_textDecoration(IHTMLStyle *iface, BSTR v)
1255 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1257 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1259 /* textDecoration can only be one of the following */
1260 if(!v || strcmpiW(styleNone, v) == 0 || strcmpiW(valUnderline, v) == 0 ||
1261 strcmpiW(valOverline, v) == 0 || strcmpiW(valLineThrough, v) == 0 ||
1262 strcmpiW(valBlink, v) == 0)
1264 return set_style_attr(This, STYLEID_TEXT_DECORATION , v, 0);
1267 return E_INVALIDARG;
1270 static HRESULT WINAPI HTMLStyle_get_textDecoration(IHTMLStyle *iface, BSTR *p)
1272 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1274 TRACE("(%p)->(%p)\n", This, p);
1276 return get_style_attr(This, STYLEID_TEXT_DECORATION, p);
1279 static HRESULT WINAPI HTMLStyle_put_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL v)
1281 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1283 TRACE("(%p)->(%x)\n", This, v);
1285 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? styleNone : emptyW, 0);
1288 static HRESULT WINAPI HTMLStyle_get_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL *p)
1290 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1292 TRACE("(%p)->(%p)\n", This, p);
1294 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, styleNone, p);
1297 static HRESULT WINAPI HTMLStyle_put_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL v)
1299 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1301 TRACE("(%p)->(%x)\n", This, v);
1303 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valUnderline : emptyW, 0);
1306 static HRESULT WINAPI HTMLStyle_get_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL *p)
1308 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1310 TRACE("(%p)->(%p)\n", This, p);
1312 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valUnderline, p);
1315 static HRESULT WINAPI HTMLStyle_put_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL v)
1317 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1319 TRACE("(%p)->(%x)\n", This, v);
1321 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valOverline : emptyW, 0);
1324 static HRESULT WINAPI HTMLStyle_get_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL *p)
1326 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1328 TRACE("(%p)->(%p)\n", This, p);
1330 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valOverline, p);
1333 static HRESULT WINAPI HTMLStyle_put_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL v)
1335 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1337 TRACE("(%p)->(%x)\n", This, v);
1339 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valLineThrough : emptyW, 0);
1342 static HRESULT WINAPI HTMLStyle_get_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL *p)
1344 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1346 TRACE("(%p)->(%p)\n", This, p);
1348 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valLineThrough, p);
1351 static HRESULT WINAPI HTMLStyle_put_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL v)
1353 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1355 TRACE("(%p)->(%x)\n", This, v);
1357 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valBlink : emptyW, 0);
1360 static HRESULT WINAPI HTMLStyle_get_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL *p)
1362 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1364 TRACE("(%p)->(%p)\n", This, p);
1366 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valBlink, p);
1369 static HRESULT WINAPI HTMLStyle_put_verticalAlign(IHTMLStyle *iface, VARIANT v)
1371 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1373 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1375 return set_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, &v, ATTR_FIX_PX);
1378 static HRESULT WINAPI HTMLStyle_get_verticalAlign(IHTMLStyle *iface, VARIANT *p)
1380 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1382 TRACE("(%p)->(%p)\n", This, p);
1384 return get_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, p, 0);
1387 static HRESULT WINAPI HTMLStyle_put_textTransform(IHTMLStyle *iface, BSTR v)
1389 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1390 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1391 return E_NOTIMPL;
1394 static HRESULT WINAPI HTMLStyle_get_textTransform(IHTMLStyle *iface, BSTR *p)
1396 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1397 FIXME("(%p)->(%p)\n", This, p);
1398 return E_NOTIMPL;
1401 static HRESULT WINAPI HTMLStyle_put_textAlign(IHTMLStyle *iface, BSTR v)
1403 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1405 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1407 return set_style_attr(This, STYLEID_TEXT_ALIGN, v, 0);
1410 static HRESULT WINAPI HTMLStyle_get_textAlign(IHTMLStyle *iface, BSTR *p)
1412 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1414 TRACE("(%p)->(%p)\n", This, p);
1416 return get_style_attr(This, STYLEID_TEXT_ALIGN, p);
1419 static HRESULT WINAPI HTMLStyle_put_textIndent(IHTMLStyle *iface, VARIANT v)
1421 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1422 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1423 return E_NOTIMPL;
1426 static HRESULT WINAPI HTMLStyle_get_textIndent(IHTMLStyle *iface, VARIANT *p)
1428 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1429 FIXME("(%p)->(%p)\n", This, p);
1430 return E_NOTIMPL;
1433 static HRESULT WINAPI HTMLStyle_put_lineHeight(IHTMLStyle *iface, VARIANT v)
1435 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1436 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1437 return E_NOTIMPL;
1440 static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
1442 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1443 FIXME("(%p)->(%p)\n", This, p);
1444 return E_NOTIMPL;
1447 static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
1449 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1451 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1453 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, &v, ATTR_FIX_PX);
1456 static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
1458 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1460 TRACE("(%p)->(%p)\n", This, p);
1462 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
1465 static HRESULT WINAPI HTMLStyle_put_marginRight(IHTMLStyle *iface, VARIANT v)
1467 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1469 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1471 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, &v, ATTR_FIX_PX);
1474 static HRESULT WINAPI HTMLStyle_get_marginRight(IHTMLStyle *iface, VARIANT *p)
1476 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1477 TRACE("(%p)->(%p)\n", This, p);
1478 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
1481 static HRESULT WINAPI HTMLStyle_put_marginBottom(IHTMLStyle *iface, VARIANT v)
1483 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1485 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1487 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, &v, ATTR_FIX_PX);
1490 static HRESULT WINAPI HTMLStyle_get_marginBottom(IHTMLStyle *iface, VARIANT *p)
1492 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1494 TRACE("(%p)->(%p)\n", This, p);
1496 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, p, 0);
1499 static HRESULT WINAPI HTMLStyle_put_marginLeft(IHTMLStyle *iface, VARIANT v)
1501 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1503 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1505 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, &v, ATTR_FIX_PX);
1508 static HRESULT WINAPI HTMLStyle_put_margin(IHTMLStyle *iface, BSTR v)
1510 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1512 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1514 return set_style_attr(This, STYLEID_MARGIN, v, 0);
1517 static HRESULT WINAPI HTMLStyle_get_margin(IHTMLStyle *iface, BSTR *p)
1519 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1521 TRACE("(%p)->(%p)\n", This, p);
1523 return get_style_attr(This, STYLEID_MARGIN, p);
1526 static HRESULT WINAPI HTMLStyle_get_marginLeft(IHTMLStyle *iface, VARIANT *p)
1528 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1529 TRACE("(%p)->(%p)\n", This, p);
1530 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
1533 static HRESULT WINAPI HTMLStyle_put_paddingTop(IHTMLStyle *iface, VARIANT v)
1535 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1537 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1539 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, &v, ATTR_FIX_PX);
1542 static HRESULT WINAPI HTMLStyle_get_paddingTop(IHTMLStyle *iface, VARIANT *p)
1544 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1546 TRACE("(%p)->(%p)\n", This, p);
1548 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, p, 0);
1551 static HRESULT WINAPI HTMLStyle_put_paddingRight(IHTMLStyle *iface, VARIANT v)
1553 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1555 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1557 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, &v, ATTR_FIX_PX);
1560 static HRESULT WINAPI HTMLStyle_get_paddingRight(IHTMLStyle *iface, VARIANT *p)
1562 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1564 TRACE("(%p)->(%p)\n", This, p);
1566 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, p, 0);
1569 static HRESULT WINAPI HTMLStyle_put_paddingBottom(IHTMLStyle *iface, VARIANT v)
1571 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1573 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1575 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, &v, ATTR_FIX_PX);
1578 static HRESULT WINAPI HTMLStyle_get_paddingBottom(IHTMLStyle *iface, VARIANT *p)
1580 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1582 TRACE("(%p)->(%p)\n", This, p);
1584 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, p, 0);
1587 static HRESULT WINAPI HTMLStyle_put_paddingLeft(IHTMLStyle *iface, VARIANT v)
1589 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1591 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1593 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, &v, ATTR_FIX_PX);
1596 static HRESULT WINAPI HTMLStyle_get_paddingLeft(IHTMLStyle *iface, VARIANT *p)
1598 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1600 TRACE("(%p)->(%p)\n", This, p);
1602 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, p, 0);
1605 static HRESULT WINAPI HTMLStyle_put_padding(IHTMLStyle *iface, BSTR v)
1607 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1609 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1611 return set_style_attr(This, STYLEID_PADDING, v, 0);
1614 static HRESULT WINAPI HTMLStyle_get_padding(IHTMLStyle *iface, BSTR *p)
1616 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1618 TRACE("(%p)->(%p)\n", This, p);
1620 return get_style_attr(This, STYLEID_PADDING, p);
1623 static HRESULT WINAPI HTMLStyle_put_border(IHTMLStyle *iface, BSTR v)
1625 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1627 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1629 return set_style_attr(This, STYLEID_BORDER, v, 0);
1632 static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
1634 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1636 TRACE("(%p)->(%p)\n", This, p);
1638 return get_style_attr(This, STYLEID_BORDER, p);
1641 static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
1643 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1644 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1645 return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX);
1648 static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
1650 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1651 TRACE("(%p)->(%p)\n", This, p);
1652 return get_style_attr(This, STYLEID_BORDER_TOP, p);
1655 static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
1657 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1658 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1659 return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX);
1662 static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
1664 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1665 TRACE("(%p)->(%p)\n", This, p);
1666 return get_style_attr(This, STYLEID_BORDER_RIGHT, p);
1669 static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
1671 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1672 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1673 return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX);
1676 static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
1678 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1679 TRACE("(%p)->(%p)\n", This, p);
1680 return get_style_attr(This, STYLEID_BORDER_BOTTOM, p);
1683 static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
1685 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1687 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1689 return set_style_attr(This, STYLEID_BORDER_LEFT, v, ATTR_FIX_PX);
1692 static HRESULT WINAPI HTMLStyle_get_borderLeft(IHTMLStyle *iface, BSTR *p)
1694 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1696 TRACE("(%p)->(%p)\n", This, p);
1698 return get_style_attr(This, STYLEID_BORDER_LEFT, p);
1701 static HRESULT WINAPI HTMLStyle_put_borderColor(IHTMLStyle *iface, BSTR v)
1703 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1705 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1707 return set_style_attr(This, STYLEID_BORDER_COLOR, v, 0);
1710 static HRESULT WINAPI HTMLStyle_get_borderColor(IHTMLStyle *iface, BSTR *p)
1712 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1714 TRACE("(%p)->(%p)\n", This, p);
1716 return get_style_attr(This, STYLEID_BORDER_COLOR, p);
1719 static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v)
1721 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1723 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1725 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, &v, ATTR_HEX_INT);
1728 static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p)
1730 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1732 TRACE("(%p)->(%p)\n", This, p);
1734 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0);
1737 static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v)
1739 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1741 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1743 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, &v, ATTR_HEX_INT);
1746 static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p)
1748 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1750 TRACE("(%p)->(%p)\n", This, p);
1752 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0);
1755 static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v)
1757 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1759 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1761 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, &v, ATTR_HEX_INT);
1764 static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p)
1766 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1768 TRACE("(%p)->(%p)\n", This, p);
1770 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0);
1773 static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v)
1775 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1777 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1779 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, &v, ATTR_HEX_INT);
1782 static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p)
1784 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1786 TRACE("(%p)->(%p)\n", This, p);
1788 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0);
1791 static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v)
1793 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1794 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1795 return set_style_attr(This, STYLEID_BORDER_WIDTH, v, ATTR_FIX_PX);
1798 static HRESULT WINAPI HTMLStyle_get_borderWidth(IHTMLStyle *iface, BSTR *p)
1800 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1801 TRACE("(%p)->(%p)\n", This, p);
1802 return get_style_attr(This, STYLEID_BORDER_WIDTH, p);
1805 static HRESULT WINAPI HTMLStyle_put_borderTopWidth(IHTMLStyle *iface, VARIANT v)
1807 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1809 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1811 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, &v, 0);
1814 static HRESULT WINAPI HTMLStyle_get_borderTopWidth(IHTMLStyle *iface, VARIANT *p)
1816 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1818 TRACE("(%p)->(%p)\n", This, p);
1820 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, p, 0);
1823 static HRESULT WINAPI HTMLStyle_put_borderRightWidth(IHTMLStyle *iface, VARIANT v)
1825 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1827 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1829 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, &v, 0);
1832 static HRESULT WINAPI HTMLStyle_get_borderRightWidth(IHTMLStyle *iface, VARIANT *p)
1834 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1836 TRACE("(%p)->(%p)\n", This, p);
1838 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, p, 0);
1841 static HRESULT WINAPI HTMLStyle_put_borderBottomWidth(IHTMLStyle *iface, VARIANT v)
1843 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1845 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1847 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, &v, 0);
1850 static HRESULT WINAPI HTMLStyle_get_borderBottomWidth(IHTMLStyle *iface, VARIANT *p)
1852 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1853 TRACE("(%p)->(%p)\n", This, p);
1854 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, p, 0);
1857 static HRESULT WINAPI HTMLStyle_put_borderLeftWidth(IHTMLStyle *iface, VARIANT v)
1859 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1861 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1863 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, &v, 0);
1866 static HRESULT WINAPI HTMLStyle_get_borderLeftWidth(IHTMLStyle *iface, VARIANT *p)
1868 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1869 TRACE("(%p)->(%p)\n", This, p);
1870 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, p, 0);
1873 static HRESULT WINAPI HTMLStyle_put_borderStyle(IHTMLStyle *iface, BSTR v)
1875 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1876 static const WCHAR styleWindowInset[] = {'w','i','n','d','o','w','-','i','n','s','e','t',0};
1877 HRESULT hres = S_OK;
1878 BSTR pstyle;
1879 int i=0;
1880 int last = 0;
1882 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1884 while(v[i] && hres == S_OK)
1886 if(v[i] == (WCHAR)' ')
1888 pstyle = SysAllocStringLen(&v[last], (i-last));
1889 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1891 TRACE("1. Invalid style (%s)\n", debugstr_w(pstyle));
1892 hres = E_INVALIDARG;
1894 SysFreeString(pstyle);
1895 last = i+1;
1897 i++;
1900 if(hres == S_OK)
1902 pstyle = SysAllocStringLen(&v[last], i-last);
1903 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1905 TRACE("2. Invalid style (%s)\n", debugstr_w(pstyle));
1906 hres = E_INVALIDARG;
1908 SysFreeString(pstyle);
1911 if(hres == S_OK)
1912 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, v, 0);
1914 return hres;
1917 static HRESULT WINAPI HTMLStyle_get_borderStyle(IHTMLStyle *iface, BSTR *p)
1919 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1920 TRACE("(%p)->(%p)\n", This, p);
1921 return get_style_attr(This, STYLEID_BORDER_STYLE, p);
1924 static HRESULT WINAPI HTMLStyle_put_borderTopStyle(IHTMLStyle *iface, BSTR v)
1926 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1927 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1929 if(!is_valid_border_style(v))
1930 return E_INVALIDARG;
1932 return set_style_attr(This, STYLEID_BORDER_TOP_STYLE, v, 0);
1935 static HRESULT WINAPI HTMLStyle_get_borderTopStyle(IHTMLStyle *iface, BSTR *p)
1937 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1938 TRACE("(%p)->(%p)\n", This, p);
1939 return get_style_attr(This, STYLEID_BORDER_TOP_STYLE, p);
1942 static HRESULT WINAPI HTMLStyle_put_borderRightStyle(IHTMLStyle *iface, BSTR v)
1944 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1945 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1947 if(!is_valid_border_style(v))
1948 return E_INVALIDARG;
1950 return set_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, v, 0);
1953 static HRESULT WINAPI HTMLStyle_get_borderRightStyle(IHTMLStyle *iface, BSTR *p)
1955 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1956 TRACE("(%p)->(%p)\n", This, p);
1957 return get_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, p);
1960 static HRESULT WINAPI HTMLStyle_put_borderBottomStyle(IHTMLStyle *iface, BSTR v)
1962 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1963 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1965 if(!is_valid_border_style(v))
1966 return E_INVALIDARG;
1968 return set_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, v, 0);
1971 static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p)
1973 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1974 TRACE("(%p)->(%p)\n", This, p);
1975 return get_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, p);
1978 static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v)
1980 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1981 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1983 if(!is_valid_border_style(v))
1984 return E_INVALIDARG;
1986 return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0);
1989 static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p)
1991 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1992 TRACE("(%p)->(%p)\n", This, p);
1993 return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p);
1996 static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
1998 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2000 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2002 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX);
2005 static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
2007 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2009 TRACE("(%p)->(%p)\n", This, p);
2011 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, p, 0);
2014 static HRESULT WINAPI HTMLStyle_put_height(IHTMLStyle *iface, VARIANT v)
2016 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2018 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2020 return set_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, &v, ATTR_FIX_PX);
2023 static HRESULT WINAPI HTMLStyle_get_height(IHTMLStyle *iface, VARIANT *p)
2025 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2027 TRACE("(%p)->(%p)\n", This, p);
2029 return get_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, p, 0);
2032 static HRESULT WINAPI HTMLStyle_put_styleFloat(IHTMLStyle *iface, BSTR v)
2034 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2035 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2036 return E_NOTIMPL;
2039 static HRESULT WINAPI HTMLStyle_get_styleFloat(IHTMLStyle *iface, BSTR *p)
2041 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2042 FIXME("(%p)->(%p)\n", This, p);
2043 return E_NOTIMPL;
2046 static HRESULT WINAPI HTMLStyle_put_clear(IHTMLStyle *iface, BSTR v)
2048 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2049 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2050 return E_NOTIMPL;
2053 static HRESULT WINAPI HTMLStyle_get_clear(IHTMLStyle *iface, BSTR *p)
2055 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2056 FIXME("(%p)->(%p)\n", This, p);
2057 return E_NOTIMPL;
2060 static HRESULT WINAPI HTMLStyle_put_display(IHTMLStyle *iface, BSTR v)
2062 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2064 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2066 return set_style_attr(This, STYLEID_DISPLAY, v, 0);
2069 static HRESULT WINAPI HTMLStyle_get_display(IHTMLStyle *iface, BSTR *p)
2071 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2073 TRACE("(%p)->(%p)\n", This, p);
2075 return get_style_attr(This, STYLEID_DISPLAY, p);
2078 static HRESULT WINAPI HTMLStyle_put_visibility(IHTMLStyle *iface, BSTR v)
2080 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2082 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2084 return set_style_attr(This, STYLEID_VISIBILITY, v, 0);
2087 static HRESULT WINAPI HTMLStyle_get_visibility(IHTMLStyle *iface, BSTR *p)
2089 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2091 TRACE("(%p)->(%p)\n", This, p);
2093 return get_style_attr(This, STYLEID_VISIBILITY, p);
2096 static HRESULT WINAPI HTMLStyle_put_listStyleType(IHTMLStyle *iface, BSTR v)
2098 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2099 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2100 return E_NOTIMPL;
2103 static HRESULT WINAPI HTMLStyle_get_listStyleType(IHTMLStyle *iface, BSTR *p)
2105 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2106 FIXME("(%p)->(%p)\n", This, p);
2107 return E_NOTIMPL;
2110 static HRESULT WINAPI HTMLStyle_put_listStylePosition(IHTMLStyle *iface, BSTR v)
2112 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2113 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2114 return E_NOTIMPL;
2117 static HRESULT WINAPI HTMLStyle_get_listStylePosition(IHTMLStyle *iface, BSTR *p)
2119 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2120 FIXME("(%p)->(%p)\n", This, p);
2121 return E_NOTIMPL;
2124 static HRESULT WINAPI HTMLStyle_put_listStyleImage(IHTMLStyle *iface, BSTR v)
2126 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2127 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2128 return E_NOTIMPL;
2131 static HRESULT WINAPI HTMLStyle_get_listStyleImage(IHTMLStyle *iface, BSTR *p)
2133 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2134 FIXME("(%p)->(%p)\n", This, p);
2135 return E_NOTIMPL;
2138 static HRESULT WINAPI HTMLStyle_put_listStyle(IHTMLStyle *iface, BSTR v)
2140 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2141 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2142 return E_NOTIMPL;
2145 static HRESULT WINAPI HTMLStyle_get_listStyle(IHTMLStyle *iface, BSTR *p)
2147 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2148 FIXME("(%p)->(%p)\n", This, p);
2149 return E_NOTIMPL;
2152 static HRESULT WINAPI HTMLStyle_put_whiteSpace(IHTMLStyle *iface, BSTR v)
2154 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2155 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2156 return E_NOTIMPL;
2159 static HRESULT WINAPI HTMLStyle_get_whiteSpace(IHTMLStyle *iface, BSTR *p)
2161 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2162 FIXME("(%p)->(%p)\n", This, p);
2163 return E_NOTIMPL;
2166 static HRESULT WINAPI HTMLStyle_put_top(IHTMLStyle *iface, VARIANT v)
2168 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2170 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2172 return set_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, &v, 0);
2175 static HRESULT WINAPI HTMLStyle_get_top(IHTMLStyle *iface, VARIANT *p)
2177 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2179 TRACE("(%p)->(%p)\n", This, p);
2181 return get_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, p, 0);
2184 static HRESULT WINAPI HTMLStyle_put_left(IHTMLStyle *iface, VARIANT v)
2186 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2188 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2190 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, &v, 0);
2193 static HRESULT WINAPI HTMLStyle_get_left(IHTMLStyle *iface, VARIANT *p)
2195 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2197 TRACE("(%p)->(%p)\n", This, p);
2199 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, p, 0);
2202 static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
2204 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2205 TRACE("(%p)->(%p)\n", This, p);
2206 return IHTMLStyle2_get_position(&This->IHTMLStyle2_iface, p);
2209 static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
2211 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2213 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2215 return set_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, &v, 0);
2218 static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
2220 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2222 TRACE("(%p)->(%p)\n", This, p);
2224 return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
2227 static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
2229 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2230 static const WCHAR szVisible[] = {'v','i','s','i','b','l','e',0};
2231 static const WCHAR szScroll[] = {'s','c','r','o','l','l',0};
2232 static const WCHAR szHidden[] = {'h','i','d','d','e','n',0};
2233 static const WCHAR szAuto[] = {'a','u','t','o',0};
2235 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2237 /* overflow can only be one of the follow values. */
2238 if(!v || !*v || strcmpiW(szVisible, v) == 0 || strcmpiW(szScroll, v) == 0 ||
2239 strcmpiW(szHidden, v) == 0 || strcmpiW(szAuto, v) == 0)
2241 return set_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, v, 0);
2244 return E_INVALIDARG;
2248 static HRESULT WINAPI HTMLStyle_get_overflow(IHTMLStyle *iface, BSTR *p)
2250 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2252 TRACE("(%p)->(%p)\n", This, p);
2254 if(!p)
2255 return E_INVALIDARG;
2257 return get_style_attr(This, STYLEID_OVERFLOW, p);
2260 static HRESULT WINAPI HTMLStyle_put_pageBreakBefore(IHTMLStyle *iface, BSTR v)
2262 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2264 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2266 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, v, 0);
2269 static HRESULT WINAPI HTMLStyle_get_pageBreakBefore(IHTMLStyle *iface, BSTR *p)
2271 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2273 TRACE("(%p)->(%p)\n", This, p);
2275 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, p, 0);
2278 static HRESULT WINAPI HTMLStyle_put_pageBreakAfter(IHTMLStyle *iface, BSTR v)
2280 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2282 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2284 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, v, 0);
2287 static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p)
2289 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2291 TRACE("(%p)->(%p)\n", This, p);
2293 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, p, 0);
2296 static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
2298 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2299 nsAString text_str;
2300 nsresult nsres;
2302 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2304 nsAString_InitDepend(&text_str, v);
2305 nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str);
2306 nsAString_Finish(&text_str);
2307 if(NS_FAILED(nsres)) {
2308 FIXME("SetCssStyle failed: %08x\n", nsres);
2309 return E_FAIL;
2312 return S_OK;
2315 static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p)
2317 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2318 nsAString text_str;
2319 nsresult nsres;
2321 TRACE("(%p)->(%p)\n", This, p);
2323 /* FIXME: Gecko style formatting is different than IE (uppercase). */
2324 nsAString_Init(&text_str, NULL);
2325 nsres = nsIDOMCSSStyleDeclaration_GetCssText(This->nsstyle, &text_str);
2326 if(NS_SUCCEEDED(nsres)) {
2327 const PRUnichar *text;
2329 nsAString_GetData(&text_str, &text);
2330 *p = *text ? SysAllocString(text) : NULL;
2331 }else {
2332 FIXME("GetCssStyle failed: %08x\n", nsres);
2333 *p = NULL;
2336 nsAString_Finish(&text_str);
2337 return S_OK;
2340 static HRESULT WINAPI HTMLStyle_put_pixelTop(IHTMLStyle *iface, LONG v)
2342 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2343 FIXME("(%p)->()\n", This);
2344 return E_NOTIMPL;
2347 static HRESULT WINAPI HTMLStyle_get_pixelTop(IHTMLStyle *iface, LONG *p)
2349 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2350 FIXME("(%p)->()\n", This);
2351 return E_NOTIMPL;
2354 static HRESULT WINAPI HTMLStyle_put_pixelLeft(IHTMLStyle *iface, LONG v)
2356 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2357 FIXME("(%p)->()\n", This);
2358 return E_NOTIMPL;
2361 static HRESULT WINAPI HTMLStyle_get_pixelLeft(IHTMLStyle *iface, LONG *p)
2363 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2364 FIXME("(%p)->()\n", This);
2365 return E_NOTIMPL;
2368 static HRESULT WINAPI HTMLStyle_put_pixelWidth(IHTMLStyle *iface, LONG v)
2370 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2371 FIXME("(%p)->()\n", This);
2372 return E_NOTIMPL;
2375 static HRESULT WINAPI HTMLStyle_get_pixelWidth(IHTMLStyle *iface, LONG *p)
2377 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2378 FIXME("(%p)->()\n", This);
2379 return E_NOTIMPL;
2382 static HRESULT WINAPI HTMLStyle_put_pixelHeight(IHTMLStyle *iface, LONG v)
2384 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2385 FIXME("(%p)->()\n", This);
2386 return E_NOTIMPL;
2389 static HRESULT WINAPI HTMLStyle_get_pixelHeight(IHTMLStyle *iface, LONG *p)
2391 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2392 FIXME("(%p)->()\n", This);
2393 return E_NOTIMPL;
2396 static HRESULT WINAPI HTMLStyle_put_posTop(IHTMLStyle *iface, float v)
2398 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2400 TRACE("(%p)->(%f)\n", This, v);
2402 return set_style_pos(This, STYLEID_TOP, v);
2405 static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
2407 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2409 TRACE("(%p)->(%p)\n", This, p);
2411 if(!p)
2412 return E_POINTER;
2414 return get_nsstyle_pos(This, STYLEID_TOP, p);
2417 static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
2419 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2421 TRACE("(%p)->(%f)\n", This, v);
2423 return set_style_pos(This, STYLEID_LEFT, v);
2426 static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
2428 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2430 TRACE("(%p)->(%p)\n", This, p);
2432 if(!p)
2433 return E_POINTER;
2435 return get_nsstyle_pos(This, STYLEID_LEFT, p);
2438 static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
2440 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2442 TRACE("(%p)->(%f)\n", This, v);
2444 return set_style_pos(This, STYLEID_WIDTH, v);
2447 static HRESULT WINAPI HTMLStyle_get_posWidth(IHTMLStyle *iface, float *p)
2449 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2451 TRACE("(%p)->(%p)\n", This, p);
2453 if(!p)
2454 return E_POINTER;
2456 if(get_nsstyle_pos(This, STYLEID_WIDTH, p) != S_OK)
2457 *p = 0.0f;
2459 return S_OK;
2462 static HRESULT WINAPI HTMLStyle_put_posHeight(IHTMLStyle *iface, float v)
2464 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2466 TRACE("(%p)->(%f)\n", This, v);
2468 return set_style_pos(This, STYLEID_HEIGHT, v);
2471 static HRESULT WINAPI HTMLStyle_get_posHeight(IHTMLStyle *iface, float *p)
2473 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2475 TRACE("(%p)->(%p)\n", This, p);
2477 if(!p)
2478 return E_POINTER;
2480 if(get_nsstyle_pos(This, STYLEID_HEIGHT, p) != S_OK)
2481 *p = 0.0f;
2483 return S_OK;
2486 static HRESULT WINAPI HTMLStyle_put_cursor(IHTMLStyle *iface, BSTR v)
2488 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2490 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2492 return set_style_attr(This, STYLEID_CURSOR, v, 0);
2495 static HRESULT WINAPI HTMLStyle_get_cursor(IHTMLStyle *iface, BSTR *p)
2497 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2499 TRACE("(%p)->(%p)\n", This, p);
2501 return get_style_attr(This, STYLEID_CURSOR, p);
2504 static HRESULT WINAPI HTMLStyle_put_clip(IHTMLStyle *iface, BSTR v)
2506 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2508 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2510 return set_style_attr(This, STYLEID_CLIP, v, 0);
2513 static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
2515 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2517 TRACE("(%p)->(%p)\n", This, p);
2519 return get_nsstyle_attr(This->nsstyle, STYLEID_CLIP, p, ATTR_REMOVE_COMMA);
2522 static void set_opacity(HTMLStyle *This, const WCHAR *val)
2524 nsAString name_str, val_str, empty_str;
2525 nsresult nsres;
2527 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y',0};
2529 TRACE("%s\n", debugstr_w(val));
2531 nsAString_InitDepend(&name_str, opacityW);
2532 nsAString_InitDepend(&val_str, val);
2533 nsAString_InitDepend(&empty_str, emptyW);
2535 nsres = nsIDOMCSSStyleDeclaration_SetProperty(This->nsstyle, &name_str, &val_str, &empty_str);
2536 if(NS_FAILED(nsres))
2537 ERR("SetProperty failed: %08x\n", nsres);
2539 nsAString_Finish(&name_str);
2540 nsAString_Finish(&val_str);
2541 nsAString_Finish(&empty_str);
2544 static void update_filter(HTMLStyle *This)
2546 const WCHAR *ptr = This->elem->filter, *ptr2;
2548 static const WCHAR alphaW[] = {'a','l','p','h','a'};
2550 if(!ptr) {
2551 set_opacity(This, emptyW);
2552 return;
2555 while(1) {
2556 while(isspaceW(*ptr))
2557 ptr++;
2558 if(!*ptr)
2559 break;
2561 ptr2 = ptr;
2562 while(isalnumW(*ptr))
2563 ptr++;
2564 if(ptr == ptr2) {
2565 WARN("unexpected char '%c'\n", *ptr);
2566 break;
2568 if(*ptr != '(') {
2569 WARN("expected '('\n");
2570 continue;
2573 if(ptr2 + sizeof(alphaW)/sizeof(WCHAR) == ptr && !memcmp(ptr2, alphaW, sizeof(alphaW))) {
2574 static const WCHAR formatW[] = {'%','f',0};
2575 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y','='};
2577 ptr++;
2578 do {
2579 while(isspaceW(*ptr))
2580 ptr++;
2582 ptr2 = ptr;
2583 while(*ptr && *ptr != ',' && *ptr != ')')
2584 ptr++;
2585 if(!*ptr) {
2586 WARN("unexpected end of string\n");
2587 break;
2590 if(ptr-ptr2 > sizeof(opacityW)/sizeof(WCHAR) && !memcmp(ptr2, opacityW, sizeof(opacityW))) {
2591 float fval = 0.0f, e = 0.1f;
2592 WCHAR buf[32];
2594 ptr2 += sizeof(opacityW)/sizeof(WCHAR);
2596 while(isdigitW(*ptr2))
2597 fval = fval*10.0f + (float)(*ptr2++ - '0');
2599 if(*ptr2 == '.') {
2600 while(isdigitW(*++ptr2)) {
2601 fval += e * (float)(*ptr2++ - '0');
2602 e *= 0.1f;
2606 sprintfW(buf, formatW, fval * 0.01f);
2607 set_opacity(This, buf);
2608 }else {
2609 FIXME("unknown param %s\n", debugstr_wn(ptr2, ptr-ptr2));
2612 if(*ptr == ',')
2613 ptr++;
2614 }while(*ptr != ')');
2615 }else {
2616 FIXME("unknown filter %s\n", debugstr_wn(ptr2, ptr-ptr2));
2617 ptr = strchrW(ptr, ')');
2618 if(!ptr)
2619 break;
2620 ptr++;
2625 static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
2627 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2628 WCHAR *new_filter = NULL;
2630 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2632 if(!This->elem) {
2633 FIXME("Element already destroyed\n");
2634 return E_UNEXPECTED;
2637 if(v) {
2638 new_filter = heap_strdupW(v);
2639 if(!new_filter)
2640 return E_OUTOFMEMORY;
2643 heap_free(This->elem->filter);
2644 This->elem->filter = new_filter;
2646 update_filter(This);
2647 return S_OK;
2650 static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
2652 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2654 TRACE("(%p)->(%p)\n", This, p);
2656 if(!This->elem) {
2657 FIXME("Element already destroyed\n");
2658 return E_UNEXPECTED;
2661 if(This->elem->filter) {
2662 *p = SysAllocString(This->elem->filter);
2663 if(!*p)
2664 return E_OUTOFMEMORY;
2665 }else {
2666 *p = NULL;
2669 return S_OK;
2672 static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2673 VARIANT AttributeValue, LONG lFlags)
2675 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2676 HRESULT hres;
2677 DISPID dispid;
2679 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName),
2680 debugstr_variant(&AttributeValue), lFlags);
2682 if(!strAttributeName)
2683 return E_INVALIDARG;
2685 if(lFlags == 1)
2686 FIXME("Parameter lFlags ignored\n");
2688 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2689 LOCALE_USER_DEFAULT, &dispid);
2690 if(hres == S_OK)
2692 VARIANT ret;
2693 DISPID dispidNamed = DISPID_PROPERTYPUT;
2694 DISPPARAMS params;
2696 params.cArgs = 1;
2697 params.rgvarg = &AttributeValue;
2698 params.cNamedArgs = 1;
2699 params.rgdispidNamedArgs = &dispidNamed;
2701 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2702 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2704 else
2706 FIXME("Custom attributes not supported.\n");
2709 TRACE("ret: %08x\n", hres);
2711 return hres;
2714 static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2715 LONG lFlags, VARIANT *AttributeValue)
2717 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2718 HRESULT hres;
2719 DISPID dispid;
2721 TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName),
2722 AttributeValue, lFlags);
2724 if(!AttributeValue || !strAttributeName)
2725 return E_INVALIDARG;
2727 if(lFlags == 1)
2728 FIXME("Parameter lFlags ignored\n");
2730 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2731 LOCALE_USER_DEFAULT, &dispid);
2732 if(hres == S_OK)
2734 DISPPARAMS params = {NULL, NULL, 0, 0 };
2736 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2737 DISPATCH_PROPERTYGET, &params, AttributeValue, NULL, NULL);
2739 else
2741 FIXME("Custom attributes not supported.\n");
2744 return hres;
2747 static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2748 LONG lFlags, VARIANT_BOOL *pfSuccess)
2750 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2751 FIXME("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName),
2752 lFlags, pfSuccess);
2753 return E_NOTIMPL;
2756 static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
2758 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2759 FIXME("(%p)->(%p)\n", This, String);
2760 return E_NOTIMPL;
2763 static const IHTMLStyleVtbl HTMLStyleVtbl = {
2764 HTMLStyle_QueryInterface,
2765 HTMLStyle_AddRef,
2766 HTMLStyle_Release,
2767 HTMLStyle_GetTypeInfoCount,
2768 HTMLStyle_GetTypeInfo,
2769 HTMLStyle_GetIDsOfNames,
2770 HTMLStyle_Invoke,
2771 HTMLStyle_put_fontFamily,
2772 HTMLStyle_get_fontFamily,
2773 HTMLStyle_put_fontStyle,
2774 HTMLStyle_get_fontStyle,
2775 HTMLStyle_put_fontVariant,
2776 HTMLStyle_get_fontVariant,
2777 HTMLStyle_put_fontWeight,
2778 HTMLStyle_get_fontWeight,
2779 HTMLStyle_put_fontSize,
2780 HTMLStyle_get_fontSize,
2781 HTMLStyle_put_font,
2782 HTMLStyle_get_font,
2783 HTMLStyle_put_color,
2784 HTMLStyle_get_color,
2785 HTMLStyle_put_background,
2786 HTMLStyle_get_background,
2787 HTMLStyle_put_backgroundColor,
2788 HTMLStyle_get_backgroundColor,
2789 HTMLStyle_put_backgroundImage,
2790 HTMLStyle_get_backgroundImage,
2791 HTMLStyle_put_backgroundRepeat,
2792 HTMLStyle_get_backgroundRepeat,
2793 HTMLStyle_put_backgroundAttachment,
2794 HTMLStyle_get_backgroundAttachment,
2795 HTMLStyle_put_backgroundPosition,
2796 HTMLStyle_get_backgroundPosition,
2797 HTMLStyle_put_backgroundPositionX,
2798 HTMLStyle_get_backgroundPositionX,
2799 HTMLStyle_put_backgroundPositionY,
2800 HTMLStyle_get_backgroundPositionY,
2801 HTMLStyle_put_wordSpacing,
2802 HTMLStyle_get_wordSpacing,
2803 HTMLStyle_put_letterSpacing,
2804 HTMLStyle_get_letterSpacing,
2805 HTMLStyle_put_textDecoration,
2806 HTMLStyle_get_textDecoration,
2807 HTMLStyle_put_textDecorationNone,
2808 HTMLStyle_get_textDecorationNone,
2809 HTMLStyle_put_textDecorationUnderline,
2810 HTMLStyle_get_textDecorationUnderline,
2811 HTMLStyle_put_textDecorationOverline,
2812 HTMLStyle_get_textDecorationOverline,
2813 HTMLStyle_put_textDecorationLineThrough,
2814 HTMLStyle_get_textDecorationLineThrough,
2815 HTMLStyle_put_textDecorationBlink,
2816 HTMLStyle_get_textDecorationBlink,
2817 HTMLStyle_put_verticalAlign,
2818 HTMLStyle_get_verticalAlign,
2819 HTMLStyle_put_textTransform,
2820 HTMLStyle_get_textTransform,
2821 HTMLStyle_put_textAlign,
2822 HTMLStyle_get_textAlign,
2823 HTMLStyle_put_textIndent,
2824 HTMLStyle_get_textIndent,
2825 HTMLStyle_put_lineHeight,
2826 HTMLStyle_get_lineHeight,
2827 HTMLStyle_put_marginTop,
2828 HTMLStyle_get_marginTop,
2829 HTMLStyle_put_marginRight,
2830 HTMLStyle_get_marginRight,
2831 HTMLStyle_put_marginBottom,
2832 HTMLStyle_get_marginBottom,
2833 HTMLStyle_put_marginLeft,
2834 HTMLStyle_get_marginLeft,
2835 HTMLStyle_put_margin,
2836 HTMLStyle_get_margin,
2837 HTMLStyle_put_paddingTop,
2838 HTMLStyle_get_paddingTop,
2839 HTMLStyle_put_paddingRight,
2840 HTMLStyle_get_paddingRight,
2841 HTMLStyle_put_paddingBottom,
2842 HTMLStyle_get_paddingBottom,
2843 HTMLStyle_put_paddingLeft,
2844 HTMLStyle_get_paddingLeft,
2845 HTMLStyle_put_padding,
2846 HTMLStyle_get_padding,
2847 HTMLStyle_put_border,
2848 HTMLStyle_get_border,
2849 HTMLStyle_put_borderTop,
2850 HTMLStyle_get_borderTop,
2851 HTMLStyle_put_borderRight,
2852 HTMLStyle_get_borderRight,
2853 HTMLStyle_put_borderBottom,
2854 HTMLStyle_get_borderBottom,
2855 HTMLStyle_put_borderLeft,
2856 HTMLStyle_get_borderLeft,
2857 HTMLStyle_put_borderColor,
2858 HTMLStyle_get_borderColor,
2859 HTMLStyle_put_borderTopColor,
2860 HTMLStyle_get_borderTopColor,
2861 HTMLStyle_put_borderRightColor,
2862 HTMLStyle_get_borderRightColor,
2863 HTMLStyle_put_borderBottomColor,
2864 HTMLStyle_get_borderBottomColor,
2865 HTMLStyle_put_borderLeftColor,
2866 HTMLStyle_get_borderLeftColor,
2867 HTMLStyle_put_borderWidth,
2868 HTMLStyle_get_borderWidth,
2869 HTMLStyle_put_borderTopWidth,
2870 HTMLStyle_get_borderTopWidth,
2871 HTMLStyle_put_borderRightWidth,
2872 HTMLStyle_get_borderRightWidth,
2873 HTMLStyle_put_borderBottomWidth,
2874 HTMLStyle_get_borderBottomWidth,
2875 HTMLStyle_put_borderLeftWidth,
2876 HTMLStyle_get_borderLeftWidth,
2877 HTMLStyle_put_borderStyle,
2878 HTMLStyle_get_borderStyle,
2879 HTMLStyle_put_borderTopStyle,
2880 HTMLStyle_get_borderTopStyle,
2881 HTMLStyle_put_borderRightStyle,
2882 HTMLStyle_get_borderRightStyle,
2883 HTMLStyle_put_borderBottomStyle,
2884 HTMLStyle_get_borderBottomStyle,
2885 HTMLStyle_put_borderLeftStyle,
2886 HTMLStyle_get_borderLeftStyle,
2887 HTMLStyle_put_width,
2888 HTMLStyle_get_width,
2889 HTMLStyle_put_height,
2890 HTMLStyle_get_height,
2891 HTMLStyle_put_styleFloat,
2892 HTMLStyle_get_styleFloat,
2893 HTMLStyle_put_clear,
2894 HTMLStyle_get_clear,
2895 HTMLStyle_put_display,
2896 HTMLStyle_get_display,
2897 HTMLStyle_put_visibility,
2898 HTMLStyle_get_visibility,
2899 HTMLStyle_put_listStyleType,
2900 HTMLStyle_get_listStyleType,
2901 HTMLStyle_put_listStylePosition,
2902 HTMLStyle_get_listStylePosition,
2903 HTMLStyle_put_listStyleImage,
2904 HTMLStyle_get_listStyleImage,
2905 HTMLStyle_put_listStyle,
2906 HTMLStyle_get_listStyle,
2907 HTMLStyle_put_whiteSpace,
2908 HTMLStyle_get_whiteSpace,
2909 HTMLStyle_put_top,
2910 HTMLStyle_get_top,
2911 HTMLStyle_put_left,
2912 HTMLStyle_get_left,
2913 HTMLStyle_get_position,
2914 HTMLStyle_put_zIndex,
2915 HTMLStyle_get_zIndex,
2916 HTMLStyle_put_overflow,
2917 HTMLStyle_get_overflow,
2918 HTMLStyle_put_pageBreakBefore,
2919 HTMLStyle_get_pageBreakBefore,
2920 HTMLStyle_put_pageBreakAfter,
2921 HTMLStyle_get_pageBreakAfter,
2922 HTMLStyle_put_cssText,
2923 HTMLStyle_get_cssText,
2924 HTMLStyle_put_pixelTop,
2925 HTMLStyle_get_pixelTop,
2926 HTMLStyle_put_pixelLeft,
2927 HTMLStyle_get_pixelLeft,
2928 HTMLStyle_put_pixelWidth,
2929 HTMLStyle_get_pixelWidth,
2930 HTMLStyle_put_pixelHeight,
2931 HTMLStyle_get_pixelHeight,
2932 HTMLStyle_put_posTop,
2933 HTMLStyle_get_posTop,
2934 HTMLStyle_put_posLeft,
2935 HTMLStyle_get_posLeft,
2936 HTMLStyle_put_posWidth,
2937 HTMLStyle_get_posWidth,
2938 HTMLStyle_put_posHeight,
2939 HTMLStyle_get_posHeight,
2940 HTMLStyle_put_cursor,
2941 HTMLStyle_get_cursor,
2942 HTMLStyle_put_clip,
2943 HTMLStyle_get_clip,
2944 HTMLStyle_put_filter,
2945 HTMLStyle_get_filter,
2946 HTMLStyle_setAttribute,
2947 HTMLStyle_getAttribute,
2948 HTMLStyle_removeAttribute,
2949 HTMLStyle_toString
2952 static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
2954 const style_tbl_entry_t *style_entry;
2956 style_entry = lookup_style_tbl(name);
2957 if(style_entry) {
2958 *dispid = style_entry->dispid;
2959 return S_OK;
2962 return DISP_E_UNKNOWNNAME;
2965 static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
2966 NULL,
2967 HTMLStyle_get_dispid,
2968 NULL,
2969 NULL
2972 static const tid_t HTMLStyle_iface_tids[] = {
2973 IHTMLStyle_tid,
2974 IHTMLStyle2_tid,
2975 IHTMLStyle3_tid,
2976 IHTMLStyle4_tid,
2977 IHTMLStyle5_tid,
2978 IHTMLStyle6_tid,
2981 static dispex_static_data_t HTMLStyle_dispex = {
2982 &HTMLStyle_dispex_vtbl,
2983 DispHTMLStyle_tid,
2984 NULL,
2985 HTMLStyle_iface_tids
2988 HRESULT HTMLStyle_Create(HTMLElement *elem, nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
2990 HTMLStyle *style;
2992 style = heap_alloc_zero(sizeof(HTMLStyle));
2993 if(!style)
2994 return E_OUTOFMEMORY;
2996 style->IHTMLStyle_iface.lpVtbl = &HTMLStyleVtbl;
2997 style->ref = 1;
2998 style->nsstyle = nsstyle;
2999 style->elem = elem;
3000 HTMLStyle2_Init(style);
3001 HTMLStyle3_Init(style);
3003 nsIDOMCSSStyleDeclaration_AddRef(nsstyle);
3005 init_dispex(&style->dispex, (IUnknown*)&style->IHTMLStyle_iface, &HTMLStyle_dispex);
3007 *ret = style;
3008 return S_OK;