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
);
911 TRACE("(%p)->(%p)\n", This
, p
);
913 return get_elem_source_index(This
, p
);
916 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
918 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
919 FIXME("(%p)->(%p)\n", This
, p
);
923 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
925 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
926 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
930 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
932 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
933 FIXME("(%p)->(%p)\n", This
, p
);
937 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
939 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
942 TRACE("(%p)->(%p)\n", This
, p
);
944 nsres
= nsIDOMHTMLElement_GetOffsetLeft(This
->nselem
, p
);
945 if(NS_FAILED(nsres
)) {
946 ERR("GetOffsetLeft failed: %08x\n", nsres
);
953 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
955 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
958 TRACE("(%p)->(%p)\n", This
, p
);
960 nsres
= nsIDOMHTMLElement_GetOffsetTop(This
->nselem
, p
);
961 if(NS_FAILED(nsres
)) {
962 ERR("GetOffsetTop failed: %08x\n", nsres
);
969 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
971 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
974 TRACE("(%p)->(%p)\n", This
, p
);
976 nsres
= nsIDOMHTMLElement_GetOffsetWidth(This
->nselem
, p
);
977 if(NS_FAILED(nsres
)) {
978 ERR("GetOffsetWidth failed: %08x\n", nsres
);
985 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
987 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
990 TRACE("(%p)->(%p)\n", This
, p
);
992 nsres
= nsIDOMHTMLElement_GetOffsetHeight(This
->nselem
, p
);
993 if(NS_FAILED(nsres
)) {
994 ERR("GetOffsetHeight failed: %08x\n", nsres
);
1001 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
1003 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1004 nsIDOMElement
*nsparent
;
1008 TRACE("(%p)->(%p)\n", This
, p
);
1010 nsres
= nsIDOMHTMLElement_GetOffsetParent(This
->nselem
, &nsparent
);
1011 if(NS_FAILED(nsres
)) {
1012 ERR("GetOffsetParent failed: %08x\n", nsres
);
1019 hres
= get_node(This
->node
.doc
, (nsIDOMNode
*)nsparent
, TRUE
, &node
);
1020 nsIDOMElement_Release(nsparent
);
1024 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)p
);
1034 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
1036 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1040 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1043 FIXME("NULL nselem\n");
1047 nsAString_InitDepend(&html_str
, v
);
1048 nsres
= nsIDOMHTMLElement_SetInnerHTML(This
->nselem
, &html_str
);
1049 nsAString_Finish(&html_str
);
1050 if(NS_FAILED(nsres
)) {
1051 FIXME("SetInnerHtml failed %08x\n", nsres
);
1058 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
1060 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1064 TRACE("(%p)->(%p)\n", This
, p
);
1067 FIXME("NULL nselem\n");
1071 nsAString_Init(&html_str
, NULL
);
1072 nsres
= nsIDOMHTMLElement_GetInnerHTML(This
->nselem
, &html_str
);
1073 return return_nsstr(nsres
, &html_str
, p
);
1076 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
1078 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1079 nsIDOMNode
*nschild
, *tmp
;
1080 nsIDOMText
*text_node
;
1084 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1087 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
1088 if(NS_FAILED(nsres
)) {
1089 ERR("GetLastChild failed: %08x\n", nsres
);
1095 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
1096 nsIDOMNode_Release(nschild
);
1097 if(NS_FAILED(nsres
)) {
1098 ERR("RemoveChild failed: %08x\n", nsres
);
1101 nsIDOMNode_Release(tmp
);
1104 nsAString_InitDepend(&text_str
, v
);
1105 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
1106 nsAString_Finish(&text_str
);
1107 if(NS_FAILED(nsres
)) {
1108 ERR("CreateTextNode failed: %08x\n", nsres
);
1112 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
1113 if(NS_FAILED(nsres
)) {
1114 ERR("AppendChild failed: %08x\n", nsres
);
1118 nsIDOMNode_Release(tmp
);
1122 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
1124 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1126 TRACE("(%p)->(%p)\n", This
, p
);
1128 return get_node_text(&This
->node
, p
);
1131 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
1133 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1135 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1137 return replace_node_by_html(This
->node
.doc
->nsdoc
, This
->node
.nsnode
, v
);
1140 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
1142 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1146 WARN("(%p)->(%p) semi-stub\n", This
, p
);
1148 nsAString_Init(&html_str
, NULL
);
1149 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
1150 if(SUCCEEDED(hres
)) {
1151 const PRUnichar
*html
;
1153 nsAString_GetData(&html_str
, &html
);
1154 *p
= SysAllocString(html
);
1156 hres
= E_OUTOFMEMORY
;
1159 nsAString_Finish(&html_str
);
1161 TRACE("ret %s\n", debugstr_w(*p
));
1165 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
1167 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1168 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1172 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
1174 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1175 FIXME("(%p)->(%p)\n", This
, p
);
1179 HRESULT
insert_adjacent_node(HTMLElement
*This
, const WCHAR
*where
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret_node
)
1181 nsIDOMNode
*ret_nsnode
;
1183 HRESULT hres
= S_OK
;
1185 static const WCHAR beforebeginW
[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1186 static const WCHAR afterbeginW
[] = {'a','f','t','e','r','b','e','g','i','n',0};
1187 static const WCHAR beforeendW
[] = {'b','e','f','o','r','e','e','n','d',0};
1188 static const WCHAR afterendW
[] = {'a','f','t','e','r','e','n','d',0};
1190 if (!strcmpiW(where
, beforebeginW
)) {
1193 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1194 if(NS_FAILED(nsres
))
1198 return E_INVALIDARG
;
1200 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, This
->node
.nsnode
, &ret_nsnode
);
1201 nsIDOMNode_Release(parent
);
1202 }else if(!strcmpiW(where
, afterbeginW
)) {
1203 nsIDOMNode
*first_child
;
1205 nsres
= nsIDOMNode_GetFirstChild(This
->node
.nsnode
, &first_child
);
1206 if(NS_FAILED(nsres
))
1209 nsres
= nsIDOMNode_InsertBefore(This
->node
.nsnode
, nsnode
, first_child
, &ret_nsnode
);
1210 if(NS_FAILED(nsres
))
1214 nsIDOMNode_Release(first_child
);
1215 }else if (!strcmpiW(where
, beforeendW
)) {
1216 nsres
= nsIDOMNode_AppendChild(This
->node
.nsnode
, nsnode
, &ret_nsnode
);
1217 }else if (!strcmpiW(where
, afterendW
)) {
1218 nsIDOMNode
*next_sibling
, *parent
;
1220 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1221 if(NS_FAILED(nsres
))
1224 return E_INVALIDARG
;
1226 nsres
= nsIDOMNode_GetNextSibling(This
->node
.nsnode
, &next_sibling
);
1227 if(NS_SUCCEEDED(nsres
)) {
1229 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &ret_nsnode
);
1230 nsIDOMNode_Release(next_sibling
);
1232 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &ret_nsnode
);
1236 nsIDOMNode_Release(parent
);
1238 ERR("invalid where: %s\n", debugstr_w(where
));
1239 return E_INVALIDARG
;
1242 if (NS_FAILED(nsres
))
1246 hres
= get_node(This
->node
.doc
, ret_nsnode
, TRUE
, ret_node
);
1247 nsIDOMNode_Release(ret_nsnode
);
1251 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1254 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1261 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1263 if(!This
->node
.doc
->nsdoc
) {
1264 WARN("NULL nsdoc\n");
1265 return E_UNEXPECTED
;
1268 nsres
= nsIDOMHTMLDocument_CreateRange(This
->node
.doc
->nsdoc
, &range
);
1269 if(NS_FAILED(nsres
))
1271 ERR("CreateRange failed: %08x\n", nsres
);
1275 nsIDOMRange_SetStartBefore(range
, This
->node
.nsnode
);
1277 nsAString_InitDepend(&ns_html
, html
);
1278 nsres
= nsIDOMRange_CreateContextualFragment(range
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1279 nsAString_Finish(&ns_html
);
1280 nsIDOMRange_Release(range
);
1282 if(NS_FAILED(nsres
) || !nsnode
)
1284 ERR("CreateTextNode failed: %08x\n", nsres
);
1288 hr
= insert_adjacent_node(This
, where
, nsnode
, NULL
);
1289 nsIDOMNode_Release(nsnode
);
1293 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1296 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1302 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1304 if(!This
->node
.doc
->nsdoc
) {
1305 WARN("NULL nsdoc\n");
1306 return E_UNEXPECTED
;
1310 nsAString_InitDepend(&ns_text
, text
);
1311 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1312 nsAString_Finish(&ns_text
);
1314 if(NS_FAILED(nsres
) || !nsnode
)
1316 ERR("CreateTextNode failed: %08x\n", nsres
);
1320 hr
= insert_adjacent_node(This
, where
, nsnode
, NULL
);
1321 nsIDOMNode_Release(nsnode
);
1326 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1328 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1329 FIXME("(%p)->(%p)\n", This
, p
);
1333 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1335 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1336 FIXME("(%p)->(%p)\n", This
, p
);
1340 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1342 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1344 TRACE("(%p)\n", This
);
1346 return call_fire_event(&This
->node
, EVENTID_CLICK
);
1349 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1350 IHTMLFiltersCollection
**p
)
1352 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1353 TRACE("(%p)->(%p)\n", This
, p
);
1358 *p
= HTMLFiltersCollection_Create();
1363 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1365 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1366 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1370 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1372 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1373 FIXME("(%p)->(%p)\n", This
, p
);
1377 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1379 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1380 FIXME("(%p)->(%p)\n", This
, String
);
1384 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1386 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1387 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1391 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1393 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1394 FIXME("(%p)->(%p)\n", This
, p
);
1398 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1400 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1401 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1405 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1407 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1408 FIXME("(%p)->(%p)\n", This
, p
);
1412 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1414 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1415 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1419 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1421 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1422 FIXME("(%p)->(%p)\n", This
, p
);
1426 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1428 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1429 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1433 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1435 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1436 FIXME("(%p)->(%p)\n", This
, p
);
1440 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1442 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1443 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1447 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1449 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1450 FIXME("(%p)->(%p)\n", This
, p
);
1454 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1456 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1457 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1461 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1463 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1464 FIXME("(%p)->(%p)\n", This
, p
);
1468 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1470 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1472 FIXME("(%p)->(%s) semi-stub\n", This
, debugstr_variant(&v
));
1474 return set_node_event(&This
->node
, EVENTID_DATAAVAILABLE
, &v
);
1477 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1479 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1481 TRACE("(%p)->(%p)\n", This
, p
);
1483 return get_node_event(&This
->node
, EVENTID_DATAAVAILABLE
, p
);
1486 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1488 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1489 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1493 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1495 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1496 FIXME("(%p)->(%p)\n", This
, p
);
1500 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1502 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1503 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1507 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1509 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1510 FIXME("(%p)->(%p)\n", This
, p
);
1514 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1516 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1517 nsIDOMNodeList
*nsnode_list
;
1520 TRACE("(%p)->(%p)\n", This
, p
);
1522 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1523 if(NS_FAILED(nsres
)) {
1524 ERR("GetChildNodes failed: %08x\n", nsres
);
1528 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, nsnode_list
);
1530 nsIDOMNodeList_Release(nsnode_list
);
1534 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1536 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1538 TRACE("(%p)->(%p)\n", This
, p
);
1540 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1544 static const IHTMLElementVtbl HTMLElementVtbl
= {
1545 HTMLElement_QueryInterface
,
1547 HTMLElement_Release
,
1548 HTMLElement_GetTypeInfoCount
,
1549 HTMLElement_GetTypeInfo
,
1550 HTMLElement_GetIDsOfNames
,
1552 HTMLElement_setAttribute
,
1553 HTMLElement_getAttribute
,
1554 HTMLElement_removeAttribute
,
1555 HTMLElement_put_className
,
1556 HTMLElement_get_className
,
1559 HTMLElement_get_tagName
,
1560 HTMLElement_get_parentElement
,
1561 HTMLElement_get_style
,
1562 HTMLElement_put_onhelp
,
1563 HTMLElement_get_onhelp
,
1564 HTMLElement_put_onclick
,
1565 HTMLElement_get_onclick
,
1566 HTMLElement_put_ondblclick
,
1567 HTMLElement_get_ondblclick
,
1568 HTMLElement_put_onkeydown
,
1569 HTMLElement_get_onkeydown
,
1570 HTMLElement_put_onkeyup
,
1571 HTMLElement_get_onkeyup
,
1572 HTMLElement_put_onkeypress
,
1573 HTMLElement_get_onkeypress
,
1574 HTMLElement_put_onmouseout
,
1575 HTMLElement_get_onmouseout
,
1576 HTMLElement_put_onmouseover
,
1577 HTMLElement_get_onmouseover
,
1578 HTMLElement_put_onmousemove
,
1579 HTMLElement_get_onmousemove
,
1580 HTMLElement_put_onmousedown
,
1581 HTMLElement_get_onmousedown
,
1582 HTMLElement_put_onmouseup
,
1583 HTMLElement_get_onmouseup
,
1584 HTMLElement_get_document
,
1585 HTMLElement_put_title
,
1586 HTMLElement_get_title
,
1587 HTMLElement_put_language
,
1588 HTMLElement_get_language
,
1589 HTMLElement_put_onselectstart
,
1590 HTMLElement_get_onselectstart
,
1591 HTMLElement_scrollIntoView
,
1592 HTMLElement_contains
,
1593 HTMLElement_get_sourceIndex
,
1594 HTMLElement_get_recordNumber
,
1595 HTMLElement_put_lang
,
1596 HTMLElement_get_lang
,
1597 HTMLElement_get_offsetLeft
,
1598 HTMLElement_get_offsetTop
,
1599 HTMLElement_get_offsetWidth
,
1600 HTMLElement_get_offsetHeight
,
1601 HTMLElement_get_offsetParent
,
1602 HTMLElement_put_innerHTML
,
1603 HTMLElement_get_innerHTML
,
1604 HTMLElement_put_innerText
,
1605 HTMLElement_get_innerText
,
1606 HTMLElement_put_outerHTML
,
1607 HTMLElement_get_outerHTML
,
1608 HTMLElement_put_outerText
,
1609 HTMLElement_get_outerText
,
1610 HTMLElement_insertAdjacentHTML
,
1611 HTMLElement_insertAdjacentText
,
1612 HTMLElement_get_parentTextEdit
,
1613 HTMLElement_get_isTextEdit
,
1615 HTMLElement_get_filters
,
1616 HTMLElement_put_ondragstart
,
1617 HTMLElement_get_ondragstart
,
1618 HTMLElement_toString
,
1619 HTMLElement_put_onbeforeupdate
,
1620 HTMLElement_get_onbeforeupdate
,
1621 HTMLElement_put_onafterupdate
,
1622 HTMLElement_get_onafterupdate
,
1623 HTMLElement_put_onerrorupdate
,
1624 HTMLElement_get_onerrorupdate
,
1625 HTMLElement_put_onrowexit
,
1626 HTMLElement_get_onrowexit
,
1627 HTMLElement_put_onrowenter
,
1628 HTMLElement_get_onrowenter
,
1629 HTMLElement_put_ondatasetchanged
,
1630 HTMLElement_get_ondatasetchanged
,
1631 HTMLElement_put_ondataavailable
,
1632 HTMLElement_get_ondataavailable
,
1633 HTMLElement_put_ondatasetcomplete
,
1634 HTMLElement_get_ondatasetcomplete
,
1635 HTMLElement_put_onfilterchange
,
1636 HTMLElement_get_onfilterchange
,
1637 HTMLElement_get_children
,
1641 HTMLElement
*unsafe_impl_from_IHTMLElement(IHTMLElement
*iface
)
1643 return iface
->lpVtbl
== &HTMLElementVtbl
? impl_from_IHTMLElement(iface
) : NULL
;
1646 static inline HTMLElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
1648 return CONTAINING_RECORD(iface
, HTMLElement
, node
);
1651 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1653 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1655 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1656 *ppv
= &This
->IHTMLElement_iface
;
1657 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1658 *ppv
= &This
->IHTMLElement_iface
;
1659 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1660 *ppv
= &This
->IHTMLElement_iface
;
1661 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1662 *ppv
= &This
->IHTMLElement2_iface
;
1663 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1664 *ppv
= &This
->IHTMLElement3_iface
;
1665 }else if(IsEqualGUID(&IID_IHTMLElement4
, riid
)) {
1666 *ppv
= &This
->IHTMLElement4_iface
;
1667 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1668 *ppv
= &This
->cp_container
.IConnectionPointContainer_iface
;
1670 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1673 IUnknown_AddRef((IUnknown
*)*ppv
);
1677 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1679 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1681 ConnectionPointContainer_Destroy(&This
->cp_container
);
1684 This
->style
->elem
= NULL
;
1685 IHTMLStyle_Release(&This
->style
->IHTMLStyle_iface
);
1687 if(This
->runtime_style
) {
1688 This
->runtime_style
->elem
= NULL
;
1689 IHTMLStyle_Release(&This
->runtime_style
->IHTMLStyle_iface
);
1692 HTMLDOMAttribute
*attr
;
1694 LIST_FOR_EACH_ENTRY(attr
, &This
->attrs
->attrs
, HTMLDOMAttribute
, entry
)
1697 This
->attrs
->elem
= NULL
;
1698 IHTMLAttributeCollection_Release(&This
->attrs
->IHTMLAttributeCollection_iface
);
1701 heap_free(This
->filter
);
1703 HTMLDOMNode_destructor(&This
->node
);
1706 HRESULT
HTMLElement_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
1708 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1709 HTMLElement
*new_elem
;
1712 hres
= HTMLElement_Create(This
->node
.doc
, nsnode
, FALSE
, &new_elem
);
1717 new_elem
->filter
= heap_strdupW(This
->filter
);
1718 if(!new_elem
->filter
) {
1719 IHTMLElement_Release(&This
->IHTMLElement_iface
);
1720 return E_OUTOFMEMORY
;
1724 *ret
= &new_elem
->node
;
1728 HRESULT
HTMLElement_handle_event(HTMLDOMNode
*iface
, DWORD eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
1730 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1733 case EVENTID_KEYDOWN
: {
1734 nsIDOMKeyEvent
*key_event
;
1737 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMKeyEvent
, (void**)&key_event
);
1738 if(NS_SUCCEEDED(nsres
)) {
1741 nsIDOMKeyEvent_GetKeyCode(key_event
, &code
);
1744 case VK_F1
: /* DOM_VK_F1 */
1745 TRACE("F1 pressed\n");
1746 fire_event(This
->node
.doc
, EVENTID_HELP
, TRUE
, This
->node
.nsnode
, NULL
, NULL
);
1747 *prevent_default
= TRUE
;
1750 nsIDOMKeyEvent_Release(key_event
);
1758 cp_static_data_t HTMLElementEvents2_data
= { HTMLElementEvents2_tid
, NULL
/* FIXME */, TRUE
};
1760 const cpc_entry_t HTMLElement_cpc
[] = {
1765 static const NodeImplVtbl HTMLElementImplVtbl
= {
1767 HTMLElement_destructor
,
1770 HTMLElement_handle_event
,
1771 HTMLElement_get_attr_col
1774 static inline HTMLElement
*impl_from_DispatchEx(DispatchEx
*iface
)
1776 return CONTAINING_RECORD(iface
, HTMLElement
, node
.dispex
);
1779 static HRESULT
HTMLElement_get_dispid(DispatchEx
*dispex
, BSTR name
,
1780 DWORD grfdex
, DISPID
*pid
)
1782 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1784 if(This
->node
.vtbl
->get_dispid
)
1785 return This
->node
.vtbl
->get_dispid(&This
->node
, name
, grfdex
, pid
);
1787 return DISP_E_UNKNOWNNAME
;
1790 static HRESULT
HTMLElement_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
1791 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
1792 IServiceProvider
*caller
)
1794 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1796 if(This
->node
.vtbl
->invoke
)
1797 return This
->node
.vtbl
->invoke(&This
->node
, id
, lcid
, flags
,
1798 params
, res
, ei
, caller
);
1800 ERR("(%p): element has no invoke method\n", This
);
1804 static HRESULT
HTMLElement_populate_props(DispatchEx
*dispex
)
1806 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1807 nsIDOMMozNamedAttrMap
*attrs
;
1810 const PRUnichar
*str
;
1822 nsres
= nsIDOMHTMLElement_GetAttributes(This
->nselem
, &attrs
);
1823 if(NS_FAILED(nsres
))
1826 nsres
= nsIDOMMozNamedAttrMap_GetLength(attrs
, &len
);
1827 if(NS_FAILED(nsres
)) {
1828 nsIDOMMozNamedAttrMap_Release(attrs
);
1832 nsAString_Init(&nsstr
, NULL
);
1833 for(i
=0; i
<len
; i
++) {
1834 nsres
= nsIDOMMozNamedAttrMap_Item(attrs
, i
, &attr
);
1835 if(NS_FAILED(nsres
))
1838 nsres
= nsIDOMAttr_GetNodeName(attr
, &nsstr
);
1839 if(NS_FAILED(nsres
)) {
1840 nsIDOMAttr_Release(attr
);
1844 nsAString_GetData(&nsstr
, &str
);
1845 name
= SysAllocString(str
);
1847 nsIDOMAttr_Release(attr
);
1851 hres
= IDispatchEx_GetDispID(&dispex
->IDispatchEx_iface
, name
, fdexNameCaseInsensitive
, &id
);
1852 if(hres
!= DISP_E_UNKNOWNNAME
) {
1853 nsIDOMAttr_Release(attr
);
1854 SysFreeString(name
);
1858 nsres
= nsIDOMAttr_GetNodeValue(attr
, &nsstr
);
1859 nsIDOMAttr_Release(attr
);
1860 if(NS_FAILED(nsres
)) {
1861 SysFreeString(name
);
1865 nsAString_GetData(&nsstr
, &str
);
1866 V_VT(&value
) = VT_BSTR
;
1868 V_BSTR(&value
) = SysAllocString(str
);
1869 if(!V_BSTR(&value
)) {
1870 SysFreeString(name
);
1874 V_BSTR(&value
) = NULL
;
1876 IHTMLElement_setAttribute(&This
->IHTMLElement_iface
, name
, value
, 0);
1877 SysFreeString(name
);
1878 VariantClear(&value
);
1880 nsAString_Finish(&nsstr
);
1882 nsIDOMMozNamedAttrMap_Release(attrs
);
1886 static const tid_t HTMLElement_iface_tids
[] = {
1891 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl
= {
1893 HTMLElement_get_dispid
,
1895 HTMLElement_populate_props
1898 static dispex_static_data_t HTMLElement_dispex
= {
1899 &HTMLElement_dispex_vtbl
,
1900 DispHTMLUnknownElement_tid
,
1902 HTMLElement_iface_tids
1905 void HTMLElement_Init(HTMLElement
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, dispex_static_data_t
*dispex_data
)
1907 This
->IHTMLElement_iface
.lpVtbl
= &HTMLElementVtbl
;
1909 HTMLElement2_Init(This
);
1910 HTMLElement3_Init(This
);
1912 if(dispex_data
&& !dispex_data
->vtbl
)
1913 dispex_data
->vtbl
= &HTMLElement_dispex_vtbl
;
1914 init_dispex(&This
->node
.dispex
, (IUnknown
*)&This
->IHTMLElement_iface
,
1915 dispex_data
? dispex_data
: &HTMLElement_dispex
);
1918 HTMLDOMNode_Init(doc
, &This
->node
, (nsIDOMNode
*)nselem
);
1920 /* No AddRef, share reference with HTMLDOMNode */
1921 assert((nsIDOMNode
*)nselem
== This
->node
.nsnode
);
1922 This
->nselem
= nselem
;
1925 This
->node
.cp_container
= &This
->cp_container
;
1926 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)&This
->IHTMLElement_iface
, This
->node
.vtbl
->cpc_entries
);
1929 HRESULT
HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
, HTMLElement
**ret
)
1931 nsIDOMHTMLElement
*nselem
;
1932 nsAString class_name_str
;
1933 const PRUnichar
*class_name
;
1934 const tag_desc_t
*tag
;
1939 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1940 if(NS_FAILED(nsres
))
1943 nsAString_Init(&class_name_str
, NULL
);
1944 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1946 nsAString_GetData(&class_name_str
, &class_name
);
1948 tag
= get_tag_desc(class_name
);
1950 hres
= tag
->constructor(doc
, nselem
, &elem
);
1951 }else if(use_generic
) {
1952 hres
= HTMLGenericElement_Create(doc
, nselem
, &elem
);
1954 elem
= heap_alloc_zero(sizeof(HTMLElement
));
1956 elem
->node
.vtbl
= &HTMLElementImplVtbl
;
1957 HTMLElement_Init(elem
, doc
, nselem
, &HTMLElement_dispex
);
1960 hres
= E_OUTOFMEMORY
;
1964 TRACE("%s ret %p\n", debugstr_w(class_name
), elem
);
1966 nsIDOMHTMLElement_Release(nselem
);
1967 nsAString_Finish(&class_name_str
);
1975 HRESULT
get_elem(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**ret
)
1980 hres
= get_node(doc
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
1984 *ret
= impl_from_HTMLDOMNode(node
);
1988 /* interface IHTMLFiltersCollection */
1989 static HRESULT WINAPI
HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection
*iface
, REFIID riid
, void **ppv
)
1991 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1993 TRACE("%p %s %p\n", This
, debugstr_mshtml_guid(riid
), ppv
);
1995 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1996 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1997 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection
, riid
)) {
1998 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This
, ppv
);
1999 *ppv
= &This
->IHTMLFiltersCollection_iface
;
2000 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
2001 return *ppv
? S_OK
: E_NOINTERFACE
;
2004 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
2005 return E_NOINTERFACE
;
2008 IUnknown_AddRef((IUnknown
*)*ppv
);
2012 static ULONG WINAPI
HTMLFiltersCollection_AddRef(IHTMLFiltersCollection
*iface
)
2014 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2015 LONG ref
= InterlockedIncrement(&This
->ref
);
2017 TRACE("(%p) ref=%d\n", This
, ref
);
2022 static ULONG WINAPI
HTMLFiltersCollection_Release(IHTMLFiltersCollection
*iface
)
2024 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2025 LONG ref
= InterlockedDecrement(&This
->ref
);
2027 TRACE("(%p) ref=%d\n", This
, ref
);
2037 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection
*iface
, UINT
*pctinfo
)
2039 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2040 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2043 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection
*iface
,
2044 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
2046 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2047 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2050 static HRESULT WINAPI
HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection
*iface
,
2051 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
,
2052 LCID lcid
, DISPID
*rgDispId
)
2054 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2055 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2059 static HRESULT WINAPI
HTMLFiltersCollection_Invoke(IHTMLFiltersCollection
*iface
, DISPID dispIdMember
, REFIID riid
,
2060 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
2061 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2063 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2064 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2065 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2068 static HRESULT WINAPI
HTMLFiltersCollection_get_length(IHTMLFiltersCollection
*iface
, LONG
*p
)
2070 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2075 FIXME("(%p)->(%p) Always returning 0\n", This
, p
);
2081 static HRESULT WINAPI
HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection
*iface
, IUnknown
**p
)
2083 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2084 FIXME("(%p)->(%p)\n", This
, p
);
2088 static HRESULT WINAPI
HTMLFiltersCollection_item(IHTMLFiltersCollection
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
2090 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2091 FIXME("(%p)->(%p, %p)\n", This
, pvarIndex
, pvarResult
);
2095 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl
= {
2096 HTMLFiltersCollection_QueryInterface
,
2097 HTMLFiltersCollection_AddRef
,
2098 HTMLFiltersCollection_Release
,
2099 HTMLFiltersCollection_GetTypeInfoCount
,
2100 HTMLFiltersCollection_GetTypeInfo
,
2101 HTMLFiltersCollection_GetIDsOfNames
,
2102 HTMLFiltersCollection_Invoke
,
2103 HTMLFiltersCollection_get_length
,
2104 HTMLFiltersCollection_get__newEnum
,
2105 HTMLFiltersCollection_item
2108 static HRESULT
HTMLFiltersCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2113 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
2114 idx
= idx
*10 + (*ptr
-'0');
2116 return DISP_E_UNKNOWNNAME
;
2118 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
2119 TRACE("ret %x\n", *dispid
);
2123 static HRESULT
HTMLFiltersCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2124 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2126 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex
, id
, lcid
, flags
, params
, res
, ei
);
2128 V_VT(res
) = VT_DISPATCH
;
2129 V_DISPATCH(res
) = NULL
;
2131 FIXME("always returning NULL\n");
2136 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl
= {
2138 HTMLFiltersCollection_get_dispid
,
2139 HTMLFiltersCollection_invoke
,
2143 static const tid_t HTMLFiltersCollection_iface_tids
[] = {
2144 IHTMLFiltersCollection_tid
,
2147 static dispex_static_data_t HTMLFiltersCollection_dispex
= {
2148 &HTMLFiltersCollection_dispex_vtbl
,
2149 IHTMLFiltersCollection_tid
,
2151 HTMLFiltersCollection_iface_tids
2154 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void)
2156 HTMLFiltersCollection
*ret
= heap_alloc(sizeof(HTMLFiltersCollection
));
2158 ret
->IHTMLFiltersCollection_iface
.lpVtbl
= &HTMLFiltersCollectionVtbl
;
2161 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLFiltersCollection_iface
,
2162 &HTMLFiltersCollection_dispex
);
2164 return &ret
->IHTMLFiltersCollection_iface
;
2167 /* interface IHTMLAttributeCollection */
2168 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection
*iface
)
2170 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection_iface
);
2173 static HRESULT WINAPI
HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection
*iface
, REFIID riid
, void **ppv
)
2175 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2177 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
2178 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2179 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection
, riid
)) {
2180 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2181 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2
, riid
)) {
2182 *ppv
= &This
->IHTMLAttributeCollection2_iface
;
2183 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3
, riid
)) {
2184 *ppv
= &This
->IHTMLAttributeCollection3_iface
;
2185 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
2186 return *ppv
? S_OK
: E_NOINTERFACE
;
2189 WARN("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
2190 return E_NOINTERFACE
;
2193 IUnknown_AddRef((IUnknown
*)*ppv
);
2197 static ULONG WINAPI
HTMLAttributeCollection_AddRef(IHTMLAttributeCollection
*iface
)
2199 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2200 LONG ref
= InterlockedIncrement(&This
->ref
);
2202 TRACE("(%p) ref=%d\n", This
, ref
);
2207 static ULONG WINAPI
HTMLAttributeCollection_Release(IHTMLAttributeCollection
*iface
)
2209 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2210 LONG ref
= InterlockedDecrement(&This
->ref
);
2212 TRACE("(%p) ref=%d\n", This
, ref
);
2215 while(!list_empty(&This
->attrs
)) {
2216 HTMLDOMAttribute
*attr
= LIST_ENTRY(list_head(&This
->attrs
), HTMLDOMAttribute
, entry
);
2218 list_remove(&attr
->entry
);
2220 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2229 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection
*iface
, UINT
*pctinfo
)
2231 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2232 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2235 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection
*iface
, UINT iTInfo
,
2236 LCID lcid
, ITypeInfo
**ppTInfo
)
2238 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2239 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2242 static HRESULT WINAPI
HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection
*iface
, REFIID riid
,
2243 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2245 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2246 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2250 static HRESULT WINAPI
HTMLAttributeCollection_Invoke(IHTMLAttributeCollection
*iface
, DISPID dispIdMember
,
2251 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2252 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2254 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2255 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2256 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2259 static HRESULT
get_attr_dispid_by_idx(HTMLAttributeCollection
*This
, LONG
*idx
, DISPID
*dispid
)
2261 IDispatchEx
*dispex
= &This
->elem
->node
.dispex
.IDispatchEx_iface
;
2262 DISPID id
= DISPID_STARTENUM
;
2266 FIXME("filter non-enumerable attributes out\n");
2269 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
2272 else if(hres
== S_FALSE
)
2282 return *idx
==len
? S_OK
: DISP_E_UNKNOWNNAME
;
2289 static inline HRESULT
get_attr_dispid_by_name(HTMLAttributeCollection
*This
, BSTR name
, DISPID
*id
)
2293 if(name
[0]>='0' && name
[0]<='9') {
2297 idx
= strtoulW(name
, &end_ptr
, 10);
2299 hres
= get_attr_dispid_by_idx(This
, &idx
, id
);
2306 WARN("NULL elem\n");
2307 return E_UNEXPECTED
;
2310 hres
= IDispatchEx_GetDispID(&This
->elem
->node
.dispex
.IDispatchEx_iface
,
2311 name
, fdexNameCaseInsensitive
, id
);
2315 static inline HRESULT
get_domattr(HTMLAttributeCollection
*This
, DISPID id
, LONG
*list_pos
, HTMLDOMAttribute
**attr
)
2317 HTMLDOMAttribute
*iter
;
2322 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2323 if(iter
->dispid
== id
) {
2332 WARN("NULL elem\n");
2333 return E_UNEXPECTED
;
2336 hres
= HTMLDOMAttribute_Create(NULL
, This
->elem
, id
, attr
);
2341 IHTMLDOMAttribute_AddRef(&(*attr
)->IHTMLDOMAttribute_iface
);
2347 static HRESULT WINAPI
HTMLAttributeCollection_get_length(IHTMLAttributeCollection
*iface
, LONG
*p
)
2349 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2352 TRACE("(%p)->(%p)\n", This
, p
);
2355 hres
= get_attr_dispid_by_idx(This
, p
, NULL
);
2359 static HRESULT WINAPI
HTMLAttributeCollection__newEnum(IHTMLAttributeCollection
*iface
, IUnknown
**p
)
2361 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2362 FIXME("(%p)->(%p)\n", This
, p
);
2366 static HRESULT WINAPI
HTMLAttributeCollection_item(IHTMLAttributeCollection
*iface
, VARIANT
*name
, IDispatch
**ppItem
)
2368 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2369 HTMLDOMAttribute
*attr
;
2373 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(name
), ppItem
);
2375 switch(V_VT(name
)) {
2377 hres
= get_attr_dispid_by_idx(This
, &V_I4(name
), &id
);
2380 hres
= get_attr_dispid_by_name(This
, V_BSTR(name
), &id
);
2383 FIXME("unsupported name %s\n", debugstr_variant(name
));
2386 if(hres
== DISP_E_UNKNOWNNAME
)
2387 return E_INVALIDARG
;
2391 hres
= get_domattr(This
, id
, NULL
, &attr
);
2395 *ppItem
= (IDispatch
*)&attr
->IHTMLDOMAttribute_iface
;
2399 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl
= {
2400 HTMLAttributeCollection_QueryInterface
,
2401 HTMLAttributeCollection_AddRef
,
2402 HTMLAttributeCollection_Release
,
2403 HTMLAttributeCollection_GetTypeInfoCount
,
2404 HTMLAttributeCollection_GetTypeInfo
,
2405 HTMLAttributeCollection_GetIDsOfNames
,
2406 HTMLAttributeCollection_Invoke
,
2407 HTMLAttributeCollection_get_length
,
2408 HTMLAttributeCollection__newEnum
,
2409 HTMLAttributeCollection_item
2412 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2
*iface
)
2414 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection2_iface
);
2417 static HRESULT WINAPI
HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2
*iface
, REFIID riid
, void **ppv
)
2419 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2420 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2423 static ULONG WINAPI
HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2
*iface
)
2425 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2426 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2429 static ULONG WINAPI
HTMLAttributeCollection2_Release(IHTMLAttributeCollection2
*iface
)
2431 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2432 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2435 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2
*iface
, UINT
*pctinfo
)
2437 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2438 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2441 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2
*iface
, UINT iTInfo
,
2442 LCID lcid
, ITypeInfo
**ppTInfo
)
2444 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2445 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2448 static HRESULT WINAPI
HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2
*iface
, REFIID riid
,
2449 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2451 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2452 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2456 static HRESULT WINAPI
HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2
*iface
, DISPID dispIdMember
,
2457 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2458 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2460 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2461 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2462 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2465 static HRESULT WINAPI
HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2
*iface
, BSTR bstrName
,
2466 IHTMLDOMAttribute
**newretNode
)
2468 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2469 HTMLDOMAttribute
*attr
;
2473 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2475 hres
= get_attr_dispid_by_name(This
, bstrName
, &id
);
2476 if(hres
== DISP_E_UNKNOWNNAME
) {
2479 } else if(FAILED(hres
)) {
2483 hres
= get_domattr(This
, id
, NULL
, &attr
);
2487 *newretNode
= &attr
->IHTMLDOMAttribute_iface
;
2491 static HRESULT WINAPI
HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2
*iface
,
2492 IHTMLDOMAttribute
*ppNode
, IHTMLDOMAttribute
**newretNode
)
2494 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2495 FIXME("(%p)->(%p %p)\n", This
, ppNode
, newretNode
);
2499 static HRESULT WINAPI
HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2
*iface
,
2500 BSTR bstrName
, IHTMLDOMAttribute
**newretNode
)
2502 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2503 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2507 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl
= {
2508 HTMLAttributeCollection2_QueryInterface
,
2509 HTMLAttributeCollection2_AddRef
,
2510 HTMLAttributeCollection2_Release
,
2511 HTMLAttributeCollection2_GetTypeInfoCount
,
2512 HTMLAttributeCollection2_GetTypeInfo
,
2513 HTMLAttributeCollection2_GetIDsOfNames
,
2514 HTMLAttributeCollection2_Invoke
,
2515 HTMLAttributeCollection2_getNamedItem
,
2516 HTMLAttributeCollection2_setNamedItem
,
2517 HTMLAttributeCollection2_removeNamedItem
2520 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3
*iface
)
2522 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection3_iface
);
2525 static HRESULT WINAPI
HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3
*iface
, REFIID riid
, void **ppv
)
2527 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2528 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2531 static ULONG WINAPI
HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3
*iface
)
2533 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2534 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2537 static ULONG WINAPI
HTMLAttributeCollection3_Release(IHTMLAttributeCollection3
*iface
)
2539 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2540 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2543 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3
*iface
, UINT
*pctinfo
)
2545 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2546 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2549 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3
*iface
, UINT iTInfo
,
2550 LCID lcid
, ITypeInfo
**ppTInfo
)
2552 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2553 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2556 static HRESULT WINAPI
HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3
*iface
, REFIID riid
,
2557 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2559 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2560 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2564 static HRESULT WINAPI
HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3
*iface
, DISPID dispIdMember
,
2565 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2566 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2568 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2569 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2570 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2573 static HRESULT WINAPI
HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3
*iface
, BSTR bstrName
,
2574 IHTMLDOMAttribute
**ppNodeOut
)
2576 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2577 return IHTMLAttributeCollection2_getNamedItem(&This
->IHTMLAttributeCollection2_iface
, bstrName
, ppNodeOut
);
2580 static HRESULT WINAPI
HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3
*iface
,
2581 IHTMLDOMAttribute
*pNodeIn
, IHTMLDOMAttribute
**ppNodeOut
)
2583 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2584 FIXME("(%p)->(%p %p)\n", This
, pNodeIn
, ppNodeOut
);
2588 static HRESULT WINAPI
HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3
*iface
,
2589 BSTR bstrName
, IHTMLDOMAttribute
**ppNodeOut
)
2591 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2592 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), ppNodeOut
);
2596 static HRESULT WINAPI
HTMLAttributeCollection3_item(IHTMLAttributeCollection3
*iface
, LONG index
, IHTMLDOMAttribute
**ppNodeOut
)
2598 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2599 HTMLDOMAttribute
*attr
;
2603 TRACE("(%p)->(%d %p)\n", This
, index
, ppNodeOut
);
2605 hres
= get_attr_dispid_by_idx(This
, &index
, &id
);
2606 if(hres
== DISP_E_UNKNOWNNAME
)
2607 return E_INVALIDARG
;
2611 hres
= get_domattr(This
, id
, NULL
, &attr
);
2615 *ppNodeOut
= &attr
->IHTMLDOMAttribute_iface
;
2619 static HRESULT WINAPI
HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3
*iface
, LONG
*p
)
2621 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2622 return IHTMLAttributeCollection_get_length(&This
->IHTMLAttributeCollection_iface
, p
);
2625 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl
= {
2626 HTMLAttributeCollection3_QueryInterface
,
2627 HTMLAttributeCollection3_AddRef
,
2628 HTMLAttributeCollection3_Release
,
2629 HTMLAttributeCollection3_GetTypeInfoCount
,
2630 HTMLAttributeCollection3_GetTypeInfo
,
2631 HTMLAttributeCollection3_GetIDsOfNames
,
2632 HTMLAttributeCollection3_Invoke
,
2633 HTMLAttributeCollection3_getNamedItem
,
2634 HTMLAttributeCollection3_setNamedItem
,
2635 HTMLAttributeCollection3_removeNamedItem
,
2636 HTMLAttributeCollection3_item
,
2637 HTMLAttributeCollection3_get_length
2640 static inline HTMLAttributeCollection
*HTMLAttributeCollection_from_DispatchEx(DispatchEx
*iface
)
2642 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, dispex
);
2645 static HRESULT
HTMLAttributeCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2647 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2648 HTMLDOMAttribute
*attr
;
2652 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(name
), flags
, dispid
);
2654 hres
= get_attr_dispid_by_name(This
, name
, dispid
);
2658 hres
= get_domattr(This
, *dispid
, &pos
, &attr
);
2661 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2663 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+pos
;
2667 static HRESULT
HTMLAttributeCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
2668 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2670 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2672 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
2675 case DISPATCH_PROPERTYGET
: {
2676 HTMLDOMAttribute
*iter
;
2679 pos
= id
-MSHTML_DISPID_CUSTOM_MIN
;
2681 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2683 IHTMLDOMAttribute_AddRef(&iter
->IHTMLDOMAttribute_iface
);
2684 V_VT(res
) = VT_DISPATCH
;
2685 V_DISPATCH(res
) = (IDispatch
*)&iter
->IHTMLDOMAttribute_iface
;
2691 WARN("invalid arg\n");
2692 return E_INVALIDARG
;
2696 FIXME("unimplemented flags %x\n", flags
);
2701 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl
= {
2703 HTMLAttributeCollection_get_dispid
,
2704 HTMLAttributeCollection_invoke
,
2708 static const tid_t HTMLAttributeCollection_iface_tids
[] = {
2709 IHTMLAttributeCollection_tid
,
2710 IHTMLAttributeCollection2_tid
,
2711 IHTMLAttributeCollection3_tid
,
2715 static dispex_static_data_t HTMLAttributeCollection_dispex
= {
2716 &HTMLAttributeCollection_dispex_vtbl
,
2717 DispHTMLAttributeCollection_tid
,
2719 HTMLAttributeCollection_iface_tids
2722 HRESULT
HTMLElement_get_attr_col(HTMLDOMNode
*iface
, HTMLAttributeCollection
**ac
)
2724 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
2727 IHTMLAttributeCollection_AddRef(&This
->attrs
->IHTMLAttributeCollection_iface
);
2732 This
->attrs
= heap_alloc_zero(sizeof(HTMLAttributeCollection
));
2734 return E_OUTOFMEMORY
;
2736 This
->attrs
->IHTMLAttributeCollection_iface
.lpVtbl
= &HTMLAttributeCollectionVtbl
;
2737 This
->attrs
->IHTMLAttributeCollection2_iface
.lpVtbl
= &HTMLAttributeCollection2Vtbl
;
2738 This
->attrs
->IHTMLAttributeCollection3_iface
.lpVtbl
= &HTMLAttributeCollection3Vtbl
;
2739 This
->attrs
->ref
= 2;
2741 This
->attrs
->elem
= This
;
2742 list_init(&This
->attrs
->attrs
);
2743 init_dispex(&This
->attrs
->dispex
, (IUnknown
*)&This
->attrs
->IHTMLAttributeCollection_iface
,
2744 &HTMLAttributeCollection_dispex
);