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 nsIDOMElementCSSInlineStyle *nselemstyle;
247 nsIDOMCSSStyleDeclaration *nsstyle;
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);
259 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
260 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
261 if(NS_FAILED(nsres)) {
262 ERR("GetStyle failed: %08x\n", nsres);
266 /* FIXME: Store style instead of creating a new instance in each call */
267 *p = HTMLStyle_Create(nsstyle);
269 nsIDOMCSSStyleDeclaration_Release(nsstyle);
273 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
275 HTMLElement *This = HTMLELEM_THIS(iface);
276 FIXME("(%p)->()\n", This);
280 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
282 HTMLElement *This = HTMLELEM_THIS(iface);
283 FIXME("(%p)->(%p)\n", This, p);
287 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
289 HTMLElement *This = HTMLELEM_THIS(iface);
290 FIXME("(%p)->()\n", This);
294 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
296 HTMLElement *This = HTMLELEM_THIS(iface);
297 FIXME("(%p)->(%p)\n", This, p);
301 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
303 HTMLElement *This = HTMLELEM_THIS(iface);
304 FIXME("(%p)->()\n", This);
308 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
310 HTMLElement *This = HTMLELEM_THIS(iface);
311 FIXME("(%p)->(%p)\n", This, p);
315 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
317 HTMLElement *This = HTMLELEM_THIS(iface);
318 FIXME("(%p)->()\n", This);
322 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
324 HTMLElement *This = HTMLELEM_THIS(iface);
325 FIXME("(%p)->(%p)\n", This, p);
329 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
331 HTMLElement *This = HTMLELEM_THIS(iface);
332 FIXME("(%p)->()\n", This);
336 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
338 HTMLElement *This = HTMLELEM_THIS(iface);
339 FIXME("(%p)->(%p)\n", This, p);
343 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
345 HTMLElement *This = HTMLELEM_THIS(iface);
346 FIXME("(%p)->()\n", This);
350 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
352 HTMLElement *This = HTMLELEM_THIS(iface);
353 FIXME("(%p)->(%p)\n", This, p);
357 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
359 HTMLElement *This = HTMLELEM_THIS(iface);
360 FIXME("(%p)->()\n", This);
364 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
366 HTMLElement *This = HTMLELEM_THIS(iface);
367 FIXME("(%p)->(%p)\n", This, p);
371 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
373 HTMLElement *This = HTMLELEM_THIS(iface);
374 FIXME("(%p)->()\n", This);
378 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
380 HTMLElement *This = HTMLELEM_THIS(iface);
381 FIXME("(%p)->(%p)\n", This, p);
385 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
387 HTMLElement *This = HTMLELEM_THIS(iface);
388 FIXME("(%p)->()\n", This);
392 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
394 HTMLElement *This = HTMLELEM_THIS(iface);
395 FIXME("(%p)->(%p)\n", This, p);
399 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
401 HTMLElement *This = HTMLELEM_THIS(iface);
402 FIXME("(%p)->()\n", This);
406 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
408 HTMLElement *This = HTMLELEM_THIS(iface);
409 FIXME("(%p)->(%p)\n", This, p);
413 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
415 HTMLElement *This = HTMLELEM_THIS(iface);
416 FIXME("(%p)->()\n", This);
420 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
422 HTMLElement *This = HTMLELEM_THIS(iface);
423 FIXME("(%p)->(%p)\n", This, p);
427 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
429 HTMLElement *This = HTMLELEM_THIS(iface);
430 FIXME("(%p)->(%p)\n", This, p);
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));
441 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
443 HTMLElement *This = HTMLELEM_THIS(iface);
444 FIXME("(%p)->(%p)\n", This, p);
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));
455 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
457 HTMLElement *This = HTMLELEM_THIS(iface);
458 FIXME("(%p)->(%p)\n", This, p);
462 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
464 HTMLElement *This = HTMLELEM_THIS(iface);
465 FIXME("(%p)->()\n", This);
469 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
471 HTMLElement *This = HTMLELEM_THIS(iface);
472 FIXME("(%p)->(%p)\n", This, p);
476 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
478 HTMLElement *This = HTMLELEM_THIS(iface);
479 FIXME("(%p)->()\n", This);
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);
491 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, long *p)
493 HTMLElement *This = HTMLELEM_THIS(iface);
494 FIXME("(%p)->(%p)\n", This, p);
498 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
500 HTMLElement *This = HTMLELEM_THIS(iface);
501 FIXME("(%p)->(%p)\n", This, p);
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));
512 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
514 HTMLElement *This = HTMLELEM_THIS(iface);
515 FIXME("(%p)->(%p)\n", This, p);
519 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, long *p)
521 HTMLElement *This = HTMLELEM_THIS(iface);
522 FIXME("(%p)->(%p)\n", This, p);
526 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, long *p)
528 HTMLElement *This = HTMLELEM_THIS(iface);
529 FIXME("(%p)->(%p)\n", This, p);
533 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, long *p)
535 HTMLElement *This = HTMLELEM_THIS(iface);
536 FIXME("(%p)->(%p)\n", This, p);
540 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, long *p)
542 HTMLElement *This = HTMLELEM_THIS(iface);
543 FIXME("(%p)->(%p)\n", This, p);
547 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
549 HTMLElement *This = HTMLELEM_THIS(iface);
550 FIXME("(%p)->(%p)\n", This, p);
554 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
556 HTMLElement *This = HTMLELEM_THIS(iface);
557 nsIDOMNSHTMLElement *nselem;
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);
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);
581 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
583 HTMLElement *This = HTMLELEM_THIS(iface);
584 FIXME("(%p)->(%p)\n", This, p);
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));
595 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
597 HTMLElement *This = HTMLELEM_THIS(iface);
598 FIXME("(%p)->(%p)\n", This, p);
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));
609 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
611 HTMLElement *This = HTMLELEM_THIS(iface);
612 FIXME("(%p)->(%p)\n", This, p);
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));
623 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
625 HTMLElement *This = HTMLELEM_THIS(iface);
626 FIXME("(%p)->(%p)\n", This, p);
630 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
633 HTMLElement *This = HTMLELEM_THIS(iface);
634 FIXME("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
638 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
641 HTMLElement *This = HTMLELEM_THIS(iface);
642 FIXME("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
646 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
648 HTMLElement *This = HTMLELEM_THIS(iface);
649 FIXME("(%p)->(%p)\n", This, p);
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);
660 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
662 HTMLElement *This = HTMLELEM_THIS(iface);
663 FIXME("(%p)\n", This);
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);
675 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
677 HTMLElement *This = HTMLELEM_THIS(iface);
678 FIXME("(%p)->()\n", This);
682 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
684 HTMLElement *This = HTMLELEM_THIS(iface);
685 FIXME("(%p)->(%p)\n", This, p);
689 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
691 HTMLElement *This = HTMLELEM_THIS(iface);
692 FIXME("(%p)->(%p)\n", This, String);
696 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
698 HTMLElement *This = HTMLELEM_THIS(iface);
699 FIXME("(%p)->()\n", This);
703 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
705 HTMLElement *This = HTMLELEM_THIS(iface);
706 FIXME("(%p)->(%p)\n", This, p);
710 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
712 HTMLElement *This = HTMLELEM_THIS(iface);
713 FIXME("(%p)->()\n", This);
717 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
719 HTMLElement *This = HTMLELEM_THIS(iface);
720 FIXME("(%p)->(%p)\n", This, p);
724 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
726 HTMLElement *This = HTMLELEM_THIS(iface);
727 FIXME("(%p)->()\n", This);
731 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
733 HTMLElement *This = HTMLELEM_THIS(iface);
734 FIXME("(%p)->(%p)\n", This, p);
738 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
740 HTMLElement *This = HTMLELEM_THIS(iface);
741 FIXME("(%p)->()\n", This);
745 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
747 HTMLElement *This = HTMLELEM_THIS(iface);
748 FIXME("(%p)->(%p)\n", This, p);
752 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
754 HTMLElement *This = HTMLELEM_THIS(iface);
755 FIXME("(%p)->()\n", This);
759 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
761 HTMLElement *This = HTMLELEM_THIS(iface);
762 FIXME("(%p)->(%p)\n", This, p);
766 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
768 HTMLElement *This = HTMLELEM_THIS(iface);
769 FIXME("(%p)->()\n", This);
773 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
775 HTMLElement *This = HTMLELEM_THIS(iface);
776 FIXME("(%p)->(%p)\n", This, p);
780 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
782 HTMLElement *This = HTMLELEM_THIS(iface);
783 FIXME("(%p)->()\n", This);
787 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
789 HTMLElement *This = HTMLELEM_THIS(iface);
790 FIXME("(%p)->(%p)\n", This, p);
794 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
796 HTMLElement *This = HTMLELEM_THIS(iface);
797 FIXME("(%p)->()\n", This);
801 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
803 HTMLElement *This = HTMLELEM_THIS(iface);
804 FIXME("(%p)->(%p)\n", This, p);
808 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
810 HTMLElement *This = HTMLELEM_THIS(iface);
811 FIXME("(%p)->()\n", This);
815 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
817 HTMLElement *This = HTMLELEM_THIS(iface);
818 FIXME("(%p)->(%p)\n", This, p);
822 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
824 HTMLElement *This = HTMLELEM_THIS(iface);
825 FIXME("(%p)->(%p)\n", This, p);
829 static void create_all_list(HTMLDocument *doc, HTMLElement *elem, elem_vector *buf)
831 nsIDOMNodeList *nsnode_list;
833 PRUint32 list_len = 0, i;
837 nsres = nsIDOMNode_GetChildNodes(elem->node->nsnode, &nsnode_list);
838 if(NS_FAILED(nsres)) {
839 ERR("GetChildNodes failed: %08x\n", nsres);
843 nsIDOMNodeList_GetLength(nsnode_list, &list_len);
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);
854 node = get_node(doc, iter);
855 if(node->node_type != NT_HTMLELEM)
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);
875 mshtml_free(buf.buf);
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);
889 This->destructor(This->impl);
892 nsIDOMHTMLElement_Release(This->nselem);
899 static const IHTMLElementVtbl HTMLElementVtbl = {
900 HTMLElement_QueryInterface,
903 HTMLElement_GetTypeInfoCount,
904 HTMLElement_GetTypeInfo,
905 HTMLElement_GetIDsOfNames,
907 HTMLElement_setAttribute,
908 HTMLElement_getAttribute,
909 HTMLElement_removeAttribute,
910 HTMLElement_put_className,
911 HTMLElement_get_className,
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,
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,
996 HRESULT HTMLElement_QI(HTMLElement *This, REFIID riid, void **ppv)
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);
1015 IHTMLElement_AddRef(HTMLELEM(This));
1019 return HTMLDOMNode_QI(This->node, riid, ppv);
1022 void HTMLElement_Create(HTMLDOMNode *node)
1025 nsAString class_name_str;
1026 const PRUnichar *class_name;
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;
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))
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);
1068 const IHTMLElementCollectionVtbl *lpHTMLElementCollectionVtbl;
1071 HTMLElement **elems;
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);
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);
1100 IHTMLElementCollection_AddRef(HTMLELEMCOL(This));
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);
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);
1126 IUnknown_Release(This->ref_unk);
1127 mshtml_free(This->elems);
1134 static HRESULT WINAPI HTMLElementCollection_GetTypeInfoCount(IHTMLElementCollection *iface,
1137 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1138 FIXME("(%p)->(%p)\n", This, pctinfo);
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);
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,
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);
1169 static HRESULT WINAPI HTMLElementCollection_toString(IHTMLElementCollection *iface,
1172 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1173 FIXME("(%p)->(%p)\n", This, String);
1177 static HRESULT WINAPI HTMLElementCollection_put_length(IHTMLElementCollection *iface,
1180 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1181 FIXME("(%p)->(%ld)\n", This, v);
1185 static HRESULT WINAPI HTMLElementCollection_get_length(IHTMLElementCollection *iface,
1188 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1190 TRACE("(%p)->(%p)\n", This, p);
1196 static HRESULT WINAPI HTMLElementCollection_get__newEnum(IHTMLElementCollection *iface,
1199 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1200 FIXME("(%p)->(%p)\n", This, p);
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);
1224 if(V_VT(&name) == VT_BSTR) {
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);
1249 *pdisp = (IDispatch*)This->elems[i];
1250 TRACE("Returning element %d pdisp=%p\n", i, pdisp);
1251 IDispatch_AddRef(*pdisp);
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);
1261 ERR("Invalid index. index=%d >= buf.len=%d\n",V_I4(&index), buf.len);
1262 return E_INVALIDARG;
1265 mshtml_free(buf.buf);
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);
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)
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);
1315 mshtml_free(buf.buf);
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);
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,
1345 HTMLElementCollection *ret = mshtml_alloc(sizeof(HTMLElementCollection));
1347 ret->lpHTMLElementCollectionVtbl = &HTMLElementCollectionVtbl;
1352 IUnknown_AddRef(ref_unk);
1353 ret->ref_unk = ref_unk;
1355 TRACE("ret=%p len=%d\n", ret, len);
1357 *p = (IDispatch*)ret;