htmlstyle.c 74.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Copyright 2006 Jacek Caban for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <stdarg.h>
20
#include <math.h>
21 22 23 24 25 26 27

#define COBJMACROS

#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
28
#include "mshtmdid.h"
29

30 31 32
#include "mshtml_private.h"
#include "htmlstyle.h"

33 34 35 36 37
#include "wine/debug.h"
#include "wine/unicode.h"

WINE_DEFAULT_DEBUG_CHANNEL(mshtml);

38 39
static const WCHAR attrBackground[] =
    {'b','a','c','k','g','r','o','u','n','d',0};
40 41
static const WCHAR attrBackgroundColor[] =
    {'b','a','c','k','g','r','o','u','n','d','-','c','o','l','o','r',0};
42 43
static const WCHAR attrBackgroundImage[] =
    {'b','a','c','k','g','r','o','u','n','d','-','i','m','a','g','e',0};
44 45
static const WCHAR attrBackgroundPositionX[] =
    {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','x',0};
46 47
static const WCHAR attrBackgroundPositionY[] =
    {'b','a','c','k','g','r','o','u','n','d','-','p','o','s','i','t','i','o','n','-','y',0};
48 49
static const WCHAR attrBackgroundRepeat[] =
    {'b','a','c','k','g','r','o','u','n','d','-','r','e','p','e','a','t',0};
50 51
static const WCHAR attrBorder[] =
    {'b','o','r','d','e','r',0};
52 53
static const WCHAR attrBorderBottomStyle[] =
    {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','s','t','y','l','e',0};
54 55
static const WCHAR attrBorderBottomWidth[] =
    {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','w','i','d','t','h',0};
56 57
static const WCHAR attrBorderColor[] =
    {'b','o','r','d','e','r','-','c','o','l','o','r',0};
58 59
static const WCHAR attrBorderLeft[] =
    {'b','o','r','d','e','r','-','l','e','f','t',0};
60 61
static const WCHAR attrBorderLeftStyle[] =
    {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0};
62 63
static const WCHAR attrBorderRightStyle[] =
    {'b','o','r','d','e','r','-','r','i','g','h','t','-','s','t','y','l','e',0};
64 65
static const WCHAR attrBorderRightWidth[] =
    {'b','o','r','d','e','r','-','r','i','g','h','t','-','w','i','d','t','h',0};
66 67
static const WCHAR attrBorderStyle[] =
    {'b','o','r','d','e','r','-','s','t','y','l','e',0};
68 69
static const WCHAR attrBorderTopStyle[] =
    {'b','o','r','d','e','r','-','t','o','p','-','s','t','y','l','e',0};
70 71
static const WCHAR attrBorderTopWidth[] =
    {'b','o','r','d','e','r','-','t','o','p','-','w','i','d','t','h',0};
72 73
static const WCHAR attrBorderWidth[] =
    {'b','o','r','d','e','r','-','w','i','d','t','h',0};
74 75
static const WCHAR attrColor[] =
    {'c','o','l','o','r',0};
76 77
static const WCHAR attrCursor[] =
    {'c','u','r','s','o','r',0};
78 79
static const WCHAR attrDisplay[] =
    {'d','i','s','p','l','a','y',0};
80 81
static const WCHAR attrFilter[] =
    {'f','i','l','e','t','e','r',0};
82 83
static const WCHAR attrFontFamily[] =
    {'f','o','n','t','-','f','a','m','i','l','y',0};
84 85
static const WCHAR attrFontSize[] =
    {'f','o','n','t','-','s','i','z','e',0};
86 87
static const WCHAR attrFontStyle[] =
    {'f','o','n','t','-','s','t','y','l','e',0};
88 89
static const WCHAR attrFontVariant[] =
    {'f','o','n','t','-','v','a','r','i','a','n','t',0};
90 91
static const WCHAR attrFontWeight[] =
    {'f','o','n','t','-','w','e','i','g','h','t',0};
92 93
static const WCHAR attrHeight[] =
    {'h','e','i','g','h','t',0};
94 95
static const WCHAR attrLeft[] =
    {'l','e','f','t',0};
96 97
static const WCHAR attrMargin[] =
    {'m','a','r','g','i','n',0};
98 99 100 101
static const WCHAR attrMarginLeft[] =
    {'m','a','r','g','i','n','-','l','e','f','t',0};
static const WCHAR attrMarginRight[] =
    {'m','a','r','g','i','n','-','r','i','g','h','t',0};
102 103
static const WCHAR attrMinHeight[] =
    {'m','i','n','-','h','e','i','g','h','t',0};
104 105
static const WCHAR attrOverflow[] =
    {'o','v','e','r','f','l','o','w',0};
106 107
static const WCHAR attrPaddingLeft[] =
    {'p','a','d','d','i','n','g','-','l','e','f','t',0};
108 109
static const WCHAR attrPosition[] =
    {'p','o','s','i','t','i','o','n',0};
110 111
static const WCHAR attrTextAlign[] =
    {'t','e','x','t','-','a','l','i','g','n',0};
112 113
static const WCHAR attrTextDecoration[] =
    {'t','e','x','t','-','d','e','c','o','r','a','t','i','o','n',0};
114 115
static const WCHAR attrTop[] =
    {'t','o','p',0};
116 117
static const WCHAR attrVerticalAlign[] =
    {'v','e','r','t','i','c','a','l','-','a','l','i','g','n',0};
118 119
static const WCHAR attrVisibility[] =
    {'v','i','s','i','b','i','l','i','t','y',0};
120 121
static const WCHAR attrWidth[] =
    {'w','i','d','t','h',0};
122 123
static const WCHAR attrZIndex[] =
    {'z','-','i','n','d','e','x',0};
124

125 126 127 128 129 130 131
static const struct{
    const WCHAR *name;
    DISPID dispid;
} style_tbl[] = {
    {attrBackground,           DISPID_IHTMLSTYLE_BACKGROUND},
    {attrBackgroundColor,      DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
    {attrBackgroundImage,      DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
132
    {attrBackgroundPositionX,  DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONX},
133
    {attrBackgroundPositionY,  DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
134
    {attrBackgroundRepeat,     DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
135
    {attrBorder,               DISPID_IHTMLSTYLE_BORDER},
136
    {attrBorderBottomStyle,    DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
137
    {attrBorderBottomWidth,    DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
138
    {attrBorderColor,          DISPID_IHTMLSTYLE_BORDERCOLOR},
139
    {attrBorderLeft,           DISPID_IHTMLSTYLE_BORDERLEFT},
140
    {attrBorderLeftStyle,      DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
141
    {attrBorderRightStyle,     DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
142
    {attrBorderRightWidth,     DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
143
    {attrBorderStyle,          DISPID_IHTMLSTYLE_BORDERSTYLE},
144
    {attrBorderTopStyle,       DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
145
    {attrBorderTopWidth,       DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
146
    {attrBorderWidth,          DISPID_IHTMLSTYLE_BORDERWIDTH},
147 148 149
    {attrColor,                DISPID_IHTMLSTYLE_COLOR},
    {attrCursor,               DISPID_IHTMLSTYLE_CURSOR},
    {attrDisplay,              DISPID_IHTMLSTYLE_DISPLAY},
150
    {attrFilter,               DISPID_IHTMLSTYLE_FILTER},
151 152 153
    {attrFontFamily,           DISPID_IHTMLSTYLE_FONTFAMILY},
    {attrFontSize,             DISPID_IHTMLSTYLE_FONTSIZE},
    {attrFontStyle,            DISPID_IHTMLSTYLE_FONTSTYLE},
154
    {attrFontVariant,          DISPID_IHTMLSTYLE_FONTVARIANT},
155 156 157 158 159 160
    {attrFontWeight,           DISPID_IHTMLSTYLE_FONTWEIGHT},
    {attrHeight,               DISPID_IHTMLSTYLE_HEIGHT},
    {attrLeft,                 DISPID_IHTMLSTYLE_LEFT},
    {attrMargin,               DISPID_IHTMLSTYLE_MARGIN},
    {attrMarginLeft,           DISPID_IHTMLSTYLE_MARGINLEFT},
    {attrMarginRight,          DISPID_IHTMLSTYLE_MARGINRIGHT},
161
    {attrMinHeight,            DISPID_IHTMLSTYLE4_MINHEIGHT},
162
    {attrOverflow,             DISPID_IHTMLSTYLE_OVERFLOW},
163 164
    {attrPaddingLeft,          DISPID_IHTMLSTYLE_PADDINGLEFT},
    {attrPosition,             DISPID_IHTMLSTYLE2_POSITION},
165
    {attrTextAlign,            DISPID_IHTMLSTYLE_TEXTALIGN},
166 167 168 169 170 171
    {attrTextDecoration,       DISPID_IHTMLSTYLE_TEXTDECORATION},
    {attrTop,                  DISPID_IHTMLSTYLE_TOP},
    {attrVerticalAlign,        DISPID_IHTMLSTYLE_VERTICALALIGN},
    {attrVisibility,           DISPID_IHTMLSTYLE_VISIBILITY},
    {attrWidth,                DISPID_IHTMLSTYLE_WIDTH},
    {attrZIndex,               DISPID_IHTMLSTYLE_ZINDEX}
172 173
};

174 175 176 177
static const WCHAR valLineThrough[] =
    {'l','i','n','e','-','t','h','r','o','u','g','h',0};
static const WCHAR valUnderline[] =
    {'u','n','d','e','r','l','i','n','e',0};
178 179
static const WCHAR szNormal[] =
    {'n','o','r','m','a','l',0};
180 181
static const WCHAR styleNone[] =
    {'n','o','n','e',0};
182 183
static const WCHAR valOverline[] =
    {'o','v','e','r','l','i','n','e',0};
184 185
static const WCHAR valBlink[] =
    {'b','l','i','n','k',0};
186

187 188 189
static const WCHAR px_formatW[] = {'%','d','p','x',0};
static const WCHAR emptyW[] = {0};

190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
static LPWSTR fix_px_value(LPCWSTR val)
{
    LPCWSTR ptr = val;

    while(*ptr) {
        while(*ptr && isspaceW(*ptr))
            ptr++;
        if(!*ptr)
            break;

        while(*ptr && isdigitW(*ptr))
            ptr++;

        if(!*ptr || isspaceW(*ptr)) {
            LPWSTR ret, p;
            int len = strlenW(val)+1;

            ret = heap_alloc((len+2)*sizeof(WCHAR));
            memcpy(ret, val, (ptr-val)*sizeof(WCHAR));
            p = ret + (ptr-val);
            *p++ = 'p';
            *p++ = 'x';
            strcpyW(p, ptr);

            TRACE("fixed %s -> %s\n", debugstr_w(val), debugstr_w(ret));

            return ret;
        }

        while(*ptr && !isspaceW(*ptr))
            ptr++;
    }

    return NULL;
}

226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
static LPWSTR fix_url_value(LPCWSTR val)
{
    WCHAR *ret, *ptr;

    static const WCHAR urlW[] = {'u','r','l','('};

    if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
        return NULL;

    ret = heap_strdupW(val);

    for(ptr = ret; *ptr; ptr++) {
        if(*ptr == '\\')
            *ptr = '/';
    }

    return ret;
}

245
HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCWSTR value, DWORD flags)
246 247
{
    nsAString str_name, str_value, str_empty;
248
    LPWSTR val = NULL;
249 250 251 252
    nsresult nsres;

    static const PRUnichar wszEmpty[] = {0};

253 254
    if(flags & ATTR_FIX_PX)
        val = fix_px_value(value);
255 256
    if(flags & ATTR_FIX_URL)
        val = fix_url_value(value);
257

258
    nsAString_Init(&str_name, style_tbl[sid].name);
259
    nsAString_Init(&str_value, val ? val : value);
260
    nsAString_Init(&str_empty, wszEmpty);
261
    heap_free(val);
262

263
    nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
264 265 266 267 268 269 270 271 272 273
    if(NS_FAILED(nsres))
        ERR("SetProperty failed: %08x\n", nsres);

    nsAString_Finish(&str_name);
    nsAString_Finish(&str_value);
    nsAString_Finish(&str_empty);

    return S_OK;
}

274
HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *value, DWORD flags)
275 276 277 278 279 280 281 282
{
    switch(V_VT(value)) {
    case VT_NULL:
        return set_nsstyle_attr(nsstyle, sid, emptyW, flags);

    case VT_BSTR:
        return set_nsstyle_attr(nsstyle, sid, V_BSTR(value), flags);

283 284 285 286 287 288 289
    case VT_I4: {
        WCHAR str[14];
        static const WCHAR format[] = {'%','d',0};

        wsprintfW(str, format, V_I4(value));
        return set_nsstyle_attr(nsstyle, sid, str, flags);
    }
290 291 292 293 294 295 296 297 298
    default:
        FIXME("not implemented vt %d\n", V_VT(value));
        return E_NOTIMPL;

    }

    return S_OK;
}

299 300 301 302 303
static inline HRESULT set_style_attr(HTMLStyle *This, styleid_t sid, LPCWSTR value, DWORD flags)
{
    return set_nsstyle_attr(This->nsstyle, sid, value, flags);
}

304
static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, nsAString *value)
305
{
306
    nsAString str_name;
307 308
    nsresult nsres;

309
    nsAString_Init(&str_name, style_tbl[sid].name);
310

311
    nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
312
    if(NS_FAILED(nsres)) {
313
        ERR("SetProperty failed: %08x\n", nsres);
314 315 316 317 318 319 320 321
        return E_FAIL;
    }

    nsAString_Finish(&str_name);

    return NS_OK;
}

322
HRESULT get_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, BSTR *p)
323 324 325 326 327 328
{
    nsAString str_value;
    const PRUnichar *value;

    nsAString_Init(&str_value, NULL);

329
    get_nsstyle_attr_nsval(nsstyle, sid, &str_value);
330

331
    nsAString_GetData(&str_value, &value);
332
    *p = *value ? SysAllocString(value) : NULL;
333 334 335

    nsAString_Finish(&str_value);

336
    TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_w(*p));
337 338 339
    return S_OK;
}

340
HRESULT get_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, VARIANT *p, DWORD flags)
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
{
    nsAString str_value;
    const PRUnichar *value;
    BOOL set = FALSE;

    nsAString_Init(&str_value, NULL);

    get_nsstyle_attr_nsval(nsstyle, sid, &str_value);

    nsAString_GetData(&str_value, &value);

    if(flags & ATTR_STR_TO_INT) {
        const PRUnichar *ptr = value;
        BOOL neg = FALSE;
        INT i = 0;

        if(*ptr == '-') {
            neg = TRUE;
            ptr++;
        }

        while(isdigitW(*ptr))
            i = i*10 + (*ptr++ - '0');

        if(!*ptr) {
            V_VT(p) = VT_I4;
            V_I4(p) = neg ? -i : i;
            set = TRUE;
        }
    }

    if(!set) {
        BSTR str = NULL;

        if(*value) {
            str = SysAllocString(value);
            if(!str)
                return E_OUTOFMEMORY;
        }

        V_VT(p) = VT_BSTR;
        V_BSTR(p) = str;
    }

    nsAString_Finish(&str_value);

387
    TRACE("%s -> %s\n", debugstr_w(style_tbl[sid].name), debugstr_variant(p));
388 389 390
    return S_OK;
}

391 392 393 394 395
static inline HRESULT get_style_attr(HTMLStyle *This, styleid_t sid, BSTR *p)
{
    return get_nsstyle_attr(This->nsstyle, sid, p);
}

396
static HRESULT check_style_attr_value(HTMLStyle *This, styleid_t sid, LPCWSTR exval, VARIANT_BOOL *p)
397 398 399 400 401
{
    nsAString str_value;
    const PRUnichar *value;

    nsAString_Init(&str_value, NULL);
402

403
    get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
404

405
    nsAString_GetData(&str_value, &value);
406 407 408
    *p = strcmpW(value, exval) ? VARIANT_FALSE : VARIANT_TRUE;
    nsAString_Finish(&str_value);

409
    TRACE("%s -> %x\n", debugstr_w(style_tbl[sid].name), *p);
410 411 412
    return S_OK;
}

413 414 415 416 417 418 419 420 421 422 423 424
static inline HRESULT set_style_pos(HTMLStyle *This, styleid_t sid, float value)
{
    WCHAR szValue[25];
    WCHAR szFormat[] = {'%','.','0','f','p','x',0};

    value = floor(value);

    sprintfW(szValue, szFormat, value);

    return set_style_attr(This, sid, szValue, 0);
}

425
static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p)
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
{
    nsAString str_value;
    HRESULT hres;
    WCHAR pxW[] = {'p','x',0};

    TRACE("%p %d %p\n", This, sid, p);

    *p = 0.0f;

    nsAString_Init(&str_value, NULL);

    hres = get_nsstyle_attr_nsval(This->nsstyle, sid, &str_value);
    if(hres == S_OK)
    {
        WCHAR *ptr;
        const PRUnichar *value;

        nsAString_GetData(&str_value, &value);
        if(value)
        {
            *p = strtolW(value, &ptr, 10);

            if(*ptr && strcmpW(ptr, pxW))
            {
                nsAString_Finish(&str_value);
                FIXME("only px values are currently supported\n");
                return E_FAIL;
            }
        }
    }

    TRACE("ret %f\n", *p);

    nsAString_Finish(&str_value);

    return hres;
}

464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
static BOOL is_valid_border_style(BSTR v)
{
    static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0};
    static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0};
    static const WCHAR styleSolid[]  = {'s','o','l','i','d',0};
    static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0};
    static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0};
    static const WCHAR styleRidge[]  = {'r','i','d','g','e',0};
    static const WCHAR styleInset[]  = {'i','n','s','e','t',0};
    static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0};

    TRACE("%s\n", debugstr_w(v));

    if(!v || strcmpiW(v, styleNone)   == 0 || strcmpiW(v, styleDotted) == 0 ||
             strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid)  == 0 ||
             strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 ||
             strcmpiW(v, styleRidge)  == 0 || strcmpiW(v, styleInset)  == 0 ||
             strcmpiW(v, styleOutset) == 0 )
    {
        return TRUE;
    }

    return FALSE;
}

489 490 491 492 493 494 495 496 497 498 499 500 501 502
#define HTMLSTYLE_THIS(iface) DEFINE_THIS(HTMLStyle, HTMLStyle, iface)

static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);

    *ppv = NULL;

    if(IsEqualGUID(&IID_IUnknown, riid)) {
        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
        *ppv = HTMLSTYLE(This);
    }else if(IsEqualGUID(&IID_IHTMLStyle, riid)) {
        TRACE("(%p)->(IID_IHTMLStyle %p)\n", This, ppv);
        *ppv = HTMLSTYLE(This);
503 504 505
    }else if(IsEqualGUID(&IID_IHTMLStyle2, riid)) {
        TRACE("(%p)->(IID_IHTMLStyle2 %p)\n", This, ppv);
        *ppv = HTMLSTYLE2(This);
506 507 508
    }else if(IsEqualGUID(&IID_IHTMLStyle3, riid)) {
        TRACE("(%p)->(IID_IHTMLStyle3 %p)\n", This, ppv);
        *ppv = HTMLSTYLE3(This);
509 510 511
    }else if(IsEqualGUID(&IID_IHTMLStyle4, riid)) {
        TRACE("(%p)->(IID_IHTMLStyle4 %p)\n", This, ppv);
        *ppv = HTMLSTYLE4(This);
512 513
    }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
        return *ppv ? S_OK : E_NOINTERFACE;
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
    }

    if(*ppv) {
        IUnknown_AddRef((IUnknown*)*ppv);
        return S_OK;
    }

    WARN("unsupported %s\n", debugstr_guid(riid));
    return E_NOINTERFACE;
}

