mshtml: Properly handle NULL value in set_nsstyle_attr.
[wine.git] / dlls / mshtml / htmlstyle.c
blob95d7a889c7c3ffca54e062cb70a6d5fea8bcc835
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 <assert.h>
21 #include <math.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "mshtmdid.h"
31 #include "mshtml_private.h"
32 #include "htmlstyle.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 static const WCHAR attrBackground[] =
39 {'b','a','c','k','g','r','o','u','n','d',0};
40 static const WCHAR attrBackgroundColor[] =
41 {'b','a','c','k','g','r','o','u','n','d','-','c','o','l','o','r',0};
42 static const WCHAR attrBackgroundImage[] =
43 {'b','a','c','k','g','r','o','u','n','d','-','i','m','a','g','e',0};
44 static const WCHAR attrBackgroundPosition[] =
45 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n',0};
46 static const WCHAR attrBackgroundPositionX[] =
47 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','x',0};
48 static const WCHAR attrBackgroundPositionY[] =
49 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','y',0};
50 static const WCHAR attrBackgroundRepeat[] =
51 {'b','a','c','k','g','r','o','u','n','d','-','r','e','p','e','a','t',0};
52 static const WCHAR attrBorder[] =
53 {'b','o','r','d','e','r',0};
54 static const WCHAR attrBorderBottom[] =
55 {'b','o','r','d','e','r','-','b','o','t','t','o','m',0};
56 static const WCHAR attrBorderBottomColor[] =
57 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','c','o','l','o','r',0};
58 static const WCHAR attrBorderBottomStyle[] =
59 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','s','t','y','l','e',0};
60 static const WCHAR attrBorderBottomWidth[] =
61 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','w','i','d','t','h',0};
62 static const WCHAR attrBorderColor[] =
63 {'b','o','r','d','e','r','-','c','o','l','o','r',0};
64 static const WCHAR attrBorderLeft[] =
65 {'b','o','r','d','e','r','-','l','e','f','t',0};
66 static const WCHAR attrBorderLeftColor[] =
67 {'b','o','r','d','e','r','-','l','e','f','t','-','c','o','l','o','r',0};
68 static const WCHAR attrBorderLeftStyle[] =
69 {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0};
70 static const WCHAR attrBorderLeftWidth[] =
71 {'b','o','r','d','e','r','-','l','e','f','t','-','w','i','d','t','h',0};
72 static const WCHAR attrBorderRight[] =
73 {'b','o','r','d','e','r','-','r','i','g','h','t',0};
74 static const WCHAR attrBorderRightColor[] =
75 {'b','o','r','d','e','r','-','r','i','g','h','t','-','c','o','l','o','r',0};
76 static const WCHAR attrBorderRightStyle[] =
77 {'b','o','r','d','e','r','-','r','i','g','h','t','-','s','t','y','l','e',0};
78 static const WCHAR attrBorderRightWidth[] =
79 {'b','o','r','d','e','r','-','r','i','g','h','t','-','w','i','d','t','h',0};
80 static const WCHAR attrBorderTop[] =
81 {'b','o','r','d','e','r','-','t','o','p',0};
82 static const WCHAR attrBorderTopColor[] =
83 {'b','o','r','d','e','r','-','t','o','p','-','c','o','l','o','r',0};
84 static const WCHAR attrBorderStyle[] =
85 {'b','o','r','d','e','r','-','s','t','y','l','e',0};
86 static const WCHAR attrBorderTopStyle[] =
87 {'b','o','r','d','e','r','-','t','o','p','-','s','t','y','l','e',0};
88 static const WCHAR attrBorderTopWidth[] =
89 {'b','o','r','d','e','r','-','t','o','p','-','w','i','d','t','h',0};
90 static const WCHAR attrBorderWidth[] =
91 {'b','o','r','d','e','r','-','w','i','d','t','h',0};
92 static const WCHAR attrBottom[] =
93 {'b','o','t','t','o','m',0};
94 static const WCHAR attrClear[] =
95 {'c','l','e','a','r',0};
96 static const WCHAR attrClip[] =
97 {'c','l','i','p',0};
98 static const WCHAR attrColor[] =
99 {'c','o','l','o','r',0};
100 static const WCHAR attrCursor[] =
101 {'c','u','r','s','o','r',0};
102 static const WCHAR attrDirection[] =
103 {'d','i','r','e','c','t','i','o','n',0};
104 static const WCHAR attrDisplay[] =
105 {'d','i','s','p','l','a','y',0};
106 static const WCHAR attrFilter[] =
107 {'f','i','l','e','t','e','r',0};
108 static const WCHAR attrFontFamily[] =
109 {'f','o','n','t','-','f','a','m','i','l','y',0};
110 static const WCHAR attrFontSize[] =
111 {'f','o','n','t','-','s','i','z','e',0};
112 static const WCHAR attrFontStyle[] =
113 {'f','o','n','t','-','s','t','y','l','e',0};
114 static const WCHAR attrFontVariant[] =
115 {'f','o','n','t','-','v','a','r','i','a','n','t',0};
116 static const WCHAR attrFontWeight[] =
117 {'f','o','n','t','-','w','e','i','g','h','t',0};
118 static const WCHAR attrHeight[] =
119 {'h','e','i','g','h','t',0};
120 static const WCHAR attrLeft[] =
121 {'l','e','f','t',0};
122 static const WCHAR attrLetterSpacing[] =
123 {'l','e','t','t','e','r','-','s','p','a','c','i','n','g',0};
124 static const WCHAR attrLineHeight[] =
125 {'l','i','n','e','-','h','e','i','g','h','t',0};
126 static const WCHAR attrMargin[] =
127 {'m','a','r','g','i','n',0};
128 static const WCHAR attrMarginBottom[] =
129 {'m','a','r','g','i','n','-','b','o','t','t','o','m',0};
130 static const WCHAR attrMarginLeft[] =
131 {'m','a','r','g','i','n','-','l','e','f','t',0};
132 static const WCHAR attrMarginRight[] =
133 {'m','a','r','g','i','n','-','r','i','g','h','t',0};
134 static const WCHAR attrMarginTop[] =
135 {'m','a','r','g','i','n','-','t','o','p',0};
136 static const WCHAR attrMinHeight[] =
137 {'m','i','n','-','h','e','i','g','h','t',0};
138 static const WCHAR attrOverflow[] =
139 {'o','v','e','r','f','l','o','w',0};
140 static const WCHAR attrOverflowX[] =
141 {'o','v','e','r','f','l','o','w','-','x',0};
142 static const WCHAR attrOverflowY[] =
143 {'o','v','e','r','f','l','o','w','-','y',0};
144 static const WCHAR attrPadding[] =
145 {'p','a','d','d','i','n','g',0};
146 static const WCHAR attrPaddingBottom[] =
147 {'p','a','d','d','i','n','g','-','b','o','t','t','o','m',0};
148 static const WCHAR attrPaddingLeft[] =
149 {'p','a','d','d','i','n','g','-','l','e','f','t',0};
150 static const WCHAR attrPaddingRight[] =
151 {'p','a','d','d','i','n','g','-','r','i','g','h','t',0};
152 static const WCHAR attrPaddingTop[] =
153 {'p','a','d','d','i','n','g','-','t','o','p',0};
154 static const WCHAR attrPageBreakAfter[] =
155 {'p','a','g','e','-','b','r','e','a','k','-','a','f','t','e','r',0};
156 static const WCHAR attrPageBreakBefore[] =
157 {'p','a','g','e','-','b','r','e','a','k','-','b','e','f','o','r','e',0};
158 static const WCHAR attrPosition[] =
159 {'p','o','s','i','t','i','o','n',0};
160 static const WCHAR attrRight[] =
161 {'r','i','g','h','t',0};
162 static const WCHAR attrTextAlign[] =
163 {'t','e','x','t','-','a','l','i','g','n',0};
164 static const WCHAR attrTextDecoration[] =
165 {'t','e','x','t','-','d','e','c','o','r','a','t','i','o','n',0};
166 static const WCHAR attrTextIndent[] =
167 {'t','e','x','t','-','i','n','d','e','n','t',0};
168 static const WCHAR attrTop[] =
169 {'t','o','p',0};
170 static const WCHAR attrVerticalAlign[] =
171 {'v','e','r','t','i','c','a','l','-','a','l','i','g','n',0};
172 static const WCHAR attrVisibility[] =
173 {'v','i','s','i','b','i','l','i','t','y',0};
174 static const WCHAR attrWidth[] =
175 {'w','i','d','t','h',0};
176 static const WCHAR attrWordSpacing[] =
177 {'w','o','r','d','-','s','p','a','c','i','n','g',0};
178 static const WCHAR attrWordWrap[] =
179 {'w','o','r','d','-','w','r','a','p',0};
180 static const WCHAR attrZIndex[] =
181 {'z','-','i','n','d','e','x',0};
183 typedef struct {
184 const WCHAR *name;
185 DISPID dispid;
186 } style_tbl_entry_t;
188 static const style_tbl_entry_t style_tbl[] = {
189 {attrBackground, DISPID_IHTMLSTYLE_BACKGROUND},
190 {attrBackgroundColor, DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
191 {attrBackgroundImage, DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
192 {attrBackgroundPosition, DISPID_IHTMLSTYLE_BACKGROUNDPOSITION},
193 {attrBackgroundPositionX, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONX},
194 {attrBackgroundPositionY, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
195 {attrBackgroundRepeat, DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
196 {attrBorder, DISPID_IHTMLSTYLE_BORDER},
197 {attrBorderBottom, DISPID_IHTMLSTYLE_BORDERBOTTOM},
198 {attrBorderBottomColor, DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR},
199 {attrBorderBottomStyle, DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
200 {attrBorderBottomWidth, DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
201 {attrBorderColor, DISPID_IHTMLSTYLE_BORDERCOLOR},
202 {attrBorderLeft, DISPID_IHTMLSTYLE_BORDERLEFT},
203 {attrBorderLeftColor, DISPID_IHTMLSTYLE_BORDERLEFTCOLOR},
204 {attrBorderLeftStyle, DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
205 {attrBorderLeftWidth, DISPID_IHTMLSTYLE_BORDERLEFTWIDTH},
206 {attrBorderRight, DISPID_IHTMLSTYLE_BORDERRIGHT},
207 {attrBorderRightColor, DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR},
208 {attrBorderRightStyle, DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
209 {attrBorderRightWidth, DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
210 {attrBorderStyle, DISPID_IHTMLSTYLE_BORDERSTYLE},
211 {attrBorderTop, DISPID_IHTMLSTYLE_BORDERTOP},
212 {attrBorderTopColor, DISPID_IHTMLSTYLE_BORDERTOPCOLOR},
213 {attrBorderTopStyle, DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
214 {attrBorderTopWidth, DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
215 {attrBorderWidth, DISPID_IHTMLSTYLE_BORDERWIDTH},
216 {attrBottom, DISPID_IHTMLSTYLE2_BOTTOM},
217 {attrClear, DISPID_IHTMLSTYLE_CLEAR},
218 {attrClip, DISPID_IHTMLSTYLE_CLIP},
219 {attrColor, DISPID_IHTMLSTYLE_COLOR},
220 {attrCursor, DISPID_IHTMLSTYLE_CURSOR},
221 {attrDirection, DISPID_IHTMLSTYLE2_DIRECTION},
222 {attrDisplay, DISPID_IHTMLSTYLE_DISPLAY},
223 {attrFilter, DISPID_IHTMLSTYLE_FILTER},
224 {attrFontFamily, DISPID_IHTMLSTYLE_FONTFAMILY},
225 {attrFontSize, DISPID_IHTMLSTYLE_FONTSIZE},
226 {attrFontStyle, DISPID_IHTMLSTYLE_FONTSTYLE},
227 {attrFontVariant, DISPID_IHTMLSTYLE_FONTVARIANT},
228 {attrFontWeight, DISPID_IHTMLSTYLE_FONTWEIGHT},
229 {attrHeight, DISPID_IHTMLSTYLE_HEIGHT},
230 {attrLeft, DISPID_IHTMLSTYLE_LEFT},
231 {attrLetterSpacing, DISPID_IHTMLSTYLE_LETTERSPACING},
232 {attrLineHeight, DISPID_IHTMLSTYLE_LINEHEIGHT},
233 {attrMargin, DISPID_IHTMLSTYLE_MARGIN},
234 {attrMarginBottom, DISPID_IHTMLSTYLE_MARGINBOTTOM},
235 {attrMarginLeft, DISPID_IHTMLSTYLE_MARGINLEFT},
236 {attrMarginRight, DISPID_IHTMLSTYLE_MARGINRIGHT},
237 {attrMarginTop, DISPID_IHTMLSTYLE_MARGINTOP},
238 {attrMinHeight, DISPID_IHTMLSTYLE4_MINHEIGHT},
239 {attrOverflow, DISPID_IHTMLSTYLE_OVERFLOW},
240 {attrOverflowX, DISPID_IHTMLSTYLE2_OVERFLOWX},
241 {attrOverflowY, DISPID_IHTMLSTYLE2_OVERFLOWY},
242 {attrPadding, DISPID_IHTMLSTYLE_PADDING},
243 {attrPaddingBottom, DISPID_IHTMLSTYLE_PADDINGBOTTOM},
244 {attrPaddingLeft, DISPID_IHTMLSTYLE_PADDINGLEFT},
245 {attrPaddingRight, DISPID_IHTMLSTYLE_PADDINGRIGHT},
246 {attrPaddingTop, DISPID_IHTMLSTYLE_PADDINGTOP},
247 {attrPageBreakAfter, DISPID_IHTMLSTYLE_PAGEBREAKAFTER},
248 {attrPageBreakBefore, DISPID_IHTMLSTYLE_PAGEBREAKBEFORE},
249 {attrPosition, DISPID_IHTMLSTYLE2_POSITION},
250 {attrRight, DISPID_IHTMLSTYLE2_RIGHT},
251 {attrTextAlign, DISPID_IHTMLSTYLE_TEXTALIGN},
252 {attrTextDecoration, DISPID_IHTMLSTYLE_TEXTDECORATION},
253 {attrTextIndent, DISPID_IHTMLSTYLE_TEXTINDENT},
254 {attrTop, DISPID_IHTMLSTYLE_TOP},
255 {attrVerticalAlign, DISPID_IHTMLSTYLE_VERTICALALIGN},
256 {attrVisibility, DISPID_IHTMLSTYLE_VISIBILITY},
257 {attrWidth, DISPID_IHTMLSTYLE_WIDTH},
258 {attrWordSpacing, DISPID_IHTMLSTYLE_WORDSPACING},
259 {attrWordWrap, DISPID_IHTMLSTYLE3_WORDWRAP},
260 {attrZIndex, DISPID_IHTMLSTYLE_ZINDEX}
263 static const WCHAR valLineThrough[] =
264 {'l','i','n','e','-','t','h','r','o','u','g','h',0};
265 static const WCHAR valUnderline[] =
266 {'u','n','d','e','r','l','i','n','e',0};
267 static const WCHAR szNormal[] =
268 {'n','o','r','m','a','l',0};
269 static const WCHAR styleNone[] =
270 {'n','o','n','e',0};
271 static const WCHAR valOverline[] =
272 {'o','v','e','r','l','i','n','e',0};
273 static const WCHAR valBlink[] =
274 {'b','l','i','n','k',0};
276 static const WCHAR px_formatW[] = {'%','d','p','x',0};
277 static const WCHAR emptyW[] = {0};
279 static const style_tbl_entry_t *lookup_style_tbl(const WCHAR *name)
281 int c, i, min = 0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
283 while(min <= max) {
284 i = (min+max)/2;
286 c = strcmpW(style_tbl[i].name, name);
287 if(!c)
288 return style_tbl+i;
290 if(c > 0)
291 max = i-1;
292 else
293 min = i+1;
296 return NULL;
299 static LPWSTR fix_px_value(LPCWSTR val)
301 LPCWSTR ptr = val;
303 while(*ptr) {
304 while(*ptr && isspaceW(*ptr))
305 ptr++;
306 if(!*ptr)
307 break;
309 while(*ptr && isdigitW(*ptr))
310 ptr++;
312 if(!*ptr || isspaceW(*ptr)) {
313 LPWSTR ret, p;
314 int len = strlenW(val)+1;
316 ret = heap_alloc((len+2)*sizeof(WCHAR));
317 memcpy(ret, val, (ptr-val)*sizeof(WCHAR));
318 p = ret + (ptr-val);
319 *p++ = 'p';
320 *p++ = 'x';
321 strcpyW(p, ptr);
323 TRACE("fixed %s -> %s\n", debugstr_w(val), debugstr_w(ret));
325 return ret;
328 while(*ptr && !isspaceW(*ptr))
329 ptr++;
332 return NULL;
335 static LPWSTR fix_url_value(LPCWSTR val)
337 WCHAR *ret, *ptr;
339 static const WCHAR urlW[] = {'u','r','l','('};
341 if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
342 return NULL;
344 ret = heap_strdupW(val);
346 for(ptr = ret; *ptr; ptr++) {
347 if(*ptr == '\\')
348 *ptr = '/';
351 return ret;
354 HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, const WCHAR *value, DWORD flags)
356 nsAString str_name, str_value, str_empty;
357 LPWSTR val = NULL;
358 nsresult nsres;
360 if(value) {
361 if(flags & ATTR_FIX_PX)
362 val = fix_px_value(value);
363 if(flags & ATTR_FIX_URL)
364 val = fix_url_value(value);
367 nsAString_InitDepend(&str_name, style_tbl[sid].name);
368 nsAString_InitDepend(&str_value, val ? val : value);
369 nsAString_InitDepend(&str_empty, emptyW);
371 nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
372 if(NS_FAILED(nsres))
373 ERR("SetProperty failed: %08x\n", nsres);
375 nsAString_Finish(&str_name);
376 nsAString_Finish(&str_value);
377 nsAString_Finish(&str_empty);
378 heap_free(val);
380 return S_OK;
383 static HRESULT var_to_styleval(const VARIANT *v, WCHAR *buf, DWORD flags, const WCHAR **ret)
385 switch(V_VT(v)) {
386 case VT_NULL:
387 *ret = emptyW;
388 return S_OK;
390 case VT_BSTR:
391 *ret = V_BSTR(v);
392 return S_OK;
394 case VT_BSTR|VT_BYREF:
395 *ret = *V_BSTRREF(v);
396 return S_OK;
398 case VT_I4: {
399 static const WCHAR formatW[] = {'%','d',0};
400 static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
402 if(flags & ATTR_HEX_INT)
403 wsprintfW(buf, hex_formatW, V_I4(v));
404 else if(flags & ATTR_FIX_PX)
405 wsprintfW(buf, px_formatW, V_I4(v));
406 else
407 wsprintfW(buf, formatW, V_I4(v));
409 *ret = buf;
410 return S_OK;
412 default:
413 FIXME("not implemented for %s\n", debugstr_variant(v));
414 return E_NOTIMPL;
419 HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *value, DWORD flags)
421 const WCHAR *val;
422 WCHAR buf[14];
423 HRESULT hres;
425 hres = var_to_styleval(value, buf, flags, &val);
426 if(FAILED(hres))
427 return hres;
429 return set_nsstyle_attr(nsstyle, sid, val, flags);
432 static inline HRESULT set_style_attr(HTMLStyle *This, styleid_t sid, LPCWSTR value, DWORD flags)
434 return set_nsstyle_attr(This->nsstyle, sid, value, flags);
437 static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, nsAString *value)
439 nsAString str_name;
440 nsresult nsres;
442 nsAString_InitDepend(&str_name, style_tbl[sid].name);
444 nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
445 if(NS_FAILED(nsres)) {
446 ERR("SetProperty failed: %08x\n", nsres);
447 return E_FAIL;
450 nsAString_Finish(&str_name);
452 return NS_OK;
455 static HRESULT nsstyle_to_bstr(const WCHAR *val, DWORD flags, BSTR *p)
457 BSTR ret;
458 DWORD len;
460 if(!*val) {
461 *p = NULL;
462 return S_OK;
465 ret = SysAllocString(val);
466 if(!ret)
467 return E_OUTOFMEMORY;
469 len = SysStringLen(ret);
471 if(flags & ATTR_REMOVE_COMMA) {
472 DWORD new_len = len;
473 WCHAR *ptr, *ptr2;
475 for(ptr = ret; (ptr = strchrW(ptr, ',')); ptr++)
476 new_len--;
478 if(new_len != len) {
479 BSTR new_ret;
481 new_ret = SysAllocStringLen(NULL, new_len);
482 if(!new_ret) {
483 SysFreeString(ret);
484 return E_OUTOFMEMORY;
487 for(ptr2 = new_ret, ptr = ret; *ptr; ptr++) {
488 if(*ptr != ',')
489 *ptr2++ = *ptr;
492 SysFreeString(ret);
493 ret = new_ret;
497 *p = ret;
498 return S_OK;
501 HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR *p, DWORD flags)
503 nsAString str_value;
504 const PRUnichar *value;
505 HRESULT hres;
507 nsAString_Init(&str_value, NULL);
509 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
511 nsAString_GetData(&str_value, &value);
512 hres = nsstyle_to_bstr(value, flags, p);
513 nsAString_Finish(&str_value);
515 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_w(*p));
516 return hres;
519 HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
521 nsAString str_value;
522 const PRUnichar *value;
523 BOOL set = FALSE;
524 HRESULT hres = S_OK;
526 nsAString_Init(&str_value, NULL);
528 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
530 nsAString_GetData(&str_value, &value);
532 if(flags & ATTR_STR_TO_INT) {
533 const PRUnichar *ptr = value;
534 BOOL neg = FALSE;
535 INT i = 0;
537 if(*ptr == '-') {
538 neg = TRUE;
539 ptr++;
542 while(isdigitW(*ptr))
543 i = i*10 + (*ptr++ - '0');
545 if(!*ptr) {
546 V_VT(p) = VT_I4;
547 V_I4(p) = neg ? -i : i;
548 set = TRUE;
552 if(!set) {
553 BSTR str;
555 hres = nsstyle_to_bstr(value, flags, &str);
556 if(SUCCEEDED(hres)) {
557 V_VT(p) = VT_BSTR;
558 V_BSTR(p) = str;
562 nsAString_Finish(&str_value);
564 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_variant(p));
565 return S_OK;
568 static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
570 return get_nsstyle_attr(This->nsstyle, sid, p, 0);
573 static HRESULT check_style_attr_value(HTMLStyle *This, styleid_t sid, LPCWSTR exval, VARIANT_BOOL *p)
575 nsAString str_value;
576 const PRUnichar *value;
578 nsAString_Init(&str_value, NULL);
580 get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
582 nsAString_GetData(&str_value, &value);
583 *p = strcmpW(value, exval) ? VARIANT_FALSE : VARIANT_TRUE;
584 nsAString_Finish(&str_value);
586 TRACE("%s -> %x\n", debugstr_w(style_tbl[sid].name), *p);
587 return S_OK;
590 static inline HRESULT set_style_pos(HTMLStyle *This, styleid_t sid, float value)
592 WCHAR szValue[25];
593 WCHAR szFormat[] = {'%','.','0','f','p','x',0};
595 value = floor(value);
597 sprintfW(szValue, szFormat, value);
599 return set_style_attr(This, sid, szValue, 0);
602 static HRESULT set_style_pxattr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LONG value)
604 WCHAR value_str[16];
606 sprintfW(value_str, px_formatW, value);
608 return set_nsstyle_attr(nsstyle, sid, value_str, 0);
611 static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p)
613 nsAString str_value;
614 HRESULT hres;
615 WCHAR pxW[] = {'p','x',0};
617 TRACE("%p %d %p\n", This, sid, p);
619 *p = 0.0f;
621 nsAString_Init(&str_value, NULL);
623 hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
624 if(hres == S_OK)
626 WCHAR *ptr;
627 const PRUnichar *value;
629 nsAString_GetData(&str_value, &value);
630 if(value)
632 *p = strtolW(value, &ptr, 10);
634 if(*ptr && strcmpW(ptr, pxW))
636 nsAString_Finish(&str_value);
637 FIXME("only px values are currently supported\n");
638 return E_FAIL;
643 TRACE("ret %f\n", *p);
645 nsAString_Finish(&str_value);
647 return hres;
650 static BOOL is_valid_border_style(BSTR v)
652 static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0};
653 static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0};
654 static const WCHAR styleSolid[] = {'s','o','l','i','d',0};
655 static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0};
656 static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0};
657 static const WCHAR styleRidge[] = {'r','i','d','g','e',0};
658 static const WCHAR styleInset[] = {'i','n','s','e','t',0};
659 static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0};
661 TRACE("%s\n", debugstr_w(v));
663 if(!v || strcmpiW(v, styleNone) == 0 || strcmpiW(v, styleDotted) == 0 ||
664 strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid) == 0 ||
665 strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 ||
666 strcmpiW(v, styleRidge) == 0 || strcmpiW(v, styleInset) == 0 ||
667 strcmpiW(v, styleOutset) == 0 )
669 return TRUE;
672 return FALSE;
675 static inline HTMLStyle *impl_from_IHTMLStyle(IHTMLStyle *iface)
677 return CONTAINING_RECORD(iface, HTMLStyle, IHTMLStyle_iface);
680 static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv)
682 HTMLStyle *This = impl_from_IHTMLStyle(iface);
684 *ppv = NULL;
686 if(IsEqualGUID(&IID_IUnknown, riid)) {
687 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
688 *ppv = &This->IHTMLStyle_iface;
689 }else if(IsEqualGUID(&IID_IHTMLStyle, riid)) {
690 TRACE("(%p)->(IID_IHTMLStyle %p)\n", This, ppv);
691 *ppv = &This->IHTMLStyle_iface;
692 }else if(IsEqualGUID(&IID_IHTMLStyle2, riid)) {
693 TRACE("(%p)->(IID_IHTMLStyle2 %p)\n", This, ppv);
694 *ppv = &This->IHTMLStyle2_iface;
695 }else if(IsEqualGUID(&IID_IHTMLStyle3, riid)) {
696 TRACE("(%p)->(IID_IHTMLStyle3 %p)\n", This, ppv);
697 *ppv = &This->IHTMLStyle3_iface;
698 }else if(IsEqualGUID(&IID_IHTMLStyle4, riid)) {
699 TRACE("(%p)->(IID_IHTMLStyle4 %p)\n", This, ppv);
700 *ppv = &This->IHTMLStyle4_iface;
701 }else if(IsEqualGUID(&IID_IHTMLStyle5, riid)) {
702 TRACE("(%p)->(IID_IHTMLStyle5 %p)\n", This, ppv);
703 *ppv = &This->IHTMLStyle5_iface;
704 }else if(IsEqualGUID(&IID_IHTMLStyle6, riid)) {
705 TRACE("(%p)->(IID_IHTMLStyle6 %p)\n", This, ppv);
706 *ppv = &This->IHTMLStyle6_iface;
707 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
708 return *ppv ? S_OK : E_NOINTERFACE;
711 if(*ppv) {
712 IUnknown_AddRef((IUnknown*)*ppv);
713 return S_OK;
716 WARN("unsupported %s\n", debugstr_guid(riid));
717 return E_NOINTERFACE;
720 static ULONG WINAPI HTMLStyle_AddRef(IHTMLStyle *iface)
722 HTMLStyle *This = impl_from_IHTMLStyle(iface);
723 LONG ref = InterlockedIncrement(&This->ref);
725 TRACE("(%p) ref=%d\n", This, ref);
727 return ref;
730 static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
732 HTMLStyle *This = impl_from_IHTMLStyle(iface);
733 LONG ref = InterlockedDecrement(&This->ref);
735 TRACE("(%p) ref=%d\n", This, ref);
737 if(!ref) {
738 assert(!This->elem);
739 if(This->nsstyle)
740 nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
741 release_dispex(&This->dispex);
742 heap_free(This);
745 return ref;
748 static HRESULT WINAPI HTMLStyle_GetTypeInfoCount(IHTMLStyle *iface, UINT *pctinfo)
750 HTMLStyle *This = impl_from_IHTMLStyle(iface);
751 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
754 static HRESULT WINAPI HTMLStyle_GetTypeInfo(IHTMLStyle *iface, UINT iTInfo,
755 LCID lcid, ITypeInfo **ppTInfo)
757 HTMLStyle *This = impl_from_IHTMLStyle(iface);
758 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
761 static HRESULT WINAPI HTMLStyle_GetIDsOfNames(IHTMLStyle *iface, REFIID riid,
762 LPOLESTR *rgszNames, UINT cNames,
763 LCID lcid, DISPID *rgDispId)
765 HTMLStyle *This = impl_from_IHTMLStyle(iface);
766 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
767 lcid, rgDispId);
770 static HRESULT WINAPI HTMLStyle_Invoke(IHTMLStyle *iface, DISPID dispIdMember,
771 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
772 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
774 HTMLStyle *This = impl_from_IHTMLStyle(iface);
775 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
776 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
779 static HRESULT WINAPI HTMLStyle_put_fontFamily(IHTMLStyle *iface, BSTR v)
781 HTMLStyle *This = impl_from_IHTMLStyle(iface);
783 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
785 return set_style_attr(This, STYLEID_FONT_FAMILY, v, 0);
788 static HRESULT WINAPI HTMLStyle_get_fontFamily(IHTMLStyle *iface, BSTR *p)
790 HTMLStyle *This = impl_from_IHTMLStyle(iface);
792 TRACE("(%p)->(%p)\n", This, p);
794 return get_style_attr(This, STYLEID_FONT_FAMILY, p);
797 static HRESULT WINAPI HTMLStyle_put_fontStyle(IHTMLStyle *iface, BSTR v)
799 HTMLStyle *This = impl_from_IHTMLStyle(iface);
800 static const WCHAR szItalic[] = {'i','t','a','l','i','c',0};
801 static const WCHAR szOblique[] = {'o','b','l','i','q','u','e',0};
803 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
805 /* fontStyle can only be one of the follow values. */
806 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szItalic, v) == 0 ||
807 strcmpiW(szOblique, v) == 0)
809 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, v, 0);
812 return E_INVALIDARG;
815 static HRESULT WINAPI HTMLStyle_get_fontStyle(IHTMLStyle *iface, BSTR *p)
817 HTMLStyle *This = impl_from_IHTMLStyle(iface);
819 TRACE("(%p)->(%p)\n", This, p);
821 return get_style_attr(This, STYLEID_FONT_STYLE, p);
824 static HRESULT WINAPI HTMLStyle_put_fontVariant(IHTMLStyle *iface, BSTR v)
826 HTMLStyle *This = impl_from_IHTMLStyle(iface);
827 static const WCHAR szCaps[] = {'s','m','a','l','l','-','c','a','p','s',0};
829 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
831 /* fontVariant can only be one of the follow values. */
832 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szCaps, v) == 0)
834 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, v, 0);
837 return E_INVALIDARG;
840 static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p)
842 HTMLStyle *This = impl_from_IHTMLStyle(iface);
843 TRACE("(%p)->(%p)\n", This, p);
845 if(!p)
846 return E_INVALIDARG;
848 return get_style_attr(This, STYLEID_FONT_VARIANT, p);
851 static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v)
853 HTMLStyle *This = impl_from_IHTMLStyle(iface);
854 static const WCHAR styleBold[] = {'b','o','l','d',0};
855 static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0};
856 static const WCHAR styleLighter[] = {'l','i','g','h','t','e','r',0};
857 static const WCHAR style100[] = {'1','0','0',0};
858 static const WCHAR style200[] = {'2','0','0',0};
859 static const WCHAR style300[] = {'3','0','0',0};
860 static const WCHAR style400[] = {'4','0','0',0};
861 static const WCHAR style500[] = {'5','0','0',0};
862 static const WCHAR style600[] = {'6','0','0',0};
863 static const WCHAR style700[] = {'7','0','0',0};
864 static const WCHAR style800[] = {'8','0','0',0};
865 static const WCHAR style900[] = {'9','0','0',0};
867 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
869 /* fontWeight can only be one of the following */
870 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(styleBold, v) == 0 ||
871 strcmpiW(styleBolder, v) == 0 || strcmpiW(styleLighter, v) == 0 ||
872 strcmpiW(style100, v) == 0 || strcmpiW(style200, v) == 0 ||
873 strcmpiW(style300, v) == 0 || strcmpiW(style400, v) == 0 ||
874 strcmpiW(style500, v) == 0 || strcmpiW(style600, v) == 0 ||
875 strcmpiW(style700, v) == 0 || strcmpiW(style800, v) == 0 ||
876 strcmpiW(style900, v) == 0
879 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0);
882 return E_INVALIDARG;
885 static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p)
887 HTMLStyle *This = impl_from_IHTMLStyle(iface);
889 TRACE("(%p)->(%p)\n", This, p);
891 return get_style_attr(This, STYLEID_FONT_WEIGHT, p);
894 static HRESULT WINAPI HTMLStyle_put_fontSize(IHTMLStyle *iface, VARIANT v)
896 HTMLStyle *This = impl_from_IHTMLStyle(iface);
898 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
900 return set_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, &v, ATTR_FIX_PX);
903 static HRESULT WINAPI HTMLStyle_get_fontSize(IHTMLStyle *iface, VARIANT *p)
905 HTMLStyle *This = impl_from_IHTMLStyle(iface);
907 TRACE("(%p)->(%p)\n", This, p);
909 return get_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, p, 0);
912 static HRESULT WINAPI HTMLStyle_put_font(IHTMLStyle *iface, BSTR v)
914 HTMLStyle *This = impl_from_IHTMLStyle(iface);
915 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
916 return E_NOTIMPL;
919 static HRESULT WINAPI HTMLStyle_get_font(IHTMLStyle *iface, BSTR *p)
921 HTMLStyle *This = impl_from_IHTMLStyle(iface);
922 FIXME("(%p)->(%p)\n", This, p);
923 return E_NOTIMPL;
926 static HRESULT WINAPI HTMLStyle_put_color(IHTMLStyle *iface, VARIANT v)
928 HTMLStyle *This = impl_from_IHTMLStyle(iface);
930 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
932 return set_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, &v, ATTR_HEX_INT);
935 static HRESULT WINAPI HTMLStyle_get_color(IHTMLStyle *iface, VARIANT *p)
937 HTMLStyle *This = impl_from_IHTMLStyle(iface);
939 TRACE("(%p)->(%p)\n", This, p);
941 return get_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, p, 0);
944 static HRESULT WINAPI HTMLStyle_put_background(IHTMLStyle *iface, BSTR v)
946 HTMLStyle *This = impl_from_IHTMLStyle(iface);
948 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
950 return set_style_attr(This, STYLEID_BACKGROUND, v, 0);
953 static HRESULT WINAPI HTMLStyle_get_background(IHTMLStyle *iface, BSTR *p)
955 HTMLStyle *This = impl_from_IHTMLStyle(iface);
957 TRACE("(%p)->(%p)\n", This, p);
959 return get_style_attr(This, STYLEID_BACKGROUND, p);
962 static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v)
964 HTMLStyle *This = impl_from_IHTMLStyle(iface);
966 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
968 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, &v, ATTR_HEX_INT);
971 static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
973 HTMLStyle *This = impl_from_IHTMLStyle(iface);
975 TRACE("(%p)->(%p)\n", This, p);
977 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, p, 0);
980 static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
982 HTMLStyle *This = impl_from_IHTMLStyle(iface);
984 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
986 return set_style_attr(This, STYLEID_BACKGROUND_IMAGE, v, ATTR_FIX_URL);
989 static HRESULT WINAPI HTMLStyle_get_backgroundImage(IHTMLStyle *iface, BSTR *p)
991 HTMLStyle *This = impl_from_IHTMLStyle(iface);
993 TRACE("(%p)->(%p)\n", This, p);
995 return get_style_attr(This, STYLEID_BACKGROUND_IMAGE, p);
998 static HRESULT WINAPI HTMLStyle_put_backgroundRepeat(IHTMLStyle *iface, BSTR v)
1000 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1001 static const WCHAR styleRepeat[] = {'r','e','p','e','a','t',0};
1002 static const WCHAR styleNoRepeat[] = {'n','o','-','r','e','p','e','a','t',0};
1003 static const WCHAR styleRepeatX[] = {'r','e','p','e','a','t','-','x',0};
1004 static const WCHAR styleRepeatY[] = {'r','e','p','e','a','t','-','y',0};
1006 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1008 /* fontWeight can only be one of the following */
1009 if(!v || strcmpiW(styleRepeat, v) == 0 || strcmpiW(styleNoRepeat, v) == 0 ||
1010 strcmpiW(styleRepeatX, v) == 0 || strcmpiW(styleRepeatY, v) == 0 )
1012 return set_style_attr(This, STYLEID_BACKGROUND_REPEAT , v, 0);
1015 return E_INVALIDARG;
1018 static HRESULT WINAPI HTMLStyle_get_backgroundRepeat(IHTMLStyle *iface, BSTR *p)
1020 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1022 TRACE("(%p)->(%p)\n", This, p);
1024 return get_style_attr(This, STYLEID_BACKGROUND_REPEAT, p);
1027 static HRESULT WINAPI HTMLStyle_put_backgroundAttachment(IHTMLStyle *iface, BSTR v)
1029 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1030 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1031 return E_NOTIMPL;
1034 static HRESULT WINAPI HTMLStyle_get_backgroundAttachment(IHTMLStyle *iface, BSTR *p)
1036 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1037 FIXME("(%p)->(%p)\n", This, p);
1038 return E_NOTIMPL;
1041 static HRESULT WINAPI HTMLStyle_put_backgroundPosition(IHTMLStyle *iface, BSTR v)
1043 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1045 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1047 return set_style_attr(This, STYLEID_BACKGROUND_POSITION, v, 0);
1050 static HRESULT WINAPI HTMLStyle_get_backgroundPosition(IHTMLStyle *iface, BSTR *p)
1052 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1054 TRACE("(%p)->(%p)\n", This, p);
1056 return get_style_attr(This, STYLEID_BACKGROUND_POSITION, p);
1059 static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIANT v)
1061 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1062 WCHAR buf[14], *pos_val;
1063 nsAString pos_str;
1064 const WCHAR *val;
1065 DWORD val_len;
1066 HRESULT hres;
1068 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1070 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1071 if(FAILED(hres))
1072 return hres;
1074 val_len = val ? strlenW(val) : 0;
1076 nsAString_Init(&pos_str, NULL);
1077 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1078 if(SUCCEEDED(hres)) {
1079 const PRUnichar *pos, *posy;
1080 DWORD posy_len;
1082 nsAString_GetData(&pos_str, &pos);
1083 posy = strchrW(pos, ' ');
1084 if(!posy) {
1085 static const WCHAR zero_pxW[] = {' ','0','p','x',0};
1087 TRACE("no space in %s\n", debugstr_w(pos));
1088 posy = zero_pxW;
1091 posy_len = strlenW(posy);
1092 pos_val = heap_alloc((val_len+posy_len+1)*sizeof(WCHAR));
1093 if(pos_val) {
1094 if(val_len)
1095 memcpy(pos_val, val, val_len*sizeof(WCHAR));
1096 if(posy_len)
1097 memcpy(pos_val+val_len, posy, posy_len*sizeof(WCHAR));
1098 pos_val[val_len+posy_len] = 0;
1099 }else {
1100 hres = E_OUTOFMEMORY;
1103 nsAString_Finish(&pos_str);
1104 if(FAILED(hres))
1105 return hres;
1107 TRACE("setting position to %s\n", debugstr_w(pos_val));
1108 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1109 heap_free(pos_val);
1110 return hres;
1113 static HRESULT WINAPI HTMLStyle_get_backgroundPositionX(IHTMLStyle *iface, VARIANT *p)
1115 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1116 nsAString pos_str;
1117 BSTR ret;
1118 HRESULT hres;
1120 TRACE("(%p)->(%p)\n", This, p);
1122 nsAString_Init(&pos_str, NULL);
1123 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1124 if(SUCCEEDED(hres)) {
1125 const PRUnichar *pos, *space;
1127 nsAString_GetData(&pos_str, &pos);
1128 space = strchrW(pos, ' ');
1129 if(!space) {
1130 WARN("no space in %s\n", debugstr_w(pos));
1131 space = pos + strlenW(pos);
1134 if(space != pos) {
1135 ret = SysAllocStringLen(pos, space-pos);
1136 if(!ret)
1137 hres = E_OUTOFMEMORY;
1138 }else {
1139 ret = NULL;
1142 nsAString_Finish(&pos_str);
1143 if(FAILED(hres))
1144 return hres;
1146 TRACE("returning %s\n", debugstr_w(ret));
1147 V_VT(p) = VT_BSTR;
1148 V_BSTR(p) = ret;
1149 return S_OK;
1152 static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIANT v)
1154 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1155 WCHAR buf[14], *pos_val;
1156 nsAString pos_str;
1157 const WCHAR *val;
1158 DWORD val_len;
1159 HRESULT hres;
1161 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1163 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1164 if(FAILED(hres))
1165 return hres;
1167 val_len = val ? strlenW(val) : 0;
1169 nsAString_Init(&pos_str, NULL);
1170 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1171 if(SUCCEEDED(hres)) {
1172 const PRUnichar *pos, *space;
1173 DWORD posx_len;
1175 nsAString_GetData(&pos_str, &pos);
1176 space = strchrW(pos, ' ');
1177 if(space) {
1178 space++;
1179 }else {
1180 static const WCHAR zero_pxW[] = {'0','p','x',' ',0};
1182 TRACE("no space in %s\n", debugstr_w(pos));
1183 pos = zero_pxW;
1184 space = pos + sizeof(zero_pxW)/sizeof(WCHAR)-1;
1187 posx_len = space-pos;
1189 pos_val = heap_alloc((posx_len+val_len+1)*sizeof(WCHAR));
1190 if(pos_val) {
1191 memcpy(pos_val, pos, posx_len*sizeof(WCHAR));
1192 if(val_len)
1193 memcpy(pos_val+posx_len, val, val_len*sizeof(WCHAR));
1194 pos_val[posx_len+val_len] = 0;
1195 }else {
1196 hres = E_OUTOFMEMORY;
1199 nsAString_Finish(&pos_str);
1200 if(FAILED(hres))
1201 return hres;
1203 TRACE("setting position to %s\n", debugstr_w(pos_val));
1204 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1205 heap_free(pos_val);
1206 return hres;
1209 static HRESULT WINAPI HTMLStyle_get_backgroundPositionY(IHTMLStyle *iface, VARIANT *p)
1211 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1212 nsAString pos_str;
1213 BSTR ret;
1214 HRESULT hres;
1216 TRACE("(%p)->(%p)\n", This, p);
1218 nsAString_Init(&pos_str, NULL);
1219 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1220 if(SUCCEEDED(hres)) {
1221 const PRUnichar *pos, *posy;
1223 nsAString_GetData(&pos_str, &pos);
1224 posy = strchrW(pos, ' ');
1225 if(posy) {
1226 ret = SysAllocString(posy+1);
1227 if(!ret)
1228 hres = E_OUTOFMEMORY;
1229 }else {
1230 ret = NULL;
1233 nsAString_Finish(&pos_str);
1234 if(FAILED(hres))
1235 return hres;
1237 TRACE("returning %s\n", debugstr_w(ret));
1238 V_VT(p) = VT_BSTR;
1239 V_BSTR(p) = ret;
1240 return S_OK;
1243 static HRESULT WINAPI HTMLStyle_put_wordSpacing(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_WORD_SPACING, &v, 0);
1252 static HRESULT WINAPI HTMLStyle_get_wordSpacing(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_WORD_SPACING, p, 0);
1259 static HRESULT WINAPI HTMLStyle_put_letterSpacing(IHTMLStyle *iface, VARIANT v)
1261 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1263 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1265 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, &v, 0);
1268 static HRESULT WINAPI HTMLStyle_get_letterSpacing(IHTMLStyle *iface, VARIANT *p)
1270 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1271 TRACE("(%p)->(%p)\n", This, p);
1272 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, p, 0);
1275 static HRESULT WINAPI HTMLStyle_put_textDecoration(IHTMLStyle *iface, BSTR v)
1277 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1279 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1281 /* textDecoration can only be one of the following */
1282 if(!v || strcmpiW(styleNone, v) == 0 || strcmpiW(valUnderline, v) == 0 ||
1283 strcmpiW(valOverline, v) == 0 || strcmpiW(valLineThrough, v) == 0 ||
1284 strcmpiW(valBlink, v) == 0)
1286 return set_style_attr(This, STYLEID_TEXT_DECORATION , v, 0);
1289 return E_INVALIDARG;
1292 static HRESULT WINAPI HTMLStyle_get_textDecoration(IHTMLStyle *iface, BSTR *p)
1294 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1296 TRACE("(%p)->(%p)\n", This, p);
1298 return get_style_attr(This, STYLEID_TEXT_DECORATION, p);
1301 static HRESULT WINAPI HTMLStyle_put_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL v)
1303 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1305 TRACE("(%p)->(%x)\n", This, v);
1307 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? styleNone : emptyW, 0);
1310 static HRESULT WINAPI HTMLStyle_get_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL *p)
1312 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1314 TRACE("(%p)->(%p)\n", This, p);
1316 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, styleNone, p);
1319 static HRESULT WINAPI HTMLStyle_put_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL v)
1321 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1323 TRACE("(%p)->(%x)\n", This, v);
1325 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valUnderline : emptyW, 0);
1328 static HRESULT WINAPI HTMLStyle_get_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL *p)
1330 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1332 TRACE("(%p)->(%p)\n", This, p);
1334 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valUnderline, p);
1337 static HRESULT WINAPI HTMLStyle_put_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL v)
1339 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1341 TRACE("(%p)->(%x)\n", This, v);
1343 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valOverline : emptyW, 0);
1346 static HRESULT WINAPI HTMLStyle_get_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL *p)
1348 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1350 TRACE("(%p)->(%p)\n", This, p);
1352 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valOverline, p);
1355 static HRESULT WINAPI HTMLStyle_put_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL v)
1357 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1359 TRACE("(%p)->(%x)\n", This, v);
1361 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valLineThrough : emptyW, 0);
1364 static HRESULT WINAPI HTMLStyle_get_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL *p)
1366 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1368 TRACE("(%p)->(%p)\n", This, p);
1370 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valLineThrough, p);
1373 static HRESULT WINAPI HTMLStyle_put_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL v)
1375 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1377 TRACE("(%p)->(%x)\n", This, v);
1379 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valBlink : emptyW, 0);
1382 static HRESULT WINAPI HTMLStyle_get_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL *p)
1384 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1386 TRACE("(%p)->(%p)\n", This, p);
1388 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valBlink, p);
1391 static HRESULT WINAPI HTMLStyle_put_verticalAlign(IHTMLStyle *iface, VARIANT v)
1393 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1395 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1397 return set_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, &v, ATTR_FIX_PX);
1400 static HRESULT WINAPI HTMLStyle_get_verticalAlign(IHTMLStyle *iface, VARIANT *p)
1402 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1404 TRACE("(%p)->(%p)\n", This, p);
1406 return get_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, p, 0);
1409 static HRESULT WINAPI HTMLStyle_put_textTransform(IHTMLStyle *iface, BSTR v)
1411 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1412 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1413 return E_NOTIMPL;
1416 static HRESULT WINAPI HTMLStyle_get_textTransform(IHTMLStyle *iface, BSTR *p)
1418 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1419 FIXME("(%p)->(%p)\n", This, p);
1420 return E_NOTIMPL;
1423 static HRESULT WINAPI HTMLStyle_put_textAlign(IHTMLStyle *iface, BSTR v)
1425 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1427 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1429 return set_style_attr(This, STYLEID_TEXT_ALIGN, v, 0);
1432 static HRESULT WINAPI HTMLStyle_get_textAlign(IHTMLStyle *iface, BSTR *p)
1434 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1436 TRACE("(%p)->(%p)\n", This, p);
1438 return get_style_attr(This, STYLEID_TEXT_ALIGN, p);
1441 static HRESULT WINAPI HTMLStyle_put_textIndent(IHTMLStyle *iface, VARIANT v)
1443 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1444 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1445 return E_NOTIMPL;
1448 static HRESULT WINAPI HTMLStyle_get_textIndent(IHTMLStyle *iface, VARIANT *p)
1450 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1451 FIXME("(%p)->(%p)\n", This, p);
1452 return E_NOTIMPL;
1455 static HRESULT WINAPI HTMLStyle_put_lineHeight(IHTMLStyle *iface, VARIANT v)
1457 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1458 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1459 return E_NOTIMPL;
1462 static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
1464 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1465 FIXME("(%p)->(%p)\n", This, p);
1466 return E_NOTIMPL;
1469 static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
1471 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1473 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1475 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, &v, ATTR_FIX_PX);
1478 static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
1480 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1482 TRACE("(%p)->(%p)\n", This, p);
1484 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
1487 static HRESULT WINAPI HTMLStyle_put_marginRight(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_RIGHT, &v, ATTR_FIX_PX);
1496 static HRESULT WINAPI HTMLStyle_get_marginRight(IHTMLStyle *iface, VARIANT *p)
1498 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1499 TRACE("(%p)->(%p)\n", This, p);
1500 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
1503 static HRESULT WINAPI HTMLStyle_put_marginBottom(IHTMLStyle *iface, VARIANT v)
1505 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1507 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1509 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, &v, ATTR_FIX_PX);
1512 static HRESULT WINAPI HTMLStyle_get_marginBottom(IHTMLStyle *iface, VARIANT *p)
1514 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1516 TRACE("(%p)->(%p)\n", This, p);
1518 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, p, 0);
1521 static HRESULT WINAPI HTMLStyle_put_marginLeft(IHTMLStyle *iface, VARIANT v)
1523 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1525 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1527 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, &v, ATTR_FIX_PX);
1530 static HRESULT WINAPI HTMLStyle_put_margin(IHTMLStyle *iface, BSTR v)
1532 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1534 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1536 return set_style_attr(This, STYLEID_MARGIN, v, 0);
1539 static HRESULT WINAPI HTMLStyle_get_margin(IHTMLStyle *iface, BSTR *p)
1541 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1543 TRACE("(%p)->(%p)\n", This, p);
1545 return get_style_attr(This, STYLEID_MARGIN, p);
1548 static HRESULT WINAPI HTMLStyle_get_marginLeft(IHTMLStyle *iface, VARIANT *p)
1550 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1551 TRACE("(%p)->(%p)\n", This, p);
1552 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
1555 static HRESULT WINAPI HTMLStyle_put_paddingTop(IHTMLStyle *iface, VARIANT v)
1557 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1559 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1561 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, &v, ATTR_FIX_PX);
1564 static HRESULT WINAPI HTMLStyle_get_paddingTop(IHTMLStyle *iface, VARIANT *p)
1566 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1568 TRACE("(%p)->(%p)\n", This, p);
1570 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, p, 0);
1573 static HRESULT WINAPI HTMLStyle_put_paddingRight(IHTMLStyle *iface, VARIANT v)
1575 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1577 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1579 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, &v, ATTR_FIX_PX);
1582 static HRESULT WINAPI HTMLStyle_get_paddingRight(IHTMLStyle *iface, VARIANT *p)
1584 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1586 TRACE("(%p)->(%p)\n", This, p);
1588 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, p, 0);
1591 static HRESULT WINAPI HTMLStyle_put_paddingBottom(IHTMLStyle *iface, VARIANT v)
1593 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1595 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1597 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, &v, ATTR_FIX_PX);
1600 static HRESULT WINAPI HTMLStyle_get_paddingBottom(IHTMLStyle *iface, VARIANT *p)
1602 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1604 TRACE("(%p)->(%p)\n", This, p);
1606 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, p, 0);
1609 static HRESULT WINAPI HTMLStyle_put_paddingLeft(IHTMLStyle *iface, VARIANT v)
1611 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1613 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1615 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, &v, ATTR_FIX_PX);
1618 static HRESULT WINAPI HTMLStyle_get_paddingLeft(IHTMLStyle *iface, VARIANT *p)
1620 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1622 TRACE("(%p)->(%p)\n", This, p);
1624 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, p, 0);
1627 static HRESULT WINAPI HTMLStyle_put_padding(IHTMLStyle *iface, BSTR v)
1629 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1631 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1633 return set_style_attr(This, STYLEID_PADDING, v, 0);
1636 static HRESULT WINAPI HTMLStyle_get_padding(IHTMLStyle *iface, BSTR *p)
1638 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1640 TRACE("(%p)->(%p)\n", This, p);
1642 return get_style_attr(This, STYLEID_PADDING, p);
1645 static HRESULT WINAPI HTMLStyle_put_border(IHTMLStyle *iface, BSTR v)
1647 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1649 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1651 return set_style_attr(This, STYLEID_BORDER, v, 0);
1654 static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
1656 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1658 TRACE("(%p)->(%p)\n", This, p);
1660 return get_style_attr(This, STYLEID_BORDER, p);
1663 static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
1665 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1666 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1667 return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX);
1670 static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
1672 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1673 TRACE("(%p)->(%p)\n", This, p);
1674 return get_style_attr(This, STYLEID_BORDER_TOP, p);
1677 static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
1679 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1680 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1681 return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX);
1684 static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
1686 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1687 TRACE("(%p)->(%p)\n", This, p);
1688 return get_style_attr(This, STYLEID_BORDER_RIGHT, p);
1691 static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
1693 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1694 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1695 return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX);
1698 static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
1700 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1701 TRACE("(%p)->(%p)\n", This, p);
1702 return get_style_attr(This, STYLEID_BORDER_BOTTOM, p);
1705 static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
1707 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1709 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1711 return set_style_attr(This, STYLEID_BORDER_LEFT, v, ATTR_FIX_PX);
1714 static HRESULT WINAPI HTMLStyle_get_borderLeft(IHTMLStyle *iface, BSTR *p)
1716 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1718 TRACE("(%p)->(%p)\n", This, p);
1720 return get_style_attr(This, STYLEID_BORDER_LEFT, p);
1723 static HRESULT WINAPI HTMLStyle_put_borderColor(IHTMLStyle *iface, BSTR v)
1725 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1727 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1729 return set_style_attr(This, STYLEID_BORDER_COLOR, v, 0);
1732 static HRESULT WINAPI HTMLStyle_get_borderColor(IHTMLStyle *iface, BSTR *p)
1734 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1736 TRACE("(%p)->(%p)\n", This, p);
1738 return get_style_attr(This, STYLEID_BORDER_COLOR, p);
1741 static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v)
1743 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1745 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1747 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, &v, ATTR_HEX_INT);
1750 static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p)
1752 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1754 TRACE("(%p)->(%p)\n", This, p);
1756 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0);
1759 static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v)
1761 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1763 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1765 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, &v, ATTR_HEX_INT);
1768 static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p)
1770 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1772 TRACE("(%p)->(%p)\n", This, p);
1774 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0);
1777 static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v)
1779 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1781 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1783 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, &v, ATTR_HEX_INT);
1786 static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p)
1788 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1790 TRACE("(%p)->(%p)\n", This, p);
1792 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0);
1795 static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v)
1797 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1799 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1801 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, &v, ATTR_HEX_INT);
1804 static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p)
1806 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1808 TRACE("(%p)->(%p)\n", This, p);
1810 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0);
1813 static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v)
1815 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1816 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1817 return set_style_attr(This, STYLEID_BORDER_WIDTH, v, ATTR_FIX_PX);
1820 static HRESULT WINAPI HTMLStyle_get_borderWidth(IHTMLStyle *iface, BSTR *p)
1822 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1823 TRACE("(%p)->(%p)\n", This, p);
1824 return get_style_attr(This, STYLEID_BORDER_WIDTH, p);
1827 static HRESULT WINAPI HTMLStyle_put_borderTopWidth(IHTMLStyle *iface, VARIANT v)
1829 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1831 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1833 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, &v, 0);
1836 static HRESULT WINAPI HTMLStyle_get_borderTopWidth(IHTMLStyle *iface, VARIANT *p)
1838 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1840 TRACE("(%p)->(%p)\n", This, p);
1842 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, p, 0);
1845 static HRESULT WINAPI HTMLStyle_put_borderRightWidth(IHTMLStyle *iface, VARIANT v)
1847 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1849 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1851 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, &v, 0);
1854 static HRESULT WINAPI HTMLStyle_get_borderRightWidth(IHTMLStyle *iface, VARIANT *p)
1856 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1858 TRACE("(%p)->(%p)\n", This, p);
1860 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, p, 0);
1863 static HRESULT WINAPI HTMLStyle_put_borderBottomWidth(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_BOTTOM_WIDTH, &v, 0);
1872 static HRESULT WINAPI HTMLStyle_get_borderBottomWidth(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_BOTTOM_WIDTH, p, 0);
1879 static HRESULT WINAPI HTMLStyle_put_borderLeftWidth(IHTMLStyle *iface, VARIANT v)
1881 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1883 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1885 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, &v, 0);
1888 static HRESULT WINAPI HTMLStyle_get_borderLeftWidth(IHTMLStyle *iface, VARIANT *p)
1890 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1891 TRACE("(%p)->(%p)\n", This, p);
1892 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, p, 0);
1895 static HRESULT WINAPI HTMLStyle_put_borderStyle(IHTMLStyle *iface, BSTR v)
1897 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1898 static const WCHAR styleWindowInset[] = {'w','i','n','d','o','w','-','i','n','s','e','t',0};
1899 HRESULT hres = S_OK;
1900 BSTR pstyle;
1901 int i=0;
1902 int last = 0;
1904 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1906 while(v[i] && hres == S_OK)
1908 if(v[i] == (WCHAR)' ')
1910 pstyle = SysAllocStringLen(&v[last], (i-last));
1911 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1913 TRACE("1. Invalid style (%s)\n", debugstr_w(pstyle));
1914 hres = E_INVALIDARG;
1916 SysFreeString(pstyle);
1917 last = i+1;
1919 i++;
1922 if(hres == S_OK)
1924 pstyle = SysAllocStringLen(&v[last], i-last);
1925 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1927 TRACE("2. Invalid style (%s)\n", debugstr_w(pstyle));
1928 hres = E_INVALIDARG;
1930 SysFreeString(pstyle);
1933 if(hres == S_OK)
1934 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, v, 0);
1936 return hres;
1939 static HRESULT WINAPI HTMLStyle_get_borderStyle(IHTMLStyle *iface, BSTR *p)
1941 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1942 TRACE("(%p)->(%p)\n", This, p);
1943 return get_style_attr(This, STYLEID_BORDER_STYLE, p);
1946 static HRESULT WINAPI HTMLStyle_put_borderTopStyle(IHTMLStyle *iface, BSTR v)
1948 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1949 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1951 if(!is_valid_border_style(v))
1952 return E_INVALIDARG;
1954 return set_style_attr(This, STYLEID_BORDER_TOP_STYLE, v, 0);
1957 static HRESULT WINAPI HTMLStyle_get_borderTopStyle(IHTMLStyle *iface, BSTR *p)
1959 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1960 TRACE("(%p)->(%p)\n", This, p);
1961 return get_style_attr(This, STYLEID_BORDER_TOP_STYLE, p);
1964 static HRESULT WINAPI HTMLStyle_put_borderRightStyle(IHTMLStyle *iface, BSTR v)
1966 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1967 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1969 if(!is_valid_border_style(v))
1970 return E_INVALIDARG;
1972 return set_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, v, 0);
1975 static HRESULT WINAPI HTMLStyle_get_borderRightStyle(IHTMLStyle *iface, BSTR *p)
1977 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1978 TRACE("(%p)->(%p)\n", This, p);
1979 return get_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, p);
1982 static HRESULT WINAPI HTMLStyle_put_borderBottomStyle(IHTMLStyle *iface, BSTR v)
1984 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1985 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1987 if(!is_valid_border_style(v))
1988 return E_INVALIDARG;
1990 return set_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, v, 0);
1993 static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p)
1995 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1996 TRACE("(%p)->(%p)\n", This, p);
1997 return get_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, p);
2000 static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v)
2002 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2003 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2005 if(!is_valid_border_style(v))
2006 return E_INVALIDARG;
2008 return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0);
2011 static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p)
2013 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2014 TRACE("(%p)->(%p)\n", This, p);
2015 return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p);
2018 static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
2020 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2022 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2024 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX);
2027 static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
2029 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2031 TRACE("(%p)->(%p)\n", This, p);
2033 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, p, 0);
2036 static HRESULT WINAPI HTMLStyle_put_height(IHTMLStyle *iface, VARIANT v)
2038 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2040 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2042 return set_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, &v, ATTR_FIX_PX);
2045 static HRESULT WINAPI HTMLStyle_get_height(IHTMLStyle *iface, VARIANT *p)
2047 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2049 TRACE("(%p)->(%p)\n", This, p);
2051 return get_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, p, 0);
2054 static HRESULT WINAPI HTMLStyle_put_styleFloat(IHTMLStyle *iface, BSTR v)
2056 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2057 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2058 return E_NOTIMPL;
2061 static HRESULT WINAPI HTMLStyle_get_styleFloat(IHTMLStyle *iface, BSTR *p)
2063 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2064 FIXME("(%p)->(%p)\n", This, p);
2065 return E_NOTIMPL;
2068 static HRESULT WINAPI HTMLStyle_put_clear(IHTMLStyle *iface, BSTR v)
2070 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2072 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2074 return set_style_attr(This, STYLEID_CLEAR, v, 0);
2077 static HRESULT WINAPI HTMLStyle_get_clear(IHTMLStyle *iface, BSTR *p)
2079 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2081 TRACE("(%p)->(%p)\n", This, p);
2083 return get_style_attr(This, STYLEID_CLEAR, p);
2086 static HRESULT WINAPI HTMLStyle_put_display(IHTMLStyle *iface, BSTR v)
2088 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2090 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2092 return set_style_attr(This, STYLEID_DISPLAY, v, 0);
2095 static HRESULT WINAPI HTMLStyle_get_display(IHTMLStyle *iface, BSTR *p)
2097 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2099 TRACE("(%p)->(%p)\n", This, p);
2101 return get_style_attr(This, STYLEID_DISPLAY, p);
2104 static HRESULT WINAPI HTMLStyle_put_visibility(IHTMLStyle *iface, BSTR v)
2106 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2108 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2110 return set_style_attr(This, STYLEID_VISIBILITY, v, 0);
2113 static HRESULT WINAPI HTMLStyle_get_visibility(IHTMLStyle *iface, BSTR *p)
2115 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2117 TRACE("(%p)->(%p)\n", This, p);
2119 return get_style_attr(This, STYLEID_VISIBILITY, p);
2122 static HRESULT WINAPI HTMLStyle_put_listStyleType(IHTMLStyle *iface, BSTR v)
2124 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2125 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2126 return E_NOTIMPL;
2129 static HRESULT WINAPI HTMLStyle_get_listStyleType(IHTMLStyle *iface, BSTR *p)
2131 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2132 FIXME("(%p)->(%p)\n", This, p);
2133 return E_NOTIMPL;
2136 static HRESULT WINAPI HTMLStyle_put_listStylePosition(IHTMLStyle *iface, BSTR v)
2138 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2139 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2140 return E_NOTIMPL;
2143 static HRESULT WINAPI HTMLStyle_get_listStylePosition(IHTMLStyle *iface, BSTR *p)
2145 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2146 FIXME("(%p)->(%p)\n", This, p);
2147 return E_NOTIMPL;
2150 static HRESULT WINAPI HTMLStyle_put_listStyleImage(IHTMLStyle *iface, BSTR v)
2152 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2153 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2154 return E_NOTIMPL;
2157 static HRESULT WINAPI HTMLStyle_get_listStyleImage(IHTMLStyle *iface, BSTR *p)
2159 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2160 FIXME("(%p)->(%p)\n", This, p);
2161 return E_NOTIMPL;
2164 static HRESULT WINAPI HTMLStyle_put_listStyle(IHTMLStyle *iface, BSTR v)
2166 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2167 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2168 return E_NOTIMPL;
2171 static HRESULT WINAPI HTMLStyle_get_listStyle(IHTMLStyle *iface, BSTR *p)
2173 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2174 FIXME("(%p)->(%p)\n", This, p);
2175 return E_NOTIMPL;
2178 static HRESULT WINAPI HTMLStyle_put_whiteSpace(IHTMLStyle *iface, BSTR v)
2180 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2181 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2182 return E_NOTIMPL;
2185 static HRESULT WINAPI HTMLStyle_get_whiteSpace(IHTMLStyle *iface, BSTR *p)
2187 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2188 FIXME("(%p)->(%p)\n", This, p);
2189 return E_NOTIMPL;
2192 static HRESULT WINAPI HTMLStyle_put_top(IHTMLStyle *iface, VARIANT v)
2194 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2196 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2198 return set_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, &v, 0);
2201 static HRESULT WINAPI HTMLStyle_get_top(IHTMLStyle *iface, VARIANT *p)
2203 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2205 TRACE("(%p)->(%p)\n", This, p);
2207 return get_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, p, 0);
2210 static HRESULT WINAPI HTMLStyle_put_left(IHTMLStyle *iface, VARIANT v)
2212 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2214 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2216 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, &v, 0);
2219 static HRESULT WINAPI HTMLStyle_get_left(IHTMLStyle *iface, VARIANT *p)
2221 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2223 TRACE("(%p)->(%p)\n", This, p);
2225 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, p, 0);
2228 static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
2230 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2231 TRACE("(%p)->(%p)\n", This, p);
2232 return IHTMLStyle2_get_position(&This->IHTMLStyle2_iface, p);
2235 static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
2237 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2239 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2241 return set_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, &v, 0);
2244 static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
2246 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2248 TRACE("(%p)->(%p)\n", This, p);
2250 return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
2253 static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
2255 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2256 static const WCHAR szVisible[] = {'v','i','s','i','b','l','e',0};
2257 static const WCHAR szScroll[] = {'s','c','r','o','l','l',0};
2258 static const WCHAR szHidden[] = {'h','i','d','d','e','n',0};
2259 static const WCHAR szAuto[] = {'a','u','t','o',0};
2261 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2263 /* overflow can only be one of the follow values. */
2264 if(!v || !*v || strcmpiW(szVisible, v) == 0 || strcmpiW(szScroll, v) == 0 ||
2265 strcmpiW(szHidden, v) == 0 || strcmpiW(szAuto, v) == 0)
2267 return set_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, v, 0);
2270 return E_INVALIDARG;
2274 static HRESULT WINAPI HTMLStyle_get_overflow(IHTMLStyle *iface, BSTR *p)
2276 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2278 TRACE("(%p)->(%p)\n", This, p);
2280 if(!p)
2281 return E_INVALIDARG;
2283 return get_style_attr(This, STYLEID_OVERFLOW, p);
2286 static HRESULT WINAPI HTMLStyle_put_pageBreakBefore(IHTMLStyle *iface, BSTR v)
2288 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2290 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2292 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, v, 0);
2295 static HRESULT WINAPI HTMLStyle_get_pageBreakBefore(IHTMLStyle *iface, BSTR *p)
2297 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2299 TRACE("(%p)->(%p)\n", This, p);
2301 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, p, 0);
2304 static HRESULT WINAPI HTMLStyle_put_pageBreakAfter(IHTMLStyle *iface, BSTR v)
2306 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2308 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2310 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, v, 0);
2313 static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p)
2315 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2317 TRACE("(%p)->(%p)\n", This, p);
2319 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, p, 0);
2322 static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
2324 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2325 nsAString text_str;
2326 nsresult nsres;
2328 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2330 nsAString_InitDepend(&text_str, v);
2331 nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str);
2332 nsAString_Finish(&text_str);
2333 if(NS_FAILED(nsres)) {
2334 FIXME("SetCssStyle failed: %08x\n", nsres);
2335 return E_FAIL;
2338 return S_OK;
2341 static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p)
2343 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2344 nsAString text_str;
2345 nsresult nsres;
2347 TRACE("(%p)->(%p)\n", This, p);
2349 /* FIXME: Gecko style formatting is different than IE (uppercase). */
2350 nsAString_Init(&text_str, NULL);
2351 nsres = nsIDOMCSSStyleDeclaration_GetCssText(This->nsstyle, &text_str);
2352 if(NS_SUCCEEDED(nsres)) {
2353 const PRUnichar *text;
2355 nsAString_GetData(&text_str, &text);
2356 *p = *text ? SysAllocString(text) : NULL;
2357 }else {
2358 FIXME("GetCssStyle failed: %08x\n", nsres);
2359 *p = NULL;
2362 nsAString_Finish(&text_str);
2363 return S_OK;
2366 static HRESULT WINAPI HTMLStyle_put_pixelTop(IHTMLStyle *iface, LONG v)
2368 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2369 FIXME("(%p)->()\n", This);
2370 return E_NOTIMPL;
2373 static HRESULT WINAPI HTMLStyle_get_pixelTop(IHTMLStyle *iface, LONG *p)
2375 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2376 FIXME("(%p)->()\n", This);
2377 return E_NOTIMPL;
2380 static HRESULT WINAPI HTMLStyle_put_pixelLeft(IHTMLStyle *iface, LONG v)
2382 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2383 FIXME("(%p)->()\n", This);
2384 return E_NOTIMPL;
2387 static HRESULT WINAPI HTMLStyle_get_pixelLeft(IHTMLStyle *iface, LONG *p)
2389 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2390 FIXME("(%p)->()\n", This);
2391 return E_NOTIMPL;
2394 static HRESULT WINAPI HTMLStyle_put_pixelWidth(IHTMLStyle *iface, LONG v)
2396 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2398 TRACE("(%p)->()\n", This);
2400 return set_style_pxattr(This->nsstyle, STYLEID_WIDTH, v);
2403 static HRESULT WINAPI HTMLStyle_get_pixelWidth(IHTMLStyle *iface, LONG *p)
2405 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2406 FIXME("(%p)->()\n", This);
2407 return E_NOTIMPL;
2410 static HRESULT WINAPI HTMLStyle_put_pixelHeight(IHTMLStyle *iface, LONG v)
2412 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2413 FIXME("(%p)->()\n", This);
2414 return E_NOTIMPL;
2417 static HRESULT WINAPI HTMLStyle_get_pixelHeight(IHTMLStyle *iface, LONG *p)
2419 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2420 FIXME("(%p)->()\n", This);
2421 return E_NOTIMPL;
2424 static HRESULT WINAPI HTMLStyle_put_posTop(IHTMLStyle *iface, float v)
2426 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2428 TRACE("(%p)->(%f)\n", This, v);
2430 return set_style_pos(This, STYLEID_TOP, v);
2433 static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
2435 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2437 TRACE("(%p)->(%p)\n", This, p);
2439 if(!p)
2440 return E_POINTER;
2442 return get_nsstyle_pos(This, STYLEID_TOP, p);
2445 static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
2447 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2449 TRACE("(%p)->(%f)\n", This, v);
2451 return set_style_pos(This, STYLEID_LEFT, v);
2454 static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
2456 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2458 TRACE("(%p)->(%p)\n", This, p);
2460 if(!p)
2461 return E_POINTER;
2463 return get_nsstyle_pos(This, STYLEID_LEFT, p);
2466 static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
2468 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2470 TRACE("(%p)->(%f)\n", This, v);
2472 return set_style_pos(This, STYLEID_WIDTH, v);
2475 static HRESULT WINAPI HTMLStyle_get_posWidth(IHTMLStyle *iface, float *p)
2477 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2479 TRACE("(%p)->(%p)\n", This, p);
2481 if(!p)
2482 return E_POINTER;
2484 if(get_nsstyle_pos(This, STYLEID_WIDTH, p) != S_OK)
2485 *p = 0.0f;
2487 return S_OK;
2490 static HRESULT WINAPI HTMLStyle_put_posHeight(IHTMLStyle *iface, float v)
2492 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2494 TRACE("(%p)->(%f)\n", This, v);
2496 return set_style_pos(This, STYLEID_HEIGHT, v);
2499 static HRESULT WINAPI HTMLStyle_get_posHeight(IHTMLStyle *iface, float *p)
2501 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2503 TRACE("(%p)->(%p)\n", This, p);
2505 if(!p)
2506 return E_POINTER;
2508 if(get_nsstyle_pos(This, STYLEID_HEIGHT, p) != S_OK)
2509 *p = 0.0f;
2511 return S_OK;
2514 static HRESULT WINAPI HTMLStyle_put_cursor(IHTMLStyle *iface, BSTR v)
2516 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2518 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2520 return set_style_attr(This, STYLEID_CURSOR, v, 0);
2523 static HRESULT WINAPI HTMLStyle_get_cursor(IHTMLStyle *iface, BSTR *p)
2525 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2527 TRACE("(%p)->(%p)\n", This, p);
2529 return get_style_attr(This, STYLEID_CURSOR, p);
2532 static HRESULT WINAPI HTMLStyle_put_clip(IHTMLStyle *iface, BSTR v)
2534 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2536 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2538 return set_style_attr(This, STYLEID_CLIP, v, 0);
2541 static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
2543 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2545 TRACE("(%p)->(%p)\n", This, p);
2547 return get_nsstyle_attr(This->nsstyle, STYLEID_CLIP, p, ATTR_REMOVE_COMMA);
2550 static void set_opacity(HTMLStyle *This, const WCHAR *val)
2552 nsAString name_str, val_str, empty_str;
2553 nsresult nsres;
2555 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y',0};
2557 TRACE("%s\n", debugstr_w(val));
2559 nsAString_InitDepend(&name_str, opacityW);
2560 nsAString_InitDepend(&val_str, val);
2561 nsAString_InitDepend(&empty_str, emptyW);
2563 nsres = nsIDOMCSSStyleDeclaration_SetProperty(This->nsstyle, &name_str, &val_str, &empty_str);
2564 if(NS_FAILED(nsres))
2565 ERR("SetProperty failed: %08x\n", nsres);
2567 nsAString_Finish(&name_str);
2568 nsAString_Finish(&val_str);
2569 nsAString_Finish(&empty_str);
2572 static void update_filter(HTMLStyle *This)
2574 const WCHAR *ptr = This->elem->filter, *ptr2;
2576 static const WCHAR alphaW[] = {'a','l','p','h','a'};
2578 if(!ptr) {
2579 set_opacity(This, emptyW);
2580 return;
2583 while(1) {
2584 while(isspaceW(*ptr))
2585 ptr++;
2586 if(!*ptr)
2587 break;
2589 ptr2 = ptr;
2590 while(isalnumW(*ptr))
2591 ptr++;
2592 if(ptr == ptr2) {
2593 WARN("unexpected char '%c'\n", *ptr);
2594 break;
2596 if(*ptr != '(') {
2597 WARN("expected '('\n");
2598 continue;
2601 if(ptr2 + sizeof(alphaW)/sizeof(WCHAR) == ptr && !memcmp(ptr2, alphaW, sizeof(alphaW))) {
2602 static const WCHAR formatW[] = {'%','f',0};
2603 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y','='};
2605 ptr++;
2606 do {
2607 while(isspaceW(*ptr))
2608 ptr++;
2610 ptr2 = ptr;
2611 while(*ptr && *ptr != ',' && *ptr != ')')
2612 ptr++;
2613 if(!*ptr) {
2614 WARN("unexpected end of string\n");
2615 break;
2618 if(ptr-ptr2 > sizeof(opacityW)/sizeof(WCHAR) && !memcmp(ptr2, opacityW, sizeof(opacityW))) {
2619 float fval = 0.0f, e = 0.1f;
2620 WCHAR buf[32];
2622 ptr2 += sizeof(opacityW)/sizeof(WCHAR);
2624 while(isdigitW(*ptr2))
2625 fval = fval*10.0f + (float)(*ptr2++ - '0');
2627 if(*ptr2 == '.') {
2628 while(isdigitW(*++ptr2)) {
2629 fval += e * (float)(*ptr2++ - '0');
2630 e *= 0.1f;
2634 sprintfW(buf, formatW, fval * 0.01f);
2635 set_opacity(This, buf);
2636 }else {
2637 FIXME("unknown param %s\n", debugstr_wn(ptr2, ptr-ptr2));
2640 if(*ptr == ',')
2641 ptr++;
2642 }while(*ptr != ')');
2643 }else {
2644 FIXME("unknown filter %s\n", debugstr_wn(ptr2, ptr-ptr2));
2645 ptr = strchrW(ptr, ')');
2646 if(!ptr)
2647 break;
2648 ptr++;
2653 static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
2655 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2656 WCHAR *new_filter = NULL;
2658 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2660 if(!This->elem) {
2661 FIXME("Element already destroyed\n");
2662 return E_UNEXPECTED;
2665 if(v) {
2666 new_filter = heap_strdupW(v);
2667 if(!new_filter)
2668 return E_OUTOFMEMORY;
2671 heap_free(This->elem->filter);
2672 This->elem->filter = new_filter;
2674 update_filter(This);
2675 return S_OK;
2678 static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
2680 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2682 TRACE("(%p)->(%p)\n", This, p);
2684 if(!This->elem) {
2685 FIXME("Element already destroyed\n");
2686 return E_UNEXPECTED;
2689 if(This->elem->filter) {
2690 *p = SysAllocString(This->elem->filter);
2691 if(!*p)
2692 return E_OUTOFMEMORY;
2693 }else {
2694 *p = NULL;
2697 return S_OK;
2700 static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2701 VARIANT AttributeValue, LONG lFlags)
2703 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2704 HRESULT hres;
2705 DISPID dispid;
2707 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName),
2708 debugstr_variant(&AttributeValue), lFlags);
2710 if(!strAttributeName)
2711 return E_INVALIDARG;
2713 if(lFlags == 1)
2714 FIXME("Parameter lFlags ignored\n");
2716 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2717 LOCALE_USER_DEFAULT, &dispid);
2718 if(hres == S_OK)
2720 VARIANT ret;
2721 DISPID dispidNamed = DISPID_PROPERTYPUT;
2722 DISPPARAMS params;
2724 params.cArgs = 1;
2725 params.rgvarg = &AttributeValue;
2726 params.cNamedArgs = 1;
2727 params.rgdispidNamedArgs = &dispidNamed;
2729 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2730 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2732 else
2734 FIXME("Custom attributes not supported.\n");
2737 TRACE("ret: %08x\n", hres);
2739 return hres;
2742 static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2743 LONG lFlags, VARIANT *AttributeValue)
2745 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2746 HRESULT hres;
2747 DISPID dispid;
2749 TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName),
2750 AttributeValue, lFlags);
2752 if(!AttributeValue || !strAttributeName)
2753 return E_INVALIDARG;
2755 if(lFlags == 1)
2756 FIXME("Parameter lFlags ignored\n");
2758 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2759 LOCALE_USER_DEFAULT, &dispid);
2760 if(hres == S_OK)
2762 DISPPARAMS params = {NULL, NULL, 0, 0 };
2764 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2765 DISPATCH_PROPERTYGET, &params, AttributeValue, NULL, NULL);
2767 else
2769 FIXME("Custom attributes not supported.\n");
2772 return hres;
2775 static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2776 LONG lFlags, VARIANT_BOOL *pfSuccess)
2778 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2779 const style_tbl_entry_t *style_entry;
2780 nsAString name_str, ret_str;
2781 nsresult nsres;
2782 HRESULT hres;
2784 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
2786 style_entry = lookup_style_tbl(strAttributeName);
2787 if(!style_entry) {
2788 DISPID dispid;
2789 unsigned i;
2791 hres = IDispatchEx_GetDispID(&This->dispex.IDispatchEx_iface, strAttributeName,
2792 (lFlags&1) ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
2793 if(hres != S_OK) {
2794 *pfSuccess = VARIANT_FALSE;
2795 return S_OK;
2798 for(i=0; i < sizeof(style_tbl)/sizeof(*style_tbl); i++) {
2799 if(dispid == style_tbl[i].dispid)
2800 break;
2803 if(i == sizeof(style_tbl)/sizeof(*style_tbl))
2804 return remove_prop(&This->dispex, strAttributeName, pfSuccess);
2805 style_entry = style_tbl+i;
2808 /* filter property is a special case */
2809 if(style_entry->dispid == DISPID_IHTMLSTYLE_FILTER) {
2810 *pfSuccess = This->elem->filter && *This->elem->filter ? VARIANT_TRUE : VARIANT_FALSE;
2811 heap_free(This->elem->filter);
2812 This->elem->filter = NULL;
2813 update_filter(This);
2814 return S_OK;
2817 nsAString_InitDepend(&name_str, style_entry->name);
2818 nsAString_Init(&ret_str, NULL);
2819 nsres = nsIDOMCSSStyleDeclaration_RemoveProperty(This->nsstyle, &name_str, &ret_str);
2820 if(NS_SUCCEEDED(nsres)) {
2821 const PRUnichar *ret;
2822 nsAString_GetData(&ret_str, &ret);
2823 *pfSuccess = *ret ? VARIANT_TRUE : VARIANT_FALSE;
2824 }else {
2825 ERR("RemoveProperty failed: %08x\n", nsres);
2827 nsAString_Finish(&name_str);
2828 nsAString_Finish(&ret_str);
2829 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
2832 static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
2834 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2835 FIXME("(%p)->(%p)\n", This, String);
2836 return E_NOTIMPL;
2839 static const IHTMLStyleVtbl HTMLStyleVtbl = {
2840 HTMLStyle_QueryInterface,
2841 HTMLStyle_AddRef,
2842 HTMLStyle_Release,
2843 HTMLStyle_GetTypeInfoCount,
2844 HTMLStyle_GetTypeInfo,
2845 HTMLStyle_GetIDsOfNames,
2846 HTMLStyle_Invoke,
2847 HTMLStyle_put_fontFamily,
2848 HTMLStyle_get_fontFamily,
2849 HTMLStyle_put_fontStyle,
2850 HTMLStyle_get_fontStyle,
2851 HTMLStyle_put_fontVariant,
2852 HTMLStyle_get_fontVariant,
2853 HTMLStyle_put_fontWeight,
2854 HTMLStyle_get_fontWeight,
2855 HTMLStyle_put_fontSize,
2856 HTMLStyle_get_fontSize,
2857 HTMLStyle_put_font,
2858 HTMLStyle_get_font,
2859 HTMLStyle_put_color,
2860 HTMLStyle_get_color,
2861 HTMLStyle_put_background,
2862 HTMLStyle_get_background,
2863 HTMLStyle_put_backgroundColor,
2864 HTMLStyle_get_backgroundColor,
2865 HTMLStyle_put_backgroundImage,
2866 HTMLStyle_get_backgroundImage,
2867 HTMLStyle_put_backgroundRepeat,
2868 HTMLStyle_get_backgroundRepeat,
2869 HTMLStyle_put_backgroundAttachment,
2870 HTMLStyle_get_backgroundAttachment,
2871 HTMLStyle_put_backgroundPosition,
2872 HTMLStyle_get_backgroundPosition,
2873 HTMLStyle_put_backgroundPositionX,
2874 HTMLStyle_get_backgroundPositionX,
2875 HTMLStyle_put_backgroundPositionY,
2876 HTMLStyle_get_backgroundPositionY,
2877 HTMLStyle_put_wordSpacing,
2878 HTMLStyle_get_wordSpacing,
2879 HTMLStyle_put_letterSpacing,
2880 HTMLStyle_get_letterSpacing,
2881 HTMLStyle_put_textDecoration,
2882 HTMLStyle_get_textDecoration,
2883 HTMLStyle_put_textDecorationNone,
2884 HTMLStyle_get_textDecorationNone,
2885 HTMLStyle_put_textDecorationUnderline,
2886 HTMLStyle_get_textDecorationUnderline,
2887 HTMLStyle_put_textDecorationOverline,
2888 HTMLStyle_get_textDecorationOverline,
2889 HTMLStyle_put_textDecorationLineThrough,
2890 HTMLStyle_get_textDecorationLineThrough,
2891 HTMLStyle_put_textDecorationBlink,
2892 HTMLStyle_get_textDecorationBlink,
2893 HTMLStyle_put_verticalAlign,
2894 HTMLStyle_get_verticalAlign,
2895 HTMLStyle_put_textTransform,
2896 HTMLStyle_get_textTransform,
2897 HTMLStyle_put_textAlign,
2898 HTMLStyle_get_textAlign,
2899 HTMLStyle_put_textIndent,
2900 HTMLStyle_get_textIndent,
2901 HTMLStyle_put_lineHeight,
2902 HTMLStyle_get_lineHeight,
2903 HTMLStyle_put_marginTop,
2904 HTMLStyle_get_marginTop,
2905 HTMLStyle_put_marginRight,
2906 HTMLStyle_get_marginRight,
2907 HTMLStyle_put_marginBottom,
2908 HTMLStyle_get_marginBottom,
2909 HTMLStyle_put_marginLeft,
2910 HTMLStyle_get_marginLeft,
2911 HTMLStyle_put_margin,
2912 HTMLStyle_get_margin,
2913 HTMLStyle_put_paddingTop,
2914 HTMLStyle_get_paddingTop,
2915 HTMLStyle_put_paddingRight,
2916 HTMLStyle_get_paddingRight,
2917 HTMLStyle_put_paddingBottom,
2918 HTMLStyle_get_paddingBottom,
2919 HTMLStyle_put_paddingLeft,
2920 HTMLStyle_get_paddingLeft,
2921 HTMLStyle_put_padding,
2922 HTMLStyle_get_padding,
2923 HTMLStyle_put_border,
2924 HTMLStyle_get_border,
2925 HTMLStyle_put_borderTop,
2926 HTMLStyle_get_borderTop,
2927 HTMLStyle_put_borderRight,
2928 HTMLStyle_get_borderRight,
2929 HTMLStyle_put_borderBottom,
2930 HTMLStyle_get_borderBottom,
2931 HTMLStyle_put_borderLeft,
2932 HTMLStyle_get_borderLeft,
2933 HTMLStyle_put_borderColor,
2934 HTMLStyle_get_borderColor,
2935 HTMLStyle_put_borderTopColor,
2936 HTMLStyle_get_borderTopColor,
2937 HTMLStyle_put_borderRightColor,
2938 HTMLStyle_get_borderRightColor,
2939 HTMLStyle_put_borderBottomColor,
2940 HTMLStyle_get_borderBottomColor,
2941 HTMLStyle_put_borderLeftColor,
2942 HTMLStyle_get_borderLeftColor,
2943 HTMLStyle_put_borderWidth,
2944 HTMLStyle_get_borderWidth,
2945 HTMLStyle_put_borderTopWidth,
2946 HTMLStyle_get_borderTopWidth,
2947 HTMLStyle_put_borderRightWidth,
2948 HTMLStyle_get_borderRightWidth,
2949 HTMLStyle_put_borderBottomWidth,
2950 HTMLStyle_get_borderBottomWidth,
2951 HTMLStyle_put_borderLeftWidth,
2952 HTMLStyle_get_borderLeftWidth,
2953 HTMLStyle_put_borderStyle,
2954 HTMLStyle_get_borderStyle,
2955 HTMLStyle_put_borderTopStyle,
2956 HTMLStyle_get_borderTopStyle,
2957 HTMLStyle_put_borderRightStyle,
2958 HTMLStyle_get_borderRightStyle,
2959 HTMLStyle_put_borderBottomStyle,
2960 HTMLStyle_get_borderBottomStyle,
2961 HTMLStyle_put_borderLeftStyle,
2962 HTMLStyle_get_borderLeftStyle,
2963 HTMLStyle_put_width,
2964 HTMLStyle_get_width,
2965 HTMLStyle_put_height,
2966 HTMLStyle_get_height,
2967 HTMLStyle_put_styleFloat,
2968 HTMLStyle_get_styleFloat,
2969 HTMLStyle_put_clear,
2970 HTMLStyle_get_clear,
2971 HTMLStyle_put_display,
2972 HTMLStyle_get_display,
2973 HTMLStyle_put_visibility,
2974 HTMLStyle_get_visibility,
2975 HTMLStyle_put_listStyleType,
2976 HTMLStyle_get_listStyleType,
2977 HTMLStyle_put_listStylePosition,
2978 HTMLStyle_get_listStylePosition,
2979 HTMLStyle_put_listStyleImage,
2980 HTMLStyle_get_listStyleImage,
2981 HTMLStyle_put_listStyle,
2982 HTMLStyle_get_listStyle,
2983 HTMLStyle_put_whiteSpace,
2984 HTMLStyle_get_whiteSpace,
2985 HTMLStyle_put_top,
2986 HTMLStyle_get_top,
2987 HTMLStyle_put_left,
2988 HTMLStyle_get_left,
2989 HTMLStyle_get_position,
2990 HTMLStyle_put_zIndex,
2991 HTMLStyle_get_zIndex,
2992 HTMLStyle_put_overflow,
2993 HTMLStyle_get_overflow,
2994 HTMLStyle_put_pageBreakBefore,
2995 HTMLStyle_get_pageBreakBefore,
2996 HTMLStyle_put_pageBreakAfter,
2997 HTMLStyle_get_pageBreakAfter,
2998 HTMLStyle_put_cssText,
2999 HTMLStyle_get_cssText,
3000 HTMLStyle_put_pixelTop,
3001 HTMLStyle_get_pixelTop,
3002 HTMLStyle_put_pixelLeft,
3003 HTMLStyle_get_pixelLeft,
3004 HTMLStyle_put_pixelWidth,
3005 HTMLStyle_get_pixelWidth,
3006 HTMLStyle_put_pixelHeight,
3007 HTMLStyle_get_pixelHeight,
3008 HTMLStyle_put_posTop,
3009 HTMLStyle_get_posTop,
3010 HTMLStyle_put_posLeft,
3011 HTMLStyle_get_posLeft,
3012 HTMLStyle_put_posWidth,
3013 HTMLStyle_get_posWidth,
3014 HTMLStyle_put_posHeight,
3015 HTMLStyle_get_posHeight,
3016 HTMLStyle_put_cursor,
3017 HTMLStyle_get_cursor,
3018 HTMLStyle_put_clip,
3019 HTMLStyle_get_clip,
3020 HTMLStyle_put_filter,
3021 HTMLStyle_get_filter,
3022 HTMLStyle_setAttribute,
3023 HTMLStyle_getAttribute,
3024 HTMLStyle_removeAttribute,
3025 HTMLStyle_toString
3028 static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
3030 const style_tbl_entry_t *style_entry;
3032 style_entry = lookup_style_tbl(name);
3033 if(style_entry) {
3034 *dispid = style_entry->dispid;
3035 return S_OK;
3038 return DISP_E_UNKNOWNNAME;
3041 static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
3042 NULL,
3043 HTMLStyle_get_dispid,
3044 NULL,
3045 NULL
3048 static const tid_t HTMLStyle_iface_tids[] = {
3049 IHTMLStyle_tid,
3050 IHTMLStyle2_tid,
3051 IHTMLStyle3_tid,
3052 IHTMLStyle4_tid,
3053 IHTMLStyle5_tid,
3054 IHTMLStyle6_tid,
3057 static dispex_static_data_t HTMLStyle_dispex = {
3058 &HTMLStyle_dispex_vtbl,
3059 DispHTMLStyle_tid,
3060 NULL,
3061 HTMLStyle_iface_tids
3064 HRESULT HTMLStyle_Create(HTMLElement *elem, HTMLStyle **ret)
3066 nsIDOMElementCSSInlineStyle *nselemstyle;
3067 nsIDOMCSSStyleDeclaration *nsstyle;
3068 HTMLStyle *style;
3069 nsresult nsres;
3071 if(!elem->nselem) {
3072 FIXME("NULL nselem\n");
3073 return E_NOTIMPL;
3076 nsres = nsIDOMHTMLElement_QueryInterface(elem->nselem, &IID_nsIDOMElementCSSInlineStyle,
3077 (void**)&nselemstyle);
3078 assert(nsres == NS_OK);
3080 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
3081 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
3082 if(NS_FAILED(nsres)) {
3083 ERR("GetStyle failed: %08x\n", nsres);
3084 return E_FAIL;
3087 style = heap_alloc_zero(sizeof(HTMLStyle));
3088 if(!style) {
3089 nsIDOMCSSStyleDeclaration_Release(nsstyle);
3090 return E_OUTOFMEMORY;
3093 style->IHTMLStyle_iface.lpVtbl = &HTMLStyleVtbl;
3094 style->ref = 1;
3095 style->nsstyle = nsstyle;
3096 style->elem = elem;
3097 HTMLStyle2_Init(style);
3098 HTMLStyle3_Init(style);
3100 nsIDOMCSSStyleDeclaration_AddRef(nsstyle);
3102 init_dispex(&style->dispex, (IUnknown*)&style->IHTMLStyle_iface, &HTMLStyle_dispex);
3104 *ret = style;
3105 return S_OK;