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_Init(&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
);
201 FIXME("(%p)->()\n", This
);
205 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
207 HTMLElement
*This
= HTMLELEM_THIS(iface
);
208 nsAString classname_str
;
211 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
214 FIXME("NULL nselem\n");
218 nsAString_Init(&classname_str
, v
);
219 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
220 nsAString_Finish(&classname_str
);
222 ERR("SetClassName failed: %08x\n", nsres
);
227 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
229 HTMLElement
*This
= HTMLELEM_THIS(iface
);
234 TRACE("(%p)->(%p)\n", This
, p
);
237 FIXME("NULL nselem\n");
241 nsAString_Init(&class_str
, NULL
);
242 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
244 if(NS_SUCCEEDED(nsres
)) {
245 const PRUnichar
*class;
246 nsAString_GetData(&class_str
, &class);
247 *p
= *class ? SysAllocString(class) : NULL
;
249 ERR("GetClassName failed: %08x\n", nsres
);
253 nsAString_Finish(&class_str
);
255 TRACE("className=%s\n", debugstr_w(*p
));
259 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
261 HTMLElement
*This
= HTMLELEM_THIS(iface
);
265 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
268 FIXME("nselem == NULL\n");
272 nsAString_Init(&id_str
, v
);
273 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
274 nsAString_Finish(&id_str
);
276 ERR("SetId failed: %08x\n", nsres
);
281 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
283 HTMLElement
*This
= HTMLELEM_THIS(iface
);
288 TRACE("(%p)->(%p)\n", This
, p
);
295 nsAString_Init(&id_str
, NULL
);
296 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
297 nsAString_GetData(&id_str
, &id
);
300 ERR("GetId failed: %08x\n", nsres
);
302 *p
= SysAllocString(id
);
304 nsAString_Finish(&id_str
);
308 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
310 HTMLElement
*This
= HTMLELEM_THIS(iface
);
311 const PRUnichar
*tag
;
315 TRACE("(%p)->(%p)\n", This
, p
);
318 static const WCHAR comment_tagW
[] = {'!',0};
320 WARN("NULL nselem, assuming comment\n");
322 *p
= SysAllocString(comment_tagW
);
326 nsAString_Init(&tag_str
, NULL
);
327 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
328 if(NS_SUCCEEDED(nsres
)) {
329 nsAString_GetData(&tag_str
, &tag
);
330 *p
= SysAllocString(tag
);
332 ERR("GetTagName failed: %08x\n", nsres
);
335 nsAString_Finish(&tag_str
);
340 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
342 HTMLElement
*This
= HTMLELEM_THIS(iface
);
346 TRACE("(%p)->(%p)\n", This
, p
);
348 hres
= IHTMLDOMNode_get_parentNode(HTMLDOMNODE(&This
->node
), &node
);
352 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
353 IHTMLDOMNode_Release(node
);
360 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
362 HTMLElement
*This
= HTMLELEM_THIS(iface
);
363 nsIDOMElementCSSInlineStyle
*nselemstyle
;
364 nsIDOMCSSStyleDeclaration
*nsstyle
;
367 TRACE("(%p)->(%p)\n", This
, p
);
370 FIXME("NULL nselem\n");
374 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMElementCSSInlineStyle
,
375 (void**)&nselemstyle
);
376 if(NS_FAILED(nsres
)) {
377 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres
);
381 nsres
= nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle
, &nsstyle
);
382 nsIDOMElementCSSInlineStyle_Release(nselemstyle
);
383 if(NS_FAILED(nsres
)) {
384 ERR("GetStyle failed: %08x\n", nsres
);
388 /* FIXME: Store style instead of creating a new instance in each call */
389 *p
= HTMLStyle_Create(nsstyle
);
391 nsIDOMCSSStyleDeclaration_Release(nsstyle
);
395 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
397 HTMLElement
*This
= HTMLELEM_THIS(iface
);
398 FIXME("(%p)->()\n", This
);
402 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
404 HTMLElement
*This
= HTMLELEM_THIS(iface
);
405 FIXME("(%p)->(%p)\n", This
, p
);
409 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
411 HTMLElement
*This
= HTMLELEM_THIS(iface
);
413 TRACE("(%p)->()\n", This
);
415 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
418 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
420 HTMLElement
*This
= HTMLELEM_THIS(iface
);
422 TRACE("(%p)->(%p)\n", This
, p
);
424 return get_node_event(&This
->node
, EVENTID_CLICK
, p
);
427 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
429 HTMLElement
*This
= HTMLELEM_THIS(iface
);
431 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
433 return set_node_event(&This
->node
, EVENTID_DBLCLICK
, &v
);
436 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
438 HTMLElement
*This
= HTMLELEM_THIS(iface
);
440 TRACE("(%p)->(%p)\n", This
, p
);
442 return get_node_event(&This
->node
, EVENTID_DBLCLICK
, p
);
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
);
479 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
481 HTMLElement
*This
= HTMLELEM_THIS(iface
);
482 FIXME("(%p)->()\n", This
);
486 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
488 HTMLElement
*This
= HTMLELEM_THIS(iface
);
489 FIXME("(%p)->(%p)\n", This
, p
);
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
);
536 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
538 HTMLElement
*This
= HTMLELEM_THIS(iface
);
539 FIXME("(%p)->(%p)\n", This
, p
);
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
);
588 if(This
->node
.vtbl
->get_document
)
589 return This
->node
.vtbl
->get_document(&This
->node
, p
);
591 *p
= (IDispatch
*)HTMLDOC(&This
->node
.doc
->basedoc
);
592 IDispatch_AddRef(*p
);
596 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
598 HTMLElement
*This
= HTMLELEM_THIS(iface
);
602 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
604 nsAString_Init(&title_str
, v
);
605 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
606 nsAString_Finish(&title_str
);
608 ERR("SetTitle failed: %08x\n", nsres
);
613 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
615 HTMLElement
*This
= HTMLELEM_THIS(iface
);
619 TRACE("(%p)->(%p)\n", This
, p
);
621 nsAString_Init(&title_str
, NULL
);
622 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
623 if(NS_SUCCEEDED(nsres
)) {
624 const PRUnichar
*title
;
626 nsAString_GetData(&title_str
, &title
);
627 *p
= *title
? SysAllocString(title
) : NULL
;
629 ERR("GetTitle failed: %08x\n", nsres
);
636 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
638 HTMLElement
*This
= HTMLELEM_THIS(iface
);
639 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
643 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
645 HTMLElement
*This
= HTMLELEM_THIS(iface
);
646 FIXME("(%p)->(%p)\n", This
, p
);
650 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
652 HTMLElement
*This
= HTMLELEM_THIS(iface
);
654 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
656 return set_node_event(&This
->node
, EVENTID_SELECTSTART
, &v
);
659 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
661 HTMLElement
*This
= HTMLELEM_THIS(iface
);
663 TRACE("(%p)->(%p)\n", This
, p
);
665 return get_node_event(&This
->node
, EVENTID_SELECTSTART
, p
);
668 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
670 HTMLElement
*This
= HTMLELEM_THIS(iface
);
671 FIXME("(%p)->()\n", This
);
675 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
676 VARIANT_BOOL
*pfResult
)
678 HTMLElement
*This
= HTMLELEM_THIS(iface
);
679 FIXME("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
683 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, LONG
*p
)
685 HTMLElement
*This
= HTMLELEM_THIS(iface
);
686 FIXME("(%p)->(%p)\n", This
, p
);
690 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
692 HTMLElement
*This
= HTMLELEM_THIS(iface
);
693 FIXME("(%p)->(%p)\n", This
, p
);
697 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
699 HTMLElement
*This
= HTMLELEM_THIS(iface
);
700 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
704 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
706 HTMLElement
*This
= HTMLELEM_THIS(iface
);
707 FIXME("(%p)->(%p)\n", This
, p
);
711 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
713 HTMLElement
*This
= HTMLELEM_THIS(iface
);
714 FIXME("(%p)->(%p)\n", This
, p
);
718 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
720 HTMLElement
*This
= HTMLELEM_THIS(iface
);
721 nsIDOMNSHTMLElement
*nselem
;
725 TRACE("(%p)->(%p)\n", This
, p
);
727 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
728 if(NS_FAILED(nsres
)) {
729 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
733 nsres
= nsIDOMNSHTMLElement_GetOffsetTop(nselem
, &top
);
734 nsIDOMNSHTMLElement_Release(nselem
);
735 if(NS_FAILED(nsres
)) {
736 ERR("GetOffsetTop failed: %08x\n", nsres
);
744 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
746 HTMLElement
*This
= HTMLELEM_THIS(iface
);
747 nsIDOMNSHTMLElement
*nselem
;
751 TRACE("(%p)->(%p)\n", This
, p
);
753 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
754 if(NS_FAILED(nsres
)) {
755 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
759 nsres
= nsIDOMNSHTMLElement_GetOffsetWidth(nselem
, &offset
);
760 nsIDOMNSHTMLElement_Release(nselem
);
761 if(NS_FAILED(nsres
)) {
762 ERR("GetOffsetWidth failed: %08x\n", nsres
);
770 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
772 HTMLElement
*This
= HTMLELEM_THIS(iface
);
773 nsIDOMNSHTMLElement
*nselem
;
777 TRACE("(%p)->(%p)\n", This
, p
);
779 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
780 if(NS_FAILED(nsres
)) {
781 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
785 nsres
= nsIDOMNSHTMLElement_GetOffsetHeight(nselem
, &offset
);
786 nsIDOMNSHTMLElement_Release(nselem
);
787 if(NS_FAILED(nsres
)) {
788 ERR("GetOffsetHeight failed: %08x\n", nsres
);
796 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
798 HTMLElement
*This
= HTMLELEM_THIS(iface
);
799 FIXME("(%p)->(%p)\n", This
, p
);
803 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
805 HTMLElement
*This
= HTMLELEM_THIS(iface
);
806 nsIDOMNSHTMLElement
*nselem
;
810 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
813 FIXME("NULL nselem\n");
817 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
818 if(NS_FAILED(nsres
)) {
819 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
823 nsAString_Init(&html_str
, v
);
824 nsres
= nsIDOMNSHTMLElement_SetInnerHTML(nselem
, &html_str
);
825 nsAString_Finish(&html_str
);
827 if(NS_FAILED(nsres
)) {
828 FIXME("SetInnerHtml failed %08x\n", nsres
);
835 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
837 HTMLElement
*This
= HTMLELEM_THIS(iface
);
838 nsIDOMNSHTMLElement
*nselem
;
842 TRACE("(%p)->(%p)\n", This
, p
);
845 FIXME("NULL nselem\n");
849 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
850 if(NS_FAILED(nsres
)) {
851 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
855 nsAString_Init(&html_str
, NULL
);
856 nsres
= nsIDOMNSHTMLElement_GetInnerHTML(nselem
, &html_str
);
857 if(NS_SUCCEEDED(nsres
)) {
858 const PRUnichar
*html
;
860 nsAString_GetData(&html_str
, &html
);
861 *p
= *html
? SysAllocString(html
) : NULL
;
863 FIXME("SetInnerHtml failed %08x\n", nsres
);
867 nsAString_Finish(&html_str
);
871 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
873 HTMLElement
*This
= HTMLELEM_THIS(iface
);
874 nsIDOMNode
*nschild
, *tmp
;
875 nsIDOMText
*text_node
;
879 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
882 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
883 if(NS_FAILED(nsres
)) {
884 ERR("GetLastChild failed: %08x\n", nsres
);
890 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
891 nsIDOMNode_Release(nschild
);
892 if(NS_FAILED(nsres
)) {
893 ERR("RemoveChild failed: %08x\n", nsres
);
896 nsIDOMNode_Release(tmp
);
899 nsAString_Init(&text_str
, v
);
900 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
901 nsAString_Finish(&text_str
);
902 if(NS_FAILED(nsres
)) {
903 ERR("CreateTextNode failed: %08x\n", nsres
);
907 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
908 if(NS_FAILED(nsres
)) {
909 ERR("AppendChild failed: %08x\n", nsres
);
913 nsIDOMNode_Release(tmp
);
917 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
919 HTMLElement
*This
= HTMLELEM_THIS(iface
);
921 TRACE("(%p)->(%p)\n", This
, p
);
923 return get_node_text(&This
->node
, p
);
926 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
928 HTMLElement
*This
= HTMLELEM_THIS(iface
);
929 nsIDOMDocumentFragment
*nsfragment
;
930 nsIDOMDocumentRange
*nsdocrange
;
931 nsIDOMNSRange
*nsrange
;
932 nsIDOMNode
*nsparent
;
938 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
940 nsres
= nsIDOMHTMLDocument_QueryInterface(This
->node
.doc
->nsdoc
, &IID_nsIDOMDocumentRange
, (void**)&nsdocrange
);
944 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
945 nsIDOMDocumentRange_Release(nsdocrange
);
946 if(NS_FAILED(nsres
)) {
947 ERR("CreateRange failed: %08x\n", nsres
);
951 nsres
= nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void**)&nsrange
);
952 nsIDOMRange_Release(range
);
953 if(NS_FAILED(nsres
)) {
954 ERR("Could not get nsIDOMNSRange: %08x\n", nsres
);
958 nsAString_Init(&html_str
, v
);
959 nsIDOMNSRange_CreateContextualFragment(nsrange
, &html_str
, &nsfragment
);
960 nsIDOMNSRange_Release(nsrange
);
961 nsAString_Finish(&html_str
);
962 if(NS_FAILED(nsres
)) {
963 ERR("CreateContextualFragment failed: %08x\n", nsres
);
967 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &nsparent
);
968 if(NS_SUCCEEDED(nsres
) && nsparent
) {
971 nsres
= nsIDOMNode_ReplaceChild(nsparent
, (nsIDOMNode
*)nsfragment
, This
->node
.nsnode
, &nstmp
);
972 nsIDOMNode_Release(nsparent
);
973 if(NS_FAILED(nsres
)) {
974 ERR("ReplaceChild failed: %08x\n", nsres
);
977 nsIDOMNode_Release(nstmp
);
980 ERR("GetParentNode failed: %08x\n", nsres
);
984 nsIDOMDocumentFragment_Release(nsfragment
);
988 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
990 HTMLElement
*This
= HTMLELEM_THIS(iface
);
994 WARN("(%p)->(%p) semi-stub\n", This
, p
);
996 nsAString_Init(&html_str
, NULL
);
997 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
998 if(SUCCEEDED(hres
)) {
999 const PRUnichar
*html
;
1001 nsAString_GetData(&html_str
, &html
);
1002 *p
= SysAllocString(html
);
1004 hres
= E_OUTOFMEMORY
;
1007 nsAString_Finish(&html_str
);
1009 TRACE("ret %s\n", debugstr_w(*p
));
1013 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
1015 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1016 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1020 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
1022 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1023 FIXME("(%p)->(%p)\n", This
, p
);
1027 static HRESULT
HTMLElement_InsertAdjacentNode(HTMLElement
*This
, BSTR where
, nsIDOMNode
*nsnode
)
1029 static const WCHAR wszBeforeBegin
[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1030 static const WCHAR wszAfterBegin
[] = {'a','f','t','e','r','B','e','g','i','n',0};
1031 static const WCHAR wszBeforeEnd
[] = {'b','e','f','o','r','e','E','n','d',0};
1032 static const WCHAR wszAfterEnd
[] = {'a','f','t','e','r','E','n','d',0};
1035 if (!strcmpiW(where
, wszBeforeBegin
))
1039 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1040 if (!parent
) return E_INVALIDARG
;
1041 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, This
->node
.nsnode
, &unused
);
1042 if (unused
) nsIDOMNode_Release(unused
);
1043 nsIDOMNode_Release(parent
);
1045 else if (!strcmpiW(where
, wszAfterBegin
))
1048 nsIDOMNode
*first_child
;
1049 nsIDOMNode_GetFirstChild(This
->node
.nsnode
, &first_child
);
1050 nsres
= nsIDOMNode_InsertBefore(This
->node
.nsnode
, nsnode
, first_child
, &unused
);
1051 if (unused
) nsIDOMNode_Release(unused
);
1052 if (first_child
) nsIDOMNode_Release(first_child
);
1054 else if (!strcmpiW(where
, wszBeforeEnd
))
1057 nsres
= nsIDOMNode_AppendChild(This
->node
.nsnode
, nsnode
, &unused
);
1058 if (unused
) nsIDOMNode_Release(unused
);
1060 else if (!strcmpiW(where
, wszAfterEnd
))
1063 nsIDOMNode
*next_sibling
;
1065 nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1066 if (!parent
) return E_INVALIDARG
;
1068 nsIDOMNode_GetNextSibling(This
->node
.nsnode
, &next_sibling
);
1071 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &unused
);
1072 nsIDOMNode_Release(next_sibling
);
1075 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &unused
);
1076 nsIDOMNode_Release(parent
);
1077 if (unused
) nsIDOMNode_Release(unused
);
1081 ERR("invalid where: %s\n", debugstr_w(where
));
1082 return E_INVALIDARG
;
1085 if (NS_FAILED(nsres
))
1091 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1094 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1095 nsIDOMDocumentRange
*nsdocrange
;
1097 nsIDOMNSRange
*nsrange
;
1103 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1105 if(!This
->node
.doc
->nsdoc
) {
1106 WARN("NULL nsdoc\n");
1107 return E_UNEXPECTED
;
1110 nsres
= nsIDOMDocument_QueryInterface(This
->node
.doc
->nsdoc
, &IID_nsIDOMDocumentRange
, (void **)&nsdocrange
);
1111 if(NS_FAILED(nsres
))
1113 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres
);
1116 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
1117 nsIDOMDocumentRange_Release(nsdocrange
);
1118 if(NS_FAILED(nsres
))
1120 ERR("CreateRange failed: %08x\n", nsres
);
1124 nsIDOMRange_SetStartBefore(range
, This
->node
.nsnode
);
1126 nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void **)&nsrange
);
1127 nsIDOMRange_Release(range
);
1128 if(NS_FAILED(nsres
))
1130 ERR("getting nsIDOMNSRange failed: %08x\n", nsres
);
1134 nsAString_Init(&ns_html
, html
);
1136 nsres
= nsIDOMNSRange_CreateContextualFragment(nsrange
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1137 nsIDOMNSRange_Release(nsrange
);
1138 nsAString_Finish(&ns_html
);
1140 if(NS_FAILED(nsres
) || !nsnode
)
1142 ERR("CreateTextNode failed: %08x\n", nsres
);
1146 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1147 nsIDOMNode_Release(nsnode
);
1152 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1155 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1161 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1163 if(!This
->node
.doc
->nsdoc
) {
1164 WARN("NULL nsdoc\n");
1165 return E_UNEXPECTED
;
1169 nsAString_Init(&ns_text
, text
);
1170 nsres
= nsIDOMDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1171 nsAString_Finish(&ns_text
);
1173 if(NS_FAILED(nsres
) || !nsnode
)
1175 ERR("CreateTextNode failed: %08x\n", nsres
);
1179 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1180 nsIDOMNode_Release(nsnode
);
1185 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1187 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1188 FIXME("(%p)->(%p)\n", This
, p
);
1192 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1194 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1195 FIXME("(%p)->(%p)\n", This
, p
);
1199 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1201 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1203 TRACE("(%p)\n", This
);
1205 return call_event(&This
->node
, EVENTID_CLICK
);
1208 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1209 IHTMLFiltersCollection
**p
)
1211 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1212 TRACE("(%p)->(%p)\n", This
, p
);
1217 *p
= HTMLFiltersCollection_Create();
1222 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1224 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1225 FIXME("(%p)->()\n", This
);
1229 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1231 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1232 FIXME("(%p)->(%p)\n", This
, p
);
1236 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1238 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1239 FIXME("(%p)->(%p)\n", This
, String
);
1243 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1245 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1246 FIXME("(%p)->()\n", This
);
1250 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1252 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1253 FIXME("(%p)->(%p)\n", This
, p
);
1257 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1259 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1260 FIXME("(%p)->()\n", This
);
1264 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1266 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1267 FIXME("(%p)->(%p)\n", This
, p
);
1271 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1273 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1274 FIXME("(%p)->()\n", This
);
1278 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1280 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1281 FIXME("(%p)->(%p)\n", This
, p
);
1285 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1287 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1288 FIXME("(%p)->()\n", This
);
1292 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1294 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1295 FIXME("(%p)->(%p)\n", This
, p
);
1299 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1301 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1302 FIXME("(%p)->()\n", This
);
1306 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1308 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1309 FIXME("(%p)->(%p)\n", This
, p
);
1313 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1315 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1316 FIXME("(%p)->()\n", This
);
1320 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1322 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1323 FIXME("(%p)->(%p)\n", This
, p
);
1327 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1329 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1330 FIXME("(%p)->()\n", This
);
1334 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1336 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1337 FIXME("(%p)->(%p)\n", This
, p
);
1341 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1343 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1344 FIXME("(%p)->()\n", This
);
1348 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1350 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1351 FIXME("(%p)->(%p)\n", This
, p
);
1355 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1357 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1358 FIXME("(%p)->()\n", This
);
1362 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1364 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1365 FIXME("(%p)->(%p)\n", This
, p
);
1369 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1371 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1372 nsIDOMNodeList
*nsnode_list
;
1375 TRACE("(%p)->(%p)\n", This
, p
);
1377 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1378 if(NS_FAILED(nsres
)) {
1379 ERR("GetChildNodes failed: %08x\n", nsres
);
1383 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, (IUnknown
*)HTMLELEM(This
), nsnode_list
);
1385 nsIDOMNodeList_Release(nsnode_list
);
1389 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1391 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1393 TRACE("(%p)->(%p)\n", This
, p
);
1395 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1399 static HRESULT
HTMLElement_get_dispid(IUnknown
*iface
, BSTR name
,
1400 DWORD grfdex
, DISPID
*pid
)
1402 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1404 if(This
->node
.vtbl
->get_dispid
)
1405 return This
->node
.vtbl
->get_dispid(&This
->node
, name
, grfdex
, pid
);
1407 return DISP_E_UNKNOWNNAME
;
1410 static HRESULT
HTMLElement_invoke(IUnknown
*iface
, DISPID id
, LCID lcid
,
1411 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
1412 IServiceProvider
*caller
)
1414 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1416 if(This
->node
.vtbl
->invoke
)
1417 return This
->node
.vtbl
->invoke(&This
->node
, id
, lcid
, flags
,
1418 params
, res
, ei
, caller
);
1420 ERR("(%p): element has no invoke method\n", This
);
1424 #undef HTMLELEM_THIS
1426 static const IHTMLElementVtbl HTMLElementVtbl
= {
1427 HTMLElement_QueryInterface
,
1429 HTMLElement_Release
,
1430 HTMLElement_GetTypeInfoCount
,
1431 HTMLElement_GetTypeInfo
,
1432 HTMLElement_GetIDsOfNames
,
1434 HTMLElement_setAttribute
,
1435 HTMLElement_getAttribute
,
1436 HTMLElement_removeAttribute
,
1437 HTMLElement_put_className
,
1438 HTMLElement_get_className
,
1441 HTMLElement_get_tagName
,
1442 HTMLElement_get_parentElement
,
1443 HTMLElement_get_style
,
1444 HTMLElement_put_onhelp
,
1445 HTMLElement_get_onhelp
,
1446 HTMLElement_put_onclick
,
1447 HTMLElement_get_onclick
,
1448 HTMLElement_put_ondblclick
,
1449 HTMLElement_get_ondblclick
,
1450 HTMLElement_put_onkeydown
,
1451 HTMLElement_get_onkeydown
,
1452 HTMLElement_put_onkeyup
,
1453 HTMLElement_get_onkeyup
,
1454 HTMLElement_put_onkeypress
,
1455 HTMLElement_get_onkeypress
,
1456 HTMLElement_put_onmouseout
,
1457 HTMLElement_get_onmouseout
,
1458 HTMLElement_put_onmouseover
,
1459 HTMLElement_get_onmouseover
,
1460 HTMLElement_put_onmousemove
,
1461 HTMLElement_get_onmousemove
,
1462 HTMLElement_put_onmousedown
,
1463 HTMLElement_get_onmousedown
,
1464 HTMLElement_put_onmouseup
,
1465 HTMLElement_get_onmouseup
,
1466 HTMLElement_get_document
,
1467 HTMLElement_put_title
,
1468 HTMLElement_get_title
,
1469 HTMLElement_put_language
,
1470 HTMLElement_get_language
,
1471 HTMLElement_put_onselectstart
,
1472 HTMLElement_get_onselectstart
,
1473 HTMLElement_scrollIntoView
,
1474 HTMLElement_contains
,
1475 HTMLElement_get_sourceIndex
,
1476 HTMLElement_get_recordNumber
,
1477 HTMLElement_put_lang
,
1478 HTMLElement_get_lang
,
1479 HTMLElement_get_offsetLeft
,
1480 HTMLElement_get_offsetTop
,
1481 HTMLElement_get_offsetWidth
,
1482 HTMLElement_get_offsetHeight
,
1483 HTMLElement_get_offsetParent
,
1484 HTMLElement_put_innerHTML
,
1485 HTMLElement_get_innerHTML
,
1486 HTMLElement_put_innerText
,
1487 HTMLElement_get_innerText
,
1488 HTMLElement_put_outerHTML
,
1489 HTMLElement_get_outerHTML
,
1490 HTMLElement_put_outerText
,
1491 HTMLElement_get_outerText
,
1492 HTMLElement_insertAdjacentHTML
,
1493 HTMLElement_insertAdjacentText
,
1494 HTMLElement_get_parentTextEdit
,
1495 HTMLElement_get_isTextEdit
,
1497 HTMLElement_get_filters
,
1498 HTMLElement_put_ondragstart
,
1499 HTMLElement_get_ondragstart
,
1500 HTMLElement_toString
,
1501 HTMLElement_put_onbeforeupdate
,
1502 HTMLElement_get_onbeforeupdate
,
1503 HTMLElement_put_onafterupdate
,
1504 HTMLElement_get_onafterupdate
,
1505 HTMLElement_put_onerrorupdate
,
1506 HTMLElement_get_onerrorupdate
,
1507 HTMLElement_put_onrowexit
,
1508 HTMLElement_get_onrowexit
,
1509 HTMLElement_put_onrowenter
,
1510 HTMLElement_get_onrowenter
,
1511 HTMLElement_put_ondatasetchanged
,
1512 HTMLElement_get_ondatasetchanged
,
1513 HTMLElement_put_ondataavailable
,
1514 HTMLElement_get_ondataavailable
,
1515 HTMLElement_put_ondatasetcomplete
,
1516 HTMLElement_get_ondatasetcomplete
,
1517 HTMLElement_put_onfilterchange
,
1518 HTMLElement_get_onfilterchange
,
1519 HTMLElement_get_children
,
1523 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1525 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1529 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1530 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1531 *ppv
= HTMLELEM(This
);
1532 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1533 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1534 *ppv
= HTMLELEM(This
);
1535 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1536 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
1537 *ppv
= HTMLELEM(This
);
1538 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1539 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
1540 *ppv
= HTMLELEM2(This
);
1541 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1542 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This
, ppv
);
1543 *ppv
= HTMLELEM3(This
);
1544 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1545 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1546 *ppv
= CONPTCONT(&This
->cp_container
);
1550 IHTMLElement_AddRef(HTMLELEM(This
));
1554 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1557 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1559 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1561 ConnectionPointContainer_Destroy(&This
->cp_container
);
1564 nsIDOMHTMLElement_Release(This
->nselem
);
1566 HTMLDOMNode_destructor(&This
->node
);
1569 static const NodeImplVtbl HTMLElementImplVtbl
= {
1571 HTMLElement_destructor
1574 static const tid_t HTMLElement_iface_tids
[] = {
1583 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl
= {
1585 HTMLElement_get_dispid
,
1589 static dispex_static_data_t HTMLElement_dispex
= {
1590 &HTMLElement_dispex_vtbl
,
1591 DispHTMLUnknownElement_tid
,
1593 HTMLElement_iface_tids
1596 void HTMLElement_Init(HTMLElement
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, dispex_static_data_t
*dispex_data
)
1598 This
->lpHTMLElementVtbl
= &HTMLElementVtbl
;
1600 HTMLElement2_Init(This
);
1601 HTMLElement3_Init(This
);
1603 if(dispex_data
&& !dispex_data
->vtbl
)
1604 dispex_data
->vtbl
= &HTMLElement_dispex_vtbl
;
1605 init_dispex(&This
->node
.dispex
, (IUnknown
*)HTMLELEM(This
), dispex_data
? dispex_data
: &HTMLElement_dispex
);
1608 nsIDOMHTMLElement_AddRef(nselem
);
1609 This
->nselem
= nselem
;
1611 HTMLDOMNode_Init(doc
, &This
->node
, (nsIDOMNode
*)nselem
);
1613 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)HTMLELEM(This
));
1616 HTMLElement
*HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
)
1618 nsIDOMHTMLElement
*nselem
;
1619 HTMLElement
*ret
= NULL
;
1620 nsAString class_name_str
;
1621 const PRUnichar
*class_name
;
1624 static const WCHAR wszA
[] = {'A',0};
1625 static const WCHAR wszBODY
[] = {'B','O','D','Y',0};
1626 static const WCHAR wszFORM
[] = {'F','O','R','M',0};
1627 static const WCHAR wszFRAME
[] = {'F','R','A','M','E',0};
1628 static const WCHAR wszIFRAME
[] = {'I','F','R','A','M','E',0};
1629 static const WCHAR wszIMG
[] = {'I','M','G',0};
1630 static const WCHAR wszINPUT
[] = {'I','N','P','U','T',0};
1631 static const WCHAR wszOPTION
[] = {'O','P','T','I','O','N',0};
1632 static const WCHAR wszSCRIPT
[] = {'S','C','R','I','P','T',0};
1633 static const WCHAR wszSELECT
[] = {'S','E','L','E','C','T',0};
1634 static const WCHAR wszTABLE
[] = {'T','A','B','L','E',0};
1635 static const WCHAR wszTR
[] = {'T','R',0};
1636 static const WCHAR wszTEXTAREA
[] = {'T','E','X','T','A','R','E','A',0};
1638 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1639 if(NS_FAILED(nsres
))
1642 nsAString_Init(&class_name_str
, NULL
);
1643 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1645 nsAString_GetData(&class_name_str
, &class_name
);
1647 if(!strcmpW(class_name
, wszA
))
1648 ret
= HTMLAnchorElement_Create(doc
, nselem
);
1649 else if(!strcmpW(class_name
, wszBODY
))
1650 ret
= HTMLBodyElement_Create(doc
, nselem
);
1651 else if(!strcmpW(class_name
, wszFORM
))
1652 ret
= HTMLFormElement_Create(doc
, nselem
);
1653 else if(!strcmpW(class_name
, wszFRAME
))
1654 ret
= HTMLFrameElement_Create(doc
, nselem
);
1655 else if(!strcmpW(class_name
, wszIFRAME
))
1656 ret
= HTMLIFrame_Create(doc
, nselem
);
1657 else if(!strcmpW(class_name
, wszIMG
))
1658 ret
= HTMLImgElement_Create(doc
, nselem
);
1659 else if(!strcmpW(class_name
, wszINPUT
))
1660 ret
= HTMLInputElement_Create(doc
, nselem
);
1661 else if(!strcmpW(class_name
, wszOPTION
))
1662 ret
= HTMLOptionElement_Create(doc
, nselem
);
1663 else if(!strcmpW(class_name
, wszSCRIPT
))
1664 ret
= HTMLScriptElement_Create(doc
, nselem
);
1665 else if(!strcmpW(class_name
, wszSELECT
))
1666 ret
= HTMLSelectElement_Create(doc
, nselem
);
1667 else if(!strcmpW(class_name
, wszTABLE
))
1668 ret
= HTMLTable_Create(doc
, nselem
);
1669 else if(!strcmpW(class_name
, wszTR
))
1670 ret
= HTMLTableRow_Create(doc
, nselem
);
1671 else if(!strcmpW(class_name
, wszTEXTAREA
))
1672 ret
= HTMLTextAreaElement_Create(doc
, nselem
);
1673 else if(use_generic
)
1674 ret
= HTMLGenericElement_Create(doc
, nselem
);
1677 ret
= heap_alloc_zero(sizeof(HTMLElement
));
1678 HTMLElement_Init(ret
, doc
, nselem
, NULL
);
1679 ret
->node
.vtbl
= &HTMLElementImplVtbl
;
1682 TRACE("%s ret %p\n", debugstr_w(class_name
), ret
);
1684 nsIDOMElement_Release(nselem
);
1685 nsAString_Finish(&class_name_str
);
1690 /* interaface IHTMLFiltersCollection */
1691 static HRESULT WINAPI
HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection
*iface
, REFIID riid
, void **ppv
)
1693 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1695 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
1697 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1698 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1699 *ppv
= HTMLFILTERSCOLLECTION(This
);
1700 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection
, riid
)) {
1701 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This
, ppv
);
1702 *ppv
= HTMLFILTERSCOLLECTION(This
);
1703 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
1704 return *ppv
? S_OK
: E_NOINTERFACE
;
1708 IUnknown_AddRef((IUnknown
*)*ppv
);
1712 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1713 return E_NOINTERFACE
;
1716 static ULONG WINAPI
HTMLFiltersCollection_AddRef(IHTMLFiltersCollection
*iface
)
1718 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1719 LONG ref
= InterlockedIncrement(&This
->ref
);
1721 TRACE("(%p) ref=%d\n", This
, ref
);
1726 static ULONG WINAPI
HTMLFiltersCollection_Release(IHTMLFiltersCollection
*iface
)
1728 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1729 LONG ref
= InterlockedDecrement(&This
->ref
);
1731 TRACE("(%p) ref=%d\n", This
, ref
);
1741 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection
*iface
, UINT
*pctinfo
)
1743 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1744 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->dispex
), pctinfo
);
1747 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection
*iface
,
1748 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1750 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1751 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->dispex
), iTInfo
, lcid
, ppTInfo
);
1754 static HRESULT WINAPI
HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection
*iface
,
1755 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
,
1756 LCID lcid
, DISPID
*rgDispId
)
1758 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1759 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1762 static HRESULT WINAPI
HTMLFiltersCollection_Invoke(IHTMLFiltersCollection
*iface
, DISPID dispIdMember
, REFIID riid
,
1763 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
1764 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1766 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1767 return IDispatchEx_Invoke(DISPATCHEX(&This
->dispex
), dispIdMember
, riid
, lcid
,
1768 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1771 static HRESULT WINAPI
HTMLFiltersCollection_get_length(IHTMLFiltersCollection
*iface
, LONG
*p
)
1773 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1775 FIXME("(%p)->(%p) Always returning 0\n", This
, p
);
1786 static HRESULT WINAPI
HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection
*iface
, IUnknown
**p
)
1788 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1789 FIXME("(%p)->(%p)\n", This
, p
);
1793 static HRESULT WINAPI
HTMLFiltersCollection_item(IHTMLFiltersCollection
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
1795 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1796 FIXME("(%p)->(%p, %p)\n", This
, pvarIndex
, pvarResult
);
1800 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl
= {
1801 HTMLFiltersCollection_QueryInterface
,
1802 HTMLFiltersCollection_AddRef
,
1803 HTMLFiltersCollection_Release
,
1804 HTMLFiltersCollection_GetTypeInfoCount
,
1805 HTMLFiltersCollection_GetTypeInfo
,
1806 HTMLFiltersCollection_GetIDsOfNames
,
1807 HTMLFiltersCollection_Invoke
,
1808 HTMLFiltersCollection_get_length
,
1809 HTMLFiltersCollection_get__newEnum
,
1810 HTMLFiltersCollection_item
1813 static HRESULT
HTMLFiltersCollection_get_dispid(IUnknown
*iface
, BSTR name
, DWORD flags
, DISPID
*dispid
)
1818 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
1819 idx
= idx
*10 + (*ptr
-'0');
1821 return DISP_E_UNKNOWNNAME
;
1823 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
1824 TRACE("ret %x\n", *dispid
);
1828 static HRESULT
HTMLFiltersCollection_invoke(IUnknown
*iface
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
1829 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
1831 HTMLFiltersCollection
*This
= HTMLFILTERSCOLLECTION_THIS(iface
);
1833 TRACE("(%p)->(%x %x %x %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
);
1835 V_VT(res
) = VT_DISPATCH
;
1836 V_DISPATCH(res
) = NULL
;
1838 FIXME("always returning NULL\n");
1843 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl
= {
1845 HTMLFiltersCollection_get_dispid
,
1846 HTMLFiltersCollection_invoke
1849 static const tid_t HTMLFiltersCollection_iface_tids
[] = {
1850 IHTMLFiltersCollection_tid
,
1853 static dispex_static_data_t HTMLFiltersCollection_dispex
= {
1854 &HTMLFiltersCollection_dispex_vtbl
,
1855 IHTMLFiltersCollection_tid
,
1857 HTMLFiltersCollection_iface_tids
1860 IHTMLFiltersCollection
*HTMLFiltersCollection_Create()
1862 HTMLFiltersCollection
*ret
= heap_alloc(sizeof(HTMLFiltersCollection
));
1864 ret
->lpHTMLFiltersCollectionVtbl
= &HTMLFiltersCollectionVtbl
;
1867 init_dispex(&ret
->dispex
, (IUnknown
*)HTMLFILTERSCOLLECTION(ret
), &HTMLFiltersCollection_dispex
);
1869 return HTMLFILTERSCOLLECTION(ret
);