static ULONG WINAPI HTMLStyle_AddRef(IHTMLStyle *iface)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    LONG ref = InterlockedIncrement(&This->ref);

    TRACE("(%p) ref=%d\n", This, ref);

    return ref;
}

static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    LONG ref = InterlockedDecrement(&This->ref);

    TRACE("(%p) ref=%d\n", This, ref);

542 543 544
    if(!ref) {
        if(This->nsstyle)
            nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
545
        heap_free(This);
546
    }
547 548 549 550 551 552 553

    return ref;
}

static HRESULT WINAPI HTMLStyle_GetTypeInfoCount(IHTMLStyle *iface, UINT *pctinfo)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
554
    return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
555 556 557 558 559 560
}

static HRESULT WINAPI HTMLStyle_GetTypeInfo(IHTMLStyle *iface, UINT iTInfo,
                                              LCID lcid, ITypeInfo **ppTInfo)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
561
    return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
562 563 564 565 566 567 568
}

static HRESULT WINAPI HTMLStyle_GetIDsOfNames(IHTMLStyle *iface, REFIID riid,
                                                LPOLESTR *rgszNames, UINT cNames,
                                                LCID lcid, DISPID *rgDispId)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
569
    return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
570 571 572 573 574 575 576
}

static HRESULT WINAPI HTMLStyle_Invoke(IHTMLStyle *iface, DISPID dispIdMember,
                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
577 578
    return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid,
            wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
579 580 581 582 583
}

