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
19 #include "mshtml_private.h"
21 static const WCHAR aW
[] = {'A',0};
22 static const WCHAR bodyW
[] = {'B','O','D','Y',0};
23 static const WCHAR buttonW
[] = {'B','U','T','T','O','N',0};
24 static const WCHAR embedW
[] = {'E','M','B','E','D',0};
25 static const WCHAR formW
[] = {'F','O','R','M',0};
26 static const WCHAR frameW
[] = {'F','R','A','M','E',0};
27 static const WCHAR headW
[] = {'H','E','A','D',0};
28 static const WCHAR iframeW
[] = {'I','F','R','A','M','E',0};
29 static const WCHAR imgW
[] = {'I','M','G',0};
30 static const WCHAR inputW
[] = {'I','N','P','U','T',0};
31 static const WCHAR labelW
[] = {'L','A','B','E','L',0};
32 static const WCHAR linkW
[] = {'L','I','N','K',0};
33 static const WCHAR metaW
[] = {'M','E','T','A',0};
34 static const WCHAR objectW
[] = {'O','B','J','E','C','T',0};
35 static const WCHAR optionW
[] = {'O','P','T','I','O','N',0};
36 static const WCHAR scriptW
[] = {'S','C','R','I','P','T',0};
37 static const WCHAR selectW
[] = {'S','E','L','E','C','T',0};
38 static const WCHAR styleW
[] = {'S','T','Y','L','E',0};
39 static const WCHAR tableW
[] = {'T','A','B','L','E',0};
40 static const WCHAR tdW
[] = {'T','D',0};
41 static const WCHAR textareaW
[] = {'T','E','X','T','A','R','E','A',0};
42 static const WCHAR title_tagW
[]= {'T','I','T','L','E',0};
43 static const WCHAR trW
[] = {'T','R',0};
47 HRESULT (*constructor
)(HTMLDocumentNode
*,nsIDOMHTMLElement
*,HTMLElement
**);
50 static const tag_desc_t tag_descs
[] = {
51 {aW
, HTMLAnchorElement_Create
},
52 {bodyW
, HTMLBodyElement_Create
},
53 {buttonW
, HTMLButtonElement_Create
},
54 {embedW
, HTMLEmbedElement_Create
},
55 {formW
, HTMLFormElement_Create
},
56 {frameW
, HTMLFrameElement_Create
},
57 {headW
, HTMLHeadElement_Create
},
58 {iframeW
, HTMLIFrame_Create
},
59 {imgW
, HTMLImgElement_Create
},
60 {inputW
, HTMLInputElement_Create
},
61 {labelW
, HTMLLabelElement_Create
},
62 {linkW
, HTMLLinkElement_Create
},
63 {metaW
, HTMLMetaElement_Create
},
64 {objectW
, HTMLObjectElement_Create
},
65 {optionW
, HTMLOptionElement_Create
},
66 {scriptW
, HTMLScriptElement_Create
},
67 {selectW
, HTMLSelectElement_Create
},
68 {styleW
, HTMLStyleElement_Create
},
69 {tableW
, HTMLTable_Create
},
70 {tdW
, HTMLTableCell_Create
},
71 {textareaW
, HTMLTextAreaElement_Create
},
72 {title_tagW
, HTMLTitleElement_Create
},
73 {trW
, HTMLTableRow_Create
}
76 static const tag_desc_t
*get_tag_desc(const WCHAR
*tag_name
)
78 DWORD min
=0, max
=sizeof(tag_descs
)/sizeof(*tag_descs
)-1, i
;
83 r
= strcmpW(tag_name
, tag_descs
[i
].name
);
96 HRESULT
replace_node_by_html(nsIDOMHTMLDocument
*nsdoc
, nsIDOMNode
*nsnode
, const WCHAR
*html
)
98 nsIDOMDocumentFragment
*nsfragment
;
105 nsres
= nsIDOMHTMLDocument_CreateRange(nsdoc
, &range
);
106 if(NS_FAILED(nsres
)) {
107 ERR("CreateRange failed: %08x\n", nsres
);
111 nsAString_InitDepend(&html_str
, html
);
112 nsIDOMRange_CreateContextualFragment(range
, &html_str
, &nsfragment
);
113 nsIDOMRange_Release(range
);
114 nsAString_Finish(&html_str
);
115 if(NS_FAILED(nsres
)) {
116 ERR("CreateContextualFragment failed: %08x\n", nsres
);
120 nsres
= nsIDOMNode_GetParentNode(nsnode
, &nsparent
);
121 if(NS_SUCCEEDED(nsres
) && nsparent
) {
124 nsres
= nsIDOMNode_ReplaceChild(nsparent
, (nsIDOMNode
*)nsfragment
, nsnode
, &nstmp
);
125 nsIDOMNode_Release(nsparent
);
126 if(NS_FAILED(nsres
)) {
127 ERR("ReplaceChild failed: %08x\n", nsres
);
130 nsIDOMNode_Release(nstmp
);
133 ERR("GetParentNode failed: %08x\n", nsres
);
137 nsIDOMDocumentFragment_Release(nsfragment
);
144 IHTMLFiltersCollection IHTMLFiltersCollection_iface
;
147 } HTMLFiltersCollection
;
149 static inline HTMLFiltersCollection
*impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection
*iface
)
151 return CONTAINING_RECORD(iface
, HTMLFiltersCollection
, IHTMLFiltersCollection_iface
);
154 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void);
156 static inline HTMLElement
*impl_from_IHTMLElement(IHTMLElement
*iface
)
158 return CONTAINING_RECORD(iface
, HTMLElement
, IHTMLElement_iface
);
161 HRESULT
create_nselem(HTMLDocumentNode
*doc
, const WCHAR
*tag
, nsIDOMHTMLElement
**ret
)
163 nsIDOMElement
*nselem
;
168 WARN("NULL nsdoc\n");
172 nsAString_InitDepend(&tag_str
, tag
);
173 nsres
= nsIDOMHTMLDocument_CreateElement(doc
->nsdoc
, &tag_str
, &nselem
);
174 nsAString_Finish(&tag_str
);
175 if(NS_FAILED(nsres
)) {
176 ERR("CreateElement failed: %08x\n", nsres
);
180 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLElement
, (void**)ret
);
181 nsIDOMElement_Release(nselem
);
182 if(NS_FAILED(nsres
)) {
183 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres
);
190 HRESULT
create_element(HTMLDocumentNode
*doc
, const WCHAR
*tag
, HTMLElement
**ret
)
192 nsIDOMHTMLElement
*nselem
;
195 /* Use owner doc if called on document fragment */
199 hres
= create_nselem(doc
, tag
, &nselem
);
203 hres
= HTMLElement_Create(doc
, (nsIDOMNode
*)nselem
, TRUE
, ret
);
204 nsIDOMHTMLElement_Release(nselem
);
208 static HRESULT WINAPI
HTMLElement_QueryInterface(IHTMLElement
*iface
,
209 REFIID riid
, void **ppv
)
211 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
213 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
216 static ULONG WINAPI
HTMLElement_AddRef(IHTMLElement
*iface
)
218 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
220 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
223 static ULONG WINAPI
HTMLElement_Release(IHTMLElement
*iface
)
225 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
227 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
230 static HRESULT WINAPI
HTMLElement_GetTypeInfoCount(IHTMLElement
*iface
, UINT
*pctinfo
)
232 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
233 return IDispatchEx_GetTypeInfoCount(&This
->node
.dispex
.IDispatchEx_iface
, pctinfo
);
236 static HRESULT WINAPI
HTMLElement_GetTypeInfo(IHTMLElement
*iface
, UINT iTInfo
,
237 LCID lcid
, ITypeInfo
**ppTInfo
)
239 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
240 return IDispatchEx_GetTypeInfo(&This
->node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
243 static HRESULT WINAPI
HTMLElement_GetIDsOfNames(IHTMLElement
*iface
, REFIID riid
,
244 LPOLESTR
*rgszNames
, UINT cNames
,
245 LCID lcid
, DISPID
*rgDispId
)
247 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
248 return IDispatchEx_GetIDsOfNames(&This
->node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
252 static HRESULT WINAPI
HTMLElement_Invoke(IHTMLElement
*iface
, DISPID dispIdMember
,
253 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
254 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
256 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
257 return IDispatchEx_Invoke(&This
->node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
258 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
261 static HRESULT WINAPI
HTMLElement_setAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
262 VARIANT AttributeValue
, LONG lFlags
)
264 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
266 DISPID dispid
, dispidNamed
= DISPID_PROPERTYPUT
;
267 DISPPARAMS dispParams
;
270 TRACE("(%p)->(%s %s %08x)\n", This
, debugstr_w(strAttributeName
), debugstr_variant(&AttributeValue
), lFlags
);
272 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
273 fdexNameCaseInsensitive
| fdexNameEnsure
, &dispid
);
277 dispParams
.cArgs
= 1;
278 dispParams
.cNamedArgs
= 1;
279 dispParams
.rgdispidNamedArgs
= &dispidNamed
;
280 dispParams
.rgvarg
= &AttributeValue
;
282 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
,
283 LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYPUT
, &dispParams
, NULL
, &excep
, NULL
);
287 static HRESULT WINAPI
HTMLElement_getAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
288 LONG lFlags
, VARIANT
*AttributeValue
)
290 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
293 DISPPARAMS dispParams
= {NULL
, NULL
, 0, 0};
296 TRACE("(%p)->(%s %08x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, AttributeValue
);
298 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
299 fdexNameCaseInsensitive
, &dispid
);
300 if(hres
== DISP_E_UNKNOWNNAME
) {
301 V_VT(AttributeValue
) = VT_NULL
;
306 V_VT(AttributeValue
) = VT_NULL
;
310 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
, LOCALE_SYSTEM_DEFAULT
,
311 DISPATCH_PROPERTYGET
, &dispParams
, AttributeValue
, &excep
, NULL
);
316 static HRESULT WINAPI
HTMLElement_removeAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
317 LONG lFlags
, VARIANT_BOOL
*pfSuccess
)
319 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
321 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, pfSuccess
);
323 return remove_prop(&This
->node
.dispex
, strAttributeName
, pfSuccess
);
326 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
328 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
329 nsAString classname_str
;
332 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
335 FIXME("NULL nselem\n");
339 nsAString_InitDepend(&classname_str
, v
);
340 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
341 nsAString_Finish(&classname_str
);
343 ERR("SetClassName failed: %08x\n", nsres
);
348 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
350 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
354 TRACE("(%p)->(%p)\n", This
, p
);
357 FIXME("NULL nselem\n");
361 nsAString_Init(&class_str
, NULL
);
362 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
363 return return_nsstr(nsres
, &class_str
, p
);
366 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
368 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
372 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
375 FIXME("nselem == NULL\n");
379 nsAString_InitDepend(&id_str
, v
);
380 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
381 nsAString_Finish(&id_str
);
383 ERR("SetId failed: %08x\n", nsres
);
388 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
390 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
394 TRACE("(%p)->(%p)\n", This
, p
);
401 nsAString_Init(&id_str
, NULL
);
402 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
403 return return_nsstr(nsres
, &id_str
, p
);
406 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
408 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
412 TRACE("(%p)->(%p)\n", This
, p
);
415 static const WCHAR comment_tagW
[] = {'!',0};
417 WARN("NULL nselem, assuming comment\n");
419 *p
= SysAllocString(comment_tagW
);
420 return *p
? S_OK
: E_OUTOFMEMORY
;
423 nsAString_Init(&tag_str
, NULL
);
424 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
425 return return_nsstr(nsres
, &tag_str
, p
);
428 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
430 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
434 TRACE("(%p)->(%p)\n", This
, p
);
436 hres
= IHTMLDOMNode_get_parentNode(&This
->node
.IHTMLDOMNode_iface
, &node
);
440 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
441 IHTMLDOMNode_Release(node
);
448 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
450 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
452 TRACE("(%p)->(%p)\n", This
, p
);
457 hres
= HTMLStyle_Create(This
, &This
->style
);
462 *p
= &This
->style
->IHTMLStyle_iface
;
463 IHTMLStyle_AddRef(*p
);
467 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
469 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
470 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
474 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
476 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
477 FIXME("(%p)->(%p)\n", This
, p
);
481 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
483 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
485 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
487 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
490 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
492 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
494 TRACE("(%p)->(%p)\n", This
, p
);
496 return get_node_event(&This
->node
, EVENTID_CLICK
, p
);
499 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
501 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
503 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
505 return set_node_event(&This
->node
, EVENTID_DBLCLICK
, &v
);
508 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
510 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
512 TRACE("(%p)->(%p)\n", This
, p
);
514 return get_node_event(&This
->node
, EVENTID_DBLCLICK
, p
);
517 static HRESULT WINAPI
HTMLElement_put_onkeydown(IHTMLElement
*iface
, VARIANT v
)
519 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
521 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
523 return set_node_event(&This
->node
, EVENTID_KEYDOWN
, &v
);
526 static HRESULT WINAPI
HTMLElement_get_onkeydown(IHTMLElement
*iface
, VARIANT
*p
)
528 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
530 TRACE("(%p)->(%p)\n", This
, p
);
532 return get_node_event(&This
->node
, EVENTID_KEYDOWN
, p
);
535 static HRESULT WINAPI
HTMLElement_put_onkeyup(IHTMLElement
*iface
, VARIANT v
)
537 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
539 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
541 return set_node_event(&This
->node
, EVENTID_KEYUP
, &v
);
544 static HRESULT WINAPI
HTMLElement_get_onkeyup(IHTMLElement
*iface
, VARIANT
*p
)
546 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
547 FIXME("(%p)->(%p)\n", This
, p
);
551 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
553 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
555 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
557 return set_node_event(&This
->node
, EVENTID_KEYPRESS
, &v
);
560 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
562 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
564 TRACE("(%p)->(%p)\n", This
, p
);
566 return get_node_event(&This
->node
, EVENTID_KEYPRESS
, p
);
569 static HRESULT WINAPI
HTMLElement_put_onmouseout(IHTMLElement
*iface
, VARIANT v
)
571 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
573 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
575 return set_node_event(&This
->node
, EVENTID_MOUSEOUT
, &v
);
578 static HRESULT WINAPI
HTMLElement_get_onmouseout(IHTMLElement
*iface
, VARIANT
*p
)
580 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
582 TRACE("(%p)->(%p)\n", This
, p
);
584 return get_node_event(&This
->node
, EVENTID_MOUSEOUT
, p
);
587 static HRESULT WINAPI
HTMLElement_put_onmouseover(IHTMLElement
*iface
, VARIANT v
)
589 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
591 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
593 return set_node_event(&This
->node
, EVENTID_MOUSEOVER
, &v
);
596 static HRESULT WINAPI
HTMLElement_get_onmouseover(IHTMLElement
*iface
, VARIANT
*p
)
598 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
600 TRACE("(%p)->(%p)\n", This
, p
);
602 return get_node_event(&This
->node
, EVENTID_MOUSEOVER
, p
);
605 static HRESULT WINAPI
HTMLElement_put_onmousemove(IHTMLElement
*iface
, VARIANT v
)
607 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
609 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
611 return set_node_event(&This
->node
, EVENTID_MOUSEMOVE
, &v
);
614 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
616 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
618 TRACE("(%p)->(%p)\n", This
, p
);
620 return get_node_event(&This
->node
, EVENTID_MOUSEMOVE
, p
);
623 static HRESULT WINAPI
HTMLElement_put_onmousedown(IHTMLElement
*iface
, VARIANT v
)
625 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
627 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
629 return set_node_event(&This
->node
, EVENTID_MOUSEDOWN
, &v
);
632 static HRESULT WINAPI
HTMLElement_get_onmousedown(IHTMLElement
*iface
, VARIANT
*p
)
634 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
636 TRACE("(%p)->(%p)\n", This
, p
);
638 return get_node_event(&This
->node
, EVENTID_MOUSEDOWN
, p
);
641 static HRESULT WINAPI
HTMLElement_put_onmouseup(IHTMLElement
*iface
, VARIANT v
)
643 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
645 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
647 return set_node_event(&This
->node
, EVENTID_MOUSEUP
, &v
);
650 static HRESULT WINAPI
HTMLElement_get_onmouseup(IHTMLElement
*iface
, VARIANT
*p
)
652 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
654 TRACE("(%p)->(%p)\n", This
, p
);
656 return get_node_event(&This
->node
, EVENTID_MOUSEUP
, p
);
659 static HRESULT WINAPI
HTMLElement_get_document(IHTMLElement
*iface
, IDispatch
**p
)
661 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
663 TRACE("(%p)->(%p)\n", This
, p
);
668 if(This
->node
.vtbl
->get_document
)
669 return This
->node
.vtbl
->get_document(&This
->node
, p
);
671 *p
= (IDispatch
*)&This
->node
.doc
->basedoc
.IHTMLDocument2_iface
;
672 IDispatch_AddRef(*p
);
676 static const WCHAR titleW
[] = {'t','i','t','l','e',0};
678 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
680 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
684 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
690 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, TRUE
, &var
);
696 V_BSTR(var
) = v
? SysAllocString(v
) : NULL
;
700 nsAString_InitDepend(&title_str
, v
);
701 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
702 nsAString_Finish(&title_str
);
704 ERR("SetTitle failed: %08x\n", nsres
);
709 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
711 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
715 TRACE("(%p)->(%p)\n", This
, p
);
721 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, FALSE
, &var
);
722 if(hres
== DISP_E_UNKNOWNNAME
) {
724 }else if(V_VT(var
) != VT_BSTR
) {
725 FIXME("title = %s\n", debugstr_variant(var
));
728 *p
= V_BSTR(var
) ? SysAllocString(V_BSTR(var
)) : NULL
;
734 nsAString_Init(&title_str
, NULL
);
735 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
736 return return_nsstr(nsres
, &title_str
, p
);
739 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
741 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
742 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
746 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
748 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
749 FIXME("(%p)->(%p)\n", This
, p
);
753 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
755 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
757 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
759 return set_node_event(&This
->node
, EVENTID_SELECTSTART
, &v
);
762 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
764 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
766 TRACE("(%p)->(%p)\n", This
, p
);
768 return get_node_event(&This
->node
, EVENTID_SELECTSTART
, p
);
771 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
773 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
774 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&varargStart
));
778 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
779 VARIANT_BOOL
*pfResult
)
781 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
786 TRACE("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
788 child
= unsafe_impl_from_IHTMLElement(pChild
);
790 ERR("not our element\n");
794 nsres
= nsIDOMNode_Contains(This
->node
.nsnode
, child
->node
.nsnode
, &result
);
795 if(NS_FAILED(nsres
)) {
800 *pfResult
= result
? VARIANT_TRUE
: VARIANT_FALSE
;
804 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, LONG
*p
)
806 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
807 FIXME("(%p)->(%p)\n", This
, p
);
811 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
813 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
814 FIXME("(%p)->(%p)\n", This
, p
);
818 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
820 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
821 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
825 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
827 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
828 FIXME("(%p)->(%p)\n", This
, p
);
832 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
834 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
837 TRACE("(%p)->(%p)\n", This
, p
);
839 nsres
= nsIDOMHTMLElement_GetOffsetLeft(This
->nselem
, p
);
840 if(NS_FAILED(nsres
)) {
841 ERR("GetOffsetLeft failed: %08x\n", nsres
);
848 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
850 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
853 TRACE("(%p)->(%p)\n", This
, p
);
855 nsres
= nsIDOMHTMLElement_GetOffsetTop(This
->nselem
, p
);
856 if(NS_FAILED(nsres
)) {
857 ERR("GetOffsetTop failed: %08x\n", nsres
);
864 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
866 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
869 TRACE("(%p)->(%p)\n", This
, p
);
871 nsres
= nsIDOMHTMLElement_GetOffsetWidth(This
->nselem
, p
);
872 if(NS_FAILED(nsres
)) {
873 ERR("GetOffsetWidth failed: %08x\n", nsres
);
880 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
882 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
885 TRACE("(%p)->(%p)\n", This
, p
);
887 nsres
= nsIDOMHTMLElement_GetOffsetHeight(This
->nselem
, p
);
888 if(NS_FAILED(nsres
)) {
889 ERR("GetOffsetHeight failed: %08x\n", nsres
);
896 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
898 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
899 nsIDOMElement
*nsparent
;
903 TRACE("(%p)->(%p)\n", This
, p
);
905 nsres
= nsIDOMHTMLElement_GetOffsetParent(This
->nselem
, &nsparent
);
906 if(NS_FAILED(nsres
)) {
907 ERR("GetOffsetParent failed: %08x\n", nsres
);
914 hres
= get_node(This
->node
.doc
, (nsIDOMNode
*)nsparent
, TRUE
, &node
);
915 nsIDOMElement_Release(nsparent
);
919 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)p
);
929 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
931 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
935 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
938 FIXME("NULL nselem\n");
942 nsAString_InitDepend(&html_str
, v
);
943 nsres
= nsIDOMHTMLElement_SetInnerHTML(This
->nselem
, &html_str
);
944 nsAString_Finish(&html_str
);
945 if(NS_FAILED(nsres
)) {
946 FIXME("SetInnerHtml failed %08x\n", nsres
);
953 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
955 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
959 TRACE("(%p)->(%p)\n", This
, p
);
962 FIXME("NULL nselem\n");
966 nsAString_Init(&html_str
, NULL
);
967 nsres
= nsIDOMHTMLElement_GetInnerHTML(This
->nselem
, &html_str
);
968 return return_nsstr(nsres
, &html_str
, p
);
971 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
973 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
974 nsIDOMNode
*nschild
, *tmp
;
975 nsIDOMText
*text_node
;
979 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
982 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
983 if(NS_FAILED(nsres
)) {
984 ERR("GetLastChild failed: %08x\n", nsres
);
990 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
991 nsIDOMNode_Release(nschild
);
992 if(NS_FAILED(nsres
)) {
993 ERR("RemoveChild failed: %08x\n", nsres
);
996 nsIDOMNode_Release(tmp
);
999 nsAString_InitDepend(&text_str
, v
);
1000 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
1001 nsAString_Finish(&text_str
);
1002 if(NS_FAILED(nsres
)) {
1003 ERR("CreateTextNode failed: %08x\n", nsres
);
1007 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
1008 if(NS_FAILED(nsres
)) {
1009 ERR("AppendChild failed: %08x\n", nsres
);
1013 nsIDOMNode_Release(tmp
);
1017 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
1019 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1021 TRACE("(%p)->(%p)\n", This
, p
);
1023 return get_node_text(&This
->node
, p
);
1026 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
1028 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1030 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1032 return replace_node_by_html(This
->node
.doc
->nsdoc
, This
->node
.nsnode
, v
);
1035 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
1037 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1041 WARN("(%p)->(%p) semi-stub\n", This
, p
);
1043 nsAString_Init(&html_str
, NULL
);
1044 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
1045 if(SUCCEEDED(hres
)) {
1046 const PRUnichar
*html
;
1048 nsAString_GetData(&html_str
, &html
);
1049 *p
= SysAllocString(html
);
1051 hres
= E_OUTOFMEMORY
;
1054 nsAString_Finish(&html_str
);
1056 TRACE("ret %s\n", debugstr_w(*p
));
1060 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
1062 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1063 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1067 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
1069 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1070 FIXME("(%p)->(%p)\n", This
, p
);
1074 HRESULT
insert_adjacent_node(HTMLElement
*This
, const WCHAR
*where
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret_node
)
1076 nsIDOMNode
*ret_nsnode
;
1078 HRESULT hres
= S_OK
;
1080 static const WCHAR beforebeginW
[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1081 static const WCHAR afterbeginW
[] = {'a','f','t','e','r','b','e','g','i','n',0};
1082 static const WCHAR beforeendW
[] = {'b','e','f','o','r','e','e','n','d',0};
1083 static const WCHAR afterendW
[] = {'a','f','t','e','r','e','n','d',0};
1085 if (!strcmpiW(where
, beforebeginW
)) {
1088 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1089 if(NS_FAILED(nsres
))
1093 return E_INVALIDARG
;
1095 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, This
->node
.nsnode
, &ret_nsnode
);
1096 nsIDOMNode_Release(parent
);
1097 }else if(!strcmpiW(where
, afterbeginW
)) {
1098 nsIDOMNode
*first_child
;
1100 nsres
= nsIDOMNode_GetFirstChild(This
->node
.nsnode
, &first_child
);
1101 if(NS_FAILED(nsres
))
1104 nsres
= nsIDOMNode_InsertBefore(This
->node
.nsnode
, nsnode
, first_child
, &ret_nsnode
);
1105 if(NS_FAILED(nsres
))
1109 nsIDOMNode_Release(first_child
);
1110 }else if (!strcmpiW(where
, beforeendW
)) {
1111 nsres
= nsIDOMNode_AppendChild(This
->node
.nsnode
, nsnode
, &ret_nsnode
);
1112 }else if (!strcmpiW(where
, afterendW
)) {
1113 nsIDOMNode
*next_sibling
, *parent
;
1115 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1116 if(NS_FAILED(nsres
))
1119 return E_INVALIDARG
;
1121 nsres
= nsIDOMNode_GetNextSibling(This
->node
.nsnode
, &next_sibling
);
1122 if(NS_SUCCEEDED(nsres
)) {
1124 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &ret_nsnode
);
1125 nsIDOMNode_Release(next_sibling
);
1127 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &ret_nsnode
);
1131 nsIDOMNode_Release(parent
);
1133 ERR("invalid where: %s\n", debugstr_w(where
));
1134 return E_INVALIDARG
;
1137 if (NS_FAILED(nsres
))
1141 hres
= get_node(This
->node
.doc
, ret_nsnode
, TRUE
, ret_node
);
1142 nsIDOMNode_Release(ret_nsnode
);
1146 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1149 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1156 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1158 if(!This
->node
.doc
->nsdoc
) {
1159 WARN("NULL nsdoc\n");
1160 return E_UNEXPECTED
;
1163 nsres
= nsIDOMHTMLDocument_CreateRange(This
->node
.doc
->nsdoc
, &range
);
1164 if(NS_FAILED(nsres
))
1166 ERR("CreateRange failed: %08x\n", nsres
);
1170 nsIDOMRange_SetStartBefore(range
, This
->node
.nsnode
);
1172 nsAString_InitDepend(&ns_html
, html
);
1173 nsres
= nsIDOMRange_CreateContextualFragment(range
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1174 nsAString_Finish(&ns_html
);
1175 nsIDOMRange_Release(range
);
1177 if(NS_FAILED(nsres
) || !nsnode
)
1179 ERR("CreateTextNode failed: %08x\n", nsres
);
1183 hr
= insert_adjacent_node(This
, where
, nsnode
, NULL
);
1184 nsIDOMNode_Release(nsnode
);
1188 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1191 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1197 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1199 if(!This
->node
.doc
->nsdoc
) {
1200 WARN("NULL nsdoc\n");
1201 return E_UNEXPECTED
;
1205 nsAString_InitDepend(&ns_text
, text
);
1206 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1207 nsAString_Finish(&ns_text
);
1209 if(NS_FAILED(nsres
) || !nsnode
)
1211 ERR("CreateTextNode failed: %08x\n", nsres
);
1215 hr
= insert_adjacent_node(This
, where
, nsnode
, NULL
);
1216 nsIDOMNode_Release(nsnode
);
1221 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1223 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1224 FIXME("(%p)->(%p)\n", This
, p
);
1228 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1230 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1231 FIXME("(%p)->(%p)\n", This
, p
);
1235 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1237 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1239 TRACE("(%p)\n", This
);
1241 return call_fire_event(&This
->node
, EVENTID_CLICK
);
1244 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1245 IHTMLFiltersCollection
**p
)
1247 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1248 TRACE("(%p)->(%p)\n", This
, p
);
1253 *p
= HTMLFiltersCollection_Create();
1258 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1260 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1261 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1265 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1267 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1268 FIXME("(%p)->(%p)\n", This
, p
);
1272 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1274 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1275 FIXME("(%p)->(%p)\n", This
, String
);
1279 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1281 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1282 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1286 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1288 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1289 FIXME("(%p)->(%p)\n", This
, p
);
1293 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1295 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1296 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1300 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1302 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1303 FIXME("(%p)->(%p)\n", This
, p
);
1307 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1309 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1310 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1314 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1316 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1317 FIXME("(%p)->(%p)\n", This
, p
);
1321 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1323 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1324 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1328 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1330 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1331 FIXME("(%p)->(%p)\n", This
, p
);
1335 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1337 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1338 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1342 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1344 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1345 FIXME("(%p)->(%p)\n", This
, p
);
1349 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1351 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1352 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1356 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1358 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1359 FIXME("(%p)->(%p)\n", This
, p
);
1363 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1365 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1367 FIXME("(%p)->(%s) semi-stub\n", This
, debugstr_variant(&v
));
1369 return set_node_event(&This
->node
, EVENTID_DATAAVAILABLE
, &v
);
1372 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1374 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1376 TRACE("(%p)->(%p)\n", This
, p
);
1378 return get_node_event(&This
->node
, EVENTID_DATAAVAILABLE
, p
);
1381 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1383 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1384 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1388 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1390 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1391 FIXME("(%p)->(%p)\n", This
, p
);
1395 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1397 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1398 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1402 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1404 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1405 FIXME("(%p)->(%p)\n", This
, p
);
1409 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1411 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1412 nsIDOMNodeList
*nsnode_list
;
1415 TRACE("(%p)->(%p)\n", This
, p
);
1417 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1418 if(NS_FAILED(nsres
)) {
1419 ERR("GetChildNodes failed: %08x\n", nsres
);
1423 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, nsnode_list
);
1425 nsIDOMNodeList_Release(nsnode_list
);
1429 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1431 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1433 TRACE("(%p)->(%p)\n", This
, p
);
1435 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1439 static const IHTMLElementVtbl HTMLElementVtbl
= {
1440 HTMLElement_QueryInterface
,
1442 HTMLElement_Release
,
1443 HTMLElement_GetTypeInfoCount
,
1444 HTMLElement_GetTypeInfo
,
1445 HTMLElement_GetIDsOfNames
,
1447 HTMLElement_setAttribute
,
1448 HTMLElement_getAttribute
,
1449 HTMLElement_removeAttribute
,
1450 HTMLElement_put_className
,
1451 HTMLElement_get_className
,
1454 HTMLElement_get_tagName
,
1455 HTMLElement_get_parentElement
,
1456 HTMLElement_get_style
,
1457 HTMLElement_put_onhelp
,
1458 HTMLElement_get_onhelp
,
1459 HTMLElement_put_onclick
,
1460 HTMLElement_get_onclick
,
1461 HTMLElement_put_ondblclick
,
1462 HTMLElement_get_ondblclick
,
1463 HTMLElement_put_onkeydown
,
1464 HTMLElement_get_onkeydown
,
1465 HTMLElement_put_onkeyup
,
1466 HTMLElement_get_onkeyup
,
1467 HTMLElement_put_onkeypress
,
1468 HTMLElement_get_onkeypress
,
1469 HTMLElement_put_onmouseout
,
1470 HTMLElement_get_onmouseout
,
1471 HTMLElement_put_onmouseover
,
1472 HTMLElement_get_onmouseover
,
1473 HTMLElement_put_onmousemove
,
1474 HTMLElement_get_onmousemove
,
1475 HTMLElement_put_onmousedown
,
1476 HTMLElement_get_onmousedown
,
1477 HTMLElement_put_onmouseup
,
1478 HTMLElement_get_onmouseup
,
1479 HTMLElement_get_document
,
1480 HTMLElement_put_title
,
1481 HTMLElement_get_title
,
1482 HTMLElement_put_language
,
1483 HTMLElement_get_language
,
1484 HTMLElement_put_onselectstart
,
1485 HTMLElement_get_onselectstart
,
1486 HTMLElement_scrollIntoView
,
1487 HTMLElement_contains
,
1488 HTMLElement_get_sourceIndex
,
1489 HTMLElement_get_recordNumber
,
1490 HTMLElement_put_lang
,
1491 HTMLElement_get_lang
,
1492 HTMLElement_get_offsetLeft
,
1493 HTMLElement_get_offsetTop
,
1494 HTMLElement_get_offsetWidth
,
1495 HTMLElement_get_offsetHeight
,
1496 HTMLElement_get_offsetParent
,
1497 HTMLElement_put_innerHTML
,
1498 HTMLElement_get_innerHTML
,
1499 HTMLElement_put_innerText
,
1500 HTMLElement_get_innerText
,
1501 HTMLElement_put_outerHTML
,
1502 HTMLElement_get_outerHTML
,
1503 HTMLElement_put_outerText
,
1504 HTMLElement_get_outerText
,
1505 HTMLElement_insertAdjacentHTML
,
1506 HTMLElement_insertAdjacentText
,
1507 HTMLElement_get_parentTextEdit
,
1508 HTMLElement_get_isTextEdit
,
1510 HTMLElement_get_filters
,
1511 HTMLElement_put_ondragstart
,
1512 HTMLElement_get_ondragstart
,
1513 HTMLElement_toString
,
1514 HTMLElement_put_onbeforeupdate
,
1515 HTMLElement_get_onbeforeupdate
,
1516 HTMLElement_put_onafterupdate
,
1517 HTMLElement_get_onafterupdate
,
1518 HTMLElement_put_onerrorupdate
,
1519 HTMLElement_get_onerrorupdate
,
1520 HTMLElement_put_onrowexit
,
1521 HTMLElement_get_onrowexit
,
1522 HTMLElement_put_onrowenter
,
1523 HTMLElement_get_onrowenter
,
1524 HTMLElement_put_ondatasetchanged
,
1525 HTMLElement_get_ondatasetchanged
,
1526 HTMLElement_put_ondataavailable
,
1527 HTMLElement_get_ondataavailable
,
1528 HTMLElement_put_ondatasetcomplete
,
1529 HTMLElement_get_ondatasetcomplete
,
1530 HTMLElement_put_onfilterchange
,
1531 HTMLElement_get_onfilterchange
,
1532 HTMLElement_get_children
,
1536 HTMLElement
*unsafe_impl_from_IHTMLElement(IHTMLElement
*iface
)
1538 return iface
->lpVtbl
== &HTMLElementVtbl
? impl_from_IHTMLElement(iface
) : NULL
;
1541 static inline HTMLElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
1543 return CONTAINING_RECORD(iface
, HTMLElement
, node
);
1546 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1548 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1552 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1553 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1554 *ppv
= &This
->IHTMLElement_iface
;
1555 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1556 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1557 *ppv
= &This
->IHTMLElement_iface
;
1558 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1559 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
1560 *ppv
= &This
->IHTMLElement_iface
;
1561 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1562 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
1563 *ppv
= &This
->IHTMLElement2_iface
;
1564 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1565 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This
, ppv
);
1566 *ppv
= &This
->IHTMLElement3_iface
;
1567 }else if(IsEqualGUID(&IID_IHTMLElement4
, riid
)) {
1568 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This
, ppv
);
1569 *ppv
= &This
->IHTMLElement4_iface
;
1570 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1571 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1572 *ppv
= &This
->cp_container
.IConnectionPointContainer_iface
;
1576 IHTMLElement_AddRef(&This
->IHTMLElement_iface
);
1580 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1583 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1585 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1587 ConnectionPointContainer_Destroy(&This
->cp_container
);
1590 This
->style
->elem
= NULL
;
1591 IHTMLStyle_Release(&This
->style
->IHTMLStyle_iface
);
1593 if(This
->runtime_style
) {
1594 This
->runtime_style
->elem
= NULL
;
1595 IHTMLStyle_Release(&This
->runtime_style
->IHTMLStyle_iface
);
1598 HTMLDOMAttribute
*attr
;
1600 LIST_FOR_EACH_ENTRY(attr
, &This
->attrs
->attrs
, HTMLDOMAttribute
, entry
)
1603 This
->attrs
->elem
= NULL
;
1604 IHTMLAttributeCollection_Release(&This
->attrs
->IHTMLAttributeCollection_iface
);
1607 heap_free(This
->filter
);
1609 HTMLDOMNode_destructor(&This
->node
);
1612 HRESULT
HTMLElement_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
1614 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1615 HTMLElement
*new_elem
;
1618 hres
= HTMLElement_Create(This
->node
.doc
, nsnode
, FALSE
, &new_elem
);
1623 new_elem
->filter
= heap_strdupW(This
->filter
);
1624 if(!new_elem
->filter
) {
1625 IHTMLElement_Release(&This
->IHTMLElement_iface
);
1626 return E_OUTOFMEMORY
;
1630 *ret
= &new_elem
->node
;
1634 HRESULT
HTMLElement_handle_event(HTMLDOMNode
*iface
, DWORD eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
1636 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1639 case EVENTID_KEYDOWN
: {
1640 nsIDOMKeyEvent
*key_event
;
1643 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMKeyEvent
, (void**)&key_event
);
1644 if(NS_SUCCEEDED(nsres
)) {
1647 nsIDOMKeyEvent_GetKeyCode(key_event
, &code
);
1650 case VK_F1
: /* DOM_VK_F1 */
1651 TRACE("F1 pressed\n");
1652 fire_event(This
->node
.doc
, EVENTID_HELP
, TRUE
, This
->node
.nsnode
, NULL
, NULL
);
1653 *prevent_default
= TRUE
;
1656 nsIDOMKeyEvent_Release(key_event
);
1664 cp_static_data_t HTMLElementEvents2_data
= { HTMLElementEvents2_tid
, NULL
/* FIXME */, TRUE
};
1666 const cpc_entry_t HTMLElement_cpc
[] = {
1671 static const NodeImplVtbl HTMLElementImplVtbl
= {
1673 HTMLElement_destructor
,
1676 HTMLElement_handle_event
,
1677 HTMLElement_get_attr_col
1680 static inline HTMLElement
*impl_from_DispatchEx(DispatchEx
*iface
)
1682 return CONTAINING_RECORD(iface
, HTMLElement
, node
.dispex
);
1685 static HRESULT
HTMLElement_get_dispid(DispatchEx
*dispex
, BSTR name
,
1686 DWORD grfdex
, DISPID
*pid
)
1688 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1690 if(This
->node
.vtbl
->get_dispid
)
1691 return This
->node
.vtbl
->get_dispid(&This
->node
, name
, grfdex
, pid
);
1693 return DISP_E_UNKNOWNNAME
;
1696 static HRESULT
HTMLElement_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
1697 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
1698 IServiceProvider
*caller
)
1700 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1702 if(This
->node
.vtbl
->invoke
)
1703 return This
->node
.vtbl
->invoke(&This
->node
, id
, lcid
, flags
,
1704 params
, res
, ei
, caller
);
1706 ERR("(%p): element has no invoke method\n", This
);
1710 static HRESULT
HTMLElement_populate_props(DispatchEx
*dispex
)
1712 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1713 nsIDOMMozNamedAttrMap
*attrs
;
1716 const PRUnichar
*str
;
1728 nsres
= nsIDOMHTMLElement_GetAttributes(This
->nselem
, &attrs
);
1729 if(NS_FAILED(nsres
))
1732 nsres
= nsIDOMMozNamedAttrMap_GetLength(attrs
, &len
);
1733 if(NS_FAILED(nsres
)) {
1734 nsIDOMMozNamedAttrMap_Release(attrs
);
1738 nsAString_Init(&nsstr
, NULL
);
1739 for(i
=0; i
<len
; i
++) {
1740 nsres
= nsIDOMMozNamedAttrMap_Item(attrs
, i
, &attr
);
1741 if(NS_FAILED(nsres
))
1744 nsres
= nsIDOMAttr_GetNodeName(attr
, &nsstr
);
1745 if(NS_FAILED(nsres
)) {
1746 nsIDOMAttr_Release(attr
);
1750 nsAString_GetData(&nsstr
, &str
);
1751 name
= SysAllocString(str
);
1753 nsIDOMAttr_Release(attr
);
1757 hres
= IDispatchEx_GetDispID(&dispex
->IDispatchEx_iface
, name
, fdexNameCaseInsensitive
, &id
);
1758 if(hres
!= DISP_E_UNKNOWNNAME
) {
1759 nsIDOMAttr_Release(attr
);
1760 SysFreeString(name
);
1764 nsres
= nsIDOMAttr_GetNodeValue(attr
, &nsstr
);
1765 nsIDOMAttr_Release(attr
);
1766 if(NS_FAILED(nsres
)) {
1767 SysFreeString(name
);
1771 nsAString_GetData(&nsstr
, &str
);
1772 V_VT(&value
) = VT_BSTR
;
1774 V_BSTR(&value
) = SysAllocString(str
);
1775 if(!V_BSTR(&value
)) {
1776 SysFreeString(name
);
1780 V_BSTR(&value
) = NULL
;
1782 IHTMLElement_setAttribute(&This
->IHTMLElement_iface
, name
, value
, 0);
1783 SysFreeString(name
);
1784 VariantClear(&value
);
1786 nsAString_Finish(&nsstr
);
1788 nsIDOMMozNamedAttrMap_Release(attrs
);
1792 static const tid_t HTMLElement_iface_tids
[] = {
1797 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl
= {
1799 HTMLElement_get_dispid
,
1801 HTMLElement_populate_props
1804 static dispex_static_data_t HTMLElement_dispex
= {
1805 &HTMLElement_dispex_vtbl
,
1806 DispHTMLUnknownElement_tid
,
1808 HTMLElement_iface_tids
1811 void HTMLElement_Init(HTMLElement
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, dispex_static_data_t
*dispex_data
)
1813 This
->IHTMLElement_iface
.lpVtbl
= &HTMLElementVtbl
;
1815 HTMLElement2_Init(This
);
1816 HTMLElement3_Init(This
);
1818 if(dispex_data
&& !dispex_data
->vtbl
)
1819 dispex_data
->vtbl
= &HTMLElement_dispex_vtbl
;
1820 init_dispex(&This
->node
.dispex
, (IUnknown
*)&This
->IHTMLElement_iface
,
1821 dispex_data
? dispex_data
: &HTMLElement_dispex
);
1824 HTMLDOMNode_Init(doc
, &This
->node
, (nsIDOMNode
*)nselem
);
1826 /* No AddRef, share reference with HTMLDOMNode */
1827 assert((nsIDOMNode
*)nselem
== This
->node
.nsnode
);
1828 This
->nselem
= nselem
;
1831 This
->node
.cp_container
= &This
->cp_container
;
1832 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)&This
->IHTMLElement_iface
, This
->node
.vtbl
->cpc_entries
);
1835 HRESULT
HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
, HTMLElement
**ret
)
1837 nsIDOMHTMLElement
*nselem
;
1838 nsAString class_name_str
;
1839 const PRUnichar
*class_name
;
1840 const tag_desc_t
*tag
;
1845 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1846 if(NS_FAILED(nsres
))
1849 nsAString_Init(&class_name_str
, NULL
);
1850 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1852 nsAString_GetData(&class_name_str
, &class_name
);
1854 tag
= get_tag_desc(class_name
);
1856 hres
= tag
->constructor(doc
, nselem
, &elem
);
1857 }else if(use_generic
) {
1858 hres
= HTMLGenericElement_Create(doc
, nselem
, &elem
);
1860 elem
= heap_alloc_zero(sizeof(HTMLElement
));
1862 elem
->node
.vtbl
= &HTMLElementImplVtbl
;
1863 HTMLElement_Init(elem
, doc
, nselem
, &HTMLElement_dispex
);
1866 hres
= E_OUTOFMEMORY
;
1870 TRACE("%s ret %p\n", debugstr_w(class_name
), elem
);
1872 nsIDOMHTMLElement_Release(nselem
);
1873 nsAString_Finish(&class_name_str
);
1881 HRESULT
get_elem(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**ret
)
1886 hres
= get_node(doc
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
1890 *ret
= impl_from_HTMLDOMNode(node
);
1894 /* interface IHTMLFiltersCollection */
1895 static HRESULT WINAPI
HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection
*iface
, REFIID riid
, void **ppv
)
1897 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1899 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
1901 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1902 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1903 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1904 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection
, riid
)) {
1905 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This
, ppv
);
1906 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1907 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
1908 return *ppv
? S_OK
: E_NOINTERFACE
;
1912 IUnknown_AddRef((IUnknown
*)*ppv
);
1916 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1917 return E_NOINTERFACE
;
1920 static ULONG WINAPI
HTMLFiltersCollection_AddRef(IHTMLFiltersCollection
*iface
)
1922 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1923 LONG ref
= InterlockedIncrement(&This
->ref
);
1925 TRACE("(%p) ref=%d\n", This
, ref
);
1930 static ULONG WINAPI
HTMLFiltersCollection_Release(IHTMLFiltersCollection
*iface
)
1932 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1933 LONG ref
= InterlockedDecrement(&This
->ref
);
1935 TRACE("(%p) ref=%d\n", This
, ref
);
1945 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection
*iface
, UINT
*pctinfo
)
1947 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1948 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
1951 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection
*iface
,
1952 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1954 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1955 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1958 static HRESULT WINAPI
HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection
*iface
,
1959 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
,
1960 LCID lcid
, DISPID
*rgDispId
)
1962 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1963 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
1967 static HRESULT WINAPI
HTMLFiltersCollection_Invoke(IHTMLFiltersCollection
*iface
, DISPID dispIdMember
, REFIID riid
,
1968 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
1969 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1971 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1972 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
1973 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1976 static HRESULT WINAPI
HTMLFiltersCollection_get_length(IHTMLFiltersCollection
*iface
, LONG
*p
)
1978 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1983 FIXME("(%p)->(%p) Always returning 0\n", This
, p
);
1989 static HRESULT WINAPI
HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection
*iface
, IUnknown
**p
)
1991 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1992 FIXME("(%p)->(%p)\n", This
, p
);
1996 static HRESULT WINAPI
HTMLFiltersCollection_item(IHTMLFiltersCollection
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
1998 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1999 FIXME("(%p)->(%p, %p)\n", This
, pvarIndex
, pvarResult
);
2003 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl
= {
2004 HTMLFiltersCollection_QueryInterface
,
2005 HTMLFiltersCollection_AddRef
,
2006 HTMLFiltersCollection_Release
,
2007 HTMLFiltersCollection_GetTypeInfoCount
,
2008 HTMLFiltersCollection_GetTypeInfo
,
2009 HTMLFiltersCollection_GetIDsOfNames
,
2010 HTMLFiltersCollection_Invoke
,
2011 HTMLFiltersCollection_get_length
,
2012 HTMLFiltersCollection_get__newEnum
,
2013 HTMLFiltersCollection_item
2016 static HRESULT
HTMLFiltersCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2021 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
2022 idx
= idx
*10 + (*ptr
-'0');
2024 return DISP_E_UNKNOWNNAME
;
2026 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
2027 TRACE("ret %x\n", *dispid
);
2031 static HRESULT
HTMLFiltersCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2032 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2034 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex
, id
, lcid
, flags
, params
, res
, ei
);
2036 V_VT(res
) = VT_DISPATCH
;
2037 V_DISPATCH(res
) = NULL
;
2039 FIXME("always returning NULL\n");
2044 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl
= {
2046 HTMLFiltersCollection_get_dispid
,
2047 HTMLFiltersCollection_invoke
,
2051 static const tid_t HTMLFiltersCollection_iface_tids
[] = {
2052 IHTMLFiltersCollection_tid
,
2055 static dispex_static_data_t HTMLFiltersCollection_dispex
= {
2056 &HTMLFiltersCollection_dispex_vtbl
,
2057 IHTMLFiltersCollection_tid
,
2059 HTMLFiltersCollection_iface_tids
2062 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void)
2064 HTMLFiltersCollection
*ret
= heap_alloc(sizeof(HTMLFiltersCollection
));
2066 ret
->IHTMLFiltersCollection_iface
.lpVtbl
= &HTMLFiltersCollectionVtbl
;
2069 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLFiltersCollection_iface
,
2070 &HTMLFiltersCollection_dispex
);
2072 return &ret
->IHTMLFiltersCollection_iface
;
2075 /* interface IHTMLAttributeCollection */
2076 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection
*iface
)
2078 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection_iface
);
2081 static HRESULT WINAPI
HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection
*iface
, REFIID riid
, void **ppv
)
2083 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2087 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
2088 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
2089 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2090 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection
, riid
)) {
2091 TRACE("(%p)->(IID_IHTMLAttributeCollection %p)\n", This
, ppv
);
2092 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2093 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2
, riid
)) {
2094 TRACE("(%p)->(IID_IHTMLAttributeCollection2 %p)\n", This
, ppv
);
2095 *ppv
= &This
->IHTMLAttributeCollection2_iface
;
2096 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3
, riid
)) {
2097 TRACE("(%p)->(IID_IHTMLAttributeCollection3 %p)\n", This
, ppv
);
2098 *ppv
= &This
->IHTMLAttributeCollection3_iface
;
2099 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
2100 return *ppv
? S_OK
: E_NOINTERFACE
;
2104 IUnknown_AddRef((IUnknown
*)*ppv
);
2108 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
2109 return E_NOINTERFACE
;
2112 static ULONG WINAPI
HTMLAttributeCollection_AddRef(IHTMLAttributeCollection
*iface
)
2114 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2115 LONG ref
= InterlockedIncrement(&This
->ref
);
2117 TRACE("(%p) ref=%d\n", This
, ref
);
2122 static ULONG WINAPI
HTMLAttributeCollection_Release(IHTMLAttributeCollection
*iface
)
2124 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2125 LONG ref
= InterlockedDecrement(&This
->ref
);
2127 TRACE("(%p) ref=%d\n", This
, ref
);
2130 while(!list_empty(&This
->attrs
)) {
2131 HTMLDOMAttribute
*attr
= LIST_ENTRY(list_head(&This
->attrs
), HTMLDOMAttribute
, entry
);
2133 list_remove(&attr
->entry
);
2135 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2144 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection
*iface
, UINT
*pctinfo
)
2146 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2147 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2150 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection
*iface
, UINT iTInfo
,
2151 LCID lcid
, ITypeInfo
**ppTInfo
)
2153 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2154 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2157 static HRESULT WINAPI
HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection
*iface
, REFIID riid
,
2158 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2160 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2161 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2165 static HRESULT WINAPI
HTMLAttributeCollection_Invoke(IHTMLAttributeCollection
*iface
, DISPID dispIdMember
,
2166 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2167 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2169 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2170 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2171 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2174 static HRESULT
get_attr_dispid_by_idx(HTMLAttributeCollection
*This
, LONG
*idx
, DISPID
*dispid
)
2176 IDispatchEx
*dispex
= &This
->elem
->node
.dispex
.IDispatchEx_iface
;
2177 DISPID id
= DISPID_STARTENUM
;
2181 FIXME("filter non-enumerable attributes out\n");
2184 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
2187 else if(hres
== S_FALSE
)
2197 return *idx
==len
? S_OK
: DISP_E_UNKNOWNNAME
;
2204 static inline HRESULT
get_attr_dispid_by_name(HTMLAttributeCollection
*This
, BSTR name
, DISPID
*id
)
2208 if(name
[0]>='0' && name
[0]<='9') {
2212 idx
= strtoulW(name
, &end_ptr
, 10);
2214 hres
= get_attr_dispid_by_idx(This
, &idx
, id
);
2221 WARN("NULL elem\n");
2222 return E_UNEXPECTED
;
2225 hres
= IDispatchEx_GetDispID(&This
->elem
->node
.dispex
.IDispatchEx_iface
,
2226 name
, fdexNameCaseInsensitive
, id
);
2230 static inline HRESULT
get_domattr(HTMLAttributeCollection
*This
, DISPID id
, LONG
*list_pos
, HTMLDOMAttribute
**attr
)
2232 HTMLDOMAttribute
*iter
;
2237 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2238 if(iter
->dispid
== id
) {
2247 WARN("NULL elem\n");
2248 return E_UNEXPECTED
;
2251 hres
= HTMLDOMAttribute_Create(NULL
, This
->elem
, id
, attr
);
2256 IHTMLDOMAttribute_AddRef(&(*attr
)->IHTMLDOMAttribute_iface
);
2262 static HRESULT WINAPI
HTMLAttributeCollection_get_length(IHTMLAttributeCollection
*iface
, LONG
*p
)
2264 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2267 TRACE("(%p)->(%p)\n", This
, p
);
2270 hres
= get_attr_dispid_by_idx(This
, p
, NULL
);
2274 static HRESULT WINAPI
HTMLAttributeCollection__newEnum(IHTMLAttributeCollection
*iface
, IUnknown
**p
)
2276 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2277 FIXME("(%p)->(%p)\n", This
, p
);
2281 static HRESULT WINAPI
HTMLAttributeCollection_item(IHTMLAttributeCollection
*iface
, VARIANT
*name
, IDispatch
**ppItem
)
2283 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2284 HTMLDOMAttribute
*attr
;
2288 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(name
), ppItem
);
2290 switch(V_VT(name
)) {
2292 hres
= get_attr_dispid_by_idx(This
, &V_I4(name
), &id
);
2295 hres
= get_attr_dispid_by_name(This
, V_BSTR(name
), &id
);
2298 FIXME("unsupported name %s\n", debugstr_variant(name
));
2301 if(hres
== DISP_E_UNKNOWNNAME
)
2302 return E_INVALIDARG
;
2306 hres
= get_domattr(This
, id
, NULL
, &attr
);
2310 *ppItem
= (IDispatch
*)&attr
->IHTMLDOMAttribute_iface
;
2314 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl
= {
2315 HTMLAttributeCollection_QueryInterface
,
2316 HTMLAttributeCollection_AddRef
,
2317 HTMLAttributeCollection_Release
,
2318 HTMLAttributeCollection_GetTypeInfoCount
,
2319 HTMLAttributeCollection_GetTypeInfo
,
2320 HTMLAttributeCollection_GetIDsOfNames
,
2321 HTMLAttributeCollection_Invoke
,
2322 HTMLAttributeCollection_get_length
,
2323 HTMLAttributeCollection__newEnum
,
2324 HTMLAttributeCollection_item
2327 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2
*iface
)
2329 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection2_iface
);
2332 static HRESULT WINAPI
HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2
*iface
, REFIID riid
, void **ppv
)
2334 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2335 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2338 static ULONG WINAPI
HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2
*iface
)
2340 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2341 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2344 static ULONG WINAPI
HTMLAttributeCollection2_Release(IHTMLAttributeCollection2
*iface
)
2346 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2347 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2350 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2
*iface
, UINT
*pctinfo
)
2352 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2353 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2356 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2
*iface
, UINT iTInfo
,
2357 LCID lcid
, ITypeInfo
**ppTInfo
)
2359 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2360 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2363 static HRESULT WINAPI
HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2
*iface
, REFIID riid
,
2364 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2366 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2367 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2371 static HRESULT WINAPI
HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2
*iface
, DISPID dispIdMember
,
2372 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2373 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2375 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2376 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2377 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2380 static HRESULT WINAPI
HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2
*iface
, BSTR bstrName
,
2381 IHTMLDOMAttribute
**newretNode
)
2383 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2384 HTMLDOMAttribute
*attr
;
2388 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2390 hres
= get_attr_dispid_by_name(This
, bstrName
, &id
);
2391 if(hres
== DISP_E_UNKNOWNNAME
) {
2394 } else if(FAILED(hres
)) {
2398 hres
= get_domattr(This
, id
, NULL
, &attr
);
2402 *newretNode
= &attr
->IHTMLDOMAttribute_iface
;
2406 static HRESULT WINAPI
HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2
*iface
,
2407 IHTMLDOMAttribute
*ppNode
, IHTMLDOMAttribute
**newretNode
)
2409 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2410 FIXME("(%p)->(%p %p)\n", This
, ppNode
, newretNode
);
2414 static HRESULT WINAPI
HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2
*iface
,
2415 BSTR bstrName
, IHTMLDOMAttribute
**newretNode
)
2417 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2418 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2422 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl
= {
2423 HTMLAttributeCollection2_QueryInterface
,
2424 HTMLAttributeCollection2_AddRef
,
2425 HTMLAttributeCollection2_Release
,
2426 HTMLAttributeCollection2_GetTypeInfoCount
,
2427 HTMLAttributeCollection2_GetTypeInfo
,
2428 HTMLAttributeCollection2_GetIDsOfNames
,
2429 HTMLAttributeCollection2_Invoke
,
2430 HTMLAttributeCollection2_getNamedItem
,
2431 HTMLAttributeCollection2_setNamedItem
,
2432 HTMLAttributeCollection2_removeNamedItem
2435 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3
*iface
)
2437 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection3_iface
);
2440 static HRESULT WINAPI
HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3
*iface
, REFIID riid
, void **ppv
)
2442 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2443 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2446 static ULONG WINAPI
HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3
*iface
)
2448 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2449 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2452 static ULONG WINAPI
HTMLAttributeCollection3_Release(IHTMLAttributeCollection3
*iface
)
2454 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2455 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2458 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3
*iface
, UINT
*pctinfo
)
2460 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2461 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2464 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3
*iface
, UINT iTInfo
,
2465 LCID lcid
, ITypeInfo
**ppTInfo
)
2467 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2468 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2471 static HRESULT WINAPI
HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3
*iface
, REFIID riid
,
2472 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2474 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2475 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2479 static HRESULT WINAPI
HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3
*iface
, DISPID dispIdMember
,
2480 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2481 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2483 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2484 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2485 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2488 static HRESULT WINAPI
HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3
*iface
, BSTR bstrName
,
2489 IHTMLDOMAttribute
**ppNodeOut
)
2491 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2492 return IHTMLAttributeCollection2_getNamedItem(&This
->IHTMLAttributeCollection2_iface
, bstrName
, ppNodeOut
);
2495 static HRESULT WINAPI
HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3
*iface
,
2496 IHTMLDOMAttribute
*pNodeIn
, IHTMLDOMAttribute
**ppNodeOut
)
2498 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2499 FIXME("(%p)->(%p %p)\n", This
, pNodeIn
, ppNodeOut
);
2503 static HRESULT WINAPI
HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3
*iface
,
2504 BSTR bstrName
, IHTMLDOMAttribute
**ppNodeOut
)
2506 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2507 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), ppNodeOut
);
2511 static HRESULT WINAPI
HTMLAttributeCollection3_item(IHTMLAttributeCollection3
*iface
, LONG index
, IHTMLDOMAttribute
**ppNodeOut
)
2513 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2514 HTMLDOMAttribute
*attr
;
2518 TRACE("(%p)->(%d %p)\n", This
, index
, ppNodeOut
);
2520 hres
= get_attr_dispid_by_idx(This
, &index
, &id
);
2521 if(hres
== DISP_E_UNKNOWNNAME
)
2522 return E_INVALIDARG
;
2526 hres
= get_domattr(This
, id
, NULL
, &attr
);
2530 *ppNodeOut
= &attr
->IHTMLDOMAttribute_iface
;
2534 static HRESULT WINAPI
HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3
*iface
, LONG
*p
)
2536 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2537 return IHTMLAttributeCollection_get_length(&This
->IHTMLAttributeCollection_iface
, p
);
2540 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl
= {
2541 HTMLAttributeCollection3_QueryInterface
,
2542 HTMLAttributeCollection3_AddRef
,
2543 HTMLAttributeCollection3_Release
,
2544 HTMLAttributeCollection3_GetTypeInfoCount
,
2545 HTMLAttributeCollection3_GetTypeInfo
,
2546 HTMLAttributeCollection3_GetIDsOfNames
,
2547 HTMLAttributeCollection3_Invoke
,
2548 HTMLAttributeCollection3_getNamedItem
,
2549 HTMLAttributeCollection3_setNamedItem
,
2550 HTMLAttributeCollection3_removeNamedItem
,
2551 HTMLAttributeCollection3_item
,
2552 HTMLAttributeCollection3_get_length
2555 static inline HTMLAttributeCollection
*HTMLAttributeCollection_from_DispatchEx(DispatchEx
*iface
)
2557 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, dispex
);
2560 static HRESULT
HTMLAttributeCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2562 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2563 HTMLDOMAttribute
*attr
;
2567 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(name
), flags
, dispid
);
2569 hres
= get_attr_dispid_by_name(This
, name
, dispid
);
2573 hres
= get_domattr(This
, *dispid
, &pos
, &attr
);
2576 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2578 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+pos
;
2582 static HRESULT
HTMLAttributeCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
2583 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2585 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2587 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
2590 case DISPATCH_PROPERTYGET
: {
2591 HTMLDOMAttribute
*iter
;
2594 pos
= id
-MSHTML_DISPID_CUSTOM_MIN
;
2596 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2598 IHTMLDOMAttribute_AddRef(&iter
->IHTMLDOMAttribute_iface
);
2599 V_VT(res
) = VT_DISPATCH
;
2600 V_DISPATCH(res
) = (IDispatch
*)&iter
->IHTMLDOMAttribute_iface
;
2606 WARN("invalid arg\n");
2607 return E_INVALIDARG
;
2611 FIXME("unimplemented flags %x\n", flags
);
2616 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl
= {
2618 HTMLAttributeCollection_get_dispid
,
2619 HTMLAttributeCollection_invoke
,
2623 static const tid_t HTMLAttributeCollection_iface_tids
[] = {
2624 IHTMLAttributeCollection_tid
,
2625 IHTMLAttributeCollection2_tid
,
2626 IHTMLAttributeCollection3_tid
,
2630 static dispex_static_data_t HTMLAttributeCollection_dispex
= {
2631 &HTMLAttributeCollection_dispex_vtbl
,
2632 DispHTMLAttributeCollection_tid
,
2634 HTMLAttributeCollection_iface_tids
2637 HRESULT
HTMLElement_get_attr_col(HTMLDOMNode
*iface
, HTMLAttributeCollection
**ac
)
2639 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
2642 IHTMLAttributeCollection_AddRef(&This
->attrs
->IHTMLAttributeCollection_iface
);
2647 This
->attrs
= heap_alloc_zero(sizeof(HTMLAttributeCollection
));
2649 return E_OUTOFMEMORY
;
2651 This
->attrs
->IHTMLAttributeCollection_iface
.lpVtbl
= &HTMLAttributeCollectionVtbl
;
2652 This
->attrs
->IHTMLAttributeCollection2_iface
.lpVtbl
= &HTMLAttributeCollection2Vtbl
;
2653 This
->attrs
->IHTMLAttributeCollection3_iface
.lpVtbl
= &HTMLAttributeCollection3Vtbl
;
2654 This
->attrs
->ref
= 2;
2656 This
->attrs
->elem
= This
;
2657 list_init(&This
->attrs
->attrs
);
2658 init_dispex(&This
->attrs
->dispex
, (IUnknown
*)&This
->attrs
->IHTMLAttributeCollection_iface
,
2659 &HTMLAttributeCollection_dispex
);