From 952a54cbd933dbee18cbcc88521db11fb4ee7747 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 11 Jul 2008 23:45:04 +0200 Subject: [PATCH] mshtml: Added IHTMLElement2::getElementsByTagName implementation. --- dlls/mshtml/htmlelem.c | 25 +++++++++++++++++++++++++ dlls/mshtml/htmlelem2.c | 23 +++++++++++++++++++---- dlls/mshtml/mshtml_private.h | 1 + 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 5f67356338..670c615195 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1896,6 +1896,31 @@ IHTMLElementCollection *create_all_collection(HTMLDOMNode *node) return HTMLElementCollection_Create((IUnknown*)HTMLDOMNODE(node), buf.buf, buf.len); } +IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument *doc, IUnknown *unk, nsIDOMNodeList *nslist) +{ + PRUint32 length = 0, i; + elem_vector buf; + + nsIDOMNodeList_GetLength(nslist, &length); + + buf.len = buf.size = length; + if(buf.len) { + nsIDOMNode *nsnode; + + buf.buf = heap_alloc(buf.size*sizeof(HTMLElement*)); + + for(i=0; i(%s %p)\n", This, debugstr_w(v), pelColl); - return E_NOTIMPL; + nsIDOMNodeList *nslist; + nsAString tag_str; + nsresult nsres; + + TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl); + + nsAString_Init(&tag_str, v); + nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nslist); + nsAString_Finish(&tag_str); + if(NS_FAILED(nsres)) { + ERR("GetElementByTagName failed: %08x\n", nsres); + return E_FAIL; + } + + *pelColl = create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nslist); + nsIDOMNodeList_Release(nslist); + return S_OK; } #undef HTMLELEM2_THIS @@ -1032,7 +1047,7 @@ static const IHTMLElement2Vtbl HTMLElement2Vtbl = { HTMLElement2_put_onbeforeeditfocus, HTMLElement2_get_onbeforeeditfocus, HTMLElement2_get_readyStateValue, - HTMLElement2_getElementByTagName, + HTMLElement2_getElementsByTagName, }; void HTMLElement2_Init(HTMLElement *This) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index ef7868df0b..88f444d15a 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -566,6 +566,7 @@ void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*); IDispatch *script_parse_event(HTMLDocument*,LPCWSTR); IHTMLElementCollection *create_all_collection(HTMLDOMNode*); +IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument*,IUnknown*,nsIDOMNodeList*); /* commands */ typedef struct {