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"
36 #include "htmlstyle.h"
38 static const WCHAR aW
[] = {'A',0};
39 static const WCHAR bodyW
[] = {'B','O','D','Y',0};
40 static const WCHAR embedW
[] = {'E','M','B','E','D',0};
41 static const WCHAR formW
[] = {'F','O','R','M',0};
42 static const WCHAR frameW
[] = {'F','R','A','M','E',0};
43 static const WCHAR iframeW
[] = {'I','F','R','A','M','E',0};
44 static const WCHAR imgW
[] = {'I','M','G',0};
45 static const WCHAR inputW
[] = {'I','N','P','U','T',0};
46 static const WCHAR objectW
[] = {'O','B','J','E','C','T',0};
47 static const WCHAR optionW
[] = {'O','P','T','I','O','N',0};
48 static const WCHAR scriptW
[] = {'S','C','R','I','P','T',0};
49 static const WCHAR selectW
[] = {'S','E','L','E','C','T',0};
50 static const WCHAR styleW
[] = {'S','T','Y','L','E',0};
51 static const WCHAR tableW
[] = {'T','A','B','L','E',0};
52 static const WCHAR textareaW
[] = {'T','E','X','T','A','R','E','A',0};
53 static const WCHAR trW
[] = {'T','R',0};
57 HRESULT (*constructor
)(HTMLDocumentNode
*,nsIDOMHTMLElement
*,HTMLElement
**);
60 static const tag_desc_t tag_descs
[] = {
61 {aW
, HTMLAnchorElement_Create
},
62 {bodyW
, HTMLBodyElement_Create
},
63 {embedW
, HTMLEmbedElement_Create
},
64 {formW
, HTMLFormElement_Create
},
65 {frameW
, HTMLFrameElement_Create
},
66 {iframeW
, HTMLIFrame_Create
},
67 {imgW
, HTMLImgElement_Create
},
68 {inputW
, HTMLInputElement_Create
},
69 {objectW
, HTMLObjectElement_Create
},
70 {optionW
, HTMLOptionElement_Create
},
71 {scriptW
, HTMLScriptElement_Create
},
72 {selectW
, HTMLSelectElement_Create
},
73 {styleW
, HTMLStyleElement_Create
},
74 {tableW
, HTMLTable_Create
},
75 {textareaW
, HTMLTextAreaElement_Create
},
76 {trW
, HTMLTableRow_Create
}
79 static const tag_desc_t
*get_tag_desc(const WCHAR
*tag_name
)
81 DWORD min
=0, max
=sizeof(tag_descs
)/sizeof(*tag_descs
)-1, i
;
86 r
= strcmpW(tag_name
, tag_descs
[i
].name
);
102 IHTMLFiltersCollection IHTMLFiltersCollection_iface
;
105 } HTMLFiltersCollection
;
107 static inline HTMLFiltersCollection
*impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection
*iface
)
109 return CONTAINING_RECORD(iface
, HTMLFiltersCollection
, IHTMLFiltersCollection_iface
);
112 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void);
115 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
117 static inline HTMLElement
*impl_from_IHTMLElement(IHTMLElement
*iface
)
119 return CONTAINING_RECORD(iface
, HTMLElement
, IHTMLElement_iface
);
122 HRESULT
create_nselem(HTMLDocumentNode
*doc
, const WCHAR
*tag
, nsIDOMHTMLElement
**ret
)
124 nsIDOMElement
*nselem
;
129 WARN("NULL nsdoc\n");
133 nsAString_InitDepend(&tag_str
, tag
);
134 nsres
= nsIDOMDocument_CreateElement(doc
->nsdoc
, &tag_str
, &nselem
);
135 nsAString_Finish(&tag_str
);
136 if(NS_FAILED(nsres
)) {
137 ERR("CreateElement failed: %08x\n", nsres
);
141 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLElement
, (void**)ret
);
142 nsIDOMElement_Release(nselem
);
143 if(NS_FAILED(nsres
)) {
144 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres
);
151 static HRESULT WINAPI
HTMLElement_QueryInterface(IHTMLElement
*iface
,
152 REFIID riid
, void **ppv
)
154 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
156 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
159 static ULONG WINAPI
HTMLElement_AddRef(IHTMLElement
*iface
)
161 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
163 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
166 static ULONG WINAPI
HTMLElement_Release(IHTMLElement
*iface
)
168 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
170 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
173 static HRESULT WINAPI
HTMLElement_GetTypeInfoCount(IHTMLElement
*iface
, UINT
*pctinfo
)
175 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
176 return IDispatchEx_GetTypeInfoCount(&This
->node
.dispex
.IDispatchEx_iface
, pctinfo
);
179 static HRESULT WINAPI
HTMLElement_GetTypeInfo(IHTMLElement
*iface
, UINT iTInfo
,
180 LCID lcid
, ITypeInfo
**ppTInfo
)
182 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
183 return IDispatchEx_GetTypeInfo(&This
->node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
186 static HRESULT WINAPI
HTMLElement_GetIDsOfNames(IHTMLElement
*iface
, REFIID riid
,
187 LPOLESTR
*rgszNames
, UINT cNames
,
188 LCID lcid
, DISPID
*rgDispId
)
190 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
191 return IDispatchEx_GetIDsOfNames(&This
->node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
195 static HRESULT WINAPI
HTMLElement_Invoke(IHTMLElement
*iface
, DISPID dispIdMember
,
196 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
197 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
199 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
200 return IDispatchEx_Invoke(&This
->node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
201 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
204 static HRESULT WINAPI
HTMLElement_setAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
205 VARIANT AttributeValue
, LONG lFlags
)
207 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
209 DISPID dispid
, dispidNamed
= DISPID_PROPERTYPUT
;
210 DISPPARAMS dispParams
;
213 TRACE("(%p)->(%s . %08x)\n", This
, debugstr_w(strAttributeName
), lFlags
);
215 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
216 fdexNameCaseInsensitive
| fdexNameEnsure
, &dispid
);
220 dispParams
.cArgs
= 1;
221 dispParams
.cNamedArgs
= 1;
222 dispParams
.rgdispidNamedArgs
= &dispidNamed
;
223 dispParams
.rgvarg
= &AttributeValue
;
225 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
,
226 LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYPUT
, &dispParams
, NULL
, &excep
, NULL
);
230 static HRESULT WINAPI
HTMLElement_getAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
231 LONG lFlags
, VARIANT
*AttributeValue
)
233 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
236 DISPPARAMS dispParams
= {NULL
, NULL
, 0, 0};
239 TRACE("(%p)->(%s %08x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, AttributeValue
);
241 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
242 fdexNameCaseInsensitive
, &dispid
);
243 if(hres
== DISP_E_UNKNOWNNAME
) {
244 V_VT(AttributeValue
) = VT_NULL
;
249 V_VT(AttributeValue
) = VT_NULL
;
253 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
, LOCALE_SYSTEM_DEFAULT
,
254 DISPATCH_PROPERTYGET
, &dispParams
, AttributeValue
, &excep
, NULL
);
259 static HRESULT WINAPI
HTMLElement_removeAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
260 LONG lFlags
, VARIANT_BOOL
*pfSuccess
)
262 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
264 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, pfSuccess
);
266 return remove_prop(&This
->node
.dispex
, strAttributeName
, pfSuccess
);
269 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
271 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
272 nsAString classname_str
;
275 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
278 FIXME("NULL nselem\n");
282 nsAString_InitDepend(&classname_str
, v
);
283 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
284 nsAString_Finish(&classname_str
);
286 ERR("SetClassName failed: %08x\n", nsres
);
291 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
293 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
298 TRACE("(%p)->(%p)\n", This
, p
);
301 FIXME("NULL nselem\n");
305 nsAString_Init(&class_str
, NULL
);
306 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
308 if(NS_SUCCEEDED(nsres
)) {
309 const PRUnichar
*class;
310 nsAString_GetData(&class_str
, &class);
311 *p
= *class ? SysAllocString(class) : NULL
;
313 ERR("GetClassName failed: %08x\n", nsres
);
317 nsAString_Finish(&class_str
);
319 TRACE("className=%s\n", debugstr_w(*p
));
323 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
325 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
329 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
332 FIXME("nselem == NULL\n");
336 nsAString_InitDepend(&id_str
, v
);
337 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
338 nsAString_Finish(&id_str
);
340 ERR("SetId failed: %08x\n", nsres
);
345 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
347 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
352 TRACE("(%p)->(%p)\n", This
, p
);
359 nsAString_Init(&id_str
, NULL
);
360 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
361 nsAString_GetData(&id_str
, &id
);
364 ERR("GetId failed: %08x\n", nsres
);
366 *p
= SysAllocString(id
);
368 nsAString_Finish(&id_str
);
372 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
374 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
375 const PRUnichar
*tag
;
379 TRACE("(%p)->(%p)\n", This
, p
);
382 static const WCHAR comment_tagW
[] = {'!',0};
384 WARN("NULL nselem, assuming comment\n");
386 *p
= SysAllocString(comment_tagW
);
390 nsAString_Init(&tag_str
, NULL
);
391 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
392 if(NS_SUCCEEDED(nsres
)) {
393 nsAString_GetData(&tag_str
, &tag
);
394 *p
= SysAllocString(tag
);
396 ERR("GetTagName failed: %08x\n", nsres
);
399 nsAString_Finish(&tag_str
);
404 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
406 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
410 TRACE("(%p)->(%p)\n", This
, p
);
412 hres
= IHTMLDOMNode_get_parentNode(&This
->node
.IHTMLDOMNode_iface
, &node
);
416 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
417 IHTMLDOMNode_Release(node
);
424 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
426 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
428 TRACE("(%p)->(%p)\n", This
, p
);
431 nsIDOMElementCSSInlineStyle
*nselemstyle
;
432 nsIDOMCSSStyleDeclaration
*nsstyle
;
437 FIXME("NULL nselem\n");
441 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMElementCSSInlineStyle
,
442 (void**)&nselemstyle
);
443 if(NS_FAILED(nsres
)) {
444 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres
);
448 nsres
= nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle
, &nsstyle
);
449 nsIDOMElementCSSInlineStyle_Release(nselemstyle
);
450 if(NS_FAILED(nsres
)) {
451 ERR("GetStyle failed: %08x\n", nsres
);
455 hres
= HTMLStyle_Create(nsstyle
, &This
->style
);
456 nsIDOMCSSStyleDeclaration_Release(nsstyle
);
461 *p
= &This
->style
->IHTMLStyle_iface
;
462 IHTMLStyle_AddRef(*p
);
466 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
468 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
469 FIXME("(%p)->()\n", This
);
473 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
475 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
476 FIXME("(%p)->(%p)\n", This
, p
);
480 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
482 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
484 TRACE("(%p)->()\n", This
);
486 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
489 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
491 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
493 TRACE("(%p)->(%p)\n", This
, p
);
495 return get_node_event(&This
->node
, EVENTID_CLICK
, p
);
498 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
500 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
502 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
504 return set_node_event(&This
->node
, EVENTID_DBLCLICK
, &v
);
507 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
509 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
511 TRACE("(%p)->(%p)\n", This
, p
);
513 return get_node_event(&This
->node
, EVENTID_DBLCLICK
, p
);
516 static HRESULT WINAPI
HTMLElement_put_onkeydown(IHTMLElement
*iface
, VARIANT v
)
518 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
520 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
522 return set_node_event(&This
->node
, EVENTID_KEYDOWN
, &v
);
525 static HRESULT WINAPI
HTMLElement_get_onkeydown(IHTMLElement
*iface
, VARIANT
*p
)
527 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
529 TRACE("(%p)->(%p)\n", This
, p
);
531 return get_node_event(&This
->node
, EVENTID_KEYDOWN
, p
);
534 static HRESULT WINAPI
HTMLElement_put_onkeyup(IHTMLElement
*iface
, VARIANT v
)
536 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
538 TRACE("(%p)->()\n", This
);
540 return set_node_event(&This
->node
, EVENTID_KEYUP
, &v
);
543 static HRESULT WINAPI
HTMLElement_get_onkeyup(IHTMLElement
*iface
, VARIANT
*p
)
545 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
546 FIXME("(%p)->(%p)\n", This
, p
);
550 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
552 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
553 FIXME("(%p)->()\n", This
);
557 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
559 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
560 FIXME("(%p)->(%p)\n", This
, p
);
564 static HRESULT WINAPI
HTMLElement_put_onmouseout(IHTMLElement
*iface
, VARIANT v
)
566 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
568 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
570 return set_node_event(&This
->node
, EVENTID_MOUSEOUT
, &v
);
573 static HRESULT WINAPI
HTMLElement_get_onmouseout(IHTMLElement
*iface
, VARIANT
*p
)
575 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
577 TRACE("(%p)->(%p)\n", This
, p
);
579 return get_node_event(&This
->node
, EVENTID_MOUSEOUT
, p
);
582 static HRESULT WINAPI
HTMLElement_put_onmouseover(IHTMLElement
*iface
, VARIANT v
)
584 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
586 TRACE("(%p)->()\n", This
);
588 return set_node_event(&This
->node
, EVENTID_MOUSEOVER
, &v
);
591 static HRESULT WINAPI
HTMLElement_get_onmouseover(IHTMLElement
*iface
, VARIANT
*p
)
593 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
595 TRACE("(%p)->(%p)\n", This
, p
);
597 return get_node_event(&This
->node
, EVENTID_MOUSEOVER
, p
);
600 static HRESULT WINAPI
HTMLElement_put_onmousemove(IHTMLElement
*iface
, VARIANT v
)
602 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
604 TRACE("(%p)->()\n", This
);
606 return set_node_event(&This
->node
, EVENTID_MOUSEMOVE
, &v
);
609 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
611 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
613 TRACE("(%p)->(%p)\n", This
, p
);
615 return get_node_event(&This
->node
, EVENTID_MOUSEMOVE
, p
);
618 static HRESULT WINAPI
HTMLElement_put_onmousedown(IHTMLElement
*iface
, VARIANT v
)
620 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
622 TRACE("(%p)->()\n", This
);
624 return set_node_event(&This
->node
, EVENTID_MOUSEDOWN
, &v
);
627 static HRESULT WINAPI
HTMLElement_get_onmousedown(IHTMLElement
*iface
, VARIANT
*p
)
629 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
631 TRACE("(%p)->(%p)\n", This
, p
);
633 return get_node_event(&This
->node
, EVENTID_MOUSEDOWN
, p
);
636 static HRESULT WINAPI
HTMLElement_put_onmouseup(IHTMLElement
*iface
, VARIANT v
)
638 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
640 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
642 return set_node_event(&This
->node
, EVENTID_MOUSEUP
, &v
);
645 static HRESULT WINAPI
HTMLElement_get_onmouseup(IHTMLElement
*iface
, VARIANT
*p
)
647 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
649 TRACE("(%p)->(%p)\n", This
, p
);
651 return get_node_event(&This
->node
, EVENTID_MOUSEUP
, p
);
654 static HRESULT WINAPI
HTMLElement_get_document(IHTMLElement
*iface
, IDispatch
**p
)
656 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
658 TRACE("(%p)->(%p)\n", This
, p
);
663 if(This
->node
.vtbl
->get_document
)
664 return This
->node
.vtbl
->get_document(&This
->node
, p
);
666 *p
= (IDispatch
*)&This
->node
.doc
->basedoc
.IHTMLDocument2_iface
;
667 IDispatch_AddRef(*p
);
671 static const WCHAR titleW
[] = {'t','i','t','l','e',0};
673 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
675 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
679 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
685 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, TRUE
, &var
);
691 V_BSTR(var
) = v
? SysAllocString(v
) : NULL
;
695 nsAString_InitDepend(&title_str
, v
);
696 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
697 nsAString_Finish(&title_str
);
699 ERR("SetTitle failed: %08x\n", nsres
);
704 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
706 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
710 TRACE("(%p)->(%p)\n", This
, p
);
716 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, FALSE
, &var
);
717 if(hres
== DISP_E_UNKNOWNNAME
) {
719 }else if(V_VT(var
) != VT_BSTR
) {
720 FIXME("title = %s\n", debugstr_variant(var
));
723 *p
= V_BSTR(var
) ? SysAllocString(V_BSTR(var
)) : NULL
;
729 nsAString_Init(&title_str
, NULL
);
730 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
731 if(NS_SUCCEEDED(nsres
)) {
732 const PRUnichar
*title
;
734 nsAString_GetData(&title_str
, &title
);
735 *p
= *title
? SysAllocString(title
) : NULL
;
737 ERR("GetTitle failed: %08x\n", nsres
);
744 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
746 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
747 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
751 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
753 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
754 FIXME("(%p)->(%p)\n", This
, p
);
758 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
760 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
762 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
764 return set_node_event(&This
->node
, EVENTID_SELECTSTART
, &v
);
767 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
769 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
771 TRACE("(%p)->(%p)\n", This
, p
);
773 return get_node_event(&This
->node
, EVENTID_SELECTSTART
, p
);
776 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
778 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
779 FIXME("(%p)->()\n", This
);
783 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
784 VARIANT_BOOL
*pfResult
)
786 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
787 FIXME("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
791 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, LONG
*p
)
793 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
794 FIXME("(%p)->(%p)\n", This
, p
);
798 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
800 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
801 FIXME("(%p)->(%p)\n", This
, p
);
805 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
807 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
808 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
812 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
814 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
815 FIXME("(%p)->(%p)\n", This
, p
);
819 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
821 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
822 FIXME("(%p)->(%p)\n", This
, p
);
826 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
828 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
829 nsIDOMNSHTMLElement
*nselem
;
833 TRACE("(%p)->(%p)\n", This
, p
);
835 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
836 if(NS_FAILED(nsres
)) {
837 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
841 nsres
= nsIDOMNSHTMLElement_GetOffsetTop(nselem
, &top
);
842 nsIDOMNSHTMLElement_Release(nselem
);
843 if(NS_FAILED(nsres
)) {
844 ERR("GetOffsetTop failed: %08x\n", nsres
);
852 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
854 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
855 nsIDOMNSHTMLElement
*nselem
;
859 TRACE("(%p)->(%p)\n", This
, p
);
861 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
862 if(NS_FAILED(nsres
)) {
863 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
867 nsres
= nsIDOMNSHTMLElement_GetOffsetWidth(nselem
, &offset
);
868 nsIDOMNSHTMLElement_Release(nselem
);
869 if(NS_FAILED(nsres
)) {
870 ERR("GetOffsetWidth failed: %08x\n", nsres
);
878 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
880 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
881 nsIDOMNSHTMLElement
*nselem
;
885 TRACE("(%p)->(%p)\n", This
, p
);
887 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
888 if(NS_FAILED(nsres
)) {
889 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
893 nsres
= nsIDOMNSHTMLElement_GetOffsetHeight(nselem
, &offset
);
894 nsIDOMNSHTMLElement_Release(nselem
);
895 if(NS_FAILED(nsres
)) {
896 ERR("GetOffsetHeight failed: %08x\n", nsres
);
904 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
906 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
907 FIXME("(%p)->(%p)\n", This
, p
);
911 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
913 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
914 nsIDOMNSHTMLElement
*nselem
;
918 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
921 FIXME("NULL nselem\n");
925 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
926 if(NS_FAILED(nsres
)) {
927 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
931 nsAString_InitDepend(&html_str
, v
);
932 nsres
= nsIDOMNSHTMLElement_SetInnerHTML(nselem
, &html_str
);
933 nsAString_Finish(&html_str
);
935 if(NS_FAILED(nsres
)) {
936 FIXME("SetInnerHtml failed %08x\n", nsres
);
943 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
945 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
946 nsIDOMNSHTMLElement
*nselem
;
950 TRACE("(%p)->(%p)\n", This
, p
);
953 FIXME("NULL nselem\n");
957 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
958 if(NS_FAILED(nsres
)) {
959 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
963 nsAString_Init(&html_str
, NULL
);
964 nsres
= nsIDOMNSHTMLElement_GetInnerHTML(nselem
, &html_str
);
965 if(NS_SUCCEEDED(nsres
)) {
966 const PRUnichar
*html
;
968 nsAString_GetData(&html_str
, &html
);
969 *p
= *html
? SysAllocString(html
) : NULL
;
971 FIXME("SetInnerHtml failed %08x\n", nsres
);
975 nsAString_Finish(&html_str
);
979 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
981 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
982 nsIDOMNode
*nschild
, *tmp
;
983 nsIDOMText
*text_node
;
987 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
990 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
991 if(NS_FAILED(nsres
)) {
992 ERR("GetLastChild failed: %08x\n", nsres
);
998 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
999 nsIDOMNode_Release(nschild
);
1000 if(NS_FAILED(nsres
)) {
1001 ERR("RemoveChild failed: %08x\n", nsres
);
1004 nsIDOMNode_Release(tmp
);
1007 nsAString_InitDepend(&text_str
, v
);
1008 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
1009 nsAString_Finish(&text_str
);
1010 if(NS_FAILED(nsres
)) {
1011 ERR("CreateTextNode failed: %08x\n", nsres
);
1015 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
1016 if(NS_FAILED(nsres
)) {
1017 ERR("AppendChild failed: %08x\n", nsres
);
1021 nsIDOMNode_Release(tmp
);
1025 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
1027 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1029 TRACE("(%p)->(%p)\n", This
, p
);
1031 return get_node_text(&This
->node
, p
);
1034 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
1036 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1037 nsIDOMDocumentFragment
*nsfragment
;
1038 nsIDOMDocumentRange
*nsdocrange
;
1039 nsIDOMNSRange
*nsrange
;
1040 nsIDOMNode
*nsparent
;
1044 HRESULT hres
= S_OK
;
1046 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1048 nsres
= nsIDOMHTMLDocument_QueryInterface(This
->node
.doc
->nsdoc
, &IID_nsIDOMDocumentRange
, (void**)&nsdocrange
);
1049 if(NS_FAILED(nsres
))
1052 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
1053 nsIDOMDocumentRange_Release(nsdocrange
);
1054 if(NS_FAILED(nsres
)) {
1055 ERR("CreateRange failed: %08x\n", nsres
);
1059 nsres
= nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void**)&nsrange
);
1060 nsIDOMRange_Release(range
);
1061 if(NS_FAILED(nsres
)) {
1062 ERR("Could not get nsIDOMNSRange: %08x\n", nsres
);
1066 nsAString_InitDepend(&html_str
, v
);
1067 nsIDOMNSRange_CreateContextualFragment(nsrange
, &html_str
, &nsfragment
);
1068 nsIDOMNSRange_Release(nsrange
);
1069 nsAString_Finish(&html_str
);
1070 if(NS_FAILED(nsres
)) {
1071 ERR("CreateContextualFragment failed: %08x\n", nsres
);
1075 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &nsparent
);
1076 if(NS_SUCCEEDED(nsres
) && nsparent
) {
1079 nsres
= nsIDOMNode_ReplaceChild(nsparent
, (nsIDOMNode
*)nsfragment
, This
->node
.nsnode
, &nstmp
);
1080 nsIDOMNode_Release(nsparent
);
1081 if(NS_FAILED(nsres
)) {
1082 ERR("ReplaceChild failed: %08x\n", nsres
);
1085 nsIDOMNode_Release(nstmp
);
1088 ERR("GetParentNode failed: %08x\n", nsres
);
1092 nsIDOMDocumentFragment_Release(nsfragment
);
1096 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
1098 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1102 WARN("(%p)->(%p) semi-stub\n", This
, p
);
1104 nsAString_Init(&html_str
, NULL
);
1105 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
1106 if(SUCCEEDED(hres
)) {
1107 const PRUnichar
*html
;
1109 nsAString_GetData(&html_str
, &html
);
1110 *p
= SysAllocString(html
);
1112 hres
= E_OUTOFMEMORY
;
1115 nsAString_Finish(&html_str
);
1117 TRACE("ret %s\n", debugstr_w(*p
));
1121 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
1123 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1124 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1128 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
1130 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1131 FIXME("(%p)->(%p)\n", This
, p
);
1135 static HRESULT
HTMLElement_InsertAdjacentNode(HTMLElement
*This
, BSTR where
, nsIDOMNode
*nsnode
)
1137 static const WCHAR wszBeforeBegin
[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1138 static const WCHAR wszAfterBegin
[] = {'a','f','t','e','r','B','e','g','i','n',0};
1139 static const WCHAR wszBeforeEnd
[] = {'b','e','f','o','r','e','E','n','d',0};
1140 static const WCHAR wszAfterEnd
[] = {'a','f','t','e','r','E','n','d',0};
1143 if (!strcmpiW(where
, wszBeforeBegin
))
1147 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1148 if (!parent
) return E_INVALIDARG
;
1149 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, This
->node
.nsnode
, &unused
);
1150 if (unused
) nsIDOMNode_Release(unused
);
1151 nsIDOMNode_Release(parent
);
1153 else if (!strcmpiW(where
, wszAfterBegin
))
1156 nsIDOMNode
*first_child
;
1157 nsIDOMNode_GetFirstChild(This
->node
.nsnode
, &first_child
);
1158 nsres
= nsIDOMNode_InsertBefore(This
->node
.nsnode
, nsnode
, first_child
, &unused
);
1159 if (unused
) nsIDOMNode_Release(unused
);
1160 if (first_child
) nsIDOMNode_Release(first_child
);
1162 else if (!strcmpiW(where
, wszBeforeEnd
))
1165 nsres
= nsIDOMNode_AppendChild(This
->node
.nsnode
, nsnode
, &unused
);
1166 if (unused
) nsIDOMNode_Release(unused
);
1168 else if (!strcmpiW(where
, wszAfterEnd
))
1171 nsIDOMNode
*next_sibling
;
1173 nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1174 if (!parent
) return E_INVALIDARG
;
1176 nsIDOMNode_GetNextSibling(This
->node
.nsnode
, &next_sibling
);
1179 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &unused
);
1180 nsIDOMNode_Release(next_sibling
);
1183 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &unused
);
1184 nsIDOMNode_Release(parent
);
1185 if (unused
) nsIDOMNode_Release(unused
);
1189 ERR("invalid where: %s\n", debugstr_w(where
));
1190 return E_INVALIDARG
;
1193 if (NS_FAILED(nsres
))
1199 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1202 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1203 nsIDOMDocumentRange
*nsdocrange
;
1205 nsIDOMNSRange
*nsrange
;
1211 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1213 if(!This
->node
.doc
->nsdoc
) {
1214 WARN("NULL nsdoc\n");
1215 return E_UNEXPECTED
;
1218 nsres
= nsIDOMDocument_QueryInterface(This
->node
.doc
->nsdoc
, &IID_nsIDOMDocumentRange
, (void **)&nsdocrange
);
1219 if(NS_FAILED(nsres
))
1221 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres
);
1224 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
1225 nsIDOMDocumentRange_Release(nsdocrange
);
1226 if(NS_FAILED(nsres
))
1228 ERR("CreateRange failed: %08x\n", nsres
);
1232 nsIDOMRange_SetStartBefore(range
, This
->node
.nsnode
);
1234 nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void **)&nsrange
);
1235 nsIDOMRange_Release(range
);
1236 if(NS_FAILED(nsres
))
1238 ERR("getting nsIDOMNSRange failed: %08x\n", nsres
);
1242 nsAString_InitDepend(&ns_html
, html
);
1244 nsres
= nsIDOMNSRange_CreateContextualFragment(nsrange
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1245 nsIDOMNSRange_Release(nsrange
);
1246 nsAString_Finish(&ns_html
);
1248 if(NS_FAILED(nsres
) || !nsnode
)
1250 ERR("CreateTextNode failed: %08x\n", nsres
);
1254 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1255 nsIDOMNode_Release(nsnode
);
1260 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1263 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1269 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1271 if(!This
->node
.doc
->nsdoc
) {
1272 WARN("NULL nsdoc\n");
1273 return E_UNEXPECTED
;
1277 nsAString_InitDepend(&ns_text
, text
);
1278 nsres
= nsIDOMDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1279 nsAString_Finish(&ns_text
);
1281 if(NS_FAILED(nsres
) || !nsnode
)
1283 ERR("CreateTextNode failed: %08x\n", nsres
);
1287 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1288 nsIDOMNode_Release(nsnode
);
1293 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1295 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1296 FIXME("(%p)->(%p)\n", This
, p
);
1300 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1302 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1303 FIXME("(%p)->(%p)\n", This
, p
);
1307 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1309 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1311 TRACE("(%p)\n", This
);
1313 return call_event(&This
->node
, EVENTID_CLICK
);
1316 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1317 IHTMLFiltersCollection
**p
)
1319 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1320 TRACE("(%p)->(%p)\n", This
, p
);
1325 *p
= HTMLFiltersCollection_Create();
1330 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1332 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1333 FIXME("(%p)->()\n", This
);
1337 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1339 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1340 FIXME("(%p)->(%p)\n", This
, p
);
1344 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1346 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1347 FIXME("(%p)->(%p)\n", This
, String
);
1351 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1353 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1354 FIXME("(%p)->()\n", This
);
1358 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1360 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1361 FIXME("(%p)->(%p)\n", This
, p
);
1365 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1367 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1368 FIXME("(%p)->()\n", This
);
1372 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1374 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1375 FIXME("(%p)->(%p)\n", This
, p
);
1379 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1381 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1382 FIXME("(%p)->()\n", This
);
1386 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1388 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1389 FIXME("(%p)->(%p)\n", This
, p
);
1393 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1395 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1396 FIXME("(%p)->()\n", This
);
1400 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1402 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1403 FIXME("(%p)->(%p)\n", This
, p
);
1407 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1409 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1410 FIXME("(%p)->()\n", This
);
1414 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1416 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1417 FIXME("(%p)->(%p)\n", This
, p
);
1421 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1423 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1424 FIXME("(%p)->()\n", This
);
1428 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1430 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1431 FIXME("(%p)->(%p)\n", This
, p
);
1435 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1437 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1438 FIXME("(%p)->()\n", This
);
1442 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1444 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1445 FIXME("(%p)->(%p)\n", This
, p
);
1449 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1451 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1452 FIXME("(%p)->()\n", This
);
1456 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1458 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1459 FIXME("(%p)->(%p)\n", This
, p
);
1463 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1465 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1466 FIXME("(%p)->()\n", This
);
1470 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1472 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1473 FIXME("(%p)->(%p)\n", This
, p
);
1477 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1479 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1480 nsIDOMNodeList
*nsnode_list
;
1483 TRACE("(%p)->(%p)\n", This
, p
);
1485 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1486 if(NS_FAILED(nsres
)) {
1487 ERR("GetChildNodes failed: %08x\n", nsres
);
1491 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
,
1492 (IUnknown
*)&This
->IHTMLElement_iface
, nsnode_list
);
1494 nsIDOMNodeList_Release(nsnode_list
);
1498 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1500 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1502 TRACE("(%p)->(%p)\n", This
, p
);
1504 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1508 static const IHTMLElementVtbl HTMLElementVtbl
= {
1509 HTMLElement_QueryInterface
,
1511 HTMLElement_Release
,
1512 HTMLElement_GetTypeInfoCount
,
1513 HTMLElement_GetTypeInfo
,
1514 HTMLElement_GetIDsOfNames
,
1516 HTMLElement_setAttribute
,
1517 HTMLElement_getAttribute
,
1518 HTMLElement_removeAttribute
,
1519 HTMLElement_put_className
,
1520 HTMLElement_get_className
,
1523 HTMLElement_get_tagName
,
1524 HTMLElement_get_parentElement
,
1525 HTMLElement_get_style
,
1526 HTMLElement_put_onhelp
,
1527 HTMLElement_get_onhelp
,
1528 HTMLElement_put_onclick
,
1529 HTMLElement_get_onclick
,
1530 HTMLElement_put_ondblclick
,
1531 HTMLElement_get_ondblclick
,
1532 HTMLElement_put_onkeydown
,
1533 HTMLElement_get_onkeydown
,
1534 HTMLElement_put_onkeyup
,
1535 HTMLElement_get_onkeyup
,
1536 HTMLElement_put_onkeypress
,
1537 HTMLElement_get_onkeypress
,
1538 HTMLElement_put_onmouseout
,
1539 HTMLElement_get_onmouseout
,
1540 HTMLElement_put_onmouseover
,
1541 HTMLElement_get_onmouseover
,
1542 HTMLElement_put_onmousemove
,
1543 HTMLElement_get_onmousemove
,
1544 HTMLElement_put_onmousedown
,
1545 HTMLElement_get_onmousedown
,
1546 HTMLElement_put_onmouseup
,
1547 HTMLElement_get_onmouseup
,
1548 HTMLElement_get_document
,
1549 HTMLElement_put_title
,
1550 HTMLElement_get_title
,
1551 HTMLElement_put_language
,
1552 HTMLElement_get_language
,
1553 HTMLElement_put_onselectstart
,
1554 HTMLElement_get_onselectstart
,
1555 HTMLElement_scrollIntoView
,
1556 HTMLElement_contains
,
1557 HTMLElement_get_sourceIndex
,
1558 HTMLElement_get_recordNumber
,
1559 HTMLElement_put_lang
,
1560 HTMLElement_get_lang
,
1561 HTMLElement_get_offsetLeft
,
1562 HTMLElement_get_offsetTop
,
1563 HTMLElement_get_offsetWidth
,
1564 HTMLElement_get_offsetHeight
,
1565 HTMLElement_get_offsetParent
,
1566 HTMLElement_put_innerHTML
,
1567 HTMLElement_get_innerHTML
,
1568 HTMLElement_put_innerText
,
1569 HTMLElement_get_innerText
,
1570 HTMLElement_put_outerHTML
,
1571 HTMLElement_get_outerHTML
,
1572 HTMLElement_put_outerText
,
1573 HTMLElement_get_outerText
,
1574 HTMLElement_insertAdjacentHTML
,
1575 HTMLElement_insertAdjacentText
,
1576 HTMLElement_get_parentTextEdit
,
1577 HTMLElement_get_isTextEdit
,
1579 HTMLElement_get_filters
,
1580 HTMLElement_put_ondragstart
,
1581 HTMLElement_get_ondragstart
,
1582 HTMLElement_toString
,
1583 HTMLElement_put_onbeforeupdate
,
1584 HTMLElement_get_onbeforeupdate
,
1585 HTMLElement_put_onafterupdate
,
1586 HTMLElement_get_onafterupdate
,
1587 HTMLElement_put_onerrorupdate
,
1588 HTMLElement_get_onerrorupdate
,
1589 HTMLElement_put_onrowexit
,
1590 HTMLElement_get_onrowexit
,
1591 HTMLElement_put_onrowenter
,
1592 HTMLElement_get_onrowenter
,
1593 HTMLElement_put_ondatasetchanged
,
1594 HTMLElement_get_ondatasetchanged
,
1595 HTMLElement_put_ondataavailable
,
1596 HTMLElement_get_ondataavailable
,
1597 HTMLElement_put_ondatasetcomplete
,
1598 HTMLElement_get_ondatasetcomplete
,
1599 HTMLElement_put_onfilterchange
,
1600 HTMLElement_get_onfilterchange
,
1601 HTMLElement_get_children
,
1605 static inline HTMLElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
1607 return CONTAINING_RECORD(iface
, HTMLElement
, node
);
1610 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1612 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1616 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1617 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1618 *ppv
= &This
->IHTMLElement_iface
;
1619 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1620 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1621 *ppv
= &This
->IHTMLElement_iface
;
1622 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1623 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
1624 *ppv
= &This
->IHTMLElement_iface
;
1625 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1626 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
1627 *ppv
= &This
->IHTMLElement2_iface
;
1628 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1629 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This
, ppv
);
1630 *ppv
= &This
->IHTMLElement3_iface
;
1631 }else if(IsEqualGUID(&IID_IHTMLElement4
, riid
)) {
1632 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This
, ppv
);
1633 *ppv
= &This
->IHTMLElement4_iface
;
1634 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1635 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1636 *ppv
= &This
->cp_container
.IConnectionPointContainer_iface
;
1640 IHTMLElement_AddRef(&This
->IHTMLElement_iface
);
1644 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1647 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1649 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1650 HTMLDOMAttribute
*attr
;
1652 while(!list_empty(&This
->attrs
)) {
1653 attr
= LIST_ENTRY(list_head(&This
->attrs
), HTMLDOMAttribute
, entry
);
1655 list_remove(&attr
->entry
);
1657 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
1660 ConnectionPointContainer_Destroy(&This
->cp_container
);
1663 nsIDOMHTMLElement_Release(This
->nselem
);
1665 IHTMLStyle_Release(&This
->style
->IHTMLStyle_iface
);
1667 HTMLDOMNode_destructor(&This
->node
);
1670 HRESULT
HTMLElement_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
1672 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1673 HTMLElement
*new_elem
;
1676 hres
= HTMLElement_Create(This
->node
.doc
, nsnode
, FALSE
, &new_elem
);
1680 IHTMLElement_AddRef(&new_elem
->IHTMLElement_iface
);
1681 *ret
= &new_elem
->node
;
1685 static const NodeImplVtbl HTMLElementImplVtbl
= {
1687 HTMLElement_destructor
,
1691 static inline HTMLElement
*impl_from_DispatchEx(DispatchEx
*iface
)
1693 return CONTAINING_RECORD(iface
, HTMLElement
, node
.dispex
);
1696 static HRESULT
HTMLElement_get_dispid(DispatchEx
*dispex
, BSTR name
,
1697 DWORD grfdex
, DISPID
*pid
)
1699 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1701 if(This
->node
.vtbl
->get_dispid
)
1702 return This
->node
.vtbl
->get_dispid(&This
->node
, name
, grfdex
, pid
);
1704 return DISP_E_UNKNOWNNAME
;
1707 static HRESULT
HTMLElement_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
1708 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
1709 IServiceProvider
*caller
)
1711 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1713 if(This
->node
.vtbl
->invoke
)
1714 return This
->node
.vtbl
->invoke(&This
->node
, id
, lcid
, flags
,
1715 params
, res
, ei
, caller
);
1717 ERR("(%p): element has no invoke method\n", This
);
1721 static const tid_t HTMLElement_iface_tids
[] = {
1726 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl
= {
1728 HTMLElement_get_dispid
,
1732 static dispex_static_data_t HTMLElement_dispex
= {
1733 &HTMLElement_dispex_vtbl
,
1734 DispHTMLUnknownElement_tid
,
1736 HTMLElement_iface_tids
1739 void HTMLElement_Init(HTMLElement
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, dispex_static_data_t
*dispex_data
)
1741 This
->IHTMLElement_iface
.lpVtbl
= &HTMLElementVtbl
;
1743 HTMLElement2_Init(This
);
1744 HTMLElement3_Init(This
);
1746 if(dispex_data
&& !dispex_data
->vtbl
)
1747 dispex_data
->vtbl
= &HTMLElement_dispex_vtbl
;
1748 init_dispex(&This
->node
.dispex
, (IUnknown
*)&This
->IHTMLElement_iface
,
1749 dispex_data
? dispex_data
: &HTMLElement_dispex
);
1752 nsIDOMHTMLElement_AddRef(nselem
);
1753 This
->nselem
= nselem
;
1754 list_init(&This
->attrs
);
1756 HTMLDOMNode_Init(doc
, &This
->node
, (nsIDOMNode
*)nselem
);
1758 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)&This
->IHTMLElement_iface
);
1761 HRESULT
HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
, HTMLElement
**ret
)
1763 nsIDOMHTMLElement
*nselem
;
1764 nsAString class_name_str
;
1765 const PRUnichar
*class_name
;
1766 const tag_desc_t
*tag
;
1771 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1772 if(NS_FAILED(nsres
))
1775 nsAString_Init(&class_name_str
, NULL
);
1776 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1778 nsAString_GetData(&class_name_str
, &class_name
);
1780 tag
= get_tag_desc(class_name
);
1782 hres
= tag
->constructor(doc
, nselem
, &elem
);
1783 }else if(use_generic
) {
1784 hres
= HTMLGenericElement_Create(doc
, nselem
, &elem
);
1786 elem
= heap_alloc_zero(sizeof(HTMLElement
));
1788 HTMLElement_Init(elem
, doc
, nselem
, &HTMLElement_dispex
);
1789 elem
->node
.vtbl
= &HTMLElementImplVtbl
;
1792 hres
= E_OUTOFMEMORY
;
1796 TRACE("%s ret %p\n", debugstr_w(class_name
), elem
);
1798 nsIDOMElement_Release(nselem
);
1799 nsAString_Finish(&class_name_str
);
1807 /* interface IHTMLFiltersCollection */
1808 static HRESULT WINAPI
HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection
*iface
, REFIID riid
, void **ppv
)
1810 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1812 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
1814 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1815 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1816 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1817 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection
, riid
)) {
1818 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This
, ppv
);
1819 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1820 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
1821 return *ppv
? S_OK
: E_NOINTERFACE
;
1825 IUnknown_AddRef((IUnknown
*)*ppv
);
1829 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1830 return E_NOINTERFACE
;
1833 static ULONG WINAPI
HTMLFiltersCollection_AddRef(IHTMLFiltersCollection
*iface
)
1835 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1836 LONG ref
= InterlockedIncrement(&This
->ref
);
1838 TRACE("(%p) ref=%d\n", This
, ref
);
1843 static ULONG WINAPI
HTMLFiltersCollection_Release(IHTMLFiltersCollection
*iface
)
1845 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1846 LONG ref
= InterlockedDecrement(&This
->ref
);
1848 TRACE("(%p) ref=%d\n", This
, ref
);
1858 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection
*iface
, UINT
*pctinfo
)
1860 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1861 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
1864 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection
*iface
,
1865 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1867 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1868 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1871 static HRESULT WINAPI
HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection
*iface
,
1872 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
,
1873 LCID lcid
, DISPID
*rgDispId
)
1875 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1876 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
1880 static HRESULT WINAPI
HTMLFiltersCollection_Invoke(IHTMLFiltersCollection
*iface
, DISPID dispIdMember
, REFIID riid
,
1881 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
1882 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1884 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1885 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
1886 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1889 static HRESULT WINAPI
HTMLFiltersCollection_get_length(IHTMLFiltersCollection
*iface
, LONG
*p
)
1891 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1896 FIXME("(%p)->(%p) Always returning 0\n", This
, p
);
1902 static HRESULT WINAPI
HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection
*iface
, IUnknown
**p
)
1904 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1905 FIXME("(%p)->(%p)\n", This
, p
);
1909 static HRESULT WINAPI
HTMLFiltersCollection_item(IHTMLFiltersCollection
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
1911 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1912 FIXME("(%p)->(%p, %p)\n", This
, pvarIndex
, pvarResult
);
1916 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl
= {
1917 HTMLFiltersCollection_QueryInterface
,
1918 HTMLFiltersCollection_AddRef
,
1919 HTMLFiltersCollection_Release
,
1920 HTMLFiltersCollection_GetTypeInfoCount
,
1921 HTMLFiltersCollection_GetTypeInfo
,
1922 HTMLFiltersCollection_GetIDsOfNames
,
1923 HTMLFiltersCollection_Invoke
,
1924 HTMLFiltersCollection_get_length
,
1925 HTMLFiltersCollection_get__newEnum
,
1926 HTMLFiltersCollection_item
1929 static HRESULT
HTMLFiltersCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
1934 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
1935 idx
= idx
*10 + (*ptr
-'0');
1937 return DISP_E_UNKNOWNNAME
;
1939 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
1940 TRACE("ret %x\n", *dispid
);
1944 static HRESULT
HTMLFiltersCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
1945 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
1947 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex
, id
, lcid
, flags
, params
, res
, ei
);
1949 V_VT(res
) = VT_DISPATCH
;
1950 V_DISPATCH(res
) = NULL
;
1952 FIXME("always returning NULL\n");
1957 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl
= {
1959 HTMLFiltersCollection_get_dispid
,
1960 HTMLFiltersCollection_invoke
1963 static const tid_t HTMLFiltersCollection_iface_tids
[] = {
1964 IHTMLFiltersCollection_tid
,
1967 static dispex_static_data_t HTMLFiltersCollection_dispex
= {
1968 &HTMLFiltersCollection_dispex_vtbl
,
1969 IHTMLFiltersCollection_tid
,
1971 HTMLFiltersCollection_iface_tids
1974 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void)
1976 HTMLFiltersCollection
*ret
= heap_alloc(sizeof(HTMLFiltersCollection
));
1978 ret
->IHTMLFiltersCollection_iface
.lpVtbl
= &HTMLFiltersCollectionVtbl
;
1981 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLFiltersCollection_iface
,
1982 &HTMLFiltersCollection_dispex
);
1984 return &ret
->IHTMLFiltersCollection_iface
;