[MSHTML]
[reactos.git] / reactos / dll / win32 / mshtml / htmlstyle.c
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #include <stdarg.h>
20 #include <math.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28 #include "mshtmdid.h"
29
30 #include "mshtml_private.h"
31 #include "htmlstyle.h"
32
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37
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 attrBackgroundPositionX[] =
45 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','x',0};
46 static const WCHAR attrBackgroundPositionY[] =
47 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','y',0};
48 static const WCHAR attrBackgroundRepeat[] =
49 {'b','a','c','k','g','r','o','u','n','d','-','r','e','p','e','a','t',0};
50 static const WCHAR attrBorder[] =
51 {'b','o','r','d','e','r',0};
52 static const WCHAR attrBorderBottom[] =
53 {'b','o','r','d','e','r','-','b','o','t','t','o','m',0};
54 static const WCHAR attrBorderBottomColor[] =
55 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','c','o','l','o','r',0};
56 static const WCHAR attrBorderBottomStyle[] =
57 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','s','t','y','l','e',0};
58 static const WCHAR attrBorderBottomWidth[] =
59 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','w','i','d','t','h',0};
60 static const WCHAR attrBorderColor[] =
61 {'b','o','r','d','e','r','-','c','o','l','o','r',0};
62 static const WCHAR attrBorderLeft[] =
63 {'b','o','r','d','e','r','-','l','e','f','t',0};
64 static const WCHAR attrBorderLeftColor[] =
65 {'b','o','r','d','e','r','-','l','e','f','t','-','c','o','l','o','r',0};
66 static const WCHAR attrBorderLeftStyle[] =
67 {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0};
68 static const WCHAR attrBorderLeftWidth[] =
69 {'b','o','r','d','e','r','-','l','e','f','t','-','w','i','d','t','h',0};
70 static const WCHAR attrBorderRight[] =
71 {'b','o','r','d','e','r','-','r','i','g','h','t',0};
72 static const WCHAR attrBorderRightColor[] =
73 {'b','o','r','d','e','r','-','r','i','g','h','t','-','c','o','l','o','r',0};
74 static const WCHAR attrBorderRightStyle[] =
75 {'b','o','r','d','e','r','-','r','i','g','h','t','-','s','t','y','l','e',0};
76 static const WCHAR attrBorderRightWidth[] =
77 {'b','o','r','d','e','r','-','r','i','g','h','t','-','w','i','d','t','h',0};
78 static const WCHAR attrBorderTop[] =
79 {'b','o','r','d','e','r','-','t','o','p',0};
80 static const WCHAR attrBorderTopColor[] =
81 {'b','o','r','d','e','r','-','t','o','p','-','c','o','l','o','r',0};
82 static const WCHAR attrBorderStyle[] =
83 {'b','o','r','d','e','r','-','s','t','y','l','e',0};
84 static const WCHAR attrBorderTopStyle[] =
85 {'b','o','r','d','e','r','-','t','o','p','-','s','t','y','l','e',0};
86 static const WCHAR attrBorderTopWidth[] =
87 {'b','o','r','d','e','r','-','t','o','p','-','w','i','d','t','h',0};
88 static const WCHAR attrBorderWidth[] =
89 {'b','o','r','d','e','r','-','w','i','d','t','h',0};
90 static const WCHAR attrBottom[] =
91 {'b','o','t','t','o','m',0};
92 static const WCHAR attrColor[] =
93 {'c','o','l','o','r',0};
94 static const WCHAR attrCursor[] =
95 {'c','u','r','s','o','r',0};
96 static const WCHAR attrDisplay[] =
97 {'d','i','s','p','l','a','y',0};
98 static const WCHAR attrFilter[] =
99 {'f','i','l','e','t','e','r',0};
100 static const WCHAR attrFontFamily[] =
101 {'f','o','n','t','-','f','a','m','i','l','y',0};
102 static const WCHAR attrFontSize[] =
103 {'f','o','n','t','-','s','i','z','e',0};
104 static const WCHAR attrFontStyle[] =
105 {'f','o','n','t','-','s','t','y','l','e',0};
106 static const WCHAR attrFontVariant[] =
107 {'f','o','n','t','-','v','a','r','i','a','n','t',0};
108 static const WCHAR attrFontWeight[] =
109 {'f','o','n','t','-','w','e','i','g','h','t',0};
110 static const WCHAR attrHeight[] =
111 {'h','e','i','g','h','t',0};
112 static const WCHAR attrLeft[] =
113 {'l','e','f','t',0};
114 static const WCHAR attrLetterSpacing[] =
115 {'l','e','t','t','e','r','-','s','p','a','c','i','n','g',0};
116 static const WCHAR attrLineHeight[] =
117 {'l','i','n','e','-','h','e','i','g','h','t',0};
118 static const WCHAR attrMargin[] =
119 {'m','a','r','g','i','n',0};
120 static const WCHAR attrMarginBottom[] =
121 {'m','a','r','g','i','n','-','b','o','t','t','o','m',0};
122 static const WCHAR attrMarginLeft[] =
123 {'m','a','r','g','i','n','-','l','e','f','t',0};
124 static const WCHAR attrMarginRight[] =
125 {'m','a','r','g','i','n','-','r','i','g','h','t',0};
126 static const WCHAR attrMarginTop[] =
127 {'m','a','r','g','i','n','-','t','o','p',0};
128 static const WCHAR attrMinHeight[] =
129 {'m','i','n','-','h','e','i','g','h','t',0};
130 static const WCHAR attrOverflow[] =
131 {'o','v','e','r','f','l','o','w',0};
132 static const WCHAR attrPaddingBottom[] =
133 {'p','a','d','d','i','n','g','-','b','o','t','t','o','m',0};
134 static const WCHAR attrPaddingLeft[] =
135 {'p','a','d','d','i','n','g','-','l','e','f','t',0};
136 static const WCHAR attrPaddingRight[] =
137 {'p','a','d','d','i','n','g','-','r','i','g','h','t',0};
138 static const WCHAR attrPaddingTop[] =
139 {'p','a','d','d','i','n','g','-','t','o','p',0};
140 static const WCHAR attrPosition[] =
141 {'p','o','s','i','t','i','o','n',0};
142 static const WCHAR attrRight[] =
143 {'r','i','g','h','t',0};
144 static const WCHAR attrTextAlign[] =
145 {'t','e','x','t','-','a','l','i','g','n',0};
146 static const WCHAR attrTextDecoration[] =
147 {'t','e','x','t','-','d','e','c','o','r','a','t','i','o','n',0};
148 static const WCHAR attrTextIndent[] =
149 {'t','e','x','t','-','i','n','d','e','n','t',0};
150 static const WCHAR attrTop[] =
151 {'t','o','p',0};
152 static const WCHAR attrVerticalAlign[] =
153 {'v','e','r','t','i','c','a','l','-','a','l','i','g','n',0};
154 static const WCHAR attrVisibility[] =
155 {'v','i','s','i','b','i','l','i','t','y',0};
156 static const WCHAR attrWidth[] =
157 {'w','i','d','t','h',0};
158 static const WCHAR attrWordSpacing[] =
159 {'w','o','r','d','-','s','p','a','c','i','n','g',0};
160 static const WCHAR attrWordWrap[] =
161 {'w','o','r','d','-','w','r','a','p',0};
162 static const WCHAR attrZIndex[] =
163 {'z','-','i','n','d','e','x',0};
164
165 static const struct{
166 const WCHAR *name;
167 DISPID dispid;
168 } style_tbl[] = {
169 {attrBackground, DISPID_IHTMLSTYLE_BACKGROUND},
170 {attrBackgroundColor, DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
171 {attrBackgroundImage, DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
172 {attrBackgroundPositionX, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONX},
173 {attrBackgroundPositionY, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
174 {attrBackgroundRepeat, DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
175 {attrBorder, DISPID_IHTMLSTYLE_BORDER},
176 {attrBorderBottom, DISPID_IHTMLSTYLE_BORDERBOTTOM},
177 {attrBorderBottomColor, DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR},
178 {attrBorderBottomStyle, DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
179 {attrBorderBottomWidth, DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
180 {attrBorderColor, DISPID_IHTMLSTYLE_BORDERCOLOR},
181 {attrBorderLeft, DISPID_IHTMLSTYLE_BORDERLEFT},
182 {attrBorderLeftColor, DISPID_IHTMLSTYLE_BORDERLEFTCOLOR},
183 {attrBorderLeftStyle, DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
184 {attrBorderLeftWidth, DISPID_IHTMLSTYLE_BORDERLEFTWIDTH},
185 {attrBorderRight, DISPID_IHTMLSTYLE_BORDERRIGHT},
186 {attrBorderRightColor, DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR},
187 {attrBorderRightStyle, DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
188 {attrBorderRightWidth, DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
189 {attrBorderStyle, DISPID_IHTMLSTYLE_BORDERSTYLE},
190 {attrBorderTop, DISPID_IHTMLSTYLE_BORDERTOP},
191 {attrBorderTopColor, DISPID_IHTMLSTYLE_BORDERTOPCOLOR},
192 {attrBorderTopStyle, DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
193 {attrBorderTopWidth, DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
194 {attrBorderWidth, DISPID_IHTMLSTYLE_BORDERWIDTH},
195 {attrBottom, DISPID_IHTMLSTYLE2_BOTTOM},
196 {attrColor, DISPID_IHTMLSTYLE_COLOR},
197 {attrCursor, DISPID_IHTMLSTYLE_CURSOR},
198 {attrDisplay, DISPID_IHTMLSTYLE_DISPLAY},
199 {attrFilter, DISPID_IHTMLSTYLE_FILTER},
200 {attrFontFamily, DISPID_IHTMLSTYLE_FONTFAMILY},
201 {attrFontSize, DISPID_IHTMLSTYLE_FONTSIZE},
202 {attrFontStyle, DISPID_IHTMLSTYLE_FONTSTYLE},
203 {attrFontVariant, DISPID_IHTMLSTYLE_FONTVARIANT},
204 {attrFontWeight, DISPID_IHTMLSTYLE_FONTWEIGHT},
205 {attrHeight, DISPID_IHTMLSTYLE_HEIGHT},
206 {attrLeft, DISPID_IHTMLSTYLE_LEFT},
207 {attrLetterSpacing, DISPID_IHTMLSTYLE_LETTERSPACING},
208 {attrLineHeight, DISPID_IHTMLSTYLE_LINEHEIGHT},
209 {attrMargin, DISPID_IHTMLSTYLE_MARGIN},
210 {attrMarginBottom, DISPID_IHTMLSTYLE_MARGINBOTTOM},
211 {attrMarginLeft, DISPID_IHTMLSTYLE_MARGINLEFT},
212 {attrMarginRight, DISPID_IHTMLSTYLE_MARGINRIGHT},
213 {attrMarginTop, DISPID_IHTMLSTYLE_MARGINTOP},
214 {attrMinHeight, DISPID_IHTMLSTYLE4_MINHEIGHT},
215 {attrOverflow, DISPID_IHTMLSTYLE_OVERFLOW},
216 {attrPaddingBottom, DISPID_IHTMLSTYLE_PADDINGBOTTOM},
217 {attrPaddingLeft, DISPID_IHTMLSTYLE_PADDINGLEFT},
218 {attrPaddingRight, DISPID_IHTMLSTYLE_PADDINGRIGHT},
219 {attrPaddingTop, DISPID_IHTMLSTYLE_PADDINGTOP},
220 {attrPosition, DISPID_IHTMLSTYLE2_POSITION},
221 {attrRight, DISPID_IHTMLSTYLE2_RIGHT},
222 {attrTextAlign, DISPID_IHTMLSTYLE_TEXTALIGN},
223 {attrTextDecoration, DISPID_IHTMLSTYLE_TEXTDECORATION},
224 {attrTextIndent, DISPID_IHTMLSTYLE_TEXTINDENT},
225 {attrTop, DISPID_IHTMLSTYLE_TOP},
226 {attrVerticalAlign, DISPID_IHTMLSTYLE_VERTICALALIGN},
227 {attrVisibility, DISPID_IHTMLSTYLE_VISIBILITY},
228 {attrWidth, DISPID_IHTMLSTYLE_WIDTH},
229 {attrWordSpacing, DISPID_IHTMLSTYLE_WORDSPACING},
230 {attrWordWrap, DISPID_IHTMLSTYLE3_WORDWRAP},
231 {attrZIndex, DISPID_IHTMLSTYLE_ZINDEX}
232 };
233
234 static const WCHAR valLineThrough[] =
235 {'l','i','n','e','-','t','h','r','o','u','g','h',0};
236 static const WCHAR valUnderline[] =
237 {'u','n','d','e','r','l','i','n','e',0};
238 static const WCHAR szNormal[] =
239 {'n','o','r','m','a','l',0};
240 static const WCHAR styleNone[] =
241 {'n','o','n','e',0};
242 static const WCHAR valOverline[] =
243 {'o','v','e','r','l','i','n','e',0};
244 static const WCHAR valBlink[] =
245 {'b','l','i','n','k',0};
246
247 static const WCHAR px_formatW[] = {'%','d','p','x',0};
248 static const WCHAR emptyW[] = {0};
249
250 static LPWSTR fix_px_value(LPCWSTR val)
251 {
252 LPCWSTR ptr = val;
253
254 while(*ptr) {
255 while(*ptr && isspaceW(*ptr))
256 ptr++;
257 if(!*ptr)
258 break;
259
260 while(*ptr && isdigitW(*ptr))
261 ptr++;
262
263 if(!*ptr || isspaceW(*ptr)) {
264 LPWSTR ret, p;
265 int len = strlenW(val)+1;
266
267 ret = heap_alloc((len+2)*sizeof(WCHAR));
268 memcpy(ret, val, (ptr-val)*sizeof(WCHAR));
269 p = ret + (ptr-val);
270 *p++ = 'p';
271 *p++ = 'x';
272 strcpyW(p, ptr);
273
274 TRACE("fixed %s -> %s\n", debugstr_w(val), debugstr_w(ret));
275
276 return ret;
277 }
278
279 while(*ptr && !isspaceW(*ptr))
280 ptr++;
281 }
282
283 return NULL;
284 }
285
286 static LPWSTR fix_url_value(LPCWSTR val)
287 {
288 WCHAR *ret, *ptr;
289
290 static const WCHAR urlW[] = {'u','r','l','('};
291
292 if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
293 return NULL;
294
295 ret = heap_strdupW(val);
296
297 for(ptr = ret; *ptr; ptr++) {
298 if(*ptr == '\\')
299 *ptr = '/';
300 }
301
302 return ret;
303 }
304
305 HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCWSTR value, DWORD flags)
306 {
307 nsAString str_name, str_value, str_empty;
308 LPWSTR val = NULL;
309 nsresult nsres;
310
311 static const PRUnichar wszEmpty[] = {0};
312
313 if(flags & ATTR_FIX_PX)
314 val = fix_px_value(value);
315 if(flags & ATTR_FIX_URL)
316 val = fix_url_value(value);
317
318 nsAString_Init(&str_name, style_tbl[sid].name);
319 nsAString_Init(&str_value, val ? val : value);
320 nsAString_Init(&str_empty, wszEmpty);
321 heap_free(val);
322
323 nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
324 if(NS_FAILED(nsres))
325 ERR("SetProperty failed: %08x\n", nsres);
326
327 nsAString_Finish(&str_name);
328 nsAString_Finish(&str_value);
329 nsAString_Finish(&str_empty);
330
331 return S_OK;
332 }
333
334 HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *value, DWORD flags)
335 {
336 switch(V_VT(value)) {
337 case VT_NULL:
338 return set_nsstyle_attr(nsstyle, sid, emptyW, flags);
339
340 case VT_BSTR:
341 return set_nsstyle_attr(nsstyle, sid, V_BSTR(value), flags);
342
343 case VT_BSTR|VT_BYREF:
344 return set_nsstyle_attr(nsstyle, sid, *V_BSTRREF(value), flags);
345
346 case VT_I4: {
347 WCHAR str[14];
348 static const WCHAR format[] = {'%','d',0};
349
350 wsprintfW(str, format, V_I4(value));
351 return set_nsstyle_attr(nsstyle, sid, str, flags);
352 }
353 default:
354 FIXME("not implemented vt %d\n", V_VT(value));
355 return E_NOTIMPL;
356
357 }
358
359 return S_OK;
360 }
361
362 static inline HRESULT set_style_attr(HTMLStyle *This, styleid_t sid, LPCWSTR value, DWORD flags)
363 {
364 return set_nsstyle_attr(This->nsstyle, sid, value, flags);
365 }
366
367 static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, nsAString *value)
368 {
369 nsAString str_name;
370 nsresult nsres;
371
372 nsAString_Init(&str_name, style_tbl[sid].name);
373
374 nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
375 if(NS_FAILED(nsres)) {
376 ERR("SetProperty failed: %08x\n", nsres);
377 return E_FAIL;
378 }
379
380 nsAString_Finish(&str_name);
381
382 return NS_OK;
383 }
384
385 HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR *p)
386 {
387 nsAString str_value;
388 const PRUnichar *value;
389
390 nsAString_Init(&str_value, NULL);
391
392 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
393
394 nsAString_GetData(&str_value, &value);
395 *p = *value ? SysAllocString(value) : NULL;
396
397 nsAString_Finish(&str_value);
398
399 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_w(*p));
400 return S_OK;
401 }
402
403 HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
404 {
405 nsAString str_value;
406 const PRUnichar *value;
407 BOOL set = FALSE;
408
409 nsAString_Init(&str_value, NULL);
410
411 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
412
413 nsAString_GetData(&str_value, &value);
414
415 if(flags & ATTR_STR_TO_INT) {
416 const PRUnichar *ptr = value;
417 BOOL neg = FALSE;
418 INT i = 0;
419
420 if(*ptr == '-') {
421 neg = TRUE;
422 ptr++;
423 }
424
425 while(isdigitW(*ptr))
426 i = i*10 + (*ptr++ - '0');
427
428 if(!*ptr) {
429 V_VT(p) = VT_I4;
430 V_I4(p) = neg ? -i : i;
431 set = TRUE;
432 }
433 }
434
435 if(!set) {
436 BSTR str = NULL;
437
438 if(*value) {
439 str = SysAllocString(value);
440 if(!str)
441 return E_OUTOFMEMORY;
442 }
443
444 V_VT(p) = VT_BSTR;
445 V_BSTR(p) = str;
446 }
447
448 nsAString_Finish(&str_value);
449
450 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_variant(p));
451 return S_OK;
452 }
453
454 static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
455 {
456 return get_nsstyle_attr(This->nsstyle, sid, p);
457 }
458
459 static HRESULT check_style_attr_value(HTMLStyle *This, styleid_t sid, LPCWSTR exval, VARIANT_BOOL *p)
460 {
461 nsAString str_value;
462 const PRUnichar *value;
463
464 nsAString_Init(&str_value, NULL);
465
466 get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
467
468 nsAString_GetData(&str_value, &value);
469 *p = strcmpW(value, exval) ? VARIANT_FALSE : VARIANT_TRUE;
470 nsAString_Finish(&str_value);
471
472 TRACE("%s -> %x\n", debugstr_w(style_tbl[sid].name), *p);
473 return S_OK;
474 }
475
476 static inline HRESULT set_style_pos(HTMLStyle *This, styleid_t sid, float value)
477 {
478 WCHAR szValue[25];
479 WCHAR szFormat[] = {'%','.','0','f','p','x',0};
480
481 value = floor(value);
482
483 sprintfW(szValue, szFormat, value);
484
485 return set_style_attr(This, sid, szValue, 0);
486 }
487
488 static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p)
489 {
490 nsAString str_value;
491 HRESULT hres;
492 WCHAR pxW[] = {'p','x',0};
493
494 TRACE("%p %d %p\n", This, sid, p);
495
496 *p = 0.0f;
497
498 nsAString_Init(&str_value, NULL);
499
500 hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
501 if(hres == S_OK)
502 {
503 WCHAR *ptr;
504 const PRUnichar *value;
505
506 nsAString_GetData(&str_value, &value);
507 if(value)
508 {
509 *p = strtolW(value, &ptr, 10);
510
511 if(*ptr && strcmpW(ptr, pxW))
512 {
513 nsAString_Finish(&str_value);
514 FIXME("only px values are currently supported\n");
515 return E_FAIL;
516 }
517 }
518 }
519
520 TRACE("ret %f\n", *p);
521
522 nsAString_Finish(&str_value);
523
524 return hres;
525 }
526
527 static BOOL is_valid_border_style(BSTR v)
528 {
529 static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0};
530 static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0};
531 static const WCHAR styleSolid[] = {'s','o','l','i','d',0};
532 static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0};
533 static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0};
534 static const WCHAR styleRidge[] = {'r','i','d','g','e',0};
535 static const WCHAR styleInset[] = {'i','n','s','e','t',0};
536 static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0};
537
538 TRACE("%s\n", debugstr_w(v));
539
540 if(!v || strcmpiW(v, styleNone) == 0 || strcmpiW(v, styleDotted) == 0 ||
541 strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid) == 0 ||
542 strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 ||
543 strcmpiW(v, styleRidge) == 0 || strcmpiW(v, styleInset) == 0 ||
544 strcmpiW(v, styleOutset) == 0 )
545 {
546 return TRUE;
547 }
548
549 return FALSE;
550 }
551
552 #define HTMLSTYLE_THIS(iface) DEFINE_THIS(HTMLStyle, HTMLStyle, iface)
553
554 static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv)
555 {
556 HTMLStyle *This = HTMLSTYLE_THIS(iface);
557
558 *ppv = NULL;
559
560 if(IsEqualGUID(&IID_IUnknown, riid)) {
561 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
562 *ppv = HTMLSTYLE(This);
563 }else if(IsEqualGUID(&IID_IHTMLStyle, riid)) {
564 TRACE("(%p)->(IID_IHTMLStyle %p)\n", This, ppv);
565 *ppv = HTMLSTYLE(This);
566 }else if(IsEqualGUID(&IID_IHTMLStyle2, riid)) {
567 TRACE("(%p)->(IID_IHTMLStyle2 %p)\n", This, ppv);
568 *ppv = HTMLSTYLE2(This);
569 }else if(IsEqualGUID(&IID_IHTMLStyle3, riid)) {
570 TRACE("(%p)->(IID_IHTMLStyle3 %p)\n", This, ppv);
571 *ppv = HTMLSTYLE3(This);
572 }else if(IsEqualGUID(&IID_IHTMLStyle4, riid)) {
573 TRACE("(%p)->(IID_IHTMLStyle4 %p)\n", This, ppv);
574 *ppv = HTMLSTYLE4(This);
575 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
576 return *ppv ? S_OK : E_NOINTERFACE;
577 }
578
579 if(*ppv) {
580 IUnknown_AddRef((IUnknown*)*ppv);
581 return S_OK;
582 }
583
584 WARN("unsupported %s\n", debugstr_guid(riid));
585 return E_NOINTERFACE;
586 }
587
588 static ULONG WINAPI HTMLStyle_AddRef(IHTMLStyle *iface)
589 {
590 HTMLStyle *This = HTMLSTYLE_THIS(iface);
591 LONG ref = InterlockedIncrement(&This->ref);
592
593 TRACE("(%p) ref=%d\n", This, ref);
594
595 return ref;
596 }
597
598 static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
599 {
600 HTMLStyle *This = HTMLSTYLE_THIS(iface);
601 LONG ref = InterlockedDecrement(&This->ref);
602
603 TRACE("(%p) ref=%d\n", This, ref);
604
605 if(!ref) {
606 if(This->nsstyle)
607 nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
608 release_dispex(&This->dispex);
609 heap_free(This);
610 }
611
612 return ref;
613 }
614
615 static HRESULT WINAPI HTMLStyle_GetTypeInfoCount(IHTMLStyle *iface, UINT *pctinfo)
616 {
617 HTMLStyle *This = HTMLSTYLE_THIS(iface);
618 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
619 }
620
621 static HRESULT WINAPI HTMLStyle_GetTypeInfo(IHTMLStyle *iface, UINT iTInfo,
622 LCID lcid, ITypeInfo **ppTInfo)
623 {
624 HTMLStyle *This = HTMLSTYLE_THIS(iface);
625 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
626 }
627
628 static HRESULT WINAPI HTMLStyle_GetIDsOfNames(IHTMLStyle *iface, REFIID riid,
629 LPOLESTR *rgszNames, UINT cNames,
630 LCID lcid, DISPID *rgDispId)
631 {
632 HTMLStyle *This = HTMLSTYLE_THIS(iface);
633 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
634 }
635
636 static HRESULT WINAPI HTMLStyle_Invoke(IHTMLStyle *iface, DISPID dispIdMember,
637 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
638 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
639 {
640 HTMLStyle *This = HTMLSTYLE_THIS(iface);
641 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid,
642 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
643 }
644
645 static HRESULT WINAPI HTMLStyle_put_fontFamily(IHTMLStyle *iface, BSTR v)
646 {
647 HTMLStyle *This = HTMLSTYLE_THIS(iface);
648
649 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
650
651 return set_style_attr(This, STYLEID_FONT_FAMILY, v, 0);
652 }
653
654 static HRESULT WINAPI HTMLStyle_get_fontFamily(IHTMLStyle *iface, BSTR *p)
655 {
656 HTMLStyle *This = HTMLSTYLE_THIS(iface);
657
658 TRACE("(%p)->(%p)\n", This, p);
659
660 return get_style_attr(This, STYLEID_FONT_FAMILY, p);
661 }
662
663 static HRESULT WINAPI HTMLStyle_put_fontStyle(IHTMLStyle *iface, BSTR v)
664 {
665 HTMLStyle *This = HTMLSTYLE_THIS(iface);
666 static const WCHAR szItalic[] = {'i','t','a','l','i','c',0};
667 static const WCHAR szOblique[] = {'o','b','l','i','q','u','e',0};
668
669 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
670
671 /* fontStyle can only be one of the follow values. */
672 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szItalic, v) == 0 ||
673 strcmpiW(szOblique, v) == 0)
674 {
675 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, v, 0);
676 }
677
678 return E_INVALIDARG;
679 }
680
681 static HRESULT WINAPI HTMLStyle_get_fontStyle(IHTMLStyle *iface, BSTR *p)
682 {
683 HTMLStyle *This = HTMLSTYLE_THIS(iface);
684
685 TRACE("(%p)->(%p)\n", This, p);
686
687 return get_style_attr(This, STYLEID_FONT_STYLE, p);
688 }
689
690 static HRESULT WINAPI HTMLStyle_put_fontVariant(IHTMLStyle *iface, BSTR v)
691 {
692 HTMLStyle *This = HTMLSTYLE_THIS(iface);
693 static const WCHAR szCaps[] = {'s','m','a','l','l','-','c','a','p','s',0};
694
695 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
696
697 /* fontVariant can only be one of the follow values. */
698 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szCaps, v) == 0)
699 {
700 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, v, 0);
701 }
702
703 return E_INVALIDARG;
704 }
705
706 static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p)
707 {
708 HTMLStyle *This = HTMLSTYLE_THIS(iface);
709 TRACE("(%p)->(%p)\n", This, p);
710
711 if(!p)
712 return E_INVALIDARG;
713
714 return get_style_attr(This, STYLEID_FONT_VARIANT, p);
715 }
716
717 static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v)
718 {
719 HTMLStyle *This = HTMLSTYLE_THIS(iface);
720 static const WCHAR styleBold[] = {'b','o','l','d',0};
721 static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0};
722 static const WCHAR styleLighter[] = {'l','i','g','h','t','e','r',0};
723 static const WCHAR style100[] = {'1','0','0',0};
724 static const WCHAR style200[] = {'2','0','0',0};
725 static const WCHAR style300[] = {'3','0','0',0};
726 static const WCHAR style400[] = {'4','0','0',0};
727 static const WCHAR style500[] = {'5','0','0',0};
728 static const WCHAR style600[] = {'6','0','0',0};
729 static const WCHAR style700[] = {'7','0','0',0};
730 static const WCHAR style800[] = {'8','0','0',0};
731 static const WCHAR style900[] = {'9','0','0',0};
732
733 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
734
735 /* fontWeight can only be one of the following */
736 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(styleBold, v) == 0 ||
737 strcmpiW(styleBolder, v) == 0 || strcmpiW(styleLighter, v) == 0 ||
738 strcmpiW(style100, v) == 0 || strcmpiW(style200, v) == 0 ||
739 strcmpiW(style300, v) == 0 || strcmpiW(style400, v) == 0 ||
740 strcmpiW(style500, v) == 0 || strcmpiW(style600, v) == 0 ||
741 strcmpiW(style700, v) == 0 || strcmpiW(style800, v) == 0 ||
742 strcmpiW(style900, v) == 0
743 )
744 {
745 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0);
746 }
747
748 return E_INVALIDARG;
749 }
750
751 static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p)
752 {
753 HTMLStyle *This = HTMLSTYLE_THIS(iface);
754
755 TRACE("(%p)->(%p)\n", This, p);
756
757 return get_style_attr(This, STYLEID_FONT_WEIGHT, p);
758 }
759
760 static HRESULT WINAPI HTMLStyle_put_fontSize(IHTMLStyle *iface, VARIANT v)
761 {
762 HTMLStyle *This = HTMLSTYLE_THIS(iface);
763
764 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
765
766 switch(V_VT(&v)) {
767 case VT_BSTR:
768 return set_style_attr(This, STYLEID_FONT_SIZE, V_BSTR(&v), 0);
769 default:
770 FIXME("not supported vt %d\n", V_VT(&v));
771 }
772
773 return S_OK;
774 }
775
776 static HRESULT WINAPI HTMLStyle_get_fontSize(IHTMLStyle *iface, VARIANT *p)
777 {
778 HTMLStyle *This = HTMLSTYLE_THIS(iface);
779
780 TRACE("(%p)->(%p)\n", This, p);
781
782 V_VT(p) = VT_BSTR;
783 return get_style_attr(This, STYLEID_FONT_SIZE, &V_BSTR(p));
784 }
785
786 static HRESULT WINAPI HTMLStyle_put_font(IHTMLStyle *iface, BSTR v)
787 {
788 HTMLStyle *This = HTMLSTYLE_THIS(iface);
789 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
790 return E_NOTIMPL;
791 }
792
793 static HRESULT WINAPI HTMLStyle_get_font(IHTMLStyle *iface, BSTR *p)
794 {
795 HTMLStyle *This = HTMLSTYLE_THIS(iface);
796 FIXME("(%p)->(%p)\n", This, p);
797 return E_NOTIMPL;
798 }
799
800 static HRESULT WINAPI HTMLStyle_put_color(IHTMLStyle *iface, VARIANT v)
801 {
802 HTMLStyle *This = HTMLSTYLE_THIS(iface);
803
804 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
805
806 switch(V_VT(&v)) {
807 case VT_BSTR:
808 TRACE("%s\n", debugstr_w(V_BSTR(&v)));
809 return set_style_attr(This, STYLEID_COLOR, V_BSTR(&v), 0);
810
811 default:
812 FIXME("unsupported vt=%d\n", V_VT(&v));
813 }
814
815 return E_NOTIMPL;
816 }
817
818 static HRESULT WINAPI HTMLStyle_get_color(IHTMLStyle *iface, VARIANT *p)
819 {
820 HTMLStyle *This = HTMLSTYLE_THIS(iface);
821
822 TRACE("(%p)->(%p)\n", This, p);
823
824 V_VT(p) = VT_BSTR;
825 return get_style_attr(This, STYLEID_COLOR, &V_BSTR(p));
826 }
827
828 static HRESULT WINAPI HTMLStyle_put_background(IHTMLStyle *iface, BSTR v)
829 {
830 HTMLStyle *This = HTMLSTYLE_THIS(iface);
831
832 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
833
834 return set_style_attr(This, STYLEID_BACKGROUND, v, 0);
835 }
836
837 static HRESULT WINAPI HTMLStyle_get_background(IHTMLStyle *iface, BSTR *p)
838 {
839 HTMLStyle *This = HTMLSTYLE_THIS(iface);
840
841 TRACE("(%p)->(%p)\n", This, p);
842
843 return get_style_attr(This, STYLEID_BACKGROUND, p);
844 }
845
846 static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v)
847 {
848 HTMLStyle *This = HTMLSTYLE_THIS(iface);
849
850 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
851
852 switch(V_VT(&v)) {
853 case VT_BSTR:
854 return set_style_attr(This, STYLEID_BACKGROUND_COLOR, V_BSTR(&v), 0);
855 case VT_I4: {
856 WCHAR value[10];
857 static const WCHAR format[] = {'#','%','0','6','x',0};
858
859 wsprintfW(value, format, V_I4(&v));
860 return set_style_attr(This, STYLEID_BACKGROUND_COLOR, value, 0);
861 }
862 default:
863 FIXME("unsupported vt %d\n", V_VT(&v));
864 }
865
866 return S_OK;
867 }
868
869 static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
870 {
871 HTMLStyle *This = HTMLSTYLE_THIS(iface);
872 TRACE("(%p)->(%p)\n", This, p);
873
874 V_VT(p) = VT_BSTR;
875 return get_style_attr(This, STYLEID_BACKGROUND_COLOR, &V_BSTR(p));
876 }
877
878 static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
879 {
880 HTMLStyle *This = HTMLSTYLE_THIS(iface);
881
882 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
883
884 return set_style_attr(This, STYLEID_BACKGROUND_IMAGE, v, ATTR_FIX_URL);
885 }
886
887 static HRESULT WINAPI HTMLStyle_get_backgroundImage(IHTMLStyle *iface, BSTR *p)
888 {
889 HTMLStyle *This = HTMLSTYLE_THIS(iface);
890
891 TRACE("(%p)->(%p)\n", This, p);
892
893 return get_style_attr(This, STYLEID_BACKGROUND_IMAGE, p);
894 }
895
896 static HRESULT WINAPI HTMLStyle_put_backgroundRepeat(IHTMLStyle *iface, BSTR v)
897 {
898 HTMLStyle *This = HTMLSTYLE_THIS(iface);
899 static const WCHAR styleRepeat[] = {'r','e','p','e','a','t',0};
900 static const WCHAR styleNoRepeat[] = {'n','o','-','r','e','p','e','a','t',0};
901 static const WCHAR styleRepeatX[] = {'r','e','p','e','a','t','-','x',0};
902 static const WCHAR styleRepeatY[] = {'r','e','p','e','a','t','-','y',0};
903
904 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
905
906 /* fontWeight can only be one of the following */
907 if(!v || strcmpiW(styleRepeat, v) == 0 || strcmpiW(styleNoRepeat, v) == 0 ||
908 strcmpiW(styleRepeatX, v) == 0 || strcmpiW(styleRepeatY, v) == 0 )
909 {
910 return set_style_attr(This, STYLEID_BACKGROUND_REPEAT , v, 0);
911 }
912
913 return E_INVALIDARG;
914 }
915
916 static HRESULT WINAPI HTMLStyle_get_backgroundRepeat(IHTMLStyle *iface, BSTR *p)
917 {
918 HTMLStyle *This = HTMLSTYLE_THIS(iface);
919
920 TRACE("(%p)->(%p)\n", This, p);
921
922 return get_style_attr(This, STYLEID_BACKGROUND_REPEAT, p);
923 }
924
925 static HRESULT WINAPI HTMLStyle_put_backgroundAttachment(IHTMLStyle *iface, BSTR v)
926 {
927 HTMLStyle *This = HTMLSTYLE_THIS(iface);
928 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
929 return E_NOTIMPL;
930 }
931
932 static HRESULT WINAPI HTMLStyle_get_backgroundAttachment(IHTMLStyle *iface, BSTR *p)
933 {
934 HTMLStyle *This = HTMLSTYLE_THIS(iface);
935 FIXME("(%p)->(%p)\n", This, p);
936 return E_NOTIMPL;
937 }
938
939 static HRESULT WINAPI HTMLStyle_put_backgroundPosition(IHTMLStyle *iface, BSTR v)
940 {
941 HTMLStyle *This = HTMLSTYLE_THIS(iface);
942 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
943 return E_NOTIMPL;
944 }
945
946 static HRESULT WINAPI HTMLStyle_get_backgroundPosition(IHTMLStyle *iface, BSTR *p)
947 {
948 HTMLStyle *This = HTMLSTYLE_THIS(iface);
949 FIXME("(%p)->(%p)\n", This, p);
950 return E_NOTIMPL;
951 }
952
953 static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIANT v)
954 {
955 HTMLStyle *This = HTMLSTYLE_THIS(iface);
956 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
957 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_POSITION_X, &v, 0);
958 }
959
960 static HRESULT WINAPI HTMLStyle_get_backgroundPositionX(IHTMLStyle *iface, VARIANT *p)
961 {
962 HTMLStyle *This = HTMLSTYLE_THIS(iface);
963 TRACE("(%p)->(%p)\n", This, p);
964 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_POSITION_X, p, 0);
965 }
966
967 static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIANT v)
968 {
969 HTMLStyle *This = HTMLSTYLE_THIS(iface);
970 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
971 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_POSITION_Y, &v, 0);
972 }
973
974 static HRESULT WINAPI HTMLStyle_get_backgroundPositionY(IHTMLStyle *iface, VARIANT *p)
975 {
976 HTMLStyle *This = HTMLSTYLE_THIS(iface);
977 TRACE("(%p)->(%p)\n", This, p);
978 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_POSITION_Y, p, 0);
979 }
980
981 static HRESULT WINAPI HTMLStyle_put_wordSpacing(IHTMLStyle *iface, VARIANT v)
982 {
983 HTMLStyle *This = HTMLSTYLE_THIS(iface);
984 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
985 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, &v, 0);
986 }
987
988 static HRESULT WINAPI HTMLStyle_get_wordSpacing(IHTMLStyle *iface, VARIANT *p)
989 {
990 HTMLStyle *This = HTMLSTYLE_THIS(iface);
991 TRACE("(%p)->(%p)\n", This, p);
992 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, p, 0);
993 }
994
995 static HRESULT WINAPI HTMLStyle_put_letterSpacing(IHTMLStyle *iface, VARIANT v)
996 {
997 HTMLStyle *This = HTMLSTYLE_THIS(iface);
998 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
999 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, &v, 0);
1000 }
1001
1002 static HRESULT WINAPI HTMLStyle_get_letterSpacing(IHTMLStyle *iface, VARIANT *p)
1003 {
1004 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1005 TRACE("(%p)->(%p)\n", This, p);
1006 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, p, 0);
1007 }
1008
1009 static HRESULT WINAPI HTMLStyle_put_textDecoration(IHTMLStyle *iface, BSTR v)
1010 {
1011 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1012
1013 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1014
1015 /* textDecoration can only be one of the following */
1016 if(!v || strcmpiW(styleNone, v) == 0 || strcmpiW(valUnderline, v) == 0 ||
1017 strcmpiW(valOverline, v) == 0 || strcmpiW(valLineThrough, v) == 0 ||
1018 strcmpiW(valBlink, v) == 0)
1019 {
1020 return set_style_attr(This, STYLEID_TEXT_DECORATION , v, 0);
1021 }
1022
1023 return E_INVALIDARG;
1024 }
1025
1026 static HRESULT WINAPI HTMLStyle_get_textDecoration(IHTMLStyle *iface, BSTR *p)
1027 {
1028 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1029
1030 TRACE("(%p)->(%p)\n", This, p);
1031
1032 return get_style_attr(This, STYLEID_TEXT_DECORATION, p);
1033 }
1034
1035 static HRESULT WINAPI HTMLStyle_put_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL v)
1036 {
1037 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1038
1039 TRACE("(%p)->(%x)\n", This, v);
1040
1041 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? styleNone : emptyW, 0);
1042 }
1043
1044 static HRESULT WINAPI HTMLStyle_get_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL *p)
1045 {
1046 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1047
1048 TRACE("(%p)->(%p)\n", This, p);
1049
1050 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, styleNone, p);
1051 }
1052
1053 static HRESULT WINAPI HTMLStyle_put_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL v)
1054 {
1055 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1056
1057 TRACE("(%p)->(%x)\n", This, v);
1058
1059 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valUnderline : emptyW, 0);
1060 }
1061
1062 static HRESULT WINAPI HTMLStyle_get_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL *p)
1063 {
1064 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1065
1066 TRACE("(%p)->(%p)\n", This, p);
1067
1068 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valUnderline, p);
1069 }
1070
1071 static HRESULT WINAPI HTMLStyle_put_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL v)
1072 {
1073 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1074
1075 TRACE("(%p)->(%x)\n", This, v);
1076
1077 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valOverline : emptyW, 0);
1078 }
1079
1080 static HRESULT WINAPI HTMLStyle_get_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL *p)
1081 {
1082 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1083
1084 TRACE("(%p)->(%p)\n", This, p);
1085
1086 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valOverline, p);
1087 }
1088
1089 static HRESULT WINAPI HTMLStyle_put_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL v)
1090 {
1091 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1092
1093 TRACE("(%p)->(%x)\n", This, v);
1094
1095 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valLineThrough : emptyW, 0);
1096 }
1097
1098 static HRESULT WINAPI HTMLStyle_get_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL *p)
1099 {
1100 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1101
1102 TRACE("(%p)->(%p)\n", This, p);
1103
1104 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valLineThrough, p);
1105 }
1106
1107 static HRESULT WINAPI HTMLStyle_put_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL v)
1108 {
1109 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1110
1111 TRACE("(%p)->(%x)\n", This, v);
1112
1113 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valBlink : emptyW, 0);
1114 }
1115
1116 static HRESULT WINAPI HTMLStyle_get_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL *p)
1117 {
1118 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1119
1120 TRACE("(%p)->(%p)\n", This, p);
1121
1122 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valBlink, p);
1123 }
1124
1125 static HRESULT WINAPI HTMLStyle_put_verticalAlign(IHTMLStyle *iface, VARIANT v)
1126 {
1127 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1128
1129 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1130
1131 switch(V_VT(&v)) {
1132 case VT_BSTR:
1133 return set_style_attr(This, STYLEID_VERTICAL_ALIGN, V_BSTR(&v), 0);
1134 default:
1135 FIXME("not implemented vt %d\n", V_VT(&v));
1136 return E_NOTIMPL;
1137 }
1138
1139 return S_OK;
1140 }
1141
1142 static HRESULT WINAPI HTMLStyle_get_verticalAlign(IHTMLStyle *iface, VARIANT *p)
1143 {
1144 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1145 BSTR ret;
1146 HRESULT hres;
1147
1148 TRACE("(%p)->(%p)\n", This, p);
1149
1150 hres = get_style_attr(This, STYLEID_VERTICAL_ALIGN, &ret);
1151 if(FAILED(hres))
1152 return hres;
1153
1154 V_VT(p) = VT_BSTR;
1155 V_BSTR(p) = ret;
1156 return S_OK;
1157 }
1158
1159 static HRESULT WINAPI HTMLStyle_put_textTransform(IHTMLStyle *iface, BSTR v)
1160 {
1161 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1162 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1163 return E_NOTIMPL;
1164 }
1165
1166 static HRESULT WINAPI HTMLStyle_get_textTransform(IHTMLStyle *iface, BSTR *p)
1167 {
1168 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1169 FIXME("(%p)->(%p)\n", This, p);
1170 return E_NOTIMPL;
1171 }
1172
1173 static HRESULT WINAPI HTMLStyle_put_textAlign(IHTMLStyle *iface, BSTR v)
1174 {
1175 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1176
1177 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1178
1179 return set_style_attr(This, STYLEID_TEXT_ALIGN, v, 0);
1180 }
1181
1182 static HRESULT WINAPI HTMLStyle_get_textAlign(IHTMLStyle *iface, BSTR *p)
1183 {
1184 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1185
1186 TRACE("(%p)->(%p)\n", This, p);
1187
1188 return get_style_attr(This, STYLEID_TEXT_ALIGN, p);
1189 }
1190
1191 static HRESULT WINAPI HTMLStyle_put_textIndent(IHTMLStyle *iface, VARIANT v)
1192 {
1193 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1194 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1195 return E_NOTIMPL;
1196 }
1197
1198 static HRESULT WINAPI HTMLStyle_get_textIndent(IHTMLStyle *iface, VARIANT *p)
1199 {
1200 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1201 FIXME("(%p)->(%p)\n", This, p);
1202 return E_NOTIMPL;
1203 }
1204
1205 static HRESULT WINAPI HTMLStyle_put_lineHeight(IHTMLStyle *iface, VARIANT v)
1206 {
1207 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1208 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1209 return E_NOTIMPL;
1210 }
1211
1212 static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
1213 {
1214 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1215 FIXME("(%p)->(%p)\n", This, p);
1216 return E_NOTIMPL;
1217 }
1218
1219 static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
1220 {
1221 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1222
1223 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1224
1225 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, &v, 0);
1226 }
1227
1228 static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
1229 {
1230 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1231
1232 TRACE("(%p)->(%p)\n", This, p);
1233
1234 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
1235 }
1236
1237 static HRESULT WINAPI HTMLStyle_put_marginRight(IHTMLStyle *iface, VARIANT v)
1238 {
1239 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1240
1241 TRACE("(%p)->(v(%d))\n", This, V_VT(&v));
1242
1243 switch(V_VT(&v)) {
1244 case VT_NULL:
1245 return set_style_attr(This, STYLEID_MARGIN_RIGHT, emptyW, 0);
1246 case VT_I4: {
1247 WCHAR buf[14];
1248
1249 wsprintfW(buf, px_formatW, V_I4(&v));
1250 return set_style_attr(This, STYLEID_MARGIN_RIGHT, buf, 0);
1251 }
1252 case VT_BSTR:
1253 return set_style_attr(This, STYLEID_MARGIN_RIGHT, V_BSTR(&v), 0);
1254 default:
1255 FIXME("Unsupported vt=%d\n", V_VT(&v));
1256 }
1257
1258 return E_NOTIMPL;
1259 }
1260
1261 static HRESULT WINAPI HTMLStyle_get_marginRight(IHTMLStyle *iface, VARIANT *p)
1262 {
1263 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1264 TRACE("(%p)->(%p)\n", This, p);
1265 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
1266 }
1267
1268 static HRESULT WINAPI HTMLStyle_put_marginBottom(IHTMLStyle *iface, VARIANT v)
1269 {
1270 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1271 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1272 return E_NOTIMPL;
1273 }
1274
1275 static HRESULT WINAPI HTMLStyle_get_marginBottom(IHTMLStyle *iface, VARIANT *p)
1276 {
1277 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1278 FIXME("(%p)->(%p)\n", This, p);
1279 return E_NOTIMPL;
1280 }
1281
1282 static HRESULT WINAPI HTMLStyle_put_marginLeft(IHTMLStyle *iface, VARIANT v)
1283 {
1284 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1285
1286 switch(V_VT(&v)) {
1287 case VT_NULL:
1288 TRACE("(%p)->(NULL)\n", This);
1289 return set_style_attr(This, STYLEID_MARGIN_LEFT, emptyW, 0);
1290 case VT_I4: {
1291 WCHAR buf[14];
1292
1293 TRACE("(%p)->(%d)\n", This, V_I4(&v));
1294
1295 wsprintfW(buf, px_formatW, V_I4(&v));
1296 return set_style_attr(This, STYLEID_MARGIN_LEFT, buf, 0);
1297 }
1298 case VT_BSTR:
1299 TRACE("(%p)->(%s)\n", This, debugstr_w(V_BSTR(&v)));
1300 return set_style_attr(This, STYLEID_MARGIN_LEFT, V_BSTR(&v), 0);
1301 default:
1302 FIXME("Unsupported vt=%d\n", V_VT(&v));
1303 }
1304
1305 return E_NOTIMPL;
1306 }
1307
1308 static HRESULT WINAPI HTMLStyle_put_margin(IHTMLStyle *iface, BSTR v)
1309 {
1310 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1311
1312 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1313
1314 return set_style_attr(This, STYLEID_MARGIN, v, 0);
1315 }
1316
1317 static HRESULT WINAPI HTMLStyle_get_margin(IHTMLStyle *iface, BSTR *p)
1318 {
1319 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1320
1321 TRACE("(%p)->(%p)\n", This, p);
1322
1323 return get_style_attr(This, STYLEID_MARGIN, p);
1324 }
1325
1326 static HRESULT WINAPI HTMLStyle_get_marginLeft(IHTMLStyle *iface, VARIANT *p)
1327 {
1328 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1329 TRACE("(%p)->(%p)\n", This, p);
1330 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
1331 }
1332
1333 static HRESULT WINAPI HTMLStyle_put_paddingTop(IHTMLStyle *iface, VARIANT v)
1334 {
1335 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1336 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1337 return E_NOTIMPL;
1338 }
1339
1340 static HRESULT WINAPI HTMLStyle_get_paddingTop(IHTMLStyle *iface, VARIANT *p)
1341 {
1342 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1343 FIXME("(%p)->(%p)\n", This, p);
1344 return E_NOTIMPL;
1345 }
1346
1347 static HRESULT WINAPI HTMLStyle_put_paddingRight(IHTMLStyle *iface, VARIANT v)
1348 {
1349 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1350 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1351 return E_NOTIMPL;
1352 }
1353
1354 static HRESULT WINAPI HTMLStyle_get_paddingRight(IHTMLStyle *iface, VARIANT *p)
1355 {
1356 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1357 FIXME("(%p)->(%p)\n", This, p);
1358 return E_NOTIMPL;
1359 }
1360
1361 static HRESULT WINAPI HTMLStyle_put_paddingBottom(IHTMLStyle *iface, VARIANT v)
1362 {
1363 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1364 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1365 return E_NOTIMPL;
1366 }
1367
1368 static HRESULT WINAPI HTMLStyle_get_paddingBottom(IHTMLStyle *iface, VARIANT *p)
1369 {
1370 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1371 FIXME("(%p)->(%p)\n", This, p);
1372 return E_NOTIMPL;
1373 }
1374
1375 static HRESULT WINAPI HTMLStyle_put_paddingLeft(IHTMLStyle *iface, VARIANT v)
1376 {
1377 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1378
1379 TRACE("(%p)->(vt=%d)\n", This, V_VT(&v));
1380
1381 switch(V_VT(&v)) {
1382 case VT_I4: {
1383 WCHAR buf[14];
1384
1385 wsprintfW(buf, px_formatW, V_I4(&v));
1386 return set_style_attr(This, STYLEID_PADDING_LEFT, buf, 0);
1387 }
1388 case VT_BSTR:
1389 return set_style_attr(This, STYLEID_PADDING_LEFT, V_BSTR(&v), 0);
1390 default:
1391 FIXME("unsupported vt=%d\n", V_VT(&v));
1392 }
1393
1394 return E_NOTIMPL;
1395 }
1396
1397 static HRESULT WINAPI HTMLStyle_get_paddingLeft(IHTMLStyle *iface, VARIANT *p)
1398 {
1399 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1400 BSTR ret;
1401 HRESULT hres;
1402
1403 TRACE("(%p)->(%p)\n", This, p);
1404
1405 hres = get_style_attr(This, STYLEID_PADDING_LEFT, &ret);
1406 if(FAILED(hres))
1407 return hres;
1408
1409 V_VT(p) = VT_BSTR;
1410 V_BSTR(p) = ret;
1411 return S_OK;
1412 }
1413
1414 static HRESULT WINAPI HTMLStyle_put_padding(IHTMLStyle *iface, BSTR v)
1415 {
1416 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1417 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1418 return E_NOTIMPL;
1419 }
1420
1421 static HRESULT WINAPI HTMLStyle_get_padding(IHTMLStyle *iface, BSTR *p)
1422 {
1423 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1424 FIXME("(%p)->(%p)\n", This, p);
1425 return E_NOTIMPL;
1426 }
1427
1428 static HRESULT WINAPI HTMLStyle_put_border(IHTMLStyle *iface, BSTR v)
1429 {
1430 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1431
1432 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1433
1434 return set_style_attr(This, STYLEID_BORDER, v, 0);
1435 }
1436
1437 static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
1438 {
1439 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1440
1441 TRACE("(%p)->(%p)\n", This, p);
1442
1443 return get_style_attr(This, STYLEID_BORDER, p);
1444 }
1445
1446 static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
1447 {
1448 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1449 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1450 return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX);
1451 }
1452
1453 static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
1454 {
1455 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1456 TRACE("(%p)->(%p)\n", This, p);
1457 return get_style_attr(This, STYLEID_BORDER_TOP, p);
1458 }
1459
1460 static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
1461 {
1462 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1463 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1464 return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX);
1465 }
1466
1467 static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
1468 {
1469 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1470 TRACE("(%p)->(%p)\n", This, p);
1471 return get_style_attr(This, STYLEID_BORDER_RIGHT, p);
1472 }
1473
1474 static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
1475 {
1476 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1477 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1478 return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX);
1479 }
1480
1481 static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
1482 {
1483 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1484 TRACE("(%p)->(%p)\n", This, p);
1485 return get_style_attr(This, STYLEID_BORDER_BOTTOM, p);
1486 }
1487
1488 static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
1489 {
1490 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1491
1492 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1493
1494 return set_style_attr(This, STYLEID_BORDER_LEFT, v, ATTR_FIX_PX);
1495 }
1496
1497 static HRESULT WINAPI HTMLStyle_get_borderLeft(IHTMLStyle *iface, BSTR *p)
1498 {
1499 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1500
1501 TRACE("(%p)->(%p)\n", This, p);
1502
1503 return get_style_attr(This, STYLEID_BORDER_LEFT, p);
1504 }
1505
1506 static HRESULT WINAPI HTMLStyle_put_borderColor(IHTMLStyle *iface, BSTR v)
1507 {
1508 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1509
1510 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1511
1512 return set_style_attr(This, STYLEID_BORDER_COLOR, v, 0);
1513 }
1514
1515 static HRESULT WINAPI HTMLStyle_get_borderColor(IHTMLStyle *iface, BSTR *p)
1516 {
1517 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1518
1519 TRACE("(%p)->(%p)\n", This, p);
1520
1521 return get_style_attr(This, STYLEID_BORDER_COLOR, p);
1522 }
1523
1524 static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v)
1525 {
1526 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1527 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1528 return E_NOTIMPL;
1529 }
1530
1531 static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p)
1532 {
1533 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1534 FIXME("(%p)->(%p)\n", This, p);
1535 return E_NOTIMPL;
1536 }
1537
1538 static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v)
1539 {
1540 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1541 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1542 return E_NOTIMPL;
1543 }
1544
1545 static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p)
1546 {
1547 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1548 FIXME("(%p)->(%p)\n", This, p);
1549 return E_NOTIMPL;
1550 }
1551
1552 static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v)
1553 {
1554 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1555 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1556 return E_NOTIMPL;
1557 }
1558
1559 static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p)
1560 {
1561 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1562 FIXME("(%p)->(%p)\n", This, p);
1563 return E_NOTIMPL;
1564 }
1565
1566 static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v)
1567 {
1568 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1569 FIXME("(%p)->(v%d)\n", This, V_VT(&v));
1570 return E_NOTIMPL;
1571 }
1572
1573 static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p)
1574 {
1575 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1576 FIXME("(%p)->(%p)\n", This, p);
1577 return E_NOTIMPL;
1578 }
1579
1580 static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v)
1581 {
1582 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1583 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1584 return set_style_attr(This, STYLEID_BORDER_WIDTH, v, ATTR_FIX_PX);
1585 }
1586
1587 static HRESULT WINAPI HTMLStyle_get_borderWidth(IHTMLStyle *iface, BSTR *p)
1588 {
1589 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1590 TRACE("(%p)->(%p)\n", This, p);
1591 return get_style_attr(This, STYLEID_BORDER_WIDTH, p);
1592 }
1593
1594 static HRESULT WINAPI HTMLStyle_put_borderTopWidth(IHTMLStyle *iface, VARIANT v)
1595 {
1596 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1597 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1598 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, &v, 0);
1599 }
1600
1601 static HRESULT WINAPI HTMLStyle_get_borderTopWidth(IHTMLStyle *iface, VARIANT *p)
1602 {
1603 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1604
1605 TRACE("(%p)->(%p)\n", This, p);
1606
1607 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, p, 0);
1608 }
1609
1610 static HRESULT WINAPI HTMLStyle_put_borderRightWidth(IHTMLStyle *iface, VARIANT v)
1611 {
1612 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1613 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1614 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, &v, 0);
1615 }
1616
1617 static HRESULT WINAPI HTMLStyle_get_borderRightWidth(IHTMLStyle *iface, VARIANT *p)
1618 {
1619 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1620 TRACE("(%p)->(%p)\n", This, p);
1621 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, p, 0);
1622 }
1623
1624 static HRESULT WINAPI HTMLStyle_put_borderBottomWidth(IHTMLStyle *iface, VARIANT v)
1625 {
1626 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1627
1628 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1629 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, &v, 0);
1630 }
1631
1632 static HRESULT WINAPI HTMLStyle_get_borderBottomWidth(IHTMLStyle *iface, VARIANT *p)
1633 {
1634 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1635 TRACE("(%p)->(%p)\n", This, p);
1636 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, p, 0);
1637 }
1638
1639 static HRESULT WINAPI HTMLStyle_put_borderLeftWidth(IHTMLStyle *iface, VARIANT v)
1640 {
1641 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1642 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1643 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, &v, 0);
1644 }
1645
1646 static HRESULT WINAPI HTMLStyle_get_borderLeftWidth(IHTMLStyle *iface, VARIANT *p)
1647 {
1648 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1649 TRACE("(%p)->(%p)\n", This, p);
1650 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, p, 0);
1651 }
1652
1653 static HRESULT WINAPI HTMLStyle_put_borderStyle(IHTMLStyle *iface, BSTR v)
1654 {
1655 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1656 static const WCHAR styleWindowInset[] = {'w','i','n','d','o','w','-','i','n','s','e','t',0};
1657 HRESULT hres = S_OK;
1658 BSTR pstyle;
1659 int i=0;
1660 int last = 0;
1661
1662 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1663
1664 while(v[i] && hres == S_OK)
1665 {
1666 if(v[i] == (WCHAR)' ')
1667 {
1668 pstyle = SysAllocStringLen(&v[last], (i-last));
1669 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1670 {
1671 TRACE("1. Invalid style (%s)\n", debugstr_w(pstyle));
1672 hres = E_INVALIDARG;
1673 }
1674 SysFreeString(pstyle);
1675 last = i+1;
1676 }
1677 i++;
1678 }
1679
1680 if(hres == S_OK)
1681 {
1682 pstyle = SysAllocStringLen(&v[last], i-last);
1683 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1684 {
1685 TRACE("2. Invalid style (%s)\n", debugstr_w(pstyle));
1686 hres = E_INVALIDARG;
1687 }
1688 SysFreeString(pstyle);
1689 }
1690
1691 if(hres == S_OK)
1692 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, v, 0);
1693
1694 return hres;
1695 }
1696
1697 static HRESULT WINAPI HTMLStyle_get_borderStyle(IHTMLStyle *iface, BSTR *p)
1698 {
1699 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1700 TRACE("(%p)->(%p)\n", This, p);
1701 return get_style_attr(This, STYLEID_BORDER_STYLE, p);
1702 }
1703
1704 static HRESULT WINAPI HTMLStyle_put_borderTopStyle(IHTMLStyle *iface, BSTR v)
1705 {
1706 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1707 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1708
1709 if(!is_valid_border_style(v))
1710 return E_INVALIDARG;
1711
1712 return set_style_attr(This, STYLEID_BORDER_TOP_STYLE, v, 0);
1713 }
1714
1715 static HRESULT WINAPI HTMLStyle_get_borderTopStyle(IHTMLStyle *iface, BSTR *p)
1716 {
1717 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1718 TRACE("(%p)->(%p)\n", This, p);
1719 return get_style_attr(This, STYLEID_BORDER_TOP_STYLE, p);
1720 }
1721
1722 static HRESULT WINAPI HTMLStyle_put_borderRightStyle(IHTMLStyle *iface, BSTR v)
1723 {
1724 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1725 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1726
1727 if(!is_valid_border_style(v))
1728 return E_INVALIDARG;
1729
1730 return set_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, v, 0);
1731 }
1732
1733 static HRESULT WINAPI HTMLStyle_get_borderRightStyle(IHTMLStyle *iface, BSTR *p)
1734 {
1735 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1736 TRACE("(%p)->(%p)\n", This, p);
1737 return get_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, p);
1738 }
1739
1740 static HRESULT WINAPI HTMLStyle_put_borderBottomStyle(IHTMLStyle *iface, BSTR v)
1741 {
1742 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1743 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1744
1745 if(!is_valid_border_style(v))
1746 return E_INVALIDARG;
1747
1748 return set_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, v, 0);
1749 }
1750
1751 static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p)
1752 {
1753 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1754 TRACE("(%p)->(%p)\n", This, p);
1755 return get_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, p);
1756 }
1757
1758 static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v)
1759 {
1760 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1761 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1762
1763 if(!is_valid_border_style(v))
1764 return E_INVALIDARG;
1765
1766 return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0);
1767 }
1768
1769 static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p)
1770 {
1771 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1772 TRACE("(%p)->(%p)\n", This, p);
1773 return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p);
1774 }
1775
1776 static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
1777 {
1778 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1779
1780 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
1781
1782 switch(V_VT(&v)) {
1783 case VT_BSTR:
1784 TRACE("%s\n", debugstr_w(V_BSTR(&v)));
1785 return set_style_attr(This, STYLEID_WIDTH, V_BSTR(&v), 0);
1786 default:
1787 FIXME("unsupported vt %d\n", V_VT(&v));
1788 }
1789
1790 return E_NOTIMPL;
1791 }
1792
1793 static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
1794 {
1795 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1796
1797 TRACE("(%p)->(%p)\n", This, p);
1798
1799 V_VT(p) = VT_BSTR;
1800 return get_style_attr(This, STYLEID_WIDTH, &V_BSTR(p));
1801 }
1802
1803 static HRESULT WINAPI HTMLStyle_put_height(IHTMLStyle *iface, VARIANT v)
1804 {
1805 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1806
1807 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1808
1809 switch(V_VT(&v)) {
1810 case VT_BSTR:
1811 return set_style_attr(This, STYLEID_HEIGHT, V_BSTR(&v), 0);
1812 default:
1813 FIXME("unimplemented vt %d\n", V_VT(&v));
1814 return E_NOTIMPL;
1815 }
1816
1817 return S_OK;
1818 }
1819
1820 static HRESULT WINAPI HTMLStyle_get_height(IHTMLStyle *iface, VARIANT *p)
1821 {
1822 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1823 BSTR ret;
1824 HRESULT hres;
1825
1826 TRACE("(%p)->(%p)\n", This, p);
1827
1828 hres = get_style_attr(This, STYLEID_HEIGHT, &ret);
1829 if(FAILED(hres))
1830 return hres;
1831
1832 V_VT(p) = VT_BSTR;
1833 V_BSTR(p) = ret;
1834 return S_OK;
1835 }
1836
1837 static HRESULT WINAPI HTMLStyle_put_styleFloat(IHTMLStyle *iface, BSTR v)
1838 {
1839 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1840 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1841 return E_NOTIMPL;
1842 }
1843
1844 static HRESULT WINAPI HTMLStyle_get_styleFloat(IHTMLStyle *iface, BSTR *p)
1845 {
1846 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1847 FIXME("(%p)->(%p)\n", This, p);
1848 return E_NOTIMPL;
1849 }
1850
1851 static HRESULT WINAPI HTMLStyle_put_clear(IHTMLStyle *iface, BSTR v)
1852 {
1853 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1854 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1855 return E_NOTIMPL;
1856 }
1857
1858 static HRESULT WINAPI HTMLStyle_get_clear(IHTMLStyle *iface, BSTR *p)
1859 {
1860 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1861 FIXME("(%p)->(%p)\n", This, p);
1862 return E_NOTIMPL;
1863 }
1864
1865 static HRESULT WINAPI HTMLStyle_put_display(IHTMLStyle *iface, BSTR v)
1866 {
1867 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1868
1869 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1870
1871 return set_style_attr(This, STYLEID_DISPLAY, v, 0);
1872 }
1873
1874 static HRESULT WINAPI HTMLStyle_get_display(IHTMLStyle *iface, BSTR *p)
1875 {
1876 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1877
1878 TRACE("(%p)->(%p)\n", This, p);
1879
1880 return get_style_attr(This, STYLEID_DISPLAY, p);
1881 }
1882
1883 static HRESULT WINAPI HTMLStyle_put_visibility(IHTMLStyle *iface, BSTR v)
1884 {
1885 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1886
1887 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1888
1889 return set_style_attr(This, STYLEID_VISIBILITY, v, 0);
1890 }
1891
1892 static HRESULT WINAPI HTMLStyle_get_visibility(IHTMLStyle *iface, BSTR *p)
1893 {
1894 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1895
1896 TRACE("(%p)->(%p)\n", This, p);
1897
1898 return get_style_attr(This, STYLEID_VISIBILITY, p);
1899 }
1900
1901 static HRESULT WINAPI HTMLStyle_put_listStyleType(IHTMLStyle *iface, BSTR v)
1902 {
1903 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1904 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1905 return E_NOTIMPL;
1906 }
1907
1908 static HRESULT WINAPI HTMLStyle_get_listStyleType(IHTMLStyle *iface, BSTR *p)
1909 {
1910 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1911 FIXME("(%p)->(%p)\n", This, p);
1912 return E_NOTIMPL;
1913 }
1914
1915 static HRESULT WINAPI HTMLStyle_put_listStylePosition(IHTMLStyle *iface, BSTR v)
1916 {
1917 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1918 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1919 return E_NOTIMPL;
1920 }
1921
1922 static HRESULT WINAPI HTMLStyle_get_listStylePosition(IHTMLStyle *iface, BSTR *p)
1923 {
1924 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1925 FIXME("(%p)->(%p)\n", This, p);
1926 return E_NOTIMPL;
1927 }
1928
1929 static HRESULT WINAPI HTMLStyle_put_listStyleImage(IHTMLStyle *iface, BSTR v)
1930 {
1931 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1932 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1933 return E_NOTIMPL;
1934 }
1935
1936 static HRESULT WINAPI HTMLStyle_get_listStyleImage(IHTMLStyle *iface, BSTR *p)
1937 {
1938 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1939 FIXME("(%p)->(%p)\n", This, p);
1940 return E_NOTIMPL;
1941 }
1942
1943 static HRESULT WINAPI HTMLStyle_put_listStyle(IHTMLStyle *iface, BSTR v)
1944 {
1945 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1946 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1947 return E_NOTIMPL;
1948 }
1949
1950 static HRESULT WINAPI HTMLStyle_get_listStyle(IHTMLStyle *iface, BSTR *p)
1951 {
1952 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1953 FIXME("(%p)->(%p)\n", This, p);
1954 return E_NOTIMPL;
1955 }
1956
1957 static HRESULT WINAPI HTMLStyle_put_whiteSpace(IHTMLStyle *iface, BSTR v)
1958 {
1959 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1960 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1961 return E_NOTIMPL;
1962 }
1963
1964 static HRESULT WINAPI HTMLStyle_get_whiteSpace(IHTMLStyle *iface, BSTR *p)
1965 {
1966 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1967 FIXME("(%p)->(%p)\n", This, p);
1968 return E_NOTIMPL;
1969 }
1970
1971 static HRESULT WINAPI HTMLStyle_put_top(IHTMLStyle *iface, VARIANT v)
1972 {
1973 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1974
1975 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1976
1977 return set_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, &v, 0);
1978 }
1979
1980 static HRESULT WINAPI HTMLStyle_get_top(IHTMLStyle *iface, VARIANT *p)
1981 {
1982 HTMLStyle *This = HTMLSTYLE_THIS(iface);
1983 BSTR ret;
1984 HRESULT hres;
1985
1986 TRACE("(%p)->(%p)\n", This, p);
1987
1988 hres = get_style_attr(This, STYLEID_TOP, &ret);
1989 if(FAILED(hres))
1990 return hres;
1991
1992 V_VT(p) = VT_BSTR;
1993 V_BSTR(p) = ret;
1994 return S_OK;
1995 }
1996
1997 static HRESULT WINAPI HTMLStyle_put_left(IHTMLStyle *iface, VARIANT v)
1998 {
1999 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2000
2001 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2002
2003 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, &v, 0);
2004 }
2005
2006 static HRESULT WINAPI HTMLStyle_get_left(IHTMLStyle *iface, VARIANT *p)
2007 {
2008 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2009 BSTR ret;
2010 HRESULT hres;
2011
2012 TRACE("(%p)->(%p)\n", This, p);
2013
2014 hres = get_style_attr(This, STYLEID_LEFT, &ret);
2015 if(FAILED(hres))
2016 return hres;
2017
2018 V_VT(p) = VT_BSTR;
2019 V_BSTR(p) = ret;
2020 return S_OK;
2021 }
2022
2023 static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
2024 {
2025 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2026 TRACE("(%p)->(%p)\n", This, p);
2027 return IHTMLStyle2_get_position(HTMLSTYLE2(This), p);
2028 }
2029
2030 static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
2031 {
2032 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2033
2034 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2035
2036 switch(V_VT(&v)) {
2037 case VT_BSTR:
2038 return set_style_attr(This, STYLEID_Z_INDEX, V_BSTR(&v), 0);
2039 case VT_I4: {
2040 WCHAR value[14];
2041 static const WCHAR format[] = {'%','d',0};
2042
2043 wsprintfW(value, format, V_I4(&v));
2044 return set_style_attr(This, STYLEID_Z_INDEX, value, 0);
2045 }
2046 default:
2047 FIXME("unimplemented vt %d\n", V_VT(&v));
2048 return E_NOTIMPL;
2049 }
2050
2051 return S_OK;
2052 }
2053
2054 static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
2055 {
2056 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2057
2058 TRACE("(%p)->(%p)\n", This, p);
2059
2060 return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
2061 }
2062
2063 static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
2064 {
2065 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2066 static const WCHAR szVisible[] = {'v','i','s','i','b','l','e',0};
2067 static const WCHAR szScroll[] = {'s','c','r','o','l','l',0};
2068 static const WCHAR szHidden[] = {'h','i','d','d','e','n',0};
2069 static const WCHAR szAuto[] = {'a','u','t','o',0};
2070
2071 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2072
2073 /* overflow can only be one of the follow values. */
2074 if(!v || !*v || strcmpiW(szVisible, v) == 0 || strcmpiW(szScroll, v) == 0 ||
2075 strcmpiW(szHidden, v) == 0 || strcmpiW(szAuto, v) == 0)
2076 {
2077 return set_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, v, 0);
2078 }
2079
2080 return E_INVALIDARG;
2081 }
2082
2083
2084 static HRESULT WINAPI HTMLStyle_get_overflow(IHTMLStyle *iface, BSTR *p)
2085 {
2086 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2087
2088 TRACE("(%p)->(%p)\n", This, p);
2089
2090 if(!p)
2091 return E_INVALIDARG;
2092
2093 return get_style_attr(This, STYLEID_OVERFLOW, p);
2094 }
2095
2096 static HRESULT WINAPI HTMLStyle_put_pageBreakBefore(IHTMLStyle *iface, BSTR v)
2097 {
2098 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2099 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2100 return E_NOTIMPL;
2101 }
2102
2103 static HRESULT WINAPI HTMLStyle_get_pageBreakBefore(IHTMLStyle *iface, BSTR *p)
2104 {
2105 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2106 FIXME("(%p)->(%p)\n", This, p);
2107 return E_NOTIMPL;
2108 }
2109
2110 static HRESULT WINAPI HTMLStyle_put_pageBreakAfter(IHTMLStyle *iface, BSTR v)
2111 {
2112 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2113 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2114 return E_NOTIMPL;
2115 }
2116
2117 static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p)
2118 {
2119 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2120 FIXME("(%p)->(%p)\n", This, p);
2121 return E_NOTIMPL;
2122 }
2123
2124 static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
2125 {
2126 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2127 nsAString text_str;
2128 nsresult nsres;
2129
2130 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2131
2132 nsAString_Init(&text_str, v);
2133 nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str);
2134 nsAString_Finish(&text_str);
2135 if(NS_FAILED(nsres)) {
2136 FIXME("SetCssStyle failed: %08x\n", nsres);
2137 return E_FAIL;
2138 }
2139
2140 return S_OK;
2141 }
2142
2143 static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p)
2144 {
2145 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2146 nsAString text_str;
2147 nsresult nsres;
2148
2149 TRACE("(%p)->(%p)\n", This, p);
2150
2151 /* FIXME: Gecko style formatting is different than IE (uppercase). */
2152 nsAString_Init(&text_str, NULL);
2153 nsres = nsIDOMCSSStyleDeclaration_GetCssText(This->nsstyle, &text_str);
2154 if(NS_SUCCEEDED(nsres)) {
2155 const PRUnichar *text;
2156
2157 nsAString_GetData(&text_str, &text);
2158 *p = *text ? SysAllocString(text) : NULL;
2159 }else {
2160 FIXME("GetCssStyle failed: %08x\n", nsres);
2161 *p = NULL;
2162 }
2163
2164 nsAString_Finish(&text_str);
2165 return S_OK;
2166 }
2167
2168 static HRESULT WINAPI HTMLStyle_put_pixelTop(IHTMLStyle *iface, LONG v)
2169 {
2170 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2171 FIXME("(%p)->()\n", This);
2172 return E_NOTIMPL;
2173 }
2174
2175 static HRESULT WINAPI HTMLStyle_get_pixelTop(IHTMLStyle *iface, LONG *p)
2176 {
2177 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2178 FIXME("(%p)->()\n", This);
2179 return E_NOTIMPL;
2180 }
2181
2182 static HRESULT WINAPI HTMLStyle_put_pixelLeft(IHTMLStyle *iface, LONG v)
2183 {
2184 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2185 FIXME("(%p)->()\n", This);
2186 return E_NOTIMPL;
2187 }
2188
2189 static HRESULT WINAPI HTMLStyle_get_pixelLeft(IHTMLStyle *iface, LONG *p)
2190 {
2191 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2192 FIXME("(%p)->()\n", This);
2193 return E_NOTIMPL;
2194 }
2195
2196 static HRESULT WINAPI HTMLStyle_put_pixelWidth(IHTMLStyle *iface, LONG v)
2197 {
2198 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2199 FIXME("(%p)->()\n", This);
2200 return E_NOTIMPL;
2201 }
2202
2203 static HRESULT WINAPI HTMLStyle_get_pixelWidth(IHTMLStyle *iface, LONG *p)
2204 {
2205 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2206 FIXME("(%p)->()\n", This);
2207 return E_NOTIMPL;
2208 }
2209
2210 static HRESULT WINAPI HTMLStyle_put_pixelHeight(IHTMLStyle *iface, LONG v)
2211 {
2212 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2213 FIXME("(%p)->()\n", This);
2214 return E_NOTIMPL;
2215 }
2216
2217 static HRESULT WINAPI HTMLStyle_get_pixelHeight(IHTMLStyle *iface, LONG *p)
2218 {
2219 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2220 FIXME("(%p)->()\n", This);
2221 return E_NOTIMPL;
2222 }
2223
2224 static HRESULT WINAPI HTMLStyle_put_posTop(IHTMLStyle *iface, float v)
2225 {
2226 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2227
2228 TRACE("(%p)->(%f)\n", This, v);
2229
2230 return set_style_pos(This, STYLEID_TOP, v);
2231 }
2232
2233 static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
2234 {
2235 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2236
2237 TRACE("(%p)->(%p)\n", This, p);
2238
2239 if(!p)
2240 return E_POINTER;
2241
2242 return get_nsstyle_pos(This, STYLEID_TOP, p);
2243 }
2244
2245 static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
2246 {
2247 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2248
2249 TRACE("(%p)->(%f)\n", This, v);
2250
2251 return set_style_pos(This, STYLEID_LEFT, v);
2252 }
2253
2254 static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
2255 {
2256 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2257
2258 TRACE("(%p)->(%p)\n", This, p);
2259
2260 if(!p)
2261 return E_POINTER;
2262
2263 return get_nsstyle_pos(This, STYLEID_LEFT, p);
2264 }
2265
2266 static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
2267 {
2268 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2269
2270 TRACE("(%p)->(%f)\n", This, v);
2271
2272 return set_style_pos(This, STYLEID_WIDTH, v);
2273 }
2274
2275 static HRESULT WINAPI HTMLStyle_get_posWidth(IHTMLStyle *iface, float *p)
2276 {
2277 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2278
2279 TRACE("(%p)->(%p)\n", This, p);
2280
2281 if(!p)
2282 return E_POINTER;
2283
2284 if(get_nsstyle_pos(This, STYLEID_WIDTH, p) != S_OK)
2285 *p = 0.0f;
2286
2287 return S_OK;
2288 }
2289
2290 static HRESULT WINAPI HTMLStyle_put_posHeight(IHTMLStyle *iface, float v)
2291 {
2292 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2293
2294 TRACE("(%p)->(%f)\n", This, v);
2295
2296 return set_style_pos(This, STYLEID_HEIGHT, v);
2297 }
2298
2299 static HRESULT WINAPI HTMLStyle_get_posHeight(IHTMLStyle *iface, float *p)
2300 {
2301 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2302
2303 TRACE("(%p)->(%p)\n", This, p);
2304
2305 if(!p)
2306 return E_POINTER;
2307
2308 if(get_nsstyle_pos(This, STYLEID_HEIGHT, p) != S_OK)
2309 *p = 0.0f;
2310
2311 return S_OK;
2312 }
2313
2314 static HRESULT WINAPI HTMLStyle_put_cursor(IHTMLStyle *iface, BSTR v)
2315 {
2316 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2317
2318 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2319
2320 return set_style_attr(This, STYLEID_CURSOR, v, 0);
2321 }
2322
2323 static HRESULT WINAPI HTMLStyle_get_cursor(IHTMLStyle *iface, BSTR *p)
2324 {
2325 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2326
2327 TRACE("(%p)->(%p)\n", This, p);
2328
2329 return get_style_attr(This, STYLEID_CURSOR, p);
2330 }
2331
2332 static HRESULT WINAPI HTMLStyle_put_clip(IHTMLStyle *iface, BSTR v)
2333 {
2334 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2335 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2336 return E_NOTIMPL;
2337 }
2338
2339 static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
2340 {
2341 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2342 FIXME("(%p)->(%p)\n", This, p);
2343 return E_NOTIMPL;
2344 }
2345
2346 static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
2347 {
2348 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2349
2350 WARN("(%p)->(%s)\n", This, debugstr_w(v));
2351
2352 /* FIXME: Handle MS-style filters */
2353 return set_style_attr(This, STYLEID_FILTER, v, 0);
2354 }
2355
2356 static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
2357 {
2358 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2359
2360 WARN("(%p)->(%p)\n", This, p);
2361
2362 /* FIXME: Handle MS-style filters */
2363 return get_style_attr(This, STYLEID_FILTER, p);
2364 }
2365
2366 static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2367 VARIANT AttributeValue, LONG lFlags)
2368 {
2369 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2370 HRESULT hres;
2371 DISPID dispid;
2372
2373 TRACE("(%p)->(%s v%d %08x)\n", This, debugstr_w(strAttributeName),
2374 V_VT(&AttributeValue), lFlags);
2375
2376 if(!strAttributeName)
2377 return E_INVALIDARG;
2378
2379 if(lFlags == 1)
2380 FIXME("Parameter lFlags ignored\n");
2381
2382 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2383 LOCALE_USER_DEFAULT, &dispid);
2384 if(hres == S_OK)
2385 {
2386 VARIANT ret;
2387 DISPID dispidNamed = DISPID_PROPERTYPUT;
2388 DISPPARAMS params;
2389
2390 params.cArgs = 1;
2391 params.rgvarg = &AttributeValue;
2392 params.cNamedArgs = 1;
2393 params.rgdispidNamedArgs = &dispidNamed;
2394
2395 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2396 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2397 }
2398 else
2399 {
2400 FIXME("Custom attributes not supported.\n");
2401 }
2402
2403 TRACE("ret: %08x\n", hres);
2404
2405 return hres;
2406 }
2407
2408 static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2409 LONG lFlags, VARIANT *AttributeValue)
2410 {
2411 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2412 HRESULT hres;
2413 DISPID dispid;
2414
2415 TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName),
2416 AttributeValue, lFlags);
2417
2418 if(!AttributeValue || !strAttributeName)
2419 return E_INVALIDARG;
2420
2421 if(lFlags == 1)
2422 FIXME("Parameter lFlags ignored\n");
2423
2424 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2425 LOCALE_USER_DEFAULT, &dispid);
2426 if(hres == S_OK)
2427 {
2428 DISPPARAMS params = {NULL, NULL, 0, 0 };
2429
2430 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2431 DISPATCH_PROPERTYGET, &params, AttributeValue, NULL, NULL);
2432 }
2433 else
2434 {
2435 FIXME("Custom attributes not supported.\n");
2436 }
2437
2438 return hres;
2439 }
2440
2441 static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2442 LONG lFlags, VARIANT_BOOL *pfSuccess)
2443 {
2444 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2445 FIXME("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName),
2446 lFlags, pfSuccess);
2447 return E_NOTIMPL;
2448 }
2449
2450 static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
2451 {
2452 HTMLStyle *This = HTMLSTYLE_THIS(iface);
2453 FIXME("(%p)->(%p)\n", This, String);
2454 return E_NOTIMPL;
2455 }
2456
2457 static HRESULT HTMLStyle_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid)
2458 {
2459 int c, i, min=0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
2460
2461 while(min <= max) {
2462 i = (min+max)/2;
2463
2464 c = strcmpW(style_tbl[i].name, name);
2465 if(!c) {
2466 *dispid = style_tbl[i].dispid;
2467 return S_OK;
2468 }
2469
2470 if(c > 0)
2471 max = i-1;
2472 else
2473 min = i+1;
2474 }
2475
2476 return DISP_E_UNKNOWNNAME;
2477 }
2478
2479 static const IHTMLStyleVtbl HTMLStyleVtbl = {
2480 HTMLStyle_QueryInterface,
2481 HTMLStyle_AddRef,
2482 HTMLStyle_Release,
2483 HTMLStyle_GetTypeInfoCount,
2484 HTMLStyle_GetTypeInfo,
2485 HTMLStyle_GetIDsOfNames,
2486 HTMLStyle_Invoke,
2487 HTMLStyle_put_fontFamily,
2488 HTMLStyle_get_fontFamily,
2489 HTMLStyle_put_fontStyle,
2490 HTMLStyle_get_fontStyle,
2491 HTMLStyle_put_fontVariant,
2492 HTMLStyle_get_fontVariant,
2493 HTMLStyle_put_fontWeight,
2494 HTMLStyle_get_fontWeight,
2495 HTMLStyle_put_fontSize,
2496 HTMLStyle_get_fontSize,
2497 HTMLStyle_put_font,
2498 HTMLStyle_get_font,
2499 HTMLStyle_put_color,
2500 HTMLStyle_get_color,
2501 HTMLStyle_put_background,
2502 HTMLStyle_get_background,
2503 HTMLStyle_put_backgroundColor,
2504 HTMLStyle_get_backgroundColor,
2505 HTMLStyle_put_backgroundImage,
2506 HTMLStyle_get_backgroundImage,
2507 HTMLStyle_put_backgroundRepeat,
2508 HTMLStyle_get_backgroundRepeat,
2509 HTMLStyle_put_backgroundAttachment,
2510 HTMLStyle_get_backgroundAttachment,
2511 HTMLStyle_put_backgroundPosition,
2512 HTMLStyle_get_backgroundPosition,
2513 HTMLStyle_put_backgroundPositionX,
2514 HTMLStyle_get_backgroundPositionX,
2515 HTMLStyle_put_backgroundPositionY,
2516 HTMLStyle_get_backgroundPositionY,
2517 HTMLStyle_put_wordSpacing,
2518 HTMLStyle_get_wordSpacing,
2519 HTMLStyle_put_letterSpacing,
2520 HTMLStyle_get_letterSpacing,
2521 HTMLStyle_put_textDecoration,
2522 HTMLStyle_get_textDecoration,
2523 HTMLStyle_put_textDecorationNone,
2524 HTMLStyle_get_textDecorationNone,
2525 HTMLStyle_put_textDecorationUnderline,
2526 HTMLStyle_get_textDecorationUnderline,
2527 HTMLStyle_put_textDecorationOverline,
2528 HTMLStyle_get_textDecorationOverline,
2529 HTMLStyle_put_textDecorationLineThrough,
2530 HTMLStyle_get_textDecorationLineThrough,
2531 HTMLStyle_put_textDecorationBlink,
2532 HTMLStyle_get_textDecorationBlink,
2533 HTMLStyle_put_verticalAlign,
2534 HTMLStyle_get_verticalAlign,
2535 HTMLStyle_put_textTransform,
2536 HTMLStyle_get_textTransform,
2537 HTMLStyle_put_textAlign,
2538 HTMLStyle_get_textAlign,
2539 HTMLStyle_put_textIndent,
2540 HTMLStyle_get_textIndent,
2541 HTMLStyle_put_lineHeight,
2542 HTMLStyle_get_lineHeight,
2543 HTMLStyle_put_marginTop,
2544 HTMLStyle_get_marginTop,
2545 HTMLStyle_put_marginRight,
2546 HTMLStyle_get_marginRight,
2547 HTMLStyle_put_marginBottom,
2548 HTMLStyle_get_marginBottom,
2549 HTMLStyle_put_marginLeft,
2550 HTMLStyle_get_marginLeft,
2551 HTMLStyle_put_margin,
2552 HTMLStyle_get_margin,
2553 HTMLStyle_put_paddingTop,
2554 HTMLStyle_get_paddingTop,
2555 HTMLStyle_put_paddingRight,
2556 HTMLStyle_get_paddingRight,
2557 HTMLStyle_put_paddingBottom,
2558 HTMLStyle_get_paddingBottom,
2559 HTMLStyle_put_paddingLeft,
2560 HTMLStyle_get_paddingLeft,
2561 HTMLStyle_put_padding,
2562 HTMLStyle_get_padding,
2563 HTMLStyle_put_border,
2564 HTMLStyle_get_border,
2565 HTMLStyle_put_borderTop,
2566 HTMLStyle_get_borderTop,
2567 HTMLStyle_put_borderRight,
2568 HTMLStyle_get_borderRight,
2569 HTMLStyle_put_borderBottom,
2570 HTMLStyle_get_borderBottom,
2571 HTMLStyle_put_borderLeft,
2572 HTMLStyle_get_borderLeft,
2573 HTMLStyle_put_borderColor,
2574 HTMLStyle_get_borderColor,
2575 HTMLStyle_put_borderTopColor,
2576 HTMLStyle_get_borderTopColor,
2577 HTMLStyle_put_borderRightColor,
2578 HTMLStyle_get_borderRightColor,
2579 HTMLStyle_put_borderBottomColor,
2580 HTMLStyle_get_borderBottomColor,
2581 HTMLStyle_put_borderLeftColor,
2582 HTMLStyle_get_borderLeftColor,
2583 HTMLStyle_put_borderWidth,
2584 HTMLStyle_get_borderWidth,
2585 HTMLStyle_put_borderTopWidth,
2586 HTMLStyle_get_borderTopWidth,
2587 HTMLStyle_put_borderRightWidth,
2588 HTMLStyle_get_borderRightWidth,
2589 HTMLStyle_put_borderBottomWidth,
2590 HTMLStyle_get_borderBottomWidth,
2591 HTMLStyle_put_borderLeftWidth,
2592 HTMLStyle_get_borderLeftWidth,
2593 HTMLStyle_put_borderStyle,
2594 HTMLStyle_get_borderStyle,
2595 HTMLStyle_put_borderTopStyle,
2596 HTMLStyle_get_borderTopStyle,
2597 HTMLStyle_put_borderRightStyle,
2598 HTMLStyle_get_borderRightStyle,
2599 HTMLStyle_put_borderBottomStyle,
2600 HTMLStyle_get_borderBottomStyle,
2601 HTMLStyle_put_borderLeftStyle,
2602 HTMLStyle_get_borderLeftStyle,
2603 HTMLStyle_put_width,
2604 HTMLStyle_get_width,
2605 HTMLStyle_put_height,
2606 HTMLStyle_get_height,
2607 HTMLStyle_put_styleFloat,
2608 HTMLStyle_get_styleFloat,
2609 HTMLStyle_put_clear,
2610 HTMLStyle_get_clear,
2611 HTMLStyle_put_display,
2612 HTMLStyle_get_display,
2613 HTMLStyle_put_visibility,
2614 HTMLStyle_get_visibility,
2615 HTMLStyle_put_listStyleType,
2616 HTMLStyle_get_listStyleType,
2617 HTMLStyle_put_listStylePosition,
2618 HTMLStyle_get_listStylePosition,
2619 HTMLStyle_put_listStyleImage,
2620 HTMLStyle_get_listStyleImage,
2621 HTMLStyle_put_listStyle,
2622 HTMLStyle_get_listStyle,
2623 HTMLStyle_put_whiteSpace,
2624 HTMLStyle_get_whiteSpace,
2625 HTMLStyle_put_top,
2626 HTMLStyle_get_top,
2627 HTMLStyle_put_left,
2628 HTMLStyle_get_left,
2629 HTMLStyle_get_position,
2630 HTMLStyle_put_zIndex,
2631 HTMLStyle_get_zIndex,
2632 HTMLStyle_put_overflow,
2633 HTMLStyle_get_overflow,
2634 HTMLStyle_put_pageBreakBefore,
2635 HTMLStyle_get_pageBreakBefore,
2636 HTMLStyle_put_pageBreakAfter,
2637 HTMLStyle_get_pageBreakAfter,
2638 HTMLStyle_put_cssText,
2639 HTMLStyle_get_cssText,
2640 HTMLStyle_put_pixelTop,
2641 HTMLStyle_get_pixelTop,
2642 HTMLStyle_put_pixelLeft,
2643 HTMLStyle_get_pixelLeft,
2644 HTMLStyle_put_pixelWidth,
2645 HTMLStyle_get_pixelWidth,
2646 HTMLStyle_put_pixelHeight,
2647 HTMLStyle_get_pixelHeight,
2648 HTMLStyle_put_posTop,
2649 HTMLStyle_get_posTop,
2650 HTMLStyle_put_posLeft,
2651 HTMLStyle_get_posLeft,
2652 HTMLStyle_put_posWidth,
2653 HTMLStyle_get_posWidth,
2654 HTMLStyle_put_posHeight,
2655 HTMLStyle_get_posHeight,
2656 HTMLStyle_put_cursor,
2657 HTMLStyle_get_cursor,
2658 HTMLStyle_put_clip,
2659 HTMLStyle_get_clip,
2660 HTMLStyle_put_filter,
2661 HTMLStyle_get_filter,
2662 HTMLStyle_setAttribute,
2663 HTMLStyle_getAttribute,
2664 HTMLStyle_removeAttribute,
2665 HTMLStyle_toString
2666 };
2667
2668 static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
2669 NULL,
2670 HTMLStyle_get_dispid,
2671 NULL
2672 };
2673
2674 static const tid_t HTMLStyle_iface_tids[] = {
2675 IHTMLStyle_tid,
2676 IHTMLStyle2_tid,
2677 IHTMLStyle3_tid,
2678 IHTMLStyle4_tid,
2679 0
2680 };
2681 static dispex_static_data_t HTMLStyle_dispex = {
2682 &HTMLStyle_dispex_vtbl,
2683 DispHTMLStyle_tid,
2684 NULL,
2685 HTMLStyle_iface_tids
2686 };
2687
2688 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration *nsstyle)
2689 {
2690 HTMLStyle *ret = heap_alloc_zero(sizeof(HTMLStyle));
2691
2692 ret->lpHTMLStyleVtbl = &HTMLStyleVtbl;
2693 ret->ref = 1;
2694 ret->nsstyle = nsstyle;
2695 HTMLStyle2_Init(ret);
2696 HTMLStyle3_Init(ret);
2697
2698 nsIDOMCSSStyleDeclaration_AddRef(nsstyle);
2699
2700 init_dispex(&ret->dispex, (IUnknown*)HTMLSTYLE(ret), &HTMLStyle_dispex);
2701
2702 return HTMLSTYLE(ret);
2703 }