mshtml: Added IHTMLElement2::getElementsByTagName implementation.

This commit is contained in:
Jacek Caban 2008-07-11 23:45:04 +02:00 committed by Alexandre Julliard
parent 1de0055cc0
commit 952a54cbd9
3 changed files with 45 additions and 4 deletions

View File

@ -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)
{

View File

@ -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)

View File

@ -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 {