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