static HRESULT WINAPI HTMLStyle_put_fontFamily(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
584 585 586

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

587
    return set_style_attr(This, STYLEID_FONT_FAMILY, v, 0);
588 589 590 591 592
}

static HRESULT WINAPI HTMLStyle_get_fontFamily(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
593 594 595

    TRACE("(%p)->(%p)\n", This, p);

596
    return get_style_attr(This, STYLEID_FONT_FAMILY, p);
597 598 599 600 601
}

static HRESULT WINAPI HTMLStyle_put_fontStyle(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
602 603 604 605 606 607 608 609 610 611 612 613 614
    static const WCHAR szItalic[]  = {'i','t','a','l','i','c',0};
    static const WCHAR szOblique[]  = {'o','b','l','i','q','u','e',0};

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    /* fontStyle can only be one of the follow values. */
    if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szItalic, v) == 0 ||
             strcmpiW(szOblique, v) == 0)
    {
        return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, v, 0);
    }

    return E_INVALIDARG;
615 616 617 618 619
}

static HRESULT WINAPI HTMLStyle_get_fontStyle(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
620 621 622

    TRACE("(%p)->(%p)\n", This, p);

623
    return get_style_attr(This, STYLEID_FONT_STYLE, p);
624 625 626 627 628
}

static HRESULT WINAPI HTMLStyle_put_fontVariant(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
629 630 631 632 633 634 635 636 637 638 639
    static const WCHAR szCaps[]  = {'s','m','a','l','l','-','c','a','p','s',0};

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    /* fontVariant can only be one of the follow values. */
    if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(szCaps, v) == 0)
    {
        return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, v, 0);
    }

    return E_INVALIDARG;
640 641 642 643 644
}

static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
645 646 647 648 649 650
    TRACE("(%p)->(%p)\n", This, p);

    if(!p)
       return E_INVALIDARG;

    return get_style_attr(This, STYLEID_FONT_VARIANT, p);
651 652 653 654 655
}

static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
    static const WCHAR styleBold[] = {'b','o','l','d',0};
    static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0};
    static const WCHAR styleLighter[]  = {'l','i','g','h','t','e','r',0};
    static const WCHAR style100[] = {'1','0','0',0};
    static const WCHAR style200[] = {'2','0','0',0};
    static const WCHAR style300[] = {'3','0','0',0};
    static const WCHAR style400[] = {'4','0','0',0};
    static const WCHAR style500[] = {'5','0','0',0};
    static const WCHAR style600[] = {'6','0','0',0};
    static const WCHAR style700[] = {'7','0','0',0};
    static const WCHAR style800[] = {'8','0','0',0};
    static const WCHAR style900[] = {'9','0','0',0};

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    /* fontWeight can only be one of the following */
    if(!v || strcmpiW(szNormal, v) == 0    || strcmpiW(styleBold, v) == 0    ||
             strcmpiW(styleBolder, v) == 0 || strcmpiW(styleLighter, v) == 0 ||
             strcmpiW(style100, v) == 0    || strcmpiW(style200, v) == 0     ||
             strcmpiW(style300, v) == 0    || strcmpiW(style400, v) == 0     ||
             strcmpiW(style500, v) == 0    || strcmpiW(style600, v) == 0     ||
             strcmpiW(style700, v) == 0    || strcmpiW(style800, v) == 0     ||
             strcmpiW(style900, v) == 0
             )
    {
        return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0);
    }

    return E_INVALIDARG;
685 686 687 688 689
}

static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
690 691 692

    TRACE("(%p)->(%p)\n", This, p);

693
    return get_style_attr(This, STYLEID_FONT_WEIGHT, p);
694 695 696 697 698
}

static HRESULT WINAPI HTMLStyle_put_fontSize(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
699 700 701 702 703

    TRACE("(%p)->(v%d)\n", This, V_VT(&v));

    switch(V_VT(&v)) {
    case VT_BSTR:
704
        return set_style_attr(This, STYLEID_FONT_SIZE, V_BSTR(&v), 0);
705 706 707 708 709
    default:
        FIXME("not supported vt %d\n", V_VT(&v));
    }

    return S_OK;
710 711 712 713 714
}

static HRESULT WINAPI HTMLStyle_get_fontSize(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
715 716 717 718

    TRACE("(%p)->(%p)\n", This, p);

    V_VT(p) = VT_BSTR;
719
    return get_style_attr(This, STYLEID_FONT_SIZE, &V_BSTR(p));
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738
}

