Module: wine Branch: master Commit: 952a54cbd933dbee18cbcc88521db11fb4ee7747 URL: http://source.winehq.org/git/wine.git/?a=commit;h=952a54cbd933dbee18cbcc8852...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Jul 11 23:45:04 2008 +0200
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 5f67356..670c615 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<length; i++) { + nsIDOMNodeList_Item(nslist, i, &nsnode); + buf.buf[i] = HTMLELEM_NODE_THIS(get_node(doc, nsnode, TRUE)); + nsIDOMNode_Release(nsnode); + } + }else { + buf.buf = NULL; + } + + return HTMLElementCollection_Create(unk, buf.buf, buf.len); +} + static IHTMLElementCollection *HTMLElementCollection_Create(IUnknown *ref_unk, HTMLElement **elems, DWORD len) { diff --git a/dlls/mshtml/htmlelem2.c b/dlls/mshtml/htmlelem2.c index d12c60c..5d0443e 100644 --- a/dlls/mshtml/htmlelem2.c +++ b/dlls/mshtml/htmlelem2.c @@ -917,12 +917,27 @@ static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, lon return E_NOTIMPL; }
-static HRESULT WINAPI HTMLElement2_getElementByTagName(IHTMLElement2 *iface, BSTR v, +static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v, IHTMLElementCollection **pelColl) { HTMLElement *This = HTMLELEM2_THIS(iface); - FIXME("(%p)->(%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 ef7868d..88f444d 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 {