mshtml: Added get_onmouseover implementations.
[wine/wine64.git] / dlls / mshtml / htmlelem.c
blobb53521a192e36a539d501235d8303cc5328bd554
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "ole2.h"
29 #include "shlwapi.h"
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "mshtml_private.h"
35 #include "htmlevent.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
41 #define HTMLELEM_NODE_THIS(iface) DEFINE_THIS2(HTMLElement, node, iface)
43 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
44 REFIID riid, void **ppv)
46 HTMLElement *This = HTMLELEM_THIS(iface);
48 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->node), riid, ppv);
51 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
53 HTMLElement *This = HTMLELEM_THIS(iface);
55 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->node));
58 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
60 HTMLElement *This = HTMLELEM_THIS(iface);
62 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->node));
65 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
67 HTMLElement *This = HTMLELEM_THIS(iface);
68 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->node.dispex), pctinfo);
71 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
72 LCID lcid, ITypeInfo **ppTInfo)
74 HTMLElement *This = HTMLELEM_THIS(iface);
75 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->node.dispex), iTInfo, lcid, ppTInfo);
78 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
79 LPOLESTR *rgszNames, UINT cNames,
80 LCID lcid, DISPID *rgDispId)
82 HTMLElement *This = HTMLELEM_THIS(iface);
83 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
86 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
87 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
88 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
90 HTMLElement *This = HTMLELEM_THIS(iface);
91 return IDispatchEx_Invoke(DISPATCHEX(&This->node.dispex), dispIdMember, riid, lcid,
92 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
95 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
96 VARIANT AttributeValue, LONG lFlags)
98 HTMLElement *This = HTMLELEM_THIS(iface);
99 nsAString attr_str;
100 nsAString value_str;
101 nsresult nsres;
102 HRESULT hres;
103 VARIANT AttributeValueChanged;
105 WARN("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
107 if(!This->nselem) {
108 FIXME("NULL nselem\n");
109 return E_NOTIMPL;
112 VariantInit(&AttributeValueChanged);
114 hres = VariantChangeType(&AttributeValueChanged, &AttributeValue, 0, VT_BSTR);
115 if (FAILED(hres)) {
116 WARN("couldn't convert input attribute value %d to VT_BSTR\n", V_VT(&AttributeValue));
117 return hres;
120 nsAString_Init(&attr_str, strAttributeName);
121 nsAString_Init(&value_str, V_BSTR(&AttributeValueChanged));
123 TRACE("setting %s to %s\n", debugstr_w(strAttributeName),
124 debugstr_w(V_BSTR(&AttributeValueChanged)));
126 nsres = nsIDOMHTMLElement_SetAttribute(This->nselem, &attr_str, &value_str);
127 nsAString_Finish(&attr_str);
128 nsAString_Finish(&value_str);
130 if(NS_SUCCEEDED(nsres)) {
131 hres = S_OK;
132 }else {
133 ERR("SetAttribute failed: %08x\n", nsres);
134 hres = E_FAIL;
137 return hres;
140 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
141 LONG lFlags, VARIANT *AttributeValue)
143 HTMLElement *This = HTMLELEM_THIS(iface);
144 nsAString attr_str;
145 nsAString value_str;
146 const PRUnichar *value;
147 nsresult nsres;
148 HRESULT hres = S_OK;
150 WARN("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
152 if(!This->nselem) {
153 FIXME("NULL nselem\n");
154 V_VT(AttributeValue) = VT_NULL;
155 return S_OK;
158 V_VT(AttributeValue) = VT_NULL;
160 nsAString_Init(&attr_str, strAttributeName);
161 nsAString_Init(&value_str, NULL);
163 nsres = nsIDOMHTMLElement_GetAttribute(This->nselem, &attr_str, &value_str);
164 nsAString_Finish(&attr_str);
166 if(NS_SUCCEEDED(nsres)) {
167 static const WCHAR wszSRC[] = {'s','r','c',0};
168 nsAString_GetData(&value_str, &value);
169 if(!strcmpiW(strAttributeName, wszSRC))
171 WCHAR buffer[256];
172 DWORD len;
173 BSTR bstrBaseUrl;
174 hres = IHTMLDocument2_get_URL(HTMLDOC(This->node.doc), &bstrBaseUrl);
175 if(SUCCEEDED(hres)) {
176 hres = CoInternetCombineUrl(bstrBaseUrl, value,
177 URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
178 buffer, sizeof(buffer)/sizeof(WCHAR), &len, 0);
179 SysFreeString(bstrBaseUrl);
180 if(SUCCEEDED(hres)) {
181 V_VT(AttributeValue) = VT_BSTR;
182 V_BSTR(AttributeValue) = SysAllocString(buffer);
183 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue)));
186 }else if(*value) {
187 V_VT(AttributeValue) = VT_BSTR;
188 V_BSTR(AttributeValue) = SysAllocString(value);
189 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue)));
191 }else {
192 ERR("GetAttribute failed: %08x\n", nsres);
193 hres = E_FAIL;
196 nsAString_Finish(&value_str);
198 return hres;
201 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
202 LONG lFlags, VARIANT_BOOL *pfSuccess)
204 HTMLElement *This = HTMLELEM_THIS(iface);
205 FIXME("(%p)->()\n", This);
206 return E_NOTIMPL;
209 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
211 HTMLElement *This = HTMLELEM_THIS(iface);
212 nsAString classname_str;
213 nsresult nsres;
215 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
217 if(!This->nselem) {
218 FIXME("NULL nselem\n");
219 return E_NOTIMPL;
222 nsAString_Init(&classname_str, v);
223 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
224 nsAString_Finish(&classname_str);
225 if(NS_FAILED(nsres))
226 ERR("SetClassName failed: %08x\n", nsres);
228 return S_OK;
231 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
233 HTMLElement *This = HTMLELEM_THIS(iface);
234 nsAString class_str;
235 nsresult nsres;
236 HRESULT hres = S_OK;
238 TRACE("(%p)->(%p)\n", This, p);
240 if(!This->nselem) {
241 FIXME("NULL nselem\n");
242 return E_NOTIMPL;
245 nsAString_Init(&class_str, NULL);
246 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
248 if(NS_SUCCEEDED(nsres)) {
249 const PRUnichar *class;
250 nsAString_GetData(&class_str, &class);
251 *p = *class ? SysAllocString(class) : NULL;
252 }else {
253 ERR("GetClassName failed: %08x\n", nsres);
254 hres = E_FAIL;
257 nsAString_Finish(&class_str);
259 TRACE("className=%s\n", debugstr_w(*p));
260 return hres;
263 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
265 HTMLElement *This = HTMLELEM_THIS(iface);
266 nsAString id_str;
267 nsresult nsres;
269 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
271 if(!This->nselem) {
272 FIXME("nselem == NULL\n");
273 return S_OK;
276 nsAString_Init(&id_str, v);
277 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
278 nsAString_Finish(&id_str);
279 if(NS_FAILED(nsres))
280 ERR("SetId failed: %08x\n", nsres);
282 return S_OK;
285 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
287 HTMLElement *This = HTMLELEM_THIS(iface);
288 const PRUnichar *id;
289 nsAString id_str;
290 nsresult nsres;
292 TRACE("(%p)->(%p)\n", This, p);
294 *p = NULL;
296 if(!This->nselem)
297 return S_OK;
299 nsAString_Init(&id_str, NULL);
300 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
301 nsAString_GetData(&id_str, &id);
303 if(NS_FAILED(nsres))
304 ERR("GetId failed: %08x\n", nsres);
305 else if(*id)
306 *p = SysAllocString(id);
308 nsAString_Finish(&id_str);
309 return S_OK;
312 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
314 HTMLElement *This = HTMLELEM_THIS(iface);
315 const PRUnichar *tag;
316 nsAString tag_str;
317 nsresult nsres;
319 TRACE("(%p)->(%p)\n", This, p);
321 if(!This->nselem) {
322 static const WCHAR comment_tagW[] = {'!',0};
324 WARN("NULL nselem, assuming comment\n");
326 *p = SysAllocString(comment_tagW);
327 return S_OK;
330 nsAString_Init(&tag_str, NULL);
331 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
332 if(NS_SUCCEEDED(nsres)) {
333 nsAString_GetData(&tag_str, &tag);
334 *p = SysAllocString(tag);
335 }else {
336 ERR("GetTagName failed: %08x\n", nsres);
337 *p = NULL;
339 nsAString_Finish(&tag_str);
341 return S_OK;
344 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
346 HTMLElement *This = HTMLELEM_THIS(iface);
347 IHTMLDOMNode *node;
348 HRESULT hres;
350 TRACE("(%p)->(%p)\n", This, p);
352 hres = IHTMLDOMNode_get_parentNode(HTMLDOMNODE(&This->node), &node);
353 if(FAILED(hres))
354 return hres;
356 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
357 IHTMLDOMNode_Release(node);
358 if(FAILED(hres))
359 *p = NULL;
361 return S_OK;
364 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
366 HTMLElement *This = HTMLELEM_THIS(iface);
367 nsIDOMElementCSSInlineStyle *nselemstyle;
368 nsIDOMCSSStyleDeclaration *nsstyle;
369 nsresult nsres;
371 TRACE("(%p)->(%p)\n", This, p);
373 if(!This->nselem) {
374 FIXME("NULL nselem\n");
375 return E_NOTIMPL;
378 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
379 (void**)&nselemstyle);
380 if(NS_FAILED(nsres)) {
381 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
382 return E_FAIL;
385 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
386 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
387 if(NS_FAILED(nsres)) {
388 ERR("GetStyle failed: %08x\n", nsres);
389 return E_FAIL;
392 /* FIXME: Store style instead of creating a new instance in each call */
393 *p = HTMLStyle_Create(nsstyle);
395 nsIDOMCSSStyleDeclaration_Release(nsstyle);
396 return S_OK;
399 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
401 HTMLElement *This = HTMLELEM_THIS(iface);
402 FIXME("(%p)->()\n", This);
403 return E_NOTIMPL;
406 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
408 HTMLElement *This = HTMLELEM_THIS(iface);
409 FIXME("(%p)->(%p)\n", This, p);
410 return E_NOTIMPL;
413 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
415 HTMLElement *This = HTMLELEM_THIS(iface);
417 TRACE("(%p)->()\n", This);
419 return set_node_event(&This->node, EVENTID_CLICK, &v);
422 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
424 HTMLElement *This = HTMLELEM_THIS(iface);
425 FIXME("(%p)->(%p)\n", This, p);
426 return E_NOTIMPL;
429 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
431 HTMLElement *This = HTMLELEM_THIS(iface);
432 FIXME("(%p)->()\n", This);
433 return E_NOTIMPL;
436 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
438 HTMLElement *This = HTMLELEM_THIS(iface);
439 FIXME("(%p)->(%p)\n", This, p);
440 return E_NOTIMPL;
443 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
445 HTMLElement *This = HTMLELEM_THIS(iface);
446 FIXME("(%p)->()\n", This);
447 return E_NOTIMPL;
450 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
452 HTMLElement *This = HTMLELEM_THIS(iface);
453 FIXME("(%p)->(%p)\n", This, p);
454 return E_NOTIMPL;
457 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
459 HTMLElement *This = HTMLELEM_THIS(iface);
461 TRACE("(%p)->()\n", This);
463 return set_node_event(&This->node, EVENTID_KEYUP, &v);
466 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
468 HTMLElement *This = HTMLELEM_THIS(iface);
469 FIXME("(%p)->(%p)\n", This, p);
470 return E_NOTIMPL;
473 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
475 HTMLElement *This = HTMLELEM_THIS(iface);
476 FIXME("(%p)->()\n", This);
477 return E_NOTIMPL;
480 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
482 HTMLElement *This = HTMLELEM_THIS(iface);
483 FIXME("(%p)->(%p)\n", This, p);
484 return E_NOTIMPL;
487 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
489 HTMLElement *This = HTMLELEM_THIS(iface);
490 FIXME("(%p)->()\n", This);
491 return E_NOTIMPL;
494 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
496 HTMLElement *This = HTMLELEM_THIS(iface);
497 FIXME("(%p)->(%p)\n", This, p);
498 return E_NOTIMPL;
501 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
503 HTMLElement *This = HTMLELEM_THIS(iface);
505 TRACE("(%p)->()\n", This);
507 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
510 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
512 HTMLElement *This = HTMLELEM_THIS(iface);
514 TRACE("(%p)->(%p)\n", This, p);
516 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
519 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
521 HTMLElement *This = HTMLELEM_THIS(iface);
522 FIXME("(%p)->()\n", This);
523 return E_NOTIMPL;
526 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
528 HTMLElement *This = HTMLELEM_THIS(iface);
529 FIXME("(%p)->(%p)\n", This, p);
530 return E_NOTIMPL;
533 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
535 HTMLElement *This = HTMLELEM_THIS(iface);
536 FIXME("(%p)->()\n", This);
537 return E_NOTIMPL;
540 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
542 HTMLElement *This = HTMLELEM_THIS(iface);
543 FIXME("(%p)->(%p)\n", This, p);
544 return E_NOTIMPL;
547 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
549 HTMLElement *This = HTMLELEM_THIS(iface);
550 FIXME("(%p)->()\n", This);
551 return E_NOTIMPL;
554 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
556 HTMLElement *This = HTMLELEM_THIS(iface);
557 FIXME("(%p)->(%p)\n", This, p);
558 return E_NOTIMPL;
561 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
563 HTMLElement *This = HTMLELEM_THIS(iface);
564 FIXME("(%p)->(%p)\n", This, p);
565 return E_NOTIMPL;
568 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
570 HTMLElement *This = HTMLELEM_THIS(iface);
571 nsAString title_str;
572 nsresult nsres;
574 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
576 nsAString_Init(&title_str, v);
577 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
578 nsAString_Finish(&title_str);
579 if(NS_FAILED(nsres))
580 ERR("SetTitle failed: %08x\n", nsres);
582 return S_OK;
585 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
587 HTMLElement *This = HTMLELEM_THIS(iface);
588 nsAString title_str;
589 nsresult nsres;
591 TRACE("(%p)->(%p)\n", This, p);
593 nsAString_Init(&title_str, NULL);
594 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
595 if(NS_SUCCEEDED(nsres)) {
596 const PRUnichar *title;
598 nsAString_GetData(&title_str, &title);
599 *p = *title ? SysAllocString(title) : NULL;
600 }else {
601 ERR("GetTitle failed: %08x\n", nsres);
602 return E_FAIL;
605 return S_OK;
608 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
610 HTMLElement *This = HTMLELEM_THIS(iface);
611 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
612 return E_NOTIMPL;
615 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
617 HTMLElement *This = HTMLELEM_THIS(iface);
618 FIXME("(%p)->(%p)\n", This, p);
619 return E_NOTIMPL;
622 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
624 HTMLElement *This = HTMLELEM_THIS(iface);
625 FIXME("(%p)->()\n", This);
626 return E_NOTIMPL;
629 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
631 HTMLElement *This = HTMLELEM_THIS(iface);
632 FIXME("(%p)->(%p)\n", This, p);
633 return E_NOTIMPL;
636 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
638 HTMLElement *This = HTMLELEM_THIS(iface);
639 FIXME("(%p)->()\n", This);
640 return E_NOTIMPL;
643 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
644 VARIANT_BOOL *pfResult)
646 HTMLElement *This = HTMLELEM_THIS(iface);
647 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
648 return E_NOTIMPL;
651 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, long *p)
653 HTMLElement *This = HTMLELEM_THIS(iface);
654 FIXME("(%p)->(%p)\n", This, p);
655 return E_NOTIMPL;
658 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
660 HTMLElement *This = HTMLELEM_THIS(iface);
661 FIXME("(%p)->(%p)\n", This, p);
662 return E_NOTIMPL;
665 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
667 HTMLElement *This = HTMLELEM_THIS(iface);
668 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
669 return E_NOTIMPL;
672 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
674 HTMLElement *This = HTMLELEM_THIS(iface);
675 FIXME("(%p)->(%p)\n", This, p);
676 return E_NOTIMPL;
679 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, long *p)
681 HTMLElement *This = HTMLELEM_THIS(iface);
682 FIXME("(%p)->(%p)\n", This, p);
683 return E_NOTIMPL;
686 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, long *p)
688 HTMLElement *This = HTMLELEM_THIS(iface);
689 nsIDOMNSHTMLElement *nselem;
690 PRInt32 top = 0;
691 nsresult nsres;
693 TRACE("(%p)->(%p)\n", This, p);
695 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
696 if(NS_FAILED(nsres)) {
697 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
698 return E_FAIL;
701 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
702 nsIDOMNSHTMLElement_Release(nselem);
703 if(NS_FAILED(nsres)) {
704 ERR("GetOffsetTop failed: %08x\n", nsres);
705 return E_FAIL;
708 *p = top;
709 return S_OK;
712 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, long *p)
714 HTMLElement *This = HTMLELEM_THIS(iface);
715 nsIDOMNSHTMLElement *nselem;
716 PRInt32 offset = 0;
717 nsresult nsres;
719 TRACE("(%p)->(%p)\n", This, p);
721 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
722 if(NS_FAILED(nsres)) {
723 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
724 return E_FAIL;
727 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
728 nsIDOMNSHTMLElement_Release(nselem);
729 if(NS_FAILED(nsres)) {
730 ERR("GetOffsetWidth failed: %08x\n", nsres);
731 return E_FAIL;
734 *p = offset;
735 return S_OK;
738 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, long *p)
740 HTMLElement *This = HTMLELEM_THIS(iface);
741 nsIDOMNSHTMLElement *nselem;
742 PRInt32 offset = 0;
743 nsresult nsres;
745 TRACE("(%p)->(%p)\n", This, p);
747 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
748 if(NS_FAILED(nsres)) {
749 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
750 return E_FAIL;
753 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
754 nsIDOMNSHTMLElement_Release(nselem);
755 if(NS_FAILED(nsres)) {
756 ERR("GetOffsetHeight failed: %08x\n", nsres);
757 return E_FAIL;
760 *p = offset;
761 return S_OK;
764 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
766 HTMLElement *This = HTMLELEM_THIS(iface);
767 FIXME("(%p)->(%p)\n", This, p);
768 return E_NOTIMPL;
771 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
773 HTMLElement *This = HTMLELEM_THIS(iface);
774 nsIDOMNSHTMLElement *nselem;
775 nsAString html_str;
776 nsresult nsres;
778 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
780 if(!This->nselem) {
781 FIXME("NULL nselem\n");
782 return E_NOTIMPL;
785 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
786 if(NS_FAILED(nsres)) {
787 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
788 return E_FAIL;
791 nsAString_Init(&html_str, v);
792 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
793 nsAString_Finish(&html_str);
795 if(NS_FAILED(nsres)) {
796 FIXME("SetInnerHtml failed %08x\n", nsres);
797 return E_FAIL;
800 return S_OK;
803 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
805 HTMLElement *This = HTMLELEM_THIS(iface);
806 FIXME("(%p)->(%p)\n", This, p);
807 return E_NOTIMPL;
810 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
812 HTMLElement *This = HTMLELEM_THIS(iface);
813 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
814 return E_NOTIMPL;
817 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
819 HTMLElement *This = HTMLELEM_THIS(iface);
820 FIXME("(%p)->(%p)\n", This, p);
821 return E_NOTIMPL;
824 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
826 HTMLElement *This = HTMLELEM_THIS(iface);
827 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
828 return E_NOTIMPL;
831 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
833 HTMLElement *This = HTMLELEM_THIS(iface);
834 FIXME("(%p)->(%p)\n", This, p);
835 return E_NOTIMPL;
838 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
840 HTMLElement *This = HTMLELEM_THIS(iface);
841 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
842 return E_NOTIMPL;
845 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
847 HTMLElement *This = HTMLELEM_THIS(iface);
848 FIXME("(%p)->(%p)\n", This, p);
849 return E_NOTIMPL;
852 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
854 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
855 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
856 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
857 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
858 nsresult nsres;
860 if(!This->nselem) {
861 FIXME("NULL nselem\n");
862 return E_NOTIMPL;
865 if (!strcmpiW(where, wszBeforeBegin))
867 nsIDOMNode *unused;
868 nsIDOMNode *parent;
869 nsres = nsIDOMNode_GetParentNode(This->nselem, &parent);
870 if (!parent) return E_INVALIDARG;
871 nsres = nsIDOMNode_InsertBefore(parent, nsnode,
872 (nsIDOMNode *)This->nselem, &unused);
873 if (unused) nsIDOMNode_Release(unused);
874 nsIDOMNode_Release(parent);
876 else if (!strcmpiW(where, wszAfterBegin))
878 nsIDOMNode *unused;
879 nsIDOMNode *first_child;
880 nsIDOMNode_GetFirstChild(This->nselem, &first_child);
881 nsres = nsIDOMNode_InsertBefore(This->nselem, nsnode, first_child, &unused);
882 if (unused) nsIDOMNode_Release(unused);
883 if (first_child) nsIDOMNode_Release(first_child);
885 else if (!strcmpiW(where, wszBeforeEnd))
887 nsIDOMNode *unused;
888 nsres = nsIDOMNode_AppendChild(This->nselem, nsnode, &unused);
889 if (unused) nsIDOMNode_Release(unused);
891 else if (!strcmpiW(where, wszAfterEnd))
893 nsIDOMNode *unused;
894 nsIDOMNode *next_sibling;
895 nsIDOMNode *parent;
896 nsIDOMNode_GetParentNode(This->nselem, &parent);
897 if (!parent) return E_INVALIDARG;
899 nsIDOMNode_GetNextSibling(This->nselem, &next_sibling);
900 if (next_sibling)
902 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
903 nsIDOMNode_Release(next_sibling);
905 else
906 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
907 nsIDOMNode_Release(parent);
908 if (unused) nsIDOMNode_Release(unused);
910 else
912 ERR("invalid where: %s\n", debugstr_w(where));
913 return E_INVALIDARG;
916 if (NS_FAILED(nsres))
917 return E_FAIL;
918 else
919 return S_OK;
922 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
923 BSTR html)
925 HTMLElement *This = HTMLELEM_THIS(iface);
926 nsIDOMDocumentRange *nsdocrange;
927 nsIDOMRange *range;
928 nsIDOMNSRange *nsrange;
929 nsIDOMNode *nsnode;
930 nsAString ns_html;
931 nsresult nsres;
932 HRESULT hr;
934 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
936 if(!This->node.doc->nsdoc) {
937 WARN("NULL nsdoc\n");
938 return E_UNEXPECTED;
941 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
942 if(NS_FAILED(nsres))
944 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
945 return E_FAIL;
947 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
948 nsIDOMDocumentRange_Release(nsdocrange);
949 if(NS_FAILED(nsres))
951 ERR("CreateRange failed: %08x\n", nsres);
952 return E_FAIL;
955 nsIDOMRange_SetStartBefore(range, (nsIDOMNode *)This->nselem);
957 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
958 nsIDOMRange_Release(range);
959 if(NS_FAILED(nsres))
961 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
962 return E_FAIL;
965 nsAString_Init(&ns_html, html);
967 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
968 nsIDOMNSRange_Release(nsrange);
969 nsAString_Finish(&ns_html);
971 if(NS_FAILED(nsres) || !nsnode)
973 ERR("CreateTextNode failed: %08x\n", nsres);
974 return E_FAIL;
977 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
978 nsIDOMNode_Release(nsnode);
980 return hr;
983 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
984 BSTR text)
986 HTMLElement *This = HTMLELEM_THIS(iface);
987 nsIDOMNode *nsnode;
988 nsAString ns_text;
989 nsresult nsres;
990 HRESULT hr;
992 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
994 if(!This->node.doc->nsdoc) {
995 WARN("NULL nsdoc\n");
996 return E_UNEXPECTED;
1000 nsAString_Init(&ns_text, text);
1001 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1002 nsAString_Finish(&ns_text);
1004 if(NS_FAILED(nsres) || !nsnode)
1006 ERR("CreateTextNode failed: %08x\n", nsres);
1007 return E_FAIL;
1010 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1011 nsIDOMNode_Release(nsnode);
1013 return hr;
1016 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1018 HTMLElement *This = HTMLELEM_THIS(iface);
1019 FIXME("(%p)->(%p)\n", This, p);
1020 return E_NOTIMPL;
1023 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1025 HTMLElement *This = HTMLELEM_THIS(iface);
1026 FIXME("(%p)->(%p)\n", This, p);
1027 return E_NOTIMPL;
1030 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1032 HTMLElement *This = HTMLELEM_THIS(iface);
1033 FIXME("(%p)\n", This);
1034 return E_NOTIMPL;
1037 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1038 IHTMLFiltersCollection **p)
1040 HTMLElement *This = HTMLELEM_THIS(iface);
1041 FIXME("(%p)->(%p)\n", This, p);
1042 return E_NOTIMPL;
1045 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1047 HTMLElement *This = HTMLELEM_THIS(iface);
1048 FIXME("(%p)->()\n", This);
1049 return E_NOTIMPL;
1052 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1054 HTMLElement *This = HTMLELEM_THIS(iface);
1055 FIXME("(%p)->(%p)\n", This, p);
1056 return E_NOTIMPL;
1059 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1061 HTMLElement *This = HTMLELEM_THIS(iface);
1062 FIXME("(%p)->(%p)\n", This, String);
1063 return E_NOTIMPL;
1066 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1068 HTMLElement *This = HTMLELEM_THIS(iface);
1069 FIXME("(%p)->()\n", This);
1070 return E_NOTIMPL;
1073 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1075 HTMLElement *This = HTMLELEM_THIS(iface);
1076 FIXME("(%p)->(%p)\n", This, p);
1077 return E_NOTIMPL;
1080 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1082 HTMLElement *This = HTMLELEM_THIS(iface);
1083 FIXME("(%p)->()\n", This);
1084 return E_NOTIMPL;
1087 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1089 HTMLElement *This = HTMLELEM_THIS(iface);
1090 FIXME("(%p)->(%p)\n", This, p);
1091 return E_NOTIMPL;
1094 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1096 HTMLElement *This = HTMLELEM_THIS(iface);
1097 FIXME("(%p)->()\n", This);
1098 return E_NOTIMPL;
1101 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1103 HTMLElement *This = HTMLELEM_THIS(iface);
1104 FIXME("(%p)->(%p)\n", This, p);
1105 return E_NOTIMPL;
1108 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1110 HTMLElement *This = HTMLELEM_THIS(iface);
1111 FIXME("(%p)->()\n", This);
1112 return E_NOTIMPL;
1115 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1117 HTMLElement *This = HTMLELEM_THIS(iface);
1118 FIXME("(%p)->(%p)\n", This, p);
1119 return E_NOTIMPL;
1122 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1124 HTMLElement *This = HTMLELEM_THIS(iface);
1125 FIXME("(%p)->()\n", This);
1126 return E_NOTIMPL;
1129 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1131 HTMLElement *This = HTMLELEM_THIS(iface);
1132 FIXME("(%p)->(%p)\n", This, p);
1133 return E_NOTIMPL;
1136 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1138 HTMLElement *This = HTMLELEM_THIS(iface);
1139 FIXME("(%p)->()\n", This);
1140 return E_NOTIMPL;
1143 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1145 HTMLElement *This = HTMLELEM_THIS(iface);
1146 FIXME("(%p)->(%p)\n", This, p);
1147 return E_NOTIMPL;
1150 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1152 HTMLElement *This = HTMLELEM_THIS(iface);
1153 FIXME("(%p)->()\n", This);
1154 return E_NOTIMPL;
1157 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1159 HTMLElement *This = HTMLELEM_THIS(iface);
1160 FIXME("(%p)->(%p)\n", This, p);
1161 return E_NOTIMPL;
1164 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1166 HTMLElement *This = HTMLELEM_THIS(iface);
1167 FIXME("(%p)->()\n", This);
1168 return E_NOTIMPL;
1171 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1173 HTMLElement *This = HTMLELEM_THIS(iface);
1174 FIXME("(%p)->(%p)\n", This, p);
1175 return E_NOTIMPL;
1178 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1180 HTMLElement *This = HTMLELEM_THIS(iface);
1181 FIXME("(%p)->()\n", This);
1182 return E_NOTIMPL;
1185 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1187 HTMLElement *This = HTMLELEM_THIS(iface);
1188 FIXME("(%p)->(%p)\n", This, p);
1189 return E_NOTIMPL;
1192 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1194 HTMLElement *This = HTMLELEM_THIS(iface);
1195 nsIDOMNodeList *nsnode_list;
1196 nsresult nsres;
1198 TRACE("(%p)->(%p)\n", This, p);
1200 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1201 if(NS_FAILED(nsres)) {
1202 ERR("GetChildNodes failed: %08x\n", nsres);
1203 return E_FAIL;
1206 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nsnode_list);
1208 nsIDOMNodeList_Release(nsnode_list);
1209 return S_OK;
1212 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1214 HTMLElement *This = HTMLELEM_THIS(iface);
1216 TRACE("(%p)->(%p)\n", This, p);
1218 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1219 return S_OK;
1222 #undef HTMLELEM_THIS
1224 static const IHTMLElementVtbl HTMLElementVtbl = {
1225 HTMLElement_QueryInterface,
1226 HTMLElement_AddRef,
1227 HTMLElement_Release,
1228 HTMLElement_GetTypeInfoCount,
1229 HTMLElement_GetTypeInfo,
1230 HTMLElement_GetIDsOfNames,
1231 HTMLElement_Invoke,
1232 HTMLElement_setAttribute,
1233 HTMLElement_getAttribute,
1234 HTMLElement_removeAttribute,
1235 HTMLElement_put_className,
1236 HTMLElement_get_className,
1237 HTMLElement_put_id,
1238 HTMLElement_get_id,
1239 HTMLElement_get_tagName,
1240 HTMLElement_get_parentElement,
1241 HTMLElement_get_style,
1242 HTMLElement_put_onhelp,
1243 HTMLElement_get_onhelp,
1244 HTMLElement_put_onclick,
1245 HTMLElement_get_onclick,
1246 HTMLElement_put_ondblclick,
1247 HTMLElement_get_ondblclick,
1248 HTMLElement_put_onkeydown,
1249 HTMLElement_get_onkeydown,
1250 HTMLElement_put_onkeyup,
1251 HTMLElement_get_onkeyup,
1252 HTMLElement_put_onkeypress,
1253 HTMLElement_get_onkeypress,
1254 HTMLElement_put_onmouseout,
1255 HTMLElement_get_onmouseout,
1256 HTMLElement_put_onmouseover,
1257 HTMLElement_get_onmouseover,
1258 HTMLElement_put_onmousemove,
1259 HTMLElement_get_onmousemove,
1260 HTMLElement_put_onmousedown,
1261 HTMLElement_get_onmousedown,
1262 HTMLElement_put_onmouseup,
1263 HTMLElement_get_onmouseup,
1264 HTMLElement_get_document,
1265 HTMLElement_put_title,
1266 HTMLElement_get_title,
1267 HTMLElement_put_language,
1268 HTMLElement_get_language,
1269 HTMLElement_put_onselectstart,
1270 HTMLElement_get_onselectstart,
1271 HTMLElement_scrollIntoView,
1272 HTMLElement_contains,
1273 HTMLElement_get_sourceIndex,
1274 HTMLElement_get_recordNumber,
1275 HTMLElement_put_lang,
1276 HTMLElement_get_lang,
1277 HTMLElement_get_offsetLeft,
1278 HTMLElement_get_offsetTop,
1279 HTMLElement_get_offsetWidth,
1280 HTMLElement_get_offsetHeight,
1281 HTMLElement_get_offsetParent,
1282 HTMLElement_put_innerHTML,
1283 HTMLElement_get_innerHTML,
1284 HTMLElement_put_innerText,
1285 HTMLElement_get_innerText,
1286 HTMLElement_put_outerHTML,
1287 HTMLElement_get_outerHTML,
1288 HTMLElement_put_outerText,
1289 HTMLElement_get_outerText,
1290 HTMLElement_insertAdjacentHTML,
1291 HTMLElement_insertAdjacentText,
1292 HTMLElement_get_parentTextEdit,
1293 HTMLElement_get_isTextEdit,
1294 HTMLElement_click,
1295 HTMLElement_get_filters,
1296 HTMLElement_put_ondragstart,
1297 HTMLElement_get_ondragstart,
1298 HTMLElement_toString,
1299 HTMLElement_put_onbeforeupdate,
1300 HTMLElement_get_onbeforeupdate,
1301 HTMLElement_put_onafterupdate,
1302 HTMLElement_get_onafterupdate,
1303 HTMLElement_put_onerrorupdate,
1304 HTMLElement_get_onerrorupdate,
1305 HTMLElement_put_onrowexit,
1306 HTMLElement_get_onrowexit,
1307 HTMLElement_put_onrowenter,
1308 HTMLElement_get_onrowenter,
1309 HTMLElement_put_ondatasetchanged,
1310 HTMLElement_get_ondatasetchanged,
1311 HTMLElement_put_ondataavailable,
1312 HTMLElement_get_ondataavailable,
1313 HTMLElement_put_ondatasetcomplete,
1314 HTMLElement_get_ondatasetcomplete,
1315 HTMLElement_put_onfilterchange,
1316 HTMLElement_get_onfilterchange,
1317 HTMLElement_get_children,
1318 HTMLElement_get_all
1321 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1323 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1325 *ppv = NULL;
1327 if(IsEqualGUID(&IID_IUnknown, riid)) {
1328 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1329 *ppv = HTMLELEM(This);
1330 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1331 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1332 *ppv = HTMLELEM(This);
1333 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1334 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1335 *ppv = HTMLELEM(This);
1336 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1337 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1338 *ppv = HTMLELEM2(This);
1339 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1340 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1341 *ppv = HTMLELEM3(This);
1342 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1343 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1344 *ppv = CONPTCONT(&This->cp_container);
1347 if(*ppv) {
1348 IHTMLElement_AddRef(HTMLELEM(This));
1349 return S_OK;
1352 return HTMLDOMNode_QI(&This->node, riid, ppv);
1355 void HTMLElement_destructor(HTMLDOMNode *iface)
1357 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1359 ConnectionPointContainer_Destroy(&This->cp_container);
1361 if(This->nselem)
1362 nsIDOMHTMLElement_Release(This->nselem);
1364 HTMLDOMNode_destructor(&This->node);
1367 static const NodeImplVtbl HTMLElementImplVtbl = {
1368 HTMLElement_QI,
1369 HTMLElement_destructor
1372 static const tid_t HTMLElement_iface_tids[] = {
1373 IHTMLDOMNode_tid,
1374 IHTMLDOMNode2_tid,
1375 IHTMLElement_tid,
1376 IHTMLElement2_tid,
1377 IHTMLElement3_tid,
1381 static dispex_static_data_t HTMLElement_dispex = {
1382 NULL,
1383 DispHTMLUnknownElement_tid,
1384 NULL,
1385 HTMLElement_iface_tids
1388 void HTMLElement_Init(HTMLElement *This)
1390 This->lpHTMLElementVtbl = &HTMLElementVtbl;
1392 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
1394 HTMLElement2_Init(This);
1395 HTMLElement3_Init(This);
1397 if(!This->node.dispex.data)
1398 init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), &HTMLElement_dispex);
1401 HTMLElement *HTMLElement_Create(HTMLDocument *doc, nsIDOMNode *nsnode, BOOL use_generic)
1403 nsIDOMHTMLElement *nselem;
1404 HTMLElement *ret = NULL;
1405 nsAString class_name_str;
1406 const PRUnichar *class_name;
1407 nsresult nsres;
1409 static const WCHAR wszA[] = {'A',0};
1410 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
1411 static const WCHAR wszIFRAME[] = {'I','F','R','A','M','E',0};
1412 static const WCHAR wszIMG[] = {'I','M','G',0};
1413 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
1414 static const WCHAR wszOPTION[] = {'O','P','T','I','O','N',0};
1415 static const WCHAR wszSCRIPT[] = {'S','C','R','I','P','T',0};
1416 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
1417 static const WCHAR wszTABLE[] = {'T','A','B','L','E',0};
1418 static const WCHAR wszTR[] = {'T','R',0};
1419 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
1421 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1422 if(NS_FAILED(nsres))
1423 return NULL;
1425 nsAString_Init(&class_name_str, NULL);
1426 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1428 nsAString_GetData(&class_name_str, &class_name);
1430 if(!strcmpW(class_name, wszA))
1431 ret = HTMLAnchorElement_Create(nselem);
1432 else if(!strcmpW(class_name, wszBODY))
1433 ret = HTMLBodyElement_Create(nselem);
1434 else if(!strcmpW(class_name, wszIFRAME))
1435 ret = HTMLIFrame_Create(nselem);
1436 else if(!strcmpW(class_name, wszIMG))
1437 ret = HTMLImgElement_Create(nselem);
1438 else if(!strcmpW(class_name, wszINPUT))
1439 ret = HTMLInputElement_Create(nselem);
1440 else if(!strcmpW(class_name, wszOPTION))
1441 ret = HTMLOptionElement_Create(nselem);
1442 else if(!strcmpW(class_name, wszSCRIPT))
1443 ret = HTMLScriptElement_Create(nselem);
1444 else if(!strcmpW(class_name, wszSELECT))
1445 ret = HTMLSelectElement_Create(nselem);
1446 else if(!strcmpW(class_name, wszTABLE))
1447 ret = HTMLTable_Create(nselem);
1448 else if(!strcmpW(class_name, wszTR))
1449 ret = HTMLTableRow_Create(nselem);
1450 else if(!strcmpW(class_name, wszTEXTAREA))
1451 ret = HTMLTextAreaElement_Create(nselem);
1452 else if(use_generic)
1453 ret = HTMLGenericElement_Create(nselem);
1455 if(!ret) {
1456 ret = heap_alloc_zero(sizeof(HTMLElement));
1457 HTMLElement_Init(ret);
1458 ret->node.vtbl = &HTMLElementImplVtbl;
1461 TRACE("%s ret %p\n", debugstr_w(class_name), ret);
1463 nsAString_Finish(&class_name_str);
1465 ret->nselem = nselem;
1466 HTMLDOMNode_Init(doc, &ret->node, (nsIDOMNode*)nselem);
1468 return ret;