static HRESULT WINAPI HTMLStyle_put_font(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_font(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_color(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
739 740 741 742 743 744

    TRACE("(%p)->(v%d)\n", This, V_VT(&v));

    switch(V_VT(&v)) {
    case VT_BSTR:
        TRACE("%s\n", debugstr_w(V_BSTR(&v)));
745
        return set_style_attr(This, STYLEID_COLOR, V_BSTR(&v), 0);
746 747 748 749 750

    default:
        FIXME("unsupported vt=%d\n", V_VT(&v));
    }

751 752 753 754 755 756
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_color(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
757 758 759 760

    TRACE("(%p)->(%p)\n", This, p);

    V_VT(p) = VT_BSTR;
761
    return get_style_attr(This, STYLEID_COLOR, &V_BSTR(p));
762 763 764 765 766
}

static HRESULT WINAPI HTMLStyle_put_background(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
767 768 769

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

770
    return set_style_attr(This, STYLEID_BACKGROUND, v, 0);
771 772 773 774 775
}

static HRESULT WINAPI HTMLStyle_get_background(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
776 777 778

    TRACE("(%p)->(%p)\n", This, p);

779
    return get_style_attr(This, STYLEID_BACKGROUND, p);
780 781 782 783 784
}

static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
785 786 787 788 789

    TRACE("(%p)->(v%d)\n", This, V_VT(&v));

    switch(V_VT(&v)) {
    case VT_BSTR:
790
        return set_style_attr(This, STYLEID_BACKGROUND_COLOR, V_BSTR(&v), 0);
791 792 793 794 795
    case VT_I4: {
        WCHAR value[10];
        static const WCHAR format[] = {'#','%','0','6','x',0};

        wsprintfW(value, format, V_I4(&v));
796
        return set_style_attr(This, STYLEID_BACKGROUND_COLOR, value, 0);
797 798 799 800 801 802
    }
    default:
        FIXME("unsupported vt %d\n", V_VT(&v));
    }

    return S_OK;
803 804 805 806 807
}

static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
808 809 810 811
    TRACE("(%p)->(%p)\n", This, p);

    V_VT(p) = VT_BSTR;
    return get_style_attr(This, STYLEID_BACKGROUND_COLOR, &V_BSTR(p));
812 813 814 815 816
}

static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
817 818 819

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

820
    return set_style_attr(This, STYLEID_BACKGROUND_IMAGE, v, ATTR_FIX_URL);
821 822 823 824 825
}

static HRESULT WINAPI HTMLStyle_get_backgroundImage(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
826 827 828 829

    TRACE("(%p)->(%p)\n", This, p);

    return get_style_attr(This, STYLEID_BACKGROUND_IMAGE, p);
830 831 832 833 834
}

static HRESULT WINAPI HTMLStyle_put_backgroundRepeat(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849
    static const WCHAR styleRepeat[]   = {'r','e','p','e','a','t',0};
    static const WCHAR styleNoRepeat[] = {'n','o','-','r','e','p','e','a','t',0};
    static const WCHAR styleRepeatX[]  = {'r','e','p','e','a','t','-','x',0};
    static const WCHAR styleRepeatY[]  = {'r','e','p','e','a','t','-','y',0};

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    /* fontWeight can only be one of the following */
    if(!v || strcmpiW(styleRepeat, v) == 0    || strcmpiW(styleNoRepeat, v) == 0    ||
             strcmpiW(styleRepeatX, v) == 0 || strcmpiW(styleRepeatY, v) == 0 )
    {
        return set_style_attr(This, STYLEID_BACKGROUND_REPEAT , v, 0);
    }

    return E_INVALIDARG;
850 851 852 853 854
}

static HRESULT WINAPI HTMLStyle_get_backgroundRepeat(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
855 856 857 858

    TRACE("(%p)->(%p)\n", This, p);

    return get_style_attr(This, STYLEID_BACKGROUND_REPEAT, p);
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891
}

static HRESULT WINAPI HTMLStyle_put_backgroundAttachment(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_backgroundAttachment(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_backgroundPosition(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_backgroundPosition(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
892 893
    TRACE("(%p)->(v%d)\n", This, V_VT(&v));
    return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_POSITION_X, &v, 0);
894 895 896 897 898
}

static HRESULT WINAPI HTMLStyle_get_backgroundPositionX(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
899 900
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_POSITION_X, p, 0);
901 902 903 904 905
}

static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
906 907
    TRACE("(%p)->(v%d)\n", This, V_VT(&v));
    return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_POSITION_Y, &v, 0);
908 909 910 911 912
}

static HRESULT WINAPI HTMLStyle_get_backgroundPositionY(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
913 914
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_POSITION_Y, p, 0);
915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947
}

static HRESULT WINAPI HTMLStyle_put_wordSpacing(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_wordSpacing(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_letterSpacing(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_letterSpacing(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_textDecoration(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
948 949 950 951 952 953 954 955 956 957 958 959

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    /* textDecoration can only be one of the following */
    if(!v || strcmpiW(styleNone, v)   == 0 || strcmpiW(valUnderline, v)   == 0 ||
             strcmpiW(valOverline, v) == 0 || strcmpiW(valLineThrough, v) == 0 ||
             strcmpiW(valBlink, v)    == 0)
    {
        return set_style_attr(This, STYLEID_TEXT_DECORATION , v, 0);
    }

    return E_INVALIDARG;
960 961 962 963 964
}

static HRESULT WINAPI HTMLStyle_get_textDecoration(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
965 966 967

    TRACE("(%p)->(%p)\n", This, p);

968
    return get_style_attr(This, STYLEID_TEXT_DECORATION, p);
969 970 971 972 973
}

static HRESULT WINAPI HTMLStyle_put_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
974 975 976 977

    TRACE("(%p)->(%x)\n", This, v);

    return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? styleNone : emptyW, 0);
978 979 980 981 982
}

static HRESULT WINAPI HTMLStyle_get_textDecorationNone(IHTMLStyle *iface, VARIANT_BOOL *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
983 984 985 986

    TRACE("(%p)->(%p)\n", This, p);

    return check_style_attr_value(This, STYLEID_TEXT_DECORATION, styleNone, p);
987 988 989 990 991
}

static HRESULT WINAPI HTMLStyle_put_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
992 993 994 995

    TRACE("(%p)->(%x)\n", This, v);

    return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valUnderline : emptyW, 0);
996 997 998 999 1000
}

static HRESULT WINAPI HTMLStyle_get_textDecorationUnderline(IHTMLStyle *iface, VARIANT_BOOL *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1001 1002 1003

    TRACE("(%p)->(%p)\n", This, p);

1004
    return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valUnderline, p);
1005 1006 1007 1008 1009
}

static HRESULT WINAPI HTMLStyle_put_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1010 1011 1012 1013

    TRACE("(%p)->(%x)\n", This, v);

    return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valOverline : emptyW, 0);
1014 1015 1016 1017 1018
}

static HRESULT WINAPI HTMLStyle_get_textDecorationOverline(IHTMLStyle *iface, VARIANT_BOOL *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1019 1020 1021 1022

    TRACE("(%p)->(%p)\n", This, p);

    return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valOverline, p);
1023 1024 1025 1026 1027
}

static HRESULT WINAPI HTMLStyle_put_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1028 1029 1030 1031

    TRACE("(%p)->(%x)\n", This, v);

    return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valLineThrough : emptyW, 0);
1032 1033 1034 1035 1036
}

static HRESULT WINAPI HTMLStyle_get_textDecorationLineThrough(IHTMLStyle *iface, VARIANT_BOOL *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1037 1038 1039

    TRACE("(%p)->(%p)\n", This, p);

1040
    return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valLineThrough, p);
1041 1042 1043 1044 1045
}

static HRESULT WINAPI HTMLStyle_put_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1046 1047 1048 1049

    TRACE("(%p)->(%x)\n", This, v);

    return set_style_attr(This, STYLEID_TEXT_DECORATION, v ? valBlink : emptyW, 0);
1050 1051 1052 1053 1054
}

static HRESULT WINAPI HTMLStyle_get_textDecorationBlink(IHTMLStyle *iface, VARIANT_BOOL *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1055 1056 1057 1058

    TRACE("(%p)->(%p)\n", This, p);

    return check_style_attr_value(This, STYLEID_TEXT_DECORATION, valBlink, p);
1059 1060 1061 1062 1063
}

static HRESULT WINAPI HTMLStyle_put_verticalAlign(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075

    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));

    switch(V_VT(&v)) {
    case VT_BSTR:
        return set_style_attr(This, STYLEID_VERTICAL_ALIGN, V_BSTR(&v), 0);
    default:
        FIXME("not implemented vt %d\n", V_VT(&v));
        return E_NOTIMPL;
    }

    return S_OK;
1076 1077 1078 1079 1080
}

static HRESULT WINAPI HTMLStyle_get_verticalAlign(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
    BSTR ret;
    HRESULT hres;

    TRACE("(%p)->(%p)\n", This, p);

    hres = get_style_attr(This, STYLEID_VERTICAL_ALIGN, &ret);
    if(FAILED(hres))
        return hres;

    V_VT(p) = VT_BSTR;
    V_BSTR(p) = ret;
    return S_OK;
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111
}

