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