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
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**);
47 static void elem_vector_add(elem_vector *buf, HTMLElement *elem)
49 if(buf->len == buf->size) {
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);
66 return IUnknown_QueryInterface(This->impl, riid, ppv);
68 hres = HTMLElement_QI(This, riid, ppv);
70 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
75 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
77 HTMLElement *This = HTMLELEM_THIS(iface);
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);
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);
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);
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,
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);
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);
140 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
141 LONG lFlags, VARIANT *AttributeValue)
143 HTMLElement *This = HTMLELEM_THIS(iface);
146 const PRUnichar *value;
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)));
164 ERR("GetAttribute failed: %08x\n", nsres);
168 nsAString_Finish(&value_str);
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);
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));
188 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
190 HTMLElement *This = HTMLELEM_THIS(iface);
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);
205 ERR("GetClassName failed: %08x\n", nsres);
209 nsAString_Finish(&class_str);
211 TRACE("className=%s\n", debugstr_w(*p));
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));
222 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
224 HTMLElement *This = HTMLELEM_THIS(iface);
225 FIXME("(%p)->(%p)\n", This, p);
229 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
231 HTMLElement *This = HTMLELEM_THIS(iface);
232 FIXME("(%p)->(%p)\n", This, p);
236 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
238 HTMLElement *This = HTMLELEM_THIS(iface);
239 FIXME("(%p)->(%p)\n", This, p);
243 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
245 HTMLElement *This = HTMLELEM_THIS(iface);
246 FIXME("(%p)->(%p)\n", This, p);
250 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
252 HTMLElement *This = HTMLELEM_THIS(iface);
253 FIXME("(%p)->()\n", This);
257 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
259 HTMLElement *This = HTMLELEM_THIS(iface);
260 FIXME("(%p)->(%p)\n", This, p);
264 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
266 HTMLElement *This = HTMLELEM_THIS(iface);
267 FIXME("(%p)->()\n", This);
271 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
273 HTMLElement *This = HTMLELEM_THIS(iface);
274 FIXME("(%p)->(%p)\n", This, p);
278 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
280 HTMLElement *This = HTMLELEM_THIS(iface);
281 FIXME("(%p)->()\n", This);
285 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
287 HTMLElement *This = HTMLELEM_THIS(iface);
288 FIXME("(%p)->(%p)\n", This, p);
292 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
294 HTMLElement *This = HTMLELEM_THIS(iface);
295 FIXME("(%p)->()\n", This);
299 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
301 HTMLElement *This = HTMLELEM_THIS(iface);
302 FIXME("(%p)->(%p)\n", This, p);
306 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
308 HTMLElement *This = HTMLELEM_THIS(iface);
309 FIXME("(%p)->()\n", This);
313 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
315 HTMLElement *This = HTMLELEM_THIS(iface);
316 FIXME("(%p)->(%p)\n", This, p);
320 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
322 HTMLElement *This = HTMLELEM_THIS(iface);
323 FIXME("(%p)->()\n", This);
327 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
329 HTMLElement *This = HTMLELEM_THIS(iface);
330 FIXME("(%p)->(%p)\n", This, p);
334 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
336 HTMLElement *This = HTMLELEM_THIS(iface);
337 FIXME("(%p)->()\n", This);
341 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
343 HTMLElement *This = HTMLELEM_THIS(iface);
344 FIXME("(%p)->(%p)\n", This, p);
348 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
350 HTMLElement *This = HTMLELEM_THIS(iface);
351 FIXME("(%p)->()\n", This);
355 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
357 HTMLElement *This = HTMLELEM_THIS(iface);
358 FIXME("(%p)->(%p)\n", This, p);
362 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
364 HTMLElement *This = HTMLELEM_THIS(iface);
365 FIXME("(%p)->()\n", This);
369 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
371 HTMLElement *This = HTMLELEM_THIS(iface);
372 FIXME("(%p)->(%p)\n", This, p);
376 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
378 HTMLElement *This = HTMLELEM_THIS(iface);
379 FIXME("(%p)->()\n", This);
383 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
385 HTMLElement *This = HTMLELEM_THIS(iface);
386 FIXME("(%p)->(%p)\n", This, p);
390 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
392 HTMLElement *This = HTMLELEM_THIS(iface);
393 FIXME("(%p)->()\n", This);
397 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
399 HTMLElement *This = HTMLELEM_THIS(iface);
400 FIXME("(%p)->(%p)\n", This, p);
404 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
406 HTMLElement *This = HTMLELEM_THIS(iface);
407 FIXME("(%p)->(%p)\n", This, p);
411 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
413 HTMLElement *This = HTMLELEM_THIS(iface);
414 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
418 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
420 HTMLElement *This = HTMLELEM_THIS(iface);
421 FIXME("(%p)->(%p)\n", This, p);
425 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
427 HTMLElement *This = HTMLELEM_THIS(iface);
428 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
432 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
434 HTMLElement *This = HTMLELEM_THIS(iface);
435 FIXME("(%p)->(%p)\n", This, p);
439 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
441 HTMLElement *This = HTMLELEM_THIS(iface);
442 FIXME("(%p)->()\n", This);
446 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
448 HTMLElement *This = HTMLELEM_THIS(iface);
449 FIXME("(%p)->(%p)\n", This, p);
453 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
455 HTMLElement *This = HTMLELEM_THIS(iface);
456 FIXME("(%p)->()\n", This);
460 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
461 VARIANT_BOOL *pfResult)
463 HTMLElement *This = HTMLELEM_THIS(iface);
464 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
468 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, long *p)
470 HTMLElement *This = HTMLELEM_THIS(iface);
471 FIXME("(%p)->(%p)\n", This, p);
475 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
477 HTMLElement *This = HTMLELEM_THIS(iface);
478 FIXME("(%p)->(%p)\n", This, p);
482 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
484 HTMLElement *This = HTMLELEM_THIS(iface);
485 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
489 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
491 HTMLElement *This = HTMLELEM_THIS(iface);
492 FIXME("(%p)->(%p)\n", This, p);
496 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, long *p)
498 HTMLElement *This = HTMLELEM_THIS(iface);
499 FIXME("(%p)->(%p)\n", This, p);
503 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, long *p)
505 HTMLElement *This = HTMLELEM_THIS(iface);
506 FIXME("(%p)->(%p)\n", This, p);
510 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, long *p)
512 HTMLElement *This = HTMLELEM_THIS(iface);
513 FIXME("(%p)->(%p)\n", This, p);
517 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, long *p)
519 HTMLElement *This = HTMLELEM_THIS(iface);
520 FIXME("(%p)->(%p)\n", This, p);
524 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
526 HTMLElement *This = HTMLELEM_THIS(iface);
527 FIXME("(%p)->(%p)\n", This, p);
531 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
533 HTMLElement *This = HTMLELEM_THIS(iface);
534 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
538 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
540 HTMLElement *This = HTMLELEM_THIS(iface);
541 FIXME("(%p)->(%p)\n", This, p);
545 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
547 HTMLElement *This = HTMLELEM_THIS(iface);
548 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
552 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
554 HTMLElement *This = HTMLELEM_THIS(iface);
555 FIXME("(%p)->(%p)\n", This, p);
559 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
561 HTMLElement *This = HTMLELEM_THIS(iface);
562 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
566 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
568 HTMLElement *This = HTMLELEM_THIS(iface);
569 FIXME("(%p)->(%p)\n", This, p);
573 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
575 HTMLElement *This = HTMLELEM_THIS(iface);
576 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
580 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
582 HTMLElement *This = HTMLELEM_THIS(iface);
583 FIXME("(%p)->(%p)\n", This, p);
587 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
590 HTMLElement *This = HTMLELEM_THIS(iface);
591 FIXME("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
595 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
598 HTMLElement *This = HTMLELEM_THIS(iface);
599 FIXME("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
603 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
605 HTMLElement *This = HTMLELEM_THIS(iface);
606 FIXME("(%p)->(%p)\n", This, p);
610 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
612 HTMLElement *This = HTMLELEM_THIS(iface);
613 FIXME("(%p)->(%p)\n", This, p);
617 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
619 HTMLElement *This = HTMLELEM_THIS(iface);
620 FIXME("(%p)\n", This);
624 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
625 IHTMLFiltersCollection **p)
627 HTMLElement *This = HTMLELEM_THIS(iface);
628 FIXME("(%p)->(%p)\n", This, p);
632 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
634 HTMLElement *This = HTMLELEM_THIS(iface);
635 FIXME("(%p)->()\n", This);
639 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
641 HTMLElement *This = HTMLELEM_THIS(iface);
642 FIXME("(%p)->(%p)\n", This, p);
646 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
648 HTMLElement *This = HTMLELEM_THIS(iface);
649 FIXME("(%p)->(%p)\n", This, String);
653 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
655 HTMLElement *This = HTMLELEM_THIS(iface);
656 FIXME("(%p)->()\n", This);
660 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
662 HTMLElement *This = HTMLELEM_THIS(iface);
663 FIXME("(%p)->(%p)\n", This, p);
667 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
669 HTMLElement *This = HTMLELEM_THIS(iface);
670 FIXME("(%p)->()\n", This);
674 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
676 HTMLElement *This = HTMLELEM_THIS(iface);
677 FIXME("(%p)->(%p)\n", This, p);
681 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
683 HTMLElement *This = HTMLELEM_THIS(iface);
684 FIXME("(%p)->()\n", This);
688 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
690 HTMLElement *This = HTMLELEM_THIS(iface);
691 FIXME("(%p)->(%p)\n", This, p);
695 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
697 HTMLElement *This = HTMLELEM_THIS(iface);
698 FIXME("(%p)->()\n", This);
702 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
704 HTMLElement *This = HTMLELEM_THIS(iface);
705 FIXME("(%p)->(%p)\n", This, p);
709 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
711 HTMLElement *This = HTMLELEM_THIS(iface);
712 FIXME("(%p)->()\n", This);
716 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
718 HTMLElement *This = HTMLELEM_THIS(iface);
719 FIXME("(%p)->(%p)\n", This, p);
723 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
725 HTMLElement *This = HTMLELEM_THIS(iface);
726 FIXME("(%p)->()\n", This);
730 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
732 HTMLElement *This = HTMLELEM_THIS(iface);
733 FIXME("(%p)->(%p)\n", This, p);
737 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
739 HTMLElement *This = HTMLELEM_THIS(iface);
740 FIXME("(%p)->()\n", This);
744 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
746 HTMLElement *This = HTMLELEM_THIS(iface);
747 FIXME("(%p)->(%p)\n", This, p);
751 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
753 HTMLElement *This = HTMLELEM_THIS(iface);
754 FIXME("(%p)->()\n", This);
758 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
760 HTMLElement *This = HTMLELEM_THIS(iface);
761 FIXME("(%p)->(%p)\n", This, p);
765 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
767 HTMLElement *This = HTMLELEM_THIS(iface);
768 FIXME("(%p)->()\n", This);
772 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
774 HTMLElement *This = HTMLELEM_THIS(iface);
775 FIXME("(%p)->(%p)\n", This, p);
779 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
781 HTMLElement *This = HTMLELEM_THIS(iface);
782 FIXME("(%p)->(%p)\n", This, p);
786 static void create_all_list(HTMLDocument *doc, HTMLElement *elem, elem_vector *buf)
788 nsIDOMNodeList *nsnode_list;
790 PRUint32 list_len = 0, i;
794 nsres = nsIDOMNode_GetChildNodes(elem->node->nsnode, &nsnode_list);
795 if(NS_FAILED(nsres)) {
796 ERR("GetChildNodes failed: %08x\n", nsres);
800 nsIDOMNodeList_GetLength(nsnode_list, &list_len);
804 for(i=0; i<list_len; i++) {
805 nsres = nsIDOMNodeList_Item(nsnode_list, i, &iter);
806 if(NS_FAILED(nsres)) {
807 ERR("Item failed: %08x\n", nsres);
811 node = get_node(doc, iter);
812 if(node->node_type != NT_HTMLELEM)
815 elem_vector_add(buf, (HTMLElement*)node->impl.elem);
816 create_all_list(doc, (HTMLElement*)node->impl.elem, buf);
820 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
822 HTMLElement *This = HTMLELEM_THIS(iface);
823 elem_vector buf = {NULL, 0, 8};
825 TRACE("(%p)->(%p)\n", This, p);
827 buf.buf = mshtml_alloc(buf.size*sizeof(HTMLElement**));
829 create_all_list(This->node->doc, This, &buf);
832 mshtml_free(buf.buf);
834 }else if(buf.size > buf.len) {
835 buf.buf = mshtml_realloc(buf.buf, buf.len*sizeof(HTMLElement**));
838 return HTMLElementCollection_Create((IUnknown*)HTMLELEM(This), buf.buf, buf.len, p);
841 static void HTMLElement_destructor(IUnknown *iface)
843 HTMLElement *This = HTMLELEM_THIS(iface);
846 This->destructor(This->impl);
849 nsIDOMHTMLElement_Release(This->nselem);
856 static const IHTMLElementVtbl HTMLElementVtbl = {
857 HTMLElement_QueryInterface,
860 HTMLElement_GetTypeInfoCount,
861 HTMLElement_GetTypeInfo,
862 HTMLElement_GetIDsOfNames,
864 HTMLElement_setAttribute,
865 HTMLElement_getAttribute,
866 HTMLElement_removeAttribute,
867 HTMLElement_put_className,
868 HTMLElement_get_className,
871 HTMLElement_get_tagName,
872 HTMLElement_get_parentElement,
873 HTMLElement_get_style,
874 HTMLElement_put_onhelp,
875 HTMLElement_get_onhelp,
876 HTMLElement_put_onclick,
877 HTMLElement_get_onclick,
878 HTMLElement_put_ondblclick,
879 HTMLElement_get_ondblclick,
880 HTMLElement_put_onkeydown,
881 HTMLElement_get_onkeydown,
882 HTMLElement_put_onkeyup,
883 HTMLElement_get_onkeyup,
884 HTMLElement_put_onkeypress,
885 HTMLElement_get_onkeypress,
886 HTMLElement_put_onmouseout,
887 HTMLElement_get_onmouseout,
888 HTMLElement_put_onmouseover,
889 HTMLElement_get_onmouseover,
890 HTMLElement_put_onmousemove,
891 HTMLElement_get_onmousemove,
892 HTMLElement_put_onmousedown,
893 HTMLElement_get_onmousedown,
894 HTMLElement_put_onmouseup,
895 HTMLElement_get_onmouseup,
896 HTMLElement_get_document,
897 HTMLElement_put_title,
898 HTMLElement_get_title,
899 HTMLElement_put_language,
900 HTMLElement_get_language,
901 HTMLElement_put_onselectstart,
902 HTMLElement_get_onselectstart,
903 HTMLElement_scrollIntoView,
904 HTMLElement_contains,
905 HTMLElement_get_sourceIndex,
906 HTMLElement_get_recordNumber,
907 HTMLElement_put_lang,
908 HTMLElement_get_lang,
909 HTMLElement_get_offsetLeft,
910 HTMLElement_get_offsetTop,
911 HTMLElement_get_offsetWidth,
912 HTMLElement_get_offsetHeight,
913 HTMLElement_get_offsetParent,
914 HTMLElement_put_innerHTML,
915 HTMLElement_get_innerHTML,
916 HTMLElement_put_innerText,
917 HTMLElement_get_innerText,
918 HTMLElement_put_outerHTML,
919 HTMLElement_get_outerHTML,
920 HTMLElement_put_outerText,
921 HTMLElement_get_outerText,
922 HTMLElement_insertAdjacentHTML,
923 HTMLElement_insertAdjacentText,
924 HTMLElement_get_parentTextEdit,
925 HTMLElement_get_isTextEdit,
927 HTMLElement_get_filters,
928 HTMLElement_put_ondragstart,
929 HTMLElement_get_ondragstart,
930 HTMLElement_toString,
931 HTMLElement_put_onbeforeupdate,
932 HTMLElement_get_onbeforeupdate,
933 HTMLElement_put_onafterupdate,
934 HTMLElement_get_onafterupdate,
935 HTMLElement_put_onerrorupdate,
936 HTMLElement_get_onerrorupdate,
937 HTMLElement_put_onrowexit,
938 HTMLElement_get_onrowexit,
939 HTMLElement_put_onrowenter,
940 HTMLElement_get_onrowenter,
941 HTMLElement_put_ondatasetchanged,
942 HTMLElement_get_ondatasetchanged,
943 HTMLElement_put_ondataavailable,
944 HTMLElement_get_ondataavailable,
945 HTMLElement_put_ondatasetcomplete,
946 HTMLElement_get_ondatasetcomplete,
947 HTMLElement_put_onfilterchange,
948 HTMLElement_get_onfilterchange,
949 HTMLElement_get_children,
953 HRESULT HTMLElement_QI(HTMLElement *This, REFIID riid, void **ppv)
957 if(IsEqualGUID(&IID_IUnknown, riid)) {
958 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
959 *ppv = HTMLELEM(This);
960 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
961 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
962 *ppv = HTMLELEM(This);
963 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
964 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
965 *ppv = HTMLELEM(This);
966 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
967 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
968 *ppv = HTMLELEM2(This);
972 IHTMLElement_AddRef(HTMLELEM(This));
976 return HTMLDOMNode_QI(This->node, riid, ppv);
979 void HTMLElement_Create(HTMLDOMNode *node)
982 nsAString class_name_str;
983 const PRUnichar *class_name;
986 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
987 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
988 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
989 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
991 ret = mshtml_alloc(sizeof(HTMLElement));
992 ret->lpHTMLElementVtbl = &HTMLElementVtbl;
995 ret->destructor = NULL;
997 node->node_type = NT_HTMLELEM;
998 node->impl.elem = HTMLELEM(ret);
999 node->destructor = HTMLElement_destructor;
1001 HTMLElement2_Init(ret);
1003 nsres = nsIDOMNode_QueryInterface(node->nsnode, &IID_nsIDOMHTMLElement, (void**)&ret->nselem);
1004 if(NS_FAILED(nsres))
1007 nsAString_Init(&class_name_str, NULL);
1008 nsIDOMHTMLElement_GetTagName(ret->nselem, &class_name_str);
1010 nsAString_GetData(&class_name_str, &class_name, NULL);
1012 if(!strcmpW(class_name, wszBODY))
1013 HTMLBodyElement_Create(ret);
1014 else if(!strcmpW(class_name, wszINPUT))
1015 HTMLInputElement_Create(ret);
1016 else if(!strcmpW(class_name, wszSELECT))
1017 HTMLSelectElement_Create(ret);
1018 else if(!strcmpW(class_name, wszTEXTAREA))
1019 HTMLTextAreaElement_Create(ret);
1021 nsAString_Finish(&class_name_str);
1025 const IHTMLElementCollectionVtbl *lpHTMLElementCollectionVtbl;
1028 HTMLElement **elems;
1032 } HTMLElementCollection;
1034 #define HTMLELEMCOL(x) ((IHTMLElementCollection*) &(x)->lpHTMLElementCollectionVtbl)
1036 #define ELEMCOL_THIS(iface) DEFINE_THIS(HTMLElementCollection, HTMLElementCollection, iface)
1038 static HRESULT WINAPI HTMLElementCollection_QueryInterface(IHTMLElementCollection *iface,
1039 REFIID riid, void **ppv)
1041 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1045 if(IsEqualGUID(&IID_IUnknown, riid)) {
1046 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1047 *ppv = HTMLELEMCOL(This);
1048 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1049 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1050 *ppv = HTMLELEMCOL(This);
1051 }else if(IsEqualGUID(&IID_IHTMLElementCollection, riid)) {
1052 TRACE("(%p)->(IID_IHTMLElementCollection %p)\n", This, ppv);
1053 *ppv = HTMLELEMCOL(This);
1057 IHTMLElementCollection_AddRef(HTMLELEMCOL(This));
1061 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1062 return E_NOINTERFACE;
1065 static ULONG WINAPI HTMLElementCollection_AddRef(IHTMLElementCollection *iface)
1067 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1068 LONG ref = InterlockedIncrement(&This->ref);
1070 TRACE("(%p) ref=%d\n", This, ref);
1075 static ULONG WINAPI HTMLElementCollection_Release(IHTMLElementCollection *iface)
1077 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1078 LONG ref = InterlockedDecrement(&This->ref);
1080 TRACE("(%p) ref=%d\n", This, ref);
1083 IUnknown_Release(This->ref_unk);
1084 mshtml_free(This->elems);
1091 static HRESULT WINAPI HTMLElementCollection_GetTypeInfoCount(IHTMLElementCollection *iface,
1094 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1095 FIXME("(%p)->(%p)\n", This, pctinfo);
1099 static HRESULT WINAPI HTMLElementCollection_GetTypeInfo(IHTMLElementCollection *iface,
1100 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1102 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1103 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1107 static HRESULT WINAPI HTMLElementCollection_GetIDsOfNames(IHTMLElementCollection *iface,
1108 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1110 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1111 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1116 static HRESULT WINAPI HTMLElementCollection_Invoke(IHTMLElementCollection *iface,
1117 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1118 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1120 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1121 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1122 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1126 static HRESULT WINAPI HTMLElementCollection_toString(IHTMLElementCollection *iface,
1129 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1130 FIXME("(%p)->(%p)\n", This, String);
1134 static HRESULT WINAPI HTMLElementCollection_put_length(IHTMLElementCollection *iface,
1137 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1138 FIXME("(%p)->(%ld)\n", This, v);
1142 static HRESULT WINAPI HTMLElementCollection_get_length(IHTMLElementCollection *iface,
1145 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1147 TRACE("(%p)->(%p)\n", This, p);
1153 static HRESULT WINAPI HTMLElementCollection_get__newEnum(IHTMLElementCollection *iface,
1156 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1157 FIXME("(%p)->(%p)\n", This, p);
1161 static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
1162 VARIANT name, VARIANT index, IDispatch **pdisp)
1164 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1166 if(V_VT(&index) != VT_I4) {
1167 WARN("Invalid index vt=%d\n", V_VT(&index));
1168 return E_INVALIDARG;
1171 if(V_VT(&name) != VT_I4 || V_I4(&name) != V_I4(&index))
1172 FIXME("Unsupproted name vt=%d\n", V_VT(&name));
1174 TRACE("(%p)->(%d %d %p)\n", This, V_I4(&name), V_I4(&index), pdisp);
1176 if(V_I4(&index) < 0 || V_I4(&index) >= This->len)
1177 return E_INVALIDARG;
1179 *pdisp = (IDispatch*)This->elems[V_I4(&index)];
1180 IDispatch_AddRef(*pdisp);
1184 static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface,
1185 VARIANT tagName, IDispatch **pdisp)
1187 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1190 const PRUnichar *tag;
1191 elem_vector buf = {NULL, 0, 8};
1193 if(V_VT(&tagName) != VT_BSTR) {
1194 WARN("Invalid arg\n");
1195 return DISP_E_MEMBERNOTFOUND;
1198 TRACE("(%p)->(%s %p)\n", This, debugstr_w(V_BSTR(&tagName)), pdisp);
1200 buf.buf = mshtml_alloc(buf.size*sizeof(HTMLElement*));
1202 nsAString_Init(&tag_str, NULL);
1204 for(i=0; i<This->len; i++) {
1205 if(!This->elems[i]->nselem)
1208 nsIDOMElement_GetTagName(This->elems[i]->nselem, &tag_str);
1209 nsAString_GetData(&tag_str, &tag, NULL);
1211 if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, tag, -1,
1212 V_BSTR(&tagName), -1) == CSTR_EQUAL)
1213 elem_vector_add(&buf, This->elems[i]);
1216 nsAString_Finish(&tag_str);
1218 TRACE("fount %d tags\n", buf.len);
1221 mshtml_free(buf.buf);
1223 }else if(buf.size > buf.len) {
1224 buf.buf = mshtml_realloc(buf.buf, buf.len*sizeof(HTMLElement*));
1227 return HTMLElementCollection_Create(This->ref_unk, buf.buf, buf.len, pdisp);
1232 static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl = {
1233 HTMLElementCollection_QueryInterface,
1234 HTMLElementCollection_AddRef,
1235 HTMLElementCollection_Release,
1236 HTMLElementCollection_GetTypeInfoCount,
1237 HTMLElementCollection_GetTypeInfo,
1238 HTMLElementCollection_GetIDsOfNames,
1239 HTMLElementCollection_Invoke,
1240 HTMLElementCollection_toString,
1241 HTMLElementCollection_put_length,
1242 HTMLElementCollection_get_length,
1243 HTMLElementCollection_get__newEnum,
1244 HTMLElementCollection_item,
1245 HTMLElementCollection_tags
1248 static HRESULT HTMLElementCollection_Create(IUnknown *ref_unk, HTMLElement **elems, DWORD len,
1251 HTMLElementCollection *ret = mshtml_alloc(sizeof(HTMLElementCollection));
1253 ret->lpHTMLElementCollectionVtbl = &HTMLElementCollectionVtbl;
1258 IUnknown_AddRef(ref_unk);
1259 ret->ref_unk = ref_unk;
1261 TRACE("ret=%p len=%d\n", ret, len);
1263 *p = (IDispatch*)ret;