static HRESULT WINAPI HTMLStyle_put_textTransform(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_textTransform(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_textAlign(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1112 1113 1114 1115

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    return set_style_attr(This, STYLEID_TEXT_ALIGN, v, 0);
1116 1117 1118 1119 1120
}

static HRESULT WINAPI HTMLStyle_get_textAlign(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1121 1122 1123 1124

    TRACE("(%p)->(%p)\n", This, p);

    return get_style_attr(This, STYLEID_TEXT_ALIGN, p);
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
}

static HRESULT WINAPI HTMLStyle_put_textIndent(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_textIndent(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_lineHeight(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_marginRight(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1172 1173 1174 1175 1176

    TRACE("(%p)->(v(%d))\n", This, V_VT(&v));

    switch(V_VT(&v)) {
    case VT_NULL:
1177
        return set_style_attr(This, STYLEID_MARGIN_RIGHT, emptyW, 0);
1178 1179 1180 1181
    case VT_I4: {
        WCHAR buf[14];

        wsprintfW(buf, px_formatW, V_I4(&v));
1182
        return set_style_attr(This, STYLEID_MARGIN_RIGHT, buf, 0);
1183 1184
    }
    case VT_BSTR:
1185
        return set_style_attr(This, STYLEID_MARGIN_RIGHT, V_BSTR(&v), 0);
1186 1187 1188 1189
    default:
        FIXME("Unsupported vt=%d\n", V_VT(&v));
    }

1190 1191 1192 1193 1194 1195
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_marginRight(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1196 1197
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216
}

static HRESULT WINAPI HTMLStyle_put_marginBottom(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_marginBottom(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_marginLeft(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1217 1218 1219 1220

    switch(V_VT(&v)) {
    case VT_NULL:
        TRACE("(%p)->(NULL)\n", This);
1221
        return set_style_attr(This, STYLEID_MARGIN_LEFT, emptyW, 0);
1222 1223 1224 1225 1226 1227
    case VT_I4: {
        WCHAR buf[14];

        TRACE("(%p)->(%d)\n", This, V_I4(&v));

        wsprintfW(buf, px_formatW, V_I4(&v));
1228
        return set_style_attr(This, STYLEID_MARGIN_LEFT, buf, 0);
1229 1230 1231
    }
    case VT_BSTR:
        TRACE("(%p)->(%s)\n", This, debugstr_w(V_BSTR(&v)));
1232
        return set_style_attr(This, STYLEID_MARGIN_LEFT, V_BSTR(&v), 0);
1233 1234 1235 1236
    default:
        FIXME("Unsupported vt=%d\n", V_VT(&v));
    }

1237 1238 1239 1240 1241 1242
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_margin(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1243 1244 1245

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

1246
    return set_style_attr(This, STYLEID_MARGIN, v, 0);
1247 1248 1249 1250 1251
}

static HRESULT WINAPI HTMLStyle_get_margin(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1252 1253 1254

    TRACE("(%p)->(%p)\n", This, p);

1255
    return get_style_attr(This, STYLEID_MARGIN, p);
1256 1257 1258 1259 1260
}

static HRESULT WINAPI HTMLStyle_get_marginLeft(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1261 1262
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
}

static HRESULT WINAPI HTMLStyle_put_paddingTop(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_paddingTop(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_paddingRight(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_paddingRight(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_paddingBottom(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_paddingBottom(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_paddingLeft(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1310 1311 1312 1313 1314 1315 1316 1317

    TRACE("(%p)->(vt=%d)\n", This, V_VT(&v));

    switch(V_VT(&v)) {
    case VT_I4: {
        WCHAR buf[14];

        wsprintfW(buf, px_formatW, V_I4(&v));
1318
        return set_style_attr(This, STYLEID_PADDING_LEFT, buf, 0);
1319 1320
    }
    case VT_BSTR:
1321
        return set_style_attr(This, STYLEID_PADDING_LEFT, V_BSTR(&v), 0);
1322 1323 1324 1325
    default:
        FIXME("unsupported vt=%d\n", V_VT(&v));
    }

1326 1327 1328 1329 1330 1331
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_paddingLeft(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343
    BSTR ret;
    HRESULT hres;

    TRACE("(%p)->(%p)\n", This, p);

    hres = get_style_attr(This, STYLEID_PADDING_LEFT, &ret);
    if(FAILED(hres))
        return hres;

    V_VT(p) = VT_BSTR;
    V_BSTR(p) = ret;
    return S_OK;
1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362
}

static HRESULT WINAPI HTMLStyle_put_padding(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_padding(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_border(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1363 1364 1365 1366

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    return set_style_attr(This, STYLEID_BORDER, v, 0);
1367 1368 1369 1370 1371
}

static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1372 1373 1374 1375

    TRACE("(%p)->(%p)\n", This, p);

    return get_style_attr(This, STYLEID_BORDER, p);
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422
}

static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1423 1424 1425

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

1426
    return set_style_attr(This, STYLEID_BORDER_LEFT, v, ATTR_FIX_PX);
1427 1428 1429 1430 1431
}

static HRESULT WINAPI HTMLStyle_get_borderLeft(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1432 1433 1434 1435

    TRACE("(%p)->(%p)\n", This, p);

    return get_style_attr(This, STYLEID_BORDER_LEFT, p);
1436 1437 1438 1439 1440
}

static HRESULT WINAPI HTMLStyle_put_borderColor(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1441 1442 1443 1444

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    return set_style_attr(This, STYLEID_BORDER_COLOR, v, 0);
1445 1446 1447 1448 1449
}

static HRESULT WINAPI HTMLStyle_get_borderColor(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1450 1451 1452 1453

    TRACE("(%p)->(%p)\n", This, p);

    return get_style_attr(This, STYLEID_BORDER_COLOR, p);
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514
}

static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1515 1516
    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
    return set_style_attr(This, STYLEID_BORDER_WIDTH, v, ATTR_FIX_PX);
1517 1518 1519 1520 1521
}

static HRESULT WINAPI HTMLStyle_get_borderWidth(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1522 1523
    TRACE("(%p)->(%p)\n", This, p);
    return get_style_attr(This, STYLEID_BORDER_WIDTH, p);
1524 1525 1526 1527 1528
}

static HRESULT WINAPI HTMLStyle_put_borderTopWidth(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1529 1530
    TRACE("(%p)->(v%d)\n", This, V_VT(&v));
    return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, &v, 0);
1531 1532 1533 1534 1535
}

static HRESULT WINAPI HTMLStyle_get_borderTopWidth(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1536 1537 1538 1539

    TRACE("(%p)->(%p)\n", This, p);

    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, p, 0);
1540 1541 1542 1543 1544
}

static HRESULT WINAPI HTMLStyle_put_borderRightWidth(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1545 1546
    TRACE("(%p)->(v%d)\n", This, V_VT(&v));
    return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, &v, 0);
1547 1548 1549 1550 1551
}

static HRESULT WINAPI HTMLStyle_get_borderRightWidth(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1552 1553
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, p, 0);
1554 1555 1556 1557 1558
}

static HRESULT WINAPI HTMLStyle_put_borderBottomWidth(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1559 1560 1561

    TRACE("(%p)->(v%d)\n", This, V_VT(&v));
    return set_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, &v, 0);
1562 1563 1564 1565 1566
}

static HRESULT WINAPI HTMLStyle_get_borderBottomWidth(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1567 1568
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, p, 0);
1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587
}

static HRESULT WINAPI HTMLStyle_put_borderLeftWidth(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_borderLeftWidth(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_borderStyle(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626
    static const WCHAR styleWindowInset[]  = {'w','i','n','d','o','w','-','i','n','s','e','t',0};
    HRESULT hres = S_OK;
    BSTR pstyle;
    int i=0;
    int last = 0;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    while(v[i] && hres == S_OK)
    {
        if(v[i] == (WCHAR)' ')
        {
            pstyle = SysAllocStringLen(&v[last], (i-last));
            if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
            {
                TRACE("1. Invalid style (%s)\n", debugstr_w(pstyle));
                hres = E_INVALIDARG;
            }
            SysFreeString(pstyle);
            last = i+1;
        }
        i++;
    }

    if(hres == S_OK)
    {
        pstyle = SysAllocStringLen(&v[last], i-last);
        if( !(is_valid_border_style(pstyle) || strcmpiW(styleWindowInset, pstyle) == 0))
        {
            TRACE("2. Invalid style (%s)\n", debugstr_w(pstyle));
            hres = E_INVALIDARG;
        }
        SysFreeString(pstyle);
    }

    if(hres == S_OK)
        hres = set_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, v, 0);

    return hres;
1627 1628 1629 1630 1631
}

static HRESULT WINAPI HTMLStyle_get_borderStyle(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1632 1633
    TRACE("(%p)->(%p)\n", This, p);
    return get_style_attr(This, STYLEID_BORDER_STYLE, p);
1634 1635 1636 1637 1638
}

static HRESULT WINAPI HTMLStyle_put_borderTopStyle(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1639 1640 1641 1642 1643 1644
    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    if(!is_valid_border_style(v))
        return E_INVALIDARG;

    return set_style_attr(This, STYLEID_BORDER_TOP_STYLE, v, 0);
1645 1646 1647 1648 1649
}

static HRESULT WINAPI HTMLStyle_get_borderTopStyle(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1650 1651
    TRACE("(%p)->(%p)\n", This, p);
    return get_style_attr(This, STYLEID_BORDER_TOP_STYLE, p);
1652 1653 1654 1655 1656
}

static HRESULT WINAPI HTMLStyle_put_borderRightStyle(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1657 1658 1659 1660 1661 1662
    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    if(!is_valid_border_style(v))
        return E_INVALIDARG;

    return set_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, v, 0);
1663 1664 1665 1666 1667
}

static HRESULT WINAPI HTMLStyle_get_borderRightStyle(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1668 1669
    TRACE("(%p)->(%p)\n", This, p);
    return get_style_attr(This, STYLEID_BORDER_RIGHT_STYLE, p);
1670 1671 1672 1673 1674
}

static HRESULT WINAPI HTMLStyle_put_borderBottomStyle(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1675 1676 1677 1678 1679 1680
    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    if(!is_valid_border_style(v))
        return E_INVALIDARG;

    return set_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, v, 0);
1681 1682 1683 1684 1685
}

static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1686 1687
    TRACE("(%p)->(%p)\n", This, p);
    return get_style_attr(This, STYLEID_BORDER_BOTTOM_STYLE, p);
1688 1689 1690 1691 1692
}

static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1693 1694 1695 1696 1697 1698
    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    if(!is_valid_border_style(v))
        return E_INVALIDARG;

    return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0);
1699 1700 1701 1702 1703
}

static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1704 1705
    TRACE("(%p)->(%p)\n", This, p);
    return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p);
1706 1707 1708 1709 1710
}

static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1711 1712 1713 1714 1715 1716

    TRACE("(%p)->(v%d)\n", This, V_VT(&v));

    switch(V_VT(&v)) {
    case VT_BSTR:
        TRACE("%s\n", debugstr_w(V_BSTR(&v)));
1717
        return set_style_attr(This, STYLEID_WIDTH, V_BSTR(&v), 0);
1718 1719 1720 1721
    default:
        FIXME("unsupported vt %d\n", V_VT(&v));
    }

1722 1723 1724 1725 1726 1727
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1728 1729 1730 1731

    TRACE("(%p)->(%p)\n", This, p);

    V_VT(p) = VT_BSTR;
1732
    return get_style_attr(This, STYLEID_WIDTH, &V_BSTR(p));
1733 1734 1735 1736 1737
}

static HRESULT WINAPI HTMLStyle_put_height(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749

    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));

    switch(V_VT(&v)) {
    case VT_BSTR:
        return set_style_attr(This, STYLEID_HEIGHT, V_BSTR(&v), 0);
    default:
        FIXME("unimplemented vt %d\n", V_VT(&v));
        return E_NOTIMPL;
    }

    return S_OK;
1750 1751 1752 1753 1754
}

