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