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"
33 #include "mshtml_private.h"
34 #include "htmlevent.h"
35 #include "htmlstyle.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
39 static const WCHAR aW
[] = {'A',0};
40 static const WCHAR bodyW
[] = {'B','O','D','Y',0};
41 static const WCHAR buttonW
[] = {'B','U','T','T','O','N',0};
42 static const WCHAR embedW
[] = {'E','M','B','E','D',0};
43 static const WCHAR formW
[] = {'F','O','R','M',0};
44 static const WCHAR frameW
[] = {'F','R','A','M','E',0};
45 static const WCHAR headW
[] = {'H','E','A','D',0};
46 static const WCHAR iframeW
[] = {'I','F','R','A','M','E',0};
47 static const WCHAR imgW
[] = {'I','M','G',0};
48 static const WCHAR inputW
[] = {'I','N','P','U','T',0};
49 static const WCHAR labelW
[] = {'L','A','B','E','L',0};
50 static const WCHAR linkW
[] = {'L','I','N','K',0};
51 static const WCHAR metaW
[] = {'M','E','T','A',0};
52 static const WCHAR objectW
[] = {'O','B','J','E','C','T',0};
53 static const WCHAR optionW
[] = {'O','P','T','I','O','N',0};
54 static const WCHAR scriptW
[] = {'S','C','R','I','P','T',0};
55 static const WCHAR selectW
[] = {'S','E','L','E','C','T',0};
56 static const WCHAR styleW
[] = {'S','T','Y','L','E',0};
57 static const WCHAR tableW
[] = {'T','A','B','L','E',0};
58 static const WCHAR tdW
[] = {'T','D',0};
59 static const WCHAR textareaW
[] = {'T','E','X','T','A','R','E','A',0};
60 static const WCHAR title_tagW
[]= {'T','I','T','L','E',0};
61 static const WCHAR trW
[] = {'T','R',0};
65 HRESULT (*constructor
)(HTMLDocumentNode
*,nsIDOMHTMLElement
*,HTMLElement
**);
68 static const tag_desc_t tag_descs
[] = {
69 {aW
, HTMLAnchorElement_Create
},
70 {bodyW
, HTMLBodyElement_Create
},
71 {buttonW
, HTMLButtonElement_Create
},
72 {embedW
, HTMLEmbedElement_Create
},
73 {formW
, HTMLFormElement_Create
},
74 {frameW
, HTMLFrameElement_Create
},
75 {headW
, HTMLHeadElement_Create
},
76 {iframeW
, HTMLIFrame_Create
},
77 {imgW
, HTMLImgElement_Create
},
78 {inputW
, HTMLInputElement_Create
},
79 {labelW
, HTMLLabelElement_Create
},
80 {linkW
, HTMLLinkElement_Create
},
81 {metaW
, HTMLMetaElement_Create
},
82 {objectW
, HTMLObjectElement_Create
},
83 {optionW
, HTMLOptionElement_Create
},
84 {scriptW
, HTMLScriptElement_Create
},
85 {selectW
, HTMLSelectElement_Create
},
86 {styleW
, HTMLStyleElement_Create
},
87 {tableW
, HTMLTable_Create
},
88 {tdW
, HTMLTableCell_Create
},
89 {textareaW
, HTMLTextAreaElement_Create
},
90 {title_tagW
, HTMLTitleElement_Create
},
91 {trW
, HTMLTableRow_Create
}
94 static const tag_desc_t
*get_tag_desc(const WCHAR
*tag_name
)
96 DWORD min
=0, max
=sizeof(tag_descs
)/sizeof(*tag_descs
)-1, i
;
101 r
= strcmpW(tag_name
, tag_descs
[i
].name
);
114 HRESULT
replace_node_by_html(nsIDOMHTMLDocument
*nsdoc
, nsIDOMNode
*nsnode
, const WCHAR
*html
)
116 nsIDOMDocumentFragment
*nsfragment
;
117 nsIDOMNode
*nsparent
;
123 nsres
= nsIDOMHTMLDocument_CreateRange(nsdoc
, &range
);
124 if(NS_FAILED(nsres
)) {
125 ERR("CreateRange failed: %08x\n", nsres
);
129 nsAString_InitDepend(&html_str
, html
);
130 nsIDOMRange_CreateContextualFragment(range
, &html_str
, &nsfragment
);
131 nsIDOMRange_Release(range
);
132 nsAString_Finish(&html_str
);
133 if(NS_FAILED(nsres
)) {
134 ERR("CreateContextualFragment failed: %08x\n", nsres
);
138 nsres
= nsIDOMNode_GetParentNode(nsnode
, &nsparent
);
139 if(NS_SUCCEEDED(nsres
) && nsparent
) {
142 nsres
= nsIDOMNode_ReplaceChild(nsparent
, (nsIDOMNode
*)nsfragment
, nsnode
, &nstmp
);
143 nsIDOMNode_Release(nsparent
);
144 if(NS_FAILED(nsres
)) {
145 ERR("ReplaceChild failed: %08x\n", nsres
);
148 nsIDOMNode_Release(nstmp
);
151 ERR("GetParentNode failed: %08x\n", nsres
);
155 nsIDOMDocumentFragment_Release(nsfragment
);
159 nsresult
get_elem_attr_value(nsIDOMHTMLElement
*nselem
, const WCHAR
*name
, nsAString
*val_str
, const PRUnichar
**val
)
164 nsAString_InitDepend(&name_str
, name
);
165 nsAString_Init(val_str
, NULL
);
166 nsres
= nsIDOMHTMLElement_GetAttribute(nselem
, &name_str
, val_str
);
167 nsAString_Finish(&name_str
);
168 if(NS_FAILED(nsres
)) {
169 ERR("GetAttribute(%s) failed: %08x\n", debugstr_w(name
), nsres
);
170 nsAString_Finish(val_str
);
174 nsAString_GetData(val_str
, val
);
178 HRESULT
elem_string_attr_getter(HTMLElement
*elem
, const WCHAR
*name
, BOOL use_null
, BSTR
*p
)
180 const PRUnichar
*val
;
185 nsres
= get_elem_attr_value(elem
->nselem
, name
, &val_str
, &val
);
189 TRACE("%s: returning %s\n", debugstr_w(name
), debugstr_w(val
));
191 if(*val
|| !use_null
) {
192 *p
= SysAllocString(val
);
194 hres
= E_OUTOFMEMORY
;
198 nsAString_Finish(&val_str
);
202 HRESULT
elem_string_attr_setter(HTMLElement
*elem
, const WCHAR
*name
, const WCHAR
*value
)
204 nsAString name_str
, val_str
;
207 nsAString_InitDepend(&name_str
, name
);
208 nsAString_InitDepend(&val_str
, value
);
209 nsres
= nsIDOMHTMLElement_SetAttribute(elem
->nselem
, &name_str
, &val_str
);
210 nsAString_Finish(&name_str
);
211 nsAString_Finish(&val_str
);
213 if(NS_FAILED(nsres
)) {
214 WARN("SetAttribute failed: %08x\n", nsres
);
224 IHTMLFiltersCollection IHTMLFiltersCollection_iface
;
227 } HTMLFiltersCollection
;
229 static inline HTMLFiltersCollection
*impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection
*iface
)
231 return CONTAINING_RECORD(iface
, HTMLFiltersCollection
, IHTMLFiltersCollection_iface
);
234 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void);
236 static inline HTMLElement
*impl_from_IHTMLElement(IHTMLElement
*iface
)
238 return CONTAINING_RECORD(iface
, HTMLElement
, IHTMLElement_iface
);
241 HRESULT
create_nselem(HTMLDocumentNode
*doc
, const WCHAR
*tag
, nsIDOMHTMLElement
**ret
)
243 nsIDOMElement
*nselem
;
248 WARN("NULL nsdoc\n");
252 nsAString_InitDepend(&tag_str
, tag
);
253 nsres
= nsIDOMHTMLDocument_CreateElement(doc
->nsdoc
, &tag_str
, &nselem
);
254 nsAString_Finish(&tag_str
);
255 if(NS_FAILED(nsres
)) {
256 ERR("CreateElement failed: %08x\n", nsres
);
260 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLElement
, (void**)ret
);
261 nsIDOMElement_Release(nselem
);
262 if(NS_FAILED(nsres
)) {
263 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres
);
270 HRESULT
create_element(HTMLDocumentNode
*doc
, const WCHAR
*tag
, HTMLElement
**ret
)
272 nsIDOMHTMLElement
*nselem
;
275 /* Use owner doc if called on document fragment */
279 hres
= create_nselem(doc
, tag
, &nselem
);
283 hres
= HTMLElement_Create(doc
, (nsIDOMNode
*)nselem
, TRUE
, ret
);
284 nsIDOMHTMLElement_Release(nselem
);
288 static HRESULT WINAPI
HTMLElement_QueryInterface(IHTMLElement
*iface
,
289 REFIID riid
, void **ppv
)
291 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
293 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
296 static ULONG WINAPI
HTMLElement_AddRef(IHTMLElement
*iface
)
298 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
300 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
303 static ULONG WINAPI
HTMLElement_Release(IHTMLElement
*iface
)
305 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
307 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
310 static HRESULT WINAPI
HTMLElement_GetTypeInfoCount(IHTMLElement
*iface
, UINT
*pctinfo
)
312 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
313 return IDispatchEx_GetTypeInfoCount(&This
->node
.dispex
.IDispatchEx_iface
, pctinfo
);
316 static HRESULT WINAPI
HTMLElement_GetTypeInfo(IHTMLElement
*iface
, UINT iTInfo
,
317 LCID lcid
, ITypeInfo
**ppTInfo
)
319 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
320 return IDispatchEx_GetTypeInfo(&This
->node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
323 static HRESULT WINAPI
HTMLElement_GetIDsOfNames(IHTMLElement
*iface
, REFIID riid
,
324 LPOLESTR
*rgszNames
, UINT cNames
,
325 LCID lcid
, DISPID
*rgDispId
)
327 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
328 return IDispatchEx_GetIDsOfNames(&This
->node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
332 static HRESULT WINAPI
HTMLElement_Invoke(IHTMLElement
*iface
, DISPID dispIdMember
,
333 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
334 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
336 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
337 return IDispatchEx_Invoke(&This
->node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
338 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
341 static HRESULT WINAPI
HTMLElement_setAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
342 VARIANT AttributeValue
, LONG lFlags
)
344 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
346 DISPID dispid
, dispidNamed
= DISPID_PROPERTYPUT
;
347 DISPPARAMS dispParams
;
350 TRACE("(%p)->(%s %s %08x)\n", This
, debugstr_w(strAttributeName
), debugstr_variant(&AttributeValue
), lFlags
);
352 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
353 fdexNameCaseInsensitive
| fdexNameEnsure
, &dispid
);
357 dispParams
.cArgs
= 1;
358 dispParams
.cNamedArgs
= 1;
359 dispParams
.rgdispidNamedArgs
= &dispidNamed
;
360 dispParams
.rgvarg
= &AttributeValue
;
362 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
,
363 LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYPUT
, &dispParams
, NULL
, &excep
, NULL
);
367 static HRESULT WINAPI
HTMLElement_getAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
368 LONG lFlags
, VARIANT
*AttributeValue
)
370 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
373 DISPPARAMS dispParams
= {NULL
, NULL
, 0, 0};
376 TRACE("(%p)->(%s %08x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, AttributeValue
);
378 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
379 fdexNameCaseInsensitive
, &dispid
);
380 if(hres
== DISP_E_UNKNOWNNAME
) {
381 V_VT(AttributeValue
) = VT_NULL
;
386 V_VT(AttributeValue
) = VT_NULL
;
390 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
, LOCALE_SYSTEM_DEFAULT
,
391 DISPATCH_PROPERTYGET
, &dispParams
, AttributeValue
, &excep
, NULL
);
396 static HRESULT WINAPI
HTMLElement_removeAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
397 LONG lFlags
, VARIANT_BOOL
*pfSuccess
)
399 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
401 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, pfSuccess
);
403 return remove_prop(&This
->node
.dispex
, strAttributeName
, pfSuccess
);
406 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
408 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
409 nsAString classname_str
;
412 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
415 FIXME("NULL nselem\n");
419 nsAString_InitDepend(&classname_str
, v
);
420 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
421 nsAString_Finish(&classname_str
);
423 ERR("SetClassName failed: %08x\n", nsres
);
428 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
430 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
434 TRACE("(%p)->(%p)\n", This
, p
);
437 FIXME("NULL nselem\n");
441 nsAString_Init(&class_str
, NULL
);
442 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
443 return return_nsstr(nsres
, &class_str
, p
);
446 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
448 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
452 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
455 FIXME("nselem == NULL\n");
459 nsAString_InitDepend(&id_str
, v
);
460 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
461 nsAString_Finish(&id_str
);
463 ERR("SetId failed: %08x\n", nsres
);
468 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
470 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
474 TRACE("(%p)->(%p)\n", This
, p
);
481 nsAString_Init(&id_str
, NULL
);
482 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
483 return return_nsstr(nsres
, &id_str
, p
);
486 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
488 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
492 TRACE("(%p)->(%p)\n", This
, p
);
495 static const WCHAR comment_tagW
[] = {'!',0};
497 WARN("NULL nselem, assuming comment\n");
499 *p
= SysAllocString(comment_tagW
);
500 return *p
? S_OK
: E_OUTOFMEMORY
;
503 nsAString_Init(&tag_str
, NULL
);
504 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
505 return return_nsstr(nsres
, &tag_str
, p
);
508 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
510 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
514 TRACE("(%p)->(%p)\n", This
, p
);
516 hres
= IHTMLDOMNode_get_parentNode(&This
->node
.IHTMLDOMNode_iface
, &node
);
520 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
521 IHTMLDOMNode_Release(node
);
528 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
530 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
532 TRACE("(%p)->(%p)\n", This
, p
);
537 hres
= HTMLStyle_Create(This
, &This
->style
);
542 *p
= &This
->style
->IHTMLStyle_iface
;
543 IHTMLStyle_AddRef(*p
);
547 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
549 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
550 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
554 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
556 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
557 FIXME("(%p)->(%p)\n", This
, p
);
561 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
563 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
565 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
567 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
570 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
572 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
574 TRACE("(%p)->(%p)\n", This
, p
);
576 return get_node_event(&This
->node
, EVENTID_CLICK
, p
);
579 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
581 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
583 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
585 return set_node_event(&This
->node
, EVENTID_DBLCLICK
, &v
);
588 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
590 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
592 TRACE("(%p)->(%p)\n", This
, p
);
594 return get_node_event(&This
->node
, EVENTID_DBLCLICK
, p
);
597 static HRESULT WINAPI
HTMLElement_put_onkeydown(IHTMLElement
*iface
, VARIANT v
)
599 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
601 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
603 return set_node_event(&This
->node
, EVENTID_KEYDOWN
, &v
);
606 static HRESULT WINAPI
HTMLElement_get_onkeydown(IHTMLElement
*iface
, VARIANT
*p
)
608 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
610 TRACE("(%p)->(%p)\n", This
, p
);
612 return get_node_event(&This
->node
, EVENTID_KEYDOWN
, p
);
615 static HRESULT WINAPI
HTMLElement_put_onkeyup(IHTMLElement
*iface
, VARIANT v
)
617 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
619 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
621 return set_node_event(&This
->node
, EVENTID_KEYUP
, &v
);
624 static HRESULT WINAPI
HTMLElement_get_onkeyup(IHTMLElement
*iface
, VARIANT
*p
)
626 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
627 FIXME("(%p)->(%p)\n", This
, p
);
631 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
633 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
635 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
637 return set_node_event(&This
->node
, EVENTID_KEYPRESS
, &v
);
640 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
642 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
644 TRACE("(%p)->(%p)\n", This
, p
);
646 return get_node_event(&This
->node
, EVENTID_KEYPRESS
, p
);
649 static HRESULT WINAPI
HTMLElement_put_onmouseout(IHTMLElement
*iface
, VARIANT v
)
651 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
653 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
655 return set_node_event(&This
->node
, EVENTID_MOUSEOUT
, &v
);
658 static HRESULT WINAPI
HTMLElement_get_onmouseout(IHTMLElement
*iface
, VARIANT
*p
)
660 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
662 TRACE("(%p)->(%p)\n", This
, p
);
664 return get_node_event(&This
->node
, EVENTID_MOUSEOUT
, p
);
667 static HRESULT WINAPI
HTMLElement_put_onmouseover(IHTMLElement
*iface
, VARIANT v
)
669 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
671 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
673 return set_node_event(&This
->node
, EVENTID_MOUSEOVER
, &v
);
676 static HRESULT WINAPI
HTMLElement_get_onmouseover(IHTMLElement
*iface
, VARIANT
*p
)
678 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
680 TRACE("(%p)->(%p)\n", This
, p
);
682 return get_node_event(&This
->node
, EVENTID_MOUSEOVER
, p
);
685 static HRESULT WINAPI
HTMLElement_put_onmousemove(IHTMLElement
*iface
, VARIANT v
)
687 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
689 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
691 return set_node_event(&This
->node
, EVENTID_MOUSEMOVE
, &v
);
694 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
696 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
698 TRACE("(%p)->(%p)\n", This
, p
);
700 return get_node_event(&This
->node
, EVENTID_MOUSEMOVE
, p
);
703 static HRESULT WINAPI
HTMLElement_put_onmousedown(IHTMLElement
*iface
, VARIANT v
)
705 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
707 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
709 return set_node_event(&This
->node
, EVENTID_MOUSEDOWN
, &v
);
712 static HRESULT WINAPI
HTMLElement_get_onmousedown(IHTMLElement
*iface
, VARIANT
*p
)
714 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
716 TRACE("(%p)->(%p)\n", This
, p
);
718 return get_node_event(&This
->node
, EVENTID_MOUSEDOWN
, p
);
721 static HRESULT WINAPI
HTMLElement_put_onmouseup(IHTMLElement
*iface
, VARIANT v
)
723 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
725 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
727 return set_node_event(&This
->node
, EVENTID_MOUSEUP
, &v
);
730 static HRESULT WINAPI
HTMLElement_get_onmouseup(IHTMLElement
*iface
, VARIANT
*p
)
732 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
734 TRACE("(%p)->(%p)\n", This
, p
);
736 return get_node_event(&This
->node
, EVENTID_MOUSEUP
, p
);
739 static HRESULT WINAPI
HTMLElement_get_document(IHTMLElement
*iface
, IDispatch
**p
)
741 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
743 TRACE("(%p)->(%p)\n", This
, p
);
748 if(This
->node
.vtbl
->get_document
)
749 return This
->node
.vtbl
->get_document(&This
->node
, p
);
751 *p
= (IDispatch
*)&This
->node
.doc
->basedoc
.IHTMLDocument2_iface
;
752 IDispatch_AddRef(*p
);
756 static const WCHAR titleW
[] = {'t','i','t','l','e',0};
758 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
760 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
764 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
770 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, TRUE
, &var
);
776 V_BSTR(var
) = v
? SysAllocString(v
) : NULL
;
780 nsAString_InitDepend(&title_str
, v
);
781 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
782 nsAString_Finish(&title_str
);
784 ERR("SetTitle failed: %08x\n", nsres
);
789 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
791 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
795 TRACE("(%p)->(%p)\n", This
, p
);
801 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, FALSE
, &var
);
802 if(hres
== DISP_E_UNKNOWNNAME
) {
804 }else if(V_VT(var
) != VT_BSTR
) {
805 FIXME("title = %s\n", debugstr_variant(var
));
808 *p
= V_BSTR(var
) ? SysAllocString(V_BSTR(var
)) : NULL
;
814 nsAString_Init(&title_str
, NULL
);
815 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
816 return return_nsstr(nsres
, &title_str
, p
);
819 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
821 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
822 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
826 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
828 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
829 FIXME("(%p)->(%p)\n", This
, p
);
833 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
835 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
837 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
839 return set_node_event(&This
->node
, EVENTID_SELECTSTART
, &v
);
842 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
844 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
846 TRACE("(%p)->(%p)\n", This
, p
);
848 return get_node_event(&This
->node
, EVENTID_SELECTSTART
, p
);
851 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
853 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
854 cpp_bool start
= TRUE
;
857 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&varargStart
));
859 switch(V_VT(&varargStart
)) {
864 start
= V_BOOL(&varargStart
) != VARIANT_FALSE
;
867 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart
));
871 FIXME("Unsupported for comments\n");
875 nsres
= nsIDOMHTMLElement_ScrollIntoView(This
->nselem
, start
, 1);
876 assert(nsres
== NS_OK
);
881 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
882 VARIANT_BOOL
*pfResult
)
884 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
885 cpp_bool result
= FALSE
;
887 TRACE("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
893 child
= unsafe_impl_from_IHTMLElement(pChild
);
895 ERR("not our element\n");
899 nsres
= nsIDOMNode_Contains(This
->node
.nsnode
, child
->node
.nsnode
, &result
);
900 assert(nsres
== NS_OK
);
903 *pfResult
= result
? VARIANT_TRUE
: VARIANT_FALSE
;
907 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, LONG
*p
)
909 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
910 FIXME("(%p)->(%p)\n", This
, p
);
914 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
916 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
917 FIXME("(%p)->(%p)\n", This
, p
);
921 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
923 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
924 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
928 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
930 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
931 FIXME("(%p)->(%p)\n", This
, p
);
935 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
937 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
940 TRACE("(%p)->(%p)\n", This
, p
);
942 nsres
= nsIDOMHTMLElement_GetOffsetLeft(This
->nselem
, p
);
943 if(NS_FAILED(nsres
)) {
944 ERR("GetOffsetLeft failed: %08x\n", nsres
);
951 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
953 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
956 TRACE("(%p)->(%p)\n", This
, p
);
958 nsres
= nsIDOMHTMLElement_GetOffsetTop(This
->nselem
, p
);
959 if(NS_FAILED(nsres
)) {
960 ERR("GetOffsetTop failed: %08x\n", nsres
);
967 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
969 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
972 TRACE("(%p)->(%p)\n", This
, p
);
974 nsres
= nsIDOMHTMLElement_GetOffsetWidth(This
->nselem
, p
);
975 if(NS_FAILED(nsres
)) {
976 ERR("GetOffsetWidth failed: %08x\n", nsres
);
983 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
985 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
988 TRACE("(%p)->(%p)\n", This
, p
);
990 nsres
= nsIDOMHTMLElement_GetOffsetHeight(This
->nselem
, p
);
991 if(NS_FAILED(nsres
)) {
992 ERR("GetOffsetHeight failed: %08x\n", nsres
);
999 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
1001 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1002 nsIDOMElement
*nsparent
;
1006 TRACE("(%p)->(%p)\n", This
, p
);
1008 nsres
= nsIDOMHTMLElement_GetOffsetParent(This
->nselem
, &nsparent
);
1009 if(NS_FAILED(nsres
)) {
1010 ERR("GetOffsetParent failed: %08x\n", nsres
);
1017 hres
= get_node(This
->node
.doc
, (nsIDOMNode
*)nsparent
, TRUE
, &node
);
1018 nsIDOMElement_Release(nsparent
);
1022 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)p
);
1032 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
1034 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1038 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1041 FIXME("NULL nselem\n");
1045 nsAString_InitDepend(&html_str
, v
);
1046 nsres
= nsIDOMHTMLElement_SetInnerHTML(This
->nselem
, &html_str
);
1047 nsAString_Finish(&html_str
);
1048 if(NS_FAILED(nsres
)) {
1049 FIXME("SetInnerHtml failed %08x\n", nsres
);
1056 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
1058 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1062 TRACE("(%p)->(%p)\n", This
, p
);
1065 FIXME("NULL nselem\n");
1069 nsAString_Init(&html_str
, NULL
);
1070 nsres
= nsIDOMHTMLElement_GetInnerHTML(This
->nselem
, &html_str
);
1071 return return_nsstr(nsres
, &html_str
, p
);
1074 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
1076 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1077 nsIDOMNode
*nschild
, *tmp
;
1078 nsIDOMText
*text_node
;
1082 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1085 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
1086 if(NS_FAILED(nsres
)) {
1087 ERR("GetLastChild failed: %08x\n", nsres
);
1093 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
1094 nsIDOMNode_Release(nschild
);
1095 if(NS_FAILED(nsres
)) {
1096 ERR("RemoveChild failed: %08x\n", nsres
);
1099 nsIDOMNode_Release(tmp
);
1102 nsAString_InitDepend(&text_str
, v
);
1103 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
1104 nsAString_Finish(&text_str
);
1105 if(NS_FAILED(nsres
)) {
1106 ERR("CreateTextNode failed: %08x\n", nsres
);
1110 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
1111 if(NS_FAILED(nsres
)) {
1112 ERR("AppendChild failed: %08x\n", nsres
);
1116 nsIDOMNode_Release(tmp
);
1120 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
1122 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1124 TRACE("(%p)->(%p)\n", This
, p
);
1126 return get_node_text(&This
->node
, p
);
1129 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
1131 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1133 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1135 return replace_node_by_html(This
->node
.doc
->nsdoc
, This
->node
.nsnode
, v
);
1138 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
1140 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1144 WARN("(%p)->(%p) semi-stub\n", This
, p
);
1146 nsAString_Init(&html_str
, NULL
);
1147 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
1148 if(SUCCEEDED(hres
)) {
1149 const PRUnichar
*html
;
1151 nsAString_GetData(&html_str
, &html
);
1152 *p
= SysAllocString(html
);
1154 hres
= E_OUTOFMEMORY
;
1157 nsAString_Finish(&html_str
);
1159 TRACE("ret %s\n", debugstr_w(*p
));
1163 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
1165 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1166 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1170 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
1172 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1173 FIXME("(%p)->(%p)\n", This
, p
);
1177 HRESULT
insert_adjacent_node(HTMLElement
*This
, const WCHAR
*where
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret_node
)
1179 nsIDOMNode
*ret_nsnode
;
1181 HRESULT hres
= S_OK
;
1183 static const WCHAR beforebeginW
[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1184 static const WCHAR afterbeginW
[] = {'a','f','t','e','r','b','e','g','i','n',0};
1185 static const WCHAR beforeendW
[] = {'b','e','f','o','r','e','e','n','d',0};
1186 static const WCHAR afterendW
[] = {'a','f','t','e','r','e','n','d',0};
1188 if (!strcmpiW(where
, beforebeginW
)) {
1191 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1192 if(NS_FAILED(nsres
))
1196 return E_INVALIDARG
;
1198 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, This
->node
.nsnode
, &ret_nsnode
);
1199 nsIDOMNode_Release(parent
);
1200 }else if(!strcmpiW(where
, afterbeginW
)) {
1201 nsIDOMNode
*first_child
;
1203 nsres
= nsIDOMNode_GetFirstChild(This
->node
.nsnode
, &first_child
);
1204 if(NS_FAILED(nsres
))
1207 nsres
= nsIDOMNode_InsertBefore(This
->node
.nsnode
, nsnode
, first_child
, &ret_nsnode
);
1208 if(NS_FAILED(nsres
))
1212 nsIDOMNode_Release(first_child
);
1213 }else if (!strcmpiW(where
, beforeendW
)) {
1214 nsres
= nsIDOMNode_AppendChild(This
->node
.nsnode
, nsnode
, &ret_nsnode
);
1215 }else if (!strcmpiW(where
, afterendW
)) {
1216 nsIDOMNode
*next_sibling
, *parent
;
1218 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1219 if(NS_FAILED(nsres
))
1222 return E_INVALIDARG
;
1224 nsres
= nsIDOMNode_GetNextSibling(This
->node
.nsnode
, &next_sibling
);
1225 if(NS_SUCCEEDED(nsres
)) {
1227 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &ret_nsnode
);
1228 nsIDOMNode_Release(next_sibling
);
1230 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &ret_nsnode
);
1234 nsIDOMNode_Release(parent
);
1236 ERR("invalid where: %s\n", debugstr_w(where
));
1237 return E_INVALIDARG
;
1240 if (NS_FAILED(nsres
))
1244 hres
= get_node(This
->node
.doc
, ret_nsnode
, TRUE
, ret_node
);
1245 nsIDOMNode_Release(ret_nsnode
);
1249 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1252 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1259 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1261 if(!This
->node
.doc
->nsdoc
) {
1262 WARN("NULL nsdoc\n");
1263 return E_UNEXPECTED
;
1266 nsres
= nsIDOMHTMLDocument_CreateRange(This
->node
.doc
->nsdoc
, &range
);
1267 if(NS_FAILED(nsres
))
1269 ERR("CreateRange failed: %08x\n", nsres
);
1273 nsIDOMRange_SetStartBefore(range
, This
->node
.nsnode
);
1275 nsAString_InitDepend(&ns_html
, html
);
1276 nsres
= nsIDOMRange_CreateContextualFragment(range
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1277 nsAString_Finish(&ns_html
);
1278 nsIDOMRange_Release(range
);
1280 if(NS_FAILED(nsres
) || !nsnode
)
1282 ERR("CreateTextNode failed: %08x\n", nsres
);
1286 hr
= insert_adjacent_node(This
, where
, nsnode
, NULL
);
1287 nsIDOMNode_Release(nsnode
);
1291 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1294 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1300 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1302 if(!This
->node
.doc
->nsdoc
) {
1303 WARN("NULL nsdoc\n");
1304 return E_UNEXPECTED
;
1308 nsAString_InitDepend(&ns_text
, text
);
1309 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1310 nsAString_Finish(&ns_text
);
1312 if(NS_FAILED(nsres
) || !nsnode
)
1314 ERR("CreateTextNode failed: %08x\n", nsres
);
1318 hr
= insert_adjacent_node(This
, where
, nsnode
, NULL
);
1319 nsIDOMNode_Release(nsnode
);
1324 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1326 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1327 FIXME("(%p)->(%p)\n", This
, p
);
1331 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1333 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1334 FIXME("(%p)->(%p)\n", This
, p
);
1338 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1340 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1342 TRACE("(%p)\n", This
);
1344 return call_fire_event(&This
->node
, EVENTID_CLICK
);
1347 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1348 IHTMLFiltersCollection
**p
)
1350 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1351 TRACE("(%p)->(%p)\n", This
, p
);
1356 *p
= HTMLFiltersCollection_Create();
1361 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1363 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1364 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1368 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1370 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1371 FIXME("(%p)->(%p)\n", This
, p
);
1375 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1377 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1378 FIXME("(%p)->(%p)\n", This
, String
);
1382 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1384 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1385 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1389 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1391 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1392 FIXME("(%p)->(%p)\n", This
, p
);
1396 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1398 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1399 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1403 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1405 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1406 FIXME("(%p)->(%p)\n", This
, p
);
1410 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1412 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1413 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1417 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1419 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1420 FIXME("(%p)->(%p)\n", This
, p
);
1424 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1426 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1427 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1431 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1433 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1434 FIXME("(%p)->(%p)\n", This
, p
);
1438 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1440 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1441 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1445 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1447 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1448 FIXME("(%p)->(%p)\n", This
, p
);
1452 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1454 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1455 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1459 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1461 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1462 FIXME("(%p)->(%p)\n", This
, p
);
1466 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1468 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1470 FIXME("(%p)->(%s) semi-stub\n", This
, debugstr_variant(&v
));
1472 return set_node_event(&This
->node
, EVENTID_DATAAVAILABLE
, &v
);
1475 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1477 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1479 TRACE("(%p)->(%p)\n", This
, p
);
1481 return get_node_event(&This
->node
, EVENTID_DATAAVAILABLE
, p
);
1484 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1486 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1487 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1491 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1493 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1494 FIXME("(%p)->(%p)\n", This
, p
);
1498 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1500 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1501 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1505 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1507 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1508 FIXME("(%p)->(%p)\n", This
, p
);
1512 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1514 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1515 nsIDOMNodeList
*nsnode_list
;
1518 TRACE("(%p)->(%p)\n", This
, p
);
1520 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1521 if(NS_FAILED(nsres
)) {
1522 ERR("GetChildNodes failed: %08x\n", nsres
);
1526 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, nsnode_list
);
1528 nsIDOMNodeList_Release(nsnode_list
);
1532 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1534 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1536 TRACE("(%p)->(%p)\n", This
, p
);
1538 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1542 static const IHTMLElementVtbl HTMLElementVtbl
= {
1543 HTMLElement_QueryInterface
,
1545 HTMLElement_Release
,
1546 HTMLElement_GetTypeInfoCount
,
1547 HTMLElement_GetTypeInfo
,
1548 HTMLElement_GetIDsOfNames
,
1550 HTMLElement_setAttribute
,
1551 HTMLElement_getAttribute
,
1552 HTMLElement_removeAttribute
,
1553 HTMLElement_put_className
,
1554 HTMLElement_get_className
,
1557 HTMLElement_get_tagName
,
1558 HTMLElement_get_parentElement
,
1559 HTMLElement_get_style
,
1560 HTMLElement_put_onhelp
,
1561 HTMLElement_get_onhelp
,
1562 HTMLElement_put_onclick
,
1563 HTMLElement_get_onclick
,
1564 HTMLElement_put_ondblclick
,
1565 HTMLElement_get_ondblclick
,
1566 HTMLElement_put_onkeydown
,
1567 HTMLElement_get_onkeydown
,
1568 HTMLElement_put_onkeyup
,
1569 HTMLElement_get_onkeyup
,
1570 HTMLElement_put_onkeypress
,
1571 HTMLElement_get_onkeypress
,
1572 HTMLElement_put_onmouseout
,
1573 HTMLElement_get_onmouseout
,
1574 HTMLElement_put_onmouseover
,
1575 HTMLElement_get_onmouseover
,
1576 HTMLElement_put_onmousemove
,
1577 HTMLElement_get_onmousemove
,
1578 HTMLElement_put_onmousedown
,
1579 HTMLElement_get_onmousedown
,
1580 HTMLElement_put_onmouseup
,
1581 HTMLElement_get_onmouseup
,
1582 HTMLElement_get_document
,
1583 HTMLElement_put_title
,
1584 HTMLElement_get_title
,
1585 HTMLElement_put_language
,
1586 HTMLElement_get_language
,
1587 HTMLElement_put_onselectstart
,
1588 HTMLElement_get_onselectstart
,
1589 HTMLElement_scrollIntoView
,
1590 HTMLElement_contains
,
1591 HTMLElement_get_sourceIndex
,
1592 HTMLElement_get_recordNumber
,
1593 HTMLElement_put_lang
,
1594 HTMLElement_get_lang
,
1595 HTMLElement_get_offsetLeft
,
1596 HTMLElement_get_offsetTop
,
1597 HTMLElement_get_offsetWidth
,
1598 HTMLElement_get_offsetHeight
,
1599 HTMLElement_get_offsetParent
,
1600 HTMLElement_put_innerHTML
,
1601 HTMLElement_get_innerHTML
,
1602 HTMLElement_put_innerText
,
1603 HTMLElement_get_innerText
,
1604 HTMLElement_put_outerHTML
,
1605 HTMLElement_get_outerHTML
,
1606 HTMLElement_put_outerText
,
1607 HTMLElement_get_outerText
,
1608 HTMLElement_insertAdjacentHTML
,
1609 HTMLElement_insertAdjacentText
,
1610 HTMLElement_get_parentTextEdit
,
1611 HTMLElement_get_isTextEdit
,
1613 HTMLElement_get_filters
,
1614 HTMLElement_put_ondragstart
,
1615 HTMLElement_get_ondragstart
,
1616 HTMLElement_toString
,
1617 HTMLElement_put_onbeforeupdate
,
1618 HTMLElement_get_onbeforeupdate
,
1619 HTMLElement_put_onafterupdate
,
1620 HTMLElement_get_onafterupdate
,
1621 HTMLElement_put_onerrorupdate
,
1622 HTMLElement_get_onerrorupdate
,
1623 HTMLElement_put_onrowexit
,
1624 HTMLElement_get_onrowexit
,
1625 HTMLElement_put_onrowenter
,
1626 HTMLElement_get_onrowenter
,
1627 HTMLElement_put_ondatasetchanged
,
1628 HTMLElement_get_ondatasetchanged
,
1629 HTMLElement_put_ondataavailable
,
1630 HTMLElement_get_ondataavailable
,
1631 HTMLElement_put_ondatasetcomplete
,
1632 HTMLElement_get_ondatasetcomplete
,
1633 HTMLElement_put_onfilterchange
,
1634 HTMLElement_get_onfilterchange
,
1635 HTMLElement_get_children
,
1639 HTMLElement
*unsafe_impl_from_IHTMLElement(IHTMLElement
*iface
)
1641 return iface
->lpVtbl
== &HTMLElementVtbl
? impl_from_IHTMLElement(iface
) : NULL
;
1644 static inline HTMLElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
1646 return CONTAINING_RECORD(iface
, HTMLElement
, node
);
1649 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1651 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1653 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1654 *ppv
= &This
->IHTMLElement_iface
;
1655 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1656 *ppv
= &This
->IHTMLElement_iface
;
1657 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1658 *ppv
= &This
->IHTMLElement_iface
;
1659 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1660 *ppv
= &This
->IHTMLElement2_iface
;
1661 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1662 *ppv
= &This
->IHTMLElement3_iface
;
1663 }else if(IsEqualGUID(&IID_IHTMLElement4
, riid
)) {
1664 *ppv
= &This
->IHTMLElement4_iface
;
1665 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1666 *ppv
= &This
->cp_container
.IConnectionPointContainer_iface
;
1668 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1671 IUnknown_AddRef((IUnknown
*)*ppv
);
1675 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1677 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1679 ConnectionPointContainer_Destroy(&This
->cp_container
);
1682 This
->style
->elem
= NULL
;
1683 IHTMLStyle_Release(&This
->style
->IHTMLStyle_iface
);
1685 if(This
->runtime_style
) {
1686 This
->runtime_style
->elem
= NULL
;
1687 IHTMLStyle_Release(&This
->runtime_style
->IHTMLStyle_iface
);
1690 HTMLDOMAttribute
*attr
;
1692 LIST_FOR_EACH_ENTRY(attr
, &This
->attrs
->attrs
, HTMLDOMAttribute
, entry
)
1695 This
->attrs
->elem
= NULL
;
1696 IHTMLAttributeCollection_Release(&This
->attrs
->IHTMLAttributeCollection_iface
);
1699 heap_free(This
->filter
);
1701 HTMLDOMNode_destructor(&This
->node
);
1704 HRESULT
HTMLElement_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
1706 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1707 HTMLElement
*new_elem
;
1710 hres
= HTMLElement_Create(This
->node
.doc
, nsnode
, FALSE
, &new_elem
);
1715 new_elem
->filter
= heap_strdupW(This
->filter
);
1716 if(!new_elem
->filter
) {
1717 IHTMLElement_Release(&This
->IHTMLElement_iface
);
1718 return E_OUTOFMEMORY
;
1722 *ret
= &new_elem
->node
;
1726 HRESULT
HTMLElement_handle_event(HTMLDOMNode
*iface
, DWORD eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
1728 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1731 case EVENTID_KEYDOWN
: {
1732 nsIDOMKeyEvent
*key_event
;
1735 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMKeyEvent
, (void**)&key_event
);
1736 if(NS_SUCCEEDED(nsres
)) {
1739 nsIDOMKeyEvent_GetKeyCode(key_event
, &code
);
1742 case VK_F1
: /* DOM_VK_F1 */
1743 TRACE("F1 pressed\n");
1744 fire_event(This
->node
.doc
, EVENTID_HELP
, TRUE
, This
->node
.nsnode
, NULL
, NULL
);
1745 *prevent_default
= TRUE
;
1748 nsIDOMKeyEvent_Release(key_event
);
1756 cp_static_data_t HTMLElementEvents2_data
= { HTMLElementEvents2_tid
, NULL
/* FIXME */, TRUE
};
1758 const cpc_entry_t HTMLElement_cpc
[] = {
1763 static const NodeImplVtbl HTMLElementImplVtbl
= {
1765 HTMLElement_destructor
,
1768 HTMLElement_handle_event
,
1769 HTMLElement_get_attr_col
1772 static inline HTMLElement
*impl_from_DispatchEx(DispatchEx
*iface
)
1774 return CONTAINING_RECORD(iface
, HTMLElement
, node
.dispex
);
1777 static HRESULT
HTMLElement_get_dispid(DispatchEx
*dispex
, BSTR name
,
1778 DWORD grfdex
, DISPID
*pid
)
1780 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1782 if(This
->node
.vtbl
->get_dispid
)
1783 return This
->node
.vtbl
->get_dispid(&This
->node
, name
, grfdex
, pid
);
1785 return DISP_E_UNKNOWNNAME
;
1788 static HRESULT
HTMLElement_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
1789 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
1790 IServiceProvider
*caller
)
1792 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1794 if(This
->node
.vtbl
->invoke
)
1795 return This
->node
.vtbl
->invoke(&This
->node
, id
, lcid
, flags
,
1796 params
, res
, ei
, caller
);
1798 ERR("(%p): element has no invoke method\n", This
);
1802 static HRESULT
HTMLElement_populate_props(DispatchEx
*dispex
)
1804 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1805 nsIDOMMozNamedAttrMap
*attrs
;
1808 const PRUnichar
*str
;
1820 nsres
= nsIDOMHTMLElement_GetAttributes(This
->nselem
, &attrs
);
1821 if(NS_FAILED(nsres
))
1824 nsres
= nsIDOMMozNamedAttrMap_GetLength(attrs
, &len
);
1825 if(NS_FAILED(nsres
)) {
1826 nsIDOMMozNamedAttrMap_Release(attrs
);
1830 nsAString_Init(&nsstr
, NULL
);
1831 for(i
=0; i
<len
; i
++) {
1832 nsres
= nsIDOMMozNamedAttrMap_Item(attrs
, i
, &attr
);
1833 if(NS_FAILED(nsres
))
1836 nsres
= nsIDOMAttr_GetNodeName(attr
, &nsstr
);
1837 if(NS_FAILED(nsres
)) {
1838 nsIDOMAttr_Release(attr
);
1842 nsAString_GetData(&nsstr
, &str
);
1843 name
= SysAllocString(str
);
1845 nsIDOMAttr_Release(attr
);
1849 hres
= IDispatchEx_GetDispID(&dispex
->IDispatchEx_iface
, name
, fdexNameCaseInsensitive
, &id
);
1850 if(hres
!= DISP_E_UNKNOWNNAME
) {
1851 nsIDOMAttr_Release(attr
);
1852 SysFreeString(name
);
1856 nsres
= nsIDOMAttr_GetNodeValue(attr
, &nsstr
);
1857 nsIDOMAttr_Release(attr
);
1858 if(NS_FAILED(nsres
)) {
1859 SysFreeString(name
);
1863 nsAString_GetData(&nsstr
, &str
);
1864 V_VT(&value
) = VT_BSTR
;
1866 V_BSTR(&value
) = SysAllocString(str
);
1867 if(!V_BSTR(&value
)) {
1868 SysFreeString(name
);
1872 V_BSTR(&value
) = NULL
;
1874 IHTMLElement_setAttribute(&This
->IHTMLElement_iface
, name
, value
, 0);
1875 SysFreeString(name
);
1876 VariantClear(&value
);
1878 nsAString_Finish(&nsstr
);
1880 nsIDOMMozNamedAttrMap_Release(attrs
);
1884 static const tid_t HTMLElement_iface_tids
[] = {
1889 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl
= {
1891 HTMLElement_get_dispid
,
1893 HTMLElement_populate_props
1896 static dispex_static_data_t HTMLElement_dispex
= {
1897 &HTMLElement_dispex_vtbl
,
1898 DispHTMLUnknownElement_tid
,
1900 HTMLElement_iface_tids
1903 void HTMLElement_Init(HTMLElement
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, dispex_static_data_t
*dispex_data
)
1905 This
->IHTMLElement_iface
.lpVtbl
= &HTMLElementVtbl
;
1907 HTMLElement2_Init(This
);
1908 HTMLElement3_Init(This
);
1910 if(dispex_data
&& !dispex_data
->vtbl
)
1911 dispex_data
->vtbl
= &HTMLElement_dispex_vtbl
;
1912 init_dispex(&This
->node
.dispex
, (IUnknown
*)&This
->IHTMLElement_iface
,
1913 dispex_data
? dispex_data
: &HTMLElement_dispex
);
1916 HTMLDOMNode_Init(doc
, &This
->node
, (nsIDOMNode
*)nselem
);
1918 /* No AddRef, share reference with HTMLDOMNode */
1919 assert((nsIDOMNode
*)nselem
== This
->node
.nsnode
);
1920 This
->nselem
= nselem
;
1923 This
->node
.cp_container
= &This
->cp_container
;
1924 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)&This
->IHTMLElement_iface
, This
->node
.vtbl
->cpc_entries
);
1927 HRESULT
HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
, HTMLElement
**ret
)
1929 nsIDOMHTMLElement
*nselem
;
1930 nsAString class_name_str
;
1931 const PRUnichar
*class_name
;
1932 const tag_desc_t
*tag
;
1937 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1938 if(NS_FAILED(nsres
))
1941 nsAString_Init(&class_name_str
, NULL
);
1942 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1944 nsAString_GetData(&class_name_str
, &class_name
);
1946 tag
= get_tag_desc(class_name
);
1948 hres
= tag
->constructor(doc
, nselem
, &elem
);
1949 }else if(use_generic
) {
1950 hres
= HTMLGenericElement_Create(doc
, nselem
, &elem
);
1952 elem
= heap_alloc_zero(sizeof(HTMLElement
));
1954 elem
->node
.vtbl
= &HTMLElementImplVtbl
;
1955 HTMLElement_Init(elem
, doc
, nselem
, &HTMLElement_dispex
);
1958 hres
= E_OUTOFMEMORY
;
1962 TRACE("%s ret %p\n", debugstr_w(class_name
), elem
);
1964 nsIDOMHTMLElement_Release(nselem
);
1965 nsAString_Finish(&class_name_str
);
1973 HRESULT
get_elem(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**ret
)
1978 hres
= get_node(doc
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
1982 *ret
= impl_from_HTMLDOMNode(node
);
1986 /* interface IHTMLFiltersCollection */
1987 static HRESULT WINAPI
HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection
*iface
, REFIID riid
, void **ppv
)
1989 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1991 TRACE("%p %s %p\n", This
, debugstr_mshtml_guid(riid
), ppv
);
1993 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1994 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1995 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection
, riid
)) {
1996 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This
, ppv
);
1997 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1998 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
1999 return *ppv
? S_OK
: E_NOINTERFACE
;
2002 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
2003 return E_NOINTERFACE
;
2006 IUnknown_AddRef((IUnknown
*)*ppv
);
2010 static ULONG WINAPI
HTMLFiltersCollection_AddRef(IHTMLFiltersCollection
*iface
)
2012 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2013 LONG ref
= InterlockedIncrement(&This
->ref
);
2015 TRACE("(%p) ref=%d\n", This
, ref
);
2020 static ULONG WINAPI
HTMLFiltersCollection_Release(IHTMLFiltersCollection
*iface
)
2022 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2023 LONG ref
= InterlockedDecrement(&This
->ref
);
2025 TRACE("(%p) ref=%d\n", This
, ref
);
2035 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection
*iface
, UINT
*pctinfo
)
2037 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2038 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2041 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection
*iface
,
2042 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
2044 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2045 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2048 static HRESULT WINAPI
HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection
*iface
,
2049 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
,
2050 LCID lcid
, DISPID
*rgDispId
)
2052 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2053 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2057 static HRESULT WINAPI
HTMLFiltersCollection_Invoke(IHTMLFiltersCollection
*iface
, DISPID dispIdMember
, REFIID riid
,
2058 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
2059 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2061 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2062 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2063 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2066 static HRESULT WINAPI
HTMLFiltersCollection_get_length(IHTMLFiltersCollection
*iface
, LONG
*p
)
2068 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2073 FIXME("(%p)->(%p) Always returning 0\n", This
, p
);
2079 static HRESULT WINAPI
HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection
*iface
, IUnknown
**p
)
2081 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2082 FIXME("(%p)->(%p)\n", This
, p
);
2086 static HRESULT WINAPI
HTMLFiltersCollection_item(IHTMLFiltersCollection
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
2088 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2089 FIXME("(%p)->(%p, %p)\n", This
, pvarIndex
, pvarResult
);
2093 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl
= {
2094 HTMLFiltersCollection_QueryInterface
,
2095 HTMLFiltersCollection_AddRef
,
2096 HTMLFiltersCollection_Release
,
2097 HTMLFiltersCollection_GetTypeInfoCount
,
2098 HTMLFiltersCollection_GetTypeInfo
,
2099 HTMLFiltersCollection_GetIDsOfNames
,
2100 HTMLFiltersCollection_Invoke
,
2101 HTMLFiltersCollection_get_length
,
2102 HTMLFiltersCollection_get__newEnum
,
2103 HTMLFiltersCollection_item
2106 static HRESULT
HTMLFiltersCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2111 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
2112 idx
= idx
*10 + (*ptr
-'0');
2114 return DISP_E_UNKNOWNNAME
;
2116 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
2117 TRACE("ret %x\n", *dispid
);
2121 static HRESULT
HTMLFiltersCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2122 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2124 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex
, id
, lcid
, flags
, params
, res
, ei
);
2126 V_VT(res
) = VT_DISPATCH
;
2127 V_DISPATCH(res
) = NULL
;
2129 FIXME("always returning NULL\n");
2134 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl
= {
2136 HTMLFiltersCollection_get_dispid
,
2137 HTMLFiltersCollection_invoke
,
2141 static const tid_t HTMLFiltersCollection_iface_tids
[] = {
2142 IHTMLFiltersCollection_tid
,
2145 static dispex_static_data_t HTMLFiltersCollection_dispex
= {
2146 &HTMLFiltersCollection_dispex_vtbl
,
2147 IHTMLFiltersCollection_tid
,
2149 HTMLFiltersCollection_iface_tids
2152 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void)
2154 HTMLFiltersCollection
*ret
= heap_alloc(sizeof(HTMLFiltersCollection
));
2156 ret
->IHTMLFiltersCollection_iface
.lpVtbl
= &HTMLFiltersCollectionVtbl
;
2159 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLFiltersCollection_iface
,
2160 &HTMLFiltersCollection_dispex
);
2162 return &ret
->IHTMLFiltersCollection_iface
;
2165 /* interface IHTMLAttributeCollection */
2166 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection
*iface
)
2168 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection_iface
);
2171 static HRESULT WINAPI
HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection
*iface
, REFIID riid
, void **ppv
)
2173 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2175 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
2176 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2177 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection
, riid
)) {
2178 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2179 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2
, riid
)) {
2180 *ppv
= &This
->IHTMLAttributeCollection2_iface
;
2181 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3
, riid
)) {
2182 *ppv
= &This
->IHTMLAttributeCollection3_iface
;
2183 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
2184 return *ppv
? S_OK
: E_NOINTERFACE
;
2187 WARN("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
2188 return E_NOINTERFACE
;
2191 IUnknown_AddRef((IUnknown
*)*ppv
);
2195 static ULONG WINAPI
HTMLAttributeCollection_AddRef(IHTMLAttributeCollection
*iface
)
2197 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2198 LONG ref
= InterlockedIncrement(&This
->ref
);
2200 TRACE("(%p) ref=%d\n", This
, ref
);
2205 static ULONG WINAPI
HTMLAttributeCollection_Release(IHTMLAttributeCollection
*iface
)
2207 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2208 LONG ref
= InterlockedDecrement(&This
->ref
);
2210 TRACE("(%p) ref=%d\n", This
, ref
);
2213 while(!list_empty(&This
->attrs
)) {
2214 HTMLDOMAttribute
*attr
= LIST_ENTRY(list_head(&This
->attrs
), HTMLDOMAttribute
, entry
);
2216 list_remove(&attr
->entry
);
2218 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2227 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection
*iface
, UINT
*pctinfo
)
2229 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2230 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2233 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection
*iface
, UINT iTInfo
,
2234 LCID lcid
, ITypeInfo
**ppTInfo
)
2236 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2237 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2240 static HRESULT WINAPI
HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection
*iface
, REFIID riid
,
2241 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2243 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2244 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2248 static HRESULT WINAPI
HTMLAttributeCollection_Invoke(IHTMLAttributeCollection
*iface
, DISPID dispIdMember
,
2249 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2250 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2252 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2253 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2254 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2257 static HRESULT
get_attr_dispid_by_idx(HTMLAttributeCollection
*This
, LONG
*idx
, DISPID
*dispid
)
2259 IDispatchEx
*dispex
= &This
->elem
->node
.dispex
.IDispatchEx_iface
;
2260 DISPID id
= DISPID_STARTENUM
;
2264 FIXME("filter non-enumerable attributes out\n");
2267 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
2270 else if(hres
== S_FALSE
)
2280 return *idx
==len
? S_OK
: DISP_E_UNKNOWNNAME
;
2287 static inline HRESULT
get_attr_dispid_by_name(HTMLAttributeCollection
*This
, BSTR name
, DISPID
*id
)
2291 if(name
[0]>='0' && name
[0]<='9') {
2295 idx
= strtoulW(name
, &end_ptr
, 10);
2297 hres
= get_attr_dispid_by_idx(This
, &idx
, id
);
2304 WARN("NULL elem\n");
2305 return E_UNEXPECTED
;
2308 hres
= IDispatchEx_GetDispID(&This
->elem
->node
.dispex
.IDispatchEx_iface
,
2309 name
, fdexNameCaseInsensitive
, id
);
2313 static inline HRESULT
get_domattr(HTMLAttributeCollection
*This
, DISPID id
, LONG
*list_pos
, HTMLDOMAttribute
**attr
)
2315 HTMLDOMAttribute
*iter
;
2320 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2321 if(iter
->dispid
== id
) {
2330 WARN("NULL elem\n");
2331 return E_UNEXPECTED
;
2334 hres
= HTMLDOMAttribute_Create(NULL
, This
->elem
, id
, attr
);
2339 IHTMLDOMAttribute_AddRef(&(*attr
)->IHTMLDOMAttribute_iface
);
2345 static HRESULT WINAPI
HTMLAttributeCollection_get_length(IHTMLAttributeCollection
*iface
, LONG
*p
)
2347 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2350 TRACE("(%p)->(%p)\n", This
, p
);
2353 hres
= get_attr_dispid_by_idx(This
, p
, NULL
);
2357 static HRESULT WINAPI
HTMLAttributeCollection__newEnum(IHTMLAttributeCollection
*iface
, IUnknown
**p
)
2359 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2360 FIXME("(%p)->(%p)\n", This
, p
);
2364 static HRESULT WINAPI
HTMLAttributeCollection_item(IHTMLAttributeCollection
*iface
, VARIANT
*name
, IDispatch
**ppItem
)
2366 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2367 HTMLDOMAttribute
*attr
;
2371 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(name
), ppItem
);
2373 switch(V_VT(name
)) {
2375 hres
= get_attr_dispid_by_idx(This
, &V_I4(name
), &id
);
2378 hres
= get_attr_dispid_by_name(This
, V_BSTR(name
), &id
);
2381 FIXME("unsupported name %s\n", debugstr_variant(name
));
2384 if(hres
== DISP_E_UNKNOWNNAME
)
2385 return E_INVALIDARG
;
2389 hres
= get_domattr(This
, id
, NULL
, &attr
);
2393 *ppItem
= (IDispatch
*)&attr
->IHTMLDOMAttribute_iface
;
2397 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl
= {
2398 HTMLAttributeCollection_QueryInterface
,
2399 HTMLAttributeCollection_AddRef
,
2400 HTMLAttributeCollection_Release
,
2401 HTMLAttributeCollection_GetTypeInfoCount
,
2402 HTMLAttributeCollection_GetTypeInfo
,
2403 HTMLAttributeCollection_GetIDsOfNames
,
2404 HTMLAttributeCollection_Invoke
,
2405 HTMLAttributeCollection_get_length
,
2406 HTMLAttributeCollection__newEnum
,
2407 HTMLAttributeCollection_item
2410 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2
*iface
)
2412 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection2_iface
);
2415 static HRESULT WINAPI
HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2
*iface
, REFIID riid
, void **ppv
)
2417 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2418 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2421 static ULONG WINAPI
HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2
*iface
)
2423 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2424 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2427 static ULONG WINAPI
HTMLAttributeCollection2_Release(IHTMLAttributeCollection2
*iface
)
2429 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2430 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2433 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2
*iface
, UINT
*pctinfo
)
2435 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2436 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2439 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2
*iface
, UINT iTInfo
,
2440 LCID lcid
, ITypeInfo
**ppTInfo
)
2442 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2443 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2446 static HRESULT WINAPI
HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2
*iface
, REFIID riid
,
2447 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2449 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2450 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2454 static HRESULT WINAPI
HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2
*iface
, DISPID dispIdMember
,
2455 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2456 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2458 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2459 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2460 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2463 static HRESULT WINAPI
HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2
*iface
, BSTR bstrName
,
2464 IHTMLDOMAttribute
**newretNode
)
2466 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2467 HTMLDOMAttribute
*attr
;
2471 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2473 hres
= get_attr_dispid_by_name(This
, bstrName
, &id
);
2474 if(hres
== DISP_E_UNKNOWNNAME
) {
2477 } else if(FAILED(hres
)) {
2481 hres
= get_domattr(This
, id
, NULL
, &attr
);
2485 *newretNode
= &attr
->IHTMLDOMAttribute_iface
;
2489 static HRESULT WINAPI
HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2
*iface
,
2490 IHTMLDOMAttribute
*ppNode
, IHTMLDOMAttribute
**newretNode
)
2492 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2493 FIXME("(%p)->(%p %p)\n", This
, ppNode
, newretNode
);
2497 static HRESULT WINAPI
HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2
*iface
,
2498 BSTR bstrName
, IHTMLDOMAttribute
**newretNode
)
2500 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2501 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2505 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl
= {
2506 HTMLAttributeCollection2_QueryInterface
,
2507 HTMLAttributeCollection2_AddRef
,
2508 HTMLAttributeCollection2_Release
,
2509 HTMLAttributeCollection2_GetTypeInfoCount
,
2510 HTMLAttributeCollection2_GetTypeInfo
,
2511 HTMLAttributeCollection2_GetIDsOfNames
,
2512 HTMLAttributeCollection2_Invoke
,
2513 HTMLAttributeCollection2_getNamedItem
,
2514 HTMLAttributeCollection2_setNamedItem
,
2515 HTMLAttributeCollection2_removeNamedItem
2518 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3
*iface
)
2520 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection3_iface
);
2523 static HRESULT WINAPI
HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3
*iface
, REFIID riid
, void **ppv
)
2525 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2526 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2529 static ULONG WINAPI
HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3
*iface
)
2531 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2532 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2535 static ULONG WINAPI
HTMLAttributeCollection3_Release(IHTMLAttributeCollection3
*iface
)
2537 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2538 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2541 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3
*iface
, UINT
*pctinfo
)
2543 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2544 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2547 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3
*iface
, UINT iTInfo
,
2548 LCID lcid
, ITypeInfo
**ppTInfo
)
2550 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2551 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2554 static HRESULT WINAPI
HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3
*iface
, REFIID riid
,
2555 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2557 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2558 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2562 static HRESULT WINAPI
HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3
*iface
, DISPID dispIdMember
,
2563 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2564 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2566 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2567 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2568 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2571 static HRESULT WINAPI
HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3
*iface
, BSTR bstrName
,
2572 IHTMLDOMAttribute
**ppNodeOut
)
2574 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2575 return IHTMLAttributeCollection2_getNamedItem(&This
->IHTMLAttributeCollection2_iface
, bstrName
, ppNodeOut
);
2578 static HRESULT WINAPI
HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3
*iface
,
2579 IHTMLDOMAttribute
*pNodeIn
, IHTMLDOMAttribute
**ppNodeOut
)
2581 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2582 FIXME("(%p)->(%p %p)\n", This
, pNodeIn
, ppNodeOut
);
2586 static HRESULT WINAPI
HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3
*iface
,
2587 BSTR bstrName
, IHTMLDOMAttribute
**ppNodeOut
)
2589 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2590 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), ppNodeOut
);
2594 static HRESULT WINAPI
HTMLAttributeCollection3_item(IHTMLAttributeCollection3
*iface
, LONG index
, IHTMLDOMAttribute
**ppNodeOut
)
2596 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2597 HTMLDOMAttribute
*attr
;
2601 TRACE("(%p)->(%d %p)\n", This
, index
, ppNodeOut
);
2603 hres
= get_attr_dispid_by_idx(This
, &index
, &id
);
2604 if(hres
== DISP_E_UNKNOWNNAME
)
2605 return E_INVALIDARG
;
2609 hres
= get_domattr(This
, id
, NULL
, &attr
);
2613 *ppNodeOut
= &attr
->IHTMLDOMAttribute_iface
;
2617 static HRESULT WINAPI
HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3
*iface
, LONG
*p
)
2619 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2620 return IHTMLAttributeCollection_get_length(&This
->IHTMLAttributeCollection_iface
, p
);
2623 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl
= {
2624 HTMLAttributeCollection3_QueryInterface
,
2625 HTMLAttributeCollection3_AddRef
,
2626 HTMLAttributeCollection3_Release
,
2627 HTMLAttributeCollection3_GetTypeInfoCount
,
2628 HTMLAttributeCollection3_GetTypeInfo
,
2629 HTMLAttributeCollection3_GetIDsOfNames
,
2630 HTMLAttributeCollection3_Invoke
,
2631 HTMLAttributeCollection3_getNamedItem
,
2632 HTMLAttributeCollection3_setNamedItem
,
2633 HTMLAttributeCollection3_removeNamedItem
,
2634 HTMLAttributeCollection3_item
,
2635 HTMLAttributeCollection3_get_length
2638 static inline HTMLAttributeCollection
*HTMLAttributeCollection_from_DispatchEx(DispatchEx
*iface
)
2640 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, dispex
);
2643 static HRESULT
HTMLAttributeCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2645 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2646 HTMLDOMAttribute
*attr
;
2650 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(name
), flags
, dispid
);
2652 hres
= get_attr_dispid_by_name(This
, name
, dispid
);
2656 hres
= get_domattr(This
, *dispid
, &pos
, &attr
);
2659 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2661 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+pos
;
2665 static HRESULT
HTMLAttributeCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
2666 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2668 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2670 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
2673 case DISPATCH_PROPERTYGET
: {
2674 HTMLDOMAttribute
*iter
;
2677 pos
= id
-MSHTML_DISPID_CUSTOM_MIN
;
2679 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2681 IHTMLDOMAttribute_AddRef(&iter
->IHTMLDOMAttribute_iface
);
2682 V_VT(res
) = VT_DISPATCH
;
2683 V_DISPATCH(res
) = (IDispatch
*)&iter
->IHTMLDOMAttribute_iface
;
2689 WARN("invalid arg\n");
2690 return E_INVALIDARG
;
2694 FIXME("unimplemented flags %x\n", flags
);
2699 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl
= {
2701 HTMLAttributeCollection_get_dispid
,
2702 HTMLAttributeCollection_invoke
,
2706 static const tid_t HTMLAttributeCollection_iface_tids
[] = {
2707 IHTMLAttributeCollection_tid
,
2708 IHTMLAttributeCollection2_tid
,
2709 IHTMLAttributeCollection3_tid
,
2713 static dispex_static_data_t HTMLAttributeCollection_dispex
= {
2714 &HTMLAttributeCollection_dispex_vtbl
,
2715 DispHTMLAttributeCollection_tid
,
2717 HTMLAttributeCollection_iface_tids
2720 HRESULT
HTMLElement_get_attr_col(HTMLDOMNode
*iface
, HTMLAttributeCollection
**ac
)
2722 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
2725 IHTMLAttributeCollection_AddRef(&This
->attrs
->IHTMLAttributeCollection_iface
);
2730 This
->attrs
= heap_alloc_zero(sizeof(HTMLAttributeCollection
));
2732 return E_OUTOFMEMORY
;
2734 This
->attrs
->IHTMLAttributeCollection_iface
.lpVtbl
= &HTMLAttributeCollectionVtbl
;
2735 This
->attrs
->IHTMLAttributeCollection2_iface
.lpVtbl
= &HTMLAttributeCollection2Vtbl
;
2736 This
->attrs
->IHTMLAttributeCollection3_iface
.lpVtbl
= &HTMLAttributeCollection3Vtbl
;
2737 This
->attrs
->ref
= 2;
2739 This
->attrs
->elem
= This
;
2740 list_init(&This
->attrs
->attrs
);
2741 init_dispex(&This
->attrs
->dispex
, (IUnknown
*)&This
->attrs
->IHTMLAttributeCollection_iface
,
2742 &HTMLAttributeCollection_dispex
);