mshtml: Use proper helpers to implement IHTMLSyle::fontSize property.
[wine/multimedia.git] / dlls / mshtml / htmlstyle.c
blob69f3720a31db5eb3b829dc7d96af6dbbed26a08c
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <math.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28 #include "mshtmdid.h"
30 #include "mshtml_private.h"
31 #include "htmlstyle.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 static const WCHAR attrBackground[] =
38 {'b','a','c','k','g','r','o','u','n','d',0};
39 static const WCHAR attrBackgroundColor[] =
40 {'b','a','c','k','g','r','o','u','n','d','-','c','o','l','o','r',0};
41 static const WCHAR attrBackgroundImage[] =
42 {'b','a','c','k','g','r','o','u','n','d','-','i','m','a','g','e',0};
43 static const WCHAR attrBackgroundPosition[] =
44 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n',0};
45 static const WCHAR attrBackgroundPositionX[] =
46 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','x',0};
47 static const WCHAR attrBackgroundPositionY[] =
48 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','y',0};
49 static const WCHAR attrBackgroundRepeat[] =
50 {'b','a','c','k','g','r','o','u','n','d','-','r','e','p','e','a','t',0};
51 static const WCHAR attrBorder[] =
52 {'b','o','r','d','e','r',0};
53 static const WCHAR attrBorderBottom[] =
54 {'b','o','r','d','e','r','-','b','o','t','t','o','m',0};
55 static const WCHAR attrBorderBottomColor[] =
56 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','c','o','l','o','r',0};
57 static const WCHAR attrBorderBottomStyle[] =
58 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','s','t','y','l','e',0};
59 static const WCHAR attrBorderBottomWidth[] =
60 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','w','i','d','t','h',0};
61 static const WCHAR attrBorderColor[] =
62 {'b','o','r','d','e','r','-','c','o','l','o','r',0};
63 static const WCHAR attrBorderLeft[] =
64 {'b','o','r','d','e','r','-','l','e','f','t',0};
65 static const WCHAR attrBorderLeftColor[] =
66 {'b','o','r','d','e','r','-','l','e','f','t','-','c','o','l','o','r',0};
67 static const WCHAR attrBorderLeftStyle[] =
68 {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0};
69 static const WCHAR attrBorderLeftWidth[] =
70 {'b','o','r','d','e','r','-','l','e','f','t','-','w','i','d','t','h',0};
71 static const WCHAR attrBorderRight[] =
72 {'b','o','r','d','e','r','-','r','i','g','h','t',0};
73 static const WCHAR attrBorderRightColor[] =
74 {'b','o','r','d','e','r','-','r','i','g','h','t','-','c','o','l','o','r',0};
75 static const WCHAR attrBorderRightStyle[] =
76 {'b','o','r','d','e','r','-','r','i','g','h','t','-','s','t','y','l','e',0};
77 static const WCHAR attrBorderRightWidth[] =
78 {'b','o','r','d','e','r','-','r','i','g','h','t','-','w','i','d','t','h',0};
79 static const WCHAR attrBorderTop[] =
80 {'b','o','r','d','e','r','-','t','o','p',0};
81 static const WCHAR attrBorderTopColor[] =
82 {'b','o','r','d','e','r','-','t','o','p','-','c','o','l','o','r',0};
83 static const WCHAR attrBorderStyle[] =
84 {'b','o','r','d','e','r','-','s','t','y','l','e',0};
85 static const WCHAR attrBorderTopStyle[] =
86 {'b','o','r','d','e','r','-','t','o','p','-','s','t','y','l','e',0};
87 static const WCHAR attrBorderTopWidth[] =
88 {'b','o','r','d','e','r','-','t','o','p','-','w','i','d','t','h',0};
89 static const WCHAR attrBorderWidth[] =
90 {'b','o','r','d','e','r','-','w','i','d','t','h',0};
91 static const WCHAR attrBottom[] =
92 {'b','o','t','t','o','m',0};
93 static const WCHAR attrClip[] =
94 {'c','l','i','p',0};
95 static const WCHAR attrColor[] =
96 {'c','o','l','o','r',0};
97 static const WCHAR attrCursor[] =
98 {'c','u','r','s','o','r',0};
99 static const WCHAR attrDirection[] =
100 {'d','i','r','e','c','t','i','o','n',0};
101 static const WCHAR attrDisplay[] =
102 {'d','i','s','p','l','a','y',0};
103 static const WCHAR attrFilter[] =
104 {'f','i','l','e','t','e','r',0};
105 static const WCHAR attrFontFamily[] =
106 {'f','o','n','t','-','f','a','m','i','l','y',0};
107 static const WCHAR attrFontSize[] =
108 {'f','o','n','t','-','s','i','z','e',0};
109 static const WCHAR attrFontStyle[] =
110 {'f','o','n','t','-','s','t','y','l','e',0};
111 static const WCHAR attrFontVariant[] =
112 {'f','o','n','t','-','v','a','r','i','a','n','t',0};
113 static const WCHAR attrFontWeight[] =
114 {'f','o','n','t','-','w','e','i','g','h','t',0};
115 static const WCHAR attrHeight[] =
116 {'h','e','i','g','h','t',0};
117 static const WCHAR attrLeft[] =
118 {'l','e','f','t',0};
119 static const WCHAR attrLetterSpacing[] =
120 {'l','e','t','t','e','r','-','s','p','a','c','i','n','g',0};
121 static const WCHAR attrLineHeight[] =
122 {'l','i','n','e','-','h','e','i','g','h','t',0};
123 static const WCHAR attrMargin[] =
124 {'m','a','r','g','i','n',0};
125 static const WCHAR attrMarginBottom[] =
126 {'m','a','r','g','i','n','-','b','o','t','t','o','m',0};
127 static const WCHAR attrMarginLeft[] =
128 {'m','a','r','g','i','n','-','l','e','f','t',0};
129 static const WCHAR attrMarginRight[] =
130 {'m','a','r','g','i','n','-','r','i','g','h','t',0};
131 static const WCHAR attrMarginTop[] =
132 {'m','a','r','g','i','n','-','t','o','p',0};
133 static const WCHAR attrMinHeight[] =
134 {'m','i','n','-','h','e','i','g','h','t',0};
135 static const WCHAR attrOverflow[] =
136 {'o','v','e','r','f','l','o','w',0};
137 static const WCHAR attrPadding[] =
138 {'p','a','d','d','i','n','g',0};
139 static const WCHAR attrPaddingBottom[] =
140 {'p','a','d','d','i','n','g','-','b','o','t','t','o','m',0};
141 static const WCHAR attrPaddingLeft[] =
142 {'p','a','d','d','i','n','g','-','l','e','f','t',0};
143 static const WCHAR attrPaddingRight[] =
144 {'p','a','d','d','i','n','g','-','r','i','g','h','t',0};
145 static const WCHAR attrPaddingTop[] =
146 {'p','a','d','d','i','n','g','-','t','o','p',0};
147 static const WCHAR attrPageBreakAfter[] =
148 {'p','a','g','e','-','b','r','e','a','k','-','a','f','t','e','r',0};
149 static const WCHAR attrPageBreakBefore[] =
150 {'p','a','g','e','-','b','r','e','a','k','-','b','e','f','o','r','e',0};
151 static const WCHAR attrPosition[] =
152 {'p','o','s','i','t','i','o','n',0};
153 static const WCHAR attrRight[] =
154 {'r','i','g','h','t',0};
155 static const WCHAR attrTextAlign[] =
156 {'t','e','x','t','-','a','l','i','g','n',0};
157 static const WCHAR attrTextDecoration[] =
158 {'t','e','x','t','-','d','e','c','o','r','a','t','i','o','n',0};
159 static const WCHAR attrTextIndent[] =
160 {'t','e','x','t','-','i','n','d','e','n','t',0};
161 static const WCHAR attrTop[] =
162 {'t','o','p',0};
163 static const WCHAR attrVerticalAlign[] =
164 {'v','e','r','t','i','c','a','l','-','a','l','i','g','n',0};
165 static const WCHAR attrVisibility[] =
166 {'v','i','s','i','b','i','l','i','t','y',0};
167 static const WCHAR attrWidth[] =
168 {'w','i','d','t','h',0};
169 static const WCHAR attrWordSpacing[] =
170 {'w','o','r','d','-','s','p','a','c','i','n','g',0};
171 static const WCHAR attrWordWrap[] =
172 {'w','o','r','d','-','w','r','a','p',0};
173 static const WCHAR attrZIndex[] =
174 {'z','-','i','n','d','e','x',0};
176 static const struct{
177 const WCHAR *name;
178 DISPID dispid;
179 } style_tbl[] = {
180 {attrBackground, DISPID_IHTMLSTYLE_BACKGROUND},
181 {attrBackgroundColor, DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
182 {attrBackgroundImage, DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
183 {attrBackgroundPosition, DISPID_IHTMLSTYLE_BACKGROUNDPOSITION},
184 {attrBackgroundPositionX, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONX},
185 {attrBackgroundPositionY, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
186 {attrBackgroundRepeat, DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
187 {attrBorder, DISPID_IHTMLSTYLE_BORDER},
188 {attrBorderBottom, DISPID_IHTMLSTYLE_BORDERBOTTOM},
189 {attrBorderBottomColor, DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR},
190 {attrBorderBottomStyle, DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
191 {attrBorderBottomWidth, DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
192 {attrBorderColor, DISPID_IHTMLSTYLE_BORDERCOLOR},
193 {attrBorderLeft, DISPID_IHTMLSTYLE_BORDERLEFT},
194 {attrBorderLeftColor, DISPID_IHTMLSTYLE_BORDERLEFTCOLOR},
195 {attrBorderLeftStyle, DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
196 {attrBorderLeftWidth, DISPID_IHTMLSTYLE_BORDERLEFTWIDTH},
197 {attrBorderRight, DISPID_IHTMLSTYLE_BORDERRIGHT},
198 {attrBorderRightColor, DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR},
199 {attrBorderRightStyle, DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
200 {attrBorderRightWidth, DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
201 {attrBorderStyle, DISPID_IHTMLSTYLE_BORDERSTYLE},
202 {attrBorderTop, DISPID_IHTMLSTYLE_BORDERTOP},
203 {attrBorderTopColor, DISPID_IHTMLSTYLE_BORDERTOPCOLOR},
204 {attrBorderTopStyle, DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
205 {attrBorderTopWidth, DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
206 {attrBorderWidth, DISPID_IHTMLSTYLE_BORDERWIDTH},
207 {attrBottom, DISPID_IHTMLSTYLE2_BOTTOM},
208 {attrClip, DISPID_IHTMLSTYLE_CLIP},
209 {attrColor, DISPID_IHTMLSTYLE_COLOR},
210 {attrCursor, DISPID_IHTMLSTYLE_CURSOR},
211 {attrDirection, DISPID_IHTMLSTYLE2_DIRECTION},
212 {attrDisplay, DISPID_IHTMLSTYLE_DISPLAY},
213 {attrFilter, DISPID_IHTMLSTYLE_FILTER},
214 {attrFontFamily, DISPID_IHTMLSTYLE_FONTFAMILY},
215 {attrFontSize, DISPID_IHTMLSTYLE_FONTSIZE},
216 {attrFontStyle, DISPID_IHTMLSTYLE_FONTSTYLE},
217 {attrFontVariant, DISPID_IHTMLSTYLE_FONTVARIANT},
218 {attrFontWeight, DISPID_IHTMLSTYLE_FONTWEIGHT},
219 {attrHeight, DISPID_IHTMLSTYLE_HEIGHT},
220 {attrLeft, DISPID_IHTMLSTYLE_LEFT},
221 {attrLetterSpacing, DISPID_IHTMLSTYLE_LETTERSPACING},
222 {attrLineHeight, DISPID_IHTMLSTYLE_LINEHEIGHT},
223 {attrMargin, DISPID_IHTMLSTYLE_MARGIN},
224 {attrMarginBottom, DISPID_IHTMLSTYLE_MARGINBOTTOM},
225 {attrMarginLeft, DISPID_IHTMLSTYLE_MARGINLEFT},
226 {attrMarginRight, DISPID_IHTMLSTYLE_MARGINRIGHT},
227 {attrMarginTop, DISPID_IHTMLSTYLE_MARGINTOP},
228 {attrMinHeight, DISPID_IHTMLSTYLE4_MINHEIGHT},
229 {attrOverflow, DISPID_IHTMLSTYLE_OVERFLOW},
230 {attrPadding, DISPID_IHTMLSTYLE_PADDING},
231 {attrPaddingBottom, DISPID_IHTMLSTYLE_PADDINGBOTTOM},
232 {attrPaddingLeft, DISPID_IHTMLSTYLE_PADDINGLEFT},
233 {attrPaddingRight, DISPID_IHTMLSTYLE_PADDINGRIGHT},
234 {attrPaddingTop, DISPID_IHTMLSTYLE_PADDINGTOP},
235 {attrPageBreakAfter, DISPID_IHTMLSTYLE_PAGEBREAKAFTER},
236 {attrPageBreakBefore, DISPID_IHTMLSTYLE_PAGEBREAKBEFORE},
237 {attrPosition, DISPID_IHTMLSTYLE2_POSITION},
238 {attrRight, DISPID_IHTMLSTYLE2_RIGHT},
239 {attrTextAlign, DISPID_IHTMLSTYLE_TEXTALIGN},
240 {attrTextDecoration, DISPID_IHTMLSTYLE_TEXTDECORATION},
241 {attrTextIndent, DISPID_IHTMLSTYLE_TEXTINDENT},
242 {attrTop, DISPID_IHTMLSTYLE_TOP},
243 {attrVerticalAlign, DISPID_IHTMLSTYLE_VERTICALALIGN},
244 {attrVisibility, DISPID_IHTMLSTYLE_VISIBILITY},
245 {attrWidth, DISPID_IHTMLSTYLE_WIDTH},
246 {attrWordSpacing, DISPID_IHTMLSTYLE_WORDSPACING},
247 {attrWordWrap, DISPID_IHTMLSTYLE3_WORDWRAP},
248 {attrZIndex, DISPID_IHTMLSTYLE_ZINDEX}
251 static const WCHAR valLineThrough[] =
252 {'l','i','n','e','-','t','h','r','o','u','g','h',0};
253 static const WCHAR valUnderline[] =
254 {'u','n','d','e','r','l','i','n','e',0};
255 static const WCHAR szNormal[] =
256 {'n','o','r','m','a','l',0};
257 static const WCHAR styleNone[] =
258 {'n','o','n','e',0};
259 static const WCHAR valOverline[] =
260 {'o','v','e','r','l','i','n','e',0};
261 static const WCHAR valBlink[] =
262 {'b','l','i','n','k',0};
264 static const WCHAR px_formatW[] = {'%','d','p','x',0};
265 static const WCHAR emptyW[] = {0};
267 static LPWSTR fix_px_value(LPCWSTR val)
269 LPCWSTR ptr = val;
271 while(*ptr) {
272 while(*ptr && isspaceW(*ptr))
273 ptr++;
274 if(!*ptr)
275 break;
277 while(*ptr && isdigitW(*ptr))
278 ptr++;
280 if(!*ptr || isspaceW(*ptr)) {
281 LPWSTR ret, p;
282 int len = strlenW(val)+1;
284 ret = heap_alloc((len+2)*sizeof(WCHAR));
285 memcpy(ret, val, (ptr-val)*sizeof(WCHAR));
286 p = ret + (ptr-val);
287 *p++ = 'p';
288 *p++ = 'x';
289 strcpyW(p, ptr);
291 TRACE("fixed %s -> %s\n", debugstr_w(val), debugstr_w(ret));
293 return ret;
296 while(*ptr && !isspaceW(*ptr))
297 ptr++;
300 return NULL;
303 static LPWSTR fix_url_value(LPCWSTR val)
305 WCHAR *ret, *ptr;
307 static const WCHAR urlW[] = {'u','r','l','('};
309 if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
310 return NULL;
312 ret = heap_strdupW(val);
314 for(ptr = ret; *ptr; ptr++) {
315 if(*ptr == '\\')
316 *ptr = '/';
319 return ret;
322 HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCWSTR value, DWORD flags)
324 nsAString str_name, str_value, str_empty;
325 LPWSTR val = NULL;
326 nsresult nsres;
328 if(flags & ATTR_FIX_PX)
329 val = fix_px_value(value);
330 if(flags & ATTR_FIX_URL)
331 val = fix_url_value(value);
333 nsAString_InitDepend(&str_name, style_tbl[sid].name);
334 nsAString_InitDepend(&str_value, val ? val : value);
335 nsAString_InitDepend(&str_empty, emptyW);
337 nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
338 if(NS_FAILED(nsres))
339 ERR("SetProperty failed: %08x\n", nsres);
341 nsAString_Finish(&str_name);
342 nsAString_Finish(&str_value);
343 nsAString_Finish(&str_empty);
344 heap_free(val);
346 return S_OK;
349 static HRESULT var_to_styleval(const VARIANT *v, WCHAR *buf, DWORD flags, const WCHAR **ret)
351 switch(V_VT(v)) {
352 case VT_NULL:
353 *ret = emptyW;
354 return S_OK;
356 case VT_BSTR:
357 *ret = V_BSTR(v);
358 return S_OK;
360 case VT_BSTR|VT_BYREF:
361 *ret = *V_BSTRREF(v);
362 return S_OK;
364 case VT_I4: {
365 static const WCHAR formatW[] = {'%','d',0};
366 static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
368 if(flags & ATTR_HEX_INT)
369 wsprintfW(buf, hex_formatW, V_I4(v));
370 else if(flags & ATTR_FIX_PX)
371 wsprintfW(buf, px_formatW, V_I4(v));
372 else
373 wsprintfW(buf, formatW, V_I4(v));
375 *ret = buf;
376 return S_OK;
378 default:
379 FIXME("not implemented for %s\n", debugstr_variant(v));
380 return E_NOTIMPL;
385 HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *value, DWORD flags)
387 const WCHAR *val;
388 WCHAR buf[14];
389 HRESULT hres;
391 hres = var_to_styleval(value, buf, flags, &val);
392 if(FAILED(hres))
393 return hres;
395 return set_nsstyle_attr(nsstyle, sid, val, flags);
398 static inline HRESULT set_style_attr(HTMLStyle *This, styleid_t sid, LPCWSTR value, DWORD flags)
400 return set_nsstyle_attr(This->nsstyle, sid, value, flags);
403 static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, nsAString *value)
405 nsAString str_name;
406 nsresult nsres;
408 nsAString_InitDepend(&str_name, style_tbl[sid].name);
410 nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
411 if(NS_FAILED(nsres)) {
412 ERR("SetProperty failed: %08x\n", nsres);
413 return E_FAIL;
416 nsAString_Finish(&str_name);
418 return NS_OK;
421 static HRESULT nsstyle_to_bstr(const WCHAR *val, DWORD flags, BSTR *p)
423 BSTR ret;
424 DWORD len;
426 if(!*val) {
427 *p = NULL;
428 return S_OK;
431 ret = SysAllocString(val);
432 if(!ret)
433 return E_OUTOFMEMORY;
435 len = SysStringLen(ret);
437 if(flags & ATTR_REMOVE_COMMA) {
438 DWORD new_len = len;
439 WCHAR *ptr, *ptr2;
441 for(ptr = ret; (ptr = strchrW(ptr, ',')); ptr++)
442 new_len--;
444 if(new_len != len) {
445 BSTR new_ret;
447 new_ret = SysAllocStringLen(NULL, new_len);
448 if(!new_ret) {
449 SysFreeString(ret);
450 return E_OUTOFMEMORY;
453 for(ptr2 = new_ret, ptr = ret; *ptr; ptr++) {
454 if(*ptr != ',')
455 *ptr2++ = *ptr;
458 SysFreeString(ret);
459 ret = new_ret;
463 *p = ret;
464 return S_OK;
467 HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR *p, DWORD flags)
469 nsAString str_value;
470 const PRUnichar *value;
471 HRESULT hres;
473 nsAString_Init(&str_value, NULL);
475 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
477 nsAString_GetData(&str_value, &value);
478 hres = nsstyle_to_bstr(value, flags, p);
479 nsAString_Finish(&str_value);
481 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_w(*p));
482 return hres;
485 HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
487 nsAString str_value;
488 const PRUnichar *value;
489 BOOL set = FALSE;
490 HRESULT hres = S_OK;
492 nsAString_Init(&str_value, NULL);
494 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
496 nsAString_GetData(&str_value, &value);
498 if(flags & ATTR_STR_TO_INT) {
499 const PRUnichar *ptr = value;
500 BOOL neg = FALSE;
501 INT i = 0;
503 if(*ptr == '-') {
504 neg = TRUE;
505 ptr++;
508 while(isdigitW(*ptr))
509 i = i*10 + (*ptr++ - '0');
511 if(!*ptr) {
512 V_VT(p) = VT_I4;
513 V_I4(p) = neg ? -i : i;
514 set = TRUE;
518 if(!set) {
519 BSTR str;
521 hres = nsstyle_to_bstr(value, flags, &str);
522 if(SUCCEEDED(hres)) {
523 V_VT(p) = VT_BSTR;
524 V_BSTR(p) = str;
528 nsAString_Finish(&str_value);
530 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_variant(p));
531 return S_OK;
534 static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
536 return get_nsstyle_attr(This->nsstyle, sid, p, 0);
539 static HRESULT check_style_attr_value(HTMLStyle *This, styleid_t sid, LPCWSTR exval, VARIANT_BOOL *p)
541 nsAString str_value;
542 const PRUnichar *value;
544 nsAString_Init(&str_value, NULL);
546 get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
548 nsAString_GetData(&str_value, &value);
549 *p = strcmpW(value, exval) ? VARIANT_FALSE : VARIANT_TRUE;
550 nsAString_Finish(&str_value);
552 TRACE("%s -> %x\n", debugstr_w(style_tbl[sid].name), *p);
553 return S_OK;
556 static inline HRESULT set_style_pos(HTMLStyle *This, styleid_t sid, float value)
558 WCHAR szValue[25];
559 WCHAR szFormat[] = {'%','.','0','f','p','x',0};
561 value = floor(value);
563 sprintfW(szValue, szFormat, value);
565 return set_style_attr(This, sid, szValue, 0);
568 static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p)
570 nsAString str_value;
571 HRESULT hres;
572 WCHAR pxW[] = {'p','x',0};
574 TRACE("%p %d %p\n", This, sid, p);
576 *p = 0.0f;
578 nsAString_Init(&str_value, NULL);
580 hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
581 if(hres == S_OK)
583 WCHAR *ptr;
584 const PRUnichar *value;
586 nsAString_GetData(&str_value, &value);
587 if(value)
589 *p = strtolW(value, &ptr, 10);
591 if(*ptr && strcmpW(ptr, pxW))
593 nsAString_Finish(&str_value);
594 FIXME("only px values are currently supported\n");
595 return E_FAIL;
600 TRACE("ret %f\n", *p);
602 nsAString_Finish(&str_value);
604 return hres;
607 static BOOL is_valid_border_style(BSTR v)
609 static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0};
610 static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0};
611 static const WCHAR styleSolid[] = {'s','o','l','i','d',0};
612 static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0};
613 static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0};
614 static const WCHAR styleRidge[] = {'r','i','d','g','e',0};
615 static const WCHAR styleInset[] = {'i','n','s','e','t',0};
616 static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0};
618 TRACE("%s\n", debugstr_w(v));
620 if(!v || strcmpiW(v, styleNone) == 0 || strcmpiW(v, styleDotted) == 0 ||
621 strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid) == 0 ||
622 strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 ||
623 strcmpiW(v, styleRidge) == 0 || strcmpiW(v, styleInset) == 0 ||
624 strcmpiW(v, styleOutset) == 0 )
626 return TRUE;
629 return FALSE;
632 static inline HTMLStyle *impl_from_IHTMLStyle(IHTMLStyle *iface)
634 return CONTAINING_RECORD(iface, HTMLStyle, IHTMLStyle_iface);
637 static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv)
639 HTMLStyle *This = impl_from_IHTMLStyle(iface);
641 *ppv = NULL;
643 if(IsEqualGUID(&IID_IUnknown, riid)) {
644 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
645 *ppv = &This->IHTMLStyle_iface;
646 }else if(IsEqualGUID(&IID_IHTMLStyle, riid)) {
647 TRACE("(%p)->(IID_IHTMLStyle %p)\n", This, ppv);
648 *ppv = &This->IHTMLStyle_iface;
649 }else if(IsEqualGUID(&IID_IHTMLStyle2, riid)) {
650 TRACE("(%p)->(IID_IHTMLStyle2 %p)\n", This, ppv);
651 *ppv = &This->IHTMLStyle2_iface;
652 }else if(IsEqualGUID(&IID_IHTMLStyle3, riid)) {
653 TRACE("(%p)->(IID_IHTMLStyle3 %p)\n", This, ppv);
654 *ppv = &This->IHTMLStyle3_iface;
655 }else if(IsEqualGUID(&IID_IHTMLStyle4, riid)) {
656 TRACE("(%p)->(IID_IHTMLStyle4 %p)\n", This, ppv);
657 *ppv = &This->IHTMLStyle4_iface;
658 }else if(IsEqualGUID(&IID_IHTMLStyle5, riid)) {
659 TRACE("(%p)->(IID_IHTMLStyle5 %p)\n", This, ppv);
660 *ppv = &This->IHTMLStyle5_iface;
661 }else if(IsEqualGUID(&IID_IHTMLStyle6, riid)) {
662 TRACE("(%p)->(IID_IHTMLStyle6 %p)\n", This, ppv);
663 *ppv = &This->IHTMLStyle6_iface;
664 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
665 return *ppv ? S_OK : E_NOINTERFACE;
668 if(*ppv) {
669 IUnknown_AddRef((IUnknown*)*ppv);
670 return S_OK;
673 WARN("unsupported %s\n", debugstr_guid(riid));
674 return E_NOINTERFACE;
677 static ULONG WINAPI HTMLStyle_AddRef(IHTMLStyle *iface)
679 HTMLStyle *This = impl_from_IHTMLStyle(iface);
680 LONG ref = InterlockedIncrement(&This->ref);
682 TRACE("(%p) ref=%d\n", This, ref);
684 return ref;
687 static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
689 HTMLStyle *This = impl_from_IHTMLStyle(iface);
690 LONG ref = InterlockedDecrement(&This->ref);
692 TRACE("(%p) ref=%d\n", This, ref);
694 if(!ref) {
695 if(This->nsstyle)
696 nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
697 release_dispex(&This->dispex);
698 heap_free(This);
701 return ref;
704 static HRESULT WINAPI HTMLStyle_GetTypeInfoCount(IHTMLStyle *iface, UINT *pctinfo)
706 HTMLStyle *This = impl_from_IHTMLStyle(iface);
707 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
710 static HRESULT WINAPI HTMLStyle_GetTypeInfo(IHTMLStyle *iface, UINT iTInfo,
711 LCID lcid, ITypeInfo **ppTInfo)
713 HTMLStyle *This = impl_from_IHTMLStyle(iface);
714 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
717 static HRESULT WINAPI HTMLStyle_GetIDsOfNames(IHTMLStyle *iface, REFIID riid,
718 LPOLESTR *rgszNames, UINT cNames,
719 LCID lcid, DISPID *rgDispId)
721 HTMLStyle *This = impl_from_IHTMLStyle(iface);
722 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
723 lcid, rgDispId);
726 static HRESULT WINAPI HTMLStyle_Invoke(IHTMLStyle *iface, DISPID dispIdMember,
727 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
728 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
730 HTMLStyle *This = impl_from_IHTMLStyle(iface);
731 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
732 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
735 static HRESULT WINAPI HTMLStyle_put_fontFamily(IHTMLStyle *iface, BSTR v)
737 HTMLStyle *This = impl_from_IHTMLStyle(iface);
739 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
741 return set_style_attr(This, STYLEID_FONT_FAMILY, v, 0);
744 static HRESULT WINAPI HTMLStyle_get_fontFamily(IHTMLStyle *iface, BSTR *p)
746 HTMLStyle *This = impl_from_IHTMLStyle(iface);
748 TRACE("(%p)->(%p)\n", This, p);
750 return get_style_attr(This, STYLEID_FONT_FAMILY, p);
753 static HRESULT WINAPI HTMLStyle_put_fontStyle(IHTMLStyle *iface, BSTR v)
755 HTMLStyle *This = impl_from_IHTMLStyle(iface);
756 static const WCHAR szItalic[] = {'i','t','a','l','i','c',0};
757 static const WCHAR szOblique[] = {'o','b','l','i','q','u','e',0};
759 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
761 /* fontStyle can only be one of the follow values. */
762 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szItalic, v) == 0 ||
763 strcmpiW(szOblique, v) == 0)
765 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, v, 0);
768 return E_INVALIDARG;
771 static HRESULT WINAPI HTMLStyle_get_fontStyle(IHTMLStyle *iface, BSTR *p)
773 HTMLStyle *This = impl_from_IHTMLStyle(iface);
775 TRACE("(%p)->(%p)\n", This, p);
777 return get_style_attr(This, STYLEID_FONT_STYLE, p);
780 static HRESULT WINAPI HTMLStyle_put_fontVariant(IHTMLStyle *iface, BSTR v)
782 HTMLStyle *This = impl_from_IHTMLStyle(iface);
783 static const WCHAR szCaps[] = {'s','m','a','l','l','-','c','a','p','s',0};
785 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
787 /* fontVariant can only be one of the follow values. */
788 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szCaps, v) == 0)
790 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, v, 0);
793 return E_INVALIDARG;
796 static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p)
798 HTMLStyle *This = impl_from_IHTMLStyle(iface);
799 TRACE("(%p)->(%p)\n", This, p);
801 if(!p)
802 return E_INVALIDARG;
804 return get_style_attr(This, STYLEID_FONT_VARIANT, p);
807 static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v)
809 HTMLStyle *This = impl_from_IHTMLStyle(iface);
810 static const WCHAR styleBold[] = {'b','o','l','d',0};
811 static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0};
812 static const WCHAR styleLighter[] = {'l','i','g','h','t','e','r',0};
813 static const WCHAR style100[] = {'1','0','0',0};
814 static const WCHAR style200[] = {'2','0','0',0};
815 static const WCHAR style300[] = {'3','0','0',0};
816 static const WCHAR style400[] = {'4','0','0',0};
817 static const WCHAR style500[] = {'5','0','0',0};
818 static const WCHAR style600[] = {'6','0','0',0};
819 static const WCHAR style700[] = {'7','0','0',0};
820 static const WCHAR style800[] = {'8','0','0',0};
821 static const WCHAR style900[] = {'9','0','0',0};
823 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
825 /* fontWeight can only be one of the following */
826 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(styleBold, v) == 0 ||
827 strcmpiW(styleBolder, v) == 0 || strcmpiW(styleLighter, v) == 0 ||
828 strcmpiW(style100, v) == 0 || strcmpiW(style200, v) == 0 ||
829 strcmpiW(style300, v) == 0 || strcmpiW(style400, v) == 0 ||
830 strcmpiW(style500, v) == 0 || strcmpiW(style600, v) == 0 ||
831 strcmpiW(style700, v) == 0 || strcmpiW(style800, v) == 0 ||
832 strcmpiW(style900, v) == 0
835 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0);
838 return E_INVALIDARG;
841 static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p)
843 HTMLStyle *This = impl_from_IHTMLStyle(iface);
845 TRACE("(%p)->(%p)\n", This, p);
847 return get_style_attr(This, STYLEID_FONT_WEIGHT, p);
850 static HRESULT WINAPI HTMLStyle_put_fontSize(IHTMLStyle *iface, VARIANT v)
852 HTMLStyle *This = impl_from_IHTMLStyle(iface);
854 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
856 return set_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, &v, ATTR_FIX_PX);
859 static HRESULT WINAPI HTMLStyle_get_fontSize(IHTMLStyle *iface, VARIANT *p)
861 HTMLStyle *This = impl_from_IHTMLStyle(iface);
863 TRACE("(%p)->(%p)\n", This, p);
865 return get_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, p, 0);
868 static HRESULT WINAPI HTMLStyle_put_font(IHTMLStyle *iface, BSTR v)
870 HTMLStyle *This = impl_from_IHTMLStyle(iface);
871 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
872 return E_NOTIMPL;
875 static HRESULT WINAPI HTMLStyle_get_font(IHTMLStyle *iface, BSTR *p)
877 HTMLStyle *This = impl_from_IHTMLStyle(iface);
878 FIXME("(%p)->(%p)\n", This, p);
879 return E_NOTIMPL;
882 static HRESULT WINAPI HTMLStyle_put_color(IHTMLStyle *iface, VARIANT v)
884 HTMLStyle *This = impl_from_IHTMLStyle(iface);
886 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
888 switch(V_VT(&v)) {
889 case VT_BSTR:
890 TRACE("%s\n", debugstr_w(V_BSTR(&v)));
891 return set_style_attr(This, STYLEID_COLOR, V_BSTR(&v), 0);
893 default:
894 FIXME("unsupported vt=%d\n", V_VT(&v));
897 return E_NOTIMPL;
900 static HRESULT WINAPI HTMLStyle_get_color(IHTMLStyle *iface, VARIANT *p)
902 HTMLStyle *This = impl_from_IHTMLStyle(iface);
904 TRACE("(%p)->(%p)\n", This, p);
906 V_VT(p) = VT_BSTR;
907 return get_style_attr(This, STYLEID_COLOR, &V_BSTR(p));
910 static HRESULT WINAPI HTMLStyle_put_background(IHTMLStyle *iface, BSTR v)
912 HTMLStyle *This = impl_from_IHTMLStyle(iface);
914 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
916 return set_style_attr(This, STYLEID_BACKGROUND, v, 0);
919 static HRESULT WINAPI HTMLStyle_get_background(IHTMLStyle *iface, BSTR *p)
921 HTMLStyle *This = impl_from_IHTMLStyle(iface);
923 TRACE("(%p)->(%p)\n", This, p);
925 return get_style_attr(This, STYLEID_BACKGROUND, p);
928 static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v)
930 HTMLStyle *This = impl_from_IHTMLStyle(iface);
932 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
934 switch(V_VT(&v)) {
935 case VT_BSTR:
936 return set_style_attr(This, STYLEID_BACKGROUND_COLOR, V_BSTR(&v), 0);
937 case VT_I4: {
938 WCHAR value[10];
939 static const WCHAR format[] = {'#','%','0','6','x',0};
941 wsprintfW(value, format, V_I4(&v));
942 return set_style_attr(This, STYLEID_BACKGROUND_COLOR, value, 0);
944 default:
945 FIXME("unsupported vt %d\n", V_VT(&v));
948 return S_OK;
951 static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
953 HTMLStyle *This = impl_from_IHTMLStyle(iface);
954 TRACE("(%p)->(%p)\n", This, p);
956 V_VT(p) = VT_BSTR;
957 return get_style_attr(This, STYLEID_BACKGROUND_COLOR, &V_BSTR(p));
960 static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
962 HTMLStyle *This = impl_from_IHTMLStyle(iface);
964 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
966 return set_style_attr(This, STYLEID_BACKGROUND_IMAGE, v, ATTR_FIX_URL);
969 static HRESULT WINAPI HTMLStyle_get_backgroundImage(IHTMLStyle *iface, BSTR *p)
971 HTMLStyle *This = impl_from_IHTMLStyle(iface);
973 TRACE("(%p)->(%p)\n", This, p);
975 return get_style_attr(This, STYLEID_BACKGROUND_IMAGE, p);
978 static HRESULT WINAPI HTMLStyle_put_backgroundRepeat(IHTMLStyle *iface, BSTR v)
980 HTMLStyle *This = impl_from_IHTMLStyle(iface);
981 static const WCHAR styleRepeat[] = {'r','e','p','e','a','t',0};
982 static const WCHAR styleNoRepeat[] = {'n','o','-','r','e','p','e','a','t',0};
983 static const WCHAR styleRepeatX[] = {'r','e','p','e','a','t','-','x',0};
984 static const WCHAR styleRepeatY[] = {'r','e','p','e','a','t','-','y',0};
986 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
988 /* fontWeight can only be one of the following */
989 if(!v || strcmpiW(styleRepeat, v) == 0 || strcmpiW(styleNoRepeat, v) == 0 ||
990 strcmpiW(styleRepeatX, v) == 0 || strcmpiW(styleRepeatY, v) == 0 )
992 return set_style_attr(This, STYLEID_BACKGROUND_REPEAT , v, 0);
995 return E_INVALIDARG;
998 static HRESULT WINAPI HTMLStyle_get_backgroundRepeat(IHTMLStyle *iface, BSTR *p)
1000 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1002 TRACE("(%p)->(%p)\n", This, p);
1004 return get_style_attr(This, STYLEID_BACKGROUND_REPEAT, p);
1007 static HRESULT WINAPI HTMLStyle_put_backgroundAttachment(IHTMLStyle *iface, BSTR v)
1009 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1010 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1011 return E_NOTIMPL;
1014 static HRESULT WINAPI HTMLStyle_get_backgroundAttachment(IHTMLStyle *iface, BSTR *p)
1016 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1017 FIXME("(%p)->(%p)\n", This, p);
1018 return E_NOTIMPL;
1021 static HRESULT WINAPI HTMLStyle_put_backgroundPosition(IHTMLStyle *iface, BSTR v)
1023 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1025 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1027 return set_style_attr(This, STYLEID_BACKGROUND_POSITION, v, 0);
1030 static HRESULT WINAPI HTMLStyle_get_backgroundPosition(IHTMLStyle *iface, BSTR *p)
1032 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1034 TRACE("(%p)->(%p)\n", This, p);
1036 return get_style_attr(This, STYLEID_BACKGROUND_POSITION, p);
1039 static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIANT v)
1041 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1042 WCHAR buf[14], *pos_val;
1043 nsAString pos_str;
1044 const WCHAR *val;
1045 DWORD val_len;
1046 HRESULT hres;
1048 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1050 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1051 if(FAILED(hres))
1052 return hres;
1054 val_len = val ? strlenW(val) : 0;
1056 nsAString_Init(&pos_str, NULL);
1057 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1058 if(SUCCEEDED(hres)) {
1059 const PRUnichar *pos, *posy;
1060 DWORD posy_len;
1062 nsAString_GetData(&pos_str, &pos);
1063 posy = strchrW(pos, ' ');
1064 if(!posy) {
1065 static const WCHAR zero_pxW[] = {' ','0','p','x',0};
1067 TRACE("no space in %s\n", debugstr_w(pos));
1068 posy = zero_pxW;
1071 posy_len = strlenW(posy);
1072 pos_val = heap_alloc((val_len+posy_len+1)*sizeof(WCHAR));
1073 if(pos_val) {
1074 if(val_len)
1075 memcpy(pos_val, val, val_len*sizeof(WCHAR));
1076 if(posy_len)
1077 memcpy(pos_val+val_len, posy, posy_len*sizeof(WCHAR));
1078 pos_val[val_len+posy_len] = 0;
1079 }else {
1080 hres = E_OUTOFMEMORY;
1083 nsAString_Finish(&pos_str);
1084 if(FAILED(hres))
1085 return hres;
1087 TRACE("setting position to %s\n", debugstr_w(pos_val));
1088 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1089 heap_free(pos_val);
1090 return hres;
1093 static HRESULT WINAPI HTMLStyle_get_backgroundPositionX(IHTMLStyle *iface, VARIANT *p)
1095 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1096 nsAString pos_str;
1097 BSTR ret;
1098 HRESULT hres;
1100 TRACE("(%p)->(%p)\n", This, p);
1102 nsAString_Init(&pos_str, NULL);
1103 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1104 if(SUCCEEDED(hres)) {
1105 const PRUnichar *pos, *space;
1107 nsAString_GetData(&pos_str, &pos);
1108 space = strchrW(pos, ' ');
1109 if(!space) {
1110 WARN("no space in %s\n", debugstr_w(pos));
1111 space = pos + strlenW(pos);
1114 if(space != pos) {
1115 ret = SysAllocStringLen(pos, space-pos);
1116 if(!ret)
1117 hres = E_OUTOFMEMORY;
1118 }else {
1119 ret = NULL;
1122 nsAString_Finish(&pos_str);
1123 if(FAILED(hres))
1124 return hres;
1126 TRACE("returning %s\n", debugstr_w(ret));
1127 V_VT(p) = VT_BSTR;
1128 V_BSTR(p) = ret;
1129 return S_OK;
1132 static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIANT v)
1134 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1135 WCHAR buf[14], *pos_val;
1136 nsAString pos_str;
1137 const WCHAR *val;
1138 DWORD val_len;
1139 HRESULT hres;
1141 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1143 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1144 if(FAILED(hres))
1145 return hres;
1147 val_len = val ? strlenW(val) : 0;
1149 nsAString_Init(&pos_str, NULL);
1150 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1151 if(SUCCEEDED(hres)) {
1152 const PRUnichar *pos, *space;
1153 DWORD posx_len;
1155 nsAString_GetData(&pos_str, &pos);
1156 space = strchrW(pos, ' ');
1157 if(space) {
1158 space++;
1159 }else {
1160 static const WCHAR zero_pxW[] = {'0','p','x',' ',0};
1162 TRACE("no space in %s\n", debugstr_w(pos));
1163 pos = zero_pxW;
1164 space = pos + sizeof(zero_pxW)/sizeof(WCHAR)-1;
1167 posx_len = space-pos;
1169 pos_val = heap_alloc((posx_len+val_len+1)*sizeof(WCHAR));
1170 if(pos_val) {
1171 memcpy(pos_val, pos, posx_len*sizeof(WCHAR));
1172 if(val_len)
1173 memcpy(pos_val+posx_len, val, val_len*sizeof(WCHAR));
1174 pos_val[posx_len+val_len] = 0;
1175 }else {
1176 hres = E_OUTOFMEMORY;
1179 nsAString_Finish(&pos_str);
1180 if(FAILED(hres))
1181 return hres;
1183 TRACE("setting position to %s\n", debugstr_w(pos_val));
1184 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1185 heap_free(pos_val);
1186 return hres;
1189 static HRESULT WINAPI HTMLStyle_get_backgroundPositionY(IHTMLStyle *iface, VARIANT *p)
1191 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1192 nsAString pos_str;
1193 BSTR ret;
1194 HRESULT hres;
1196 TRACE("(%p)->(%p)\n", This, p);
1198 nsAString_Init(&pos_str, NULL);
1199 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1200 if(SUCCEEDED(hres)) {
1201 const PRUnichar *pos, *posy;
1203 nsAString_GetData(&pos_str, &pos);
1204 posy = strchrW(pos, ' ');
1205 if(posy) {
1206 ret = SysAllocString(posy+1);
1207 if(!ret)
1208 hres = E_OUTOFMEMORY;
1209 }else {
1210 ret = NULL;
1213 nsAString_Finish(&pos_str);
1214 if(FAILED(hres))
1215 return hres;
1217 TRACE("returning %s\n", debugstr_w(ret));
1218 V_VT(p) = VT_BSTR;
1219 V_BSTR(p) = ret;
1220 return S_OK;
1223 static HRESULT WINAPI HTMLStyle_put_wordSpacing(IHTMLStyle *iface, VARIANT v)
1225 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1227 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1229 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, &v, 0);
1232 static HRESULT WINAPI HTMLStyle_get_wordSpacing(IHTMLStyle *iface, VARIANT *p)
1234 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1235 TRACE("(%p)->(%p)\n", This, p);
1236 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, p, 0);
1239 static HRESULT WINAPI HTMLStyle_put_letterSpacing(IHTMLStyle *iface, VARIANT v)
1241 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1243 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1245 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, &v, 0);
1248 static HRESULT WINAPI HTMLStyle_get_letterSpacing(IHTMLStyle *iface, VARIANT *p)
1250 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1251 TRACE("(%p)->(%p)\n", This, p);
1252 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, p, 0);
1255 static HRESULT WINAPI HTMLStyle_put_textDecoration(IHTMLStyle *iface, BSTR v)
1257 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1259 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1261 /* textDecoration can only be one of the following */
1262 if(!v || strcmpiW(styleNone, v) == 0 || strcmpiW(valUnderline, v) == 0 ||
1263 strcmpiW(valOverline, v) == 0 || strcmpiW(valLineThrough, v) == 0 ||
1264 strcmpiW(valBlink, v) == 0)
1266 return set_style_attr(This, STYLEID_TEXT_DECORATION , v, 0);
1269 return E_INVALIDARG;
1272 static HRESULT WINAPI HTMLStyle_get_textDecoration(IHTMLStyle *iface, BSTR *p)
1274 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1276 TRACE("(%p)->(%p)\n", This, p);
1278 return get_style_attr(This, STYLEID_TEXT_DECORATION, p);
1281 static HRESULT WINAPI HTMLStyle_put_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL v)
1283 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1285 TRACE("(%p)->(%x)\n", This, v);
1287 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? styleNone : emptyW, 0);
1290 static HRESULT WINAPI HTMLStyle_get_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL *p)
1292 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1294 TRACE("(%p)->(%p)\n", This, p);
1296 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, styleNone, p);
1299 static HRESULT WINAPI HTMLStyle_put_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL v)
1301 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1303 TRACE("(%p)->(%x)\n", This, v);
1305 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valUnderline : emptyW, 0);
1308 static HRESULT WINAPI HTMLStyle_get_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL *p)
1310 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1312 TRACE("(%p)->(%p)\n", This, p);
1314 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valUnderline, p);
1317 static HRESULT WINAPI HTMLStyle_put_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL v)
1319 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1321 TRACE("(%p)->(%x)\n", This, v);
1323 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valOverline : emptyW, 0);
1326 static HRESULT WINAPI HTMLStyle_get_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL *p)
1328 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1330 TRACE("(%p)->(%p)\n", This, p);
1332 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valOverline, p);
1335 static HRESULT WINAPI HTMLStyle_put_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL v)
1337 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1339 TRACE("(%p)->(%x)\n", This, v);
1341 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valLineThrough : emptyW, 0);
1344 static HRESULT WINAPI HTMLStyle_get_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL *p)
1346 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1348 TRACE("(%p)->(%p)\n", This, p);
1350 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valLineThrough, p);
1353 static HRESULT WINAPI HTMLStyle_put_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL v)
1355 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1357 TRACE("(%p)->(%x)\n", This, v);
1359 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valBlink : emptyW, 0);
1362 static HRESULT WINAPI HTMLStyle_get_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL *p)
1364 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1366 TRACE("(%p)->(%p)\n", This, p);
1368 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valBlink, p);
1371 static HRESULT WINAPI HTMLStyle_put_verticalAlign(IHTMLStyle *iface, VARIANT v)
1373 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1375 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1377 switch(V_VT(&v)) {
1378 case VT_BSTR:
1379 return set_style_attr(This, STYLEID_VERTICAL_ALIGN, V_BSTR(&v), 0);
1380 default:
1381 FIXME("not implemented vt %d\n", V_VT(&v));
1382 return E_NOTIMPL;
1385 return S_OK;
1388 static HRESULT WINAPI HTMLStyle_get_verticalAlign(IHTMLStyle *iface, VARIANT *p)
1390 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1391 BSTR ret;
1392 HRESULT hres;
1394 TRACE("(%p)->(%p)\n", This, p);
1396 hres = get_style_attr(This, STYLEID_VERTICAL_ALIGN, &ret);
1397 if(FAILED(hres))
1398 return hres;
1400 V_VT(p) = VT_BSTR;
1401 V_BSTR(p) = ret;
1402 return S_OK;
1405 static HRESULT WINAPI HTMLStyle_put_textTransform(IHTMLStyle *iface, BSTR v)
1407 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1408 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1409 return E_NOTIMPL;
1412 static HRESULT WINAPI HTMLStyle_get_textTransform(IHTMLStyle *iface, BSTR *p)
1414 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1415 FIXME("(%p)->(%p)\n", This, p);
1416 return E_NOTIMPL;
1419 static HRESULT WINAPI HTMLStyle_put_textAlign(IHTMLStyle *iface, BSTR v)
1421 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1423 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1425 return set_style_attr(This, STYLEID_TEXT_ALIGN, v, 0);
1428 static HRESULT WINAPI HTMLStyle_get_textAlign(IHTMLStyle *iface, BSTR *p)
1430 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1432 TRACE("(%p)->(%p)\n", This, p);
1434 return get_style_attr(This, STYLEID_TEXT_ALIGN, p);
1437 static HRESULT WINAPI HTMLStyle_put_textIndent(IHTMLStyle *iface, VARIANT v)
1439 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1440 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1441 return E_NOTIMPL;
1444 static HRESULT WINAPI HTMLStyle_get_textIndent(IHTMLStyle *iface, VARIANT *p)
1446 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1447 FIXME("(%p)->(%p)\n", This, p);
1448 return E_NOTIMPL;
1451 static HRESULT WINAPI HTMLStyle_put_lineHeight(IHTMLStyle *iface, VARIANT v)
1453 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1454 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1455 return E_NOTIMPL;
1458 static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
1460 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1461 FIXME("(%p)->(%p)\n", This, p);
1462 return E_NOTIMPL;
1465 static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
1467 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1469 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1471 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, &v, ATTR_FIX_PX);
1474 static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
1476 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1478 TRACE("(%p)->(%p)\n", This, p);
1480 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
1483 static HRESULT WINAPI HTMLStyle_put_marginRight(IHTMLStyle *iface, VARIANT v)
1485 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1487 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1489 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, &v, ATTR_FIX_PX);
1492 static HRESULT WINAPI HTMLStyle_get_marginRight(IHTMLStyle *iface, VARIANT *p)
1494 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1495 TRACE("(%p)->(%p)\n", This, p);
1496 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
1499 static HRESULT WINAPI HTMLStyle_put_marginBottom(IHTMLStyle *iface, VARIANT v)
1501 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1503 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1505 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, &v, ATTR_FIX_PX);
1508 static HRESULT WINAPI HTMLStyle_get_marginBottom(IHTMLStyle *iface, VARIANT *p)
1510 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1512 TRACE("(%p)->(%p)\n", This, p);
1514 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, p, 0);
1517 static HRESULT WINAPI HTMLStyle_put_marginLeft(IHTMLStyle *iface, VARIANT v)
1519 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1521 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1523 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, &v, ATTR_FIX_PX);
1526 static HRESULT WINAPI HTMLStyle_put_margin(IHTMLStyle *iface, BSTR v)
1528 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1530 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1532 return set_style_attr(This, STYLEID_MARGIN, v, 0);
1535 static HRESULT WINAPI HTMLStyle_get_margin(IHTMLStyle *iface, BSTR *p)
1537 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1539 TRACE("(%p)->(%p)\n", This, p);
1541 return get_style_attr(This, STYLEID_MARGIN, p);
1544 static HRESULT WINAPI HTMLStyle_get_marginLeft(IHTMLStyle *iface, VARIANT *p)
1546 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1547 TRACE("(%p)->(%p)\n", This, p);
1548 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
1551 static HRESULT WINAPI HTMLStyle_put_paddingTop(IHTMLStyle *iface, VARIANT v)
1553 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1555 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1557 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, &v, ATTR_FIX_PX);
1560 static HRESULT WINAPI HTMLStyle_get_paddingTop(IHTMLStyle *iface, VARIANT *p)
1562 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1564 TRACE("(%p)->(%p)\n", This, p);
1566 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, p, 0);
1569 static HRESULT WINAPI HTMLStyle_put_paddingRight(IHTMLStyle *iface, VARIANT v)
1571 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1573 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1575 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, &v, ATTR_FIX_PX);
1578 static HRESULT WINAPI HTMLStyle_get_paddingRight(IHTMLStyle *iface, VARIANT *p)
1580 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1582 TRACE("(%p)->(%p)\n", This, p);
1584 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, p, 0);
1587 static HRESULT WINAPI HTMLStyle_put_paddingBottom(IHTMLStyle *iface, VARIANT v)
1589 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1591 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1593 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, &v, ATTR_FIX_PX);
1596 static HRESULT WINAPI HTMLStyle_get_paddingBottom(IHTMLStyle *iface, VARIANT *p)
1598 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1600 TRACE("(%p)->(%p)\n", This, p);
1602 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, p, 0);
1605 static HRESULT WINAPI HTMLStyle_put_paddingLeft(IHTMLStyle *iface, VARIANT v)
1607 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1609 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1611 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, &v, ATTR_FIX_PX);
1614 static HRESULT WINAPI HTMLStyle_get_paddingLeft(IHTMLStyle *iface, VARIANT *p)
1616 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1618 TRACE("(%p)->(%p)\n", This, p);
1620 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, p, 0);
1623 static HRESULT WINAPI HTMLStyle_put_padding(IHTMLStyle *iface, BSTR v)
1625 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1627 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1629 return set_style_attr(This, STYLEID_PADDING, v, 0);
1632 static HRESULT WINAPI HTMLStyle_get_padding(IHTMLStyle *iface, BSTR *p)
1634 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1636 TRACE("(%p)->(%p)\n", This, p);
1638 return get_style_attr(This, STYLEID_PADDING, p);
1641 static HRESULT WINAPI HTMLStyle_put_border(IHTMLStyle *iface, BSTR v)
1643 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1645 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1647 return set_style_attr(This, STYLEID_BORDER, v, 0);
1650 static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
1652 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1654 TRACE("(%p)->(%p)\n", This, p);
1656 return get_style_attr(This, STYLEID_BORDER, p);
1659 static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
1661 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1662 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1663 return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX);
1666 static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
1668 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1669 TRACE("(%p)->(%p)\n", This, p);
1670 return get_style_attr(This, STYLEID_BORDER_TOP, p);
1673 static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
1675 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1676 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1677 return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX);
1680 static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
1682 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1683 TRACE("(%p)->(%p)\n", This, p);
1684 return get_style_attr(This, STYLEID_BORDER_RIGHT, p);
1687 static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
1689 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1690 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1691 return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX);
1694 static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
1696 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1697 TRACE("(%p)->(%p)\n", This, p);
1698 return get_style_attr(This, STYLEID_BORDER_BOTTOM, p);
1701 static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
1703 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1705 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1707 return set_style_attr(This, STYLEID_BORDER_LEFT, v, ATTR_FIX_PX);
1710 static HRESULT WINAPI HTMLStyle_get_borderLeft(IHTMLStyle *iface, BSTR *p)
1712 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1714 TRACE("(%p)->(%p)\n", This, p);
1716 return get_style_attr(This, STYLEID_BORDER_LEFT, p);
1719 static HRESULT WINAPI HTMLStyle_put_borderColor(IHTMLStyle *iface, BSTR v)
1721 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1723 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1725 return set_style_attr(This, STYLEID_BORDER_COLOR, v, 0);
1728 static HRESULT WINAPI HTMLStyle_get_borderColor(IHTMLStyle *iface, BSTR *p)
1730 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1732 TRACE("(%p)->(%p)\n", This, p);
1734 return get_style_attr(This, STYLEID_BORDER_COLOR, p);
1737 static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v)
1739 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1741 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1743 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, &v, ATTR_HEX_INT);
1746 static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p)
1748 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1750 TRACE("(%p)->(%p)\n", This, p);
1752 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0);
1755 static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v)
1757 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1759 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1761 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, &v, ATTR_HEX_INT);
1764 static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p)
1766 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1768 TRACE("(%p)->(%p)\n", This, p);
1770 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0);
1773 static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v)
1775 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1777 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1779 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, &v, ATTR_HEX_INT);
1782 static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p)
1784 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1786 TRACE("(%p)->(%p)\n", This, p);
1788 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0);
1791 static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v)
1793 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1795 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1797 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, &v, ATTR_HEX_INT);
1800 static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p)
1802 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1804 TRACE("(%p)->(%p)\n", This, p);
1806 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0);
1809 static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v)
1811 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1812 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1813 return set_style_attr(This, STYLEID_BORDER_WIDTH, v, ATTR_FIX_PX);
1816 static HRESULT WINAPI HTMLStyle_get_borderWidth(IHTMLStyle *iface, BSTR *p)
1818 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1819 TRACE("(%p)->(%p)\n", This, p);
1820 return get_style_attr(This, STYLEID_BORDER_WIDTH, p);
1823 static HRESULT WINAPI HTMLStyle_put_borderTopWidth(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_TOP_WIDTH, &v, 0);
1832 static HRESULT WINAPI HTMLStyle_get_borderTopWidth(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_TOP_WIDTH, p, 0);
1841 static HRESULT WINAPI HTMLStyle_put_borderRightWidth(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_RIGHT_WIDTH, &v, 0);
1850 static HRESULT WINAPI HTMLStyle_get_borderRightWidth(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_RIGHT_WIDTH, p, 0);
1859 static HRESULT WINAPI HTMLStyle_put_borderBottomWidth(IHTMLStyle *iface, VARIANT v)
1861 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1863 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1865 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, &v, 0);
1868 static HRESULT WINAPI HTMLStyle_get_borderBottomWidth(IHTMLStyle *iface, VARIANT *p)
1870 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1871 TRACE("(%p)->(%p)\n", This, p);
1872 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, p, 0);
1875 static HRESULT WINAPI HTMLStyle_put_borderLeftWidth(IHTMLStyle *iface, VARIANT v)
1877 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1879 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1881 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, &v, 0);
1884 static HRESULT WINAPI HTMLStyle_get_borderLeftWidth(IHTMLStyle *iface, VARIANT *p)
1886 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1887 TRACE("(%p)->(%p)\n", This, p);
1888 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, p, 0);
1891 static HRESULT WINAPI HTMLStyle_put_borderStyle(IHTMLStyle *iface, BSTR v)
1893 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1894 static const WCHAR styleWindowInset[] = {'w','i','n','d','o','w','-','i','n','s','e','t',0};
1895 HRESULT hres = S_OK;
1896 BSTR pstyle;
1897 int i=0;
1898 int last = 0;
1900 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1902 while(v[i] && hres == S_OK)
1904 if(v[i] == (WCHAR)' ')
1906 pstyle = SysAllocStringLen(&v[last], (i-last));
1907 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1909 TRACE("1. Invalid style (%s)\n", debugstr_w(pstyle));
1910 hres = E_INVALIDARG;
1912 SysFreeString(pstyle);
1913 last = i+1;
1915 i++;
1918 if(hres == S_OK)
1920 pstyle = SysAllocStringLen(&v[last], i-last);
1921 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1923 TRACE("2. Invalid style (%s)\n", debugstr_w(pstyle));
1924 hres = E_INVALIDARG;
1926 SysFreeString(pstyle);
1929 if(hres == S_OK)
1930 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, v, 0);
1932 return hres;
1935 static HRESULT WINAPI HTMLStyle_get_borderStyle(IHTMLStyle *iface, BSTR *p)
1937 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1938 TRACE("(%p)->(%p)\n", This, p);
1939 return get_style_attr(This, STYLEID_BORDER_STYLE, p);
1942 static HRESULT WINAPI HTMLStyle_put_borderTopStyle(IHTMLStyle *iface, BSTR v)
1944 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1945 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1947 if(!is_valid_border_style(v))
1948 return E_INVALIDARG;
1950 return set_style_attr(This, STYLEID_BORDER_TOP_STYLE, v, 0);
1953 static HRESULT WINAPI HTMLStyle_get_borderTopStyle(IHTMLStyle *iface, BSTR *p)
1955 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1956 TRACE("(%p)->(%p)\n", This, p);
1957 return get_style_attr(This, STYLEID_BORDER_TOP_STYLE, p);
1960 static HRESULT WINAPI HTMLStyle_put_borderRightStyle(IHTMLStyle *iface, BSTR v)
1962 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1963 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1965 if(!is_valid_border_style(v))
1966 return E_INVALIDARG;
1968 return set_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, v, 0);
1971 static HRESULT WINAPI HTMLStyle_get_borderRightStyle(IHTMLStyle *iface, BSTR *p)
1973 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1974 TRACE("(%p)->(%p)\n", This, p);
1975 return get_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, p);
1978 static HRESULT WINAPI HTMLStyle_put_borderBottomStyle(IHTMLStyle *iface, BSTR v)
1980 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1981 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1983 if(!is_valid_border_style(v))
1984 return E_INVALIDARG;
1986 return set_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, v, 0);
1989 static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p)
1991 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1992 TRACE("(%p)->(%p)\n", This, p);
1993 return get_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, p);
1996 static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v)
1998 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1999 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2001 if(!is_valid_border_style(v))
2002 return E_INVALIDARG;
2004 return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0);
2007 static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p)
2009 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2010 TRACE("(%p)->(%p)\n", This, p);
2011 return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p);
2014 static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
2016 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2018 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2020 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX);
2023 static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
2025 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2027 TRACE("(%p)->(%p)\n", This, p);
2029 V_VT(p) = VT_BSTR;
2030 return get_style_attr(This, STYLEID_WIDTH, &V_BSTR(p));
2033 static HRESULT WINAPI HTMLStyle_put_height(IHTMLStyle *iface, VARIANT v)
2035 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2037 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2039 return set_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, &v, ATTR_FIX_PX);
2042 static HRESULT WINAPI HTMLStyle_get_height(IHTMLStyle *iface, VARIANT *p)
2044 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2045 BSTR ret;
2046 HRESULT hres;
2048 TRACE("(%p)->(%p)\n", This, p);
2050 hres = get_style_attr(This, STYLEID_HEIGHT, &ret);
2051 if(FAILED(hres))
2052 return hres;
2054 V_VT(p) = VT_BSTR;
2055 V_BSTR(p) = ret;
2056 return S_OK;
2059 static HRESULT WINAPI HTMLStyle_put_styleFloat(IHTMLStyle *iface, BSTR v)
2061 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2062 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2063 return E_NOTIMPL;
2066 static HRESULT WINAPI HTMLStyle_get_styleFloat(IHTMLStyle *iface, BSTR *p)
2068 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2069 FIXME("(%p)->(%p)\n", This, p);
2070 return E_NOTIMPL;
2073 static HRESULT WINAPI HTMLStyle_put_clear(IHTMLStyle *iface, BSTR v)
2075 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2076 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2077 return E_NOTIMPL;
2080 static HRESULT WINAPI HTMLStyle_get_clear(IHTMLStyle *iface, BSTR *p)
2082 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2083 FIXME("(%p)->(%p)\n", This, p);
2084 return E_NOTIMPL;
2087 static HRESULT WINAPI HTMLStyle_put_display(IHTMLStyle *iface, BSTR v)
2089 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2091 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2093 return set_style_attr(This, STYLEID_DISPLAY, v, 0);
2096 static HRESULT WINAPI HTMLStyle_get_display(IHTMLStyle *iface, BSTR *p)
2098 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2100 TRACE("(%p)->(%p)\n", This, p);
2102 return get_style_attr(This, STYLEID_DISPLAY, p);
2105 static HRESULT WINAPI HTMLStyle_put_visibility(IHTMLStyle *iface, BSTR v)
2107 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2109 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2111 return set_style_attr(This, STYLEID_VISIBILITY, v, 0);
2114 static HRESULT WINAPI HTMLStyle_get_visibility(IHTMLStyle *iface, BSTR *p)
2116 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2118 TRACE("(%p)->(%p)\n", This, p);
2120 return get_style_attr(This, STYLEID_VISIBILITY, p);
2123 static HRESULT WINAPI HTMLStyle_put_listStyleType(IHTMLStyle *iface, BSTR v)
2125 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2126 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2127 return E_NOTIMPL;
2130 static HRESULT WINAPI HTMLStyle_get_listStyleType(IHTMLStyle *iface, BSTR *p)
2132 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2133 FIXME("(%p)->(%p)\n", This, p);
2134 return E_NOTIMPL;
2137 static HRESULT WINAPI HTMLStyle_put_listStylePosition(IHTMLStyle *iface, BSTR v)
2139 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2140 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2141 return E_NOTIMPL;
2144 static HRESULT WINAPI HTMLStyle_get_listStylePosition(IHTMLStyle *iface, BSTR *p)
2146 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2147 FIXME("(%p)->(%p)\n", This, p);
2148 return E_NOTIMPL;
2151 static HRESULT WINAPI HTMLStyle_put_listStyleImage(IHTMLStyle *iface, BSTR v)
2153 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2154 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2155 return E_NOTIMPL;
2158 static HRESULT WINAPI HTMLStyle_get_listStyleImage(IHTMLStyle *iface, BSTR *p)
2160 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2161 FIXME("(%p)->(%p)\n", This, p);
2162 return E_NOTIMPL;
2165 static HRESULT WINAPI HTMLStyle_put_listStyle(IHTMLStyle *iface, BSTR v)
2167 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2168 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2169 return E_NOTIMPL;
2172 static HRESULT WINAPI HTMLStyle_get_listStyle(IHTMLStyle *iface, BSTR *p)
2174 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2175 FIXME("(%p)->(%p)\n", This, p);
2176 return E_NOTIMPL;
2179 static HRESULT WINAPI HTMLStyle_put_whiteSpace(IHTMLStyle *iface, BSTR v)
2181 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2182 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2183 return E_NOTIMPL;
2186 static HRESULT WINAPI HTMLStyle_get_whiteSpace(IHTMLStyle *iface, BSTR *p)
2188 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2189 FIXME("(%p)->(%p)\n", This, p);
2190 return E_NOTIMPL;
2193 static HRESULT WINAPI HTMLStyle_put_top(IHTMLStyle *iface, VARIANT v)
2195 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2197 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2199 return set_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, &v, 0);
2202 static HRESULT WINAPI HTMLStyle_get_top(IHTMLStyle *iface, VARIANT *p)
2204 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2205 BSTR ret;
2206 HRESULT hres;
2208 TRACE("(%p)->(%p)\n", This, p);
2210 hres = get_style_attr(This, STYLEID_TOP, &ret);
2211 if(FAILED(hres))
2212 return hres;
2214 V_VT(p) = VT_BSTR;
2215 V_BSTR(p) = ret;
2216 return S_OK;
2219 static HRESULT WINAPI HTMLStyle_put_left(IHTMLStyle *iface, VARIANT v)
2221 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2223 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2225 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, &v, 0);
2228 static HRESULT WINAPI HTMLStyle_get_left(IHTMLStyle *iface, VARIANT *p)
2230 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2231 BSTR ret;
2232 HRESULT hres;
2234 TRACE("(%p)->(%p)\n", This, p);
2236 hres = get_style_attr(This, STYLEID_LEFT, &ret);
2237 if(FAILED(hres))
2238 return hres;
2240 V_VT(p) = VT_BSTR;
2241 V_BSTR(p) = ret;
2242 return S_OK;
2245 static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
2247 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2248 TRACE("(%p)->(%p)\n", This, p);
2249 return IHTMLStyle2_get_position(&This->IHTMLStyle2_iface, p);
2252 static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
2254 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2256 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2258 switch(V_VT(&v)) {
2259 case VT_BSTR:
2260 return set_style_attr(This, STYLEID_Z_INDEX, V_BSTR(&v), 0);
2261 case VT_I4: {
2262 WCHAR value[14];
2263 static const WCHAR format[] = {'%','d',0};
2265 wsprintfW(value, format, V_I4(&v));
2266 return set_style_attr(This, STYLEID_Z_INDEX, value, 0);
2268 default:
2269 FIXME("unimplemented vt %d\n", V_VT(&v));
2270 return E_NOTIMPL;
2273 return S_OK;
2276 static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
2278 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2280 TRACE("(%p)->(%p)\n", This, p);
2282 return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
2285 static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
2287 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2288 static const WCHAR szVisible[] = {'v','i','s','i','b','l','e',0};
2289 static const WCHAR szScroll[] = {'s','c','r','o','l','l',0};
2290 static const WCHAR szHidden[] = {'h','i','d','d','e','n',0};
2291 static const WCHAR szAuto[] = {'a','u','t','o',0};
2293 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2295 /* overflow can only be one of the follow values. */
2296 if(!v || !*v || strcmpiW(szVisible, v) == 0 || strcmpiW(szScroll, v) == 0 ||
2297 strcmpiW(szHidden, v) == 0 || strcmpiW(szAuto, v) == 0)
2299 return set_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, v, 0);
2302 return E_INVALIDARG;
2306 static HRESULT WINAPI HTMLStyle_get_overflow(IHTMLStyle *iface, BSTR *p)
2308 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2310 TRACE("(%p)->(%p)\n", This, p);
2312 if(!p)
2313 return E_INVALIDARG;
2315 return get_style_attr(This, STYLEID_OVERFLOW, p);
2318 static HRESULT WINAPI HTMLStyle_put_pageBreakBefore(IHTMLStyle *iface, BSTR v)
2320 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2322 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2324 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, v, 0);
2327 static HRESULT WINAPI HTMLStyle_get_pageBreakBefore(IHTMLStyle *iface, BSTR *p)
2329 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2331 TRACE("(%p)->(%p)\n", This, p);
2333 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, p, 0);
2336 static HRESULT WINAPI HTMLStyle_put_pageBreakAfter(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_AFTER, v, 0);
2345 static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(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_AFTER, p, 0);
2354 static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
2356 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2357 nsAString text_str;
2358 nsresult nsres;
2360 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2362 nsAString_InitDepend(&text_str, v);
2363 nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str);
2364 nsAString_Finish(&text_str);
2365 if(NS_FAILED(nsres)) {
2366 FIXME("SetCssStyle failed: %08x\n", nsres);
2367 return E_FAIL;
2370 return S_OK;
2373 static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p)
2375 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2376 nsAString text_str;
2377 nsresult nsres;
2379 TRACE("(%p)->(%p)\n", This, p);
2381 /* FIXME: Gecko style formatting is different than IE (uppercase). */
2382 nsAString_Init(&text_str, NULL);
2383 nsres = nsIDOMCSSStyleDeclaration_GetCssText(This->nsstyle, &text_str);
2384 if(NS_SUCCEEDED(nsres)) {
2385 const PRUnichar *text;
2387 nsAString_GetData(&text_str, &text);
2388 *p = *text ? SysAllocString(text) : NULL;
2389 }else {
2390 FIXME("GetCssStyle failed: %08x\n", nsres);
2391 *p = NULL;
2394 nsAString_Finish(&text_str);
2395 return S_OK;
2398 static HRESULT WINAPI HTMLStyle_put_pixelTop(IHTMLStyle *iface, LONG v)
2400 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2401 FIXME("(%p)->()\n", This);
2402 return E_NOTIMPL;
2405 static HRESULT WINAPI HTMLStyle_get_pixelTop(IHTMLStyle *iface, LONG *p)
2407 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2408 FIXME("(%p)->()\n", This);
2409 return E_NOTIMPL;
2412 static HRESULT WINAPI HTMLStyle_put_pixelLeft(IHTMLStyle *iface, LONG v)
2414 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2415 FIXME("(%p)->()\n", This);
2416 return E_NOTIMPL;
2419 static HRESULT WINAPI HTMLStyle_get_pixelLeft(IHTMLStyle *iface, LONG *p)
2421 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2422 FIXME("(%p)->()\n", This);
2423 return E_NOTIMPL;
2426 static HRESULT WINAPI HTMLStyle_put_pixelWidth(IHTMLStyle *iface, LONG v)
2428 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2429 FIXME("(%p)->()\n", This);
2430 return E_NOTIMPL;
2433 static HRESULT WINAPI HTMLStyle_get_pixelWidth(IHTMLStyle *iface, LONG *p)
2435 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2436 FIXME("(%p)->()\n", This);
2437 return E_NOTIMPL;
2440 static HRESULT WINAPI HTMLStyle_put_pixelHeight(IHTMLStyle *iface, LONG v)
2442 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2443 FIXME("(%p)->()\n", This);
2444 return E_NOTIMPL;
2447 static HRESULT WINAPI HTMLStyle_get_pixelHeight(IHTMLStyle *iface, LONG *p)
2449 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2450 FIXME("(%p)->()\n", This);
2451 return E_NOTIMPL;
2454 static HRESULT WINAPI HTMLStyle_put_posTop(IHTMLStyle *iface, float v)
2456 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2458 TRACE("(%p)->(%f)\n", This, v);
2460 return set_style_pos(This, STYLEID_TOP, v);
2463 static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
2465 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2467 TRACE("(%p)->(%p)\n", This, p);
2469 if(!p)
2470 return E_POINTER;
2472 return get_nsstyle_pos(This, STYLEID_TOP, p);
2475 static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
2477 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2479 TRACE("(%p)->(%f)\n", This, v);
2481 return set_style_pos(This, STYLEID_LEFT, v);
2484 static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
2486 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2488 TRACE("(%p)->(%p)\n", This, p);
2490 if(!p)
2491 return E_POINTER;
2493 return get_nsstyle_pos(This, STYLEID_LEFT, p);
2496 static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
2498 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2500 TRACE("(%p)->(%f)\n", This, v);
2502 return set_style_pos(This, STYLEID_WIDTH, v);
2505 static HRESULT WINAPI HTMLStyle_get_posWidth(IHTMLStyle *iface, float *p)
2507 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2509 TRACE("(%p)->(%p)\n", This, p);
2511 if(!p)
2512 return E_POINTER;
2514 if(get_nsstyle_pos(This, STYLEID_WIDTH, p) != S_OK)
2515 *p = 0.0f;
2517 return S_OK;
2520 static HRESULT WINAPI HTMLStyle_put_posHeight(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_HEIGHT, v);
2529 static HRESULT WINAPI HTMLStyle_get_posHeight(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_HEIGHT, p) != S_OK)
2539 *p = 0.0f;
2541 return S_OK;
2544 static HRESULT WINAPI HTMLStyle_put_cursor(IHTMLStyle *iface, BSTR v)
2546 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2548 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2550 return set_style_attr(This, STYLEID_CURSOR, v, 0);
2553 static HRESULT WINAPI HTMLStyle_get_cursor(IHTMLStyle *iface, BSTR *p)
2555 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2557 TRACE("(%p)->(%p)\n", This, p);
2559 return get_style_attr(This, STYLEID_CURSOR, p);
2562 static HRESULT WINAPI HTMLStyle_put_clip(IHTMLStyle *iface, BSTR v)
2564 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2566 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2568 return set_style_attr(This, STYLEID_CLIP, v, 0);
2571 static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
2573 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2575 TRACE("(%p)->(%p)\n", This, p);
2577 return get_nsstyle_attr(This->nsstyle, STYLEID_CLIP, p, ATTR_REMOVE_COMMA);
2580 static void set_opacity(HTMLStyle *This, const WCHAR *val)
2582 nsAString name_str, val_str, empty_str;
2583 nsresult nsres;
2585 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y',0};
2587 TRACE("%s\n", debugstr_w(val));
2589 nsAString_InitDepend(&name_str, opacityW);
2590 nsAString_InitDepend(&val_str, val);
2591 nsAString_InitDepend(&empty_str, emptyW);
2593 nsres = nsIDOMCSSStyleDeclaration_SetProperty(This->nsstyle, &name_str, &val_str, &empty_str);
2594 if(NS_FAILED(nsres))
2595 ERR("SetProperty failed: %08x\n", nsres);
2597 nsAString_Finish(&name_str);
2598 nsAString_Finish(&val_str);
2599 nsAString_Finish(&empty_str);
2602 static void update_filter(HTMLStyle *This)
2604 const WCHAR *ptr = This->elem->filter, *ptr2;
2606 static const WCHAR alphaW[] = {'a','l','p','h','a'};
2608 if(!ptr) {
2609 set_opacity(This, emptyW);
2610 return;
2613 while(1) {
2614 while(isspaceW(*ptr))
2615 ptr++;
2616 if(!*ptr)
2617 break;
2619 ptr2 = ptr;
2620 while(isalnumW(*ptr))
2621 ptr++;
2622 if(ptr == ptr2) {
2623 WARN("unexpected char '%c'\n", *ptr);
2624 break;
2626 if(*ptr != '(') {
2627 WARN("expected '('\n");
2628 continue;
2631 if(ptr2 + sizeof(alphaW)/sizeof(WCHAR) == ptr && !memcmp(ptr2, alphaW, sizeof(alphaW))) {
2632 static const WCHAR formatW[] = {'%','f',0};
2633 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y','='};
2635 ptr++;
2636 do {
2637 while(isspaceW(*ptr))
2638 ptr++;
2640 ptr2 = ptr;
2641 while(*ptr && *ptr != ',' && *ptr != ')')
2642 ptr++;
2643 if(!*ptr) {
2644 WARN("unexpected end of string\n");
2645 break;
2648 if(ptr-ptr2 > sizeof(opacityW)/sizeof(WCHAR) && !memcmp(ptr2, opacityW, sizeof(opacityW))) {
2649 float fval = 0.0f, e = 0.1f;
2650 WCHAR buf[32];
2652 ptr2 += sizeof(opacityW)/sizeof(WCHAR);
2654 while(isdigitW(*ptr2))
2655 fval = fval*10.0f + (float)(*ptr2++ - '0');
2657 if(*ptr2 == '.') {
2658 while(isdigitW(*++ptr2)) {
2659 fval += e * (float)(*ptr2++ - '0');
2660 e *= 0.1f;
2664 sprintfW(buf, formatW, fval * 0.01f);
2665 set_opacity(This, buf);
2666 }else {
2667 FIXME("unknown param %s\n", debugstr_wn(ptr2, ptr-ptr2));
2670 if(*ptr == ',')
2671 ptr++;
2672 }while(*ptr != ')');
2673 }else {
2674 FIXME("unknown filter %s\n", debugstr_wn(ptr2, ptr-ptr2));
2675 ptr = strchrW(ptr, ')');
2676 if(!ptr)
2677 break;
2678 ptr++;
2683 static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
2685 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2686 WCHAR *new_filter = NULL;
2688 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2690 if(!This->elem) {
2691 FIXME("Element already destroyed\n");
2692 return E_UNEXPECTED;
2695 if(v) {
2696 new_filter = heap_strdupW(v);
2697 if(!new_filter)
2698 return E_OUTOFMEMORY;
2701 heap_free(This->elem->filter);
2702 This->elem->filter = new_filter;
2704 update_filter(This);
2705 return S_OK;
2708 static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
2710 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2712 TRACE("(%p)->(%p)\n", This, p);
2714 if(!This->elem) {
2715 FIXME("Element already destroyed\n");
2716 return E_UNEXPECTED;
2719 if(This->elem->filter) {
2720 *p = SysAllocString(This->elem->filter);
2721 if(!*p)
2722 return E_OUTOFMEMORY;
2723 }else {
2724 *p = NULL;
2727 return S_OK;
2730 static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2731 VARIANT AttributeValue, LONG lFlags)
2733 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2734 HRESULT hres;
2735 DISPID dispid;
2737 TRACE("(%p)->(%s v%d %08x)\n", This, debugstr_w(strAttributeName),
2738 V_VT(&AttributeValue), lFlags);
2740 if(!strAttributeName)
2741 return E_INVALIDARG;
2743 if(lFlags == 1)
2744 FIXME("Parameter lFlags ignored\n");
2746 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2747 LOCALE_USER_DEFAULT, &dispid);
2748 if(hres == S_OK)
2750 VARIANT ret;
2751 DISPID dispidNamed = DISPID_PROPERTYPUT;
2752 DISPPARAMS params;
2754 params.cArgs = 1;
2755 params.rgvarg = &AttributeValue;
2756 params.cNamedArgs = 1;
2757 params.rgdispidNamedArgs = &dispidNamed;
2759 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2760 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2762 else
2764 FIXME("Custom attributes not supported.\n");
2767 TRACE("ret: %08x\n", hres);
2769 return hres;
2772 static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2773 LONG lFlags, VARIANT *AttributeValue)
2775 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2776 HRESULT hres;
2777 DISPID dispid;
2779 TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName),
2780 AttributeValue, lFlags);
2782 if(!AttributeValue || !strAttributeName)
2783 return E_INVALIDARG;
2785 if(lFlags == 1)
2786 FIXME("Parameter lFlags ignored\n");
2788 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2789 LOCALE_USER_DEFAULT, &dispid);
2790 if(hres == S_OK)
2792 DISPPARAMS params = {NULL, NULL, 0, 0 };
2794 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2795 DISPATCH_PROPERTYGET, &params, AttributeValue, NULL, NULL);
2797 else
2799 FIXME("Custom attributes not supported.\n");
2802 return hres;
2805 static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2806 LONG lFlags, VARIANT_BOOL *pfSuccess)
2808 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2809 FIXME("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName),
2810 lFlags, pfSuccess);
2811 return E_NOTIMPL;
2814 static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
2816 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2817 FIXME("(%p)->(%p)\n", This, String);
2818 return E_NOTIMPL;
2821 static const IHTMLStyleVtbl HTMLStyleVtbl = {
2822 HTMLStyle_QueryInterface,
2823 HTMLStyle_AddRef,
2824 HTMLStyle_Release,
2825 HTMLStyle_GetTypeInfoCount,
2826 HTMLStyle_GetTypeInfo,
2827 HTMLStyle_GetIDsOfNames,
2828 HTMLStyle_Invoke,
2829 HTMLStyle_put_fontFamily,
2830 HTMLStyle_get_fontFamily,
2831 HTMLStyle_put_fontStyle,
2832 HTMLStyle_get_fontStyle,
2833 HTMLStyle_put_fontVariant,
2834 HTMLStyle_get_fontVariant,
2835 HTMLStyle_put_fontWeight,
2836 HTMLStyle_get_fontWeight,
2837 HTMLStyle_put_fontSize,
2838 HTMLStyle_get_fontSize,
2839 HTMLStyle_put_font,
2840 HTMLStyle_get_font,
2841 HTMLStyle_put_color,
2842 HTMLStyle_get_color,
2843 HTMLStyle_put_background,
2844 HTMLStyle_get_background,
2845 HTMLStyle_put_backgroundColor,
2846 HTMLStyle_get_backgroundColor,
2847 HTMLStyle_put_backgroundImage,
2848 HTMLStyle_get_backgroundImage,
2849 HTMLStyle_put_backgroundRepeat,
2850 HTMLStyle_get_backgroundRepeat,
2851 HTMLStyle_put_backgroundAttachment,
2852 HTMLStyle_get_backgroundAttachment,
2853 HTMLStyle_put_backgroundPosition,
2854 HTMLStyle_get_backgroundPosition,
2855 HTMLStyle_put_backgroundPositionX,
2856 HTMLStyle_get_backgroundPositionX,
2857 HTMLStyle_put_backgroundPositionY,
2858 HTMLStyle_get_backgroundPositionY,
2859 HTMLStyle_put_wordSpacing,
2860 HTMLStyle_get_wordSpacing,
2861 HTMLStyle_put_letterSpacing,
2862 HTMLStyle_get_letterSpacing,
2863 HTMLStyle_put_textDecoration,
2864 HTMLStyle_get_textDecoration,
2865 HTMLStyle_put_textDecorationNone,
2866 HTMLStyle_get_textDecorationNone,
2867 HTMLStyle_put_textDecorationUnderline,
2868 HTMLStyle_get_textDecorationUnderline,
2869 HTMLStyle_put_textDecorationOverline,
2870 HTMLStyle_get_textDecorationOverline,
2871 HTMLStyle_put_textDecorationLineThrough,
2872 HTMLStyle_get_textDecorationLineThrough,
2873 HTMLStyle_put_textDecorationBlink,
2874 HTMLStyle_get_textDecorationBlink,
2875 HTMLStyle_put_verticalAlign,
2876 HTMLStyle_get_verticalAlign,
2877 HTMLStyle_put_textTransform,
2878 HTMLStyle_get_textTransform,
2879 HTMLStyle_put_textAlign,
2880 HTMLStyle_get_textAlign,
2881 HTMLStyle_put_textIndent,
2882 HTMLStyle_get_textIndent,
2883 HTMLStyle_put_lineHeight,
2884 HTMLStyle_get_lineHeight,
2885 HTMLStyle_put_marginTop,
2886 HTMLStyle_get_marginTop,
2887 HTMLStyle_put_marginRight,
2888 HTMLStyle_get_marginRight,
2889 HTMLStyle_put_marginBottom,
2890 HTMLStyle_get_marginBottom,
2891 HTMLStyle_put_marginLeft,
2892 HTMLStyle_get_marginLeft,
2893 HTMLStyle_put_margin,
2894 HTMLStyle_get_margin,
2895 HTMLStyle_put_paddingTop,
2896 HTMLStyle_get_paddingTop,
2897 HTMLStyle_put_paddingRight,
2898 HTMLStyle_get_paddingRight,
2899 HTMLStyle_put_paddingBottom,
2900 HTMLStyle_get_paddingBottom,
2901 HTMLStyle_put_paddingLeft,
2902 HTMLStyle_get_paddingLeft,
2903 HTMLStyle_put_padding,
2904 HTMLStyle_get_padding,
2905 HTMLStyle_put_border,
2906 HTMLStyle_get_border,
2907 HTMLStyle_put_borderTop,
2908 HTMLStyle_get_borderTop,
2909 HTMLStyle_put_borderRight,
2910 HTMLStyle_get_borderRight,
2911 HTMLStyle_put_borderBottom,
2912 HTMLStyle_get_borderBottom,
2913 HTMLStyle_put_borderLeft,
2914 HTMLStyle_get_borderLeft,
2915 HTMLStyle_put_borderColor,
2916 HTMLStyle_get_borderColor,
2917 HTMLStyle_put_borderTopColor,
2918 HTMLStyle_get_borderTopColor,
2919 HTMLStyle_put_borderRightColor,
2920 HTMLStyle_get_borderRightColor,
2921 HTMLStyle_put_borderBottomColor,
2922 HTMLStyle_get_borderBottomColor,
2923 HTMLStyle_put_borderLeftColor,
2924 HTMLStyle_get_borderLeftColor,
2925 HTMLStyle_put_borderWidth,
2926 HTMLStyle_get_borderWidth,
2927 HTMLStyle_put_borderTopWidth,
2928 HTMLStyle_get_borderTopWidth,
2929 HTMLStyle_put_borderRightWidth,
2930 HTMLStyle_get_borderRightWidth,
2931 HTMLStyle_put_borderBottomWidth,
2932 HTMLStyle_get_borderBottomWidth,
2933 HTMLStyle_put_borderLeftWidth,
2934 HTMLStyle_get_borderLeftWidth,
2935 HTMLStyle_put_borderStyle,
2936 HTMLStyle_get_borderStyle,
2937 HTMLStyle_put_borderTopStyle,
2938 HTMLStyle_get_borderTopStyle,
2939 HTMLStyle_put_borderRightStyle,
2940 HTMLStyle_get_borderRightStyle,
2941 HTMLStyle_put_borderBottomStyle,
2942 HTMLStyle_get_borderBottomStyle,
2943 HTMLStyle_put_borderLeftStyle,
2944 HTMLStyle_get_borderLeftStyle,
2945 HTMLStyle_put_width,
2946 HTMLStyle_get_width,
2947 HTMLStyle_put_height,
2948 HTMLStyle_get_height,
2949 HTMLStyle_put_styleFloat,
2950 HTMLStyle_get_styleFloat,
2951 HTMLStyle_put_clear,
2952 HTMLStyle_get_clear,
2953 HTMLStyle_put_display,
2954 HTMLStyle_get_display,
2955 HTMLStyle_put_visibility,
2956 HTMLStyle_get_visibility,
2957 HTMLStyle_put_listStyleType,
2958 HTMLStyle_get_listStyleType,
2959 HTMLStyle_put_listStylePosition,
2960 HTMLStyle_get_listStylePosition,
2961 HTMLStyle_put_listStyleImage,
2962 HTMLStyle_get_listStyleImage,
2963 HTMLStyle_put_listStyle,
2964 HTMLStyle_get_listStyle,
2965 HTMLStyle_put_whiteSpace,
2966 HTMLStyle_get_whiteSpace,
2967 HTMLStyle_put_top,
2968 HTMLStyle_get_top,
2969 HTMLStyle_put_left,
2970 HTMLStyle_get_left,
2971 HTMLStyle_get_position,
2972 HTMLStyle_put_zIndex,
2973 HTMLStyle_get_zIndex,
2974 HTMLStyle_put_overflow,
2975 HTMLStyle_get_overflow,
2976 HTMLStyle_put_pageBreakBefore,
2977 HTMLStyle_get_pageBreakBefore,
2978 HTMLStyle_put_pageBreakAfter,
2979 HTMLStyle_get_pageBreakAfter,
2980 HTMLStyle_put_cssText,
2981 HTMLStyle_get_cssText,
2982 HTMLStyle_put_pixelTop,
2983 HTMLStyle_get_pixelTop,
2984 HTMLStyle_put_pixelLeft,
2985 HTMLStyle_get_pixelLeft,
2986 HTMLStyle_put_pixelWidth,
2987 HTMLStyle_get_pixelWidth,
2988 HTMLStyle_put_pixelHeight,
2989 HTMLStyle_get_pixelHeight,
2990 HTMLStyle_put_posTop,
2991 HTMLStyle_get_posTop,
2992 HTMLStyle_put_posLeft,
2993 HTMLStyle_get_posLeft,
2994 HTMLStyle_put_posWidth,
2995 HTMLStyle_get_posWidth,
2996 HTMLStyle_put_posHeight,
2997 HTMLStyle_get_posHeight,
2998 HTMLStyle_put_cursor,
2999 HTMLStyle_get_cursor,
3000 HTMLStyle_put_clip,
3001 HTMLStyle_get_clip,
3002 HTMLStyle_put_filter,
3003 HTMLStyle_get_filter,
3004 HTMLStyle_setAttribute,
3005 HTMLStyle_getAttribute,
3006 HTMLStyle_removeAttribute,
3007 HTMLStyle_toString
3010 static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
3012 int c, i, min=0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
3014 while(min <= max) {
3015 i = (min+max)/2;
3017 c = strcmpW(style_tbl[i].name, name);
3018 if(!c) {
3019 *dispid = style_tbl[i].dispid;
3020 return S_OK;
3023 if(c > 0)
3024 max = i-1;
3025 else
3026 min = i+1;
3029 return DISP_E_UNKNOWNNAME;
3032 static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
3033 NULL,
3034 HTMLStyle_get_dispid,
3035 NULL,
3036 NULL
3039 static const tid_t HTMLStyle_iface_tids[] = {
3040 IHTMLStyle_tid,
3041 IHTMLStyle2_tid,
3042 IHTMLStyle3_tid,
3043 IHTMLStyle4_tid,
3044 IHTMLStyle5_tid,
3045 IHTMLStyle6_tid,
3048 static dispex_static_data_t HTMLStyle_dispex = {
3049 &HTMLStyle_dispex_vtbl,
3050 DispHTMLStyle_tid,
3051 NULL,
3052 HTMLStyle_iface_tids
3055 HRESULT HTMLStyle_Create(HTMLElement *elem, nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
3057 HTMLStyle *style;
3059 style = heap_alloc_zero(sizeof(HTMLStyle));
3060 if(!style)
3061 return E_OUTOFMEMORY;
3063 style->IHTMLStyle_iface.lpVtbl = &HTMLStyleVtbl;
3064 style->ref = 1;
3065 style->nsstyle = nsstyle;
3066 style->elem = elem;
3067 HTMLStyle2_Init(style);
3068 HTMLStyle3_Init(style);
3070 nsIDOMCSSStyleDeclaration_AddRef(nsstyle);
3072 init_dispex(&style->dispex, (IUnknown*)&style->IHTMLStyle_iface, &HTMLStyle_dispex);
3074 *ret = style;
3075 return S_OK;