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
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "mshtml_private.h"
35 #include "htmlevent.h"
40 const IHTMLFiltersCollectionVtbl
*lpHTMLFiltersCollectionVtbl
;
43 } HTMLFiltersCollection
;
45 #define HTMLFILTERSCOLLECTION(x) ((IHTMLFiltersCollection*) &(x)->lpHTMLFiltersCollectionVtbl)
47 #define HTMLFILTERSCOLLECTION_THIS(iface) \
48 DEFINE_THIS(HTMLFiltersCollection, HTMLFiltersCollection, iface)
50 IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void);
53 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
55 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
57 HRESULT
create_nselem(HTMLDocumentNode
*doc
, const WCHAR
*tag
, nsIDOMHTMLElement
**ret
)
59 nsIDOMElement
*nselem
;
68 nsAString_InitDepend(&tag_str
, tag
);
69 nsres
= nsIDOMDocument_CreateElement(doc
->nsdoc
, &tag_str
, &nselem
);
70 nsAString_Finish(&tag_str
);
71 if(NS_FAILED(nsres
)) {
72 ERR("CreateElement failed: %08x\n", nsres
);
76 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLElement
, (void**)ret
);
77 nsIDOMElement_Release(nselem
);
78 if(NS_FAILED(nsres
)) {
79 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres
);
86 #define HTMLELEM_NODE_THIS(iface) DEFINE_THIS2(HTMLElement, node, iface)
88 static HRESULT WINAPI
HTMLElement_QueryInterface(IHTMLElement
*iface
,
89 REFIID riid
, void **ppv
)
91 HTMLElement
*This
= HTMLELEM_THIS(iface
);
93 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->node
), riid
, ppv
);
96 static ULONG WINAPI
HTMLElement_AddRef(IHTMLElement
*iface
)
98 HTMLElement
*This
= HTMLELEM_THIS(iface
);
100 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->node
));
103 static ULONG WINAPI
HTMLElement_Release(IHTMLElement
*iface
)
105 HTMLElement
*This
= HTMLELEM_THIS(iface
);
107 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->node
));
110 static HRESULT WINAPI
HTMLElement_GetTypeInfoCount(IHTMLElement
*iface
, UINT
*pctinfo
)
112 HTMLElement
*This
= HTMLELEM_THIS(iface
);
113 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->node
.dispex
), pctinfo
);
116 static HRESULT WINAPI
HTMLElement_GetTypeInfo(IHTMLElement
*iface
, UINT iTInfo
,
117 LCID lcid
, ITypeInfo
**ppTInfo
)
119 HTMLElement
*This
= HTMLELEM_THIS(iface
);
120 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->node
.dispex
), iTInfo
, lcid
, ppTInfo
);
123 static HRESULT WINAPI
HTMLElement_GetIDsOfNames(IHTMLElement
*iface
, REFIID riid
,
124 LPOLESTR
*rgszNames
, UINT cNames
,
125 LCID lcid
, DISPID
*rgDispId
)
127 HTMLElement
*This
= HTMLELEM_THIS(iface
);
128 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->node
.dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
131 static HRESULT WINAPI
HTMLElement_Invoke(IHTMLElement
*iface
, DISPID dispIdMember
,
132 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
133 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
135 HTMLElement
*This
= HTMLELEM_THIS(iface
);
136 return IDispatchEx_Invoke(DISPATCHEX(&This
->node
.dispex
), dispIdMember
, riid
, lcid
,
137 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
140 static HRESULT WINAPI
HTMLElement_setAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
141 VARIANT AttributeValue
, LONG lFlags
)
143 HTMLElement
*This
= HTMLELEM_THIS(iface
);
145 DISPID dispid
, dispidNamed
= DISPID_PROPERTYPUT
;
146 DISPPARAMS dispParams
;
149 TRACE("(%p)->(%s . %08x)\n", This
, debugstr_w(strAttributeName
), lFlags
);
151 hres
= IDispatchEx_GetDispID(DISPATCHEX(&This
->node
.dispex
), strAttributeName
,
152 fdexNameCaseInsensitive
| fdexNameEnsure
, &dispid
);
156 dispParams
.cArgs
= 1;
157 dispParams
.cNamedArgs
= 1;
158 dispParams
.rgdispidNamedArgs
= &dispidNamed
;
159 dispParams
.rgvarg
= &AttributeValue
;
161 hres
= IDispatchEx_InvokeEx(DISPATCHEX(&This
->node
.dispex
), dispid
,
162 LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYPUT
, &dispParams
,
167 static HRESULT WINAPI
HTMLElement_getAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
168 LONG lFlags
, VARIANT
*AttributeValue
)
170 HTMLElement
*This
= HTMLELEM_THIS(iface
);
173 DISPPARAMS dispParams
= {NULL
, NULL
, 0, 0};
176 TRACE("(%p)->(%s %08x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, AttributeValue
);
178 hres
= IDispatchEx_GetDispID(DISPATCHEX(&This
->node
.dispex
), strAttributeName
,
179 fdexNameCaseInsensitive
, &dispid
);
180 if(hres
== DISP_E_UNKNOWNNAME
) {
181 V_VT(AttributeValue
) = VT_NULL
;
186 V_VT(AttributeValue
) = VT_NULL
;
190 hres
= IDispatchEx_InvokeEx(DISPATCHEX(&This
->node
.dispex
), dispid
,
191 LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYGET
, &dispParams
,
192 AttributeValue
, &excep
, NULL
);
197 static HRESULT WINAPI
HTMLElement_removeAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
198 LONG lFlags
, VARIANT_BOOL
*pfSuccess
)
200 HTMLElement
*This
= HTMLELEM_THIS(iface
);
202 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, pfSuccess
);
204 return remove_prop(&This
->node
.dispex
, strAttributeName
, pfSuccess
);
207 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
209 HTMLElement
*This
= HTMLELEM_THIS(iface
);
210 nsAString classname_str
;
213 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
216 FIXME("NULL nselem\n");
220 nsAString_InitDepend(&classname_str
, v
);
221 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
222 nsAString_Finish(&classname_str
);
224 ERR("SetClassName failed: %08x\n", nsres
);
229 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
231 HTMLElement
*This
= HTMLELEM_THIS(iface
);
236 TRACE("(%p)->(%p)\n", This
, p
);
239 FIXME("NULL nselem\n");
243 nsAString_Init(&class_str
, NULL
);
244 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
246 if(NS_SUCCEEDED(nsres
)) {
247 const PRUnichar
*class;
248 nsAString_GetData(&class_str
, &class);
249 *p
= *class ? SysAllocString(class) : NULL
;
251 ERR("GetClassName failed: %08x\n", nsres
);
255 nsAString_Finish(&class_str
);
257 TRACE("className=%s\n", debugstr_w(*p
));
261 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
263 HTMLElement
*This
= HTMLELEM_THIS(iface
);
267 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
270 FIXME("nselem == NULL\n");
274 nsAString_InitDepend(&id_str
, v
);
275 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
276 nsAString_Finish(&id_str
);
278 ERR("SetId failed: %08x\n", nsres
);
283 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
285 HTMLElement
*This
= HTMLELEM_THIS(iface
);
290 TRACE("(%p)->(%p)\n", This
, p
);
297 nsAString_Init(&id_str
, NULL
);
298 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
299 nsAString_GetData(&id_str
, &id
);
302 ERR("GetId failed: %08x\n", nsres
);
304 *p
= SysAllocString(id
);
306 nsAString_Finish(&id_str
);
310 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
312 HTMLElement
*This
= HTMLELEM_THIS(iface
);
313 const PRUnichar
*tag
;
317 TRACE("(%p)->(%p)\n", This
, p
);
320 static const WCHAR comment_tagW
[] = {'!',0};
322 WARN("NULL nselem, assuming comment\n");
324 *p
= SysAllocString(comment_tagW
);
328 nsAString_Init(&tag_str
, NULL
);
329 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
330 if(NS_SUCCEEDED(nsres
)) {
331 nsAString_GetData(&tag_str
, &tag
);
332 *p
= SysAllocString(tag
);
334 ERR("GetTagName failed: %08x\n", nsres
);
337 nsAString_Finish(&tag_str
);
342 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
344 HTMLElement
*This
= HTMLELEM_THIS(iface
);
348 TRACE("(%p)->(%p)\n", This
, p
);
350 hres
= IHTMLDOMNode_get_parentNode(HTMLDOMNODE(&This
->node
), &node
);
354 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
355 IHTMLDOMNode_Release(node
);
362 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
364 HTMLElement
*This
= HTMLELEM_THIS(iface
);
365 nsIDOMElementCSSInlineStyle
*nselemstyle
;
366 nsIDOMCSSStyleDeclaration
*nsstyle
;
369 TRACE("(%p)->(%p)\n", This
, p
);
372 FIXME("NULL nselem\n");
376 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMElementCSSInlineStyle
,
377 (void**)&nselemstyle
);
378 if(NS_FAILED(nsres
)) {
379 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres
);
383 nsres
= nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle
, &nsstyle
);
384 nsIDOMElementCSSInlineStyle_Release(nselemstyle
);
385 if(NS_FAILED(nsres
)) {
386 ERR("GetStyle failed: %08x\n", nsres
);
390 /* FIXME: Store style instead of creating a new instance in each call */
391 *p
= HTMLStyle_Create(nsstyle
);
393 nsIDOMCSSStyleDeclaration_Release(nsstyle
);
397 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
399 HTMLElement
*This
= HTMLELEM_THIS(iface
);
400 FIXME("(%p)->()\n", This
);
404 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
406 HTMLElement
*This
= HTMLELEM_THIS(iface
);
407 FIXME("(%p)->(%p)\n", This
, p
);
411 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
413 HTMLElement
*This
= HTMLELEM_THIS(iface
);
415 TRACE("(%p)->()\n", This
);
417 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
420 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
422 HTMLElement
*This
= HTMLELEM_THIS(iface
);
424 TRACE("(%p)->(%p)\n", This
, p
);
426 return get_node_event(&This
->node
, EVENTID_CLICK
, p
);
429 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
431 HTMLElement
*This
= HTMLELEM_THIS(iface
);
433 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
435 return set_node_event(&This
->node
, EVENTID_DBLCLICK
, &v
);
438 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
440 HTMLElement
*This
= HTMLELEM_THIS(iface
);
442 TRACE("(%p)->(%p)\n", This
, p
);
444 return get_node_event(&This
->node
, EVENTID_DBLCLICK
, p
);
447 static HRESULT WINAPI
HTMLElement_put_onkeydown(IHTMLElement
*iface
, VARIANT v
)
449 HTMLElement
*This
= HTMLELEM_THIS(iface
);
451 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
453 return set_node_event(&This
->node
, EVENTID_KEYDOWN
, &v
);
456 static HRESULT WINAPI
HTMLElement_get_onkeydown(IHTMLElement
*iface
, VARIANT
*p
)
458 HTMLElement
*This
= HTMLELEM_THIS(iface
);
460 TRACE("(%p)->(%p)\n", This
, p
);
462 return get_node_event(&This
->node
, EVENTID_KEYDOWN
, p
);
465 static HRESULT WINAPI
HTMLElement_put_onkeyup(IHTMLElement
*iface
, VARIANT v
)
467 HTMLElement
*This
= HTMLELEM_THIS(iface
);
469 TRACE("(%p)->()\n", This
);
471 return set_node_event(&This
->node
, EVENTID_KEYUP
, &v
);
474 static HRESULT WINAPI
HTMLElement_get_onkeyup(IHTMLElement
*iface
, VARIANT
*p
)
476 HTMLElement
*This
= HTMLELEM_THIS(iface
);
477 FIXME("(%p)->(%p)\n", This
, p
);
481 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
483 HTMLElement
*This
= HTMLELEM_THIS(iface
);
484 FIXME("(%p)->()\n", This
);
488 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
490 HTMLElement
*This
= HTMLELEM_THIS(iface
);
491 FIXME("(%p)->(%p)\n", This
, p
);
495 static HRESULT WINAPI
HTMLElement_put_onmouseout(IHTMLElement
*iface
, VARIANT v
)
497 HTMLElement
*This
= HTMLELEM_THIS(iface
);
499 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
501 return set_node_event(&This
->node
, EVENTID_MOUSEOUT
, &v
);
504 static HRESULT WINAPI
HTMLElement_get_onmouseout(IHTMLElement
*iface
, VARIANT
*p
)
506 HTMLElement
*This
= HTMLELEM_THIS(iface
);
508 TRACE("(%p)->(%p)\n", This
, p
);
510 return get_node_event(&This
->node
, EVENTID_MOUSEOUT
, p
);
513 static HRESULT WINAPI
HTMLElement_put_onmouseover(IHTMLElement
*iface
, VARIANT v
)
515 HTMLElement
*This
= HTMLELEM_THIS(iface
);
517 TRACE("(%p)->()\n", This
);
519 return set_node_event(&This
->node
, EVENTID_MOUSEOVER
, &v
);
522 static HRESULT WINAPI
HTMLElement_get_onmouseover(IHTMLElement
*iface
, VARIANT
*p
)
524 HTMLElement
*This
= HTMLELEM_THIS(iface
);
526 TRACE("(%p)->(%p)\n", This
, p
);
528 return get_node_event(&This
->node
, EVENTID_MOUSEOVER
, p
);
531 static HRESULT WINAPI
HTMLElement_put_onmousemove(IHTMLElement
*iface
, VARIANT v
)
533 HTMLElement
*This
= HTMLELEM_THIS(iface
);
534 FIXME("(%p)->()\n", This
);
538 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
540 HTMLElement
*This
= HTMLELEM_THIS(iface
);
541 FIXME("(%p)->(%p)\n", This
, p
);
545 static HRESULT WINAPI
HTMLElement_put_onmousedown(IHTMLElement
*iface
, VARIANT v
)
547 HTMLElement
*This
= HTMLELEM_THIS(iface
);
549 TRACE("(%p)->()\n", This
);
551 return set_node_event(&This
->node
, EVENTID_MOUSEDOWN
, &v
);
554 static HRESULT WINAPI
HTMLElement_get_onmousedown(IHTMLElement
*iface
, VARIANT
*p
)
556 HTMLElement
*This
= HTMLELEM_THIS(iface
);
558 TRACE("(%p)->(%p)\n", This
, p
);
560 return get_node_event(&This
->node
, EVENTID_MOUSEDOWN
, p
);
563 static HRESULT WINAPI
HTMLElement_put_onmouseup(IHTMLElement
*iface
, VARIANT v
)
565 HTMLElement
*This
= HTMLELEM_THIS(iface
);
567 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
569 return set_node_event(&This
->node
, EVENTID_MOUSEUP
, &v
);
572 static HRESULT WINAPI
HTMLElement_get_onmouseup(IHTMLElement
*iface
, VARIANT
*p
)
574 HTMLElement
*This
= HTMLELEM_THIS(iface
);
576 TRACE("(%p)->(%p)\n", This
, p
);
578 return get_node_event(&This
->node
, EVENTID_MOUSEUP
, p
);
581 static HRESULT WINAPI
HTMLElement_get_document(IHTMLElement
*iface
, IDispatch
**p
)
583 HTMLElement
*This
= HTMLELEM_THIS(iface
);
585 TRACE("(%p)->(%p)\n", This
, p
);
590 if(This
->node
.vtbl
->get_document
)
591 return This
->node
.vtbl
->get_document(&This
->node
, p
);
593 *p
= (IDispatch
*)HTMLDOC(&This
->node
.doc
->basedoc
);
594 IDispatch_AddRef(*p
);
598 static const WCHAR titleW
[] = {'t','i','t','l','e',0};
600 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
602 HTMLElement
*This
= HTMLELEM_THIS(iface
);
606 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
612 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, TRUE
, &var
);
618 V_BSTR(var
) = v
? SysAllocString(v
) : NULL
;
622 nsAString_InitDepend(&title_str
, v
);
623 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
624 nsAString_Finish(&title_str
);
626 ERR("SetTitle failed: %08x\n", nsres
);
631 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
633 HTMLElement
*This
= HTMLELEM_THIS(iface
);
637 TRACE("(%p)->(%p)\n", This
, p
);
643 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, FALSE
, &var
);
644 if(hres
== DISP_E_UNKNOWNNAME
) {
646 }else if(V_VT(var
) != VT_BSTR
) {
647 FIXME("title = %s\n", debugstr_variant(var
));
650 *p
= V_BSTR(var
) ? SysAllocString(V_BSTR(var
)) : NULL
;
656 nsAString_Init(&title_str
, NULL
);
657 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
658 if(NS_SUCCEEDED(nsres
)) {
659 const PRUnichar
*title
;
661 nsAString_GetData(&title_str
, &title
);
662 *p
= *title
? SysAllocString(title
) : NULL
;
664 ERR("GetTitle failed: %08x\n", nsres
);
671 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
673 HTMLElement
*This
= HTMLELEM_THIS(iface
);
674 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
678 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
680 HTMLElement
*This
= HTMLELEM_THIS(iface
);
681 FIXME("(%p)->(%p)\n", This
, p
);
685 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
687 HTMLElement
*This
= HTMLELEM_THIS(iface
);
689 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
691 return set_node_event(&This
->node
, EVENTID_SELECTSTART
, &v
);
694 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
696 HTMLElement
*This
= HTMLELEM_THIS(iface
);
698 TRACE("(%p)->(%p)\n", This
, p
);
700 return get_node_event(&This
->node
, EVENTID_SELECTSTART
, p
);
703 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
705 HTMLElement
*This
= HTMLELEM_THIS(iface
);
706 FIXME("(%p)->()\n", This
);
710 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
711 VARIANT_BOOL
*pfResult
)
713 HTMLElement
*This
= HTMLELEM_THIS(iface
);
714 FIXME("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
718 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, LONG
*p
)
720 HTMLElement
*This
= HTMLELEM_THIS(iface
);
721 FIXME("(%p)->(%p)\n", This
, p
);
725 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
727 HTMLElement
*This
= HTMLELEM_THIS(iface
);
728 FIXME("(%p)->(%p)\n", This
, p
);
732 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
734 HTMLElement
*This
= HTMLELEM_THIS(iface
);
735 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
739 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
741 HTMLElement
*This
= HTMLELEM_THIS(iface
);
742 FIXME("(%p)->(%p)\n", This
, p
);
746 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
748 HTMLElement
*This
= HTMLELEM_THIS(iface
);
749 FIXME("(%p)->(%p)\n", This
, p
);
753 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
755 HTMLElement
*This
= HTMLELEM_THIS(iface
);
756 nsIDOMNSHTMLElement
*nselem
;
760 TRACE("(%p)->(%p)\n", This
, p
);
762 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
763 if(NS_FAILED(nsres
)) {
764 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
768 nsres
= nsIDOMNSHTMLElement_GetOffsetTop(nselem
, &top
);
769 nsIDOMNSHTMLElement_Release(nselem
);
770 if(NS_FAILED(nsres
)) {
771 ERR("GetOffsetTop failed: %08x\n", nsres
);
779 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
781 HTMLElement
*This
= HTMLELEM_THIS(iface
);
782 nsIDOMNSHTMLElement
*nselem
;
786 TRACE("(%p)->(%p)\n", This
, p
);
788 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
789 if(NS_FAILED(nsres
)) {
790 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
794 nsres
= nsIDOMNSHTMLElement_GetOffsetWidth(nselem
, &offset
);
795 nsIDOMNSHTMLElement_Release(nselem
);
796 if(NS_FAILED(nsres
)) {
797 ERR("GetOffsetWidth failed: %08x\n", nsres
);
805 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
807 HTMLElement
*This
= HTMLELEM_THIS(iface
);
808 nsIDOMNSHTMLElement
*nselem
;
812 TRACE("(%p)->(%p)\n", This
, p
);
814 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
815 if(NS_FAILED(nsres
)) {
816 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
820 nsres
= nsIDOMNSHTMLElement_GetOffsetHeight(nselem
, &offset
);
821 nsIDOMNSHTMLElement_Release(nselem
);
822 if(NS_FAILED(nsres
)) {
823 ERR("GetOffsetHeight failed: %08x\n", nsres
);
831 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
833 HTMLElement
*This
= HTMLELEM_THIS(iface
);
834 FIXME("(%p)->(%p)\n", This
, p
);
838 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
840 HTMLElement
*This
= HTMLELEM_THIS(iface
);
841 nsIDOMNSHTMLElement
*nselem
;
845 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
848 FIXME("NULL nselem\n");
852 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
853 if(NS_FAILED(nsres
)) {
854 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
858 nsAString_InitDepend(&html_str
, v
);
859 nsres
= nsIDOMNSHTMLElement_SetInnerHTML(nselem
, &html_str
);
860 nsAString_Finish(&html_str
);
862 if(NS_FAILED(nsres
)) {
863 FIXME("SetInnerHtml failed %08x\n", nsres
);
870 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
872 HTMLElement
*This
= HTMLELEM_THIS(iface
);
873 nsIDOMNSHTMLElement
*nselem
;
877 TRACE("(%p)->(%p)\n", This
, p
);
880 FIXME("NULL nselem\n");
884 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
885 if(NS_FAILED(nsres
)) {
886 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
890 nsAString_Init(&html_str
, NULL
);
891 nsres
= nsIDOMNSHTMLElement_GetInnerHTML(nselem
, &html_str
);
892 if(NS_SUCCEEDED(nsres
)) {
893 const PRUnichar
*html
;
895 nsAString_GetData(&html_str
, &html
);
896 *p
= *html
? SysAllocString(html
) : NULL
;
898 FIXME("SetInnerHtml failed %08x\n", nsres
);
902 nsAString_Finish(&html_str
);
906 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
908 HTMLElement
*This
= HTMLELEM_THIS(iface
);
909 nsIDOMNode
*nschild
, *tmp
;
910 nsIDOMText
*text_node
;
914 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
917 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
918 if(NS_FAILED(nsres
)) {
919 ERR("GetLastChild failed: %08x\n", nsres
);
925 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
926 nsIDOMNode_Release(nschild
);
927 if(NS_FAILED(nsres
)) {
928 ERR("RemoveChild failed: %08x\n", nsres
);
931 nsIDOMNode_Release(tmp
);
934 nsAString_InitDepend(&text_str
, v
);
935 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
936 nsAString_Finish(&text_str
);
937 if(NS_FAILED(nsres
)) {
938 ERR("CreateTextNode failed: %08x\n", nsres
);
942 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
943 if(NS_FAILED(nsres
)) {
944 ERR("AppendChild failed: %08x\n", nsres
);
948 nsIDOMNode_Release(tmp
);
952 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
954 HTMLElement
*This
= HTMLELEM_THIS(iface
);
956 TRACE("(%p)->(%p)\n", This
, p
);
958 return get_node_text(&This
->node
, p
);
961 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
963 HTMLElement
*This
= HTMLELEM_THIS(iface
);
964 nsIDOMDocumentFragment
*nsfragment
;
965 nsIDOMDocumentRange
*nsdocrange
;
966 nsIDOMNSRange
*nsrange
;
967 nsIDOMNode
*nsparent
;
973 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
975 nsres
= nsIDOMHTMLDocument_QueryInterface(This
->node
.doc
->nsdoc
, &IID_nsIDOMDocumentRange
, (void**)&nsdocrange
);
979 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
980 nsIDOMDocumentRange_Release(nsdocrange
);
981 if(NS_FAILED(nsres
)) {
982 ERR("CreateRange failed: %08x\n", nsres
);
986 nsres
= nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void**)&nsrange
);
987 nsIDOMRange_Release(range
);
988 if(NS_FAILED(nsres
)) {
989 ERR("Could not get nsIDOMNSRange: %08x\n", nsres
);
993 nsAString_InitDepend(&html_str
, v
);
994 nsIDOMNSRange_CreateContextualFragment(nsrange
, &html_str
, &nsfragment
);
995 nsIDOMNSRange_Release(nsrange
);
996 nsAString_Finish(&html_str
);
997 if(NS_FAILED(nsres
)) {
998 ERR("CreateContextualFragment failed: %08x\n", nsres
);
1002 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &nsparent
);
1003 if(NS_SUCCEEDED(nsres
) && nsparent
) {
1006 nsres
= nsIDOMNode_ReplaceChild(nsparent
, (nsIDOMNode
*)nsfragment
, This
->node
.nsnode
, &nstmp
);
1007 nsIDOMNode_Release(nsparent
);
1008 if(NS_FAILED(nsres
)) {
1009 ERR("ReplaceChild failed: %08x\n", nsres
);
1012 nsIDOMNode_Release(nstmp
);
1015 ERR("GetParentNode failed: %08x\n", nsres
);
1019 nsIDOMDocumentFragment_Release(nsfragment
);
1023 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
1025 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1029 WARN("(%p)->(%p) semi-stub\n", This
, p
);
1031 nsAString_Init(&html_str
, NULL
);
1032 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
1033 if(SUCCEEDED(hres
)) {
1034 const PRUnichar
*html
;
1036 nsAString_GetData(&html_str
, &html
);
1037 *p
= SysAllocString(html
);
1039 hres
= E_OUTOFMEMORY
;
1042 nsAString_Finish(&html_str
);
1044 TRACE("ret %s\n", debugstr_w(*p
));
1048 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
1050 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1051 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1055 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
1057 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1058 FIXME("(%p)->(%p)\n", This
, p
);
1062 static HRESULT
HTMLElement_InsertAdjacentNode(HTMLElement
*This
, BSTR where
, nsIDOMNode
*nsnode
)
1064 static const WCHAR wszBeforeBegin
[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1065 static const WCHAR wszAfterBegin
[] = {'a','f','t','e','r','B','e','g','i','n',0};
1066 static const WCHAR wszBeforeEnd
[] = {'b','e','f','o','r','e','E','n','d',0};
1067 static const WCHAR wszAfterEnd
[] = {'a','f','t','e','r','E','n','d',0};
1070 if (!strcmpiW(where
, wszBeforeBegin
))
1074 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1075 if (!parent
) return E_INVALIDARG
;
1076 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, This
->node
.nsnode
, &unused
);
1077 if (unused
) nsIDOMNode_Release(unused
);
1078 nsIDOMNode_Release(parent
);
1080 else if (!strcmpiW(where
, wszAfterBegin
))
1083 nsIDOMNode
*first_child
;
1084 nsIDOMNode_GetFirstChild(This
->node
.nsnode
, &first_child
);
1085 nsres
= nsIDOMNode_InsertBefore(This
->node
.nsnode
, nsnode
, first_child
, &unused
);
1086 if (unused
) nsIDOMNode_Release(unused
);
1087 if (first_child
) nsIDOMNode_Release(first_child
);
1089 else if (!strcmpiW(where
, wszBeforeEnd
))
1092 nsres
= nsIDOMNode_AppendChild(This
->node
.nsnode
, nsnode
, &unused
);
1093 if (unused
) nsIDOMNode_Release(unused
);
1095 else if (!strcmpiW(where
, wszAfterEnd
))
1098 nsIDOMNode
*next_sibling
;
1100 nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1101 if (!parent
) return E_INVALIDARG
;
1103 nsIDOMNode_GetNextSibling(This
->node
.nsnode
, &next_sibling
);
1106 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &unused
);
1107 nsIDOMNode_Release(next_sibling
);
1110 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &unused
);
1111 nsIDOMNode_Release(parent
);
1112 if (unused
) nsIDOMNode_Release(unused
);
1116 ERR("invalid where: %s\n", debugstr_w(where
));
1117 return E_INVALIDARG
;
1120 if (NS_FAILED(nsres
))
1126 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1129 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1130 nsIDOMDocumentRange
*nsdocrange
;
1132 nsIDOMNSRange
*nsrange
;
1138 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1140 if(!This
->node
.doc
->nsdoc
) {
1141 WARN("NULL nsdoc\n");
1142 return E_UNEXPECTED
;
1145 nsres
= nsIDOMDocument_QueryInterface(This
->node
.doc
->nsdoc
, &IID_nsIDOMDocumentRange
, (void **)&nsdocrange
);
1146 if(NS_FAILED(nsres
))
1148 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres
);
1151 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
1152 nsIDOMDocumentRange_Release(nsdocrange
);
1153 if(NS_FAILED(nsres
))
1155 ERR("CreateRange failed: %08x\n", nsres
);
1159 nsIDOMRange_SetStartBefore(range
, This
->node
.nsnode
);
1161 nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void **)&nsrange
);
1162 nsIDOMRange_Release(range
);
1163 if(NS_FAILED(nsres
))
1165 ERR("getting nsIDOMNSRange failed: %08x\n", nsres
);
1169 nsAString_InitDepend(&ns_html
, html
);
1171 nsres
= nsIDOMNSRange_CreateContextualFragment(nsrange
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1172 nsIDOMNSRange_Release(nsrange
);
1173 nsAString_Finish(&ns_html
);
1175 if(NS_FAILED(nsres
) || !nsnode
)
1177 ERR("CreateTextNode failed: %08x\n", nsres
);
1181 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1182 nsIDOMNode_Release(nsnode
);
1187 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1190 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1196 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1198 if(!This
->node
.doc
->nsdoc
) {
1199 WARN("NULL nsdoc\n");
1200 return E_UNEXPECTED
;
1204 nsAString_InitDepend(&ns_text
, text
);
1205 nsres
= nsIDOMDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1206 nsAString_Finish(&ns_text
);
1208 if(NS_FAILED(nsres
) || !nsnode
)
1210 ERR("CreateTextNode failed: %08x\n", nsres
);
1214 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1215 nsIDOMNode_Release(nsnode
);
1220 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1222 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1223 FIXME("(%p)->(%p)\n", This
, p
);
1227 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1229 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1230 FIXME("(%p)->(%p)\n", This
, p
);
1234 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1236 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1238 TRACE("(%p)\n", This
);
1240 return call_event(&This
->node
, EVENTID_CLICK
);
1243 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1244 IHTMLFiltersCollection
**p
)
1246 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1247 TRACE("(%p)->(%p)\n", This
, p
);
1252 *p
= HTMLFiltersCollection_Create();
1257 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1259 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1260 FIXME("(%p)->()\n", This
);
1264 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1266 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1267 FIXME("(%p)->(%p)\n", This
, p
);
1271 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1273 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1274 FIXME("(%p)->(%p)\n", This
, String
);
1278 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1280 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1281 FIXME("(%p)->()\n", This
);
1285 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1287 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1288 FIXME("(%p)->(%p)\n", This
, p
);
1292 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1294 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1295 FIXME("(%p)->()\n", This
);
1299 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1301 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1302 FIXME("(%p)->(%p)\n", This
, p
);
1306 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1308 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1309 FIXME("(%p)->()\n", This
);
1313 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1315 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1316 FIXME("(%p)->(%p)\n", This
, p
);
1320 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1322 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1323 FIXME("(%p)->()\n", This
);
1327 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1329 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1330 FIXME("(%p)->(%p)\n", This
, p
);
1334 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1336 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1337 FIXME("(%p)->()\n", This
);
1341 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1343 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1344 FIXME("(%p)->(%p)\n", This
, p
);
1348 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1350 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1351 FIXME("(%p)->()\n", This
);
1355 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1357 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1358 FIXME("(%p)->(%p)\n", This
, p
);
1362 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1364 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1365 FIXME("(%p)->()\n", This
);
1369 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1371 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1372 FIXME("(%p)->(%p)\n", This
, p
);
1376 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1378 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1379 FIXME("(%p)->()\n", This
);
1383 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1385 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1386 FIXME("(%p)->(%p)\n", This
, p
);
1390 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1392 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1393 FIXME("(%p)->()\n", This
);
1397 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1399 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1400 FIXME("(%p)->(%p)\n", This
, p
);
1404 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1406 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1407 nsIDOMNodeList
*nsnode_list
;
1410 TRACE("(%p)->(%p)\n", This
, p
);
1412 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1413 if(NS_FAILED(nsres
)) {
1414 ERR("GetChildNodes failed: %08x\n", nsres
);
1418 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, (IUnknown
*)HTMLELEM(This
), nsnode_list
);
1420 nsIDOMNodeList_Release(nsnode_list
);
1424 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1426 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1428 TRACE("(%p)->(%p)\n", This
, p
);
1430 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1434 static HRESULT
HTMLElement_get_dispid(IUnknown
*iface
, BSTR name
,
1435 DWORD grfdex
, DISPID
*pid
)
1437 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1439 if(This
->node
.vtbl
->get_dispid
)
1440 return This
->node
.vtbl
->get_dispid(&This
->node
, name
, grfdex
, pid
);
1442 return DISP_E_UNKNOWNNAME
;
1445 static HRESULT
HTMLElement_invoke(IUnknown
*iface
, DISPID id
, LCID lcid
,
1446 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
1447 IServiceProvider
*caller
)
1449 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1451 if(This
->node
.vtbl
->invoke
)
1452 return This
->node
.vtbl
->invoke(&This
->node
, id
, lcid
, flags
,
1453 params
, res
, ei
, caller
);
1455 ERR("(%p): element has no invoke method\n", This
);
1459 #undef HTMLELEM_THIS
1461 static const IHTMLElementVtbl HTMLElementVtbl
= {
1462 HTMLElement_QueryInterface
,
1464 HTMLElement_Release
,
1465 HTMLElement_GetTypeInfoCount
,
1466 HTMLElement_GetTypeInfo
,
1467 HTMLElement_GetIDsOfNames
,
1469 HTMLElement_setAttribute
,
1470 HTMLElement_getAttribute
,
1471 HTMLElement_removeAttribute
,
1472 HTMLElement_put_className
,
1473 HTMLElement_get_className
,
1476 HTMLElement_get_tagName
,
1477 HTMLElement_get_parentElement
,
1478 HTMLElement_get_style
,
1479 HTMLElement_put_onhelp
,
1480 HTMLElement_get_onhelp
,
1481 HTMLElement_put_onclick
,
1482 HTMLElement_get_onclick
,
1483 HTMLElement_put_ondblclick
,
1484 HTMLElement_get_ondblclick
,
1485 HTMLElement_put_onkeydown
,
1486 HTMLElement_get_onkeydown
,
1487 HTMLElement_put_onkeyup
,
1488 HTMLElement_get_onkeyup
,
1489 HTMLElement_put_onkeypress
,
1490 HTMLElement_get_onkeypress
,
1491 HTMLElement_put_onmouseout
,
1492 HTMLElement_get_onmouseout
,
1493 HTMLElement_put_onmouseover
,
1494 HTMLElement_get_onmouseover
,
1495 HTMLElement_put_onmousemove
,
1496 HTMLElement_get_onmousemove
,
1497 HTMLElement_put_onmousedown
,
1498 HTMLElement_get_onmousedown
,
1499 HTMLElement_put_onmouseup
,
1500 HTMLElement_get_onmouseup
,
1501 HTMLElement_get_document
,
1502 HTMLElement_put_title
,
1503 HTMLElement_get_title
,
1504 HTMLElement_put_language
,
1505 HTMLElement_get_language
,
1506 HTMLElement_put_onselectstart
,
1507 HTMLElement_get_onselectstart
,
1508 HTMLElement_scrollIntoView
,
1509 HTMLElement_contains
,
1510 HTMLElement_get_sourceIndex
,
1511 HTMLElement_get_recordNumber
,
1512 HTMLElement_put_lang
,
1513 HTMLElement_get_lang
,
1514 HTMLElement_get_offsetLeft
,
1515 HTMLElement_get_offsetTop
,
1516 HTMLElement_get_offsetWidth
,
1517 HTMLElement_get_offsetHeight
,
1518 HTMLElement_get_offsetParent
,
1519 HTMLElement_put_innerHTML
,
1520 HTMLElement_get_innerHTML
,
1521 HTMLElement_put_innerText
,
1522 HTMLElement_get_innerText
,
1523 HTMLElement_put_outerHTML
,
1524 HTMLElement_get_outerHTML
,
1525 HTMLElement_put_outerText
,
1526 HTMLElement_get_outerText
,
1527 HTMLElement_insertAdjacentHTML
,
1528 HTMLElement_insertAdjacentText
,
1529 HTMLElement_get_parentTextEdit
,
1530 HTMLElement_get_isTextEdit
,
1532 HTMLElement_get_filters
,
1533 HTMLElement_put_ondragstart
,
1534 HTMLElement_get_ondragstart
,
1535 HTMLElement_toString
,
1536 HTMLElement_put_onbeforeupdate
,
1537 HTMLElement_get_onbeforeupdate
,
1538 HTMLElement_put_onafterupdate
,
1539 HTMLElement_get_onafterupdate
,
1540 HTMLElement_put_onerrorupdate
,
1541 HTMLElement_get_onerrorupdate
,
1542 HTMLElement_put_onrowexit
,
1543 HTMLElement_get_onrowexit
,
1544 HTMLElement_put_onrowenter
,
1545 HTMLElement_get_onrowenter
,
1546 HTMLElement_put_ondatasetchanged
,
1547 HTMLElement_get_ondatasetchanged
,
1548 HTMLElement_put_ondataavailable
,
1549 HTMLElement_get_ondataavailable
,
1550 HTMLElement_put_ondatasetcomplete
,
1551 HTMLElement_get_ondatasetcomplete
,
1552 HTMLElement_put_onfilterchange
,
1553 HTMLElement_get_onfilterchange
,
1554 HTMLElement_get_children
,
1558 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1560 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1564 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1565 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1566 *ppv
= HTMLELEM(This
);
1567 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1568 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1569 *ppv
= HTMLELEM(This
);
1570 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1571 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
1572 *ppv
= HTMLELEM(This
);
1573 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1574 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
1575 *ppv
= HTMLELEM2(This
);
1576 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1577 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This
, ppv
);
1578 *ppv
= HTMLELEM3(This
);
1579 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1580 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1581 *ppv
= CONPTCONT(&This
->cp_container
);
1585 IHTMLElement_AddRef(HTMLELEM(This
));
1589 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1592 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1594 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1596 ConnectionPointContainer_Destroy(&This
->cp_container
);
1599 nsIDOMHTMLElement_Release(This
->nselem
);
1601 HTMLDOMNode_destructor(&This
->node
);
1604 static const NodeImplVtbl HTMLElementImplVtbl
= {
1606 HTMLElement_destructor
1609 static const tid_t HTMLElement_iface_tids
[] = {
1614 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl
= {
1616 HTMLElement_get_dispid
,
1620 static dispex_static_data_t HTMLElement_dispex
= {
1621 &HTMLElement_dispex_vtbl
,
1622 DispHTMLUnknownElement_tid
,
1624 HTMLElement_iface_tids
1627 void HTMLElement_Init(HTMLElement
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, dispex_static_data_t
*dispex_data
)
1629 This
->lpHTMLElementVtbl
= &HTMLElementVtbl
;
1631 HTMLElement2_Init(This
);
1632 HTMLElement3_Init(This
);
1634 if(dispex_data
&& !dispex_data
->vtbl
)
1635 dispex_data
->vtbl
= &HTMLElement_dispex_vtbl
;
1636 init_dispex(&This
->node
.dispex
, (IUnknown
*)HTMLELEM(This
), dispex_data
? dispex_data
: &HTMLElement_dispex
);
1639 nsIDOMHTMLElement_AddRef(nselem
);
1640 This
->nselem
= nselem
;
1642 HTMLDOMNode_Init(doc
, &This
->node
, (nsIDOMNode
*)nselem
);
1644 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)HTMLELEM(This
));
1647 HTMLElement
*HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
)
1649 nsIDOMHTMLElement
*nselem
;
1650 HTMLElement
*ret
= NULL
;
1651 nsAString class_name_str
;
1652 const PRUnichar
*class_name
;
1655 static const WCHAR wszA
[] = {'A',0};
1656 static const WCHAR wszBODY
[] = {'B','O','D','Y',0};
1657 static const WCHAR wszFORM
[] = {'F','O','R','M',0};
1658 static const WCHAR wszFRAME
[] = {'F','R','A','M','E',0};
1659 static const WCHAR wszIFRAME
[] = {'I','F','R','A','M','E',0};
1660 static const WCHAR wszIMG
[] = {'I','M','G',0};
1661 static const WCHAR wszINPUT
[] = {'I','N','P','U','T',0};
1662 static const WCHAR wszOPTION
[] = {'O','P','T','I','O','N',0};
1663 static const WCHAR wszSCRIPT
[] = {'S','C','R','I','P','T',0};
1664 static const WCHAR wszSELECT
[] = {'S','E','L','E','C','T',0};
1665 static const WCHAR wszTABLE
[] = {'T','A','B','L','E',0};
1666 static const WCHAR wszTR
[] = {'T','R',0};
1667 static const WCHAR wszTEXTAREA
[] = {'T','E','X','T','A','R','E','A',0};
1669 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1670 if(NS_FAILED(nsres
))
1673 nsAString_Init(&class_name_str
, NULL
);
1674 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1676 nsAString_GetData(&class_name_str
, &class_name
);
1678 if(!strcmpW(class_name
, wszA
))
1679 ret
= HTMLAnchorElement_Create(doc
, nselem
);
1680 else if(!strcmpW(class_name
, wszBODY
))
1681 ret
= HTMLBodyElement_Create(doc
, nselem
);
1682 else if(!strcmpW(class_name
, wszFORM
))
1683 ret
= HTMLFormElement_Create(doc
, nselem
);
1684 else if(!strcmpW(class_name
, wszFRAME
))
1685 ret
= HTMLFrameElement_Create(doc
, nselem
);
1686 else if(!strcmpW(class_name
, wszIFRAME
))
1687 ret
= HTMLIFrame_Create(doc
, nselem
);
1688 else if(!strcmpW(class_name
, wszIMG
))
1689 ret
= HTMLImgElement_Create(doc
, nselem
);
1690 else if(!strcmpW(class_name
, wszINPUT
))
1691 ret
= HTMLInputElement_Create(doc
, nselem
);
1692 else if(!strcmpW(class_name
, wszOPTION
))
1693 ret
= HTMLOptionElement_Create(doc
, nselem
);
1694 else if(!strcmpW(class_name
, wszSCRIPT
))
1695 ret
= HTMLScriptElement_Create(doc
, nselem
);
1696 else if(!strcmpW(class_name
, wszSELECT
))
1697 ret
= HTMLSelectElement_Create(doc
, nselem
);
1698 else if(!strcmpW(class_name
, wszTABLE
))
1699 ret
= HTMLTable_Create(doc
, nselem
);
1700 else if(!strcmpW(class_name
, wszTR
))
1701 ret
= HTMLTableRow_Create(doc
, nselem
);
1702 else if(!strcmpW(class_name
, wszTEXTAREA
))
1703 ret
= HTMLTextAreaElement_Create(doc
, nselem
);
1704 else if(use_generic
)
1705 ret
= HTMLGenericElement_Create(doc
, nselem
);
1708 ret
= heap_alloc_zero(sizeof(HTMLElement
));
1709 HTMLElement_Init(ret
, doc
, nselem
, &HTMLElement_dispex
);
1710 ret
->node
.vtbl
= &HTMLElementImplVtbl
;
1713 TRACE("%s ret %p\n", debugstr_w(class_name
), ret
);
1715 nsIDOMElement_Release(nselem
);
1716 nsAString_Finish(&class_name_str
);
1721 /* interface IHTMLFiltersCollection */
1722 static HRESULT WINAPI
HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection
*iface
, REFIID riid
, void **ppv
)
1724 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1726 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
1728 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1729 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1730 *ppv
= HTMLFILTERSCOLLECTION(This
);
1731 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection
, riid
)) {
1732 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This
, ppv
);
1733 *ppv
= HTMLFILTERSCOLLECTION(This
);
1734 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
1735 return *ppv
? S_OK
: E_NOINTERFACE
;
1739 IUnknown_AddRef((IUnknown
*)*ppv
);
1743 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1744 return E_NOINTERFACE
;
1747 static ULONG WINAPI
HTMLFiltersCollection_AddRef(IHTMLFiltersCollection
*iface
)
1749 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1750 LONG ref
= InterlockedIncrement(&This
->ref
);
1752 TRACE("(%p) ref=%d\n", This
, ref
);
1757 static ULONG WINAPI
HTMLFiltersCollection_Release(IHTMLFiltersCollection
*iface
)
1759 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1760 LONG ref
= InterlockedDecrement(&This
->ref
);
1762 TRACE("(%p) ref=%d\n", This
, ref
);
1772 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection
*iface
, UINT
*pctinfo
)
1774 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1775 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->dispex
), pctinfo
);
1778 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection
*iface
,
1779 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1781 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1782 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->dispex
), iTInfo
, lcid
, ppTInfo
);
1785 static HRESULT WINAPI
HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection
*iface
,
1786 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
,
1787 LCID lcid
, DISPID
*rgDispId
)
1789 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1790 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1793 static HRESULT WINAPI
HTMLFiltersCollection_Invoke(IHTMLFiltersCollection
*iface
, DISPID dispIdMember
, REFIID riid
,
1794 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
1795 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1797 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1798 return IDispatchEx_Invoke(DISPATCHEX(&This
->dispex
), dispIdMember
, riid
, lcid
,
1799 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1802 static HRESULT WINAPI
HTMLFiltersCollection_get_length(IHTMLFiltersCollection
*iface
, LONG
*p
)
1804 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1809 FIXME("(%p)->(%p) Always returning 0\n", This
, p
);
1815 static HRESULT WINAPI
HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection
*iface
, IUnknown
**p
)
1817 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1818 FIXME("(%p)->(%p)\n", This
, p
);
1822 static HRESULT WINAPI
HTMLFiltersCollection_item(IHTMLFiltersCollection
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
1824 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1825 FIXME("(%p)->(%p, %p)\n", This
, pvarIndex
, pvarResult
);
1829 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl
= {
1830 HTMLFiltersCollection_QueryInterface
,
1831 HTMLFiltersCollection_AddRef
,
1832 HTMLFiltersCollection_Release
,
1833 HTMLFiltersCollection_GetTypeInfoCount
,
1834 HTMLFiltersCollection_GetTypeInfo
,
1835 HTMLFiltersCollection_GetIDsOfNames
,
1836 HTMLFiltersCollection_Invoke
,
1837 HTMLFiltersCollection_get_length
,
1838 HTMLFiltersCollection_get__newEnum
,
1839 HTMLFiltersCollection_item
1842 static HRESULT
HTMLFiltersCollection_get_dispid(IUnknown
*iface
, BSTR name
, DWORD flags
, DISPID
*dispid
)
1847 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
1848 idx
= idx
*10 + (*ptr
-'0');
1850 return DISP_E_UNKNOWNNAME
;
1852 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
1853 TRACE("ret %x\n", *dispid
);
1857 static HRESULT
HTMLFiltersCollection_invoke(IUnknown
*iface
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
1858 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
1860 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1862 TRACE("(%p)->(%x %x %x %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
);
1864 V_VT(res
) = VT_DISPATCH
;
1865 V_DISPATCH(res
) = NULL
;
1867 FIXME("always returning NULL\n");
1872 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl
= {
1874 HTMLFiltersCollection_get_dispid
,
1875 HTMLFiltersCollection_invoke
1878 static const tid_t HTMLFiltersCollection_iface_tids
[] = {
1879 IHTMLFiltersCollection_tid
,
1882 static dispex_static_data_t HTMLFiltersCollection_dispex
= {
1883 &HTMLFiltersCollection_dispex_vtbl
,
1884 IHTMLFiltersCollection_tid
,
1886 HTMLFiltersCollection_iface_tids
1889 IHTMLFiltersCollection
*HTMLFiltersCollection_Create()
1891 HTMLFiltersCollection
*ret
= heap_alloc(sizeof(HTMLFiltersCollection
));
1893 ret
->lpHTMLFiltersCollectionVtbl
= &HTMLFiltersCollectionVtbl
;
1896 init_dispex(&ret
->dispex
, (IUnknown
*)HTMLFILTERSCOLLECTION(ret
), &HTMLFiltersCollection_dispex
);
1898 return HTMLFILTERSCOLLECTION(ret
);