htmlcurstyle.c 32.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 * Copyright 2008 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>

#define COBJMACROS

#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"

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

#include "wine/debug.h"
32 33 34

WINE_DEFAULT_DEBUG_CHANNEL(mshtml);

35
struct HTMLCurrentStyle {
36
    DispatchEx dispex;
37
    IHTMLCurrentStyle IHTMLCurrentStyle_iface;
38 39

    LONG ref;
40 41

    nsIDOMCSSStyleDeclaration *nsstyle;
42
};
43

44 45 46 47
static inline HTMLCurrentStyle *impl_from_IHTMLCurrentStyle(IHTMLCurrentStyle *iface)
{
    return CONTAINING_RECORD(iface, HTMLCurrentStyle, IHTMLCurrentStyle_iface);
}
48 49 50

static HRESULT WINAPI HTMLCurrentStyle_QueryInterface(IHTMLCurrentStyle *iface, REFIID riid, void **ppv)
{
51
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
52 53 54 55 56

    *ppv = NULL;

    if(IsEqualGUID(&IID_IUnknown, riid)) {
        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
57
        *ppv = &This->IHTMLCurrentStyle_iface;
58 59
    }else if(IsEqualGUID(&IID_IHTMLCurrentStyle, riid)) {
        TRACE("(%p)->(IID_IHTMLCurrentStyle %p)\n", This, ppv);
60
        *ppv = &This->IHTMLCurrentStyle_iface;
61 62
    }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
        return *ppv ? S_OK : E_NOINTERFACE;
63 64 65 66 67 68 69 70 71 72 73 74 75
    }

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

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

static ULONG WINAPI HTMLCurrentStyle_AddRef(IHTMLCurrentStyle *iface)
{
76
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
77 78 79 80 81 82 83 84 85
    LONG ref = InterlockedIncrement(&This->ref);

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

    return ref;
}

static ULONG WINAPI HTMLCurrentStyle_Release(IHTMLCurrentStyle *iface)
{
86
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
87 88 89 90
    LONG ref = InterlockedDecrement(&This->ref);

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

91 92 93
    if(!ref) {
        if(This->nsstyle)
            nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
94
        release_dispex(&This->dispex);
95
        heap_free(This);
96
    }
97 98 99 100 101 102

    return ref;
}

static HRESULT WINAPI HTMLCurrentStyle_GetTypeInfoCount(IHTMLCurrentStyle *iface, UINT *pctinfo)
{
103
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
104
    return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
105 106 107 108 109
}

static HRESULT WINAPI HTMLCurrentStyle_GetTypeInfo(IHTMLCurrentStyle *iface, UINT iTInfo,
        LCID lcid, ITypeInfo **ppTInfo)
{
110
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
111
    return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
112 113 114 115 116
}

static HRESULT WINAPI HTMLCurrentStyle_GetIDsOfNames(IHTMLCurrentStyle *iface, REFIID riid,
        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
117
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
118 119
    return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
            lcid, rgDispId);
120 121 122 123 124 125
}

static HRESULT WINAPI HTMLCurrentStyle_Invoke(IHTMLCurrentStyle *iface, DISPID dispIdMember,
        REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
        VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
126
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
127
    return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
128
            wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
129 130 131 132
}

static HRESULT WINAPI HTMLCurrentStyle_get_position(IHTMLCurrentStyle *iface, BSTR *p)
{
133
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
134 135 136 137

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

    return get_nsstyle_attr(This->nsstyle, STYLEID_POSITION, p);
138 139 140 141
}

static HRESULT WINAPI HTMLCurrentStyle_get_styleFloat(IHTMLCurrentStyle *iface, BSTR *p)
{
142
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
143 144 145 146 147 148
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_color(IHTMLCurrentStyle *iface, VARIANT *p)
{
149
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
150 151
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_COLOR, p, 0);
152 153 154 155
}

static HRESULT WINAPI HTMLCurrentStyle_get_backgroundColor(IHTMLCurrentStyle *iface, VARIANT *p)
{
156
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
157 158
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, p, 0);
159 160 161 162
}

