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