static HRESULT WINAPI HTMLStyle_get_height(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766
    BSTR ret;
    HRESULT hres;

    TRACE("(%p)->(%p)\n", This, p);

    hres = get_style_attr(This, STYLEID_HEIGHT, &ret);
    if(FAILED(hres))
        return hres;

    V_VT(p) = VT_BSTR;
    V_BSTR(p) = ret;
    return S_OK;
1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799
}

static HRESULT WINAPI HTMLStyle_put_styleFloat(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_styleFloat(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_clear(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_clear(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_display(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1800 1801 1802

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

1803
    return set_style_attr(This, STYLEID_DISPLAY, v, 0);
1804 1805 1806 1807 1808
}

static HRESULT WINAPI HTMLStyle_get_display(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1809 1810 1811

    TRACE("(%p)->(%p)\n", This, p);

1812
    return get_style_attr(This, STYLEID_DISPLAY, p);
1813 1814 1815 1816 1817
}

static HRESULT WINAPI HTMLStyle_put_visibility(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1818 1819 1820

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

1821
    return set_style_attr(This, STYLEID_VISIBILITY, v, 0);
1822 1823 1824 1825 1826
}

static HRESULT WINAPI HTMLStyle_get_visibility(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1827 1828 1829

    TRACE("(%p)->(%p)\n", This, p);

1830
    return get_style_attr(This, STYLEID_VISIBILITY, p);
1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905
}

static HRESULT WINAPI HTMLStyle_put_listStyleType(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_listStyleType(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_listStylePosition(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_listStylePosition(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_listStyleImage(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_listStyleImage(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_listStyle(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_listStyle(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_whiteSpace(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_whiteSpace(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_top(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1906 1907 1908

    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));

1909
    return set_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, &v, 0);
1910 1911 1912 1913 1914
}

static HRESULT WINAPI HTMLStyle_get_top(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926
    BSTR ret;
    HRESULT hres;

    TRACE("(%p)->(%p)\n", This, p);

    hres = get_style_attr(This, STYLEID_TOP, &ret);
    if(FAILED(hres))
        return hres;

    V_VT(p) = VT_BSTR;
    V_BSTR(p) = ret;
    return S_OK;
1927 1928 1929 1930 1931
}

static HRESULT WINAPI HTMLStyle_put_left(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1932 1933 1934

    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));

1935
    return set_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, &v, 0);
1936 1937 1938 1939 1940
}

static HRESULT WINAPI HTMLStyle_get_left(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952
    BSTR ret;
    HRESULT hres;

    TRACE("(%p)->(%p)\n", This, p);

    hres = get_style_attr(This, STYLEID_LEFT, &ret);
    if(FAILED(hres))
        return hres;

    V_VT(p) = VT_BSTR;
    V_BSTR(p) = ret;
    return S_OK;
1953 1954 1955 1956 1957
}

static HRESULT WINAPI HTMLStyle_get_position(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1958 1959
    TRACE("(%p)->(%p)\n", This, p);
    return IHTMLStyle2_get_position(HTMLSTYLE2(This), p);
1960 1961 1962 1963 1964
}

static HRESULT WINAPI HTMLStyle_put_zIndex(IHTMLStyle *iface, VARIANT v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1965 1966 1967 1968 1969 1970

    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));

    switch(V_VT(&v)) {
    case VT_BSTR:
        return set_style_attr(This, STYLEID_Z_INDEX, V_BSTR(&v), 0);
1971 1972 1973 1974 1975 1976 1977
    case VT_I4: {
        WCHAR value[14];
        static const WCHAR format[] = {'%','d',0};

        wsprintfW(value, format, V_I4(&v));
        return set_style_attr(This, STYLEID_Z_INDEX, value, 0);
    }
1978 1979 1980 1981 1982 1983
    default:
        FIXME("unimplemented vt %d\n", V_VT(&v));
        return E_NOTIMPL;
    }

    return S_OK;
1984 1985 1986 1987 1988
}

static HRESULT WINAPI HTMLStyle_get_zIndex(IHTMLStyle *iface, VARIANT *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1989 1990 1991 1992

    TRACE("(%p)->(%p)\n", This, p);

    return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
1993 1994 1995 1996 1997
}

static HRESULT WINAPI HTMLStyle_put_overflow(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
    static const WCHAR szVisible[] = {'v','i','s','i','b','l','e',0};
    static const WCHAR szScroll[]  = {'s','c','r','o','l','l',0};
    static const WCHAR szHidden[]  = {'h','i','d','d','e','n',0};
    static const WCHAR szAuto[]    = {'a','u','t','o',0};

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    /* overflow can only be one of the follow values. */
    if(!v || strcmpiW(szVisible, v) == 0 || strcmpiW(szScroll, v) == 0 ||
             strcmpiW(szHidden, v) == 0  || strcmpiW(szAuto, v) == 0)
    {
        return set_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, v, 0);
    }

    return E_INVALIDARG;
2013 2014
}

2015

2016 2017 2018
static HRESULT WINAPI HTMLStyle_get_overflow(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2019 2020 2021 2022 2023 2024 2025

    TRACE("(%p)->(%p)\n", This, p);

    if(!p)
       return E_INVALIDARG;

    return get_style_attr(This, STYLEID_OVERFLOW, p);
2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058
}

static HRESULT WINAPI HTMLStyle_put_pageBreakBefore(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_pageBreakBefore(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_pageBreakAfter(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072
    nsAString text_str;
    nsresult nsres;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    nsAString_Init(&text_str, v);
    nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str);
    nsAString_Finish(&text_str);
    if(NS_FAILED(nsres)) {
        FIXME("SetCssStyle failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
2073 2074 2075 2076 2077
}

static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097
    nsAString text_str;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    /* FIXME: Gecko style formatting is different than IE (uppercase). */
    nsAString_Init(&text_str, NULL);
    nsres = nsIDOMCSSStyleDeclaration_GetCssText(This->nsstyle, &text_str);
    if(NS_SUCCEEDED(nsres)) {
        const PRUnichar *text;

        nsAString_GetData(&text_str, &text);
        *p = *text ? SysAllocString(text) : NULL;
    }else {
        FIXME("GetCssStyle failed: %08x\n", nsres);
        *p = NULL;
    }

    nsAString_Finish(&text_str);
    return S_OK;
2098 2099
}

2100
static HRESULT WINAPI HTMLStyle_put_pixelTop(IHTMLStyle *iface, LONG v)
2101 2102 2103 2104 2105 2106
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

2107
static HRESULT WINAPI HTMLStyle_get_pixelTop(IHTMLStyle *iface, LONG *p)
2108 2109 2110 2111 2112 2113
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

2114
static HRESULT WINAPI HTMLStyle_put_pixelLeft(IHTMLStyle *iface, LONG v)
2115 2116 2117 2118 2119 2120
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

2121
static HRESULT WINAPI HTMLStyle_get_pixelLeft(IHTMLStyle *iface, LONG *p)
2122 2123 2124 2125 2126 2127
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

2128
static HRESULT WINAPI HTMLStyle_put_pixelWidth(IHTMLStyle *iface, LONG v)
2129 2130 2131 2132 2133 2134
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

2135
static HRESULT WINAPI HTMLStyle_get_pixelWidth(IHTMLStyle *iface, LONG *p)
2136 2137 2138 2139 2140 2141
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

2142
static HRESULT WINAPI HTMLStyle_put_pixelHeight(IHTMLStyle *iface, LONG v)
2143 2144 2145 2146 2147 2148
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

2149
static HRESULT WINAPI HTMLStyle_get_pixelHeight(IHTMLStyle *iface, LONG *p)
2150 2151 2152 2153 2154 2155 2156 2157 2158
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_posTop(IHTMLStyle *iface, float v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2159 2160 2161 2162

    TRACE("(%p)->(%f)\n", This, v);

    return set_style_pos(This, STYLEID_TOP, v);
2163 2164 2165 2166 2167
}

static HRESULT WINAPI HTMLStyle_get_posTop(IHTMLStyle *iface, float *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2168 2169 2170 2171 2172 2173 2174

    TRACE("(%p)->(%p)\n", This, p);

    if(!p)
        return E_POINTER;

    return get_nsstyle_pos(This, STYLEID_TOP, p);
2175 2176 2177 2178 2179
}

static HRESULT WINAPI HTMLStyle_put_posLeft(IHTMLStyle *iface, float v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2180 2181 2182 2183

    TRACE("(%p)->(%f)\n", This, v);

    return set_style_pos(This, STYLEID_LEFT, v);
2184 2185 2186 2187 2188
}

static HRESULT WINAPI HTMLStyle_get_posLeft(IHTMLStyle *iface, float *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2189 2190 2191 2192 2193 2194 2195

    TRACE("(%p)->(%p)\n", This, p);

    if(!p)
        return E_POINTER;

    return get_nsstyle_pos(This, STYLEID_LEFT, p);
2196 2197 2198 2199 2200
}

static HRESULT WINAPI HTMLStyle_put_posWidth(IHTMLStyle *iface, float v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2201 2202 2203 2204

    TRACE("(%p)->(%f)\n", This, v);

    return set_style_pos(This, STYLEID_WIDTH, v);
2205 2206 2207 2208 2209
}

static HRESULT WINAPI HTMLStyle_get_posWidth(IHTMLStyle *iface, float *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2210 2211 2212 2213 2214 2215 2216 2217 2218 2219

    TRACE("(%p)->(%p)\n", This, p);

    if(!p)
        return E_POINTER;

    if(get_nsstyle_pos(This, STYLEID_WIDTH, p) != S_OK)
        *p = 0.0f;

    return S_OK;
2220 2221 2222 2223 2224
}

static HRESULT WINAPI HTMLStyle_put_posHeight(IHTMLStyle *iface, float v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2225 2226 2227 2228

    TRACE("(%p)->(%f)\n", This, v);

    return set_style_pos(This, STYLEID_HEIGHT, v);
2229 2230 2231 2232 2233
}

static HRESULT WINAPI HTMLStyle_get_posHeight(IHTMLStyle *iface, float *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2234 2235 2236 2237 2238 2239 2240 2241 2242 2243

    TRACE("(%p)->(%p)\n", This, p);

    if(!p)
        return E_POINTER;

    if(get_nsstyle_pos(This, STYLEID_HEIGHT, p) != S_OK)
        *p = 0.0f;

    return S_OK;
2244 2245 2246 2247 2248
}

static HRESULT WINAPI HTMLStyle_put_cursor(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2249 2250 2251 2252

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    return set_style_attr(This, STYLEID_CURSOR, v, 0);
2253 2254 2255 2256 2257
}

static HRESULT WINAPI HTMLStyle_get_cursor(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2258 2259 2260 2261

    TRACE("(%p)->(%p)\n", This, p);

    return get_style_attr(This, STYLEID_CURSOR, p);
2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280
}

static HRESULT WINAPI HTMLStyle_put_clip(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2281 2282 2283 2284 2285

    WARN("(%p)->(%s)\n", This, debugstr_w(v));

    /* FIXME: Handle MS-style filters */
    return set_style_attr(This, STYLEID_FILTER, v, 0);
2286 2287 2288 2289 2290
}

static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2291 2292 2293 2294 2295

    WARN("(%p)->(%p)\n", This, p);

    /* FIXME: Handle MS-style filters */
    return get_style_attr(This, STYLEID_FILTER, p);
2296 2297 2298 2299 2300 2301
}

static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
        VARIANT AttributeValue, LONG lFlags)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313
    HRESULT hres;
    DISPID dispid;

    TRACE("(%p)->(%s v%d %08x)\n", This, debugstr_w(strAttributeName),
           V_VT(&AttributeValue), lFlags);

    if(!strAttributeName)
        return E_INVALIDARG;

    if(lFlags == 1)
        FIXME("Parameter lFlags ignored\n");

2314
    hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337
                        LOCALE_USER_DEFAULT, &dispid);
    if(hres == S_OK)
    {
        VARIANT ret;
        DISPID dispidNamed = DISPID_PROPERTYPUT;
        DISPPARAMS params;

        params.cArgs = 1;
        params.rgvarg = &AttributeValue;
        params.cNamedArgs = 1;
        params.rgdispidNamedArgs = &dispidNamed;

        hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
            DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
    }
    else
    {
        FIXME("Custom attributes not supported.\n");
    }

    TRACE("ret: %08x\n", hres);

    return hres;
2338 2339 2340 2341 2342 2343
}

static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName,
        LONG lFlags, VARIANT *AttributeValue)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355
    HRESULT hres;
    DISPID dispid;

    TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName),
          AttributeValue, lFlags);

    if(!AttributeValue || !strAttributeName)
        return E_INVALIDARG;

    if(lFlags == 1)
        FIXME("Parameter lFlags ignored\n");

