Jacek Caban : mshtml: Add IHTMLWindow7::getComputedStyle implementation.
Alexandre Julliard
julliard at winehq.org
Wed Mar 27 17:27:37 CDT 2019
Module: wine
Branch: master
Commit: 08939329709c3436ce7b3563b1b20c108241fac6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=08939329709c3436ce7b3563b1b20c108241fac6
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Mar 27 18:52:14 2019 +0100
mshtml: Add IHTMLWindow7::getComputedStyle implementation.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mshtml/htmlstyle.c | 22 ++++++++++++++++++++++
dlls/mshtml/htmlstyle.h | 1 +
dlls/mshtml/htmlwindow.c | 39 +++++++++++++++++++++++++++++++++++++--
dlls/mshtml/mshtml_private.h | 1 +
dlls/mshtml/tests/dom.c | 30 ++++++++++++++++++++++++++++++
5 files changed, 91 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index 7f99c89..441346b 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -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;
diff --git a/dlls/mshtml/htmlstyle.h b/dlls/mshtml/htmlstyle.h
index 2c4b76b..9dcf3d9 100644
--- a/dlls/mshtml/htmlstyle.h
+++ b/dlls/mshtml/htmlstyle.h
@@ -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;
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index 926ebb9..55c03df 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -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)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index a2b05e7..967fda2 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -128,6 +128,7 @@ typedef struct EventTarget EventTarget;
XDIID(DispHTMLTextAreaElement) \
XDIID(DispHTMLTitleElement) \
XDIID(DispHTMLUnknownElement) \
+ XDIID(DispHTMLW3CComputedStyle) \
XDIID(DispHTMLWindow2) \
XDIID(DispHTMLXMLHttpRequest) \
XDIID(HTMLDocumentEvents) \
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index bf23163..7475c8f 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -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");
}
More information about the wine-cvs
mailing list