Module: wine Branch: master Commit: 7858cc01b77da7c6b2e0db65dd751bb1e42faa7d URL: https://source.winehq.org/git/wine.git/?a=commit;h=7858cc01b77da7c6b2e0db65d...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Mar 28 15:55:46 2019 +0100
mshtml: Add IHTMLDocument7::createElementNS implementation.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mshtml/htmldoc.c | 35 +++++++++++++++++++++++++++++++++-- dlls/mshtml/tests/elements.js | 20 ++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 20d1c74..656acaf 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -3288,8 +3288,39 @@ static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem) { HTMLDocument *This = impl_from_IHTMLDocument7(iface); - FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem); - return E_NOTIMPL; + nsIDOMElement *dom_element; + HTMLElement *element; + nsAString ns, tag; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem); + + if(!This->doc_node->nsdoc) { + FIXME("NULL nsdoc\n"); + return E_FAIL; + } + + if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR) + FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS)); + + nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL); + nsAString_InitDepend(&tag, bstrTag); + nsres = nsIDOMHTMLDocument_CreateElementNS(This->doc_node->nsdoc, &ns, &tag, &dom_element); + nsAString_Finish(&ns); + nsAString_Finish(&tag); + if(NS_FAILED(nsres)) { + WARN("CreateElementNS failed: %08x\n", nsres); + return map_nsresult(nsres); + } + + hres = HTMLElement_Create(This->doc_node, (nsIDOMNode*)dom_element, FALSE, &element); + nsIDOMElement_Release(dom_element); + if(FAILED(hres)) + return hres; + + *newElem = &element->IHTMLElement_iface; + return S_OK; }
static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS, diff --git a/dlls/mshtml/tests/elements.js b/dlls/mshtml/tests/elements.js index 5077885..287ff35 100644 --- a/dlls/mshtml/tests/elements.js +++ b/dlls/mshtml/tests/elements.js @@ -168,6 +168,25 @@ function test_getElementsByClassName() { next_test(); }
+function test_createElementNS() { + var svg_ns = "http://www.w3.org/2000/svg"; + var elem; + + elem = document.createElementNS(null, "test"); + ok(elem.tagName === "test", "elem.tagName = " + elem.tagName); + + elem = document.createElementNS(svg_ns, "test"); + ok(elem.tagName === "test", "elem.tagName = " + elem.tagName); + + elem = document.createElementNS(svg_ns, "svg"); + ok(elem.tagName === "svg", "elem.tagName = " + elem.tagName); + + elem = document.createElementNS("test", "svg"); + ok(elem.tagName === "svg", "elem.tagName = " + elem.tagName); + + next_test(); +} + function test_query_selector() { document.body.innerHTML = '<div class="class1">' + '<div class="class1"></div>' @@ -351,6 +370,7 @@ var tests = [ test_textContent, test_ElementTraversal, test_getElementsByClassName, + test_createElementNS, test_head, test_iframe, test_anchor,