static HRESULT WINAPI HTMLCurrentStyle_get_fontFamily(IHTMLCurrentStyle *iface, BSTR *p)
{
163
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
164 165 166 167

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

    return get_nsstyle_attr(This->nsstyle, STYLEID_FONT_FAMILY, p);
168 169 170 171
}

static HRESULT WINAPI HTMLCurrentStyle_get_fontStyle(IHTMLCurrentStyle *iface, BSTR *p)
{
172
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
173 174
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_FONT_STYLE, p);
175 176 177 178
}

static HRESULT WINAPI HTMLCurrentStyle_get_fontVariant(IHTMLCurrentStyle *iface, BSTR *p)
{
179
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
180 181
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_FONT_VARIANT, p);
182 183 184 185
}

static HRESULT WINAPI HTMLCurrentStyle_get_fontWeight(IHTMLCurrentStyle *iface, VARIANT *p)
{
186
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
187 188
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_WEIGHT, p, ATTR_STR_TO_INT);
189 190 191 192
}

static HRESULT WINAPI HTMLCurrentStyle_get_fontSize(IHTMLCurrentStyle *iface, VARIANT *p)
{
193
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
194 195
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_FONT_SIZE, p, 0);
196 197 198 199
}

static HRESULT WINAPI HTMLCurrentStyle_get_backgroundImage(IHTMLCurrentStyle *iface, BSTR *p)
{
200
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
201 202
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_IMAGE, p);
203 204 205 206
}

static HRESULT WINAPI HTMLCurrentStyle_get_backgroundPositionX(IHTMLCurrentStyle *iface, VARIANT *p)
{
207
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
208 209 210 211 212 213
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_backgroundPositionY(IHTMLCurrentStyle *iface, VARIANT *p)
{
214
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
215 216 217 218 219 220
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_backgroundRepeat(IHTMLCurrentStyle *iface, BSTR *p)
{
221
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
222 223
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_BACKGROUND_REPEAT, p);
224 225 226 227
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderLeftColor(IHTMLCurrentStyle *iface, VARIANT *p)
{
228
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
229 230
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0);
231 232 233 234
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderTopColor(IHTMLCurrentStyle *iface, VARIANT *p)
{
235
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
236 237
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0);
238 239 240 241
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderRightColor(IHTMLCurrentStyle *iface, VARIANT *p)
{
242
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
243 244
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0);
245 246 247 248
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderBottomColor(IHTMLCurrentStyle *iface, VARIANT *p)
{
249
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
250 251
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0);
252 253 254 255
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderTopStyle(IHTMLCurrentStyle *iface, BSTR *p)
{
256
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
257 258
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_BORDER_TOP_STYLE, p);
259 260 261 262
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderRightStyle(IHTMLCurrentStyle *iface, BSTR *p)
{
263
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
264 265
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_BORDER_RIGHT_STYLE, p);
266 267 268 269
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderBottomStyle(IHTMLCurrentStyle *iface, BSTR *p)
{
270
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
271 272
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_BORDER_BOTTOM_STYLE, p);
273 274 275 276
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderLeftStyle(IHTMLCurrentStyle *iface, BSTR *p)
{
277
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
278 279
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_BORDER_LEFT_STYLE, p);
280 281 282 283
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderTopWidth(IHTMLCurrentStyle *iface, VARIANT *p)
{
284
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
285 286
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_WIDTH, p, 0);
287 288 289 290
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderRightWidth(IHTMLCurrentStyle *iface, VARIANT *p)
{
291
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
292 293
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_WIDTH, p, 0);
294 295 296 297
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderBottomWidth(IHTMLCurrentStyle *iface, VARIANT *p)
{
298
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
299 300
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_WIDTH, p, 0);
301 302 303 304
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderLeftWidth(IHTMLCurrentStyle *iface, VARIANT *p)
{
305
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
306 307
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_WIDTH, p, 0);
308 309 310 311
}

static HRESULT WINAPI HTMLCurrentStyle_get_left(IHTMLCurrentStyle *iface, VARIANT *p)
{
312
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
313 314
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_LEFT, p, 0);
315 316 317 318
}

