shcore: Use CRT allocation functions.
[wine.git] / dlls / mshtml / htmlelem.c
blob991f960f0ca744462b3c3a539cbcb6834b6f1b6b
1 /*
2 * Copyright 2006-2010 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 <stdarg.h>
20 #include <math.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "ole2.h"
29 #include "shlwapi.h"
30 #include "mshtmdid.h"
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
35 #include "htmlevent.h"
36 #include "htmlstyle.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
40 #define ATTRFLAG_CASESENSITIVE 0x0001
41 #define ATTRFLAG_ASSTRING 0x0002
42 #define ATTRFLAG_EXPANDURL 0x0004
44 typedef struct {
45 const WCHAR *name;
46 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMElement*,HTMLElement**);
47 } tag_desc_t;
49 static HRESULT HTMLElement_Ctor(HTMLDocumentNode*,nsIDOMElement*,HTMLElement**);
51 static const tag_desc_t tag_descs[] = {
52 {L"A", HTMLAnchorElement_Create},
53 {L"ABBR", HTMLElement_Ctor},
54 {L"ACRONYM", HTMLElement_Ctor},
55 {L"ADDRESS", HTMLElement_Ctor},
56 {L"APPLET", HTMLElement_Ctor},
57 {L"AREA", HTMLAreaElement_Create},
58 {L"ARTICLE", HTMLElement_Ctor},
59 {L"ASIDE", HTMLElement_Ctor},
60 {L"AUDIO", HTMLElement_Ctor},
61 {L"B", HTMLElement_Ctor},
62 {L"BASE", HTMLElement_Ctor},
63 {L"BASEFONT", HTMLElement_Ctor},
64 {L"BDO", HTMLElement_Ctor},
65 {L"BIG", HTMLElement_Ctor},
66 {L"BLOCKQUOTE", HTMLElement_Ctor},
67 {L"BODY", HTMLBodyElement_Create},
68 {L"BR", HTMLElement_Ctor},
69 {L"BUTTON", HTMLButtonElement_Create},
70 {L"CANVAS", HTMLElement_Ctor},
71 {L"CAPTION", HTMLElement_Ctor},
72 {L"CENTER", HTMLElement_Ctor},
73 {L"CITE", HTMLElement_Ctor},
74 {L"CODE", HTMLElement_Ctor},
75 {L"COL", HTMLElement_Ctor},
76 {L"COLGROUP", HTMLElement_Ctor},
77 {L"DATALIST", HTMLElement_Ctor},
78 {L"DD", HTMLElement_Ctor},
79 {L"DEL", HTMLElement_Ctor},
80 {L"DFN", HTMLElement_Ctor},
81 {L"DIR", HTMLElement_Ctor},
82 {L"DIV", HTMLElement_Ctor},
83 {L"DL", HTMLElement_Ctor},
84 {L"DT", HTMLElement_Ctor},
85 {L"EM", HTMLElement_Ctor},
86 {L"EMBED", HTMLEmbedElement_Create},
87 {L"FIELDSET", HTMLElement_Ctor},
88 {L"FIGCAPTION", HTMLElement_Ctor},
89 {L"FIGURE", HTMLElement_Ctor},
90 {L"FONT", HTMLElement_Ctor},
91 {L"FOOTER", HTMLElement_Ctor},
92 {L"FORM", HTMLFormElement_Create},
93 {L"FRAME", HTMLFrameElement_Create},
94 {L"FRAMESET", HTMLElement_Ctor},
95 {L"H1", HTMLElement_Ctor},
96 {L"H2", HTMLElement_Ctor},
97 {L"H3", HTMLElement_Ctor},
98 {L"H4", HTMLElement_Ctor},
99 {L"H5", HTMLElement_Ctor},
100 {L"H6", HTMLElement_Ctor},
101 {L"HEAD", HTMLHeadElement_Create},
102 {L"HEADER", HTMLElement_Ctor},
103 {L"HR", HTMLElement_Ctor},
104 {L"HTML", HTMLHtmlElement_Create},
105 {L"I", HTMLElement_Ctor},
106 {L"IFRAME", HTMLIFrame_Create},
107 {L"IMG", HTMLImgElement_Create},
108 {L"INPUT", HTMLInputElement_Create},
109 {L"INS", HTMLElement_Ctor},
110 {L"KBD", HTMLElement_Ctor},
111 {L"LABEL", HTMLLabelElement_Create},
112 {L"LEGEND", HTMLElement_Ctor},
113 {L"LI", HTMLElement_Ctor},
114 {L"LINK", HTMLLinkElement_Create},
115 {L"MAP", HTMLElement_Ctor},
116 {L"MARK", HTMLElement_Ctor},
117 {L"META", HTMLMetaElement_Create},
118 {L"NAV", HTMLElement_Ctor},
119 {L"NOFRAMES", HTMLElement_Ctor},
120 {L"NOSCRIPT", HTMLElement_Ctor},
121 {L"OBJECT", HTMLObjectElement_Create},
122 {L"OL", HTMLElement_Ctor},
123 {L"OPTGROUP", HTMLElement_Ctor},
124 {L"OPTION", HTMLOptionElement_Create},
125 {L"P", HTMLElement_Ctor},
126 {L"PARAM", HTMLElement_Ctor},
127 {L"PRE", HTMLElement_Ctor},
128 {L"PROGRESS", HTMLElement_Ctor},
129 {L"Q", HTMLElement_Ctor},
130 {L"RP", HTMLElement_Ctor},
131 {L"RT", HTMLElement_Ctor},
132 {L"RUBY", HTMLElement_Ctor},
133 {L"S", HTMLElement_Ctor},
134 {L"SAMP", HTMLElement_Ctor},
135 {L"SCRIPT", HTMLScriptElement_Create},
136 {L"SECTION", HTMLElement_Ctor},
137 {L"SELECT", HTMLSelectElement_Create},
138 {L"SMALL", HTMLElement_Ctor},
139 {L"SOURCE", HTMLElement_Ctor},
140 {L"SPAN", HTMLElement_Ctor},
141 {L"STRIKE", HTMLElement_Ctor},
142 {L"STRONG", HTMLElement_Ctor},
143 {L"STYLE", HTMLStyleElement_Create},
144 {L"SUB", HTMLElement_Ctor},
145 {L"SUP", HTMLElement_Ctor},
146 {L"TABLE", HTMLTable_Create},
147 {L"TBODY", HTMLElement_Ctor},
148 {L"TD", HTMLTableCell_Create},
149 {L"TEXTAREA", HTMLTextAreaElement_Create},
150 {L"TFOOT", HTMLElement_Ctor},
151 {L"TH", HTMLElement_Ctor},
152 {L"THEAD", HTMLElement_Ctor},
153 {L"TITLE", HTMLTitleElement_Create},
154 {L"TR", HTMLTableRow_Create},
155 {L"TRACK", HTMLElement_Ctor},
156 {L"TT", HTMLElement_Ctor},
157 {L"U", HTMLElement_Ctor},
158 {L"UL", HTMLElement_Ctor},
159 {L"VAR", HTMLElement_Ctor},
160 {L"VIDEO", HTMLElement_Ctor},
161 {L"WBR", HTMLElement_Ctor}
164 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
166 DWORD min=0, max=ARRAY_SIZE(tag_descs)-1, i;
167 int r;
169 while(min <= max) {
170 i = (min+max)/2;
171 r = wcscmp(tag_name, tag_descs[i].name);
172 if(!r)
173 return tag_descs+i;
175 if(r < 0)
176 max = i-1;
177 else
178 min = i+1;
181 return NULL;
184 HRESULT replace_node_by_html(nsIDOMDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
186 nsIDOMDocumentFragment *nsfragment;
187 nsIDOMNode *nsparent;
188 nsIDOMRange *range;
189 nsAString html_str;
190 nsresult nsres;
191 HRESULT hres = S_OK;
193 nsres = nsIDOMDocument_CreateRange(nsdoc, &range);
194 if(NS_FAILED(nsres)) {
195 ERR("CreateRange failed: %08lx\n", nsres);
196 return E_FAIL;
199 nsAString_InitDepend(&html_str, html);
200 nsIDOMRange_CreateContextualFragment(range, &html_str, &nsfragment);
201 nsIDOMRange_Release(range);
202 nsAString_Finish(&html_str);
203 if(NS_FAILED(nsres)) {
204 ERR("CreateContextualFragment failed: %08lx\n", nsres);
205 return E_FAIL;
208 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
209 if(NS_SUCCEEDED(nsres) && nsparent) {
210 nsIDOMNode *nstmp;
212 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
213 nsIDOMNode_Release(nsparent);
214 if(NS_FAILED(nsres)) {
215 ERR("ReplaceChild failed: %08lx\n", nsres);
216 hres = E_FAIL;
217 }else if(nstmp) {
218 nsIDOMNode_Release(nstmp);
220 }else {
221 ERR("GetParentNode failed: %08lx\n", nsres);
222 hres = E_FAIL;
225 nsIDOMDocumentFragment_Release(nsfragment);
226 return hres;
229 nsresult get_elem_attr_value(nsIDOMElement *nselem, const WCHAR *name, nsAString *val_str, const PRUnichar **val)
231 nsAString name_str;
232 nsresult nsres;
234 nsAString_InitDepend(&name_str, name);
235 nsAString_Init(val_str, NULL);
236 nsres = nsIDOMElement_GetAttribute(nselem, &name_str, val_str);
237 nsAString_Finish(&name_str);
238 if(NS_FAILED(nsres)) {
239 ERR("GetAttribute(%s) failed: %08lx\n", debugstr_w(name), nsres);
240 nsAString_Finish(val_str);
241 return nsres;
244 nsAString_GetData(val_str, val);
245 return NS_OK;
248 HRESULT elem_string_attr_getter(HTMLElement *elem, const WCHAR *name, BOOL use_null, BSTR *p)
250 const PRUnichar *val;
251 nsAString val_str;
252 nsresult nsres;
253 HRESULT hres = S_OK;
255 nsres = get_elem_attr_value(elem->dom_element, name, &val_str, &val);
256 if(NS_FAILED(nsres))
257 return E_FAIL;
259 TRACE("%s: returning %s\n", debugstr_w(name), debugstr_w(val));
261 if(*val || !use_null) {
262 *p = SysAllocString(val);
263 if(!*p)
264 hres = E_OUTOFMEMORY;
265 }else {
266 *p = NULL;
268 nsAString_Finish(&val_str);
269 return hres;
272 HRESULT elem_string_attr_setter(HTMLElement *elem, const WCHAR *name, const WCHAR *value)
274 nsAString name_str, val_str;
275 nsresult nsres;
277 nsAString_InitDepend(&name_str, name);
278 nsAString_InitDepend(&val_str, value);
279 nsres = nsIDOMElement_SetAttribute(elem->dom_element, &name_str, &val_str);
280 nsAString_Finish(&name_str);
281 nsAString_Finish(&val_str);
283 if(NS_FAILED(nsres)) {
284 WARN("SetAttribute failed: %08lx\n", nsres);
285 return E_FAIL;
288 return S_OK;
291 static VARIANT_BOOL element_has_attribute(HTMLElement *element, const WCHAR *name)
293 nsAString name_str;
294 cpp_bool r;
295 nsresult nsres;
297 if(!element->dom_element) {
298 WARN("no DOM element\n");
299 return VARIANT_FALSE;
302 nsAString_InitDepend(&name_str, name);
303 nsres = nsIDOMElement_HasAttribute(element->dom_element, &name_str, &r);
304 return variant_bool(NS_SUCCEEDED(nsres) && r);
307 static HRESULT element_remove_attribute(HTMLElement *element, const WCHAR *name)
309 nsAString name_str;
310 nsresult nsres;
312 if(!element->dom_element) {
313 WARN("no DOM element\n");
314 return S_OK;
317 nsAString_InitDepend(&name_str, name);
318 nsres = nsIDOMElement_RemoveAttribute(element->dom_element, &name_str);
319 nsAString_Finish(&name_str);
320 return map_nsresult(nsres);
323 HRESULT get_readystate_string(READYSTATE readystate, BSTR *p)
325 static const LPCWSTR readystate_strs[] = {
326 L"uninitialized",
327 L"loading",
328 L"loaded",
329 L"interactive",
330 L"complete"
333 assert(readystate <= READYSTATE_COMPLETE);
334 *p = SysAllocString(readystate_strs[readystate]);
335 return *p ? S_OK : E_OUTOFMEMORY;
338 typedef struct
340 DispatchEx dispex;
341 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
342 } HTMLFiltersCollection;
344 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
346 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
349 static HRESULT create_filters_collection(compat_mode_t compat_mode, IHTMLFiltersCollection **ret);
351 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
353 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
356 static HRESULT copy_nselem_attrs(nsIDOMElement *nselem_with_attrs, nsIDOMElement *nselem)
358 nsIDOMMozNamedAttrMap *attrs;
359 nsAString name_str, val_str;
360 nsresult nsres, nsres2;
361 nsIDOMAttr *attr;
362 UINT32 i, length;
364 nsres = nsIDOMElement_GetAttributes(nselem_with_attrs, &attrs);
365 if(NS_FAILED(nsres))
366 return E_FAIL;
368 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &length);
369 if(NS_FAILED(nsres)) {
370 nsIDOMMozNamedAttrMap_Release(attrs);
371 return E_FAIL;
374 nsAString_Init(&name_str, NULL);
375 nsAString_Init(&val_str, NULL);
376 for(i = 0; i < length; i++) {
377 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
378 if(NS_FAILED(nsres))
379 continue;
381 nsres = nsIDOMAttr_GetNodeName(attr, &name_str);
382 nsres2 = nsIDOMAttr_GetNodeValue(attr, &val_str);
383 nsIDOMAttr_Release(attr);
384 if(NS_FAILED(nsres) || NS_FAILED(nsres2))
385 continue;
387 nsIDOMElement_SetAttribute(nselem, &name_str, &val_str);
389 nsAString_Finish(&name_str);
390 nsAString_Finish(&val_str);
392 nsIDOMMozNamedAttrMap_Release(attrs);
393 return S_OK;
396 static HRESULT create_nselem_parse(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMElement **ret)
398 static const WCHAR prefix[4] = L"<FOO";
399 nsIDOMDocumentFragment *nsfragment;
400 WCHAR *p = wcschr(tag + 1, '>');
401 UINT32 i, name_len, size;
402 nsIDOMElement *nselem;
403 nsIDOMRange *nsrange;
404 nsIDOMNode *nsnode;
405 nsresult nsres;
406 nsAString str;
407 HRESULT hres;
409 if(!p || p[1] || wcschr(tag + 1, '<'))
410 return E_FAIL;
411 if(!doc->dom_document) {
412 WARN("NULL dom_document\n");
413 return E_UNEXPECTED;
416 /* Ignore the starting token and > or /> end token */
417 name_len = p - tag - 1 - (p[-1] == '/');
419 /* Get the tag name using HTML whitespace rules */
420 for(i = 1; i <= name_len; i++) {
421 if((tag[i] >= 0x09 && tag[i] <= 0x0d) || tag[i] == ' ') {
422 name_len = i - 1;
423 break;
426 if(!name_len)
427 return E_FAIL;
428 size = (p + 2 - (tag + 1 + name_len)) * sizeof(WCHAR);
430 /* Parse the input via a contextual fragment, using a dummy unknown tag */
431 nsres = nsIDOMDocument_CreateRange(doc->dom_document, &nsrange);
432 if(NS_FAILED(nsres))
433 return map_nsresult(nsres);
435 if(!(p = malloc(sizeof(prefix) + size))) {
436 nsIDOMRange_Release(nsrange);
437 return E_OUTOFMEMORY;
439 memcpy(p, prefix, sizeof(prefix));
440 memcpy(p + ARRAY_SIZE(prefix), tag + 1 + name_len, size);
442 nsAString_InitDepend(&str, p);
443 nsIDOMRange_CreateContextualFragment(nsrange, &str, &nsfragment);
444 nsIDOMRange_Release(nsrange);
445 nsAString_Finish(&str);
446 free(p);
447 if(NS_FAILED(nsres))
448 return map_nsresult(nsres);
450 /* Grab the parsed element and copy its attributes into the proper element */
451 nsres = nsIDOMDocumentFragment_GetFirstChild(nsfragment, &nsnode);
452 nsIDOMDocumentFragment_Release(nsfragment);
453 if(NS_FAILED(nsres) || !nsnode)
454 return E_FAIL;
456 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
457 nsIDOMNode_Release(nsnode);
458 if(NS_FAILED(nsres))
459 return E_FAIL;
461 if(!(p = malloc((name_len + 1) * sizeof(WCHAR))))
462 hres = E_OUTOFMEMORY;
463 else {
464 memcpy(p, tag + 1, name_len * sizeof(WCHAR));
465 p[name_len] = '\0';
467 nsAString_InitDepend(&str, p);
468 nsres = nsIDOMDocument_CreateElement(doc->dom_document, &str, ret);
469 nsAString_Finish(&str);
470 free(p);
472 if(NS_FAILED(nsres))
473 hres = map_nsresult(nsres);
474 else {
475 hres = copy_nselem_attrs(nselem, *ret);
476 if(FAILED(hres))
477 nsIDOMElement_Release(*ret);
480 nsIDOMElement_Release(nselem);
481 return hres;
484 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMElement **ret)
486 nsAString tag_str;
487 nsresult nsres;
489 if(!doc->dom_document) {
490 WARN("NULL dom_document\n");
491 return E_UNEXPECTED;
494 nsAString_InitDepend(&tag_str, tag);
495 nsres = nsIDOMDocument_CreateElement(doc->dom_document, &tag_str, ret);
496 nsAString_Finish(&tag_str);
497 if(NS_FAILED(nsres)) {
498 ERR("CreateElement failed: %08lx\n", nsres);
499 return E_FAIL;
502 return S_OK;
505 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
507 nsIDOMElement *nselem;
508 HRESULT hres;
510 /* Use owner doc if called on document fragment */
511 if(!doc->dom_document)
512 doc = doc->node.doc;
514 /* IE8 and below allow creating elements with attributes, such as <div class="a"> */
515 if(tag[0] == '<' && dispex_compat_mode(&doc->node.event_target.dispex) <= COMPAT_MODE_IE8)
516 hres = create_nselem_parse(doc, tag, &nselem);
517 else
518 hres = create_nselem(doc, tag, &nselem);
519 if(FAILED(hres))
520 return hres;
522 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
523 nsIDOMElement_Release(nselem);
524 return hres;
527 typedef struct {
528 DispatchEx dispex;
529 IHTMLRect IHTMLRect_iface;
530 IHTMLRect2 IHTMLRect2_iface;
532 nsIDOMClientRect *nsrect;
533 } HTMLRect;
535 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
537 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
540 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
542 HTMLRect *This = impl_from_IHTMLRect(iface);
544 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
546 if(IsEqualGUID(&IID_IUnknown, riid)) {
547 *ppv = &This->IHTMLRect_iface;
548 }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
549 *ppv = &This->IHTMLRect_iface;
550 }else if (IsEqualGUID(&IID_IHTMLRect2, riid)) {
551 *ppv = &This->IHTMLRect2_iface;
552 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
553 return *ppv ? S_OK : E_NOINTERFACE;
554 }else {
555 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
556 *ppv = NULL;
557 return E_NOINTERFACE;
560 IUnknown_AddRef((IUnknown*)*ppv);
561 return S_OK;
564 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
566 HTMLRect *This = impl_from_IHTMLRect(iface);
567 LONG ref = dispex_ref_incr(&This->dispex);
569 TRACE("(%p) ref=%ld\n", This, ref);
571 return ref;
574 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
576 HTMLRect *This = impl_from_IHTMLRect(iface);
577 LONG ref = dispex_ref_decr(&This->dispex);
579 TRACE("(%p) ref=%ld\n", This, ref);
581 return ref;
584 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
586 HTMLRect *This = impl_from_IHTMLRect(iface);
587 FIXME("(%p)->(%p)\n", This, pctinfo);
588 return E_NOTIMPL;
591 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
592 LCID lcid, ITypeInfo **ppTInfo)
594 HTMLRect *This = impl_from_IHTMLRect(iface);
596 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
599 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
600 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
602 HTMLRect *This = impl_from_IHTMLRect(iface);
604 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
605 lcid, rgDispId);
608 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
609 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
610 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
612 HTMLRect *This = impl_from_IHTMLRect(iface);
614 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
615 pDispParams, pVarResult, pExcepInfo, puArgErr);
618 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
620 HTMLRect *This = impl_from_IHTMLRect(iface);
621 FIXME("(%p)->(%ld)\n", This, v);
622 return E_NOTIMPL;
625 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
627 HTMLRect *This = impl_from_IHTMLRect(iface);
628 float left;
629 nsresult nsres;
631 TRACE("(%p)->(%p)\n", This, p);
633 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
634 if(NS_FAILED(nsres)) {
635 ERR("GetLeft failed: %08lx\n", nsres);
636 return E_FAIL;
639 *p = floor(left+0.5);
640 return S_OK;
643 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
645 HTMLRect *This = impl_from_IHTMLRect(iface);
646 FIXME("(%p)->(%ld)\n", This, v);
647 return E_NOTIMPL;
650 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
652 HTMLRect *This = impl_from_IHTMLRect(iface);
653 float top;
654 nsresult nsres;
656 TRACE("(%p)->(%p)\n", This, p);
658 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
659 if(NS_FAILED(nsres)) {
660 ERR("GetTop failed: %08lx\n", nsres);
661 return E_FAIL;
664 *p = floor(top+0.5);
665 return S_OK;
668 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
670 HTMLRect *This = impl_from_IHTMLRect(iface);
671 FIXME("(%p)->(%ld)\n", This, v);
672 return E_NOTIMPL;
675 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
677 HTMLRect *This = impl_from_IHTMLRect(iface);
678 float right;
679 nsresult nsres;
681 TRACE("(%p)->(%p)\n", This, p);
683 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
684 if(NS_FAILED(nsres)) {
685 ERR("GetRight failed: %08lx\n", nsres);
686 return E_FAIL;
689 *p = floor(right+0.5);
690 return S_OK;
693 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
695 HTMLRect *This = impl_from_IHTMLRect(iface);
696 FIXME("(%p)->(%ld)\n", This, v);
697 return E_NOTIMPL;
700 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
702 HTMLRect *This = impl_from_IHTMLRect(iface);
703 float bottom;
704 nsresult nsres;
706 TRACE("(%p)->(%p)\n", This, p);
708 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
709 if(NS_FAILED(nsres)) {
710 ERR("GetBottom failed: %08lx\n", nsres);
711 return E_FAIL;
714 *p = floor(bottom+0.5);
715 return S_OK;
718 static inline HTMLRect *impl_from_IHTMLRect2(IHTMLRect2 *iface)
720 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect2_iface);
723 static HRESULT WINAPI HTMLRect2_QueryInterface(IHTMLRect2 *iface, REFIID riid, void **ppv)
725 HTMLRect *This = impl_from_IHTMLRect2(iface);
726 return IHTMLRect_QueryInterface(&This->IHTMLRect_iface, riid, ppv);
729 static ULONG WINAPI HTMLRect2_AddRef(IHTMLRect2 *iface)
731 HTMLRect *This = impl_from_IHTMLRect2(iface);
732 return IHTMLRect_AddRef(&This->IHTMLRect_iface);
735 static ULONG WINAPI HTMLRect2_Release(IHTMLRect2 *iface)
737 HTMLRect *This = impl_from_IHTMLRect2(iface);
738 return IHTMLRect_Release(&This->IHTMLRect_iface);
741 static HRESULT WINAPI HTMLRect2_GetTypeInfoCount(IHTMLRect2 *iface, UINT *pctinfo)
743 HTMLRect *This = impl_from_IHTMLRect2(iface);
744 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
747 static HRESULT WINAPI HTMLRect2_GetTypeInfo(IHTMLRect2 *iface, UINT iTInfo,
748 LCID lcid, ITypeInfo **ppTInfo)
750 HTMLRect *This = impl_from_IHTMLRect2(iface);
751 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
754 static HRESULT WINAPI HTMLRect2_GetIDsOfNames(IHTMLRect2 *iface, REFIID riid,
755 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
757 HTMLRect *This = impl_from_IHTMLRect2(iface);
758 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
759 lcid, rgDispId);
762 static HRESULT WINAPI HTMLRect2_Invoke(IHTMLRect2 *iface, DISPID dispIdMember,
763 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
764 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
766 HTMLRect *This = impl_from_IHTMLRect2(iface);
767 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
768 pDispParams, pVarResult, pExcepInfo, puArgErr);
771 static HRESULT WINAPI HTMLRect2_get_width(IHTMLRect2 *iface, FLOAT *p)
773 HTMLRect *This = impl_from_IHTMLRect2(iface);
774 nsresult nsres;
776 TRACE("(%p)->(%p)\n", This, p);
778 nsres = nsIDOMClientRect_GetWidth(This->nsrect, p);
779 if (NS_FAILED(nsres)) {
780 ERR("GetWidth failed: %08lx\n", nsres);
781 return E_FAIL;
784 return S_OK;
787 static HRESULT WINAPI HTMLRect2_get_height(IHTMLRect2 *iface, FLOAT *p)
789 HTMLRect *This = impl_from_IHTMLRect2(iface);
790 nsresult nsres;
792 TRACE("(%p)->(%p)\n", This, p);
794 nsres = nsIDOMClientRect_GetHeight(This->nsrect, p);
795 if (NS_FAILED(nsres)) {
796 ERR("GetHeight failed: %08lx\n", nsres);
797 return E_FAIL;
800 return S_OK;
803 static const IHTMLRectVtbl HTMLRectVtbl = {
804 HTMLRect_QueryInterface,
805 HTMLRect_AddRef,
806 HTMLRect_Release,
807 HTMLRect_GetTypeInfoCount,
808 HTMLRect_GetTypeInfo,
809 HTMLRect_GetIDsOfNames,
810 HTMLRect_Invoke,
811 HTMLRect_put_left,
812 HTMLRect_get_left,
813 HTMLRect_put_top,
814 HTMLRect_get_top,
815 HTMLRect_put_right,
816 HTMLRect_get_right,
817 HTMLRect_put_bottom,
818 HTMLRect_get_bottom
821 static const IHTMLRect2Vtbl HTMLRect2Vtbl = {
822 HTMLRect2_QueryInterface,
823 HTMLRect2_AddRef,
824 HTMLRect2_Release,
825 HTMLRect2_GetTypeInfoCount,
826 HTMLRect2_GetTypeInfo,
827 HTMLRect2_GetIDsOfNames,
828 HTMLRect2_Invoke,
829 HTMLRect2_get_width,
830 HTMLRect2_get_height,
833 static inline HTMLRect *HTMLRect_from_DispatchEx(DispatchEx *iface)
835 return CONTAINING_RECORD(iface, HTMLRect, dispex);
838 static void HTMLRect_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
840 HTMLRect *This = HTMLRect_from_DispatchEx(dispex);
841 if(This->nsrect)
842 note_cc_edge((nsISupports*)This->nsrect, "nsrect", cb);
845 static void HTMLRect_unlink(DispatchEx *dispex)
847 HTMLRect *This = HTMLRect_from_DispatchEx(dispex);
848 unlink_ref(&This->nsrect);
851 static void HTMLRect_destructor(DispatchEx *dispex)
853 HTMLRect *This = HTMLRect_from_DispatchEx(dispex);
854 free(This);
857 void HTMLRect_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
859 if (mode >= COMPAT_MODE_IE9)
860 dispex_info_add_interface(info, IHTMLRect2_tid, NULL);
863 static const dispex_static_data_vtbl_t HTMLRect_dispex_vtbl = {
864 .destructor = HTMLRect_destructor,
865 .traverse = HTMLRect_traverse,
866 .unlink = HTMLRect_unlink
869 static const tid_t HTMLRect_iface_tids[] = {
870 IHTMLRect_tid,
873 static dispex_static_data_t HTMLRect_dispex = {
874 "ClientRect",
875 &HTMLRect_dispex_vtbl,
876 IHTMLRect_tid,
877 HTMLRect_iface_tids,
878 HTMLRect_init_dispex_info
881 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, compat_mode_t compat_mode, IHTMLRect **ret)
883 HTMLRect *rect;
885 rect = calloc(1, sizeof(HTMLRect));
886 if(!rect)
887 return E_OUTOFMEMORY;
889 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
890 rect->IHTMLRect2_iface.lpVtbl = &HTMLRect2Vtbl;
892 init_dispatch(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex, compat_mode);
894 nsIDOMClientRect_AddRef(nsrect);
895 rect->nsrect = nsrect;
897 *ret = &rect->IHTMLRect_iface;
898 return S_OK;
901 typedef struct {
902 DispatchEx dispex;
903 IHTMLRectCollection IHTMLRectCollection_iface;
905 nsIDOMClientRectList *rect_list;
906 } HTMLRectCollection;
908 typedef struct {
909 IEnumVARIANT IEnumVARIANT_iface;
911 LONG ref;
913 ULONG iter;
914 HTMLRectCollection *col;
915 } HTMLRectCollectionEnum;
917 static inline HTMLRectCollectionEnum *HTMLRectCollectionEnum_from_IEnumVARIANT(IEnumVARIANT *iface)
919 return CONTAINING_RECORD(iface, HTMLRectCollectionEnum, IEnumVARIANT_iface);
922 static HRESULT WINAPI HTMLRectCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
924 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
926 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
928 if(IsEqualGUID(riid, &IID_IUnknown)) {
929 *ppv = &This->IEnumVARIANT_iface;
930 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
931 *ppv = &This->IEnumVARIANT_iface;
932 }else {
933 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
934 *ppv = NULL;
935 return E_NOINTERFACE;
938 IUnknown_AddRef((IUnknown*)*ppv);
939 return S_OK;
942 static ULONG WINAPI HTMLRectCollectionEnum_AddRef(IEnumVARIANT *iface)
944 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
945 LONG ref = InterlockedIncrement(&This->ref);
947 TRACE("(%p) ref=%ld\n", This, ref);
949 return ref;
952 static ULONG WINAPI HTMLRectCollectionEnum_Release(IEnumVARIANT *iface)
954 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
955 LONG ref = InterlockedDecrement(&This->ref);
957 TRACE("(%p) ref=%ld\n", This, ref);
959 if(!ref) {
960 IHTMLRectCollection_Release(&This->col->IHTMLRectCollection_iface);
961 free(This);
964 return ref;
967 static HRESULT WINAPI HTMLRectCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
969 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
970 VARIANT index;
971 HRESULT hres;
972 ULONG num, i;
973 UINT32 len;
975 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
977 nsIDOMClientRectList_GetLength(This->col->rect_list, &len);
978 num = min(len - This->iter, celt);
979 V_VT(&index) = VT_I4;
981 for(i = 0; i < num; i++) {
982 V_I4(&index) = This->iter + i;
983 hres = IHTMLRectCollection_item(&This->col->IHTMLRectCollection_iface, &index, &rgVar[i]);
984 if(FAILED(hres)) {
985 while(i--)
986 VariantClear(&rgVar[i]);
987 return hres;
991 This->iter += num;
992 if(pCeltFetched)
993 *pCeltFetched = num;
994 return num == celt ? S_OK : S_FALSE;
997 static HRESULT WINAPI HTMLRectCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
999 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
1000 UINT32 len;
1002 TRACE("(%p)->(%lu)\n", This, celt);
1004 nsIDOMClientRectList_GetLength(This->col->rect_list, &len);
1005 if(This->iter + celt > len) {
1006 This->iter = len;
1007 return S_FALSE;
1010 This->iter += celt;
1011 return S_OK;
1014 static HRESULT WINAPI HTMLRectCollectionEnum_Reset(IEnumVARIANT *iface)
1016 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
1018 TRACE("(%p)->()\n", This);
1020 This->iter = 0;
1021 return S_OK;
1024 static HRESULT WINAPI HTMLRectCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
1026 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
1027 FIXME("(%p)->(%p)\n", This, ppEnum);
1028 return E_NOTIMPL;
1031 static const IEnumVARIANTVtbl HTMLRectCollectionEnumVtbl = {
1032 HTMLRectCollectionEnum_QueryInterface,
1033 HTMLRectCollectionEnum_AddRef,
1034 HTMLRectCollectionEnum_Release,
1035 HTMLRectCollectionEnum_Next,
1036 HTMLRectCollectionEnum_Skip,
1037 HTMLRectCollectionEnum_Reset,
1038 HTMLRectCollectionEnum_Clone
1041 static inline HTMLRectCollection *impl_from_IHTMLRectCollection(IHTMLRectCollection *iface)
1043 return CONTAINING_RECORD(iface, HTMLRectCollection, IHTMLRectCollection_iface);
1046 static HRESULT WINAPI HTMLRectCollection_QueryInterface(IHTMLRectCollection *iface, REFIID riid, void **ppv)
1048 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1050 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
1052 if(IsEqualGUID(&IID_IUnknown, riid)) {
1053 *ppv = &This->IHTMLRectCollection_iface;
1054 }else if(IsEqualGUID(&IID_IHTMLRectCollection, riid)) {
1055 *ppv = &This->IHTMLRectCollection_iface;
1056 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1057 return *ppv ? S_OK : E_NOINTERFACE;
1058 }else {
1059 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
1060 *ppv = NULL;
1061 return E_NOINTERFACE;
1064 IUnknown_AddRef((IUnknown*)*ppv);
1065 return S_OK;
1068 static ULONG WINAPI HTMLRectCollection_AddRef(IHTMLRectCollection *iface)
1070 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1071 LONG ref = dispex_ref_incr(&This->dispex);
1073 TRACE("(%p) ref=%ld\n", This, ref);
1075 return ref;
1078 static ULONG WINAPI HTMLRectCollection_Release(IHTMLRectCollection *iface)
1080 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1081 LONG ref = dispex_ref_decr(&This->dispex);
1083 TRACE("(%p) ref=%ld\n", This, ref);
1085 return ref;
1088 static HRESULT WINAPI HTMLRectCollection_GetTypeInfoCount(IHTMLRectCollection *iface, UINT *pctinfo)
1090 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1091 FIXME("(%p)->(%p)\n", This, pctinfo);
1092 return E_NOTIMPL;
1095 static HRESULT WINAPI HTMLRectCollection_GetTypeInfo(IHTMLRectCollection *iface, UINT iTInfo,
1096 LCID lcid, ITypeInfo **ppTInfo)
1098 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1099 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1102 static HRESULT WINAPI HTMLRectCollection_GetIDsOfNames(IHTMLRectCollection *iface, REFIID riid,
1103 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1105 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1106 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1107 lcid, rgDispId);
1110 static HRESULT WINAPI HTMLRectCollection_Invoke(IHTMLRectCollection *iface, DISPID dispIdMember,
1111 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1112 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1114 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1115 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1116 pDispParams, pVarResult, pExcepInfo, puArgErr);
1119 static HRESULT WINAPI HTMLRectCollection_get_length(IHTMLRectCollection *iface, LONG *p)
1121 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1122 UINT32 length;
1123 nsresult nsres;
1125 TRACE("(%p)->(%p)\n", This, p);
1127 nsres = nsIDOMClientRectList_GetLength(This->rect_list, &length);
1128 assert(nsres == NS_OK);
1129 *p = length;
1130 return S_OK;
1133 static HRESULT WINAPI HTMLRectCollection_get__newEnum(IHTMLRectCollection *iface, IUnknown **p)
1135 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1136 HTMLRectCollectionEnum *ret;
1138 TRACE("(%p)->(%p)\n", This, p);
1140 ret = malloc(sizeof(*ret));
1141 if(!ret)
1142 return E_OUTOFMEMORY;
1144 ret->IEnumVARIANT_iface.lpVtbl = &HTMLRectCollectionEnumVtbl;
1145 ret->ref = 1;
1146 ret->iter = 0;
1148 HTMLRectCollection_AddRef(&This->IHTMLRectCollection_iface);
1149 ret->col = This;
1151 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
1152 return S_OK;
1155 static HRESULT WINAPI HTMLRectCollection_item(IHTMLRectCollection *iface, VARIANT *index, VARIANT *result)
1157 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1158 nsIDOMClientRect *nsrect;
1159 IHTMLRect *rect;
1160 nsresult nsres;
1161 HRESULT hres;
1163 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(index), result);
1165 if(V_VT(index) != VT_I4 || V_I4(index) < 0) {
1166 FIXME("Unsupported for %s index\n", debugstr_variant(index));
1167 return E_NOTIMPL;
1170 nsres = nsIDOMClientRectList_Item(This->rect_list, V_I4(index), &nsrect);
1171 if(NS_FAILED(nsres))
1172 return map_nsresult(nsres);
1173 if(!nsrect) {
1174 V_VT(result) = VT_NULL;
1175 return S_OK;
1178 hres = create_html_rect(nsrect, dispex_compat_mode(&This->dispex), &rect);
1179 nsIDOMClientRect_Release(nsrect);
1180 if(FAILED(hres))
1181 return hres;
1183 V_VT(result) = VT_DISPATCH;
1184 V_DISPATCH(result) = (IDispatch *)rect;
1185 return S_OK;
1188 static const IHTMLRectCollectionVtbl HTMLRectCollectionVtbl = {
1189 HTMLRectCollection_QueryInterface,
1190 HTMLRectCollection_AddRef,
1191 HTMLRectCollection_Release,
1192 HTMLRectCollection_GetTypeInfoCount,
1193 HTMLRectCollection_GetTypeInfo,
1194 HTMLRectCollection_GetIDsOfNames,
1195 HTMLRectCollection_Invoke,
1196 HTMLRectCollection_get_length,
1197 HTMLRectCollection_get__newEnum,
1198 HTMLRectCollection_item
1201 static inline HTMLRectCollection *HTMLRectCollection_from_DispatchEx(DispatchEx *iface)
1203 return CONTAINING_RECORD(iface, HTMLRectCollection, dispex);
1206 static void HTMLRectCollection_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
1208 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1209 if(This->rect_list)
1210 note_cc_edge((nsISupports*)This->rect_list, "rect_list", cb);
1213 static void HTMLRectCollection_unlink(DispatchEx *dispex)
1215 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1216 unlink_ref(&This->rect_list);
1219 static void HTMLRectCollection_destructor(DispatchEx *dispex)
1221 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1222 free(This);
1225 static HRESULT HTMLRectCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1227 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1228 UINT32 len = 0;
1229 DWORD idx = 0;
1230 WCHAR *ptr;
1232 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
1233 idx = idx*10 + (*ptr-'0');
1234 if(*ptr)
1235 return DISP_E_UNKNOWNNAME;
1237 nsIDOMClientRectList_GetLength(This->rect_list, &len);
1238 if(idx >= len)
1239 return DISP_E_UNKNOWNNAME;
1241 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1242 TRACE("ret %lx\n", *dispid);
1243 return S_OK;
1246 static HRESULT HTMLRectCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
1248 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1249 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
1250 UINT32 len = 0;
1251 WCHAR buf[11];
1253 nsIDOMClientRectList_GetLength(This->rect_list, &len);
1254 if(idx >= len)
1255 return DISP_E_MEMBERNOTFOUND;
1257 len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx);
1258 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
1261 static HRESULT HTMLRectCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1262 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1264 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1266 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
1268 switch(flags) {
1269 case DISPATCH_PROPERTYGET: {
1270 nsIDOMClientRect *rect;
1271 IHTMLRect *html_rect;
1272 nsresult nsres;
1273 HRESULT hres;
1275 nsres = nsIDOMClientRectList_Item(This->rect_list, id - MSHTML_DISPID_CUSTOM_MIN, &rect);
1276 if(NS_FAILED(nsres) || !rect) {
1277 WARN("Unknown item\n");
1278 return DISP_E_MEMBERNOTFOUND;
1281 hres = create_html_rect(rect, dispex_compat_mode(&This->dispex), &html_rect);
1282 nsIDOMClientRect_Release(rect);
1283 if(FAILED(hres))
1284 return hres;
1286 V_VT(res) = VT_DISPATCH;
1287 V_DISPATCH(res) = (IDispatch*)html_rect;
1288 break;
1291 default:
1292 FIXME("unimplemented flags %x\n", flags);
1293 return E_NOTIMPL;
1296 return S_OK;
1299 static const dispex_static_data_vtbl_t HTMLRectCollection_dispex_vtbl = {
1300 .destructor = HTMLRectCollection_destructor,
1301 .traverse = HTMLRectCollection_traverse,
1302 .unlink = HTMLRectCollection_unlink,
1303 .get_dispid = HTMLRectCollection_get_dispid,
1304 .get_name = HTMLRectCollection_get_name,
1305 .invoke = HTMLRectCollection_invoke,
1307 static const tid_t HTMLRectCollection_iface_tids[] = {
1308 IHTMLRectCollection_tid,
1311 static dispex_static_data_t HTMLRectCollection_dispex = {
1312 "ClientRectList",
1313 &HTMLRectCollection_dispex_vtbl,
1314 IHTMLRectCollection_tid,
1315 HTMLRectCollection_iface_tids
1318 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
1319 REFIID riid, void **ppv)
1321 HTMLElement *This = impl_from_IHTMLElement(iface);
1323 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
1326 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
1328 HTMLElement *This = impl_from_IHTMLElement(iface);
1330 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
1333 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
1335 HTMLElement *This = impl_from_IHTMLElement(iface);
1337 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
1340 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
1342 HTMLElement *This = impl_from_IHTMLElement(iface);
1343 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
1346 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
1347 LCID lcid, ITypeInfo **ppTInfo)
1349 HTMLElement *This = impl_from_IHTMLElement(iface);
1350 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1353 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
1354 LPOLESTR *rgszNames, UINT cNames,
1355 LCID lcid, DISPID *rgDispId)
1357 HTMLElement *This = impl_from_IHTMLElement(iface);
1358 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1359 lcid, rgDispId);
1362 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
1363 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1364 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1366 HTMLElement *This = impl_from_IHTMLElement(iface);
1367 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1368 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1371 static inline WCHAR *translate_attr_name(WCHAR *attr_name, compat_mode_t compat_mode)
1373 static WCHAR classNameW[] = L"className";
1374 WCHAR *ret = attr_name;
1376 if(compat_mode >= COMPAT_MODE_IE8 && !wcsicmp(attr_name, L"class"))
1377 ret = classNameW;
1378 return ret;
1381 static HRESULT set_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *v)
1383 DISPID propput_dispid = DISPID_PROPERTYPUT;
1384 DISPPARAMS dp = {v, &propput_dispid, 1, 1};
1385 EXCEPINFO ei;
1387 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
1388 TRACE("Ignoring call on style attribute\n");
1389 return S_OK;
1392 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid,
1393 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
1396 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
1397 VARIANT AttributeValue, LONG lFlags)
1399 HTMLElement *This = impl_from_IHTMLElement(iface);
1400 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1401 nsAString name_str, value_str;
1402 VARIANT val = AttributeValue;
1403 BOOL needs_free = FALSE;
1404 nsresult nsres;
1405 DISPID dispid;
1406 HRESULT hres;
1408 TRACE("(%p)->(%s %s %08lx)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
1410 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1411 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1412 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
1413 if(FAILED(hres))
1414 return hres;
1416 if(compat_mode >= COMPAT_MODE_IE8 && get_dispid_type(dispid) == DISPEXPROP_BUILTIN) {
1417 if(V_VT(&val) != VT_BSTR && V_VT(&val) != VT_NULL) {
1418 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1420 V_VT(&val) = VT_EMPTY;
1421 hres = VariantChangeTypeEx(&val, &AttributeValue, lcid, 0, VT_BSTR);
1422 if(FAILED(hres))
1423 return hres;
1425 if(V_BSTR(&val))
1426 needs_free = TRUE;
1427 else
1428 V_VT(&val) = VT_NULL;
1432 /* className and style are special cases */
1433 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1434 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1435 hres = set_elem_attr_value_by_dispid(This, dispid, &val);
1436 goto done;
1440 hres = variant_to_nsstr(&val, FALSE, &value_str);
1441 if(FAILED(hres))
1442 goto done;
1444 nsAString_InitDepend(&name_str, strAttributeName);
1445 nsres = nsIDOMElement_SetAttribute(This->dom_element, &name_str, &value_str);
1446 nsAString_Finish(&name_str);
1447 nsAString_Finish(&value_str);
1448 if(NS_FAILED(nsres))
1449 WARN("SetAttribute failed: %08lx\n", nsres);
1450 hres = map_nsresult(nsres);
1452 done:
1453 if(needs_free)
1454 SysFreeString(V_BSTR(&val));
1455 return hres;
1458 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *ret)
1460 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
1461 EXCEPINFO excep;
1463 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
1464 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
1467 HRESULT attr_value_to_string(VARIANT *v)
1469 HRESULT hres;
1471 switch(V_VT(v)) {
1472 case VT_BSTR:
1473 break;
1474 case VT_NULL:
1475 V_BSTR(v) = SysAllocString(L"null");
1476 if(!V_BSTR(v))
1477 return E_OUTOFMEMORY;
1478 V_VT(v) = VT_BSTR;
1479 break;
1480 case VT_DISPATCH:
1481 IDispatch_Release(V_DISPATCH(v));
1482 V_VT(v) = VT_BSTR;
1483 V_BSTR(v) = SysAllocString(NULL);
1484 break;
1485 default:
1486 hres = VariantChangeType(v, v, 0, VT_BSTR);
1487 if(FAILED(hres))
1488 return hres;
1491 return S_OK;
1494 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
1495 LONG lFlags, VARIANT *AttributeValue)
1497 HTMLElement *This = impl_from_IHTMLElement(iface);
1498 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1499 nsAString name_str, value_str;
1500 nsresult nsres;
1501 DISPID dispid;
1502 HRESULT hres;
1504 TRACE("(%p)->(%s %08lx %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
1506 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
1507 FIXME("Unsupported flags %lx\n", lFlags);
1509 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1510 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1511 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
1512 if(FAILED(hres)) {
1513 V_VT(AttributeValue) = VT_NULL;
1514 return (hres == DISP_E_UNKNOWNNAME) ? S_OK : hres;
1517 /* className and style are special cases */
1518 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1519 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1520 hres = get_elem_attr_value_by_dispid(This, dispid, AttributeValue);
1521 if(FAILED(hres))
1522 return hres;
1524 if(compat_mode >= COMPAT_MODE_IE8 && V_VT(AttributeValue) != VT_BSTR && V_VT(AttributeValue) != VT_NULL) {
1525 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1527 hres = VariantChangeTypeEx(AttributeValue, AttributeValue, lcid, 0, VT_BSTR);
1528 if(FAILED(hres)) {
1529 VariantClear(AttributeValue);
1530 return hres;
1532 if(!V_BSTR(AttributeValue))
1533 V_VT(AttributeValue) = VT_NULL;
1534 }else if(lFlags & ATTRFLAG_ASSTRING)
1535 hres = attr_value_to_string(AttributeValue);
1536 return hres;
1540 nsAString_InitDepend(&name_str, strAttributeName);
1541 nsAString_InitDepend(&value_str, NULL);
1542 nsres = nsIDOMElement_GetAttribute(This->dom_element, &name_str, &value_str);
1543 nsAString_Finish(&name_str);
1544 return return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
1547 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
1548 LONG lFlags, VARIANT_BOOL *pfSuccess)
1550 HTMLElement *This = impl_from_IHTMLElement(iface);
1551 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1552 DISPID id;
1553 HRESULT hres;
1555 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
1557 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1558 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1559 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
1560 if(hres == DISP_E_UNKNOWNNAME) {
1561 *pfSuccess = VARIANT_FALSE;
1562 return S_OK;
1564 if(FAILED(hres))
1565 return hres;
1567 if(id == DISPID_IHTMLELEMENT_STYLE) {
1568 IHTMLStyle *style;
1570 TRACE("Special case: style\n");
1572 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
1573 if(FAILED(hres))
1574 return hres;
1576 hres = IHTMLStyle_put_cssText(style, NULL);
1577 IHTMLStyle_Release(style);
1578 if(FAILED(hres))
1579 return hres;
1581 if(compat_mode >= COMPAT_MODE_IE8)
1582 element_remove_attribute(This, strAttributeName);
1584 *pfSuccess = VARIANT_TRUE;
1585 return S_OK;
1588 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element || id != DISPID_IHTMLELEMENT_CLASSNAME)
1589 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
1592 *pfSuccess = element_has_attribute(This, strAttributeName);
1593 if(*pfSuccess)
1594 return element_remove_attribute(This, strAttributeName);
1595 return S_OK;
1598 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
1600 HTMLElement *This = impl_from_IHTMLElement(iface);
1601 nsAString classname_str;
1602 nsresult nsres;
1604 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1606 if(!This->dom_element) {
1607 FIXME("comment element\n");
1608 return E_NOTIMPL;
1611 nsAString_InitDepend(&classname_str, v);
1612 nsres = nsIDOMElement_SetClassName(This->dom_element, &classname_str);
1613 nsAString_Finish(&classname_str);
1614 if(NS_FAILED(nsres))
1615 ERR("SetClassName failed: %08lx\n", nsres);
1617 return S_OK;
1620 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
1622 HTMLElement *This = impl_from_IHTMLElement(iface);
1623 nsAString class_str;
1624 nsresult nsres;
1626 TRACE("(%p)->(%p)\n", This, p);
1628 if(!This->dom_element) {
1629 FIXME("comment element\n");
1630 return E_NOTIMPL;
1633 nsAString_Init(&class_str, NULL);
1634 nsres = nsIDOMElement_GetClassName(This->dom_element, &class_str);
1635 return return_nsstr(nsres, &class_str, p);
1638 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
1640 HTMLElement *This = impl_from_IHTMLElement(iface);
1641 nsAString id_str;
1642 nsresult nsres;
1644 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1646 if(!This->dom_element) {
1647 FIXME("comment element\n");
1648 return S_OK;
1651 nsAString_InitDepend(&id_str, v);
1652 nsres = nsIDOMElement_SetId(This->dom_element, &id_str);
1653 nsAString_Finish(&id_str);
1654 if(NS_FAILED(nsres))
1655 ERR("SetId failed: %08lx\n", nsres);
1657 return S_OK;
1660 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
1662 HTMLElement *This = impl_from_IHTMLElement(iface);
1663 nsAString id_str;
1664 nsresult nsres;
1666 TRACE("(%p)->(%p)\n", This, p);
1668 if(!This->dom_element) {
1669 *p = NULL;
1670 return S_OK;
1673 nsAString_Init(&id_str, NULL);
1674 nsres = nsIDOMElement_GetId(This->dom_element, &id_str);
1675 return return_nsstr(nsres, &id_str, p);
1678 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
1680 HTMLElement *This = impl_from_IHTMLElement(iface);
1681 nsAString tag_str;
1682 nsresult nsres;
1684 TRACE("(%p)->(%p)\n", This, p);
1686 if(!This->dom_element) {
1687 TRACE("comment element\n");
1688 *p = SysAllocString(L"!");
1689 return *p ? S_OK : E_OUTOFMEMORY;
1692 nsAString_Init(&tag_str, NULL);
1693 nsres = nsIDOMElement_GetTagName(This->dom_element, &tag_str);
1694 return return_nsstr(nsres, &tag_str, p);
1697 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
1699 HTMLElement *This = impl_from_IHTMLElement(iface);
1700 IHTMLDOMNode *node;
1701 HRESULT hres;
1703 TRACE("(%p)->(%p)\n", This, p);
1705 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
1706 if(FAILED(hres))
1707 return hres;
1709 if(!node) {
1710 *p = NULL;
1711 return S_OK;
1714 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
1715 IHTMLDOMNode_Release(node);
1716 if(FAILED(hres))
1717 *p = NULL;
1719 return S_OK;
1722 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
1724 HTMLElement *This = impl_from_IHTMLElement(iface);
1726 TRACE("(%p)->(%p)\n", This, p);
1728 if(!This->style) {
1729 HRESULT hres;
1731 hres = HTMLStyle_Create(This, &This->style);
1732 if(FAILED(hres))
1733 return hres;
1736 *p = &This->style->IHTMLStyle_iface;
1737 IHTMLStyle_AddRef(*p);
1738 return S_OK;
1741 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
1743 HTMLElement *This = impl_from_IHTMLElement(iface);
1745 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1747 return set_node_event(&This->node, EVENTID_HELP, &v);
1750 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
1752 HTMLElement *This = impl_from_IHTMLElement(iface);
1754 TRACE("(%p)->(%p)\n", This, p);
1756 return get_node_event(&This->node, EVENTID_HELP, p);
1759 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
1761 HTMLElement *This = impl_from_IHTMLElement(iface);
1763 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1765 return set_node_event(&This->node, EVENTID_CLICK, &v);
1768 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
1770 HTMLElement *This = impl_from_IHTMLElement(iface);
1772 TRACE("(%p)->(%p)\n", This, p);
1774 return get_node_event(&This->node, EVENTID_CLICK, p);
1777 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
1779 HTMLElement *This = impl_from_IHTMLElement(iface);
1781 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1783 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
1786 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
1788 HTMLElement *This = impl_from_IHTMLElement(iface);
1790 TRACE("(%p)->(%p)\n", This, p);
1792 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
1795 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
1797 HTMLElement *This = impl_from_IHTMLElement(iface);
1799 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1801 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
1804 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
1806 HTMLElement *This = impl_from_IHTMLElement(iface);
1808 TRACE("(%p)->(%p)\n", This, p);
1810 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
1813 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
1815 HTMLElement *This = impl_from_IHTMLElement(iface);
1817 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1819 return set_node_event(&This->node, EVENTID_KEYUP, &v);
1822 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
1824 HTMLElement *This = impl_from_IHTMLElement(iface);
1826 TRACE("(%p)->(%p)\n", This, p);
1828 return get_node_event(&This->node, EVENTID_KEYUP, p);
1831 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
1833 HTMLElement *This = impl_from_IHTMLElement(iface);
1835 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1837 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
1840 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
1842 HTMLElement *This = impl_from_IHTMLElement(iface);
1844 TRACE("(%p)->(%p)\n", This, p);
1846 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
1849 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
1851 HTMLElement *This = impl_from_IHTMLElement(iface);
1853 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1855 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
1858 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
1860 HTMLElement *This = impl_from_IHTMLElement(iface);
1862 TRACE("(%p)->(%p)\n", This, p);
1864 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1867 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1869 HTMLElement *This = impl_from_IHTMLElement(iface);
1871 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1873 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1876 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1878 HTMLElement *This = impl_from_IHTMLElement(iface);
1880 TRACE("(%p)->(%p)\n", This, p);
1882 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1885 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1887 HTMLElement *This = impl_from_IHTMLElement(iface);
1889 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1891 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1894 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1896 HTMLElement *This = impl_from_IHTMLElement(iface);
1898 TRACE("(%p)->(%p)\n", This, p);
1900 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1903 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1905 HTMLElement *This = impl_from_IHTMLElement(iface);
1907 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1909 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1912 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1914 HTMLElement *This = impl_from_IHTMLElement(iface);
1916 TRACE("(%p)->(%p)\n", This, p);
1918 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1921 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1923 HTMLElement *This = impl_from_IHTMLElement(iface);
1925 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1927 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1930 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1932 HTMLElement *This = impl_from_IHTMLElement(iface);
1934 TRACE("(%p)->(%p)\n", This, p);
1936 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1939 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1941 HTMLElement *This = impl_from_IHTMLElement(iface);
1943 TRACE("(%p)->(%p)\n", This, p);
1945 if(!p)
1946 return E_POINTER;
1948 if(This->node.vtbl->get_document)
1949 return This->node.vtbl->get_document(&This->node, p);
1951 *p = (IDispatch*)&This->node.doc->IHTMLDocument2_iface;
1952 IDispatch_AddRef(*p);
1953 return S_OK;
1956 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1958 HTMLElement *This = impl_from_IHTMLElement(iface);
1959 nsAString title_str;
1960 nsresult nsres;
1962 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1964 if(!This->dom_element) {
1965 VARIANT *var;
1966 HRESULT hres;
1968 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", TRUE, &var);
1969 if(FAILED(hres))
1970 return hres;
1972 VariantClear(var);
1973 V_VT(var) = VT_BSTR;
1974 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1975 return S_OK;
1978 if(!This->html_element)
1979 return elem_string_attr_setter(This, L"title", v);
1981 nsAString_InitDepend(&title_str, v);
1982 nsres = nsIDOMHTMLElement_SetTitle(This->html_element, &title_str);
1983 nsAString_Finish(&title_str);
1984 if(NS_FAILED(nsres))
1985 ERR("SetTitle failed: %08lx\n", nsres);
1987 return S_OK;
1990 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1992 HTMLElement *This = impl_from_IHTMLElement(iface);
1993 nsAString title_str;
1994 nsresult nsres;
1996 TRACE("(%p)->(%p)\n", This, p);
1998 if(!This->dom_element) {
1999 VARIANT *var;
2000 HRESULT hres;
2002 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", FALSE, &var);
2003 if(hres == DISP_E_UNKNOWNNAME) {
2004 *p = NULL;
2005 }else if(V_VT(var) != VT_BSTR) {
2006 FIXME("title = %s\n", debugstr_variant(var));
2007 return E_FAIL;
2008 }else {
2009 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
2012 return S_OK;
2015 if(!This->html_element)
2016 return elem_string_attr_getter(This, L"title", FALSE, p);
2018 nsAString_Init(&title_str, NULL);
2019 nsres = nsIDOMHTMLElement_GetTitle(This->html_element, &title_str);
2020 return return_nsstr(nsres, &title_str, p);
2023 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
2025 HTMLElement *This = impl_from_IHTMLElement(iface);
2027 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2029 return elem_string_attr_setter(This, L"language", v);
2032 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
2034 HTMLElement *This = impl_from_IHTMLElement(iface);
2036 TRACE("(%p)->(%p)\n", This, p);
2038 return elem_string_attr_getter(This, L"language", TRUE, p);
2041 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
2043 HTMLElement *This = impl_from_IHTMLElement(iface);
2045 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2047 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
2050 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
2052 HTMLElement *This = impl_from_IHTMLElement(iface);
2054 TRACE("(%p)->(%p)\n", This, p);
2056 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
2059 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
2061 HTMLElement *This = impl_from_IHTMLElement(iface);
2062 cpp_bool start = TRUE;
2063 nsresult nsres;
2065 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
2067 switch(V_VT(&varargStart)) {
2068 case VT_EMPTY:
2069 case VT_ERROR:
2070 break;
2071 case VT_BOOL:
2072 start = V_BOOL(&varargStart) != VARIANT_FALSE;
2073 break;
2074 default:
2075 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
2078 if(!This->html_element) {
2079 FIXME("non-HTML elements\n");
2080 return E_NOTIMPL;
2083 nsres = nsIDOMHTMLElement_ScrollIntoView(This->html_element, start, 1);
2084 assert(nsres == NS_OK);
2086 return S_OK;
2089 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
2090 VARIANT_BOOL *pfResult)
2092 HTMLElement *This = impl_from_IHTMLElement(iface);
2093 cpp_bool result = FALSE;
2095 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
2097 if(pChild) {
2098 HTMLElement *child;
2099 nsresult nsres;
2101 child = unsafe_impl_from_IHTMLElement(pChild);
2102 if(!child) {
2103 ERR("not our element\n");
2104 return E_FAIL;
2107 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
2108 assert(nsres == NS_OK);
2111 *pfResult = variant_bool(result);
2112 return S_OK;
2115 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
2117 HTMLElement *This = impl_from_IHTMLElement(iface);
2119 TRACE("(%p)->(%p)\n", This, p);
2121 return get_elem_source_index(This, p);
2124 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
2126 HTMLElement *This = impl_from_IHTMLElement(iface);
2127 FIXME("(%p)->(%p)\n", This, p);
2128 return E_NOTIMPL;
2131 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
2133 HTMLElement *This = impl_from_IHTMLElement(iface);
2134 nsAString nsstr;
2135 nsresult nsres;
2137 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2139 if(!This->html_element) {
2140 FIXME("non-HTML element\n");
2141 return E_NOTIMPL;
2144 nsAString_InitDepend(&nsstr, v);
2145 nsres = nsIDOMHTMLElement_SetLang(This->html_element, &nsstr);
2146 nsAString_Finish(&nsstr);
2147 if(NS_FAILED(nsres)) {
2148 ERR("SetLang failed: %08lx\n", nsres);
2149 return E_FAIL;
2152 return S_OK;
2155 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
2157 HTMLElement *This = impl_from_IHTMLElement(iface);
2158 nsAString nsstr;
2159 nsresult nsres;
2161 TRACE("(%p)->(%p)\n", This, p);
2163 if(!This->html_element) {
2164 FIXME("non-HTML element\n");
2165 return E_NOTIMPL;
2168 nsAString_Init(&nsstr, NULL);
2169 nsres = nsIDOMHTMLElement_GetLang(This->html_element, &nsstr);
2170 return return_nsstr(nsres, &nsstr, p);
2173 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
2175 HTMLElement *This = impl_from_IHTMLElement(iface);
2176 nsresult nsres;
2178 TRACE("(%p)->(%p)\n", This, p);
2180 if(!This->html_element) {
2181 FIXME("non-HTML element\n");
2182 return E_NOTIMPL;
2185 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->html_element, p);
2186 if(NS_FAILED(nsres)) {
2187 ERR("GetOffsetLeft failed: %08lx\n", nsres);
2188 return E_FAIL;
2191 return S_OK;
2194 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
2196 HTMLElement *This = impl_from_IHTMLElement(iface);
2197 nsresult nsres;
2199 TRACE("(%p)->(%p)\n", This, p);
2201 if(!This->html_element) {
2202 FIXME("non-HTML element\n");
2203 return E_NOTIMPL;
2206 nsres = nsIDOMHTMLElement_GetOffsetTop(This->html_element, p);
2207 if(NS_FAILED(nsres)) {
2208 ERR("GetOffsetTop failed: %08lx\n", nsres);
2209 return E_FAIL;
2212 return S_OK;
2215 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
2217 HTMLElement *This = impl_from_IHTMLElement(iface);
2218 nsresult nsres;
2220 TRACE("(%p)->(%p)\n", This, p);
2222 if(!This->html_element) {
2223 FIXME("non-HTML element\n");
2224 return E_NOTIMPL;
2227 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->html_element, p);
2228 if(NS_FAILED(nsres)) {
2229 ERR("GetOffsetWidth failed: %08lx\n", nsres);
2230 return E_FAIL;
2233 return S_OK;
2236 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
2238 HTMLElement *This = impl_from_IHTMLElement(iface);
2239 nsresult nsres;
2241 TRACE("(%p)->(%p)\n", This, p);
2243 if(!This->html_element) {
2244 FIXME("non-HTML element\n");
2245 return E_NOTIMPL;
2248 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->html_element, p);
2249 if(NS_FAILED(nsres)) {
2250 ERR("GetOffsetHeight failed: %08lx\n", nsres);
2251 return E_FAIL;
2254 return S_OK;
2257 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
2259 HTMLElement *This = impl_from_IHTMLElement(iface);
2260 nsIDOMElement *nsparent;
2261 HTMLElement *parent;
2262 nsresult nsres;
2263 HRESULT hres;
2265 TRACE("(%p)->(%p)\n", This, p);
2267 if(!This->html_element) {
2268 FIXME("non-HTML element\n");
2269 return E_NOTIMPL;
2272 nsres = nsIDOMHTMLElement_GetOffsetParent(This->html_element, &nsparent);
2273 if(NS_FAILED(nsres)) {
2274 ERR("GetOffsetParent failed: %08lx\n", nsres);
2275 return E_FAIL;
2278 if(!nsparent) {
2279 *p = NULL;
2280 return S_OK;
2283 hres = get_element(nsparent, &parent);
2284 nsIDOMElement_Release(nsparent);
2285 if(FAILED(hres))
2286 return hres;
2288 *p = &parent->IHTMLElement_iface;
2289 return S_OK;
2292 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
2294 HTMLElement *This = impl_from_IHTMLElement(iface);
2295 nsAString html_str;
2296 nsresult nsres;
2298 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2300 if(!This->html_element) {
2301 FIXME("non-HTML element\n");
2302 return E_NOTIMPL;
2305 nsAString_InitDepend(&html_str, v);
2306 nsres = nsIDOMHTMLElement_SetInnerHTML(This->html_element, &html_str);
2307 nsAString_Finish(&html_str);
2308 if(NS_FAILED(nsres)) {
2309 FIXME("SetInnerHtml failed %08lx\n", nsres);
2310 return E_FAIL;
2313 return S_OK;
2316 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
2318 HTMLElement *This = impl_from_IHTMLElement(iface);
2319 nsAString html_str;
2320 nsresult nsres;
2322 TRACE("(%p)->(%p)\n", This, p);
2324 if(!This->html_element) {
2325 FIXME("non-HTML element\n");
2326 return E_NOTIMPL;
2329 nsAString_Init(&html_str, NULL);
2330 nsres = nsIDOMHTMLElement_GetInnerHTML(This->html_element, &html_str);
2331 return return_nsstr(nsres, &html_str, p);
2334 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
2336 HTMLElement *This = impl_from_IHTMLElement(iface);
2337 nsIDOMNode *nschild, *tmp;
2338 nsIDOMText *text_node;
2339 nsAString text_str;
2340 nsresult nsres;
2342 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2344 while(1) {
2345 nsres = nsIDOMElement_GetLastChild(This->dom_element, &nschild);
2346 if(NS_FAILED(nsres)) {
2347 ERR("GetLastChild failed: %08lx\n", nsres);
2348 return E_FAIL;
2350 if(!nschild)
2351 break;
2353 nsres = nsIDOMElement_RemoveChild(This->dom_element, nschild, &tmp);
2354 nsIDOMNode_Release(nschild);
2355 if(NS_FAILED(nsres)) {
2356 ERR("RemoveChild failed: %08lx\n", nsres);
2357 return E_FAIL;
2359 nsIDOMNode_Release(tmp);
2362 nsAString_InitDepend(&text_str, v);
2363 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &text_str, &text_node);
2364 nsAString_Finish(&text_str);
2365 if(NS_FAILED(nsres)) {
2366 ERR("CreateTextNode failed: %08lx\n", nsres);
2367 return E_FAIL;
2370 nsres = nsIDOMElement_AppendChild(This->dom_element, (nsIDOMNode*)text_node, &tmp);
2371 nsIDOMText_Release(text_node);
2372 if(NS_FAILED(nsres)) {
2373 ERR("AppendChild failed: %08lx\n", nsres);
2374 return E_FAIL;
2377 nsIDOMNode_Release(tmp);
2378 return S_OK;
2381 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
2383 HTMLElement *This = impl_from_IHTMLElement(iface);
2385 TRACE("(%p)->(%p)\n", This, p);
2387 return get_node_text(&This->node, p);
2390 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
2392 HTMLElement *This = impl_from_IHTMLElement(iface);
2394 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2396 return replace_node_by_html(This->node.doc->dom_document, This->node.nsnode, v);
2399 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
2401 HTMLElement *This = impl_from_IHTMLElement(iface);
2402 nsAString html_str;
2403 HRESULT hres;
2405 WARN("(%p)->(%p) semi-stub\n", This, p);
2407 nsAString_Init(&html_str, NULL);
2408 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
2409 if(SUCCEEDED(hres)) {
2410 const PRUnichar *html;
2412 nsAString_GetData(&html_str, &html);
2413 *p = SysAllocString(html);
2414 if(!*p)
2415 hres = E_OUTOFMEMORY;
2418 nsAString_Finish(&html_str);
2420 TRACE("ret %s\n", debugstr_w(*p));
2421 return hres;
2424 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
2426 HTMLElement *This = impl_from_IHTMLElement(iface);
2427 nsIDOMText *text_node;
2428 nsIDOMRange *range;
2429 nsAString nsstr;
2430 nsresult nsres;
2432 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2434 if(This->node.vtbl->is_settable && !This->node.vtbl->is_settable(&This->node, DISPID_IHTMLELEMENT_OUTERTEXT)) {
2435 WARN("Called on element that does not support setting the property.\n");
2436 return 0x800a0258; /* undocumented error code */
2439 if(!This->node.doc->dom_document) {
2440 FIXME("NULL dom_document\n");
2441 return E_FAIL;
2444 nsAString_InitDepend(&nsstr, v);
2445 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &nsstr, &text_node);
2446 nsAString_Finish(&nsstr);
2447 if(NS_FAILED(nsres)) {
2448 ERR("CreateTextNode failed\n");
2449 return E_FAIL;
2452 nsres = nsIDOMDocument_CreateRange(This->node.doc->dom_document, &range);
2453 if(NS_SUCCEEDED(nsres)) {
2454 nsres = nsIDOMRange_SelectNode(range, This->node.nsnode);
2455 if(NS_SUCCEEDED(nsres))
2456 nsres = nsIDOMRange_DeleteContents(range);
2457 if(NS_SUCCEEDED(nsres))
2458 nsres = nsIDOMRange_InsertNode(range, (nsIDOMNode*)text_node);
2459 if(NS_SUCCEEDED(nsres))
2460 nsres = nsIDOMRange_SelectNodeContents(range, This->node.nsnode);
2461 if(NS_SUCCEEDED(nsres))
2462 nsres = nsIDOMRange_DeleteContents(range);
2463 nsIDOMRange_Release(range);
2465 nsIDOMText_Release(text_node);
2466 if(NS_FAILED(nsres)) {
2467 ERR("failed to set text: %08lx\n", nsres);
2468 return E_FAIL;
2471 return S_OK;
2474 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
2476 HTMLElement *This = impl_from_IHTMLElement(iface);
2478 TRACE("(%p)->(%p)\n", This, p);
2480 /* getter is the same as innerText */
2481 return IHTMLElement_get_innerText(&This->IHTMLElement_iface, p);
2484 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
2486 nsIDOMNode *ret_nsnode;
2487 nsresult nsres;
2488 HRESULT hres = S_OK;
2490 if (!wcsicmp(where, L"beforebegin")) {
2491 nsIDOMNode *parent;
2493 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2494 if(NS_FAILED(nsres))
2495 return E_FAIL;
2497 if(!parent)
2498 return E_INVALIDARG;
2500 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
2501 nsIDOMNode_Release(parent);
2502 }else if(!wcsicmp(where, L"afterbegin")) {
2503 nsIDOMNode *first_child;
2505 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
2506 if(NS_FAILED(nsres))
2507 return E_FAIL;
2509 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
2510 if(NS_FAILED(nsres))
2511 return E_FAIL;
2513 if (first_child)
2514 nsIDOMNode_Release(first_child);
2515 }else if (!wcsicmp(where, L"beforeend")) {
2516 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
2517 }else if (!wcsicmp(where, L"afterend")) {
2518 nsIDOMNode *next_sibling, *parent;
2520 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2521 if(NS_FAILED(nsres))
2522 return E_FAIL;
2523 if(!parent)
2524 return E_INVALIDARG;
2526 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
2527 if(NS_SUCCEEDED(nsres)) {
2528 if(next_sibling) {
2529 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
2530 nsIDOMNode_Release(next_sibling);
2531 }else {
2532 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
2536 nsIDOMNode_Release(parent);
2537 }else {
2538 ERR("invalid where: %s\n", debugstr_w(where));
2539 return E_INVALIDARG;
2542 if (NS_FAILED(nsres))
2543 return E_FAIL;
2545 if(ret_node)
2546 hres = get_node(ret_nsnode, TRUE, ret_node);
2547 nsIDOMNode_Release(ret_nsnode);
2548 return hres;
2551 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
2552 BSTR html)
2554 HTMLElement *This = impl_from_IHTMLElement(iface);
2555 nsIDOMRange *range;
2556 nsIDOMNode *nsnode;
2557 nsAString ns_html;
2558 nsresult nsres;
2559 HRESULT hr;
2561 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
2563 if(!This->node.doc->dom_document) {
2564 WARN("NULL dom_document\n");
2565 return E_UNEXPECTED;
2568 nsres = nsIDOMDocument_CreateRange(This->node.doc->dom_document, &range);
2569 if(NS_FAILED(nsres))
2571 ERR("CreateRange failed: %08lx\n", nsres);
2572 return E_FAIL;
2575 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
2577 nsAString_InitDepend(&ns_html, html);
2578 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
2579 nsAString_Finish(&ns_html);
2580 nsIDOMRange_Release(range);
2582 if(NS_FAILED(nsres) || !nsnode)
2584 ERR("CreateTextNode failed: %08lx\n", nsres);
2585 return E_FAIL;
2588 hr = insert_adjacent_node(This, where, nsnode, NULL);
2589 nsIDOMNode_Release(nsnode);
2590 return hr;
2593 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
2594 BSTR text)
2596 HTMLElement *This = impl_from_IHTMLElement(iface);
2597 nsIDOMNode *nsnode;
2598 nsAString ns_text;
2599 nsresult nsres;
2600 HRESULT hr;
2602 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
2604 if(!This->node.doc->dom_document) {
2605 WARN("NULL dom_document\n");
2606 return E_UNEXPECTED;
2610 nsAString_InitDepend(&ns_text, text);
2611 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &ns_text, (nsIDOMText **)&nsnode);
2612 nsAString_Finish(&ns_text);
2614 if(NS_FAILED(nsres) || !nsnode)
2616 ERR("CreateTextNode failed: %08lx\n", nsres);
2617 return E_FAIL;
2620 hr = insert_adjacent_node(This, where, nsnode, NULL);
2621 nsIDOMNode_Release(nsnode);
2623 return hr;
2626 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
2628 HTMLElement *This = impl_from_IHTMLElement(iface);
2629 FIXME("(%p)->(%p)\n", This, p);
2630 return E_NOTIMPL;
2633 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
2635 HTMLElement *This = impl_from_IHTMLElement(iface);
2637 TRACE("(%p)->(%p)\n", This, p);
2639 *p = variant_bool(This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node));
2640 return S_OK;
2643 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
2645 HTMLElement *This = impl_from_IHTMLElement(iface);
2646 nsresult nsres;
2648 TRACE("(%p)\n", This);
2650 if(!This->html_element) {
2651 FIXME("non-HTML element\n");
2652 return E_NOTIMPL;
2655 nsres = nsIDOMHTMLElement_Click(This->html_element);
2656 if(NS_FAILED(nsres)) {
2657 ERR("Click failed: %08lx\n", nsres);
2658 return E_FAIL;
2661 return S_OK;
2664 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface, IHTMLFiltersCollection **p)
2666 HTMLElement *This = impl_from_IHTMLElement(iface);
2668 TRACE("(%p)->(%p)\n", This, p);
2670 if(!p)
2671 return E_POINTER;
2673 return create_filters_collection(dispex_compat_mode(&This->node.event_target.dispex), p);
2676 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
2678 HTMLElement *This = impl_from_IHTMLElement(iface);
2680 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2682 return set_node_event(&This->node, EVENTID_DRAGSTART, &v);
2685 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
2687 HTMLElement *This = impl_from_IHTMLElement(iface);
2689 TRACE("(%p)->(%p)\n", This, p);
2691 return get_node_event(&This->node, EVENTID_DRAGSTART, p);
2694 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
2696 HTMLElement *This = impl_from_IHTMLElement(iface);
2697 HRESULT hres;
2698 VARIANT var;
2700 TRACE("(%p)->(%p)\n", This, String);
2702 if(!String)
2703 return E_INVALIDARG;
2705 hres = IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, DISPID_VALUE,
2706 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, NULL, &var, NULL, NULL);
2707 if(SUCCEEDED(hres)) {
2708 assert(V_VT(&var) == VT_BSTR);
2709 *String = V_BSTR(&var);
2711 return hres;
2714 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
2716 HTMLElement *This = impl_from_IHTMLElement(iface);
2717 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2718 return E_NOTIMPL;
2721 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
2723 HTMLElement *This = impl_from_IHTMLElement(iface);
2724 FIXME("(%p)->(%p)\n", This, p);
2725 return E_NOTIMPL;
2728 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
2730 HTMLElement *This = impl_from_IHTMLElement(iface);
2731 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2732 return E_NOTIMPL;
2735 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
2737 HTMLElement *This = impl_from_IHTMLElement(iface);
2738 FIXME("(%p)->(%p)\n", This, p);
2739 return E_NOTIMPL;
2742 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
2744 HTMLElement *This = impl_from_IHTMLElement(iface);
2745 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2746 return E_NOTIMPL;
2749 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
2751 HTMLElement *This = impl_from_IHTMLElement(iface);
2752 FIXME("(%p)->(%p)\n", This, p);
2753 return E_NOTIMPL;
2756 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
2758 HTMLElement *This = impl_from_IHTMLElement(iface);
2759 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2760 return E_NOTIMPL;
2763 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
2765 HTMLElement *This = impl_from_IHTMLElement(iface);
2766 FIXME("(%p)->(%p)\n", This, p);
2767 return E_NOTIMPL;
2770 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
2772 HTMLElement *This = impl_from_IHTMLElement(iface);
2773 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2774 return E_NOTIMPL;
2777 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
2779 HTMLElement *This = impl_from_IHTMLElement(iface);
2780 FIXME("(%p)->(%p)\n", This, p);
2781 return E_NOTIMPL;
2784 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
2786 HTMLElement *This = impl_from_IHTMLElement(iface);
2787 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2788 return E_NOTIMPL;
2791 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
2793 HTMLElement *This = impl_from_IHTMLElement(iface);
2794 FIXME("(%p)->(%p)\n", This, p);
2795 return E_NOTIMPL;
2798 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
2800 HTMLElement *This = impl_from_IHTMLElement(iface);
2802 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
2804 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
2807 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
2809 HTMLElement *This = impl_from_IHTMLElement(iface);
2811 TRACE("(%p)->(%p)\n", This, p);
2813 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
2816 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
2818 HTMLElement *This = impl_from_IHTMLElement(iface);
2819 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2820 return E_NOTIMPL;
2823 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
2825 HTMLElement *This = impl_from_IHTMLElement(iface);
2826 FIXME("(%p)->(%p)\n", This, p);
2827 return E_NOTIMPL;
2830 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
2832 HTMLElement *This = impl_from_IHTMLElement(iface);
2833 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2834 return E_NOTIMPL;
2837 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
2839 HTMLElement *This = impl_from_IHTMLElement(iface);
2840 FIXME("(%p)->(%p)\n", This, p);
2841 return E_NOTIMPL;
2844 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
2846 HTMLElement *This = impl_from_IHTMLElement(iface);
2847 nsIDOMNodeList *nsnode_list;
2848 nsresult nsres;
2850 TRACE("(%p)->(%p)\n", This, p);
2852 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
2853 if(NS_FAILED(nsres)) {
2854 ERR("GetChildNodes failed: %08lx\n", nsres);
2855 return E_FAIL;
2858 *p = (IDispatch*)create_collection_from_nodelist(nsnode_list, This->node.doc->document_mode);
2860 nsIDOMNodeList_Release(nsnode_list);
2861 return S_OK;
2864 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
2866 HTMLElement *This = impl_from_IHTMLElement(iface);
2868 TRACE("(%p)->(%p)\n", This, p);
2870 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
2871 return S_OK;
2874 static const IHTMLElementVtbl HTMLElementVtbl = {
2875 HTMLElement_QueryInterface,
2876 HTMLElement_AddRef,
2877 HTMLElement_Release,
2878 HTMLElement_GetTypeInfoCount,
2879 HTMLElement_GetTypeInfo,
2880 HTMLElement_GetIDsOfNames,
2881 HTMLElement_Invoke,
2882 HTMLElement_setAttribute,
2883 HTMLElement_getAttribute,
2884 HTMLElement_removeAttribute,
2885 HTMLElement_put_className,
2886 HTMLElement_get_className,
2887 HTMLElement_put_id,
2888 HTMLElement_get_id,
2889 HTMLElement_get_tagName,
2890 HTMLElement_get_parentElement,
2891 HTMLElement_get_style,
2892 HTMLElement_put_onhelp,
2893 HTMLElement_get_onhelp,
2894 HTMLElement_put_onclick,
2895 HTMLElement_get_onclick,
2896 HTMLElement_put_ondblclick,
2897 HTMLElement_get_ondblclick,
2898 HTMLElement_put_onkeydown,
2899 HTMLElement_get_onkeydown,
2900 HTMLElement_put_onkeyup,
2901 HTMLElement_get_onkeyup,
2902 HTMLElement_put_onkeypress,
2903 HTMLElement_get_onkeypress,
2904 HTMLElement_put_onmouseout,
2905 HTMLElement_get_onmouseout,
2906 HTMLElement_put_onmouseover,
2907 HTMLElement_get_onmouseover,
2908 HTMLElement_put_onmousemove,
2909 HTMLElement_get_onmousemove,
2910 HTMLElement_put_onmousedown,
2911 HTMLElement_get_onmousedown,
2912 HTMLElement_put_onmouseup,
2913 HTMLElement_get_onmouseup,
2914 HTMLElement_get_document,
2915 HTMLElement_put_title,
2916 HTMLElement_get_title,
2917 HTMLElement_put_language,
2918 HTMLElement_get_language,
2919 HTMLElement_put_onselectstart,
2920 HTMLElement_get_onselectstart,
2921 HTMLElement_scrollIntoView,
2922 HTMLElement_contains,
2923 HTMLElement_get_sourceIndex,
2924 HTMLElement_get_recordNumber,
2925 HTMLElement_put_lang,
2926 HTMLElement_get_lang,
2927 HTMLElement_get_offsetLeft,
2928 HTMLElement_get_offsetTop,
2929 HTMLElement_get_offsetWidth,
2930 HTMLElement_get_offsetHeight,
2931 HTMLElement_get_offsetParent,
2932 HTMLElement_put_innerHTML,
2933 HTMLElement_get_innerHTML,
2934 HTMLElement_put_innerText,
2935 HTMLElement_get_innerText,
2936 HTMLElement_put_outerHTML,
2937 HTMLElement_get_outerHTML,
2938 HTMLElement_put_outerText,
2939 HTMLElement_get_outerText,
2940 HTMLElement_insertAdjacentHTML,
2941 HTMLElement_insertAdjacentText,
2942 HTMLElement_get_parentTextEdit,
2943 HTMLElement_get_isTextEdit,
2944 HTMLElement_click,
2945 HTMLElement_get_filters,
2946 HTMLElement_put_ondragstart,
2947 HTMLElement_get_ondragstart,
2948 HTMLElement_toString,
2949 HTMLElement_put_onbeforeupdate,
2950 HTMLElement_get_onbeforeupdate,
2951 HTMLElement_put_onafterupdate,
2952 HTMLElement_get_onafterupdate,
2953 HTMLElement_put_onerrorupdate,
2954 HTMLElement_get_onerrorupdate,
2955 HTMLElement_put_onrowexit,
2956 HTMLElement_get_onrowexit,
2957 HTMLElement_put_onrowenter,
2958 HTMLElement_get_onrowenter,
2959 HTMLElement_put_ondatasetchanged,
2960 HTMLElement_get_ondatasetchanged,
2961 HTMLElement_put_ondataavailable,
2962 HTMLElement_get_ondataavailable,
2963 HTMLElement_put_ondatasetcomplete,
2964 HTMLElement_get_ondatasetcomplete,
2965 HTMLElement_put_onfilterchange,
2966 HTMLElement_get_onfilterchange,
2967 HTMLElement_get_children,
2968 HTMLElement_get_all
2971 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2973 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2976 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2978 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2981 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
2982 REFIID riid, void **ppv)
2984 HTMLElement *This = impl_from_IHTMLElement2(iface);
2985 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2988 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2990 HTMLElement *This = impl_from_IHTMLElement2(iface);
2991 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2994 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2996 HTMLElement *This = impl_from_IHTMLElement2(iface);
2997 return IHTMLElement_Release(&This->IHTMLElement_iface);
3000 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
3002 HTMLElement *This = impl_from_IHTMLElement2(iface);
3003 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3006 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
3007 LCID lcid, ITypeInfo **ppTInfo)
3009 HTMLElement *This = impl_from_IHTMLElement2(iface);
3010 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3013 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
3014 LPOLESTR *rgszNames, UINT cNames,
3015 LCID lcid, DISPID *rgDispId)
3017 HTMLElement *This = impl_from_IHTMLElement2(iface);
3018 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3019 lcid, rgDispId);
3022 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
3023 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3024 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3026 HTMLElement *This = impl_from_IHTMLElement2(iface);
3027 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3028 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3031 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
3033 HTMLElement *This = impl_from_IHTMLElement2(iface);
3034 FIXME("(%p)->(%p)\n", This, p);
3035 return E_NOTIMPL;
3038 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
3040 HTMLElement *This = impl_from_IHTMLElement2(iface);
3041 FIXME("(%p)->(%x)\n", This, containerCapture);
3042 return E_NOTIMPL;
3045 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
3047 HTMLElement *This = impl_from_IHTMLElement2(iface);
3048 FIXME("(%p)\n", This);
3049 return E_NOTIMPL;
3052 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
3054 HTMLElement *This = impl_from_IHTMLElement2(iface);
3055 FIXME("(%p)->()\n", This);
3056 return E_NOTIMPL;
3059 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
3061 HTMLElement *This = impl_from_IHTMLElement2(iface);
3062 FIXME("(%p)->(%p)\n", This, p);
3063 return E_NOTIMPL;
3066 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
3067 LONG x, LONG y, BSTR *component)
3069 HTMLElement *This = impl_from_IHTMLElement2(iface);
3070 FIXME("(%p)->(%ld %ld %p)\n", This, x, y, component);
3071 return E_NOTIMPL;
3074 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
3076 HTMLElement *This = impl_from_IHTMLElement2(iface);
3078 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
3080 if(!This->node.doc->content_ready || !This->node.doc->doc_obj->in_place_active)
3081 return E_PENDING;
3083 WARN("stub\n");
3084 return S_OK;
3087 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
3089 HTMLElement *This = impl_from_IHTMLElement2(iface);
3091 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3093 return set_node_event(&This->node, EVENTID_SCROLL, &v);
3096 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
3098 HTMLElement *This = impl_from_IHTMLElement2(iface);
3100 TRACE("(%p)->(%p)\n", This, p);
3102 return get_node_event(&This->node, EVENTID_SCROLL, p);
3105 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
3107 HTMLElement *This = impl_from_IHTMLElement2(iface);
3109 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3111 return set_node_event(&This->node, EVENTID_DRAG, &v);
3114 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
3116 HTMLElement *This = impl_from_IHTMLElement2(iface);
3118 TRACE("(%p)->(%p)\n", This, p);
3120 return get_node_event(&This->node, EVENTID_DRAG, p);
3123 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
3125 HTMLElement *This = impl_from_IHTMLElement2(iface);
3126 FIXME("(%p)->()\n", This);
3127 return E_NOTIMPL;
3130 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
3132 HTMLElement *This = impl_from_IHTMLElement2(iface);
3133 FIXME("(%p)->(%p)\n", This, p);
3134 return E_NOTIMPL;
3137 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
3139 HTMLElement *This = impl_from_IHTMLElement2(iface);
3140 FIXME("(%p)->()\n", This);
3141 return E_NOTIMPL;
3144 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
3146 HTMLElement *This = impl_from_IHTMLElement2(iface);
3147 FIXME("(%p)->(%p)\n", This, p);
3148 return E_NOTIMPL;
3151 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
3153 HTMLElement *This = impl_from_IHTMLElement2(iface);
3154 FIXME("(%p)->()\n", This);
3155 return E_NOTIMPL;
3158 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
3160 HTMLElement *This = impl_from_IHTMLElement2(iface);
3161 FIXME("(%p)->(%p)\n", This, p);
3162 return E_NOTIMPL;
3165 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
3167 HTMLElement *This = impl_from_IHTMLElement2(iface);
3168 FIXME("(%p)->()\n", This);
3169 return E_NOTIMPL;
3172 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
3174 HTMLElement *This = impl_from_IHTMLElement2(iface);
3175 FIXME("(%p)->(%p)\n", This, p);
3176 return E_NOTIMPL;
3179 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
3181 HTMLElement *This = impl_from_IHTMLElement2(iface);
3182 FIXME("(%p)->()\n", This);
3183 return E_NOTIMPL;
3186 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
3188 HTMLElement *This = impl_from_IHTMLElement2(iface);
3189 FIXME("(%p)->(%p)\n", This, p);
3190 return E_NOTIMPL;
3193 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
3195 HTMLElement *This = impl_from_IHTMLElement2(iface);
3196 FIXME("(%p)->()\n", This);
3197 return E_NOTIMPL;
3200 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
3202 HTMLElement *This = impl_from_IHTMLElement2(iface);
3203 FIXME("(%p)->(%p)\n", This, p);
3204 return E_NOTIMPL;
3207 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
3209 HTMLElement *This = impl_from_IHTMLElement2(iface);
3210 FIXME("(%p)->()\n", This);
3211 return E_NOTIMPL;
3214 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
3216 HTMLElement *This = impl_from_IHTMLElement2(iface);
3217 FIXME("(%p)->(%p)\n", This, p);
3218 return E_NOTIMPL;
3221 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
3223 HTMLElement *This = impl_from_IHTMLElement2(iface);
3224 FIXME("(%p)->()\n", This);
3225 return E_NOTIMPL;
3228 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
3230 HTMLElement *This = impl_from_IHTMLElement2(iface);
3231 FIXME("(%p)->(%p)\n", This, p);
3232 return E_NOTIMPL;
3235 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
3237 HTMLElement *This = impl_from_IHTMLElement2(iface);
3238 FIXME("(%p)->()\n", This);
3239 return E_NOTIMPL;
3242 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
3244 HTMLElement *This = impl_from_IHTMLElement2(iface);
3245 FIXME("(%p)->(%p)\n", This, p);
3246 return E_NOTIMPL;
3249 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
3251 HTMLElement *This = impl_from_IHTMLElement2(iface);
3252 FIXME("(%p)->()\n", This);
3253 return E_NOTIMPL;
3256 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
3258 HTMLElement *This = impl_from_IHTMLElement2(iface);
3259 FIXME("(%p)->(%p)\n", This, p);
3260 return E_NOTIMPL;
3263 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
3265 HTMLElement *This = impl_from_IHTMLElement2(iface);
3267 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3269 return set_node_event(&This->node, EVENTID_PASTE, &v);
3272 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
3274 HTMLElement *This = impl_from_IHTMLElement2(iface);
3276 TRACE("(%p)->(%p)\n", This, p);
3278 return get_node_event(&This->node, EVENTID_PASTE, p);
3281 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
3283 HTMLElement *This = impl_from_IHTMLElement2(iface);
3285 TRACE("(%p)->(%p)\n", This, p);
3287 return HTMLCurrentStyle_Create(This, p);
3290 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
3292 HTMLElement *This = impl_from_IHTMLElement2(iface);
3293 FIXME("(%p)->()\n", This);
3294 return E_NOTIMPL;
3297 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
3299 HTMLElement *This = impl_from_IHTMLElement2(iface);
3300 FIXME("(%p)->(%p)\n", This, p);
3301 return E_NOTIMPL;
3304 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
3306 HTMLElement *This = impl_from_IHTMLElement2(iface);
3307 nsIDOMClientRectList *rect_list;
3308 HTMLRectCollection *rects;
3309 nsresult nsres;
3311 TRACE("(%p)->(%p)\n", This, pRectCol);
3313 if(!This->dom_element) {
3314 FIXME("comment element\n");
3315 return E_NOTIMPL;
3318 nsres = nsIDOMElement_GetClientRects(This->dom_element, &rect_list);
3319 if(NS_FAILED(nsres)) {
3320 WARN("GetClientRects failed: %08lx\n", nsres);
3321 return map_nsresult(nsres);
3324 rects = calloc(1, sizeof(*rects));
3325 if(!rects) {
3326 nsIDOMClientRectList_Release(rect_list);
3327 return E_OUTOFMEMORY;
3330 rects->IHTMLRectCollection_iface.lpVtbl = &HTMLRectCollectionVtbl;
3331 rects->rect_list = rect_list;
3332 init_dispatch(&rects->dispex, (IUnknown*)&rects->IHTMLRectCollection_iface,
3333 &HTMLRectCollection_dispex, dispex_compat_mode(&This->node.event_target.dispex));
3335 *pRectCol = &rects->IHTMLRectCollection_iface;
3336 return S_OK;
3339 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
3341 HTMLElement *This = impl_from_IHTMLElement2(iface);
3342 nsIDOMClientRect *nsrect;
3343 nsresult nsres;
3344 HRESULT hres;
3346 TRACE("(%p)->(%p)\n", This, pRect);
3348 if(!This->dom_element) {
3349 FIXME("comment element\n");
3350 return E_NOTIMPL;
3353 nsres = nsIDOMElement_GetBoundingClientRect(This->dom_element, &nsrect);
3354 if(NS_FAILED(nsres) || !nsrect) {
3355 ERR("GetBoindingClientRect failed: %08lx\n", nsres);
3356 return E_FAIL;
3359 hres = create_html_rect(nsrect, dispex_compat_mode(&This->node.event_target.dispex), pRect);
3361 nsIDOMClientRect_Release(nsrect);
3362 return hres;
3365 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
3366 BSTR expression, BSTR language)
3368 HTMLElement *This = impl_from_IHTMLElement2(iface);
3369 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
3370 debugstr_w(language));
3371 return E_NOTIMPL;
3374 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
3375 VARIANT *expression)
3377 HTMLElement *This = impl_from_IHTMLElement2(iface);
3378 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
3379 return E_NOTIMPL;
3382 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
3383 VARIANT_BOOL *pfSuccess)
3385 HTMLElement *This = impl_from_IHTMLElement2(iface);
3386 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
3387 return E_NOTIMPL;
3390 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
3392 HTMLElement *This = impl_from_IHTMLElement2(iface);
3393 nsresult nsres;
3395 TRACE("(%p)->(%d)\n", This, v);
3397 if(!This->html_element) {
3398 FIXME("non-HTML element\n");
3399 return E_NOTIMPL;
3402 nsres = nsIDOMHTMLElement_SetTabIndex(This->html_element, v);
3403 if(NS_FAILED(nsres))
3404 ERR("GetTabIndex failed: %08lx\n", nsres);
3406 return S_OK;
3409 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
3411 HTMLElement *This = impl_from_IHTMLElement2(iface);
3412 LONG index;
3413 nsresult nsres;
3415 TRACE("(%p)->(%p)\n", This, p);
3417 if(!This->html_element) {
3418 FIXME("non-HTML element\n");
3419 return E_NOTIMPL;
3422 nsres = nsIDOMHTMLElement_GetTabIndex(This->html_element, &index);
3423 if(NS_FAILED(nsres)) {
3424 ERR("GetTabIndex failed: %08lx\n", nsres);
3425 return E_FAIL;
3428 *p = index;
3429 return S_OK;
3432 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
3434 HTMLElement *This = impl_from_IHTMLElement2(iface);
3435 nsresult nsres;
3437 TRACE("(%p)\n", This);
3439 if(!This->html_element) {
3440 FIXME("non-HTML element\n");
3441 return E_NOTIMPL;
3444 nsres = nsIDOMHTMLElement_Focus(This->html_element);
3445 if(NS_FAILED(nsres))
3446 ERR("Focus failed: %08lx\n", nsres);
3448 return S_OK;
3451 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
3453 HTMLElement *This = impl_from_IHTMLElement2(iface);
3454 nsAString nsstr;
3455 nsresult nsres;
3457 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3459 if(!This->html_element) {
3460 FIXME("non-HTML element\n");
3461 return E_NOTIMPL;
3464 nsAString_InitDepend(&nsstr, v);
3465 nsres = nsIDOMHTMLElement_SetAccessKey(This->html_element, &nsstr);
3466 nsAString_Finish(&nsstr);
3467 return map_nsresult(nsres);
3470 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
3472 HTMLElement *This = impl_from_IHTMLElement2(iface);
3473 nsAString nsstr;
3474 nsresult nsres;
3476 TRACE("(%p)->(%p)\n", This, p);
3478 if(!This->html_element) {
3479 FIXME("non-HTML element\n");
3480 return E_NOTIMPL;
3483 nsAString_InitDepend(&nsstr, NULL);
3484 nsres = nsIDOMHTMLElement_GetAccessKey(This->html_element, &nsstr);
3485 return return_nsstr(nsres, &nsstr, p);
3488 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
3490 HTMLElement *This = impl_from_IHTMLElement2(iface);
3492 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3494 return set_node_event(&This->node, EVENTID_BLUR, &v);
3497 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
3499 HTMLElement *This = impl_from_IHTMLElement2(iface);
3501 TRACE("(%p)->(%p)\n", This, p);
3503 return get_node_event(&This->node, EVENTID_BLUR, p);
3506 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
3508 HTMLElement *This = impl_from_IHTMLElement2(iface);
3510 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3512 return set_node_event(&This->node, EVENTID_FOCUS, &v);
3515 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
3517 HTMLElement *This = impl_from_IHTMLElement2(iface);
3519 TRACE("(%p)->(%p)\n", This, p);
3521 return get_node_event(&This->node, EVENTID_FOCUS, p);
3524 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
3526 HTMLElement *This = impl_from_IHTMLElement2(iface);
3528 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3530 return set_node_event(&This->node, EVENTID_RESIZE, &v);
3533 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
3535 HTMLElement *This = impl_from_IHTMLElement2(iface);
3537 TRACE("(%p)->(%p)\n", This, p);
3539 return get_node_event(&This->node, EVENTID_RESIZE, p);
3542 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
3544 HTMLElement *This = impl_from_IHTMLElement2(iface);
3545 nsresult nsres;
3547 TRACE("(%p)\n", This);
3549 if(!This->html_element) {
3550 FIXME("non-HTML element\n");
3551 return E_NOTIMPL;
3554 nsres = nsIDOMHTMLElement_Blur(This->html_element);
3555 if(NS_FAILED(nsres)) {
3556 ERR("Blur failed: %08lx\n", nsres);
3557 return E_FAIL;
3560 return S_OK;
3563 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3565 HTMLElement *This = impl_from_IHTMLElement2(iface);
3566 FIXME("(%p)->(%p)\n", This, pUnk);
3567 return E_NOTIMPL;
3570 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3572 HTMLElement *This = impl_from_IHTMLElement2(iface);
3573 FIXME("(%p)->(%p)\n", This, pUnk);
3574 return E_NOTIMPL;
3577 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
3579 HTMLElement *This = impl_from_IHTMLElement2(iface);
3580 nsresult nsres;
3582 TRACE("(%p)->(%p)\n", This, p);
3584 if(!This->dom_element) {
3585 FIXME("Unimplemented for comment element\n");
3586 return E_NOTIMPL;
3589 nsres = nsIDOMElement_GetClientHeight(This->dom_element, p);
3590 assert(nsres == NS_OK);
3591 return S_OK;
3594 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
3596 HTMLElement *This = impl_from_IHTMLElement2(iface);
3597 nsresult nsres;
3599 TRACE("(%p)->(%p)\n", This, p);
3601 if(!This->dom_element) {
3602 FIXME("comment element\n");
3603 return E_NOTIMPL;
3606 nsres = nsIDOMElement_GetClientWidth(This->dom_element, p);
3607 assert(nsres == NS_OK);
3608 return S_OK;
3611 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
3613 HTMLElement *This = impl_from_IHTMLElement2(iface);
3614 nsresult nsres;
3616 TRACE("(%p)->(%p)\n", This, p);
3618 if(!This->dom_element) {
3619 FIXME("comment element\n");
3620 return E_NOTIMPL;
3623 nsres = nsIDOMElement_GetClientTop(This->dom_element, p);
3624 assert(nsres == NS_OK);
3626 TRACE("*p = %ld\n", *p);
3627 return S_OK;
3630 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
3632 HTMLElement *This = impl_from_IHTMLElement2(iface);
3633 nsresult nsres;
3635 TRACE("(%p)->(%p)\n", This, p);
3637 if(!This->dom_element) {
3638 FIXME("comment element\n");
3639 return E_NOTIMPL;
3642 nsres = nsIDOMElement_GetClientLeft(This->dom_element, p);
3643 assert(nsres == NS_OK);
3645 TRACE("*p = %ld\n", *p);
3646 return S_OK;
3649 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
3650 IDispatch *pDisp, VARIANT_BOOL *pfResult)
3652 HTMLElement *This = impl_from_IHTMLElement2(iface);
3654 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
3656 return attach_event(&This->node.event_target, event, pDisp, pfResult);
3659 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
3661 HTMLElement *This = impl_from_IHTMLElement2(iface);
3663 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
3665 return detach_event(&This->node.event_target, event, pDisp);
3668 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
3670 HTMLElement *This = impl_from_IHTMLElement2(iface);
3671 BSTR str;
3673 TRACE("(%p)->(%p)\n", This, p);
3675 if(This->node.vtbl->get_readystate) {
3676 HRESULT hres;
3678 hres = This->node.vtbl->get_readystate(&This->node, &str);
3679 if(FAILED(hres))
3680 return hres;
3681 }else {
3682 str = SysAllocString(L"complete");
3683 if(!str)
3684 return E_OUTOFMEMORY;
3687 V_VT(p) = VT_BSTR;
3688 V_BSTR(p) = str;
3689 return S_OK;
3692 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
3694 HTMLElement *This = impl_from_IHTMLElement2(iface);
3696 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3698 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
3701 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
3703 HTMLElement *This = impl_from_IHTMLElement2(iface);
3705 TRACE("(%p)->(%p)\n", This, p);
3707 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
3710 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
3712 HTMLElement *This = impl_from_IHTMLElement2(iface);
3713 FIXME("(%p)->()\n", This);
3714 return E_NOTIMPL;
3717 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
3719 HTMLElement *This = impl_from_IHTMLElement2(iface);
3720 FIXME("(%p)->(%p)\n", This, p);
3721 return E_NOTIMPL;
3724 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
3726 HTMLElement *This = impl_from_IHTMLElement2(iface);
3727 FIXME("(%p)->()\n", This);
3728 return E_NOTIMPL;
3731 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
3733 HTMLElement *This = impl_from_IHTMLElement2(iface);
3734 FIXME("(%p)->(%p)\n", This, p);
3735 return E_NOTIMPL;
3738 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
3740 HTMLElement *This = impl_from_IHTMLElement2(iface);
3741 FIXME("(%p)->()\n", This);
3742 return E_NOTIMPL;
3745 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
3747 HTMLElement *This = impl_from_IHTMLElement2(iface);
3748 FIXME("(%p)->(%p)\n", This, p);
3749 return E_NOTIMPL;
3752 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
3754 HTMLElement *This = impl_from_IHTMLElement2(iface);
3755 nsAString nsstr;
3756 nsresult nsres;
3758 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3760 if(!This->html_element) {
3761 FIXME("non-HTML element\n");
3762 return S_OK;
3765 nsAString_InitDepend(&nsstr, v);
3766 nsres = nsIDOMHTMLElement_SetDir(This->html_element, &nsstr);
3767 nsAString_Finish(&nsstr);
3768 if(NS_FAILED(nsres)) {
3769 ERR("SetDir failed: %08lx\n", nsres);
3770 return E_FAIL;
3773 return S_OK;
3776 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
3778 HTMLElement *This = impl_from_IHTMLElement2(iface);
3779 nsAString dir_str;
3780 nsresult nsres;
3782 TRACE("(%p)->(%p)\n", This, p);
3784 if(!This->html_element) {
3785 if(This->dom_element)
3786 FIXME("non-HTML element\n");
3787 *p = NULL;
3788 return S_OK;
3791 nsAString_Init(&dir_str, NULL);
3792 nsres = nsIDOMHTMLElement_GetDir(This->html_element, &dir_str);
3793 return return_nsstr(nsres, &dir_str, p);
3796 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
3798 HTMLElement *This = impl_from_IHTMLElement2(iface);
3799 FIXME("(%p)->(%p)\n", This, range);
3800 return E_NOTIMPL;
3803 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
3805 HTMLElement *This = impl_from_IHTMLElement2(iface);
3806 nsresult nsres;
3808 TRACE("(%p)->(%p)\n", This, p);
3810 if(!This->dom_element) {
3811 FIXME("comment element\n");
3812 return E_NOTIMPL;
3815 nsres = nsIDOMElement_GetScrollHeight(This->dom_element, p);
3816 assert(nsres == NS_OK);
3817 TRACE("*p = %ld\n", *p);
3818 return S_OK;
3821 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
3823 HTMLElement *This = impl_from_IHTMLElement2(iface);
3824 nsresult nsres;
3826 TRACE("(%p)->(%p)\n", This, p);
3828 if(!This->dom_element) {
3829 FIXME("comment element\n");
3830 return E_NOTIMPL;
3833 nsres = nsIDOMElement_GetScrollWidth(This->dom_element, p);
3834 assert(nsres == NS_OK);
3836 TRACE("*p = %ld\n", *p);
3837 return S_OK;
3840 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
3842 HTMLElement *This = impl_from_IHTMLElement2(iface);
3844 TRACE("(%p)->(%ld)\n", This, v);
3846 if(!This->dom_element) {
3847 FIXME("comment element\n");
3848 return E_NOTIMPL;
3851 nsIDOMElement_SetScrollTop(This->dom_element, v);
3852 return S_OK;
3855 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
3857 HTMLElement *This = impl_from_IHTMLElement2(iface);
3858 nsresult nsres;
3860 TRACE("(%p)->(%p)\n", This, p);
3862 if(!This->dom_element) {
3863 FIXME("comment element\n");
3864 return E_NOTIMPL;
3867 nsres = nsIDOMElement_GetScrollTop(This->dom_element, p);
3868 assert(nsres == NS_OK);
3870 TRACE("*p = %ld\n", *p);
3871 return S_OK;
3874 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
3876 HTMLElement *This = impl_from_IHTMLElement2(iface);
3878 TRACE("(%p)->(%ld)\n", This, v);
3880 if(!This->dom_element) {
3881 FIXME("comment element\n");
3882 return E_NOTIMPL;
3885 nsIDOMElement_SetScrollLeft(This->dom_element, v);
3886 return S_OK;
3889 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
3891 HTMLElement *This = impl_from_IHTMLElement2(iface);
3892 nsresult nsres;
3894 TRACE("(%p)->(%p)\n", This, p);
3896 if(!p)
3897 return E_INVALIDARG;
3899 if(!This->dom_element) {
3900 FIXME("comment element\n");
3901 return E_NOTIMPL;
3904 nsres = nsIDOMElement_GetScrollLeft(This->dom_element, p);
3905 assert(nsres == NS_OK);
3906 TRACE("*p = %ld\n", *p);
3907 return S_OK;
3910 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
3912 HTMLElement *This = impl_from_IHTMLElement2(iface);
3913 FIXME("(%p)\n", This);
3914 return E_NOTIMPL;
3917 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
3919 HTMLElement *This = impl_from_IHTMLElement2(iface);
3920 FIXME("(%p)->(%p)\n", This, mergeThis);
3921 return E_NOTIMPL;
3924 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
3926 HTMLElement *This = impl_from_IHTMLElement2(iface);
3928 TRACE("(%p)->()\n", This);
3930 return set_node_event(&This->node, EVENTID_CONTEXTMENU, &v);
3933 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
3935 HTMLElement *This = impl_from_IHTMLElement2(iface);
3937 TRACE("(%p)->(%p)\n", This, p);
3939 return get_node_event(&This->node, EVENTID_CONTEXTMENU, p);
3942 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
3943 IHTMLElement *insertedElement, IHTMLElement **inserted)
3945 HTMLElement *This = impl_from_IHTMLElement2(iface);
3946 HTMLDOMNode *ret_node;
3947 HTMLElement *elem;
3948 HRESULT hres;
3950 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
3952 elem = unsafe_impl_from_IHTMLElement(insertedElement);
3953 if(!elem)
3954 return E_INVALIDARG;
3956 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
3957 if(FAILED(hres))
3958 return hres;
3960 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
3961 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
3962 return hres;
3965 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
3966 BSTR where, IHTMLElement **applied)
3968 HTMLElement *This = impl_from_IHTMLElement2(iface);
3969 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
3970 return E_NOTIMPL;
3973 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
3975 HTMLElement *This = impl_from_IHTMLElement2(iface);
3976 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
3977 return E_NOTIMPL;
3980 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
3981 BSTR newText, BSTR *oldText)
3983 HTMLElement *This = impl_from_IHTMLElement2(iface);
3984 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
3985 return E_NOTIMPL;
3988 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
3990 HTMLElement *This = impl_from_IHTMLElement2(iface);
3991 FIXME("(%p)->(%p)\n", This, p);
3992 return E_NOTIMPL;
3995 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
3996 VARIANT *pvarFactory, LONG *pCookie)
3998 HTMLElement *This = impl_from_IHTMLElement2(iface);
3999 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
4000 return E_NOTIMPL;
4003 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
4004 VARIANT_BOOL *pfResult)
4006 HTMLElement *This = impl_from_IHTMLElement2(iface);
4007 FIXME("(%p)->(%ld %p)\n", This, cookie, pfResult);
4008 return E_NOTIMPL;
4011 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
4013 HTMLElement *This = impl_from_IHTMLElement2(iface);
4015 FIXME("(%p)->(%p): hack\n", This, p);
4017 /* We can't implement correct behavior on top of Gecko (although we could
4018 try a bit harder). Making runtimeStyle behave like regular style is
4019 enough for most use cases. */
4020 if(!This->runtime_style) {
4021 HRESULT hres;
4023 hres = HTMLStyle_Create(This, &This->runtime_style);
4024 if(FAILED(hres))
4025 return hres;
4028 *p = &This->runtime_style->IHTMLStyle_iface;
4029 IHTMLStyle_AddRef(*p);
4030 return S_OK;
4033 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
4035 HTMLElement *This = impl_from_IHTMLElement2(iface);
4036 FIXME("(%p)->(%p)\n", This, p);
4037 return E_NOTIMPL;
4040 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
4042 HTMLElement *This = impl_from_IHTMLElement2(iface);
4043 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
4044 return E_NOTIMPL;
4047 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
4049 HTMLElement *This = impl_from_IHTMLElement2(iface);
4050 FIXME("(%p)->(%p)\n", This, p);
4051 return E_NOTIMPL;
4054 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
4056 HTMLElement *This = impl_from_IHTMLElement2(iface);
4057 FIXME("(%p)->()\n", This);
4058 return E_NOTIMPL;
4061 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
4063 HTMLElement *This = impl_from_IHTMLElement2(iface);
4064 FIXME("(%p)->(%p)\n", This, p);
4065 return E_NOTIMPL;
4068 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
4070 HTMLElement *This = impl_from_IHTMLElement2(iface);
4071 FIXME("(%p)->(%p)\n", This, p);
4072 return E_NOTIMPL;
4075 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
4076 IHTMLElementCollection **pelColl)
4078 HTMLElement *This = impl_from_IHTMLElement2(iface);
4079 nsIDOMHTMLCollection *nscol;
4080 nsAString tag_str;
4081 nsresult nsres;
4083 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
4085 if(!This->dom_element) {
4086 *pelColl = create_collection_from_htmlcol(NULL, This->node.doc->document_mode);
4087 return S_OK;
4090 nsAString_InitDepend(&tag_str, v);
4091 nsres = nsIDOMElement_GetElementsByTagName(This->dom_element, &tag_str, &nscol);
4092 nsAString_Finish(&tag_str);
4093 if(NS_FAILED(nsres)) {
4094 ERR("GetElementByTagName failed: %08lx\n", nsres);
4095 return E_FAIL;
4098 *pelColl = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
4099 nsIDOMHTMLCollection_Release(nscol);
4100 return S_OK;
4103 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
4104 HTMLElement2_QueryInterface,
4105 HTMLElement2_AddRef,
4106 HTMLElement2_Release,
4107 HTMLElement2_GetTypeInfoCount,
4108 HTMLElement2_GetTypeInfo,
4109 HTMLElement2_GetIDsOfNames,
4110 HTMLElement2_Invoke,
4111 HTMLElement2_get_scopeName,
4112 HTMLElement2_setCapture,
4113 HTMLElement2_releaseCapture,
4114 HTMLElement2_put_onlosecapture,
4115 HTMLElement2_get_onlosecapture,
4116 HTMLElement2_componentFromPoint,
4117 HTMLElement2_doScroll,
4118 HTMLElement2_put_onscroll,
4119 HTMLElement2_get_onscroll,
4120 HTMLElement2_put_ondrag,
4121 HTMLElement2_get_ondrag,
4122 HTMLElement2_put_ondragend,
4123 HTMLElement2_get_ondragend,
4124 HTMLElement2_put_ondragenter,
4125 HTMLElement2_get_ondragenter,
4126 HTMLElement2_put_ondragover,
4127 HTMLElement2_get_ondragover,
4128 HTMLElement2_put_ondragleave,
4129 HTMLElement2_get_ondragleave,
4130 HTMLElement2_put_ondrop,
4131 HTMLElement2_get_ondrop,
4132 HTMLElement2_put_onbeforecut,
4133 HTMLElement2_get_onbeforecut,
4134 HTMLElement2_put_oncut,
4135 HTMLElement2_get_oncut,
4136 HTMLElement2_put_onbeforecopy,
4137 HTMLElement2_get_onbeforecopy,
4138 HTMLElement2_put_oncopy,
4139 HTMLElement2_get_oncopy,
4140 HTMLElement2_put_onbeforepaste,
4141 HTMLElement2_get_onbeforepaste,
4142 HTMLElement2_put_onpaste,
4143 HTMLElement2_get_onpaste,
4144 HTMLElement2_get_currentStyle,
4145 HTMLElement2_put_onpropertychange,
4146 HTMLElement2_get_onpropertychange,
4147 HTMLElement2_getClientRects,
4148 HTMLElement2_getBoundingClientRect,
4149 HTMLElement2_setExpression,
4150 HTMLElement2_getExpression,
4151 HTMLElement2_removeExpression,
4152 HTMLElement2_put_tabIndex,
4153 HTMLElement2_get_tabIndex,
4154 HTMLElement2_focus,
4155 HTMLElement2_put_accessKey,
4156 HTMLElement2_get_accessKey,
4157 HTMLElement2_put_onblur,
4158 HTMLElement2_get_onblur,
4159 HTMLElement2_put_onfocus,
4160 HTMLElement2_get_onfocus,
4161 HTMLElement2_put_onresize,
4162 HTMLElement2_get_onresize,
4163 HTMLElement2_blur,
4164 HTMLElement2_addFilter,
4165 HTMLElement2_removeFilter,
4166 HTMLElement2_get_clientHeight,
4167 HTMLElement2_get_clientWidth,
4168 HTMLElement2_get_clientTop,
4169 HTMLElement2_get_clientLeft,
4170 HTMLElement2_attachEvent,
4171 HTMLElement2_detachEvent,
4172 HTMLElement2_get_readyState,
4173 HTMLElement2_put_onreadystatechange,
4174 HTMLElement2_get_onreadystatechange,
4175 HTMLElement2_put_onrowsdelete,
4176 HTMLElement2_get_onrowsdelete,
4177 HTMLElement2_put_onrowsinserted,
4178 HTMLElement2_get_onrowsinserted,
4179 HTMLElement2_put_oncellchange,
4180 HTMLElement2_get_oncellchange,
4181 HTMLElement2_put_dir,
4182 HTMLElement2_get_dir,
4183 HTMLElement2_createControlRange,
4184 HTMLElement2_get_scrollHeight,
4185 HTMLElement2_get_scrollWidth,
4186 HTMLElement2_put_scrollTop,
4187 HTMLElement2_get_scrollTop,
4188 HTMLElement2_put_scrollLeft,
4189 HTMLElement2_get_scrollLeft,
4190 HTMLElement2_clearAttributes,
4191 HTMLElement2_mergeAttributes,
4192 HTMLElement2_put_oncontextmenu,
4193 HTMLElement2_get_oncontextmenu,
4194 HTMLElement2_insertAdjacentElement,
4195 HTMLElement2_applyElement,
4196 HTMLElement2_getAdjacentText,
4197 HTMLElement2_replaceAdjacentText,
4198 HTMLElement2_get_canHandleChildren,
4199 HTMLElement2_addBehavior,
4200 HTMLElement2_removeBehavior,
4201 HTMLElement2_get_runtimeStyle,
4202 HTMLElement2_get_behaviorUrns,
4203 HTMLElement2_put_tagUrn,
4204 HTMLElement2_get_tagUrn,
4205 HTMLElement2_put_onbeforeeditfocus,
4206 HTMLElement2_get_onbeforeeditfocus,
4207 HTMLElement2_get_readyStateValue,
4208 HTMLElement2_getElementsByTagName,
4211 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
4213 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
4216 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
4217 REFIID riid, void **ppv)
4219 HTMLElement *This = impl_from_IHTMLElement3(iface);
4220 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4223 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
4225 HTMLElement *This = impl_from_IHTMLElement3(iface);
4226 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4229 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
4231 HTMLElement *This = impl_from_IHTMLElement3(iface);
4232 return IHTMLElement_Release(&This->IHTMLElement_iface);
4235 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
4237 HTMLElement *This = impl_from_IHTMLElement3(iface);
4238 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4241 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
4242 LCID lcid, ITypeInfo **ppTInfo)
4244 HTMLElement *This = impl_from_IHTMLElement3(iface);
4245 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4248 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
4249 LPOLESTR *rgszNames, UINT cNames,
4250 LCID lcid, DISPID *rgDispId)
4252 HTMLElement *This = impl_from_IHTMLElement3(iface);
4253 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4254 lcid, rgDispId);
4257 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
4258 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4259 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4261 HTMLElement *This = impl_from_IHTMLElement3(iface);
4262 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4263 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4266 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
4268 HTMLElement *This = impl_from_IHTMLElement3(iface);
4269 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
4270 return E_NOTIMPL;
4273 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
4275 HTMLElement *This = impl_from_IHTMLElement3(iface);
4276 FIXME("(%p)->(%p)\n", This, p);
4277 return E_NOTIMPL;
4280 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
4282 HTMLElement *This = impl_from_IHTMLElement3(iface);
4283 FIXME("(%p)->(%p)\n", This, p);
4284 return E_NOTIMPL;
4287 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
4289 HTMLElement *This = impl_from_IHTMLElement3(iface);
4290 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4291 return E_NOTIMPL;
4294 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
4296 HTMLElement *This = impl_from_IHTMLElement3(iface);
4297 FIXME("(%p)->(%p)\n", This, p);
4298 return E_NOTIMPL;
4301 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
4303 HTMLElement *This = impl_from_IHTMLElement3(iface);
4304 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4305 return E_NOTIMPL;
4308 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
4310 HTMLElement *This = impl_from_IHTMLElement3(iface);
4311 FIXME("(%p)->(%p)\n", This, p);
4312 return E_NOTIMPL;
4315 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
4317 HTMLElement *This = impl_from_IHTMLElement3(iface);
4318 FIXME("(%p)->(%x)\n", This, v);
4319 return E_NOTIMPL;
4322 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
4324 HTMLElement *This = impl_from_IHTMLElement3(iface);
4325 FIXME("(%p)->(%p)\n", This, p);
4326 return E_NOTIMPL;
4329 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
4331 HTMLElement *This = impl_from_IHTMLElement3(iface);
4332 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4333 return E_NOTIMPL;
4336 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
4338 HTMLElement *This = impl_from_IHTMLElement3(iface);
4339 FIXME("(%p)->(%p)\n", This, p);
4340 return E_NOTIMPL;
4343 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
4345 HTMLElement *This = impl_from_IHTMLElement3(iface);
4346 FIXME("(%p)\n", This);
4347 return E_NOTIMPL;
4350 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
4352 HTMLElement *This = impl_from_IHTMLElement3(iface);
4353 nsresult nsres;
4354 nsAString str;
4356 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
4358 if(!This->html_element) {
4359 FIXME("non-HTML element\n");
4360 return E_NOTIMPL;
4363 nsAString_InitDepend(&str, v);
4364 nsres = nsIDOMHTMLElement_SetContentEditable(This->html_element, &str);
4365 nsAString_Finish(&str);
4367 if (NS_FAILED(nsres)){
4368 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
4369 return E_FAIL;
4372 return S_OK;
4375 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
4377 HTMLElement *This = impl_from_IHTMLElement3(iface);
4378 nsresult nsres;
4379 nsAString str;
4381 TRACE("(%p)->(%p)\n", This, p);
4383 if(!This->html_element) {
4384 FIXME("non-HTML element\n");
4385 return E_NOTIMPL;
4388 nsAString_Init(&str, NULL);
4389 nsres = nsIDOMHTMLElement_GetContentEditable(This->html_element, &str);
4390 return return_nsstr(nsres, &str, p);
4393 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
4395 HTMLElement *This = impl_from_IHTMLElement3(iface);
4396 nsresult nsres;
4397 cpp_bool r;
4399 TRACE("(%p)->(%p)\n", This, p);
4401 if(!This->html_element) {
4402 FIXME("non-HTML element\n");
4403 return E_NOTIMPL;
4406 nsres = nsIDOMHTMLElement_GetIsContentEditable(This->html_element, &r);
4407 *p = variant_bool(NS_SUCCEEDED(nsres) && r);
4408 return S_OK;
4411 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
4413 HTMLElement *This = impl_from_IHTMLElement3(iface);
4414 FIXME("(%p)->(%x)\n", This, v);
4415 return E_NOTIMPL;
4418 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
4420 HTMLElement *This = impl_from_IHTMLElement3(iface);
4421 FIXME("(%p)->(%p)\n", This, p);
4422 return E_NOTIMPL;
4425 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
4427 HTMLElement *This = impl_from_IHTMLElement3(iface);
4429 TRACE("(%p)->(%x)\n", This, v);
4431 if(This->node.vtbl->put_disabled)
4432 return This->node.vtbl->put_disabled(&This->node, v);
4434 if(!v) return element_remove_attribute(This, L"disabled");
4435 return elem_string_attr_setter(This, L"disabled", L"");
4438 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4440 HTMLElement *This = impl_from_IHTMLElement3(iface);
4442 TRACE("(%p)->(%p)\n", This, p);
4444 if(This->node.vtbl->get_disabled)
4445 return This->node.vtbl->get_disabled(&This->node, p);
4447 *p = variant_bool(element_has_attribute(This, L"disabled"));
4448 return S_OK;
4451 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4453 HTMLElement *This = impl_from_IHTMLElement3(iface);
4454 FIXME("(%p)->(%p)\n", This, p);
4455 return E_NOTIMPL;
4458 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
4460 HTMLElement *This = impl_from_IHTMLElement3(iface);
4461 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4462 return E_NOTIMPL;
4465 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
4467 HTMLElement *This = impl_from_IHTMLElement3(iface);
4468 FIXME("(%p)->(%p)\n", This, p);
4469 return E_NOTIMPL;
4472 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
4474 HTMLElement *This = impl_from_IHTMLElement3(iface);
4475 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4476 return E_NOTIMPL;
4479 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
4481 HTMLElement *This = impl_from_IHTMLElement3(iface);
4482 FIXME("(%p)->(%p)\n", This, p);
4483 return E_NOTIMPL;
4486 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
4487 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
4489 HTMLElement *This = impl_from_IHTMLElement3(iface);
4491 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
4492 pfCancelled);
4494 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
4497 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
4499 HTMLElement *This = impl_from_IHTMLElement3(iface);
4500 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4501 return E_NOTIMPL;
4504 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
4506 HTMLElement *This = impl_from_IHTMLElement3(iface);
4507 FIXME("(%p)->(%p)\n", This, p);
4508 return E_NOTIMPL;
4511 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
4513 HTMLElement *This = impl_from_IHTMLElement3(iface);
4514 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4515 return E_NOTIMPL;
4518 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
4520 HTMLElement *This = impl_from_IHTMLElement3(iface);
4521 FIXME("(%p)->(%p)\n", This, p);
4522 return E_NOTIMPL;
4525 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
4527 HTMLElement *This = impl_from_IHTMLElement3(iface);
4528 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4529 return E_NOTIMPL;
4532 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
4534 HTMLElement *This = impl_from_IHTMLElement3(iface);
4535 FIXME("(%p)->(%p)\n", This, p);
4536 return E_NOTIMPL;
4539 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
4541 HTMLElement *This = impl_from_IHTMLElement3(iface);
4542 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4543 return E_NOTIMPL;
4546 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
4548 HTMLElement *This = impl_from_IHTMLElement3(iface);
4549 FIXME("(%p)->(%p)\n", This, p);
4550 return E_NOTIMPL;
4553 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
4555 HTMLElement *This = impl_from_IHTMLElement3(iface);
4556 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4557 return E_NOTIMPL;
4560 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
4562 HTMLElement *This = impl_from_IHTMLElement3(iface);
4563 FIXME("(%p)->(%p)\n", This, p);
4564 return E_NOTIMPL;
4567 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
4569 HTMLElement *This = impl_from_IHTMLElement3(iface);
4570 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4571 return E_NOTIMPL;
4574 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
4576 HTMLElement *This = impl_from_IHTMLElement3(iface);
4577 FIXME("(%p)->(%p)\n", This, p);
4578 return E_NOTIMPL;
4581 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
4583 HTMLElement *This = impl_from_IHTMLElement3(iface);
4584 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4585 return E_NOTIMPL;
4588 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
4590 HTMLElement *This = impl_from_IHTMLElement3(iface);
4591 FIXME("(%p)->(%p)\n", This, p);
4592 return E_NOTIMPL;
4595 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
4597 HTMLElement *This = impl_from_IHTMLElement3(iface);
4598 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4599 return E_NOTIMPL;
4602 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
4604 HTMLElement *This = impl_from_IHTMLElement3(iface);
4605 FIXME("(%p)->(%p)\n", This, p);
4606 return E_NOTIMPL;
4609 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
4611 HTMLElement *This = impl_from_IHTMLElement3(iface);
4612 FIXME("(%p)->(%p)\n", This, pfRet);
4613 return E_NOTIMPL;
4616 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
4618 HTMLElement *This = impl_from_IHTMLElement3(iface);
4619 FIXME("(%p)->(%p)\n", This, p);
4620 return E_NOTIMPL;
4623 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
4624 HTMLElement3_QueryInterface,
4625 HTMLElement3_AddRef,
4626 HTMLElement3_Release,
4627 HTMLElement3_GetTypeInfoCount,
4628 HTMLElement3_GetTypeInfo,
4629 HTMLElement3_GetIDsOfNames,
4630 HTMLElement3_Invoke,
4631 HTMLElement3_mergeAttributes,
4632 HTMLElement3_get_isMultiLine,
4633 HTMLElement3_get_canHaveHTML,
4634 HTMLElement3_put_onlayoutcomplete,
4635 HTMLElement3_get_onlayoutcomplete,
4636 HTMLElement3_put_onpage,
4637 HTMLElement3_get_onpage,
4638 HTMLElement3_put_inflateBlock,
4639 HTMLElement3_get_inflateBlock,
4640 HTMLElement3_put_onbeforedeactivate,
4641 HTMLElement3_get_onbeforedeactivate,
4642 HTMLElement3_setActive,
4643 HTMLElement3_put_contentEditable,
4644 HTMLElement3_get_contentEditable,
4645 HTMLElement3_get_isContentEditable,
4646 HTMLElement3_put_hideFocus,
4647 HTMLElement3_get_hideFocus,
4648 HTMLElement3_put_disabled,
4649 HTMLElement3_get_disabled,
4650 HTMLElement3_get_isDisabled,
4651 HTMLElement3_put_onmove,
4652 HTMLElement3_get_onmove,
4653 HTMLElement3_put_oncontrolselect,
4654 HTMLElement3_get_oncontrolselect,
4655 HTMLElement3_fireEvent,
4656 HTMLElement3_put_onresizestart,
4657 HTMLElement3_get_onresizestart,
4658 HTMLElement3_put_onresizeend,
4659 HTMLElement3_get_onresizeend,
4660 HTMLElement3_put_onmovestart,
4661 HTMLElement3_get_onmovestart,
4662 HTMLElement3_put_onmoveend,
4663 HTMLElement3_get_onmoveend,
4664 HTMLElement3_put_onmousecenter,
4665 HTMLElement3_get_onmousecenter,
4666 HTMLElement3_put_onmouseleave,
4667 HTMLElement3_get_onmouseleave,
4668 HTMLElement3_put_onactivate,
4669 HTMLElement3_get_onactivate,
4670 HTMLElement3_put_ondeactivate,
4671 HTMLElement3_get_ondeactivate,
4672 HTMLElement3_dragDrop,
4673 HTMLElement3_get_glyphMode
4676 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
4678 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
4681 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
4682 REFIID riid, void **ppv)
4684 HTMLElement *This = impl_from_IHTMLElement4(iface);
4685 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4688 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
4690 HTMLElement *This = impl_from_IHTMLElement4(iface);
4691 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4694 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
4696 HTMLElement *This = impl_from_IHTMLElement4(iface);
4697 return IHTMLElement_Release(&This->IHTMLElement_iface);
4700 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
4702 HTMLElement *This = impl_from_IHTMLElement4(iface);
4703 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4706 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
4707 LCID lcid, ITypeInfo **ppTInfo)
4709 HTMLElement *This = impl_from_IHTMLElement4(iface);
4710 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4713 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
4714 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4716 HTMLElement *This = impl_from_IHTMLElement4(iface);
4717 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4718 lcid, rgDispId);
4721 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
4722 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4724 HTMLElement *This = impl_from_IHTMLElement4(iface);
4725 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4726 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4729 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
4731 HTMLElement *This = impl_from_IHTMLElement4(iface);
4733 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4735 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
4738 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
4740 HTMLElement *This = impl_from_IHTMLElement4(iface);
4742 TRACE("(%p)->(%p)\n", This, p);
4744 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
4747 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
4749 HTMLElement *This = impl_from_IHTMLElement4(iface);
4750 FIXME("(%p)\n", This);
4751 return E_NOTIMPL;
4754 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
4756 HTMLElement *This = impl_from_IHTMLElement4(iface);
4757 HTMLAttributeCollection *attrs;
4758 HRESULT hres;
4760 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
4762 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4763 if(FAILED(hres))
4764 return hres;
4766 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
4767 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4768 return hres;
4771 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4772 IHTMLDOMAttribute **ppretAttribute)
4774 HTMLElement *This = impl_from_IHTMLElement4(iface);
4775 HTMLDOMAttribute *attr, *iter, *replace = NULL;
4776 HTMLAttributeCollection *attrs;
4777 DISPID dispid;
4778 HRESULT hres;
4780 TRACE("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4782 attr = unsafe_impl_from_IHTMLDOMAttribute(pattr);
4783 if(!attr)
4784 return E_INVALIDARG;
4786 if(attr->elem) {
4787 WARN("Tried to set already attached attribute.\n");
4788 return E_INVALIDARG;
4791 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface,
4792 attr->name, fdexNameCaseInsensitive|fdexNameEnsure, &dispid);
4793 if(FAILED(hres))
4794 return hres;
4796 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4797 if(FAILED(hres))
4798 return hres;
4800 LIST_FOR_EACH_ENTRY(iter, &attrs->attrs, HTMLDOMAttribute, entry) {
4801 if(iter->dispid == dispid) {
4802 replace = iter;
4803 break;
4807 if(replace) {
4808 hres = get_elem_attr_value_by_dispid(This, dispid, &replace->value);
4809 if(FAILED(hres)) {
4810 WARN("could not get attr value: %08lx\n", hres);
4811 V_VT(&replace->value) = VT_EMPTY;
4813 if(!replace->name) {
4814 replace->name = attr->name;
4815 attr->name = NULL;
4817 list_add_head(&replace->entry, &attr->entry);
4818 list_remove(&replace->entry);
4819 replace->elem = NULL;
4820 }else {
4821 list_add_tail(&attrs->attrs, &attr->entry);
4824 IHTMLDOMAttribute_AddRef(&attr->IHTMLDOMAttribute_iface);
4825 attr->elem = This;
4826 attr->dispid = dispid;
4828 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4830 hres = set_elem_attr_value_by_dispid(This, dispid, &attr->value);
4831 if(FAILED(hres))
4832 WARN("Could not set attribute value: %08lx\n", hres);
4833 VariantClear(&attr->value);
4835 *ppretAttribute = replace ? &replace->IHTMLDOMAttribute_iface : NULL;
4836 return S_OK;
4839 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4840 IHTMLDOMAttribute **ppretAttribute)
4842 HTMLElement *This = impl_from_IHTMLElement4(iface);
4843 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4844 return E_NOTIMPL;
4847 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
4849 HTMLElement *This = impl_from_IHTMLElement4(iface);
4851 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4853 return set_node_event(&This->node, EVENTID_BEFOREACTIVATE, &v);
4856 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
4858 HTMLElement *This = impl_from_IHTMLElement4(iface);
4860 TRACE("(%p)->(%p)\n", This, p);
4862 return get_node_event(&This->node, EVENTID_BEFOREACTIVATE, p);
4865 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
4867 HTMLElement *This = impl_from_IHTMLElement4(iface);
4869 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4871 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
4874 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
4876 HTMLElement *This = impl_from_IHTMLElement4(iface);
4878 TRACE("(%p)->(%p)\n", This, p);
4880 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
4883 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
4885 HTMLElement *This = impl_from_IHTMLElement4(iface);
4887 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4889 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
4892 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
4894 HTMLElement *This = impl_from_IHTMLElement4(iface);
4896 TRACE("(%p)->(%p)\n", This, p);
4898 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
4901 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
4902 HTMLElement4_QueryInterface,
4903 HTMLElement4_AddRef,
4904 HTMLElement4_Release,
4905 HTMLElement4_GetTypeInfoCount,
4906 HTMLElement4_GetTypeInfo,
4907 HTMLElement4_GetIDsOfNames,
4908 HTMLElement4_Invoke,
4909 HTMLElement4_put_onmousewheel,
4910 HTMLElement4_get_onmousewheel,
4911 HTMLElement4_normalize,
4912 HTMLElement4_getAttributeNode,
4913 HTMLElement4_setAttributeNode,
4914 HTMLElement4_removeAttributeNode,
4915 HTMLElement4_put_onbeforeactivate,
4916 HTMLElement4_get_onbeforeactivate,
4917 HTMLElement4_put_onfocusin,
4918 HTMLElement4_get_onfocusin,
4919 HTMLElement4_put_onfocusout,
4920 HTMLElement4_get_onfocusout
4923 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
4925 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
4928 static HRESULT WINAPI HTMLElement6_QueryInterface(IHTMLElement6 *iface,
4929 REFIID riid, void **ppv)
4931 HTMLElement *This = impl_from_IHTMLElement6(iface);
4932 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4935 static ULONG WINAPI HTMLElement6_AddRef(IHTMLElement6 *iface)
4937 HTMLElement *This = impl_from_IHTMLElement6(iface);
4938 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4941 static ULONG WINAPI HTMLElement6_Release(IHTMLElement6 *iface)
4943 HTMLElement *This = impl_from_IHTMLElement6(iface);
4944 return IHTMLElement_Release(&This->IHTMLElement_iface);
4947 static HRESULT WINAPI HTMLElement6_GetTypeInfoCount(IHTMLElement6 *iface, UINT *pctinfo)
4949 HTMLElement *This = impl_from_IHTMLElement6(iface);
4950 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4953 static HRESULT WINAPI HTMLElement6_GetTypeInfo(IHTMLElement6 *iface, UINT iTInfo,
4954 LCID lcid, ITypeInfo **ppTInfo)
4956 HTMLElement *This = impl_from_IHTMLElement6(iface);
4957 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4960 static HRESULT WINAPI HTMLElement6_GetIDsOfNames(IHTMLElement6 *iface, REFIID riid,
4961 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4963 HTMLElement *This = impl_from_IHTMLElement6(iface);
4964 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4965 lcid, rgDispId);
4968 static HRESULT WINAPI HTMLElement6_Invoke(IHTMLElement6 *iface, DISPID dispIdMember, REFIID riid,
4969 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4971 HTMLElement *This = impl_from_IHTMLElement6(iface);
4972 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4973 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4976 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
4978 HTMLElement *This = impl_from_IHTMLElement6(iface);
4979 nsAString ns_str, name_str, value_str;
4980 nsresult nsres;
4981 HRESULT hres;
4983 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
4985 if(!This->dom_element) {
4986 FIXME("No dom_element\n");
4987 return E_NOTIMPL;
4990 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4991 if(FAILED(hres))
4992 return hres;
4994 nsAString_InitDepend(&name_str, strAttributeName);
4995 nsAString_InitDepend(&value_str, NULL);
4996 nsres = nsIDOMElement_GetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
4997 nsAString_Finish(&ns_str);
4998 nsAString_Finish(&name_str);
5000 hres = return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
5001 if(SUCCEEDED(hres) && V_VT(AttributeValue) == VT_NULL) {
5002 V_VT(AttributeValue) = VT_BSTR;
5003 V_BSTR(AttributeValue) = NULL;
5005 return hres;
5008 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
5010 HTMLElement *This = impl_from_IHTMLElement6(iface);
5011 nsAString ns_str, name_str, value_str;
5012 const PRUnichar *ns;
5013 nsresult nsres;
5014 HRESULT hres;
5016 TRACE("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
5018 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
5019 if(FAILED(hres))
5020 return hres;
5021 nsAString_GetData(&ns_str, &ns);
5022 if((!ns || !ns[0]) && wcschr(strAttributeName, ':')) {
5023 nsAString_Finish(&ns_str);
5024 /* FIXME: Return NamespaceError */
5025 return E_FAIL;
5028 if(!This->dom_element) {
5029 FIXME("No dom_element\n");
5030 nsAString_Finish(&ns_str);
5031 return E_NOTIMPL;
5034 hres = variant_to_nsstr(pvarAttributeValue, FALSE, &value_str);
5035 if(FAILED(hres)) {
5036 nsAString_Finish(&ns_str);
5037 return hres;
5040 nsAString_InitDepend(&name_str, strAttributeName);
5041 nsres = nsIDOMElement_SetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
5042 nsAString_Finish(&ns_str);
5043 nsAString_Finish(&name_str);
5044 nsAString_Finish(&value_str);
5045 if(NS_FAILED(nsres))
5046 WARN("SetAttributeNS failed: %08lx\n", nsres);
5047 return map_nsresult(nsres);
5050 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
5052 HTMLElement *This = impl_from_IHTMLElement6(iface);
5053 nsAString ns_str, name_str;
5054 nsresult nsres;
5055 HRESULT hres;
5057 TRACE("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
5059 if(!This->dom_element) {
5060 FIXME("No dom_element\n");
5061 return E_NOTIMPL;
5064 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
5065 if(FAILED(hres))
5066 return hres;
5068 nsAString_InitDepend(&name_str, strAttributeName);
5069 nsres = nsIDOMElement_RemoveAttributeNS(This->dom_element, &ns_str, &name_str);
5070 nsAString_Finish(&ns_str);
5071 nsAString_Finish(&name_str);
5072 return map_nsresult(nsres);
5075 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
5077 HTMLElement *This = impl_from_IHTMLElement6(iface);
5078 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
5079 return E_NOTIMPL;
5082 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5084 HTMLElement *This = impl_from_IHTMLElement6(iface);
5085 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
5086 return E_NOTIMPL;
5089 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
5091 HTMLElement *This = impl_from_IHTMLElement6(iface);
5092 nsAString ns_str, name_str;
5093 nsresult nsres;
5094 HRESULT hres;
5095 cpp_bool r;
5097 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
5099 if(!This->dom_element) {
5100 FIXME("No dom_element\n");
5101 return E_NOTIMPL;
5104 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
5105 if(FAILED(hres))
5106 return hres;
5108 nsAString_InitDepend(&name_str, name);
5109 nsres = nsIDOMElement_HasAttributeNS(This->dom_element, &ns_str, &name_str, &r);
5110 nsAString_Finish(&ns_str);
5111 nsAString_Finish(&name_str);
5112 *pfHasAttribute = variant_bool(NS_SUCCEEDED(nsres) && r);
5113 return S_OK;
5116 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
5118 HTMLElement *This = impl_from_IHTMLElement6(iface);
5120 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), AttributeValue);
5122 return IHTMLElement_getAttribute(&This->IHTMLElement_iface, strAttributeName, 0, AttributeValue);
5125 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
5127 HTMLElement *This = impl_from_IHTMLElement6(iface);
5129 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
5131 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, strAttributeName, *pvarAttributeValue, 0);
5134 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
5136 HTMLElement *This = impl_from_IHTMLElement6(iface);
5137 VARIANT_BOOL success;
5139 WARN("(%p)->(%s) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName));
5141 return IHTMLElement_removeAttribute(&This->IHTMLElement_iface, strAttributeName, 0, &success);
5144 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
5146 HTMLElement *This = impl_from_IHTMLElement6(iface);
5147 IHTMLDOMAttribute *attr;
5148 HRESULT hres;
5150 WARN("(%p)->(%s %p) forwarding to IHTMLElement4\n", This, debugstr_w(strAttributeName), ppretAttribute);
5152 hres = IHTMLElement4_getAttributeNode(&This->IHTMLElement4_iface, strAttributeName, &attr);
5153 if(FAILED(hres))
5154 return hres;
5156 if(attr) {
5157 hres = IHTMLDOMAttribute_QueryInterface(attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
5158 IHTMLDOMAttribute_Release(attr);
5159 }else {
5160 *ppretAttribute = NULL;
5162 return hres;
5165 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5167 HTMLElement *This = impl_from_IHTMLElement6(iface);
5168 IHTMLDOMAttribute *attr, *ret_attr;
5169 HRESULT hres;
5171 WARN("(%p)->(%p %p) forwarding to IHTMLElement4\n", This, pattr, ppretAttribute);
5173 hres = IHTMLDOMAttribute2_QueryInterface(pattr, &IID_IHTMLDOMAttribute, (void**)&attr);
5174 if(FAILED(hres))
5175 return hres;
5177 hres = IHTMLElement4_setAttributeNode(&This->IHTMLElement4_iface, attr, &ret_attr);
5178 if(FAILED(hres))
5179 return hres;
5181 if(ret_attr) {
5182 hres = IHTMLDOMAttribute_QueryInterface(ret_attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
5183 IHTMLDOMAttribute_Release(ret_attr);
5184 }else {
5185 *ppretAttribute = NULL;
5187 return hres;
5190 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5192 HTMLElement *This = impl_from_IHTMLElement6(iface);
5193 FIXME("(%p)->()\n", This);
5194 return E_NOTIMPL;
5197 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *p)
5199 HTMLElement *This = impl_from_IHTMLElement6(iface);
5201 TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), p);
5203 *p = element_has_attribute(This, name);
5204 return S_OK;
5207 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
5209 HTMLElement *This = impl_from_IHTMLElement6(iface);
5210 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
5211 return E_NOTIMPL;
5214 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
5216 HTMLElement *This = impl_from_IHTMLElement6(iface);
5218 TRACE("(%p)->(%p)\n", This, p);
5220 return IHTMLElement_get_tagName(&This->IHTMLElement_iface, p);
5223 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
5225 HTMLElement *This = impl_from_IHTMLElement6(iface);
5227 TRACE("(%p)->(%p)\n", This, p);
5229 return IHTMLDOMNode_get_nodeName(&This->node.IHTMLDOMNode_iface, p);
5232 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
5234 HTMLElement *This = impl_from_IHTMLElement6(iface);
5235 nsIDOMHTMLCollection *nscol = NULL;
5236 nsAString nsstr;
5237 nsresult nsres;
5239 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
5241 if(This->dom_element) {
5242 nsAString_InitDepend(&nsstr, v);
5243 nsres = nsIDOMElement_GetElementsByClassName(This->dom_element, &nsstr, &nscol);
5244 nsAString_Finish(&nsstr);
5245 if(NS_FAILED(nsres)) {
5246 ERR("GetElementsByClassName failed: %08lx\n", nsres);
5247 return E_FAIL;
5251 *pel = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
5252 nsIDOMHTMLCollection_Release(nscol);
5253 return S_OK;
5256 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
5258 HTMLElement *This = impl_from_IHTMLElement6(iface);
5259 nsAString nsstr;
5260 cpp_bool b;
5261 nsresult nsres;
5263 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
5265 if(!This->dom_element) {
5266 FIXME("No dom element\n");
5267 return E_UNEXPECTED;
5270 nsAString_InitDepend(&nsstr, v);
5271 nsres = nsIDOMElement_MozMatchesSelector(This->dom_element, &nsstr, &b);
5272 nsAString_Finish(&nsstr);
5273 if(NS_FAILED(nsres)) {
5274 WARN("MozMatchesSelector failed: %08lx\n", nsres);
5275 return map_nsresult(nsres);
5278 *pfMatches = b;
5279 return S_OK;
5282 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
5284 HTMLElement *This = impl_from_IHTMLElement6(iface);
5286 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5288 return set_node_event(&This->node, EVENTID_ABORT, &v);
5291 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
5293 HTMLElement *This = impl_from_IHTMLElement6(iface);
5295 TRACE("(%p)->(%p)\n", This, p);
5297 return get_node_event(&This->node, EVENTID_ABORT, p);
5300 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
5302 HTMLElement *This = impl_from_IHTMLElement6(iface);
5303 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5304 return E_NOTIMPL;
5307 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
5309 HTMLElement *This = impl_from_IHTMLElement6(iface);
5310 FIXME("(%p)->(%p)\n", This, p);
5311 return E_NOTIMPL;
5314 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
5316 HTMLElement *This = impl_from_IHTMLElement6(iface);
5317 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5318 return E_NOTIMPL;
5321 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
5323 HTMLElement *This = impl_from_IHTMLElement6(iface);
5324 FIXME("(%p)->(%p)\n", This, p);
5325 return E_NOTIMPL;
5328 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
5330 HTMLElement *This = impl_from_IHTMLElement6(iface);
5332 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5334 return set_node_event(&This->node, EVENTID_CHANGE, &v);
5337 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
5339 HTMLElement *This = impl_from_IHTMLElement6(iface);
5341 TRACE("(%p)->(%p)\n", This, p);
5343 return get_node_event(&This->node, EVENTID_CHANGE, p);
5346 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
5348 HTMLElement *This = impl_from_IHTMLElement6(iface);
5349 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5350 return E_NOTIMPL;
5353 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
5355 HTMLElement *This = impl_from_IHTMLElement6(iface);
5356 FIXME("(%p)->(%p)\n", This, p);
5357 return E_NOTIMPL;
5360 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
5362 HTMLElement *This = impl_from_IHTMLElement6(iface);
5363 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5364 return E_NOTIMPL;
5367 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
5369 HTMLElement *This = impl_from_IHTMLElement6(iface);
5370 FIXME("(%p)->(%p)\n", This, p);
5371 return E_NOTIMPL;
5374 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
5376 HTMLElement *This = impl_from_IHTMLElement6(iface);
5377 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5378 return E_NOTIMPL;
5381 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
5383 HTMLElement *This = impl_from_IHTMLElement6(iface);
5384 FIXME("(%p)->(%p)\n", This, p);
5385 return E_NOTIMPL;
5388 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
5390 HTMLElement *This = impl_from_IHTMLElement6(iface);
5392 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5394 return set_node_event(&This->node, EVENTID_ERROR, &v);
5397 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
5399 HTMLElement *This = impl_from_IHTMLElement6(iface);
5401 TRACE("(%p)->(%p)\n", This, p);
5403 return get_node_event(&This->node, EVENTID_ERROR, p);
5406 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
5408 HTMLElement *This = impl_from_IHTMLElement6(iface);
5410 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5412 return set_node_event(&This->node, EVENTID_INPUT, &v);
5415 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
5417 HTMLElement *This = impl_from_IHTMLElement6(iface);
5419 TRACE("(%p)->(%p)\n", This, p);
5421 return get_node_event(&This->node, EVENTID_INPUT, p);
5424 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
5426 HTMLElement *This = impl_from_IHTMLElement6(iface);
5428 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5430 return set_node_event(&This->node, EVENTID_LOAD, &v);
5433 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
5435 HTMLElement *This = impl_from_IHTMLElement6(iface);
5437 TRACE("(%p)->(%p)\n", This, p);
5439 return get_node_event(&This->node, EVENTID_LOAD, p);
5442 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
5444 HTMLElement *This = impl_from_IHTMLElement6(iface);
5445 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5446 return E_NOTIMPL;
5449 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
5451 HTMLElement *This = impl_from_IHTMLElement6(iface);
5452 FIXME("(%p)->(%p)\n", This, p);
5453 return E_NOTIMPL;
5456 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
5458 HTMLElement *This = impl_from_IHTMLElement6(iface);
5459 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5460 return E_NOTIMPL;
5463 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
5465 HTMLElement *This = impl_from_IHTMLElement6(iface);
5466 FIXME("(%p)->(%p)\n", This, p);
5467 return E_NOTIMPL;
5470 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
5472 HTMLElement *This = impl_from_IHTMLElement6(iface);
5473 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5474 return E_NOTIMPL;
5477 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
5479 HTMLElement *This = impl_from_IHTMLElement6(iface);
5480 FIXME("(%p)->(%p)\n", This, p);
5481 return E_NOTIMPL;
5484 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
5486 HTMLElement *This = impl_from_IHTMLElement6(iface);
5487 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5488 return E_NOTIMPL;
5491 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
5493 HTMLElement *This = impl_from_IHTMLElement6(iface);
5494 FIXME("(%p)->(%p)\n", This, p);
5495 return E_NOTIMPL;
5498 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
5500 HTMLElement *This = impl_from_IHTMLElement6(iface);
5501 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5502 return E_NOTIMPL;
5505 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
5507 HTMLElement *This = impl_from_IHTMLElement6(iface);
5508 FIXME("(%p)->(%p)\n", This, p);
5509 return E_NOTIMPL;
5512 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
5514 HTMLElement *This = impl_from_IHTMLElement6(iface);
5515 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5516 return E_NOTIMPL;
5519 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
5521 HTMLElement *This = impl_from_IHTMLElement6(iface);
5522 FIXME("(%p)->(%p)\n", This, p);
5523 return E_NOTIMPL;
5526 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
5528 HTMLElement *This = impl_from_IHTMLElement6(iface);
5529 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5530 return E_NOTIMPL;
5533 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
5535 HTMLElement *This = impl_from_IHTMLElement6(iface);
5536 FIXME("(%p)->(%p)\n", This, p);
5537 return E_NOTIMPL;
5540 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
5542 HTMLElement *This = impl_from_IHTMLElement6(iface);
5543 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5544 return E_NOTIMPL;
5547 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
5549 HTMLElement *This = impl_from_IHTMLElement6(iface);
5550 FIXME("(%p)->(%p)\n", This, p);
5551 return E_NOTIMPL;
5554 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
5556 HTMLElement *This = impl_from_IHTMLElement6(iface);
5557 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5558 return E_NOTIMPL;
5561 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
5563 HTMLElement *This = impl_from_IHTMLElement6(iface);
5564 FIXME("(%p)->(%p)\n", This, p);
5565 return E_NOTIMPL;
5568 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
5570 HTMLElement *This = impl_from_IHTMLElement6(iface);
5571 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5572 return E_NOTIMPL;
5575 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
5577 HTMLElement *This = impl_from_IHTMLElement6(iface);
5578 FIXME("(%p)->(%p)\n", This, p);
5579 return E_NOTIMPL;
5582 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
5584 HTMLElement *This = impl_from_IHTMLElement6(iface);
5585 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5586 return E_NOTIMPL;
5589 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
5591 HTMLElement *This = impl_from_IHTMLElement6(iface);
5592 FIXME("(%p)->(%p)\n", This, p);
5593 return E_NOTIMPL;
5596 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
5598 HTMLElement *This = impl_from_IHTMLElement6(iface);
5599 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5600 return E_NOTIMPL;
5603 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
5605 HTMLElement *This = impl_from_IHTMLElement6(iface);
5606 FIXME("(%p)->(%p)\n", This, p);
5607 return E_NOTIMPL;
5610 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
5612 HTMLElement *This = impl_from_IHTMLElement6(iface);
5613 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5614 return E_NOTIMPL;
5617 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
5619 HTMLElement *This = impl_from_IHTMLElement6(iface);
5620 FIXME("(%p)->(%p)\n", This, p);
5621 return E_NOTIMPL;
5624 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
5626 HTMLElement *This = impl_from_IHTMLElement6(iface);
5628 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5630 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
5633 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
5635 HTMLElement *This = impl_from_IHTMLElement6(iface);
5637 TRACE("(%p)->(%p)\n", This, p);
5639 return get_node_event(&This->node, EVENTID_SUBMIT, p);
5642 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
5644 HTMLElement *This = impl_from_IHTMLElement6(iface);
5645 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5646 return E_NOTIMPL;
5649 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
5651 HTMLElement *This = impl_from_IHTMLElement6(iface);
5652 FIXME("(%p)->(%p)\n", This, p);
5653 return E_NOTIMPL;
5656 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
5658 HTMLElement *This = impl_from_IHTMLElement6(iface);
5659 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5660 return E_NOTIMPL;
5663 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
5665 HTMLElement *This = impl_from_IHTMLElement6(iface);
5666 FIXME("(%p)->(%p)\n", This, p);
5667 return E_NOTIMPL;
5670 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
5672 HTMLElement *This = impl_from_IHTMLElement6(iface);
5673 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5674 return E_NOTIMPL;
5677 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
5679 HTMLElement *This = impl_from_IHTMLElement6(iface);
5680 FIXME("(%p)->(%p)\n", This, p);
5681 return E_NOTIMPL;
5684 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
5686 HTMLElement *This = impl_from_IHTMLElement6(iface);
5687 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5688 return E_NOTIMPL;
5691 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
5693 HTMLElement *This = impl_from_IHTMLElement6(iface);
5694 FIXME("(%p)->(%p)\n", This, p);
5695 return E_NOTIMPL;
5698 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
5700 HTMLElement *This = impl_from_IHTMLElement6(iface);
5701 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
5702 return E_NOTIMPL;
5705 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
5706 HTMLElement6_QueryInterface,
5707 HTMLElement6_AddRef,
5708 HTMLElement6_Release,
5709 HTMLElement6_GetTypeInfoCount,
5710 HTMLElement6_GetTypeInfo,
5711 HTMLElement6_GetIDsOfNames,
5712 HTMLElement6_Invoke,
5713 HTMLElement6_getAttributeNS,
5714 HTMLElement6_setAttributeNS,
5715 HTMLElement6_removeAttributeNS,
5716 HTMLElement6_getAttributeNodeNS,
5717 HTMLElement6_setAttributeNodeNS,
5718 HTMLElement6_hasAttributeNS,
5719 HTMLElement6_getAttribute,
5720 HTMLElement6_setAttribute,
5721 HTMLElement6_removeAttribute,
5722 HTMLElement6_getAttributeNode,
5723 HTMLElement6_setAttributeNode,
5724 HTMLElement6_removeAttributeNode,
5725 HTMLElement6_hasAttribute,
5726 HTMLElement6_getElementsByTagNameNS,
5727 HTMLElement6_get_tagName,
5728 HTMLElement6_get_nodeName,
5729 HTMLElement6_getElementsByClassName,
5730 HTMLElement6_msMatchesSelector,
5731 HTMLElement6_put_onabort,
5732 HTMLElement6_get_onabort,
5733 HTMLElement6_put_oncanplay,
5734 HTMLElement6_get_oncanplay,
5735 HTMLElement6_put_oncanplaythrough,
5736 HTMLElement6_get_oncanplaythrough,
5737 HTMLElement6_put_onchange,
5738 HTMLElement6_get_onchange,
5739 HTMLElement6_put_ondurationchange,
5740 HTMLElement6_get_ondurationchange,
5741 HTMLElement6_put_onemptied,
5742 HTMLElement6_get_onemptied,
5743 HTMLElement6_put_onended,
5744 HTMLElement6_get_onended,
5745 HTMLElement6_put_onerror,
5746 HTMLElement6_get_onerror,
5747 HTMLElement6_put_oninput,
5748 HTMLElement6_get_oninput,
5749 HTMLElement6_put_onload,
5750 HTMLElement6_get_onload,
5751 HTMLElement6_put_onloadeddata,
5752 HTMLElement6_get_onloadeddata,
5753 HTMLElement6_put_onloadedmetadata,
5754 HTMLElement6_get_onloadedmetadata,
5755 HTMLElement6_put_onloadstart,
5756 HTMLElement6_get_onloadstart,
5757 HTMLElement6_put_onpause,
5758 HTMLElement6_get_onpause,
5759 HTMLElement6_put_onplay,
5760 HTMLElement6_get_onplay,
5761 HTMLElement6_put_onplaying,
5762 HTMLElement6_get_onplaying,
5763 HTMLElement6_put_onprogress,
5764 HTMLElement6_get_onprogress,
5765 HTMLElement6_put_onratechange,
5766 HTMLElement6_get_onratechange,
5767 HTMLElement6_put_onreset,
5768 HTMLElement6_get_onreset,
5769 HTMLElement6_put_onseeked,
5770 HTMLElement6_get_onseeked,
5771 HTMLElement6_put_onseeking,
5772 HTMLElement6_get_onseeking,
5773 HTMLElement6_put_onselect,
5774 HTMLElement6_get_onselect,
5775 HTMLElement6_put_onstalled,
5776 HTMLElement6_get_onstalled,
5777 HTMLElement6_put_onsubmit,
5778 HTMLElement6_get_onsubmit,
5779 HTMLElement6_put_onsuspend,
5780 HTMLElement6_get_onsuspend,
5781 HTMLElement6_put_ontimeupdate,
5782 HTMLElement6_get_ontimeupdate,
5783 HTMLElement6_put_onvolumechange,
5784 HTMLElement6_get_onvolumechange,
5785 HTMLElement6_put_onwaiting,
5786 HTMLElement6_get_onwaiting,
5787 HTMLElement6_hasAttributes
5790 static inline HTMLElement *impl_from_IHTMLElement7(IHTMLElement7 *iface)
5792 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement7_iface);
5795 static HRESULT WINAPI HTMLElement7_QueryInterface(IHTMLElement7 *iface,
5796 REFIID riid, void **ppv)
5798 HTMLElement *This = impl_from_IHTMLElement7(iface);
5799 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
5802 static ULONG WINAPI HTMLElement7_AddRef(IHTMLElement7 *iface)
5804 HTMLElement *This = impl_from_IHTMLElement7(iface);
5805 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5808 static ULONG WINAPI HTMLElement7_Release(IHTMLElement7 *iface)
5810 HTMLElement *This = impl_from_IHTMLElement7(iface);
5811 return IHTMLElement_Release(&This->IHTMLElement_iface);
5814 static HRESULT WINAPI HTMLElement7_GetTypeInfoCount(IHTMLElement7 *iface, UINT *pctinfo)
5816 HTMLElement *This = impl_from_IHTMLElement7(iface);
5817 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5820 static HRESULT WINAPI HTMLElement7_GetTypeInfo(IHTMLElement7 *iface, UINT iTInfo,
5821 LCID lcid, ITypeInfo **ppTInfo)
5823 HTMLElement *This = impl_from_IHTMLElement7(iface);
5824 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5827 static HRESULT WINAPI HTMLElement7_GetIDsOfNames(IHTMLElement7 *iface, REFIID riid,
5828 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5830 HTMLElement *This = impl_from_IHTMLElement7(iface);
5831 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5832 lcid, rgDispId);
5835 static HRESULT WINAPI HTMLElement7_Invoke(IHTMLElement7 *iface, DISPID dispIdMember, REFIID riid,
5836 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5838 HTMLElement *This = impl_from_IHTMLElement7(iface);
5839 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5840 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5843 static HRESULT WINAPI HTMLElement7_put_onmspointerdown(IHTMLElement7 *iface, VARIANT v)
5845 HTMLElement *This = impl_from_IHTMLElement7(iface);
5846 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5847 return E_NOTIMPL;
5850 static HRESULT WINAPI HTMLElement7_get_onmspointerdown(IHTMLElement7 *iface, VARIANT *p)
5852 HTMLElement *This = impl_from_IHTMLElement7(iface);
5853 FIXME("(%p)->(%p)\n", This, p);
5854 return E_NOTIMPL;
5857 static HRESULT WINAPI HTMLElement7_put_onmspointermove(IHTMLElement7 *iface, VARIANT v)
5859 HTMLElement *This = impl_from_IHTMLElement7(iface);
5860 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5861 return E_NOTIMPL;
5864 static HRESULT WINAPI HTMLElement7_get_onmspointermove(IHTMLElement7 *iface, VARIANT *p)
5866 HTMLElement *This = impl_from_IHTMLElement7(iface);
5867 FIXME("(%p)->(%p)\n", This, p);
5868 return E_NOTIMPL;
5871 static HRESULT WINAPI HTMLElement7_put_onmspointerup(IHTMLElement7 *iface, VARIANT v)
5873 HTMLElement *This = impl_from_IHTMLElement7(iface);
5874 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5875 return E_NOTIMPL;
5878 static HRESULT WINAPI HTMLElement7_get_onmspointerup(IHTMLElement7 *iface, VARIANT *p)
5880 HTMLElement *This = impl_from_IHTMLElement7(iface);
5881 FIXME("(%p)->(%p)\n", This, p);
5882 return E_NOTIMPL;
5885 static HRESULT WINAPI HTMLElement7_put_onmspointerover(IHTMLElement7 *iface, VARIANT v)
5887 HTMLElement *This = impl_from_IHTMLElement7(iface);
5888 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5889 return E_NOTIMPL;
5892 static HRESULT WINAPI HTMLElement7_get_onmspointerover(IHTMLElement7 *iface, VARIANT *p)
5894 HTMLElement *This = impl_from_IHTMLElement7(iface);
5895 FIXME("(%p)->(%p)\n", This, p);
5896 return E_NOTIMPL;
5899 static HRESULT WINAPI HTMLElement7_put_onmspointerout(IHTMLElement7 *iface, VARIANT v)
5901 HTMLElement *This = impl_from_IHTMLElement7(iface);
5902 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5903 return E_NOTIMPL;
5906 static HRESULT WINAPI HTMLElement7_get_onmspointerout(IHTMLElement7 *iface, VARIANT *p)
5908 HTMLElement *This = impl_from_IHTMLElement7(iface);
5909 FIXME("(%p)->(%p)\n", This, p);
5910 return E_NOTIMPL;
5913 static HRESULT WINAPI HTMLElement7_put_onmspointercancel(IHTMLElement7 *iface, VARIANT v)
5915 HTMLElement *This = impl_from_IHTMLElement7(iface);
5916 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5917 return E_NOTIMPL;
5920 static HRESULT WINAPI HTMLElement7_get_onmspointercancel(IHTMLElement7 *iface, VARIANT *p)
5922 HTMLElement *This = impl_from_IHTMLElement7(iface);
5923 FIXME("(%p)->(%p)\n", This, p);
5924 return E_NOTIMPL;
5927 static HRESULT WINAPI HTMLElement7_put_onmspointerhover(IHTMLElement7 *iface, VARIANT v)
5929 HTMLElement *This = impl_from_IHTMLElement7(iface);
5930 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5931 return E_NOTIMPL;
5934 static HRESULT WINAPI HTMLElement7_get_onmspointerhover(IHTMLElement7 *iface, VARIANT *p)
5936 HTMLElement *This = impl_from_IHTMLElement7(iface);
5937 FIXME("(%p)->(%p)\n", This, p);
5938 return E_NOTIMPL;
5941 static HRESULT WINAPI HTMLElement7_put_onmslostpointercapture(IHTMLElement7 *iface, VARIANT v)
5943 HTMLElement *This = impl_from_IHTMLElement7(iface);
5944 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5945 return E_NOTIMPL;
5948 static HRESULT WINAPI HTMLElement7_get_onmslostpointercapture(IHTMLElement7 *iface, VARIANT *p)
5950 HTMLElement *This = impl_from_IHTMLElement7(iface);
5951 FIXME("(%p)->(%p)\n", This, p);
5952 return E_NOTIMPL;
5955 static HRESULT WINAPI HTMLElement7_put_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT v)
5957 HTMLElement *This = impl_from_IHTMLElement7(iface);
5958 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5959 return E_NOTIMPL;
5962 static HRESULT WINAPI HTMLElement7_get_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT *p)
5964 HTMLElement *This = impl_from_IHTMLElement7(iface);
5965 FIXME("(%p)->(%p)\n", This, p);
5966 return E_NOTIMPL;
5969 static HRESULT WINAPI HTMLElement7_put_onmsgesturestart(IHTMLElement7 *iface, VARIANT v)
5971 HTMLElement *This = impl_from_IHTMLElement7(iface);
5972 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5973 return E_NOTIMPL;
5976 static HRESULT WINAPI HTMLElement7_get_onmsgesturestart(IHTMLElement7 *iface, VARIANT *p)
5978 HTMLElement *This = impl_from_IHTMLElement7(iface);
5979 FIXME("(%p)->(%p)\n", This, p);
5980 return E_NOTIMPL;
5983 static HRESULT WINAPI HTMLElement7_put_onmsgesturechange(IHTMLElement7 *iface, VARIANT v)
5985 HTMLElement *This = impl_from_IHTMLElement7(iface);
5986 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5987 return E_NOTIMPL;
5990 static HRESULT WINAPI HTMLElement7_get_onmsgesturechange(IHTMLElement7 *iface, VARIANT *p)
5992 HTMLElement *This = impl_from_IHTMLElement7(iface);
5993 FIXME("(%p)->(%p)\n", This, p);
5994 return E_NOTIMPL;
5997 static HRESULT WINAPI HTMLElement7_put_onmsgestureend(IHTMLElement7 *iface, VARIANT v)
5999 HTMLElement *This = impl_from_IHTMLElement7(iface);
6000 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6001 return E_NOTIMPL;
6004 static HRESULT WINAPI HTMLElement7_get_onmsgestureend(IHTMLElement7 *iface, VARIANT *p)
6006 HTMLElement *This = impl_from_IHTMLElement7(iface);
6007 FIXME("(%p)->(%p)\n", This, p);
6008 return E_NOTIMPL;
6011 static HRESULT WINAPI HTMLElement7_put_onmsgesturehold(IHTMLElement7 *iface, VARIANT v)
6013 HTMLElement *This = impl_from_IHTMLElement7(iface);
6014 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6015 return E_NOTIMPL;
6018 static HRESULT WINAPI HTMLElement7_get_onmsgesturehold(IHTMLElement7 *iface, VARIANT *p)
6020 HTMLElement *This = impl_from_IHTMLElement7(iface);
6021 FIXME("(%p)->(%p)\n", This, p);
6022 return E_NOTIMPL;
6025 static HRESULT WINAPI HTMLElement7_put_onmsgesturetap(IHTMLElement7 *iface, VARIANT v)
6027 HTMLElement *This = impl_from_IHTMLElement7(iface);
6028 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6029 return E_NOTIMPL;
6032 static HRESULT WINAPI HTMLElement7_get_onmsgesturetap(IHTMLElement7 *iface, VARIANT *p)
6034 HTMLElement *This = impl_from_IHTMLElement7(iface);
6035 FIXME("(%p)->(%p)\n", This, p);
6036 return E_NOTIMPL;
6039 static HRESULT WINAPI HTMLElement7_put_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT v)
6041 HTMLElement *This = impl_from_IHTMLElement7(iface);
6042 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6043 return E_NOTIMPL;
6046 static HRESULT WINAPI HTMLElement7_get_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT *p)
6048 HTMLElement *This = impl_from_IHTMLElement7(iface);
6049 FIXME("(%p)->(%p)\n", This, p);
6050 return E_NOTIMPL;
6053 static HRESULT WINAPI HTMLElement7_put_onmsinertiastart(IHTMLElement7 *iface, VARIANT v)
6055 HTMLElement *This = impl_from_IHTMLElement7(iface);
6056 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6057 return E_NOTIMPL;
6060 static HRESULT WINAPI HTMLElement7_get_onmsinertiastart(IHTMLElement7 *iface, VARIANT *p)
6062 HTMLElement *This = impl_from_IHTMLElement7(iface);
6063 FIXME("(%p)->(%p)\n", This, p);
6064 return E_NOTIMPL;
6067 static HRESULT WINAPI HTMLElement7_msSetPointerCapture(IHTMLElement7 *iface, LONG pointer_id)
6069 HTMLElement *This = impl_from_IHTMLElement7(iface);
6070 FIXME("(%p)->(%ld)\n", This, pointer_id);
6071 return E_NOTIMPL;
6074 static HRESULT WINAPI HTMLElement7_msReleasePointerCapture(IHTMLElement7 *iface, LONG pointer_id)
6076 HTMLElement *This = impl_from_IHTMLElement7(iface);
6077 FIXME("(%p)->(%ld)\n", This, pointer_id);
6078 return E_NOTIMPL;
6081 static HRESULT WINAPI HTMLElement7_put_onmstransitionstart(IHTMLElement7 *iface, VARIANT v)
6083 HTMLElement *This = impl_from_IHTMLElement7(iface);
6084 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6085 return E_NOTIMPL;
6088 static HRESULT WINAPI HTMLElement7_get_onmstransitionstart(IHTMLElement7 *iface, VARIANT *p)
6090 HTMLElement *This = impl_from_IHTMLElement7(iface);
6091 FIXME("(%p)->(%p)\n", This, p);
6092 return E_NOTIMPL;
6095 static HRESULT WINAPI HTMLElement7_put_onmstransitionend(IHTMLElement7 *iface, VARIANT v)
6097 HTMLElement *This = impl_from_IHTMLElement7(iface);
6098 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6099 return E_NOTIMPL;
6102 static HRESULT WINAPI HTMLElement7_get_onmstransitionend(IHTMLElement7 *iface, VARIANT *p)
6104 HTMLElement *This = impl_from_IHTMLElement7(iface);
6105 FIXME("(%p)->(%p)\n", This, p);
6106 return E_NOTIMPL;
6109 static HRESULT WINAPI HTMLElement7_put_onmsanimationstart(IHTMLElement7 *iface, VARIANT v)
6111 HTMLElement *This = impl_from_IHTMLElement7(iface);
6112 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6113 return E_NOTIMPL;
6116 static HRESULT WINAPI HTMLElement7_get_onmsanimationstart(IHTMLElement7 *iface, VARIANT *p)
6118 HTMLElement *This = impl_from_IHTMLElement7(iface);
6119 FIXME("(%p)->(%p)\n", This, p);
6120 return E_NOTIMPL;
6123 static HRESULT WINAPI HTMLElement7_put_onmsanimationend(IHTMLElement7 *iface, VARIANT v)
6125 HTMLElement *This = impl_from_IHTMLElement7(iface);
6126 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6127 return E_NOTIMPL;
6130 static HRESULT WINAPI HTMLElement7_get_onmsanimationend(IHTMLElement7 *iface, VARIANT *p)
6132 HTMLElement *This = impl_from_IHTMLElement7(iface);
6133 FIXME("(%p)->(%p)\n", This, p);
6134 return E_NOTIMPL;
6137 static HRESULT WINAPI HTMLElement7_put_onmsanimationiteration(IHTMLElement7 *iface, VARIANT v)
6139 HTMLElement *This = impl_from_IHTMLElement7(iface);
6140 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6141 return E_NOTIMPL;
6144 static HRESULT WINAPI HTMLElement7_get_onmsanimationiteration(IHTMLElement7 *iface, VARIANT *p)
6146 HTMLElement *This = impl_from_IHTMLElement7(iface);
6147 FIXME("(%p)->(%p)\n", This, p);
6148 return E_NOTIMPL;
6151 static HRESULT WINAPI HTMLElement7_put_oninvalid(IHTMLElement7 *iface, VARIANT v)
6153 HTMLElement *This = impl_from_IHTMLElement7(iface);
6154 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6155 return E_NOTIMPL;
6158 static HRESULT WINAPI HTMLElement7_get_oninvalid(IHTMLElement7 *iface, VARIANT *p)
6160 HTMLElement *This = impl_from_IHTMLElement7(iface);
6161 FIXME("(%p)->(%p)\n", This, p);
6162 return E_NOTIMPL;
6165 static HRESULT WINAPI HTMLElement7_put_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR v)
6167 HTMLElement *This = impl_from_IHTMLElement7(iface);
6168 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
6169 return E_NOTIMPL;
6172 static HRESULT WINAPI HTMLElement7_get_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR *p)
6174 HTMLElement *This = impl_from_IHTMLElement7(iface);
6175 FIXME("(%p)->(%p)\n", This, p);
6176 return E_NOTIMPL;
6179 static HRESULT WINAPI HTMLElement7_put_spellcheck(IHTMLElement7 *iface, VARIANT v)
6181 HTMLElement *This = impl_from_IHTMLElement7(iface);
6183 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
6185 if(!This->html_element) {
6186 FIXME("non-HTML element\n");
6187 return E_NOTIMPL;
6190 if(V_VT(&v) != VT_BOOL) {
6191 FIXME("unsupported argument %s\n", debugstr_variant(&v));
6192 return E_NOTIMPL;
6195 return map_nsresult(nsIDOMHTMLElement_SetSpellcheck(This->html_element, !!V_BOOL(&v)));
6198 static HRESULT WINAPI HTMLElement7_get_spellcheck(IHTMLElement7 *iface, VARIANT *p)
6200 HTMLElement *This = impl_from_IHTMLElement7(iface);
6201 cpp_bool spellcheck;
6202 nsresult nsres;
6204 TRACE("(%p)->(%p)\n", This, p);
6206 if(!This->html_element) {
6207 FIXME("non-HTML element\n");
6208 return E_NOTIMPL;
6211 nsres = nsIDOMHTMLElement_GetSpellcheck(This->html_element, &spellcheck);
6212 if(NS_FAILED(nsres))
6213 return map_nsresult(nsres);
6215 V_VT(p) = VT_BOOL;
6216 V_BOOL(p) = spellcheck ? VARIANT_TRUE : VARIANT_FALSE;
6217 return S_OK;
6220 static HRESULT WINAPI HTMLElement7_put_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT v)
6222 HTMLElement *This = impl_from_IHTMLElement7(iface);
6223 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6224 return E_NOTIMPL;
6227 static HRESULT WINAPI HTMLElement7_get_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT *p)
6229 HTMLElement *This = impl_from_IHTMLElement7(iface);
6230 FIXME("(%p)->(%p)\n", This, p);
6231 return E_NOTIMPL;
6234 static HRESULT WINAPI HTMLElement7_put_oncuechange(IHTMLElement7 *iface, VARIANT v)
6236 HTMLElement *This = impl_from_IHTMLElement7(iface);
6237 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6238 return E_NOTIMPL;
6241 static HRESULT WINAPI HTMLElement7_get_oncuechange(IHTMLElement7 *iface, VARIANT *p)
6243 HTMLElement *This = impl_from_IHTMLElement7(iface);
6244 FIXME("(%p)->(%p)\n", This, p);
6245 return E_NOTIMPL;
6248 static const IHTMLElement7Vtbl HTMLElement7Vtbl = {
6249 HTMLElement7_QueryInterface,
6250 HTMLElement7_AddRef,
6251 HTMLElement7_Release,
6252 HTMLElement7_GetTypeInfoCount,
6253 HTMLElement7_GetTypeInfo,
6254 HTMLElement7_GetIDsOfNames,
6255 HTMLElement7_Invoke,
6256 HTMLElement7_put_onmspointerdown,
6257 HTMLElement7_get_onmspointerdown,
6258 HTMLElement7_put_onmspointermove,
6259 HTMLElement7_get_onmspointermove,
6260 HTMLElement7_put_onmspointerup,
6261 HTMLElement7_get_onmspointerup,
6262 HTMLElement7_put_onmspointerover,
6263 HTMLElement7_get_onmspointerover,
6264 HTMLElement7_put_onmspointerout,
6265 HTMLElement7_get_onmspointerout,
6266 HTMLElement7_put_onmspointercancel,
6267 HTMLElement7_get_onmspointercancel,
6268 HTMLElement7_put_onmspointerhover,
6269 HTMLElement7_get_onmspointerhover,
6270 HTMLElement7_put_onmslostpointercapture,
6271 HTMLElement7_get_onmslostpointercapture,
6272 HTMLElement7_put_onmsgotpointercapture,
6273 HTMLElement7_get_onmsgotpointercapture,
6274 HTMLElement7_put_onmsgesturestart,
6275 HTMLElement7_get_onmsgesturestart,
6276 HTMLElement7_put_onmsgesturechange,
6277 HTMLElement7_get_onmsgesturechange,
6278 HTMLElement7_put_onmsgestureend,
6279 HTMLElement7_get_onmsgestureend,
6280 HTMLElement7_put_onmsgesturehold,
6281 HTMLElement7_get_onmsgesturehold,
6282 HTMLElement7_put_onmsgesturetap,
6283 HTMLElement7_get_onmsgesturetap,
6284 HTMLElement7_put_onmsgesturedoubletap,
6285 HTMLElement7_get_onmsgesturedoubletap,
6286 HTMLElement7_put_onmsinertiastart,
6287 HTMLElement7_get_onmsinertiastart,
6288 HTMLElement7_msSetPointerCapture,
6289 HTMLElement7_msReleasePointerCapture,
6290 HTMLElement7_put_onmstransitionstart,
6291 HTMLElement7_get_onmstransitionstart,
6292 HTMLElement7_put_onmstransitionend,
6293 HTMLElement7_get_onmstransitionend,
6294 HTMLElement7_put_onmsanimationstart,
6295 HTMLElement7_get_onmsanimationstart,
6296 HTMLElement7_put_onmsanimationend,
6297 HTMLElement7_get_onmsanimationend,
6298 HTMLElement7_put_onmsanimationiteration,
6299 HTMLElement7_get_onmsanimationiteration,
6300 HTMLElement7_put_oninvalid,
6301 HTMLElement7_get_oninvalid,
6302 HTMLElement7_put_xmsAcceleratorKey,
6303 HTMLElement7_get_xmsAcceleratorKey,
6304 HTMLElement7_put_spellcheck,
6305 HTMLElement7_get_spellcheck,
6306 HTMLElement7_put_onmsmanipulationstatechanged,
6307 HTMLElement7_get_onmsmanipulationstatechanged,
6308 HTMLElement7_put_oncuechange,
6309 HTMLElement7_get_oncuechange
6313 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
6315 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
6318 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
6320 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6321 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6324 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
6326 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6327 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6330 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
6332 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6333 return IHTMLElement_Release(&This->IHTMLElement_iface);
6336 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
6338 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6339 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6342 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
6343 LCID lcid, ITypeInfo **ppTInfo)
6345 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6346 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6349 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
6350 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6352 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6353 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6354 lcid, rgDispId);
6357 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
6358 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6360 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6361 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6362 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6365 HRESULT elem_unique_id(unsigned id, BSTR *p)
6367 WCHAR buf[32];
6369 swprintf(buf, ARRAY_SIZE(buf), L"ms__id%u", id);
6370 *p = SysAllocString(buf);
6371 return *p ? S_OK : E_OUTOFMEMORY;
6374 static void ensure_unique_id(HTMLElement *elem)
6376 if(!elem->unique_id)
6377 elem->unique_id = ++elem->node.doc->unique_id;
6380 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
6382 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6384 TRACE("(%p)->(%p)\n", This, p);
6386 ensure_unique_id(This);
6387 *p = This->unique_id;
6388 return S_OK;
6391 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
6393 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6395 TRACE("(%p)->(%p)\n", This, p);
6397 ensure_unique_id(This);
6398 return elem_unique_id(This->unique_id, p);
6401 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
6402 HTMLUniqueName_QueryInterface,
6403 HTMLUniqueName_AddRef,
6404 HTMLUniqueName_Release,
6405 HTMLUniqueName_GetTypeInfoCount,
6406 HTMLUniqueName_GetTypeInfo,
6407 HTMLUniqueName_GetIDsOfNames,
6408 HTMLUniqueName_Invoke,
6409 HTMLUniqueName_get_uniqueNumber,
6410 HTMLUniqueName_get_uniqueID
6413 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
6415 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
6418 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
6420 HTMLElement *This = impl_from_IElementSelector(iface);
6421 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6424 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
6426 HTMLElement *This = impl_from_IElementSelector(iface);
6427 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6430 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
6432 HTMLElement *This = impl_from_IElementSelector(iface);
6433 return IHTMLElement_Release(&This->IHTMLElement_iface);
6436 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
6438 HTMLElement *This = impl_from_IElementSelector(iface);
6439 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6442 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
6443 LCID lcid, ITypeInfo **ppTInfo)
6445 HTMLElement *This = impl_from_IElementSelector(iface);
6446 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6449 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
6450 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6452 HTMLElement *This = impl_from_IElementSelector(iface);
6453 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
6456 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
6457 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6459 HTMLElement *This = impl_from_IElementSelector(iface);
6460 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
6461 pDispParams, pVarResult, pExcepInfo, puArgErr);
6464 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
6466 HTMLElement *This = impl_from_IElementSelector(iface);
6467 nsIDOMElement *nselem;
6468 HTMLElement *elem;
6469 nsAString nsstr;
6470 nsresult nsres;
6471 HRESULT hres;
6473 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6475 if(!This->dom_element) {
6476 FIXME("comment element\n");
6477 return E_NOTIMPL;
6480 nsAString_InitDepend(&nsstr, v);
6481 nsres = nsIDOMElement_QuerySelector(This->dom_element, &nsstr, &nselem);
6482 nsAString_Finish(&nsstr);
6483 if(NS_FAILED(nsres)) {
6484 WARN("QuerySelector failed: %08lx\n", nsres);
6485 return map_nsresult(nsres);
6488 if(!nselem) {
6489 *pel = NULL;
6490 return S_OK;
6493 hres = get_element(nselem, &elem);
6494 nsIDOMElement_Release(nselem);
6495 if(FAILED(hres))
6496 return hres;
6498 *pel = &elem->IHTMLElement_iface;
6499 return S_OK;
6502 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
6504 HTMLElement *This = impl_from_IElementSelector(iface);
6505 nsIDOMNodeList *node_list;
6506 nsAString nsstr;
6507 nsresult nsres;
6508 HRESULT hres;
6510 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6512 if(!This->dom_element) {
6513 FIXME("comment element\n");
6514 return E_NOTIMPL;
6517 nsAString_InitDepend(&nsstr, v);
6518 nsres = nsIDOMElement_QuerySelectorAll(This->dom_element, &nsstr, &node_list);
6519 nsAString_Finish(&nsstr);
6520 if(NS_FAILED(nsres)) {
6521 WARN("QuerySelectorAll failed: %08lx\n", nsres);
6522 return map_nsresult(nsres);
6525 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
6526 nsIDOMNodeList_Release(node_list);
6527 return hres;
6530 static const IElementSelectorVtbl ElementSelectorVtbl = {
6531 ElementSelector_QueryInterface,
6532 ElementSelector_AddRef,
6533 ElementSelector_Release,
6534 ElementSelector_GetTypeInfoCount,
6535 ElementSelector_GetTypeInfo,
6536 ElementSelector_GetIDsOfNames,
6537 ElementSelector_Invoke,
6538 ElementSelector_querySelector,
6539 ElementSelector_querySelectorAll
6542 static inline HTMLElement *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
6544 return CONTAINING_RECORD(iface, HTMLElement, IProvideMultipleClassInfo_iface);
6547 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
6548 REFIID riid, void **ppv)
6550 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6551 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6554 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
6556 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6557 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6560 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
6562 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6563 return IHTMLElement_Release(&This->IHTMLElement_iface);
6566 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
6568 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6569 TRACE("(%p)->(%p)\n", This, ppTI);
6570 return get_class_typeinfo(This->node.vtbl->clsid, ppTI);
6573 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
6575 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6576 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
6577 return E_NOTIMPL;
6580 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
6582 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6583 FIXME("(%p)->(%p)\n", This, pcti);
6584 *pcti = 1;
6585 return S_OK;
6588 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
6589 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
6591 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6592 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
6593 return E_NOTIMPL;
6596 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
6597 ProvideClassInfo_QueryInterface,
6598 ProvideClassInfo_AddRef,
6599 ProvideClassInfo_Release,
6600 ProvideClassInfo_GetClassInfo,
6601 ProvideClassInfo2_GetGUID,
6602 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
6603 ProvideMultipleClassInfo_GetInfoOfIndex
6606 static inline HTMLElement *impl_from_IElementTraversal(IElementTraversal *iface)
6608 return CONTAINING_RECORD(iface, HTMLElement, IElementTraversal_iface);
6611 static HRESULT WINAPI ElementTraversal_QueryInterface(IElementTraversal *iface, REFIID riid, void **ppv)
6613 HTMLElement *This = impl_from_IElementTraversal(iface);
6614 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6617 static ULONG WINAPI ElementTraversal_AddRef(IElementTraversal *iface)
6619 HTMLElement *This = impl_from_IElementTraversal(iface);
6621 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6624 static ULONG WINAPI ElementTraversal_Release(IElementTraversal *iface)
6626 HTMLElement *This = impl_from_IElementTraversal(iface);
6628 return IHTMLElement_Release(&This->IHTMLElement_iface);
6631 static HRESULT WINAPI ElementTraversal_GetTypeInfoCount(IElementTraversal *iface, UINT *pctinfo)
6633 HTMLElement *This = impl_from_IElementTraversal(iface);
6634 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6637 static HRESULT WINAPI ElementTraversal_GetTypeInfo(IElementTraversal *iface, UINT iTInfo,
6638 LCID lcid, ITypeInfo **ppTInfo)
6640 HTMLElement *This = impl_from_IElementTraversal(iface);
6641 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6644 static HRESULT WINAPI ElementTraversal_GetIDsOfNames(IElementTraversal *iface, REFIID riid,
6645 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6647 HTMLElement *This = impl_from_IElementTraversal(iface);
6648 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6649 lcid, rgDispId);
6652 static HRESULT WINAPI ElementTraversal_Invoke(IElementTraversal *iface, DISPID dispIdMember, REFIID riid,
6653 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6655 HTMLElement *This = impl_from_IElementTraversal(iface);
6656 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6657 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6660 static HRESULT WINAPI ElementTraversal_get_firstElementChild(IElementTraversal *iface, IHTMLElement **p)
6662 HTMLElement *This = impl_from_IElementTraversal(iface);
6663 nsIDOMElement *nselem = NULL;
6664 HTMLElement *elem;
6665 HRESULT hres;
6667 TRACE("(%p)->(%p)\n", This, p);
6669 if(!This->dom_element) {
6670 *p = NULL;
6671 return S_OK;
6674 nsIDOMElement_GetFirstElementChild(This->dom_element, &nselem);
6675 if(!nselem) {
6676 *p = NULL;
6677 return S_OK;
6680 hres = get_element(nselem, &elem);
6681 nsIDOMElement_Release(nselem);
6682 if(FAILED(hres))
6683 return hres;
6685 *p = &elem->IHTMLElement_iface;
6686 return S_OK;
6689 static HRESULT WINAPI ElementTraversal_get_lastElementChild(IElementTraversal *iface, IHTMLElement **p)
6691 HTMLElement *This = impl_from_IElementTraversal(iface);
6692 nsIDOMElement *nselem = NULL;
6693 HTMLElement *elem;
6694 HRESULT hres;
6696 TRACE("(%p)->(%p)\n", This, p);
6698 if(!This->dom_element) {
6699 *p = NULL;
6700 return S_OK;
6703 nsIDOMElement_GetLastElementChild(This->dom_element, &nselem);
6704 if(!nselem) {
6705 *p = NULL;
6706 return S_OK;
6709 hres = get_element(nselem, &elem);
6710 nsIDOMElement_Release(nselem);
6711 if(FAILED(hres))
6712 return hres;
6714 *p = &elem->IHTMLElement_iface;
6715 return S_OK;
6718 static HRESULT WINAPI ElementTraversal_get_previousElementSibling(IElementTraversal *iface, IHTMLElement **p)
6720 HTMLElement *This = impl_from_IElementTraversal(iface);
6721 nsIDOMElement *nselem = NULL;
6722 HTMLElement *elem;
6723 HRESULT hres;
6725 TRACE("(%p)->(%p)\n", This, p);
6727 if(!This->dom_element) {
6728 *p = NULL;
6729 return S_OK;
6732 nsIDOMElement_GetPreviousElementSibling(This->dom_element, &nselem);
6733 if(!nselem) {
6734 *p = NULL;
6735 return S_OK;
6738 hres = get_element(nselem, &elem);
6739 nsIDOMElement_Release(nselem);
6740 if(FAILED(hres))
6741 return hres;
6743 *p = &elem->IHTMLElement_iface;
6744 return S_OK;
6747 static HRESULT WINAPI ElementTraversal_get_nextElementSibling(IElementTraversal *iface, IHTMLElement **p)
6749 HTMLElement *This = impl_from_IElementTraversal(iface);
6750 nsIDOMElement *nselem = NULL;
6751 HTMLElement *elem;
6752 HRESULT hres;
6754 TRACE("(%p)->(%p)\n", This, p);
6756 if(!This->dom_element) {
6757 *p = NULL;
6758 return S_OK;
6761 nsIDOMElement_GetNextElementSibling(This->dom_element, &nselem);
6762 if(!nselem) {
6763 *p = NULL;
6764 return S_OK;
6767 hres = get_element(nselem, &elem);
6768 nsIDOMElement_Release(nselem);
6769 if(FAILED(hres))
6770 return hres;
6772 *p = &elem->IHTMLElement_iface;
6773 return S_OK;
6776 static HRESULT WINAPI ElementTraversal_get_childElementCount(IElementTraversal *iface, LONG *p)
6778 HTMLElement *This = impl_from_IElementTraversal(iface);
6779 UINT32 count = 0;
6781 TRACE("(%p)->(%p)\n", This, p);
6783 if(This->dom_element)
6784 nsIDOMElement_GetChildElementCount(This->dom_element, &count);
6786 *p = count;
6787 return S_OK;
6790 static const IElementTraversalVtbl ElementTraversalVtbl = {
6791 ElementTraversal_QueryInterface,
6792 ElementTraversal_AddRef,
6793 ElementTraversal_Release,
6794 ElementTraversal_GetTypeInfoCount,
6795 ElementTraversal_GetTypeInfo,
6796 ElementTraversal_GetIDsOfNames,
6797 ElementTraversal_Invoke,
6798 ElementTraversal_get_firstElementChild,
6799 ElementTraversal_get_lastElementChild,
6800 ElementTraversal_get_previousElementSibling,
6801 ElementTraversal_get_nextElementSibling,
6802 ElementTraversal_get_childElementCount
6805 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
6807 return CONTAINING_RECORD(iface, HTMLElement, node);
6810 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
6812 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6814 if(IsEqualGUID(&IID_IUnknown, riid)) {
6815 *ppv = &This->IHTMLElement_iface;
6816 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
6817 *ppv = &This->IHTMLElement_iface;
6818 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
6819 *ppv = &This->IHTMLElement_iface;
6820 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
6821 *ppv = &This->IHTMLElement2_iface;
6822 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
6823 *ppv = &This->IHTMLElement3_iface;
6824 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
6825 *ppv = &This->IHTMLElement4_iface;
6826 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
6827 *ppv = &This->IHTMLElement6_iface;
6828 }else if(IsEqualGUID(&IID_IHTMLElement7, riid)) {
6829 *ppv = &This->IHTMLElement7_iface;
6830 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
6831 *ppv = &This->IHTMLUniqueName_iface;
6832 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
6833 *ppv = &This->IElementSelector_iface;
6834 }else if(IsEqualGUID(&IID_IElementTraversal, riid)) {
6835 *ppv = &This->IElementTraversal_iface;
6836 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
6837 *ppv = &This->cp_container.IConnectionPointContainer_iface;
6838 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
6839 *ppv = &This->IProvideMultipleClassInfo_iface;
6840 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
6841 *ppv = &This->IProvideMultipleClassInfo_iface;
6842 }else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid)) {
6843 *ppv = &This->IProvideMultipleClassInfo_iface;
6844 }else if(IsEqualGUID(&IID_IWineHTMLElementPrivate, riid)) {
6845 *ppv = &This->IWineHTMLElementPrivate_iface;
6846 }else {
6847 return HTMLDOMNode_QI(&This->node, riid, ppv);
6850 IUnknown_AddRef((IUnknown*)*ppv);
6851 return S_OK;
6854 void HTMLElement_destructor(HTMLDOMNode *iface)
6856 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6858 ConnectionPointContainer_Destroy(&This->cp_container);
6860 if(This->style) {
6861 This->style->elem = NULL;
6862 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
6864 if(This->runtime_style) {
6865 This->runtime_style->elem = NULL;
6866 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
6868 if(This->attrs) {
6869 HTMLDOMAttribute *attr;
6871 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
6872 attr->elem = NULL;
6874 This->attrs->elem = NULL;
6875 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
6878 free(This->filter);
6881 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
6883 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6884 HTMLElement *new_elem;
6885 HRESULT hres;
6887 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
6888 if(FAILED(hres))
6889 return hres;
6891 if(This->filter) {
6892 new_elem->filter = wcsdup(This->filter);
6893 if(!new_elem->filter) {
6894 IHTMLElement_Release(&This->IHTMLElement_iface);
6895 return E_OUTOFMEMORY;
6899 *ret = &new_elem->node;
6900 return S_OK;
6903 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
6905 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6907 switch(eid) {
6908 case EVENTID_KEYDOWN: {
6909 nsIDOMKeyEvent *key_event;
6910 nsresult nsres;
6912 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
6913 if(NS_SUCCEEDED(nsres)) {
6914 UINT32 code = 0;
6916 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
6918 if(code == VK_F1 /* DOM_VK_F1 */) {
6919 DOMEvent *help_event;
6920 HRESULT hres;
6922 TRACE("F1 pressed\n");
6924 hres = create_document_event(This->node.doc, EVENTID_HELP, &help_event);
6925 if(SUCCEEDED(hres)) {
6926 dispatch_event(&This->node.event_target, help_event);
6927 IDOMEvent_Release(&help_event->IDOMEvent_iface);
6929 *prevent_default = TRUE;
6932 nsIDOMKeyEvent_Release(key_event);
6937 return S_OK;
6940 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
6942 const cpc_entry_t HTMLElement_cpc[] = {
6943 HTMLELEMENT_CPC,
6944 {NULL}
6947 static const NodeImplVtbl HTMLElementImplVtbl = {
6948 .clsid = &CLSID_HTMLUnknownElement,
6949 .qi = HTMLElement_QI,
6950 .destructor = HTMLElement_destructor,
6951 .cpc_entries = HTMLElement_cpc,
6952 .clone = HTMLElement_clone,
6953 .handle_event = HTMLElement_handle_event,
6954 .get_attr_col = HTMLElement_get_attr_col
6957 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
6959 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
6962 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
6963 DWORD grfdex, DISPID *pid)
6965 HTMLElement *This = impl_from_DispatchEx(dispex);
6967 if(This->node.vtbl->get_dispid)
6968 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
6970 return DISP_E_UNKNOWNNAME;
6973 static HRESULT HTMLElement_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
6975 HTMLElement *This = impl_from_DispatchEx(dispex);
6977 if(This->node.vtbl->get_name)
6978 return This->node.vtbl->get_name(&This->node, id, name);
6980 ERR("(%p): element has no get_name method\n", This);
6981 return DISP_E_MEMBERNOTFOUND;
6984 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
6985 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
6986 IServiceProvider *caller)
6988 HTMLElement *This = impl_from_DispatchEx(dispex);
6990 if(This->node.vtbl->invoke)
6991 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
6992 params, res, ei, caller);
6994 ERR("(%p): element has no invoke method\n", This);
6995 return E_NOTIMPL;
6998 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
7000 HTMLElement *This = impl_from_DispatchEx(dispex);
7001 nsIDOMMozNamedAttrMap *attrs;
7002 nsIDOMAttr *attr;
7003 nsAString nsstr;
7004 const PRUnichar *str;
7005 BSTR name;
7006 VARIANT value;
7007 unsigned i;
7008 UINT32 len;
7009 DISPID id;
7010 nsresult nsres;
7011 HRESULT hres;
7013 if(!This->dom_element)
7014 return S_FALSE;
7016 if(dispex_compat_mode(dispex) >= COMPAT_MODE_IE9)
7017 return S_OK;
7019 nsres = nsIDOMElement_GetAttributes(This->dom_element, &attrs);
7020 if(NS_FAILED(nsres))
7021 return E_FAIL;
7023 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
7024 if(NS_FAILED(nsres)) {
7025 nsIDOMMozNamedAttrMap_Release(attrs);
7026 return E_FAIL;
7029 nsAString_Init(&nsstr, NULL);
7030 for(i=0; i<len; i++) {
7031 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
7032 if(NS_FAILED(nsres))
7033 continue;
7035 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
7036 if(NS_FAILED(nsres)) {
7037 nsIDOMAttr_Release(attr);
7038 continue;
7041 nsAString_GetData(&nsstr, &str);
7042 name = SysAllocString(str);
7043 if(!name) {
7044 nsIDOMAttr_Release(attr);
7045 continue;
7048 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
7049 if(hres != DISP_E_UNKNOWNNAME) {
7050 nsIDOMAttr_Release(attr);
7051 SysFreeString(name);
7052 continue;
7055 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
7056 nsIDOMAttr_Release(attr);
7057 if(NS_FAILED(nsres)) {
7058 SysFreeString(name);
7059 continue;
7062 nsAString_GetData(&nsstr, &str);
7063 V_VT(&value) = VT_BSTR;
7064 if(*str) {
7065 V_BSTR(&value) = SysAllocString(str);
7066 if(!V_BSTR(&value)) {
7067 SysFreeString(name);
7068 continue;
7070 } else
7071 V_BSTR(&value) = NULL;
7073 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
7074 SysFreeString(name);
7075 VariantClear(&value);
7077 nsAString_Finish(&nsstr);
7079 nsIDOMMozNamedAttrMap_Release(attrs);
7080 return S_OK;
7083 static nsISupports *HTMLElement_get_gecko_target(DispatchEx *dispex)
7085 HTMLElement *This = impl_from_DispatchEx(dispex);
7086 return (nsISupports*)This->node.nsnode;
7089 static void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
7091 HTMLElement *This = impl_from_DispatchEx(dispex);
7092 ensure_doc_nsevent_handler(This->node.doc, This->node.nsnode, eid);
7095 static HRESULT HTMLElement_handle_event_default(DispatchEx *dispex, eventid_t eid, nsIDOMEvent *nsevent, BOOL *prevent_default)
7097 HTMLElement *This = impl_from_DispatchEx(dispex);
7099 if(!This->node.vtbl->handle_event)
7100 return S_OK;
7101 return This->node.vtbl->handle_event(&This->node, eid, nsevent, prevent_default);
7104 static EventTarget *HTMLElement_get_parent_event_target(DispatchEx *dispex)
7106 HTMLElement *This = impl_from_DispatchEx(dispex);
7107 HTMLDOMNode *node;
7108 nsIDOMNode *nsnode;
7109 nsresult nsres;
7110 HRESULT hres;
7112 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
7113 assert(nsres == NS_OK);
7114 if(!nsnode)
7115 return NULL;
7117 hres = get_node(nsnode, TRUE, &node);
7118 nsIDOMNode_Release(nsnode);
7119 if(FAILED(hres))
7120 return NULL;
7122 return &node->event_target;
7125 static ConnectionPointContainer *HTMLElement_get_cp_container(DispatchEx *dispex)
7127 HTMLElement *This = impl_from_DispatchEx(dispex);
7128 IConnectionPointContainer_AddRef(&This->cp_container.IConnectionPointContainer_iface);
7129 return &This->cp_container;
7132 static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
7134 HTMLElement *This = impl_from_DispatchEx(dispex);
7135 return default_set_current_event(This->node.doc->window, event);
7138 static HRESULT IHTMLElement6_hasAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7139 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7141 VARIANT args[2];
7142 HRESULT hres;
7143 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7145 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7146 return S_FALSE;
7148 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7149 case VT_EMPTY:
7150 case VT_BSTR:
7151 case VT_NULL:
7152 return S_FALSE;
7153 default:
7154 break;
7157 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7158 if(FAILED(hres))
7159 return hres;
7160 args[0] = dp->rgvarg[dp->cArgs - 2];
7162 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_HASATTRIBUTENS, &new_dp, res, ei, caller);
7163 VariantClear(&args[1]);
7164 return hres;
7167 static HRESULT IHTMLElement6_getAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7168 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7170 VARIANT args[2];
7171 HRESULT hres;
7172 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7174 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7175 return S_FALSE;
7177 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7178 case VT_EMPTY:
7179 case VT_BSTR:
7180 case VT_NULL:
7181 return S_FALSE;
7182 default:
7183 break;
7186 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7187 if(FAILED(hres))
7188 return hres;
7189 args[0] = dp->rgvarg[dp->cArgs - 2];
7191 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_GETATTRIBUTENS, &new_dp, res, ei, caller);
7192 VariantClear(&args[1]);
7193 return hres;
7196 static HRESULT IHTMLElement6_setAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7197 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7199 BOOL ns_conv = FALSE, val_conv = FALSE;
7200 VARIANT args[3];
7201 HRESULT hres;
7202 DISPPARAMS new_dp = { args, NULL, 3, 0 };
7204 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 3 || dp->cNamedArgs)
7205 return S_FALSE;
7207 if(dispex_compat_mode(dispex) < COMPAT_MODE_IE10)
7208 args[2] = dp->rgvarg[dp->cArgs - 1];
7209 else {
7210 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7211 case VT_EMPTY:
7212 case VT_BSTR:
7213 case VT_NULL:
7214 args[2] = dp->rgvarg[dp->cArgs - 1];
7215 break;
7216 default:
7217 hres = change_type(&args[2], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7218 if(FAILED(hres))
7219 return hres;
7220 ns_conv = TRUE;
7221 break;
7225 switch(V_VT(&dp->rgvarg[dp->cArgs - 3])) {
7226 case VT_EMPTY:
7227 case VT_BSTR:
7228 case VT_NULL:
7229 if(!ns_conv)
7230 return S_FALSE;
7231 args[0] = dp->rgvarg[dp->cArgs - 3];
7232 break;
7233 default:
7234 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 3], VT_BSTR, caller);
7235 if(FAILED(hres)) {
7236 if(ns_conv)
7237 VariantClear(&args[2]);
7238 return hres;
7240 val_conv = TRUE;
7241 break;
7244 args[1] = dp->rgvarg[dp->cArgs - 2];
7245 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_SETATTRIBUTENS, &new_dp, res, ei, caller);
7246 if(ns_conv) VariantClear(&args[2]);
7247 if(val_conv) VariantClear(&args[0]);
7248 return hres;
7251 static HRESULT IHTMLElement6_removeAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7252 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7254 VARIANT args[2];
7255 HRESULT hres;
7256 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7258 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7259 return S_FALSE;
7261 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7262 case VT_EMPTY:
7263 case VT_BSTR:
7264 case VT_NULL:
7265 return S_FALSE;
7266 default:
7267 break;
7270 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7271 if(FAILED(hres))
7272 return hres;
7273 args[0] = dp->rgvarg[dp->cArgs - 2];
7275 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, &new_dp, res, ei, caller);
7276 VariantClear(&args[1]);
7277 return hres;
7280 static HRESULT IHTMLElement6_setAttribute_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7281 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7283 VARIANT args[2];
7284 HRESULT hres;
7285 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7287 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7288 return S_FALSE;
7290 switch(V_VT(&dp->rgvarg[dp->cArgs - 2])) {
7291 case VT_EMPTY:
7292 case VT_BSTR:
7293 case VT_NULL:
7294 return S_FALSE;
7295 default:
7296 break;
7299 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 2], VT_BSTR, caller);
7300 if(FAILED(hres))
7301 return hres;
7302 args[1] = dp->rgvarg[dp->cArgs - 1];
7304 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, &new_dp, res, ei, caller);
7305 VariantClear(&args[0]);
7306 return hres;
7309 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
7311 static const dispex_hook_t elem6_ie9_hooks[] = {
7312 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
7313 {DISPID_UNKNOWN}
7315 static const dispex_hook_t elem6_ie10_hooks[] = {
7316 {DISPID_IHTMLELEMENT6_HASATTRIBUTENS, IHTMLElement6_hasAttributeNS_hook},
7317 {DISPID_IHTMLELEMENT6_GETATTRIBUTENS, IHTMLElement6_getAttributeNS_hook},
7318 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
7319 {DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, IHTMLElement6_removeAttributeNS_hook},
7320 {DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, IHTMLElement6_setAttribute_hook},
7321 {DISPID_UNKNOWN}
7323 static const dispex_hook_t elem2_ie11_hooks[] = {
7324 {DISPID_IHTMLELEMENT2_ATTACHEVENT, NULL},
7325 {DISPID_IHTMLELEMENT2_DETACHEVENT, NULL},
7326 {DISPID_IHTMLELEMENT2_DOSCROLL, NULL},
7327 {DISPID_IHTMLELEMENT2_READYSTATE, NULL},
7328 {DISPID_UNKNOWN}
7331 HTMLDOMNode_init_dispex_info(info, mode);
7333 dispex_info_add_interface(info, IHTMLElement2_tid, mode >= COMPAT_MODE_IE11 ? elem2_ie11_hooks : NULL);
7335 if(mode >= COMPAT_MODE_IE8)
7336 dispex_info_add_interface(info, IElementSelector_tid, NULL);
7338 if(mode >= COMPAT_MODE_IE9) {
7339 dispex_info_add_interface(info, IHTMLElement6_tid, mode >= COMPAT_MODE_IE10 ? elem6_ie10_hooks : elem6_ie9_hooks);
7340 dispex_info_add_interface(info, IElementTraversal_tid, NULL);
7343 if(mode >= COMPAT_MODE_IE10)
7345 dispex_info_add_interface(info, IHTMLElement7_tid, NULL);
7346 dispex_info_add_interface(info, IWineHTMLElementPrivate_tid, NULL);
7350 static const tid_t HTMLElement_iface_tids[] = {
7351 HTMLELEMENT_TIDS,
7355 const event_target_vtbl_t HTMLElement_event_target_vtbl = {
7357 .destructor = HTMLDOMNode_destructor,
7358 .traverse = HTMLDOMNode_traverse,
7359 .unlink = HTMLDOMNode_unlink,
7360 .get_dispid = HTMLElement_get_dispid,
7361 .get_name = HTMLElement_get_name,
7362 .invoke = HTMLElement_invoke,
7363 .populate_props = HTMLElement_populate_props
7365 .get_gecko_target = HTMLElement_get_gecko_target,
7366 .bind_event = HTMLElement_bind_event,
7367 .get_parent_event_target = HTMLElement_get_parent_event_target,
7368 .handle_event_default = HTMLElement_handle_event_default,
7369 .get_cp_container = HTMLElement_get_cp_container,
7370 .set_current_event = HTMLElement_set_current_event
7373 struct token_list {
7374 DispatchEx dispex;
7375 IWineDOMTokenList IWineDOMTokenList_iface;
7376 IHTMLElement *element;
7379 static inline struct token_list *impl_from_IWineDOMTokenList(IWineDOMTokenList *iface)
7381 return CONTAINING_RECORD(iface, struct token_list, IWineDOMTokenList_iface);
7384 static HRESULT WINAPI token_list_QueryInterface(IWineDOMTokenList *iface, REFIID riid, void **ppv)
7386 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7388 TRACE("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
7390 if(IsEqualGUID(&IID_IUnknown, riid)) {
7391 *ppv = &token_list->IWineDOMTokenList_iface;
7392 }else if(IsEqualGUID(&IID_IWineDOMTokenList, riid)) {
7393 *ppv = &token_list->IWineDOMTokenList_iface;
7394 }else if(dispex_query_interface(&token_list->dispex, riid, ppv)) {
7395 return *ppv ? S_OK : E_NOINTERFACE;
7396 }else {
7397 WARN("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
7398 *ppv = NULL;
7399 return E_NOINTERFACE;
7402 IUnknown_AddRef((IUnknown*)*ppv);
7403 return S_OK;
7406 static ULONG WINAPI token_list_AddRef(IWineDOMTokenList *iface)
7408 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7409 LONG ref = dispex_ref_incr(&token_list->dispex);
7411 TRACE("(%p) ref=%ld\n", token_list, ref);
7413 return ref;
7416 static ULONG WINAPI token_list_Release(IWineDOMTokenList *iface)
7418 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7419 LONG ref = dispex_ref_decr(&token_list->dispex);
7421 TRACE("(%p) ref=%ld\n", token_list, ref);
7423 return ref;
7426 static HRESULT WINAPI token_list_GetTypeInfoCount(IWineDOMTokenList *iface, UINT *pctinfo)
7428 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7429 FIXME("(%p)->(%p)\n", token_list, pctinfo);
7430 return E_NOTIMPL;
7433 static HRESULT WINAPI token_list_GetTypeInfo(IWineDOMTokenList *iface, UINT iTInfo,
7434 LCID lcid, ITypeInfo **ppTInfo)
7436 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7438 return IDispatchEx_GetTypeInfo(&token_list->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7441 static HRESULT WINAPI token_list_GetIDsOfNames(IWineDOMTokenList *iface, REFIID riid,
7442 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
7444 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7446 return IDispatchEx_GetIDsOfNames(&token_list->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7447 lcid, rgDispId);
7450 static HRESULT WINAPI token_list_Invoke(IWineDOMTokenList *iface, DISPID dispIdMember,
7451 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7452 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7454 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7456 return IDispatchEx_Invoke(&token_list->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
7457 pDispParams, pVarResult, pExcepInfo, puArgErr);
7460 static const WCHAR *find_token(const WCHAR *list, const WCHAR *token, unsigned int token_len)
7462 const WCHAR *ptr, *next;
7464 if (!list || !token)
7465 return NULL;
7467 ptr = list;
7468 while (*ptr)
7470 while (iswspace(*ptr))
7471 ++ptr;
7472 if (!*ptr)
7473 break;
7474 next = ptr + 1;
7475 while (*next && !iswspace(*next))
7476 ++next;
7478 if (next - ptr == token_len && !wcsncmp(ptr, token, token_len))
7479 return ptr;
7480 ptr = next;
7482 return NULL;
7485 static HRESULT token_list_add_remove(IWineDOMTokenList *iface, BSTR token, BOOL remove, VARIANT_BOOL *toggle_ret)
7487 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7488 unsigned int i, len, old_len, new_len;
7489 const WCHAR *old_pos;
7490 BSTR new, old;
7491 HRESULT hr;
7493 TRACE("token_list %p, token %s, remove %#x, toggle_ret %p.\n", token_list, debugstr_w(token), remove, toggle_ret);
7495 len = token ? lstrlenW(token) : 0;
7496 if (!len)
7498 WARN("Empty token.\n");
7499 return E_INVALIDARG;
7502 for (i = 0; i < len; ++i)
7503 if (iswspace(token[i]))
7505 WARN("Token has spaces.\n");
7506 return E_INVALIDARG;
7509 if (FAILED(hr = IHTMLElement_get_className(token_list->element, &old)))
7510 return hr;
7512 TRACE("old %s.\n", debugstr_w(old));
7514 old_pos = find_token(old, token, len);
7515 if (toggle_ret)
7517 remove = !!old_pos;
7518 *toggle_ret = !remove;
7520 else if (!!old_pos != remove)
7522 SysFreeString(old);
7523 return S_OK;
7526 old_len = old ? lstrlenW(old) : 0;
7527 if (remove)
7529 while (old_pos != old && iswspace(old_pos[-1]))
7531 --old_pos;
7532 ++len;
7534 while (iswspace(old_pos[len]))
7535 ++len;
7537 if (old_pos != old && old_pos[len])
7538 --len;
7540 new_len = old_len - len;
7542 else
7544 new_len = old_len + len + !!old_len;
7547 if (!(new = SysAllocStringLen(NULL, new_len)))
7549 ERR("No memory.\n");
7550 SysFreeString(old);
7551 return E_OUTOFMEMORY;
7554 if (remove)
7556 memcpy(new, old, sizeof(*new) * (old_pos - old));
7557 memcpy(new + (old_pos - old), old_pos + len, sizeof(*new) * (old_len - (old_pos - old) - len + 1));
7559 else
7561 memcpy(new, old, sizeof(*new) * old_len);
7562 if (old_len)
7563 new[old_len++]= L' ';
7564 memcpy(new + old_len, token, sizeof(*new) * len);
7565 new[old_len + len] = 0;
7568 SysFreeString(old);
7570 TRACE("new %s.\n", debugstr_w(new));
7572 hr = IHTMLElement_put_className(token_list->element, new);
7573 SysFreeString(new);
7574 return hr;
7577 static HRESULT WINAPI token_list_add(IWineDOMTokenList *iface, BSTR token)
7579 return token_list_add_remove(iface, token, FALSE, NULL);
7582 static HRESULT WINAPI token_list_remove(IWineDOMTokenList *iface, BSTR token)
7584 return token_list_add_remove(iface, token, TRUE, NULL);
7587 static HRESULT WINAPI token_list_toggle(IWineDOMTokenList *iface, BSTR token, VARIANT_BOOL *p)
7589 VARIANT_BOOL tmp;
7590 return token_list_add_remove(iface, token, FALSE, p ? p : &tmp);
7593 static HRESULT WINAPI token_list_contains(IWineDOMTokenList *iface, BSTR token, VARIANT_BOOL *p)
7595 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7596 unsigned len;
7597 HRESULT hres;
7598 BSTR list;
7600 TRACE("(%p)->(%s %p)\n", token_list, debugstr_w(token), p);
7602 if(!token || !*token)
7603 return E_INVALIDARG;
7605 for(len = 0; token[len]; len++)
7606 if(iswspace(token[len]))
7607 return E_INVALIDARG;
7609 hres = IHTMLElement_get_className(token_list->element, &list);
7610 if(FAILED(hres))
7611 return hres;
7613 *p = find_token(list, token, len) ? VARIANT_TRUE : VARIANT_FALSE;
7614 SysFreeString(list);
7615 return S_OK;
7618 static HRESULT WINAPI token_list_get_length(IWineDOMTokenList *iface, LONG *p)
7620 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7621 unsigned length = 0;
7622 const WCHAR *ptr;
7623 HRESULT hres;
7624 BSTR list;
7626 TRACE("(%p)->(%p)\n", token_list, p);
7628 hres = IHTMLElement_get_className(token_list->element, &list);
7629 if(FAILED(hres))
7630 return hres;
7632 if(!list) {
7633 *p = 0;
7634 return S_OK;
7637 ptr = list;
7638 do {
7639 while(iswspace(*ptr))
7640 ptr++;
7641 if(!*ptr)
7642 break;
7643 length++;
7644 ptr++;
7645 while(*ptr && !iswspace(*ptr))
7646 ptr++;
7647 } while(*ptr++);
7649 SysFreeString(list);
7650 *p = length;
7651 return S_OK;
7654 static HRESULT WINAPI token_list_item(IWineDOMTokenList *iface, LONG index, VARIANT *p)
7656 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7657 BSTR list, token = NULL;
7658 unsigned i = 0;
7659 HRESULT hres;
7660 WCHAR *ptr;
7662 TRACE("(%p)->(%ld %p)\n", token_list, index, p);
7664 hres = IHTMLElement_get_className(token_list->element, &list);
7665 if(FAILED(hres))
7666 return hres;
7668 if(!list) {
7669 V_VT(p) = VT_NULL;
7670 return S_OK;
7673 ptr = list;
7674 do {
7675 while(iswspace(*ptr))
7676 ptr++;
7677 if(!*ptr)
7678 break;
7679 if(i == index) {
7680 token = ptr++;
7681 while(*ptr && !iswspace(*ptr))
7682 ptr++;
7683 token = SysAllocStringLen(token, ptr - token);
7684 if(!token) {
7685 SysFreeString(list);
7686 return E_OUTOFMEMORY;
7688 break;
7690 i++;
7691 ptr++;
7692 while(*ptr && !iswspace(*ptr))
7693 ptr++;
7694 } while(*ptr++);
7696 SysFreeString(list);
7697 if(!token)
7698 V_VT(p) = VT_NULL;
7699 else {
7700 V_VT(p) = VT_BSTR;
7701 V_BSTR(p) = token;
7703 return S_OK;
7706 static HRESULT WINAPI token_list_toString(IWineDOMTokenList *iface, BSTR *String)
7708 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7710 TRACE("(%p)->(%p)\n", token_list, String);
7712 return IHTMLElement_get_className(token_list->element, String);
7715 static const IWineDOMTokenListVtbl WineDOMTokenListVtbl = {
7716 token_list_QueryInterface,
7717 token_list_AddRef,
7718 token_list_Release,
7719 token_list_GetTypeInfoCount,
7720 token_list_GetTypeInfo,
7721 token_list_GetIDsOfNames,
7722 token_list_Invoke,
7723 token_list_add,
7724 token_list_remove,
7725 token_list_toggle,
7726 token_list_contains,
7727 token_list_get_length,
7728 token_list_item,
7729 token_list_toString
7732 /* idx can be negative, so offset it halfway through custom dispids */
7733 #define DISPID_TOKENLIST_0 (MSHTML_DISPID_CUSTOM_MIN + (MSHTML_DISPID_CUSTOM_MAX+1 - MSHTML_DISPID_CUSTOM_MIN) / 2)
7735 static inline struct token_list *token_list_from_DispatchEx(DispatchEx *iface)
7737 return CONTAINING_RECORD(iface, struct token_list, dispex);
7740 static void token_list_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
7742 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7743 if(token_list->element)
7744 note_cc_edge((nsISupports*)token_list->element, "element", cb);
7747 static void token_list_unlink(DispatchEx *dispex)
7749 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7750 unlink_ref(&token_list->element);
7753 static void token_list_destructor(DispatchEx *dispex)
7755 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7756 free(token_list);
7759 static HRESULT token_list_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params,
7760 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7762 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7763 HRESULT hres;
7765 switch(flags) {
7766 case DISPATCH_PROPERTYGET:
7767 hres = IHTMLElement_get_className(token_list->element, &V_BSTR(res));
7768 if(FAILED(hres))
7769 return hres;
7770 V_VT(res) = VT_BSTR;
7771 break;
7772 default:
7773 FIXME("Unimplemented flags %x\n", flags);
7774 return E_NOTIMPL;
7777 return S_OK;
7780 static HRESULT token_list_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
7782 WCHAR *end;
7783 LONG idx;
7784 ULONG i;
7786 idx = wcstol(name, &end, 10);
7787 if(*end)
7788 return DISP_E_UNKNOWNNAME;
7790 i = idx + DISPID_TOKENLIST_0 - MSHTML_DISPID_CUSTOM_MIN;
7791 if(i > MSHTML_CUSTOM_DISPID_CNT)
7792 return DISP_E_UNKNOWNNAME;
7794 *dispid = MSHTML_DISPID_CUSTOM_MIN + i;
7795 return S_OK;
7798 static HRESULT token_list_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
7800 LONG idx = id - MSHTML_DISPID_CUSTOM_MIN;
7801 WCHAR buf[12];
7802 UINT len;
7804 len = swprintf(buf, ARRAY_SIZE(buf), L"%d", idx);
7805 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
7808 static HRESULT token_list_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
7809 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7811 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7813 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", token_list, id, lcid, flags, params, res, ei, caller);
7815 switch(flags) {
7816 case DISPATCH_PROPERTYGET:
7817 return token_list_item(&token_list->IWineDOMTokenList_iface, id - DISPID_TOKENLIST_0, res);
7818 case DISPATCH_PROPERTYPUTREF|DISPATCH_PROPERTYPUT:
7819 case DISPATCH_PROPERTYPUTREF:
7820 case DISPATCH_PROPERTYPUT:
7821 /* Ignored by IE */
7822 return S_OK;
7823 case DISPATCH_METHOD|DISPATCH_PROPERTYGET:
7824 case DISPATCH_METHOD:
7825 return MSHTML_E_NOT_FUNC;
7826 default:
7827 break;
7830 return MSHTML_E_INVALID_ACTION;
7833 static const dispex_static_data_vtbl_t token_list_dispex_vtbl = {
7834 .destructor = token_list_destructor,
7835 .traverse = token_list_traverse,
7836 .unlink = token_list_unlink,
7837 .value = token_list_value,
7838 .get_dispid = token_list_get_dispid,
7839 .get_name = token_list_get_name,
7840 .invoke = token_list_invoke
7843 static const tid_t token_list_iface_tids[] = {
7844 IWineDOMTokenList_tid,
7847 static dispex_static_data_t token_list_dispex = {
7848 "DOMTokenList",
7849 &token_list_dispex_vtbl,
7850 IWineDOMTokenList_tid,
7851 token_list_iface_tids
7854 static HRESULT create_token_list(compat_mode_t compat_mode, IHTMLElement *element, IWineDOMTokenList **ret)
7856 struct token_list *obj;
7858 obj = calloc(1, sizeof(*obj));
7859 if(!obj)
7861 ERR("No memory.\n");
7862 return E_OUTOFMEMORY;
7865 obj->IWineDOMTokenList_iface.lpVtbl = &WineDOMTokenListVtbl;
7866 init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineDOMTokenList_iface, &token_list_dispex, compat_mode);
7867 IHTMLElement_AddRef(element);
7868 obj->element = element;
7870 *ret = &obj->IWineDOMTokenList_iface;
7871 return S_OK;
7874 static inline HTMLElement *impl_from_IWineHTMLElementPrivateVtbl(IWineHTMLElementPrivate *iface)
7876 return CONTAINING_RECORD(iface, HTMLElement, IWineHTMLElementPrivate_iface);
7879 static HRESULT WINAPI htmlelement_private_QueryInterface(IWineHTMLElementPrivate *iface,
7880 REFIID riid, void **ppv)
7882 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7884 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
7887 static ULONG WINAPI htmlelement_private_AddRef(IWineHTMLElementPrivate *iface)
7889 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7891 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
7894 static ULONG WINAPI htmlelement_private_Release(IWineHTMLElementPrivate *iface)
7896 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7898 return IHTMLElement_Release(&This->IHTMLElement_iface);
7901 static HRESULT WINAPI htmlelement_private_GetTypeInfoCount(IWineHTMLElementPrivate *iface, UINT *pctinfo)
7903 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7905 return HTMLElement_GetTypeInfoCount(&This->IHTMLElement_iface, pctinfo);
7908 static HRESULT WINAPI htmlelement_private_GetTypeInfo(IWineHTMLElementPrivate *iface, UINT iTInfo,
7909 LCID lcid, ITypeInfo **ppTInfo)
7911 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7913 return HTMLElement_GetTypeInfo(&This->IHTMLElement_iface, iTInfo, lcid, ppTInfo);
7916 static HRESULT WINAPI htmlelement_private_GetIDsOfNames(IWineHTMLElementPrivate *iface, REFIID riid,
7917 LPOLESTR *rgszNames, UINT cNames,
7918 LCID lcid, DISPID *rgDispId)
7920 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7922 return HTMLElement_GetIDsOfNames(&This->IHTMLElement_iface, riid, rgszNames, cNames, lcid,
7923 rgDispId);
7926 static HRESULT WINAPI htmlelement_private_Invoke(IWineHTMLElementPrivate *iface, DISPID dispIdMember,
7927 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7928 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7930 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7932 return HTMLElement_Invoke(&This->IHTMLElement_iface, dispIdMember, riid, lcid, wFlags,
7933 pDispParams, pVarResult, pExcepInfo, puArgErr);
7936 static HRESULT WINAPI htmlelement_private_get_classList(IWineHTMLElementPrivate *iface, IDispatch **class_list)
7938 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7940 TRACE("iface %p, class_list %p.\n", iface, class_list);
7942 return create_token_list(dispex_compat_mode(&This->node.event_target.dispex), &This->IHTMLElement_iface,
7943 (IWineDOMTokenList **)class_list);
7946 static const IWineHTMLElementPrivateVtbl WineHTMLElementPrivateVtbl = {
7947 htmlelement_private_QueryInterface,
7948 htmlelement_private_AddRef,
7949 htmlelement_private_Release,
7950 htmlelement_private_GetTypeInfoCount,
7951 htmlelement_private_GetTypeInfo,
7952 htmlelement_private_GetIDsOfNames,
7953 htmlelement_private_Invoke,
7954 htmlelement_private_get_classList,
7957 static dispex_static_data_t HTMLElement_dispex = {
7958 "HTMLElement",
7959 &HTMLElement_event_target_vtbl.dispex_vtbl,
7960 DispHTMLUnknownElement_tid,
7961 HTMLElement_iface_tids,
7962 HTMLElement_init_dispex_info
7965 static dispex_static_data_t HTMLUnknownElement_dispex = {
7966 "HTMLUnknownElement",
7967 &HTMLElement_event_target_vtbl.dispex_vtbl,
7968 DispHTMLUnknownElement_tid,
7969 HTMLElement_iface_tids,
7970 HTMLElement_init_dispex_info
7973 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMElement *nselem, dispex_static_data_t *dispex_data)
7975 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
7976 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
7977 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
7978 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
7979 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
7980 This->IHTMLElement7_iface.lpVtbl = &HTMLElement7Vtbl;
7981 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
7982 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
7983 This->IElementTraversal_iface.lpVtbl = &ElementTraversalVtbl;
7984 This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
7985 This->IWineHTMLElementPrivate_iface.lpVtbl = &WineHTMLElementPrivateVtbl;
7987 if(nselem) {
7988 nsIDOMHTMLElement *html_element;
7989 nsresult nsres;
7991 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data ? dispex_data : &HTMLUnknownElement_dispex);
7993 /* No AddRef, share reference with HTMLDOMNode */
7994 assert((nsIDOMNode*)nselem == This->node.nsnode);
7995 This->dom_element = nselem;
7997 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)&html_element);
7998 if(NS_SUCCEEDED(nsres)) {
7999 This->html_element = html_element;
8000 /* share reference with HTMLDOMNode */
8001 assert((nsIDOMNode*)html_element == This->node.nsnode);
8002 nsIDOMHTMLElement_Release(html_element);
8006 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
8009 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
8011 nsIDOMElement *nselem;
8012 nsAString tag_name_str;
8013 const PRUnichar *tag_name;
8014 const tag_desc_t *tag;
8015 HTMLElement *elem;
8016 nsresult nsres;
8017 HRESULT hres;
8019 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
8020 if(NS_FAILED(nsres)) {
8021 ERR("no nsIDOMElement iface\n");
8022 return E_FAIL;
8025 nsAString_Init(&tag_name_str, NULL);
8026 nsIDOMElement_GetTagName(nselem, &tag_name_str);
8028 nsAString_GetData(&tag_name_str, &tag_name);
8030 tag = get_tag_desc(tag_name);
8031 if(tag) {
8032 hres = tag->constructor(doc, nselem, &elem);
8033 }else {
8034 nsIDOMSVGElement *svg_element;
8036 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMSVGElement, (void**)&svg_element);
8037 if(NS_SUCCEEDED(nsres)) {
8038 hres = create_svg_element(doc, svg_element, tag_name, &elem);
8039 nsIDOMSVGElement_Release(svg_element);
8040 }else if(use_generic) {
8041 hres = HTMLGenericElement_Create(doc, nselem, &elem);
8042 }else {
8043 elem = calloc(1, sizeof(HTMLElement));
8044 if(elem) {
8045 elem->node.vtbl = &HTMLElementImplVtbl;
8046 HTMLElement_Init(elem, doc, nselem, &HTMLUnknownElement_dispex);
8047 hres = S_OK;
8048 }else {
8049 hres = E_OUTOFMEMORY;
8054 TRACE("%s ret %p\n", debugstr_w(tag_name), elem);
8056 nsIDOMElement_Release(nselem);
8057 nsAString_Finish(&tag_name_str);
8058 if(FAILED(hres))
8059 return hres;
8061 *ret = elem;
8062 return S_OK;
8065 static HRESULT HTMLElement_Ctor(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
8067 HTMLElement *ret;
8069 ret = calloc(1, sizeof(*ret));
8070 if(!ret)
8071 return E_OUTOFMEMORY;
8073 ret->node.vtbl = &HTMLElementImplVtbl;
8074 HTMLElement_Init(ret, doc, nselem, &HTMLElement_dispex);
8076 *elem = ret;
8077 return S_OK;
8080 HRESULT get_element(nsIDOMElement *nselem, HTMLElement **ret)
8082 HTMLDOMNode *node;
8083 HRESULT hres;
8085 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
8086 if(FAILED(hres))
8087 return hres;
8089 *ret = impl_from_HTMLDOMNode(node);
8090 return S_OK;
8093 /* interface IHTMLFiltersCollection */
8094 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
8096 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8098 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
8100 if(IsEqualGUID(&IID_IUnknown, riid)) {
8101 *ppv = &This->IHTMLFiltersCollection_iface;
8102 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
8103 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
8104 *ppv = &This->IHTMLFiltersCollection_iface;
8105 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
8106 return *ppv ? S_OK : E_NOINTERFACE;
8107 }else {
8108 *ppv = NULL;
8109 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8110 return E_NOINTERFACE;
8113 IUnknown_AddRef((IUnknown*)*ppv);
8114 return S_OK;
8117 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
8119 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8120 LONG ref = dispex_ref_incr(&This->dispex);
8122 TRACE("(%p) ref=%ld\n", This, ref);
8124 return ref;
8127 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
8129 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8130 LONG ref = dispex_ref_decr(&This->dispex);
8132 TRACE("(%p) ref=%ld\n", This, ref);
8134 return ref;
8137 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
8139 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8140 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8143 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
8144 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
8146 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8147 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8150 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
8151 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
8152 LCID lcid, DISPID *rgDispId)
8154 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8155 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8156 lcid, rgDispId);
8159 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
8160 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
8161 EXCEPINFO *pExcepInfo, UINT *puArgErr)
8163 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8164 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8165 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8168 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
8170 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8172 if(!p)
8173 return E_POINTER;
8175 FIXME("(%p)->(%p) Always returning 0\n", This, p);
8176 *p = 0;
8178 return S_OK;
8181 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
8183 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8184 FIXME("(%p)->(%p)\n", This, p);
8185 return E_NOTIMPL;
8188 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
8190 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8191 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
8192 return E_NOTIMPL;
8195 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
8196 HTMLFiltersCollection_QueryInterface,
8197 HTMLFiltersCollection_AddRef,
8198 HTMLFiltersCollection_Release,
8199 HTMLFiltersCollection_GetTypeInfoCount,
8200 HTMLFiltersCollection_GetTypeInfo,
8201 HTMLFiltersCollection_GetIDsOfNames,
8202 HTMLFiltersCollection_Invoke,
8203 HTMLFiltersCollection_get_length,
8204 HTMLFiltersCollection_get__newEnum,
8205 HTMLFiltersCollection_item
8208 static inline HTMLFiltersCollection *HTMLFiltersCollection_from_DispatchEx(DispatchEx *iface)
8210 return CONTAINING_RECORD(iface, HTMLFiltersCollection, dispex);
8213 static void HTMLFiltersCollection_destructor(DispatchEx *dispex)
8215 HTMLFiltersCollection *This = HTMLFiltersCollection_from_DispatchEx(dispex);
8216 free(This);
8219 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
8221 WCHAR *ptr;
8222 int idx = 0;
8224 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
8225 idx = idx*10 + (*ptr-'0');
8226 if(*ptr)
8227 return DISP_E_UNKNOWNNAME;
8229 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
8230 TRACE("ret %lx\n", *dispid);
8231 return S_OK;
8234 static HRESULT HTMLFiltersCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
8236 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
8237 WCHAR buf[11];
8238 UINT len;
8240 len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx);
8241 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
8244 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
8245 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
8247 TRACE("(%p)->(%lx %lx %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
8249 V_VT(res) = VT_DISPATCH;
8250 V_DISPATCH(res) = NULL;
8252 FIXME("always returning NULL\n");
8254 return S_OK;
8257 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
8258 .destructor = HTMLFiltersCollection_destructor,
8259 .get_dispid = HTMLFiltersCollection_get_dispid,
8260 .get_name = HTMLFiltersCollection_get_name,
8261 .invoke = HTMLFiltersCollection_invoke,
8264 static const tid_t HTMLFiltersCollection_iface_tids[] = {
8265 IHTMLFiltersCollection_tid,
8268 static dispex_static_data_t HTMLFiltersCollection_dispex = {
8269 "FiltersCollection",
8270 &HTMLFiltersCollection_dispex_vtbl,
8271 IHTMLFiltersCollection_tid,
8272 HTMLFiltersCollection_iface_tids
8275 static HRESULT create_filters_collection(compat_mode_t compat_mode, IHTMLFiltersCollection **ret)
8277 HTMLFiltersCollection *collection;
8279 if(!(collection = malloc(sizeof(HTMLFiltersCollection))))
8280 return E_OUTOFMEMORY;
8282 collection->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
8284 init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLFiltersCollection_iface,
8285 &HTMLFiltersCollection_dispex, min(compat_mode, COMPAT_MODE_IE8));
8287 *ret = &collection->IHTMLFiltersCollection_iface;
8288 return S_OK;
8291 static HRESULT get_attr_dispid_by_relative_idx(HTMLAttributeCollection *This, LONG *idx, DISPID start, DISPID *dispid)
8293 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
8294 DISPID id = start;
8295 LONG len = -1;
8296 HRESULT hres;
8298 FIXME("filter non-enumerable attributes out\n");
8300 while(1) {
8301 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
8302 if(FAILED(hres))
8303 return hres;
8304 else if(hres == S_FALSE)
8305 break;
8307 len++;
8308 if(len == *idx)
8309 break;
8312 if(dispid) {
8313 *dispid = id;
8314 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
8317 *idx = len+1;
8318 return S_OK;
8321 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
8323 return get_attr_dispid_by_relative_idx(This, idx, DISPID_STARTENUM, dispid);
8326 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
8328 HRESULT hres;
8330 if(name[0]>='0' && name[0]<='9') {
8331 WCHAR *end_ptr;
8332 LONG idx;
8334 idx = wcstoul(name, &end_ptr, 10);
8335 if(!*end_ptr) {
8336 hres = get_attr_dispid_by_idx(This, &idx, id);
8337 if(SUCCEEDED(hres))
8338 return hres;
8342 if(!This->elem) {
8343 WARN("NULL elem\n");
8344 return E_UNEXPECTED;
8347 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
8348 name, fdexNameCaseInsensitive, id);
8349 return hres;
8352 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
8354 HTMLDOMAttribute *iter;
8355 LONG pos = 0;
8356 HRESULT hres;
8358 *attr = NULL;
8359 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
8360 if(iter->dispid == id) {
8361 *attr = iter;
8362 break;
8364 pos++;
8367 if(!*attr) {
8368 if(!This->elem) {
8369 WARN("NULL elem\n");
8370 return E_UNEXPECTED;
8373 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, dispex_compat_mode(&This->elem->node.event_target.dispex), attr);
8374 if(FAILED(hres))
8375 return hres;
8378 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
8379 if(list_pos)
8380 *list_pos = pos;
8381 return S_OK;
8384 typedef struct {
8385 IEnumVARIANT IEnumVARIANT_iface;
8387 LONG ref;
8389 ULONG iter;
8390 DISPID iter_dispid;
8391 HTMLAttributeCollection *col;
8392 } HTMLAttributeCollectionEnum;
8394 static inline HTMLAttributeCollectionEnum *HTMLAttributeCollectionEnum_from_IEnumVARIANT(IEnumVARIANT *iface)
8396 return CONTAINING_RECORD(iface, HTMLAttributeCollectionEnum, IEnumVARIANT_iface);
8399 static HRESULT WINAPI HTMLAttributeCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
8401 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8403 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8405 if(IsEqualGUID(riid, &IID_IUnknown)) {
8406 *ppv = &This->IEnumVARIANT_iface;
8407 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
8408 *ppv = &This->IEnumVARIANT_iface;
8409 }else {
8410 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8411 *ppv = NULL;
8412 return E_NOINTERFACE;
8415 IUnknown_AddRef((IUnknown*)*ppv);
8416 return S_OK;
8419 static ULONG WINAPI HTMLAttributeCollectionEnum_AddRef(IEnumVARIANT *iface)
8421 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8422 LONG ref = InterlockedIncrement(&This->ref);
8424 TRACE("(%p) ref=%ld\n", This, ref);
8426 return ref;
8429 static ULONG WINAPI HTMLAttributeCollectionEnum_Release(IEnumVARIANT *iface)
8431 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8432 LONG ref = InterlockedDecrement(&This->ref);
8434 TRACE("(%p) ref=%ld\n", This, ref);
8436 if(!ref) {
8437 IHTMLAttributeCollection_Release(&This->col->IHTMLAttributeCollection_iface);
8438 free(This);
8441 return ref;
8444 static HRESULT WINAPI HTMLAttributeCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
8446 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8447 DISPID tmp, dispid = This->iter_dispid;
8448 HTMLDOMAttribute *attr;
8449 LONG rel_index = 0;
8450 HRESULT hres;
8451 ULONG i;
8453 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
8455 for(i = 0; i < celt; i++) {
8456 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, dispid, &tmp);
8457 if(SUCCEEDED(hres)) {
8458 dispid = tmp;
8459 hres = get_domattr(This->col, dispid, NULL, &attr);
8461 else if(hres == DISP_E_UNKNOWNNAME)
8462 break;
8464 if(FAILED(hres)) {
8465 while(i--)
8466 VariantClear(&rgVar[i]);
8467 return hres;
8470 V_VT(&rgVar[i]) = VT_DISPATCH;
8471 V_DISPATCH(&rgVar[i]) = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
8474 This->iter += i;
8475 This->iter_dispid = dispid;
8476 if(pCeltFetched)
8477 *pCeltFetched = i;
8478 return i == celt ? S_OK : S_FALSE;
8481 static HRESULT WINAPI HTMLAttributeCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
8483 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8484 LONG remaining, rel_index;
8485 DISPID dispid;
8486 HRESULT hres;
8488 TRACE("(%p)->(%lu)\n", This, celt);
8490 if(!celt)
8491 return S_OK;
8493 rel_index = -1;
8494 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, NULL);
8495 if(FAILED(hres))
8496 return hres;
8497 remaining = min(celt, rel_index);
8499 if(remaining) {
8500 rel_index = remaining - 1;
8501 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, &dispid);
8502 if(FAILED(hres))
8503 return hres;
8504 This->iter += remaining;
8505 This->iter_dispid = dispid;
8507 return celt > remaining ? S_FALSE : S_OK;
8510 static HRESULT WINAPI HTMLAttributeCollectionEnum_Reset(IEnumVARIANT *iface)
8512 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8514 TRACE("(%p)->()\n", This);
8516 This->iter = 0;
8517 This->iter_dispid = DISPID_STARTENUM;
8518 return S_OK;
8521 static HRESULT WINAPI HTMLAttributeCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
8523 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8524 FIXME("(%p)->(%p)\n", This, ppEnum);
8525 return E_NOTIMPL;
8528 static const IEnumVARIANTVtbl HTMLAttributeCollectionEnumVtbl = {
8529 HTMLAttributeCollectionEnum_QueryInterface,
8530 HTMLAttributeCollectionEnum_AddRef,
8531 HTMLAttributeCollectionEnum_Release,
8532 HTMLAttributeCollectionEnum_Next,
8533 HTMLAttributeCollectionEnum_Skip,
8534 HTMLAttributeCollectionEnum_Reset,
8535 HTMLAttributeCollectionEnum_Clone
8538 /* interface IHTMLAttributeCollection */
8539 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
8541 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
8544 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
8546 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8548 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8550 if(IsEqualGUID(&IID_IUnknown, riid)) {
8551 *ppv = &This->IHTMLAttributeCollection_iface;
8552 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
8553 *ppv = &This->IHTMLAttributeCollection_iface;
8554 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
8555 *ppv = &This->IHTMLAttributeCollection2_iface;
8556 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
8557 *ppv = &This->IHTMLAttributeCollection3_iface;
8558 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
8559 return *ppv ? S_OK : E_NOINTERFACE;
8560 }else {
8561 *ppv = NULL;
8562 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8563 return E_NOINTERFACE;
8566 IUnknown_AddRef((IUnknown*)*ppv);
8567 return S_OK;
8570 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
8572 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8573 LONG ref = dispex_ref_incr(&This->dispex);
8575 TRACE("(%p) ref=%ld\n", This, ref);
8577 return ref;
8580 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
8582 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8583 LONG ref = dispex_ref_decr(&This->dispex);
8585 TRACE("(%p) ref=%ld\n", This, ref);
8587 return ref;
8590 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
8592 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8593 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8596 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
8597 LCID lcid, ITypeInfo **ppTInfo)
8599 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8600 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8603 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
8604 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8606 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8607 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8608 lcid, rgDispId);
8611 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
8612 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8613 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8615 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8616 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8617 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8620 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
8622 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8623 HRESULT hres;
8625 TRACE("(%p)->(%p)\n", This, p);
8627 *p = -1;
8628 hres = get_attr_dispid_by_idx(This, p, NULL);
8629 return hres;
8632 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
8634 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8635 HTMLAttributeCollectionEnum *ret;
8637 TRACE("(%p)->(%p)\n", This, p);
8639 ret = malloc(sizeof(*ret));
8640 if(!ret)
8641 return E_OUTOFMEMORY;
8643 ret->IEnumVARIANT_iface.lpVtbl = &HTMLAttributeCollectionEnumVtbl;
8644 ret->ref = 1;
8645 ret->iter = 0;
8646 ret->iter_dispid = DISPID_STARTENUM;
8648 HTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8649 ret->col = This;
8651 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
8652 return S_OK;
8655 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
8657 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8658 HTMLDOMAttribute *attr;
8659 DISPID id;
8660 HRESULT hres;
8662 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
8664 switch(V_VT(name)) {
8665 case VT_I4:
8666 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
8667 break;
8668 case VT_BSTR:
8669 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
8670 break;
8671 default:
8672 FIXME("unsupported name %s\n", debugstr_variant(name));
8673 hres = E_NOTIMPL;
8675 if(hres == DISP_E_UNKNOWNNAME)
8676 return E_INVALIDARG;
8677 if(FAILED(hres))
8678 return hres;
8680 hres = get_domattr(This, id, NULL, &attr);
8681 if(FAILED(hres))
8682 return hres;
8684 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
8685 return S_OK;
8688 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
8689 HTMLAttributeCollection_QueryInterface,
8690 HTMLAttributeCollection_AddRef,
8691 HTMLAttributeCollection_Release,
8692 HTMLAttributeCollection_GetTypeInfoCount,
8693 HTMLAttributeCollection_GetTypeInfo,
8694 HTMLAttributeCollection_GetIDsOfNames,
8695 HTMLAttributeCollection_Invoke,
8696 HTMLAttributeCollection_get_length,
8697 HTMLAttributeCollection__newEnum,
8698 HTMLAttributeCollection_item
8701 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
8703 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
8706 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
8708 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8709 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
8712 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
8714 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8715 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8718 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
8720 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8721 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
8724 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
8726 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8727 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8730 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
8731 LCID lcid, ITypeInfo **ppTInfo)
8733 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8734 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8737 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
8738 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8740 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8741 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8742 lcid, rgDispId);
8745 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
8746 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8747 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8749 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8750 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8751 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8754 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
8755 IHTMLDOMAttribute **newretNode)
8757 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8758 HTMLDOMAttribute *attr;
8759 DISPID id;
8760 HRESULT hres;
8762 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
8764 hres = get_attr_dispid_by_name(This, bstrName, &id);
8765 if(hres == DISP_E_UNKNOWNNAME) {
8766 *newretNode = NULL;
8767 return S_OK;
8768 } else if(FAILED(hres)) {
8769 return hres;
8772 hres = get_domattr(This, id, NULL, &attr);
8773 if(FAILED(hres))
8774 return hres;
8776 *newretNode = &attr->IHTMLDOMAttribute_iface;
8777 return S_OK;
8780 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
8781 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
8783 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8784 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
8785 return E_NOTIMPL;
8788 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
8789 BSTR bstrName, IHTMLDOMAttribute **newretNode)
8791 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8792 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
8793 return E_NOTIMPL;
8796 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
8797 HTMLAttributeCollection2_QueryInterface,
8798 HTMLAttributeCollection2_AddRef,
8799 HTMLAttributeCollection2_Release,
8800 HTMLAttributeCollection2_GetTypeInfoCount,
8801 HTMLAttributeCollection2_GetTypeInfo,
8802 HTMLAttributeCollection2_GetIDsOfNames,
8803 HTMLAttributeCollection2_Invoke,
8804 HTMLAttributeCollection2_getNamedItem,
8805 HTMLAttributeCollection2_setNamedItem,
8806 HTMLAttributeCollection2_removeNamedItem
8809 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
8811 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
8814 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
8816 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8817 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
8820 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
8822 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8823 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8826 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
8828 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8829 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
8832 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
8834 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8835 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8838 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
8839 LCID lcid, ITypeInfo **ppTInfo)
8841 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8842 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8845 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
8846 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8848 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8849 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8850 lcid, rgDispId);
8853 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
8854 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8855 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8857 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8858 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8859 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8862 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
8863 IHTMLDOMAttribute **ppNodeOut)
8865 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8866 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
8869 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
8870 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
8872 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8873 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
8874 return E_NOTIMPL;
8877 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
8878 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
8880 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8881 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
8882 return E_NOTIMPL;
8885 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
8887 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8888 HTMLDOMAttribute *attr;
8889 DISPID id;
8890 HRESULT hres;
8892 TRACE("(%p)->(%ld %p)\n", This, index, ppNodeOut);
8894 hres = get_attr_dispid_by_idx(This, &index, &id);
8895 if(hres == DISP_E_UNKNOWNNAME)
8896 return E_INVALIDARG;
8897 if(FAILED(hres))
8898 return hres;
8900 hres = get_domattr(This, id, NULL, &attr);
8901 if(FAILED(hres))
8902 return hres;
8904 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
8905 return S_OK;
8908 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
8910 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8911 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
8914 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
8915 HTMLAttributeCollection3_QueryInterface,
8916 HTMLAttributeCollection3_AddRef,
8917 HTMLAttributeCollection3_Release,
8918 HTMLAttributeCollection3_GetTypeInfoCount,
8919 HTMLAttributeCollection3_GetTypeInfo,
8920 HTMLAttributeCollection3_GetIDsOfNames,
8921 HTMLAttributeCollection3_Invoke,
8922 HTMLAttributeCollection3_getNamedItem,
8923 HTMLAttributeCollection3_setNamedItem,
8924 HTMLAttributeCollection3_removeNamedItem,
8925 HTMLAttributeCollection3_item,
8926 HTMLAttributeCollection3_get_length
8929 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
8931 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
8934 static void HTMLAttributeCollection_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
8936 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8937 HTMLDOMAttribute *attr;
8939 LIST_FOR_EACH_ENTRY(attr, &This->attrs, HTMLDOMAttribute, entry)
8940 note_cc_edge((nsISupports*)&attr->IHTMLDOMAttribute_iface, "attr", cb);
8943 static void HTMLAttributeCollection_unlink(DispatchEx *dispex)
8945 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8946 while(!list_empty(&This->attrs)) {
8947 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
8949 list_remove(&attr->entry);
8950 attr->elem = NULL;
8951 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8955 static void HTMLAttributeCollection_destructor(DispatchEx *dispex)
8957 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8958 free(This);
8961 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
8963 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8964 HTMLDOMAttribute *attr;
8965 LONG pos;
8966 HRESULT hres;
8968 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(name), flags, dispid);
8970 hres = get_attr_dispid_by_name(This, name, dispid);
8971 if(FAILED(hres))
8972 return hres;
8974 hres = get_domattr(This, *dispid, &pos, &attr);
8975 if(FAILED(hres))
8976 return hres;
8977 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8979 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
8980 return S_OK;
8983 static HRESULT HTMLAttributeCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
8985 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8987 FIXME("(%p)->(%lx %p)\n", This, id, name);
8989 return E_NOTIMPL;
8992 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
8993 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
8995 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8997 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
8999 switch(flags) {
9000 case DISPATCH_PROPERTYGET: {
9001 HTMLDOMAttribute *iter;
9002 DWORD pos;
9004 pos = id-MSHTML_DISPID_CUSTOM_MIN;
9006 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
9007 if(!pos) {
9008 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
9009 V_VT(res) = VT_DISPATCH;
9010 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
9011 return S_OK;
9013 pos--;
9016 WARN("invalid arg\n");
9017 return E_INVALIDARG;
9020 default:
9021 FIXME("unimplemented flags %x\n", flags);
9022 return E_NOTIMPL;
9026 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
9027 .destructor = HTMLAttributeCollection_destructor,
9028 .traverse = HTMLAttributeCollection_traverse,
9029 .unlink = HTMLAttributeCollection_unlink,
9030 .get_dispid = HTMLAttributeCollection_get_dispid,
9031 .get_name = HTMLAttributeCollection_get_name,
9032 .invoke = HTMLAttributeCollection_invoke,
9035 static const tid_t HTMLAttributeCollection_iface_tids[] = {
9036 IHTMLAttributeCollection_tid,
9037 IHTMLAttributeCollection2_tid,
9038 IHTMLAttributeCollection3_tid,
9042 static dispex_static_data_t HTMLAttributeCollection_dispex = {
9043 "NamedNodeMap",
9044 &HTMLAttributeCollection_dispex_vtbl,
9045 DispHTMLAttributeCollection_tid,
9046 HTMLAttributeCollection_iface_tids
9049 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
9051 HTMLElement *This = impl_from_HTMLDOMNode(iface);
9053 if(This->attrs) {
9054 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
9055 *ac = This->attrs;
9056 return S_OK;
9059 This->attrs = calloc(1, sizeof(HTMLAttributeCollection));
9060 if(!This->attrs)
9061 return E_OUTOFMEMORY;
9063 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
9064 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
9065 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
9067 This->attrs->elem = This;
9068 list_init(&This->attrs->attrs);
9069 init_dispatch(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
9070 &HTMLAttributeCollection_dispex, dispex_compat_mode(&iface->event_target.dispex));
9072 *ac = This->attrs;
9073 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
9074 return S_OK;