wow64: In wow64_NtSetInformationToken forward TokenIntegrityLevel.
[wine.git] / dlls / mshtml / htmlelem.c
blob1e20e75366a4558ffcb8eca84663c537bd83e1a0
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 DISPEX_IDISPATCH_IMPL(HTMLRect, IHTMLRect, impl_from_IHTMLRect(iface)->dispex)
542 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
544 HTMLRect *This = impl_from_IHTMLRect(iface);
545 FIXME("(%p)->(%ld)\n", This, v);
546 return E_NOTIMPL;
549 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
551 HTMLRect *This = impl_from_IHTMLRect(iface);
552 float left;
553 nsresult nsres;
555 TRACE("(%p)->(%p)\n", This, p);
557 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
558 if(NS_FAILED(nsres)) {
559 ERR("GetLeft failed: %08lx\n", nsres);
560 return E_FAIL;
563 *p = floor(left+0.5);
564 return S_OK;
567 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
569 HTMLRect *This = impl_from_IHTMLRect(iface);
570 FIXME("(%p)->(%ld)\n", This, v);
571 return E_NOTIMPL;
574 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
576 HTMLRect *This = impl_from_IHTMLRect(iface);
577 float top;
578 nsresult nsres;
580 TRACE("(%p)->(%p)\n", This, p);
582 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
583 if(NS_FAILED(nsres)) {
584 ERR("GetTop failed: %08lx\n", nsres);
585 return E_FAIL;
588 *p = floor(top+0.5);
589 return S_OK;
592 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
594 HTMLRect *This = impl_from_IHTMLRect(iface);
595 FIXME("(%p)->(%ld)\n", This, v);
596 return E_NOTIMPL;
599 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
601 HTMLRect *This = impl_from_IHTMLRect(iface);
602 float right;
603 nsresult nsres;
605 TRACE("(%p)->(%p)\n", This, p);
607 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
608 if(NS_FAILED(nsres)) {
609 ERR("GetRight failed: %08lx\n", nsres);
610 return E_FAIL;
613 *p = floor(right+0.5);
614 return S_OK;
617 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
619 HTMLRect *This = impl_from_IHTMLRect(iface);
620 FIXME("(%p)->(%ld)\n", This, v);
621 return E_NOTIMPL;
624 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
626 HTMLRect *This = impl_from_IHTMLRect(iface);
627 float bottom;
628 nsresult nsres;
630 TRACE("(%p)->(%p)\n", This, p);
632 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
633 if(NS_FAILED(nsres)) {
634 ERR("GetBottom failed: %08lx\n", nsres);
635 return E_FAIL;
638 *p = floor(bottom+0.5);
639 return S_OK;
642 static inline HTMLRect *impl_from_IHTMLRect2(IHTMLRect2 *iface)
644 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect2_iface);
647 DISPEX_IDISPATCH_IMPL(HTMLRect2, IHTMLRect2, impl_from_IHTMLRect2(iface)->dispex)
649 static HRESULT WINAPI HTMLRect2_get_width(IHTMLRect2 *iface, FLOAT *p)
651 HTMLRect *This = impl_from_IHTMLRect2(iface);
652 nsresult nsres;
654 TRACE("(%p)->(%p)\n", This, p);
656 nsres = nsIDOMClientRect_GetWidth(This->nsrect, p);
657 if (NS_FAILED(nsres)) {
658 ERR("GetWidth failed: %08lx\n", nsres);
659 return E_FAIL;
662 return S_OK;
665 static HRESULT WINAPI HTMLRect2_get_height(IHTMLRect2 *iface, FLOAT *p)
667 HTMLRect *This = impl_from_IHTMLRect2(iface);
668 nsresult nsres;
670 TRACE("(%p)->(%p)\n", This, p);
672 nsres = nsIDOMClientRect_GetHeight(This->nsrect, p);
673 if (NS_FAILED(nsres)) {
674 ERR("GetHeight failed: %08lx\n", nsres);
675 return E_FAIL;
678 return S_OK;
681 static const IHTMLRectVtbl HTMLRectVtbl = {
682 HTMLRect_QueryInterface,
683 HTMLRect_AddRef,
684 HTMLRect_Release,
685 HTMLRect_GetTypeInfoCount,
686 HTMLRect_GetTypeInfo,
687 HTMLRect_GetIDsOfNames,
688 HTMLRect_Invoke,
689 HTMLRect_put_left,
690 HTMLRect_get_left,
691 HTMLRect_put_top,
692 HTMLRect_get_top,
693 HTMLRect_put_right,
694 HTMLRect_get_right,
695 HTMLRect_put_bottom,
696 HTMLRect_get_bottom
699 static const IHTMLRect2Vtbl HTMLRect2Vtbl = {
700 HTMLRect2_QueryInterface,
701 HTMLRect2_AddRef,
702 HTMLRect2_Release,
703 HTMLRect2_GetTypeInfoCount,
704 HTMLRect2_GetTypeInfo,
705 HTMLRect2_GetIDsOfNames,
706 HTMLRect2_Invoke,
707 HTMLRect2_get_width,
708 HTMLRect2_get_height,
711 static inline HTMLRect *HTMLRect_from_DispatchEx(DispatchEx *iface)
713 return CONTAINING_RECORD(iface, HTMLRect, dispex);
716 static void *HTMLRect_query_interface(DispatchEx *dispex, REFIID riid)
718 HTMLRect *This = HTMLRect_from_DispatchEx(dispex);
720 if(IsEqualGUID(&IID_IHTMLRect, riid))
721 return &This->IHTMLRect_iface;
722 if(IsEqualGUID(&IID_IHTMLRect2, riid))
723 return &This->IHTMLRect2_iface;
725 return NULL;
728 static void HTMLRect_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
730 HTMLRect *This = HTMLRect_from_DispatchEx(dispex);
731 if(This->nsrect)
732 note_cc_edge((nsISupports*)This->nsrect, "nsrect", cb);
735 static void HTMLRect_unlink(DispatchEx *dispex)
737 HTMLRect *This = HTMLRect_from_DispatchEx(dispex);
738 unlink_ref(&This->nsrect);
741 static void HTMLRect_destructor(DispatchEx *dispex)
743 HTMLRect *This = HTMLRect_from_DispatchEx(dispex);
744 free(This);
747 void HTMLRect_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
749 if (mode >= COMPAT_MODE_IE9)
750 dispex_info_add_interface(info, IHTMLRect2_tid, NULL);
753 static const dispex_static_data_vtbl_t HTMLRect_dispex_vtbl = {
754 .query_interface = HTMLRect_query_interface,
755 .destructor = HTMLRect_destructor,
756 .traverse = HTMLRect_traverse,
757 .unlink = HTMLRect_unlink
760 static const tid_t HTMLRect_iface_tids[] = {
761 IHTMLRect_tid,
764 static dispex_static_data_t HTMLRect_dispex = {
765 "ClientRect",
766 &HTMLRect_dispex_vtbl,
767 IHTMLRect_tid,
768 HTMLRect_iface_tids,
769 HTMLRect_init_dispex_info
772 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, compat_mode_t compat_mode, IHTMLRect **ret)
774 HTMLRect *rect;
776 rect = calloc(1, sizeof(HTMLRect));
777 if(!rect)
778 return E_OUTOFMEMORY;
780 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
781 rect->IHTMLRect2_iface.lpVtbl = &HTMLRect2Vtbl;
783 init_dispatch(&rect->dispex, &HTMLRect_dispex, compat_mode);
785 nsIDOMClientRect_AddRef(nsrect);
786 rect->nsrect = nsrect;
788 *ret = &rect->IHTMLRect_iface;
789 return S_OK;
792 typedef struct {
793 DispatchEx dispex;
794 IHTMLRectCollection IHTMLRectCollection_iface;
796 nsIDOMClientRectList *rect_list;
797 } HTMLRectCollection;
799 typedef struct {
800 IEnumVARIANT IEnumVARIANT_iface;
802 LONG ref;
804 ULONG iter;
805 HTMLRectCollection *col;
806 } HTMLRectCollectionEnum;
808 static inline HTMLRectCollectionEnum *HTMLRectCollectionEnum_from_IEnumVARIANT(IEnumVARIANT *iface)
810 return CONTAINING_RECORD(iface, HTMLRectCollectionEnum, IEnumVARIANT_iface);
813 static HRESULT WINAPI HTMLRectCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
815 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
817 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
819 if(IsEqualGUID(riid, &IID_IUnknown)) {
820 *ppv = &This->IEnumVARIANT_iface;
821 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
822 *ppv = &This->IEnumVARIANT_iface;
823 }else {
824 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
825 *ppv = NULL;
826 return E_NOINTERFACE;
829 IUnknown_AddRef((IUnknown*)*ppv);
830 return S_OK;
833 static ULONG WINAPI HTMLRectCollectionEnum_AddRef(IEnumVARIANT *iface)
835 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
836 LONG ref = InterlockedIncrement(&This->ref);
838 TRACE("(%p) ref=%ld\n", This, ref);
840 return ref;
843 static ULONG WINAPI HTMLRectCollectionEnum_Release(IEnumVARIANT *iface)
845 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
846 LONG ref = InterlockedDecrement(&This->ref);
848 TRACE("(%p) ref=%ld\n", This, ref);
850 if(!ref) {
851 IHTMLRectCollection_Release(&This->col->IHTMLRectCollection_iface);
852 free(This);
855 return ref;
858 static HRESULT WINAPI HTMLRectCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
860 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
861 VARIANT index;
862 HRESULT hres;
863 ULONG num, i;
864 UINT32 len;
866 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
868 nsIDOMClientRectList_GetLength(This->col->rect_list, &len);
869 num = min(len - This->iter, celt);
870 V_VT(&index) = VT_I4;
872 for(i = 0; i < num; i++) {
873 V_I4(&index) = This->iter + i;
874 hres = IHTMLRectCollection_item(&This->col->IHTMLRectCollection_iface, &index, &rgVar[i]);
875 if(FAILED(hres)) {
876 while(i--)
877 VariantClear(&rgVar[i]);
878 return hres;
882 This->iter += num;
883 if(pCeltFetched)
884 *pCeltFetched = num;
885 return num == celt ? S_OK : S_FALSE;
888 static HRESULT WINAPI HTMLRectCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
890 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
891 UINT32 len;
893 TRACE("(%p)->(%lu)\n", This, celt);
895 nsIDOMClientRectList_GetLength(This->col->rect_list, &len);
896 if(This->iter + celt > len) {
897 This->iter = len;
898 return S_FALSE;
901 This->iter += celt;
902 return S_OK;
905 static HRESULT WINAPI HTMLRectCollectionEnum_Reset(IEnumVARIANT *iface)
907 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
909 TRACE("(%p)->()\n", This);
911 This->iter = 0;
912 return S_OK;
915 static HRESULT WINAPI HTMLRectCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
917 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
918 FIXME("(%p)->(%p)\n", This, ppEnum);
919 return E_NOTIMPL;
922 static const IEnumVARIANTVtbl HTMLRectCollectionEnumVtbl = {
923 HTMLRectCollectionEnum_QueryInterface,
924 HTMLRectCollectionEnum_AddRef,
925 HTMLRectCollectionEnum_Release,
926 HTMLRectCollectionEnum_Next,
927 HTMLRectCollectionEnum_Skip,
928 HTMLRectCollectionEnum_Reset,
929 HTMLRectCollectionEnum_Clone
932 static inline HTMLRectCollection *impl_from_IHTMLRectCollection(IHTMLRectCollection *iface)
934 return CONTAINING_RECORD(iface, HTMLRectCollection, IHTMLRectCollection_iface);
937 DISPEX_IDISPATCH_IMPL(HTMLRectCollection, IHTMLRectCollection, impl_from_IHTMLRectCollection(iface)->dispex)
939 static HRESULT WINAPI HTMLRectCollection_get_length(IHTMLRectCollection *iface, LONG *p)
941 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
942 UINT32 length;
943 nsresult nsres;
945 TRACE("(%p)->(%p)\n", This, p);
947 nsres = nsIDOMClientRectList_GetLength(This->rect_list, &length);
948 assert(nsres == NS_OK);
949 *p = length;
950 return S_OK;
953 static HRESULT WINAPI HTMLRectCollection_get__newEnum(IHTMLRectCollection *iface, IUnknown **p)
955 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
956 HTMLRectCollectionEnum *ret;
958 TRACE("(%p)->(%p)\n", This, p);
960 ret = malloc(sizeof(*ret));
961 if(!ret)
962 return E_OUTOFMEMORY;
964 ret->IEnumVARIANT_iface.lpVtbl = &HTMLRectCollectionEnumVtbl;
965 ret->ref = 1;
966 ret->iter = 0;
968 HTMLRectCollection_AddRef(&This->IHTMLRectCollection_iface);
969 ret->col = This;
971 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
972 return S_OK;
975 static HRESULT WINAPI HTMLRectCollection_item(IHTMLRectCollection *iface, VARIANT *index, VARIANT *result)
977 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
978 nsIDOMClientRect *nsrect;
979 IHTMLRect *rect;
980 nsresult nsres;
981 HRESULT hres;
983 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(index), result);
985 if(V_VT(index) != VT_I4 || V_I4(index) < 0) {
986 FIXME("Unsupported for %s index\n", debugstr_variant(index));
987 return E_NOTIMPL;
990 nsres = nsIDOMClientRectList_Item(This->rect_list, V_I4(index), &nsrect);
991 if(NS_FAILED(nsres))
992 return map_nsresult(nsres);
993 if(!nsrect) {
994 V_VT(result) = VT_NULL;
995 return S_OK;
998 hres = create_html_rect(nsrect, dispex_compat_mode(&This->dispex), &rect);
999 nsIDOMClientRect_Release(nsrect);
1000 if(FAILED(hres))
1001 return hres;
1003 V_VT(result) = VT_DISPATCH;
1004 V_DISPATCH(result) = (IDispatch *)rect;
1005 return S_OK;
1008 static const IHTMLRectCollectionVtbl HTMLRectCollectionVtbl = {
1009 HTMLRectCollection_QueryInterface,
1010 HTMLRectCollection_AddRef,
1011 HTMLRectCollection_Release,
1012 HTMLRectCollection_GetTypeInfoCount,
1013 HTMLRectCollection_GetTypeInfo,
1014 HTMLRectCollection_GetIDsOfNames,
1015 HTMLRectCollection_Invoke,
1016 HTMLRectCollection_get_length,
1017 HTMLRectCollection_get__newEnum,
1018 HTMLRectCollection_item
1021 static inline HTMLRectCollection *HTMLRectCollection_from_DispatchEx(DispatchEx *iface)
1023 return CONTAINING_RECORD(iface, HTMLRectCollection, dispex);
1026 static void *HTMLRectCollection_query_interface(DispatchEx *dispex, REFIID riid)
1028 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1030 if(IsEqualGUID(&IID_IHTMLRectCollection, riid))
1031 return &This->IHTMLRectCollection_iface;
1033 return NULL;
1036 static void HTMLRectCollection_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
1038 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1039 if(This->rect_list)
1040 note_cc_edge((nsISupports*)This->rect_list, "rect_list", cb);
1043 static void HTMLRectCollection_unlink(DispatchEx *dispex)
1045 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1046 unlink_ref(&This->rect_list);
1049 static void HTMLRectCollection_destructor(DispatchEx *dispex)
1051 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1052 free(This);
1055 static HRESULT HTMLRectCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1057 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1058 UINT32 len = 0;
1059 DWORD idx = 0;
1060 WCHAR *ptr;
1062 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
1063 idx = idx*10 + (*ptr-'0');
1064 if(*ptr)
1065 return DISP_E_UNKNOWNNAME;
1067 nsIDOMClientRectList_GetLength(This->rect_list, &len);
1068 if(idx >= len)
1069 return DISP_E_UNKNOWNNAME;
1071 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1072 TRACE("ret %lx\n", *dispid);
1073 return S_OK;
1076 static HRESULT HTMLRectCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
1078 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1079 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
1080 UINT32 len = 0;
1081 WCHAR buf[11];
1083 nsIDOMClientRectList_GetLength(This->rect_list, &len);
1084 if(idx >= len)
1085 return DISP_E_MEMBERNOTFOUND;
1087 len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx);
1088 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
1091 static HRESULT HTMLRectCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1092 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1094 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1096 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
1098 switch(flags) {
1099 case DISPATCH_PROPERTYGET: {
1100 nsIDOMClientRect *rect;
1101 IHTMLRect *html_rect;
1102 nsresult nsres;
1103 HRESULT hres;
1105 nsres = nsIDOMClientRectList_Item(This->rect_list, id - MSHTML_DISPID_CUSTOM_MIN, &rect);
1106 if(NS_FAILED(nsres) || !rect) {
1107 WARN("Unknown item\n");
1108 return DISP_E_MEMBERNOTFOUND;
1111 hres = create_html_rect(rect, dispex_compat_mode(&This->dispex), &html_rect);
1112 nsIDOMClientRect_Release(rect);
1113 if(FAILED(hres))
1114 return hres;
1116 V_VT(res) = VT_DISPATCH;
1117 V_DISPATCH(res) = (IDispatch*)html_rect;
1118 break;
1121 default:
1122 FIXME("unimplemented flags %x\n", flags);
1123 return E_NOTIMPL;
1126 return S_OK;
1129 static const dispex_static_data_vtbl_t HTMLRectCollection_dispex_vtbl = {
1130 .query_interface = HTMLRectCollection_query_interface,
1131 .destructor = HTMLRectCollection_destructor,
1132 .traverse = HTMLRectCollection_traverse,
1133 .unlink = HTMLRectCollection_unlink,
1134 .get_dispid = HTMLRectCollection_get_dispid,
1135 .get_name = HTMLRectCollection_get_name,
1136 .invoke = HTMLRectCollection_invoke,
1138 static const tid_t HTMLRectCollection_iface_tids[] = {
1139 IHTMLRectCollection_tid,
1142 static dispex_static_data_t HTMLRectCollection_dispex = {
1143 "ClientRectList",
1144 &HTMLRectCollection_dispex_vtbl,
1145 IHTMLRectCollection_tid,
1146 HTMLRectCollection_iface_tids
1149 DISPEX_IDISPATCH_IMPL(HTMLElement, IHTMLElement,
1150 impl_from_IHTMLElement(iface)->node.event_target.dispex)
1152 static inline WCHAR *translate_attr_name(WCHAR *attr_name, compat_mode_t compat_mode)
1154 static WCHAR classNameW[] = L"className";
1155 WCHAR *ret = attr_name;
1157 if(compat_mode >= COMPAT_MODE_IE8 && !wcsicmp(attr_name, L"class"))
1158 ret = classNameW;
1159 return ret;
1162 static HRESULT set_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *v)
1164 DISPID propput_dispid = DISPID_PROPERTYPUT;
1165 DISPPARAMS dp = {v, &propput_dispid, 1, 1};
1166 EXCEPINFO ei;
1168 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
1169 TRACE("Ignoring call on style attribute\n");
1170 return S_OK;
1173 return IWineJSDispatchHost_InvokeEx(&elem->node.event_target.dispex.IWineJSDispatchHost_iface, dispid,
1174 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
1177 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
1178 VARIANT AttributeValue, LONG lFlags)
1180 HTMLElement *This = impl_from_IHTMLElement(iface);
1181 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1182 nsAString name_str, value_str;
1183 VARIANT val = AttributeValue;
1184 BOOL needs_free = FALSE;
1185 nsresult nsres;
1186 DISPID dispid;
1187 HRESULT hres;
1189 TRACE("(%p)->(%s %s %08lx)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
1191 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1192 hres = IWineJSDispatchHost_GetDispID(&This->node.event_target.dispex.IWineJSDispatchHost_iface, translate_attr_name(strAttributeName, compat_mode),
1193 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
1194 if(FAILED(hres))
1195 return hres;
1197 if(compat_mode >= COMPAT_MODE_IE8 && get_dispid_type(dispid) == DISPEXPROP_BUILTIN) {
1198 if(V_VT(&val) != VT_BSTR && V_VT(&val) != VT_NULL) {
1199 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1201 V_VT(&val) = VT_EMPTY;
1202 hres = VariantChangeTypeEx(&val, &AttributeValue, lcid, 0, VT_BSTR);
1203 if(FAILED(hres))
1204 return hres;
1206 if(V_BSTR(&val))
1207 needs_free = TRUE;
1208 else
1209 V_VT(&val) = VT_NULL;
1213 /* className and style are special cases */
1214 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1215 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1216 hres = set_elem_attr_value_by_dispid(This, dispid, &val);
1217 goto done;
1221 hres = variant_to_nsstr(&val, FALSE, &value_str);
1222 if(FAILED(hres))
1223 goto done;
1225 nsAString_InitDepend(&name_str, strAttributeName);
1226 nsres = nsIDOMElement_SetAttribute(This->dom_element, &name_str, &value_str);
1227 nsAString_Finish(&name_str);
1228 nsAString_Finish(&value_str);
1229 if(NS_FAILED(nsres))
1230 WARN("SetAttribute failed: %08lx\n", nsres);
1231 hres = map_nsresult(nsres);
1233 done:
1234 if(needs_free)
1235 SysFreeString(V_BSTR(&val));
1236 return hres;
1239 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *ret)
1241 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
1242 EXCEPINFO excep;
1244 return IWineJSDispatchHost_InvokeEx(&elem->node.event_target.dispex.IWineJSDispatchHost_iface, dispid, LOCALE_SYSTEM_DEFAULT,
1245 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
1248 HRESULT attr_value_to_string(VARIANT *v)
1250 HRESULT hres;
1252 switch(V_VT(v)) {
1253 case VT_BSTR:
1254 break;
1255 case VT_NULL:
1256 V_BSTR(v) = SysAllocString(L"null");
1257 if(!V_BSTR(v))
1258 return E_OUTOFMEMORY;
1259 V_VT(v) = VT_BSTR;
1260 break;
1261 case VT_DISPATCH:
1262 IDispatch_Release(V_DISPATCH(v));
1263 V_VT(v) = VT_BSTR;
1264 V_BSTR(v) = SysAllocString(NULL);
1265 break;
1266 default:
1267 hres = VariantChangeType(v, v, 0, VT_BSTR);
1268 if(FAILED(hres))
1269 return hres;
1272 return S_OK;
1275 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
1276 LONG lFlags, VARIANT *AttributeValue)
1278 HTMLElement *This = impl_from_IHTMLElement(iface);
1279 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1280 nsAString name_str, value_str;
1281 nsresult nsres;
1282 DISPID dispid;
1283 HRESULT hres;
1285 TRACE("(%p)->(%s %08lx %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
1287 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
1288 FIXME("Unsupported flags %lx\n", lFlags);
1290 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1291 hres = IWineJSDispatchHost_GetDispID(&This->node.event_target.dispex.IWineJSDispatchHost_iface, translate_attr_name(strAttributeName, compat_mode),
1292 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
1293 if(FAILED(hres)) {
1294 V_VT(AttributeValue) = VT_NULL;
1295 return (hres == DISP_E_UNKNOWNNAME) ? S_OK : hres;
1298 /* className and style are special cases */
1299 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1300 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1301 hres = get_elem_attr_value_by_dispid(This, dispid, AttributeValue);
1302 if(FAILED(hres))
1303 return hres;
1305 if(compat_mode >= COMPAT_MODE_IE8 && V_VT(AttributeValue) != VT_BSTR && V_VT(AttributeValue) != VT_NULL) {
1306 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1308 hres = VariantChangeTypeEx(AttributeValue, AttributeValue, lcid, 0, VT_BSTR);
1309 if(FAILED(hres)) {
1310 VariantClear(AttributeValue);
1311 return hres;
1313 if(!V_BSTR(AttributeValue))
1314 V_VT(AttributeValue) = VT_NULL;
1315 }else if(lFlags & ATTRFLAG_ASSTRING)
1316 hres = attr_value_to_string(AttributeValue);
1317 return hres;
1321 nsAString_InitDepend(&name_str, strAttributeName);
1322 nsAString_InitDepend(&value_str, NULL);
1323 nsres = nsIDOMElement_GetAttribute(This->dom_element, &name_str, &value_str);
1324 nsAString_Finish(&name_str);
1325 return return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
1328 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
1329 LONG lFlags, VARIANT_BOOL *pfSuccess)
1331 HTMLElement *This = impl_from_IHTMLElement(iface);
1332 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1333 DISPID id;
1334 HRESULT hres;
1336 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
1338 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1339 hres = IWineJSDispatchHost_GetDispID(&This->node.event_target.dispex.IWineJSDispatchHost_iface, translate_attr_name(strAttributeName, compat_mode),
1340 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
1341 if(hres == DISP_E_UNKNOWNNAME) {
1342 *pfSuccess = VARIANT_FALSE;
1343 return S_OK;
1345 if(FAILED(hres))
1346 return hres;
1348 if(id == DISPID_IHTMLELEMENT_STYLE) {
1349 IHTMLStyle *style;
1351 TRACE("Special case: style\n");
1353 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
1354 if(FAILED(hres))
1355 return hres;
1357 hres = IHTMLStyle_put_cssText(style, NULL);
1358 IHTMLStyle_Release(style);
1359 if(FAILED(hres))
1360 return hres;
1362 if(compat_mode >= COMPAT_MODE_IE8)
1363 element_remove_attribute(This, strAttributeName);
1365 *pfSuccess = VARIANT_TRUE;
1366 return S_OK;
1369 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element || id != DISPID_IHTMLELEMENT_CLASSNAME)
1370 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
1373 *pfSuccess = element_has_attribute(This, strAttributeName);
1374 if(*pfSuccess)
1375 return element_remove_attribute(This, strAttributeName);
1376 return S_OK;
1379 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
1381 HTMLElement *This = impl_from_IHTMLElement(iface);
1382 nsAString classname_str;
1383 nsresult nsres;
1385 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1387 if(!This->dom_element) {
1388 FIXME("comment element\n");
1389 return E_NOTIMPL;
1392 nsAString_InitDepend(&classname_str, v);
1393 nsres = nsIDOMElement_SetClassName(This->dom_element, &classname_str);
1394 nsAString_Finish(&classname_str);
1395 if(NS_FAILED(nsres))
1396 ERR("SetClassName failed: %08lx\n", nsres);
1398 return S_OK;
1401 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
1403 HTMLElement *This = impl_from_IHTMLElement(iface);
1404 nsAString class_str;
1405 nsresult nsres;
1407 TRACE("(%p)->(%p)\n", This, p);
1409 if(!This->dom_element) {
1410 FIXME("comment element\n");
1411 return E_NOTIMPL;
1414 nsAString_Init(&class_str, NULL);
1415 nsres = nsIDOMElement_GetClassName(This->dom_element, &class_str);
1416 return return_nsstr(nsres, &class_str, p);
1419 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
1421 HTMLElement *This = impl_from_IHTMLElement(iface);
1422 nsAString id_str;
1423 nsresult nsres;
1425 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1427 if(!This->dom_element) {
1428 FIXME("comment element\n");
1429 return S_OK;
1432 nsAString_InitDepend(&id_str, v);
1433 nsres = nsIDOMElement_SetId(This->dom_element, &id_str);
1434 nsAString_Finish(&id_str);
1435 if(NS_FAILED(nsres))
1436 ERR("SetId failed: %08lx\n", nsres);
1438 return S_OK;
1441 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
1443 HTMLElement *This = impl_from_IHTMLElement(iface);
1444 nsAString id_str;
1445 nsresult nsres;
1447 TRACE("(%p)->(%p)\n", This, p);
1449 if(!This->dom_element) {
1450 *p = NULL;
1451 return S_OK;
1454 nsAString_Init(&id_str, NULL);
1455 nsres = nsIDOMElement_GetId(This->dom_element, &id_str);
1456 return return_nsstr(nsres, &id_str, p);
1459 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
1461 HTMLElement *This = impl_from_IHTMLElement(iface);
1462 nsAString tag_str;
1463 nsresult nsres;
1465 TRACE("(%p)->(%p)\n", This, p);
1467 if(!This->dom_element) {
1468 TRACE("comment element\n");
1469 *p = SysAllocString(L"!");
1470 return *p ? S_OK : E_OUTOFMEMORY;
1473 nsAString_Init(&tag_str, NULL);
1474 nsres = nsIDOMElement_GetTagName(This->dom_element, &tag_str);
1475 return return_nsstr(nsres, &tag_str, p);
1478 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
1480 HTMLElement *This = impl_from_IHTMLElement(iface);
1481 IHTMLDOMNode *node;
1482 HRESULT hres;
1484 TRACE("(%p)->(%p)\n", This, p);
1486 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
1487 if(FAILED(hres))
1488 return hres;
1490 if(!node) {
1491 *p = NULL;
1492 return S_OK;
1495 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
1496 IHTMLDOMNode_Release(node);
1497 if(FAILED(hres))
1498 *p = NULL;
1500 return S_OK;
1503 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
1505 HTMLElement *This = impl_from_IHTMLElement(iface);
1507 TRACE("(%p)->(%p)\n", This, p);
1509 if(!This->style) {
1510 HRESULT hres;
1512 hres = HTMLStyle_Create(This, &This->style);
1513 if(FAILED(hres))
1514 return hres;
1517 *p = &This->style->IHTMLStyle_iface;
1518 IHTMLStyle_AddRef(*p);
1519 return S_OK;
1522 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
1524 HTMLElement *This = impl_from_IHTMLElement(iface);
1526 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1528 return set_node_event(&This->node, EVENTID_HELP, &v);
1531 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
1533 HTMLElement *This = impl_from_IHTMLElement(iface);
1535 TRACE("(%p)->(%p)\n", This, p);
1537 return get_node_event(&This->node, EVENTID_HELP, p);
1540 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
1542 HTMLElement *This = impl_from_IHTMLElement(iface);
1544 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1546 return set_node_event(&This->node, EVENTID_CLICK, &v);
1549 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
1551 HTMLElement *This = impl_from_IHTMLElement(iface);
1553 TRACE("(%p)->(%p)\n", This, p);
1555 return get_node_event(&This->node, EVENTID_CLICK, p);
1558 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
1560 HTMLElement *This = impl_from_IHTMLElement(iface);
1562 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1564 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
1567 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
1569 HTMLElement *This = impl_from_IHTMLElement(iface);
1571 TRACE("(%p)->(%p)\n", This, p);
1573 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
1576 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
1578 HTMLElement *This = impl_from_IHTMLElement(iface);
1580 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1582 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
1585 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
1587 HTMLElement *This = impl_from_IHTMLElement(iface);
1589 TRACE("(%p)->(%p)\n", This, p);
1591 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
1594 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
1596 HTMLElement *This = impl_from_IHTMLElement(iface);
1598 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1600 return set_node_event(&This->node, EVENTID_KEYUP, &v);
1603 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
1605 HTMLElement *This = impl_from_IHTMLElement(iface);
1607 TRACE("(%p)->(%p)\n", This, p);
1609 return get_node_event(&This->node, EVENTID_KEYUP, p);
1612 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
1614 HTMLElement *This = impl_from_IHTMLElement(iface);
1616 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1618 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
1621 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
1623 HTMLElement *This = impl_from_IHTMLElement(iface);
1625 TRACE("(%p)->(%p)\n", This, p);
1627 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
1630 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
1632 HTMLElement *This = impl_from_IHTMLElement(iface);
1634 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1636 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
1639 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
1641 HTMLElement *This = impl_from_IHTMLElement(iface);
1643 TRACE("(%p)->(%p)\n", This, p);
1645 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1648 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1650 HTMLElement *This = impl_from_IHTMLElement(iface);
1652 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1654 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1657 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1659 HTMLElement *This = impl_from_IHTMLElement(iface);
1661 TRACE("(%p)->(%p)\n", This, p);
1663 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1666 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1668 HTMLElement *This = impl_from_IHTMLElement(iface);
1670 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1672 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1675 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1677 HTMLElement *This = impl_from_IHTMLElement(iface);
1679 TRACE("(%p)->(%p)\n", This, p);
1681 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1684 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1686 HTMLElement *This = impl_from_IHTMLElement(iface);
1688 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1690 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1693 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1695 HTMLElement *This = impl_from_IHTMLElement(iface);
1697 TRACE("(%p)->(%p)\n", This, p);
1699 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1702 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1704 HTMLElement *This = impl_from_IHTMLElement(iface);
1706 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1708 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1711 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1713 HTMLElement *This = impl_from_IHTMLElement(iface);
1715 TRACE("(%p)->(%p)\n", This, p);
1717 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1720 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1722 HTMLElement *This = impl_from_IHTMLElement(iface);
1724 TRACE("(%p)->(%p)\n", This, p);
1726 if(!p)
1727 return E_POINTER;
1729 if(This->node.vtbl->get_document)
1730 return This->node.vtbl->get_document(&This->node, p);
1732 *p = (IDispatch*)&This->node.doc->IHTMLDocument2_iface;
1733 IDispatch_AddRef(*p);
1734 return S_OK;
1737 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1739 HTMLElement *This = impl_from_IHTMLElement(iface);
1740 nsAString title_str;
1741 nsresult nsres;
1743 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1745 if(!This->dom_element) {
1746 VARIANT *var;
1747 HRESULT hres;
1749 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", TRUE, &var);
1750 if(FAILED(hres))
1751 return hres;
1753 VariantClear(var);
1754 V_VT(var) = VT_BSTR;
1755 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1756 return S_OK;
1759 if(!This->html_element)
1760 return elem_string_attr_setter(This, L"title", v);
1762 nsAString_InitDepend(&title_str, v);
1763 nsres = nsIDOMHTMLElement_SetTitle(This->html_element, &title_str);
1764 nsAString_Finish(&title_str);
1765 if(NS_FAILED(nsres))
1766 ERR("SetTitle failed: %08lx\n", nsres);
1768 return S_OK;
1771 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1773 HTMLElement *This = impl_from_IHTMLElement(iface);
1774 nsAString title_str;
1775 nsresult nsres;
1777 TRACE("(%p)->(%p)\n", This, p);
1779 if(!This->dom_element) {
1780 VARIANT *var;
1781 HRESULT hres;
1783 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", FALSE, &var);
1784 if(hres == DISP_E_UNKNOWNNAME) {
1785 *p = NULL;
1786 }else if(V_VT(var) != VT_BSTR) {
1787 FIXME("title = %s\n", debugstr_variant(var));
1788 return E_FAIL;
1789 }else {
1790 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1793 return S_OK;
1796 if(!This->html_element)
1797 return elem_string_attr_getter(This, L"title", FALSE, p);
1799 nsAString_Init(&title_str, NULL);
1800 nsres = nsIDOMHTMLElement_GetTitle(This->html_element, &title_str);
1801 return return_nsstr(nsres, &title_str, p);
1804 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1806 HTMLElement *This = impl_from_IHTMLElement(iface);
1808 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1810 return elem_string_attr_setter(This, L"language", v);
1813 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1815 HTMLElement *This = impl_from_IHTMLElement(iface);
1817 TRACE("(%p)->(%p)\n", This, p);
1819 return elem_string_attr_getter(This, L"language", TRUE, p);
1822 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1824 HTMLElement *This = impl_from_IHTMLElement(iface);
1826 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1828 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1831 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1833 HTMLElement *This = impl_from_IHTMLElement(iface);
1835 TRACE("(%p)->(%p)\n", This, p);
1837 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1840 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1842 HTMLElement *This = impl_from_IHTMLElement(iface);
1843 cpp_bool start = TRUE;
1844 nsresult nsres;
1846 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1848 switch(V_VT(&varargStart)) {
1849 case VT_EMPTY:
1850 case VT_ERROR:
1851 break;
1852 case VT_BOOL:
1853 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1854 break;
1855 default:
1856 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1859 if(!This->html_element) {
1860 FIXME("non-HTML elements\n");
1861 return E_NOTIMPL;
1864 nsres = nsIDOMHTMLElement_ScrollIntoView(This->html_element, start, 1);
1865 assert(nsres == NS_OK);
1867 return S_OK;
1870 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1871 VARIANT_BOOL *pfResult)
1873 HTMLElement *This = impl_from_IHTMLElement(iface);
1874 cpp_bool result = FALSE;
1876 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1878 if(pChild) {
1879 HTMLElement *child;
1880 nsresult nsres;
1882 child = unsafe_impl_from_IHTMLElement(pChild);
1883 if(!child) {
1884 ERR("not our element\n");
1885 return E_FAIL;
1888 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1889 assert(nsres == NS_OK);
1892 *pfResult = variant_bool(result);
1893 return S_OK;
1896 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1898 HTMLElement *This = impl_from_IHTMLElement(iface);
1900 TRACE("(%p)->(%p)\n", This, p);
1902 return get_elem_source_index(This, p);
1905 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1907 HTMLElement *This = impl_from_IHTMLElement(iface);
1908 FIXME("(%p)->(%p)\n", This, p);
1909 return E_NOTIMPL;
1912 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1914 HTMLElement *This = impl_from_IHTMLElement(iface);
1915 nsAString nsstr;
1916 nsresult nsres;
1918 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1920 if(!This->html_element) {
1921 FIXME("non-HTML element\n");
1922 return E_NOTIMPL;
1925 nsAString_InitDepend(&nsstr, v);
1926 nsres = nsIDOMHTMLElement_SetLang(This->html_element, &nsstr);
1927 nsAString_Finish(&nsstr);
1928 if(NS_FAILED(nsres)) {
1929 ERR("SetLang failed: %08lx\n", nsres);
1930 return E_FAIL;
1933 return S_OK;
1936 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
1938 HTMLElement *This = impl_from_IHTMLElement(iface);
1939 nsAString nsstr;
1940 nsresult nsres;
1942 TRACE("(%p)->(%p)\n", This, p);
1944 if(!This->html_element) {
1945 FIXME("non-HTML element\n");
1946 return E_NOTIMPL;
1949 nsAString_Init(&nsstr, NULL);
1950 nsres = nsIDOMHTMLElement_GetLang(This->html_element, &nsstr);
1951 return return_nsstr(nsres, &nsstr, p);
1954 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
1956 HTMLElement *This = impl_from_IHTMLElement(iface);
1957 nsresult nsres;
1959 TRACE("(%p)->(%p)\n", This, p);
1961 if(!This->html_element) {
1962 FIXME("non-HTML element\n");
1963 return E_NOTIMPL;
1966 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->html_element, p);
1967 if(NS_FAILED(nsres)) {
1968 ERR("GetOffsetLeft failed: %08lx\n", nsres);
1969 return E_FAIL;
1972 return S_OK;
1975 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
1977 HTMLElement *This = impl_from_IHTMLElement(iface);
1978 nsresult nsres;
1980 TRACE("(%p)->(%p)\n", This, p);
1982 if(!This->html_element) {
1983 FIXME("non-HTML element\n");
1984 return E_NOTIMPL;
1987 nsres = nsIDOMHTMLElement_GetOffsetTop(This->html_element, p);
1988 if(NS_FAILED(nsres)) {
1989 ERR("GetOffsetTop failed: %08lx\n", nsres);
1990 return E_FAIL;
1993 return S_OK;
1996 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
1998 HTMLElement *This = impl_from_IHTMLElement(iface);
1999 nsresult nsres;
2001 TRACE("(%p)->(%p)\n", This, p);
2003 if(!This->html_element) {
2004 FIXME("non-HTML element\n");
2005 return E_NOTIMPL;
2008 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->html_element, p);
2009 if(NS_FAILED(nsres)) {
2010 ERR("GetOffsetWidth failed: %08lx\n", nsres);
2011 return E_FAIL;
2014 return S_OK;
2017 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
2019 HTMLElement *This = impl_from_IHTMLElement(iface);
2020 nsresult nsres;
2022 TRACE("(%p)->(%p)\n", This, p);
2024 if(!This->html_element) {
2025 FIXME("non-HTML element\n");
2026 return E_NOTIMPL;
2029 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->html_element, p);
2030 if(NS_FAILED(nsres)) {
2031 ERR("GetOffsetHeight failed: %08lx\n", nsres);
2032 return E_FAIL;
2035 return S_OK;
2038 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
2040 HTMLElement *This = impl_from_IHTMLElement(iface);
2041 nsIDOMElement *nsparent;
2042 HTMLElement *parent;
2043 nsresult nsres;
2044 HRESULT hres;
2046 TRACE("(%p)->(%p)\n", This, p);
2048 if(!This->html_element) {
2049 FIXME("non-HTML element\n");
2050 return E_NOTIMPL;
2053 nsres = nsIDOMHTMLElement_GetOffsetParent(This->html_element, &nsparent);
2054 if(NS_FAILED(nsres)) {
2055 ERR("GetOffsetParent failed: %08lx\n", nsres);
2056 return E_FAIL;
2059 if(!nsparent) {
2060 *p = NULL;
2061 return S_OK;
2064 hres = get_element(nsparent, &parent);
2065 nsIDOMElement_Release(nsparent);
2066 if(FAILED(hres))
2067 return hres;
2069 *p = &parent->IHTMLElement_iface;
2070 return S_OK;
2073 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
2075 HTMLElement *This = impl_from_IHTMLElement(iface);
2076 nsAString html_str;
2077 nsresult nsres;
2079 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2081 if(!This->html_element) {
2082 FIXME("non-HTML element\n");
2083 return E_NOTIMPL;
2086 nsAString_InitDepend(&html_str, v);
2087 nsres = nsIDOMHTMLElement_SetInnerHTML(This->html_element, &html_str);
2088 nsAString_Finish(&html_str);
2089 if(NS_FAILED(nsres)) {
2090 FIXME("SetInnerHtml failed %08lx\n", nsres);
2091 return E_FAIL;
2094 return S_OK;
2097 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
2099 HTMLElement *This = impl_from_IHTMLElement(iface);
2100 nsAString html_str;
2101 nsresult nsres;
2103 TRACE("(%p)->(%p)\n", This, p);
2105 if(!This->html_element) {
2106 FIXME("non-HTML element\n");
2107 return E_NOTIMPL;
2110 nsAString_Init(&html_str, NULL);
2111 nsres = nsIDOMHTMLElement_GetInnerHTML(This->html_element, &html_str);
2112 return return_nsstr(nsres, &html_str, p);
2115 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
2117 HTMLElement *This = impl_from_IHTMLElement(iface);
2118 nsIDOMNode *nschild, *tmp;
2119 nsIDOMText *text_node;
2120 nsAString text_str;
2121 nsresult nsres;
2123 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2125 while(1) {
2126 nsres = nsIDOMElement_GetLastChild(This->dom_element, &nschild);
2127 if(NS_FAILED(nsres)) {
2128 ERR("GetLastChild failed: %08lx\n", nsres);
2129 return E_FAIL;
2131 if(!nschild)
2132 break;
2134 nsres = nsIDOMElement_RemoveChild(This->dom_element, nschild, &tmp);
2135 nsIDOMNode_Release(nschild);
2136 if(NS_FAILED(nsres)) {
2137 ERR("RemoveChild failed: %08lx\n", nsres);
2138 return E_FAIL;
2140 nsIDOMNode_Release(tmp);
2143 nsAString_InitDepend(&text_str, v);
2144 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &text_str, &text_node);
2145 nsAString_Finish(&text_str);
2146 if(NS_FAILED(nsres)) {
2147 ERR("CreateTextNode failed: %08lx\n", nsres);
2148 return E_FAIL;
2151 nsres = nsIDOMElement_AppendChild(This->dom_element, (nsIDOMNode*)text_node, &tmp);
2152 nsIDOMText_Release(text_node);
2153 if(NS_FAILED(nsres)) {
2154 ERR("AppendChild failed: %08lx\n", nsres);
2155 return E_FAIL;
2158 nsIDOMNode_Release(tmp);
2159 return S_OK;
2162 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
2164 HTMLElement *This = impl_from_IHTMLElement(iface);
2166 TRACE("(%p)->(%p)\n", This, p);
2168 return get_node_text(&This->node, p);
2171 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
2173 HTMLElement *This = impl_from_IHTMLElement(iface);
2175 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2177 return replace_node_by_html(This->node.doc->dom_document, This->node.nsnode, v);
2180 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
2182 HTMLElement *This = impl_from_IHTMLElement(iface);
2183 nsAString html_str;
2184 HRESULT hres;
2186 WARN("(%p)->(%p) semi-stub\n", This, p);
2188 nsAString_Init(&html_str, NULL);
2189 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
2190 if(SUCCEEDED(hres)) {
2191 const PRUnichar *html;
2193 nsAString_GetData(&html_str, &html);
2194 *p = SysAllocString(html);
2195 if(!*p)
2196 hres = E_OUTOFMEMORY;
2199 nsAString_Finish(&html_str);
2201 TRACE("ret %s\n", debugstr_w(*p));
2202 return hres;
2205 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
2207 HTMLElement *This = impl_from_IHTMLElement(iface);
2208 nsIDOMText *text_node;
2209 nsIDOMRange *range;
2210 nsAString nsstr;
2211 nsresult nsres;
2213 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2215 if(This->node.vtbl->is_settable && !This->node.vtbl->is_settable(&This->node, DISPID_IHTMLELEMENT_OUTERTEXT)) {
2216 WARN("Called on element that does not support setting the property.\n");
2217 return 0x800a0258; /* undocumented error code */
2220 if(!This->node.doc->dom_document) {
2221 FIXME("NULL dom_document\n");
2222 return E_FAIL;
2225 nsAString_InitDepend(&nsstr, v);
2226 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &nsstr, &text_node);
2227 nsAString_Finish(&nsstr);
2228 if(NS_FAILED(nsres)) {
2229 ERR("CreateTextNode failed\n");
2230 return E_FAIL;
2233 nsres = nsIDOMDocument_CreateRange(This->node.doc->dom_document, &range);
2234 if(NS_SUCCEEDED(nsres)) {
2235 nsres = nsIDOMRange_SelectNode(range, This->node.nsnode);
2236 if(NS_SUCCEEDED(nsres))
2237 nsres = nsIDOMRange_DeleteContents(range);
2238 if(NS_SUCCEEDED(nsres))
2239 nsres = nsIDOMRange_InsertNode(range, (nsIDOMNode*)text_node);
2240 if(NS_SUCCEEDED(nsres))
2241 nsres = nsIDOMRange_SelectNodeContents(range, This->node.nsnode);
2242 if(NS_SUCCEEDED(nsres))
2243 nsres = nsIDOMRange_DeleteContents(range);
2244 nsIDOMRange_Release(range);
2246 nsIDOMText_Release(text_node);
2247 if(NS_FAILED(nsres)) {
2248 ERR("failed to set text: %08lx\n", nsres);
2249 return E_FAIL;
2252 return S_OK;
2255 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
2257 HTMLElement *This = impl_from_IHTMLElement(iface);
2259 TRACE("(%p)->(%p)\n", This, p);
2261 /* getter is the same as innerText */
2262 return IHTMLElement_get_innerText(&This->IHTMLElement_iface, p);
2265 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
2267 nsIDOMNode *ret_nsnode;
2268 nsresult nsres;
2269 HRESULT hres = S_OK;
2271 if (!wcsicmp(where, L"beforebegin")) {
2272 nsIDOMNode *parent;
2274 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2275 if(NS_FAILED(nsres))
2276 return E_FAIL;
2278 if(!parent)
2279 return E_INVALIDARG;
2281 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
2282 nsIDOMNode_Release(parent);
2283 }else if(!wcsicmp(where, L"afterbegin")) {
2284 nsIDOMNode *first_child;
2286 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
2287 if(NS_FAILED(nsres))
2288 return E_FAIL;
2290 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
2291 if(NS_FAILED(nsres))
2292 return E_FAIL;
2294 if (first_child)
2295 nsIDOMNode_Release(first_child);
2296 }else if (!wcsicmp(where, L"beforeend")) {
2297 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
2298 }else if (!wcsicmp(where, L"afterend")) {
2299 nsIDOMNode *next_sibling, *parent;
2301 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2302 if(NS_FAILED(nsres))
2303 return E_FAIL;
2304 if(!parent)
2305 return E_INVALIDARG;
2307 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
2308 if(NS_SUCCEEDED(nsres)) {
2309 if(next_sibling) {
2310 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
2311 nsIDOMNode_Release(next_sibling);
2312 }else {
2313 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
2317 nsIDOMNode_Release(parent);
2318 }else {
2319 ERR("invalid where: %s\n", debugstr_w(where));
2320 return E_INVALIDARG;
2323 if (NS_FAILED(nsres))
2324 return E_FAIL;
2326 if(ret_node)
2327 hres = get_node(ret_nsnode, TRUE, ret_node);
2328 nsIDOMNode_Release(ret_nsnode);
2329 return hres;
2332 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
2333 BSTR html)
2335 HTMLElement *This = impl_from_IHTMLElement(iface);
2336 nsIDOMRange *range;
2337 nsIDOMNode *nsnode;
2338 nsAString ns_html;
2339 nsresult nsres;
2340 HRESULT hr;
2342 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
2344 if(!This->node.doc->dom_document) {
2345 WARN("NULL dom_document\n");
2346 return E_UNEXPECTED;
2349 nsres = nsIDOMDocument_CreateRange(This->node.doc->dom_document, &range);
2350 if(NS_FAILED(nsres))
2352 ERR("CreateRange failed: %08lx\n", nsres);
2353 return E_FAIL;
2356 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
2358 nsAString_InitDepend(&ns_html, html);
2359 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
2360 nsAString_Finish(&ns_html);
2361 nsIDOMRange_Release(range);
2363 if(NS_FAILED(nsres) || !nsnode)
2365 ERR("CreateTextNode failed: %08lx\n", nsres);
2366 return E_FAIL;
2369 hr = insert_adjacent_node(This, where, nsnode, NULL);
2370 nsIDOMNode_Release(nsnode);
2371 return hr;
2374 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
2375 BSTR text)
2377 HTMLElement *This = impl_from_IHTMLElement(iface);
2378 nsIDOMNode *nsnode;
2379 nsAString ns_text;
2380 nsresult nsres;
2381 HRESULT hr;
2383 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
2385 if(!This->node.doc->dom_document) {
2386 WARN("NULL dom_document\n");
2387 return E_UNEXPECTED;
2391 nsAString_InitDepend(&ns_text, text);
2392 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &ns_text, (nsIDOMText **)&nsnode);
2393 nsAString_Finish(&ns_text);
2395 if(NS_FAILED(nsres) || !nsnode)
2397 ERR("CreateTextNode failed: %08lx\n", nsres);
2398 return E_FAIL;
2401 hr = insert_adjacent_node(This, where, nsnode, NULL);
2402 nsIDOMNode_Release(nsnode);
2404 return hr;
2407 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
2409 HTMLElement *This = impl_from_IHTMLElement(iface);
2410 FIXME("(%p)->(%p)\n", This, p);
2411 return E_NOTIMPL;
2414 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
2416 HTMLElement *This = impl_from_IHTMLElement(iface);
2418 TRACE("(%p)->(%p)\n", This, p);
2420 *p = variant_bool(This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node));
2421 return S_OK;
2424 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
2426 HTMLElement *This = impl_from_IHTMLElement(iface);
2427 nsresult nsres;
2429 TRACE("(%p)\n", This);
2431 if(!This->html_element) {
2432 FIXME("non-HTML element\n");
2433 return E_NOTIMPL;
2436 nsres = nsIDOMHTMLElement_Click(This->html_element);
2437 if(NS_FAILED(nsres)) {
2438 ERR("Click failed: %08lx\n", nsres);
2439 return E_FAIL;
2442 return S_OK;
2445 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface, IHTMLFiltersCollection **p)
2447 HTMLElement *This = impl_from_IHTMLElement(iface);
2449 TRACE("(%p)->(%p)\n", This, p);
2451 if(!p)
2452 return E_POINTER;
2454 return create_filters_collection(dispex_compat_mode(&This->node.event_target.dispex), p);
2457 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
2459 HTMLElement *This = impl_from_IHTMLElement(iface);
2461 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2463 return set_node_event(&This->node, EVENTID_DRAGSTART, &v);
2466 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
2468 HTMLElement *This = impl_from_IHTMLElement(iface);
2470 TRACE("(%p)->(%p)\n", This, p);
2472 return get_node_event(&This->node, EVENTID_DRAGSTART, p);
2475 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
2477 HTMLElement *This = impl_from_IHTMLElement(iface);
2478 HRESULT hres;
2479 VARIANT var;
2481 TRACE("(%p)->(%p)\n", This, String);
2483 if(!String)
2484 return E_INVALIDARG;
2486 hres = IWineJSDispatchHost_InvokeEx(&This->node.event_target.dispex.IWineJSDispatchHost_iface, DISPID_VALUE,
2487 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, NULL, &var, NULL, NULL);
2488 if(SUCCEEDED(hres)) {
2489 assert(V_VT(&var) == VT_BSTR);
2490 *String = V_BSTR(&var);
2492 return hres;
2495 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
2497 HTMLElement *This = impl_from_IHTMLElement(iface);
2498 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2499 return E_NOTIMPL;
2502 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
2504 HTMLElement *This = impl_from_IHTMLElement(iface);
2505 FIXME("(%p)->(%p)\n", This, p);
2506 return E_NOTIMPL;
2509 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
2511 HTMLElement *This = impl_from_IHTMLElement(iface);
2512 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2513 return E_NOTIMPL;
2516 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
2518 HTMLElement *This = impl_from_IHTMLElement(iface);
2519 FIXME("(%p)->(%p)\n", This, p);
2520 return E_NOTIMPL;
2523 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
2525 HTMLElement *This = impl_from_IHTMLElement(iface);
2526 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2527 return E_NOTIMPL;
2530 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
2532 HTMLElement *This = impl_from_IHTMLElement(iface);
2533 FIXME("(%p)->(%p)\n", This, p);
2534 return E_NOTIMPL;
2537 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
2539 HTMLElement *This = impl_from_IHTMLElement(iface);
2540 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2541 return E_NOTIMPL;
2544 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
2546 HTMLElement *This = impl_from_IHTMLElement(iface);
2547 FIXME("(%p)->(%p)\n", This, p);
2548 return E_NOTIMPL;
2551 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
2553 HTMLElement *This = impl_from_IHTMLElement(iface);
2554 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2555 return E_NOTIMPL;
2558 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
2560 HTMLElement *This = impl_from_IHTMLElement(iface);
2561 FIXME("(%p)->(%p)\n", This, p);
2562 return E_NOTIMPL;
2565 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
2567 HTMLElement *This = impl_from_IHTMLElement(iface);
2568 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2569 return E_NOTIMPL;
2572 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
2574 HTMLElement *This = impl_from_IHTMLElement(iface);
2575 FIXME("(%p)->(%p)\n", This, p);
2576 return E_NOTIMPL;
2579 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
2581 HTMLElement *This = impl_from_IHTMLElement(iface);
2583 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
2585 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
2588 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
2590 HTMLElement *This = impl_from_IHTMLElement(iface);
2592 TRACE("(%p)->(%p)\n", This, p);
2594 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
2597 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
2599 HTMLElement *This = impl_from_IHTMLElement(iface);
2600 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2601 return E_NOTIMPL;
2604 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
2606 HTMLElement *This = impl_from_IHTMLElement(iface);
2607 FIXME("(%p)->(%p)\n", This, p);
2608 return E_NOTIMPL;
2611 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
2613 HTMLElement *This = impl_from_IHTMLElement(iface);
2614 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2615 return E_NOTIMPL;
2618 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
2620 HTMLElement *This = impl_from_IHTMLElement(iface);
2621 FIXME("(%p)->(%p)\n", This, p);
2622 return E_NOTIMPL;
2625 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
2627 HTMLElement *This = impl_from_IHTMLElement(iface);
2628 nsIDOMNodeList *nsnode_list;
2629 nsresult nsres;
2631 TRACE("(%p)->(%p)\n", This, p);
2633 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
2634 if(NS_FAILED(nsres)) {
2635 ERR("GetChildNodes failed: %08lx\n", nsres);
2636 return E_FAIL;
2639 *p = (IDispatch*)create_collection_from_nodelist(nsnode_list, This->node.doc->document_mode);
2641 nsIDOMNodeList_Release(nsnode_list);
2642 return S_OK;
2645 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
2647 HTMLElement *This = impl_from_IHTMLElement(iface);
2649 TRACE("(%p)->(%p)\n", This, p);
2651 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
2652 return S_OK;
2655 static const IHTMLElementVtbl HTMLElementVtbl = {
2656 HTMLElement_QueryInterface,
2657 HTMLElement_AddRef,
2658 HTMLElement_Release,
2659 HTMLElement_GetTypeInfoCount,
2660 HTMLElement_GetTypeInfo,
2661 HTMLElement_GetIDsOfNames,
2662 HTMLElement_Invoke,
2663 HTMLElement_setAttribute,
2664 HTMLElement_getAttribute,
2665 HTMLElement_removeAttribute,
2666 HTMLElement_put_className,
2667 HTMLElement_get_className,
2668 HTMLElement_put_id,
2669 HTMLElement_get_id,
2670 HTMLElement_get_tagName,
2671 HTMLElement_get_parentElement,
2672 HTMLElement_get_style,
2673 HTMLElement_put_onhelp,
2674 HTMLElement_get_onhelp,
2675 HTMLElement_put_onclick,
2676 HTMLElement_get_onclick,
2677 HTMLElement_put_ondblclick,
2678 HTMLElement_get_ondblclick,
2679 HTMLElement_put_onkeydown,
2680 HTMLElement_get_onkeydown,
2681 HTMLElement_put_onkeyup,
2682 HTMLElement_get_onkeyup,
2683 HTMLElement_put_onkeypress,
2684 HTMLElement_get_onkeypress,
2685 HTMLElement_put_onmouseout,
2686 HTMLElement_get_onmouseout,
2687 HTMLElement_put_onmouseover,
2688 HTMLElement_get_onmouseover,
2689 HTMLElement_put_onmousemove,
2690 HTMLElement_get_onmousemove,
2691 HTMLElement_put_onmousedown,
2692 HTMLElement_get_onmousedown,
2693 HTMLElement_put_onmouseup,
2694 HTMLElement_get_onmouseup,
2695 HTMLElement_get_document,
2696 HTMLElement_put_title,
2697 HTMLElement_get_title,
2698 HTMLElement_put_language,
2699 HTMLElement_get_language,
2700 HTMLElement_put_onselectstart,
2701 HTMLElement_get_onselectstart,
2702 HTMLElement_scrollIntoView,
2703 HTMLElement_contains,
2704 HTMLElement_get_sourceIndex,
2705 HTMLElement_get_recordNumber,
2706 HTMLElement_put_lang,
2707 HTMLElement_get_lang,
2708 HTMLElement_get_offsetLeft,
2709 HTMLElement_get_offsetTop,
2710 HTMLElement_get_offsetWidth,
2711 HTMLElement_get_offsetHeight,
2712 HTMLElement_get_offsetParent,
2713 HTMLElement_put_innerHTML,
2714 HTMLElement_get_innerHTML,
2715 HTMLElement_put_innerText,
2716 HTMLElement_get_innerText,
2717 HTMLElement_put_outerHTML,
2718 HTMLElement_get_outerHTML,
2719 HTMLElement_put_outerText,
2720 HTMLElement_get_outerText,
2721 HTMLElement_insertAdjacentHTML,
2722 HTMLElement_insertAdjacentText,
2723 HTMLElement_get_parentTextEdit,
2724 HTMLElement_get_isTextEdit,
2725 HTMLElement_click,
2726 HTMLElement_get_filters,
2727 HTMLElement_put_ondragstart,
2728 HTMLElement_get_ondragstart,
2729 HTMLElement_toString,
2730 HTMLElement_put_onbeforeupdate,
2731 HTMLElement_get_onbeforeupdate,
2732 HTMLElement_put_onafterupdate,
2733 HTMLElement_get_onafterupdate,
2734 HTMLElement_put_onerrorupdate,
2735 HTMLElement_get_onerrorupdate,
2736 HTMLElement_put_onrowexit,
2737 HTMLElement_get_onrowexit,
2738 HTMLElement_put_onrowenter,
2739 HTMLElement_get_onrowenter,
2740 HTMLElement_put_ondatasetchanged,
2741 HTMLElement_get_ondatasetchanged,
2742 HTMLElement_put_ondataavailable,
2743 HTMLElement_get_ondataavailable,
2744 HTMLElement_put_ondatasetcomplete,
2745 HTMLElement_get_ondatasetcomplete,
2746 HTMLElement_put_onfilterchange,
2747 HTMLElement_get_onfilterchange,
2748 HTMLElement_get_children,
2749 HTMLElement_get_all
2752 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2754 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2757 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2759 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2762 DISPEX_IDISPATCH_IMPL(HTMLElement2, IHTMLElement2,
2763 impl_from_IHTMLElement2(iface)->node.event_target.dispex)
2765 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2767 HTMLElement *This = impl_from_IHTMLElement2(iface);
2768 FIXME("(%p)->(%p)\n", This, p);
2769 return E_NOTIMPL;
2772 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2774 HTMLElement *This = impl_from_IHTMLElement2(iface);
2775 FIXME("(%p)->(%x)\n", This, containerCapture);
2776 return E_NOTIMPL;
2779 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2781 HTMLElement *This = impl_from_IHTMLElement2(iface);
2782 FIXME("(%p)\n", This);
2783 return E_NOTIMPL;
2786 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2788 HTMLElement *This = impl_from_IHTMLElement2(iface);
2789 FIXME("(%p)->()\n", This);
2790 return E_NOTIMPL;
2793 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2795 HTMLElement *This = impl_from_IHTMLElement2(iface);
2796 FIXME("(%p)->(%p)\n", This, p);
2797 return E_NOTIMPL;
2800 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2801 LONG x, LONG y, BSTR *component)
2803 HTMLElement *This = impl_from_IHTMLElement2(iface);
2804 FIXME("(%p)->(%ld %ld %p)\n", This, x, y, component);
2805 return E_NOTIMPL;
2808 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2810 HTMLElement *This = impl_from_IHTMLElement2(iface);
2812 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2814 if(!This->node.doc->content_ready || !This->node.doc->doc_obj->in_place_active)
2815 return E_PENDING;
2817 WARN("stub\n");
2818 return S_OK;
2821 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2823 HTMLElement *This = impl_from_IHTMLElement2(iface);
2825 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2827 return set_node_event(&This->node, EVENTID_SCROLL, &v);
2830 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2832 HTMLElement *This = impl_from_IHTMLElement2(iface);
2834 TRACE("(%p)->(%p)\n", This, p);
2836 return get_node_event(&This->node, EVENTID_SCROLL, p);
2839 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2841 HTMLElement *This = impl_from_IHTMLElement2(iface);
2843 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2845 return set_node_event(&This->node, EVENTID_DRAG, &v);
2848 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2850 HTMLElement *This = impl_from_IHTMLElement2(iface);
2852 TRACE("(%p)->(%p)\n", This, p);
2854 return get_node_event(&This->node, EVENTID_DRAG, p);
2857 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2859 HTMLElement *This = impl_from_IHTMLElement2(iface);
2860 FIXME("(%p)->()\n", This);
2861 return E_NOTIMPL;
2864 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2866 HTMLElement *This = impl_from_IHTMLElement2(iface);
2867 FIXME("(%p)->(%p)\n", This, p);
2868 return E_NOTIMPL;
2871 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2873 HTMLElement *This = impl_from_IHTMLElement2(iface);
2874 FIXME("(%p)->()\n", This);
2875 return E_NOTIMPL;
2878 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2880 HTMLElement *This = impl_from_IHTMLElement2(iface);
2881 FIXME("(%p)->(%p)\n", This, p);
2882 return E_NOTIMPL;
2885 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2887 HTMLElement *This = impl_from_IHTMLElement2(iface);
2888 FIXME("(%p)->()\n", This);
2889 return E_NOTIMPL;
2892 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2894 HTMLElement *This = impl_from_IHTMLElement2(iface);
2895 FIXME("(%p)->(%p)\n", This, p);
2896 return E_NOTIMPL;
2899 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2901 HTMLElement *This = impl_from_IHTMLElement2(iface);
2902 FIXME("(%p)->()\n", This);
2903 return E_NOTIMPL;
2906 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2908 HTMLElement *This = impl_from_IHTMLElement2(iface);
2909 FIXME("(%p)->(%p)\n", This, p);
2910 return E_NOTIMPL;
2913 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2915 HTMLElement *This = impl_from_IHTMLElement2(iface);
2916 FIXME("(%p)->()\n", This);
2917 return E_NOTIMPL;
2920 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2922 HTMLElement *This = impl_from_IHTMLElement2(iface);
2923 FIXME("(%p)->(%p)\n", This, p);
2924 return E_NOTIMPL;
2927 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2929 HTMLElement *This = impl_from_IHTMLElement2(iface);
2930 FIXME("(%p)->()\n", This);
2931 return E_NOTIMPL;
2934 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2936 HTMLElement *This = impl_from_IHTMLElement2(iface);
2937 FIXME("(%p)->(%p)\n", This, p);
2938 return E_NOTIMPL;
2941 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2943 HTMLElement *This = impl_from_IHTMLElement2(iface);
2944 FIXME("(%p)->()\n", This);
2945 return E_NOTIMPL;
2948 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2950 HTMLElement *This = impl_from_IHTMLElement2(iface);
2951 FIXME("(%p)->(%p)\n", This, p);
2952 return E_NOTIMPL;
2955 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2957 HTMLElement *This = impl_from_IHTMLElement2(iface);
2958 FIXME("(%p)->()\n", This);
2959 return E_NOTIMPL;
2962 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2964 HTMLElement *This = impl_from_IHTMLElement2(iface);
2965 FIXME("(%p)->(%p)\n", This, p);
2966 return E_NOTIMPL;
2969 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2971 HTMLElement *This = impl_from_IHTMLElement2(iface);
2972 FIXME("(%p)->()\n", This);
2973 return E_NOTIMPL;
2976 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2978 HTMLElement *This = impl_from_IHTMLElement2(iface);
2979 FIXME("(%p)->(%p)\n", This, p);
2980 return E_NOTIMPL;
2983 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2985 HTMLElement *This = impl_from_IHTMLElement2(iface);
2986 FIXME("(%p)->()\n", This);
2987 return E_NOTIMPL;
2990 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2992 HTMLElement *This = impl_from_IHTMLElement2(iface);
2993 FIXME("(%p)->(%p)\n", This, p);
2994 return E_NOTIMPL;
2997 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2999 HTMLElement *This = impl_from_IHTMLElement2(iface);
3001 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3003 return set_node_event(&This->node, EVENTID_PASTE, &v);
3006 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
3008 HTMLElement *This = impl_from_IHTMLElement2(iface);
3010 TRACE("(%p)->(%p)\n", This, p);
3012 return get_node_event(&This->node, EVENTID_PASTE, p);
3015 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
3017 HTMLElement *This = impl_from_IHTMLElement2(iface);
3019 TRACE("(%p)->(%p)\n", This, p);
3021 return HTMLCurrentStyle_Create(This, p);
3024 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
3026 HTMLElement *This = impl_from_IHTMLElement2(iface);
3027 FIXME("(%p)->()\n", This);
3028 return E_NOTIMPL;
3031 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
3033 HTMLElement *This = impl_from_IHTMLElement2(iface);
3034 FIXME("(%p)->(%p)\n", This, p);
3035 return E_NOTIMPL;
3038 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
3040 HTMLElement *This = impl_from_IHTMLElement2(iface);
3041 nsIDOMClientRectList *rect_list;
3042 HTMLRectCollection *rects;
3043 nsresult nsres;
3045 TRACE("(%p)->(%p)\n", This, pRectCol);
3047 if(!This->dom_element) {
3048 FIXME("comment element\n");
3049 return E_NOTIMPL;
3052 nsres = nsIDOMElement_GetClientRects(This->dom_element, &rect_list);
3053 if(NS_FAILED(nsres)) {
3054 WARN("GetClientRects failed: %08lx\n", nsres);
3055 return map_nsresult(nsres);
3058 rects = calloc(1, sizeof(*rects));
3059 if(!rects) {
3060 nsIDOMClientRectList_Release(rect_list);
3061 return E_OUTOFMEMORY;
3064 rects->IHTMLRectCollection_iface.lpVtbl = &HTMLRectCollectionVtbl;
3065 rects->rect_list = rect_list;
3066 init_dispatch(&rects->dispex, &HTMLRectCollection_dispex, dispex_compat_mode(&This->node.event_target.dispex));
3068 *pRectCol = &rects->IHTMLRectCollection_iface;
3069 return S_OK;
3072 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
3074 HTMLElement *This = impl_from_IHTMLElement2(iface);
3075 nsIDOMClientRect *nsrect;
3076 nsresult nsres;
3077 HRESULT hres;
3079 TRACE("(%p)->(%p)\n", This, pRect);
3081 if(!This->dom_element) {
3082 FIXME("comment element\n");
3083 return E_NOTIMPL;
3086 nsres = nsIDOMElement_GetBoundingClientRect(This->dom_element, &nsrect);
3087 if(NS_FAILED(nsres) || !nsrect) {
3088 ERR("GetBoindingClientRect failed: %08lx\n", nsres);
3089 return E_FAIL;
3092 hres = create_html_rect(nsrect, dispex_compat_mode(&This->node.event_target.dispex), pRect);
3094 nsIDOMClientRect_Release(nsrect);
3095 return hres;
3098 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
3099 BSTR expression, BSTR language)
3101 HTMLElement *This = impl_from_IHTMLElement2(iface);
3102 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
3103 debugstr_w(language));
3104 return E_NOTIMPL;
3107 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
3108 VARIANT *expression)
3110 HTMLElement *This = impl_from_IHTMLElement2(iface);
3111 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
3112 return E_NOTIMPL;
3115 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
3116 VARIANT_BOOL *pfSuccess)
3118 HTMLElement *This = impl_from_IHTMLElement2(iface);
3119 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
3120 return E_NOTIMPL;
3123 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
3125 HTMLElement *This = impl_from_IHTMLElement2(iface);
3126 nsresult nsres;
3128 TRACE("(%p)->(%d)\n", This, v);
3130 if(!This->html_element) {
3131 FIXME("non-HTML element\n");
3132 return E_NOTIMPL;
3135 nsres = nsIDOMHTMLElement_SetTabIndex(This->html_element, v);
3136 if(NS_FAILED(nsres))
3137 ERR("GetTabIndex failed: %08lx\n", nsres);
3139 return S_OK;
3142 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
3144 HTMLElement *This = impl_from_IHTMLElement2(iface);
3145 LONG index;
3146 nsresult nsres;
3148 TRACE("(%p)->(%p)\n", This, p);
3150 if(!This->html_element) {
3151 FIXME("non-HTML element\n");
3152 return E_NOTIMPL;
3155 nsres = nsIDOMHTMLElement_GetTabIndex(This->html_element, &index);
3156 if(NS_FAILED(nsres)) {
3157 ERR("GetTabIndex failed: %08lx\n", nsres);
3158 return E_FAIL;
3161 *p = index;
3162 return S_OK;
3165 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
3167 HTMLElement *This = impl_from_IHTMLElement2(iface);
3168 nsresult nsres;
3170 TRACE("(%p)\n", This);
3172 if(!This->html_element) {
3173 FIXME("non-HTML element\n");
3174 return E_NOTIMPL;
3177 nsres = nsIDOMHTMLElement_Focus(This->html_element);
3178 if(NS_FAILED(nsres))
3179 ERR("Focus failed: %08lx\n", nsres);
3181 return S_OK;
3184 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
3186 HTMLElement *This = impl_from_IHTMLElement2(iface);
3187 nsAString nsstr;
3188 nsresult nsres;
3190 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3192 if(!This->html_element) {
3193 FIXME("non-HTML element\n");
3194 return E_NOTIMPL;
3197 nsAString_InitDepend(&nsstr, v);
3198 nsres = nsIDOMHTMLElement_SetAccessKey(This->html_element, &nsstr);
3199 nsAString_Finish(&nsstr);
3200 return map_nsresult(nsres);
3203 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
3205 HTMLElement *This = impl_from_IHTMLElement2(iface);
3206 nsAString nsstr;
3207 nsresult nsres;
3209 TRACE("(%p)->(%p)\n", This, p);
3211 if(!This->html_element) {
3212 FIXME("non-HTML element\n");
3213 return E_NOTIMPL;
3216 nsAString_InitDepend(&nsstr, NULL);
3217 nsres = nsIDOMHTMLElement_GetAccessKey(This->html_element, &nsstr);
3218 return return_nsstr(nsres, &nsstr, p);
3221 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
3223 HTMLElement *This = impl_from_IHTMLElement2(iface);
3225 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3227 return set_node_event(&This->node, EVENTID_BLUR, &v);
3230 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
3232 HTMLElement *This = impl_from_IHTMLElement2(iface);
3234 TRACE("(%p)->(%p)\n", This, p);
3236 return get_node_event(&This->node, EVENTID_BLUR, p);
3239 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
3241 HTMLElement *This = impl_from_IHTMLElement2(iface);
3243 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3245 return set_node_event(&This->node, EVENTID_FOCUS, &v);
3248 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
3250 HTMLElement *This = impl_from_IHTMLElement2(iface);
3252 TRACE("(%p)->(%p)\n", This, p);
3254 return get_node_event(&This->node, EVENTID_FOCUS, p);
3257 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
3259 HTMLElement *This = impl_from_IHTMLElement2(iface);
3261 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3263 return set_node_event(&This->node, EVENTID_RESIZE, &v);
3266 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
3268 HTMLElement *This = impl_from_IHTMLElement2(iface);
3270 TRACE("(%p)->(%p)\n", This, p);
3272 return get_node_event(&This->node, EVENTID_RESIZE, p);
3275 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
3277 HTMLElement *This = impl_from_IHTMLElement2(iface);
3278 nsresult nsres;
3280 TRACE("(%p)\n", This);
3282 if(!This->html_element) {
3283 FIXME("non-HTML element\n");
3284 return E_NOTIMPL;
3287 nsres = nsIDOMHTMLElement_Blur(This->html_element);
3288 if(NS_FAILED(nsres)) {
3289 ERR("Blur failed: %08lx\n", nsres);
3290 return E_FAIL;
3293 return S_OK;
3296 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3298 HTMLElement *This = impl_from_IHTMLElement2(iface);
3299 FIXME("(%p)->(%p)\n", This, pUnk);
3300 return E_NOTIMPL;
3303 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3305 HTMLElement *This = impl_from_IHTMLElement2(iface);
3306 FIXME("(%p)->(%p)\n", This, pUnk);
3307 return E_NOTIMPL;
3310 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
3312 HTMLElement *This = impl_from_IHTMLElement2(iface);
3313 nsresult nsres;
3315 TRACE("(%p)->(%p)\n", This, p);
3317 if(!This->dom_element) {
3318 FIXME("Unimplemented for comment element\n");
3319 return E_NOTIMPL;
3322 nsres = nsIDOMElement_GetClientHeight(This->dom_element, p);
3323 assert(nsres == NS_OK);
3324 return S_OK;
3327 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
3329 HTMLElement *This = impl_from_IHTMLElement2(iface);
3330 nsresult nsres;
3332 TRACE("(%p)->(%p)\n", This, p);
3334 if(!This->dom_element) {
3335 FIXME("comment element\n");
3336 return E_NOTIMPL;
3339 nsres = nsIDOMElement_GetClientWidth(This->dom_element, p);
3340 assert(nsres == NS_OK);
3341 return S_OK;
3344 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
3346 HTMLElement *This = impl_from_IHTMLElement2(iface);
3347 nsresult nsres;
3349 TRACE("(%p)->(%p)\n", This, p);
3351 if(!This->dom_element) {
3352 FIXME("comment element\n");
3353 return E_NOTIMPL;
3356 nsres = nsIDOMElement_GetClientTop(This->dom_element, p);
3357 assert(nsres == NS_OK);
3359 TRACE("*p = %ld\n", *p);
3360 return S_OK;
3363 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
3365 HTMLElement *This = impl_from_IHTMLElement2(iface);
3366 nsresult nsres;
3368 TRACE("(%p)->(%p)\n", This, p);
3370 if(!This->dom_element) {
3371 FIXME("comment element\n");
3372 return E_NOTIMPL;
3375 nsres = nsIDOMElement_GetClientLeft(This->dom_element, p);
3376 assert(nsres == NS_OK);
3378 TRACE("*p = %ld\n", *p);
3379 return S_OK;
3382 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
3383 IDispatch *pDisp, VARIANT_BOOL *pfResult)
3385 HTMLElement *This = impl_from_IHTMLElement2(iface);
3387 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
3389 return attach_event(&This->node.event_target, event, pDisp, pfResult);
3392 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
3394 HTMLElement *This = impl_from_IHTMLElement2(iface);
3396 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
3398 return detach_event(&This->node.event_target, event, pDisp);
3401 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
3403 HTMLElement *This = impl_from_IHTMLElement2(iface);
3404 BSTR str;
3406 TRACE("(%p)->(%p)\n", This, p);
3408 if(This->node.vtbl->get_readystate) {
3409 HRESULT hres;
3411 hres = This->node.vtbl->get_readystate(&This->node, &str);
3412 if(FAILED(hres))
3413 return hres;
3414 }else {
3415 str = SysAllocString(L"complete");
3416 if(!str)
3417 return E_OUTOFMEMORY;
3420 V_VT(p) = VT_BSTR;
3421 V_BSTR(p) = str;
3422 return S_OK;
3425 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
3427 HTMLElement *This = impl_from_IHTMLElement2(iface);
3429 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3431 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
3434 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
3436 HTMLElement *This = impl_from_IHTMLElement2(iface);
3438 TRACE("(%p)->(%p)\n", This, p);
3440 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
3443 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
3445 HTMLElement *This = impl_from_IHTMLElement2(iface);
3446 FIXME("(%p)->()\n", This);
3447 return E_NOTIMPL;
3450 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
3452 HTMLElement *This = impl_from_IHTMLElement2(iface);
3453 FIXME("(%p)->(%p)\n", This, p);
3454 return E_NOTIMPL;
3457 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
3459 HTMLElement *This = impl_from_IHTMLElement2(iface);
3460 FIXME("(%p)->()\n", This);
3461 return E_NOTIMPL;
3464 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
3466 HTMLElement *This = impl_from_IHTMLElement2(iface);
3467 FIXME("(%p)->(%p)\n", This, p);
3468 return E_NOTIMPL;
3471 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
3473 HTMLElement *This = impl_from_IHTMLElement2(iface);
3474 FIXME("(%p)->()\n", This);
3475 return E_NOTIMPL;
3478 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
3480 HTMLElement *This = impl_from_IHTMLElement2(iface);
3481 FIXME("(%p)->(%p)\n", This, p);
3482 return E_NOTIMPL;
3485 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
3487 HTMLElement *This = impl_from_IHTMLElement2(iface);
3488 nsAString nsstr;
3489 nsresult nsres;
3491 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3493 if(!This->html_element) {
3494 FIXME("non-HTML element\n");
3495 return S_OK;
3498 nsAString_InitDepend(&nsstr, v);
3499 nsres = nsIDOMHTMLElement_SetDir(This->html_element, &nsstr);
3500 nsAString_Finish(&nsstr);
3501 if(NS_FAILED(nsres)) {
3502 ERR("SetDir failed: %08lx\n", nsres);
3503 return E_FAIL;
3506 return S_OK;
3509 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
3511 HTMLElement *This = impl_from_IHTMLElement2(iface);
3512 nsAString dir_str;
3513 nsresult nsres;
3515 TRACE("(%p)->(%p)\n", This, p);
3517 if(!This->html_element) {
3518 if(This->dom_element)
3519 FIXME("non-HTML element\n");
3520 *p = NULL;
3521 return S_OK;
3524 nsAString_Init(&dir_str, NULL);
3525 nsres = nsIDOMHTMLElement_GetDir(This->html_element, &dir_str);
3526 return return_nsstr(nsres, &dir_str, p);
3529 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
3531 HTMLElement *This = impl_from_IHTMLElement2(iface);
3532 FIXME("(%p)->(%p)\n", This, range);
3533 return E_NOTIMPL;
3536 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
3538 HTMLElement *This = impl_from_IHTMLElement2(iface);
3539 nsresult nsres;
3541 TRACE("(%p)->(%p)\n", This, p);
3543 if(!This->dom_element) {
3544 FIXME("comment element\n");
3545 return E_NOTIMPL;
3548 nsres = nsIDOMElement_GetScrollHeight(This->dom_element, p);
3549 assert(nsres == NS_OK);
3550 TRACE("*p = %ld\n", *p);
3551 return S_OK;
3554 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
3556 HTMLElement *This = impl_from_IHTMLElement2(iface);
3557 nsresult nsres;
3559 TRACE("(%p)->(%p)\n", This, p);
3561 if(!This->dom_element) {
3562 FIXME("comment element\n");
3563 return E_NOTIMPL;
3566 nsres = nsIDOMElement_GetScrollWidth(This->dom_element, p);
3567 assert(nsres == NS_OK);
3569 TRACE("*p = %ld\n", *p);
3570 return S_OK;
3573 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
3575 HTMLElement *This = impl_from_IHTMLElement2(iface);
3577 TRACE("(%p)->(%ld)\n", This, v);
3579 if(!This->dom_element) {
3580 FIXME("comment element\n");
3581 return E_NOTIMPL;
3584 nsIDOMElement_SetScrollTop(This->dom_element, v);
3585 return S_OK;
3588 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
3590 HTMLElement *This = impl_from_IHTMLElement2(iface);
3591 nsresult nsres;
3593 TRACE("(%p)->(%p)\n", This, p);
3595 if(!This->dom_element) {
3596 FIXME("comment element\n");
3597 return E_NOTIMPL;
3600 nsres = nsIDOMElement_GetScrollTop(This->dom_element, p);
3601 assert(nsres == NS_OK);
3603 TRACE("*p = %ld\n", *p);
3604 return S_OK;
3607 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
3609 HTMLElement *This = impl_from_IHTMLElement2(iface);
3611 TRACE("(%p)->(%ld)\n", This, v);
3613 if(!This->dom_element) {
3614 FIXME("comment element\n");
3615 return E_NOTIMPL;
3618 nsIDOMElement_SetScrollLeft(This->dom_element, v);
3619 return S_OK;
3622 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
3624 HTMLElement *This = impl_from_IHTMLElement2(iface);
3625 nsresult nsres;
3627 TRACE("(%p)->(%p)\n", This, p);
3629 if(!p)
3630 return E_INVALIDARG;
3632 if(!This->dom_element) {
3633 FIXME("comment element\n");
3634 return E_NOTIMPL;
3637 nsres = nsIDOMElement_GetScrollLeft(This->dom_element, p);
3638 assert(nsres == NS_OK);
3639 TRACE("*p = %ld\n", *p);
3640 return S_OK;
3643 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
3645 HTMLElement *This = impl_from_IHTMLElement2(iface);
3646 FIXME("(%p)\n", This);
3647 return E_NOTIMPL;
3650 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
3652 HTMLElement *This = impl_from_IHTMLElement2(iface);
3653 FIXME("(%p)->(%p)\n", This, mergeThis);
3654 return E_NOTIMPL;
3657 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
3659 HTMLElement *This = impl_from_IHTMLElement2(iface);
3661 TRACE("(%p)->()\n", This);
3663 return set_node_event(&This->node, EVENTID_CONTEXTMENU, &v);
3666 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
3668 HTMLElement *This = impl_from_IHTMLElement2(iface);
3670 TRACE("(%p)->(%p)\n", This, p);
3672 return get_node_event(&This->node, EVENTID_CONTEXTMENU, p);
3675 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
3676 IHTMLElement *insertedElement, IHTMLElement **inserted)
3678 HTMLElement *This = impl_from_IHTMLElement2(iface);
3679 HTMLDOMNode *ret_node;
3680 HTMLElement *elem;
3681 HRESULT hres;
3683 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
3685 elem = unsafe_impl_from_IHTMLElement(insertedElement);
3686 if(!elem)
3687 return E_INVALIDARG;
3689 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
3690 if(FAILED(hres))
3691 return hres;
3693 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
3694 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
3695 return hres;
3698 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
3699 BSTR where, IHTMLElement **applied)
3701 HTMLElement *This = impl_from_IHTMLElement2(iface);
3702 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
3703 return E_NOTIMPL;
3706 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
3708 HTMLElement *This = impl_from_IHTMLElement2(iface);
3709 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
3710 return E_NOTIMPL;
3713 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
3714 BSTR newText, BSTR *oldText)
3716 HTMLElement *This = impl_from_IHTMLElement2(iface);
3717 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
3718 return E_NOTIMPL;
3721 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
3723 HTMLElement *This = impl_from_IHTMLElement2(iface);
3724 FIXME("(%p)->(%p)\n", This, p);
3725 return E_NOTIMPL;
3728 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
3729 VARIANT *pvarFactory, LONG *pCookie)
3731 HTMLElement *This = impl_from_IHTMLElement2(iface);
3732 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
3733 return E_NOTIMPL;
3736 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
3737 VARIANT_BOOL *pfResult)
3739 HTMLElement *This = impl_from_IHTMLElement2(iface);
3740 FIXME("(%p)->(%ld %p)\n", This, cookie, pfResult);
3741 return E_NOTIMPL;
3744 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
3746 HTMLElement *This = impl_from_IHTMLElement2(iface);
3748 FIXME("(%p)->(%p): hack\n", This, p);
3750 /* We can't implement correct behavior on top of Gecko (although we could
3751 try a bit harder). Making runtimeStyle behave like regular style is
3752 enough for most use cases. */
3753 if(!This->runtime_style) {
3754 HRESULT hres;
3756 hres = HTMLStyle_Create(This, &This->runtime_style);
3757 if(FAILED(hres))
3758 return hres;
3761 *p = &This->runtime_style->IHTMLStyle_iface;
3762 IHTMLStyle_AddRef(*p);
3763 return S_OK;
3766 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
3768 HTMLElement *This = impl_from_IHTMLElement2(iface);
3769 FIXME("(%p)->(%p)\n", This, p);
3770 return E_NOTIMPL;
3773 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
3775 HTMLElement *This = impl_from_IHTMLElement2(iface);
3776 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3777 return E_NOTIMPL;
3780 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
3782 HTMLElement *This = impl_from_IHTMLElement2(iface);
3783 FIXME("(%p)->(%p)\n", This, p);
3784 return E_NOTIMPL;
3787 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
3789 HTMLElement *This = impl_from_IHTMLElement2(iface);
3790 FIXME("(%p)->()\n", This);
3791 return E_NOTIMPL;
3794 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
3796 HTMLElement *This = impl_from_IHTMLElement2(iface);
3797 FIXME("(%p)->(%p)\n", This, p);
3798 return E_NOTIMPL;
3801 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
3803 HTMLElement *This = impl_from_IHTMLElement2(iface);
3804 FIXME("(%p)->(%p)\n", This, p);
3805 return E_NOTIMPL;
3808 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
3809 IHTMLElementCollection **pelColl)
3811 HTMLElement *This = impl_from_IHTMLElement2(iface);
3812 nsIDOMHTMLCollection *nscol;
3813 nsAString tag_str;
3814 nsresult nsres;
3816 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
3818 if(!This->dom_element) {
3819 *pelColl = create_collection_from_htmlcol(NULL, This->node.doc->document_mode);
3820 return S_OK;
3823 nsAString_InitDepend(&tag_str, v);
3824 nsres = nsIDOMElement_GetElementsByTagName(This->dom_element, &tag_str, &nscol);
3825 nsAString_Finish(&tag_str);
3826 if(NS_FAILED(nsres)) {
3827 ERR("GetElementByTagName failed: %08lx\n", nsres);
3828 return E_FAIL;
3831 *pelColl = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
3832 nsIDOMHTMLCollection_Release(nscol);
3833 return S_OK;
3836 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
3837 HTMLElement2_QueryInterface,
3838 HTMLElement2_AddRef,
3839 HTMLElement2_Release,
3840 HTMLElement2_GetTypeInfoCount,
3841 HTMLElement2_GetTypeInfo,
3842 HTMLElement2_GetIDsOfNames,
3843 HTMLElement2_Invoke,
3844 HTMLElement2_get_scopeName,
3845 HTMLElement2_setCapture,
3846 HTMLElement2_releaseCapture,
3847 HTMLElement2_put_onlosecapture,
3848 HTMLElement2_get_onlosecapture,
3849 HTMLElement2_componentFromPoint,
3850 HTMLElement2_doScroll,
3851 HTMLElement2_put_onscroll,
3852 HTMLElement2_get_onscroll,
3853 HTMLElement2_put_ondrag,
3854 HTMLElement2_get_ondrag,
3855 HTMLElement2_put_ondragend,
3856 HTMLElement2_get_ondragend,
3857 HTMLElement2_put_ondragenter,
3858 HTMLElement2_get_ondragenter,
3859 HTMLElement2_put_ondragover,
3860 HTMLElement2_get_ondragover,
3861 HTMLElement2_put_ondragleave,
3862 HTMLElement2_get_ondragleave,
3863 HTMLElement2_put_ondrop,
3864 HTMLElement2_get_ondrop,
3865 HTMLElement2_put_onbeforecut,
3866 HTMLElement2_get_onbeforecut,
3867 HTMLElement2_put_oncut,
3868 HTMLElement2_get_oncut,
3869 HTMLElement2_put_onbeforecopy,
3870 HTMLElement2_get_onbeforecopy,
3871 HTMLElement2_put_oncopy,
3872 HTMLElement2_get_oncopy,
3873 HTMLElement2_put_onbeforepaste,
3874 HTMLElement2_get_onbeforepaste,
3875 HTMLElement2_put_onpaste,
3876 HTMLElement2_get_onpaste,
3877 HTMLElement2_get_currentStyle,
3878 HTMLElement2_put_onpropertychange,
3879 HTMLElement2_get_onpropertychange,
3880 HTMLElement2_getClientRects,
3881 HTMLElement2_getBoundingClientRect,
3882 HTMLElement2_setExpression,
3883 HTMLElement2_getExpression,
3884 HTMLElement2_removeExpression,
3885 HTMLElement2_put_tabIndex,
3886 HTMLElement2_get_tabIndex,
3887 HTMLElement2_focus,
3888 HTMLElement2_put_accessKey,
3889 HTMLElement2_get_accessKey,
3890 HTMLElement2_put_onblur,
3891 HTMLElement2_get_onblur,
3892 HTMLElement2_put_onfocus,
3893 HTMLElement2_get_onfocus,
3894 HTMLElement2_put_onresize,
3895 HTMLElement2_get_onresize,
3896 HTMLElement2_blur,
3897 HTMLElement2_addFilter,
3898 HTMLElement2_removeFilter,
3899 HTMLElement2_get_clientHeight,
3900 HTMLElement2_get_clientWidth,
3901 HTMLElement2_get_clientTop,
3902 HTMLElement2_get_clientLeft,
3903 HTMLElement2_attachEvent,
3904 HTMLElement2_detachEvent,
3905 HTMLElement2_get_readyState,
3906 HTMLElement2_put_onreadystatechange,
3907 HTMLElement2_get_onreadystatechange,
3908 HTMLElement2_put_onrowsdelete,
3909 HTMLElement2_get_onrowsdelete,
3910 HTMLElement2_put_onrowsinserted,
3911 HTMLElement2_get_onrowsinserted,
3912 HTMLElement2_put_oncellchange,
3913 HTMLElement2_get_oncellchange,
3914 HTMLElement2_put_dir,
3915 HTMLElement2_get_dir,
3916 HTMLElement2_createControlRange,
3917 HTMLElement2_get_scrollHeight,
3918 HTMLElement2_get_scrollWidth,
3919 HTMLElement2_put_scrollTop,
3920 HTMLElement2_get_scrollTop,
3921 HTMLElement2_put_scrollLeft,
3922 HTMLElement2_get_scrollLeft,
3923 HTMLElement2_clearAttributes,
3924 HTMLElement2_mergeAttributes,
3925 HTMLElement2_put_oncontextmenu,
3926 HTMLElement2_get_oncontextmenu,
3927 HTMLElement2_insertAdjacentElement,
3928 HTMLElement2_applyElement,
3929 HTMLElement2_getAdjacentText,
3930 HTMLElement2_replaceAdjacentText,
3931 HTMLElement2_get_canHandleChildren,
3932 HTMLElement2_addBehavior,
3933 HTMLElement2_removeBehavior,
3934 HTMLElement2_get_runtimeStyle,
3935 HTMLElement2_get_behaviorUrns,
3936 HTMLElement2_put_tagUrn,
3937 HTMLElement2_get_tagUrn,
3938 HTMLElement2_put_onbeforeeditfocus,
3939 HTMLElement2_get_onbeforeeditfocus,
3940 HTMLElement2_get_readyStateValue,
3941 HTMLElement2_getElementsByTagName,
3944 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3946 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3949 DISPEX_IDISPATCH_IMPL(HTMLElement3, IHTMLElement3,
3950 impl_from_IHTMLElement3(iface)->node.event_target.dispex)
3952 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3954 HTMLElement *This = impl_from_IHTMLElement3(iface);
3955 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3956 return E_NOTIMPL;
3959 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3961 HTMLElement *This = impl_from_IHTMLElement3(iface);
3962 FIXME("(%p)->(%p)\n", This, p);
3963 return E_NOTIMPL;
3966 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3968 HTMLElement *This = impl_from_IHTMLElement3(iface);
3969 FIXME("(%p)->(%p)\n", This, p);
3970 return E_NOTIMPL;
3973 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3975 HTMLElement *This = impl_from_IHTMLElement3(iface);
3976 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3977 return E_NOTIMPL;
3980 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3982 HTMLElement *This = impl_from_IHTMLElement3(iface);
3983 FIXME("(%p)->(%p)\n", This, p);
3984 return E_NOTIMPL;
3987 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3989 HTMLElement *This = impl_from_IHTMLElement3(iface);
3990 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3991 return E_NOTIMPL;
3994 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3996 HTMLElement *This = impl_from_IHTMLElement3(iface);
3997 FIXME("(%p)->(%p)\n", This, p);
3998 return E_NOTIMPL;
4001 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
4003 HTMLElement *This = impl_from_IHTMLElement3(iface);
4004 FIXME("(%p)->(%x)\n", This, v);
4005 return E_NOTIMPL;
4008 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
4010 HTMLElement *This = impl_from_IHTMLElement3(iface);
4011 FIXME("(%p)->(%p)\n", This, p);
4012 return E_NOTIMPL;
4015 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
4017 HTMLElement *This = impl_from_IHTMLElement3(iface);
4018 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4019 return E_NOTIMPL;
4022 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
4024 HTMLElement *This = impl_from_IHTMLElement3(iface);
4025 FIXME("(%p)->(%p)\n", This, p);
4026 return E_NOTIMPL;
4029 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
4031 HTMLElement *This = impl_from_IHTMLElement3(iface);
4032 FIXME("(%p)\n", This);
4033 return E_NOTIMPL;
4036 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
4038 HTMLElement *This = impl_from_IHTMLElement3(iface);
4039 nsresult nsres;
4040 nsAString str;
4042 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
4044 if(!This->html_element) {
4045 FIXME("non-HTML element\n");
4046 return E_NOTIMPL;
4049 nsAString_InitDepend(&str, v);
4050 nsres = nsIDOMHTMLElement_SetContentEditable(This->html_element, &str);
4051 nsAString_Finish(&str);
4053 if (NS_FAILED(nsres)){
4054 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
4055 return E_FAIL;
4058 return S_OK;
4061 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
4063 HTMLElement *This = impl_from_IHTMLElement3(iface);
4064 nsresult nsres;
4065 nsAString str;
4067 TRACE("(%p)->(%p)\n", This, p);
4069 if(!This->html_element) {
4070 FIXME("non-HTML element\n");
4071 return E_NOTIMPL;
4074 nsAString_Init(&str, NULL);
4075 nsres = nsIDOMHTMLElement_GetContentEditable(This->html_element, &str);
4076 return return_nsstr(nsres, &str, p);
4079 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
4081 HTMLElement *This = impl_from_IHTMLElement3(iface);
4082 nsresult nsres;
4083 cpp_bool r;
4085 TRACE("(%p)->(%p)\n", This, p);
4087 if(!This->html_element) {
4088 FIXME("non-HTML element\n");
4089 return E_NOTIMPL;
4092 nsres = nsIDOMHTMLElement_GetIsContentEditable(This->html_element, &r);
4093 *p = variant_bool(NS_SUCCEEDED(nsres) && r);
4094 return S_OK;
4097 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
4099 HTMLElement *This = impl_from_IHTMLElement3(iface);
4100 FIXME("(%p)->(%x)\n", This, v);
4101 return E_NOTIMPL;
4104 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
4106 HTMLElement *This = impl_from_IHTMLElement3(iface);
4107 FIXME("(%p)->(%p)\n", This, p);
4108 return E_NOTIMPL;
4111 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
4113 HTMLElement *This = impl_from_IHTMLElement3(iface);
4115 TRACE("(%p)->(%x)\n", This, v);
4117 if(This->node.vtbl->put_disabled)
4118 return This->node.vtbl->put_disabled(&This->node, v);
4120 if(!v) return element_remove_attribute(This, L"disabled");
4121 return elem_string_attr_setter(This, L"disabled", L"");
4124 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4126 HTMLElement *This = impl_from_IHTMLElement3(iface);
4128 TRACE("(%p)->(%p)\n", This, p);
4130 if(This->node.vtbl->get_disabled)
4131 return This->node.vtbl->get_disabled(&This->node, p);
4133 *p = variant_bool(element_has_attribute(This, L"disabled"));
4134 return S_OK;
4137 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4139 HTMLElement *This = impl_from_IHTMLElement3(iface);
4140 FIXME("(%p)->(%p)\n", This, p);
4141 return E_NOTIMPL;
4144 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
4146 HTMLElement *This = impl_from_IHTMLElement3(iface);
4147 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4148 return E_NOTIMPL;
4151 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
4153 HTMLElement *This = impl_from_IHTMLElement3(iface);
4154 FIXME("(%p)->(%p)\n", This, p);
4155 return E_NOTIMPL;
4158 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
4160 HTMLElement *This = impl_from_IHTMLElement3(iface);
4161 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4162 return E_NOTIMPL;
4165 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
4167 HTMLElement *This = impl_from_IHTMLElement3(iface);
4168 FIXME("(%p)->(%p)\n", This, p);
4169 return E_NOTIMPL;
4172 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
4173 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
4175 HTMLElement *This = impl_from_IHTMLElement3(iface);
4177 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
4178 pfCancelled);
4180 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
4183 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
4185 HTMLElement *This = impl_from_IHTMLElement3(iface);
4186 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4187 return E_NOTIMPL;
4190 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
4192 HTMLElement *This = impl_from_IHTMLElement3(iface);
4193 FIXME("(%p)->(%p)\n", This, p);
4194 return E_NOTIMPL;
4197 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
4199 HTMLElement *This = impl_from_IHTMLElement3(iface);
4200 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4201 return E_NOTIMPL;
4204 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
4206 HTMLElement *This = impl_from_IHTMLElement3(iface);
4207 FIXME("(%p)->(%p)\n", This, p);
4208 return E_NOTIMPL;
4211 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
4213 HTMLElement *This = impl_from_IHTMLElement3(iface);
4214 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4215 return E_NOTIMPL;
4218 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
4220 HTMLElement *This = impl_from_IHTMLElement3(iface);
4221 FIXME("(%p)->(%p)\n", This, p);
4222 return E_NOTIMPL;
4225 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
4227 HTMLElement *This = impl_from_IHTMLElement3(iface);
4228 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4229 return E_NOTIMPL;
4232 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
4234 HTMLElement *This = impl_from_IHTMLElement3(iface);
4235 FIXME("(%p)->(%p)\n", This, p);
4236 return E_NOTIMPL;
4239 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
4241 HTMLElement *This = impl_from_IHTMLElement3(iface);
4242 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4243 return E_NOTIMPL;
4246 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
4248 HTMLElement *This = impl_from_IHTMLElement3(iface);
4249 FIXME("(%p)->(%p)\n", This, p);
4250 return E_NOTIMPL;
4253 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
4255 HTMLElement *This = impl_from_IHTMLElement3(iface);
4256 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4257 return E_NOTIMPL;
4260 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
4262 HTMLElement *This = impl_from_IHTMLElement3(iface);
4263 FIXME("(%p)->(%p)\n", This, p);
4264 return E_NOTIMPL;
4267 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
4269 HTMLElement *This = impl_from_IHTMLElement3(iface);
4270 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4271 return E_NOTIMPL;
4274 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
4276 HTMLElement *This = impl_from_IHTMLElement3(iface);
4277 FIXME("(%p)->(%p)\n", This, p);
4278 return E_NOTIMPL;
4281 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
4283 HTMLElement *This = impl_from_IHTMLElement3(iface);
4284 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4285 return E_NOTIMPL;
4288 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
4290 HTMLElement *This = impl_from_IHTMLElement3(iface);
4291 FIXME("(%p)->(%p)\n", This, p);
4292 return E_NOTIMPL;
4295 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
4297 HTMLElement *This = impl_from_IHTMLElement3(iface);
4298 FIXME("(%p)->(%p)\n", This, pfRet);
4299 return E_NOTIMPL;
4302 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
4304 HTMLElement *This = impl_from_IHTMLElement3(iface);
4305 FIXME("(%p)->(%p)\n", This, p);
4306 return E_NOTIMPL;
4309 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
4310 HTMLElement3_QueryInterface,
4311 HTMLElement3_AddRef,
4312 HTMLElement3_Release,
4313 HTMLElement3_GetTypeInfoCount,
4314 HTMLElement3_GetTypeInfo,
4315 HTMLElement3_GetIDsOfNames,
4316 HTMLElement3_Invoke,
4317 HTMLElement3_mergeAttributes,
4318 HTMLElement3_get_isMultiLine,
4319 HTMLElement3_get_canHaveHTML,
4320 HTMLElement3_put_onlayoutcomplete,
4321 HTMLElement3_get_onlayoutcomplete,
4322 HTMLElement3_put_onpage,
4323 HTMLElement3_get_onpage,
4324 HTMLElement3_put_inflateBlock,
4325 HTMLElement3_get_inflateBlock,
4326 HTMLElement3_put_onbeforedeactivate,
4327 HTMLElement3_get_onbeforedeactivate,
4328 HTMLElement3_setActive,
4329 HTMLElement3_put_contentEditable,
4330 HTMLElement3_get_contentEditable,
4331 HTMLElement3_get_isContentEditable,
4332 HTMLElement3_put_hideFocus,
4333 HTMLElement3_get_hideFocus,
4334 HTMLElement3_put_disabled,
4335 HTMLElement3_get_disabled,
4336 HTMLElement3_get_isDisabled,
4337 HTMLElement3_put_onmove,
4338 HTMLElement3_get_onmove,
4339 HTMLElement3_put_oncontrolselect,
4340 HTMLElement3_get_oncontrolselect,
4341 HTMLElement3_fireEvent,
4342 HTMLElement3_put_onresizestart,
4343 HTMLElement3_get_onresizestart,
4344 HTMLElement3_put_onresizeend,
4345 HTMLElement3_get_onresizeend,
4346 HTMLElement3_put_onmovestart,
4347 HTMLElement3_get_onmovestart,
4348 HTMLElement3_put_onmoveend,
4349 HTMLElement3_get_onmoveend,
4350 HTMLElement3_put_onmousecenter,
4351 HTMLElement3_get_onmousecenter,
4352 HTMLElement3_put_onmouseleave,
4353 HTMLElement3_get_onmouseleave,
4354 HTMLElement3_put_onactivate,
4355 HTMLElement3_get_onactivate,
4356 HTMLElement3_put_ondeactivate,
4357 HTMLElement3_get_ondeactivate,
4358 HTMLElement3_dragDrop,
4359 HTMLElement3_get_glyphMode
4362 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
4364 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
4367 DISPEX_IDISPATCH_IMPL(HTMLElement4, IHTMLElement4,
4368 impl_from_IHTMLElement4(iface)->node.event_target.dispex)
4370 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
4372 HTMLElement *This = impl_from_IHTMLElement4(iface);
4374 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4376 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
4379 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
4381 HTMLElement *This = impl_from_IHTMLElement4(iface);
4383 TRACE("(%p)->(%p)\n", This, p);
4385 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
4388 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
4390 HTMLElement *This = impl_from_IHTMLElement4(iface);
4391 FIXME("(%p)\n", This);
4392 return E_NOTIMPL;
4395 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
4397 HTMLElement *This = impl_from_IHTMLElement4(iface);
4398 HTMLAttributeCollection *attrs;
4399 HRESULT hres;
4401 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
4403 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4404 if(FAILED(hres))
4405 return hres;
4407 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
4408 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4409 return hres;
4412 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4413 IHTMLDOMAttribute **ppretAttribute)
4415 HTMLElement *This = impl_from_IHTMLElement4(iface);
4416 HTMLDOMAttribute *attr, *iter, *replace = NULL;
4417 HTMLAttributeCollection *attrs;
4418 DISPID dispid;
4419 HRESULT hres;
4421 TRACE("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4423 attr = unsafe_impl_from_IHTMLDOMAttribute(pattr);
4424 if(!attr)
4425 return E_INVALIDARG;
4427 if(attr->elem) {
4428 WARN("Tried to set already attached attribute.\n");
4429 return E_INVALIDARG;
4432 hres = IWineJSDispatchHost_GetDispID(&This->node.event_target.dispex.IWineJSDispatchHost_iface,
4433 attr->name, fdexNameCaseInsensitive|fdexNameEnsure, &dispid);
4434 if(FAILED(hres))
4435 return hres;
4437 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4438 if(FAILED(hres))
4439 return hres;
4441 LIST_FOR_EACH_ENTRY(iter, &attrs->attrs, HTMLDOMAttribute, entry) {
4442 if(iter->dispid == dispid) {
4443 replace = iter;
4444 break;
4448 if(replace) {
4449 hres = get_elem_attr_value_by_dispid(This, dispid, &replace->value);
4450 if(FAILED(hres)) {
4451 WARN("could not get attr value: %08lx\n", hres);
4452 V_VT(&replace->value) = VT_EMPTY;
4454 if(!replace->name) {
4455 replace->name = attr->name;
4456 attr->name = NULL;
4458 list_add_head(&replace->entry, &attr->entry);
4459 list_remove(&replace->entry);
4460 replace->elem = NULL;
4461 }else {
4462 list_add_tail(&attrs->attrs, &attr->entry);
4463 IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4466 IHTMLDOMAttribute_AddRef(&attr->IHTMLDOMAttribute_iface);
4467 attr->elem = This;
4468 attr->dispid = dispid;
4470 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4472 hres = set_elem_attr_value_by_dispid(This, dispid, &attr->value);
4473 if(FAILED(hres))
4474 WARN("Could not set attribute value: %08lx\n", hres);
4475 VariantClear(&attr->value);
4477 *ppretAttribute = replace ? &replace->IHTMLDOMAttribute_iface : NULL;
4478 return S_OK;
4481 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4482 IHTMLDOMAttribute **ppretAttribute)
4484 HTMLElement *This = impl_from_IHTMLElement4(iface);
4485 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4486 return E_NOTIMPL;
4489 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
4491 HTMLElement *This = impl_from_IHTMLElement4(iface);
4493 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4495 return set_node_event(&This->node, EVENTID_BEFOREACTIVATE, &v);
4498 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
4500 HTMLElement *This = impl_from_IHTMLElement4(iface);
4502 TRACE("(%p)->(%p)\n", This, p);
4504 return get_node_event(&This->node, EVENTID_BEFOREACTIVATE, p);
4507 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
4509 HTMLElement *This = impl_from_IHTMLElement4(iface);
4511 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4513 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
4516 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
4518 HTMLElement *This = impl_from_IHTMLElement4(iface);
4520 TRACE("(%p)->(%p)\n", This, p);
4522 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
4525 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
4527 HTMLElement *This = impl_from_IHTMLElement4(iface);
4529 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4531 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
4534 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
4536 HTMLElement *This = impl_from_IHTMLElement4(iface);
4538 TRACE("(%p)->(%p)\n", This, p);
4540 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
4543 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
4544 HTMLElement4_QueryInterface,
4545 HTMLElement4_AddRef,
4546 HTMLElement4_Release,
4547 HTMLElement4_GetTypeInfoCount,
4548 HTMLElement4_GetTypeInfo,
4549 HTMLElement4_GetIDsOfNames,
4550 HTMLElement4_Invoke,
4551 HTMLElement4_put_onmousewheel,
4552 HTMLElement4_get_onmousewheel,
4553 HTMLElement4_normalize,
4554 HTMLElement4_getAttributeNode,
4555 HTMLElement4_setAttributeNode,
4556 HTMLElement4_removeAttributeNode,
4557 HTMLElement4_put_onbeforeactivate,
4558 HTMLElement4_get_onbeforeactivate,
4559 HTMLElement4_put_onfocusin,
4560 HTMLElement4_get_onfocusin,
4561 HTMLElement4_put_onfocusout,
4562 HTMLElement4_get_onfocusout
4565 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
4567 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
4570 DISPEX_IDISPATCH_IMPL(HTMLElement6, IHTMLElement6,
4571 impl_from_IHTMLElement6(iface)->node.event_target.dispex)
4573 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
4575 HTMLElement *This = impl_from_IHTMLElement6(iface);
4576 nsAString ns_str, name_str, value_str;
4577 nsresult nsres;
4578 HRESULT hres;
4580 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
4582 if(!This->dom_element) {
4583 FIXME("No dom_element\n");
4584 return E_NOTIMPL;
4587 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4588 if(FAILED(hres))
4589 return hres;
4591 nsAString_InitDepend(&name_str, strAttributeName);
4592 nsAString_InitDepend(&value_str, NULL);
4593 nsres = nsIDOMElement_GetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
4594 nsAString_Finish(&ns_str);
4595 nsAString_Finish(&name_str);
4597 hres = return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
4598 if(SUCCEEDED(hres) && V_VT(AttributeValue) == VT_NULL) {
4599 V_VT(AttributeValue) = VT_BSTR;
4600 V_BSTR(AttributeValue) = NULL;
4602 return hres;
4605 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4607 HTMLElement *This = impl_from_IHTMLElement6(iface);
4608 nsAString ns_str, name_str, value_str;
4609 const PRUnichar *ns;
4610 nsresult nsres;
4611 HRESULT hres;
4613 TRACE("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
4615 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4616 if(FAILED(hres))
4617 return hres;
4618 nsAString_GetData(&ns_str, &ns);
4619 if((!ns || !ns[0]) && wcschr(strAttributeName, ':')) {
4620 nsAString_Finish(&ns_str);
4621 /* FIXME: Return NamespaceError */
4622 return E_FAIL;
4625 if(!This->dom_element) {
4626 FIXME("No dom_element\n");
4627 nsAString_Finish(&ns_str);
4628 return E_NOTIMPL;
4631 hres = variant_to_nsstr(pvarAttributeValue, FALSE, &value_str);
4632 if(FAILED(hres)) {
4633 nsAString_Finish(&ns_str);
4634 return hres;
4637 nsAString_InitDepend(&name_str, strAttributeName);
4638 nsres = nsIDOMElement_SetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
4639 nsAString_Finish(&ns_str);
4640 nsAString_Finish(&name_str);
4641 nsAString_Finish(&value_str);
4642 if(NS_FAILED(nsres))
4643 WARN("SetAttributeNS failed: %08lx\n", nsres);
4644 return map_nsresult(nsres);
4647 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
4649 HTMLElement *This = impl_from_IHTMLElement6(iface);
4650 nsAString ns_str, name_str;
4651 nsresult nsres;
4652 HRESULT hres;
4654 TRACE("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
4656 if(!This->dom_element) {
4657 FIXME("No dom_element\n");
4658 return E_NOTIMPL;
4661 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4662 if(FAILED(hres))
4663 return hres;
4665 nsAString_InitDepend(&name_str, strAttributeName);
4666 nsres = nsIDOMElement_RemoveAttributeNS(This->dom_element, &ns_str, &name_str);
4667 nsAString_Finish(&ns_str);
4668 nsAString_Finish(&name_str);
4669 return map_nsresult(nsres);
4672 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
4674 HTMLElement *This = impl_from_IHTMLElement6(iface);
4675 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
4676 return E_NOTIMPL;
4679 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4681 HTMLElement *This = impl_from_IHTMLElement6(iface);
4682 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4683 return E_NOTIMPL;
4686 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
4688 HTMLElement *This = impl_from_IHTMLElement6(iface);
4689 nsAString ns_str, name_str;
4690 nsresult nsres;
4691 HRESULT hres;
4692 cpp_bool r;
4694 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
4696 if(!This->dom_element) {
4697 FIXME("No dom_element\n");
4698 return E_NOTIMPL;
4701 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4702 if(FAILED(hres))
4703 return hres;
4705 nsAString_InitDepend(&name_str, name);
4706 nsres = nsIDOMElement_HasAttributeNS(This->dom_element, &ns_str, &name_str, &r);
4707 nsAString_Finish(&ns_str);
4708 nsAString_Finish(&name_str);
4709 *pfHasAttribute = variant_bool(NS_SUCCEEDED(nsres) && r);
4710 return S_OK;
4713 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
4715 HTMLElement *This = impl_from_IHTMLElement6(iface);
4717 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), AttributeValue);
4719 return IHTMLElement_getAttribute(&This->IHTMLElement_iface, strAttributeName, 0, AttributeValue);
4722 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4724 HTMLElement *This = impl_from_IHTMLElement6(iface);
4726 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
4728 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, strAttributeName, *pvarAttributeValue, 0);
4731 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
4733 HTMLElement *This = impl_from_IHTMLElement6(iface);
4734 VARIANT_BOOL success;
4736 WARN("(%p)->(%s) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName));
4738 return IHTMLElement_removeAttribute(&This->IHTMLElement_iface, strAttributeName, 0, &success);
4741 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
4743 HTMLElement *This = impl_from_IHTMLElement6(iface);
4744 IHTMLDOMAttribute *attr;
4745 HRESULT hres;
4747 WARN("(%p)->(%s %p) forwarding to IHTMLElement4\n", This, debugstr_w(strAttributeName), ppretAttribute);
4749 hres = IHTMLElement4_getAttributeNode(&This->IHTMLElement4_iface, strAttributeName, &attr);
4750 if(FAILED(hres))
4751 return hres;
4753 if(attr) {
4754 hres = IHTMLDOMAttribute_QueryInterface(attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
4755 IHTMLDOMAttribute_Release(attr);
4756 }else {
4757 *ppretAttribute = NULL;
4759 return hres;
4762 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4764 HTMLElement *This = impl_from_IHTMLElement6(iface);
4765 IHTMLDOMAttribute *attr, *ret_attr;
4766 HRESULT hres;
4768 WARN("(%p)->(%p %p) forwarding to IHTMLElement4\n", This, pattr, ppretAttribute);
4770 hres = IHTMLDOMAttribute2_QueryInterface(pattr, &IID_IHTMLDOMAttribute, (void**)&attr);
4771 if(FAILED(hres))
4772 return hres;
4774 hres = IHTMLElement4_setAttributeNode(&This->IHTMLElement4_iface, attr, &ret_attr);
4775 if(FAILED(hres))
4776 return hres;
4778 if(ret_attr) {
4779 hres = IHTMLDOMAttribute_QueryInterface(ret_attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
4780 IHTMLDOMAttribute_Release(ret_attr);
4781 }else {
4782 *ppretAttribute = NULL;
4784 return hres;
4787 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4789 HTMLElement *This = impl_from_IHTMLElement6(iface);
4790 FIXME("(%p)->()\n", This);
4791 return E_NOTIMPL;
4794 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *p)
4796 HTMLElement *This = impl_from_IHTMLElement6(iface);
4798 TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), p);
4800 *p = element_has_attribute(This, name);
4801 return S_OK;
4804 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
4806 HTMLElement *This = impl_from_IHTMLElement6(iface);
4807 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
4808 return E_NOTIMPL;
4811 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
4813 HTMLElement *This = impl_from_IHTMLElement6(iface);
4815 TRACE("(%p)->(%p)\n", This, p);
4817 return IHTMLElement_get_tagName(&This->IHTMLElement_iface, p);
4820 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
4822 HTMLElement *This = impl_from_IHTMLElement6(iface);
4824 TRACE("(%p)->(%p)\n", This, p);
4826 return IHTMLDOMNode_get_nodeName(&This->node.IHTMLDOMNode_iface, p);
4829 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
4831 HTMLElement *This = impl_from_IHTMLElement6(iface);
4832 nsIDOMHTMLCollection *nscol = NULL;
4833 nsAString nsstr;
4834 nsresult nsres;
4836 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4838 if(This->dom_element) {
4839 nsAString_InitDepend(&nsstr, v);
4840 nsres = nsIDOMElement_GetElementsByClassName(This->dom_element, &nsstr, &nscol);
4841 nsAString_Finish(&nsstr);
4842 if(NS_FAILED(nsres)) {
4843 ERR("GetElementsByClassName failed: %08lx\n", nsres);
4844 return E_FAIL;
4848 *pel = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
4849 nsIDOMHTMLCollection_Release(nscol);
4850 return S_OK;
4853 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
4855 HTMLElement *This = impl_from_IHTMLElement6(iface);
4856 nsAString nsstr;
4857 cpp_bool b;
4858 nsresult nsres;
4860 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
4862 if(!This->dom_element) {
4863 FIXME("No dom element\n");
4864 return E_UNEXPECTED;
4867 nsAString_InitDepend(&nsstr, v);
4868 nsres = nsIDOMElement_MozMatchesSelector(This->dom_element, &nsstr, &b);
4869 nsAString_Finish(&nsstr);
4870 if(NS_FAILED(nsres)) {
4871 WARN("MozMatchesSelector failed: %08lx\n", nsres);
4872 return map_nsresult(nsres);
4875 *pfMatches = b;
4876 return S_OK;
4879 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
4881 HTMLElement *This = impl_from_IHTMLElement6(iface);
4883 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4885 return set_node_event(&This->node, EVENTID_ABORT, &v);
4888 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
4890 HTMLElement *This = impl_from_IHTMLElement6(iface);
4892 TRACE("(%p)->(%p)\n", This, p);
4894 return get_node_event(&This->node, EVENTID_ABORT, p);
4897 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
4899 HTMLElement *This = impl_from_IHTMLElement6(iface);
4900 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4901 return E_NOTIMPL;
4904 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
4906 HTMLElement *This = impl_from_IHTMLElement6(iface);
4907 FIXME("(%p)->(%p)\n", This, p);
4908 return E_NOTIMPL;
4911 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
4913 HTMLElement *This = impl_from_IHTMLElement6(iface);
4914 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4915 return E_NOTIMPL;
4918 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
4920 HTMLElement *This = impl_from_IHTMLElement6(iface);
4921 FIXME("(%p)->(%p)\n", This, p);
4922 return E_NOTIMPL;
4925 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
4927 HTMLElement *This = impl_from_IHTMLElement6(iface);
4929 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4931 return set_node_event(&This->node, EVENTID_CHANGE, &v);
4934 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
4936 HTMLElement *This = impl_from_IHTMLElement6(iface);
4938 TRACE("(%p)->(%p)\n", This, p);
4940 return get_node_event(&This->node, EVENTID_CHANGE, p);
4943 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
4945 HTMLElement *This = impl_from_IHTMLElement6(iface);
4946 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4947 return E_NOTIMPL;
4950 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
4952 HTMLElement *This = impl_from_IHTMLElement6(iface);
4953 FIXME("(%p)->(%p)\n", This, p);
4954 return E_NOTIMPL;
4957 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
4959 HTMLElement *This = impl_from_IHTMLElement6(iface);
4960 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4961 return E_NOTIMPL;
4964 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
4966 HTMLElement *This = impl_from_IHTMLElement6(iface);
4967 FIXME("(%p)->(%p)\n", This, p);
4968 return E_NOTIMPL;
4971 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
4973 HTMLElement *This = impl_from_IHTMLElement6(iface);
4974 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4975 return E_NOTIMPL;
4978 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
4980 HTMLElement *This = impl_from_IHTMLElement6(iface);
4981 FIXME("(%p)->(%p)\n", This, p);
4982 return E_NOTIMPL;
4985 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
4987 HTMLElement *This = impl_from_IHTMLElement6(iface);
4989 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4991 return set_node_event(&This->node, EVENTID_ERROR, &v);
4994 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
4996 HTMLElement *This = impl_from_IHTMLElement6(iface);
4998 TRACE("(%p)->(%p)\n", This, p);
5000 return get_node_event(&This->node, EVENTID_ERROR, p);
5003 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
5005 HTMLElement *This = impl_from_IHTMLElement6(iface);
5007 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5009 return set_node_event(&This->node, EVENTID_INPUT, &v);
5012 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
5014 HTMLElement *This = impl_from_IHTMLElement6(iface);
5016 TRACE("(%p)->(%p)\n", This, p);
5018 return get_node_event(&This->node, EVENTID_INPUT, p);
5021 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
5023 HTMLElement *This = impl_from_IHTMLElement6(iface);
5025 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5027 return set_node_event(&This->node, EVENTID_LOAD, &v);
5030 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
5032 HTMLElement *This = impl_from_IHTMLElement6(iface);
5034 TRACE("(%p)->(%p)\n", This, p);
5036 return get_node_event(&This->node, EVENTID_LOAD, p);
5039 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
5041 HTMLElement *This = impl_from_IHTMLElement6(iface);
5042 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5043 return E_NOTIMPL;
5046 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
5048 HTMLElement *This = impl_from_IHTMLElement6(iface);
5049 FIXME("(%p)->(%p)\n", This, p);
5050 return E_NOTIMPL;
5053 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
5055 HTMLElement *This = impl_from_IHTMLElement6(iface);
5056 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5057 return E_NOTIMPL;
5060 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
5062 HTMLElement *This = impl_from_IHTMLElement6(iface);
5063 FIXME("(%p)->(%p)\n", This, p);
5064 return E_NOTIMPL;
5067 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
5069 HTMLElement *This = impl_from_IHTMLElement6(iface);
5070 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5071 return E_NOTIMPL;
5074 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
5076 HTMLElement *This = impl_from_IHTMLElement6(iface);
5077 FIXME("(%p)->(%p)\n", This, p);
5078 return E_NOTIMPL;
5081 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
5083 HTMLElement *This = impl_from_IHTMLElement6(iface);
5084 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5085 return E_NOTIMPL;
5088 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
5090 HTMLElement *This = impl_from_IHTMLElement6(iface);
5091 FIXME("(%p)->(%p)\n", This, p);
5092 return E_NOTIMPL;
5095 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
5097 HTMLElement *This = impl_from_IHTMLElement6(iface);
5098 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5099 return E_NOTIMPL;
5102 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
5104 HTMLElement *This = impl_from_IHTMLElement6(iface);
5105 FIXME("(%p)->(%p)\n", This, p);
5106 return E_NOTIMPL;
5109 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
5111 HTMLElement *This = impl_from_IHTMLElement6(iface);
5112 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5113 return E_NOTIMPL;
5116 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
5118 HTMLElement *This = impl_from_IHTMLElement6(iface);
5119 FIXME("(%p)->(%p)\n", This, p);
5120 return E_NOTIMPL;
5123 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
5125 HTMLElement *This = impl_from_IHTMLElement6(iface);
5126 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5127 return E_NOTIMPL;
5130 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
5132 HTMLElement *This = impl_from_IHTMLElement6(iface);
5133 FIXME("(%p)->(%p)\n", This, p);
5134 return E_NOTIMPL;
5137 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
5139 HTMLElement *This = impl_from_IHTMLElement6(iface);
5140 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5141 return E_NOTIMPL;
5144 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
5146 HTMLElement *This = impl_from_IHTMLElement6(iface);
5147 FIXME("(%p)->(%p)\n", This, p);
5148 return E_NOTIMPL;
5151 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
5153 HTMLElement *This = impl_from_IHTMLElement6(iface);
5154 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5155 return E_NOTIMPL;
5158 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
5160 HTMLElement *This = impl_from_IHTMLElement6(iface);
5161 FIXME("(%p)->(%p)\n", This, p);
5162 return E_NOTIMPL;
5165 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
5167 HTMLElement *This = impl_from_IHTMLElement6(iface);
5168 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5169 return E_NOTIMPL;
5172 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
5174 HTMLElement *This = impl_from_IHTMLElement6(iface);
5175 FIXME("(%p)->(%p)\n", This, p);
5176 return E_NOTIMPL;
5179 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
5181 HTMLElement *This = impl_from_IHTMLElement6(iface);
5182 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5183 return E_NOTIMPL;
5186 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
5188 HTMLElement *This = impl_from_IHTMLElement6(iface);
5189 FIXME("(%p)->(%p)\n", This, p);
5190 return E_NOTIMPL;
5193 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
5195 HTMLElement *This = impl_from_IHTMLElement6(iface);
5196 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5197 return E_NOTIMPL;
5200 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
5202 HTMLElement *This = impl_from_IHTMLElement6(iface);
5203 FIXME("(%p)->(%p)\n", This, p);
5204 return E_NOTIMPL;
5207 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
5209 HTMLElement *This = impl_from_IHTMLElement6(iface);
5210 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5211 return E_NOTIMPL;
5214 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
5216 HTMLElement *This = impl_from_IHTMLElement6(iface);
5217 FIXME("(%p)->(%p)\n", This, p);
5218 return E_NOTIMPL;
5221 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
5223 HTMLElement *This = impl_from_IHTMLElement6(iface);
5225 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5227 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
5230 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
5232 HTMLElement *This = impl_from_IHTMLElement6(iface);
5234 TRACE("(%p)->(%p)\n", This, p);
5236 return get_node_event(&This->node, EVENTID_SUBMIT, p);
5239 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
5241 HTMLElement *This = impl_from_IHTMLElement6(iface);
5242 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5243 return E_NOTIMPL;
5246 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
5248 HTMLElement *This = impl_from_IHTMLElement6(iface);
5249 FIXME("(%p)->(%p)\n", This, p);
5250 return E_NOTIMPL;
5253 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
5255 HTMLElement *This = impl_from_IHTMLElement6(iface);
5256 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5257 return E_NOTIMPL;
5260 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
5262 HTMLElement *This = impl_from_IHTMLElement6(iface);
5263 FIXME("(%p)->(%p)\n", This, p);
5264 return E_NOTIMPL;
5267 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
5269 HTMLElement *This = impl_from_IHTMLElement6(iface);
5270 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5271 return E_NOTIMPL;
5274 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
5276 HTMLElement *This = impl_from_IHTMLElement6(iface);
5277 FIXME("(%p)->(%p)\n", This, p);
5278 return E_NOTIMPL;
5281 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
5283 HTMLElement *This = impl_from_IHTMLElement6(iface);
5284 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5285 return E_NOTIMPL;
5288 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
5290 HTMLElement *This = impl_from_IHTMLElement6(iface);
5291 FIXME("(%p)->(%p)\n", This, p);
5292 return E_NOTIMPL;
5295 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
5297 HTMLElement *This = impl_from_IHTMLElement6(iface);
5298 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
5299 return E_NOTIMPL;
5302 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
5303 HTMLElement6_QueryInterface,
5304 HTMLElement6_AddRef,
5305 HTMLElement6_Release,
5306 HTMLElement6_GetTypeInfoCount,
5307 HTMLElement6_GetTypeInfo,
5308 HTMLElement6_GetIDsOfNames,
5309 HTMLElement6_Invoke,
5310 HTMLElement6_getAttributeNS,
5311 HTMLElement6_setAttributeNS,
5312 HTMLElement6_removeAttributeNS,
5313 HTMLElement6_getAttributeNodeNS,
5314 HTMLElement6_setAttributeNodeNS,
5315 HTMLElement6_hasAttributeNS,
5316 HTMLElement6_getAttribute,
5317 HTMLElement6_setAttribute,
5318 HTMLElement6_removeAttribute,
5319 HTMLElement6_getAttributeNode,
5320 HTMLElement6_setAttributeNode,
5321 HTMLElement6_removeAttributeNode,
5322 HTMLElement6_hasAttribute,
5323 HTMLElement6_getElementsByTagNameNS,
5324 HTMLElement6_get_tagName,
5325 HTMLElement6_get_nodeName,
5326 HTMLElement6_getElementsByClassName,
5327 HTMLElement6_msMatchesSelector,
5328 HTMLElement6_put_onabort,
5329 HTMLElement6_get_onabort,
5330 HTMLElement6_put_oncanplay,
5331 HTMLElement6_get_oncanplay,
5332 HTMLElement6_put_oncanplaythrough,
5333 HTMLElement6_get_oncanplaythrough,
5334 HTMLElement6_put_onchange,
5335 HTMLElement6_get_onchange,
5336 HTMLElement6_put_ondurationchange,
5337 HTMLElement6_get_ondurationchange,
5338 HTMLElement6_put_onemptied,
5339 HTMLElement6_get_onemptied,
5340 HTMLElement6_put_onended,
5341 HTMLElement6_get_onended,
5342 HTMLElement6_put_onerror,
5343 HTMLElement6_get_onerror,
5344 HTMLElement6_put_oninput,
5345 HTMLElement6_get_oninput,
5346 HTMLElement6_put_onload,
5347 HTMLElement6_get_onload,
5348 HTMLElement6_put_onloadeddata,
5349 HTMLElement6_get_onloadeddata,
5350 HTMLElement6_put_onloadedmetadata,
5351 HTMLElement6_get_onloadedmetadata,
5352 HTMLElement6_put_onloadstart,
5353 HTMLElement6_get_onloadstart,
5354 HTMLElement6_put_onpause,
5355 HTMLElement6_get_onpause,
5356 HTMLElement6_put_onplay,
5357 HTMLElement6_get_onplay,
5358 HTMLElement6_put_onplaying,
5359 HTMLElement6_get_onplaying,
5360 HTMLElement6_put_onprogress,
5361 HTMLElement6_get_onprogress,
5362 HTMLElement6_put_onratechange,
5363 HTMLElement6_get_onratechange,
5364 HTMLElement6_put_onreset,
5365 HTMLElement6_get_onreset,
5366 HTMLElement6_put_onseeked,
5367 HTMLElement6_get_onseeked,
5368 HTMLElement6_put_onseeking,
5369 HTMLElement6_get_onseeking,
5370 HTMLElement6_put_onselect,
5371 HTMLElement6_get_onselect,
5372 HTMLElement6_put_onstalled,
5373 HTMLElement6_get_onstalled,
5374 HTMLElement6_put_onsubmit,
5375 HTMLElement6_get_onsubmit,
5376 HTMLElement6_put_onsuspend,
5377 HTMLElement6_get_onsuspend,
5378 HTMLElement6_put_ontimeupdate,
5379 HTMLElement6_get_ontimeupdate,
5380 HTMLElement6_put_onvolumechange,
5381 HTMLElement6_get_onvolumechange,
5382 HTMLElement6_put_onwaiting,
5383 HTMLElement6_get_onwaiting,
5384 HTMLElement6_hasAttributes
5387 static inline HTMLElement *impl_from_IHTMLElement7(IHTMLElement7 *iface)
5389 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement7_iface);
5392 DISPEX_IDISPATCH_IMPL(HTMLElement7, IHTMLElement7,
5393 impl_from_IHTMLElement7(iface)->node.event_target.dispex)
5395 static HRESULT WINAPI HTMLElement7_put_onmspointerdown(IHTMLElement7 *iface, VARIANT v)
5397 HTMLElement *This = impl_from_IHTMLElement7(iface);
5398 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5399 return E_NOTIMPL;
5402 static HRESULT WINAPI HTMLElement7_get_onmspointerdown(IHTMLElement7 *iface, VARIANT *p)
5404 HTMLElement *This = impl_from_IHTMLElement7(iface);
5405 FIXME("(%p)->(%p)\n", This, p);
5406 return E_NOTIMPL;
5409 static HRESULT WINAPI HTMLElement7_put_onmspointermove(IHTMLElement7 *iface, VARIANT v)
5411 HTMLElement *This = impl_from_IHTMLElement7(iface);
5412 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5413 return E_NOTIMPL;
5416 static HRESULT WINAPI HTMLElement7_get_onmspointermove(IHTMLElement7 *iface, VARIANT *p)
5418 HTMLElement *This = impl_from_IHTMLElement7(iface);
5419 FIXME("(%p)->(%p)\n", This, p);
5420 return E_NOTIMPL;
5423 static HRESULT WINAPI HTMLElement7_put_onmspointerup(IHTMLElement7 *iface, VARIANT v)
5425 HTMLElement *This = impl_from_IHTMLElement7(iface);
5426 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5427 return E_NOTIMPL;
5430 static HRESULT WINAPI HTMLElement7_get_onmspointerup(IHTMLElement7 *iface, VARIANT *p)
5432 HTMLElement *This = impl_from_IHTMLElement7(iface);
5433 FIXME("(%p)->(%p)\n", This, p);
5434 return E_NOTIMPL;
5437 static HRESULT WINAPI HTMLElement7_put_onmspointerover(IHTMLElement7 *iface, VARIANT v)
5439 HTMLElement *This = impl_from_IHTMLElement7(iface);
5440 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5441 return E_NOTIMPL;
5444 static HRESULT WINAPI HTMLElement7_get_onmspointerover(IHTMLElement7 *iface, VARIANT *p)
5446 HTMLElement *This = impl_from_IHTMLElement7(iface);
5447 FIXME("(%p)->(%p)\n", This, p);
5448 return E_NOTIMPL;
5451 static HRESULT WINAPI HTMLElement7_put_onmspointerout(IHTMLElement7 *iface, VARIANT v)
5453 HTMLElement *This = impl_from_IHTMLElement7(iface);
5454 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5455 return E_NOTIMPL;
5458 static HRESULT WINAPI HTMLElement7_get_onmspointerout(IHTMLElement7 *iface, VARIANT *p)
5460 HTMLElement *This = impl_from_IHTMLElement7(iface);
5461 FIXME("(%p)->(%p)\n", This, p);
5462 return E_NOTIMPL;
5465 static HRESULT WINAPI HTMLElement7_put_onmspointercancel(IHTMLElement7 *iface, VARIANT v)
5467 HTMLElement *This = impl_from_IHTMLElement7(iface);
5468 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5469 return E_NOTIMPL;
5472 static HRESULT WINAPI HTMLElement7_get_onmspointercancel(IHTMLElement7 *iface, VARIANT *p)
5474 HTMLElement *This = impl_from_IHTMLElement7(iface);
5475 FIXME("(%p)->(%p)\n", This, p);
5476 return E_NOTIMPL;
5479 static HRESULT WINAPI HTMLElement7_put_onmspointerhover(IHTMLElement7 *iface, VARIANT v)
5481 HTMLElement *This = impl_from_IHTMLElement7(iface);
5482 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5483 return E_NOTIMPL;
5486 static HRESULT WINAPI HTMLElement7_get_onmspointerhover(IHTMLElement7 *iface, VARIANT *p)
5488 HTMLElement *This = impl_from_IHTMLElement7(iface);
5489 FIXME("(%p)->(%p)\n", This, p);
5490 return E_NOTIMPL;
5493 static HRESULT WINAPI HTMLElement7_put_onmslostpointercapture(IHTMLElement7 *iface, VARIANT v)
5495 HTMLElement *This = impl_from_IHTMLElement7(iface);
5496 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5497 return E_NOTIMPL;
5500 static HRESULT WINAPI HTMLElement7_get_onmslostpointercapture(IHTMLElement7 *iface, VARIANT *p)
5502 HTMLElement *This = impl_from_IHTMLElement7(iface);
5503 FIXME("(%p)->(%p)\n", This, p);
5504 return E_NOTIMPL;
5507 static HRESULT WINAPI HTMLElement7_put_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT v)
5509 HTMLElement *This = impl_from_IHTMLElement7(iface);
5510 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5511 return E_NOTIMPL;
5514 static HRESULT WINAPI HTMLElement7_get_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT *p)
5516 HTMLElement *This = impl_from_IHTMLElement7(iface);
5517 FIXME("(%p)->(%p)\n", This, p);
5518 return E_NOTIMPL;
5521 static HRESULT WINAPI HTMLElement7_put_onmsgesturestart(IHTMLElement7 *iface, VARIANT v)
5523 HTMLElement *This = impl_from_IHTMLElement7(iface);
5524 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5525 return E_NOTIMPL;
5528 static HRESULT WINAPI HTMLElement7_get_onmsgesturestart(IHTMLElement7 *iface, VARIANT *p)
5530 HTMLElement *This = impl_from_IHTMLElement7(iface);
5531 FIXME("(%p)->(%p)\n", This, p);
5532 return E_NOTIMPL;
5535 static HRESULT WINAPI HTMLElement7_put_onmsgesturechange(IHTMLElement7 *iface, VARIANT v)
5537 HTMLElement *This = impl_from_IHTMLElement7(iface);
5538 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5539 return E_NOTIMPL;
5542 static HRESULT WINAPI HTMLElement7_get_onmsgesturechange(IHTMLElement7 *iface, VARIANT *p)
5544 HTMLElement *This = impl_from_IHTMLElement7(iface);
5545 FIXME("(%p)->(%p)\n", This, p);
5546 return E_NOTIMPL;
5549 static HRESULT WINAPI HTMLElement7_put_onmsgestureend(IHTMLElement7 *iface, VARIANT v)
5551 HTMLElement *This = impl_from_IHTMLElement7(iface);
5552 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5553 return E_NOTIMPL;
5556 static HRESULT WINAPI HTMLElement7_get_onmsgestureend(IHTMLElement7 *iface, VARIANT *p)
5558 HTMLElement *This = impl_from_IHTMLElement7(iface);
5559 FIXME("(%p)->(%p)\n", This, p);
5560 return E_NOTIMPL;
5563 static HRESULT WINAPI HTMLElement7_put_onmsgesturehold(IHTMLElement7 *iface, VARIANT v)
5565 HTMLElement *This = impl_from_IHTMLElement7(iface);
5566 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5567 return E_NOTIMPL;
5570 static HRESULT WINAPI HTMLElement7_get_onmsgesturehold(IHTMLElement7 *iface, VARIANT *p)
5572 HTMLElement *This = impl_from_IHTMLElement7(iface);
5573 FIXME("(%p)->(%p)\n", This, p);
5574 return E_NOTIMPL;
5577 static HRESULT WINAPI HTMLElement7_put_onmsgesturetap(IHTMLElement7 *iface, VARIANT v)
5579 HTMLElement *This = impl_from_IHTMLElement7(iface);
5580 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5581 return E_NOTIMPL;
5584 static HRESULT WINAPI HTMLElement7_get_onmsgesturetap(IHTMLElement7 *iface, VARIANT *p)
5586 HTMLElement *This = impl_from_IHTMLElement7(iface);
5587 FIXME("(%p)->(%p)\n", This, p);
5588 return E_NOTIMPL;
5591 static HRESULT WINAPI HTMLElement7_put_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT v)
5593 HTMLElement *This = impl_from_IHTMLElement7(iface);
5594 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5595 return E_NOTIMPL;
5598 static HRESULT WINAPI HTMLElement7_get_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT *p)
5600 HTMLElement *This = impl_from_IHTMLElement7(iface);
5601 FIXME("(%p)->(%p)\n", This, p);
5602 return E_NOTIMPL;
5605 static HRESULT WINAPI HTMLElement7_put_onmsinertiastart(IHTMLElement7 *iface, VARIANT v)
5607 HTMLElement *This = impl_from_IHTMLElement7(iface);
5608 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5609 return E_NOTIMPL;
5612 static HRESULT WINAPI HTMLElement7_get_onmsinertiastart(IHTMLElement7 *iface, VARIANT *p)
5614 HTMLElement *This = impl_from_IHTMLElement7(iface);
5615 FIXME("(%p)->(%p)\n", This, p);
5616 return E_NOTIMPL;
5619 static HRESULT WINAPI HTMLElement7_msSetPointerCapture(IHTMLElement7 *iface, LONG pointer_id)
5621 HTMLElement *This = impl_from_IHTMLElement7(iface);
5622 FIXME("(%p)->(%ld)\n", This, pointer_id);
5623 return E_NOTIMPL;
5626 static HRESULT WINAPI HTMLElement7_msReleasePointerCapture(IHTMLElement7 *iface, LONG pointer_id)
5628 HTMLElement *This = impl_from_IHTMLElement7(iface);
5629 FIXME("(%p)->(%ld)\n", This, pointer_id);
5630 return E_NOTIMPL;
5633 static HRESULT WINAPI HTMLElement7_put_onmstransitionstart(IHTMLElement7 *iface, VARIANT v)
5635 HTMLElement *This = impl_from_IHTMLElement7(iface);
5636 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5637 return E_NOTIMPL;
5640 static HRESULT WINAPI HTMLElement7_get_onmstransitionstart(IHTMLElement7 *iface, VARIANT *p)
5642 HTMLElement *This = impl_from_IHTMLElement7(iface);
5643 FIXME("(%p)->(%p)\n", This, p);
5644 return E_NOTIMPL;
5647 static HRESULT WINAPI HTMLElement7_put_onmstransitionend(IHTMLElement7 *iface, VARIANT v)
5649 HTMLElement *This = impl_from_IHTMLElement7(iface);
5650 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5651 return E_NOTIMPL;
5654 static HRESULT WINAPI HTMLElement7_get_onmstransitionend(IHTMLElement7 *iface, VARIANT *p)
5656 HTMLElement *This = impl_from_IHTMLElement7(iface);
5657 FIXME("(%p)->(%p)\n", This, p);
5658 return E_NOTIMPL;
5661 static HRESULT WINAPI HTMLElement7_put_onmsanimationstart(IHTMLElement7 *iface, VARIANT v)
5663 HTMLElement *This = impl_from_IHTMLElement7(iface);
5664 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5665 return E_NOTIMPL;
5668 static HRESULT WINAPI HTMLElement7_get_onmsanimationstart(IHTMLElement7 *iface, VARIANT *p)
5670 HTMLElement *This = impl_from_IHTMLElement7(iface);
5671 FIXME("(%p)->(%p)\n", This, p);
5672 return E_NOTIMPL;
5675 static HRESULT WINAPI HTMLElement7_put_onmsanimationend(IHTMLElement7 *iface, VARIANT v)
5677 HTMLElement *This = impl_from_IHTMLElement7(iface);
5678 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5679 return E_NOTIMPL;
5682 static HRESULT WINAPI HTMLElement7_get_onmsanimationend(IHTMLElement7 *iface, VARIANT *p)
5684 HTMLElement *This = impl_from_IHTMLElement7(iface);
5685 FIXME("(%p)->(%p)\n", This, p);
5686 return E_NOTIMPL;
5689 static HRESULT WINAPI HTMLElement7_put_onmsanimationiteration(IHTMLElement7 *iface, VARIANT v)
5691 HTMLElement *This = impl_from_IHTMLElement7(iface);
5692 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5693 return E_NOTIMPL;
5696 static HRESULT WINAPI HTMLElement7_get_onmsanimationiteration(IHTMLElement7 *iface, VARIANT *p)
5698 HTMLElement *This = impl_from_IHTMLElement7(iface);
5699 FIXME("(%p)->(%p)\n", This, p);
5700 return E_NOTIMPL;
5703 static HRESULT WINAPI HTMLElement7_put_oninvalid(IHTMLElement7 *iface, VARIANT v)
5705 HTMLElement *This = impl_from_IHTMLElement7(iface);
5706 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5707 return E_NOTIMPL;
5710 static HRESULT WINAPI HTMLElement7_get_oninvalid(IHTMLElement7 *iface, VARIANT *p)
5712 HTMLElement *This = impl_from_IHTMLElement7(iface);
5713 FIXME("(%p)->(%p)\n", This, p);
5714 return E_NOTIMPL;
5717 static HRESULT WINAPI HTMLElement7_put_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR v)
5719 HTMLElement *This = impl_from_IHTMLElement7(iface);
5720 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
5721 return E_NOTIMPL;
5724 static HRESULT WINAPI HTMLElement7_get_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR *p)
5726 HTMLElement *This = impl_from_IHTMLElement7(iface);
5727 FIXME("(%p)->(%p)\n", This, p);
5728 return E_NOTIMPL;
5731 static HRESULT WINAPI HTMLElement7_put_spellcheck(IHTMLElement7 *iface, VARIANT v)
5733 HTMLElement *This = impl_from_IHTMLElement7(iface);
5735 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5737 if(!This->html_element) {
5738 FIXME("non-HTML element\n");
5739 return E_NOTIMPL;
5742 if(V_VT(&v) != VT_BOOL) {
5743 FIXME("unsupported argument %s\n", debugstr_variant(&v));
5744 return E_NOTIMPL;
5747 return map_nsresult(nsIDOMHTMLElement_SetSpellcheck(This->html_element, !!V_BOOL(&v)));
5750 static HRESULT WINAPI HTMLElement7_get_spellcheck(IHTMLElement7 *iface, VARIANT *p)
5752 HTMLElement *This = impl_from_IHTMLElement7(iface);
5753 cpp_bool spellcheck;
5754 nsresult nsres;
5756 TRACE("(%p)->(%p)\n", This, p);
5758 if(!This->html_element) {
5759 FIXME("non-HTML element\n");
5760 return E_NOTIMPL;
5763 nsres = nsIDOMHTMLElement_GetSpellcheck(This->html_element, &spellcheck);
5764 if(NS_FAILED(nsres))
5765 return map_nsresult(nsres);
5767 V_VT(p) = VT_BOOL;
5768 V_BOOL(p) = spellcheck ? VARIANT_TRUE : VARIANT_FALSE;
5769 return S_OK;
5772 static HRESULT WINAPI HTMLElement7_put_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT v)
5774 HTMLElement *This = impl_from_IHTMLElement7(iface);
5775 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5776 return E_NOTIMPL;
5779 static HRESULT WINAPI HTMLElement7_get_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT *p)
5781 HTMLElement *This = impl_from_IHTMLElement7(iface);
5782 FIXME("(%p)->(%p)\n", This, p);
5783 return E_NOTIMPL;
5786 static HRESULT WINAPI HTMLElement7_put_oncuechange(IHTMLElement7 *iface, VARIANT v)
5788 HTMLElement *This = impl_from_IHTMLElement7(iface);
5789 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5790 return E_NOTIMPL;
5793 static HRESULT WINAPI HTMLElement7_get_oncuechange(IHTMLElement7 *iface, VARIANT *p)
5795 HTMLElement *This = impl_from_IHTMLElement7(iface);
5796 FIXME("(%p)->(%p)\n", This, p);
5797 return E_NOTIMPL;
5800 static const IHTMLElement7Vtbl HTMLElement7Vtbl = {
5801 HTMLElement7_QueryInterface,
5802 HTMLElement7_AddRef,
5803 HTMLElement7_Release,
5804 HTMLElement7_GetTypeInfoCount,
5805 HTMLElement7_GetTypeInfo,
5806 HTMLElement7_GetIDsOfNames,
5807 HTMLElement7_Invoke,
5808 HTMLElement7_put_onmspointerdown,
5809 HTMLElement7_get_onmspointerdown,
5810 HTMLElement7_put_onmspointermove,
5811 HTMLElement7_get_onmspointermove,
5812 HTMLElement7_put_onmspointerup,
5813 HTMLElement7_get_onmspointerup,
5814 HTMLElement7_put_onmspointerover,
5815 HTMLElement7_get_onmspointerover,
5816 HTMLElement7_put_onmspointerout,
5817 HTMLElement7_get_onmspointerout,
5818 HTMLElement7_put_onmspointercancel,
5819 HTMLElement7_get_onmspointercancel,
5820 HTMLElement7_put_onmspointerhover,
5821 HTMLElement7_get_onmspointerhover,
5822 HTMLElement7_put_onmslostpointercapture,
5823 HTMLElement7_get_onmslostpointercapture,
5824 HTMLElement7_put_onmsgotpointercapture,
5825 HTMLElement7_get_onmsgotpointercapture,
5826 HTMLElement7_put_onmsgesturestart,
5827 HTMLElement7_get_onmsgesturestart,
5828 HTMLElement7_put_onmsgesturechange,
5829 HTMLElement7_get_onmsgesturechange,
5830 HTMLElement7_put_onmsgestureend,
5831 HTMLElement7_get_onmsgestureend,
5832 HTMLElement7_put_onmsgesturehold,
5833 HTMLElement7_get_onmsgesturehold,
5834 HTMLElement7_put_onmsgesturetap,
5835 HTMLElement7_get_onmsgesturetap,
5836 HTMLElement7_put_onmsgesturedoubletap,
5837 HTMLElement7_get_onmsgesturedoubletap,
5838 HTMLElement7_put_onmsinertiastart,
5839 HTMLElement7_get_onmsinertiastart,
5840 HTMLElement7_msSetPointerCapture,
5841 HTMLElement7_msReleasePointerCapture,
5842 HTMLElement7_put_onmstransitionstart,
5843 HTMLElement7_get_onmstransitionstart,
5844 HTMLElement7_put_onmstransitionend,
5845 HTMLElement7_get_onmstransitionend,
5846 HTMLElement7_put_onmsanimationstart,
5847 HTMLElement7_get_onmsanimationstart,
5848 HTMLElement7_put_onmsanimationend,
5849 HTMLElement7_get_onmsanimationend,
5850 HTMLElement7_put_onmsanimationiteration,
5851 HTMLElement7_get_onmsanimationiteration,
5852 HTMLElement7_put_oninvalid,
5853 HTMLElement7_get_oninvalid,
5854 HTMLElement7_put_xmsAcceleratorKey,
5855 HTMLElement7_get_xmsAcceleratorKey,
5856 HTMLElement7_put_spellcheck,
5857 HTMLElement7_get_spellcheck,
5858 HTMLElement7_put_onmsmanipulationstatechanged,
5859 HTMLElement7_get_onmsmanipulationstatechanged,
5860 HTMLElement7_put_oncuechange,
5861 HTMLElement7_get_oncuechange
5865 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
5867 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
5870 DISPEX_IDISPATCH_IMPL(HTMLUniqueName, IHTMLUniqueName,
5871 impl_from_IHTMLUniqueName(iface)->node.event_target.dispex)
5873 HRESULT elem_unique_id(unsigned id, BSTR *p)
5875 WCHAR buf[32];
5877 swprintf(buf, ARRAY_SIZE(buf), L"ms__id%u", id);
5878 *p = SysAllocString(buf);
5879 return *p ? S_OK : E_OUTOFMEMORY;
5882 static void ensure_unique_id(HTMLElement *elem)
5884 if(!elem->unique_id)
5885 elem->unique_id = ++elem->node.doc->unique_id;
5888 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
5890 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5892 TRACE("(%p)->(%p)\n", This, p);
5894 ensure_unique_id(This);
5895 *p = This->unique_id;
5896 return S_OK;
5899 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
5901 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5903 TRACE("(%p)->(%p)\n", This, p);
5905 ensure_unique_id(This);
5906 return elem_unique_id(This->unique_id, p);
5909 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
5910 HTMLUniqueName_QueryInterface,
5911 HTMLUniqueName_AddRef,
5912 HTMLUniqueName_Release,
5913 HTMLUniqueName_GetTypeInfoCount,
5914 HTMLUniqueName_GetTypeInfo,
5915 HTMLUniqueName_GetIDsOfNames,
5916 HTMLUniqueName_Invoke,
5917 HTMLUniqueName_get_uniqueNumber,
5918 HTMLUniqueName_get_uniqueID
5921 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
5923 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
5926 DISPEX_IDISPATCH_IMPL(ElementSelector, IElementSelector,
5927 impl_from_IElementSelector(iface)->node.event_target.dispex)
5929 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
5931 HTMLElement *This = impl_from_IElementSelector(iface);
5932 nsIDOMElement *nselem;
5933 HTMLElement *elem;
5934 nsAString nsstr;
5935 nsresult nsres;
5936 HRESULT hres;
5938 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
5940 if(!This->dom_element) {
5941 FIXME("comment element\n");
5942 return E_NOTIMPL;
5945 nsAString_InitDepend(&nsstr, v);
5946 nsres = nsIDOMElement_QuerySelector(This->dom_element, &nsstr, &nselem);
5947 nsAString_Finish(&nsstr);
5948 if(NS_FAILED(nsres)) {
5949 WARN("QuerySelector failed: %08lx\n", nsres);
5950 return map_nsresult(nsres);
5953 if(!nselem) {
5954 *pel = NULL;
5955 return S_OK;
5958 hres = get_element(nselem, &elem);
5959 nsIDOMElement_Release(nselem);
5960 if(FAILED(hres))
5961 return hres;
5963 *pel = &elem->IHTMLElement_iface;
5964 return S_OK;
5967 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
5969 HTMLElement *This = impl_from_IElementSelector(iface);
5970 nsIDOMNodeList *node_list = NULL;
5971 nsAString nsstr;
5972 nsresult nsres;
5973 HRESULT hres;
5975 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
5977 if(!This->dom_element) {
5978 FIXME("comment element\n");
5979 return E_NOTIMPL;
5982 nsAString_InitDepend(&nsstr, v);
5983 nsres = nsIDOMElement_QuerySelectorAll(This->dom_element, &nsstr, &node_list);
5984 nsAString_Finish(&nsstr);
5985 if(NS_FAILED(nsres)) {
5986 WARN("QuerySelectorAll failed: %08lx\n", nsres);
5987 if(node_list)
5988 nsIDOMNodeList_Release(node_list);
5989 return map_nsresult(nsres);
5992 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
5993 nsIDOMNodeList_Release(node_list);
5994 return hres;
5997 static const IElementSelectorVtbl ElementSelectorVtbl = {
5998 ElementSelector_QueryInterface,
5999 ElementSelector_AddRef,
6000 ElementSelector_Release,
6001 ElementSelector_GetTypeInfoCount,
6002 ElementSelector_GetTypeInfo,
6003 ElementSelector_GetIDsOfNames,
6004 ElementSelector_Invoke,
6005 ElementSelector_querySelector,
6006 ElementSelector_querySelectorAll
6009 static inline HTMLElement *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
6011 return CONTAINING_RECORD(iface, HTMLElement, IProvideMultipleClassInfo_iface);
6014 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
6015 REFIID riid, void **ppv)
6017 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6018 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6021 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
6023 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6024 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6027 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
6029 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6030 return IHTMLElement_Release(&This->IHTMLElement_iface);
6033 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
6035 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6036 TRACE("(%p)->(%p)\n", This, ppTI);
6037 return get_class_typeinfo(This->node.vtbl->clsid, ppTI);
6040 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
6042 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6043 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
6044 return E_NOTIMPL;
6047 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
6049 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6050 FIXME("(%p)->(%p)\n", This, pcti);
6051 *pcti = 1;
6052 return S_OK;
6055 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
6056 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
6058 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6059 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
6060 return E_NOTIMPL;
6063 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
6064 ProvideClassInfo_QueryInterface,
6065 ProvideClassInfo_AddRef,
6066 ProvideClassInfo_Release,
6067 ProvideClassInfo_GetClassInfo,
6068 ProvideClassInfo2_GetGUID,
6069 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
6070 ProvideMultipleClassInfo_GetInfoOfIndex
6073 static inline HTMLElement *impl_from_IElementTraversal(IElementTraversal *iface)
6075 return CONTAINING_RECORD(iface, HTMLElement, IElementTraversal_iface);
6078 DISPEX_IDISPATCH_IMPL(ElementTraversal, IElementTraversal,
6079 impl_from_IElementTraversal(iface)->node.event_target.dispex)
6081 static HRESULT WINAPI ElementTraversal_get_firstElementChild(IElementTraversal *iface, IHTMLElement **p)
6083 HTMLElement *This = impl_from_IElementTraversal(iface);
6084 nsIDOMElement *nselem = NULL;
6085 HTMLElement *elem;
6086 HRESULT hres;
6088 TRACE("(%p)->(%p)\n", This, p);
6090 if(!This->dom_element) {
6091 *p = NULL;
6092 return S_OK;
6095 nsIDOMElement_GetFirstElementChild(This->dom_element, &nselem);
6096 if(!nselem) {
6097 *p = NULL;
6098 return S_OK;
6101 hres = get_element(nselem, &elem);
6102 nsIDOMElement_Release(nselem);
6103 if(FAILED(hres))
6104 return hres;
6106 *p = &elem->IHTMLElement_iface;
6107 return S_OK;
6110 static HRESULT WINAPI ElementTraversal_get_lastElementChild(IElementTraversal *iface, IHTMLElement **p)
6112 HTMLElement *This = impl_from_IElementTraversal(iface);
6113 nsIDOMElement *nselem = NULL;
6114 HTMLElement *elem;
6115 HRESULT hres;
6117 TRACE("(%p)->(%p)\n", This, p);
6119 if(!This->dom_element) {
6120 *p = NULL;
6121 return S_OK;
6124 nsIDOMElement_GetLastElementChild(This->dom_element, &nselem);
6125 if(!nselem) {
6126 *p = NULL;
6127 return S_OK;
6130 hres = get_element(nselem, &elem);
6131 nsIDOMElement_Release(nselem);
6132 if(FAILED(hres))
6133 return hres;
6135 *p = &elem->IHTMLElement_iface;
6136 return S_OK;
6139 static HRESULT WINAPI ElementTraversal_get_previousElementSibling(IElementTraversal *iface, IHTMLElement **p)
6141 HTMLElement *This = impl_from_IElementTraversal(iface);
6142 nsIDOMElement *nselem = NULL;
6143 HTMLElement *elem;
6144 HRESULT hres;
6146 TRACE("(%p)->(%p)\n", This, p);
6148 if(!This->dom_element) {
6149 *p = NULL;
6150 return S_OK;
6153 nsIDOMElement_GetPreviousElementSibling(This->dom_element, &nselem);
6154 if(!nselem) {
6155 *p = NULL;
6156 return S_OK;
6159 hres = get_element(nselem, &elem);
6160 nsIDOMElement_Release(nselem);
6161 if(FAILED(hres))
6162 return hres;
6164 *p = &elem->IHTMLElement_iface;
6165 return S_OK;
6168 static HRESULT WINAPI ElementTraversal_get_nextElementSibling(IElementTraversal *iface, IHTMLElement **p)
6170 HTMLElement *This = impl_from_IElementTraversal(iface);
6171 nsIDOMElement *nselem = NULL;
6172 HTMLElement *elem;
6173 HRESULT hres;
6175 TRACE("(%p)->(%p)\n", This, p);
6177 if(!This->dom_element) {
6178 *p = NULL;
6179 return S_OK;
6182 nsIDOMElement_GetNextElementSibling(This->dom_element, &nselem);
6183 if(!nselem) {
6184 *p = NULL;
6185 return S_OK;
6188 hres = get_element(nselem, &elem);
6189 nsIDOMElement_Release(nselem);
6190 if(FAILED(hres))
6191 return hres;
6193 *p = &elem->IHTMLElement_iface;
6194 return S_OK;
6197 static HRESULT WINAPI ElementTraversal_get_childElementCount(IElementTraversal *iface, LONG *p)
6199 HTMLElement *This = impl_from_IElementTraversal(iface);
6200 UINT32 count = 0;
6202 TRACE("(%p)->(%p)\n", This, p);
6204 if(This->dom_element)
6205 nsIDOMElement_GetChildElementCount(This->dom_element, &count);
6207 *p = count;
6208 return S_OK;
6211 static const IElementTraversalVtbl ElementTraversalVtbl = {
6212 ElementTraversal_QueryInterface,
6213 ElementTraversal_AddRef,
6214 ElementTraversal_Release,
6215 ElementTraversal_GetTypeInfoCount,
6216 ElementTraversal_GetTypeInfo,
6217 ElementTraversal_GetIDsOfNames,
6218 ElementTraversal_Invoke,
6219 ElementTraversal_get_firstElementChild,
6220 ElementTraversal_get_lastElementChild,
6221 ElementTraversal_get_previousElementSibling,
6222 ElementTraversal_get_nextElementSibling,
6223 ElementTraversal_get_childElementCount
6226 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
6228 return CONTAINING_RECORD(iface, HTMLElement, node);
6231 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
6233 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6234 HTMLElement *new_elem;
6235 HRESULT hres;
6237 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
6238 if(FAILED(hres))
6239 return hres;
6241 if(This->filter) {
6242 new_elem->filter = wcsdup(This->filter);
6243 if(!new_elem->filter) {
6244 IHTMLElement_Release(&This->IHTMLElement_iface);
6245 return E_OUTOFMEMORY;
6249 *ret = &new_elem->node;
6250 return S_OK;
6253 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
6255 const cpc_entry_t HTMLElement_cpc[] = {
6256 HTMLELEMENT_CPC,
6257 {NULL}
6260 static const NodeImplVtbl HTMLElementImplVtbl = {
6261 .clsid = &CLSID_HTMLUnknownElement,
6262 .cpc_entries = HTMLElement_cpc,
6263 .clone = HTMLElement_clone,
6264 .get_attr_col = HTMLElement_get_attr_col
6267 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
6269 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
6272 void *HTMLElement_query_interface(DispatchEx *dispex, REFIID riid)
6274 HTMLElement *This = impl_from_DispatchEx(dispex);
6276 if(IsEqualGUID(&IID_IHTMLElement, riid))
6277 return &This->IHTMLElement_iface;
6278 if(IsEqualGUID(&IID_IHTMLElement2, riid))
6279 return &This->IHTMLElement2_iface;
6280 if(IsEqualGUID(&IID_IHTMLElement3, riid))
6281 return &This->IHTMLElement3_iface;
6282 if(IsEqualGUID(&IID_IHTMLElement4, riid))
6283 return &This->IHTMLElement4_iface;
6284 if(IsEqualGUID(&IID_IHTMLElement6, riid))
6285 return &This->IHTMLElement6_iface;
6286 if(IsEqualGUID(&IID_IHTMLElement7, riid))
6287 return &This->IHTMLElement7_iface;
6288 if(IsEqualGUID(&IID_IHTMLUniqueName, riid))
6289 return &This->IHTMLUniqueName_iface;
6290 if(IsEqualGUID(&IID_IElementSelector, riid))
6291 return &This->IElementSelector_iface;
6292 if(IsEqualGUID(&IID_IElementTraversal, riid))
6293 return &This->IElementTraversal_iface;
6294 if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
6295 return &This->cp_container.IConnectionPointContainer_iface;
6296 if(IsEqualGUID(&IID_IProvideClassInfo, riid))
6297 return &This->IProvideMultipleClassInfo_iface;
6298 if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
6299 return &This->IProvideMultipleClassInfo_iface;
6300 if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
6301 return &This->IProvideMultipleClassInfo_iface;
6302 if(IsEqualGUID(&IID_IWineHTMLElementPrivate, riid))
6303 return &This->IWineHTMLElementPrivate_iface;
6305 return HTMLDOMNode_query_interface(&This->node.event_target.dispex, riid);
6308 void HTMLElement_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
6310 HTMLElement *This = impl_from_DispatchEx(dispex);
6311 HTMLDOMNode_traverse(&This->node.event_target.dispex, cb);
6313 if(This->style)
6314 note_cc_edge((nsISupports*)&This->style->IHTMLStyle_iface, "style", cb);
6315 if(This->runtime_style)
6316 note_cc_edge((nsISupports*)&This->runtime_style->IHTMLStyle_iface, "runtime_style", cb);
6317 if(This->attrs)
6318 note_cc_edge((nsISupports*)&This->attrs->IHTMLAttributeCollection_iface, "attrs", cb);
6321 void HTMLElement_unlink(DispatchEx *dispex)
6323 HTMLElement *This = impl_from_DispatchEx(dispex);
6324 HTMLDOMNode_unlink(&This->node.event_target.dispex);
6326 if(This->style) {
6327 HTMLStyle *style = This->style;
6328 This->style = NULL;
6329 IHTMLStyle_Release(&style->IHTMLStyle_iface);
6331 if(This->runtime_style) {
6332 HTMLStyle *runtime_style = This->runtime_style;
6333 This->runtime_style = NULL;
6334 IHTMLStyle_Release(&runtime_style->IHTMLStyle_iface);
6336 if(This->attrs) {
6337 HTMLAttributeCollection *attrs = This->attrs;
6338 This->attrs = NULL;
6339 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
6343 void HTMLElement_destructor(DispatchEx *dispex)
6345 HTMLElement *This = impl_from_DispatchEx(dispex);
6347 ConnectionPointContainer_Destroy(&This->cp_container);
6348 free(This->filter);
6349 HTMLDOMNode_destructor(&This->node.event_target.dispex);
6352 HRESULT HTMLElement_populate_props(DispatchEx *dispex)
6354 HTMLElement *This = impl_from_DispatchEx(dispex);
6355 nsIDOMMozNamedAttrMap *attrs;
6356 nsIDOMAttr *attr;
6357 nsAString nsstr;
6358 const PRUnichar *str;
6359 BSTR name;
6360 VARIANT value;
6361 unsigned i;
6362 UINT32 len;
6363 DISPID id;
6364 nsresult nsres;
6365 HRESULT hres;
6367 if(!This->dom_element)
6368 return S_FALSE;
6370 if(dispex_compat_mode(dispex) >= COMPAT_MODE_IE9)
6371 return S_OK;
6373 nsres = nsIDOMElement_GetAttributes(This->dom_element, &attrs);
6374 if(NS_FAILED(nsres))
6375 return E_FAIL;
6377 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
6378 if(NS_FAILED(nsres)) {
6379 nsIDOMMozNamedAttrMap_Release(attrs);
6380 return E_FAIL;
6383 nsAString_Init(&nsstr, NULL);
6384 for(i=0; i<len; i++) {
6385 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
6386 if(NS_FAILED(nsres))
6387 continue;
6389 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
6390 if(NS_FAILED(nsres)) {
6391 nsIDOMAttr_Release(attr);
6392 continue;
6395 nsAString_GetData(&nsstr, &str);
6396 name = SysAllocString(str);
6397 if(!name) {
6398 nsIDOMAttr_Release(attr);
6399 continue;
6402 hres = IWineJSDispatchHost_GetDispID(&dispex->IWineJSDispatchHost_iface, name, fdexNameCaseInsensitive, &id);
6403 if(hres != DISP_E_UNKNOWNNAME) {
6404 nsIDOMAttr_Release(attr);
6405 SysFreeString(name);
6406 continue;
6409 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
6410 nsIDOMAttr_Release(attr);
6411 if(NS_FAILED(nsres)) {
6412 SysFreeString(name);
6413 continue;
6416 nsAString_GetData(&nsstr, &str);
6417 V_VT(&value) = VT_BSTR;
6418 if(*str) {
6419 V_BSTR(&value) = SysAllocString(str);
6420 if(!V_BSTR(&value)) {
6421 SysFreeString(name);
6422 continue;
6424 } else
6425 V_BSTR(&value) = NULL;
6427 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
6428 SysFreeString(name);
6429 VariantClear(&value);
6431 nsAString_Finish(&nsstr);
6433 nsIDOMMozNamedAttrMap_Release(attrs);
6434 return S_OK;
6437 nsISupports *HTMLElement_get_gecko_target(DispatchEx *dispex)
6439 HTMLElement *This = impl_from_DispatchEx(dispex);
6440 return (nsISupports*)This->node.nsnode;
6443 void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
6445 HTMLElement *This = impl_from_DispatchEx(dispex);
6446 ensure_doc_nsevent_handler(This->node.doc, This->node.nsnode, eid);
6449 HRESULT HTMLElement_handle_event(DispatchEx *dispex, DOMEvent *event, BOOL *prevent_default)
6451 HTMLElement *This = impl_from_DispatchEx(dispex);
6453 switch(event->event_id) {
6454 case EVENTID_KEYDOWN: {
6455 nsIDOMKeyEvent *key_event;
6456 nsresult nsres;
6458 nsres = nsIDOMEvent_QueryInterface(event->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
6459 if(NS_SUCCEEDED(nsres)) {
6460 UINT32 code = 0;
6462 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
6464 if(code == VK_F1 /* DOM_VK_F1 */) {
6465 DOMEvent *help_event;
6466 HRESULT hres;
6468 TRACE("F1 pressed\n");
6470 hres = create_document_event(This->node.doc, EVENTID_HELP, &help_event);
6471 if(SUCCEEDED(hres)) {
6472 dispatch_event(&This->node.event_target, help_event);
6473 IDOMEvent_Release(&help_event->IDOMEvent_iface);
6475 *prevent_default = TRUE;
6478 nsIDOMKeyEvent_Release(key_event);
6480 break;
6482 default:
6483 break;
6486 return S_OK;
6489 EventTarget *HTMLElement_get_parent_event_target(DispatchEx *dispex)
6491 HTMLElement *This = impl_from_DispatchEx(dispex);
6492 HTMLDOMNode *node;
6493 nsIDOMNode *nsnode;
6494 nsresult nsres;
6495 HRESULT hres;
6497 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
6498 assert(nsres == NS_OK);
6499 if(!nsnode)
6500 return NULL;
6502 hres = get_node(nsnode, TRUE, &node);
6503 nsIDOMNode_Release(nsnode);
6504 if(FAILED(hres))
6505 return NULL;
6507 return &node->event_target;
6510 ConnectionPointContainer *HTMLElement_get_cp_container(DispatchEx *dispex)
6512 HTMLElement *This = impl_from_DispatchEx(dispex);
6513 IConnectionPointContainer_AddRef(&This->cp_container.IConnectionPointContainer_iface);
6514 return &This->cp_container;
6517 IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6519 HTMLElement *This = impl_from_DispatchEx(dispex);
6520 return default_set_current_event(This->node.doc->window, event);
6523 static HRESULT IHTMLElement6_hasAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
6524 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6526 VARIANT args[2];
6527 HRESULT hres;
6528 DISPPARAMS new_dp = { args, NULL, 2, 0 };
6530 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
6531 return S_FALSE;
6533 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
6534 case VT_EMPTY:
6535 case VT_BSTR:
6536 case VT_NULL:
6537 return S_FALSE;
6538 default:
6539 break;
6542 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
6543 if(FAILED(hres))
6544 return hres;
6545 args[0] = dp->rgvarg[dp->cArgs - 2];
6547 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_HASATTRIBUTENS, &new_dp, res, ei, caller);
6548 VariantClear(&args[1]);
6549 return hres;
6552 static HRESULT IHTMLElement6_getAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
6553 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6555 VARIANT args[2];
6556 HRESULT hres;
6557 DISPPARAMS new_dp = { args, NULL, 2, 0 };
6559 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
6560 return S_FALSE;
6562 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
6563 case VT_EMPTY:
6564 case VT_BSTR:
6565 case VT_NULL:
6566 return S_FALSE;
6567 default:
6568 break;
6571 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
6572 if(FAILED(hres))
6573 return hres;
6574 args[0] = dp->rgvarg[dp->cArgs - 2];
6576 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_GETATTRIBUTENS, &new_dp, res, ei, caller);
6577 VariantClear(&args[1]);
6578 return hres;
6581 static HRESULT IHTMLElement6_setAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
6582 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6584 BOOL ns_conv = FALSE, val_conv = FALSE;
6585 VARIANT args[3];
6586 HRESULT hres;
6587 DISPPARAMS new_dp = { args, NULL, 3, 0 };
6589 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 3 || dp->cNamedArgs)
6590 return S_FALSE;
6592 if(dispex_compat_mode(dispex) < COMPAT_MODE_IE10)
6593 args[2] = dp->rgvarg[dp->cArgs - 1];
6594 else {
6595 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
6596 case VT_EMPTY:
6597 case VT_BSTR:
6598 case VT_NULL:
6599 args[2] = dp->rgvarg[dp->cArgs - 1];
6600 break;
6601 default:
6602 hres = change_type(&args[2], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
6603 if(FAILED(hres))
6604 return hres;
6605 ns_conv = TRUE;
6606 break;
6610 switch(V_VT(&dp->rgvarg[dp->cArgs - 3])) {
6611 case VT_EMPTY:
6612 case VT_BSTR:
6613 case VT_NULL:
6614 if(!ns_conv)
6615 return S_FALSE;
6616 args[0] = dp->rgvarg[dp->cArgs - 3];
6617 break;
6618 default:
6619 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 3], VT_BSTR, caller);
6620 if(FAILED(hres)) {
6621 if(ns_conv)
6622 VariantClear(&args[2]);
6623 return hres;
6625 val_conv = TRUE;
6626 break;
6629 args[1] = dp->rgvarg[dp->cArgs - 2];
6630 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_SETATTRIBUTENS, &new_dp, res, ei, caller);
6631 if(ns_conv) VariantClear(&args[2]);
6632 if(val_conv) VariantClear(&args[0]);
6633 return hres;
6636 static HRESULT IHTMLElement6_removeAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
6637 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6639 VARIANT args[2];
6640 HRESULT hres;
6641 DISPPARAMS new_dp = { args, NULL, 2, 0 };
6643 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
6644 return S_FALSE;
6646 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
6647 case VT_EMPTY:
6648 case VT_BSTR:
6649 case VT_NULL:
6650 return S_FALSE;
6651 default:
6652 break;
6655 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
6656 if(FAILED(hres))
6657 return hres;
6658 args[0] = dp->rgvarg[dp->cArgs - 2];
6660 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, &new_dp, res, ei, caller);
6661 VariantClear(&args[1]);
6662 return hres;
6665 static HRESULT IHTMLElement6_setAttribute_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
6666 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6668 VARIANT args[2];
6669 HRESULT hres;
6670 DISPPARAMS new_dp = { args, NULL, 2, 0 };
6672 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
6673 return S_FALSE;
6675 switch(V_VT(&dp->rgvarg[dp->cArgs - 2])) {
6676 case VT_EMPTY:
6677 case VT_BSTR:
6678 case VT_NULL:
6679 return S_FALSE;
6680 default:
6681 break;
6684 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 2], VT_BSTR, caller);
6685 if(FAILED(hres))
6686 return hres;
6687 args[1] = dp->rgvarg[dp->cArgs - 1];
6689 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, &new_dp, res, ei, caller);
6690 VariantClear(&args[0]);
6691 return hres;
6694 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6696 static const dispex_hook_t elem6_ie9_hooks[] = {
6697 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
6698 {DISPID_UNKNOWN}
6700 static const dispex_hook_t elem6_ie10_hooks[] = {
6701 {DISPID_IHTMLELEMENT6_HASATTRIBUTENS, IHTMLElement6_hasAttributeNS_hook},
6702 {DISPID_IHTMLELEMENT6_GETATTRIBUTENS, IHTMLElement6_getAttributeNS_hook},
6703 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
6704 {DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, IHTMLElement6_removeAttributeNS_hook},
6705 {DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, IHTMLElement6_setAttribute_hook},
6706 {DISPID_UNKNOWN}
6708 static const dispex_hook_t elem2_ie11_hooks[] = {
6709 {DISPID_IHTMLELEMENT2_ATTACHEVENT, NULL},
6710 {DISPID_IHTMLELEMENT2_DETACHEVENT, NULL},
6711 {DISPID_IHTMLELEMENT2_DOSCROLL, NULL},
6712 {DISPID_IHTMLELEMENT2_READYSTATE, NULL},
6713 {DISPID_UNKNOWN}
6716 HTMLDOMNode_init_dispex_info(info, mode);
6718 dispex_info_add_interface(info, IHTMLElement2_tid, mode >= COMPAT_MODE_IE11 ? elem2_ie11_hooks : NULL);
6720 if(mode >= COMPAT_MODE_IE8)
6721 dispex_info_add_interface(info, IElementSelector_tid, NULL);
6723 if(mode >= COMPAT_MODE_IE9) {
6724 dispex_info_add_interface(info, IHTMLElement6_tid, mode >= COMPAT_MODE_IE10 ? elem6_ie10_hooks : elem6_ie9_hooks);
6725 dispex_info_add_interface(info, IElementTraversal_tid, NULL);
6728 if(mode >= COMPAT_MODE_IE10)
6730 dispex_info_add_interface(info, IHTMLElement7_tid, NULL);
6731 dispex_info_add_interface(info, IWineHTMLElementPrivate_tid, NULL);
6735 const tid_t HTMLElement_iface_tids[] = {
6736 HTMLELEMENT_TIDS,
6740 static const event_target_vtbl_t HTMLElement_event_target_vtbl = {
6742 HTMLELEMENT_DISPEX_VTBL_ENTRIES,
6743 .query_interface = HTMLElement_query_interface,
6744 .destructor = HTMLElement_destructor,
6745 .traverse = HTMLElement_traverse,
6746 .unlink = HTMLElement_unlink,
6748 HTMLELEMENT_EVENT_TARGET_VTBL_ENTRIES,
6749 .handle_event = HTMLElement_handle_event
6752 struct token_list {
6753 DispatchEx dispex;
6754 IWineDOMTokenList IWineDOMTokenList_iface;
6755 IHTMLElement *element;
6758 static inline struct token_list *impl_from_IWineDOMTokenList(IWineDOMTokenList *iface)
6760 return CONTAINING_RECORD(iface, struct token_list, IWineDOMTokenList_iface);
6763 DISPEX_IDISPATCH_IMPL(token_list, IWineDOMTokenList, impl_from_IWineDOMTokenList(iface)->dispex)
6765 static const WCHAR *find_token(const WCHAR *list, const WCHAR *token, unsigned int token_len)
6767 const WCHAR *ptr, *next;
6769 if (!list || !token)
6770 return NULL;
6772 ptr = list;
6773 while (*ptr)
6775 while (iswspace(*ptr))
6776 ++ptr;
6777 if (!*ptr)
6778 break;
6779 next = ptr + 1;
6780 while (*next && !iswspace(*next))
6781 ++next;
6783 if (next - ptr == token_len && !wcsncmp(ptr, token, token_len))
6784 return ptr;
6785 ptr = next;
6787 return NULL;
6790 static HRESULT token_list_add_remove(IWineDOMTokenList *iface, BSTR token, BOOL remove, VARIANT_BOOL *toggle_ret)
6792 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6793 unsigned int i, len, old_len, new_len;
6794 const WCHAR *old_pos;
6795 BSTR new, old;
6796 HRESULT hr;
6798 TRACE("token_list %p, token %s, remove %#x, toggle_ret %p.\n", token_list, debugstr_w(token), remove, toggle_ret);
6800 len = token ? lstrlenW(token) : 0;
6801 if (!len)
6803 WARN("Empty token.\n");
6804 return E_INVALIDARG;
6807 for (i = 0; i < len; ++i)
6808 if (iswspace(token[i]))
6810 WARN("Token has spaces.\n");
6811 return E_INVALIDARG;
6814 if (FAILED(hr = IHTMLElement_get_className(token_list->element, &old)))
6815 return hr;
6817 TRACE("old %s.\n", debugstr_w(old));
6819 old_pos = find_token(old, token, len);
6820 if (toggle_ret)
6822 remove = !!old_pos;
6823 *toggle_ret = !remove;
6825 else if (!!old_pos != remove)
6827 SysFreeString(old);
6828 return S_OK;
6831 old_len = old ? lstrlenW(old) : 0;
6832 if (remove)
6834 while (old_pos != old && iswspace(old_pos[-1]))
6836 --old_pos;
6837 ++len;
6839 while (iswspace(old_pos[len]))
6840 ++len;
6842 if (old_pos != old && old_pos[len])
6843 --len;
6845 new_len = old_len - len;
6847 else
6849 new_len = old_len + len + !!old_len;
6852 if (!(new = SysAllocStringLen(NULL, new_len)))
6854 ERR("No memory.\n");
6855 SysFreeString(old);
6856 return E_OUTOFMEMORY;
6859 if (remove)
6861 memcpy(new, old, sizeof(*new) * (old_pos - old));
6862 memcpy(new + (old_pos - old), old_pos + len, sizeof(*new) * (old_len - (old_pos - old) - len + 1));
6864 else
6866 memcpy(new, old, sizeof(*new) * old_len);
6867 if (old_len)
6868 new[old_len++]= L' ';
6869 memcpy(new + old_len, token, sizeof(*new) * len);
6870 new[old_len + len] = 0;
6873 SysFreeString(old);
6875 TRACE("new %s.\n", debugstr_w(new));
6877 hr = IHTMLElement_put_className(token_list->element, new);
6878 SysFreeString(new);
6879 return hr;
6882 static HRESULT WINAPI token_list_add(IWineDOMTokenList *iface, BSTR token)
6884 return token_list_add_remove(iface, token, FALSE, NULL);
6887 static HRESULT WINAPI token_list_remove(IWineDOMTokenList *iface, BSTR token)
6889 return token_list_add_remove(iface, token, TRUE, NULL);
6892 static HRESULT WINAPI token_list_toggle(IWineDOMTokenList *iface, BSTR token, VARIANT_BOOL *p)
6894 VARIANT_BOOL tmp;
6895 return token_list_add_remove(iface, token, FALSE, p ? p : &tmp);
6898 static HRESULT WINAPI token_list_contains(IWineDOMTokenList *iface, BSTR token, VARIANT_BOOL *p)
6900 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6901 unsigned len;
6902 HRESULT hres;
6903 BSTR list;
6905 TRACE("(%p)->(%s %p)\n", token_list, debugstr_w(token), p);
6907 if(!token || !*token)
6908 return E_INVALIDARG;
6910 for(len = 0; token[len]; len++)
6911 if(iswspace(token[len]))
6912 return E_INVALIDARG;
6914 hres = IHTMLElement_get_className(token_list->element, &list);
6915 if(FAILED(hres))
6916 return hres;
6918 *p = find_token(list, token, len) ? VARIANT_TRUE : VARIANT_FALSE;
6919 SysFreeString(list);
6920 return S_OK;
6923 static HRESULT WINAPI token_list_get_length(IWineDOMTokenList *iface, LONG *p)
6925 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6926 unsigned length = 0;
6927 const WCHAR *ptr;
6928 HRESULT hres;
6929 BSTR list;
6931 TRACE("(%p)->(%p)\n", token_list, p);
6933 hres = IHTMLElement_get_className(token_list->element, &list);
6934 if(FAILED(hres))
6935 return hres;
6937 if(!list) {
6938 *p = 0;
6939 return S_OK;
6942 ptr = list;
6943 do {
6944 while(iswspace(*ptr))
6945 ptr++;
6946 if(!*ptr)
6947 break;
6948 length++;
6949 ptr++;
6950 while(*ptr && !iswspace(*ptr))
6951 ptr++;
6952 } while(*ptr++);
6954 SysFreeString(list);
6955 *p = length;
6956 return S_OK;
6959 static HRESULT WINAPI token_list_item(IWineDOMTokenList *iface, LONG index, VARIANT *p)
6961 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6962 BSTR list, token = NULL;
6963 unsigned i = 0;
6964 HRESULT hres;
6965 WCHAR *ptr;
6967 TRACE("(%p)->(%ld %p)\n", token_list, index, p);
6969 hres = IHTMLElement_get_className(token_list->element, &list);
6970 if(FAILED(hres))
6971 return hres;
6973 if(!list) {
6974 V_VT(p) = VT_NULL;
6975 return S_OK;
6978 ptr = list;
6979 do {
6980 while(iswspace(*ptr))
6981 ptr++;
6982 if(!*ptr)
6983 break;
6984 if(i == index) {
6985 token = ptr++;
6986 while(*ptr && !iswspace(*ptr))
6987 ptr++;
6988 token = SysAllocStringLen(token, ptr - token);
6989 if(!token) {
6990 SysFreeString(list);
6991 return E_OUTOFMEMORY;
6993 break;
6995 i++;
6996 ptr++;
6997 while(*ptr && !iswspace(*ptr))
6998 ptr++;
6999 } while(*ptr++);
7001 SysFreeString(list);
7002 if(!token)
7003 V_VT(p) = VT_NULL;
7004 else {
7005 V_VT(p) = VT_BSTR;
7006 V_BSTR(p) = token;
7008 return S_OK;
7011 static HRESULT WINAPI token_list_toString(IWineDOMTokenList *iface, BSTR *String)
7013 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7015 TRACE("(%p)->(%p)\n", token_list, String);
7017 return IHTMLElement_get_className(token_list->element, String);
7020 static const IWineDOMTokenListVtbl WineDOMTokenListVtbl = {
7021 token_list_QueryInterface,
7022 token_list_AddRef,
7023 token_list_Release,
7024 token_list_GetTypeInfoCount,
7025 token_list_GetTypeInfo,
7026 token_list_GetIDsOfNames,
7027 token_list_Invoke,
7028 token_list_add,
7029 token_list_remove,
7030 token_list_toggle,
7031 token_list_contains,
7032 token_list_get_length,
7033 token_list_item,
7034 token_list_toString
7037 /* idx can be negative, so offset it halfway through custom dispids */
7038 #define DISPID_TOKENLIST_0 (MSHTML_DISPID_CUSTOM_MIN + (MSHTML_DISPID_CUSTOM_MAX+1 - MSHTML_DISPID_CUSTOM_MIN) / 2)
7040 static inline struct token_list *token_list_from_DispatchEx(DispatchEx *iface)
7042 return CONTAINING_RECORD(iface, struct token_list, dispex);
7045 static void *token_list_query_interface(DispatchEx *dispex, REFIID riid)
7047 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7049 if(IsEqualGUID(&IID_IWineDOMTokenList, riid))
7050 return &token_list->IWineDOMTokenList_iface;
7052 return NULL;
7055 static void token_list_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
7057 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7058 if(token_list->element)
7059 note_cc_edge((nsISupports*)token_list->element, "element", cb);
7062 static void token_list_unlink(DispatchEx *dispex)
7064 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7065 unlink_ref(&token_list->element);
7068 static void token_list_destructor(DispatchEx *dispex)
7070 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7071 free(token_list);
7074 static HRESULT token_list_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params,
7075 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7077 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7078 HRESULT hres;
7080 switch(flags) {
7081 case DISPATCH_PROPERTYGET:
7082 hres = IHTMLElement_get_className(token_list->element, &V_BSTR(res));
7083 if(FAILED(hres))
7084 return hres;
7085 V_VT(res) = VT_BSTR;
7086 break;
7087 default:
7088 FIXME("Unimplemented flags %x\n", flags);
7089 return E_NOTIMPL;
7092 return S_OK;
7095 static HRESULT token_list_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
7097 WCHAR *end;
7098 LONG idx;
7099 ULONG i;
7101 idx = wcstol(name, &end, 10);
7102 if(*end)
7103 return DISP_E_UNKNOWNNAME;
7105 i = idx + DISPID_TOKENLIST_0 - MSHTML_DISPID_CUSTOM_MIN;
7106 if(i > MSHTML_CUSTOM_DISPID_CNT)
7107 return DISP_E_UNKNOWNNAME;
7109 *dispid = MSHTML_DISPID_CUSTOM_MIN + i;
7110 return S_OK;
7113 static HRESULT token_list_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
7115 LONG idx = id - MSHTML_DISPID_CUSTOM_MIN;
7116 WCHAR buf[12];
7117 UINT len;
7119 len = swprintf(buf, ARRAY_SIZE(buf), L"%d", idx);
7120 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
7123 static HRESULT token_list_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
7124 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7126 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7128 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", token_list, id, lcid, flags, params, res, ei, caller);
7130 switch(flags) {
7131 case DISPATCH_PROPERTYGET:
7132 return token_list_item(&token_list->IWineDOMTokenList_iface, id - DISPID_TOKENLIST_0, res);
7133 case DISPATCH_PROPERTYPUTREF|DISPATCH_PROPERTYPUT:
7134 case DISPATCH_PROPERTYPUTREF:
7135 case DISPATCH_PROPERTYPUT:
7136 /* Ignored by IE */
7137 return S_OK;
7138 case DISPATCH_METHOD|DISPATCH_PROPERTYGET:
7139 case DISPATCH_METHOD:
7140 return MSHTML_E_NOT_FUNC;
7141 default:
7142 break;
7145 return MSHTML_E_INVALID_ACTION;
7148 static const dispex_static_data_vtbl_t token_list_dispex_vtbl = {
7149 .query_interface = token_list_query_interface,
7150 .destructor = token_list_destructor,
7151 .traverse = token_list_traverse,
7152 .unlink = token_list_unlink,
7153 .value = token_list_value,
7154 .get_dispid = token_list_get_dispid,
7155 .get_name = token_list_get_name,
7156 .invoke = token_list_invoke
7159 static const tid_t token_list_iface_tids[] = {
7160 IWineDOMTokenList_tid,
7163 static dispex_static_data_t token_list_dispex = {
7164 "DOMTokenList",
7165 &token_list_dispex_vtbl,
7166 IWineDOMTokenList_tid,
7167 token_list_iface_tids
7170 static HRESULT create_token_list(compat_mode_t compat_mode, IHTMLElement *element, IWineDOMTokenList **ret)
7172 struct token_list *obj;
7174 obj = calloc(1, sizeof(*obj));
7175 if(!obj)
7177 ERR("No memory.\n");
7178 return E_OUTOFMEMORY;
7181 obj->IWineDOMTokenList_iface.lpVtbl = &WineDOMTokenListVtbl;
7182 init_dispatch(&obj->dispex, &token_list_dispex, compat_mode);
7183 IHTMLElement_AddRef(element);
7184 obj->element = element;
7186 *ret = &obj->IWineDOMTokenList_iface;
7187 return S_OK;
7190 static inline HTMLElement *impl_from_IWineHTMLElementPrivateVtbl(IWineHTMLElementPrivate *iface)
7192 return CONTAINING_RECORD(iface, HTMLElement, IWineHTMLElementPrivate_iface);
7195 static HRESULT WINAPI htmlelement_private_QueryInterface(IWineHTMLElementPrivate *iface,
7196 REFIID riid, void **ppv)
7198 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7200 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
7203 static ULONG WINAPI htmlelement_private_AddRef(IWineHTMLElementPrivate *iface)
7205 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7207 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
7210 static ULONG WINAPI htmlelement_private_Release(IWineHTMLElementPrivate *iface)
7212 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7214 return IHTMLElement_Release(&This->IHTMLElement_iface);
7217 static HRESULT WINAPI htmlelement_private_GetTypeInfoCount(IWineHTMLElementPrivate *iface, UINT *pctinfo)
7219 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7221 return HTMLElement_GetTypeInfoCount(&This->IHTMLElement_iface, pctinfo);
7224 static HRESULT WINAPI htmlelement_private_GetTypeInfo(IWineHTMLElementPrivate *iface, UINT iTInfo,
7225 LCID lcid, ITypeInfo **ppTInfo)
7227 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7229 return HTMLElement_GetTypeInfo(&This->IHTMLElement_iface, iTInfo, lcid, ppTInfo);
7232 static HRESULT WINAPI htmlelement_private_GetIDsOfNames(IWineHTMLElementPrivate *iface, REFIID riid,
7233 LPOLESTR *rgszNames, UINT cNames,
7234 LCID lcid, DISPID *rgDispId)
7236 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7238 return HTMLElement_GetIDsOfNames(&This->IHTMLElement_iface, riid, rgszNames, cNames, lcid,
7239 rgDispId);
7242 static HRESULT WINAPI htmlelement_private_Invoke(IWineHTMLElementPrivate *iface, DISPID dispIdMember,
7243 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7244 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7246 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7248 return HTMLElement_Invoke(&This->IHTMLElement_iface, dispIdMember, riid, lcid, wFlags,
7249 pDispParams, pVarResult, pExcepInfo, puArgErr);
7252 static HRESULT WINAPI htmlelement_private_get_classList(IWineHTMLElementPrivate *iface, IDispatch **class_list)
7254 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7256 TRACE("iface %p, class_list %p.\n", iface, class_list);
7258 return create_token_list(dispex_compat_mode(&This->node.event_target.dispex), &This->IHTMLElement_iface,
7259 (IWineDOMTokenList **)class_list);
7262 static const IWineHTMLElementPrivateVtbl WineHTMLElementPrivateVtbl = {
7263 htmlelement_private_QueryInterface,
7264 htmlelement_private_AddRef,
7265 htmlelement_private_Release,
7266 htmlelement_private_GetTypeInfoCount,
7267 htmlelement_private_GetTypeInfo,
7268 htmlelement_private_GetIDsOfNames,
7269 htmlelement_private_Invoke,
7270 htmlelement_private_get_classList,
7273 static dispex_static_data_t HTMLElement_dispex = {
7274 "HTMLElement",
7275 &HTMLElement_event_target_vtbl.dispex_vtbl,
7276 DispHTMLUnknownElement_tid,
7277 HTMLElement_iface_tids,
7278 HTMLElement_init_dispex_info
7281 static dispex_static_data_t HTMLUnknownElement_dispex = {
7282 "HTMLUnknownElement",
7283 &HTMLElement_event_target_vtbl.dispex_vtbl,
7284 DispHTMLUnknownElement_tid,
7285 HTMLElement_iface_tids,
7286 HTMLElement_init_dispex_info
7289 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMElement *nselem, dispex_static_data_t *dispex_data)
7291 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
7292 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
7293 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
7294 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
7295 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
7296 This->IHTMLElement7_iface.lpVtbl = &HTMLElement7Vtbl;
7297 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
7298 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
7299 This->IElementTraversal_iface.lpVtbl = &ElementTraversalVtbl;
7300 This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
7301 This->IWineHTMLElementPrivate_iface.lpVtbl = &WineHTMLElementPrivateVtbl;
7303 if(nselem) {
7304 nsIDOMHTMLElement *html_element;
7305 nsresult nsres;
7307 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data);
7309 /* No AddRef, share reference with HTMLDOMNode */
7310 assert((nsIDOMNode*)nselem == This->node.nsnode);
7311 This->dom_element = nselem;
7313 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)&html_element);
7314 if(NS_SUCCEEDED(nsres)) {
7315 This->html_element = html_element;
7316 /* share reference with HTMLDOMNode */
7317 assert((nsIDOMNode*)html_element == This->node.nsnode);
7318 nsIDOMHTMLElement_Release(html_element);
7322 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
7325 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
7327 nsIDOMElement *nselem;
7328 nsAString tag_name_str;
7329 const PRUnichar *tag_name;
7330 const tag_desc_t *tag;
7331 HTMLElement *elem;
7332 nsresult nsres;
7333 HRESULT hres;
7335 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
7336 if(NS_FAILED(nsres)) {
7337 ERR("no nsIDOMElement iface\n");
7338 return E_FAIL;
7341 nsAString_Init(&tag_name_str, NULL);
7342 nsIDOMElement_GetTagName(nselem, &tag_name_str);
7344 nsAString_GetData(&tag_name_str, &tag_name);
7346 tag = get_tag_desc(tag_name);
7347 if(tag) {
7348 hres = tag->constructor(doc, nselem, &elem);
7349 }else {
7350 nsIDOMSVGElement *svg_element;
7352 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMSVGElement, (void**)&svg_element);
7353 if(NS_SUCCEEDED(nsres)) {
7354 hres = create_svg_element(doc, svg_element, tag_name, &elem);
7355 nsIDOMSVGElement_Release(svg_element);
7356 }else if(use_generic) {
7357 hres = HTMLGenericElement_Create(doc, nselem, &elem);
7358 }else {
7359 elem = calloc(1, sizeof(HTMLElement));
7360 if(elem) {
7361 elem->node.vtbl = &HTMLElementImplVtbl;
7362 HTMLElement_Init(elem, doc, nselem, &HTMLUnknownElement_dispex);
7363 hres = S_OK;
7364 }else {
7365 hres = E_OUTOFMEMORY;
7370 TRACE("%s ret %p\n", debugstr_w(tag_name), elem);
7372 nsIDOMElement_Release(nselem);
7373 nsAString_Finish(&tag_name_str);
7374 if(FAILED(hres))
7375 return hres;
7377 *ret = elem;
7378 return S_OK;
7381 static HRESULT HTMLElement_Ctor(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
7383 HTMLElement *ret;
7385 ret = calloc(1, sizeof(*ret));
7386 if(!ret)
7387 return E_OUTOFMEMORY;
7389 ret->node.vtbl = &HTMLElementImplVtbl;
7390 HTMLElement_Init(ret, doc, nselem, &HTMLElement_dispex);
7392 *elem = ret;
7393 return S_OK;
7396 HRESULT get_element(nsIDOMElement *nselem, HTMLElement **ret)
7398 HTMLDOMNode *node;
7399 HRESULT hres;
7401 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
7402 if(FAILED(hres))
7403 return hres;
7405 *ret = impl_from_HTMLDOMNode(node);
7406 return S_OK;
7409 DISPEX_IDISPATCH_IMPL(HTMLFiltersCollection, IHTMLFiltersCollection,
7410 impl_from_IHTMLFiltersCollection(iface)->dispex)
7412 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
7414 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7416 if(!p)
7417 return E_POINTER;
7419 FIXME("(%p)->(%p) Always returning 0\n", This, p);
7420 *p = 0;
7422 return S_OK;
7425 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
7427 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7428 FIXME("(%p)->(%p)\n", This, p);
7429 return E_NOTIMPL;
7432 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
7434 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7435 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
7436 return E_NOTIMPL;
7439 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
7440 HTMLFiltersCollection_QueryInterface,
7441 HTMLFiltersCollection_AddRef,
7442 HTMLFiltersCollection_Release,
7443 HTMLFiltersCollection_GetTypeInfoCount,
7444 HTMLFiltersCollection_GetTypeInfo,
7445 HTMLFiltersCollection_GetIDsOfNames,
7446 HTMLFiltersCollection_Invoke,
7447 HTMLFiltersCollection_get_length,
7448 HTMLFiltersCollection_get__newEnum,
7449 HTMLFiltersCollection_item
7452 static inline HTMLFiltersCollection *HTMLFiltersCollection_from_DispatchEx(DispatchEx *iface)
7454 return CONTAINING_RECORD(iface, HTMLFiltersCollection, dispex);
7457 static void *HTMLFiltersCollection_query_interface(DispatchEx *dispex, REFIID riid)
7459 HTMLFiltersCollection *This = HTMLFiltersCollection_from_DispatchEx(dispex);
7461 if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid))
7462 return &This->IHTMLFiltersCollection_iface;
7464 return NULL;
7467 static void HTMLFiltersCollection_destructor(DispatchEx *dispex)
7469 HTMLFiltersCollection *This = HTMLFiltersCollection_from_DispatchEx(dispex);
7470 free(This);
7473 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
7475 WCHAR *ptr;
7476 int idx = 0;
7478 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
7479 idx = idx*10 + (*ptr-'0');
7480 if(*ptr)
7481 return DISP_E_UNKNOWNNAME;
7483 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
7484 TRACE("ret %lx\n", *dispid);
7485 return S_OK;
7488 static HRESULT HTMLFiltersCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
7490 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
7491 WCHAR buf[11];
7492 UINT len;
7494 len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx);
7495 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
7498 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
7499 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7501 TRACE("(%p)->(%lx %lx %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
7503 V_VT(res) = VT_DISPATCH;
7504 V_DISPATCH(res) = NULL;
7506 FIXME("always returning NULL\n");
7508 return S_OK;
7511 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
7512 .query_interface = HTMLFiltersCollection_query_interface,
7513 .destructor = HTMLFiltersCollection_destructor,
7514 .get_dispid = HTMLFiltersCollection_get_dispid,
7515 .get_name = HTMLFiltersCollection_get_name,
7516 .invoke = HTMLFiltersCollection_invoke,
7519 static const tid_t HTMLFiltersCollection_iface_tids[] = {
7520 IHTMLFiltersCollection_tid,
7523 static dispex_static_data_t HTMLFiltersCollection_dispex = {
7524 "FiltersCollection",
7525 &HTMLFiltersCollection_dispex_vtbl,
7526 IHTMLFiltersCollection_tid,
7527 HTMLFiltersCollection_iface_tids
7530 static HRESULT create_filters_collection(compat_mode_t compat_mode, IHTMLFiltersCollection **ret)
7532 HTMLFiltersCollection *collection;
7534 if(!(collection = malloc(sizeof(HTMLFiltersCollection))))
7535 return E_OUTOFMEMORY;
7537 collection->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
7539 init_dispatch(&collection->dispex, &HTMLFiltersCollection_dispex, min(compat_mode, COMPAT_MODE_IE8));
7541 *ret = &collection->IHTMLFiltersCollection_iface;
7542 return S_OK;
7545 static HRESULT get_attr_dispid_by_relative_idx(HTMLAttributeCollection *This, LONG *idx, DISPID start, DISPID *dispid)
7547 IWineJSDispatchHost *dispex = &This->elem->node.event_target.dispex.IWineJSDispatchHost_iface;
7548 DISPID id = start;
7549 LONG len = -1;
7550 HRESULT hres;
7552 FIXME("filter non-enumerable attributes out\n");
7554 while(1) {
7555 hres = IWineJSDispatchHost_GetNextDispID(dispex, fdexEnumAll, id, &id);
7556 if(FAILED(hres))
7557 return hres;
7558 else if(hres == S_FALSE)
7559 break;
7561 len++;
7562 if(len == *idx)
7563 break;
7566 if(dispid) {
7567 *dispid = id;
7568 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
7571 *idx = len+1;
7572 return S_OK;
7575 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
7577 return get_attr_dispid_by_relative_idx(This, idx, DISPID_STARTENUM, dispid);
7580 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
7582 HRESULT hres;
7584 if(name[0]>='0' && name[0]<='9') {
7585 WCHAR *end_ptr;
7586 LONG idx;
7588 idx = wcstoul(name, &end_ptr, 10);
7589 if(!*end_ptr) {
7590 hres = get_attr_dispid_by_idx(This, &idx, id);
7591 if(SUCCEEDED(hres))
7592 return hres;
7596 hres = IWineJSDispatchHost_GetDispID(&This->elem->node.event_target.dispex.IWineJSDispatchHost_iface,
7597 name, fdexNameCaseInsensitive, id);
7598 return hres;
7601 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
7603 HTMLDOMAttribute *iter;
7604 LONG pos = 0;
7605 HRESULT hres;
7607 *attr = NULL;
7608 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
7609 if(iter->dispid == id) {
7610 *attr = iter;
7611 break;
7613 pos++;
7616 if(!*attr) {
7617 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, dispex_compat_mode(&This->elem->node.event_target.dispex), attr);
7618 if(FAILED(hres))
7619 return hres;
7622 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
7623 if(list_pos)
7624 *list_pos = pos;
7625 return S_OK;
7628 typedef struct {
7629 IEnumVARIANT IEnumVARIANT_iface;
7631 LONG ref;
7633 ULONG iter;
7634 DISPID iter_dispid;
7635 HTMLAttributeCollection *col;
7636 } HTMLAttributeCollectionEnum;
7638 static inline HTMLAttributeCollectionEnum *HTMLAttributeCollectionEnum_from_IEnumVARIANT(IEnumVARIANT *iface)
7640 return CONTAINING_RECORD(iface, HTMLAttributeCollectionEnum, IEnumVARIANT_iface);
7643 static HRESULT WINAPI HTMLAttributeCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
7645 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
7647 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
7649 if(IsEqualGUID(riid, &IID_IUnknown)) {
7650 *ppv = &This->IEnumVARIANT_iface;
7651 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
7652 *ppv = &This->IEnumVARIANT_iface;
7653 }else {
7654 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
7655 *ppv = NULL;
7656 return E_NOINTERFACE;
7659 IUnknown_AddRef((IUnknown*)*ppv);
7660 return S_OK;
7663 static ULONG WINAPI HTMLAttributeCollectionEnum_AddRef(IEnumVARIANT *iface)
7665 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
7666 LONG ref = InterlockedIncrement(&This->ref);
7668 TRACE("(%p) ref=%ld\n", This, ref);
7670 return ref;
7673 static ULONG WINAPI HTMLAttributeCollectionEnum_Release(IEnumVARIANT *iface)
7675 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
7676 LONG ref = InterlockedDecrement(&This->ref);
7678 TRACE("(%p) ref=%ld\n", This, ref);
7680 if(!ref) {
7681 IHTMLAttributeCollection_Release(&This->col->IHTMLAttributeCollection_iface);
7682 free(This);
7685 return ref;
7688 static HRESULT WINAPI HTMLAttributeCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
7690 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
7691 DISPID tmp, dispid = This->iter_dispid;
7692 HTMLDOMAttribute *attr;
7693 LONG rel_index = 0;
7694 HRESULT hres;
7695 ULONG i;
7697 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
7699 for(i = 0; i < celt; i++) {
7700 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, dispid, &tmp);
7701 if(SUCCEEDED(hres)) {
7702 dispid = tmp;
7703 hres = get_domattr(This->col, dispid, NULL, &attr);
7705 else if(hres == DISP_E_UNKNOWNNAME)
7706 break;
7708 if(FAILED(hres)) {
7709 while(i--)
7710 VariantClear(&rgVar[i]);
7711 return hres;
7714 V_VT(&rgVar[i]) = VT_DISPATCH;
7715 V_DISPATCH(&rgVar[i]) = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
7718 This->iter += i;
7719 This->iter_dispid = dispid;
7720 if(pCeltFetched)
7721 *pCeltFetched = i;
7722 return i == celt ? S_OK : S_FALSE;
7725 static HRESULT WINAPI HTMLAttributeCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
7727 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
7728 LONG remaining, rel_index;
7729 DISPID dispid;
7730 HRESULT hres;
7732 TRACE("(%p)->(%lu)\n", This, celt);
7734 if(!celt)
7735 return S_OK;
7737 rel_index = -1;
7738 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, NULL);
7739 if(FAILED(hres))
7740 return hres;
7741 remaining = min(celt, rel_index);
7743 if(remaining) {
7744 rel_index = remaining - 1;
7745 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, &dispid);
7746 if(FAILED(hres))
7747 return hres;
7748 This->iter += remaining;
7749 This->iter_dispid = dispid;
7751 return celt > remaining ? S_FALSE : S_OK;
7754 static HRESULT WINAPI HTMLAttributeCollectionEnum_Reset(IEnumVARIANT *iface)
7756 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
7758 TRACE("(%p)->()\n", This);
7760 This->iter = 0;
7761 This->iter_dispid = DISPID_STARTENUM;
7762 return S_OK;
7765 static HRESULT WINAPI HTMLAttributeCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
7767 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
7768 FIXME("(%p)->(%p)\n", This, ppEnum);
7769 return E_NOTIMPL;
7772 static const IEnumVARIANTVtbl HTMLAttributeCollectionEnumVtbl = {
7773 HTMLAttributeCollectionEnum_QueryInterface,
7774 HTMLAttributeCollectionEnum_AddRef,
7775 HTMLAttributeCollectionEnum_Release,
7776 HTMLAttributeCollectionEnum_Next,
7777 HTMLAttributeCollectionEnum_Skip,
7778 HTMLAttributeCollectionEnum_Reset,
7779 HTMLAttributeCollectionEnum_Clone
7782 /* interface IHTMLAttributeCollection */
7783 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
7785 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
7788 DISPEX_IDISPATCH_IMPL(HTMLAttributeCollection, IHTMLAttributeCollection,
7789 impl_from_IHTMLAttributeCollection(iface)->dispex)
7791 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
7793 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7794 HRESULT hres;
7796 TRACE("(%p)->(%p)\n", This, p);
7798 *p = -1;
7799 hres = get_attr_dispid_by_idx(This, p, NULL);
7800 return hres;
7803 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
7805 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7806 HTMLAttributeCollectionEnum *ret;
7808 TRACE("(%p)->(%p)\n", This, p);
7810 ret = malloc(sizeof(*ret));
7811 if(!ret)
7812 return E_OUTOFMEMORY;
7814 ret->IEnumVARIANT_iface.lpVtbl = &HTMLAttributeCollectionEnumVtbl;
7815 ret->ref = 1;
7816 ret->iter = 0;
7817 ret->iter_dispid = DISPID_STARTENUM;
7819 HTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
7820 ret->col = This;
7822 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
7823 return S_OK;
7826 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
7828 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7829 HTMLDOMAttribute *attr;
7830 DISPID id;
7831 HRESULT hres;
7833 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
7835 switch(V_VT(name)) {
7836 case VT_I4:
7837 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
7838 break;
7839 case VT_BSTR:
7840 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
7841 break;
7842 default:
7843 FIXME("unsupported name %s\n", debugstr_variant(name));
7844 hres = E_NOTIMPL;
7846 if(hres == DISP_E_UNKNOWNNAME)
7847 return E_INVALIDARG;
7848 if(FAILED(hres))
7849 return hres;
7851 hres = get_domattr(This, id, NULL, &attr);
7852 if(FAILED(hres))
7853 return hres;
7855 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
7856 return S_OK;
7859 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
7860 HTMLAttributeCollection_QueryInterface,
7861 HTMLAttributeCollection_AddRef,
7862 HTMLAttributeCollection_Release,
7863 HTMLAttributeCollection_GetTypeInfoCount,
7864 HTMLAttributeCollection_GetTypeInfo,
7865 HTMLAttributeCollection_GetIDsOfNames,
7866 HTMLAttributeCollection_Invoke,
7867 HTMLAttributeCollection_get_length,
7868 HTMLAttributeCollection__newEnum,
7869 HTMLAttributeCollection_item
7872 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
7874 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
7877 DISPEX_IDISPATCH_IMPL(HTMLAttributeCollection2, IHTMLAttributeCollection2,
7878 impl_from_IHTMLAttributeCollection2(iface)->dispex)
7880 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
7881 IHTMLDOMAttribute **newretNode)
7883 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7884 HTMLDOMAttribute *attr;
7885 DISPID id;
7886 HRESULT hres;
7888 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
7890 hres = get_attr_dispid_by_name(This, bstrName, &id);
7891 if(hres == DISP_E_UNKNOWNNAME) {
7892 *newretNode = NULL;
7893 return S_OK;
7894 } else if(FAILED(hres)) {
7895 return hres;
7898 hres = get_domattr(This, id, NULL, &attr);
7899 if(FAILED(hres))
7900 return hres;
7902 *newretNode = &attr->IHTMLDOMAttribute_iface;
7903 return S_OK;
7906 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
7907 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
7909 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7910 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
7911 return E_NOTIMPL;
7914 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
7915 BSTR bstrName, IHTMLDOMAttribute **newretNode)
7917 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7918 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
7919 return E_NOTIMPL;
7922 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
7923 HTMLAttributeCollection2_QueryInterface,
7924 HTMLAttributeCollection2_AddRef,
7925 HTMLAttributeCollection2_Release,
7926 HTMLAttributeCollection2_GetTypeInfoCount,
7927 HTMLAttributeCollection2_GetTypeInfo,
7928 HTMLAttributeCollection2_GetIDsOfNames,
7929 HTMLAttributeCollection2_Invoke,
7930 HTMLAttributeCollection2_getNamedItem,
7931 HTMLAttributeCollection2_setNamedItem,
7932 HTMLAttributeCollection2_removeNamedItem
7935 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
7937 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
7940 DISPEX_IDISPATCH_IMPL(HTMLAttributeCollection3, IHTMLAttributeCollection3,
7941 impl_from_IHTMLAttributeCollection3(iface)->dispex)
7943 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
7944 IHTMLDOMAttribute **ppNodeOut)
7946 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7947 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
7950 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
7951 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
7953 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7954 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
7955 return E_NOTIMPL;
7958 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
7959 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
7961 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7962 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
7963 return E_NOTIMPL;
7966 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
7968 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7969 HTMLDOMAttribute *attr;
7970 DISPID id;
7971 HRESULT hres;
7973 TRACE("(%p)->(%ld %p)\n", This, index, ppNodeOut);
7975 hres = get_attr_dispid_by_idx(This, &index, &id);
7976 if(hres == DISP_E_UNKNOWNNAME)
7977 return E_INVALIDARG;
7978 if(FAILED(hres))
7979 return hres;
7981 hres = get_domattr(This, id, NULL, &attr);
7982 if(FAILED(hres))
7983 return hres;
7985 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
7986 return S_OK;
7989 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
7991 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7992 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
7995 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
7996 HTMLAttributeCollection3_QueryInterface,
7997 HTMLAttributeCollection3_AddRef,
7998 HTMLAttributeCollection3_Release,
7999 HTMLAttributeCollection3_GetTypeInfoCount,
8000 HTMLAttributeCollection3_GetTypeInfo,
8001 HTMLAttributeCollection3_GetIDsOfNames,
8002 HTMLAttributeCollection3_Invoke,
8003 HTMLAttributeCollection3_getNamedItem,
8004 HTMLAttributeCollection3_setNamedItem,
8005 HTMLAttributeCollection3_removeNamedItem,
8006 HTMLAttributeCollection3_item,
8007 HTMLAttributeCollection3_get_length
8010 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
8012 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
8015 static void *HTMLAttributeCollection_query_interface(DispatchEx *dispex, REFIID riid)
8017 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8019 if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid))
8020 return &This->IHTMLAttributeCollection_iface;
8021 if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid))
8022 return &This->IHTMLAttributeCollection2_iface;
8023 if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid))
8024 return &This->IHTMLAttributeCollection3_iface;
8026 return NULL;
8029 static void HTMLAttributeCollection_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
8031 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8032 HTMLDOMAttribute *attr;
8034 LIST_FOR_EACH_ENTRY(attr, &This->attrs, HTMLDOMAttribute, entry)
8035 note_cc_edge((nsISupports*)&attr->IHTMLDOMAttribute_iface, "attr", cb);
8036 if(This->elem)
8037 note_cc_edge((nsISupports*)&This->elem->node.IHTMLDOMNode_iface, "elem", cb);
8040 static void HTMLAttributeCollection_unlink(DispatchEx *dispex)
8042 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8043 while(!list_empty(&This->attrs)) {
8044 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
8046 list_remove(&attr->entry);
8047 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8049 if(This->elem) {
8050 HTMLElement *elem = This->elem;
8051 This->elem = NULL;
8052 IHTMLDOMNode_Release(&elem->node.IHTMLDOMNode_iface);
8056 static void HTMLAttributeCollection_destructor(DispatchEx *dispex)
8058 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8059 free(This);
8062 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
8064 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8065 HTMLDOMAttribute *attr;
8066 LONG pos;
8067 HRESULT hres;
8069 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(name), flags, dispid);
8071 hres = get_attr_dispid_by_name(This, name, dispid);
8072 if(FAILED(hres))
8073 return hres;
8075 hres = get_domattr(This, *dispid, &pos, &attr);
8076 if(FAILED(hres))
8077 return hres;
8078 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8080 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
8081 return S_OK;
8084 static HRESULT HTMLAttributeCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
8086 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8088 FIXME("(%p)->(%lx %p)\n", This, id, name);
8090 return E_NOTIMPL;
8093 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
8094 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
8096 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8098 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
8100 switch(flags) {
8101 case DISPATCH_PROPERTYGET: {
8102 HTMLDOMAttribute *iter;
8103 DWORD pos;
8105 pos = id-MSHTML_DISPID_CUSTOM_MIN;
8107 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
8108 if(!pos) {
8109 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
8110 V_VT(res) = VT_DISPATCH;
8111 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
8112 return S_OK;
8114 pos--;
8117 WARN("invalid arg\n");
8118 return E_INVALIDARG;
8121 default:
8122 FIXME("unimplemented flags %x\n", flags);
8123 return E_NOTIMPL;
8127 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
8128 .query_interface = HTMLAttributeCollection_query_interface,
8129 .destructor = HTMLAttributeCollection_destructor,
8130 .traverse = HTMLAttributeCollection_traverse,
8131 .unlink = HTMLAttributeCollection_unlink,
8132 .get_dispid = HTMLAttributeCollection_get_dispid,
8133 .get_name = HTMLAttributeCollection_get_name,
8134 .invoke = HTMLAttributeCollection_invoke,
8137 static const tid_t HTMLAttributeCollection_iface_tids[] = {
8138 IHTMLAttributeCollection_tid,
8139 IHTMLAttributeCollection2_tid,
8140 IHTMLAttributeCollection3_tid,
8144 static dispex_static_data_t HTMLAttributeCollection_dispex = {
8145 "NamedNodeMap",
8146 &HTMLAttributeCollection_dispex_vtbl,
8147 DispHTMLAttributeCollection_tid,
8148 HTMLAttributeCollection_iface_tids
8151 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
8153 HTMLElement *This = impl_from_HTMLDOMNode(iface);
8155 if(This->attrs) {
8156 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
8157 *ac = This->attrs;
8158 return S_OK;
8161 This->attrs = calloc(1, sizeof(HTMLAttributeCollection));
8162 if(!This->attrs)
8163 return E_OUTOFMEMORY;
8165 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
8166 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
8167 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
8169 IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
8170 This->attrs->elem = This;
8171 list_init(&This->attrs->attrs);
8172 init_dispatch(&This->attrs->dispex, &HTMLAttributeCollection_dispex, dispex_compat_mode(&iface->event_target.dispex));
8174 *ac = This->attrs;
8175 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
8176 return S_OK;