Commit 08939329 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Add IHTMLWindow7::getComputedStyle implementation.

parent 12be24af
......@@ -10236,6 +10236,28 @@ HRESULT HTMLStyle_Create(HTMLElement *elem, HTMLStyle **ret)
return S_OK;
}
static const tid_t HTMLW3CComputedStyle_iface_tids[] = {
0
};
static dispex_static_data_t HTMLW3CComputedStyle_dispex = {
&CSSStyle_dispex_vtbl,
DispHTMLW3CComputedStyle_tid,
HTMLW3CComputedStyle_iface_tids,
CSSStyle_init_dispex_info
};
HRESULT create_computed_style(nsIDOMCSSStyleDeclaration *nsstyle, IHTMLCSSStyleDeclaration **p)
{
CSSStyle *style;
if(!(style = heap_alloc_zero(sizeof(*style))))
return E_OUTOFMEMORY;
init_css_style(style, nsstyle, NULL, &HTMLW3CComputedStyle_dispex, COMPAT_MODE_IE11);
*p = &style->IHTMLCSSStyleDeclaration_iface;
return S_OK;
}
HRESULT get_elem_style(HTMLElement *elem, styleid_t styleid, BSTR *ret)
{
nsIDOMCSSStyleDeclaration *style;
......
......@@ -137,6 +137,7 @@ typedef enum {
} styleid_t;
HRESULT HTMLStyle_Create(HTMLElement*,HTMLStyle**) DECLSPEC_HIDDEN;
HRESULT create_computed_style(nsIDOMCSSStyleDeclaration*,IHTMLCSSStyleDeclaration**) DECLSPEC_HIDDEN;
void init_css_style(CSSStyle*,nsIDOMCSSStyleDeclaration*,style_qi_t,
dispex_static_data_t*,compat_mode_t) DECLSPEC_HIDDEN;
......
......@@ -38,6 +38,7 @@
#include "mshtml_private.h"
#include "htmlevent.h"
#include "htmlscript.h"
#include "htmlstyle.h"
#include "pluginhost.h"
#include "binding.h"
#include "resource.h"
......@@ -2322,8 +2323,42 @@ static HRESULT WINAPI HTMLWindow7_getComputedStyle(IHTMLWindow7 *iface, IHTMLDOM
BSTR pseudo_elt, IHTMLCSSStyleDeclaration **p)
{
HTMLWindow *This = impl_from_IHTMLWindow7(iface);
FIXME("(%p)->(%p %s %p)\n", This, node, debugstr_w(pseudo_elt), p);
return E_NOTIMPL;
nsIDOMCSSStyleDeclaration *nsstyle;
nsAString pseudo_elt_str;
HTMLElement *element;
IHTMLElement *elem;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p %s %p)\n", This, node, debugstr_w(pseudo_elt), p);
if(!This->outer_window)
return E_UNEXPECTED;
hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)&elem);
if(FAILED(hres))
return hres;
element = unsafe_impl_from_IHTMLElement(elem);
if(!element) {
WARN("Not our element\n");
IHTMLElement_Release(elem);
return E_INVALIDARG;
}
nsAString_Init(&pseudo_elt_str, NULL);
nsres = nsIDOMWindow_GetComputedStyle(This->outer_window->nswindow, element->dom_element,
&pseudo_elt_str, &nsstyle);
IHTMLElement_Release(elem);
nsAString_Finish(&pseudo_elt_str);
if(NS_FAILED(nsres)) {
FIXME("GetComputedStyle failed: %08x\n", nsres);
return E_FAIL;
}
hres = create_computed_style(nsstyle, p);
nsIDOMCSSStyleDeclaration_Release(nsstyle);
return hres;
}
static HRESULT WINAPI HTMLWindow7_get_styleMedia(IHTMLWindow7 *iface, IHTMLStyleMedia **p)
......
......@@ -128,6 +128,7 @@ typedef struct EventTarget EventTarget;
XDIID(DispHTMLTextAreaElement) \
XDIID(DispHTMLTitleElement) \
XDIID(DispHTMLUnknownElement) \
XDIID(DispHTMLW3CComputedStyle) \
XDIID(DispHTMLWindow2) \
XDIID(DispHTMLXMLHttpRequest) \
XDIID(HTMLDocumentEvents) \
......
......@@ -463,6 +463,14 @@ static const IID * const cstyle_iids[] = {
NULL
};
static const IID * const computed_style_iids[] = {
&IID_IUnknown,
&IID_IDispatch,
&IID_IDispatchEx,
&IID_IHTMLCSSStyleDeclaration,
NULL
};
static const IID * const img_factory_iids[] = {
&IID_IUnknown,
&IID_IDispatch,
......@@ -6879,7 +6887,10 @@ static void test_window(IHTMLDocument2 *doc)
hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow7, (void**)&window7);
if(SUCCEEDED(hres)) {
IHTMLCSSStyleDeclaration *computed_style;
IHTMLPerformance *performance;
IHTMLDOMNode *node;
IHTMLElement *elem;
ok(window7 != NULL, "window7 == NULL\n");
......@@ -6907,6 +6918,25 @@ static void test_window(IHTMLDocument2 *doc)
IHTMLWindow7_Release(window7);
}
hres = IHTMLDocument2_get_body(doc, &elem);
ok(hres == S_OK, "get_body failed: %08x\n", hres);
hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLDOMNode, (void**)&node);
ok(hres == S_OK, "Could not get IHTMLDOMNode iface: %08x\n", hres);
hres = IHTMLWindow7_getComputedStyle(window7, node, NULL, &computed_style);
ok(hres == S_OK, "getComputedStyle failed: %08x\n", hres);
test_disp((IUnknown*)computed_style, &DIID_DispHTMLW3CComputedStyle, NULL, "[object]");
test_ifaces((IUnknown*)computed_style, computed_style_iids);
test_read_only_style(computed_style);
IHTMLCSSStyleDeclaration_Release(computed_style);
IHTMLDOMNode_Release(node);
IHTMLElement_Release(elem);
}else {
win_skip("IHTMLWindow7 not supported\n");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment