jscript: Don't set constructor property to each object instance, it belongs to their...
[wine/multimedia.git] / dlls / mshtml / htmlstyle.c
blobb9f0ddd373cb126537221e761f30b92699e8b49d
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 attrOverflowX[] =
138 {'o','v','e','r','f','l','o','w','-','x',0};
139 static const WCHAR attrOverflowY[] =
140 {'o','v','e','r','f','l','o','w','-','y',0};
141 static const WCHAR attrPadding[] =
142 {'p','a','d','d','i','n','g',0};
143 static const WCHAR attrPaddingBottom[] =
144 {'p','a','d','d','i','n','g','-','b','o','t','t','o','m',0};
145 static const WCHAR attrPaddingLeft[] =
146 {'p','a','d','d','i','n','g','-','l','e','f','t',0};
147 static const WCHAR attrPaddingRight[] =
148 {'p','a','d','d','i','n','g','-','r','i','g','h','t',0};
149 static const WCHAR attrPaddingTop[] =
150 {'p','a','d','d','i','n','g','-','t','o','p',0};
151 static const WCHAR attrPageBreakAfter[] =
152 {'p','a','g','e','-','b','r','e','a','k','-','a','f','t','e','r',0};
153 static const WCHAR attrPageBreakBefore[] =
154 {'p','a','g','e','-','b','r','e','a','k','-','b','e','f','o','r','e',0};
155 static const WCHAR attrPosition[] =
156 {'p','o','s','i','t','i','o','n',0};
157 static const WCHAR attrRight[] =
158 {'r','i','g','h','t',0};
159 static const WCHAR attrTextAlign[] =
160 {'t','e','x','t','-','a','l','i','g','n',0};
161 static const WCHAR attrTextDecoration[] =
162 {'t','e','x','t','-','d','e','c','o','r','a','t','i','o','n',0};
163 static const WCHAR attrTextIndent[] =
164 {'t','e','x','t','-','i','n','d','e','n','t',0};
165 static const WCHAR attrTop[] =
166 {'t','o','p',0};
167 static const WCHAR attrVerticalAlign[] =
168 {'v','e','r','t','i','c','a','l','-','a','l','i','g','n',0};
169 static const WCHAR attrVisibility[] =
170 {'v','i','s','i','b','i','l','i','t','y',0};
171 static const WCHAR attrWidth[] =
172 {'w','i','d','t','h',0};
173 static const WCHAR attrWordSpacing[] =
174 {'w','o','r','d','-','s','p','a','c','i','n','g',0};
175 static const WCHAR attrWordWrap[] =
176 {'w','o','r','d','-','w','r','a','p',0};
177 static const WCHAR attrZIndex[] =
178 {'z','-','i','n','d','e','x',0};
180 typedef struct {
181 const WCHAR *name;
182 DISPID dispid;
183 } style_tbl_entry_t;
185 static const style_tbl_entry_t style_tbl[] = {
186 {attrBackground, DISPID_IHTMLSTYLE_BACKGROUND},
187 {attrBackgroundColor, DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
188 {attrBackgroundImage, DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
189 {attrBackgroundPosition, DISPID_IHTMLSTYLE_BACKGROUNDPOSITION},
190 {attrBackgroundPositionX, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONX},
191 {attrBackgroundPositionY, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
192 {attrBackgroundRepeat, DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
193 {attrBorder, DISPID_IHTMLSTYLE_BORDER},
194 {attrBorderBottom, DISPID_IHTMLSTYLE_BORDERBOTTOM},
195 {attrBorderBottomColor, DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR},
196 {attrBorderBottomStyle, DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
197 {attrBorderBottomWidth, DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
198 {attrBorderColor, DISPID_IHTMLSTYLE_BORDERCOLOR},
199 {attrBorderLeft, DISPID_IHTMLSTYLE_BORDERLEFT},
200 {attrBorderLeftColor, DISPID_IHTMLSTYLE_BORDERLEFTCOLOR},
201 {attrBorderLeftStyle, DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
202 {attrBorderLeftWidth, DISPID_IHTMLSTYLE_BORDERLEFTWIDTH},
203 {attrBorderRight, DISPID_IHTMLSTYLE_BORDERRIGHT},
204 {attrBorderRightColor, DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR},
205 {attrBorderRightStyle, DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
206 {attrBorderRightWidth, DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
207 {attrBorderStyle, DISPID_IHTMLSTYLE_BORDERSTYLE},
208 {attrBorderTop, DISPID_IHTMLSTYLE_BORDERTOP},
209 {attrBorderTopColor, DISPID_IHTMLSTYLE_BORDERTOPCOLOR},
210 {attrBorderTopStyle, DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
211 {attrBorderTopWidth, DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
212 {attrBorderWidth, DISPID_IHTMLSTYLE_BORDERWIDTH},
213 {attrBottom, DISPID_IHTMLSTYLE2_BOTTOM},
214 {attrClip, DISPID_IHTMLSTYLE_CLIP},
215 {attrColor, DISPID_IHTMLSTYLE_COLOR},
216 {attrCursor, DISPID_IHTMLSTYLE_CURSOR},
217 {attrDirection, DISPID_IHTMLSTYLE2_DIRECTION},
218 {attrDisplay, DISPID_IHTMLSTYLE_DISPLAY},
219 {attrFilter, DISPID_IHTMLSTYLE_FILTER},
220 {attrFontFamily, DISPID_IHTMLSTYLE_FONTFAMILY},
221 {attrFontSize, DISPID_IHTMLSTYLE_FONTSIZE},
222 {attrFontStyle, DISPID_IHTMLSTYLE_FONTSTYLE},
223 {attrFontVariant, DISPID_IHTMLSTYLE_FONTVARIANT},
224 {attrFontWeight, DISPID_IHTMLSTYLE_FONTWEIGHT},
225 {attrHeight, DISPID_IHTMLSTYLE_HEIGHT},
226 {attrLeft, DISPID_IHTMLSTYLE_LEFT},
227 {attrLetterSpacing, DISPID_IHTMLSTYLE_LETTERSPACING},
228 {attrLineHeight, DISPID_IHTMLSTYLE_LINEHEIGHT},
229 {attrMargin, DISPID_IHTMLSTYLE_MARGIN},
230 {attrMarginBottom, DISPID_IHTMLSTYLE_MARGINBOTTOM},
231 {attrMarginLeft, DISPID_IHTMLSTYLE_MARGINLEFT},
232 {attrMarginRight, DISPID_IHTMLSTYLE_MARGINRIGHT},
233 {attrMarginTop, DISPID_IHTMLSTYLE_MARGINTOP},
234 {attrMinHeight, DISPID_IHTMLSTYLE4_MINHEIGHT},
235 {attrOverflow, DISPID_IHTMLSTYLE_OVERFLOW},
236 {attrOverflowX, DISPID_IHTMLSTYLE2_OVERFLOWX},
237 {attrOverflowY, DISPID_IHTMLSTYLE2_OVERFLOWY},
238 {attrPadding, DISPID_IHTMLSTYLE_PADDING},
239 {attrPaddingBottom, DISPID_IHTMLSTYLE_PADDINGBOTTOM},
240 {attrPaddingLeft, DISPID_IHTMLSTYLE_PADDINGLEFT},
241 {attrPaddingRight, DISPID_IHTMLSTYLE_PADDINGRIGHT},
242 {attrPaddingTop, DISPID_IHTMLSTYLE_PADDINGTOP},
243 {attrPageBreakAfter, DISPID_IHTMLSTYLE_PAGEBREAKAFTER},
244 {attrPageBreakBefore, DISPID_IHTMLSTYLE_PAGEBREAKBEFORE},
245 {attrPosition, DISPID_IHTMLSTYLE2_POSITION},
246 {attrRight, DISPID_IHTMLSTYLE2_RIGHT},
247 {attrTextAlign, DISPID_IHTMLSTYLE_TEXTALIGN},
248 {attrTextDecoration, DISPID_IHTMLSTYLE_TEXTDECORATION},
249 {attrTextIndent, DISPID_IHTMLSTYLE_TEXTINDENT},
250 {attrTop, DISPID_IHTMLSTYLE_TOP},
251 {attrVerticalAlign, DISPID_IHTMLSTYLE_VERTICALALIGN},
252 {attrVisibility, DISPID_IHTMLSTYLE_VISIBILITY},
253 {attrWidth, DISPID_IHTMLSTYLE_WIDTH},
254 {attrWordSpacing, DISPID_IHTMLSTYLE_WORDSPACING},
255 {attrWordWrap, DISPID_IHTMLSTYLE3_WORDWRAP},
256 {attrZIndex, DISPID_IHTMLSTYLE_ZINDEX}
259 static const WCHAR valLineThrough[] =
260 {'l','i','n','e','-','t','h','r','o','u','g','h',0};
261 static const WCHAR valUnderline[] =
262 {'u','n','d','e','r','l','i','n','e',0};
263 static const WCHAR szNormal[] =
264 {'n','o','r','m','a','l',0};
265 static const WCHAR styleNone[] =
266 {'n','o','n','e',0};
267 static const WCHAR valOverline[] =
268 {'o','v','e','r','l','i','n','e',0};
269 static const WCHAR valBlink[] =
270 {'b','l','i','n','k',0};
272 static const WCHAR px_formatW[] = {'%','d','p','x',0};
273 static const WCHAR emptyW[] = {0};
275 static const style_tbl_entry_t *lookup_style_tbl(const WCHAR *name)
277 int c, i, min = 0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
279 while(min <= max) {
280 i = (min+max)/2;
282 c = strcmpW(style_tbl[i].name, name);
283 if(!c)
284 return style_tbl+i;
286 if(c > 0)
287 max = i-1;
288 else
289 min = i+1;
292 return NULL;
295 static LPWSTR fix_px_value(LPCWSTR val)
297 LPCWSTR ptr = val;
299 while(*ptr) {
300 while(*ptr && isspaceW(*ptr))
301 ptr++;
302 if(!*ptr)
303 break;
305 while(*ptr && isdigitW(*ptr))
306 ptr++;
308 if(!*ptr || isspaceW(*ptr)) {
309 LPWSTR ret, p;
310 int len = strlenW(val)+1;
312 ret = heap_alloc((len+2)*sizeof(WCHAR));
313 memcpy(ret, val, (ptr-val)*sizeof(WCHAR));
314 p = ret + (ptr-val);
315 *p++ = 'p';
316 *p++ = 'x';
317 strcpyW(p, ptr);
319 TRACE("fixed %s -> %s\n", debugstr_w(val), debugstr_w(ret));
321 return ret;
324 while(*ptr && !isspaceW(*ptr))
325 ptr++;
328 return NULL;
331 static LPWSTR fix_url_value(LPCWSTR val)
333 WCHAR *ret, *ptr;
335 static const WCHAR urlW[] = {'u','r','l','('};
337 if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
338 return NULL;
340 ret = heap_strdupW(val);
342 for(ptr = ret; *ptr; ptr++) {
343 if(*ptr == '\\')
344 *ptr = '/';
347 return ret;
350 HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCWSTR value, DWORD flags)
352 nsAString str_name, str_value, str_empty;
353 LPWSTR val = NULL;
354 nsresult nsres;
356 if(flags & ATTR_FIX_PX)
357 val = fix_px_value(value);
358 if(flags & ATTR_FIX_URL)
359 val = fix_url_value(value);
361 nsAString_InitDepend(&str_name, style_tbl[sid].name);
362 nsAString_InitDepend(&str_value, val ? val : value);
363 nsAString_InitDepend(&str_empty, emptyW);
365 nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
366 if(NS_FAILED(nsres))
367 ERR("SetProperty failed: %08x\n", nsres);
369 nsAString_Finish(&str_name);
370 nsAString_Finish(&str_value);
371 nsAString_Finish(&str_empty);
372 heap_free(val);
374 return S_OK;
377 static HRESULT var_to_styleval(const VARIANT *v, WCHAR *buf, DWORD flags, const WCHAR **ret)
379 switch(V_VT(v)) {
380 case VT_NULL:
381 *ret = emptyW;
382 return S_OK;
384 case VT_BSTR:
385 *ret = V_BSTR(v);
386 return S_OK;
388 case VT_BSTR|VT_BYREF:
389 *ret = *V_BSTRREF(v);
390 return S_OK;
392 case VT_I4: {
393 static const WCHAR formatW[] = {'%','d',0};
394 static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
396 if(flags & ATTR_HEX_INT)
397 wsprintfW(buf, hex_formatW, V_I4(v));
398 else if(flags & ATTR_FIX_PX)
399 wsprintfW(buf, px_formatW, V_I4(v));
400 else
401 wsprintfW(buf, formatW, V_I4(v));
403 *ret = buf;
404 return S_OK;
406 default:
407 FIXME("not implemented for %s\n", debugstr_variant(v));
408 return E_NOTIMPL;
413 HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *value, DWORD flags)
415 const WCHAR *val;
416 WCHAR buf[14];
417 HRESULT hres;
419 hres = var_to_styleval(value, buf, flags, &val);
420 if(FAILED(hres))
421 return hres;
423 return set_nsstyle_attr(nsstyle, sid, val, flags);
426 static inline HRESULT set_style_attr(HTMLStyle *This, styleid_t sid, LPCWSTR value, DWORD flags)
428 return set_nsstyle_attr(This->nsstyle, sid, value, flags);
431 static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, nsAString *value)
433 nsAString str_name;
434 nsresult nsres;
436 nsAString_InitDepend(&str_name, style_tbl[sid].name);
438 nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
439 if(NS_FAILED(nsres)) {
440 ERR("SetProperty failed: %08x\n", nsres);
441 return E_FAIL;
444 nsAString_Finish(&str_name);
446 return NS_OK;
449 static HRESULT nsstyle_to_bstr(const WCHAR *val, DWORD flags, BSTR *p)
451 BSTR ret;
452 DWORD len;
454 if(!*val) {
455 *p = NULL;
456 return S_OK;
459 ret = SysAllocString(val);
460 if(!ret)
461 return E_OUTOFMEMORY;
463 len = SysStringLen(ret);
465 if(flags & ATTR_REMOVE_COMMA) {
466 DWORD new_len = len;
467 WCHAR *ptr, *ptr2;
469 for(ptr = ret; (ptr = strchrW(ptr, ',')); ptr++)
470 new_len--;
472 if(new_len != len) {
473 BSTR new_ret;
475 new_ret = SysAllocStringLen(NULL, new_len);
476 if(!new_ret) {
477 SysFreeString(ret);
478 return E_OUTOFMEMORY;
481 for(ptr2 = new_ret, ptr = ret; *ptr; ptr++) {
482 if(*ptr != ',')
483 *ptr2++ = *ptr;
486 SysFreeString(ret);
487 ret = new_ret;
491 *p = ret;
492 return S_OK;
495 HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR *p, DWORD flags)
497 nsAString str_value;
498 const PRUnichar *value;
499 HRESULT hres;
501 nsAString_Init(&str_value, NULL);
503 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
505 nsAString_GetData(&str_value, &value);
506 hres = nsstyle_to_bstr(value, flags, p);
507 nsAString_Finish(&str_value);
509 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_w(*p));
510 return hres;
513 HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
515 nsAString str_value;
516 const PRUnichar *value;
517 BOOL set = FALSE;
518 HRESULT hres = S_OK;
520 nsAString_Init(&str_value, NULL);
522 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
524 nsAString_GetData(&str_value, &value);
526 if(flags & ATTR_STR_TO_INT) {
527 const PRUnichar *ptr = value;
528 BOOL neg = FALSE;
529 INT i = 0;
531 if(*ptr == '-') {
532 neg = TRUE;
533 ptr++;
536 while(isdigitW(*ptr))
537 i = i*10 + (*ptr++ - '0');
539 if(!*ptr) {
540 V_VT(p) = VT_I4;
541 V_I4(p) = neg ? -i : i;
542 set = TRUE;
546 if(!set) {
547 BSTR str;
549 hres = nsstyle_to_bstr(value, flags, &str);
550 if(SUCCEEDED(hres)) {
551 V_VT(p) = VT_BSTR;
552 V_BSTR(p) = str;
556 nsAString_Finish(&str_value);
558 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_variant(p));
559 return S_OK;
562 static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
564 return get_nsstyle_attr(This->nsstyle, sid, p, 0);
567 static HRESULT check_style_attr_value(HTMLStyle *This, styleid_t sid, LPCWSTR exval, VARIANT_BOOL *p)
569 nsAString str_value;
570 const PRUnichar *value;
572 nsAString_Init(&str_value, NULL);
574 get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
576 nsAString_GetData(&str_value, &value);
577 *p = strcmpW(value, exval) ? VARIANT_FALSE : VARIANT_TRUE;
578 nsAString_Finish(&str_value);
580 TRACE("%s -> %x\n", debugstr_w(style_tbl[sid].name), *p);
581 return S_OK;
584 static inline HRESULT set_style_pos(HTMLStyle *This, styleid_t sid, float value)
586 WCHAR szValue[25];
587 WCHAR szFormat[] = {'%','.','0','f','p','x',0};
589 value = floor(value);
591 sprintfW(szValue, szFormat, value);
593 return set_style_attr(This, sid, szValue, 0);
596 static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p)
598 nsAString str_value;
599 HRESULT hres;
600 WCHAR pxW[] = {'p','x',0};
602 TRACE("%p %d %p\n", This, sid, p);
604 *p = 0.0f;
606 nsAString_Init(&str_value, NULL);
608 hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
609 if(hres == S_OK)
611 WCHAR *ptr;
612 const PRUnichar *value;
614 nsAString_GetData(&str_value, &value);
615 if(value)
617 *p = strtolW(value, &ptr, 10);
619 if(*ptr && strcmpW(ptr, pxW))
621 nsAString_Finish(&str_value);
622 FIXME("only px values are currently supported\n");
623 return E_FAIL;
628 TRACE("ret %f\n", *p);
630 nsAString_Finish(&str_value);
632 return hres;
635 static BOOL is_valid_border_style(BSTR v)
637 static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0};
638 static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0};
639 static const WCHAR styleSolid[] = {'s','o','l','i','d',0};
640 static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0};
641 static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0};
642 static const WCHAR styleRidge[] = {'r','i','d','g','e',0};
643 static const WCHAR styleInset[] = {'i','n','s','e','t',0};
644 static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0};
646 TRACE("%s\n", debugstr_w(v));
648 if(!v || strcmpiW(v, styleNone) == 0 || strcmpiW(v, styleDotted) == 0 ||
649 strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid) == 0 ||
650 strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 ||
651 strcmpiW(v, styleRidge) == 0 || strcmpiW(v, styleInset) == 0 ||
652 strcmpiW(v, styleOutset) == 0 )
654 return TRUE;
657 return FALSE;
660 static inline HTMLStyle *impl_from_IHTMLStyle(IHTMLStyle *iface)
662 return CONTAINING_RECORD(iface, HTMLStyle, IHTMLStyle_iface);
665 static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv)
667 HTMLStyle *This = impl_from_IHTMLStyle(iface);
669 *ppv = NULL;
671 if(IsEqualGUID(&IID_IUnknown, riid)) {
672 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
673 *ppv = &This->IHTMLStyle_iface;
674 }else if(IsEqualGUID(&IID_IHTMLStyle, riid)) {
675 TRACE("(%p)->(IID_IHTMLStyle %p)\n", This, ppv);
676 *ppv = &This->IHTMLStyle_iface;
677 }else if(IsEqualGUID(&IID_IHTMLStyle2, riid)) {
678 TRACE("(%p)->(IID_IHTMLStyle2 %p)\n", This, ppv);
679 *ppv = &This->IHTMLStyle2_iface;
680 }else if(IsEqualGUID(&IID_IHTMLStyle3, riid)) {
681 TRACE("(%p)->(IID_IHTMLStyle3 %p)\n", This, ppv);
682 *ppv = &This->IHTMLStyle3_iface;
683 }else if(IsEqualGUID(&IID_IHTMLStyle4, riid)) {
684 TRACE("(%p)->(IID_IHTMLStyle4 %p)\n", This, ppv);
685 *ppv = &This->IHTMLStyle4_iface;
686 }else if(IsEqualGUID(&IID_IHTMLStyle5, riid)) {
687 TRACE("(%p)->(IID_IHTMLStyle5 %p)\n", This, ppv);
688 *ppv = &This->IHTMLStyle5_iface;
689 }else if(IsEqualGUID(&IID_IHTMLStyle6, riid)) {
690 TRACE("(%p)->(IID_IHTMLStyle6 %p)\n", This, ppv);
691 *ppv = &This->IHTMLStyle6_iface;
692 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
693 return *ppv ? S_OK : E_NOINTERFACE;
696 if(*ppv) {
697 IUnknown_AddRef((IUnknown*)*ppv);
698 return S_OK;
701 WARN("unsupported %s\n", debugstr_guid(riid));
702 return E_NOINTERFACE;
705 static ULONG WINAPI HTMLStyle_AddRef(IHTMLStyle *iface)
707 HTMLStyle *This = impl_from_IHTMLStyle(iface);
708 LONG ref = InterlockedIncrement(&This->ref);
710 TRACE("(%p) ref=%d\n", This, ref);
712 return ref;
715 static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
717 HTMLStyle *This = impl_from_IHTMLStyle(iface);
718 LONG ref = InterlockedDecrement(&This->ref);
720 TRACE("(%p) ref=%d\n", This, ref);
722 if(!ref) {
723 if(This->nsstyle)
724 nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
725 release_dispex(&This->dispex);
726 heap_free(This);
729 return ref;
732 static HRESULT WINAPI HTMLStyle_GetTypeInfoCount(IHTMLStyle *iface, UINT *pctinfo)
734 HTMLStyle *This = impl_from_IHTMLStyle(iface);
735 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
738 static HRESULT WINAPI HTMLStyle_GetTypeInfo(IHTMLStyle *iface, UINT iTInfo,
739 LCID lcid, ITypeInfo **ppTInfo)
741 HTMLStyle *This = impl_from_IHTMLStyle(iface);
742 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
745 static HRESULT WINAPI HTMLStyle_GetIDsOfNames(IHTMLStyle *iface, REFIID riid,
746 LPOLESTR *rgszNames, UINT cNames,
747 LCID lcid, DISPID *rgDispId)
749 HTMLStyle *This = impl_from_IHTMLStyle(iface);
750 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
751 lcid, rgDispId);
754 static HRESULT WINAPI HTMLStyle_Invoke(IHTMLStyle *iface, DISPID dispIdMember,
755 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
756 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
758 HTMLStyle *This = impl_from_IHTMLStyle(iface);
759 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
760 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
763 static HRESULT WINAPI HTMLStyle_put_fontFamily(IHTMLStyle *iface, BSTR v)
765 HTMLStyle *This = impl_from_IHTMLStyle(iface);
767 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
769 return set_style_attr(This, STYLEID_FONT_FAMILY, v, 0);
772 static HRESULT WINAPI HTMLStyle_get_fontFamily(IHTMLStyle *iface, BSTR *p)
774 HTMLStyle *This = impl_from_IHTMLStyle(iface);
776 TRACE("(%p)->(%p)\n", This, p);
778 return get_style_attr(This, STYLEID_FONT_FAMILY, p);
781 static HRESULT WINAPI HTMLStyle_put_fontStyle(IHTMLStyle *iface, BSTR v)
783 HTMLStyle *This = impl_from_IHTMLStyle(iface);
784 static const WCHAR szItalic[] = {'i','t','a','l','i','c',0};
785 static const WCHAR szOblique[] = {'o','b','l','i','q','u','e',0};
787 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
789 /* fontStyle can only be one of the follow values. */
790 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szItalic, v) == 0 ||
791 strcmpiW(szOblique, v) == 0)
793 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, v, 0);
796 return E_INVALIDARG;
799 static HRESULT WINAPI HTMLStyle_get_fontStyle(IHTMLStyle *iface, BSTR *p)
801 HTMLStyle *This = impl_from_IHTMLStyle(iface);
803 TRACE("(%p)->(%p)\n", This, p);
805 return get_style_attr(This, STYLEID_FONT_STYLE, p);
808 static HRESULT WINAPI HTMLStyle_put_fontVariant(IHTMLStyle *iface, BSTR v)
810 HTMLStyle *This = impl_from_IHTMLStyle(iface);
811 static const WCHAR szCaps[] = {'s','m','a','l','l','-','c','a','p','s',0};
813 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
815 /* fontVariant can only be one of the follow values. */
816 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szCaps, v) == 0)
818 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, v, 0);
821 return E_INVALIDARG;
824 static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p)
826 HTMLStyle *This = impl_from_IHTMLStyle(iface);
827 TRACE("(%p)->(%p)\n", This, p);
829 if(!p)
830 return E_INVALIDARG;
832 return get_style_attr(This, STYLEID_FONT_VARIANT, p);
835 static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v)
837 HTMLStyle *This = impl_from_IHTMLStyle(iface);
838 static const WCHAR styleBold[] = {'b','o','l','d',0};
839 static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0};
840 static const WCHAR styleLighter[] = {'l','i','g','h','t','e','r',0};
841 static const WCHAR style100[] = {'1','0','0',0};
842 static const WCHAR style200[] = {'2','0','0',0};
843 static const WCHAR style300[] = {'3','0','0',0};
844 static const WCHAR style400[] = {'4','0','0',0};
845 static const WCHAR style500[] = {'5','0','0',0};
846 static const WCHAR style600[] = {'6','0','0',0};
847 static const WCHAR style700[] = {'7','0','0',0};
848 static const WCHAR style800[] = {'8','0','0',0};
849 static const WCHAR style900[] = {'9','0','0',0};
851 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
853 /* fontWeight can only be one of the following */
854 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(styleBold, v) == 0 ||
855 strcmpiW(styleBolder, v) == 0 || strcmpiW(styleLighter, v) == 0 ||
856 strcmpiW(style100, v) == 0 || strcmpiW(style200, v) == 0 ||
857 strcmpiW(style300, v) == 0 || strcmpiW(style400, v) == 0 ||
858 strcmpiW(style500, v) == 0 || strcmpiW(style600, v) == 0 ||
859 strcmpiW(style700, v) == 0 || strcmpiW(style800, v) == 0 ||
860 strcmpiW(style900, v) == 0
863 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0);
866 return E_INVALIDARG;
869 static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p)
871 HTMLStyle *This = impl_from_IHTMLStyle(iface);
873 TRACE("(%p)->(%p)\n", This, p);
875 return get_style_attr(This, STYLEID_FONT_WEIGHT, p);
878 static HRESULT WINAPI HTMLStyle_put_fontSize(IHTMLStyle *iface, VARIANT v)
880 HTMLStyle *This = impl_from_IHTMLStyle(iface);
882 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
884 return set_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, &v, ATTR_FIX_PX);
887 static HRESULT WINAPI HTMLStyle_get_fontSize(IHTMLStyle *iface, VARIANT *p)
889 HTMLStyle *This = impl_from_IHTMLStyle(iface);
891 TRACE("(%p)->(%p)\n", This, p);
893 return get_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, p, 0);
896 static HRESULT WINAPI HTMLStyle_put_font(IHTMLStyle *iface, BSTR v)
898 HTMLStyle *This = impl_from_IHTMLStyle(iface);
899 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
900 return E_NOTIMPL;
903 static HRESULT WINAPI HTMLStyle_get_font(IHTMLStyle *iface, BSTR *p)
905 HTMLStyle *This = impl_from_IHTMLStyle(iface);
906 FIXME("(%p)->(%p)\n", This, p);
907 return E_NOTIMPL;
910 static HRESULT WINAPI HTMLStyle_put_color(IHTMLStyle *iface, VARIANT v)
912 HTMLStyle *This = impl_from_IHTMLStyle(iface);
914 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
916 return set_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, &v, ATTR_HEX_INT);
919 static HRESULT WINAPI HTMLStyle_get_color(IHTMLStyle *iface, VARIANT *p)
921 HTMLStyle *This = impl_from_IHTMLStyle(iface);
923 TRACE("(%p)->(%p)\n", This, p);
925 return get_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, p, 0);
928 static HRESULT WINAPI HTMLStyle_put_background(IHTMLStyle *iface, BSTR v)
930 HTMLStyle *This = impl_from_IHTMLStyle(iface);
932 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
934 return set_style_attr(This, STYLEID_BACKGROUND, v, 0);
937 static HRESULT WINAPI HTMLStyle_get_background(IHTMLStyle *iface, BSTR *p)
939 HTMLStyle *This = impl_from_IHTMLStyle(iface);
941 TRACE("(%p)->(%p)\n", This, p);
943 return get_style_attr(This, STYLEID_BACKGROUND, p);
946 static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v)
948 HTMLStyle *This = impl_from_IHTMLStyle(iface);
950 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
952 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, &v, ATTR_HEX_INT);
955 static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
957 HTMLStyle *This = impl_from_IHTMLStyle(iface);
959 TRACE("(%p)->(%p)\n", This, p);
961 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, p, 0);
964 static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
966 HTMLStyle *This = impl_from_IHTMLStyle(iface);
968 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
970 return set_style_attr(This, STYLEID_BACKGROUND_IMAGE, v, ATTR_FIX_URL);
973 static HRESULT WINAPI HTMLStyle_get_backgroundImage(IHTMLStyle *iface, BSTR *p)
975 HTMLStyle *This = impl_from_IHTMLStyle(iface);
977 TRACE("(%p)->(%p)\n", This, p);
979 return get_style_attr(This, STYLEID_BACKGROUND_IMAGE, p);
982 static HRESULT WINAPI HTMLStyle_put_backgroundRepeat(IHTMLStyle *iface, BSTR v)
984 HTMLStyle *This = impl_from_IHTMLStyle(iface);
985 static const WCHAR styleRepeat[] = {'r','e','p','e','a','t',0};
986 static const WCHAR styleNoRepeat[] = {'n','o','-','r','e','p','e','a','t',0};
987 static const WCHAR styleRepeatX[] = {'r','e','p','e','a','t','-','x',0};
988 static const WCHAR styleRepeatY[] = {'r','e','p','e','a','t','-','y',0};
990 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
992 /* fontWeight can only be one of the following */
993 if(!v || strcmpiW(styleRepeat, v) == 0 || strcmpiW(styleNoRepeat, v) == 0 ||
994 strcmpiW(styleRepeatX, v) == 0 || strcmpiW(styleRepeatY, v) == 0 )
996 return set_style_attr(This, STYLEID_BACKGROUND_REPEAT , v, 0);
999 return E_INVALIDARG;
1002 static HRESULT WINAPI HTMLStyle_get_backgroundRepeat(IHTMLStyle *iface, BSTR *p)
1004 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1006 TRACE("(%p)->(%p)\n", This, p);
1008 return get_style_attr(This, STYLEID_BACKGROUND_REPEAT, p);
1011 static HRESULT WINAPI HTMLStyle_put_backgroundAttachment(IHTMLStyle *iface, BSTR v)
1013 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1014 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1015 return E_NOTIMPL;
1018 static HRESULT WINAPI HTMLStyle_get_backgroundAttachment(IHTMLStyle *iface, BSTR *p)
1020 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1021 FIXME("(%p)->(%p)\n", This, p);
1022 return E_NOTIMPL;
1025 static HRESULT WINAPI HTMLStyle_put_backgroundPosition(IHTMLStyle *iface, BSTR v)
1027 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1029 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1031 return set_style_attr(This, STYLEID_BACKGROUND_POSITION, v, 0);
1034 static HRESULT WINAPI HTMLStyle_get_backgroundPosition(IHTMLStyle *iface, BSTR *p)
1036 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1038 TRACE("(%p)->(%p)\n", This, p);
1040 return get_style_attr(This, STYLEID_BACKGROUND_POSITION, p);
1043 static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIANT v)
1045 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1046 WCHAR buf[14], *pos_val;
1047 nsAString pos_str;
1048 const WCHAR *val;
1049 DWORD val_len;
1050 HRESULT hres;
1052 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1054 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1055 if(FAILED(hres))
1056 return hres;
1058 val_len = val ? strlenW(val) : 0;
1060 nsAString_Init(&pos_str, NULL);
1061 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1062 if(SUCCEEDED(hres)) {
1063 const PRUnichar *pos, *posy;
1064 DWORD posy_len;
1066 nsAString_GetData(&pos_str, &pos);
1067 posy = strchrW(pos, ' ');
1068 if(!posy) {
1069 static const WCHAR zero_pxW[] = {' ','0','p','x',0};
1071 TRACE("no space in %s\n", debugstr_w(pos));
1072 posy = zero_pxW;
1075 posy_len = strlenW(posy);
1076 pos_val = heap_alloc((val_len+posy_len+1)*sizeof(WCHAR));
1077 if(pos_val) {
1078 if(val_len)
1079 memcpy(pos_val, val, val_len*sizeof(WCHAR));
1080 if(posy_len)
1081 memcpy(pos_val+val_len, posy, posy_len*sizeof(WCHAR));
1082 pos_val[val_len+posy_len] = 0;
1083 }else {
1084 hres = E_OUTOFMEMORY;
1087 nsAString_Finish(&pos_str);
1088 if(FAILED(hres))
1089 return hres;
1091 TRACE("setting position to %s\n", debugstr_w(pos_val));
1092 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1093 heap_free(pos_val);
1094 return hres;
1097 static HRESULT WINAPI HTMLStyle_get_backgroundPositionX(IHTMLStyle *iface, VARIANT *p)
1099 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1100 nsAString pos_str;
1101 BSTR ret;
1102 HRESULT hres;
1104 TRACE("(%p)->(%p)\n", This, p);
1106 nsAString_Init(&pos_str, NULL);
1107 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1108 if(SUCCEEDED(hres)) {
1109 const PRUnichar *pos, *space;
1111 nsAString_GetData(&pos_str, &pos);
1112 space = strchrW(pos, ' ');
1113 if(!space) {
1114 WARN("no space in %s\n", debugstr_w(pos));
1115 space = pos + strlenW(pos);
1118 if(space != pos) {
1119 ret = SysAllocStringLen(pos, space-pos);
1120 if(!ret)
1121 hres = E_OUTOFMEMORY;
1122 }else {
1123 ret = NULL;
1126 nsAString_Finish(&pos_str);
1127 if(FAILED(hres))
1128 return hres;
1130 TRACE("returning %s\n", debugstr_w(ret));
1131 V_VT(p) = VT_BSTR;
1132 V_BSTR(p) = ret;
1133 return S_OK;
1136 static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIANT v)
1138 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1139 WCHAR buf[14], *pos_val;
1140 nsAString pos_str;
1141 const WCHAR *val;
1142 DWORD val_len;
1143 HRESULT hres;
1145 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1147 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1148 if(FAILED(hres))
1149 return hres;
1151 val_len = val ? strlenW(val) : 0;
1153 nsAString_Init(&pos_str, NULL);
1154 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1155 if(SUCCEEDED(hres)) {
1156 const PRUnichar *pos, *space;
1157 DWORD posx_len;
1159 nsAString_GetData(&pos_str, &pos);
1160 space = strchrW(pos, ' ');
1161 if(space) {
1162 space++;
1163 }else {
1164 static const WCHAR zero_pxW[] = {'0','p','x',' ',0};
1166 TRACE("no space in %s\n", debugstr_w(pos));
1167 pos = zero_pxW;
1168 space = pos + sizeof(zero_pxW)/sizeof(WCHAR)-1;
1171 posx_len = space-pos;
1173 pos_val = heap_alloc((posx_len+val_len+1)*sizeof(WCHAR));
1174 if(pos_val) {
1175 memcpy(pos_val, pos, posx_len*sizeof(WCHAR));
1176 if(val_len)
1177 memcpy(pos_val+posx_len, val, val_len*sizeof(WCHAR));
1178 pos_val[posx_len+val_len] = 0;
1179 }else {
1180 hres = E_OUTOFMEMORY;
1183 nsAString_Finish(&pos_str);
1184 if(FAILED(hres))
1185 return hres;
1187 TRACE("setting position to %s\n", debugstr_w(pos_val));
1188 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1189 heap_free(pos_val);
1190 return hres;
1193 static HRESULT WINAPI HTMLStyle_get_backgroundPositionY(IHTMLStyle *iface, VARIANT *p)
1195 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1196 nsAString pos_str;
1197 BSTR ret;
1198 HRESULT hres;
1200 TRACE("(%p)->(%p)\n", This, p);
1202 nsAString_Init(&pos_str, NULL);
1203 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1204 if(SUCCEEDED(hres)) {
1205 const PRUnichar *pos, *posy;
1207 nsAString_GetData(&pos_str, &pos);
1208 posy = strchrW(pos, ' ');
1209 if(posy) {
1210 ret = SysAllocString(posy+1);
1211 if(!ret)
1212 hres = E_OUTOFMEMORY;
1213 }else {
1214 ret = NULL;
1217 nsAString_Finish(&pos_str);
1218 if(FAILED(hres))
1219 return hres;
1221 TRACE("returning %s\n", debugstr_w(ret));
1222 V_VT(p) = VT_BSTR;
1223 V_BSTR(p) = ret;
1224 return S_OK;
1227 static HRESULT WINAPI HTMLStyle_put_wordSpacing(IHTMLStyle *iface, VARIANT v)
1229 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1231 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1233 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, &v, 0);
1236 static HRESULT WINAPI HTMLStyle_get_wordSpacing(IHTMLStyle *iface, VARIANT *p)
1238 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1239 TRACE("(%p)->(%p)\n", This, p);
1240 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, p, 0);
1243 static HRESULT WINAPI HTMLStyle_put_letterSpacing(IHTMLStyle *iface, VARIANT v)
1245 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1247 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1249 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, &v, 0);
1252 static HRESULT WINAPI HTMLStyle_get_letterSpacing(IHTMLStyle *iface, VARIANT *p)
1254 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1255 TRACE("(%p)->(%p)\n", This, p);
1256 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, p, 0);
1259 static HRESULT WINAPI HTMLStyle_put_textDecoration(IHTMLStyle *iface, BSTR v)
1261 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1263 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1265 /* textDecoration can only be one of the following */
1266 if(!v || strcmpiW(styleNone, v) == 0 || strcmpiW(valUnderline, v) == 0 ||
1267 strcmpiW(valOverline, v) == 0 || strcmpiW(valLineThrough, v) == 0 ||
1268 strcmpiW(valBlink, v) == 0)
1270 return set_style_attr(This, STYLEID_TEXT_DECORATION , v, 0);
1273 return E_INVALIDARG;
1276 static HRESULT WINAPI HTMLStyle_get_textDecoration(IHTMLStyle *iface, BSTR *p)
1278 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1280 TRACE("(%p)->(%p)\n", This, p);
1282 return get_style_attr(This, STYLEID_TEXT_DECORATION, p);
1285 static HRESULT WINAPI HTMLStyle_put_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL v)
1287 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1289 TRACE("(%p)->(%x)\n", This, v);
1291 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? styleNone : emptyW, 0);
1294 static HRESULT WINAPI HTMLStyle_get_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL *p)
1296 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1298 TRACE("(%p)->(%p)\n", This, p);
1300 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, styleNone, p);
1303 static HRESULT WINAPI HTMLStyle_put_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL v)
1305 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1307 TRACE("(%p)->(%x)\n", This, v);
1309 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valUnderline : emptyW, 0);
1312 static HRESULT WINAPI HTMLStyle_get_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL *p)
1314 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1316 TRACE("(%p)->(%p)\n", This, p);
1318 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valUnderline, p);
1321 static HRESULT WINAPI HTMLStyle_put_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL v)
1323 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1325 TRACE("(%p)->(%x)\n", This, v);
1327 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valOverline : emptyW, 0);
1330 static HRESULT WINAPI HTMLStyle_get_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL *p)
1332 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1334 TRACE("(%p)->(%p)\n", This, p);
1336 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valOverline, p);
1339 static HRESULT WINAPI HTMLStyle_put_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL v)
1341 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1343 TRACE("(%p)->(%x)\n", This, v);
1345 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valLineThrough : emptyW, 0);
1348 static HRESULT WINAPI HTMLStyle_get_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL *p)
1350 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1352 TRACE("(%p)->(%p)\n", This, p);
1354 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valLineThrough, p);
1357 static HRESULT WINAPI HTMLStyle_put_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL v)
1359 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1361 TRACE("(%p)->(%x)\n", This, v);
1363 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valBlink : emptyW, 0);
1366 static HRESULT WINAPI HTMLStyle_get_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL *p)
1368 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1370 TRACE("(%p)->(%p)\n", This, p);
1372 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valBlink, p);
1375 static HRESULT WINAPI HTMLStyle_put_verticalAlign(IHTMLStyle *iface, VARIANT v)
1377 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1379 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1381 return set_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, &v, ATTR_FIX_PX);
1384 static HRESULT WINAPI HTMLStyle_get_verticalAlign(IHTMLStyle *iface, VARIANT *p)
1386 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1388 TRACE("(%p)->(%p)\n", This, p);
1390 return get_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, p, 0);
1393 static HRESULT WINAPI HTMLStyle_put_textTransform(IHTMLStyle *iface, BSTR v)
1395 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1396 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1397 return E_NOTIMPL;
1400 static HRESULT WINAPI HTMLStyle_get_textTransform(IHTMLStyle *iface, BSTR *p)
1402 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1403 FIXME("(%p)->(%p)\n", This, p);
1404 return E_NOTIMPL;
1407 static HRESULT WINAPI HTMLStyle_put_textAlign(IHTMLStyle *iface, BSTR v)
1409 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1411 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1413 return set_style_attr(This, STYLEID_TEXT_ALIGN, v, 0);
1416 static HRESULT WINAPI HTMLStyle_get_textAlign(IHTMLStyle *iface, BSTR *p)
1418 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1420 TRACE("(%p)->(%p)\n", This, p);
1422 return get_style_attr(This, STYLEID_TEXT_ALIGN, p);
1425 static HRESULT WINAPI HTMLStyle_put_textIndent(IHTMLStyle *iface, VARIANT v)
1427 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1428 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1429 return E_NOTIMPL;
1432 static HRESULT WINAPI HTMLStyle_get_textIndent(IHTMLStyle *iface, VARIANT *p)
1434 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1435 FIXME("(%p)->(%p)\n", This, p);
1436 return E_NOTIMPL;
1439 static HRESULT WINAPI HTMLStyle_put_lineHeight(IHTMLStyle *iface, VARIANT v)
1441 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1442 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1443 return E_NOTIMPL;
1446 static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
1448 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1449 FIXME("(%p)->(%p)\n", This, p);
1450 return E_NOTIMPL;
1453 static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
1455 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1457 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1459 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, &v, ATTR_FIX_PX);
1462 static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
1464 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1466 TRACE("(%p)->(%p)\n", This, p);
1468 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
1471 static HRESULT WINAPI HTMLStyle_put_marginRight(IHTMLStyle *iface, VARIANT v)
1473 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1475 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1477 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, &v, ATTR_FIX_PX);
1480 static HRESULT WINAPI HTMLStyle_get_marginRight(IHTMLStyle *iface, VARIANT *p)
1482 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1483 TRACE("(%p)->(%p)\n", This, p);
1484 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
1487 static HRESULT WINAPI HTMLStyle_put_marginBottom(IHTMLStyle *iface, VARIANT v)
1489 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1491 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1493 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, &v, ATTR_FIX_PX);
1496 static HRESULT WINAPI HTMLStyle_get_marginBottom(IHTMLStyle *iface, VARIANT *p)
1498 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1500 TRACE("(%p)->(%p)\n", This, p);
1502 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, p, 0);
1505 static HRESULT WINAPI HTMLStyle_put_marginLeft(IHTMLStyle *iface, VARIANT v)
1507 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1509 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1511 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, &v, ATTR_FIX_PX);
1514 static HRESULT WINAPI HTMLStyle_put_margin(IHTMLStyle *iface, BSTR v)
1516 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1518 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1520 return set_style_attr(This, STYLEID_MARGIN, v, 0);
1523 static HRESULT WINAPI HTMLStyle_get_margin(IHTMLStyle *iface, BSTR *p)
1525 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1527 TRACE("(%p)->(%p)\n", This, p);
1529 return get_style_attr(This, STYLEID_MARGIN, p);
1532 static HRESULT WINAPI HTMLStyle_get_marginLeft(IHTMLStyle *iface, VARIANT *p)
1534 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1535 TRACE("(%p)->(%p)\n", This, p);
1536 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
1539 static HRESULT WINAPI HTMLStyle_put_paddingTop(IHTMLStyle *iface, VARIANT v)
1541 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1543 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1545 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, &v, ATTR_FIX_PX);
1548 static HRESULT WINAPI HTMLStyle_get_paddingTop(IHTMLStyle *iface, VARIANT *p)
1550 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1552 TRACE("(%p)->(%p)\n", This, p);
1554 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, p, 0);
1557 static HRESULT WINAPI HTMLStyle_put_paddingRight(IHTMLStyle *iface, VARIANT v)
1559 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1561 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1563 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, &v, ATTR_FIX_PX);
1566 static HRESULT WINAPI HTMLStyle_get_paddingRight(IHTMLStyle *iface, VARIANT *p)
1568 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1570 TRACE("(%p)->(%p)\n", This, p);
1572 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, p, 0);
1575 static HRESULT WINAPI HTMLStyle_put_paddingBottom(IHTMLStyle *iface, VARIANT v)
1577 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1579 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1581 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, &v, ATTR_FIX_PX);
1584 static HRESULT WINAPI HTMLStyle_get_paddingBottom(IHTMLStyle *iface, VARIANT *p)
1586 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1588 TRACE("(%p)->(%p)\n", This, p);
1590 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, p, 0);
1593 static HRESULT WINAPI HTMLStyle_put_paddingLeft(IHTMLStyle *iface, VARIANT v)
1595 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1597 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1599 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, &v, ATTR_FIX_PX);
1602 static HRESULT WINAPI HTMLStyle_get_paddingLeft(IHTMLStyle *iface, VARIANT *p)
1604 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1606 TRACE("(%p)->(%p)\n", This, p);
1608 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, p, 0);
1611 static HRESULT WINAPI HTMLStyle_put_padding(IHTMLStyle *iface, BSTR v)
1613 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1615 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1617 return set_style_attr(This, STYLEID_PADDING, v, 0);
1620 static HRESULT WINAPI HTMLStyle_get_padding(IHTMLStyle *iface, BSTR *p)
1622 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1624 TRACE("(%p)->(%p)\n", This, p);
1626 return get_style_attr(This, STYLEID_PADDING, p);
1629 static HRESULT WINAPI HTMLStyle_put_border(IHTMLStyle *iface, BSTR v)
1631 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1633 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1635 return set_style_attr(This, STYLEID_BORDER, v, 0);
1638 static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
1640 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1642 TRACE("(%p)->(%p)\n", This, p);
1644 return get_style_attr(This, STYLEID_BORDER, p);
1647 static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
1649 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1650 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1651 return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX);
1654 static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
1656 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1657 TRACE("(%p)->(%p)\n", This, p);
1658 return get_style_attr(This, STYLEID_BORDER_TOP, p);
1661 static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
1663 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1664 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1665 return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX);
1668 static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
1670 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1671 TRACE("(%p)->(%p)\n", This, p);
1672 return get_style_attr(This, STYLEID_BORDER_RIGHT, p);
1675 static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
1677 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1678 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1679 return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX);
1682 static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
1684 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1685 TRACE("(%p)->(%p)\n", This, p);
1686 return get_style_attr(This, STYLEID_BORDER_BOTTOM, p);
1689 static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
1691 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1693 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1695 return set_style_attr(This, STYLEID_BORDER_LEFT, v, ATTR_FIX_PX);
1698 static HRESULT WINAPI HTMLStyle_get_borderLeft(IHTMLStyle *iface, BSTR *p)
1700 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1702 TRACE("(%p)->(%p)\n", This, p);
1704 return get_style_attr(This, STYLEID_BORDER_LEFT, p);
1707 static HRESULT WINAPI HTMLStyle_put_borderColor(IHTMLStyle *iface, BSTR v)
1709 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1711 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1713 return set_style_attr(This, STYLEID_BORDER_COLOR, v, 0);
1716 static HRESULT WINAPI HTMLStyle_get_borderColor(IHTMLStyle *iface, BSTR *p)
1718 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1720 TRACE("(%p)->(%p)\n", This, p);
1722 return get_style_attr(This, STYLEID_BORDER_COLOR, p);
1725 static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v)
1727 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1729 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1731 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, &v, ATTR_HEX_INT);
1734 static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p)
1736 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1738 TRACE("(%p)->(%p)\n", This, p);
1740 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0);
1743 static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v)
1745 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1747 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1749 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, &v, ATTR_HEX_INT);
1752 static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p)
1754 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1756 TRACE("(%p)->(%p)\n", This, p);
1758 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0);
1761 static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v)
1763 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1765 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1767 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, &v, ATTR_HEX_INT);
1770 static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p)
1772 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1774 TRACE("(%p)->(%p)\n", This, p);
1776 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0);
1779 static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v)
1781 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1783 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1785 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, &v, ATTR_HEX_INT);
1788 static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p)
1790 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1792 TRACE("(%p)->(%p)\n", This, p);
1794 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0);
1797 static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v)
1799 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1800 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1801 return set_style_attr(This, STYLEID_BORDER_WIDTH, v, ATTR_FIX_PX);
1804 static HRESULT WINAPI HTMLStyle_get_borderWidth(IHTMLStyle *iface, BSTR *p)
1806 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1807 TRACE("(%p)->(%p)\n", This, p);
1808 return get_style_attr(This, STYLEID_BORDER_WIDTH, p);
1811 static HRESULT WINAPI HTMLStyle_put_borderTopWidth(IHTMLStyle *iface, VARIANT v)
1813 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1815 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1817 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, &v, 0);
1820 static HRESULT WINAPI HTMLStyle_get_borderTopWidth(IHTMLStyle *iface, VARIANT *p)
1822 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1824 TRACE("(%p)->(%p)\n", This, p);
1826 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, p, 0);
1829 static HRESULT WINAPI HTMLStyle_put_borderRightWidth(IHTMLStyle *iface, VARIANT v)
1831 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1833 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1835 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, &v, 0);
1838 static HRESULT WINAPI HTMLStyle_get_borderRightWidth(IHTMLStyle *iface, VARIANT *p)
1840 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1842 TRACE("(%p)->(%p)\n", This, p);
1844 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, p, 0);
1847 static HRESULT WINAPI HTMLStyle_put_borderBottomWidth(IHTMLStyle *iface, VARIANT v)
1849 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1851 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1853 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, &v, 0);
1856 static HRESULT WINAPI HTMLStyle_get_borderBottomWidth(IHTMLStyle *iface, VARIANT *p)
1858 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1859 TRACE("(%p)->(%p)\n", This, p);
1860 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, p, 0);
1863 static HRESULT WINAPI HTMLStyle_put_borderLeftWidth(IHTMLStyle *iface, VARIANT v)
1865 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1867 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1869 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, &v, 0);
1872 static HRESULT WINAPI HTMLStyle_get_borderLeftWidth(IHTMLStyle *iface, VARIANT *p)
1874 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1875 TRACE("(%p)->(%p)\n", This, p);
1876 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, p, 0);
1879 static HRESULT WINAPI HTMLStyle_put_borderStyle(IHTMLStyle *iface, BSTR v)
1881 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1882 static const WCHAR styleWindowInset[] = {'w','i','n','d','o','w','-','i','n','s','e','t',0};
1883 HRESULT hres = S_OK;
1884 BSTR pstyle;
1885 int i=0;
1886 int last = 0;
1888 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1890 while(v[i] && hres == S_OK)
1892 if(v[i] == (WCHAR)' ')
1894 pstyle = SysAllocStringLen(&v[last], (i-last));
1895 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1897 TRACE("1. Invalid style (%s)\n", debugstr_w(pstyle));
1898 hres = E_INVALIDARG;
1900 SysFreeString(pstyle);
1901 last = i+1;
1903 i++;
1906 if(hres == S_OK)
1908 pstyle = SysAllocStringLen(&v[last], i-last);
1909 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1911 TRACE("2. Invalid style (%s)\n", debugstr_w(pstyle));
1912 hres = E_INVALIDARG;
1914 SysFreeString(pstyle);
1917 if(hres == S_OK)
1918 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, v, 0);
1920 return hres;
1923 static HRESULT WINAPI HTMLStyle_get_borderStyle(IHTMLStyle *iface, BSTR *p)
1925 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1926 TRACE("(%p)->(%p)\n", This, p);
1927 return get_style_attr(This, STYLEID_BORDER_STYLE, p);
1930 static HRESULT WINAPI HTMLStyle_put_borderTopStyle(IHTMLStyle *iface, BSTR v)
1932 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1933 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1935 if(!is_valid_border_style(v))
1936 return E_INVALIDARG;
1938 return set_style_attr(This, STYLEID_BORDER_TOP_STYLE, v, 0);
1941 static HRESULT WINAPI HTMLStyle_get_borderTopStyle(IHTMLStyle *iface, BSTR *p)
1943 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1944 TRACE("(%p)->(%p)\n", This, p);
1945 return get_style_attr(This, STYLEID_BORDER_TOP_STYLE, p);
1948 static HRESULT WINAPI HTMLStyle_put_borderRightStyle(IHTMLStyle *iface, BSTR v)
1950 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1951 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1953 if(!is_valid_border_style(v))
1954 return E_INVALIDARG;
1956 return set_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, v, 0);
1959 static HRESULT WINAPI HTMLStyle_get_borderRightStyle(IHTMLStyle *iface, BSTR *p)
1961 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1962 TRACE("(%p)->(%p)\n", This, p);
1963 return get_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, p);
1966 static HRESULT WINAPI HTMLStyle_put_borderBottomStyle(IHTMLStyle *iface, BSTR v)
1968 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1969 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1971 if(!is_valid_border_style(v))
1972 return E_INVALIDARG;
1974 return set_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, v, 0);
1977 static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p)
1979 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1980 TRACE("(%p)->(%p)\n", This, p);
1981 return get_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, p);
1984 static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v)
1986 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1987 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1989 if(!is_valid_border_style(v))
1990 return E_INVALIDARG;
1992 return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0);
1995 static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p)
1997 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1998 TRACE("(%p)->(%p)\n", This, p);
1999 return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p);
2002 static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
2004 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2006 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2008 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX);
2011 static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
2013 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2015 TRACE("(%p)->(%p)\n", This, p);
2017 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, p, 0);
2020 static HRESULT WINAPI HTMLStyle_put_height(IHTMLStyle *iface, VARIANT v)
2022 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2024 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2026 return set_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, &v, ATTR_FIX_PX);
2029 static HRESULT WINAPI HTMLStyle_get_height(IHTMLStyle *iface, VARIANT *p)
2031 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2033 TRACE("(%p)->(%p)\n", This, p);
2035 return get_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, p, 0);
2038 static HRESULT WINAPI HTMLStyle_put_styleFloat(IHTMLStyle *iface, BSTR v)
2040 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2041 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2042 return E_NOTIMPL;
2045 static HRESULT WINAPI HTMLStyle_get_styleFloat(IHTMLStyle *iface, BSTR *p)
2047 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2048 FIXME("(%p)->(%p)\n", This, p);
2049 return E_NOTIMPL;
2052 static HRESULT WINAPI HTMLStyle_put_clear(IHTMLStyle *iface, BSTR v)
2054 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2055 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2056 return E_NOTIMPL;
2059 static HRESULT WINAPI HTMLStyle_get_clear(IHTMLStyle *iface, BSTR *p)
2061 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2062 FIXME("(%p)->(%p)\n", This, p);
2063 return E_NOTIMPL;
2066 static HRESULT WINAPI HTMLStyle_put_display(IHTMLStyle *iface, BSTR v)
2068 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2070 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2072 return set_style_attr(This, STYLEID_DISPLAY, v, 0);
2075 static HRESULT WINAPI HTMLStyle_get_display(IHTMLStyle *iface, BSTR *p)
2077 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2079 TRACE("(%p)->(%p)\n", This, p);
2081 return get_style_attr(This, STYLEID_DISPLAY, p);
2084 static HRESULT WINAPI HTMLStyle_put_visibility(IHTMLStyle *iface, BSTR v)
2086 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2088 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2090 return set_style_attr(This, STYLEID_VISIBILITY, v, 0);
2093 static HRESULT WINAPI HTMLStyle_get_visibility(IHTMLStyle *iface, BSTR *p)
2095 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2097 TRACE("(%p)->(%p)\n", This, p);
2099 return get_style_attr(This, STYLEID_VISIBILITY, p);
2102 static HRESULT WINAPI HTMLStyle_put_listStyleType(IHTMLStyle *iface, BSTR v)
2104 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2105 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2106 return E_NOTIMPL;
2109 static HRESULT WINAPI HTMLStyle_get_listStyleType(IHTMLStyle *iface, BSTR *p)
2111 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2112 FIXME("(%p)->(%p)\n", This, p);
2113 return E_NOTIMPL;
2116 static HRESULT WINAPI HTMLStyle_put_listStylePosition(IHTMLStyle *iface, BSTR v)
2118 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2119 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2120 return E_NOTIMPL;
2123 static HRESULT WINAPI HTMLStyle_get_listStylePosition(IHTMLStyle *iface, BSTR *p)
2125 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2126 FIXME("(%p)->(%p)\n", This, p);
2127 return E_NOTIMPL;
2130 static HRESULT WINAPI HTMLStyle_put_listStyleImage(IHTMLStyle *iface, BSTR v)
2132 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2133 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2134 return E_NOTIMPL;
2137 static HRESULT WINAPI HTMLStyle_get_listStyleImage(IHTMLStyle *iface, BSTR *p)
2139 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2140 FIXME("(%p)->(%p)\n", This, p);
2141 return E_NOTIMPL;
2144 static HRESULT WINAPI HTMLStyle_put_listStyle(IHTMLStyle *iface, BSTR v)
2146 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2147 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2148 return E_NOTIMPL;
2151 static HRESULT WINAPI HTMLStyle_get_listStyle(IHTMLStyle *iface, BSTR *p)
2153 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2154 FIXME("(%p)->(%p)\n", This, p);
2155 return E_NOTIMPL;
2158 static HRESULT WINAPI HTMLStyle_put_whiteSpace(IHTMLStyle *iface, BSTR v)
2160 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2161 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2162 return E_NOTIMPL;
2165 static HRESULT WINAPI HTMLStyle_get_whiteSpace(IHTMLStyle *iface, BSTR *p)
2167 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2168 FIXME("(%p)->(%p)\n", This, p);
2169 return E_NOTIMPL;
2172 static HRESULT WINAPI HTMLStyle_put_top(IHTMLStyle *iface, VARIANT v)
2174 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2176 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2178 return set_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, &v, 0);
2181 static HRESULT WINAPI HTMLStyle_get_top(IHTMLStyle *iface, VARIANT *p)
2183 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2185 TRACE("(%p)->(%p)\n", This, p);
2187 return get_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, p, 0);
2190 static HRESULT WINAPI HTMLStyle_put_left(IHTMLStyle *iface, VARIANT v)
2192 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2194 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2196 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, &v, 0);
2199 static HRESULT WINAPI HTMLStyle_get_left(IHTMLStyle *iface, VARIANT *p)
2201 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2203 TRACE("(%p)->(%p)\n", This, p);
2205 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, p, 0);
2208 static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
2210 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2211 TRACE("(%p)->(%p)\n", This, p);
2212 return IHTMLStyle2_get_position(&This->IHTMLStyle2_iface, p);
2215 static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
2217 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2219 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2221 return set_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, &v, 0);
2224 static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
2226 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2228 TRACE("(%p)->(%p)\n", This, p);
2230 return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
2233 static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
2235 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2236 static const WCHAR szVisible[] = {'v','i','s','i','b','l','e',0};
2237 static const WCHAR szScroll[] = {'s','c','r','o','l','l',0};
2238 static const WCHAR szHidden[] = {'h','i','d','d','e','n',0};
2239 static const WCHAR szAuto[] = {'a','u','t','o',0};
2241 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2243 /* overflow can only be one of the follow values. */
2244 if(!v || !*v || strcmpiW(szVisible, v) == 0 || strcmpiW(szScroll, v) == 0 ||
2245 strcmpiW(szHidden, v) == 0 || strcmpiW(szAuto, v) == 0)
2247 return set_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, v, 0);
2250 return E_INVALIDARG;
2254 static HRESULT WINAPI HTMLStyle_get_overflow(IHTMLStyle *iface, BSTR *p)
2256 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2258 TRACE("(%p)->(%p)\n", This, p);
2260 if(!p)
2261 return E_INVALIDARG;
2263 return get_style_attr(This, STYLEID_OVERFLOW, p);
2266 static HRESULT WINAPI HTMLStyle_put_pageBreakBefore(IHTMLStyle *iface, BSTR v)
2268 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2270 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2272 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, v, 0);
2275 static HRESULT WINAPI HTMLStyle_get_pageBreakBefore(IHTMLStyle *iface, BSTR *p)
2277 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2279 TRACE("(%p)->(%p)\n", This, p);
2281 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, p, 0);
2284 static HRESULT WINAPI HTMLStyle_put_pageBreakAfter(IHTMLStyle *iface, BSTR v)
2286 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2288 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2290 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, v, 0);
2293 static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p)
2295 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2297 TRACE("(%p)->(%p)\n", This, p);
2299 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, p, 0);
2302 static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
2304 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2305 nsAString text_str;
2306 nsresult nsres;
2308 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2310 nsAString_InitDepend(&text_str, v);
2311 nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str);
2312 nsAString_Finish(&text_str);
2313 if(NS_FAILED(nsres)) {
2314 FIXME("SetCssStyle failed: %08x\n", nsres);
2315 return E_FAIL;
2318 return S_OK;
2321 static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p)
2323 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2324 nsAString text_str;
2325 nsresult nsres;
2327 TRACE("(%p)->(%p)\n", This, p);
2329 /* FIXME: Gecko style formatting is different than IE (uppercase). */
2330 nsAString_Init(&text_str, NULL);
2331 nsres = nsIDOMCSSStyleDeclaration_GetCssText(This->nsstyle, &text_str);
2332 if(NS_SUCCEEDED(nsres)) {
2333 const PRUnichar *text;
2335 nsAString_GetData(&text_str, &text);
2336 *p = *text ? SysAllocString(text) : NULL;
2337 }else {
2338 FIXME("GetCssStyle failed: %08x\n", nsres);
2339 *p = NULL;
2342 nsAString_Finish(&text_str);
2343 return S_OK;
2346 static HRESULT WINAPI HTMLStyle_put_pixelTop(IHTMLStyle *iface, LONG v)
2348 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2349 FIXME("(%p)->()\n", This);
2350 return E_NOTIMPL;
2353 static HRESULT WINAPI HTMLStyle_get_pixelTop(IHTMLStyle *iface, LONG *p)
2355 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2356 FIXME("(%p)->()\n", This);
2357 return E_NOTIMPL;
2360 static HRESULT WINAPI HTMLStyle_put_pixelLeft(IHTMLStyle *iface, LONG v)
2362 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2363 FIXME("(%p)->()\n", This);
2364 return E_NOTIMPL;
2367 static HRESULT WINAPI HTMLStyle_get_pixelLeft(IHTMLStyle *iface, LONG *p)
2369 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2370 FIXME("(%p)->()\n", This);
2371 return E_NOTIMPL;
2374 static HRESULT WINAPI HTMLStyle_put_pixelWidth(IHTMLStyle *iface, LONG v)
2376 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2377 FIXME("(%p)->()\n", This);
2378 return E_NOTIMPL;
2381 static HRESULT WINAPI HTMLStyle_get_pixelWidth(IHTMLStyle *iface, LONG *p)
2383 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2384 FIXME("(%p)->()\n", This);
2385 return E_NOTIMPL;
2388 static HRESULT WINAPI HTMLStyle_put_pixelHeight(IHTMLStyle *iface, LONG v)
2390 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2391 FIXME("(%p)->()\n", This);
2392 return E_NOTIMPL;
2395 static HRESULT WINAPI HTMLStyle_get_pixelHeight(IHTMLStyle *iface, LONG *p)
2397 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2398 FIXME("(%p)->()\n", This);
2399 return E_NOTIMPL;
2402 static HRESULT WINAPI HTMLStyle_put_posTop(IHTMLStyle *iface, float v)
2404 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2406 TRACE("(%p)->(%f)\n", This, v);
2408 return set_style_pos(This, STYLEID_TOP, v);
2411 static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
2413 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2415 TRACE("(%p)->(%p)\n", This, p);
2417 if(!p)
2418 return E_POINTER;
2420 return get_nsstyle_pos(This, STYLEID_TOP, p);
2423 static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
2425 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2427 TRACE("(%p)->(%f)\n", This, v);
2429 return set_style_pos(This, STYLEID_LEFT, v);
2432 static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
2434 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2436 TRACE("(%p)->(%p)\n", This, p);
2438 if(!p)
2439 return E_POINTER;
2441 return get_nsstyle_pos(This, STYLEID_LEFT, p);
2444 static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
2446 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2448 TRACE("(%p)->(%f)\n", This, v);
2450 return set_style_pos(This, STYLEID_WIDTH, v);
2453 static HRESULT WINAPI HTMLStyle_get_posWidth(IHTMLStyle *iface, float *p)
2455 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2457 TRACE("(%p)->(%p)\n", This, p);
2459 if(!p)
2460 return E_POINTER;
2462 if(get_nsstyle_pos(This, STYLEID_WIDTH, p) != S_OK)
2463 *p = 0.0f;
2465 return S_OK;
2468 static HRESULT WINAPI HTMLStyle_put_posHeight(IHTMLStyle *iface, float v)
2470 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2472 TRACE("(%p)->(%f)\n", This, v);
2474 return set_style_pos(This, STYLEID_HEIGHT, v);
2477 static HRESULT WINAPI HTMLStyle_get_posHeight(IHTMLStyle *iface, float *p)
2479 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2481 TRACE("(%p)->(%p)\n", This, p);
2483 if(!p)
2484 return E_POINTER;
2486 if(get_nsstyle_pos(This, STYLEID_HEIGHT, p) != S_OK)
2487 *p = 0.0f;
2489 return S_OK;
2492 static HRESULT WINAPI HTMLStyle_put_cursor(IHTMLStyle *iface, BSTR v)
2494 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2496 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2498 return set_style_attr(This, STYLEID_CURSOR, v, 0);
2501 static HRESULT WINAPI HTMLStyle_get_cursor(IHTMLStyle *iface, BSTR *p)
2503 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2505 TRACE("(%p)->(%p)\n", This, p);
2507 return get_style_attr(This, STYLEID_CURSOR, p);
2510 static HRESULT WINAPI HTMLStyle_put_clip(IHTMLStyle *iface, BSTR v)
2512 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2514 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2516 return set_style_attr(This, STYLEID_CLIP, v, 0);
2519 static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
2521 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2523 TRACE("(%p)->(%p)\n", This, p);
2525 return get_nsstyle_attr(This->nsstyle, STYLEID_CLIP, p, ATTR_REMOVE_COMMA);
2528 static void set_opacity(HTMLStyle *This, const WCHAR *val)
2530 nsAString name_str, val_str, empty_str;
2531 nsresult nsres;
2533 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y',0};
2535 TRACE("%s\n", debugstr_w(val));
2537 nsAString_InitDepend(&name_str, opacityW);
2538 nsAString_InitDepend(&val_str, val);
2539 nsAString_InitDepend(&empty_str, emptyW);
2541 nsres = nsIDOMCSSStyleDeclaration_SetProperty(This->nsstyle, &name_str, &val_str, &empty_str);
2542 if(NS_FAILED(nsres))
2543 ERR("SetProperty failed: %08x\n", nsres);
2545 nsAString_Finish(&name_str);
2546 nsAString_Finish(&val_str);
2547 nsAString_Finish(&empty_str);
2550 static void update_filter(HTMLStyle *This)
2552 const WCHAR *ptr = This->elem->filter, *ptr2;
2554 static const WCHAR alphaW[] = {'a','l','p','h','a'};
2556 if(!ptr) {
2557 set_opacity(This, emptyW);
2558 return;
2561 while(1) {
2562 while(isspaceW(*ptr))
2563 ptr++;
2564 if(!*ptr)
2565 break;
2567 ptr2 = ptr;
2568 while(isalnumW(*ptr))
2569 ptr++;
2570 if(ptr == ptr2) {
2571 WARN("unexpected char '%c'\n", *ptr);
2572 break;
2574 if(*ptr != '(') {
2575 WARN("expected '('\n");
2576 continue;
2579 if(ptr2 + sizeof(alphaW)/sizeof(WCHAR) == ptr && !memcmp(ptr2, alphaW, sizeof(alphaW))) {
2580 static const WCHAR formatW[] = {'%','f',0};
2581 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y','='};
2583 ptr++;
2584 do {
2585 while(isspaceW(*ptr))
2586 ptr++;
2588 ptr2 = ptr;
2589 while(*ptr && *ptr != ',' && *ptr != ')')
2590 ptr++;
2591 if(!*ptr) {
2592 WARN("unexpected end of string\n");
2593 break;
2596 if(ptr-ptr2 > sizeof(opacityW)/sizeof(WCHAR) && !memcmp(ptr2, opacityW, sizeof(opacityW))) {
2597 float fval = 0.0f, e = 0.1f;
2598 WCHAR buf[32];
2600 ptr2 += sizeof(opacityW)/sizeof(WCHAR);
2602 while(isdigitW(*ptr2))
2603 fval = fval*10.0f + (float)(*ptr2++ - '0');
2605 if(*ptr2 == '.') {
2606 while(isdigitW(*++ptr2)) {
2607 fval += e * (float)(*ptr2++ - '0');
2608 e *= 0.1f;
2612 sprintfW(buf, formatW, fval * 0.01f);
2613 set_opacity(This, buf);
2614 }else {
2615 FIXME("unknown param %s\n", debugstr_wn(ptr2, ptr-ptr2));
2618 if(*ptr == ',')
2619 ptr++;
2620 }while(*ptr != ')');
2621 }else {
2622 FIXME("unknown filter %s\n", debugstr_wn(ptr2, ptr-ptr2));
2623 ptr = strchrW(ptr, ')');
2624 if(!ptr)
2625 break;
2626 ptr++;
2631 static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
2633 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2634 WCHAR *new_filter = NULL;
2636 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2638 if(!This->elem) {
2639 FIXME("Element already destroyed\n");
2640 return E_UNEXPECTED;
2643 if(v) {
2644 new_filter = heap_strdupW(v);
2645 if(!new_filter)
2646 return E_OUTOFMEMORY;
2649 heap_free(This->elem->filter);
2650 This->elem->filter = new_filter;
2652 update_filter(This);
2653 return S_OK;
2656 static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
2658 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2660 TRACE("(%p)->(%p)\n", This, p);
2662 if(!This->elem) {
2663 FIXME("Element already destroyed\n");
2664 return E_UNEXPECTED;
2667 if(This->elem->filter) {
2668 *p = SysAllocString(This->elem->filter);
2669 if(!*p)
2670 return E_OUTOFMEMORY;
2671 }else {
2672 *p = NULL;
2675 return S_OK;
2678 static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2679 VARIANT AttributeValue, LONG lFlags)
2681 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2682 HRESULT hres;
2683 DISPID dispid;
2685 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName),
2686 debugstr_variant(&AttributeValue), lFlags);
2688 if(!strAttributeName)
2689 return E_INVALIDARG;
2691 if(lFlags == 1)
2692 FIXME("Parameter lFlags ignored\n");
2694 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2695 LOCALE_USER_DEFAULT, &dispid);
2696 if(hres == S_OK)
2698 VARIANT ret;
2699 DISPID dispidNamed = DISPID_PROPERTYPUT;
2700 DISPPARAMS params;
2702 params.cArgs = 1;
2703 params.rgvarg = &AttributeValue;
2704 params.cNamedArgs = 1;
2705 params.rgdispidNamedArgs = &dispidNamed;
2707 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2708 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2710 else
2712 FIXME("Custom attributes not supported.\n");
2715 TRACE("ret: %08x\n", hres);
2717 return hres;
2720 static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2721 LONG lFlags, VARIANT *AttributeValue)
2723 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2724 HRESULT hres;
2725 DISPID dispid;
2727 TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName),
2728 AttributeValue, lFlags);
2730 if(!AttributeValue || !strAttributeName)
2731 return E_INVALIDARG;
2733 if(lFlags == 1)
2734 FIXME("Parameter lFlags ignored\n");
2736 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2737 LOCALE_USER_DEFAULT, &dispid);
2738 if(hres == S_OK)
2740 DISPPARAMS params = {NULL, NULL, 0, 0 };
2742 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2743 DISPATCH_PROPERTYGET, &params, AttributeValue, NULL, NULL);
2745 else
2747 FIXME("Custom attributes not supported.\n");
2750 return hres;
2753 static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2754 LONG lFlags, VARIANT_BOOL *pfSuccess)
2756 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2757 const style_tbl_entry_t *style_entry;
2758 nsAString name_str, ret_str;
2759 nsresult nsres;
2760 HRESULT hres;
2762 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
2764 style_entry = lookup_style_tbl(strAttributeName);
2765 if(!style_entry) {
2766 DISPID dispid;
2767 unsigned i;
2769 hres = IDispatchEx_GetDispID(&This->dispex.IDispatchEx_iface, strAttributeName,
2770 (lFlags&1) ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
2771 if(hres != S_OK) {
2772 *pfSuccess = VARIANT_FALSE;
2773 return S_OK;
2776 for(i=0; i < sizeof(style_tbl)/sizeof(*style_tbl); i++) {
2777 if(dispid == style_tbl[i].dispid)
2778 break;
2781 if(i == sizeof(style_tbl)/sizeof(*style_tbl))
2782 return remove_prop(&This->dispex, strAttributeName, pfSuccess);
2783 style_entry = style_tbl+i;
2786 /* filter property is a special case */
2787 if(style_entry->dispid == DISPID_IHTMLSTYLE_FILTER) {
2788 *pfSuccess = This->elem->filter && *This->elem->filter ? VARIANT_TRUE : VARIANT_FALSE;
2789 heap_free(This->elem->filter);
2790 This->elem->filter = NULL;
2791 update_filter(This);
2792 return S_OK;
2795 nsAString_InitDepend(&name_str, style_entry->name);
2796 nsAString_Init(&ret_str, NULL);
2797 nsres = nsIDOMCSSStyleDeclaration_RemoveProperty(This->nsstyle, &name_str, &ret_str);
2798 if(NS_SUCCEEDED(nsres)) {
2799 const PRUnichar *ret;
2800 nsAString_GetData(&ret_str, &ret);
2801 *pfSuccess = *ret ? VARIANT_TRUE : VARIANT_FALSE;
2802 }else {
2803 ERR("RemoveProperty failed: %08x\n", nsres);
2805 nsAString_Finish(&name_str);
2806 nsAString_Finish(&ret_str);
2807 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
2810 static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
2812 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2813 FIXME("(%p)->(%p)\n", This, String);
2814 return E_NOTIMPL;
2817 static const IHTMLStyleVtbl HTMLStyleVtbl = {
2818 HTMLStyle_QueryInterface,
2819 HTMLStyle_AddRef,
2820 HTMLStyle_Release,
2821 HTMLStyle_GetTypeInfoCount,
2822 HTMLStyle_GetTypeInfo,
2823 HTMLStyle_GetIDsOfNames,
2824 HTMLStyle_Invoke,
2825 HTMLStyle_put_fontFamily,
2826 HTMLStyle_get_fontFamily,
2827 HTMLStyle_put_fontStyle,
2828 HTMLStyle_get_fontStyle,
2829 HTMLStyle_put_fontVariant,
2830 HTMLStyle_get_fontVariant,
2831 HTMLStyle_put_fontWeight,
2832 HTMLStyle_get_fontWeight,
2833 HTMLStyle_put_fontSize,
2834 HTMLStyle_get_fontSize,
2835 HTMLStyle_put_font,
2836 HTMLStyle_get_font,
2837 HTMLStyle_put_color,
2838 HTMLStyle_get_color,
2839 HTMLStyle_put_background,
2840 HTMLStyle_get_background,
2841 HTMLStyle_put_backgroundColor,
2842 HTMLStyle_get_backgroundColor,
2843 HTMLStyle_put_backgroundImage,
2844 HTMLStyle_get_backgroundImage,
2845 HTMLStyle_put_backgroundRepeat,
2846 HTMLStyle_get_backgroundRepeat,
2847 HTMLStyle_put_backgroundAttachment,
2848 HTMLStyle_get_backgroundAttachment,
2849 HTMLStyle_put_backgroundPosition,
2850 HTMLStyle_get_backgroundPosition,
2851 HTMLStyle_put_backgroundPositionX,
2852 HTMLStyle_get_backgroundPositionX,
2853 HTMLStyle_put_backgroundPositionY,
2854 HTMLStyle_get_backgroundPositionY,
2855 HTMLStyle_put_wordSpacing,
2856 HTMLStyle_get_wordSpacing,
2857 HTMLStyle_put_letterSpacing,
2858 HTMLStyle_get_letterSpacing,
2859 HTMLStyle_put_textDecoration,
2860 HTMLStyle_get_textDecoration,
2861 HTMLStyle_put_textDecorationNone,
2862 HTMLStyle_get_textDecorationNone,
2863 HTMLStyle_put_textDecorationUnderline,
2864 HTMLStyle_get_textDecorationUnderline,
2865 HTMLStyle_put_textDecorationOverline,
2866 HTMLStyle_get_textDecorationOverline,
2867 HTMLStyle_put_textDecorationLineThrough,
2868 HTMLStyle_get_textDecorationLineThrough,
2869 HTMLStyle_put_textDecorationBlink,
2870 HTMLStyle_get_textDecorationBlink,
2871 HTMLStyle_put_verticalAlign,
2872 HTMLStyle_get_verticalAlign,
2873 HTMLStyle_put_textTransform,
2874 HTMLStyle_get_textTransform,
2875 HTMLStyle_put_textAlign,
2876 HTMLStyle_get_textAlign,
2877 HTMLStyle_put_textIndent,
2878 HTMLStyle_get_textIndent,
2879 HTMLStyle_put_lineHeight,
2880 HTMLStyle_get_lineHeight,
2881 HTMLStyle_put_marginTop,
2882 HTMLStyle_get_marginTop,
2883 HTMLStyle_put_marginRight,
2884 HTMLStyle_get_marginRight,
2885 HTMLStyle_put_marginBottom,
2886 HTMLStyle_get_marginBottom,
2887 HTMLStyle_put_marginLeft,
2888 HTMLStyle_get_marginLeft,
2889 HTMLStyle_put_margin,
2890 HTMLStyle_get_margin,
2891 HTMLStyle_put_paddingTop,
2892 HTMLStyle_get_paddingTop,
2893 HTMLStyle_put_paddingRight,
2894 HTMLStyle_get_paddingRight,
2895 HTMLStyle_put_paddingBottom,
2896 HTMLStyle_get_paddingBottom,
2897 HTMLStyle_put_paddingLeft,
2898 HTMLStyle_get_paddingLeft,
2899 HTMLStyle_put_padding,
2900 HTMLStyle_get_padding,
2901 HTMLStyle_put_border,
2902 HTMLStyle_get_border,
2903 HTMLStyle_put_borderTop,
2904 HTMLStyle_get_borderTop,
2905 HTMLStyle_put_borderRight,
2906 HTMLStyle_get_borderRight,
2907 HTMLStyle_put_borderBottom,
2908 HTMLStyle_get_borderBottom,
2909 HTMLStyle_put_borderLeft,
2910 HTMLStyle_get_borderLeft,
2911 HTMLStyle_put_borderColor,
2912 HTMLStyle_get_borderColor,
2913 HTMLStyle_put_borderTopColor,
2914 HTMLStyle_get_borderTopColor,
2915 HTMLStyle_put_borderRightColor,
2916 HTMLStyle_get_borderRightColor,
2917 HTMLStyle_put_borderBottomColor,
2918 HTMLStyle_get_borderBottomColor,
2919 HTMLStyle_put_borderLeftColor,
2920 HTMLStyle_get_borderLeftColor,
2921 HTMLStyle_put_borderWidth,
2922 HTMLStyle_get_borderWidth,
2923 HTMLStyle_put_borderTopWidth,
2924 HTMLStyle_get_borderTopWidth,
2925 HTMLStyle_put_borderRightWidth,
2926 HTMLStyle_get_borderRightWidth,
2927 HTMLStyle_put_borderBottomWidth,
2928 HTMLStyle_get_borderBottomWidth,
2929 HTMLStyle_put_borderLeftWidth,
2930 HTMLStyle_get_borderLeftWidth,
2931 HTMLStyle_put_borderStyle,
2932 HTMLStyle_get_borderStyle,
2933 HTMLStyle_put_borderTopStyle,
2934 HTMLStyle_get_borderTopStyle,
2935 HTMLStyle_put_borderRightStyle,
2936 HTMLStyle_get_borderRightStyle,
2937 HTMLStyle_put_borderBottomStyle,
2938 HTMLStyle_get_borderBottomStyle,
2939 HTMLStyle_put_borderLeftStyle,
2940 HTMLStyle_get_borderLeftStyle,
2941 HTMLStyle_put_width,
2942 HTMLStyle_get_width,
2943 HTMLStyle_put_height,
2944 HTMLStyle_get_height,
2945 HTMLStyle_put_styleFloat,
2946 HTMLStyle_get_styleFloat,
2947 HTMLStyle_put_clear,
2948 HTMLStyle_get_clear,
2949 HTMLStyle_put_display,
2950 HTMLStyle_get_display,
2951 HTMLStyle_put_visibility,
2952 HTMLStyle_get_visibility,
2953 HTMLStyle_put_listStyleType,
2954 HTMLStyle_get_listStyleType,
2955 HTMLStyle_put_listStylePosition,
2956 HTMLStyle_get_listStylePosition,
2957 HTMLStyle_put_listStyleImage,
2958 HTMLStyle_get_listStyleImage,
2959 HTMLStyle_put_listStyle,
2960 HTMLStyle_get_listStyle,
2961 HTMLStyle_put_whiteSpace,
2962 HTMLStyle_get_whiteSpace,
2963 HTMLStyle_put_top,
2964 HTMLStyle_get_top,
2965 HTMLStyle_put_left,
2966 HTMLStyle_get_left,
2967 HTMLStyle_get_position,
2968 HTMLStyle_put_zIndex,
2969 HTMLStyle_get_zIndex,
2970 HTMLStyle_put_overflow,
2971 HTMLStyle_get_overflow,
2972 HTMLStyle_put_pageBreakBefore,
2973 HTMLStyle_get_pageBreakBefore,
2974 HTMLStyle_put_pageBreakAfter,
2975 HTMLStyle_get_pageBreakAfter,
2976 HTMLStyle_put_cssText,
2977 HTMLStyle_get_cssText,
2978 HTMLStyle_put_pixelTop,
2979 HTMLStyle_get_pixelTop,
2980 HTMLStyle_put_pixelLeft,
2981 HTMLStyle_get_pixelLeft,
2982 HTMLStyle_put_pixelWidth,
2983 HTMLStyle_get_pixelWidth,
2984 HTMLStyle_put_pixelHeight,
2985 HTMLStyle_get_pixelHeight,
2986 HTMLStyle_put_posTop,
2987 HTMLStyle_get_posTop,
2988 HTMLStyle_put_posLeft,
2989 HTMLStyle_get_posLeft,
2990 HTMLStyle_put_posWidth,
2991 HTMLStyle_get_posWidth,
2992 HTMLStyle_put_posHeight,
2993 HTMLStyle_get_posHeight,
2994 HTMLStyle_put_cursor,
2995 HTMLStyle_get_cursor,
2996 HTMLStyle_put_clip,
2997 HTMLStyle_get_clip,
2998 HTMLStyle_put_filter,
2999 HTMLStyle_get_filter,
3000 HTMLStyle_setAttribute,
3001 HTMLStyle_getAttribute,
3002 HTMLStyle_removeAttribute,
3003 HTMLStyle_toString
3006 static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
3008 const style_tbl_entry_t *style_entry;
3010 style_entry = lookup_style_tbl(name);
3011 if(style_entry) {
3012 *dispid = style_entry->dispid;
3013 return S_OK;
3016 return DISP_E_UNKNOWNNAME;
3019 static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
3020 NULL,
3021 HTMLStyle_get_dispid,
3022 NULL,
3023 NULL
3026 static const tid_t HTMLStyle_iface_tids[] = {
3027 IHTMLStyle_tid,
3028 IHTMLStyle2_tid,
3029 IHTMLStyle3_tid,
3030 IHTMLStyle4_tid,
3031 IHTMLStyle5_tid,
3032 IHTMLStyle6_tid,
3035 static dispex_static_data_t HTMLStyle_dispex = {
3036 &HTMLStyle_dispex_vtbl,
3037 DispHTMLStyle_tid,
3038 NULL,
3039 HTMLStyle_iface_tids
3042 HRESULT HTMLStyle_Create(HTMLElement *elem, nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
3044 HTMLStyle *style;
3046 style = heap_alloc_zero(sizeof(HTMLStyle));
3047 if(!style)
3048 return E_OUTOFMEMORY;
3050 style->IHTMLStyle_iface.lpVtbl = &HTMLStyleVtbl;
3051 style->ref = 1;
3052 style->nsstyle = nsstyle;
3053 style->elem = elem;
3054 HTMLStyle2_Init(style);
3055 HTMLStyle3_Init(style);
3057 nsIDOMCSSStyleDeclaration_AddRef(nsstyle);
3059 init_dispex(&style->dispex, (IUnknown*)&style->IHTMLStyle_iface, &HTMLStyle_dispex);
3061 *ret = style;
3062 return S_OK;