2356
    hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, &strAttributeName, 1,
2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370
                        LOCALE_USER_DEFAULT, &dispid);
    if(hres == S_OK)
    {
        DISPPARAMS params = {NULL, NULL, 0, 0 };

        hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
            DISPATCH_PROPERTYGET, &params, AttributeValue, NULL, NULL);
    }
    else
    {
        FIXME("Custom attributes not supported.\n");
    }

    return hres;
2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388
}

static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,
                                                LONG lFlags, VARIANT_BOOL *pfSuccess)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName),
         lFlags, pfSuccess);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
{
    HTMLStyle *This = HTMLSTYLE_THIS(iface);
    FIXME("(%p)->(%p)\n", This, String);
    return E_NOTIMPL;
}

2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410
static HRESULT HTMLStyle_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid)
{
    int c, i, min=0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;

    while(min <= max) {
        i = (min+max)/2;

        c = strcmpW(style_tbl[i].name, name);
        if(!c) {
            *dispid = style_tbl[i].dispid;
            return S_OK;
        }

        if(c > 0)
            max = i-1;
        else
            min = i+1;
    }

    return DISP_E_UNKNOWNNAME;
}

2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599
static const IHTMLStyleVtbl HTMLStyleVtbl = {
    HTMLStyle_QueryInterface,
    HTMLStyle_AddRef,
    HTMLStyle_Release,
    HTMLStyle_GetTypeInfoCount,
    HTMLStyle_GetTypeInfo,
    HTMLStyle_GetIDsOfNames,
    HTMLStyle_Invoke,
    HTMLStyle_put_fontFamily,
    HTMLStyle_get_fontFamily,
    HTMLStyle_put_fontStyle,
    HTMLStyle_get_fontStyle,
    HTMLStyle_put_fontVariant,
    HTMLStyle_get_fontVariant,
    HTMLStyle_put_fontWeight,
    HTMLStyle_get_fontWeight,
    HTMLStyle_put_fontSize,
    HTMLStyle_get_fontSize,
    HTMLStyle_put_font,
    HTMLStyle_get_font,
    HTMLStyle_put_color,
    HTMLStyle_get_color,
    HTMLStyle_put_background,
    HTMLStyle_get_background,
    HTMLStyle_put_backgroundColor,
    HTMLStyle_get_backgroundColor,
    HTMLStyle_put_backgroundImage,
    HTMLStyle_get_backgroundImage,
    HTMLStyle_put_backgroundRepeat,
    HTMLStyle_get_backgroundRepeat,
    HTMLStyle_put_backgroundAttachment,
    HTMLStyle_get_backgroundAttachment,
    HTMLStyle_put_backgroundPosition,
    HTMLStyle_get_backgroundPosition,
    HTMLStyle_put_backgroundPositionX,
    HTMLStyle_get_backgroundPositionX,
    HTMLStyle_put_backgroundPositionY,
    HTMLStyle_get_backgroundPositionY,
    HTMLStyle_put_wordSpacing,
    HTMLStyle_get_wordSpacing,
    HTMLStyle_put_letterSpacing,
    HTMLStyle_get_letterSpacing,
    HTMLStyle_put_textDecoration,
    HTMLStyle_get_textDecoration,
    HTMLStyle_put_textDecorationNone,
    HTMLStyle_get_textDecorationNone,
    HTMLStyle_put_textDecorationUnderline,
    HTMLStyle_get_textDecorationUnderline,
    HTMLStyle_put_textDecorationOverline,
    HTMLStyle_get_textDecorationOverline,
    HTMLStyle_put_textDecorationLineThrough,
    HTMLStyle_get_textDecorationLineThrough,
    HTMLStyle_put_textDecorationBlink,
    HTMLStyle_get_textDecorationBlink,
    HTMLStyle_put_verticalAlign,
    HTMLStyle_get_verticalAlign,
    HTMLStyle_put_textTransform,
    HTMLStyle_get_textTransform,
    HTMLStyle_put_textAlign,
    HTMLStyle_get_textAlign,
    HTMLStyle_put_textIndent,
    HTMLStyle_get_textIndent,
    HTMLStyle_put_lineHeight,
    HTMLStyle_get_lineHeight,
    HTMLStyle_put_marginTop,
    HTMLStyle_get_marginTop,
    HTMLStyle_put_marginRight,
    HTMLStyle_get_marginRight,
    HTMLStyle_put_marginBottom,
    HTMLStyle_get_marginBottom,
    HTMLStyle_put_marginLeft,
    HTMLStyle_get_marginLeft,
    HTMLStyle_put_margin,
    HTMLStyle_get_margin,
    HTMLStyle_put_paddingTop,
    HTMLStyle_get_paddingTop,
    HTMLStyle_put_paddingRight,
    HTMLStyle_get_paddingRight,
    HTMLStyle_put_paddingBottom,
    HTMLStyle_get_paddingBottom,
    HTMLStyle_put_paddingLeft,
    HTMLStyle_get_paddingLeft,
    HTMLStyle_put_padding,
    HTMLStyle_get_padding,
    HTMLStyle_put_border,
    HTMLStyle_get_border,
    HTMLStyle_put_borderTop,
    HTMLStyle_get_borderTop,
    HTMLStyle_put_borderRight,
    HTMLStyle_get_borderRight,
    HTMLStyle_put_borderBottom,
    HTMLStyle_get_borderBottom,
    HTMLStyle_put_borderLeft,
    HTMLStyle_get_borderLeft,
    HTMLStyle_put_borderColor,
    HTMLStyle_get_borderColor,
    HTMLStyle_put_borderTopColor,
    HTMLStyle_get_borderTopColor,
    HTMLStyle_put_borderRightColor,
    HTMLStyle_get_borderRightColor,
    HTMLStyle_put_borderBottomColor,
    HTMLStyle_get_borderBottomColor,
    HTMLStyle_put_borderLeftColor,
    HTMLStyle_get_borderLeftColor,
    HTMLStyle_put_borderWidth,
    HTMLStyle_get_borderWidth,
    HTMLStyle_put_borderTopWidth,
    HTMLStyle_get_borderTopWidth,
    HTMLStyle_put_borderRightWidth,
    HTMLStyle_get_borderRightWidth,
    HTMLStyle_put_borderBottomWidth,
    HTMLStyle_get_borderBottomWidth,
    HTMLStyle_put_borderLeftWidth,
    HTMLStyle_get_borderLeftWidth,
    HTMLStyle_put_borderStyle,
    HTMLStyle_get_borderStyle,
    HTMLStyle_put_borderTopStyle,
    HTMLStyle_get_borderTopStyle,
    HTMLStyle_put_borderRightStyle,
    HTMLStyle_get_borderRightStyle,
    HTMLStyle_put_borderBottomStyle,
    HTMLStyle_get_borderBottomStyle,
    HTMLStyle_put_borderLeftStyle,
    HTMLStyle_get_borderLeftStyle,
    HTMLStyle_put_width,
    HTMLStyle_get_width,
    HTMLStyle_put_height,
    HTMLStyle_get_height,
    HTMLStyle_put_styleFloat,
    HTMLStyle_get_styleFloat,
    HTMLStyle_put_clear,
    HTMLStyle_get_clear,
    HTMLStyle_put_display,
    HTMLStyle_get_display,
    HTMLStyle_put_visibility,
    HTMLStyle_get_visibility,
    HTMLStyle_put_listStyleType,
    HTMLStyle_get_listStyleType,
    HTMLStyle_put_listStylePosition,
    HTMLStyle_get_listStylePosition,
    HTMLStyle_put_listStyleImage,
    HTMLStyle_get_listStyleImage,
    HTMLStyle_put_listStyle,
    HTMLStyle_get_listStyle,
    HTMLStyle_put_whiteSpace,
    HTMLStyle_get_whiteSpace,
    HTMLStyle_put_top,
    HTMLStyle_get_top,
    HTMLStyle_put_left,
    HTMLStyle_get_left,
    HTMLStyle_get_position,
    HTMLStyle_put_zIndex,
    HTMLStyle_get_zIndex,
    HTMLStyle_put_overflow,
    HTMLStyle_get_overflow,
    HTMLStyle_put_pageBreakBefore,
    HTMLStyle_get_pageBreakBefore,
    HTMLStyle_put_pageBreakAfter,
    HTMLStyle_get_pageBreakAfter,
    HTMLStyle_put_cssText,
    HTMLStyle_get_cssText,
    HTMLStyle_put_pixelTop,
    HTMLStyle_get_pixelTop,
    HTMLStyle_put_pixelLeft,
    HTMLStyle_get_pixelLeft,
    HTMLStyle_put_pixelWidth,
    HTMLStyle_get_pixelWidth,
    HTMLStyle_put_pixelHeight,
    HTMLStyle_get_pixelHeight,
    HTMLStyle_put_posTop,
    HTMLStyle_get_posTop,
    HTMLStyle_put_posLeft,
    HTMLStyle_get_posLeft,
    HTMLStyle_put_posWidth,
    HTMLStyle_get_posWidth,
    HTMLStyle_put_posHeight,
    HTMLStyle_get_posHeight,
    HTMLStyle_put_cursor,
    HTMLStyle_get_cursor,
    HTMLStyle_put_clip,
    HTMLStyle_get_clip,
    HTMLStyle_put_filter,
    HTMLStyle_get_filter,
    HTMLStyle_setAttribute,
    HTMLStyle_getAttribute,
    HTMLStyle_removeAttribute,
    HTMLStyle_toString
};

