inetcomm: Add an implementation of IPOP3Transport::CommandLIST.
[wine/multimedia.git] / dlls / mshtml / htmlelem.c
blob4e7b747a6d0697a37508f82c264d14da4e92feb8
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);
426 TRACE("(%p)->(%p)\n", This, p);
428 return get_node_event(&This->node, EVENTID_CLICK, p);
431 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
433 HTMLElement *This = HTMLELEM_THIS(iface);
434 FIXME("(%p)->()\n", This);
435 return E_NOTIMPL;
438 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
440 HTMLElement *This = HTMLELEM_THIS(iface);
441 FIXME("(%p)->(%p)\n", This, p);
442 return E_NOTIMPL;
445 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
447 HTMLElement *This = HTMLELEM_THIS(iface);
449 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
451 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
454 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
456 HTMLElement *This = HTMLELEM_THIS(iface);
458 TRACE("(%p)->(%p)\n", This, p);
460 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
463 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
465 HTMLElement *This = HTMLELEM_THIS(iface);
467 TRACE("(%p)->()\n", This);
469 return set_node_event(&This->node, EVENTID_KEYUP, &v);
472 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
474 HTMLElement *This = HTMLELEM_THIS(iface);
475 FIXME("(%p)->(%p)\n", This, p);
476 return E_NOTIMPL;
479 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
481 HTMLElement *This = HTMLELEM_THIS(iface);
482 FIXME("(%p)->()\n", This);
483 return E_NOTIMPL;
486 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
488 HTMLElement *This = HTMLELEM_THIS(iface);
489 FIXME("(%p)->(%p)\n", This, p);
490 return E_NOTIMPL;
493 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
495 HTMLElement *This = HTMLELEM_THIS(iface);
497 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
499 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
502 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
504 HTMLElement *This = HTMLELEM_THIS(iface);
506 TRACE("(%p)->(%p)\n", This, p);
508 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
511 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
513 HTMLElement *This = HTMLELEM_THIS(iface);
515 TRACE("(%p)->()\n", This);
517 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
520 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
522 HTMLElement *This = HTMLELEM_THIS(iface);
524 TRACE("(%p)->(%p)\n", This, p);
526 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
529 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
531 HTMLElement *This = HTMLELEM_THIS(iface);
532 FIXME("(%p)->()\n", This);
533 return E_NOTIMPL;
536 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
538 HTMLElement *This = HTMLELEM_THIS(iface);
539 FIXME("(%p)->(%p)\n", This, p);
540 return E_NOTIMPL;
543 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
545 HTMLElement *This = HTMLELEM_THIS(iface);
547 TRACE("(%p)->()\n", This);
549 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
552 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
554 HTMLElement *This = HTMLELEM_THIS(iface);
556 TRACE("(%p)->(%p)\n", This, p);
558 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
561 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
563 HTMLElement *This = HTMLELEM_THIS(iface);
565 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
567 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
570 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
572 HTMLElement *This = HTMLELEM_THIS(iface);
574 TRACE("(%p)->(%p)\n", This, p);
576 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
579 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
581 HTMLElement *This = HTMLELEM_THIS(iface);
582 FIXME("(%p)->(%p)\n", This, p);
583 return E_NOTIMPL;
586 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
588 HTMLElement *This = HTMLELEM_THIS(iface);
589 nsAString title_str;
590 nsresult nsres;
592 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
594 nsAString_Init(&title_str, v);
595 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
596 nsAString_Finish(&title_str);
597 if(NS_FAILED(nsres))
598 ERR("SetTitle failed: %08x\n", nsres);
600 return S_OK;
603 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
605 HTMLElement *This = HTMLELEM_THIS(iface);
606 nsAString title_str;
607 nsresult nsres;
609 TRACE("(%p)->(%p)\n", This, p);
611 nsAString_Init(&title_str, NULL);
612 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
613 if(NS_SUCCEEDED(nsres)) {
614 const PRUnichar *title;
616 nsAString_GetData(&title_str, &title);
617 *p = *title ? SysAllocString(title) : NULL;
618 }else {
619 ERR("GetTitle failed: %08x\n", nsres);
620 return E_FAIL;
623 return S_OK;
626 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
628 HTMLElement *This = HTMLELEM_THIS(iface);
629 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
630 return E_NOTIMPL;
633 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
635 HTMLElement *This = HTMLELEM_THIS(iface);
636 FIXME("(%p)->(%p)\n", This, p);
637 return E_NOTIMPL;
640 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
642 HTMLElement *This = HTMLELEM_THIS(iface);
644 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
646 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
649 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
651 HTMLElement *This = HTMLELEM_THIS(iface);
653 TRACE("(%p)->(%p)\n", This, p);
655 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
658 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
660 HTMLElement *This = HTMLELEM_THIS(iface);
661 FIXME("(%p)->()\n", This);
662 return E_NOTIMPL;
665 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
666 VARIANT_BOOL *pfResult)
668 HTMLElement *This = HTMLELEM_THIS(iface);
669 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
670 return E_NOTIMPL;
673 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, long *p)
675 HTMLElement *This = HTMLELEM_THIS(iface);
676 FIXME("(%p)->(%p)\n", This, p);
677 return E_NOTIMPL;
680 static HRESULT WINAPI HTMLElement_get_recordNumber(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_lang(IHTMLElement *iface, BSTR v)
689 HTMLElement *This = HTMLELEM_THIS(iface);
690 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
691 return E_NOTIMPL;
694 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
696 HTMLElement *This = HTMLELEM_THIS(iface);
697 FIXME("(%p)->(%p)\n", This, p);
698 return E_NOTIMPL;
701 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, long *p)
703 HTMLElement *This = HTMLELEM_THIS(iface);
704 FIXME("(%p)->(%p)\n", This, p);
705 return E_NOTIMPL;
708 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, long *p)
710 HTMLElement *This = HTMLELEM_THIS(iface);
711 nsIDOMNSHTMLElement *nselem;
712 PRInt32 top = 0;
713 nsresult nsres;
715 TRACE("(%p)->(%p)\n", This, p);
717 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
718 if(NS_FAILED(nsres)) {
719 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
720 return E_FAIL;
723 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
724 nsIDOMNSHTMLElement_Release(nselem);
725 if(NS_FAILED(nsres)) {
726 ERR("GetOffsetTop failed: %08x\n", nsres);
727 return E_FAIL;
730 *p = top;
731 return S_OK;
734 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, long *p)
736 HTMLElement *This = HTMLELEM_THIS(iface);
737 nsIDOMNSHTMLElement *nselem;
738 PRInt32 offset = 0;
739 nsresult nsres;
741 TRACE("(%p)->(%p)\n", This, p);
743 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
744 if(NS_FAILED(nsres)) {
745 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
746 return E_FAIL;
749 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
750 nsIDOMNSHTMLElement_Release(nselem);
751 if(NS_FAILED(nsres)) {
752 ERR("GetOffsetWidth failed: %08x\n", nsres);
753 return E_FAIL;
756 *p = offset;
757 return S_OK;
760 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, long *p)
762 HTMLElement *This = HTMLELEM_THIS(iface);
763 nsIDOMNSHTMLElement *nselem;
764 PRInt32 offset = 0;
765 nsresult nsres;
767 TRACE("(%p)->(%p)\n", This, p);
769 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
770 if(NS_FAILED(nsres)) {
771 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
772 return E_FAIL;
775 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
776 nsIDOMNSHTMLElement_Release(nselem);
777 if(NS_FAILED(nsres)) {
778 ERR("GetOffsetHeight failed: %08x\n", nsres);
779 return E_FAIL;
782 *p = offset;
783 return S_OK;
786 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
788 HTMLElement *This = HTMLELEM_THIS(iface);
789 FIXME("(%p)->(%p)\n", This, p);
790 return E_NOTIMPL;
793 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
795 HTMLElement *This = HTMLELEM_THIS(iface);
796 nsIDOMNSHTMLElement *nselem;
797 nsAString html_str;
798 nsresult nsres;
800 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
802 if(!This->nselem) {
803 FIXME("NULL nselem\n");
804 return E_NOTIMPL;
807 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
808 if(NS_FAILED(nsres)) {
809 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
810 return E_FAIL;
813 nsAString_Init(&html_str, v);
814 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
815 nsAString_Finish(&html_str);
817 if(NS_FAILED(nsres)) {
818 FIXME("SetInnerHtml failed %08x\n", nsres);
819 return E_FAIL;
822 return S_OK;
825 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
827 HTMLElement *This = HTMLELEM_THIS(iface);
828 FIXME("(%p)->(%p)\n", This, p);
829 return E_NOTIMPL;
832 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
834 HTMLElement *This = HTMLELEM_THIS(iface);
835 nsIDOMNode *nschild, *tmp;
836 nsIDOMText *text_node;
837 nsAString text_str;
838 nsresult nsres;
840 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
842 while(1) {
843 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
844 if(NS_FAILED(nsres)) {
845 ERR("GetLastChild failed: %08x\n", nsres);
846 return E_FAIL;
848 if(!nschild)
849 break;
851 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
852 nsIDOMNode_Release(nschild);
853 if(NS_FAILED(nsres)) {
854 ERR("RemoveChild failed: %08x\n", nsres);
855 return E_FAIL;
857 nsIDOMNode_Release(tmp);
860 nsAString_Init(&text_str, v);
861 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
862 nsAString_Finish(&text_str);
863 if(NS_FAILED(nsres)) {
864 ERR("CreateTextNode failed: %08x\n", nsres);
865 return E_FAIL;
868 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
869 if(NS_FAILED(nsres)) {
870 ERR("AppendChild failed: %08x\n", nsres);
871 return E_FAIL;
874 nsIDOMNode_Release(tmp);
875 return S_OK;
878 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
880 HTMLElement *This = HTMLELEM_THIS(iface);
882 TRACE("(%p)->(%p)\n", This, p);
884 return get_node_text(&This->node, p);
887 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
889 HTMLElement *This = HTMLELEM_THIS(iface);
890 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
891 return E_NOTIMPL;
894 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
896 HTMLElement *This = HTMLELEM_THIS(iface);
897 FIXME("(%p)->(%p)\n", This, p);
898 return E_NOTIMPL;
901 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
903 HTMLElement *This = HTMLELEM_THIS(iface);
904 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
905 return E_NOTIMPL;
908 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
910 HTMLElement *This = HTMLELEM_THIS(iface);
911 FIXME("(%p)->(%p)\n", This, p);
912 return E_NOTIMPL;
915 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
917 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
918 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
919 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
920 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
921 nsresult nsres;
923 if(!This->nselem) {
924 FIXME("NULL nselem\n");
925 return E_NOTIMPL;
928 if (!strcmpiW(where, wszBeforeBegin))
930 nsIDOMNode *unused;
931 nsIDOMNode *parent;
932 nsres = nsIDOMNode_GetParentNode(This->nselem, &parent);
933 if (!parent) return E_INVALIDARG;
934 nsres = nsIDOMNode_InsertBefore(parent, nsnode,
935 (nsIDOMNode *)This->nselem, &unused);
936 if (unused) nsIDOMNode_Release(unused);
937 nsIDOMNode_Release(parent);
939 else if (!strcmpiW(where, wszAfterBegin))
941 nsIDOMNode *unused;
942 nsIDOMNode *first_child;
943 nsIDOMNode_GetFirstChild(This->nselem, &first_child);
944 nsres = nsIDOMNode_InsertBefore(This->nselem, nsnode, first_child, &unused);
945 if (unused) nsIDOMNode_Release(unused);
946 if (first_child) nsIDOMNode_Release(first_child);
948 else if (!strcmpiW(where, wszBeforeEnd))
950 nsIDOMNode *unused;
951 nsres = nsIDOMNode_AppendChild(This->nselem, nsnode, &unused);
952 if (unused) nsIDOMNode_Release(unused);
954 else if (!strcmpiW(where, wszAfterEnd))
956 nsIDOMNode *unused;
957 nsIDOMNode *next_sibling;
958 nsIDOMNode *parent;
959 nsIDOMNode_GetParentNode(This->nselem, &parent);
960 if (!parent) return E_INVALIDARG;
962 nsIDOMNode_GetNextSibling(This->nselem, &next_sibling);
963 if (next_sibling)
965 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
966 nsIDOMNode_Release(next_sibling);
968 else
969 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
970 nsIDOMNode_Release(parent);
971 if (unused) nsIDOMNode_Release(unused);
973 else
975 ERR("invalid where: %s\n", debugstr_w(where));
976 return E_INVALIDARG;
979 if (NS_FAILED(nsres))
980 return E_FAIL;
981 else
982 return S_OK;
985 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
986 BSTR html)
988 HTMLElement *This = HTMLELEM_THIS(iface);
989 nsIDOMDocumentRange *nsdocrange;
990 nsIDOMRange *range;
991 nsIDOMNSRange *nsrange;
992 nsIDOMNode *nsnode;
993 nsAString ns_html;
994 nsresult nsres;
995 HRESULT hr;
997 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
999 if(!This->node.doc->nsdoc) {
1000 WARN("NULL nsdoc\n");
1001 return E_UNEXPECTED;
1004 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1005 if(NS_FAILED(nsres))
1007 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1008 return E_FAIL;
1010 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1011 nsIDOMDocumentRange_Release(nsdocrange);
1012 if(NS_FAILED(nsres))
1014 ERR("CreateRange failed: %08x\n", nsres);
1015 return E_FAIL;
1018 nsIDOMRange_SetStartBefore(range, (nsIDOMNode *)This->nselem);
1020 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1021 nsIDOMRange_Release(range);
1022 if(NS_FAILED(nsres))
1024 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1025 return E_FAIL;
1028 nsAString_Init(&ns_html, html);
1030 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1031 nsIDOMNSRange_Release(nsrange);
1032 nsAString_Finish(&ns_html);
1034 if(NS_FAILED(nsres) || !nsnode)
1036 ERR("CreateTextNode failed: %08x\n", nsres);
1037 return E_FAIL;
1040 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1041 nsIDOMNode_Release(nsnode);
1043 return hr;
1046 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1047 BSTR text)
1049 HTMLElement *This = HTMLELEM_THIS(iface);
1050 nsIDOMNode *nsnode;
1051 nsAString ns_text;
1052 nsresult nsres;
1053 HRESULT hr;
1055 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1057 if(!This->node.doc->nsdoc) {
1058 WARN("NULL nsdoc\n");
1059 return E_UNEXPECTED;
1063 nsAString_Init(&ns_text, text);
1064 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1065 nsAString_Finish(&ns_text);
1067 if(NS_FAILED(nsres) || !nsnode)
1069 ERR("CreateTextNode failed: %08x\n", nsres);
1070 return E_FAIL;
1073 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1074 nsIDOMNode_Release(nsnode);
1076 return hr;
1079 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1081 HTMLElement *This = HTMLELEM_THIS(iface);
1082 FIXME("(%p)->(%p)\n", This, p);
1083 return E_NOTIMPL;
1086 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1088 HTMLElement *This = HTMLELEM_THIS(iface);
1089 FIXME("(%p)->(%p)\n", This, p);
1090 return E_NOTIMPL;
1093 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1095 HTMLElement *This = HTMLELEM_THIS(iface);
1096 FIXME("(%p)\n", This);
1097 return E_NOTIMPL;
1100 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1101 IHTMLFiltersCollection **p)
1103 HTMLElement *This = HTMLELEM_THIS(iface);
1104 FIXME("(%p)->(%p)\n", This, p);
1105 return E_NOTIMPL;
1108 static HRESULT WINAPI HTMLElement_put_ondragstart(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_ondragstart(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_toString(IHTMLElement *iface, BSTR *String)
1124 HTMLElement *This = HTMLELEM_THIS(iface);
1125 FIXME("(%p)->(%p)\n", This, String);
1126 return E_NOTIMPL;
1129 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1131 HTMLElement *This = HTMLELEM_THIS(iface);
1132 FIXME("(%p)->()\n", This);
1133 return E_NOTIMPL;
1136 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1138 HTMLElement *This = HTMLELEM_THIS(iface);
1139 FIXME("(%p)->(%p)\n", This, p);
1140 return E_NOTIMPL;
1143 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1145 HTMLElement *This = HTMLELEM_THIS(iface);
1146 FIXME("(%p)->()\n", This);
1147 return E_NOTIMPL;
1150 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1152 HTMLElement *This = HTMLELEM_THIS(iface);
1153 FIXME("(%p)->(%p)\n", This, p);
1154 return E_NOTIMPL;
1157 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1159 HTMLElement *This = HTMLELEM_THIS(iface);
1160 FIXME("(%p)->()\n", This);
1161 return E_NOTIMPL;
1164 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1166 HTMLElement *This = HTMLELEM_THIS(iface);
1167 FIXME("(%p)->(%p)\n", This, p);
1168 return E_NOTIMPL;
1171 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1173 HTMLElement *This = HTMLELEM_THIS(iface);
1174 FIXME("(%p)->()\n", This);
1175 return E_NOTIMPL;
1178 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1180 HTMLElement *This = HTMLELEM_THIS(iface);
1181 FIXME("(%p)->(%p)\n", This, p);
1182 return E_NOTIMPL;
1185 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1187 HTMLElement *This = HTMLELEM_THIS(iface);
1188 FIXME("(%p)->()\n", This);
1189 return E_NOTIMPL;
1192 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1194 HTMLElement *This = HTMLELEM_THIS(iface);
1195 FIXME("(%p)->(%p)\n", This, p);
1196 return E_NOTIMPL;
1199 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1201 HTMLElement *This = HTMLELEM_THIS(iface);
1202 FIXME("(%p)->()\n", This);
1203 return E_NOTIMPL;
1206 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1208 HTMLElement *This = HTMLELEM_THIS(iface);
1209 FIXME("(%p)->(%p)\n", This, p);
1210 return E_NOTIMPL;
1213 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1215 HTMLElement *This = HTMLELEM_THIS(iface);
1216 FIXME("(%p)->()\n", This);
1217 return E_NOTIMPL;
1220 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1222 HTMLElement *This = HTMLELEM_THIS(iface);
1223 FIXME("(%p)->(%p)\n", This, p);
1224 return E_NOTIMPL;
1227 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1229 HTMLElement *This = HTMLELEM_THIS(iface);
1230 FIXME("(%p)->()\n", This);
1231 return E_NOTIMPL;
1234 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1236 HTMLElement *This = HTMLELEM_THIS(iface);
1237 FIXME("(%p)->(%p)\n", This, p);
1238 return E_NOTIMPL;
1241 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1243 HTMLElement *This = HTMLELEM_THIS(iface);
1244 FIXME("(%p)->()\n", This);
1245 return E_NOTIMPL;
1248 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1250 HTMLElement *This = HTMLELEM_THIS(iface);
1251 FIXME("(%p)->(%p)\n", This, p);
1252 return E_NOTIMPL;
1255 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1257 HTMLElement *This = HTMLELEM_THIS(iface);
1258 nsIDOMNodeList *nsnode_list;
1259 nsresult nsres;
1261 TRACE("(%p)->(%p)\n", This, p);
1263 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1264 if(NS_FAILED(nsres)) {
1265 ERR("GetChildNodes failed: %08x\n", nsres);
1266 return E_FAIL;
1269 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nsnode_list);
1271 nsIDOMNodeList_Release(nsnode_list);
1272 return S_OK;
1275 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1277 HTMLElement *This = HTMLELEM_THIS(iface);
1279 TRACE("(%p)->(%p)\n", This, p);
1281 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1282 return S_OK;
1285 #undef HTMLELEM_THIS
1287 static const IHTMLElementVtbl HTMLElementVtbl = {
1288 HTMLElement_QueryInterface,
1289 HTMLElement_AddRef,
1290 HTMLElement_Release,
1291 HTMLElement_GetTypeInfoCount,
1292 HTMLElement_GetTypeInfo,
1293 HTMLElement_GetIDsOfNames,
1294 HTMLElement_Invoke,
1295 HTMLElement_setAttribute,
1296 HTMLElement_getAttribute,
1297 HTMLElement_removeAttribute,
1298 HTMLElement_put_className,
1299 HTMLElement_get_className,
1300 HTMLElement_put_id,
1301 HTMLElement_get_id,
1302 HTMLElement_get_tagName,
1303 HTMLElement_get_parentElement,
1304 HTMLElement_get_style,
1305 HTMLElement_put_onhelp,
1306 HTMLElement_get_onhelp,
1307 HTMLElement_put_onclick,
1308 HTMLElement_get_onclick,
1309 HTMLElement_put_ondblclick,
1310 HTMLElement_get_ondblclick,
1311 HTMLElement_put_onkeydown,
1312 HTMLElement_get_onkeydown,
1313 HTMLElement_put_onkeyup,
1314 HTMLElement_get_onkeyup,
1315 HTMLElement_put_onkeypress,
1316 HTMLElement_get_onkeypress,
1317 HTMLElement_put_onmouseout,
1318 HTMLElement_get_onmouseout,
1319 HTMLElement_put_onmouseover,
1320 HTMLElement_get_onmouseover,
1321 HTMLElement_put_onmousemove,
1322 HTMLElement_get_onmousemove,
1323 HTMLElement_put_onmousedown,
1324 HTMLElement_get_onmousedown,
1325 HTMLElement_put_onmouseup,
1326 HTMLElement_get_onmouseup,
1327 HTMLElement_get_document,
1328 HTMLElement_put_title,
1329 HTMLElement_get_title,
1330 HTMLElement_put_language,
1331 HTMLElement_get_language,
1332 HTMLElement_put_onselectstart,
1333 HTMLElement_get_onselectstart,
1334 HTMLElement_scrollIntoView,
1335 HTMLElement_contains,
1336 HTMLElement_get_sourceIndex,
1337 HTMLElement_get_recordNumber,
1338 HTMLElement_put_lang,
1339 HTMLElement_get_lang,
1340 HTMLElement_get_offsetLeft,
1341 HTMLElement_get_offsetTop,
1342 HTMLElement_get_offsetWidth,
1343 HTMLElement_get_offsetHeight,
1344 HTMLElement_get_offsetParent,
1345 HTMLElement_put_innerHTML,
1346 HTMLElement_get_innerHTML,
1347 HTMLElement_put_innerText,
1348 HTMLElement_get_innerText,
1349 HTMLElement_put_outerHTML,
1350 HTMLElement_get_outerHTML,
1351 HTMLElement_put_outerText,
1352 HTMLElement_get_outerText,
1353 HTMLElement_insertAdjacentHTML,
1354 HTMLElement_insertAdjacentText,
1355 HTMLElement_get_parentTextEdit,
1356 HTMLElement_get_isTextEdit,
1357 HTMLElement_click,
1358 HTMLElement_get_filters,
1359 HTMLElement_put_ondragstart,
1360 HTMLElement_get_ondragstart,
1361 HTMLElement_toString,
1362 HTMLElement_put_onbeforeupdate,
1363 HTMLElement_get_onbeforeupdate,
1364 HTMLElement_put_onafterupdate,
1365 HTMLElement_get_onafterupdate,
1366 HTMLElement_put_onerrorupdate,
1367 HTMLElement_get_onerrorupdate,
1368 HTMLElement_put_onrowexit,
1369 HTMLElement_get_onrowexit,
1370 HTMLElement_put_onrowenter,
1371 HTMLElement_get_onrowenter,
1372 HTMLElement_put_ondatasetchanged,
1373 HTMLElement_get_ondatasetchanged,
1374 HTMLElement_put_ondataavailable,
1375 HTMLElement_get_ondataavailable,
1376 HTMLElement_put_ondatasetcomplete,
1377 HTMLElement_get_ondatasetcomplete,
1378 HTMLElement_put_onfilterchange,
1379 HTMLElement_get_onfilterchange,
1380 HTMLElement_get_children,
1381 HTMLElement_get_all
1384 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1386 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1388 *ppv = NULL;
1390 if(IsEqualGUID(&IID_IUnknown, riid)) {
1391 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1392 *ppv = HTMLELEM(This);
1393 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1394 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1395 *ppv = HTMLELEM(This);
1396 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1397 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1398 *ppv = HTMLELEM(This);
1399 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1400 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1401 *ppv = HTMLELEM2(This);
1402 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1403 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1404 *ppv = HTMLELEM3(This);
1405 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1406 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1407 *ppv = CONPTCONT(&This->cp_container);
1410 if(*ppv) {
1411 IHTMLElement_AddRef(HTMLELEM(This));
1412 return S_OK;
1415 return HTMLDOMNode_QI(&This->node, riid, ppv);
1418 void HTMLElement_destructor(HTMLDOMNode *iface)
1420 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1422 ConnectionPointContainer_Destroy(&This->cp_container);
1424 if(This->nselem)
1425 nsIDOMHTMLElement_Release(This->nselem);
1427 HTMLDOMNode_destructor(&This->node);
1430 static const NodeImplVtbl HTMLElementImplVtbl = {
1431 HTMLElement_QI,
1432 HTMLElement_destructor
1435 static const tid_t HTMLElement_iface_tids[] = {
1436 IHTMLDOMNode_tid,
1437 IHTMLDOMNode2_tid,
1438 IHTMLElement_tid,
1439 IHTMLElement2_tid,
1440 IHTMLElement3_tid,
1444 static dispex_static_data_t HTMLElement_dispex = {
1445 NULL,
1446 DispHTMLUnknownElement_tid,
1447 NULL,
1448 HTMLElement_iface_tids
1451 void HTMLElement_Init(HTMLElement *This)
1453 This->lpHTMLElementVtbl = &HTMLElementVtbl;
1455 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
1457 HTMLElement2_Init(This);
1458 HTMLElement3_Init(This);
1460 if(!This->node.dispex.data)
1461 init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), &HTMLElement_dispex);
1464 HTMLElement *HTMLElement_Create(HTMLDocument *doc, nsIDOMNode *nsnode, BOOL use_generic)
1466 nsIDOMHTMLElement *nselem;
1467 HTMLElement *ret = NULL;
1468 nsAString class_name_str;
1469 const PRUnichar *class_name;
1470 nsresult nsres;
1472 static const WCHAR wszA[] = {'A',0};
1473 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
1474 static const WCHAR wszIFRAME[] = {'I','F','R','A','M','E',0};
1475 static const WCHAR wszIMG[] = {'I','M','G',0};
1476 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
1477 static const WCHAR wszOPTION[] = {'O','P','T','I','O','N',0};
1478 static const WCHAR wszSCRIPT[] = {'S','C','R','I','P','T',0};
1479 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
1480 static const WCHAR wszTABLE[] = {'T','A','B','L','E',0};
1481 static const WCHAR wszTR[] = {'T','R',0};
1482 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
1484 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1485 if(NS_FAILED(nsres))
1486 return NULL;
1488 nsAString_Init(&class_name_str, NULL);
1489 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1491 nsAString_GetData(&class_name_str, &class_name);
1493 if(!strcmpW(class_name, wszA))
1494 ret = HTMLAnchorElement_Create(nselem);
1495 else if(!strcmpW(class_name, wszBODY))
1496 ret = HTMLBodyElement_Create(nselem);
1497 else if(!strcmpW(class_name, wszIFRAME))
1498 ret = HTMLIFrame_Create(nselem);
1499 else if(!strcmpW(class_name, wszIMG))
1500 ret = HTMLImgElement_Create(nselem);
1501 else if(!strcmpW(class_name, wszINPUT))
1502 ret = HTMLInputElement_Create(nselem);
1503 else if(!strcmpW(class_name, wszOPTION))
1504 ret = HTMLOptionElement_Create(nselem);
1505 else if(!strcmpW(class_name, wszSCRIPT))
1506 ret = HTMLScriptElement_Create(nselem);
1507 else if(!strcmpW(class_name, wszSELECT))
1508 ret = HTMLSelectElement_Create(nselem);
1509 else if(!strcmpW(class_name, wszTABLE))
1510 ret = HTMLTable_Create(nselem);
1511 else if(!strcmpW(class_name, wszTR))
1512 ret = HTMLTableRow_Create(nselem);
1513 else if(!strcmpW(class_name, wszTEXTAREA))
1514 ret = HTMLTextAreaElement_Create(nselem);
1515 else if(use_generic)
1516 ret = HTMLGenericElement_Create(nselem);
1518 if(!ret) {
1519 ret = heap_alloc_zero(sizeof(HTMLElement));
1520 HTMLElement_Init(ret);
1521 ret->node.vtbl = &HTMLElementImplVtbl;
1524 TRACE("%s ret %p\n", debugstr_w(class_name), ret);
1526 nsAString_Finish(&class_name_str);
1528 ret->nselem = nselem;
1529 HTMLDOMNode_Init(doc, &ret->node, (nsIDOMNode*)nselem);
1531 return ret;