~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/mshtml/htmlstyle.c

Version: ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.