mshtml: Added IHTMLStyle6::boxSizing property implementation.
[wine.git] / dlls / mshtml / htmlstyle.c
blob5f4fc67ce5742581500d8a5fb1831c9e48df8cdb
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 /* FIXME: Use unprefixed version (requires Gecko changes). */
95 static const WCHAR attrBoxSizing[] =
96 {'-','m','o','z','-','b','o','x','-','s','i','z','i','n','g',0};
97 static const WCHAR attrClear[] =
98 {'c','l','e','a','r',0};
99 static const WCHAR attrClip[] =
100 {'c','l','i','p',0};
101 static const WCHAR attrColor[] =
102 {'c','o','l','o','r',0};
103 static const WCHAR attrCursor[] =
104 {'c','u','r','s','o','r',0};
105 static const WCHAR attrDirection[] =
106 {'d','i','r','e','c','t','i','o','n',0};
107 static const WCHAR attrDisplay[] =
108 {'d','i','s','p','l','a','y',0};
109 static const WCHAR attrFilter[] =
110 {'f','i','l','e','t','e','r',0};
111 static const WCHAR attrFontFamily[] =
112 {'f','o','n','t','-','f','a','m','i','l','y',0};
113 static const WCHAR attrFontSize[] =
114 {'f','o','n','t','-','s','i','z','e',0};
115 static const WCHAR attrFontStyle[] =
116 {'f','o','n','t','-','s','t','y','l','e',0};
117 static const WCHAR attrFontVariant[] =
118 {'f','o','n','t','-','v','a','r','i','a','n','t',0};
119 static const WCHAR attrFontWeight[] =
120 {'f','o','n','t','-','w','e','i','g','h','t',0};
121 static const WCHAR attrHeight[] =
122 {'h','e','i','g','h','t',0};
123 static const WCHAR attrLeft[] =
124 {'l','e','f','t',0};
125 static const WCHAR attrLetterSpacing[] =
126 {'l','e','t','t','e','r','-','s','p','a','c','i','n','g',0};
127 static const WCHAR attrLineHeight[] =
128 {'l','i','n','e','-','h','e','i','g','h','t',0};
129 static const WCHAR attrMargin[] =
130 {'m','a','r','g','i','n',0};
131 static const WCHAR attrMarginBottom[] =
132 {'m','a','r','g','i','n','-','b','o','t','t','o','m',0};
133 static const WCHAR attrMarginLeft[] =
134 {'m','a','r','g','i','n','-','l','e','f','t',0};
135 static const WCHAR attrMarginRight[] =
136 {'m','a','r','g','i','n','-','r','i','g','h','t',0};
137 static const WCHAR attrMarginTop[] =
138 {'m','a','r','g','i','n','-','t','o','p',0};
139 static const WCHAR attrMinHeight[] =
140 {'m','i','n','-','h','e','i','g','h','t',0};
141 static const WCHAR attrOutline[] =
142 {'o','u','t','l','i','n','e',0};
143 static const WCHAR attrOverflow[] =
144 {'o','v','e','r','f','l','o','w',0};
145 static const WCHAR attrOverflowX[] =
146 {'o','v','e','r','f','l','o','w','-','x',0};
147 static const WCHAR attrOverflowY[] =
148 {'o','v','e','r','f','l','o','w','-','y',0};
149 static const WCHAR attrPadding[] =
150 {'p','a','d','d','i','n','g',0};
151 static const WCHAR attrPaddingBottom[] =
152 {'p','a','d','d','i','n','g','-','b','o','t','t','o','m',0};
153 static const WCHAR attrPaddingLeft[] =
154 {'p','a','d','d','i','n','g','-','l','e','f','t',0};
155 static const WCHAR attrPaddingRight[] =
156 {'p','a','d','d','i','n','g','-','r','i','g','h','t',0};
157 static const WCHAR attrPaddingTop[] =
158 {'p','a','d','d','i','n','g','-','t','o','p',0};
159 static const WCHAR attrPageBreakAfter[] =
160 {'p','a','g','e','-','b','r','e','a','k','-','a','f','t','e','r',0};
161 static const WCHAR attrPageBreakBefore[] =
162 {'p','a','g','e','-','b','r','e','a','k','-','b','e','f','o','r','e',0};
163 static const WCHAR attrPosition[] =
164 {'p','o','s','i','t','i','o','n',0};
165 static const WCHAR attrRight[] =
166 {'r','i','g','h','t',0};
167 static const WCHAR attrTextAlign[] =
168 {'t','e','x','t','-','a','l','i','g','n',0};
169 static const WCHAR attrTextDecoration[] =
170 {'t','e','x','t','-','d','e','c','o','r','a','t','i','o','n',0};
171 static const WCHAR attrTextIndent[] =
172 {'t','e','x','t','-','i','n','d','e','n','t',0};
173 static const WCHAR attrTop[] =
174 {'t','o','p',0};
175 static const WCHAR attrVerticalAlign[] =
176 {'v','e','r','t','i','c','a','l','-','a','l','i','g','n',0};
177 static const WCHAR attrVisibility[] =
178 {'v','i','s','i','b','i','l','i','t','y',0};
179 static const WCHAR attrWhiteSpace[] =
180 {'w','h','i','t','e','-','s','p','a','c','e',0};
181 static const WCHAR attrWidth[] =
182 {'w','i','d','t','h',0};
183 static const WCHAR attrWordSpacing[] =
184 {'w','o','r','d','-','s','p','a','c','i','n','g',0};
185 static const WCHAR attrWordWrap[] =
186 {'w','o','r','d','-','w','r','a','p',0};
187 static const WCHAR attrZIndex[] =
188 {'z','-','i','n','d','e','x',0};
191 static const WCHAR pxW[] = {'p','x',0};
193 typedef struct {
194 const WCHAR *name;
195 DISPID dispid;
196 } style_tbl_entry_t;
198 static const style_tbl_entry_t style_tbl[] = {
199 {attrBackground, DISPID_IHTMLSTYLE_BACKGROUND},
200 {attrBackgroundColor, DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
201 {attrBackgroundImage, DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
202 {attrBackgroundPosition, DISPID_IHTMLSTYLE_BACKGROUNDPOSITION},
203 {attrBackgroundPositionX, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONX},
204 {attrBackgroundPositionY, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
205 {attrBackgroundRepeat, DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
206 {attrBorder, DISPID_IHTMLSTYLE_BORDER},
207 {attrBorderBottom, DISPID_IHTMLSTYLE_BORDERBOTTOM},
208 {attrBorderBottomColor, DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR},
209 {attrBorderBottomStyle, DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
210 {attrBorderBottomWidth, DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
211 {attrBorderColor, DISPID_IHTMLSTYLE_BORDERCOLOR},
212 {attrBorderLeft, DISPID_IHTMLSTYLE_BORDERLEFT},
213 {attrBorderLeftColor, DISPID_IHTMLSTYLE_BORDERLEFTCOLOR},
214 {attrBorderLeftStyle, DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
215 {attrBorderLeftWidth, DISPID_IHTMLSTYLE_BORDERLEFTWIDTH},
216 {attrBorderRight, DISPID_IHTMLSTYLE_BORDERRIGHT},
217 {attrBorderRightColor, DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR},
218 {attrBorderRightStyle, DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
219 {attrBorderRightWidth, DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
220 {attrBorderStyle, DISPID_IHTMLSTYLE_BORDERSTYLE},
221 {attrBorderTop, DISPID_IHTMLSTYLE_BORDERTOP},
222 {attrBorderTopColor, DISPID_IHTMLSTYLE_BORDERTOPCOLOR},
223 {attrBorderTopStyle, DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
224 {attrBorderTopWidth, DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
225 {attrBorderWidth, DISPID_IHTMLSTYLE_BORDERWIDTH},
226 {attrBottom, DISPID_IHTMLSTYLE2_BOTTOM},
227 {attrBoxSizing, DISPID_IHTMLSTYLE6_BOXSIZING},
228 {attrClear, DISPID_IHTMLSTYLE_CLEAR},
229 {attrClip, DISPID_IHTMLSTYLE_CLIP},
230 {attrColor, DISPID_IHTMLSTYLE_COLOR},
231 {attrCursor, DISPID_IHTMLSTYLE_CURSOR},
232 {attrDirection, DISPID_IHTMLSTYLE2_DIRECTION},
233 {attrDisplay, DISPID_IHTMLSTYLE_DISPLAY},
234 {attrFilter, DISPID_IHTMLSTYLE_FILTER},
235 {attrFontFamily, DISPID_IHTMLSTYLE_FONTFAMILY},
236 {attrFontSize, DISPID_IHTMLSTYLE_FONTSIZE},
237 {attrFontStyle, DISPID_IHTMLSTYLE_FONTSTYLE},
238 {attrFontVariant, DISPID_IHTMLSTYLE_FONTVARIANT},
239 {attrFontWeight, DISPID_IHTMLSTYLE_FONTWEIGHT},
240 {attrHeight, DISPID_IHTMLSTYLE_HEIGHT},
241 {attrLeft, DISPID_IHTMLSTYLE_LEFT},
242 {attrLetterSpacing, DISPID_IHTMLSTYLE_LETTERSPACING},
243 {attrLineHeight, DISPID_IHTMLSTYLE_LINEHEIGHT},
244 {attrMargin, DISPID_IHTMLSTYLE_MARGIN},
245 {attrMarginBottom, DISPID_IHTMLSTYLE_MARGINBOTTOM},
246 {attrMarginLeft, DISPID_IHTMLSTYLE_MARGINLEFT},
247 {attrMarginRight, DISPID_IHTMLSTYLE_MARGINRIGHT},
248 {attrMarginTop, DISPID_IHTMLSTYLE_MARGINTOP},
249 {attrMinHeight, DISPID_IHTMLSTYLE4_MINHEIGHT},
250 {attrOutline, DISPID_IHTMLSTYLE6_OUTLINE},
251 {attrOverflow, DISPID_IHTMLSTYLE_OVERFLOW},
252 {attrOverflowX, DISPID_IHTMLSTYLE2_OVERFLOWX},
253 {attrOverflowY, DISPID_IHTMLSTYLE2_OVERFLOWY},
254 {attrPadding, DISPID_IHTMLSTYLE_PADDING},
255 {attrPaddingBottom, DISPID_IHTMLSTYLE_PADDINGBOTTOM},
256 {attrPaddingLeft, DISPID_IHTMLSTYLE_PADDINGLEFT},
257 {attrPaddingRight, DISPID_IHTMLSTYLE_PADDINGRIGHT},
258 {attrPaddingTop, DISPID_IHTMLSTYLE_PADDINGTOP},
259 {attrPageBreakAfter, DISPID_IHTMLSTYLE_PAGEBREAKAFTER},
260 {attrPageBreakBefore, DISPID_IHTMLSTYLE_PAGEBREAKBEFORE},
261 {attrPosition, DISPID_IHTMLSTYLE2_POSITION},
262 {attrRight, DISPID_IHTMLSTYLE2_RIGHT},
263 {attrTextAlign, DISPID_IHTMLSTYLE_TEXTALIGN},
264 {attrTextDecoration, DISPID_IHTMLSTYLE_TEXTDECORATION},
265 {attrTextIndent, DISPID_IHTMLSTYLE_TEXTINDENT},
266 {attrTop, DISPID_IHTMLSTYLE_TOP},
267 {attrVerticalAlign, DISPID_IHTMLSTYLE_VERTICALALIGN},
268 {attrVisibility, DISPID_IHTMLSTYLE_VISIBILITY},
269 {attrWhiteSpace, DISPID_IHTMLSTYLE_WHITESPACE},
270 {attrWidth, DISPID_IHTMLSTYLE_WIDTH},
271 {attrWordSpacing, DISPID_IHTMLSTYLE_WORDSPACING},
272 {attrWordWrap, DISPID_IHTMLSTYLE3_WORDWRAP},
273 {attrZIndex, DISPID_IHTMLSTYLE_ZINDEX}
276 static const WCHAR valLineThrough[] =
277 {'l','i','n','e','-','t','h','r','o','u','g','h',0};
278 static const WCHAR valUnderline[] =
279 {'u','n','d','e','r','l','i','n','e',0};
280 static const WCHAR szNormal[] =
281 {'n','o','r','m','a','l',0};
282 static const WCHAR styleNone[] =
283 {'n','o','n','e',0};
284 static const WCHAR valOverline[] =
285 {'o','v','e','r','l','i','n','e',0};
286 static const WCHAR valBlink[] =
287 {'b','l','i','n','k',0};
289 static const WCHAR px_formatW[] = {'%','d','p','x',0};
290 static const WCHAR emptyW[] = {0};
292 static const style_tbl_entry_t *lookup_style_tbl(const WCHAR *name)
294 int c, i, min = 0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
296 while(min <= max) {
297 i = (min+max)/2;
299 c = strcmpW(style_tbl[i].name, name);
300 if(!c)
301 return style_tbl+i;
303 if(c > 0)
304 max = i-1;
305 else
306 min = i+1;
309 return NULL;
312 static LPWSTR fix_px_value(LPCWSTR val)
314 LPCWSTR ptr = val;
316 while(*ptr) {
317 while(*ptr && isspaceW(*ptr))
318 ptr++;
319 if(!*ptr)
320 break;
322 while(*ptr && isdigitW(*ptr))
323 ptr++;
325 if(!*ptr || isspaceW(*ptr)) {
326 LPWSTR ret, p;
327 int len = strlenW(val)+1;
329 ret = heap_alloc((len+2)*sizeof(WCHAR));
330 memcpy(ret, val, (ptr-val)*sizeof(WCHAR));
331 p = ret + (ptr-val);
332 *p++ = 'p';
333 *p++ = 'x';
334 strcpyW(p, ptr);
336 TRACE("fixed %s -> %s\n", debugstr_w(val), debugstr_w(ret));
338 return ret;
341 while(*ptr && !isspaceW(*ptr))
342 ptr++;
345 return NULL;
348 static LPWSTR fix_url_value(LPCWSTR val)
350 WCHAR *ret, *ptr;
352 static const WCHAR urlW[] = {'u','r','l','('};
354 if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
355 return NULL;
357 ret = heap_strdupW(val);
359 for(ptr = ret; *ptr; ptr++) {
360 if(*ptr == '\\')
361 *ptr = '/';
364 return ret;
367 HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, const WCHAR *value, DWORD flags)
369 nsAString str_name, str_value, str_empty;
370 LPWSTR val = NULL;
371 nsresult nsres;
373 if(value) {
374 if(flags & ATTR_FIX_PX)
375 val = fix_px_value(value);
376 if(flags & ATTR_FIX_URL)
377 val = fix_url_value(value);
380 nsAString_InitDepend(&str_name, style_tbl[sid].name);
381 nsAString_InitDepend(&str_value, val ? val : value);
382 nsAString_InitDepend(&str_empty, emptyW);
384 nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
385 if(NS_FAILED(nsres))
386 ERR("SetProperty failed: %08x\n", nsres);
388 nsAString_Finish(&str_name);
389 nsAString_Finish(&str_value);
390 nsAString_Finish(&str_empty);
391 heap_free(val);
393 return S_OK;
396 static HRESULT var_to_styleval(const VARIANT *v, WCHAR *buf, DWORD flags, const WCHAR **ret)
398 switch(V_VT(v)) {
399 case VT_NULL:
400 *ret = emptyW;
401 return S_OK;
403 case VT_BSTR:
404 *ret = V_BSTR(v);
405 return S_OK;
407 case VT_BSTR|VT_BYREF:
408 *ret = *V_BSTRREF(v);
409 return S_OK;
411 case VT_I4: {
412 static const WCHAR formatW[] = {'%','d',0};
413 static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
415 if(flags & ATTR_HEX_INT)
416 wsprintfW(buf, hex_formatW, V_I4(v));
417 else if(flags & ATTR_FIX_PX)
418 wsprintfW(buf, px_formatW, V_I4(v));
419 else
420 wsprintfW(buf, formatW, V_I4(v));
422 *ret = buf;
423 return S_OK;
425 default:
426 FIXME("not implemented for %s\n", debugstr_variant(v));
427 return E_NOTIMPL;
432 HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *value, DWORD flags)
434 const WCHAR *val;
435 WCHAR buf[14];
436 HRESULT hres;
438 hres = var_to_styleval(value, buf, flags, &val);
439 if(FAILED(hres))
440 return hres;
442 return set_nsstyle_attr(nsstyle, sid, val, flags);
445 static inline HRESULT set_style_attr(HTMLStyle *This, styleid_t sid, LPCWSTR value, DWORD flags)
447 return set_nsstyle_attr(This->nsstyle, sid, value, flags);
450 static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, nsAString *value)
452 nsAString str_name;
453 nsresult nsres;
455 nsAString_InitDepend(&str_name, style_tbl[sid].name);
457 nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
458 if(NS_FAILED(nsres)) {
459 ERR("SetProperty failed: %08x\n", nsres);
460 return E_FAIL;
463 nsAString_Finish(&str_name);
465 return NS_OK;
468 static HRESULT nsstyle_to_bstr(const WCHAR *val, DWORD flags, BSTR *p)
470 BSTR ret;
471 DWORD len;
473 if(!*val) {
474 *p = (flags & ATTR_NO_NULL) ? SysAllocStringLen(NULL, 0) : NULL;
475 return S_OK;
478 ret = SysAllocString(val);
479 if(!ret)
480 return E_OUTOFMEMORY;
482 len = SysStringLen(ret);
484 if(flags & ATTR_REMOVE_COMMA) {
485 DWORD new_len = len;
486 WCHAR *ptr, *ptr2;
488 for(ptr = ret; (ptr = strchrW(ptr, ',')); ptr++)
489 new_len--;
491 if(new_len != len) {
492 BSTR new_ret;
494 new_ret = SysAllocStringLen(NULL, new_len);
495 if(!new_ret) {
496 SysFreeString(ret);
497 return E_OUTOFMEMORY;
500 for(ptr2 = new_ret, ptr = ret; *ptr; ptr++) {
501 if(*ptr != ',')
502 *ptr2++ = *ptr;
505 SysFreeString(ret);
506 ret = new_ret;
510 *p = ret;
511 return S_OK;
514 HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR *p, DWORD flags)
516 nsAString str_value;
517 const PRUnichar *value;
518 HRESULT hres;
520 nsAString_Init(&str_value, NULL);
522 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
524 nsAString_GetData(&str_value, &value);
525 hres = nsstyle_to_bstr(value, flags, p);
526 nsAString_Finish(&str_value);
528 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_w(*p));
529 return hres;
532 HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
534 nsAString str_value;
535 const PRUnichar *value;
536 BOOL set = FALSE;
537 HRESULT hres = S_OK;
539 nsAString_Init(&str_value, NULL);
541 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
543 nsAString_GetData(&str_value, &value);
545 if(flags & ATTR_STR_TO_INT) {
546 const PRUnichar *ptr = value;
547 BOOL neg = FALSE;
548 INT i = 0;
550 if(*ptr == '-') {
551 neg = TRUE;
552 ptr++;
555 while(isdigitW(*ptr))
556 i = i*10 + (*ptr++ - '0');
558 if(!*ptr) {
559 V_VT(p) = VT_I4;
560 V_I4(p) = neg ? -i : i;
561 set = TRUE;
565 if(!set) {
566 BSTR str;
568 hres = nsstyle_to_bstr(value, flags, &str);
569 if(SUCCEEDED(hres)) {
570 V_VT(p) = VT_BSTR;
571 V_BSTR(p) = str;
575 nsAString_Finish(&str_value);
577 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_variant(p));
578 return S_OK;
581 static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
583 return get_nsstyle_attr(This->nsstyle, sid, p, 0);
586 static HRESULT check_style_attr_value(HTMLStyle *This, styleid_t sid, LPCWSTR exval, VARIANT_BOOL *p)
588 nsAString str_value;
589 const PRUnichar *value;
591 nsAString_Init(&str_value, NULL);
593 get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
595 nsAString_GetData(&str_value, &value);
596 *p = strcmpW(value, exval) ? VARIANT_FALSE : VARIANT_TRUE;
597 nsAString_Finish(&str_value);
599 TRACE("%s -> %x\n", debugstr_w(style_tbl[sid].name), *p);
600 return S_OK;
603 static inline HRESULT set_style_pos(HTMLStyle *This, styleid_t sid, float value)
605 WCHAR szValue[25];
606 WCHAR szFormat[] = {'%','.','0','f','p','x',0};
608 value = floor(value);
610 sprintfW(szValue, szFormat, value);
612 return set_style_attr(This, sid, szValue, 0);
615 static HRESULT set_style_pxattr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LONG value)
617 WCHAR value_str[16];
619 sprintfW(value_str, px_formatW, value);
621 return set_nsstyle_attr(nsstyle, sid, value_str, 0);
624 static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p)
626 nsAString str_value;
627 HRESULT hres;
629 TRACE("%p %d %p\n", This, sid, p);
631 *p = 0.0f;
633 nsAString_Init(&str_value, NULL);
635 hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
636 if(hres == S_OK)
638 WCHAR *ptr;
639 const PRUnichar *value;
641 nsAString_GetData(&str_value, &value);
642 if(value)
644 *p = strtolW(value, &ptr, 10);
646 if(*ptr && strcmpW(ptr, pxW))
648 nsAString_Finish(&str_value);
649 FIXME("only px values are currently supported\n");
650 hres = E_FAIL;
655 TRACE("ret %f\n", *p);
657 nsAString_Finish(&str_value);
658 return hres;
661 static HRESULT get_nsstyle_pixel_val(HTMLStyle *This, styleid_t sid, LONG *p)
663 nsAString str_value;
664 HRESULT hres;
666 nsAString_Init(&str_value, NULL);
668 hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
669 if(hres == S_OK) {
670 WCHAR *ptr;
671 const PRUnichar *value;
673 nsAString_GetData(&str_value, &value);
674 if(value) {
675 *p = strtolW(value, &ptr, 10);
677 if(*ptr == '.') {
678 /* Skip all digits. We have tests showing that we should not round the value. */
679 while(isdigitW(*++ptr));
682 if(*ptr && strcmpW(ptr, pxW)) {
683 nsAString_Finish(&str_value);
684 FIXME("%s: only px values are currently supported\n", debugstr_w(value));
685 hres = E_NOTIMPL;
687 }else {
688 *p = 0;
692 nsAString_Finish(&str_value);
693 return hres;
696 static BOOL is_valid_border_style(BSTR v)
698 static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0};
699 static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0};
700 static const WCHAR styleSolid[] = {'s','o','l','i','d',0};
701 static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0};
702 static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0};
703 static const WCHAR styleRidge[] = {'r','i','d','g','e',0};
704 static const WCHAR styleInset[] = {'i','n','s','e','t',0};
705 static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0};
707 TRACE("%s\n", debugstr_w(v));
709 if(!v || strcmpiW(v, styleNone) == 0 || strcmpiW(v, styleDotted) == 0 ||
710 strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid) == 0 ||
711 strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 ||
712 strcmpiW(v, styleRidge) == 0 || strcmpiW(v, styleInset) == 0 ||
713 strcmpiW(v, styleOutset) == 0 )
715 return TRUE;
718 return FALSE;
721 static inline HTMLStyle *impl_from_IHTMLStyle(IHTMLStyle *iface)
723 return CONTAINING_RECORD(iface, HTMLStyle, IHTMLStyle_iface);
726 static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv)
728 HTMLStyle *This = impl_from_IHTMLStyle(iface);
730 *ppv = NULL;
732 if(IsEqualGUID(&IID_IUnknown, riid)) {
733 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
734 *ppv = &This->IHTMLStyle_iface;
735 }else if(IsEqualGUID(&IID_IHTMLStyle, riid)) {
736 TRACE("(%p)->(IID_IHTMLStyle %p)\n", This, ppv);
737 *ppv = &This->IHTMLStyle_iface;
738 }else if(IsEqualGUID(&IID_IHTMLStyle2, riid)) {
739 TRACE("(%p)->(IID_IHTMLStyle2 %p)\n", This, ppv);
740 *ppv = &This->IHTMLStyle2_iface;
741 }else if(IsEqualGUID(&IID_IHTMLStyle3, riid)) {
742 TRACE("(%p)->(IID_IHTMLStyle3 %p)\n", This, ppv);
743 *ppv = &This->IHTMLStyle3_iface;
744 }else if(IsEqualGUID(&IID_IHTMLStyle4, riid)) {
745 TRACE("(%p)->(IID_IHTMLStyle4 %p)\n", This, ppv);
746 *ppv = &This->IHTMLStyle4_iface;
747 }else if(IsEqualGUID(&IID_IHTMLStyle5, riid)) {
748 TRACE("(%p)->(IID_IHTMLStyle5 %p)\n", This, ppv);
749 *ppv = &This->IHTMLStyle5_iface;
750 }else if(IsEqualGUID(&IID_IHTMLStyle6, riid)) {
751 TRACE("(%p)->(IID_IHTMLStyle6 %p)\n", This, ppv);
752 *ppv = &This->IHTMLStyle6_iface;
753 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
754 return *ppv ? S_OK : E_NOINTERFACE;
757 if(*ppv) {
758 IUnknown_AddRef((IUnknown*)*ppv);
759 return S_OK;
762 WARN("unsupported %s\n", debugstr_guid(riid));
763 return E_NOINTERFACE;
766 static ULONG WINAPI HTMLStyle_AddRef(IHTMLStyle *iface)
768 HTMLStyle *This = impl_from_IHTMLStyle(iface);
769 LONG ref = InterlockedIncrement(&This->ref);
771 TRACE("(%p) ref=%d\n", This, ref);
773 return ref;
776 static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
778 HTMLStyle *This = impl_from_IHTMLStyle(iface);
779 LONG ref = InterlockedDecrement(&This->ref);
781 TRACE("(%p) ref=%d\n", This, ref);
783 if(!ref) {
784 assert(!This->elem);
785 if(This->nsstyle)
786 nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
787 release_dispex(&This->dispex);
788 heap_free(This);
791 return ref;
794 static HRESULT WINAPI HTMLStyle_GetTypeInfoCount(IHTMLStyle *iface, UINT *pctinfo)
796 HTMLStyle *This = impl_from_IHTMLStyle(iface);
797 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
800 static HRESULT WINAPI HTMLStyle_GetTypeInfo(IHTMLStyle *iface, UINT iTInfo,
801 LCID lcid, ITypeInfo **ppTInfo)
803 HTMLStyle *This = impl_from_IHTMLStyle(iface);
804 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
807 static HRESULT WINAPI HTMLStyle_GetIDsOfNames(IHTMLStyle *iface, REFIID riid,
808 LPOLESTR *rgszNames, UINT cNames,
809 LCID lcid, DISPID *rgDispId)
811 HTMLStyle *This = impl_from_IHTMLStyle(iface);
812 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
813 lcid, rgDispId);
816 static HRESULT WINAPI HTMLStyle_Invoke(IHTMLStyle *iface, DISPID dispIdMember,
817 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
818 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
820 HTMLStyle *This = impl_from_IHTMLStyle(iface);
821 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
822 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
825 static HRESULT WINAPI HTMLStyle_put_fontFamily(IHTMLStyle *iface, BSTR v)
827 HTMLStyle *This = impl_from_IHTMLStyle(iface);
829 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
831 return set_style_attr(This, STYLEID_FONT_FAMILY, v, 0);
834 static HRESULT WINAPI HTMLStyle_get_fontFamily(IHTMLStyle *iface, BSTR *p)
836 HTMLStyle *This = impl_from_IHTMLStyle(iface);
838 TRACE("(%p)->(%p)\n", This, p);
840 return get_style_attr(This, STYLEID_FONT_FAMILY, p);
843 static HRESULT WINAPI HTMLStyle_put_fontStyle(IHTMLStyle *iface, BSTR v)
845 HTMLStyle *This = impl_from_IHTMLStyle(iface);
846 static const WCHAR szItalic[] = {'i','t','a','l','i','c',0};
847 static const WCHAR szOblique[] = {'o','b','l','i','q','u','e',0};
849 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
851 /* fontStyle can only be one of the follow values. */
852 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szItalic, v) == 0 ||
853 strcmpiW(szOblique, v) == 0)
855 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, v, 0);
858 return E_INVALIDARG;
861 static HRESULT WINAPI HTMLStyle_get_fontStyle(IHTMLStyle *iface, BSTR *p)
863 HTMLStyle *This = impl_from_IHTMLStyle(iface);
865 TRACE("(%p)->(%p)\n", This, p);
867 return get_style_attr(This, STYLEID_FONT_STYLE, p);
870 static HRESULT WINAPI HTMLStyle_put_fontVariant(IHTMLStyle *iface, BSTR v)
872 HTMLStyle *This = impl_from_IHTMLStyle(iface);
873 static const WCHAR szCaps[] = {'s','m','a','l','l','-','c','a','p','s',0};
875 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
877 /* fontVariant can only be one of the follow values. */
878 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szCaps, v) == 0)
880 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, v, 0);
883 return E_INVALIDARG;
886 static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p)
888 HTMLStyle *This = impl_from_IHTMLStyle(iface);
889 TRACE("(%p)->(%p)\n", This, p);
891 if(!p)
892 return E_INVALIDARG;
894 return get_style_attr(This, STYLEID_FONT_VARIANT, p);
897 static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v)
899 HTMLStyle *This = impl_from_IHTMLStyle(iface);
900 static const WCHAR styleBold[] = {'b','o','l','d',0};
901 static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0};
902 static const WCHAR styleLighter[] = {'l','i','g','h','t','e','r',0};
903 static const WCHAR style100[] = {'1','0','0',0};
904 static const WCHAR style200[] = {'2','0','0',0};
905 static const WCHAR style300[] = {'3','0','0',0};
906 static const WCHAR style400[] = {'4','0','0',0};
907 static const WCHAR style500[] = {'5','0','0',0};
908 static const WCHAR style600[] = {'6','0','0',0};
909 static const WCHAR style700[] = {'7','0','0',0};
910 static const WCHAR style800[] = {'8','0','0',0};
911 static const WCHAR style900[] = {'9','0','0',0};
913 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
915 /* fontWeight can only be one of the following */
916 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(styleBold, v) == 0 ||
917 strcmpiW(styleBolder, v) == 0 || strcmpiW(styleLighter, v) == 0 ||
918 strcmpiW(style100, v) == 0 || strcmpiW(style200, v) == 0 ||
919 strcmpiW(style300, v) == 0 || strcmpiW(style400, v) == 0 ||
920 strcmpiW(style500, v) == 0 || strcmpiW(style600, v) == 0 ||
921 strcmpiW(style700, v) == 0 || strcmpiW(style800, v) == 0 ||
922 strcmpiW(style900, v) == 0
925 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0);
928 return E_INVALIDARG;
931 static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p)
933 HTMLStyle *This = impl_from_IHTMLStyle(iface);
935 TRACE("(%p)->(%p)\n", This, p);
937 return get_style_attr(This, STYLEID_FONT_WEIGHT, p);
940 static HRESULT WINAPI HTMLStyle_put_fontSize(IHTMLStyle *iface, VARIANT v)
942 HTMLStyle *This = impl_from_IHTMLStyle(iface);
944 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
946 return set_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, &v, ATTR_FIX_PX);
949 static HRESULT WINAPI HTMLStyle_get_fontSize(IHTMLStyle *iface, VARIANT *p)
951 HTMLStyle *This = impl_from_IHTMLStyle(iface);
953 TRACE("(%p)->(%p)\n", This, p);
955 return get_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, p, 0);
958 static HRESULT WINAPI HTMLStyle_put_font(IHTMLStyle *iface, BSTR v)
960 HTMLStyle *This = impl_from_IHTMLStyle(iface);
961 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
962 return E_NOTIMPL;
965 static HRESULT WINAPI HTMLStyle_get_font(IHTMLStyle *iface, BSTR *p)
967 HTMLStyle *This = impl_from_IHTMLStyle(iface);
968 FIXME("(%p)->(%p)\n", This, p);
969 return E_NOTIMPL;
972 static HRESULT WINAPI HTMLStyle_put_color(IHTMLStyle *iface, VARIANT v)
974 HTMLStyle *This = impl_from_IHTMLStyle(iface);
976 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
978 return set_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, &v, ATTR_HEX_INT);
981 static HRESULT WINAPI HTMLStyle_get_color(IHTMLStyle *iface, VARIANT *p)
983 HTMLStyle *This = impl_from_IHTMLStyle(iface);
985 TRACE("(%p)->(%p)\n", This, p);
987 return get_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, p, 0);
990 static HRESULT WINAPI HTMLStyle_put_background(IHTMLStyle *iface, BSTR v)
992 HTMLStyle *This = impl_from_IHTMLStyle(iface);
994 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
996 return set_style_attr(This, STYLEID_BACKGROUND, v, 0);
999 static HRESULT WINAPI HTMLStyle_get_background(IHTMLStyle *iface, BSTR *p)
1001 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1003 TRACE("(%p)->(%p)\n", This, p);
1005 return get_style_attr(This, STYLEID_BACKGROUND, p);
1008 static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v)
1010 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1012 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1014 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, &v, ATTR_HEX_INT);
1017 static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
1019 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1021 TRACE("(%p)->(%p)\n", This, p);
1023 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, p, 0);
1026 static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
1028 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1030 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1032 return set_style_attr(This, STYLEID_BACKGROUND_IMAGE, v, ATTR_FIX_URL);
1035 static HRESULT WINAPI HTMLStyle_get_backgroundImage(IHTMLStyle *iface, BSTR *p)
1037 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1039 TRACE("(%p)->(%p)\n", This, p);
1041 return get_style_attr(This, STYLEID_BACKGROUND_IMAGE, p);
1044 static HRESULT WINAPI HTMLStyle_put_backgroundRepeat(IHTMLStyle *iface, BSTR v)
1046 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1047 static const WCHAR styleRepeat[] = {'r','e','p','e','a','t',0};
1048 static const WCHAR styleNoRepeat[] = {'n','o','-','r','e','p','e','a','t',0};
1049 static const WCHAR styleRepeatX[] = {'r','e','p','e','a','t','-','x',0};
1050 static const WCHAR styleRepeatY[] = {'r','e','p','e','a','t','-','y',0};
1052 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1054 /* fontWeight can only be one of the following */
1055 if(!v || strcmpiW(styleRepeat, v) == 0 || strcmpiW(styleNoRepeat, v) == 0 ||
1056 strcmpiW(styleRepeatX, v) == 0 || strcmpiW(styleRepeatY, v) == 0 )
1058 return set_style_attr(This, STYLEID_BACKGROUND_REPEAT , v, 0);
1061 return E_INVALIDARG;
1064 static HRESULT WINAPI HTMLStyle_get_backgroundRepeat(IHTMLStyle *iface, BSTR *p)
1066 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1068 TRACE("(%p)->(%p)\n", This, p);
1070 return get_style_attr(This, STYLEID_BACKGROUND_REPEAT, p);
1073 static HRESULT WINAPI HTMLStyle_put_backgroundAttachment(IHTMLStyle *iface, BSTR v)
1075 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1076 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1077 return E_NOTIMPL;
1080 static HRESULT WINAPI HTMLStyle_get_backgroundAttachment(IHTMLStyle *iface, BSTR *p)
1082 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1083 FIXME("(%p)->(%p)\n", This, p);
1084 return E_NOTIMPL;
1087 static HRESULT WINAPI HTMLStyle_put_backgroundPosition(IHTMLStyle *iface, BSTR v)
1089 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1091 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1093 return set_style_attr(This, STYLEID_BACKGROUND_POSITION, v, 0);
1096 static HRESULT WINAPI HTMLStyle_get_backgroundPosition(IHTMLStyle *iface, BSTR *p)
1098 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1100 TRACE("(%p)->(%p)\n", This, p);
1102 return get_style_attr(This, STYLEID_BACKGROUND_POSITION, p);
1105 static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIANT v)
1107 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1108 WCHAR buf[14], *pos_val;
1109 nsAString pos_str;
1110 const WCHAR *val;
1111 DWORD val_len;
1112 HRESULT hres;
1114 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1116 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1117 if(FAILED(hres))
1118 return hres;
1120 val_len = val ? strlenW(val) : 0;
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, *posy;
1126 DWORD posy_len;
1128 nsAString_GetData(&pos_str, &pos);
1129 posy = strchrW(pos, ' ');
1130 if(!posy) {
1131 static const WCHAR zero_pxW[] = {' ','0','p','x',0};
1133 TRACE("no space in %s\n", debugstr_w(pos));
1134 posy = zero_pxW;
1137 posy_len = strlenW(posy);
1138 pos_val = heap_alloc((val_len+posy_len+1)*sizeof(WCHAR));
1139 if(pos_val) {
1140 if(val_len)
1141 memcpy(pos_val, val, val_len*sizeof(WCHAR));
1142 if(posy_len)
1143 memcpy(pos_val+val_len, posy, posy_len*sizeof(WCHAR));
1144 pos_val[val_len+posy_len] = 0;
1145 }else {
1146 hres = E_OUTOFMEMORY;
1149 nsAString_Finish(&pos_str);
1150 if(FAILED(hres))
1151 return hres;
1153 TRACE("setting position to %s\n", debugstr_w(pos_val));
1154 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1155 heap_free(pos_val);
1156 return hres;
1159 static HRESULT WINAPI HTMLStyle_get_backgroundPositionX(IHTMLStyle *iface, VARIANT *p)
1161 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1162 nsAString pos_str;
1163 BSTR ret;
1164 HRESULT hres;
1166 TRACE("(%p)->(%p)\n", This, p);
1168 nsAString_Init(&pos_str, NULL);
1169 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1170 if(SUCCEEDED(hres)) {
1171 const PRUnichar *pos, *space;
1173 nsAString_GetData(&pos_str, &pos);
1174 space = strchrW(pos, ' ');
1175 if(!space) {
1176 WARN("no space in %s\n", debugstr_w(pos));
1177 space = pos + strlenW(pos);
1180 if(space != pos) {
1181 ret = SysAllocStringLen(pos, space-pos);
1182 if(!ret)
1183 hres = E_OUTOFMEMORY;
1184 }else {
1185 ret = NULL;
1188 nsAString_Finish(&pos_str);
1189 if(FAILED(hres))
1190 return hres;
1192 TRACE("returning %s\n", debugstr_w(ret));
1193 V_VT(p) = VT_BSTR;
1194 V_BSTR(p) = ret;
1195 return S_OK;
1198 static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIANT v)
1200 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1201 WCHAR buf[14], *pos_val;
1202 nsAString pos_str;
1203 const WCHAR *val;
1204 DWORD val_len;
1205 HRESULT hres;
1207 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1209 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1210 if(FAILED(hres))
1211 return hres;
1213 val_len = val ? strlenW(val) : 0;
1215 nsAString_Init(&pos_str, NULL);
1216 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1217 if(SUCCEEDED(hres)) {
1218 const PRUnichar *pos, *space;
1219 DWORD posx_len;
1221 nsAString_GetData(&pos_str, &pos);
1222 space = strchrW(pos, ' ');
1223 if(space) {
1224 space++;
1225 }else {
1226 static const WCHAR zero_pxW[] = {'0','p','x',' ',0};
1228 TRACE("no space in %s\n", debugstr_w(pos));
1229 pos = zero_pxW;
1230 space = pos + sizeof(zero_pxW)/sizeof(WCHAR)-1;
1233 posx_len = space-pos;
1235 pos_val = heap_alloc((posx_len+val_len+1)*sizeof(WCHAR));
1236 if(pos_val) {
1237 memcpy(pos_val, pos, posx_len*sizeof(WCHAR));
1238 if(val_len)
1239 memcpy(pos_val+posx_len, val, val_len*sizeof(WCHAR));
1240 pos_val[posx_len+val_len] = 0;
1241 }else {
1242 hres = E_OUTOFMEMORY;
1245 nsAString_Finish(&pos_str);
1246 if(FAILED(hres))
1247 return hres;
1249 TRACE("setting position to %s\n", debugstr_w(pos_val));
1250 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1251 heap_free(pos_val);
1252 return hres;
1255 static HRESULT WINAPI HTMLStyle_get_backgroundPositionY(IHTMLStyle *iface, VARIANT *p)
1257 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1258 nsAString pos_str;
1259 BSTR ret;
1260 HRESULT hres;
1262 TRACE("(%p)->(%p)\n", This, p);
1264 nsAString_Init(&pos_str, NULL);
1265 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1266 if(SUCCEEDED(hres)) {
1267 const PRUnichar *pos, *posy;
1269 nsAString_GetData(&pos_str, &pos);
1270 posy = strchrW(pos, ' ');
1271 if(posy) {
1272 ret = SysAllocString(posy+1);
1273 if(!ret)
1274 hres = E_OUTOFMEMORY;
1275 }else {
1276 ret = NULL;
1279 nsAString_Finish(&pos_str);
1280 if(FAILED(hres))
1281 return hres;
1283 TRACE("returning %s\n", debugstr_w(ret));
1284 V_VT(p) = VT_BSTR;
1285 V_BSTR(p) = ret;
1286 return S_OK;
1289 static HRESULT WINAPI HTMLStyle_put_wordSpacing(IHTMLStyle *iface, VARIANT v)
1291 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1293 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1295 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, &v, 0);
1298 static HRESULT WINAPI HTMLStyle_get_wordSpacing(IHTMLStyle *iface, VARIANT *p)
1300 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1301 TRACE("(%p)->(%p)\n", This, p);
1302 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, p, 0);
1305 static HRESULT WINAPI HTMLStyle_put_letterSpacing(IHTMLStyle *iface, VARIANT v)
1307 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1309 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1311 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, &v, 0);
1314 static HRESULT WINAPI HTMLStyle_get_letterSpacing(IHTMLStyle *iface, VARIANT *p)
1316 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1317 TRACE("(%p)->(%p)\n", This, p);
1318 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, p, 0);
1321 static HRESULT WINAPI HTMLStyle_put_textDecoration(IHTMLStyle *iface, BSTR v)
1323 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1325 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1327 /* textDecoration can only be one of the following */
1328 if(!v || strcmpiW(styleNone, v) == 0 || strcmpiW(valUnderline, v) == 0 ||
1329 strcmpiW(valOverline, v) == 0 || strcmpiW(valLineThrough, v) == 0 ||
1330 strcmpiW(valBlink, v) == 0)
1332 return set_style_attr(This, STYLEID_TEXT_DECORATION , v, 0);
1335 return E_INVALIDARG;
1338 static HRESULT WINAPI HTMLStyle_get_textDecoration(IHTMLStyle *iface, BSTR *p)
1340 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1342 TRACE("(%p)->(%p)\n", This, p);
1344 return get_style_attr(This, STYLEID_TEXT_DECORATION, p);
1347 static HRESULT WINAPI HTMLStyle_put_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL v)
1349 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1351 TRACE("(%p)->(%x)\n", This, v);
1353 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? styleNone : emptyW, 0);
1356 static HRESULT WINAPI HTMLStyle_get_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL *p)
1358 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1360 TRACE("(%p)->(%p)\n", This, p);
1362 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, styleNone, p);
1365 static HRESULT WINAPI HTMLStyle_put_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL v)
1367 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1369 TRACE("(%p)->(%x)\n", This, v);
1371 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valUnderline : emptyW, 0);
1374 static HRESULT WINAPI HTMLStyle_get_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL *p)
1376 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1378 TRACE("(%p)->(%p)\n", This, p);
1380 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valUnderline, p);
1383 static HRESULT WINAPI HTMLStyle_put_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL v)
1385 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1387 TRACE("(%p)->(%x)\n", This, v);
1389 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valOverline : emptyW, 0);
1392 static HRESULT WINAPI HTMLStyle_get_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL *p)
1394 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1396 TRACE("(%p)->(%p)\n", This, p);
1398 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valOverline, p);
1401 static HRESULT WINAPI HTMLStyle_put_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL v)
1403 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1405 TRACE("(%p)->(%x)\n", This, v);
1407 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valLineThrough : emptyW, 0);
1410 static HRESULT WINAPI HTMLStyle_get_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL *p)
1412 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1414 TRACE("(%p)->(%p)\n", This, p);
1416 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valLineThrough, p);
1419 static HRESULT WINAPI HTMLStyle_put_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL v)
1421 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1423 TRACE("(%p)->(%x)\n", This, v);
1425 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valBlink : emptyW, 0);
1428 static HRESULT WINAPI HTMLStyle_get_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL *p)
1430 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1432 TRACE("(%p)->(%p)\n", This, p);
1434 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valBlink, p);
1437 static HRESULT WINAPI HTMLStyle_put_verticalAlign(IHTMLStyle *iface, VARIANT v)
1439 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1441 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1443 return set_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, &v, ATTR_FIX_PX);
1446 static HRESULT WINAPI HTMLStyle_get_verticalAlign(IHTMLStyle *iface, VARIANT *p)
1448 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1450 TRACE("(%p)->(%p)\n", This, p);
1452 return get_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, p, 0);
1455 static HRESULT WINAPI HTMLStyle_put_textTransform(IHTMLStyle *iface, BSTR v)
1457 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1458 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1459 return E_NOTIMPL;
1462 static HRESULT WINAPI HTMLStyle_get_textTransform(IHTMLStyle *iface, BSTR *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_textAlign(IHTMLStyle *iface, BSTR v)
1471 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1473 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1475 return set_style_attr(This, STYLEID_TEXT_ALIGN, v, 0);
1478 static HRESULT WINAPI HTMLStyle_get_textAlign(IHTMLStyle *iface, BSTR *p)
1480 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1482 TRACE("(%p)->(%p)\n", This, p);
1484 return get_style_attr(This, STYLEID_TEXT_ALIGN, p);
1487 static HRESULT WINAPI HTMLStyle_put_textIndent(IHTMLStyle *iface, VARIANT v)
1489 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1490 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1491 return E_NOTIMPL;
1494 static HRESULT WINAPI HTMLStyle_get_textIndent(IHTMLStyle *iface, VARIANT *p)
1496 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1497 FIXME("(%p)->(%p)\n", This, p);
1498 return E_NOTIMPL;
1501 static HRESULT WINAPI HTMLStyle_put_lineHeight(IHTMLStyle *iface, VARIANT v)
1503 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1504 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1505 return E_NOTIMPL;
1508 static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
1510 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1511 FIXME("(%p)->(%p)\n", This, p);
1512 return E_NOTIMPL;
1515 static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
1517 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1519 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1521 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, &v, ATTR_FIX_PX);
1524 static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
1526 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1528 TRACE("(%p)->(%p)\n", This, p);
1530 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
1533 static HRESULT WINAPI HTMLStyle_put_marginRight(IHTMLStyle *iface, VARIANT v)
1535 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1537 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1539 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, &v, ATTR_FIX_PX);
1542 static HRESULT WINAPI HTMLStyle_get_marginRight(IHTMLStyle *iface, VARIANT *p)
1544 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1545 TRACE("(%p)->(%p)\n", This, p);
1546 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
1549 static HRESULT WINAPI HTMLStyle_put_marginBottom(IHTMLStyle *iface, VARIANT v)
1551 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1553 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1555 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, &v, ATTR_FIX_PX);
1558 static HRESULT WINAPI HTMLStyle_get_marginBottom(IHTMLStyle *iface, VARIANT *p)
1560 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1562 TRACE("(%p)->(%p)\n", This, p);
1564 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, p, 0);
1567 static HRESULT WINAPI HTMLStyle_put_marginLeft(IHTMLStyle *iface, VARIANT v)
1569 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1571 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1573 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, &v, ATTR_FIX_PX);
1576 static HRESULT WINAPI HTMLStyle_put_margin(IHTMLStyle *iface, BSTR v)
1578 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1580 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1582 return set_style_attr(This, STYLEID_MARGIN, v, 0);
1585 static HRESULT WINAPI HTMLStyle_get_margin(IHTMLStyle *iface, BSTR *p)
1587 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1589 TRACE("(%p)->(%p)\n", This, p);
1591 return get_style_attr(This, STYLEID_MARGIN, p);
1594 static HRESULT WINAPI HTMLStyle_get_marginLeft(IHTMLStyle *iface, VARIANT *p)
1596 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1597 TRACE("(%p)->(%p)\n", This, p);
1598 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
1601 static HRESULT WINAPI HTMLStyle_put_paddingTop(IHTMLStyle *iface, VARIANT v)
1603 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1605 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1607 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, &v, ATTR_FIX_PX);
1610 static HRESULT WINAPI HTMLStyle_get_paddingTop(IHTMLStyle *iface, VARIANT *p)
1612 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1614 TRACE("(%p)->(%p)\n", This, p);
1616 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, p, 0);
1619 static HRESULT WINAPI HTMLStyle_put_paddingRight(IHTMLStyle *iface, VARIANT v)
1621 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1623 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1625 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, &v, ATTR_FIX_PX);
1628 static HRESULT WINAPI HTMLStyle_get_paddingRight(IHTMLStyle *iface, VARIANT *p)
1630 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1632 TRACE("(%p)->(%p)\n", This, p);
1634 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, p, 0);
1637 static HRESULT WINAPI HTMLStyle_put_paddingBottom(IHTMLStyle *iface, VARIANT v)
1639 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1641 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1643 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, &v, ATTR_FIX_PX);
1646 static HRESULT WINAPI HTMLStyle_get_paddingBottom(IHTMLStyle *iface, VARIANT *p)
1648 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1650 TRACE("(%p)->(%p)\n", This, p);
1652 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, p, 0);
1655 static HRESULT WINAPI HTMLStyle_put_paddingLeft(IHTMLStyle *iface, VARIANT v)
1657 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1659 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1661 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, &v, ATTR_FIX_PX);
1664 static HRESULT WINAPI HTMLStyle_get_paddingLeft(IHTMLStyle *iface, VARIANT *p)
1666 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1668 TRACE("(%p)->(%p)\n", This, p);
1670 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, p, 0);
1673 static HRESULT WINAPI HTMLStyle_put_padding(IHTMLStyle *iface, BSTR v)
1675 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1677 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1679 return set_style_attr(This, STYLEID_PADDING, v, 0);
1682 static HRESULT WINAPI HTMLStyle_get_padding(IHTMLStyle *iface, BSTR *p)
1684 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1686 TRACE("(%p)->(%p)\n", This, p);
1688 return get_style_attr(This, STYLEID_PADDING, p);
1691 static HRESULT WINAPI HTMLStyle_put_border(IHTMLStyle *iface, BSTR v)
1693 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1695 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1697 return set_style_attr(This, STYLEID_BORDER, v, 0);
1700 static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
1702 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1704 TRACE("(%p)->(%p)\n", This, p);
1706 return get_style_attr(This, STYLEID_BORDER, p);
1709 static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
1711 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1712 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1713 return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX);
1716 static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
1718 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1719 TRACE("(%p)->(%p)\n", This, p);
1720 return get_style_attr(This, STYLEID_BORDER_TOP, p);
1723 static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
1725 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1726 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1727 return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX);
1730 static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
1732 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1733 TRACE("(%p)->(%p)\n", This, p);
1734 return get_style_attr(This, STYLEID_BORDER_RIGHT, p);
1737 static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
1739 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1740 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1741 return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX);
1744 static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
1746 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1747 TRACE("(%p)->(%p)\n", This, p);
1748 return get_style_attr(This, STYLEID_BORDER_BOTTOM, p);
1751 static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
1753 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1755 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1757 return set_style_attr(This, STYLEID_BORDER_LEFT, v, ATTR_FIX_PX);
1760 static HRESULT WINAPI HTMLStyle_get_borderLeft(IHTMLStyle *iface, BSTR *p)
1762 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1764 TRACE("(%p)->(%p)\n", This, p);
1766 return get_style_attr(This, STYLEID_BORDER_LEFT, p);
1769 static HRESULT WINAPI HTMLStyle_put_borderColor(IHTMLStyle *iface, BSTR v)
1771 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1773 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1775 return set_style_attr(This, STYLEID_BORDER_COLOR, v, 0);
1778 static HRESULT WINAPI HTMLStyle_get_borderColor(IHTMLStyle *iface, BSTR *p)
1780 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1782 TRACE("(%p)->(%p)\n", This, p);
1784 return get_style_attr(This, STYLEID_BORDER_COLOR, p);
1787 static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v)
1789 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1791 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1793 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, &v, ATTR_HEX_INT);
1796 static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p)
1798 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1800 TRACE("(%p)->(%p)\n", This, p);
1802 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0);
1805 static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v)
1807 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1809 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1811 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, &v, ATTR_HEX_INT);
1814 static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p)
1816 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1818 TRACE("(%p)->(%p)\n", This, p);
1820 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0);
1823 static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v)
1825 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1827 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1829 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, &v, ATTR_HEX_INT);
1832 static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p)
1834 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1836 TRACE("(%p)->(%p)\n", This, p);
1838 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0);
1841 static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v)
1843 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1845 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1847 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, &v, ATTR_HEX_INT);
1850 static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p)
1852 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1854 TRACE("(%p)->(%p)\n", This, p);
1856 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0);
1859 static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v)
1861 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1862 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1863 return set_style_attr(This, STYLEID_BORDER_WIDTH, v, ATTR_FIX_PX);
1866 static HRESULT WINAPI HTMLStyle_get_borderWidth(IHTMLStyle *iface, BSTR *p)
1868 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1869 TRACE("(%p)->(%p)\n", This, p);
1870 return get_style_attr(This, STYLEID_BORDER_WIDTH, p);
1873 static HRESULT WINAPI HTMLStyle_put_borderTopWidth(IHTMLStyle *iface, VARIANT v)
1875 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1877 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1879 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, &v, 0);
1882 static HRESULT WINAPI HTMLStyle_get_borderTopWidth(IHTMLStyle *iface, VARIANT *p)
1884 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1886 TRACE("(%p)->(%p)\n", This, p);
1888 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, p, 0);
1891 static HRESULT WINAPI HTMLStyle_put_borderRightWidth(IHTMLStyle *iface, VARIANT v)
1893 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1895 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1897 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, &v, 0);
1900 static HRESULT WINAPI HTMLStyle_get_borderRightWidth(IHTMLStyle *iface, VARIANT *p)
1902 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1904 TRACE("(%p)->(%p)\n", This, p);
1906 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, p, 0);
1909 static HRESULT WINAPI HTMLStyle_put_borderBottomWidth(IHTMLStyle *iface, VARIANT v)
1911 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1913 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1915 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, &v, 0);
1918 static HRESULT WINAPI HTMLStyle_get_borderBottomWidth(IHTMLStyle *iface, VARIANT *p)
1920 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1921 TRACE("(%p)->(%p)\n", This, p);
1922 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, p, 0);
1925 static HRESULT WINAPI HTMLStyle_put_borderLeftWidth(IHTMLStyle *iface, VARIANT v)
1927 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1929 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1931 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, &v, 0);
1934 static HRESULT WINAPI HTMLStyle_get_borderLeftWidth(IHTMLStyle *iface, VARIANT *p)
1936 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1937 TRACE("(%p)->(%p)\n", This, p);
1938 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, p, 0);
1941 static HRESULT WINAPI HTMLStyle_put_borderStyle(IHTMLStyle *iface, BSTR v)
1943 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1944 static const WCHAR styleWindowInset[] = {'w','i','n','d','o','w','-','i','n','s','e','t',0};
1945 HRESULT hres = S_OK;
1946 BSTR pstyle;
1947 int i=0;
1948 int last = 0;
1950 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1952 while(v[i] && hres == S_OK)
1954 if(v[i] == (WCHAR)' ')
1956 pstyle = SysAllocStringLen(&v[last], (i-last));
1957 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1959 TRACE("1. Invalid style (%s)\n", debugstr_w(pstyle));
1960 hres = E_INVALIDARG;
1962 SysFreeString(pstyle);
1963 last = i+1;
1965 i++;
1968 if(hres == S_OK)
1970 pstyle = SysAllocStringLen(&v[last], i-last);
1971 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1973 TRACE("2. Invalid style (%s)\n", debugstr_w(pstyle));
1974 hres = E_INVALIDARG;
1976 SysFreeString(pstyle);
1979 if(hres == S_OK)
1980 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, v, 0);
1982 return hres;
1985 static HRESULT WINAPI HTMLStyle_get_borderStyle(IHTMLStyle *iface, BSTR *p)
1987 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1988 TRACE("(%p)->(%p)\n", This, p);
1989 return get_style_attr(This, STYLEID_BORDER_STYLE, p);
1992 static HRESULT WINAPI HTMLStyle_put_borderTopStyle(IHTMLStyle *iface, BSTR v)
1994 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1995 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1997 if(!is_valid_border_style(v))
1998 return E_INVALIDARG;
2000 return set_style_attr(This, STYLEID_BORDER_TOP_STYLE, v, 0);
2003 static HRESULT WINAPI HTMLStyle_get_borderTopStyle(IHTMLStyle *iface, BSTR *p)
2005 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2006 TRACE("(%p)->(%p)\n", This, p);
2007 return get_style_attr(This, STYLEID_BORDER_TOP_STYLE, p);
2010 static HRESULT WINAPI HTMLStyle_put_borderRightStyle(IHTMLStyle *iface, BSTR v)
2012 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2013 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2015 if(!is_valid_border_style(v))
2016 return E_INVALIDARG;
2018 return set_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, v, 0);
2021 static HRESULT WINAPI HTMLStyle_get_borderRightStyle(IHTMLStyle *iface, BSTR *p)
2023 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2024 TRACE("(%p)->(%p)\n", This, p);
2025 return get_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, p);
2028 static HRESULT WINAPI HTMLStyle_put_borderBottomStyle(IHTMLStyle *iface, BSTR v)
2030 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2031 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2033 if(!is_valid_border_style(v))
2034 return E_INVALIDARG;
2036 return set_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, v, 0);
2039 static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p)
2041 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2042 TRACE("(%p)->(%p)\n", This, p);
2043 return get_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, p);
2046 static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v)
2048 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2049 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2051 if(!is_valid_border_style(v))
2052 return E_INVALIDARG;
2054 return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0);
2057 static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p)
2059 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2060 TRACE("(%p)->(%p)\n", This, p);
2061 return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p);
2064 static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
2066 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2068 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2070 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX);
2073 static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
2075 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2077 TRACE("(%p)->(%p)\n", This, p);
2079 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, p, 0);
2082 static HRESULT WINAPI HTMLStyle_put_height(IHTMLStyle *iface, VARIANT v)
2084 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2086 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2088 return set_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, &v, ATTR_FIX_PX);
2091 static HRESULT WINAPI HTMLStyle_get_height(IHTMLStyle *iface, VARIANT *p)
2093 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2095 TRACE("(%p)->(%p)\n", This, p);
2097 return get_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, p, 0);
2100 static HRESULT WINAPI HTMLStyle_put_styleFloat(IHTMLStyle *iface, BSTR v)
2102 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2103 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2104 return E_NOTIMPL;
2107 static HRESULT WINAPI HTMLStyle_get_styleFloat(IHTMLStyle *iface, BSTR *p)
2109 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2110 FIXME("(%p)->(%p)\n", This, p);
2111 return E_NOTIMPL;
2114 static HRESULT WINAPI HTMLStyle_put_clear(IHTMLStyle *iface, BSTR v)
2116 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2118 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2120 return set_style_attr(This, STYLEID_CLEAR, v, 0);
2123 static HRESULT WINAPI HTMLStyle_get_clear(IHTMLStyle *iface, BSTR *p)
2125 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2127 TRACE("(%p)->(%p)\n", This, p);
2129 return get_style_attr(This, STYLEID_CLEAR, p);
2132 static HRESULT WINAPI HTMLStyle_put_display(IHTMLStyle *iface, BSTR v)
2134 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2136 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2138 return set_style_attr(This, STYLEID_DISPLAY, v, 0);
2141 static HRESULT WINAPI HTMLStyle_get_display(IHTMLStyle *iface, BSTR *p)
2143 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2145 TRACE("(%p)->(%p)\n", This, p);
2147 return get_style_attr(This, STYLEID_DISPLAY, p);
2150 static HRESULT WINAPI HTMLStyle_put_visibility(IHTMLStyle *iface, BSTR v)
2152 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2154 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2156 return set_style_attr(This, STYLEID_VISIBILITY, v, 0);
2159 static HRESULT WINAPI HTMLStyle_get_visibility(IHTMLStyle *iface, BSTR *p)
2161 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2163 TRACE("(%p)->(%p)\n", This, p);
2165 return get_style_attr(This, STYLEID_VISIBILITY, p);
2168 static HRESULT WINAPI HTMLStyle_put_listStyleType(IHTMLStyle *iface, BSTR v)
2170 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2171 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2172 return E_NOTIMPL;
2175 static HRESULT WINAPI HTMLStyle_get_listStyleType(IHTMLStyle *iface, BSTR *p)
2177 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2178 FIXME("(%p)->(%p)\n", This, p);
2179 return E_NOTIMPL;
2182 static HRESULT WINAPI HTMLStyle_put_listStylePosition(IHTMLStyle *iface, BSTR v)
2184 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2185 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2186 return E_NOTIMPL;
2189 static HRESULT WINAPI HTMLStyle_get_listStylePosition(IHTMLStyle *iface, BSTR *p)
2191 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2192 FIXME("(%p)->(%p)\n", This, p);
2193 return E_NOTIMPL;
2196 static HRESULT WINAPI HTMLStyle_put_listStyleImage(IHTMLStyle *iface, BSTR v)
2198 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2199 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2200 return E_NOTIMPL;
2203 static HRESULT WINAPI HTMLStyle_get_listStyleImage(IHTMLStyle *iface, BSTR *p)
2205 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2206 FIXME("(%p)->(%p)\n", This, p);
2207 return E_NOTIMPL;
2210 static HRESULT WINAPI HTMLStyle_put_listStyle(IHTMLStyle *iface, BSTR v)
2212 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2213 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2214 return E_NOTIMPL;
2217 static HRESULT WINAPI HTMLStyle_get_listStyle(IHTMLStyle *iface, BSTR *p)
2219 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2220 FIXME("(%p)->(%p)\n", This, p);
2221 return E_NOTIMPL;
2224 static HRESULT WINAPI HTMLStyle_put_whiteSpace(IHTMLStyle *iface, BSTR v)
2226 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2228 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2230 return set_nsstyle_attr(This->nsstyle, STYLEID_WHITE_SPACE, v, 0);
2233 static HRESULT WINAPI HTMLStyle_get_whiteSpace(IHTMLStyle *iface, BSTR *p)
2235 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2237 TRACE("(%p)->(%p)\n", This, p);
2239 return get_nsstyle_attr(This->nsstyle, STYLEID_WHITE_SPACE, p, 0);
2242 static HRESULT WINAPI HTMLStyle_put_top(IHTMLStyle *iface, VARIANT v)
2244 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2246 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2248 return set_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, &v, 0);
2251 static HRESULT WINAPI HTMLStyle_get_top(IHTMLStyle *iface, VARIANT *p)
2253 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2255 TRACE("(%p)->(%p)\n", This, p);
2257 return get_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, p, 0);
2260 static HRESULT WINAPI HTMLStyle_put_left(IHTMLStyle *iface, VARIANT v)
2262 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2264 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2266 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, &v, 0);
2269 static HRESULT WINAPI HTMLStyle_get_left(IHTMLStyle *iface, VARIANT *p)
2271 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2273 TRACE("(%p)->(%p)\n", This, p);
2275 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, p, 0);
2278 static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
2280 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2281 TRACE("(%p)->(%p)\n", This, p);
2282 return IHTMLStyle2_get_position(&This->IHTMLStyle2_iface, p);
2285 static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
2287 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2289 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2291 return set_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, &v, 0);
2294 static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
2296 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2298 TRACE("(%p)->(%p)\n", This, p);
2300 return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
2303 static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
2305 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2306 static const WCHAR szVisible[] = {'v','i','s','i','b','l','e',0};
2307 static const WCHAR szScroll[] = {'s','c','r','o','l','l',0};
2308 static const WCHAR szHidden[] = {'h','i','d','d','e','n',0};
2309 static const WCHAR szAuto[] = {'a','u','t','o',0};
2311 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2313 /* overflow can only be one of the follow values. */
2314 if(!v || !*v || strcmpiW(szVisible, v) == 0 || strcmpiW(szScroll, v) == 0 ||
2315 strcmpiW(szHidden, v) == 0 || strcmpiW(szAuto, v) == 0)
2317 return set_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, v, 0);
2320 return E_INVALIDARG;
2324 static HRESULT WINAPI HTMLStyle_get_overflow(IHTMLStyle *iface, BSTR *p)
2326 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2328 TRACE("(%p)->(%p)\n", This, p);
2330 if(!p)
2331 return E_INVALIDARG;
2333 return get_style_attr(This, STYLEID_OVERFLOW, p);
2336 static HRESULT WINAPI HTMLStyle_put_pageBreakBefore(IHTMLStyle *iface, BSTR v)
2338 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2340 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2342 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, v, 0);
2345 static HRESULT WINAPI HTMLStyle_get_pageBreakBefore(IHTMLStyle *iface, BSTR *p)
2347 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2349 TRACE("(%p)->(%p)\n", This, p);
2351 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, p, 0);
2354 static HRESULT WINAPI HTMLStyle_put_pageBreakAfter(IHTMLStyle *iface, BSTR v)
2356 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2358 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2360 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, v, 0);
2363 static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p)
2365 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2367 TRACE("(%p)->(%p)\n", This, p);
2369 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, p, 0);
2372 static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
2374 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2375 nsAString text_str;
2376 nsresult nsres;
2378 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2380 nsAString_InitDepend(&text_str, v);
2381 nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str);
2382 nsAString_Finish(&text_str);
2383 if(NS_FAILED(nsres)) {
2384 FIXME("SetCssStyle failed: %08x\n", nsres);
2385 return E_FAIL;
2388 return S_OK;
2391 static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p)
2393 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2394 nsAString text_str;
2395 nsresult nsres;
2397 TRACE("(%p)->(%p)\n", This, p);
2399 /* FIXME: Gecko style formatting is different than IE (uppercase). */
2400 nsAString_Init(&text_str, NULL);
2401 nsres = nsIDOMCSSStyleDeclaration_GetCssText(This->nsstyle, &text_str);
2402 if(NS_SUCCEEDED(nsres)) {
2403 const PRUnichar *text;
2405 nsAString_GetData(&text_str, &text);
2406 *p = *text ? SysAllocString(text) : NULL;
2407 }else {
2408 FIXME("GetCssStyle failed: %08x\n", nsres);
2409 *p = NULL;
2412 nsAString_Finish(&text_str);
2413 return S_OK;
2416 static HRESULT WINAPI HTMLStyle_put_pixelTop(IHTMLStyle *iface, LONG v)
2418 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2419 FIXME("(%p)->()\n", This);
2420 return E_NOTIMPL;
2423 static HRESULT WINAPI HTMLStyle_get_pixelTop(IHTMLStyle *iface, LONG *p)
2425 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2426 FIXME("(%p)->()\n", This);
2427 return E_NOTIMPL;
2430 static HRESULT WINAPI HTMLStyle_put_pixelLeft(IHTMLStyle *iface, LONG v)
2432 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2434 TRACE("(%p)->(%d)\n", This, v);
2436 return set_style_pxattr(This->nsstyle, STYLEID_LEFT, v);
2439 static HRESULT WINAPI HTMLStyle_get_pixelLeft(IHTMLStyle *iface, LONG *p)
2441 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2443 TRACE("(%p)->(%p)\n", This, p);
2445 return get_nsstyle_pixel_val(This, STYLEID_LEFT, p);
2448 static HRESULT WINAPI HTMLStyle_put_pixelWidth(IHTMLStyle *iface, LONG v)
2450 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2452 TRACE("(%p)->()\n", This);
2454 return set_style_pxattr(This->nsstyle, STYLEID_WIDTH, v);
2457 static HRESULT WINAPI HTMLStyle_get_pixelWidth(IHTMLStyle *iface, LONG *p)
2459 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2460 FIXME("(%p)->()\n", This);
2461 return E_NOTIMPL;
2464 static HRESULT WINAPI HTMLStyle_put_pixelHeight(IHTMLStyle *iface, LONG v)
2466 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2467 FIXME("(%p)->()\n", This);
2468 return E_NOTIMPL;
2471 static HRESULT WINAPI HTMLStyle_get_pixelHeight(IHTMLStyle *iface, LONG *p)
2473 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2474 FIXME("(%p)->()\n", This);
2475 return E_NOTIMPL;
2478 static HRESULT WINAPI HTMLStyle_put_posTop(IHTMLStyle *iface, float v)
2480 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2482 TRACE("(%p)->(%f)\n", This, v);
2484 return set_style_pos(This, STYLEID_TOP, v);
2487 static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
2489 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2491 TRACE("(%p)->(%p)\n", This, p);
2493 if(!p)
2494 return E_POINTER;
2496 return get_nsstyle_pos(This, STYLEID_TOP, p);
2499 static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
2501 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2503 TRACE("(%p)->(%f)\n", This, v);
2505 return set_style_pos(This, STYLEID_LEFT, v);
2508 static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
2510 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2512 TRACE("(%p)->(%p)\n", This, p);
2514 if(!p)
2515 return E_POINTER;
2517 return get_nsstyle_pos(This, STYLEID_LEFT, p);
2520 static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
2522 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2524 TRACE("(%p)->(%f)\n", This, v);
2526 return set_style_pos(This, STYLEID_WIDTH, v);
2529 static HRESULT WINAPI HTMLStyle_get_posWidth(IHTMLStyle *iface, float *p)
2531 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2533 TRACE("(%p)->(%p)\n", This, p);
2535 if(!p)
2536 return E_POINTER;
2538 if(get_nsstyle_pos(This, STYLEID_WIDTH, p) != S_OK)
2539 *p = 0.0f;
2541 return S_OK;
2544 static HRESULT WINAPI HTMLStyle_put_posHeight(IHTMLStyle *iface, float v)
2546 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2548 TRACE("(%p)->(%f)\n", This, v);
2550 return set_style_pos(This, STYLEID_HEIGHT, v);
2553 static HRESULT WINAPI HTMLStyle_get_posHeight(IHTMLStyle *iface, float *p)
2555 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2557 TRACE("(%p)->(%p)\n", This, p);
2559 if(!p)
2560 return E_POINTER;
2562 if(get_nsstyle_pos(This, STYLEID_HEIGHT, p) != S_OK)
2563 *p = 0.0f;
2565 return S_OK;
2568 static HRESULT WINAPI HTMLStyle_put_cursor(IHTMLStyle *iface, BSTR v)
2570 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2572 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2574 return set_style_attr(This, STYLEID_CURSOR, v, 0);
2577 static HRESULT WINAPI HTMLStyle_get_cursor(IHTMLStyle *iface, BSTR *p)
2579 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2581 TRACE("(%p)->(%p)\n", This, p);
2583 return get_style_attr(This, STYLEID_CURSOR, p);
2586 static HRESULT WINAPI HTMLStyle_put_clip(IHTMLStyle *iface, BSTR v)
2588 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2590 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2592 return set_style_attr(This, STYLEID_CLIP, v, 0);
2595 static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
2597 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2599 TRACE("(%p)->(%p)\n", This, p);
2601 return get_nsstyle_attr(This->nsstyle, STYLEID_CLIP, p, ATTR_REMOVE_COMMA);
2604 static void set_opacity(HTMLStyle *This, const WCHAR *val)
2606 nsAString name_str, val_str, empty_str;
2607 nsresult nsres;
2609 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y',0};
2611 TRACE("%s\n", debugstr_w(val));
2613 nsAString_InitDepend(&name_str, opacityW);
2614 nsAString_InitDepend(&val_str, val);
2615 nsAString_InitDepend(&empty_str, emptyW);
2617 nsres = nsIDOMCSSStyleDeclaration_SetProperty(This->nsstyle, &name_str, &val_str, &empty_str);
2618 if(NS_FAILED(nsres))
2619 ERR("SetProperty failed: %08x\n", nsres);
2621 nsAString_Finish(&name_str);
2622 nsAString_Finish(&val_str);
2623 nsAString_Finish(&empty_str);
2626 static void update_filter(HTMLStyle *This)
2628 const WCHAR *ptr = This->elem->filter, *ptr2;
2630 static const WCHAR alphaW[] = {'a','l','p','h','a'};
2632 if(!ptr) {
2633 set_opacity(This, emptyW);
2634 return;
2637 while(1) {
2638 while(isspaceW(*ptr))
2639 ptr++;
2640 if(!*ptr)
2641 break;
2643 ptr2 = ptr;
2644 while(isalnumW(*ptr))
2645 ptr++;
2646 if(ptr == ptr2) {
2647 WARN("unexpected char '%c'\n", *ptr);
2648 break;
2650 if(*ptr != '(') {
2651 WARN("expected '('\n");
2652 continue;
2655 if(ptr2 + sizeof(alphaW)/sizeof(WCHAR) == ptr && !memcmp(ptr2, alphaW, sizeof(alphaW))) {
2656 static const WCHAR formatW[] = {'%','f',0};
2657 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y','='};
2659 ptr++;
2660 do {
2661 while(isspaceW(*ptr))
2662 ptr++;
2664 ptr2 = ptr;
2665 while(*ptr && *ptr != ',' && *ptr != ')')
2666 ptr++;
2667 if(!*ptr) {
2668 WARN("unexpected end of string\n");
2669 break;
2672 if(ptr-ptr2 > sizeof(opacityW)/sizeof(WCHAR) && !memcmp(ptr2, opacityW, sizeof(opacityW))) {
2673 float fval = 0.0f, e = 0.1f;
2674 WCHAR buf[32];
2676 ptr2 += sizeof(opacityW)/sizeof(WCHAR);
2678 while(isdigitW(*ptr2))
2679 fval = fval*10.0f + (float)(*ptr2++ - '0');
2681 if(*ptr2 == '.') {
2682 while(isdigitW(*++ptr2)) {
2683 fval += e * (float)(*ptr2++ - '0');
2684 e *= 0.1f;
2688 sprintfW(buf, formatW, fval * 0.01f);
2689 set_opacity(This, buf);
2690 }else {
2691 FIXME("unknown param %s\n", debugstr_wn(ptr2, ptr-ptr2));
2694 if(*ptr == ',')
2695 ptr++;
2696 }while(*ptr != ')');
2697 }else {
2698 FIXME("unknown filter %s\n", debugstr_wn(ptr2, ptr-ptr2));
2699 ptr = strchrW(ptr, ')');
2700 if(!ptr)
2701 break;
2702 ptr++;
2707 static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
2709 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2710 WCHAR *new_filter = NULL;
2712 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2714 if(!This->elem) {
2715 FIXME("Element already destroyed\n");
2716 return E_UNEXPECTED;
2719 if(v) {
2720 new_filter = heap_strdupW(v);
2721 if(!new_filter)
2722 return E_OUTOFMEMORY;
2725 heap_free(This->elem->filter);
2726 This->elem->filter = new_filter;
2728 update_filter(This);
2729 return S_OK;
2732 static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
2734 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2736 TRACE("(%p)->(%p)\n", This, p);
2738 if(!This->elem) {
2739 FIXME("Element already destroyed\n");
2740 return E_UNEXPECTED;
2743 if(This->elem->filter) {
2744 *p = SysAllocString(This->elem->filter);
2745 if(!*p)
2746 return E_OUTOFMEMORY;
2747 }else {
2748 *p = NULL;
2751 return S_OK;
2754 static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2755 VARIANT AttributeValue, LONG lFlags)
2757 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2758 HRESULT hres;
2759 DISPID dispid;
2761 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName),
2762 debugstr_variant(&AttributeValue), lFlags);
2764 if(!strAttributeName)
2765 return E_INVALIDARG;
2767 if(lFlags == 1)
2768 FIXME("Parameter lFlags ignored\n");
2770 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2771 LOCALE_USER_DEFAULT, &dispid);
2772 if(hres == S_OK)
2774 VARIANT ret;
2775 DISPID dispidNamed = DISPID_PROPERTYPUT;
2776 DISPPARAMS params;
2778 params.cArgs = 1;
2779 params.rgvarg = &AttributeValue;
2780 params.cNamedArgs = 1;
2781 params.rgdispidNamedArgs = &dispidNamed;
2783 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2784 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2786 else
2788 FIXME("Custom attributes not supported.\n");
2791 TRACE("ret: %08x\n", hres);
2793 return hres;
2796 static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2797 LONG lFlags, VARIANT *AttributeValue)
2799 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2800 HRESULT hres;
2801 DISPID dispid;
2803 TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName),
2804 AttributeValue, lFlags);
2806 if(!AttributeValue || !strAttributeName)
2807 return E_INVALIDARG;
2809 if(lFlags == 1)
2810 FIXME("Parameter lFlags ignored\n");
2812 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2813 LOCALE_USER_DEFAULT, &dispid);
2814 if(hres == S_OK)
2816 DISPPARAMS params = {NULL, NULL, 0, 0 };
2818 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2819 DISPATCH_PROPERTYGET, &params, AttributeValue, NULL, NULL);
2821 else
2823 FIXME("Custom attributes not supported.\n");
2826 return hres;
2829 static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2830 LONG lFlags, VARIANT_BOOL *pfSuccess)
2832 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2833 const style_tbl_entry_t *style_entry;
2834 nsAString name_str, ret_str;
2835 nsresult nsres;
2836 HRESULT hres;
2838 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
2840 style_entry = lookup_style_tbl(strAttributeName);
2841 if(!style_entry) {
2842 DISPID dispid;
2843 unsigned i;
2845 hres = IDispatchEx_GetDispID(&This->dispex.IDispatchEx_iface, strAttributeName,
2846 (lFlags&1) ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
2847 if(hres != S_OK) {
2848 *pfSuccess = VARIANT_FALSE;
2849 return S_OK;
2852 for(i=0; i < sizeof(style_tbl)/sizeof(*style_tbl); i++) {
2853 if(dispid == style_tbl[i].dispid)
2854 break;
2857 if(i == sizeof(style_tbl)/sizeof(*style_tbl))
2858 return remove_prop(&This->dispex, strAttributeName, pfSuccess);
2859 style_entry = style_tbl+i;
2862 /* filter property is a special case */
2863 if(style_entry->dispid == DISPID_IHTMLSTYLE_FILTER) {
2864 *pfSuccess = This->elem->filter && *This->elem->filter ? VARIANT_TRUE : VARIANT_FALSE;
2865 heap_free(This->elem->filter);
2866 This->elem->filter = NULL;
2867 update_filter(This);
2868 return S_OK;
2871 nsAString_InitDepend(&name_str, style_entry->name);
2872 nsAString_Init(&ret_str, NULL);
2873 nsres = nsIDOMCSSStyleDeclaration_RemoveProperty(This->nsstyle, &name_str, &ret_str);
2874 if(NS_SUCCEEDED(nsres)) {
2875 const PRUnichar *ret;
2876 nsAString_GetData(&ret_str, &ret);
2877 *pfSuccess = *ret ? VARIANT_TRUE : VARIANT_FALSE;
2878 }else {
2879 ERR("RemoveProperty failed: %08x\n", nsres);
2881 nsAString_Finish(&name_str);
2882 nsAString_Finish(&ret_str);
2883 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
2886 static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
2888 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2889 FIXME("(%p)->(%p)\n", This, String);
2890 return E_NOTIMPL;
2893 static const IHTMLStyleVtbl HTMLStyleVtbl = {
2894 HTMLStyle_QueryInterface,
2895 HTMLStyle_AddRef,
2896 HTMLStyle_Release,
2897 HTMLStyle_GetTypeInfoCount,
2898 HTMLStyle_GetTypeInfo,
2899 HTMLStyle_GetIDsOfNames,
2900 HTMLStyle_Invoke,
2901 HTMLStyle_put_fontFamily,
2902 HTMLStyle_get_fontFamily,
2903 HTMLStyle_put_fontStyle,
2904 HTMLStyle_get_fontStyle,
2905 HTMLStyle_put_fontVariant,
2906 HTMLStyle_get_fontVariant,
2907 HTMLStyle_put_fontWeight,
2908 HTMLStyle_get_fontWeight,
2909 HTMLStyle_put_fontSize,
2910 HTMLStyle_get_fontSize,
2911 HTMLStyle_put_font,
2912 HTMLStyle_get_font,
2913 HTMLStyle_put_color,
2914 HTMLStyle_get_color,
2915 HTMLStyle_put_background,
2916 HTMLStyle_get_background,
2917 HTMLStyle_put_backgroundColor,
2918 HTMLStyle_get_backgroundColor,
2919 HTMLStyle_put_backgroundImage,
2920 HTMLStyle_get_backgroundImage,
2921 HTMLStyle_put_backgroundRepeat,
2922 HTMLStyle_get_backgroundRepeat,
2923 HTMLStyle_put_backgroundAttachment,
2924 HTMLStyle_get_backgroundAttachment,
2925 HTMLStyle_put_backgroundPosition,
2926 HTMLStyle_get_backgroundPosition,
2927 HTMLStyle_put_backgroundPositionX,
2928 HTMLStyle_get_backgroundPositionX,
2929 HTMLStyle_put_backgroundPositionY,
2930 HTMLStyle_get_backgroundPositionY,
2931 HTMLStyle_put_wordSpacing,
2932 HTMLStyle_get_wordSpacing,
2933 HTMLStyle_put_letterSpacing,
2934 HTMLStyle_get_letterSpacing,
2935 HTMLStyle_put_textDecoration,
2936 HTMLStyle_get_textDecoration,
2937 HTMLStyle_put_textDecorationNone,
2938 HTMLStyle_get_textDecorationNone,
2939 HTMLStyle_put_textDecorationUnderline,
2940 HTMLStyle_get_textDecorationUnderline,
2941 HTMLStyle_put_textDecorationOverline,
2942 HTMLStyle_get_textDecorationOverline,
2943 HTMLStyle_put_textDecorationLineThrough,
2944 HTMLStyle_get_textDecorationLineThrough,
2945 HTMLStyle_put_textDecorationBlink,
2946 HTMLStyle_get_textDecorationBlink,
2947 HTMLStyle_put_verticalAlign,
2948 HTMLStyle_get_verticalAlign,
2949 HTMLStyle_put_textTransform,
2950 HTMLStyle_get_textTransform,
2951 HTMLStyle_put_textAlign,
2952 HTMLStyle_get_textAlign,
2953 HTMLStyle_put_textIndent,
2954 HTMLStyle_get_textIndent,
2955 HTMLStyle_put_lineHeight,
2956 HTMLStyle_get_lineHeight,
2957 HTMLStyle_put_marginTop,
2958 HTMLStyle_get_marginTop,
2959 HTMLStyle_put_marginRight,
2960 HTMLStyle_get_marginRight,
2961 HTMLStyle_put_marginBottom,
2962 HTMLStyle_get_marginBottom,
2963 HTMLStyle_put_marginLeft,
2964 HTMLStyle_get_marginLeft,
2965 HTMLStyle_put_margin,
2966 HTMLStyle_get_margin,
2967 HTMLStyle_put_paddingTop,
2968 HTMLStyle_get_paddingTop,
2969 HTMLStyle_put_paddingRight,
2970 HTMLStyle_get_paddingRight,
2971 HTMLStyle_put_paddingBottom,
2972 HTMLStyle_get_paddingBottom,
2973 HTMLStyle_put_paddingLeft,
2974 HTMLStyle_get_paddingLeft,
2975 HTMLStyle_put_padding,
2976 HTMLStyle_get_padding,
2977 HTMLStyle_put_border,
2978 HTMLStyle_get_border,
2979 HTMLStyle_put_borderTop,
2980 HTMLStyle_get_borderTop,
2981 HTMLStyle_put_borderRight,
2982 HTMLStyle_get_borderRight,
2983 HTMLStyle_put_borderBottom,
2984 HTMLStyle_get_borderBottom,
2985 HTMLStyle_put_borderLeft,
2986 HTMLStyle_get_borderLeft,
2987 HTMLStyle_put_borderColor,
2988 HTMLStyle_get_borderColor,
2989 HTMLStyle_put_borderTopColor,
2990 HTMLStyle_get_borderTopColor,
2991 HTMLStyle_put_borderRightColor,
2992 HTMLStyle_get_borderRightColor,
2993 HTMLStyle_put_borderBottomColor,
2994 HTMLStyle_get_borderBottomColor,
2995 HTMLStyle_put_borderLeftColor,
2996 HTMLStyle_get_borderLeftColor,
2997 HTMLStyle_put_borderWidth,
2998 HTMLStyle_get_borderWidth,
2999 HTMLStyle_put_borderTopWidth,
3000 HTMLStyle_get_borderTopWidth,
3001 HTMLStyle_put_borderRightWidth,
3002 HTMLStyle_get_borderRightWidth,
3003 HTMLStyle_put_borderBottomWidth,
3004 HTMLStyle_get_borderBottomWidth,
3005 HTMLStyle_put_borderLeftWidth,
3006 HTMLStyle_get_borderLeftWidth,
3007 HTMLStyle_put_borderStyle,
3008 HTMLStyle_get_borderStyle,
3009 HTMLStyle_put_borderTopStyle,
3010 HTMLStyle_get_borderTopStyle,
3011 HTMLStyle_put_borderRightStyle,
3012 HTMLStyle_get_borderRightStyle,
3013 HTMLStyle_put_borderBottomStyle,
3014 HTMLStyle_get_borderBottomStyle,
3015 HTMLStyle_put_borderLeftStyle,
3016 HTMLStyle_get_borderLeftStyle,
3017 HTMLStyle_put_width,
3018 HTMLStyle_get_width,
3019 HTMLStyle_put_height,
3020 HTMLStyle_get_height,
3021 HTMLStyle_put_styleFloat,
3022 HTMLStyle_get_styleFloat,
3023 HTMLStyle_put_clear,
3024 HTMLStyle_get_clear,
3025 HTMLStyle_put_display,
3026 HTMLStyle_get_display,
3027 HTMLStyle_put_visibility,
3028 HTMLStyle_get_visibility,
3029 HTMLStyle_put_listStyleType,
3030 HTMLStyle_get_listStyleType,
3031 HTMLStyle_put_listStylePosition,
3032 HTMLStyle_get_listStylePosition,
3033 HTMLStyle_put_listStyleImage,
3034 HTMLStyle_get_listStyleImage,
3035 HTMLStyle_put_listStyle,
3036 HTMLStyle_get_listStyle,
3037 HTMLStyle_put_whiteSpace,
3038 HTMLStyle_get_whiteSpace,
3039 HTMLStyle_put_top,
3040 HTMLStyle_get_top,
3041 HTMLStyle_put_left,
3042 HTMLStyle_get_left,
3043 HTMLStyle_get_position,
3044 HTMLStyle_put_zIndex,
3045 HTMLStyle_get_zIndex,
3046 HTMLStyle_put_overflow,
3047 HTMLStyle_get_overflow,
3048 HTMLStyle_put_pageBreakBefore,
3049 HTMLStyle_get_pageBreakBefore,
3050 HTMLStyle_put_pageBreakAfter,
3051 HTMLStyle_get_pageBreakAfter,
3052 HTMLStyle_put_cssText,
3053 HTMLStyle_get_cssText,
3054 HTMLStyle_put_pixelTop,
3055 HTMLStyle_get_pixelTop,
3056 HTMLStyle_put_pixelLeft,
3057 HTMLStyle_get_pixelLeft,
3058 HTMLStyle_put_pixelWidth,
3059 HTMLStyle_get_pixelWidth,
3060 HTMLStyle_put_pixelHeight,
3061 HTMLStyle_get_pixelHeight,
3062 HTMLStyle_put_posTop,
3063 HTMLStyle_get_posTop,
3064 HTMLStyle_put_posLeft,
3065 HTMLStyle_get_posLeft,
3066 HTMLStyle_put_posWidth,
3067 HTMLStyle_get_posWidth,
3068 HTMLStyle_put_posHeight,
3069 HTMLStyle_get_posHeight,
3070 HTMLStyle_put_cursor,
3071 HTMLStyle_get_cursor,
3072 HTMLStyle_put_clip,
3073 HTMLStyle_get_clip,
3074 HTMLStyle_put_filter,
3075 HTMLStyle_get_filter,
3076 HTMLStyle_setAttribute,
3077 HTMLStyle_getAttribute,
3078 HTMLStyle_removeAttribute,
3079 HTMLStyle_toString
3082 static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
3084 const style_tbl_entry_t *style_entry;
3086 style_entry = lookup_style_tbl(name);
3087 if(style_entry) {
3088 *dispid = style_entry->dispid;
3089 return S_OK;
3092 return DISP_E_UNKNOWNNAME;
3095 static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
3096 NULL,
3097 HTMLStyle_get_dispid,
3098 NULL,
3099 NULL
3102 static const tid_t HTMLStyle_iface_tids[] = {
3103 IHTMLStyle_tid,
3104 IHTMLStyle2_tid,
3105 IHTMLStyle3_tid,
3106 IHTMLStyle4_tid,
3107 IHTMLStyle5_tid,
3108 IHTMLStyle6_tid,
3111 static dispex_static_data_t HTMLStyle_dispex = {
3112 &HTMLStyle_dispex_vtbl,
3113 DispHTMLStyle_tid,
3114 NULL,
3115 HTMLStyle_iface_tids
3118 HRESULT HTMLStyle_Create(HTMLElement *elem, HTMLStyle **ret)
3120 nsIDOMElementCSSInlineStyle *nselemstyle;
3121 nsIDOMCSSStyleDeclaration *nsstyle;
3122 HTMLStyle *style;
3123 nsresult nsres;
3125 if(!elem->nselem) {
3126 FIXME("NULL nselem\n");
3127 return E_NOTIMPL;
3130 nsres = nsIDOMHTMLElement_QueryInterface(elem->nselem, &IID_nsIDOMElementCSSInlineStyle,
3131 (void**)&nselemstyle);
3132 assert(nsres == NS_OK);
3134 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
3135 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
3136 if(NS_FAILED(nsres)) {
3137 ERR("GetStyle failed: %08x\n", nsres);
3138 return E_FAIL;
3141 style = heap_alloc_zero(sizeof(HTMLStyle));
3142 if(!style) {
3143 nsIDOMCSSStyleDeclaration_Release(nsstyle);
3144 return E_OUTOFMEMORY;
3147 style->IHTMLStyle_iface.lpVtbl = &HTMLStyleVtbl;
3148 style->ref = 1;
3149 style->nsstyle = nsstyle;
3150 style->elem = elem;
3151 HTMLStyle2_Init(style);
3152 HTMLStyle3_Init(style);
3154 nsIDOMCSSStyleDeclaration_AddRef(nsstyle);
3156 init_dispex(&style->dispex, (IUnknown*)&style->IHTMLStyle_iface, &HTMLStyle_dispex);
3158 *ret = style;
3159 return S_OK;