gdiplus: Correct the lfHeight calculation in GdipCreateFontFromLogfontW.
[wine/multimedia.git] / dlls / mshtml / htmlelem.c
blob170d5a0761a5ad51bc55917bc9faf870b1332849
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);
583 TRACE("(%p)->(%p)\n", This, p);
585 if(!p)
586 return E_POINTER;
588 *p = (IDispatch*)HTMLDOC(This->node.doc);
589 IDispatch_AddRef(*p);
591 return S_OK;
594 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
596 HTMLElement *This = HTMLELEM_THIS(iface);
597 nsAString title_str;
598 nsresult nsres;
600 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
602 nsAString_Init(&title_str, v);
603 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
604 nsAString_Finish(&title_str);
605 if(NS_FAILED(nsres))
606 ERR("SetTitle failed: %08x\n", nsres);
608 return S_OK;
611 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
613 HTMLElement *This = HTMLELEM_THIS(iface);
614 nsAString title_str;
615 nsresult nsres;
617 TRACE("(%p)->(%p)\n", This, p);
619 nsAString_Init(&title_str, NULL);
620 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
621 if(NS_SUCCEEDED(nsres)) {
622 const PRUnichar *title;
624 nsAString_GetData(&title_str, &title);
625 *p = *title ? SysAllocString(title) : NULL;
626 }else {
627 ERR("GetTitle failed: %08x\n", nsres);
628 return E_FAIL;
631 return S_OK;
634 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
636 HTMLElement *This = HTMLELEM_THIS(iface);
637 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
638 return E_NOTIMPL;
641 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
643 HTMLElement *This = HTMLELEM_THIS(iface);
644 FIXME("(%p)->(%p)\n", This, p);
645 return E_NOTIMPL;
648 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
650 HTMLElement *This = HTMLELEM_THIS(iface);
652 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
654 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
657 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
659 HTMLElement *This = HTMLELEM_THIS(iface);
661 TRACE("(%p)->(%p)\n", This, p);
663 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
666 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
668 HTMLElement *This = HTMLELEM_THIS(iface);
669 FIXME("(%p)->()\n", This);
670 return E_NOTIMPL;
673 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
674 VARIANT_BOOL *pfResult)
676 HTMLElement *This = HTMLELEM_THIS(iface);
677 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
678 return E_NOTIMPL;
681 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
683 HTMLElement *This = HTMLELEM_THIS(iface);
684 FIXME("(%p)->(%p)\n", This, p);
685 return E_NOTIMPL;
688 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
690 HTMLElement *This = HTMLELEM_THIS(iface);
691 FIXME("(%p)->(%p)\n", This, p);
692 return E_NOTIMPL;
695 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
697 HTMLElement *This = HTMLELEM_THIS(iface);
698 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
699 return E_NOTIMPL;
702 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
704 HTMLElement *This = HTMLELEM_THIS(iface);
705 FIXME("(%p)->(%p)\n", This, p);
706 return E_NOTIMPL;
709 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
711 HTMLElement *This = HTMLELEM_THIS(iface);
712 FIXME("(%p)->(%p)\n", This, p);
713 return E_NOTIMPL;
716 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
718 HTMLElement *This = HTMLELEM_THIS(iface);
719 nsIDOMNSHTMLElement *nselem;
720 PRInt32 top = 0;
721 nsresult nsres;
723 TRACE("(%p)->(%p)\n", This, p);
725 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
726 if(NS_FAILED(nsres)) {
727 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
728 return E_FAIL;
731 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
732 nsIDOMNSHTMLElement_Release(nselem);
733 if(NS_FAILED(nsres)) {
734 ERR("GetOffsetTop failed: %08x\n", nsres);
735 return E_FAIL;
738 *p = top;
739 return S_OK;
742 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
744 HTMLElement *This = HTMLELEM_THIS(iface);
745 nsIDOMNSHTMLElement *nselem;
746 PRInt32 offset = 0;
747 nsresult nsres;
749 TRACE("(%p)->(%p)\n", This, p);
751 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
752 if(NS_FAILED(nsres)) {
753 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
754 return E_FAIL;
757 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
758 nsIDOMNSHTMLElement_Release(nselem);
759 if(NS_FAILED(nsres)) {
760 ERR("GetOffsetWidth failed: %08x\n", nsres);
761 return E_FAIL;
764 *p = offset;
765 return S_OK;
768 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
770 HTMLElement *This = HTMLELEM_THIS(iface);
771 nsIDOMNSHTMLElement *nselem;
772 PRInt32 offset = 0;
773 nsresult nsres;
775 TRACE("(%p)->(%p)\n", This, p);
777 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
778 if(NS_FAILED(nsres)) {
779 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
780 return E_FAIL;
783 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
784 nsIDOMNSHTMLElement_Release(nselem);
785 if(NS_FAILED(nsres)) {
786 ERR("GetOffsetHeight failed: %08x\n", nsres);
787 return E_FAIL;
790 *p = offset;
791 return S_OK;
794 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
796 HTMLElement *This = HTMLELEM_THIS(iface);
797 FIXME("(%p)->(%p)\n", This, p);
798 return E_NOTIMPL;
801 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
803 HTMLElement *This = HTMLELEM_THIS(iface);
804 nsIDOMNSHTMLElement *nselem;
805 nsAString html_str;
806 nsresult nsres;
808 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
810 if(!This->nselem) {
811 FIXME("NULL nselem\n");
812 return E_NOTIMPL;
815 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
816 if(NS_FAILED(nsres)) {
817 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
818 return E_FAIL;
821 nsAString_Init(&html_str, v);
822 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
823 nsAString_Finish(&html_str);
825 if(NS_FAILED(nsres)) {
826 FIXME("SetInnerHtml failed %08x\n", nsres);
827 return E_FAIL;
830 return S_OK;
833 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
835 HTMLElement *This = HTMLELEM_THIS(iface);
836 nsIDOMNSHTMLElement *nselem;
837 nsAString html_str;
838 nsresult nsres;
840 TRACE("(%p)->(%p)\n", This, p);
842 if(!This->nselem) {
843 FIXME("NULL nselem\n");
844 return E_NOTIMPL;
847 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
848 if(NS_FAILED(nsres)) {
849 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
850 return E_FAIL;
853 nsAString_Init(&html_str, NULL);
854 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
855 if(NS_SUCCEEDED(nsres)) {
856 const PRUnichar *html;
858 nsAString_GetData(&html_str, &html);
859 *p = *html ? SysAllocString(html) : NULL;
860 }else {
861 FIXME("SetInnerHtml failed %08x\n", nsres);
862 *p = NULL;
865 nsAString_Finish(&html_str);
866 return S_OK;
869 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
871 HTMLElement *This = HTMLELEM_THIS(iface);
872 nsIDOMNode *nschild, *tmp;
873 nsIDOMText *text_node;
874 nsAString text_str;
875 nsresult nsres;
877 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
879 while(1) {
880 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
881 if(NS_FAILED(nsres)) {
882 ERR("GetLastChild failed: %08x\n", nsres);
883 return E_FAIL;
885 if(!nschild)
886 break;
888 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
889 nsIDOMNode_Release(nschild);
890 if(NS_FAILED(nsres)) {
891 ERR("RemoveChild failed: %08x\n", nsres);
892 return E_FAIL;
894 nsIDOMNode_Release(tmp);
897 nsAString_Init(&text_str, v);
898 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
899 nsAString_Finish(&text_str);
900 if(NS_FAILED(nsres)) {
901 ERR("CreateTextNode failed: %08x\n", nsres);
902 return E_FAIL;
905 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
906 if(NS_FAILED(nsres)) {
907 ERR("AppendChild failed: %08x\n", nsres);
908 return E_FAIL;
911 nsIDOMNode_Release(tmp);
912 return S_OK;
915 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
917 HTMLElement *This = HTMLELEM_THIS(iface);
919 TRACE("(%p)->(%p)\n", This, p);
921 return get_node_text(&This->node, p);
924 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
926 HTMLElement *This = HTMLELEM_THIS(iface);
927 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
928 return E_NOTIMPL;
931 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
933 HTMLElement *This = HTMLELEM_THIS(iface);
934 FIXME("(%p)->(%p)\n", This, p);
935 return E_NOTIMPL;
938 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
940 HTMLElement *This = HTMLELEM_THIS(iface);
941 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
942 return E_NOTIMPL;
945 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
947 HTMLElement *This = HTMLELEM_THIS(iface);
948 FIXME("(%p)->(%p)\n", This, p);
949 return E_NOTIMPL;
952 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
954 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
955 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
956 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
957 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
958 nsresult nsres;
960 if(!This->nselem) {
961 FIXME("NULL nselem\n");
962 return E_NOTIMPL;
965 if (!strcmpiW(where, wszBeforeBegin))
967 nsIDOMNode *unused;
968 nsIDOMNode *parent;
969 nsres = nsIDOMNode_GetParentNode(This->nselem, &parent);
970 if (!parent) return E_INVALIDARG;
971 nsres = nsIDOMNode_InsertBefore(parent, nsnode,
972 (nsIDOMNode *)This->nselem, &unused);
973 if (unused) nsIDOMNode_Release(unused);
974 nsIDOMNode_Release(parent);
976 else if (!strcmpiW(where, wszAfterBegin))
978 nsIDOMNode *unused;
979 nsIDOMNode *first_child;
980 nsIDOMNode_GetFirstChild(This->nselem, &first_child);
981 nsres = nsIDOMNode_InsertBefore(This->nselem, nsnode, first_child, &unused);
982 if (unused) nsIDOMNode_Release(unused);
983 if (first_child) nsIDOMNode_Release(first_child);
985 else if (!strcmpiW(where, wszBeforeEnd))
987 nsIDOMNode *unused;
988 nsres = nsIDOMNode_AppendChild(This->nselem, nsnode, &unused);
989 if (unused) nsIDOMNode_Release(unused);
991 else if (!strcmpiW(where, wszAfterEnd))
993 nsIDOMNode *unused;
994 nsIDOMNode *next_sibling;
995 nsIDOMNode *parent;
996 nsIDOMNode_GetParentNode(This->nselem, &parent);
997 if (!parent) return E_INVALIDARG;
999 nsIDOMNode_GetNextSibling(This->nselem, &next_sibling);
1000 if (next_sibling)
1002 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1003 nsIDOMNode_Release(next_sibling);
1005 else
1006 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1007 nsIDOMNode_Release(parent);
1008 if (unused) nsIDOMNode_Release(unused);
1010 else
1012 ERR("invalid where: %s\n", debugstr_w(where));
1013 return E_INVALIDARG;
1016 if (NS_FAILED(nsres))
1017 return E_FAIL;
1018 else
1019 return S_OK;
1022 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1023 BSTR html)
1025 HTMLElement *This = HTMLELEM_THIS(iface);
1026 nsIDOMDocumentRange *nsdocrange;
1027 nsIDOMRange *range;
1028 nsIDOMNSRange *nsrange;
1029 nsIDOMNode *nsnode;
1030 nsAString ns_html;
1031 nsresult nsres;
1032 HRESULT hr;
1034 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1036 if(!This->node.doc->nsdoc) {
1037 WARN("NULL nsdoc\n");
1038 return E_UNEXPECTED;
1041 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1042 if(NS_FAILED(nsres))
1044 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1045 return E_FAIL;
1047 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1048 nsIDOMDocumentRange_Release(nsdocrange);
1049 if(NS_FAILED(nsres))
1051 ERR("CreateRange failed: %08x\n", nsres);
1052 return E_FAIL;
1055 nsIDOMRange_SetStartBefore(range, (nsIDOMNode *)This->nselem);
1057 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1058 nsIDOMRange_Release(range);
1059 if(NS_FAILED(nsres))
1061 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1062 return E_FAIL;
1065 nsAString_Init(&ns_html, html);
1067 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1068 nsIDOMNSRange_Release(nsrange);
1069 nsAString_Finish(&ns_html);
1071 if(NS_FAILED(nsres) || !nsnode)
1073 ERR("CreateTextNode failed: %08x\n", nsres);
1074 return E_FAIL;
1077 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1078 nsIDOMNode_Release(nsnode);
1080 return hr;
1083 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1084 BSTR text)
1086 HTMLElement *This = HTMLELEM_THIS(iface);
1087 nsIDOMNode *nsnode;
1088 nsAString ns_text;
1089 nsresult nsres;
1090 HRESULT hr;
1092 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1094 if(!This->node.doc->nsdoc) {
1095 WARN("NULL nsdoc\n");
1096 return E_UNEXPECTED;
1100 nsAString_Init(&ns_text, text);
1101 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1102 nsAString_Finish(&ns_text);
1104 if(NS_FAILED(nsres) || !nsnode)
1106 ERR("CreateTextNode failed: %08x\n", nsres);
1107 return E_FAIL;
1110 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1111 nsIDOMNode_Release(nsnode);
1113 return hr;
1116 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1118 HTMLElement *This = HTMLELEM_THIS(iface);
1119 FIXME("(%p)->(%p)\n", This, p);
1120 return E_NOTIMPL;
1123 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1125 HTMLElement *This = HTMLELEM_THIS(iface);
1126 FIXME("(%p)->(%p)\n", This, p);
1127 return E_NOTIMPL;
1130 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1132 HTMLElement *This = HTMLELEM_THIS(iface);
1133 FIXME("(%p)\n", This);
1134 return E_NOTIMPL;
1137 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1138 IHTMLFiltersCollection **p)
1140 HTMLElement *This = HTMLELEM_THIS(iface);
1141 FIXME("(%p)->(%p)\n", This, p);
1142 return E_NOTIMPL;
1145 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1147 HTMLElement *This = HTMLELEM_THIS(iface);
1148 FIXME("(%p)->()\n", This);
1149 return E_NOTIMPL;
1152 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1154 HTMLElement *This = HTMLELEM_THIS(iface);
1155 FIXME("(%p)->(%p)\n", This, p);
1156 return E_NOTIMPL;
1159 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1161 HTMLElement *This = HTMLELEM_THIS(iface);
1162 FIXME("(%p)->(%p)\n", This, String);
1163 return E_NOTIMPL;
1166 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1168 HTMLElement *This = HTMLELEM_THIS(iface);
1169 FIXME("(%p)->()\n", This);
1170 return E_NOTIMPL;
1173 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1175 HTMLElement *This = HTMLELEM_THIS(iface);
1176 FIXME("(%p)->(%p)\n", This, p);
1177 return E_NOTIMPL;
1180 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1182 HTMLElement *This = HTMLELEM_THIS(iface);
1183 FIXME("(%p)->()\n", This);
1184 return E_NOTIMPL;
1187 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1189 HTMLElement *This = HTMLELEM_THIS(iface);
1190 FIXME("(%p)->(%p)\n", This, p);
1191 return E_NOTIMPL;
1194 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1196 HTMLElement *This = HTMLELEM_THIS(iface);
1197 FIXME("(%p)->()\n", This);
1198 return E_NOTIMPL;
1201 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1203 HTMLElement *This = HTMLELEM_THIS(iface);
1204 FIXME("(%p)->(%p)\n", This, p);
1205 return E_NOTIMPL;
1208 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1210 HTMLElement *This = HTMLELEM_THIS(iface);
1211 FIXME("(%p)->()\n", This);
1212 return E_NOTIMPL;
1215 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1217 HTMLElement *This = HTMLELEM_THIS(iface);
1218 FIXME("(%p)->(%p)\n", This, p);
1219 return E_NOTIMPL;
1222 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1224 HTMLElement *This = HTMLELEM_THIS(iface);
1225 FIXME("(%p)->()\n", This);
1226 return E_NOTIMPL;
1229 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1231 HTMLElement *This = HTMLELEM_THIS(iface);
1232 FIXME("(%p)->(%p)\n", This, p);
1233 return E_NOTIMPL;
1236 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1238 HTMLElement *This = HTMLELEM_THIS(iface);
1239 FIXME("(%p)->()\n", This);
1240 return E_NOTIMPL;
1243 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1245 HTMLElement *This = HTMLELEM_THIS(iface);
1246 FIXME("(%p)->(%p)\n", This, p);
1247 return E_NOTIMPL;
1250 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1252 HTMLElement *This = HTMLELEM_THIS(iface);
1253 FIXME("(%p)->()\n", This);
1254 return E_NOTIMPL;
1257 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1259 HTMLElement *This = HTMLELEM_THIS(iface);
1260 FIXME("(%p)->(%p)\n", This, p);
1261 return E_NOTIMPL;
1264 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1266 HTMLElement *This = HTMLELEM_THIS(iface);
1267 FIXME("(%p)->()\n", This);
1268 return E_NOTIMPL;
1271 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1273 HTMLElement *This = HTMLELEM_THIS(iface);
1274 FIXME("(%p)->(%p)\n", This, p);
1275 return E_NOTIMPL;
1278 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1280 HTMLElement *This = HTMLELEM_THIS(iface);
1281 FIXME("(%p)->()\n", This);
1282 return E_NOTIMPL;
1285 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1287 HTMLElement *This = HTMLELEM_THIS(iface);
1288 FIXME("(%p)->(%p)\n", This, p);
1289 return E_NOTIMPL;
1292 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1294 HTMLElement *This = HTMLELEM_THIS(iface);
1295 nsIDOMNodeList *nsnode_list;
1296 nsresult nsres;
1298 TRACE("(%p)->(%p)\n", This, p);
1300 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1301 if(NS_FAILED(nsres)) {
1302 ERR("GetChildNodes failed: %08x\n", nsres);
1303 return E_FAIL;
1306 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nsnode_list);
1308 nsIDOMNodeList_Release(nsnode_list);
1309 return S_OK;
1312 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1314 HTMLElement *This = HTMLELEM_THIS(iface);
1316 TRACE("(%p)->(%p)\n", This, p);
1318 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1319 return S_OK;
1322 #undef HTMLELEM_THIS
1324 static const IHTMLElementVtbl HTMLElementVtbl = {
1325 HTMLElement_QueryInterface,
1326 HTMLElement_AddRef,
1327 HTMLElement_Release,
1328 HTMLElement_GetTypeInfoCount,
1329 HTMLElement_GetTypeInfo,
1330 HTMLElement_GetIDsOfNames,
1331 HTMLElement_Invoke,
1332 HTMLElement_setAttribute,
1333 HTMLElement_getAttribute,
1334 HTMLElement_removeAttribute,
1335 HTMLElement_put_className,
1336 HTMLElement_get_className,
1337 HTMLElement_put_id,
1338 HTMLElement_get_id,
1339 HTMLElement_get_tagName,
1340 HTMLElement_get_parentElement,
1341 HTMLElement_get_style,
1342 HTMLElement_put_onhelp,
1343 HTMLElement_get_onhelp,
1344 HTMLElement_put_onclick,
1345 HTMLElement_get_onclick,
1346 HTMLElement_put_ondblclick,
1347 HTMLElement_get_ondblclick,
1348 HTMLElement_put_onkeydown,
1349 HTMLElement_get_onkeydown,
1350 HTMLElement_put_onkeyup,
1351 HTMLElement_get_onkeyup,
1352 HTMLElement_put_onkeypress,
1353 HTMLElement_get_onkeypress,
1354 HTMLElement_put_onmouseout,
1355 HTMLElement_get_onmouseout,
1356 HTMLElement_put_onmouseover,
1357 HTMLElement_get_onmouseover,
1358 HTMLElement_put_onmousemove,
1359 HTMLElement_get_onmousemove,
1360 HTMLElement_put_onmousedown,
1361 HTMLElement_get_onmousedown,
1362 HTMLElement_put_onmouseup,
1363 HTMLElement_get_onmouseup,
1364 HTMLElement_get_document,
1365 HTMLElement_put_title,
1366 HTMLElement_get_title,
1367 HTMLElement_put_language,
1368 HTMLElement_get_language,
1369 HTMLElement_put_onselectstart,
1370 HTMLElement_get_onselectstart,
1371 HTMLElement_scrollIntoView,
1372 HTMLElement_contains,
1373 HTMLElement_get_sourceIndex,
1374 HTMLElement_get_recordNumber,
1375 HTMLElement_put_lang,
1376 HTMLElement_get_lang,
1377 HTMLElement_get_offsetLeft,
1378 HTMLElement_get_offsetTop,
1379 HTMLElement_get_offsetWidth,
1380 HTMLElement_get_offsetHeight,
1381 HTMLElement_get_offsetParent,
1382 HTMLElement_put_innerHTML,
1383 HTMLElement_get_innerHTML,
1384 HTMLElement_put_innerText,
1385 HTMLElement_get_innerText,
1386 HTMLElement_put_outerHTML,
1387 HTMLElement_get_outerHTML,
1388 HTMLElement_put_outerText,
1389 HTMLElement_get_outerText,
1390 HTMLElement_insertAdjacentHTML,
1391 HTMLElement_insertAdjacentText,
1392 HTMLElement_get_parentTextEdit,
1393 HTMLElement_get_isTextEdit,
1394 HTMLElement_click,
1395 HTMLElement_get_filters,
1396 HTMLElement_put_ondragstart,
1397 HTMLElement_get_ondragstart,
1398 HTMLElement_toString,
1399 HTMLElement_put_onbeforeupdate,
1400 HTMLElement_get_onbeforeupdate,
1401 HTMLElement_put_onafterupdate,
1402 HTMLElement_get_onafterupdate,
1403 HTMLElement_put_onerrorupdate,
1404 HTMLElement_get_onerrorupdate,
1405 HTMLElement_put_onrowexit,
1406 HTMLElement_get_onrowexit,
1407 HTMLElement_put_onrowenter,
1408 HTMLElement_get_onrowenter,
1409 HTMLElement_put_ondatasetchanged,
1410 HTMLElement_get_ondatasetchanged,
1411 HTMLElement_put_ondataavailable,
1412 HTMLElement_get_ondataavailable,
1413 HTMLElement_put_ondatasetcomplete,
1414 HTMLElement_get_ondatasetcomplete,
1415 HTMLElement_put_onfilterchange,
1416 HTMLElement_get_onfilterchange,
1417 HTMLElement_get_children,
1418 HTMLElement_get_all
1421 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1423 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1425 *ppv = NULL;
1427 if(IsEqualGUID(&IID_IUnknown, riid)) {
1428 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1429 *ppv = HTMLELEM(This);
1430 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1431 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1432 *ppv = HTMLELEM(This);
1433 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1434 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1435 *ppv = HTMLELEM(This);
1436 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1437 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1438 *ppv = HTMLELEM2(This);
1439 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1440 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1441 *ppv = HTMLELEM3(This);
1442 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1443 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1444 *ppv = CONPTCONT(&This->cp_container);
1447 if(*ppv) {
1448 IHTMLElement_AddRef(HTMLELEM(This));
1449 return S_OK;
1452 return HTMLDOMNode_QI(&This->node, riid, ppv);
1455 void HTMLElement_destructor(HTMLDOMNode *iface)
1457 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1459 ConnectionPointContainer_Destroy(&This->cp_container);
1461 if(This->nselem)
1462 nsIDOMHTMLElement_Release(This->nselem);
1464 HTMLDOMNode_destructor(&This->node);
1467 static const NodeImplVtbl HTMLElementImplVtbl = {
1468 HTMLElement_QI,
1469 HTMLElement_destructor
1472 static const tid_t HTMLElement_iface_tids[] = {
1473 IHTMLDOMNode_tid,
1474 IHTMLDOMNode2_tid,
1475 IHTMLElement_tid,
1476 IHTMLElement2_tid,
1477 IHTMLElement3_tid,
1481 static dispex_static_data_t HTMLElement_dispex = {
1482 NULL,
1483 DispHTMLUnknownElement_tid,
1484 NULL,
1485 HTMLElement_iface_tids
1488 void HTMLElement_Init(HTMLElement *This)
1490 This->lpHTMLElementVtbl = &HTMLElementVtbl;
1492 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
1494 HTMLElement2_Init(This);
1495 HTMLElement3_Init(This);
1497 if(!This->node.dispex.data)
1498 init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), &HTMLElement_dispex);
1501 HTMLElement *HTMLElement_Create(HTMLDocument *doc, nsIDOMNode *nsnode, BOOL use_generic)
1503 nsIDOMHTMLElement *nselem;
1504 HTMLElement *ret = NULL;
1505 nsAString class_name_str;
1506 const PRUnichar *class_name;
1507 nsresult nsres;
1509 static const WCHAR wszA[] = {'A',0};
1510 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
1511 static const WCHAR wszIFRAME[] = {'I','F','R','A','M','E',0};
1512 static const WCHAR wszIMG[] = {'I','M','G',0};
1513 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
1514 static const WCHAR wszOPTION[] = {'O','P','T','I','O','N',0};
1515 static const WCHAR wszSCRIPT[] = {'S','C','R','I','P','T',0};
1516 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
1517 static const WCHAR wszTABLE[] = {'T','A','B','L','E',0};
1518 static const WCHAR wszTR[] = {'T','R',0};
1519 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
1521 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1522 if(NS_FAILED(nsres))
1523 return NULL;
1525 nsAString_Init(&class_name_str, NULL);
1526 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1528 nsAString_GetData(&class_name_str, &class_name);
1530 if(!strcmpW(class_name, wszA))
1531 ret = HTMLAnchorElement_Create(nselem);
1532 else if(!strcmpW(class_name, wszBODY))
1533 ret = HTMLBodyElement_Create(nselem);
1534 else if(!strcmpW(class_name, wszIFRAME))
1535 ret = HTMLIFrame_Create(nselem);
1536 else if(!strcmpW(class_name, wszIMG))
1537 ret = HTMLImgElement_Create(nselem);
1538 else if(!strcmpW(class_name, wszINPUT))
1539 ret = HTMLInputElement_Create(nselem);
1540 else if(!strcmpW(class_name, wszOPTION))
1541 ret = HTMLOptionElement_Create(nselem);
1542 else if(!strcmpW(class_name, wszSCRIPT))
1543 ret = HTMLScriptElement_Create(nselem);
1544 else if(!strcmpW(class_name, wszSELECT))
1545 ret = HTMLSelectElement_Create(nselem);
1546 else if(!strcmpW(class_name, wszTABLE))
1547 ret = HTMLTable_Create(nselem);
1548 else if(!strcmpW(class_name, wszTR))
1549 ret = HTMLTableRow_Create(nselem);
1550 else if(!strcmpW(class_name, wszTEXTAREA))
1551 ret = HTMLTextAreaElement_Create(nselem);
1552 else if(use_generic)
1553 ret = HTMLGenericElement_Create(nselem);
1555 if(!ret) {
1556 ret = heap_alloc_zero(sizeof(HTMLElement));
1557 HTMLElement_Init(ret);
1558 ret->node.vtbl = &HTMLElementImplVtbl;
1561 TRACE("%s ret %p\n", debugstr_w(class_name), ret);
1563 nsAString_Finish(&class_name_str);
1565 ret->nselem = nselem;
1566 HTMLDOMNode_Init(doc, &ret->node, (nsIDOMNode*)nselem);
1568 return ret;