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 nsIDOMNSHTMLElement
*nselem
;
538 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
540 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
541 if(NS_FAILED(nsres
)) {
542 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
546 nsAString_Init(&html_str
, v
);
547 nsres
= nsIDOMNSHTMLElement_SetInnerHTML(nselem
, &html_str
);
548 nsAString_Finish(&html_str
);
550 if(NS_FAILED(nsres
)) {
551 FIXME("SetInnerHtml failed %08x\n", nsres
);
558 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
560 HTMLElement
*This
= HTMLELEM_THIS(iface
);
561 FIXME("(%p)->(%p)\n", This
, p
);
565 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
567 HTMLElement
*This
= HTMLELEM_THIS(iface
);
568 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
572 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
574 HTMLElement
*This
= HTMLELEM_THIS(iface
);
575 FIXME("(%p)->(%p)\n", This
, p
);
579 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
581 HTMLElement
*This
= HTMLELEM_THIS(iface
);
582 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
586 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
588 HTMLElement
*This
= HTMLELEM_THIS(iface
);
589 FIXME("(%p)->(%p)\n", This
, p
);
593 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
595 HTMLElement
*This
= HTMLELEM_THIS(iface
);
596 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
600 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
602 HTMLElement
*This
= HTMLELEM_THIS(iface
);
603 FIXME("(%p)->(%p)\n", This
, p
);
607 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
610 HTMLElement
*This
= HTMLELEM_THIS(iface
);
611 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
615 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
618 HTMLElement
*This
= HTMLELEM_THIS(iface
);
619 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
623 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
625 HTMLElement
*This
= HTMLELEM_THIS(iface
);
626 FIXME("(%p)->(%p)\n", This
, p
);
630 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
632 HTMLElement
*This
= HTMLELEM_THIS(iface
);
633 FIXME("(%p)->(%p)\n", This
, p
);
637 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
639 HTMLElement
*This
= HTMLELEM_THIS(iface
);
640 FIXME("(%p)\n", This
);
644 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
645 IHTMLFiltersCollection
**p
)
647 HTMLElement
*This
= HTMLELEM_THIS(iface
);
648 FIXME("(%p)->(%p)\n", This
, p
);
652 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
654 HTMLElement
*This
= HTMLELEM_THIS(iface
);
655 FIXME("(%p)->()\n", This
);
659 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
661 HTMLElement
*This
= HTMLELEM_THIS(iface
);
662 FIXME("(%p)->(%p)\n", This
, p
);
666 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
668 HTMLElement
*This
= HTMLELEM_THIS(iface
);
669 FIXME("(%p)->(%p)\n", This
, String
);
673 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
675 HTMLElement
*This
= HTMLELEM_THIS(iface
);
676 FIXME("(%p)->()\n", This
);
680 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
682 HTMLElement
*This
= HTMLELEM_THIS(iface
);
683 FIXME("(%p)->(%p)\n", This
, p
);
687 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
689 HTMLElement
*This
= HTMLELEM_THIS(iface
);
690 FIXME("(%p)->()\n", This
);
694 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
696 HTMLElement
*This
= HTMLELEM_THIS(iface
);
697 FIXME("(%p)->(%p)\n", This
, p
);
701 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
703 HTMLElement
*This
= HTMLELEM_THIS(iface
);
704 FIXME("(%p)->()\n", This
);
708 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
710 HTMLElement
*This
= HTMLELEM_THIS(iface
);
711 FIXME("(%p)->(%p)\n", This
, p
);
715 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
717 HTMLElement
*This
= HTMLELEM_THIS(iface
);
718 FIXME("(%p)->()\n", This
);
722 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
724 HTMLElement
*This
= HTMLELEM_THIS(iface
);
725 FIXME("(%p)->(%p)\n", This
, p
);
729 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
731 HTMLElement
*This
= HTMLELEM_THIS(iface
);
732 FIXME("(%p)->()\n", This
);
736 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
738 HTMLElement
*This
= HTMLELEM_THIS(iface
);
739 FIXME("(%p)->(%p)\n", This
, p
);
743 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
745 HTMLElement
*This
= HTMLELEM_THIS(iface
);
746 FIXME("(%p)->()\n", This
);
750 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
752 HTMLElement
*This
= HTMLELEM_THIS(iface
);
753 FIXME("(%p)->(%p)\n", This
, p
);
757 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
759 HTMLElement
*This
= HTMLELEM_THIS(iface
);
760 FIXME("(%p)->()\n", This
);
764 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
766 HTMLElement
*This
= HTMLELEM_THIS(iface
);
767 FIXME("(%p)->(%p)\n", This
, p
);
771 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
773 HTMLElement
*This
= HTMLELEM_THIS(iface
);
774 FIXME("(%p)->()\n", This
);
778 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
780 HTMLElement
*This
= HTMLELEM_THIS(iface
);
781 FIXME("(%p)->(%p)\n", This
, p
);
785 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
787 HTMLElement
*This
= HTMLELEM_THIS(iface
);
788 FIXME("(%p)->()\n", This
);
792 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
794 HTMLElement
*This
= HTMLELEM_THIS(iface
);
795 FIXME("(%p)->(%p)\n", This
, p
);
799 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
801 HTMLElement
*This
= HTMLELEM_THIS(iface
);
802 FIXME("(%p)->(%p)\n", This
, p
);
806 static void create_all_list(HTMLDocument
*doc
, HTMLElement
*elem
, elem_vector
*buf
)
808 nsIDOMNodeList
*nsnode_list
;
810 PRUint32 list_len
= 0, i
;
814 nsres
= nsIDOMNode_GetChildNodes(elem
->node
->nsnode
, &nsnode_list
);
815 if(NS_FAILED(nsres
)) {
816 ERR("GetChildNodes failed: %08x\n", nsres
);
820 nsIDOMNodeList_GetLength(nsnode_list
, &list_len
);
824 for(i
=0; i
<list_len
; i
++) {
825 nsres
= nsIDOMNodeList_Item(nsnode_list
, i
, &iter
);
826 if(NS_FAILED(nsres
)) {
827 ERR("Item failed: %08x\n", nsres
);
831 node
= get_node(doc
, iter
);
832 if(node
->node_type
!= NT_HTMLELEM
)
835 elem_vector_add(buf
, (HTMLElement
*)node
->impl
.elem
);
836 create_all_list(doc
, (HTMLElement
*)node
->impl
.elem
, buf
);
840 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
842 HTMLElement
*This
= HTMLELEM_THIS(iface
);
843 elem_vector buf
= {NULL
, 0, 8};
845 TRACE("(%p)->(%p)\n", This
, p
);
847 buf
.buf
= mshtml_alloc(buf
.size
*sizeof(HTMLElement
**));
849 create_all_list(This
->node
->doc
, This
, &buf
);
852 mshtml_free(buf
.buf
);
854 }else if(buf
.size
> buf
.len
) {
855 buf
.buf
= mshtml_realloc(buf
.buf
, buf
.len
*sizeof(HTMLElement
**));
858 return HTMLElementCollection_Create((IUnknown
*)HTMLELEM(This
), buf
.buf
, buf
.len
, p
);
861 static void HTMLElement_destructor(IUnknown
*iface
)
863 HTMLElement
*This
= HTMLELEM_THIS(iface
);
866 This
->destructor(This
->impl
);
869 nsIDOMHTMLElement_Release(This
->nselem
);
876 static const IHTMLElementVtbl HTMLElementVtbl
= {
877 HTMLElement_QueryInterface
,
880 HTMLElement_GetTypeInfoCount
,
881 HTMLElement_GetTypeInfo
,
882 HTMLElement_GetIDsOfNames
,
884 HTMLElement_setAttribute
,
885 HTMLElement_getAttribute
,
886 HTMLElement_removeAttribute
,
887 HTMLElement_put_className
,
888 HTMLElement_get_className
,
891 HTMLElement_get_tagName
,
892 HTMLElement_get_parentElement
,
893 HTMLElement_get_style
,
894 HTMLElement_put_onhelp
,
895 HTMLElement_get_onhelp
,
896 HTMLElement_put_onclick
,
897 HTMLElement_get_onclick
,
898 HTMLElement_put_ondblclick
,
899 HTMLElement_get_ondblclick
,
900 HTMLElement_put_onkeydown
,
901 HTMLElement_get_onkeydown
,
902 HTMLElement_put_onkeyup
,
903 HTMLElement_get_onkeyup
,
904 HTMLElement_put_onkeypress
,
905 HTMLElement_get_onkeypress
,
906 HTMLElement_put_onmouseout
,
907 HTMLElement_get_onmouseout
,
908 HTMLElement_put_onmouseover
,
909 HTMLElement_get_onmouseover
,
910 HTMLElement_put_onmousemove
,
911 HTMLElement_get_onmousemove
,
912 HTMLElement_put_onmousedown
,
913 HTMLElement_get_onmousedown
,
914 HTMLElement_put_onmouseup
,
915 HTMLElement_get_onmouseup
,
916 HTMLElement_get_document
,
917 HTMLElement_put_title
,
918 HTMLElement_get_title
,
919 HTMLElement_put_language
,
920 HTMLElement_get_language
,
921 HTMLElement_put_onselectstart
,
922 HTMLElement_get_onselectstart
,
923 HTMLElement_scrollIntoView
,
924 HTMLElement_contains
,
925 HTMLElement_get_sourceIndex
,
926 HTMLElement_get_recordNumber
,
927 HTMLElement_put_lang
,
928 HTMLElement_get_lang
,
929 HTMLElement_get_offsetLeft
,
930 HTMLElement_get_offsetTop
,
931 HTMLElement_get_offsetWidth
,
932 HTMLElement_get_offsetHeight
,
933 HTMLElement_get_offsetParent
,
934 HTMLElement_put_innerHTML
,
935 HTMLElement_get_innerHTML
,
936 HTMLElement_put_innerText
,
937 HTMLElement_get_innerText
,
938 HTMLElement_put_outerHTML
,
939 HTMLElement_get_outerHTML
,
940 HTMLElement_put_outerText
,
941 HTMLElement_get_outerText
,
942 HTMLElement_insertAdjacentHTML
,
943 HTMLElement_insertAdjacentText
,
944 HTMLElement_get_parentTextEdit
,
945 HTMLElement_get_isTextEdit
,
947 HTMLElement_get_filters
,
948 HTMLElement_put_ondragstart
,
949 HTMLElement_get_ondragstart
,
950 HTMLElement_toString
,
951 HTMLElement_put_onbeforeupdate
,
952 HTMLElement_get_onbeforeupdate
,
953 HTMLElement_put_onafterupdate
,
954 HTMLElement_get_onafterupdate
,
955 HTMLElement_put_onerrorupdate
,
956 HTMLElement_get_onerrorupdate
,
957 HTMLElement_put_onrowexit
,
958 HTMLElement_get_onrowexit
,
959 HTMLElement_put_onrowenter
,
960 HTMLElement_get_onrowenter
,
961 HTMLElement_put_ondatasetchanged
,
962 HTMLElement_get_ondatasetchanged
,
963 HTMLElement_put_ondataavailable
,
964 HTMLElement_get_ondataavailable
,
965 HTMLElement_put_ondatasetcomplete
,
966 HTMLElement_get_ondatasetcomplete
,
967 HTMLElement_put_onfilterchange
,
968 HTMLElement_get_onfilterchange
,
969 HTMLElement_get_children
,
973 HRESULT
HTMLElement_QI(HTMLElement
*This
, REFIID riid
, void **ppv
)
977 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
978 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
979 *ppv
= HTMLELEM(This
);
980 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
981 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
982 *ppv
= HTMLELEM(This
);
983 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
984 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
985 *ppv
= HTMLELEM(This
);
986 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
987 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
988 *ppv
= HTMLELEM2(This
);
992 IHTMLElement_AddRef(HTMLELEM(This
));
996 return HTMLDOMNode_QI(This
->node
, riid
, ppv
);
999 void HTMLElement_Create(HTMLDOMNode
*node
)
1002 nsAString class_name_str
;
1003 const PRUnichar
*class_name
;
1006 static const WCHAR wszBODY
[] = {'B','O','D','Y',0};
1007 static const WCHAR wszINPUT
[] = {'I','N','P','U','T',0};
1008 static const WCHAR wszSELECT
[] = {'S','E','L','E','C','T',0};
1009 static const WCHAR wszTEXTAREA
[] = {'T','E','X','T','A','R','E','A',0};
1011 ret
= mshtml_alloc(sizeof(HTMLElement
));
1012 ret
->lpHTMLElementVtbl
= &HTMLElementVtbl
;
1015 ret
->destructor
= NULL
;
1017 node
->node_type
= NT_HTMLELEM
;
1018 node
->impl
.elem
= HTMLELEM(ret
);
1019 node
->destructor
= HTMLElement_destructor
;
1021 HTMLElement2_Init(ret
);
1023 nsres
= nsIDOMNode_QueryInterface(node
->nsnode
, &IID_nsIDOMHTMLElement
, (void**)&ret
->nselem
);
1024 if(NS_FAILED(nsres
))
1027 nsAString_Init(&class_name_str
, NULL
);
1028 nsIDOMHTMLElement_GetTagName(ret
->nselem
, &class_name_str
);
1030 nsAString_GetData(&class_name_str
, &class_name
, NULL
);
1032 if(!strcmpW(class_name
, wszBODY
))
1033 HTMLBodyElement_Create(ret
);
1034 else if(!strcmpW(class_name
, wszINPUT
))
1035 HTMLInputElement_Create(ret
);
1036 else if(!strcmpW(class_name
, wszSELECT
))
1037 HTMLSelectElement_Create(ret
);
1038 else if(!strcmpW(class_name
, wszTEXTAREA
))
1039 HTMLTextAreaElement_Create(ret
);
1041 nsAString_Finish(&class_name_str
);
1045 const IHTMLElementCollectionVtbl
*lpHTMLElementCollectionVtbl
;
1048 HTMLElement
**elems
;
1052 } HTMLElementCollection
;
1054 #define HTMLELEMCOL(x) ((IHTMLElementCollection*) &(x)->lpHTMLElementCollectionVtbl)
1056 #define ELEMCOL_THIS(iface) DEFINE_THIS(HTMLElementCollection, HTMLElementCollection, iface)
1058 static HRESULT WINAPI
HTMLElementCollection_QueryInterface(IHTMLElementCollection
*iface
,
1059 REFIID riid
, void **ppv
)
1061 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1065 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1066 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1067 *ppv
= HTMLELEMCOL(This
);
1068 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1069 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1070 *ppv
= HTMLELEMCOL(This
);
1071 }else if(IsEqualGUID(&IID_IHTMLElementCollection
, riid
)) {
1072 TRACE("(%p)->(IID_IHTMLElementCollection %p)\n", This
, ppv
);
1073 *ppv
= HTMLELEMCOL(This
);
1077 IHTMLElementCollection_AddRef(HTMLELEMCOL(This
));
1081 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1082 return E_NOINTERFACE
;
1085 static ULONG WINAPI
HTMLElementCollection_AddRef(IHTMLElementCollection
*iface
)
1087 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1088 LONG ref
= InterlockedIncrement(&This
->ref
);
1090 TRACE("(%p) ref=%d\n", This
, ref
);
1095 static ULONG WINAPI
HTMLElementCollection_Release(IHTMLElementCollection
*iface
)
1097 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1098 LONG ref
= InterlockedDecrement(&This
->ref
);
1100 TRACE("(%p) ref=%d\n", This
, ref
);
1103 IUnknown_Release(This
->ref_unk
);
1104 mshtml_free(This
->elems
);
1111 static HRESULT WINAPI
HTMLElementCollection_GetTypeInfoCount(IHTMLElementCollection
*iface
,
1114 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1115 FIXME("(%p)->(%p)\n", This
, pctinfo
);
1119 static HRESULT WINAPI
HTMLElementCollection_GetTypeInfo(IHTMLElementCollection
*iface
,
1120 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1122 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1123 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1127 static HRESULT WINAPI
HTMLElementCollection_GetIDsOfNames(IHTMLElementCollection
*iface
,
1128 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1130 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1131 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1136 static HRESULT WINAPI
HTMLElementCollection_Invoke(IHTMLElementCollection
*iface
,
1137 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1138 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1140 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1141 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1142 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1146 static HRESULT WINAPI
HTMLElementCollection_toString(IHTMLElementCollection
*iface
,
1149 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1150 FIXME("(%p)->(%p)\n", This
, String
);
1154 static HRESULT WINAPI
HTMLElementCollection_put_length(IHTMLElementCollection
*iface
,
1157 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1158 FIXME("(%p)->(%ld)\n", This
, v
);
1162 static HRESULT WINAPI
HTMLElementCollection_get_length(IHTMLElementCollection
*iface
,
1165 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1167 TRACE("(%p)->(%p)\n", This
, p
);
1173 static HRESULT WINAPI
HTMLElementCollection_get__newEnum(IHTMLElementCollection
*iface
,
1176 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1177 FIXME("(%p)->(%p)\n", This
, p
);
1181 static HRESULT WINAPI
HTMLElementCollection_item(IHTMLElementCollection
*iface
,
1182 VARIANT name
, VARIANT index
, IDispatch
**pdisp
)
1184 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1186 if(V_VT(&index
) != VT_I4
) {
1187 WARN("Invalid index vt=%d\n", V_VT(&index
));
1188 return E_INVALIDARG
;
1191 if(V_VT(&name
) != VT_I4
|| V_I4(&name
) != V_I4(&index
))
1192 FIXME("Unsupproted name vt=%d\n", V_VT(&name
));
1194 TRACE("(%p)->(%d %d %p)\n", This
, V_I4(&name
), V_I4(&index
), pdisp
);
1196 if(V_I4(&index
) < 0 || V_I4(&index
) >= This
->len
)
1197 return E_INVALIDARG
;
1199 *pdisp
= (IDispatch
*)This
->elems
[V_I4(&index
)];
1200 IDispatch_AddRef(*pdisp
);
1204 static HRESULT WINAPI
HTMLElementCollection_tags(IHTMLElementCollection
*iface
,
1205 VARIANT tagName
, IDispatch
**pdisp
)
1207 HTMLElementCollection
*This
= ELEMCOL_THIS(iface
);
1210 const PRUnichar
*tag
;
1211 elem_vector buf
= {NULL
, 0, 8};
1213 if(V_VT(&tagName
) != VT_BSTR
) {
1214 WARN("Invalid arg\n");
1215 return DISP_E_MEMBERNOTFOUND
;
1218 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(V_BSTR(&tagName
)), pdisp
);
1220 buf
.buf
= mshtml_alloc(buf
.size
*sizeof(HTMLElement
*));
1222 nsAString_Init(&tag_str
, NULL
);
1224 for(i
=0; i
<This
->len
; i
++) {
1225 if(!This
->elems
[i
]->nselem
)
1228 nsIDOMElement_GetTagName(This
->elems
[i
]->nselem
, &tag_str
);
1229 nsAString_GetData(&tag_str
, &tag
, NULL
);
1231 if(CompareStringW(LOCALE_SYSTEM_DEFAULT
, NORM_IGNORECASE
, tag
, -1,
1232 V_BSTR(&tagName
), -1) == CSTR_EQUAL
)
1233 elem_vector_add(&buf
, This
->elems
[i
]);
1236 nsAString_Finish(&tag_str
);
1238 TRACE("fount %d tags\n", buf
.len
);
1241 mshtml_free(buf
.buf
);
1243 }else if(buf
.size
> buf
.len
) {
1244 buf
.buf
= mshtml_realloc(buf
.buf
, buf
.len
*sizeof(HTMLElement
*));
1247 return HTMLElementCollection_Create(This
->ref_unk
, buf
.buf
, buf
.len
, pdisp
);
1252 static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl
= {
1253 HTMLElementCollection_QueryInterface
,
1254 HTMLElementCollection_AddRef
,
1255 HTMLElementCollection_Release
,
1256 HTMLElementCollection_GetTypeInfoCount
,
1257 HTMLElementCollection_GetTypeInfo
,
1258 HTMLElementCollection_GetIDsOfNames
,
1259 HTMLElementCollection_Invoke
,
1260 HTMLElementCollection_toString
,
1261 HTMLElementCollection_put_length
,
1262 HTMLElementCollection_get_length
,
1263 HTMLElementCollection_get__newEnum
,
1264 HTMLElementCollection_item
,
1265 HTMLElementCollection_tags
1268 static HRESULT
HTMLElementCollection_Create(IUnknown
*ref_unk
, HTMLElement
**elems
, DWORD len
,
1271 HTMLElementCollection
*ret
= mshtml_alloc(sizeof(HTMLElementCollection
));
1273 ret
->lpHTMLElementCollectionVtbl
= &HTMLElementCollectionVtbl
;
1278 IUnknown_AddRef(ref_unk
);
1279 ret
->ref_unk
= ref_unk
;
1281 TRACE("ret=%p len=%d\n", ret
, len
);
1283 *p
= (IDispatch
*)ret
;