2600 2601 2602 2603 2604
static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
    HTMLStyle_get_dispid,
    NULL
};

2605 2606
static const tid_t HTMLStyle_iface_tids[] = {
    IHTMLStyle_tid,
2607
    IHTMLStyle2_tid,
2608 2609
    IHTMLStyle3_tid,
    IHTMLStyle4_tid,
2610 2611
    0
};
2612
static dispex_static_data_t HTMLStyle_dispex = {
2613
    &HTMLStyle_dispex_vtbl,
2614 2615
    DispHTMLStyle_tid,
    NULL,
2616
    HTMLStyle_iface_tids
2617 2618
};

2619
IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration *nsstyle)
2620
{
2621
    HTMLStyle *ret = heap_alloc_zero(sizeof(HTMLStyle));
2622 2623 2624

    ret->lpHTMLStyleVtbl = &HTMLStyleVtbl;
    ret->ref = 1;
2625
    ret->nsstyle = nsstyle;
2626
    HTMLStyle2_Init(ret);
2627
    HTMLStyle3_Init(ret);
2628 2629

    nsIDOMCSSStyleDeclaration_AddRef(nsstyle);
2630

2631 2632
    init_dispex(&ret->dispex, (IUnknown*)HTMLSTYLE(ret),  &HTMLStyle_dispex);

2633 2634
    return HTMLSTYLE(ret);
}