d3d: Enumerate palettized formats for ddraw.
[wine/multimedia.git] / dlls / mshtml / htmlelem.c
blob37abb518f2bce152e6e7a8aa041c100ed58e1b43
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 #include "mshtml_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 static HRESULT HTMLElementCollection_Create(IUnknown*,HTMLElement**,DWORD,IDispatch**);
41 typedef struct {
42 HTMLElement **buf;
43 DWORD len;
44 DWORD size;
45 } elem_vector;
47 static void elem_vector_add(elem_vector *buf, HTMLElement *elem)
49 if(buf->len == buf->size) {
50 buf->size <<= 1;
51 buf->buf = mshtml_realloc(buf->buf, buf->size*sizeof(HTMLElement**));
54 buf->buf[buf->len++] = elem;
57 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
59 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
60 REFIID riid, void **ppv)
62 HTMLElement *This = HTMLELEM_THIS(iface);
63 HRESULT hres;
65 if(This->impl)
66 return IUnknown_QueryInterface(This->impl, riid, ppv);
68 hres = HTMLElement_QI(This, riid, ppv);
69 if(FAILED(hres))
70 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
72 return hres;
75 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
77 HTMLElement *This = HTMLELEM_THIS(iface);
79 if(This->impl)
80 return IUnknown_AddRef(This->impl);
82 TRACE("(%p)\n", This);
83 return IHTMLDocument2_AddRef(HTMLDOC(This->node->doc));
86 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
88 HTMLElement *This = HTMLELEM_THIS(iface);
90 if(This->impl)
91 return IUnknown_Release(This->impl);
93 TRACE("(%p)\n", This);
94 return IHTMLDocument2_Release(HTMLDOC(This->node->doc));
97 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
99 HTMLElement *This = HTMLELEM_THIS(iface);
100 FIXME("(%p)->(%p)\n", This, pctinfo);
101 return E_NOTIMPL;
104 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
105 LCID lcid, ITypeInfo **ppTInfo)
107 HTMLElement *This = HTMLELEM_THIS(iface);
108 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
109 return E_NOTIMPL;
112 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
113 LPOLESTR *rgszNames, UINT cNames,
114 LCID lcid, DISPID *rgDispId)
116 HTMLElement *This = HTMLELEM_THIS(iface);
117 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
118 lcid, rgDispId);
119 return E_NOTIMPL;
122 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
123 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
124 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
126 HTMLElement *This = HTMLELEM_THIS(iface);
127 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
128 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
129 return E_NOTIMPL;
132 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
133 VARIANT AttributeValue, LONG lFlags)
135 HTMLElement *This = HTMLELEM_THIS(iface);
136 FIXME("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
137 return E_NOTIMPL;
140 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
141 LONG lFlags, VARIANT *AttributeValue)
143 HTMLElement *This = HTMLELEM_THIS(iface);
144 nsAString attr_str;
145 nsAString value_str;
146 const PRUnichar *value;
147 nsresult nsres;
148 HRESULT hres = S_OK;
150 WARN("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
152 nsAString_Init(&attr_str, strAttributeName);
153 nsAString_Init(&value_str, NULL);
155 nsres = nsIDOMHTMLElement_GetAttribute(This->nselem, &attr_str, &value_str);
156 nsAString_Finish(&attr_str);
158 if(NS_SUCCEEDED(nsres)) {
159 nsAString_GetData(&value_str, &value, NULL);
160 V_VT(AttributeValue) = VT_BSTR;
161 V_BSTR(AttributeValue) = SysAllocString(value);
162 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue)));
163 }else {
164 ERR("GetAttribute failed: %08x\n", nsres);
165 hres = E_FAIL;
168 nsAString_Finish(&value_str);
170 return hres;
173 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
174 LONG lFlags, VARIANT_BOOL *pfSuccess)
176 HTMLElement *This = HTMLELEM_THIS(iface);
177 FIXME("(%p)->()\n", This);
178 return E_NOTIMPL;
181 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
183 HTMLElement *This = HTMLELEM_THIS(iface);
184 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
185 return E_NOTIMPL;
188 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
190 HTMLElement *This = HTMLELEM_THIS(iface);
191 nsAString class_str;
192 nsresult nsres;
193 HRESULT hres = S_OK;
195 TRACE("(%p)->(%p)\n", This, p);
197 nsAString_Init(&class_str, NULL);
198 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
200 if(NS_SUCCEEDED(nsres)) {
201 const PRUnichar *class;
202 nsAString_GetData(&class_str, &class, NULL);
203 *p = SysAllocString(class);
204 }else {
205 ERR("GetClassName failed: %08x\n", nsres);
206 hres = E_FAIL;
209 nsAString_Finish(&class_str);
211 TRACE("className=%s\n", debugstr_w(*p));
212 return hres;
215 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
217 HTMLElement *This = HTMLELEM_THIS(iface);
218 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
219 return E_NOTIMPL;
222 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
224 HTMLElement *This = HTMLELEM_THIS(iface);
225 FIXME("(%p)->(%p)\n", This, p);
226 return E_NOTIMPL;
229 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
231 HTMLElement *This = HTMLELEM_THIS(iface);
232 FIXME("(%p)->(%p)\n", This, p);
233 return E_NOTIMPL;
236 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
238 HTMLElement *This = HTMLELEM_THIS(iface);
239 FIXME("(%p)->(%p)\n", This, p);
240 return E_NOTIMPL;
243 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
245 HTMLElement *This = HTMLELEM_THIS(iface);
246 nsIDOMElementCSSInlineStyle *nselemstyle;
247 nsIDOMCSSStyleDeclaration *nsstyle;
248 nsresult nsres;
250 TRACE("(%p)->(%p)\n", This, p);
252 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
253 (void**)&nselemstyle);
254 if(NS_FAILED(nsres)) {
255 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
256 return E_FAIL;
259 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
260 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
261 if(NS_FAILED(nsres)) {
262 ERR("GetStyle failed: %08x\n", nsres);
263 return E_FAIL;
266 /* FIXME: Store style instead of creating a new instance in each call */
267 *p = HTMLStyle_Create(nsstyle);
269 nsIDOMCSSStyleDeclaration_Release(nsstyle);
270 return S_OK;
273 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
275 HTMLElement *This = HTMLELEM_THIS(iface);
276 FIXME("(%p)->()\n", This);
277 return E_NOTIMPL;
280 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
282 HTMLElement *This = HTMLELEM_THIS(iface);
283 FIXME("(%p)->(%p)\n", This, p);
284 return E_NOTIMPL;
287 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
289 HTMLElement *This = HTMLELEM_THIS(iface);
290 FIXME("(%p)->()\n", This);
291 return E_NOTIMPL;
294 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
296 HTMLElement *This = HTMLELEM_THIS(iface);
297 FIXME("(%p)->(%p)\n", This, p);
298 return E_NOTIMPL;
301 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
303 HTMLElement *This = HTMLELEM_THIS(iface);
304 FIXME("(%p)->()\n", This);
305 return E_NOTIMPL;
308 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
310 HTMLElement *This = HTMLELEM_THIS(iface);
311 FIXME("(%p)->(%p)\n", This, p);
312 return E_NOTIMPL;
315 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
317 HTMLElement *This = HTMLELEM_THIS(iface);
318 FIXME("(%p)->()\n", This);
319 return E_NOTIMPL;
322 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
324 HTMLElement *This = HTMLELEM_THIS(iface);
325 FIXME("(%p)->(%p)\n", This, p);
326 return E_NOTIMPL;
329 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
331 HTMLElement *This = HTMLELEM_THIS(iface);
332 FIXME("(%p)->()\n", This);
333 return E_NOTIMPL;
336 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
338 HTMLElement *This = HTMLELEM_THIS(iface);
339 FIXME("(%p)->(%p)\n", This, p);
340 return E_NOTIMPL;
343 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
345 HTMLElement *This = HTMLELEM_THIS(iface);
346 FIXME("(%p)->()\n", This);
347 return E_NOTIMPL;
350 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
352 HTMLElement *This = HTMLELEM_THIS(iface);
353 FIXME("(%p)->(%p)\n", This, p);
354 return E_NOTIMPL;
357 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
359 HTMLElement *This = HTMLELEM_THIS(iface);
360 FIXME("(%p)->()\n", This);
361 return E_NOTIMPL;
364 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
366 HTMLElement *This = HTMLELEM_THIS(iface);
367 FIXME("(%p)->(%p)\n", This, p);
368 return E_NOTIMPL;
371 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
373 HTMLElement *This = HTMLELEM_THIS(iface);
374 FIXME("(%p)->()\n", This);
375 return E_NOTIMPL;
378 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
380 HTMLElement *This = HTMLELEM_THIS(iface);
381 FIXME("(%p)->(%p)\n", This, p);
382 return E_NOTIMPL;
385 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
387 HTMLElement *This = HTMLELEM_THIS(iface);
388 FIXME("(%p)->()\n", This);
389 return E_NOTIMPL;
392 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
394 HTMLElement *This = HTMLELEM_THIS(iface);
395 FIXME("(%p)->(%p)\n", This, p);
396 return E_NOTIMPL;
399 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
401 HTMLElement *This = HTMLELEM_THIS(iface);
402 FIXME("(%p)->()\n", This);
403 return E_NOTIMPL;
406 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
408 HTMLElement *This = HTMLELEM_THIS(iface);
409 FIXME("(%p)->(%p)\n", This, p);
410 return E_NOTIMPL;
413 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
415 HTMLElement *This = HTMLELEM_THIS(iface);
416 FIXME("(%p)->()\n", This);
417 return E_NOTIMPL;
420 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
422 HTMLElement *This = HTMLELEM_THIS(iface);
423 FIXME("(%p)->(%p)\n", This, p);
424 return E_NOTIMPL;
427 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
429 HTMLElement *This = HTMLELEM_THIS(iface);
430 FIXME("(%p)->(%p)\n", This, p);
431 return E_NOTIMPL;
434 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
436 HTMLElement *This = HTMLELEM_THIS(iface);
437 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
438 return E_NOTIMPL;
441 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
443 HTMLElement *This = HTMLELEM_THIS(iface);
444 FIXME("(%p)->(%p)\n", This, p);
445 return E_NOTIMPL;
448 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
450 HTMLElement *This = HTMLELEM_THIS(iface);
451 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
452 return E_NOTIMPL;
455 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
457 HTMLElement *This = HTMLELEM_THIS(iface);
458 FIXME("(%p)->(%p)\n", This, p);
459 return E_NOTIMPL;
462 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
464 HTMLElement *This = HTMLELEM_THIS(iface);
465 FIXME("(%p)->()\n", This);
466 return E_NOTIMPL;
469 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
471 HTMLElement *This = HTMLELEM_THIS(iface);
472 FIXME("(%p)->(%p)\n", This, p);
473 return E_NOTIMPL;
476 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
478 HTMLElement *This = HTMLELEM_THIS(iface);
479 FIXME("(%p)->()\n", This);
480 return E_NOTIMPL;
483 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
484 VARIANT_BOOL *pfResult)
486 HTMLElement *This = HTMLELEM_THIS(iface);
487 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
488 return E_NOTIMPL;
491 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, long *p)
493 HTMLElement *This = HTMLELEM_THIS(iface);
494 FIXME("(%p)->(%p)\n", This, p);
495 return E_NOTIMPL;
498 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
500 HTMLElement *This = HTMLELEM_THIS(iface);
501 FIXME("(%p)->(%p)\n", This, p);
502 return E_NOTIMPL;
505 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
507 HTMLElement *This = HTMLELEM_THIS(iface);
508 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
509 return E_NOTIMPL;
512 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
514 HTMLElement *This = HTMLELEM_THIS(iface);
515 FIXME("(%p)->(%p)\n", This, p);
516 return E_NOTIMPL;
519 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, long *p)
521 HTMLElement *This = HTMLELEM_THIS(iface);
522 FIXME("(%p)->(%p)\n", This, p);
523 return E_NOTIMPL;
526 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, long *p)
528 HTMLElement *This = HTMLELEM_THIS(iface);
529 FIXME("(%p)->(%p)\n", This, p);
530 return E_NOTIMPL;
533 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, long *p)
535 HTMLElement *This = HTMLELEM_THIS(iface);
536 FIXME("(%p)->(%p)\n", This, p);
537 return E_NOTIMPL;
540 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, long *p)
542 HTMLElement *This = HTMLELEM_THIS(iface);
543 FIXME("(%p)->(%p)\n", This, p);
544 return E_NOTIMPL;
547 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
549 HTMLElement *This = HTMLELEM_THIS(iface);
550 FIXME("(%p)->(%p)\n", This, p);
551 return E_NOTIMPL;
554 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
556 HTMLElement *This = HTMLELEM_THIS(iface);
557 nsIDOMNSHTMLElement *nselem;
558 nsAString html_str;
559 nsresult nsres;
561 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
563 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
564 if(NS_FAILED(nsres)) {
565 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
566 return E_FAIL;
569 nsAString_Init(&html_str, v);
570 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
571 nsAString_Finish(&html_str);
573 if(NS_FAILED(nsres)) {
574 FIXME("SetInnerHtml failed %08x\n", nsres);
575 return E_FAIL;
578 return S_OK;
581 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
583 HTMLElement *This = HTMLELEM_THIS(iface);
584 FIXME("(%p)->(%p)\n", This, p);
585 return E_NOTIMPL;
588 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
590 HTMLElement *This = HTMLELEM_THIS(iface);
591 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
592 return E_NOTIMPL;
595 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
597 HTMLElement *This = HTMLELEM_THIS(iface);
598 FIXME("(%p)->(%p)\n", This, p);
599 return E_NOTIMPL;
602 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
604 HTMLElement *This = HTMLELEM_THIS(iface);
605 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
606 return E_NOTIMPL;
609 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
611 HTMLElement *This = HTMLELEM_THIS(iface);
612 FIXME("(%p)->(%p)\n", This, p);
613 return E_NOTIMPL;
616 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
618 HTMLElement *This = HTMLELEM_THIS(iface);
619 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
620 return E_NOTIMPL;
623 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
625 HTMLElement *This = HTMLELEM_THIS(iface);
626 FIXME("(%p)->(%p)\n", This, p);
627 return E_NOTIMPL;
630 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
631 BSTR html)
633 HTMLElement *This = HTMLELEM_THIS(iface);
634 FIXME("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
635 return E_NOTIMPL;
638 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
639 BSTR text)
641 HTMLElement *This = HTMLELEM_THIS(iface);
642 FIXME("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
643 return E_NOTIMPL;
646 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
648 HTMLElement *This = HTMLELEM_THIS(iface);
649 FIXME("(%p)->(%p)\n", This, p);
650 return E_NOTIMPL;
653 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
655 HTMLElement *This = HTMLELEM_THIS(iface);
656 FIXME("(%p)->(%p)\n", This, p);
657 return E_NOTIMPL;
660 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
662 HTMLElement *This = HTMLELEM_THIS(iface);
663 FIXME("(%p)\n", This);
664 return E_NOTIMPL;
667 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
668 IHTMLFiltersCollection **p)
670 HTMLElement *This = HTMLELEM_THIS(iface);
671 FIXME("(%p)->(%p)\n", This, p);
672 return E_NOTIMPL;
675 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
677 HTMLElement *This = HTMLELEM_THIS(iface);
678 FIXME("(%p)->()\n", This);
679 return E_NOTIMPL;
682 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
684 HTMLElement *This = HTMLELEM_THIS(iface);
685 FIXME("(%p)->(%p)\n", This, p);
686 return E_NOTIMPL;
689 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
691 HTMLElement *This = HTMLELEM_THIS(iface);
692 FIXME("(%p)->(%p)\n", This, String);
693 return E_NOTIMPL;
696 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
698 HTMLElement *This = HTMLELEM_THIS(iface);
699 FIXME("(%p)->()\n", This);
700 return E_NOTIMPL;
703 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
705 HTMLElement *This = HTMLELEM_THIS(iface);
706 FIXME("(%p)->(%p)\n", This, p);
707 return E_NOTIMPL;
710 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
712 HTMLElement *This = HTMLELEM_THIS(iface);
713 FIXME("(%p)->()\n", This);
714 return E_NOTIMPL;
717 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
719 HTMLElement *This = HTMLELEM_THIS(iface);
720 FIXME("(%p)->(%p)\n", This, p);
721 return E_NOTIMPL;
724 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
726 HTMLElement *This = HTMLELEM_THIS(iface);
727 FIXME("(%p)->()\n", This);
728 return E_NOTIMPL;
731 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
733 HTMLElement *This = HTMLELEM_THIS(iface);
734 FIXME("(%p)->(%p)\n", This, p);
735 return E_NOTIMPL;
738 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
740 HTMLElement *This = HTMLELEM_THIS(iface);
741 FIXME("(%p)->()\n", This);
742 return E_NOTIMPL;
745 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
747 HTMLElement *This = HTMLELEM_THIS(iface);
748 FIXME("(%p)->(%p)\n", This, p);
749 return E_NOTIMPL;
752 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
754 HTMLElement *This = HTMLELEM_THIS(iface);
755 FIXME("(%p)->()\n", This);
756 return E_NOTIMPL;
759 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
761 HTMLElement *This = HTMLELEM_THIS(iface);
762 FIXME("(%p)->(%p)\n", This, p);
763 return E_NOTIMPL;
766 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
768 HTMLElement *This = HTMLELEM_THIS(iface);
769 FIXME("(%p)->()\n", This);
770 return E_NOTIMPL;
773 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
775 HTMLElement *This = HTMLELEM_THIS(iface);
776 FIXME("(%p)->(%p)\n", This, p);
777 return E_NOTIMPL;
780 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
782 HTMLElement *This = HTMLELEM_THIS(iface);
783 FIXME("(%p)->()\n", This);
784 return E_NOTIMPL;
787 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
789 HTMLElement *This = HTMLELEM_THIS(iface);
790 FIXME("(%p)->(%p)\n", This, p);
791 return E_NOTIMPL;
794 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
796 HTMLElement *This = HTMLELEM_THIS(iface);
797 FIXME("(%p)->()\n", This);
798 return E_NOTIMPL;
801 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
803 HTMLElement *This = HTMLELEM_THIS(iface);
804 FIXME("(%p)->(%p)\n", This, p);
805 return E_NOTIMPL;
808 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
810 HTMLElement *This = HTMLELEM_THIS(iface);
811 FIXME("(%p)->()\n", This);
812 return E_NOTIMPL;
815 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
817 HTMLElement *This = HTMLELEM_THIS(iface);
818 FIXME("(%p)->(%p)\n", This, p);
819 return E_NOTIMPL;
822 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
824 HTMLElement *This = HTMLELEM_THIS(iface);
825 FIXME("(%p)->(%p)\n", This, p);
826 return E_NOTIMPL;
829 static void create_all_list(HTMLDocument *doc, HTMLElement *elem, elem_vector *buf)
831 nsIDOMNodeList *nsnode_list;
832 nsIDOMNode *iter;
833 PRUint32 list_len = 0, i;
834 HTMLDOMNode *node;
835 nsresult nsres;
837 nsres = nsIDOMNode_GetChildNodes(elem->node->nsnode, &nsnode_list);
838 if(NS_FAILED(nsres)) {
839 ERR("GetChildNodes failed: %08x\n", nsres);
840 return;
843 nsIDOMNodeList_GetLength(nsnode_list, &list_len);
844 if(!list_len)
845 return;
847 for(i=0; i<list_len; i++) {
848 nsres = nsIDOMNodeList_Item(nsnode_list, i, &iter);
849 if(NS_FAILED(nsres)) {
850 ERR("Item failed: %08x\n", nsres);
851 continue;
854 node = get_node(doc, iter);
855 if(node->node_type != NT_HTMLELEM)
856 continue;
858 elem_vector_add(buf, (HTMLElement*)node->impl.elem);
859 create_all_list(doc, (HTMLElement*)node->impl.elem, buf);
863 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
865 HTMLElement *This = HTMLELEM_THIS(iface);
866 elem_vector buf = {NULL, 0, 8};
868 TRACE("(%p)->(%p)\n", This, p);
870 buf.buf = mshtml_alloc(buf.size*sizeof(HTMLElement**));
872 create_all_list(This->node->doc, This, &buf);
874 if(!buf.len) {
875 mshtml_free(buf.buf);
876 buf.buf = NULL;
877 }else if(buf.size > buf.len) {
878 buf.buf = mshtml_realloc(buf.buf, buf.len*sizeof(HTMLElement**));
881 return HTMLElementCollection_Create((IUnknown*)HTMLELEM(This), buf.buf, buf.len, p);
884 static void HTMLElement_destructor(IUnknown *iface)
886 HTMLElement *This = HTMLELEM_THIS(iface);
888 if(This->destructor)
889 This->destructor(This->impl);
891 if(This->nselem)
892 nsIDOMHTMLElement_Release(This->nselem);
894 mshtml_free(This);
897 #undef HTMLELEM_THIS
899 static const IHTMLElementVtbl HTMLElementVtbl = {
900 HTMLElement_QueryInterface,
901 HTMLElement_AddRef,
902 HTMLElement_Release,
903 HTMLElement_GetTypeInfoCount,
904 HTMLElement_GetTypeInfo,
905 HTMLElement_GetIDsOfNames,
906 HTMLElement_Invoke,
907 HTMLElement_setAttribute,
908 HTMLElement_getAttribute,
909 HTMLElement_removeAttribute,
910 HTMLElement_put_className,
911 HTMLElement_get_className,
912 HTMLElement_put_id,
913 HTMLElement_get_id,
914 HTMLElement_get_tagName,
915 HTMLElement_get_parentElement,
916 HTMLElement_get_style,
917 HTMLElement_put_onhelp,
918 HTMLElement_get_onhelp,
919 HTMLElement_put_onclick,
920 HTMLElement_get_onclick,
921 HTMLElement_put_ondblclick,
922 HTMLElement_get_ondblclick,
923 HTMLElement_put_onkeydown,
924 HTMLElement_get_onkeydown,
925 HTMLElement_put_onkeyup,
926 HTMLElement_get_onkeyup,
927 HTMLElement_put_onkeypress,
928 HTMLElement_get_onkeypress,
929 HTMLElement_put_onmouseout,
930 HTMLElement_get_onmouseout,
931 HTMLElement_put_onmouseover,
932 HTMLElement_get_onmouseover,
933 HTMLElement_put_onmousemove,
934 HTMLElement_get_onmousemove,
935 HTMLElement_put_onmousedown,
936 HTMLElement_get_onmousedown,
937 HTMLElement_put_onmouseup,
938 HTMLElement_get_onmouseup,
939 HTMLElement_get_document,
940 HTMLElement_put_title,
941 HTMLElement_get_title,
942 HTMLElement_put_language,
943 HTMLElement_get_language,
944 HTMLElement_put_onselectstart,
945 HTMLElement_get_onselectstart,
946 HTMLElement_scrollIntoView,
947 HTMLElement_contains,
948 HTMLElement_get_sourceIndex,
949 HTMLElement_get_recordNumber,
950 HTMLElement_put_lang,
951 HTMLElement_get_lang,
952 HTMLElement_get_offsetLeft,
953 HTMLElement_get_offsetTop,
954 HTMLElement_get_offsetWidth,
955 HTMLElement_get_offsetHeight,
956 HTMLElement_get_offsetParent,
957 HTMLElement_put_innerHTML,
958 HTMLElement_get_innerHTML,
959 HTMLElement_put_innerText,
960 HTMLElement_get_innerText,
961 HTMLElement_put_outerHTML,
962 HTMLElement_get_outerHTML,
963 HTMLElement_put_outerText,
964 HTMLElement_get_outerText,
965 HTMLElement_insertAdjacentHTML,
966 HTMLElement_insertAdjacentText,
967 HTMLElement_get_parentTextEdit,
968 HTMLElement_get_isTextEdit,
969 HTMLElement_click,
970 HTMLElement_get_filters,
971 HTMLElement_put_ondragstart,
972 HTMLElement_get_ondragstart,
973 HTMLElement_toString,
974 HTMLElement_put_onbeforeupdate,
975 HTMLElement_get_onbeforeupdate,
976 HTMLElement_put_onafterupdate,
977 HTMLElement_get_onafterupdate,
978 HTMLElement_put_onerrorupdate,
979 HTMLElement_get_onerrorupdate,
980 HTMLElement_put_onrowexit,
981 HTMLElement_get_onrowexit,
982 HTMLElement_put_onrowenter,
983 HTMLElement_get_onrowenter,
984 HTMLElement_put_ondatasetchanged,
985 HTMLElement_get_ondatasetchanged,
986 HTMLElement_put_ondataavailable,
987 HTMLElement_get_ondataavailable,
988 HTMLElement_put_ondatasetcomplete,
989 HTMLElement_get_ondatasetcomplete,
990 HTMLElement_put_onfilterchange,
991 HTMLElement_get_onfilterchange,
992 HTMLElement_get_children,
993 HTMLElement_get_all
996 HRESULT HTMLElement_QI(HTMLElement *This, REFIID riid, void **ppv)
998 *ppv = NULL;
1000 if(IsEqualGUID(&IID_IUnknown, riid)) {
1001 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1002 *ppv = HTMLELEM(This);
1003 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1004 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1005 *ppv = HTMLELEM(This);
1006 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1007 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1008 *ppv = HTMLELEM(This);
1009 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1010 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1011 *ppv = HTMLELEM2(This);
1014 if(*ppv) {
1015 IHTMLElement_AddRef(HTMLELEM(This));
1016 return S_OK;
1019 return HTMLDOMNode_QI(This->node, riid, ppv);
1022 void HTMLElement_Create(HTMLDOMNode *node)
1024 HTMLElement *ret;
1025 nsAString class_name_str;
1026 const PRUnichar *class_name;
1027 nsresult nsres;
1029 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
1030 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
1031 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
1032 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
1034 ret = mshtml_alloc(sizeof(HTMLElement));
1035 ret->lpHTMLElementVtbl = &HTMLElementVtbl;
1036 ret->node = node;
1037 ret->impl = NULL;
1038 ret->destructor = NULL;
1040 node->node_type = NT_HTMLELEM;
1041 node->impl.elem = HTMLELEM(ret);
1042 node->destructor = HTMLElement_destructor;
1044 HTMLElement2_Init(ret);
1046 nsres = nsIDOMNode_QueryInterface(node->nsnode, &IID_nsIDOMHTMLElement, (void**)&ret->nselem);
1047 if(NS_FAILED(nsres))
1048 return;
1050 nsAString_Init(&class_name_str, NULL);
1051 nsIDOMHTMLElement_GetTagName(ret->nselem, &class_name_str);
1053 nsAString_GetData(&class_name_str, &class_name, NULL);
1055 if(!strcmpW(class_name, wszBODY))
1056 HTMLBodyElement_Create(ret);
1057 else if(!strcmpW(class_name, wszINPUT))
1058 HTMLInputElement_Create(ret);
1059 else if(!strcmpW(class_name, wszSELECT))
1060 HTMLSelectElement_Create(ret);
1061 else if(!strcmpW(class_name, wszTEXTAREA))
1062 HTMLTextAreaElement_Create(ret);
1064 nsAString_Finish(&class_name_str);
1067 typedef struct {
1068 const IHTMLElementCollectionVtbl *lpHTMLElementCollectionVtbl;
1070 IUnknown *ref_unk;
1071 HTMLElement **elems;
1072 DWORD len;
1074 LONG ref;
1075 } HTMLElementCollection;
1077 #define HTMLELEMCOL(x) ((IHTMLElementCollection*) &(x)->lpHTMLElementCollectionVtbl)
1079 #define ELEMCOL_THIS(iface) DEFINE_THIS(HTMLElementCollection, HTMLElementCollection, iface)
1081 static HRESULT WINAPI HTMLElementCollection_QueryInterface(IHTMLElementCollection *iface,
1082 REFIID riid, void **ppv)
1084 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1086 *ppv = NULL;
1088 if(IsEqualGUID(&IID_IUnknown, riid)) {
1089 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1090 *ppv = HTMLELEMCOL(This);
1091 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1092 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1093 *ppv = HTMLELEMCOL(This);
1094 }else if(IsEqualGUID(&IID_IHTMLElementCollection, riid)) {
1095 TRACE("(%p)->(IID_IHTMLElementCollection %p)\n", This, ppv);
1096 *ppv = HTMLELEMCOL(This);
1099 if(*ppv) {
1100 IHTMLElementCollection_AddRef(HTMLELEMCOL(This));
1101 return S_OK;
1104 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1105 return E_NOINTERFACE;
1108 static ULONG WINAPI HTMLElementCollection_AddRef(IHTMLElementCollection *iface)
1110 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1111 LONG ref = InterlockedIncrement(&This->ref);
1113 TRACE("(%p) ref=%d\n", This, ref);
1115 return ref;
1118 static ULONG WINAPI HTMLElementCollection_Release(IHTMLElementCollection *iface)
1120 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1121 LONG ref = InterlockedDecrement(&This->ref);
1123 TRACE("(%p) ref=%d\n", This, ref);
1125 if(!ref) {
1126 IUnknown_Release(This->ref_unk);
1127 mshtml_free(This->elems);
1128 mshtml_free(This);
1131 return ref;
1134 static HRESULT WINAPI HTMLElementCollection_GetTypeInfoCount(IHTMLElementCollection *iface,
1135 UINT *pctinfo)
1137 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1138 FIXME("(%p)->(%p)\n", This, pctinfo);
1139 return E_NOTIMPL;
1142 static HRESULT WINAPI HTMLElementCollection_GetTypeInfo(IHTMLElementCollection *iface,
1143 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1145 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1146 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1147 return E_NOTIMPL;
1150 static HRESULT WINAPI HTMLElementCollection_GetIDsOfNames(IHTMLElementCollection *iface,
1151 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1153 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1154 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1155 lcid, rgDispId);
1156 return E_NOTIMPL;
1159 static HRESULT WINAPI HTMLElementCollection_Invoke(IHTMLElementCollection *iface,
1160 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1161 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1163 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1164 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1165 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1166 return E_NOTIMPL;
1169 static HRESULT WINAPI HTMLElementCollection_toString(IHTMLElementCollection *iface,
1170 BSTR *String)
1172 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1173 FIXME("(%p)->(%p)\n", This, String);
1174 return E_NOTIMPL;
1177 static HRESULT WINAPI HTMLElementCollection_put_length(IHTMLElementCollection *iface,
1178 long v)
1180 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1181 FIXME("(%p)->(%ld)\n", This, v);
1182 return E_NOTIMPL;
1185 static HRESULT WINAPI HTMLElementCollection_get_length(IHTMLElementCollection *iface,
1186 long *p)
1188 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1190 TRACE("(%p)->(%p)\n", This, p);
1192 *p = This->len;
1193 return S_OK;
1196 static HRESULT WINAPI HTMLElementCollection_get__newEnum(IHTMLElementCollection *iface,
1197 IUnknown **p)
1199 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1200 FIXME("(%p)->(%p)\n", This, p);
1201 return E_NOTIMPL;
1204 static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
1205 VARIANT name, VARIANT index, IDispatch **pdisp)
1207 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1209 TRACE("(%p)->(v(%d) v(%d) %p)\n", This, V_VT(&name), V_VT(&index), pdisp);
1211 if(V_VT(&name) == VT_I4) {
1212 TRACE("name is VT_I4: %d\n", V_I4(&name));
1213 if(V_I4(&name) < 0 || V_I4(&name) >= This->len) {
1214 ERR("Invalid name! name=%d\n", V_I4(&name));
1215 return E_INVALIDARG;
1218 *pdisp = (IDispatch*)This->elems[V_I4(&name)];
1219 IDispatch_AddRef(*pdisp);
1220 TRACE("Returning pdisp=%p\n", pdisp);
1221 return S_OK;
1224 if(V_VT(&name) == VT_BSTR) {
1225 DWORD i;
1226 nsAString tag_str;
1227 const PRUnichar *tag;
1228 elem_vector buf = {NULL, 0, 8};
1230 TRACE("name is VT_BSTR: %s\n", debugstr_w(V_BSTR(&name)));
1232 nsAString_Init(&tag_str, NULL);
1233 buf.buf = mshtml_alloc(buf.size*sizeof(HTMLElement*));
1235 for(i=0; i<This->len; i++) {
1236 if(!This->elems[i]->nselem) continue;
1238 nsIDOMHTMLElement_GetId(This->elems[i]->nselem, &tag_str);
1239 nsAString_GetData(&tag_str, &tag, NULL);
1241 if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, tag, -1,
1242 V_BSTR(&name), -1) == CSTR_EQUAL) {
1243 TRACE("Found name. elem=%d\n", i);
1244 if (V_VT(&index) == VT_I4)
1245 if (buf.len == V_I4(&index)) {
1246 nsAString_Finish(&tag_str);
1247 mshtml_free(buf.buf);
1248 buf.buf = NULL;
1249 *pdisp = (IDispatch*)This->elems[i];
1250 TRACE("Returning element %d pdisp=%p\n", i, pdisp);
1251 IDispatch_AddRef(*pdisp);
1252 return S_OK;
1254 elem_vector_add(&buf, This->elems[i]);
1257 nsAString_Finish(&tag_str);
1258 if (V_VT(&index) == VT_I4) {
1259 mshtml_free(buf.buf);
1260 buf.buf = NULL;
1261 ERR("Invalid index. index=%d >= buf.len=%d\n",V_I4(&index), buf.len);
1262 return E_INVALIDARG;
1264 if(!buf.len) {
1265 mshtml_free(buf.buf);
1266 buf.buf = NULL;
1267 } else if(buf.size > buf.len) {
1268 buf.buf = mshtml_realloc(buf.buf, buf.len*sizeof(HTMLElement*));
1270 TRACE("Returning %d element(s).\n", buf.len);
1271 return HTMLElementCollection_Create(This->ref_unk, buf.buf, buf.len, pdisp);
1274 FIXME("unsupported arguments\n");
1275 return E_INVALIDARG;
1278 static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface,
1279 VARIANT tagName, IDispatch **pdisp)
1281 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1282 DWORD i;
1283 nsAString tag_str;
1284 const PRUnichar *tag;
1285 elem_vector buf = {NULL, 0, 8};
1287 if(V_VT(&tagName) != VT_BSTR) {
1288 WARN("Invalid arg\n");
1289 return DISP_E_MEMBERNOTFOUND;
1292 TRACE("(%p)->(%s %p)\n", This, debugstr_w(V_BSTR(&tagName)), pdisp);
1294 buf.buf = mshtml_alloc(buf.size*sizeof(HTMLElement*));
1296 nsAString_Init(&tag_str, NULL);
1298 for(i=0; i<This->len; i++) {
1299 if(!This->elems[i]->nselem)
1300 continue;
1302 nsIDOMElement_GetTagName(This->elems[i]->nselem, &tag_str);
1303 nsAString_GetData(&tag_str, &tag, NULL);
1305 if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, tag, -1,
1306 V_BSTR(&tagName), -1) == CSTR_EQUAL)
1307 elem_vector_add(&buf, This->elems[i]);
1310 nsAString_Finish(&tag_str);
1312 TRACE("fount %d tags\n", buf.len);
1314 if(!buf.len) {
1315 mshtml_free(buf.buf);
1316 buf.buf = NULL;
1317 }else if(buf.size > buf.len) {
1318 buf.buf = mshtml_realloc(buf.buf, buf.len*sizeof(HTMLElement*));
1321 return HTMLElementCollection_Create(This->ref_unk, buf.buf, buf.len, pdisp);
1324 #undef ELEMCOL_THIS
1326 static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl = {
1327 HTMLElementCollection_QueryInterface,
1328 HTMLElementCollection_AddRef,
1329 HTMLElementCollection_Release,
1330 HTMLElementCollection_GetTypeInfoCount,
1331 HTMLElementCollection_GetTypeInfo,
1332 HTMLElementCollection_GetIDsOfNames,
1333 HTMLElementCollection_Invoke,
1334 HTMLElementCollection_toString,
1335 HTMLElementCollection_put_length,
1336 HTMLElementCollection_get_length,
1337 HTMLElementCollection_get__newEnum,
1338 HTMLElementCollection_item,
1339 HTMLElementCollection_tags
1342 static HRESULT HTMLElementCollection_Create(IUnknown *ref_unk, HTMLElement **elems, DWORD len,
1343 IDispatch **p)
1345 HTMLElementCollection *ret = mshtml_alloc(sizeof(HTMLElementCollection));
1347 ret->lpHTMLElementCollectionVtbl = &HTMLElementCollectionVtbl;
1348 ret->ref = 1;
1349 ret->elems = elems;
1350 ret->len = len;
1352 IUnknown_AddRef(ref_unk);
1353 ret->ref_unk = ref_unk;
1355 TRACE("ret=%p len=%d\n", ret, len);
1357 *p = (IDispatch*)ret;
1358 return S_OK;