qcap: Implement a stubbed SmartTee filter.
[wine/multimedia.git] / dlls / mshtml / htmlstyle.c
blob33318ffb6c9bff9a2e32df48963b8c6b479622bd
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <stdarg.h>
20 #include <assert.h>
21 #include <math.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "mshtmdid.h"
31 #include "mshtml_private.h"
32 #include "htmlstyle.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 static const WCHAR attrBackground[] =
39 {'b','a','c','k','g','r','o','u','n','d',0};
40 static const WCHAR attrBackgroundAttachment[] =
41 {'b','a','c','k','g','r','o','u','n','d','-','a','t','t','a','c','h','m','e','n','t',0};
42 static const WCHAR attrBackgroundColor[] =
43 {'b','a','c','k','g','r','o','u','n','d','-','c','o','l','o','r',0};
44 static const WCHAR attrBackgroundImage[] =
45 {'b','a','c','k','g','r','o','u','n','d','-','i','m','a','g','e',0};
46 static const WCHAR attrBackgroundPosition[] =
47 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n',0};
48 static const WCHAR attrBackgroundPositionX[] =
49 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','x',0};
50 static const WCHAR attrBackgroundPositionY[] =
51 {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','y',0};
52 static const WCHAR attrBackgroundRepeat[] =
53 {'b','a','c','k','g','r','o','u','n','d','-','r','e','p','e','a','t',0};
54 static const WCHAR attrBorder[] =
55 {'b','o','r','d','e','r',0};
56 static const WCHAR attrBorderBottom[] =
57 {'b','o','r','d','e','r','-','b','o','t','t','o','m',0};
58 static const WCHAR attrBorderBottomColor[] =
59 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','c','o','l','o','r',0};
60 static const WCHAR attrBorderBottomStyle[] =
61 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','s','t','y','l','e',0};
62 static const WCHAR attrBorderBottomWidth[] =
63 {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','w','i','d','t','h',0};
64 static const WCHAR attrBorderColor[] =
65 {'b','o','r','d','e','r','-','c','o','l','o','r',0};
66 static const WCHAR attrBorderLeft[] =
67 {'b','o','r','d','e','r','-','l','e','f','t',0};
68 static const WCHAR attrBorderLeftColor[] =
69 {'b','o','r','d','e','r','-','l','e','f','t','-','c','o','l','o','r',0};
70 static const WCHAR attrBorderLeftStyle[] =
71 {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0};
72 static const WCHAR attrBorderLeftWidth[] =
73 {'b','o','r','d','e','r','-','l','e','f','t','-','w','i','d','t','h',0};
74 static const WCHAR attrBorderRight[] =
75 {'b','o','r','d','e','r','-','r','i','g','h','t',0};
76 static const WCHAR attrBorderRightColor[] =
77 {'b','o','r','d','e','r','-','r','i','g','h','t','-','c','o','l','o','r',0};
78 static const WCHAR attrBorderRightStyle[] =
79 {'b','o','r','d','e','r','-','r','i','g','h','t','-','s','t','y','l','e',0};
80 static const WCHAR attrBorderRightWidth[] =
81 {'b','o','r','d','e','r','-','r','i','g','h','t','-','w','i','d','t','h',0};
82 static const WCHAR attrBorderTop[] =
83 {'b','o','r','d','e','r','-','t','o','p',0};
84 static const WCHAR attrBorderTopColor[] =
85 {'b','o','r','d','e','r','-','t','o','p','-','c','o','l','o','r',0};
86 static const WCHAR attrBorderStyle[] =
87 {'b','o','r','d','e','r','-','s','t','y','l','e',0};
88 static const WCHAR attrBorderTopStyle[] =
89 {'b','o','r','d','e','r','-','t','o','p','-','s','t','y','l','e',0};
90 static const WCHAR attrBorderTopWidth[] =
91 {'b','o','r','d','e','r','-','t','o','p','-','w','i','d','t','h',0};
92 static const WCHAR attrBorderWidth[] =
93 {'b','o','r','d','e','r','-','w','i','d','t','h',0};
94 static const WCHAR attrBottom[] =
95 {'b','o','t','t','o','m',0};
96 /* FIXME: Use unprefixed version (requires Gecko changes). */
97 static const WCHAR attrBoxSizing[] =
98 {'-','m','o','z','-','b','o','x','-','s','i','z','i','n','g',0};
99 static const WCHAR attrClear[] =
100 {'c','l','e','a','r',0};
101 static const WCHAR attrClip[] =
102 {'c','l','i','p',0};
103 static const WCHAR attrColor[] =
104 {'c','o','l','o','r',0};
105 static const WCHAR attrCursor[] =
106 {'c','u','r','s','o','r',0};
107 static const WCHAR attrDirection[] =
108 {'d','i','r','e','c','t','i','o','n',0};
109 static const WCHAR attrDisplay[] =
110 {'d','i','s','p','l','a','y',0};
111 static const WCHAR attrFilter[] =
112 {'f','i','l','e','t','e','r',0};
113 static const WCHAR attrFloat[] =
114 {'f','l','o','a','t',0};
115 static const WCHAR attrFontFamily[] =
116 {'f','o','n','t','-','f','a','m','i','l','y',0};
117 static const WCHAR attrFontSize[] =
118 {'f','o','n','t','-','s','i','z','e',0};
119 static const WCHAR attrFontStyle[] =
120 {'f','o','n','t','-','s','t','y','l','e',0};
121 static const WCHAR attrFontVariant[] =
122 {'f','o','n','t','-','v','a','r','i','a','n','t',0};
123 static const WCHAR attrFontWeight[] =
124 {'f','o','n','t','-','w','e','i','g','h','t',0};
125 static const WCHAR attrHeight[] =
126 {'h','e','i','g','h','t',0};
127 static const WCHAR attrLeft[] =
128 {'l','e','f','t',0};
129 static const WCHAR attrLetterSpacing[] =
130 {'l','e','t','t','e','r','-','s','p','a','c','i','n','g',0};
131 static const WCHAR attrLineHeight[] =
132 {'l','i','n','e','-','h','e','i','g','h','t',0};
133 static const WCHAR attrListStyle[] =
134 {'l','i','s','t','-','s','t','y','l','e',0};
135 static const WCHAR attrListStyleType[] =
136 {'l','i','s','t','-','s','t','y','l','e','-','t','y','p','e',0};
137 static const WCHAR attrListStylePosition[] =
138 {'l','i','s','t','-','s','t','y','l','e','-','p','o','s','i','t','i','o','n',0};
139 static const WCHAR attrMargin[] =
140 {'m','a','r','g','i','n',0};
141 static const WCHAR attrMarginBottom[] =
142 {'m','a','r','g','i','n','-','b','o','t','t','o','m',0};
143 static const WCHAR attrMarginLeft[] =
144 {'m','a','r','g','i','n','-','l','e','f','t',0};
145 static const WCHAR attrMarginRight[] =
146 {'m','a','r','g','i','n','-','r','i','g','h','t',0};
147 static const WCHAR attrMarginTop[] =
148 {'m','a','r','g','i','n','-','t','o','p',0};
149 static const WCHAR attrMaxHeight[] =
150 {'m','a','x','-','h','e','i','g','h','t',0};
151 static const WCHAR attrMaxWidth[] =
152 {'m','a','x','-','w','i','d','t','h',0};
153 static const WCHAR attrMinHeight[] =
154 {'m','i','n','-','h','e','i','g','h','t',0};
155 static const WCHAR attrMinWidth[] =
156 {'m','i','n','-','w','i','d','t','h',0};
157 static const WCHAR attrOutline[] =
158 {'o','u','t','l','i','n','e',0};
159 static const WCHAR attrOverflow[] =
160 {'o','v','e','r','f','l','o','w',0};
161 static const WCHAR attrOverflowX[] =
162 {'o','v','e','r','f','l','o','w','-','x',0};
163 static const WCHAR attrOverflowY[] =
164 {'o','v','e','r','f','l','o','w','-','y',0};
165 static const WCHAR attrPadding[] =
166 {'p','a','d','d','i','n','g',0};
167 static const WCHAR attrPaddingBottom[] =
168 {'p','a','d','d','i','n','g','-','b','o','t','t','o','m',0};
169 static const WCHAR attrPaddingLeft[] =
170 {'p','a','d','d','i','n','g','-','l','e','f','t',0};
171 static const WCHAR attrPaddingRight[] =
172 {'p','a','d','d','i','n','g','-','r','i','g','h','t',0};
173 static const WCHAR attrPaddingTop[] =
174 {'p','a','d','d','i','n','g','-','t','o','p',0};
175 static const WCHAR attrPageBreakAfter[] =
176 {'p','a','g','e','-','b','r','e','a','k','-','a','f','t','e','r',0};
177 static const WCHAR attrPageBreakBefore[] =
178 {'p','a','g','e','-','b','r','e','a','k','-','b','e','f','o','r','e',0};
179 static const WCHAR attrPosition[] =
180 {'p','o','s','i','t','i','o','n',0};
181 static const WCHAR attrRight[] =
182 {'r','i','g','h','t',0};
183 static const WCHAR attrTableLayout[] =
184 {'t','a','b','l','e','-','l','a','y','o','u','t',0};
185 static const WCHAR attrTextAlign[] =
186 {'t','e','x','t','-','a','l','i','g','n',0};
187 static const WCHAR attrTextDecoration[] =
188 {'t','e','x','t','-','d','e','c','o','r','a','t','i','o','n',0};
189 static const WCHAR attrTextIndent[] =
190 {'t','e','x','t','-','i','n','d','e','n','t',0};
191 static const WCHAR attrTextTransform[] =
192 {'t','e','x','t','-','t','r','a','n','s','f','o','r','m',0};
193 static const WCHAR attrTop[] =
194 {'t','o','p',0};
195 static const WCHAR attrVerticalAlign[] =
196 {'v','e','r','t','i','c','a','l','-','a','l','i','g','n',0};
197 static const WCHAR attrVisibility[] =
198 {'v','i','s','i','b','i','l','i','t','y',0};
199 static const WCHAR attrWhiteSpace[] =
200 {'w','h','i','t','e','-','s','p','a','c','e',0};
201 static const WCHAR attrWidth[] =
202 {'w','i','d','t','h',0};
203 static const WCHAR attrWordSpacing[] =
204 {'w','o','r','d','-','s','p','a','c','i','n','g',0};
205 static const WCHAR attrWordWrap[] =
206 {'w','o','r','d','-','w','r','a','p',0};
207 static const WCHAR attrZIndex[] =
208 {'z','-','i','n','d','e','x',0};
211 static const WCHAR pxW[] = {'p','x',0};
213 typedef struct {
214 const WCHAR *name;
215 DISPID dispid;
216 } style_tbl_entry_t;
218 static const style_tbl_entry_t style_tbl[] = {
219 {attrBackground, DISPID_IHTMLSTYLE_BACKGROUND},
220 {attrBackgroundAttachment, DISPID_IHTMLSTYLE_BACKGROUNDATTACHMENT},
221 {attrBackgroundColor, DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
222 {attrBackgroundImage, DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
223 {attrBackgroundPosition, DISPID_IHTMLSTYLE_BACKGROUNDPOSITION},
224 {attrBackgroundPositionX, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONX},
225 {attrBackgroundPositionY, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
226 {attrBackgroundRepeat, DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
227 {attrBorder, DISPID_IHTMLSTYLE_BORDER},
228 {attrBorderBottom, DISPID_IHTMLSTYLE_BORDERBOTTOM},
229 {attrBorderBottomColor, DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR},
230 {attrBorderBottomStyle, DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
231 {attrBorderBottomWidth, DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
232 {attrBorderColor, DISPID_IHTMLSTYLE_BORDERCOLOR},
233 {attrBorderLeft, DISPID_IHTMLSTYLE_BORDERLEFT},
234 {attrBorderLeftColor, DISPID_IHTMLSTYLE_BORDERLEFTCOLOR},
235 {attrBorderLeftStyle, DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
236 {attrBorderLeftWidth, DISPID_IHTMLSTYLE_BORDERLEFTWIDTH},
237 {attrBorderRight, DISPID_IHTMLSTYLE_BORDERRIGHT},
238 {attrBorderRightColor, DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR},
239 {attrBorderRightStyle, DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
240 {attrBorderRightWidth, DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
241 {attrBorderStyle, DISPID_IHTMLSTYLE_BORDERSTYLE},
242 {attrBorderTop, DISPID_IHTMLSTYLE_BORDERTOP},
243 {attrBorderTopColor, DISPID_IHTMLSTYLE_BORDERTOPCOLOR},
244 {attrBorderTopStyle, DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
245 {attrBorderTopWidth, DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
246 {attrBorderWidth, DISPID_IHTMLSTYLE_BORDERWIDTH},
247 {attrBottom, DISPID_IHTMLSTYLE2_BOTTOM},
248 {attrBoxSizing, DISPID_IHTMLSTYLE6_BOXSIZING},
249 {attrClear, DISPID_IHTMLSTYLE_CLEAR},
250 {attrClip, DISPID_IHTMLSTYLE_CLIP},
251 {attrColor, DISPID_IHTMLSTYLE_COLOR},
252 {attrCursor, DISPID_IHTMLSTYLE_CURSOR},
253 {attrDirection, DISPID_IHTMLSTYLE2_DIRECTION},
254 {attrDisplay, DISPID_IHTMLSTYLE_DISPLAY},
255 {attrFilter, DISPID_IHTMLSTYLE_FILTER},
256 {attrFloat, DISPID_IHTMLSTYLE_STYLEFLOAT},
257 {attrFontFamily, DISPID_IHTMLSTYLE_FONTFAMILY},
258 {attrFontSize, DISPID_IHTMLSTYLE_FONTSIZE},
259 {attrFontStyle, DISPID_IHTMLSTYLE_FONTSTYLE},
260 {attrFontVariant, DISPID_IHTMLSTYLE_FONTVARIANT},
261 {attrFontWeight, DISPID_IHTMLSTYLE_FONTWEIGHT},
262 {attrHeight, DISPID_IHTMLSTYLE_HEIGHT},
263 {attrLeft, DISPID_IHTMLSTYLE_LEFT},
264 {attrLetterSpacing, DISPID_IHTMLSTYLE_LETTERSPACING},
265 {attrLineHeight, DISPID_IHTMLSTYLE_LINEHEIGHT},
266 {attrListStyle, DISPID_IHTMLSTYLE_LISTSTYLE},
267 {attrListStylePosition, DISPID_IHTMLSTYLE_LISTSTYLEPOSITION},
268 {attrListStyleType, DISPID_IHTMLSTYLE_LISTSTYLETYPE},
269 {attrMargin, DISPID_IHTMLSTYLE_MARGIN},
270 {attrMarginBottom, DISPID_IHTMLSTYLE_MARGINBOTTOM},
271 {attrMarginLeft, DISPID_IHTMLSTYLE_MARGINLEFT},
272 {attrMarginRight, DISPID_IHTMLSTYLE_MARGINRIGHT},
273 {attrMarginTop, DISPID_IHTMLSTYLE_MARGINTOP},
274 {attrMaxHeight, DISPID_IHTMLSTYLE5_MAXHEIGHT},
275 {attrMaxWidth, DISPID_IHTMLSTYLE5_MAXWIDTH},
276 {attrMinHeight, DISPID_IHTMLSTYLE4_MINHEIGHT},
277 {attrMinWidth, DISPID_IHTMLSTYLE5_MINWIDTH},
278 {attrOutline, DISPID_IHTMLSTYLE6_OUTLINE},
279 {attrOverflow, DISPID_IHTMLSTYLE_OVERFLOW},
280 {attrOverflowX, DISPID_IHTMLSTYLE2_OVERFLOWX},
281 {attrOverflowY, DISPID_IHTMLSTYLE2_OVERFLOWY},
282 {attrPadding, DISPID_IHTMLSTYLE_PADDING},
283 {attrPaddingBottom, DISPID_IHTMLSTYLE_PADDINGBOTTOM},
284 {attrPaddingLeft, DISPID_IHTMLSTYLE_PADDINGLEFT},
285 {attrPaddingRight, DISPID_IHTMLSTYLE_PADDINGRIGHT},
286 {attrPaddingTop, DISPID_IHTMLSTYLE_PADDINGTOP},
287 {attrPageBreakAfter, DISPID_IHTMLSTYLE_PAGEBREAKAFTER},
288 {attrPageBreakBefore, DISPID_IHTMLSTYLE_PAGEBREAKBEFORE},
289 {attrPosition, DISPID_IHTMLSTYLE2_POSITION},
290 {attrRight, DISPID_IHTMLSTYLE2_RIGHT},
291 {attrTableLayout, DISPID_IHTMLSTYLE2_TABLELAYOUT},
292 {attrTextAlign, DISPID_IHTMLSTYLE_TEXTALIGN},
293 {attrTextDecoration, DISPID_IHTMLSTYLE_TEXTDECORATION},
294 {attrTextIndent, DISPID_IHTMLSTYLE_TEXTINDENT},
295 {attrTextTransform, DISPID_IHTMLSTYLE_TEXTTRANSFORM},
296 {attrTop, DISPID_IHTMLSTYLE_TOP},
297 {attrVerticalAlign, DISPID_IHTMLSTYLE_VERTICALALIGN},
298 {attrVisibility, DISPID_IHTMLSTYLE_VISIBILITY},
299 {attrWhiteSpace, DISPID_IHTMLSTYLE_WHITESPACE},
300 {attrWidth, DISPID_IHTMLSTYLE_WIDTH},
301 {attrWordSpacing, DISPID_IHTMLSTYLE_WORDSPACING},
302 {attrWordWrap, DISPID_IHTMLSTYLE3_WORDWRAP},
303 {attrZIndex, DISPID_IHTMLSTYLE_ZINDEX}
306 C_ASSERT(sizeof(style_tbl)/sizeof(*style_tbl) == STYLEID_MAX_VALUE);
308 static const WCHAR valLineThrough[] =
309 {'l','i','n','e','-','t','h','r','o','u','g','h',0};
310 static const WCHAR valUnderline[] =
311 {'u','n','d','e','r','l','i','n','e',0};
312 static const WCHAR szNormal[] =
313 {'n','o','r','m','a','l',0};
314 static const WCHAR styleNone[] =
315 {'n','o','n','e',0};
316 static const WCHAR valOverline[] =
317 {'o','v','e','r','l','i','n','e',0};
318 static const WCHAR valBlink[] =
319 {'b','l','i','n','k',0};
321 static const WCHAR px_formatW[] = {'%','d','p','x',0};
322 static const WCHAR emptyW[] = {0};
324 static const style_tbl_entry_t *lookup_style_tbl(const WCHAR *name)
326 int c, i, min = 0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
328 while(min <= max) {
329 i = (min+max)/2;
331 c = strcmpW(style_tbl[i].name, name);
332 if(!c)
333 return style_tbl+i;
335 if(c > 0)
336 max = i-1;
337 else
338 min = i+1;
341 return NULL;
344 static LPWSTR fix_px_value(LPCWSTR val)
346 LPCWSTR ptr = val;
348 while(*ptr) {
349 while(*ptr && isspaceW(*ptr))
350 ptr++;
351 if(!*ptr)
352 break;
354 while(*ptr && isdigitW(*ptr))
355 ptr++;
357 if(!*ptr || isspaceW(*ptr)) {
358 LPWSTR ret, p;
359 int len = strlenW(val)+1;
361 ret = heap_alloc((len+2)*sizeof(WCHAR));
362 memcpy(ret, val, (ptr-val)*sizeof(WCHAR));
363 p = ret + (ptr-val);
364 *p++ = 'p';
365 *p++ = 'x';
366 strcpyW(p, ptr);
368 TRACE("fixed %s -> %s\n", debugstr_w(val), debugstr_w(ret));
370 return ret;
373 while(*ptr && !isspaceW(*ptr))
374 ptr++;
377 return NULL;
380 static LPWSTR fix_url_value(LPCWSTR val)
382 WCHAR *ret, *ptr;
384 static const WCHAR urlW[] = {'u','r','l','('};
386 if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
387 return NULL;
389 ret = heap_strdupW(val);
391 for(ptr = ret; *ptr; ptr++) {
392 if(*ptr == '\\')
393 *ptr = '/';
396 return ret;
399 HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, const WCHAR *value, DWORD flags)
401 nsAString str_name, str_value, str_empty;
402 LPWSTR val = NULL;
403 nsresult nsres;
405 if(value) {
406 if(flags & ATTR_FIX_PX)
407 val = fix_px_value(value);
408 if(flags & ATTR_FIX_URL)
409 val = fix_url_value(value);
412 nsAString_InitDepend(&str_name, style_tbl[sid].name);
413 nsAString_InitDepend(&str_value, val ? val : value);
414 nsAString_InitDepend(&str_empty, emptyW);
416 nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
417 if(NS_FAILED(nsres))
418 ERR("SetProperty failed: %08x\n", nsres);
420 nsAString_Finish(&str_name);
421 nsAString_Finish(&str_value);
422 nsAString_Finish(&str_empty);
423 heap_free(val);
425 return S_OK;
428 static HRESULT var_to_styleval(const VARIANT *v, WCHAR *buf, DWORD flags, const WCHAR **ret)
430 switch(V_VT(v)) {
431 case VT_NULL:
432 *ret = emptyW;
433 return S_OK;
435 case VT_BSTR:
436 *ret = V_BSTR(v);
437 return S_OK;
439 case VT_BSTR|VT_BYREF:
440 *ret = *V_BSTRREF(v);
441 return S_OK;
443 case VT_I4: {
444 static const WCHAR formatW[] = {'%','d',0};
445 static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
447 if(flags & ATTR_HEX_INT)
448 wsprintfW(buf, hex_formatW, V_I4(v));
449 else if(flags & ATTR_FIX_PX)
450 wsprintfW(buf, px_formatW, V_I4(v));
451 else
452 wsprintfW(buf, formatW, V_I4(v));
454 *ret = buf;
455 return S_OK;
457 default:
458 FIXME("not implemented for %s\n", debugstr_variant(v));
459 return E_NOTIMPL;
464 HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *value, DWORD flags)
466 const WCHAR *val;
467 WCHAR buf[14];
468 HRESULT hres;
470 hres = var_to_styleval(value, buf, flags, &val);
471 if(FAILED(hres))
472 return hres;
474 return set_nsstyle_attr(nsstyle, sid, val, flags);
477 static inline HRESULT set_style_attr(HTMLStyle *This, styleid_t sid, LPCWSTR value, DWORD flags)
479 return set_nsstyle_attr(This->nsstyle, sid, value, flags);
482 static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, nsAString *value)
484 nsAString str_name;
485 nsresult nsres;
487 nsAString_InitDepend(&str_name, style_tbl[sid].name);
489 nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
490 if(NS_FAILED(nsres)) {
491 ERR("SetProperty failed: %08x\n", nsres);
492 return E_FAIL;
495 nsAString_Finish(&str_name);
497 return NS_OK;
500 static HRESULT nsstyle_to_bstr(const WCHAR *val, DWORD flags, BSTR *p)
502 BSTR ret;
503 DWORD len;
505 if(!*val) {
506 *p = (flags & ATTR_NO_NULL) ? SysAllocStringLen(NULL, 0) : NULL;
507 return S_OK;
510 ret = SysAllocString(val);
511 if(!ret)
512 return E_OUTOFMEMORY;
514 len = SysStringLen(ret);
516 if(flags & ATTR_REMOVE_COMMA) {
517 DWORD new_len = len;
518 WCHAR *ptr, *ptr2;
520 for(ptr = ret; (ptr = strchrW(ptr, ',')); ptr++)
521 new_len--;
523 if(new_len != len) {
524 BSTR new_ret;
526 new_ret = SysAllocStringLen(NULL, new_len);
527 if(!new_ret) {
528 SysFreeString(ret);
529 return E_OUTOFMEMORY;
532 for(ptr2 = new_ret, ptr = ret; *ptr; ptr++) {
533 if(*ptr != ',')
534 *ptr2++ = *ptr;
537 SysFreeString(ret);
538 ret = new_ret;
542 *p = ret;
543 return S_OK;
546 HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR *p, DWORD flags)
548 nsAString str_value;
549 const PRUnichar *value;
550 HRESULT hres;
552 nsAString_Init(&str_value, NULL);
554 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
556 nsAString_GetData(&str_value, &value);
557 hres = nsstyle_to_bstr(value, flags, p);
558 nsAString_Finish(&str_value);
560 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_w(*p));
561 return hres;
564 HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
566 nsAString str_value;
567 const PRUnichar *value;
568 BOOL set = FALSE;
569 HRESULT hres = S_OK;
571 nsAString_Init(&str_value, NULL);
573 get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
575 nsAString_GetData(&str_value, &value);
577 if(flags & ATTR_STR_TO_INT) {
578 const PRUnichar *ptr = value;
579 BOOL neg = FALSE;
580 INT i = 0;
582 if(*ptr == '-') {
583 neg = TRUE;
584 ptr++;
587 while(isdigitW(*ptr))
588 i = i*10 + (*ptr++ - '0');
590 if(!*ptr) {
591 V_VT(p) = VT_I4;
592 V_I4(p) = neg ? -i : i;
593 set = TRUE;
597 if(!set) {
598 BSTR str;
600 hres = nsstyle_to_bstr(value, flags, &str);
601 if(SUCCEEDED(hres)) {
602 V_VT(p) = VT_BSTR;
603 V_BSTR(p) = str;
607 nsAString_Finish(&str_value);
609 TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_variant(p));
610 return S_OK;
613 static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
615 return get_nsstyle_attr(This->nsstyle, sid, p, 0);
618 static HRESULT check_style_attr_value(HTMLStyle *This, styleid_t sid, LPCWSTR exval, VARIANT_BOOL *p)
620 nsAString str_value;
621 const PRUnichar *value;
623 nsAString_Init(&str_value, NULL);
625 get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
627 nsAString_GetData(&str_value, &value);
628 *p = strcmpW(value, exval) ? VARIANT_FALSE : VARIANT_TRUE;
629 nsAString_Finish(&str_value);
631 TRACE("%s -> %x\n", debugstr_w(style_tbl[sid].name), *p);
632 return S_OK;
635 static inline HRESULT set_style_pos(HTMLStyle *This, styleid_t sid, float value)
637 WCHAR szValue[25];
638 WCHAR szFormat[] = {'%','.','0','f','p','x',0};
640 value = floor(value);
642 sprintfW(szValue, szFormat, value);
644 return set_style_attr(This, sid, szValue, 0);
647 static HRESULT set_style_pxattr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LONG value)
649 WCHAR value_str[16];
651 sprintfW(value_str, px_formatW, value);
653 return set_nsstyle_attr(nsstyle, sid, value_str, 0);
656 static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p)
658 nsAString str_value;
659 HRESULT hres;
661 TRACE("%p %d %p\n", This, sid, p);
663 *p = 0.0f;
665 nsAString_Init(&str_value, NULL);
667 hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
668 if(hres == S_OK)
670 WCHAR *ptr;
671 const PRUnichar *value;
673 nsAString_GetData(&str_value, &value);
674 if(value)
676 *p = strtolW(value, &ptr, 10);
678 if(*ptr && strcmpW(ptr, pxW))
680 nsAString_Finish(&str_value);
681 FIXME("only px values are currently supported\n");
682 hres = E_FAIL;
687 TRACE("ret %f\n", *p);
689 nsAString_Finish(&str_value);
690 return hres;
693 static HRESULT get_nsstyle_pixel_val(HTMLStyle *This, styleid_t sid, LONG *p)
695 nsAString str_value;
696 HRESULT hres;
698 if(!p)
699 return E_POINTER;
701 nsAString_Init(&str_value, NULL);
703 hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
704 if(hres == S_OK) {
705 WCHAR *ptr;
706 const PRUnichar *value;
708 nsAString_GetData(&str_value, &value);
709 if(value) {
710 *p = strtolW(value, &ptr, 10);
712 if(*ptr == '.') {
713 /* Skip all digits. We have tests showing that we should not round the value. */
714 while(isdigitW(*++ptr));
717 if(*ptr && strcmpW(ptr, pxW)) {
718 nsAString_Finish(&str_value);
719 FIXME("%s: only px values are currently supported\n", debugstr_w(value));
720 hres = E_NOTIMPL;
722 }else {
723 *p = 0;
727 nsAString_Finish(&str_value);
728 return hres;
731 static BOOL is_valid_border_style(BSTR v)
733 static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0};
734 static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0};
735 static const WCHAR styleSolid[] = {'s','o','l','i','d',0};
736 static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0};
737 static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0};
738 static const WCHAR styleRidge[] = {'r','i','d','g','e',0};
739 static const WCHAR styleInset[] = {'i','n','s','e','t',0};
740 static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0};
742 TRACE("%s\n", debugstr_w(v));
744 if(!v || strcmpiW(v, styleNone) == 0 || strcmpiW(v, styleDotted) == 0 ||
745 strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid) == 0 ||
746 strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 ||
747 strcmpiW(v, styleRidge) == 0 || strcmpiW(v, styleInset) == 0 ||
748 strcmpiW(v, styleOutset) == 0 )
750 return TRUE;
753 return FALSE;
756 static inline HTMLStyle *impl_from_IHTMLStyle(IHTMLStyle *iface)
758 return CONTAINING_RECORD(iface, HTMLStyle, IHTMLStyle_iface);
761 static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv)
763 HTMLStyle *This = impl_from_IHTMLStyle(iface);
765 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
767 if(IsEqualGUID(&IID_IUnknown, riid)) {
768 *ppv = &This->IHTMLStyle_iface;
769 }else if(IsEqualGUID(&IID_IHTMLStyle, riid)) {
770 *ppv = &This->IHTMLStyle_iface;
771 }else if(IsEqualGUID(&IID_IHTMLStyle2, riid)) {
772 *ppv = &This->IHTMLStyle2_iface;
773 }else if(IsEqualGUID(&IID_IHTMLStyle3, riid)) {
774 *ppv = &This->IHTMLStyle3_iface;
775 }else if(IsEqualGUID(&IID_IHTMLStyle4, riid)) {
776 *ppv = &This->IHTMLStyle4_iface;
777 }else if(IsEqualGUID(&IID_IHTMLStyle5, riid)) {
778 *ppv = &This->IHTMLStyle5_iface;
779 }else if(IsEqualGUID(&IID_IHTMLStyle6, riid)) {
780 *ppv = &This->IHTMLStyle6_iface;
781 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
782 return *ppv ? S_OK : E_NOINTERFACE;
783 }else {
784 *ppv = NULL;
785 WARN("unsupported iface %s\n", debugstr_mshtml_guid(riid));
786 return E_NOINTERFACE;
789 IUnknown_AddRef((IUnknown*)*ppv);
790 return S_OK;
793 static ULONG WINAPI HTMLStyle_AddRef(IHTMLStyle *iface)
795 HTMLStyle *This = impl_from_IHTMLStyle(iface);
796 LONG ref = InterlockedIncrement(&This->ref);
798 TRACE("(%p) ref=%d\n", This, ref);
800 return ref;
803 static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
805 HTMLStyle *This = impl_from_IHTMLStyle(iface);
806 LONG ref = InterlockedDecrement(&This->ref);
808 TRACE("(%p) ref=%d\n", This, ref);
810 if(!ref) {
811 assert(!This->elem);
812 if(This->nsstyle)
813 nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
814 release_dispex(&This->dispex);
815 heap_free(This);
818 return ref;
821 static HRESULT WINAPI HTMLStyle_GetTypeInfoCount(IHTMLStyle *iface, UINT *pctinfo)
823 HTMLStyle *This = impl_from_IHTMLStyle(iface);
824 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
827 static HRESULT WINAPI HTMLStyle_GetTypeInfo(IHTMLStyle *iface, UINT iTInfo,
828 LCID lcid, ITypeInfo **ppTInfo)
830 HTMLStyle *This = impl_from_IHTMLStyle(iface);
831 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
834 static HRESULT WINAPI HTMLStyle_GetIDsOfNames(IHTMLStyle *iface, REFIID riid,
835 LPOLESTR *rgszNames, UINT cNames,
836 LCID lcid, DISPID *rgDispId)
838 HTMLStyle *This = impl_from_IHTMLStyle(iface);
839 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
840 lcid, rgDispId);
843 static HRESULT WINAPI HTMLStyle_Invoke(IHTMLStyle *iface, DISPID dispIdMember,
844 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
845 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
847 HTMLStyle *This = impl_from_IHTMLStyle(iface);
848 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
849 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
852 static HRESULT WINAPI HTMLStyle_put_fontFamily(IHTMLStyle *iface, BSTR v)
854 HTMLStyle *This = impl_from_IHTMLStyle(iface);
856 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
858 return set_style_attr(This, STYLEID_FONT_FAMILY, v, 0);
861 static HRESULT WINAPI HTMLStyle_get_fontFamily(IHTMLStyle *iface, BSTR *p)
863 HTMLStyle *This = impl_from_IHTMLStyle(iface);
865 TRACE("(%p)->(%p)\n", This, p);
867 return get_style_attr(This, STYLEID_FONT_FAMILY, p);
870 static HRESULT WINAPI HTMLStyle_put_fontStyle(IHTMLStyle *iface, BSTR v)
872 HTMLStyle *This = impl_from_IHTMLStyle(iface);
873 static const WCHAR szItalic[] = {'i','t','a','l','i','c',0};
874 static const WCHAR szOblique[] = {'o','b','l','i','q','u','e',0};
876 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
878 /* fontStyle can only be one of the follow values. */
879 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szItalic, v) == 0 ||
880 strcmpiW(szOblique, v) == 0)
882 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, v, 0);
885 return E_INVALIDARG;
888 static HRESULT WINAPI HTMLStyle_get_fontStyle(IHTMLStyle *iface, BSTR *p)
890 HTMLStyle *This = impl_from_IHTMLStyle(iface);
892 TRACE("(%p)->(%p)\n", This, p);
894 return get_style_attr(This, STYLEID_FONT_STYLE, p);
897 static HRESULT WINAPI HTMLStyle_put_fontVariant(IHTMLStyle *iface, BSTR v)
899 HTMLStyle *This = impl_from_IHTMLStyle(iface);
900 static const WCHAR szCaps[] = {'s','m','a','l','l','-','c','a','p','s',0};
902 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
904 /* fontVariant can only be one of the follow values. */
905 if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szCaps, v) == 0)
907 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, v, 0);
910 return E_INVALIDARG;
913 static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p)
915 HTMLStyle *This = impl_from_IHTMLStyle(iface);
916 TRACE("(%p)->(%p)\n", This, p);
918 if(!p)
919 return E_INVALIDARG;
921 return get_style_attr(This, STYLEID_FONT_VARIANT, p);
924 static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v)
926 HTMLStyle *This = impl_from_IHTMLStyle(iface);
927 static const WCHAR styleBold[] = {'b','o','l','d',0};
928 static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0};
929 static const WCHAR styleLighter[] = {'l','i','g','h','t','e','r',0};
930 static const WCHAR style100[] = {'1','0','0',0};
931 static const WCHAR style200[] = {'2','0','0',0};
932 static const WCHAR style300[] = {'3','0','0',0};
933 static const WCHAR style400[] = {'4','0','0',0};
934 static const WCHAR style500[] = {'5','0','0',0};
935 static const WCHAR style600[] = {'6','0','0',0};
936 static const WCHAR style700[] = {'7','0','0',0};
937 static const WCHAR style800[] = {'8','0','0',0};
938 static const WCHAR style900[] = {'9','0','0',0};
940 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
942 /* fontWeight can only be one of the following */
943 if(v && *v && strcmpiW(szNormal, v) && strcmpiW(styleBold, v) && strcmpiW(styleBolder, v)
944 && strcmpiW(styleLighter, v) && strcmpiW(style100, v) && strcmpiW(style200, v)
945 && strcmpiW(style300, v) && strcmpiW(style400, v) && strcmpiW(style500, v) && strcmpiW(style600, v)
946 && strcmpiW(style700, v) && strcmpiW(style800, v) && strcmpiW(style900, v))
947 return E_INVALIDARG;
949 return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0);
952 static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p)
954 HTMLStyle *This = impl_from_IHTMLStyle(iface);
956 TRACE("(%p)->(%p)\n", This, p);
958 return get_style_attr(This, STYLEID_FONT_WEIGHT, p);
961 static HRESULT WINAPI HTMLStyle_put_fontSize(IHTMLStyle *iface, VARIANT v)
963 HTMLStyle *This = impl_from_IHTMLStyle(iface);
965 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
967 return set_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, &v, ATTR_FIX_PX);
970 static HRESULT WINAPI HTMLStyle_get_fontSize(IHTMLStyle *iface, VARIANT *p)
972 HTMLStyle *This = impl_from_IHTMLStyle(iface);
974 TRACE("(%p)->(%p)\n", This, p);
976 return get_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, p, 0);
979 static HRESULT WINAPI HTMLStyle_put_font(IHTMLStyle *iface, BSTR v)
981 HTMLStyle *This = impl_from_IHTMLStyle(iface);
982 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
983 return E_NOTIMPL;
986 static HRESULT WINAPI HTMLStyle_get_font(IHTMLStyle *iface, BSTR *p)
988 HTMLStyle *This = impl_from_IHTMLStyle(iface);
989 FIXME("(%p)->(%p)\n", This, p);
990 return E_NOTIMPL;
993 static HRESULT WINAPI HTMLStyle_put_color(IHTMLStyle *iface, VARIANT v)
995 HTMLStyle *This = impl_from_IHTMLStyle(iface);
997 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
999 return set_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, &v, ATTR_HEX_INT);
1002 static HRESULT WINAPI HTMLStyle_get_color(IHTMLStyle *iface, VARIANT *p)
1004 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1006 TRACE("(%p)->(%p)\n", This, p);
1008 return get_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, p, 0);
1011 static HRESULT WINAPI HTMLStyle_put_background(IHTMLStyle *iface, BSTR v)
1013 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1015 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1017 return set_style_attr(This, STYLEID_BACKGROUND, v, 0);
1020 static HRESULT WINAPI HTMLStyle_get_background(IHTMLStyle *iface, BSTR *p)
1022 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1024 TRACE("(%p)->(%p)\n", This, p);
1026 return get_style_attr(This, STYLEID_BACKGROUND, p);
1029 static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v)
1031 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1033 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1035 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, &v, ATTR_HEX_INT);
1038 static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
1040 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1042 TRACE("(%p)->(%p)\n", This, p);
1044 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, p, 0);
1047 static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
1049 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1051 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1053 return set_style_attr(This, STYLEID_BACKGROUND_IMAGE, v, ATTR_FIX_URL);
1056 static HRESULT WINAPI HTMLStyle_get_backgroundImage(IHTMLStyle *iface, BSTR *p)
1058 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1060 TRACE("(%p)->(%p)\n", This, p);
1062 return get_style_attr(This, STYLEID_BACKGROUND_IMAGE, p);
1065 static HRESULT WINAPI HTMLStyle_put_backgroundRepeat(IHTMLStyle *iface, BSTR v)
1067 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1068 static const WCHAR styleRepeat[] = {'r','e','p','e','a','t',0};
1069 static const WCHAR styleNoRepeat[] = {'n','o','-','r','e','p','e','a','t',0};
1070 static const WCHAR styleRepeatX[] = {'r','e','p','e','a','t','-','x',0};
1071 static const WCHAR styleRepeatY[] = {'r','e','p','e','a','t','-','y',0};
1073 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1075 /* fontWeight can only be one of the following */
1076 if(!v || strcmpiW(styleRepeat, v) == 0 || strcmpiW(styleNoRepeat, v) == 0 ||
1077 strcmpiW(styleRepeatX, v) == 0 || strcmpiW(styleRepeatY, v) == 0 )
1079 return set_style_attr(This, STYLEID_BACKGROUND_REPEAT , v, 0);
1082 return E_INVALIDARG;
1085 static HRESULT WINAPI HTMLStyle_get_backgroundRepeat(IHTMLStyle *iface, BSTR *p)
1087 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1089 TRACE("(%p)->(%p)\n", This, p);
1091 return get_style_attr(This, STYLEID_BACKGROUND_REPEAT, p);
1094 static HRESULT WINAPI HTMLStyle_put_backgroundAttachment(IHTMLStyle *iface, BSTR v)
1096 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1098 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1100 return set_style_attr(This, STYLEID_BACKGROUND_ATTACHMENT, v, 0);
1103 static HRESULT WINAPI HTMLStyle_get_backgroundAttachment(IHTMLStyle *iface, BSTR *p)
1105 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1107 TRACE("(%p)->(%p)\n", This, p);
1109 return get_style_attr(This, STYLEID_BACKGROUND_ATTACHMENT, p);
1112 static HRESULT WINAPI HTMLStyle_put_backgroundPosition(IHTMLStyle *iface, BSTR v)
1114 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1116 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1118 return set_style_attr(This, STYLEID_BACKGROUND_POSITION, v, 0);
1121 static HRESULT WINAPI HTMLStyle_get_backgroundPosition(IHTMLStyle *iface, BSTR *p)
1123 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1125 TRACE("(%p)->(%p)\n", This, p);
1127 return get_style_attr(This, STYLEID_BACKGROUND_POSITION, p);
1130 static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIANT v)
1132 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1133 WCHAR buf[14], *pos_val;
1134 nsAString pos_str;
1135 const WCHAR *val;
1136 DWORD val_len;
1137 HRESULT hres;
1139 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1141 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1142 if(FAILED(hres))
1143 return hres;
1145 val_len = val ? strlenW(val) : 0;
1147 nsAString_Init(&pos_str, NULL);
1148 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1149 if(SUCCEEDED(hres)) {
1150 const PRUnichar *pos, *posy;
1151 DWORD posy_len;
1153 nsAString_GetData(&pos_str, &pos);
1154 posy = strchrW(pos, ' ');
1155 if(!posy) {
1156 static const WCHAR zero_pxW[] = {' ','0','p','x',0};
1158 TRACE("no space in %s\n", debugstr_w(pos));
1159 posy = zero_pxW;
1162 posy_len = strlenW(posy);
1163 pos_val = heap_alloc((val_len+posy_len+1)*sizeof(WCHAR));
1164 if(pos_val) {
1165 if(val_len)
1166 memcpy(pos_val, val, val_len*sizeof(WCHAR));
1167 if(posy_len)
1168 memcpy(pos_val+val_len, posy, posy_len*sizeof(WCHAR));
1169 pos_val[val_len+posy_len] = 0;
1170 }else {
1171 hres = E_OUTOFMEMORY;
1174 nsAString_Finish(&pos_str);
1175 if(FAILED(hres))
1176 return hres;
1178 TRACE("setting position to %s\n", debugstr_w(pos_val));
1179 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1180 heap_free(pos_val);
1181 return hres;
1184 static HRESULT WINAPI HTMLStyle_get_backgroundPositionX(IHTMLStyle *iface, VARIANT *p)
1186 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1187 nsAString pos_str;
1188 BSTR ret;
1189 HRESULT hres;
1191 TRACE("(%p)->(%p)\n", This, p);
1193 nsAString_Init(&pos_str, NULL);
1194 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1195 if(SUCCEEDED(hres)) {
1196 const PRUnichar *pos, *space;
1198 nsAString_GetData(&pos_str, &pos);
1199 space = strchrW(pos, ' ');
1200 if(!space) {
1201 WARN("no space in %s\n", debugstr_w(pos));
1202 space = pos + strlenW(pos);
1205 if(space != pos) {
1206 ret = SysAllocStringLen(pos, space-pos);
1207 if(!ret)
1208 hres = E_OUTOFMEMORY;
1209 }else {
1210 ret = NULL;
1213 nsAString_Finish(&pos_str);
1214 if(FAILED(hres))
1215 return hres;
1217 TRACE("returning %s\n", debugstr_w(ret));
1218 V_VT(p) = VT_BSTR;
1219 V_BSTR(p) = ret;
1220 return S_OK;
1223 static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIANT v)
1225 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1226 WCHAR buf[14], *pos_val;
1227 nsAString pos_str;
1228 const WCHAR *val;
1229 DWORD val_len;
1230 HRESULT hres;
1232 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1234 hres = var_to_styleval(&v, buf, ATTR_FIX_PX, &val);
1235 if(FAILED(hres))
1236 return hres;
1238 val_len = val ? strlenW(val) : 0;
1240 nsAString_Init(&pos_str, NULL);
1241 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1242 if(SUCCEEDED(hres)) {
1243 const PRUnichar *pos, *space;
1244 DWORD posx_len;
1246 nsAString_GetData(&pos_str, &pos);
1247 space = strchrW(pos, ' ');
1248 if(space) {
1249 space++;
1250 }else {
1251 static const WCHAR zero_pxW[] = {'0','p','x',' ',0};
1253 TRACE("no space in %s\n", debugstr_w(pos));
1254 pos = zero_pxW;
1255 space = pos + sizeof(zero_pxW)/sizeof(WCHAR)-1;
1258 posx_len = space-pos;
1260 pos_val = heap_alloc((posx_len+val_len+1)*sizeof(WCHAR));
1261 if(pos_val) {
1262 memcpy(pos_val, pos, posx_len*sizeof(WCHAR));
1263 if(val_len)
1264 memcpy(pos_val+posx_len, val, val_len*sizeof(WCHAR));
1265 pos_val[posx_len+val_len] = 0;
1266 }else {
1267 hres = E_OUTOFMEMORY;
1270 nsAString_Finish(&pos_str);
1271 if(FAILED(hres))
1272 return hres;
1274 TRACE("setting position to %s\n", debugstr_w(pos_val));
1275 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_POSITION, pos_val, ATTR_FIX_PX);
1276 heap_free(pos_val);
1277 return hres;
1280 static HRESULT WINAPI HTMLStyle_get_backgroundPositionY(IHTMLStyle *iface, VARIANT *p)
1282 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1283 nsAString pos_str;
1284 BSTR ret;
1285 HRESULT hres;
1287 TRACE("(%p)->(%p)\n", This, p);
1289 nsAString_Init(&pos_str, NULL);
1290 hres = get_nsstyle_attr_nsval(This->nsstyle, STYLEID_BACKGROUND_POSITION, &pos_str);
1291 if(SUCCEEDED(hres)) {
1292 const PRUnichar *pos, *posy;
1294 nsAString_GetData(&pos_str, &pos);
1295 posy = strchrW(pos, ' ');
1296 if(posy) {
1297 ret = SysAllocString(posy+1);
1298 if(!ret)
1299 hres = E_OUTOFMEMORY;
1300 }else {
1301 ret = NULL;
1304 nsAString_Finish(&pos_str);
1305 if(FAILED(hres))
1306 return hres;
1308 TRACE("returning %s\n", debugstr_w(ret));
1309 V_VT(p) = VT_BSTR;
1310 V_BSTR(p) = ret;
1311 return S_OK;
1314 static HRESULT WINAPI HTMLStyle_put_wordSpacing(IHTMLStyle *iface, VARIANT v)
1316 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1318 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1320 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, &v, 0);
1323 static HRESULT WINAPI HTMLStyle_get_wordSpacing(IHTMLStyle *iface, VARIANT *p)
1325 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1326 TRACE("(%p)->(%p)\n", This, p);
1327 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WORD_SPACING, p, 0);
1330 static HRESULT WINAPI HTMLStyle_put_letterSpacing(IHTMLStyle *iface, VARIANT v)
1332 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1334 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1336 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, &v, 0);
1339 static HRESULT WINAPI HTMLStyle_get_letterSpacing(IHTMLStyle *iface, VARIANT *p)
1341 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1342 TRACE("(%p)->(%p)\n", This, p);
1343 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, p, 0);
1346 static HRESULT WINAPI HTMLStyle_put_textDecoration(IHTMLStyle *iface, BSTR v)
1348 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1350 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1352 /* textDecoration can only be one of the following */
1353 if(!v || strcmpiW(styleNone, v) == 0 || strcmpiW(valUnderline, v) == 0 ||
1354 strcmpiW(valOverline, v) == 0 || strcmpiW(valLineThrough, v) == 0 ||
1355 strcmpiW(valBlink, v) == 0)
1357 return set_style_attr(This, STYLEID_TEXT_DECORATION , v, 0);
1360 return E_INVALIDARG;
1363 static HRESULT WINAPI HTMLStyle_get_textDecoration(IHTMLStyle *iface, BSTR *p)
1365 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1367 TRACE("(%p)->(%p)\n", This, p);
1369 return get_style_attr(This, STYLEID_TEXT_DECORATION, p);
1372 static HRESULT WINAPI HTMLStyle_put_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL v)
1374 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1376 TRACE("(%p)->(%x)\n", This, v);
1378 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? styleNone : emptyW, 0);
1381 static HRESULT WINAPI HTMLStyle_get_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL *p)
1383 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1385 TRACE("(%p)->(%p)\n", This, p);
1387 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, styleNone, p);
1390 static HRESULT WINAPI HTMLStyle_put_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL v)
1392 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1394 TRACE("(%p)->(%x)\n", This, v);
1396 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valUnderline : emptyW, 0);
1399 static HRESULT WINAPI HTMLStyle_get_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL *p)
1401 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1403 TRACE("(%p)->(%p)\n", This, p);
1405 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valUnderline, p);
1408 static HRESULT WINAPI HTMLStyle_put_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL v)
1410 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1412 TRACE("(%p)->(%x)\n", This, v);
1414 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valOverline : emptyW, 0);
1417 static HRESULT WINAPI HTMLStyle_get_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL *p)
1419 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1421 TRACE("(%p)->(%p)\n", This, p);
1423 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valOverline, p);
1426 static HRESULT WINAPI HTMLStyle_put_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL v)
1428 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1430 TRACE("(%p)->(%x)\n", This, v);
1432 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valLineThrough : emptyW, 0);
1435 static HRESULT WINAPI HTMLStyle_get_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL *p)
1437 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1439 TRACE("(%p)->(%p)\n", This, p);
1441 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valLineThrough, p);
1444 static HRESULT WINAPI HTMLStyle_put_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL v)
1446 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1448 TRACE("(%p)->(%x)\n", This, v);
1450 return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valBlink : emptyW, 0);
1453 static HRESULT WINAPI HTMLStyle_get_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL *p)
1455 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1457 TRACE("(%p)->(%p)\n", This, p);
1459 return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valBlink, p);
1462 static HRESULT WINAPI HTMLStyle_put_verticalAlign(IHTMLStyle *iface, VARIANT v)
1464 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1466 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1468 return set_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, &v, ATTR_FIX_PX);
1471 static HRESULT WINAPI HTMLStyle_get_verticalAlign(IHTMLStyle *iface, VARIANT *p)
1473 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1475 TRACE("(%p)->(%p)\n", This, p);
1477 return get_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, p, 0);
1480 static HRESULT WINAPI HTMLStyle_put_textTransform(IHTMLStyle *iface, BSTR v)
1482 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1484 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1486 return set_style_attr(This, STYLEID_TEXT_TRANSFORM, v, 0);
1489 static HRESULT WINAPI HTMLStyle_get_textTransform(IHTMLStyle *iface, BSTR *p)
1491 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1493 TRACE("(%p)->(%p)\n", This, p);
1495 return get_style_attr(This, STYLEID_TEXT_TRANSFORM, p);
1498 static HRESULT WINAPI HTMLStyle_put_textAlign(IHTMLStyle *iface, BSTR v)
1500 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1502 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1504 return set_style_attr(This, STYLEID_TEXT_ALIGN, v, 0);
1507 static HRESULT WINAPI HTMLStyle_get_textAlign(IHTMLStyle *iface, BSTR *p)
1509 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1511 TRACE("(%p)->(%p)\n", This, p);
1513 return get_style_attr(This, STYLEID_TEXT_ALIGN, p);
1516 static HRESULT WINAPI HTMLStyle_put_textIndent(IHTMLStyle *iface, VARIANT v)
1518 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1520 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1522 return set_nsstyle_attr_var(This->nsstyle, STYLEID_TEXT_INDENT, &v, ATTR_FIX_PX);
1525 static HRESULT WINAPI HTMLStyle_get_textIndent(IHTMLStyle *iface, VARIANT *p)
1527 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1529 TRACE("(%p)->(%p)\n", This, p);
1531 return get_nsstyle_attr_var(This->nsstyle, STYLEID_TEXT_INDENT, p, 0);
1534 static HRESULT WINAPI HTMLStyle_put_lineHeight(IHTMLStyle *iface, VARIANT v)
1536 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1538 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1540 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LINE_HEIGHT, &v, 0);
1543 static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
1545 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1547 TRACE("(%p)->(%p)\n", This, p);
1549 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LINE_HEIGHT, p, 0);
1552 static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
1554 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1556 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1558 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, &v, ATTR_FIX_PX);
1561 static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
1563 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1565 TRACE("(%p)->(%p)\n", This, p);
1567 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
1570 static HRESULT WINAPI HTMLStyle_put_marginRight(IHTMLStyle *iface, VARIANT v)
1572 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1574 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1576 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, &v, ATTR_FIX_PX);
1579 static HRESULT WINAPI HTMLStyle_get_marginRight(IHTMLStyle *iface, VARIANT *p)
1581 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1582 TRACE("(%p)->(%p)\n", This, p);
1583 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
1586 static HRESULT WINAPI HTMLStyle_put_marginBottom(IHTMLStyle *iface, VARIANT v)
1588 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1590 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1592 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, &v, ATTR_FIX_PX);
1595 static HRESULT WINAPI HTMLStyle_get_marginBottom(IHTMLStyle *iface, VARIANT *p)
1597 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1599 TRACE("(%p)->(%p)\n", This, p);
1601 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, p, 0);
1604 static HRESULT WINAPI HTMLStyle_put_marginLeft(IHTMLStyle *iface, VARIANT v)
1606 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1608 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1610 return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, &v, ATTR_FIX_PX);
1613 static HRESULT WINAPI HTMLStyle_put_margin(IHTMLStyle *iface, BSTR v)
1615 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1617 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1619 return set_style_attr(This, STYLEID_MARGIN, v, 0);
1622 static HRESULT WINAPI HTMLStyle_get_margin(IHTMLStyle *iface, BSTR *p)
1624 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1626 TRACE("(%p)->(%p)\n", This, p);
1628 return get_style_attr(This, STYLEID_MARGIN, p);
1631 static HRESULT WINAPI HTMLStyle_get_marginLeft(IHTMLStyle *iface, VARIANT *p)
1633 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1634 TRACE("(%p)->(%p)\n", This, p);
1635 return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
1638 static HRESULT WINAPI HTMLStyle_put_paddingTop(IHTMLStyle *iface, VARIANT v)
1640 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1642 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1644 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, &v, ATTR_FIX_PX);
1647 static HRESULT WINAPI HTMLStyle_get_paddingTop(IHTMLStyle *iface, VARIANT *p)
1649 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1651 TRACE("(%p)->(%p)\n", This, p);
1653 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, p, 0);
1656 static HRESULT WINAPI HTMLStyle_put_paddingRight(IHTMLStyle *iface, VARIANT v)
1658 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1660 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1662 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, &v, ATTR_FIX_PX);
1665 static HRESULT WINAPI HTMLStyle_get_paddingRight(IHTMLStyle *iface, VARIANT *p)
1667 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1669 TRACE("(%p)->(%p)\n", This, p);
1671 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, p, 0);
1674 static HRESULT WINAPI HTMLStyle_put_paddingBottom(IHTMLStyle *iface, VARIANT v)
1676 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1678 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1680 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, &v, ATTR_FIX_PX);
1683 static HRESULT WINAPI HTMLStyle_get_paddingBottom(IHTMLStyle *iface, VARIANT *p)
1685 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1687 TRACE("(%p)->(%p)\n", This, p);
1689 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, p, 0);
1692 static HRESULT WINAPI HTMLStyle_put_paddingLeft(IHTMLStyle *iface, VARIANT v)
1694 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1696 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1698 return set_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, &v, ATTR_FIX_PX);
1701 static HRESULT WINAPI HTMLStyle_get_paddingLeft(IHTMLStyle *iface, VARIANT *p)
1703 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1705 TRACE("(%p)->(%p)\n", This, p);
1707 return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, p, 0);
1710 static HRESULT WINAPI HTMLStyle_put_padding(IHTMLStyle *iface, BSTR v)
1712 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1714 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1716 return set_style_attr(This, STYLEID_PADDING, v, 0);
1719 static HRESULT WINAPI HTMLStyle_get_padding(IHTMLStyle *iface, BSTR *p)
1721 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1723 TRACE("(%p)->(%p)\n", This, p);
1725 return get_style_attr(This, STYLEID_PADDING, p);
1728 static HRESULT WINAPI HTMLStyle_put_border(IHTMLStyle *iface, BSTR v)
1730 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1732 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1734 return set_style_attr(This, STYLEID_BORDER, v, 0);
1737 static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
1739 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1741 TRACE("(%p)->(%p)\n", This, p);
1743 return get_style_attr(This, STYLEID_BORDER, p);
1746 static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
1748 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1749 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1750 return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX);
1753 static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
1755 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1756 TRACE("(%p)->(%p)\n", This, p);
1757 return get_style_attr(This, STYLEID_BORDER_TOP, p);
1760 static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
1762 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1763 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1764 return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX);
1767 static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
1769 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1770 TRACE("(%p)->(%p)\n", This, p);
1771 return get_style_attr(This, STYLEID_BORDER_RIGHT, p);
1774 static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
1776 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1777 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1778 return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX);
1781 static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
1783 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1784 TRACE("(%p)->(%p)\n", This, p);
1785 return get_style_attr(This, STYLEID_BORDER_BOTTOM, p);
1788 static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
1790 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1792 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1794 return set_style_attr(This, STYLEID_BORDER_LEFT, v, ATTR_FIX_PX);
1797 static HRESULT WINAPI HTMLStyle_get_borderLeft(IHTMLStyle *iface, BSTR *p)
1799 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1801 TRACE("(%p)->(%p)\n", This, p);
1803 return get_style_attr(This, STYLEID_BORDER_LEFT, p);
1806 static HRESULT WINAPI HTMLStyle_put_borderColor(IHTMLStyle *iface, BSTR v)
1808 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1810 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1812 return set_style_attr(This, STYLEID_BORDER_COLOR, v, 0);
1815 static HRESULT WINAPI HTMLStyle_get_borderColor(IHTMLStyle *iface, BSTR *p)
1817 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1819 TRACE("(%p)->(%p)\n", This, p);
1821 return get_style_attr(This, STYLEID_BORDER_COLOR, p);
1824 static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v)
1826 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1828 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1830 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, &v, ATTR_HEX_INT);
1833 static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p)
1835 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1837 TRACE("(%p)->(%p)\n", This, p);
1839 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0);
1842 static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v)
1844 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1846 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1848 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, &v, ATTR_HEX_INT);
1851 static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p)
1853 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1855 TRACE("(%p)->(%p)\n", This, p);
1857 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0);
1860 static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v)
1862 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1864 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1866 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, &v, ATTR_HEX_INT);
1869 static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p)
1871 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1873 TRACE("(%p)->(%p)\n", This, p);
1875 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0);
1878 static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v)
1880 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1882 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1884 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, &v, ATTR_HEX_INT);
1887 static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p)
1889 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1891 TRACE("(%p)->(%p)\n", This, p);
1893 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0);
1896 static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v)
1898 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1899 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1900 return set_style_attr(This, STYLEID_BORDER_WIDTH, v, ATTR_FIX_PX);
1903 static HRESULT WINAPI HTMLStyle_get_borderWidth(IHTMLStyle *iface, BSTR *p)
1905 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1906 TRACE("(%p)->(%p)\n", This, p);
1907 return get_style_attr(This, STYLEID_BORDER_WIDTH, p);
1910 static HRESULT WINAPI HTMLStyle_put_borderTopWidth(IHTMLStyle *iface, VARIANT v)
1912 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1914 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1916 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, &v, 0);
1919 static HRESULT WINAPI HTMLStyle_get_borderTopWidth(IHTMLStyle *iface, VARIANT *p)
1921 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1923 TRACE("(%p)->(%p)\n", This, p);
1925 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, p, 0);
1928 static HRESULT WINAPI HTMLStyle_put_borderRightWidth(IHTMLStyle *iface, VARIANT v)
1930 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1932 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1934 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, &v, 0);
1937 static HRESULT WINAPI HTMLStyle_get_borderRightWidth(IHTMLStyle *iface, VARIANT *p)
1939 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1941 TRACE("(%p)->(%p)\n", This, p);
1943 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, p, 0);
1946 static HRESULT WINAPI HTMLStyle_put_borderBottomWidth(IHTMLStyle *iface, VARIANT v)
1948 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1950 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1952 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, &v, 0);
1955 static HRESULT WINAPI HTMLStyle_get_borderBottomWidth(IHTMLStyle *iface, VARIANT *p)
1957 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1958 TRACE("(%p)->(%p)\n", This, p);
1959 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, p, 0);
1962 static HRESULT WINAPI HTMLStyle_put_borderLeftWidth(IHTMLStyle *iface, VARIANT v)
1964 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1966 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1968 return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, &v, 0);
1971 static HRESULT WINAPI HTMLStyle_get_borderLeftWidth(IHTMLStyle *iface, VARIANT *p)
1973 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1974 TRACE("(%p)->(%p)\n", This, p);
1975 return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, p, 0);
1978 static HRESULT WINAPI HTMLStyle_put_borderStyle(IHTMLStyle *iface, BSTR v)
1980 HTMLStyle *This = impl_from_IHTMLStyle(iface);
1981 static const WCHAR styleWindowInset[] = {'w','i','n','d','o','w','-','i','n','s','e','t',0};
1982 HRESULT hres = S_OK;
1983 BSTR pstyle;
1984 int i=0;
1985 int last = 0;
1987 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1989 while(v[i] && hres == S_OK)
1991 if(v[i] == (WCHAR)' ')
1993 pstyle = SysAllocStringLen(&v[last], (i-last));
1994 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
1996 TRACE("1. Invalid style (%s)\n", debugstr_w(pstyle));
1997 hres = E_INVALIDARG;
1999 SysFreeString(pstyle);
2000 last = i+1;
2002 i++;
2005 if(hres == S_OK)
2007 pstyle = SysAllocStringLen(&v[last], i-last);
2008 if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
2010 TRACE("2. Invalid style (%s)\n", debugstr_w(pstyle));
2011 hres = E_INVALIDARG;
2013 SysFreeString(pstyle);
2016 if(hres == S_OK)
2017 hres = set_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, v, 0);
2019 return hres;
2022 static HRESULT WINAPI HTMLStyle_get_borderStyle(IHTMLStyle *iface, BSTR *p)
2024 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2025 TRACE("(%p)->(%p)\n", This, p);
2026 return get_style_attr(This, STYLEID_BORDER_STYLE, p);
2029 static HRESULT WINAPI HTMLStyle_put_borderTopStyle(IHTMLStyle *iface, BSTR v)
2031 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2032 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2034 if(!is_valid_border_style(v))
2035 return E_INVALIDARG;
2037 return set_style_attr(This, STYLEID_BORDER_TOP_STYLE, v, 0);
2040 static HRESULT WINAPI HTMLStyle_get_borderTopStyle(IHTMLStyle *iface, BSTR *p)
2042 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2043 TRACE("(%p)->(%p)\n", This, p);
2044 return get_style_attr(This, STYLEID_BORDER_TOP_STYLE, p);
2047 static HRESULT WINAPI HTMLStyle_put_borderRightStyle(IHTMLStyle *iface, BSTR v)
2049 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2050 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2052 if(!is_valid_border_style(v))
2053 return E_INVALIDARG;
2055 return set_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, v, 0);
2058 static HRESULT WINAPI HTMLStyle_get_borderRightStyle(IHTMLStyle *iface, BSTR *p)
2060 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2061 TRACE("(%p)->(%p)\n", This, p);
2062 return get_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, p);
2065 static HRESULT WINAPI HTMLStyle_put_borderBottomStyle(IHTMLStyle *iface, BSTR v)
2067 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2068 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2070 if(!is_valid_border_style(v))
2071 return E_INVALIDARG;
2073 return set_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, v, 0);
2076 static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p)
2078 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2079 TRACE("(%p)->(%p)\n", This, p);
2080 return get_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, p);
2083 static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v)
2085 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2086 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2088 if(!is_valid_border_style(v))
2089 return E_INVALIDARG;
2091 return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0);
2094 static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p)
2096 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2097 TRACE("(%p)->(%p)\n", This, p);
2098 return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p);
2101 static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
2103 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2105 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2107 return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX);
2110 static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
2112 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2114 TRACE("(%p)->(%p)\n", This, p);
2116 return get_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, p, 0);
2119 static HRESULT WINAPI HTMLStyle_put_height(IHTMLStyle *iface, VARIANT v)
2121 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2123 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2125 return set_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, &v, ATTR_FIX_PX);
2128 static HRESULT WINAPI HTMLStyle_get_height(IHTMLStyle *iface, VARIANT *p)
2130 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2132 TRACE("(%p)->(%p)\n", This, p);
2134 return get_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, p, 0);
2137 static HRESULT WINAPI HTMLStyle_put_styleFloat(IHTMLStyle *iface, BSTR v)
2139 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2141 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2143 return set_style_attr(This, STYLEID_FLOAT, v, 0);
2146 static HRESULT WINAPI HTMLStyle_get_styleFloat(IHTMLStyle *iface, BSTR *p)
2148 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2150 TRACE("(%p)->(%p)\n", This, p);
2152 return get_style_attr(This, STYLEID_FLOAT, p);
2155 static HRESULT WINAPI HTMLStyle_put_clear(IHTMLStyle *iface, BSTR v)
2157 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2159 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2161 return set_style_attr(This, STYLEID_CLEAR, v, 0);
2164 static HRESULT WINAPI HTMLStyle_get_clear(IHTMLStyle *iface, BSTR *p)
2166 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2168 TRACE("(%p)->(%p)\n", This, p);
2170 return get_style_attr(This, STYLEID_CLEAR, p);
2173 static HRESULT WINAPI HTMLStyle_put_display(IHTMLStyle *iface, BSTR v)
2175 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2177 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2179 return set_style_attr(This, STYLEID_DISPLAY, v, 0);
2182 static HRESULT WINAPI HTMLStyle_get_display(IHTMLStyle *iface, BSTR *p)
2184 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2186 TRACE("(%p)->(%p)\n", This, p);
2188 return get_style_attr(This, STYLEID_DISPLAY, p);
2191 static HRESULT WINAPI HTMLStyle_put_visibility(IHTMLStyle *iface, BSTR v)
2193 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2195 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2197 return set_style_attr(This, STYLEID_VISIBILITY, v, 0);
2200 static HRESULT WINAPI HTMLStyle_get_visibility(IHTMLStyle *iface, BSTR *p)
2202 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2204 TRACE("(%p)->(%p)\n", This, p);
2206 return get_style_attr(This, STYLEID_VISIBILITY, p);
2209 static HRESULT WINAPI HTMLStyle_put_listStyleType(IHTMLStyle *iface, BSTR v)
2211 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2213 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2215 return set_style_attr(This, STYLEID_LISTSTYLETYPE, v, 0);
2218 static HRESULT WINAPI HTMLStyle_get_listStyleType(IHTMLStyle *iface, BSTR *p)
2220 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2222 TRACE("(%p)->(%p)\n", This, p);
2224 return get_style_attr(This, STYLEID_LISTSTYLETYPE, p);
2227 static HRESULT WINAPI HTMLStyle_put_listStylePosition(IHTMLStyle *iface, BSTR v)
2229 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2231 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2233 return set_style_attr(This, STYLEID_LISTSTYLEPOSITION, v, 0);
2236 static HRESULT WINAPI HTMLStyle_get_listStylePosition(IHTMLStyle *iface, BSTR *p)
2238 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2240 TRACE("(%p)->(%p)\n", This, p);
2242 return get_style_attr(This, STYLEID_LISTSTYLEPOSITION, p);
2245 static HRESULT WINAPI HTMLStyle_put_listStyleImage(IHTMLStyle *iface, BSTR v)
2247 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2248 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2249 return E_NOTIMPL;
2252 static HRESULT WINAPI HTMLStyle_get_listStyleImage(IHTMLStyle *iface, BSTR *p)
2254 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2255 FIXME("(%p)->(%p)\n", This, p);
2256 return E_NOTIMPL;
2259 static HRESULT WINAPI HTMLStyle_put_listStyle(IHTMLStyle *iface, BSTR v)
2261 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2263 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2265 return set_style_attr(This, STYLEID_LIST_STYLE, v, 0);
2268 static HRESULT WINAPI HTMLStyle_get_listStyle(IHTMLStyle *iface, BSTR *p)
2270 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2272 TRACE("(%p)->(%p)\n", This, p);
2274 return get_style_attr(This, STYLEID_LIST_STYLE, p);
2277 static HRESULT WINAPI HTMLStyle_put_whiteSpace(IHTMLStyle *iface, BSTR v)
2279 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2281 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2283 return set_nsstyle_attr(This->nsstyle, STYLEID_WHITE_SPACE, v, 0);
2286 static HRESULT WINAPI HTMLStyle_get_whiteSpace(IHTMLStyle *iface, BSTR *p)
2288 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2290 TRACE("(%p)->(%p)\n", This, p);
2292 return get_nsstyle_attr(This->nsstyle, STYLEID_WHITE_SPACE, p, 0);
2295 static HRESULT WINAPI HTMLStyle_put_top(IHTMLStyle *iface, VARIANT v)
2297 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2299 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2301 return set_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, &v, 0);
2304 static HRESULT WINAPI HTMLStyle_get_top(IHTMLStyle *iface, VARIANT *p)
2306 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2308 TRACE("(%p)->(%p)\n", This, p);
2310 return get_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, p, 0);
2313 static HRESULT WINAPI HTMLStyle_put_left(IHTMLStyle *iface, VARIANT v)
2315 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2317 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2319 return set_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, &v, 0);
2322 static HRESULT WINAPI HTMLStyle_get_left(IHTMLStyle *iface, VARIANT *p)
2324 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2326 TRACE("(%p)->(%p)\n", This, p);
2328 return get_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, p, 0);
2331 static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
2333 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2334 TRACE("(%p)->(%p)\n", This, p);
2335 return IHTMLStyle2_get_position(&This->IHTMLStyle2_iface, p);
2338 static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
2340 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2342 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2344 return set_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, &v, 0);
2347 static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
2349 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2351 TRACE("(%p)->(%p)\n", This, p);
2353 return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
2356 static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
2358 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2359 static const WCHAR szVisible[] = {'v','i','s','i','b','l','e',0};
2360 static const WCHAR szScroll[] = {'s','c','r','o','l','l',0};
2361 static const WCHAR szHidden[] = {'h','i','d','d','e','n',0};
2362 static const WCHAR szAuto[] = {'a','u','t','o',0};
2364 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2366 /* overflow can only be one of the follow values. */
2367 if(!v || !*v || strcmpiW(szVisible, v) == 0 || strcmpiW(szScroll, v) == 0 ||
2368 strcmpiW(szHidden, v) == 0 || strcmpiW(szAuto, v) == 0)
2370 return set_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, v, 0);
2373 return E_INVALIDARG;
2377 static HRESULT WINAPI HTMLStyle_get_overflow(IHTMLStyle *iface, BSTR *p)
2379 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2381 TRACE("(%p)->(%p)\n", This, p);
2383 if(!p)
2384 return E_INVALIDARG;
2386 return get_style_attr(This, STYLEID_OVERFLOW, p);
2389 static HRESULT WINAPI HTMLStyle_put_pageBreakBefore(IHTMLStyle *iface, BSTR v)
2391 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2393 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2395 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, v, 0);
2398 static HRESULT WINAPI HTMLStyle_get_pageBreakBefore(IHTMLStyle *iface, BSTR *p)
2400 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2402 TRACE("(%p)->(%p)\n", This, p);
2404 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_BEFORE, p, 0);
2407 static HRESULT WINAPI HTMLStyle_put_pageBreakAfter(IHTMLStyle *iface, BSTR v)
2409 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2411 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2413 return set_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, v, 0);
2416 static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p)
2418 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2420 TRACE("(%p)->(%p)\n", This, p);
2422 return get_nsstyle_attr(This->nsstyle, STYLEID_PAGE_BREAK_AFTER, p, 0);
2425 static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
2427 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2428 nsAString text_str;
2429 nsresult nsres;
2431 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2433 nsAString_InitDepend(&text_str, v);
2434 nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str);
2435 nsAString_Finish(&text_str);
2436 if(NS_FAILED(nsres)) {
2437 FIXME("SetCssStyle failed: %08x\n", nsres);
2438 return E_FAIL;
2441 return S_OK;
2444 static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p)
2446 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2447 nsAString text_str;
2448 nsresult nsres;
2450 TRACE("(%p)->(%p)\n", This, p);
2452 /* FIXME: Gecko style formatting is different than IE (uppercase). */
2453 nsAString_Init(&text_str, NULL);
2454 nsres = nsIDOMCSSStyleDeclaration_GetCssText(This->nsstyle, &text_str);
2455 if(NS_SUCCEEDED(nsres)) {
2456 const PRUnichar *text;
2458 nsAString_GetData(&text_str, &text);
2459 *p = *text ? SysAllocString(text) : NULL;
2460 }else {
2461 FIXME("GetCssStyle failed: %08x\n", nsres);
2462 *p = NULL;
2465 nsAString_Finish(&text_str);
2466 return S_OK;
2469 static HRESULT WINAPI HTMLStyle_put_pixelTop(IHTMLStyle *iface, LONG v)
2471 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2473 TRACE("(%p)->(%d)\n", This, v);
2475 return set_style_pxattr(This->nsstyle, STYLEID_TOP, v);
2478 static HRESULT WINAPI HTMLStyle_get_pixelTop(IHTMLStyle *iface, LONG *p)
2480 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2482 TRACE("(%p)->(%p)\n", This, p);
2484 return get_nsstyle_pixel_val(This, STYLEID_TOP, p);
2487 static HRESULT WINAPI HTMLStyle_put_pixelLeft(IHTMLStyle *iface, LONG v)
2489 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2491 TRACE("(%p)->(%d)\n", This, v);
2493 return set_style_pxattr(This->nsstyle, STYLEID_LEFT, v);
2496 static HRESULT WINAPI HTMLStyle_get_pixelLeft(IHTMLStyle *iface, LONG *p)
2498 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2500 TRACE("(%p)->(%p)\n", This, p);
2502 return get_nsstyle_pixel_val(This, STYLEID_LEFT, p);
2505 static HRESULT WINAPI HTMLStyle_put_pixelWidth(IHTMLStyle *iface, LONG v)
2507 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2509 TRACE("(%p)->()\n", This);
2511 return set_style_pxattr(This->nsstyle, STYLEID_WIDTH, v);
2514 static HRESULT WINAPI HTMLStyle_get_pixelWidth(IHTMLStyle *iface, LONG *p)
2516 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2518 TRACE("(%p)->(%p)\n", This, p);
2520 return get_nsstyle_pixel_val(This, STYLEID_WIDTH, p);
2523 static HRESULT WINAPI HTMLStyle_put_pixelHeight(IHTMLStyle *iface, LONG v)
2525 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2527 TRACE("(%p)->(%d)\n", This, v);
2529 return set_style_pxattr(This->nsstyle, STYLEID_HEIGHT, v);
2532 static HRESULT WINAPI HTMLStyle_get_pixelHeight(IHTMLStyle *iface, LONG *p)
2534 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2536 TRACE("(%p)->(%p)\n", This, p);
2538 return get_nsstyle_pixel_val(This, STYLEID_HEIGHT, p);
2541 static HRESULT WINAPI HTMLStyle_put_posTop(IHTMLStyle *iface, float v)
2543 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2545 TRACE("(%p)->(%f)\n", This, v);
2547 return set_style_pos(This, STYLEID_TOP, v);
2550 static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
2552 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2554 TRACE("(%p)->(%p)\n", This, p);
2556 if(!p)
2557 return E_POINTER;
2559 return get_nsstyle_pos(This, STYLEID_TOP, p);
2562 static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
2564 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2566 TRACE("(%p)->(%f)\n", This, v);
2568 return set_style_pos(This, STYLEID_LEFT, v);
2571 static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
2573 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2575 TRACE("(%p)->(%p)\n", This, p);
2577 if(!p)
2578 return E_POINTER;
2580 return get_nsstyle_pos(This, STYLEID_LEFT, p);
2583 static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
2585 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2587 TRACE("(%p)->(%f)\n", This, v);
2589 return set_style_pos(This, STYLEID_WIDTH, v);
2592 static HRESULT WINAPI HTMLStyle_get_posWidth(IHTMLStyle *iface, float *p)
2594 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2596 TRACE("(%p)->(%p)\n", This, p);
2598 if(!p)
2599 return E_POINTER;
2601 if(get_nsstyle_pos(This, STYLEID_WIDTH, p) != S_OK)
2602 *p = 0.0f;
2604 return S_OK;
2607 static HRESULT WINAPI HTMLStyle_put_posHeight(IHTMLStyle *iface, float v)
2609 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2611 TRACE("(%p)->(%f)\n", This, v);
2613 return set_style_pos(This, STYLEID_HEIGHT, v);
2616 static HRESULT WINAPI HTMLStyle_get_posHeight(IHTMLStyle *iface, float *p)
2618 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2620 TRACE("(%p)->(%p)\n", This, p);
2622 if(!p)
2623 return E_POINTER;
2625 if(get_nsstyle_pos(This, STYLEID_HEIGHT, p) != S_OK)
2626 *p = 0.0f;
2628 return S_OK;
2631 static HRESULT WINAPI HTMLStyle_put_cursor(IHTMLStyle *iface, BSTR v)
2633 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2635 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2637 return set_style_attr(This, STYLEID_CURSOR, v, 0);
2640 static HRESULT WINAPI HTMLStyle_get_cursor(IHTMLStyle *iface, BSTR *p)
2642 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2644 TRACE("(%p)->(%p)\n", This, p);
2646 return get_style_attr(This, STYLEID_CURSOR, p);
2649 static HRESULT WINAPI HTMLStyle_put_clip(IHTMLStyle *iface, BSTR v)
2651 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2653 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2655 return set_style_attr(This, STYLEID_CLIP, v, 0);
2658 static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
2660 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2662 TRACE("(%p)->(%p)\n", This, p);
2664 return get_nsstyle_attr(This->nsstyle, STYLEID_CLIP, p, ATTR_REMOVE_COMMA);
2667 static void set_opacity(HTMLStyle *This, const WCHAR *val)
2669 nsAString name_str, val_str, empty_str;
2670 nsresult nsres;
2672 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y',0};
2674 TRACE("%s\n", debugstr_w(val));
2676 nsAString_InitDepend(&name_str, opacityW);
2677 nsAString_InitDepend(&val_str, val);
2678 nsAString_InitDepend(&empty_str, emptyW);
2680 nsres = nsIDOMCSSStyleDeclaration_SetProperty(This->nsstyle, &name_str, &val_str, &empty_str);
2681 if(NS_FAILED(nsres))
2682 ERR("SetProperty failed: %08x\n", nsres);
2684 nsAString_Finish(&name_str);
2685 nsAString_Finish(&val_str);
2686 nsAString_Finish(&empty_str);
2689 static void update_filter(HTMLStyle *This)
2691 const WCHAR *ptr = This->elem->filter, *ptr2;
2693 static const WCHAR alphaW[] = {'a','l','p','h','a'};
2695 if(!ptr) {
2696 set_opacity(This, emptyW);
2697 return;
2700 while(1) {
2701 while(isspaceW(*ptr))
2702 ptr++;
2703 if(!*ptr)
2704 break;
2706 ptr2 = ptr;
2707 while(isalnumW(*ptr))
2708 ptr++;
2709 if(ptr == ptr2) {
2710 WARN("unexpected char '%c'\n", *ptr);
2711 break;
2713 if(*ptr != '(') {
2714 WARN("expected '('\n");
2715 continue;
2718 if(ptr2 + sizeof(alphaW)/sizeof(WCHAR) == ptr && !memcmp(ptr2, alphaW, sizeof(alphaW))) {
2719 static const WCHAR formatW[] = {'%','f',0};
2720 static const WCHAR opacityW[] = {'o','p','a','c','i','t','y','='};
2722 ptr++;
2723 do {
2724 while(isspaceW(*ptr))
2725 ptr++;
2727 ptr2 = ptr;
2728 while(*ptr && *ptr != ',' && *ptr != ')')
2729 ptr++;
2730 if(!*ptr) {
2731 WARN("unexpected end of string\n");
2732 break;
2735 if(ptr-ptr2 > sizeof(opacityW)/sizeof(WCHAR) && !memcmp(ptr2, opacityW, sizeof(opacityW))) {
2736 float fval = 0.0f, e = 0.1f;
2737 WCHAR buf[32];
2739 ptr2 += sizeof(opacityW)/sizeof(WCHAR);
2741 while(isdigitW(*ptr2))
2742 fval = fval*10.0f + (float)(*ptr2++ - '0');
2744 if(*ptr2 == '.') {
2745 while(isdigitW(*++ptr2)) {
2746 fval += e * (float)(*ptr2++ - '0');
2747 e *= 0.1f;
2751 sprintfW(buf, formatW, fval * 0.01f);
2752 set_opacity(This, buf);
2753 }else {
2754 FIXME("unknown param %s\n", debugstr_wn(ptr2, ptr-ptr2));
2757 if(*ptr == ',')
2758 ptr++;
2759 }while(*ptr != ')');
2760 }else {
2761 FIXME("unknown filter %s\n", debugstr_wn(ptr2, ptr-ptr2));
2762 ptr = strchrW(ptr, ')');
2763 if(!ptr)
2764 break;
2765 ptr++;
2770 static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
2772 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2773 WCHAR *new_filter = NULL;
2775 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2777 if(!This->elem) {
2778 FIXME("Element already destroyed\n");
2779 return E_UNEXPECTED;
2782 if(v) {
2783 new_filter = heap_strdupW(v);
2784 if(!new_filter)
2785 return E_OUTOFMEMORY;
2788 heap_free(This->elem->filter);
2789 This->elem->filter = new_filter;
2791 update_filter(This);
2792 return S_OK;
2795 static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
2797 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2799 TRACE("(%p)->(%p)\n", This, p);
2801 if(!This->elem) {
2802 FIXME("Element already destroyed\n");
2803 return E_UNEXPECTED;
2806 if(This->elem->filter) {
2807 *p = SysAllocString(This->elem->filter);
2808 if(!*p)
2809 return E_OUTOFMEMORY;
2810 }else {
2811 *p = NULL;
2814 return S_OK;
2817 static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2818 VARIANT AttributeValue, LONG lFlags)
2820 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2821 HRESULT hres;
2822 DISPID dispid;
2824 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName),
2825 debugstr_variant(&AttributeValue), lFlags);
2827 if(!strAttributeName)
2828 return E_INVALIDARG;
2830 if(lFlags == 1)
2831 FIXME("Parameter lFlags ignored\n");
2833 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2834 LOCALE_USER_DEFAULT, &dispid);
2835 if(hres == S_OK)
2837 VARIANT ret;
2838 DISPID dispidNamed = DISPID_PROPERTYPUT;
2839 DISPPARAMS params;
2841 params.cArgs = 1;
2842 params.rgvarg = &AttributeValue;
2843 params.cNamedArgs = 1;
2844 params.rgdispidNamedArgs = &dispidNamed;
2846 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2847 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2849 else
2851 FIXME("Custom attributes not supported.\n");
2854 TRACE("ret: %08x\n", hres);
2856 return hres;
2859 static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2860 LONG lFlags, VARIANT *AttributeValue)
2862 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2863 HRESULT hres;
2864 DISPID dispid;
2866 TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName),
2867 AttributeValue, lFlags);
2869 if(!AttributeValue || !strAttributeName)
2870 return E_INVALIDARG;
2872 if(lFlags == 1)
2873 FIXME("Parameter lFlags ignored\n");
2875 hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2876 LOCALE_USER_DEFAULT, &dispid);
2877 if(hres == S_OK)
2879 DISPPARAMS params = {NULL, NULL, 0, 0 };
2881 hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2882 DISPATCH_PROPERTYGET, &params, AttributeValue, NULL, NULL);
2884 else
2886 FIXME("Custom attributes not supported.\n");
2889 return hres;
2892 static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,
2893 LONG lFlags, VARIANT_BOOL *pfSuccess)
2895 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2896 const style_tbl_entry_t *style_entry;
2897 nsAString name_str, ret_str;
2898 nsresult nsres;
2899 HRESULT hres;
2901 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
2903 style_entry = lookup_style_tbl(strAttributeName);
2904 if(!style_entry) {
2905 DISPID dispid;
2906 unsigned i;
2908 hres = IDispatchEx_GetDispID(&This->dispex.IDispatchEx_iface, strAttributeName,
2909 (lFlags&1) ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
2910 if(hres != S_OK) {
2911 *pfSuccess = VARIANT_FALSE;
2912 return S_OK;
2915 for(i=0; i < sizeof(style_tbl)/sizeof(*style_tbl); i++) {
2916 if(dispid == style_tbl[i].dispid)
2917 break;
2920 if(i == sizeof(style_tbl)/sizeof(*style_tbl))
2921 return remove_attribute(&This->dispex, dispid, pfSuccess);
2922 style_entry = style_tbl+i;
2925 /* filter property is a special case */
2926 if(style_entry->dispid == DISPID_IHTMLSTYLE_FILTER) {
2927 *pfSuccess = This->elem->filter && *This->elem->filter ? VARIANT_TRUE : VARIANT_FALSE;
2928 heap_free(This->elem->filter);
2929 This->elem->filter = NULL;
2930 update_filter(This);
2931 return S_OK;
2934 nsAString_InitDepend(&name_str, style_entry->name);
2935 nsAString_Init(&ret_str, NULL);
2936 nsres = nsIDOMCSSStyleDeclaration_RemoveProperty(This->nsstyle, &name_str, &ret_str);
2937 if(NS_SUCCEEDED(nsres)) {
2938 const PRUnichar *ret;
2939 nsAString_GetData(&ret_str, &ret);
2940 *pfSuccess = *ret ? VARIANT_TRUE : VARIANT_FALSE;
2941 }else {
2942 ERR("RemoveProperty failed: %08x\n", nsres);
2944 nsAString_Finish(&name_str);
2945 nsAString_Finish(&ret_str);
2946 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
2949 static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
2951 HTMLStyle *This = impl_from_IHTMLStyle(iface);
2952 FIXME("(%p)->(%p)\n", This, String);
2953 return E_NOTIMPL;
2956 static const IHTMLStyleVtbl HTMLStyleVtbl = {
2957 HTMLStyle_QueryInterface,
2958 HTMLStyle_AddRef,
2959 HTMLStyle_Release,
2960 HTMLStyle_GetTypeInfoCount,
2961 HTMLStyle_GetTypeInfo,
2962 HTMLStyle_GetIDsOfNames,
2963 HTMLStyle_Invoke,
2964 HTMLStyle_put_fontFamily,
2965 HTMLStyle_get_fontFamily,
2966 HTMLStyle_put_fontStyle,
2967 HTMLStyle_get_fontStyle,
2968 HTMLStyle_put_fontVariant,
2969 HTMLStyle_get_fontVariant,
2970 HTMLStyle_put_fontWeight,
2971 HTMLStyle_get_fontWeight,
2972 HTMLStyle_put_fontSize,
2973 HTMLStyle_get_fontSize,
2974 HTMLStyle_put_font,
2975 HTMLStyle_get_font,
2976 HTMLStyle_put_color,
2977 HTMLStyle_get_color,
2978 HTMLStyle_put_background,
2979 HTMLStyle_get_background,
2980 HTMLStyle_put_backgroundColor,
2981 HTMLStyle_get_backgroundColor,
2982 HTMLStyle_put_backgroundImage,
2983 HTMLStyle_get_backgroundImage,
2984 HTMLStyle_put_backgroundRepeat,
2985 HTMLStyle_get_backgroundRepeat,
2986 HTMLStyle_put_backgroundAttachment,
2987 HTMLStyle_get_backgroundAttachment,
2988 HTMLStyle_put_backgroundPosition,
2989 HTMLStyle_get_backgroundPosition,
2990 HTMLStyle_put_backgroundPositionX,
2991 HTMLStyle_get_backgroundPositionX,
2992 HTMLStyle_put_backgroundPositionY,
2993 HTMLStyle_get_backgroundPositionY,
2994 HTMLStyle_put_wordSpacing,
2995 HTMLStyle_get_wordSpacing,
2996 HTMLStyle_put_letterSpacing,
2997 HTMLStyle_get_letterSpacing,
2998 HTMLStyle_put_textDecoration,
2999 HTMLStyle_get_textDecoration,
3000 HTMLStyle_put_textDecorationNone,
3001 HTMLStyle_get_textDecorationNone,
3002 HTMLStyle_put_textDecorationUnderline,
3003 HTMLStyle_get_textDecorationUnderline,
3004 HTMLStyle_put_textDecorationOverline,
3005 HTMLStyle_get_textDecorationOverline,
3006 HTMLStyle_put_textDecorationLineThrough,
3007 HTMLStyle_get_textDecorationLineThrough,
3008 HTMLStyle_put_textDecorationBlink,
3009 HTMLStyle_get_textDecorationBlink,
3010 HTMLStyle_put_verticalAlign,
3011 HTMLStyle_get_verticalAlign,
3012 HTMLStyle_put_textTransform,
3013 HTMLStyle_get_textTransform,
3014 HTMLStyle_put_textAlign,
3015 HTMLStyle_get_textAlign,
3016 HTMLStyle_put_textIndent,
3017 HTMLStyle_get_textIndent,
3018 HTMLStyle_put_lineHeight,
3019 HTMLStyle_get_lineHeight,
3020 HTMLStyle_put_marginTop,
3021 HTMLStyle_get_marginTop,
3022 HTMLStyle_put_marginRight,
3023 HTMLStyle_get_marginRight,
3024 HTMLStyle_put_marginBottom,
3025 HTMLStyle_get_marginBottom,
3026 HTMLStyle_put_marginLeft,
3027 HTMLStyle_get_marginLeft,
3028 HTMLStyle_put_margin,
3029 HTMLStyle_get_margin,
3030 HTMLStyle_put_paddingTop,
3031 HTMLStyle_get_paddingTop,
3032 HTMLStyle_put_paddingRight,
3033 HTMLStyle_get_paddingRight,
3034 HTMLStyle_put_paddingBottom,
3035 HTMLStyle_get_paddingBottom,
3036 HTMLStyle_put_paddingLeft,
3037 HTMLStyle_get_paddingLeft,
3038 HTMLStyle_put_padding,
3039 HTMLStyle_get_padding,
3040 HTMLStyle_put_border,
3041 HTMLStyle_get_border,
3042 HTMLStyle_put_borderTop,
3043 HTMLStyle_get_borderTop,
3044 HTMLStyle_put_borderRight,
3045 HTMLStyle_get_borderRight,
3046 HTMLStyle_put_borderBottom,
3047 HTMLStyle_get_borderBottom,
3048 HTMLStyle_put_borderLeft,
3049 HTMLStyle_get_borderLeft,
3050 HTMLStyle_put_borderColor,
3051 HTMLStyle_get_borderColor,
3052 HTMLStyle_put_borderTopColor,
3053 HTMLStyle_get_borderTopColor,
3054 HTMLStyle_put_borderRightColor,
3055 HTMLStyle_get_borderRightColor,
3056 HTMLStyle_put_borderBottomColor,
3057 HTMLStyle_get_borderBottomColor,
3058 HTMLStyle_put_borderLeftColor,
3059 HTMLStyle_get_borderLeftColor,
3060 HTMLStyle_put_borderWidth,
3061 HTMLStyle_get_borderWidth,
3062 HTMLStyle_put_borderTopWidth,
3063 HTMLStyle_get_borderTopWidth,
3064 HTMLStyle_put_borderRightWidth,
3065 HTMLStyle_get_borderRightWidth,
3066 HTMLStyle_put_borderBottomWidth,
3067 HTMLStyle_get_borderBottomWidth,
3068 HTMLStyle_put_borderLeftWidth,
3069 HTMLStyle_get_borderLeftWidth,
3070 HTMLStyle_put_borderStyle,
3071 HTMLStyle_get_borderStyle,
3072 HTMLStyle_put_borderTopStyle,
3073 HTMLStyle_get_borderTopStyle,
3074 HTMLStyle_put_borderRightStyle,
3075 HTMLStyle_get_borderRightStyle,
3076 HTMLStyle_put_borderBottomStyle,
3077 HTMLStyle_get_borderBottomStyle,
3078 HTMLStyle_put_borderLeftStyle,
3079 HTMLStyle_get_borderLeftStyle,
3080 HTMLStyle_put_width,
3081 HTMLStyle_get_width,
3082 HTMLStyle_put_height,
3083 HTMLStyle_get_height,
3084 HTMLStyle_put_styleFloat,
3085 HTMLStyle_get_styleFloat,
3086 HTMLStyle_put_clear,
3087 HTMLStyle_get_clear,
3088 HTMLStyle_put_display,
3089 HTMLStyle_get_display,
3090 HTMLStyle_put_visibility,
3091 HTMLStyle_get_visibility,
3092 HTMLStyle_put_listStyleType,
3093 HTMLStyle_get_listStyleType,
3094 HTMLStyle_put_listStylePosition,
3095 HTMLStyle_get_listStylePosition,
3096 HTMLStyle_put_listStyleImage,
3097 HTMLStyle_get_listStyleImage,
3098 HTMLStyle_put_listStyle,
3099 HTMLStyle_get_listStyle,
3100 HTMLStyle_put_whiteSpace,
3101 HTMLStyle_get_whiteSpace,
3102 HTMLStyle_put_top,
3103 HTMLStyle_get_top,
3104 HTMLStyle_put_left,
3105 HTMLStyle_get_left,
3106 HTMLStyle_get_position,
3107 HTMLStyle_put_zIndex,
3108 HTMLStyle_get_zIndex,
3109 HTMLStyle_put_overflow,
3110 HTMLStyle_get_overflow,
3111 HTMLStyle_put_pageBreakBefore,
3112 HTMLStyle_get_pageBreakBefore,
3113 HTMLStyle_put_pageBreakAfter,
3114 HTMLStyle_get_pageBreakAfter,
3115 HTMLStyle_put_cssText,
3116 HTMLStyle_get_cssText,
3117 HTMLStyle_put_pixelTop,
3118 HTMLStyle_get_pixelTop,
3119 HTMLStyle_put_pixelLeft,
3120 HTMLStyle_get_pixelLeft,
3121 HTMLStyle_put_pixelWidth,
3122 HTMLStyle_get_pixelWidth,
3123 HTMLStyle_put_pixelHeight,
3124 HTMLStyle_get_pixelHeight,
3125 HTMLStyle_put_posTop,
3126 HTMLStyle_get_posTop,
3127 HTMLStyle_put_posLeft,
3128 HTMLStyle_get_posLeft,
3129 HTMLStyle_put_posWidth,
3130 HTMLStyle_get_posWidth,
3131 HTMLStyle_put_posHeight,
3132 HTMLStyle_get_posHeight,
3133 HTMLStyle_put_cursor,
3134 HTMLStyle_get_cursor,
3135 HTMLStyle_put_clip,
3136 HTMLStyle_get_clip,
3137 HTMLStyle_put_filter,
3138 HTMLStyle_get_filter,
3139 HTMLStyle_setAttribute,
3140 HTMLStyle_getAttribute,
3141 HTMLStyle_removeAttribute,
3142 HTMLStyle_toString
3145 static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
3147 const style_tbl_entry_t *style_entry;
3149 style_entry = lookup_style_tbl(name);
3150 if(style_entry) {
3151 *dispid = style_entry->dispid;
3152 return S_OK;
3155 return DISP_E_UNKNOWNNAME;
3158 static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
3159 NULL,
3160 HTMLStyle_get_dispid,
3161 NULL,
3162 NULL
3165 static const tid_t HTMLStyle_iface_tids[] = {
3166 IHTMLStyle6_tid,
3167 IHTMLStyle5_tid,
3168 IHTMLStyle4_tid,
3169 IHTMLStyle3_tid,
3170 IHTMLStyle2_tid,
3171 IHTMLStyle_tid,
3174 static dispex_static_data_t HTMLStyle_dispex = {
3175 &HTMLStyle_dispex_vtbl,
3176 DispHTMLStyle_tid,
3177 NULL,
3178 HTMLStyle_iface_tids
3181 static HRESULT get_style_from_elem(HTMLElement *elem, nsIDOMCSSStyleDeclaration **ret)
3183 nsIDOMElementCSSInlineStyle *nselemstyle;
3184 nsresult nsres;
3186 if(!elem->nselem) {
3187 FIXME("NULL nselem\n");
3188 return E_NOTIMPL;
3191 nsres = nsIDOMHTMLElement_QueryInterface(elem->nselem, &IID_nsIDOMElementCSSInlineStyle,
3192 (void**)&nselemstyle);
3193 assert(nsres == NS_OK);
3195 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, ret);
3196 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
3197 if(NS_FAILED(nsres)) {
3198 ERR("GetStyle failed: %08x\n", nsres);
3199 return E_FAIL;
3202 return S_OK;
3205 HRESULT HTMLStyle_Create(HTMLElement *elem, HTMLStyle **ret)
3207 nsIDOMCSSStyleDeclaration *nsstyle;
3208 HTMLStyle *style;
3209 HRESULT hres;
3211 hres = get_style_from_elem(elem, &nsstyle);
3212 if(FAILED(hres))
3213 return hres;
3215 style = heap_alloc_zero(sizeof(HTMLStyle));
3216 if(!style) {
3217 nsIDOMCSSStyleDeclaration_Release(nsstyle);
3218 return E_OUTOFMEMORY;
3221 style->IHTMLStyle_iface.lpVtbl = &HTMLStyleVtbl;
3222 style->ref = 1;
3223 style->nsstyle = nsstyle;
3224 style->elem = elem;
3225 HTMLStyle2_Init(style);
3226 HTMLStyle3_Init(style);
3228 nsIDOMCSSStyleDeclaration_AddRef(nsstyle);
3230 init_dispex(&style->dispex, (IUnknown*)&style->IHTMLStyle_iface, &HTMLStyle_dispex);
3232 *ret = style;
3233 return S_OK;
3236 HRESULT get_elem_style(HTMLElement *elem, styleid_t styleid, BSTR *ret)
3238 nsIDOMCSSStyleDeclaration *style;
3239 HRESULT hres;
3241 hres = get_style_from_elem(elem, &style);
3242 if(FAILED(hres))
3243 return hres;
3245 hres = get_nsstyle_attr(style, styleid, ret, 0);
3246 nsIDOMCSSStyleDeclaration_Release(style);
3247 return hres;
3250 HRESULT set_elem_style(HTMLElement *elem, styleid_t styleid, const WCHAR *val)
3252 nsIDOMCSSStyleDeclaration *style;
3253 HRESULT hres;
3255 hres = get_style_from_elem(elem, &style);
3256 if(FAILED(hres))
3257 return hres;
3259 hres = set_nsstyle_attr(style, styleid, val, 0);
3260 nsIDOMCSSStyleDeclaration_Release(style);
3261 return hres;