taskmgr: Avoid forward declarations and make functions static.
[wine.git] / dlls / mshtml / htmlelem.c
blob41dec1322b6ed94d214b5efc3404fbaa2266dc80
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 #include "mshtml_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 static HRESULT HTMLElementCollection_Create(IUnknown*,HTMLElement**,DWORD,IDispatch**);
41 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
43 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
44 REFIID riid, void **ppv)
46 HTMLElement *This = HTMLELEM_THIS(iface);
47 HRESULT hres;
49 if(This->impl)
50 return IUnknown_QueryInterface(This->impl, riid, ppv);
52 hres = HTMLElement_QI(This, riid, ppv);
53 if(FAILED(hres))
54 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
56 return hres;
59 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
61 HTMLElement *This = HTMLELEM_THIS(iface);
63 if(This->impl)
64 return IUnknown_AddRef(This->impl);
66 TRACE("(%p)\n", This);
67 return IHTMLDocument2_AddRef(HTMLDOC(This->node->doc));
70 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
72 HTMLElement *This = HTMLELEM_THIS(iface);
74 if(This->impl)
75 return IUnknown_Release(This->impl);
77 TRACE("(%p)\n", This);
78 return IHTMLDocument2_Release(HTMLDOC(This->node->doc));
81 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
83 HTMLElement *This = HTMLELEM_THIS(iface);
84 FIXME("(%p)->(%p)\n", This, pctinfo);
85 return E_NOTIMPL;
88 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
89 LCID lcid, ITypeInfo **ppTInfo)
91 HTMLElement *This = HTMLELEM_THIS(iface);
92 FIXME("(%p)->(%u %lu %p)\n", This, iTInfo, lcid, ppTInfo);
93 return E_NOTIMPL;
96 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
97 LPOLESTR *rgszNames, UINT cNames,
98 LCID lcid, DISPID *rgDispId)
100 HTMLElement *This = HTMLELEM_THIS(iface);
101 FIXME("(%p)->(%s %p %u %lu %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
102 lcid, rgDispId);
103 return E_NOTIMPL;
106 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
107 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
108 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
110 HTMLElement *This = HTMLELEM_THIS(iface);
111 FIXME("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
112 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
113 return E_NOTIMPL;
116 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
117 VARIANT AttributeValue, LONG lFlags)
119 HTMLElement *This = HTMLELEM_THIS(iface);
120 FIXME("(%p)->(%s . %08lx)\n", This, debugstr_w(strAttributeName), lFlags);
121 return E_NOTIMPL;
124 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
125 LONG lFlags, VARIANT *AttributeValue)
127 HTMLElement *This = HTMLELEM_THIS(iface);
128 nsAString attr_str;
129 nsAString value_str;
130 const PRUnichar *value;
131 nsresult nsres;
132 HRESULT hres = S_OK;
134 WARN("(%p)->(%s %08lx %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
136 nsAString_Init(&attr_str, strAttributeName);
137 nsAString_Init(&value_str, NULL);
139 nsres = nsIDOMHTMLElement_GetAttribute(This->nselem, &attr_str, &value_str);
140 nsAString_Finish(&attr_str);
142 if(NS_SUCCEEDED(nsres)) {
143 nsAString_GetData(&value_str, &value, NULL);
144 V_VT(AttributeValue) = VT_BSTR;
145 V_BSTR(AttributeValue) = SysAllocString(value);;
146 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue)));
147 }else {
148 ERR("GetAttribute failed: %08lx\n", nsres);
149 hres = E_FAIL;
152 nsAString_Finish(&value_str);
154 return hres;
157 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
158 LONG lFlags, VARIANT_BOOL *pfSuccess)
160 HTMLElement *This = HTMLELEM_THIS(iface);
161 FIXME("(%p)->()\n", This);
162 return E_NOTIMPL;
165 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
167 HTMLElement *This = HTMLELEM_THIS(iface);
168 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
169 return E_NOTIMPL;
172 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
174 HTMLElement *This = HTMLELEM_THIS(iface);
175 FIXME("(%p)->(%p)\n", This, p);
176 return E_NOTIMPL;
179 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
181 HTMLElement *This = HTMLELEM_THIS(iface);
182 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
183 return E_NOTIMPL;
186 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
188 HTMLElement *This = HTMLELEM_THIS(iface);
189 FIXME("(%p)->(%p)\n", This, p);
190 return E_NOTIMPL;
193 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
195 HTMLElement *This = HTMLELEM_THIS(iface);
196 FIXME("(%p)->(%p)\n", This, p);
197 return E_NOTIMPL;
200 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
202 HTMLElement *This = HTMLELEM_THIS(iface);
203 FIXME("(%p)->(%p)\n", This, p);
204 return E_NOTIMPL;
207 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
209 HTMLElement *This = HTMLELEM_THIS(iface);
210 FIXME("(%p)->(%p)\n", This, p);
211 return E_NOTIMPL;
214 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
216 HTMLElement *This = HTMLELEM_THIS(iface);
217 FIXME("(%p)->()\n", This);
218 return E_NOTIMPL;
221 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
223 HTMLElement *This = HTMLELEM_THIS(iface);
224 FIXME("(%p)->(%p)\n", This, p);
225 return E_NOTIMPL;
228 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
230 HTMLElement *This = HTMLELEM_THIS(iface);
231 FIXME("(%p)->()\n", This);
232 return E_NOTIMPL;
235 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
237 HTMLElement *This = HTMLELEM_THIS(iface);
238 FIXME("(%p)->(%p)\n", This, p);
239 return E_NOTIMPL;
242 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
244 HTMLElement *This = HTMLELEM_THIS(iface);
245 FIXME("(%p)->()\n", This);
246 return E_NOTIMPL;
249 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
251 HTMLElement *This = HTMLELEM_THIS(iface);
252 FIXME("(%p)->(%p)\n", This, p);
253 return E_NOTIMPL;
256 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
258 HTMLElement *This = HTMLELEM_THIS(iface);
259 FIXME("(%p)->()\n", This);
260 return E_NOTIMPL;
263 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
265 HTMLElement *This = HTMLELEM_THIS(iface);
266 FIXME("(%p)->(%p)\n", This, p);
267 return E_NOTIMPL;
270 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
272 HTMLElement *This = HTMLELEM_THIS(iface);
273 FIXME("(%p)->()\n", This);
274 return E_NOTIMPL;
277 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
279 HTMLElement *This = HTMLELEM_THIS(iface);
280 FIXME("(%p)->(%p)\n", This, p);
281 return E_NOTIMPL;
284 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
286 HTMLElement *This = HTMLELEM_THIS(iface);
287 FIXME("(%p)->()\n", This);
288 return E_NOTIMPL;
291 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
293 HTMLElement *This = HTMLELEM_THIS(iface);
294 FIXME("(%p)->(%p)\n", This, p);
295 return E_NOTIMPL;
298 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
300 HTMLElement *This = HTMLELEM_THIS(iface);
301 FIXME("(%p)->()\n", This);
302 return E_NOTIMPL;
305 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
307 HTMLElement *This = HTMLELEM_THIS(iface);
308 FIXME("(%p)->(%p)\n", This, p);
309 return E_NOTIMPL;
312 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
314 HTMLElement *This = HTMLELEM_THIS(iface);
315 FIXME("(%p)->()\n", This);
316 return E_NOTIMPL;
319 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
321 HTMLElement *This = HTMLELEM_THIS(iface);
322 FIXME("(%p)->(%p)\n", This, p);
323 return E_NOTIMPL;
326 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
328 HTMLElement *This = HTMLELEM_THIS(iface);
329 FIXME("(%p)->()\n", This);
330 return E_NOTIMPL;
333 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
335 HTMLElement *This = HTMLELEM_THIS(iface);
336 FIXME("(%p)->(%p)\n", This, p);
337 return E_NOTIMPL;
340 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
342 HTMLElement *This = HTMLELEM_THIS(iface);
343 FIXME("(%p)->()\n", This);
344 return E_NOTIMPL;
347 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
349 HTMLElement *This = HTMLELEM_THIS(iface);
350 FIXME("(%p)->(%p)\n", This, p);
351 return E_NOTIMPL;
354 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
356 HTMLElement *This = HTMLELEM_THIS(iface);
357 FIXME("(%p)->()\n", This);
358 return E_NOTIMPL;
361 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
363 HTMLElement *This = HTMLELEM_THIS(iface);
364 FIXME("(%p)->(%p)\n", This, p);
365 return E_NOTIMPL;
368 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
370 HTMLElement *This = HTMLELEM_THIS(iface);
371 FIXME("(%p)->(%p)\n", This, p);
372 return E_NOTIMPL;
375 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
377 HTMLElement *This = HTMLELEM_THIS(iface);
378 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
379 return E_NOTIMPL;
382 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
384 HTMLElement *This = HTMLELEM_THIS(iface);
385 FIXME("(%p)->(%p)\n", This, p);
386 return E_NOTIMPL;
389 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
391 HTMLElement *This = HTMLELEM_THIS(iface);
392 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
393 return E_NOTIMPL;
396 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
398 HTMLElement *This = HTMLELEM_THIS(iface);
399 FIXME("(%p)->(%p)\n", This, p);
400 return E_NOTIMPL;
403 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
405 HTMLElement *This = HTMLELEM_THIS(iface);
406 FIXME("(%p)->()\n", This);
407 return E_NOTIMPL;
410 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
412 HTMLElement *This = HTMLELEM_THIS(iface);
413 FIXME("(%p)->(%p)\n", This, p);
414 return E_NOTIMPL;
417 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
419 HTMLElement *This = HTMLELEM_THIS(iface);
420 FIXME("(%p)->()\n", This);
421 return E_NOTIMPL;
424 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
425 VARIANT_BOOL *pfResult)
427 HTMLElement *This = HTMLELEM_THIS(iface);
428 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
429 return E_NOTIMPL;
432 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, long *p)
434 HTMLElement *This = HTMLELEM_THIS(iface);
435 FIXME("(%p)->(%p)\n", This, p);
436 return E_NOTIMPL;
439 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
441 HTMLElement *This = HTMLELEM_THIS(iface);
442 FIXME("(%p)->(%p)\n", This, p);
443 return E_NOTIMPL;
446 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
448 HTMLElement *This = HTMLELEM_THIS(iface);
449 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
450 return E_NOTIMPL;
453 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
455 HTMLElement *This = HTMLELEM_THIS(iface);
456 FIXME("(%p)->(%p)\n", This, p);
457 return E_NOTIMPL;
460 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, long *p)
462 HTMLElement *This = HTMLELEM_THIS(iface);
463 FIXME("(%p)->(%p)\n", This, p);
464 return E_NOTIMPL;
467 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, long *p)
469 HTMLElement *This = HTMLELEM_THIS(iface);
470 FIXME("(%p)->(%p)\n", This, p);
471 return E_NOTIMPL;
474 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, long *p)
476 HTMLElement *This = HTMLELEM_THIS(iface);
477 FIXME("(%p)->(%p)\n", This, p);
478 return E_NOTIMPL;
481 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, long *p)
483 HTMLElement *This = HTMLELEM_THIS(iface);
484 FIXME("(%p)->(%p)\n", This, p);
485 return E_NOTIMPL;
488 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
490 HTMLElement *This = HTMLELEM_THIS(iface);
491 FIXME("(%p)->(%p)\n", This, p);
492 return E_NOTIMPL;
495 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
497 HTMLElement *This = HTMLELEM_THIS(iface);
498 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
499 return E_NOTIMPL;
502 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
504 HTMLElement *This = HTMLELEM_THIS(iface);
505 FIXME("(%p)->(%p)\n", This, p);
506 return E_NOTIMPL;
509 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
511 HTMLElement *This = HTMLELEM_THIS(iface);
512 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
513 return E_NOTIMPL;
516 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
518 HTMLElement *This = HTMLELEM_THIS(iface);
519 FIXME("(%p)->(%p)\n", This, p);
520 return E_NOTIMPL;
523 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
525 HTMLElement *This = HTMLELEM_THIS(iface);
526 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
527 return E_NOTIMPL;
530 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
532 HTMLElement *This = HTMLELEM_THIS(iface);
533 FIXME("(%p)->(%p)\n", This, p);
534 return E_NOTIMPL;
537 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
539 HTMLElement *This = HTMLELEM_THIS(iface);
540 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
541 return E_NOTIMPL;
544 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
546 HTMLElement *This = HTMLELEM_THIS(iface);
547 FIXME("(%p)->(%p)\n", This, p);
548 return E_NOTIMPL;
551 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
552 BSTR html)
554 HTMLElement *This = HTMLELEM_THIS(iface);
555 FIXME("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
556 return E_NOTIMPL;
559 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
560 BSTR text)
562 HTMLElement *This = HTMLELEM_THIS(iface);
563 FIXME("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
564 return E_NOTIMPL;
567 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
569 HTMLElement *This = HTMLELEM_THIS(iface);
570 FIXME("(%p)->(%p)\n", This, p);
571 return E_NOTIMPL;
574 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
576 HTMLElement *This = HTMLELEM_THIS(iface);
577 FIXME("(%p)->(%p)\n", This, p);
578 return E_NOTIMPL;
581 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
583 HTMLElement *This = HTMLELEM_THIS(iface);
584 FIXME("(%p)\n", This);
585 return E_NOTIMPL;
588 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
589 IHTMLFiltersCollection **p)
591 HTMLElement *This = HTMLELEM_THIS(iface);
592 FIXME("(%p)->(%p)\n", This, p);
593 return E_NOTIMPL;
596 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
598 HTMLElement *This = HTMLELEM_THIS(iface);
599 FIXME("(%p)->()\n", This);
600 return E_NOTIMPL;
603 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
605 HTMLElement *This = HTMLELEM_THIS(iface);
606 FIXME("(%p)->(%p)\n", This, p);
607 return E_NOTIMPL;
610 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
612 HTMLElement *This = HTMLELEM_THIS(iface);
613 FIXME("(%p)->(%p)\n", This, String);
614 return E_NOTIMPL;
617 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
619 HTMLElement *This = HTMLELEM_THIS(iface);
620 FIXME("(%p)->()\n", This);
621 return E_NOTIMPL;
624 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
626 HTMLElement *This = HTMLELEM_THIS(iface);
627 FIXME("(%p)->(%p)\n", This, p);
628 return E_NOTIMPL;
631 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
633 HTMLElement *This = HTMLELEM_THIS(iface);
634 FIXME("(%p)->()\n", This);
635 return E_NOTIMPL;
638 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
640 HTMLElement *This = HTMLELEM_THIS(iface);
641 FIXME("(%p)->(%p)\n", This, p);
642 return E_NOTIMPL;
645 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
647 HTMLElement *This = HTMLELEM_THIS(iface);
648 FIXME("(%p)->()\n", This);
649 return E_NOTIMPL;
652 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
654 HTMLElement *This = HTMLELEM_THIS(iface);
655 FIXME("(%p)->(%p)\n", This, p);
656 return E_NOTIMPL;
659 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
661 HTMLElement *This = HTMLELEM_THIS(iface);
662 FIXME("(%p)->()\n", This);
663 return E_NOTIMPL;
666 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
668 HTMLElement *This = HTMLELEM_THIS(iface);
669 FIXME("(%p)->(%p)\n", This, p);
670 return E_NOTIMPL;
673 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
675 HTMLElement *This = HTMLELEM_THIS(iface);
676 FIXME("(%p)->()\n", This);
677 return E_NOTIMPL;
680 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
682 HTMLElement *This = HTMLELEM_THIS(iface);
683 FIXME("(%p)->(%p)\n", This, p);
684 return E_NOTIMPL;
687 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
689 HTMLElement *This = HTMLELEM_THIS(iface);
690 FIXME("(%p)->()\n", This);
691 return E_NOTIMPL;
694 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
696 HTMLElement *This = HTMLELEM_THIS(iface);
697 FIXME("(%p)->(%p)\n", This, p);
698 return E_NOTIMPL;
701 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
703 HTMLElement *This = HTMLELEM_THIS(iface);
704 FIXME("(%p)->()\n", This);
705 return E_NOTIMPL;
708 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
710 HTMLElement *This = HTMLELEM_THIS(iface);
711 FIXME("(%p)->(%p)\n", This, p);
712 return E_NOTIMPL;
715 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
717 HTMLElement *This = HTMLELEM_THIS(iface);
718 FIXME("(%p)->()\n", This);
719 return E_NOTIMPL;
722 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
724 HTMLElement *This = HTMLELEM_THIS(iface);
725 FIXME("(%p)->(%p)\n", This, p);
726 return E_NOTIMPL;
729 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
731 HTMLElement *This = HTMLELEM_THIS(iface);
732 FIXME("(%p)->()\n", This);
733 return E_NOTIMPL;
736 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
738 HTMLElement *This = HTMLELEM_THIS(iface);
739 FIXME("(%p)->(%p)\n", This, p);
740 return E_NOTIMPL;
743 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
745 HTMLElement *This = HTMLELEM_THIS(iface);
746 FIXME("(%p)->(%p)\n", This, p);
747 return E_NOTIMPL;
750 static void create_all_list(HTMLDocument *doc, HTMLElement *elem, HTMLElement ***list, DWORD *size,
751 DWORD *len)
753 nsIDOMNodeList *nsnode_list;
754 nsIDOMNode *iter;
755 PRUint32 list_len = 0, i;
756 HTMLDOMNode *node;
757 nsresult nsres;
759 nsres = nsIDOMNode_GetChildNodes(elem->node->nsnode, &nsnode_list);
760 if(NS_FAILED(nsres)) {
761 ERR("GetChildNodes failed: %08lx\n", nsres);
762 return;
765 nsIDOMNodeList_GetLength(nsnode_list, &list_len);
766 if(!list_len)
767 return;
769 for(i=0; i<list_len; i++) {
770 nsres = nsIDOMNodeList_Item(nsnode_list, i, &iter);
771 if(NS_FAILED(nsres)) {
772 ERR("Item failed: %08lx\n", nsres);
773 continue;
776 node = get_node(doc, iter);
777 if(node->node_type != NT_HTMLELEM)
778 continue;
780 if(*len == *size) {
781 *size <<= 1;
782 *list = HeapReAlloc(GetProcessHeap(), 0, *list, *size * sizeof(HTMLElement**));
785 (*list)[(*len)++] = (HTMLElement*)node->impl.elem;
787 create_all_list(doc, (HTMLElement*)node->impl.elem, list, size, len);
791 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
793 HTMLElement *This = HTMLELEM_THIS(iface);
794 HTMLElement **elem_list;
795 DWORD list_size = 8, len = 0;
797 TRACE("(%p)->(%p)\n", This, p);
799 elem_list = HeapAlloc(GetProcessHeap(), 0, list_size*sizeof(HTMLElement**));
801 create_all_list(This->node->doc, This, &elem_list, &list_size, &len);
803 if(!len) {
804 HeapFree(GetProcessHeap(), 0, elem_list);
805 elem_list = NULL;
806 }else if(list_size > len) {
807 elem_list = HeapReAlloc(GetProcessHeap(), 0, elem_list, len*sizeof(HTMLElement**));
810 return HTMLElementCollection_Create((IUnknown*)HTMLELEM(This), elem_list, len, p);
813 static void HTMLElement_destructor(IUnknown *iface)
815 HTMLElement *This = HTMLELEM_THIS(iface);
817 if(This->destructor)
818 This->destructor(This->impl);
820 if(This->nselem)
821 nsIDOMHTMLElement_Release(This->nselem);
823 HeapFree(GetProcessHeap(), 0, This);
826 #undef HTMLELEM_THIS
828 static const IHTMLElementVtbl HTMLElementVtbl = {
829 HTMLElement_QueryInterface,
830 HTMLElement_AddRef,
831 HTMLElement_Release,
832 HTMLElement_GetTypeInfoCount,
833 HTMLElement_GetTypeInfo,
834 HTMLElement_GetIDsOfNames,
835 HTMLElement_Invoke,
836 HTMLElement_setAttribute,
837 HTMLElement_getAttribute,
838 HTMLElement_removeAttribute,
839 HTMLElement_put_className,
840 HTMLElement_get_className,
841 HTMLElement_put_id,
842 HTMLElement_get_id,
843 HTMLElement_get_tagName,
844 HTMLElement_get_parentElement,
845 HTMLElement_get_style,
846 HTMLElement_put_onhelp,
847 HTMLElement_get_onhelp,
848 HTMLElement_put_onclick,
849 HTMLElement_get_onclick,
850 HTMLElement_put_ondblclick,
851 HTMLElement_get_ondblclick,
852 HTMLElement_put_onkeydown,
853 HTMLElement_get_onkeydown,
854 HTMLElement_put_onkeyup,
855 HTMLElement_get_onkeyup,
856 HTMLElement_put_onkeypress,
857 HTMLElement_get_onkeypress,
858 HTMLElement_put_onmouseout,
859 HTMLElement_get_onmouseout,
860 HTMLElement_put_onmouseover,
861 HTMLElement_get_onmouseover,
862 HTMLElement_put_onmousemove,
863 HTMLElement_get_onmousemove,
864 HTMLElement_put_onmousedown,
865 HTMLElement_get_onmousedown,
866 HTMLElement_put_onmouseup,
867 HTMLElement_get_onmouseup,
868 HTMLElement_get_document,
869 HTMLElement_put_title,
870 HTMLElement_get_title,
871 HTMLElement_put_language,
872 HTMLElement_get_language,
873 HTMLElement_put_onselectstart,
874 HTMLElement_get_onselectstart,
875 HTMLElement_scrollIntoView,
876 HTMLElement_contains,
877 HTMLElement_get_sourceIndex,
878 HTMLElement_get_recordNumber,
879 HTMLElement_put_lang,
880 HTMLElement_get_lang,
881 HTMLElement_get_offsetLeft,
882 HTMLElement_get_offsetTop,
883 HTMLElement_get_offsetWidth,
884 HTMLElement_get_offsetHeight,
885 HTMLElement_get_offsetParent,
886 HTMLElement_put_innerHTML,
887 HTMLElement_get_innerHTML,
888 HTMLElement_put_innerText,
889 HTMLElement_get_innerText,
890 HTMLElement_put_outerHTML,
891 HTMLElement_get_outerHTML,
892 HTMLElement_put_outerText,
893 HTMLElement_get_outerText,
894 HTMLElement_insertAdjacentHTML,
895 HTMLElement_insertAdjacentText,
896 HTMLElement_get_parentTextEdit,
897 HTMLElement_get_isTextEdit,
898 HTMLElement_click,
899 HTMLElement_get_filters,
900 HTMLElement_put_ondragstart,
901 HTMLElement_get_ondragstart,
902 HTMLElement_toString,
903 HTMLElement_put_onbeforeupdate,
904 HTMLElement_get_onbeforeupdate,
905 HTMLElement_put_onafterupdate,
906 HTMLElement_get_onafterupdate,
907 HTMLElement_put_onerrorupdate,
908 HTMLElement_get_onerrorupdate,
909 HTMLElement_put_onrowexit,
910 HTMLElement_get_onrowexit,
911 HTMLElement_put_onrowenter,
912 HTMLElement_get_onrowenter,
913 HTMLElement_put_ondatasetchanged,
914 HTMLElement_get_ondatasetchanged,
915 HTMLElement_put_ondataavailable,
916 HTMLElement_get_ondataavailable,
917 HTMLElement_put_ondatasetcomplete,
918 HTMLElement_get_ondatasetcomplete,
919 HTMLElement_put_onfilterchange,
920 HTMLElement_get_onfilterchange,
921 HTMLElement_get_children,
922 HTMLElement_get_all
925 HRESULT HTMLElement_QI(HTMLElement *This, REFIID riid, void **ppv)
927 *ppv = NULL;
929 if(IsEqualGUID(&IID_IUnknown, riid)) {
930 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
931 *ppv = HTMLELEM(This);
932 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
933 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
934 *ppv = HTMLELEM(This);
935 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
936 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
937 *ppv = HTMLELEM(This);
940 if(*ppv) {
941 IHTMLElement_AddRef(HTMLELEM(This));
942 return S_OK;
945 return HTMLDOMNode_QI(This->node, riid, ppv);
948 void HTMLElement_Create(HTMLDOMNode *node)
950 HTMLElement *ret;
951 nsAString class_name_str;
952 const PRUnichar *class_name;
953 nsresult nsres;
955 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
956 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
957 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
958 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
960 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HTMLElement));
961 ret->lpHTMLElementVtbl = &HTMLElementVtbl;
962 ret->node = node;
963 ret->impl = NULL;
964 ret->destructor = NULL;
966 node->node_type = NT_HTMLELEM;
967 node->impl.elem = HTMLELEM(ret);
968 node->destructor = HTMLElement_destructor;
970 nsres = nsIDOMNode_QueryInterface(node->nsnode, &IID_nsIDOMHTMLElement, (void**)&ret->nselem);
971 if(NS_FAILED(nsres))
972 return;
974 nsAString_Init(&class_name_str, NULL);
975 nsIDOMHTMLElement_GetTagName(ret->nselem, &class_name_str);
977 nsAString_GetData(&class_name_str, &class_name, NULL);
979 if(!strcmpW(class_name, wszBODY))
980 HTMLBodyElement_Create(ret);
981 else if(!strcmpW(class_name, wszINPUT))
982 HTMLInputElement_Create(ret);
983 else if(!strcmpW(class_name, wszSELECT))
984 HTMLSelectElement_Create(ret);
985 else if(!strcmpW(class_name, wszTEXTAREA))
986 HTMLTextAreaElement_Create(ret);
988 nsAString_Finish(&class_name_str);
991 typedef struct {
992 const IHTMLElementCollectionVtbl *lpHTMLElementCollectionVtbl;
994 IUnknown *ref_unk;
995 HTMLElement **elems;
996 DWORD len;
998 LONG ref;
999 } HTMLElementCollection;
1001 #define HTMLELEMCOL(x) ((IHTMLElementCollection*) &(x)->lpHTMLElementCollectionVtbl)
1003 #define ELEMCOL_THIS(iface) DEFINE_THIS(HTMLElementCollection, HTMLElementCollection, iface)
1005 static HRESULT WINAPI HTMLElementCollection_QueryInterface(IHTMLElementCollection *iface,
1006 REFIID riid, void **ppv)
1008 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1010 *ppv = NULL;
1012 if(IsEqualGUID(&IID_IUnknown, riid)) {
1013 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1014 *ppv = HTMLELEMCOL(This);
1015 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1016 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1017 *ppv = HTMLELEMCOL(This);
1018 }else if(IsEqualGUID(&IID_IHTMLElementCollection, riid)) {
1019 TRACE("(%p)->(IID_IHTMLElementCollection %p)\n", This, ppv);
1020 *ppv = HTMLELEMCOL(This);
1023 if(*ppv) {
1024 IHTMLElementCollection_AddRef(HTMLELEMCOL(This));
1025 return S_OK;
1028 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1029 return E_NOINTERFACE;
1032 static ULONG WINAPI HTMLElementCollection_AddRef(IHTMLElementCollection *iface)
1034 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1035 LONG ref = InterlockedIncrement(&This->ref);
1037 TRACE("(%p) ref=%ld\n", This, ref);
1039 return ref;
1042 static ULONG WINAPI HTMLElementCollection_Release(IHTMLElementCollection *iface)
1044 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1045 LONG ref = InterlockedDecrement(&This->ref);
1047 TRACE("(%p) ref=%ld\n", This, ref);
1049 if(!ref) {
1050 IUnknown_Release(This->ref_unk);
1051 HeapFree(GetProcessHeap(), 0, This->elems);
1052 HeapFree(GetProcessHeap(), 0, This);
1055 return ref;
1058 static HRESULT WINAPI HTMLElementCollection_GetTypeInfoCount(IHTMLElementCollection *iface,
1059 UINT *pctinfo)
1061 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1062 FIXME("(%p)->(%p)\n", This, pctinfo);
1063 return E_NOTIMPL;
1066 static HRESULT WINAPI HTMLElementCollection_GetTypeInfo(IHTMLElementCollection *iface,
1067 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1069 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1070 FIXME("(%p)->(%u %lu %p)\n", This, iTInfo, lcid, ppTInfo);
1071 return E_NOTIMPL;
1074 static HRESULT WINAPI HTMLElementCollection_GetIDsOfNames(IHTMLElementCollection *iface,
1075 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1077 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1078 FIXME("(%p)->(%s %p %u %lu %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1079 lcid, rgDispId);
1080 return E_NOTIMPL;
1083 static HRESULT WINAPI HTMLElementCollection_Invoke(IHTMLElementCollection *iface,
1084 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1085 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1087 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1088 FIXME("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1089 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1090 return E_NOTIMPL;
1093 static HRESULT WINAPI HTMLElementCollection_toString(IHTMLElementCollection *iface,
1094 BSTR *String)
1096 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1097 FIXME("(%p)->(%p)\n", This, String);
1098 return E_NOTIMPL;
1101 static HRESULT WINAPI HTMLElementCollection_put_length(IHTMLElementCollection *iface,
1102 long v)
1104 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1105 FIXME("(%p)->(%ld)\n", This, v);
1106 return E_NOTIMPL;
1109 static HRESULT WINAPI HTMLElementCollection_get_length(IHTMLElementCollection *iface,
1110 long *p)
1112 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1114 TRACE("(%p)->(%p)\n", This, p);
1116 *p = This->len;
1117 return S_OK;
1120 static HRESULT WINAPI HTMLElementCollection_get__newEnum(IHTMLElementCollection *iface,
1121 IUnknown **p)
1123 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1124 FIXME("(%p)->(%p)\n", This, p);
1125 return E_NOTIMPL;
1128 static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
1129 VARIANT name, VARIANT index, IDispatch **pdisp)
1131 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1133 if(V_VT(&index) != VT_I4) {
1134 WARN("Invalid index vt=%d\n", V_VT(&index));
1135 return E_INVALIDARG;
1138 if(V_VT(&name) != VT_I4 || V_I4(&name) != V_I4(&index))
1139 FIXME("Unsupproted name vt=%d\n", V_VT(&name));
1141 TRACE("(%p)->(%ld %ld %p)\n", This, V_I4(&name), V_I4(&index), pdisp);
1143 if(V_I4(&index) < 0 || V_I4(&index) >= This->len)
1144 return E_INVALIDARG;
1146 *pdisp = (IDispatch*)This->elems[V_I4(&index)];
1147 IDispatch_AddRef(*pdisp);
1148 return S_OK;
1151 static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface,
1152 VARIANT tagName, IDispatch **pdisp)
1154 HTMLElementCollection *This = ELEMCOL_THIS(iface);
1155 DWORD size = 8, len = 0, i;
1156 HTMLElement **elem_list;
1157 nsAString tag_str;
1158 const PRUnichar *tag;
1160 if(V_VT(&tagName) != VT_BSTR) {
1161 WARN("Invalid arg\n");
1162 return E_INVALIDARG;
1165 TRACE("(%p)->(%s %p)\n", This, debugstr_w(V_BSTR(&tagName)), pdisp);
1167 elem_list = HeapAlloc(GetProcessHeap(), 0, size*sizeof(HTMLElement*));
1169 nsAString_Init(&tag_str, NULL);
1171 for(i=0; i<This->len; i++) {
1172 if(!This->elems[i]->nselem)
1173 continue;
1175 nsIDOMElement_GetTagName(This->elems[i]->nselem, &tag_str);
1176 nsAString_GetData(&tag_str, &tag, NULL);
1178 if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, tag, -1,
1179 V_BSTR(&tagName), -1) == CSTR_EQUAL) {
1180 if(len == size) {
1181 size <<= 2;
1182 elem_list = HeapReAlloc(GetProcessHeap(), 0, elem_list, size);
1185 elem_list[len++] = This->elems[i];
1189 nsAString_Finish(&tag_str);
1191 TRACE("fount %ld tags\n", len);
1193 if(!len) {
1194 HeapFree(GetProcessHeap(), 0, elem_list);
1195 elem_list = NULL;
1196 }else if(size > len) {
1197 HeapReAlloc(GetProcessHeap(), 0, elem_list, len);
1200 return HTMLElementCollection_Create(This->ref_unk, elem_list, len, pdisp);
1203 #undef ELEMCOL_THIS
1205 static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl = {
1206 HTMLElementCollection_QueryInterface,
1207 HTMLElementCollection_AddRef,
1208 HTMLElementCollection_Release,
1209 HTMLElementCollection_GetTypeInfoCount,
1210 HTMLElementCollection_GetTypeInfo,
1211 HTMLElementCollection_GetIDsOfNames,
1212 HTMLElementCollection_Invoke,
1213 HTMLElementCollection_toString,
1214 HTMLElementCollection_put_length,
1215 HTMLElementCollection_get_length,
1216 HTMLElementCollection_get__newEnum,
1217 HTMLElementCollection_item,
1218 HTMLElementCollection_tags
1221 static HRESULT HTMLElementCollection_Create(IUnknown *ref_unk, HTMLElement **elems, DWORD len,
1222 IDispatch **p)
1224 HTMLElementCollection *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HTMLElementCollection));
1226 ret->lpHTMLElementCollectionVtbl = &HTMLElementCollectionVtbl;
1227 ret->ref = 1;
1228 ret->elems = elems;
1229 ret->len = len;
1231 IUnknown_AddRef(ref_unk);
1232 ret->ref_unk = ref_unk;
1234 TRACE("ret=%p len=%ld\n", ret, len);
1236 *p = (IDispatch*)ret;
1237 return S_OK;