static HRESULT WINAPI HTMLCurrentStyle_get_top(IHTMLCurrentStyle *iface, VARIANT *p)
{
319
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
320 321
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_TOP, p, 0);
322 323 324 325
}

static HRESULT WINAPI HTMLCurrentStyle_get_width(IHTMLCurrentStyle *iface, VARIANT *p)
{
326
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
327 328
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, p, 0);
329 330 331 332
}

static HRESULT WINAPI HTMLCurrentStyle_get_height(IHTMLCurrentStyle *iface, VARIANT *p)
{
333
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
334 335
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_HEIGHT, p, 0);
336 337 338 339
}

static HRESULT WINAPI HTMLCurrentStyle_get_paddingLeft(IHTMLCurrentStyle *iface, VARIANT *p)
{
340
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
341 342
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_LEFT, p, 0);
343 344 345 346
}

static HRESULT WINAPI HTMLCurrentStyle_get_paddingTop(IHTMLCurrentStyle *iface, VARIANT *p)
{
347
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
348 349
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_TOP, p, 0);
350 351 352 353
}

static HRESULT WINAPI HTMLCurrentStyle_get_paddingRight(IHTMLCurrentStyle *iface, VARIANT *p)
{
354
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
355 356
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_RIGHT, p, 0);
357 358 359 360
}

static HRESULT WINAPI HTMLCurrentStyle_get_paddingBottom(IHTMLCurrentStyle *iface, VARIANT *p)
{
361
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
362 363
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_PADDING_BOTTOM, p, 0);
364 365 366 367
}

static HRESULT WINAPI HTMLCurrentStyle_get_textAlign(IHTMLCurrentStyle *iface, BSTR *p)
{
368
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
369 370
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_TEXT_ALIGN, p);
371 372 373 374
}

static HRESULT WINAPI HTMLCurrentStyle_get_textDecoration(IHTMLCurrentStyle *iface, BSTR *p)
{
375
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
376 377
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_TEXT_DECORATION, p);
378 379 380 381
}

static HRESULT WINAPI HTMLCurrentStyle_get_display(IHTMLCurrentStyle *iface, BSTR *p)
{
382
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
383 384 385 386

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

    return get_nsstyle_attr(This->nsstyle, STYLEID_DISPLAY, p);
387 388 389 390
}

static HRESULT WINAPI HTMLCurrentStyle_get_visibility(IHTMLCurrentStyle *iface, BSTR *p)
{
391
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
392 393 394 395

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

    return get_nsstyle_attr(This->nsstyle, STYLEID_VISIBILITY, p);
396 397 398 399
}

static HRESULT WINAPI HTMLCurrentStyle_get_zIndex(IHTMLCurrentStyle *iface, VARIANT *p)
{
400
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
401 402
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_Z_INDEX, p, ATTR_STR_TO_INT);
403 404 405 406
}

static HRESULT WINAPI HTMLCurrentStyle_get_letterSpacing(IHTMLCurrentStyle *iface, VARIANT *p)
{
407
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
408 409
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_LETTER_SPACING, p, 0);
410 411 412 413
}

static HRESULT WINAPI HTMLCurrentStyle_get_lineHeight(IHTMLCurrentStyle *iface, VARIANT *p)
{
414
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
415 416
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_LINE_HEIGHT, p, 0);
417 418 419 420
}

static HRESULT WINAPI HTMLCurrentStyle_get_textIndent(IHTMLCurrentStyle *iface, VARIANT *p)
{
421
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
422 423
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_TEXT_INDENT, p, 0);
424 425 426 427
}

static HRESULT WINAPI HTMLCurrentStyle_get_verticalAlign(IHTMLCurrentStyle *iface, VARIANT *p)
{
428
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
429 430
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_VERTICAL_ALIGN, p, 0);
431 432 433 434
}

static HRESULT WINAPI HTMLCurrentStyle_get_backgroundAttachment(IHTMLCurrentStyle *iface, BSTR *p)
{
435
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
436 437 438 439 440 441
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_marginTop(IHTMLCurrentStyle *iface, VARIANT *p)
{
442
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
443 444
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
445 446 447 448
}

static HRESULT WINAPI HTMLCurrentStyle_get_marginRight(IHTMLCurrentStyle *iface, VARIANT *p)
{
449
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
450 451
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_RIGHT, p, 0);
452 453 454 455
}

static HRESULT WINAPI HTMLCurrentStyle_get_marginBottom(IHTMLCurrentStyle *iface, VARIANT *p)
{
456
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
457 458
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_BOTTOM, p, 0);
459 460 461 462
}

static HRESULT WINAPI HTMLCurrentStyle_get_marginLeft(IHTMLCurrentStyle *iface, VARIANT *p)
{
463
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
464 465
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_LEFT, p, 0);
466 467 468 469
}

static HRESULT WINAPI HTMLCurrentStyle_get_clear(IHTMLCurrentStyle *iface, BSTR *p)
{
470
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
471 472 473 474 475 476
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_listStyleType(IHTMLCurrentStyle *iface, BSTR *p)
{
477
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
478 479 480 481 482 483
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_listStylePosition(IHTMLCurrentStyle *iface, BSTR *p)
{
484
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
485 486 487 488 489 490
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_listStyleImage(IHTMLCurrentStyle *iface, BSTR *p)
{
491
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
492 493 494 495 496 497
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_clipTop(IHTMLCurrentStyle *iface, VARIANT *p)
{
498
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
499 500 501 502 503 504
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_clipRight(IHTMLCurrentStyle *iface, VARIANT *p)
{
505
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
506 507 508 509 510 511
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_clipBottom(IHTMLCurrentStyle *iface, VARIANT *p)
{
512
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
513 514 515 516 517 518
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_clipLeft(IHTMLCurrentStyle *iface, VARIANT *p)
{
519
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
520 521 522 523 524 525
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_overflow(IHTMLCurrentStyle *iface, BSTR *p)
{
526
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
527 528
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_OVERFLOW, p);
529 530 531 532
}

static HRESULT WINAPI HTMLCurrentStyle_get_pageBreakBefore(IHTMLCurrentStyle *iface, BSTR *p)
{
533
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
534 535 536 537 538 539
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_pageBreakAfter(IHTMLCurrentStyle *iface, BSTR *p)
{
540
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
541 542 543 544 545 546
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_cursor(IHTMLCurrentStyle *iface, BSTR *p)
{
547
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
548 549
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_CURSOR, p);
550 551 552 553
}

static HRESULT WINAPI HTMLCurrentStyle_get_tableLayout(IHTMLCurrentStyle *iface, BSTR *p)
{
554
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
555 556 557 558 559 560
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderCollapse(IHTMLCurrentStyle *iface, BSTR *p)
{
561
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
562 563 564 565 566 567
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_direction(IHTMLCurrentStyle *iface, BSTR *p)
{
568
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
569 570 571 572 573 574
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_behavior(IHTMLCurrentStyle *iface, BSTR *p)
{
575
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
576 577 578 579 580 581 582
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_getAttribute(IHTMLCurrentStyle *iface, BSTR strAttributeName,
        LONG lFlags, VARIANT *AttributeValue)
{
583
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
584 585 586 587 588 589
    FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_unicodeBidi(IHTMLCurrentStyle *iface, BSTR *p)
{
590
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
591 592 593 594 595 596
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_right(IHTMLCurrentStyle *iface, VARIANT *p)
{
597
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
598 599
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_RIGHT, p, 0);
600 601 602 603
}

static HRESULT WINAPI HTMLCurrentStyle_get_bottom(IHTMLCurrentStyle *iface, VARIANT *p)
{
604
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
605 606
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BOTTOM, p, 0);
607 608 609 610
}

static HRESULT WINAPI HTMLCurrentStyle_get_imeMode(IHTMLCurrentStyle *iface, BSTR *p)
{
611
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
612 613 614 615 616 617
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_rubyAlign(IHTMLCurrentStyle *iface, BSTR *p)
{
618
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
619 620 621 622 623 624
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_rubyPosition(IHTMLCurrentStyle *iface, BSTR *p)
{
625
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
626 627 628 629 630 631
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_rubyOverhang(IHTMLCurrentStyle *iface, BSTR *p)
{
632
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
633 634 635 636 637 638
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_textAutospace(IHTMLCurrentStyle *iface, BSTR *p)
{
639
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
640 641 642 643 644 645
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_lineBreak(IHTMLCurrentStyle *iface, BSTR *p)
{
646
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
647 648 649 650 651 652
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_wordBreak(IHTMLCurrentStyle *iface, BSTR *p)
{
653
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
654 655 656 657 658 659
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_textJustify(IHTMLCurrentStyle *iface, BSTR *p)
{
660
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
661 662 663 664 665 666
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_textJustifyTrim(IHTMLCurrentStyle *iface, BSTR *p)
{
667
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
668 669 670 671 672 673
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_textKashida(IHTMLCurrentStyle *iface, VARIANT *p)
{
674
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
675 676 677 678 679 680
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_blockDirection(IHTMLCurrentStyle *iface, BSTR *p)
{
681
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
682 683 684 685 686 687
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_layoutGridChar(IHTMLCurrentStyle *iface, VARIANT *p)
{
688
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
689 690 691 692 693 694
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_layoutGridLine(IHTMLCurrentStyle *iface, VARIANT *p)
{
695
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
696 697 698 699 700 701
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_layoutGridMode(IHTMLCurrentStyle *iface, BSTR *p)
{
702
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
703 704 705 706 707 708
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_layoutGridType(IHTMLCurrentStyle *iface, BSTR *p)
{
709
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
710 711 712 713 714 715
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderStyle(IHTMLCurrentStyle *iface, BSTR *p)
{
716
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
717 718
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_BORDER_STYLE, p);
719 720 721 722
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderColor(IHTMLCurrentStyle *iface, BSTR *p)
{
723
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
724 725
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_BORDER_COLOR, p);
726 727 728 729
}

static HRESULT WINAPI HTMLCurrentStyle_get_borderWidth(IHTMLCurrentStyle *iface, BSTR *p)
{
730
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
731 732
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_BORDER_WIDTH, p);
733 734 735 736
}

static HRESULT WINAPI HTMLCurrentStyle_get_padding(IHTMLCurrentStyle *iface, BSTR *p)
{
737
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
738 739 740 741 742 743
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_margin(IHTMLCurrentStyle *iface, BSTR *p)
{
744
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
745 746
    TRACE("(%p)->(%p)\n", This, p);
    return get_nsstyle_attr(This->nsstyle, STYLEID_MARGIN, p);
747 748 749 750
}

static HRESULT WINAPI HTMLCurrentStyle_get_accelerator(IHTMLCurrentStyle *iface, BSTR *p)
{
751
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
752 753 754 755 756 757
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_overflowX(IHTMLCurrentStyle *iface, BSTR *p)
{
758
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
759 760 761 762 763 764
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_overflowY(IHTMLCurrentStyle *iface, BSTR *p)
{
765
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
766 767 768 769 770 771
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLCurrentStyle_get_textTransform(IHTMLCurrentStyle *iface, BSTR *p)
{
772
    HTMLCurrentStyle *This = impl_from_IHTMLCurrentStyle(iface);
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static const IHTMLCurrentStyleVtbl HTMLCurrentStyleVtbl = {
    HTMLCurrentStyle_QueryInterface,
    HTMLCurrentStyle_AddRef,
    HTMLCurrentStyle_Release,
    HTMLCurrentStyle_GetTypeInfoCount,
    HTMLCurrentStyle_GetTypeInfo,
    HTMLCurrentStyle_GetIDsOfNames,
    HTMLCurrentStyle_Invoke,
    HTMLCurrentStyle_get_position,
    HTMLCurrentStyle_get_styleFloat,
    HTMLCurrentStyle_get_color,
    HTMLCurrentStyle_get_backgroundColor,
    HTMLCurrentStyle_get_fontFamily,
    HTMLCurrentStyle_get_fontStyle,
    HTMLCurrentStyle_get_fontVariant,
    HTMLCurrentStyle_get_fontWeight,
    HTMLCurrentStyle_get_fontSize,
    HTMLCurrentStyle_get_backgroundImage,
    HTMLCurrentStyle_get_backgroundPositionX,
    HTMLCurrentStyle_get_backgroundPositionY,
    HTMLCurrentStyle_get_backgroundRepeat,
    HTMLCurrentStyle_get_borderLeftColor,
    HTMLCurrentStyle_get_borderTopColor,
    HTMLCurrentStyle_get_borderRightColor,
    HTMLCurrentStyle_get_borderBottomColor,
    HTMLCurrentStyle_get_borderTopStyle,
    HTMLCurrentStyle_get_borderRightStyle,
    HTMLCurrentStyle_get_borderBottomStyle,
    HTMLCurrentStyle_get_borderLeftStyle,
    HTMLCurrentStyle_get_borderTopWidth,
    HTMLCurrentStyle_get_borderRightWidth,
    HTMLCurrentStyle_get_borderBottomWidth,
    HTMLCurrentStyle_get_borderLeftWidth,
    HTMLCurrentStyle_get_left,
    HTMLCurrentStyle_get_top,
    HTMLCurrentStyle_get_width,
    HTMLCurrentStyle_get_height,
    HTMLCurrentStyle_get_paddingLeft,
    HTMLCurrentStyle_get_paddingTop,
    HTMLCurrentStyle_get_paddingRight,
    HTMLCurrentStyle_get_paddingBottom,
    HTMLCurrentStyle_get_textAlign,
    HTMLCurrentStyle_get_textDecoration,
    HTMLCurrentStyle_get_display,
    HTMLCurrentStyle_get_visibility,
    HTMLCurrentStyle_get_zIndex,
    HTMLCurrentStyle_get_letterSpacing,
    HTMLCurrentStyle_get_lineHeight,
    HTMLCurrentStyle_get_textIndent,
    HTMLCurrentStyle_get_verticalAlign,
    HTMLCurrentStyle_get_backgroundAttachment,
    HTMLCurrentStyle_get_marginTop,
    HTMLCurrentStyle_get_marginRight,
    HTMLCurrentStyle_get_marginBottom,
    HTMLCurrentStyle_get_marginLeft,
    HTMLCurrentStyle_get_clear,
    HTMLCurrentStyle_get_listStyleType,
    HTMLCurrentStyle_get_listStylePosition,
    HTMLCurrentStyle_get_listStyleImage,
    HTMLCurrentStyle_get_clipTop,
    HTMLCurrentStyle_get_clipRight,
    HTMLCurrentStyle_get_clipBottom,
    HTMLCurrentStyle_get_clipLeft,
    HTMLCurrentStyle_get_overflow,
    HTMLCurrentStyle_get_pageBreakBefore,
    HTMLCurrentStyle_get_pageBreakAfter,
    HTMLCurrentStyle_get_cursor,
    HTMLCurrentStyle_get_tableLayout,
    HTMLCurrentStyle_get_borderCollapse,
    HTMLCurrentStyle_get_direction,
    HTMLCurrentStyle_get_behavior,
    HTMLCurrentStyle_getAttribute,
    HTMLCurrentStyle_get_unicodeBidi,
    HTMLCurrentStyle_get_right,
    HTMLCurrentStyle_get_bottom,
    HTMLCurrentStyle_get_imeMode,
    HTMLCurrentStyle_get_rubyAlign,
    HTMLCurrentStyle_get_rubyPosition,
    HTMLCurrentStyle_get_rubyOverhang,
    HTMLCurrentStyle_get_textAutospace,
    HTMLCurrentStyle_get_lineBreak,
    HTMLCurrentStyle_get_wordBreak,
    HTMLCurrentStyle_get_textJustify,
    HTMLCurrentStyle_get_textJustifyTrim,
    HTMLCurrentStyle_get_textKashida,
    HTMLCurrentStyle_get_blockDirection,
    HTMLCurrentStyle_get_layoutGridChar,
    HTMLCurrentStyle_get_layoutGridLine,
    HTMLCurrentStyle_get_layoutGridMode,
    HTMLCurrentStyle_get_layoutGridType,
    HTMLCurrentStyle_get_borderStyle,
    HTMLCurrentStyle_get_borderColor,
    HTMLCurrentStyle_get_borderWidth,
    HTMLCurrentStyle_get_padding,
    HTMLCurrentStyle_get_margin,
    HTMLCurrentStyle_get_accelerator,
    HTMLCurrentStyle_get_overflowX,
    HTMLCurrentStyle_get_overflowY,
    HTMLCurrentStyle_get_textTransform
};

878 879
static const tid_t HTMLCurrentStyle_iface_tids[] = {
    IHTMLCurrentStyle_tid,
880 881 882
    IHTMLCurrentStyle2_tid,
    IHTMLCurrentStyle3_tid,
    IHTMLCurrentStyle4_tid,
883 884 885 886 887 888 889 890 891
    0
};
static dispex_static_data_t HTMLCurrentStyle_dispex = {
    NULL,
    DispHTMLCurrentStyle_tid,
    NULL,
    HTMLCurrentStyle_iface_tids
};

892
HRESULT HTMLCurrentStyle_Create(HTMLElement *elem, IHTMLCurrentStyle **p)
893
{
894 895 896 897 898
    nsIDOMCSSStyleDeclaration *nsstyle;
    nsIDOMDocumentView *nsdocview;
    nsIDOMAbstractView *nsview;
    nsIDOMViewCSS *nsviewcss;
    nsAString nsempty_str;
899
    HTMLCurrentStyle *ret;
900 901
    nsresult nsres;

902
    if(!elem->node.doc->nsdoc)  {
903 904
        WARN("NULL nsdoc\n");
        return E_UNEXPECTED;
905 906
    }

907
    nsres = nsIDOMHTMLDocument_QueryInterface(elem->node.doc->nsdoc, &IID_nsIDOMDocumentView, (void**)&nsdocview);
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934
    if(NS_FAILED(nsres)) {
        ERR("Could not get nsIDOMDocumentView: %08x\n", nsres);
        return E_FAIL;
    }

    nsres = nsIDOMDocumentView_GetDefaultView(nsdocview, &nsview);
    nsIDOMDocumentView_Release(nsdocview);
    if(NS_FAILED(nsres)) {
        ERR("GetDefaultView failed: %08x\n", nsres);
        return E_FAIL;
    }

    nsres = nsIDOMAbstractView_QueryInterface(nsview, &IID_nsIDOMViewCSS, (void**)&nsviewcss);
    nsIDOMAbstractView_Release(nsview);
    if(NS_FAILED(nsres)) {
        ERR("Could not get nsIDOMViewCSS: %08x\n", nsres);
        return E_FAIL;
    }

    nsAString_Init(&nsempty_str, NULL);
    nsres = nsIDOMViewCSS_GetComputedStyle(nsviewcss, (nsIDOMElement*)elem->nselem, &nsempty_str, &nsstyle);
    nsIDOMViewCSS_Release(nsviewcss);
    nsAString_Finish(&nsempty_str);
    if(NS_FAILED(nsres)) {
        ERR("GetComputedStyle failed: %08x\n", nsres);
        return E_FAIL;
    }
935 936

    ret = heap_alloc_zero(sizeof(HTMLCurrentStyle));
937 938
    if(!ret) {
        nsIDOMCSSStyleDeclaration_Release(nsstyle);
939
        return E_OUTOFMEMORY;
940
    }
941

942
    ret->IHTMLCurrentStyle_iface.lpVtbl = &HTMLCurrentStyleVtbl;
943
    ret->ref = 1;
944
    ret->nsstyle = nsstyle;
945

946
    init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLCurrentStyle_iface,  &HTMLCurrentStyle_dispex);
947

948
    *p = &ret->IHTMLCurrentStyle_iface;
949 950
    return S_OK;
}