mshtml: Fix classList toggle() when return value pointer is NULL.
[wine.git] / dlls / mshtml / htmlelem.c
blob5dd812c9ca642eeff5a9e2e8ed0832079d942739
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;
343 LONG ref;
344 } HTMLFiltersCollection;
346 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
348 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
351 static HRESULT create_filters_collection(compat_mode_t compat_mode, IHTMLFiltersCollection **ret);
353 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
355 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
358 static HRESULT copy_nselem_attrs(nsIDOMElement *nselem_with_attrs, nsIDOMElement *nselem)
360 nsIDOMMozNamedAttrMap *attrs;
361 nsAString name_str, val_str;
362 nsresult nsres, nsres2;
363 nsIDOMAttr *attr;
364 UINT32 i, length;
366 nsres = nsIDOMElement_GetAttributes(nselem_with_attrs, &attrs);
367 if(NS_FAILED(nsres))
368 return E_FAIL;
370 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &length);
371 if(NS_FAILED(nsres)) {
372 nsIDOMMozNamedAttrMap_Release(attrs);
373 return E_FAIL;
376 nsAString_Init(&name_str, NULL);
377 nsAString_Init(&val_str, NULL);
378 for(i = 0; i < length; i++) {
379 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
380 if(NS_FAILED(nsres))
381 continue;
383 nsres = nsIDOMAttr_GetNodeName(attr, &name_str);
384 nsres2 = nsIDOMAttr_GetNodeValue(attr, &val_str);
385 nsIDOMAttr_Release(attr);
386 if(NS_FAILED(nsres) || NS_FAILED(nsres2))
387 continue;
389 nsIDOMElement_SetAttribute(nselem, &name_str, &val_str);
391 nsAString_Finish(&name_str);
392 nsAString_Finish(&val_str);
394 nsIDOMMozNamedAttrMap_Release(attrs);
395 return S_OK;
398 static HRESULT create_nselem_parse(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMElement **ret)
400 static const WCHAR prefix[4] = L"<FOO";
401 nsIDOMDocumentFragment *nsfragment;
402 WCHAR *p = wcschr(tag + 1, '>');
403 UINT32 i, name_len, size;
404 nsIDOMElement *nselem;
405 nsIDOMRange *nsrange;
406 nsIDOMNode *nsnode;
407 nsresult nsres;
408 nsAString str;
409 HRESULT hres;
411 if(!p || p[1] || wcschr(tag + 1, '<'))
412 return E_FAIL;
413 if(!doc->dom_document) {
414 WARN("NULL dom_document\n");
415 return E_UNEXPECTED;
418 /* Ignore the starting token and > or /> end token */
419 name_len = p - tag - 1 - (p[-1] == '/');
421 /* Get the tag name using HTML whitespace rules */
422 for(i = 1; i <= name_len; i++) {
423 if((tag[i] >= 0x09 && tag[i] <= 0x0d) || tag[i] == ' ') {
424 name_len = i - 1;
425 break;
428 if(!name_len)
429 return E_FAIL;
430 size = (p + 2 - (tag + 1 + name_len)) * sizeof(WCHAR);
432 /* Parse the input via a contextual fragment, using a dummy unknown tag */
433 nsres = nsIDOMDocument_CreateRange(doc->dom_document, &nsrange);
434 if(NS_FAILED(nsres))
435 return map_nsresult(nsres);
437 if(!(p = malloc(sizeof(prefix) + size))) {
438 nsIDOMRange_Release(nsrange);
439 return E_OUTOFMEMORY;
441 memcpy(p, prefix, sizeof(prefix));
442 memcpy(p + ARRAY_SIZE(prefix), tag + 1 + name_len, size);
444 nsAString_InitDepend(&str, p);
445 nsIDOMRange_CreateContextualFragment(nsrange, &str, &nsfragment);
446 nsIDOMRange_Release(nsrange);
447 nsAString_Finish(&str);
448 free(p);
449 if(NS_FAILED(nsres))
450 return map_nsresult(nsres);
452 /* Grab the parsed element and copy its attributes into the proper element */
453 nsres = nsIDOMDocumentFragment_GetFirstChild(nsfragment, &nsnode);
454 nsIDOMDocumentFragment_Release(nsfragment);
455 if(NS_FAILED(nsres) || !nsnode)
456 return E_FAIL;
458 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
459 nsIDOMNode_Release(nsnode);
460 if(NS_FAILED(nsres))
461 return E_FAIL;
463 if(!(p = malloc((name_len + 1) * sizeof(WCHAR))))
464 hres = E_OUTOFMEMORY;
465 else {
466 memcpy(p, tag + 1, name_len * sizeof(WCHAR));
467 p[name_len] = '\0';
469 nsAString_InitDepend(&str, p);
470 nsres = nsIDOMDocument_CreateElement(doc->dom_document, &str, ret);
471 nsAString_Finish(&str);
472 free(p);
474 if(NS_FAILED(nsres))
475 hres = map_nsresult(nsres);
476 else {
477 hres = copy_nselem_attrs(nselem, *ret);
478 if(FAILED(hres))
479 nsIDOMElement_Release(*ret);
482 nsIDOMElement_Release(nselem);
483 return hres;
486 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMElement **ret)
488 nsAString tag_str;
489 nsresult nsres;
491 if(!doc->dom_document) {
492 WARN("NULL dom_document\n");
493 return E_UNEXPECTED;
496 nsAString_InitDepend(&tag_str, tag);
497 nsres = nsIDOMDocument_CreateElement(doc->dom_document, &tag_str, ret);
498 nsAString_Finish(&tag_str);
499 if(NS_FAILED(nsres)) {
500 ERR("CreateElement failed: %08lx\n", nsres);
501 return E_FAIL;
504 return S_OK;
507 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
509 nsIDOMElement *nselem;
510 HRESULT hres;
512 /* Use owner doc if called on document fragment */
513 if(!doc->dom_document)
514 doc = doc->node.doc;
516 /* IE8 and below allow creating elements with attributes, such as <div class="a"> */
517 if(tag[0] == '<' && dispex_compat_mode(&doc->node.event_target.dispex) <= COMPAT_MODE_IE8)
518 hres = create_nselem_parse(doc, tag, &nselem);
519 else
520 hres = create_nselem(doc, tag, &nselem);
521 if(FAILED(hres))
522 return hres;
524 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
525 nsIDOMElement_Release(nselem);
526 return hres;
529 typedef struct {
530 DispatchEx dispex;
531 IHTMLRect IHTMLRect_iface;
532 IHTMLRect2 IHTMLRect2_iface;
534 LONG ref;
536 nsIDOMClientRect *nsrect;
537 } HTMLRect;
539 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
541 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
544 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
546 HTMLRect *This = impl_from_IHTMLRect(iface);
548 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
550 if(IsEqualGUID(&IID_IUnknown, riid)) {
551 *ppv = &This->IHTMLRect_iface;
552 }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
553 *ppv = &This->IHTMLRect_iface;
554 }else if (IsEqualGUID(&IID_IHTMLRect2, riid)) {
555 *ppv = &This->IHTMLRect2_iface;
556 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
557 return *ppv ? S_OK : E_NOINTERFACE;
558 }else {
559 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
560 *ppv = NULL;
561 return E_NOINTERFACE;
564 IUnknown_AddRef((IUnknown*)*ppv);
565 return S_OK;
568 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
570 HTMLRect *This = impl_from_IHTMLRect(iface);
571 LONG ref = InterlockedIncrement(&This->ref);
573 TRACE("(%p) ref=%ld\n", This, ref);
575 return ref;
578 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
580 HTMLRect *This = impl_from_IHTMLRect(iface);
581 LONG ref = InterlockedDecrement(&This->ref);
583 TRACE("(%p) ref=%ld\n", This, ref);
585 if(!ref) {
586 if(This->nsrect)
587 nsIDOMClientRect_Release(This->nsrect);
588 release_dispex(&This->dispex);
589 free(This);
592 return ref;
595 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
597 HTMLRect *This = impl_from_IHTMLRect(iface);
598 FIXME("(%p)->(%p)\n", This, pctinfo);
599 return E_NOTIMPL;
602 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
603 LCID lcid, ITypeInfo **ppTInfo)
605 HTMLRect *This = impl_from_IHTMLRect(iface);
607 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
610 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
611 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
613 HTMLRect *This = impl_from_IHTMLRect(iface);
615 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
616 lcid, rgDispId);
619 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
620 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
621 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
623 HTMLRect *This = impl_from_IHTMLRect(iface);
625 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
626 pDispParams, pVarResult, pExcepInfo, puArgErr);
629 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
631 HTMLRect *This = impl_from_IHTMLRect(iface);
632 FIXME("(%p)->(%ld)\n", This, v);
633 return E_NOTIMPL;
636 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
638 HTMLRect *This = impl_from_IHTMLRect(iface);
639 float left;
640 nsresult nsres;
642 TRACE("(%p)->(%p)\n", This, p);
644 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
645 if(NS_FAILED(nsres)) {
646 ERR("GetLeft failed: %08lx\n", nsres);
647 return E_FAIL;
650 *p = floor(left+0.5);
651 return S_OK;
654 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
656 HTMLRect *This = impl_from_IHTMLRect(iface);
657 FIXME("(%p)->(%ld)\n", This, v);
658 return E_NOTIMPL;
661 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
663 HTMLRect *This = impl_from_IHTMLRect(iface);
664 float top;
665 nsresult nsres;
667 TRACE("(%p)->(%p)\n", This, p);
669 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
670 if(NS_FAILED(nsres)) {
671 ERR("GetTop failed: %08lx\n", nsres);
672 return E_FAIL;
675 *p = floor(top+0.5);
676 return S_OK;
679 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
681 HTMLRect *This = impl_from_IHTMLRect(iface);
682 FIXME("(%p)->(%ld)\n", This, v);
683 return E_NOTIMPL;
686 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
688 HTMLRect *This = impl_from_IHTMLRect(iface);
689 float right;
690 nsresult nsres;
692 TRACE("(%p)->(%p)\n", This, p);
694 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
695 if(NS_FAILED(nsres)) {
696 ERR("GetRight failed: %08lx\n", nsres);
697 return E_FAIL;
700 *p = floor(right+0.5);
701 return S_OK;
704 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
706 HTMLRect *This = impl_from_IHTMLRect(iface);
707 FIXME("(%p)->(%ld)\n", This, v);
708 return E_NOTIMPL;
711 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
713 HTMLRect *This = impl_from_IHTMLRect(iface);
714 float bottom;
715 nsresult nsres;
717 TRACE("(%p)->(%p)\n", This, p);
719 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
720 if(NS_FAILED(nsres)) {
721 ERR("GetBottom failed: %08lx\n", nsres);
722 return E_FAIL;
725 *p = floor(bottom+0.5);
726 return S_OK;
729 static inline HTMLRect *impl_from_IHTMLRect2(IHTMLRect2 *iface)
731 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect2_iface);
734 static HRESULT WINAPI HTMLRect2_QueryInterface(IHTMLRect2 *iface, REFIID riid, void **ppv)
736 HTMLRect *This = impl_from_IHTMLRect2(iface);
737 return IHTMLRect_QueryInterface(&This->IHTMLRect_iface, riid, ppv);
740 static ULONG WINAPI HTMLRect2_AddRef(IHTMLRect2 *iface)
742 HTMLRect *This = impl_from_IHTMLRect2(iface);
743 return IHTMLRect_AddRef(&This->IHTMLRect_iface);
746 static ULONG WINAPI HTMLRect2_Release(IHTMLRect2 *iface)
748 HTMLRect *This = impl_from_IHTMLRect2(iface);
749 return IHTMLRect_Release(&This->IHTMLRect_iface);
752 static HRESULT WINAPI HTMLRect2_GetTypeInfoCount(IHTMLRect2 *iface, UINT *pctinfo)
754 HTMLRect *This = impl_from_IHTMLRect2(iface);
755 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
758 static HRESULT WINAPI HTMLRect2_GetTypeInfo(IHTMLRect2 *iface, UINT iTInfo,
759 LCID lcid, ITypeInfo **ppTInfo)
761 HTMLRect *This = impl_from_IHTMLRect2(iface);
762 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
765 static HRESULT WINAPI HTMLRect2_GetIDsOfNames(IHTMLRect2 *iface, REFIID riid,
766 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
768 HTMLRect *This = impl_from_IHTMLRect2(iface);
769 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
770 lcid, rgDispId);
773 static HRESULT WINAPI HTMLRect2_Invoke(IHTMLRect2 *iface, DISPID dispIdMember,
774 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
775 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
777 HTMLRect *This = impl_from_IHTMLRect2(iface);
778 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
779 pDispParams, pVarResult, pExcepInfo, puArgErr);
782 static HRESULT WINAPI HTMLRect2_get_width(IHTMLRect2 *iface, FLOAT *p)
784 HTMLRect *This = impl_from_IHTMLRect2(iface);
785 nsresult nsres;
787 TRACE("(%p)->(%p)\n", This, p);
789 nsres = nsIDOMClientRect_GetWidth(This->nsrect, p);
790 if (NS_FAILED(nsres)) {
791 ERR("GetWidth failed: %08lx\n", nsres);
792 return E_FAIL;
795 return S_OK;
798 static HRESULT WINAPI HTMLRect2_get_height(IHTMLRect2 *iface, FLOAT *p)
800 HTMLRect *This = impl_from_IHTMLRect2(iface);
801 nsresult nsres;
803 TRACE("(%p)->(%p)\n", This, p);
805 nsres = nsIDOMClientRect_GetHeight(This->nsrect, p);
806 if (NS_FAILED(nsres)) {
807 ERR("GetHeight failed: %08lx\n", nsres);
808 return E_FAIL;
811 return S_OK;
814 static const IHTMLRectVtbl HTMLRectVtbl = {
815 HTMLRect_QueryInterface,
816 HTMLRect_AddRef,
817 HTMLRect_Release,
818 HTMLRect_GetTypeInfoCount,
819 HTMLRect_GetTypeInfo,
820 HTMLRect_GetIDsOfNames,
821 HTMLRect_Invoke,
822 HTMLRect_put_left,
823 HTMLRect_get_left,
824 HTMLRect_put_top,
825 HTMLRect_get_top,
826 HTMLRect_put_right,
827 HTMLRect_get_right,
828 HTMLRect_put_bottom,
829 HTMLRect_get_bottom
832 static const IHTMLRect2Vtbl HTMLRect2Vtbl = {
833 HTMLRect2_QueryInterface,
834 HTMLRect2_AddRef,
835 HTMLRect2_Release,
836 HTMLRect2_GetTypeInfoCount,
837 HTMLRect2_GetTypeInfo,
838 HTMLRect2_GetIDsOfNames,
839 HTMLRect2_Invoke,
840 HTMLRect2_get_width,
841 HTMLRect2_get_height,
844 void HTMLRect_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
846 if (mode >= COMPAT_MODE_IE9)
847 dispex_info_add_interface(info, IHTMLRect2_tid, NULL);
850 static const tid_t HTMLRect_iface_tids[] = {
851 IHTMLRect_tid,
854 static dispex_static_data_t HTMLRect_dispex = {
855 L"ClientRect",
856 NULL,
857 IHTMLRect_tid,
858 HTMLRect_iface_tids,
859 HTMLRect_init_dispex_info
862 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, compat_mode_t compat_mode, IHTMLRect **ret)
864 HTMLRect *rect;
866 rect = calloc(1, sizeof(HTMLRect));
867 if(!rect)
868 return E_OUTOFMEMORY;
870 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
871 rect->IHTMLRect2_iface.lpVtbl = &HTMLRect2Vtbl;
872 rect->ref = 1;
874 init_dispatch(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex, compat_mode);
876 nsIDOMClientRect_AddRef(nsrect);
877 rect->nsrect = nsrect;
879 *ret = &rect->IHTMLRect_iface;
880 return S_OK;
883 typedef struct {
884 DispatchEx dispex;
885 IHTMLRectCollection IHTMLRectCollection_iface;
887 LONG ref;
889 nsIDOMClientRectList *rect_list;
890 } HTMLRectCollection;
892 typedef struct {
893 IEnumVARIANT IEnumVARIANT_iface;
895 LONG ref;
897 ULONG iter;
898 HTMLRectCollection *col;
899 } HTMLRectCollectionEnum;
901 static inline HTMLRectCollectionEnum *HTMLRectCollectionEnum_from_IEnumVARIANT(IEnumVARIANT *iface)
903 return CONTAINING_RECORD(iface, HTMLRectCollectionEnum, IEnumVARIANT_iface);
906 static HRESULT WINAPI HTMLRectCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
908 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
910 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
912 if(IsEqualGUID(riid, &IID_IUnknown)) {
913 *ppv = &This->IEnumVARIANT_iface;
914 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
915 *ppv = &This->IEnumVARIANT_iface;
916 }else {
917 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
918 *ppv = NULL;
919 return E_NOINTERFACE;
922 IUnknown_AddRef((IUnknown*)*ppv);
923 return S_OK;
926 static ULONG WINAPI HTMLRectCollectionEnum_AddRef(IEnumVARIANT *iface)
928 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
929 LONG ref = InterlockedIncrement(&This->ref);
931 TRACE("(%p) ref=%ld\n", This, ref);
933 return ref;
936 static ULONG WINAPI HTMLRectCollectionEnum_Release(IEnumVARIANT *iface)
938 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
939 LONG ref = InterlockedDecrement(&This->ref);
941 TRACE("(%p) ref=%ld\n", This, ref);
943 if(!ref) {
944 IHTMLRectCollection_Release(&This->col->IHTMLRectCollection_iface);
945 free(This);
948 return ref;
951 static HRESULT WINAPI HTMLRectCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
953 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
954 VARIANT index;
955 HRESULT hres;
956 ULONG num, i;
957 UINT32 len;
959 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
961 nsIDOMClientRectList_GetLength(This->col->rect_list, &len);
962 num = min(len - This->iter, celt);
963 V_VT(&index) = VT_I4;
965 for(i = 0; i < num; i++) {
966 V_I4(&index) = This->iter + i;
967 hres = IHTMLRectCollection_item(&This->col->IHTMLRectCollection_iface, &index, &rgVar[i]);
968 if(FAILED(hres)) {
969 while(i--)
970 VariantClear(&rgVar[i]);
971 return hres;
975 This->iter += num;
976 if(pCeltFetched)
977 *pCeltFetched = num;
978 return num == celt ? S_OK : S_FALSE;
981 static HRESULT WINAPI HTMLRectCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
983 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
984 UINT32 len;
986 TRACE("(%p)->(%lu)\n", This, celt);
988 nsIDOMClientRectList_GetLength(This->col->rect_list, &len);
989 if(This->iter + celt > len) {
990 This->iter = len;
991 return S_FALSE;
994 This->iter += celt;
995 return S_OK;
998 static HRESULT WINAPI HTMLRectCollectionEnum_Reset(IEnumVARIANT *iface)
1000 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
1002 TRACE("(%p)->()\n", This);
1004 This->iter = 0;
1005 return S_OK;
1008 static HRESULT WINAPI HTMLRectCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
1010 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
1011 FIXME("(%p)->(%p)\n", This, ppEnum);
1012 return E_NOTIMPL;
1015 static const IEnumVARIANTVtbl HTMLRectCollectionEnumVtbl = {
1016 HTMLRectCollectionEnum_QueryInterface,
1017 HTMLRectCollectionEnum_AddRef,
1018 HTMLRectCollectionEnum_Release,
1019 HTMLRectCollectionEnum_Next,
1020 HTMLRectCollectionEnum_Skip,
1021 HTMLRectCollectionEnum_Reset,
1022 HTMLRectCollectionEnum_Clone
1025 static inline HTMLRectCollection *impl_from_IHTMLRectCollection(IHTMLRectCollection *iface)
1027 return CONTAINING_RECORD(iface, HTMLRectCollection, IHTMLRectCollection_iface);
1030 static HRESULT WINAPI HTMLRectCollection_QueryInterface(IHTMLRectCollection *iface, REFIID riid, void **ppv)
1032 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1034 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
1036 if(IsEqualGUID(&IID_IUnknown, riid)) {
1037 *ppv = &This->IHTMLRectCollection_iface;
1038 }else if(IsEqualGUID(&IID_IHTMLRectCollection, riid)) {
1039 *ppv = &This->IHTMLRectCollection_iface;
1040 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1041 return *ppv ? S_OK : E_NOINTERFACE;
1042 }else {
1043 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
1044 *ppv = NULL;
1045 return E_NOINTERFACE;
1048 IUnknown_AddRef((IUnknown*)*ppv);
1049 return S_OK;
1052 static ULONG WINAPI HTMLRectCollection_AddRef(IHTMLRectCollection *iface)
1054 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1055 LONG ref = InterlockedIncrement(&This->ref);
1057 TRACE("(%p) ref=%ld\n", This, ref);
1059 return ref;
1062 static ULONG WINAPI HTMLRectCollection_Release(IHTMLRectCollection *iface)
1064 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1065 LONG ref = InterlockedDecrement(&This->ref);
1067 TRACE("(%p) ref=%ld\n", This, ref);
1069 if(!ref) {
1070 if(This->rect_list)
1071 nsIDOMClientRectList_Release(This->rect_list);
1072 release_dispex(&This->dispex);
1073 free(This);
1076 return ref;
1079 static HRESULT WINAPI HTMLRectCollection_GetTypeInfoCount(IHTMLRectCollection *iface, UINT *pctinfo)
1081 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1082 FIXME("(%p)->(%p)\n", This, pctinfo);
1083 return E_NOTIMPL;
1086 static HRESULT WINAPI HTMLRectCollection_GetTypeInfo(IHTMLRectCollection *iface, UINT iTInfo,
1087 LCID lcid, ITypeInfo **ppTInfo)
1089 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1090 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1093 static HRESULT WINAPI HTMLRectCollection_GetIDsOfNames(IHTMLRectCollection *iface, REFIID riid,
1094 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1096 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1097 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1098 lcid, rgDispId);
1101 static HRESULT WINAPI HTMLRectCollection_Invoke(IHTMLRectCollection *iface, DISPID dispIdMember,
1102 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1103 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1105 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1106 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1107 pDispParams, pVarResult, pExcepInfo, puArgErr);
1110 static HRESULT WINAPI HTMLRectCollection_get_length(IHTMLRectCollection *iface, LONG *p)
1112 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1113 UINT32 length;
1114 nsresult nsres;
1116 TRACE("(%p)->(%p)\n", This, p);
1118 nsres = nsIDOMClientRectList_GetLength(This->rect_list, &length);
1119 assert(nsres == NS_OK);
1120 *p = length;
1121 return S_OK;
1124 static HRESULT WINAPI HTMLRectCollection_get__newEnum(IHTMLRectCollection *iface, IUnknown **p)
1126 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1127 HTMLRectCollectionEnum *ret;
1129 TRACE("(%p)->(%p)\n", This, p);
1131 ret = malloc(sizeof(*ret));
1132 if(!ret)
1133 return E_OUTOFMEMORY;
1135 ret->IEnumVARIANT_iface.lpVtbl = &HTMLRectCollectionEnumVtbl;
1136 ret->ref = 1;
1137 ret->iter = 0;
1139 HTMLRectCollection_AddRef(&This->IHTMLRectCollection_iface);
1140 ret->col = This;
1142 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
1143 return S_OK;
1146 static HRESULT WINAPI HTMLRectCollection_item(IHTMLRectCollection *iface, VARIANT *index, VARIANT *result)
1148 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1149 nsIDOMClientRect *nsrect;
1150 IHTMLRect *rect;
1151 nsresult nsres;
1152 HRESULT hres;
1154 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(index), result);
1156 if(V_VT(index) != VT_I4 || V_I4(index) < 0) {
1157 FIXME("Unsupported for %s index\n", debugstr_variant(index));
1158 return E_NOTIMPL;
1161 nsres = nsIDOMClientRectList_Item(This->rect_list, V_I4(index), &nsrect);
1162 if(NS_FAILED(nsres))
1163 return map_nsresult(nsres);
1164 if(!nsrect) {
1165 V_VT(result) = VT_NULL;
1166 return S_OK;
1169 hres = create_html_rect(nsrect, dispex_compat_mode(&This->dispex), &rect);
1170 nsIDOMClientRect_Release(nsrect);
1171 if(FAILED(hres))
1172 return hres;
1174 V_VT(result) = VT_DISPATCH;
1175 V_DISPATCH(result) = (IDispatch *)rect;
1176 return S_OK;
1179 static const IHTMLRectCollectionVtbl HTMLRectCollectionVtbl = {
1180 HTMLRectCollection_QueryInterface,
1181 HTMLRectCollection_AddRef,
1182 HTMLRectCollection_Release,
1183 HTMLRectCollection_GetTypeInfoCount,
1184 HTMLRectCollection_GetTypeInfo,
1185 HTMLRectCollection_GetIDsOfNames,
1186 HTMLRectCollection_Invoke,
1187 HTMLRectCollection_get_length,
1188 HTMLRectCollection_get__newEnum,
1189 HTMLRectCollection_item
1192 static inline HTMLRectCollection *HTMLRectCollection_from_DispatchEx(DispatchEx *iface)
1194 return CONTAINING_RECORD(iface, HTMLRectCollection, dispex);
1197 static HRESULT HTMLRectCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1199 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1200 UINT32 len = 0;
1201 DWORD idx = 0;
1202 WCHAR *ptr;
1204 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
1205 idx = idx*10 + (*ptr-'0');
1206 if(*ptr)
1207 return DISP_E_UNKNOWNNAME;
1209 nsIDOMClientRectList_GetLength(This->rect_list, &len);
1210 if(idx >= len)
1211 return DISP_E_UNKNOWNNAME;
1213 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1214 TRACE("ret %lx\n", *dispid);
1215 return S_OK;
1218 static HRESULT HTMLRectCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
1220 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1221 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
1222 UINT32 len = 0;
1223 WCHAR buf[11];
1225 nsIDOMClientRectList_GetLength(This->rect_list, &len);
1226 if(idx >= len)
1227 return DISP_E_MEMBERNOTFOUND;
1229 len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx);
1230 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
1233 static HRESULT HTMLRectCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1234 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1236 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1238 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
1240 switch(flags) {
1241 case DISPATCH_PROPERTYGET: {
1242 nsIDOMClientRect *rect;
1243 IHTMLRect *html_rect;
1244 nsresult nsres;
1245 HRESULT hres;
1247 nsres = nsIDOMClientRectList_Item(This->rect_list, id - MSHTML_DISPID_CUSTOM_MIN, &rect);
1248 if(NS_FAILED(nsres) || !rect) {
1249 WARN("Unknown item\n");
1250 return DISP_E_MEMBERNOTFOUND;
1253 hres = create_html_rect(rect, dispex_compat_mode(&This->dispex), &html_rect);
1254 nsIDOMClientRect_Release(rect);
1255 if(FAILED(hres))
1256 return hres;
1258 V_VT(res) = VT_DISPATCH;
1259 V_DISPATCH(res) = (IDispatch*)html_rect;
1260 break;
1263 default:
1264 FIXME("unimplemented flags %x\n", flags);
1265 return E_NOTIMPL;
1268 return S_OK;
1271 static const dispex_static_data_vtbl_t HTMLRectCollection_dispex_vtbl = {
1272 NULL,
1273 HTMLRectCollection_get_dispid,
1274 HTMLRectCollection_get_name,
1275 HTMLRectCollection_invoke,
1276 NULL
1278 static const tid_t HTMLRectCollection_iface_tids[] = {
1279 IHTMLRectCollection_tid,
1282 static dispex_static_data_t HTMLRectCollection_dispex = {
1283 L"ClientRectList",
1284 &HTMLRectCollection_dispex_vtbl,
1285 IHTMLRectCollection_tid,
1286 HTMLRectCollection_iface_tids
1289 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
1290 REFIID riid, void **ppv)
1292 HTMLElement *This = impl_from_IHTMLElement(iface);
1294 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
1297 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
1299 HTMLElement *This = impl_from_IHTMLElement(iface);
1301 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
1304 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
1306 HTMLElement *This = impl_from_IHTMLElement(iface);
1308 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
1311 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
1313 HTMLElement *This = impl_from_IHTMLElement(iface);
1314 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
1317 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
1318 LCID lcid, ITypeInfo **ppTInfo)
1320 HTMLElement *This = impl_from_IHTMLElement(iface);
1321 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1324 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
1325 LPOLESTR *rgszNames, UINT cNames,
1326 LCID lcid, DISPID *rgDispId)
1328 HTMLElement *This = impl_from_IHTMLElement(iface);
1329 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1330 lcid, rgDispId);
1333 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
1334 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1335 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1337 HTMLElement *This = impl_from_IHTMLElement(iface);
1338 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1339 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1342 static inline WCHAR *translate_attr_name(WCHAR *attr_name, compat_mode_t compat_mode)
1344 static WCHAR classNameW[] = L"className";
1345 WCHAR *ret = attr_name;
1347 if(compat_mode >= COMPAT_MODE_IE8 && !wcsicmp(attr_name, L"class"))
1348 ret = classNameW;
1349 return ret;
1352 static HRESULT set_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *v)
1354 DISPID propput_dispid = DISPID_PROPERTYPUT;
1355 DISPPARAMS dp = {v, &propput_dispid, 1, 1};
1356 EXCEPINFO ei;
1358 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
1359 TRACE("Ignoring call on style attribute\n");
1360 return S_OK;
1363 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid,
1364 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
1367 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
1368 VARIANT AttributeValue, LONG lFlags)
1370 HTMLElement *This = impl_from_IHTMLElement(iface);
1371 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1372 nsAString name_str, value_str;
1373 VARIANT val = AttributeValue;
1374 BOOL needs_free = FALSE;
1375 nsresult nsres;
1376 DISPID dispid;
1377 HRESULT hres;
1379 TRACE("(%p)->(%s %s %08lx)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
1381 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1382 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1383 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
1384 if(FAILED(hres))
1385 return hres;
1387 if(compat_mode >= COMPAT_MODE_IE8 && get_dispid_type(dispid) == DISPEXPROP_BUILTIN) {
1388 if(V_VT(&val) != VT_BSTR && V_VT(&val) != VT_NULL) {
1389 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1391 V_VT(&val) = VT_EMPTY;
1392 hres = VariantChangeTypeEx(&val, &AttributeValue, lcid, 0, VT_BSTR);
1393 if(FAILED(hres))
1394 return hres;
1396 if(V_BSTR(&val))
1397 needs_free = TRUE;
1398 else
1399 V_VT(&val) = VT_NULL;
1403 /* className and style are special cases */
1404 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1405 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1406 hres = set_elem_attr_value_by_dispid(This, dispid, &val);
1407 goto done;
1411 hres = variant_to_nsstr(&val, FALSE, &value_str);
1412 if(FAILED(hres))
1413 goto done;
1415 nsAString_InitDepend(&name_str, strAttributeName);
1416 nsres = nsIDOMElement_SetAttribute(This->dom_element, &name_str, &value_str);
1417 nsAString_Finish(&name_str);
1418 nsAString_Finish(&value_str);
1419 if(NS_FAILED(nsres))
1420 WARN("SetAttribute failed: %08lx\n", nsres);
1421 hres = map_nsresult(nsres);
1423 done:
1424 if(needs_free)
1425 SysFreeString(V_BSTR(&val));
1426 return hres;
1429 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *ret)
1431 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
1432 EXCEPINFO excep;
1434 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
1435 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
1438 HRESULT attr_value_to_string(VARIANT *v)
1440 HRESULT hres;
1442 switch(V_VT(v)) {
1443 case VT_BSTR:
1444 break;
1445 case VT_NULL:
1446 V_BSTR(v) = SysAllocString(L"null");
1447 if(!V_BSTR(v))
1448 return E_OUTOFMEMORY;
1449 V_VT(v) = VT_BSTR;
1450 break;
1451 case VT_DISPATCH:
1452 IDispatch_Release(V_DISPATCH(v));
1453 V_VT(v) = VT_BSTR;
1454 V_BSTR(v) = SysAllocString(NULL);
1455 break;
1456 default:
1457 hres = VariantChangeType(v, v, 0, VT_BSTR);
1458 if(FAILED(hres))
1459 return hres;
1462 return S_OK;
1465 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
1466 LONG lFlags, VARIANT *AttributeValue)
1468 HTMLElement *This = impl_from_IHTMLElement(iface);
1469 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1470 nsAString name_str, value_str;
1471 nsresult nsres;
1472 DISPID dispid;
1473 HRESULT hres;
1475 TRACE("(%p)->(%s %08lx %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
1477 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
1478 FIXME("Unsupported flags %lx\n", lFlags);
1480 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1481 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1482 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
1483 if(FAILED(hres)) {
1484 V_VT(AttributeValue) = VT_NULL;
1485 return (hres == DISP_E_UNKNOWNNAME) ? S_OK : hres;
1488 /* className and style are special cases */
1489 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1490 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1491 hres = get_elem_attr_value_by_dispid(This, dispid, AttributeValue);
1492 if(FAILED(hres))
1493 return hres;
1495 if(compat_mode >= COMPAT_MODE_IE8 && V_VT(AttributeValue) != VT_BSTR && V_VT(AttributeValue) != VT_NULL) {
1496 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1498 hres = VariantChangeTypeEx(AttributeValue, AttributeValue, lcid, 0, VT_BSTR);
1499 if(FAILED(hres)) {
1500 VariantClear(AttributeValue);
1501 return hres;
1503 if(!V_BSTR(AttributeValue))
1504 V_VT(AttributeValue) = VT_NULL;
1505 }else if(lFlags & ATTRFLAG_ASSTRING)
1506 hres = attr_value_to_string(AttributeValue);
1507 return hres;
1511 nsAString_InitDepend(&name_str, strAttributeName);
1512 nsAString_InitDepend(&value_str, NULL);
1513 nsres = nsIDOMElement_GetAttribute(This->dom_element, &name_str, &value_str);
1514 nsAString_Finish(&name_str);
1515 return return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
1518 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
1519 LONG lFlags, VARIANT_BOOL *pfSuccess)
1521 HTMLElement *This = impl_from_IHTMLElement(iface);
1522 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1523 DISPID id;
1524 HRESULT hres;
1526 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
1528 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1529 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1530 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
1531 if(hres == DISP_E_UNKNOWNNAME) {
1532 *pfSuccess = VARIANT_FALSE;
1533 return S_OK;
1535 if(FAILED(hres))
1536 return hres;
1538 if(id == DISPID_IHTMLELEMENT_STYLE) {
1539 IHTMLStyle *style;
1541 TRACE("Special case: style\n");
1543 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
1544 if(FAILED(hres))
1545 return hres;
1547 hres = IHTMLStyle_put_cssText(style, NULL);
1548 IHTMLStyle_Release(style);
1549 if(FAILED(hres))
1550 return hres;
1552 if(compat_mode >= COMPAT_MODE_IE8)
1553 element_remove_attribute(This, strAttributeName);
1555 *pfSuccess = VARIANT_TRUE;
1556 return S_OK;
1559 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element || id != DISPID_IHTMLELEMENT_CLASSNAME)
1560 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
1563 *pfSuccess = element_has_attribute(This, strAttributeName);
1564 if(*pfSuccess)
1565 return element_remove_attribute(This, strAttributeName);
1566 return S_OK;
1569 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
1571 HTMLElement *This = impl_from_IHTMLElement(iface);
1572 nsAString classname_str;
1573 nsresult nsres;
1575 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1577 if(!This->dom_element) {
1578 FIXME("comment element\n");
1579 return E_NOTIMPL;
1582 nsAString_InitDepend(&classname_str, v);
1583 nsres = nsIDOMElement_SetClassName(This->dom_element, &classname_str);
1584 nsAString_Finish(&classname_str);
1585 if(NS_FAILED(nsres))
1586 ERR("SetClassName failed: %08lx\n", nsres);
1588 return S_OK;
1591 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
1593 HTMLElement *This = impl_from_IHTMLElement(iface);
1594 nsAString class_str;
1595 nsresult nsres;
1597 TRACE("(%p)->(%p)\n", This, p);
1599 if(!This->dom_element) {
1600 FIXME("comment element\n");
1601 return E_NOTIMPL;
1604 nsAString_Init(&class_str, NULL);
1605 nsres = nsIDOMElement_GetClassName(This->dom_element, &class_str);
1606 return return_nsstr(nsres, &class_str, p);
1609 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
1611 HTMLElement *This = impl_from_IHTMLElement(iface);
1612 nsAString id_str;
1613 nsresult nsres;
1615 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1617 if(!This->dom_element) {
1618 FIXME("comment element\n");
1619 return S_OK;
1622 nsAString_InitDepend(&id_str, v);
1623 nsres = nsIDOMElement_SetId(This->dom_element, &id_str);
1624 nsAString_Finish(&id_str);
1625 if(NS_FAILED(nsres))
1626 ERR("SetId failed: %08lx\n", nsres);
1628 return S_OK;
1631 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
1633 HTMLElement *This = impl_from_IHTMLElement(iface);
1634 nsAString id_str;
1635 nsresult nsres;
1637 TRACE("(%p)->(%p)\n", This, p);
1639 if(!This->dom_element) {
1640 *p = NULL;
1641 return S_OK;
1644 nsAString_Init(&id_str, NULL);
1645 nsres = nsIDOMElement_GetId(This->dom_element, &id_str);
1646 return return_nsstr(nsres, &id_str, p);
1649 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
1651 HTMLElement *This = impl_from_IHTMLElement(iface);
1652 nsAString tag_str;
1653 nsresult nsres;
1655 TRACE("(%p)->(%p)\n", This, p);
1657 if(!This->dom_element) {
1658 TRACE("comment element\n");
1659 *p = SysAllocString(L"!");
1660 return *p ? S_OK : E_OUTOFMEMORY;
1663 nsAString_Init(&tag_str, NULL);
1664 nsres = nsIDOMElement_GetTagName(This->dom_element, &tag_str);
1665 return return_nsstr(nsres, &tag_str, p);
1668 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
1670 HTMLElement *This = impl_from_IHTMLElement(iface);
1671 IHTMLDOMNode *node;
1672 HRESULT hres;
1674 TRACE("(%p)->(%p)\n", This, p);
1676 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
1677 if(FAILED(hres))
1678 return hres;
1680 if(!node) {
1681 *p = NULL;
1682 return S_OK;
1685 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
1686 IHTMLDOMNode_Release(node);
1687 if(FAILED(hres))
1688 *p = NULL;
1690 return S_OK;
1693 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
1695 HTMLElement *This = impl_from_IHTMLElement(iface);
1697 TRACE("(%p)->(%p)\n", This, p);
1699 if(!This->style) {
1700 HRESULT hres;
1702 hres = HTMLStyle_Create(This, &This->style);
1703 if(FAILED(hres))
1704 return hres;
1707 *p = &This->style->IHTMLStyle_iface;
1708 IHTMLStyle_AddRef(*p);
1709 return S_OK;
1712 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
1714 HTMLElement *This = impl_from_IHTMLElement(iface);
1716 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1718 return set_node_event(&This->node, EVENTID_HELP, &v);
1721 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
1723 HTMLElement *This = impl_from_IHTMLElement(iface);
1725 TRACE("(%p)->(%p)\n", This, p);
1727 return get_node_event(&This->node, EVENTID_HELP, p);
1730 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
1732 HTMLElement *This = impl_from_IHTMLElement(iface);
1734 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1736 return set_node_event(&This->node, EVENTID_CLICK, &v);
1739 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
1741 HTMLElement *This = impl_from_IHTMLElement(iface);
1743 TRACE("(%p)->(%p)\n", This, p);
1745 return get_node_event(&This->node, EVENTID_CLICK, p);
1748 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
1750 HTMLElement *This = impl_from_IHTMLElement(iface);
1752 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1754 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
1757 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
1759 HTMLElement *This = impl_from_IHTMLElement(iface);
1761 TRACE("(%p)->(%p)\n", This, p);
1763 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
1766 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
1768 HTMLElement *This = impl_from_IHTMLElement(iface);
1770 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1772 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
1775 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
1777 HTMLElement *This = impl_from_IHTMLElement(iface);
1779 TRACE("(%p)->(%p)\n", This, p);
1781 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
1784 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
1786 HTMLElement *This = impl_from_IHTMLElement(iface);
1788 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1790 return set_node_event(&This->node, EVENTID_KEYUP, &v);
1793 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
1795 HTMLElement *This = impl_from_IHTMLElement(iface);
1797 TRACE("(%p)->(%p)\n", This, p);
1799 return get_node_event(&This->node, EVENTID_KEYUP, p);
1802 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
1804 HTMLElement *This = impl_from_IHTMLElement(iface);
1806 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1808 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
1811 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
1813 HTMLElement *This = impl_from_IHTMLElement(iface);
1815 TRACE("(%p)->(%p)\n", This, p);
1817 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
1820 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
1822 HTMLElement *This = impl_from_IHTMLElement(iface);
1824 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1826 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
1829 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
1831 HTMLElement *This = impl_from_IHTMLElement(iface);
1833 TRACE("(%p)->(%p)\n", This, p);
1835 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1838 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1840 HTMLElement *This = impl_from_IHTMLElement(iface);
1842 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1844 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1847 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1849 HTMLElement *This = impl_from_IHTMLElement(iface);
1851 TRACE("(%p)->(%p)\n", This, p);
1853 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1856 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1858 HTMLElement *This = impl_from_IHTMLElement(iface);
1860 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1862 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1865 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1867 HTMLElement *This = impl_from_IHTMLElement(iface);
1869 TRACE("(%p)->(%p)\n", This, p);
1871 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1874 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1876 HTMLElement *This = impl_from_IHTMLElement(iface);
1878 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1880 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1883 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1885 HTMLElement *This = impl_from_IHTMLElement(iface);
1887 TRACE("(%p)->(%p)\n", This, p);
1889 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1892 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1894 HTMLElement *This = impl_from_IHTMLElement(iface);
1896 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1898 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1901 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1903 HTMLElement *This = impl_from_IHTMLElement(iface);
1905 TRACE("(%p)->(%p)\n", This, p);
1907 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1910 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1912 HTMLElement *This = impl_from_IHTMLElement(iface);
1914 TRACE("(%p)->(%p)\n", This, p);
1916 if(!p)
1917 return E_POINTER;
1919 if(This->node.vtbl->get_document)
1920 return This->node.vtbl->get_document(&This->node, p);
1922 *p = (IDispatch*)&This->node.doc->IHTMLDocument2_iface;
1923 IDispatch_AddRef(*p);
1924 return S_OK;
1927 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1929 HTMLElement *This = impl_from_IHTMLElement(iface);
1930 nsAString title_str;
1931 nsresult nsres;
1933 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1935 if(!This->dom_element) {
1936 VARIANT *var;
1937 HRESULT hres;
1939 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", TRUE, &var);
1940 if(FAILED(hres))
1941 return hres;
1943 VariantClear(var);
1944 V_VT(var) = VT_BSTR;
1945 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1946 return S_OK;
1949 if(!This->html_element)
1950 return elem_string_attr_setter(This, L"title", v);
1952 nsAString_InitDepend(&title_str, v);
1953 nsres = nsIDOMHTMLElement_SetTitle(This->html_element, &title_str);
1954 nsAString_Finish(&title_str);
1955 if(NS_FAILED(nsres))
1956 ERR("SetTitle failed: %08lx\n", nsres);
1958 return S_OK;
1961 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1963 HTMLElement *This = impl_from_IHTMLElement(iface);
1964 nsAString title_str;
1965 nsresult nsres;
1967 TRACE("(%p)->(%p)\n", This, p);
1969 if(!This->dom_element) {
1970 VARIANT *var;
1971 HRESULT hres;
1973 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", FALSE, &var);
1974 if(hres == DISP_E_UNKNOWNNAME) {
1975 *p = NULL;
1976 }else if(V_VT(var) != VT_BSTR) {
1977 FIXME("title = %s\n", debugstr_variant(var));
1978 return E_FAIL;
1979 }else {
1980 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1983 return S_OK;
1986 if(!This->html_element)
1987 return elem_string_attr_getter(This, L"title", FALSE, p);
1989 nsAString_Init(&title_str, NULL);
1990 nsres = nsIDOMHTMLElement_GetTitle(This->html_element, &title_str);
1991 return return_nsstr(nsres, &title_str, p);
1994 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1996 HTMLElement *This = impl_from_IHTMLElement(iface);
1998 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2000 return elem_string_attr_setter(This, L"language", v);
2003 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
2005 HTMLElement *This = impl_from_IHTMLElement(iface);
2007 TRACE("(%p)->(%p)\n", This, p);
2009 return elem_string_attr_getter(This, L"language", TRUE, p);
2012 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
2014 HTMLElement *This = impl_from_IHTMLElement(iface);
2016 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2018 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
2021 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
2023 HTMLElement *This = impl_from_IHTMLElement(iface);
2025 TRACE("(%p)->(%p)\n", This, p);
2027 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
2030 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
2032 HTMLElement *This = impl_from_IHTMLElement(iface);
2033 cpp_bool start = TRUE;
2034 nsresult nsres;
2036 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
2038 switch(V_VT(&varargStart)) {
2039 case VT_EMPTY:
2040 case VT_ERROR:
2041 break;
2042 case VT_BOOL:
2043 start = V_BOOL(&varargStart) != VARIANT_FALSE;
2044 break;
2045 default:
2046 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
2049 if(!This->html_element) {
2050 FIXME("non-HTML elements\n");
2051 return E_NOTIMPL;
2054 nsres = nsIDOMHTMLElement_ScrollIntoView(This->html_element, start, 1);
2055 assert(nsres == NS_OK);
2057 return S_OK;
2060 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
2061 VARIANT_BOOL *pfResult)
2063 HTMLElement *This = impl_from_IHTMLElement(iface);
2064 cpp_bool result = FALSE;
2066 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
2068 if(pChild) {
2069 HTMLElement *child;
2070 nsresult nsres;
2072 child = unsafe_impl_from_IHTMLElement(pChild);
2073 if(!child) {
2074 ERR("not our element\n");
2075 return E_FAIL;
2078 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
2079 assert(nsres == NS_OK);
2082 *pfResult = variant_bool(result);
2083 return S_OK;
2086 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
2088 HTMLElement *This = impl_from_IHTMLElement(iface);
2090 TRACE("(%p)->(%p)\n", This, p);
2092 return get_elem_source_index(This, p);
2095 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
2097 HTMLElement *This = impl_from_IHTMLElement(iface);
2098 FIXME("(%p)->(%p)\n", This, p);
2099 return E_NOTIMPL;
2102 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
2104 HTMLElement *This = impl_from_IHTMLElement(iface);
2105 nsAString nsstr;
2106 nsresult nsres;
2108 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2110 if(!This->html_element) {
2111 FIXME("non-HTML element\n");
2112 return E_NOTIMPL;
2115 nsAString_InitDepend(&nsstr, v);
2116 nsres = nsIDOMHTMLElement_SetLang(This->html_element, &nsstr);
2117 nsAString_Finish(&nsstr);
2118 if(NS_FAILED(nsres)) {
2119 ERR("SetLang failed: %08lx\n", nsres);
2120 return E_FAIL;
2123 return S_OK;
2126 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
2128 HTMLElement *This = impl_from_IHTMLElement(iface);
2129 nsAString nsstr;
2130 nsresult nsres;
2132 TRACE("(%p)->(%p)\n", This, p);
2134 if(!This->html_element) {
2135 FIXME("non-HTML element\n");
2136 return E_NOTIMPL;
2139 nsAString_Init(&nsstr, NULL);
2140 nsres = nsIDOMHTMLElement_GetLang(This->html_element, &nsstr);
2141 return return_nsstr(nsres, &nsstr, p);
2144 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
2146 HTMLElement *This = impl_from_IHTMLElement(iface);
2147 nsresult nsres;
2149 TRACE("(%p)->(%p)\n", This, p);
2151 if(!This->html_element) {
2152 FIXME("non-HTML element\n");
2153 return E_NOTIMPL;
2156 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->html_element, p);
2157 if(NS_FAILED(nsres)) {
2158 ERR("GetOffsetLeft failed: %08lx\n", nsres);
2159 return E_FAIL;
2162 return S_OK;
2165 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
2167 HTMLElement *This = impl_from_IHTMLElement(iface);
2168 nsresult nsres;
2170 TRACE("(%p)->(%p)\n", This, p);
2172 if(!This->html_element) {
2173 FIXME("non-HTML element\n");
2174 return E_NOTIMPL;
2177 nsres = nsIDOMHTMLElement_GetOffsetTop(This->html_element, p);
2178 if(NS_FAILED(nsres)) {
2179 ERR("GetOffsetTop failed: %08lx\n", nsres);
2180 return E_FAIL;
2183 return S_OK;
2186 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
2188 HTMLElement *This = impl_from_IHTMLElement(iface);
2189 nsresult nsres;
2191 TRACE("(%p)->(%p)\n", This, p);
2193 if(!This->html_element) {
2194 FIXME("non-HTML element\n");
2195 return E_NOTIMPL;
2198 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->html_element, p);
2199 if(NS_FAILED(nsres)) {
2200 ERR("GetOffsetWidth failed: %08lx\n", nsres);
2201 return E_FAIL;
2204 return S_OK;
2207 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
2209 HTMLElement *This = impl_from_IHTMLElement(iface);
2210 nsresult nsres;
2212 TRACE("(%p)->(%p)\n", This, p);
2214 if(!This->html_element) {
2215 FIXME("non-HTML element\n");
2216 return E_NOTIMPL;
2219 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->html_element, p);
2220 if(NS_FAILED(nsres)) {
2221 ERR("GetOffsetHeight failed: %08lx\n", nsres);
2222 return E_FAIL;
2225 return S_OK;
2228 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
2230 HTMLElement *This = impl_from_IHTMLElement(iface);
2231 nsIDOMElement *nsparent;
2232 HTMLElement *parent;
2233 nsresult nsres;
2234 HRESULT hres;
2236 TRACE("(%p)->(%p)\n", This, p);
2238 if(!This->html_element) {
2239 FIXME("non-HTML element\n");
2240 return E_NOTIMPL;
2243 nsres = nsIDOMHTMLElement_GetOffsetParent(This->html_element, &nsparent);
2244 if(NS_FAILED(nsres)) {
2245 ERR("GetOffsetParent failed: %08lx\n", nsres);
2246 return E_FAIL;
2249 if(!nsparent) {
2250 *p = NULL;
2251 return S_OK;
2254 hres = get_element(nsparent, &parent);
2255 nsIDOMElement_Release(nsparent);
2256 if(FAILED(hres))
2257 return hres;
2259 *p = &parent->IHTMLElement_iface;
2260 return S_OK;
2263 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
2265 HTMLElement *This = impl_from_IHTMLElement(iface);
2266 nsAString html_str;
2267 nsresult nsres;
2269 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2271 if(!This->html_element) {
2272 FIXME("non-HTML element\n");
2273 return E_NOTIMPL;
2276 nsAString_InitDepend(&html_str, v);
2277 nsres = nsIDOMHTMLElement_SetInnerHTML(This->html_element, &html_str);
2278 nsAString_Finish(&html_str);
2279 if(NS_FAILED(nsres)) {
2280 FIXME("SetInnerHtml failed %08lx\n", nsres);
2281 return E_FAIL;
2284 return S_OK;
2287 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
2289 HTMLElement *This = impl_from_IHTMLElement(iface);
2290 nsAString html_str;
2291 nsresult nsres;
2293 TRACE("(%p)->(%p)\n", This, p);
2295 if(!This->html_element) {
2296 FIXME("non-HTML element\n");
2297 return E_NOTIMPL;
2300 nsAString_Init(&html_str, NULL);
2301 nsres = nsIDOMHTMLElement_GetInnerHTML(This->html_element, &html_str);
2302 return return_nsstr(nsres, &html_str, p);
2305 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
2307 HTMLElement *This = impl_from_IHTMLElement(iface);
2308 nsIDOMNode *nschild, *tmp;
2309 nsIDOMText *text_node;
2310 nsAString text_str;
2311 nsresult nsres;
2313 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2315 while(1) {
2316 nsres = nsIDOMElement_GetLastChild(This->dom_element, &nschild);
2317 if(NS_FAILED(nsres)) {
2318 ERR("GetLastChild failed: %08lx\n", nsres);
2319 return E_FAIL;
2321 if(!nschild)
2322 break;
2324 nsres = nsIDOMElement_RemoveChild(This->dom_element, nschild, &tmp);
2325 nsIDOMNode_Release(nschild);
2326 if(NS_FAILED(nsres)) {
2327 ERR("RemoveChild failed: %08lx\n", nsres);
2328 return E_FAIL;
2330 nsIDOMNode_Release(tmp);
2333 nsAString_InitDepend(&text_str, v);
2334 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &text_str, &text_node);
2335 nsAString_Finish(&text_str);
2336 if(NS_FAILED(nsres)) {
2337 ERR("CreateTextNode failed: %08lx\n", nsres);
2338 return E_FAIL;
2341 nsres = nsIDOMElement_AppendChild(This->dom_element, (nsIDOMNode*)text_node, &tmp);
2342 if(NS_FAILED(nsres)) {
2343 ERR("AppendChild failed: %08lx\n", nsres);
2344 return E_FAIL;
2347 nsIDOMNode_Release(tmp);
2348 return S_OK;
2351 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
2353 HTMLElement *This = impl_from_IHTMLElement(iface);
2355 TRACE("(%p)->(%p)\n", This, p);
2357 return get_node_text(&This->node, p);
2360 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
2362 HTMLElement *This = impl_from_IHTMLElement(iface);
2364 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2366 return replace_node_by_html(This->node.doc->dom_document, This->node.nsnode, v);
2369 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
2371 HTMLElement *This = impl_from_IHTMLElement(iface);
2372 nsAString html_str;
2373 HRESULT hres;
2375 WARN("(%p)->(%p) semi-stub\n", This, p);
2377 nsAString_Init(&html_str, NULL);
2378 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
2379 if(SUCCEEDED(hres)) {
2380 const PRUnichar *html;
2382 nsAString_GetData(&html_str, &html);
2383 *p = SysAllocString(html);
2384 if(!*p)
2385 hres = E_OUTOFMEMORY;
2388 nsAString_Finish(&html_str);
2390 TRACE("ret %s\n", debugstr_w(*p));
2391 return hres;
2394 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
2396 HTMLElement *This = impl_from_IHTMLElement(iface);
2397 nsIDOMText *text_node;
2398 nsIDOMRange *range;
2399 nsAString nsstr;
2400 nsresult nsres;
2402 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2404 if(This->node.vtbl->is_settable && !This->node.vtbl->is_settable(&This->node, DISPID_IHTMLELEMENT_OUTERTEXT)) {
2405 WARN("Called on element that does not support setting the property.\n");
2406 return 0x800a0258; /* undocumented error code */
2409 if(!This->node.doc->dom_document) {
2410 FIXME("NULL dom_document\n");
2411 return E_FAIL;
2414 nsAString_InitDepend(&nsstr, v);
2415 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &nsstr, &text_node);
2416 nsAString_Finish(&nsstr);
2417 if(NS_FAILED(nsres)) {
2418 ERR("CreateTextNode failed\n");
2419 return E_FAIL;
2422 nsres = nsIDOMDocument_CreateRange(This->node.doc->dom_document, &range);
2423 if(NS_SUCCEEDED(nsres)) {
2424 nsres = nsIDOMRange_SelectNode(range, This->node.nsnode);
2425 if(NS_SUCCEEDED(nsres))
2426 nsres = nsIDOMRange_DeleteContents(range);
2427 if(NS_SUCCEEDED(nsres))
2428 nsres = nsIDOMRange_InsertNode(range, (nsIDOMNode*)text_node);
2429 if(NS_SUCCEEDED(nsres))
2430 nsres = nsIDOMRange_SelectNodeContents(range, This->node.nsnode);
2431 if(NS_SUCCEEDED(nsres))
2432 nsres = nsIDOMRange_DeleteContents(range);
2433 nsIDOMRange_Release(range);
2435 nsIDOMText_Release(text_node);
2436 if(NS_FAILED(nsres)) {
2437 ERR("failed to set text: %08lx\n", nsres);
2438 return E_FAIL;
2441 return S_OK;
2444 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
2446 HTMLElement *This = impl_from_IHTMLElement(iface);
2448 TRACE("(%p)->(%p)\n", This, p);
2450 /* getter is the same as innerText */
2451 return IHTMLElement_get_innerText(&This->IHTMLElement_iface, p);
2454 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
2456 nsIDOMNode *ret_nsnode;
2457 nsresult nsres;
2458 HRESULT hres = S_OK;
2460 if (!wcsicmp(where, L"beforebegin")) {
2461 nsIDOMNode *parent;
2463 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2464 if(NS_FAILED(nsres))
2465 return E_FAIL;
2467 if(!parent)
2468 return E_INVALIDARG;
2470 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
2471 nsIDOMNode_Release(parent);
2472 }else if(!wcsicmp(where, L"afterbegin")) {
2473 nsIDOMNode *first_child;
2475 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
2476 if(NS_FAILED(nsres))
2477 return E_FAIL;
2479 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
2480 if(NS_FAILED(nsres))
2481 return E_FAIL;
2483 if (first_child)
2484 nsIDOMNode_Release(first_child);
2485 }else if (!wcsicmp(where, L"beforeend")) {
2486 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
2487 }else if (!wcsicmp(where, L"afterend")) {
2488 nsIDOMNode *next_sibling, *parent;
2490 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2491 if(NS_FAILED(nsres))
2492 return E_FAIL;
2493 if(!parent)
2494 return E_INVALIDARG;
2496 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
2497 if(NS_SUCCEEDED(nsres)) {
2498 if(next_sibling) {
2499 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
2500 nsIDOMNode_Release(next_sibling);
2501 }else {
2502 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
2506 nsIDOMNode_Release(parent);
2507 }else {
2508 ERR("invalid where: %s\n", debugstr_w(where));
2509 return E_INVALIDARG;
2512 if (NS_FAILED(nsres))
2513 return E_FAIL;
2515 if(ret_node)
2516 hres = get_node(ret_nsnode, TRUE, ret_node);
2517 nsIDOMNode_Release(ret_nsnode);
2518 return hres;
2521 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
2522 BSTR html)
2524 HTMLElement *This = impl_from_IHTMLElement(iface);
2525 nsIDOMRange *range;
2526 nsIDOMNode *nsnode;
2527 nsAString ns_html;
2528 nsresult nsres;
2529 HRESULT hr;
2531 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
2533 if(!This->node.doc->dom_document) {
2534 WARN("NULL dom_document\n");
2535 return E_UNEXPECTED;
2538 nsres = nsIDOMDocument_CreateRange(This->node.doc->dom_document, &range);
2539 if(NS_FAILED(nsres))
2541 ERR("CreateRange failed: %08lx\n", nsres);
2542 return E_FAIL;
2545 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
2547 nsAString_InitDepend(&ns_html, html);
2548 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
2549 nsAString_Finish(&ns_html);
2550 nsIDOMRange_Release(range);
2552 if(NS_FAILED(nsres) || !nsnode)
2554 ERR("CreateTextNode failed: %08lx\n", nsres);
2555 return E_FAIL;
2558 hr = insert_adjacent_node(This, where, nsnode, NULL);
2559 nsIDOMNode_Release(nsnode);
2560 return hr;
2563 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
2564 BSTR text)
2566 HTMLElement *This = impl_from_IHTMLElement(iface);
2567 nsIDOMNode *nsnode;
2568 nsAString ns_text;
2569 nsresult nsres;
2570 HRESULT hr;
2572 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
2574 if(!This->node.doc->dom_document) {
2575 WARN("NULL dom_document\n");
2576 return E_UNEXPECTED;
2580 nsAString_InitDepend(&ns_text, text);
2581 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &ns_text, (nsIDOMText **)&nsnode);
2582 nsAString_Finish(&ns_text);
2584 if(NS_FAILED(nsres) || !nsnode)
2586 ERR("CreateTextNode failed: %08lx\n", nsres);
2587 return E_FAIL;
2590 hr = insert_adjacent_node(This, where, nsnode, NULL);
2591 nsIDOMNode_Release(nsnode);
2593 return hr;
2596 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
2598 HTMLElement *This = impl_from_IHTMLElement(iface);
2599 FIXME("(%p)->(%p)\n", This, p);
2600 return E_NOTIMPL;
2603 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
2605 HTMLElement *This = impl_from_IHTMLElement(iface);
2607 TRACE("(%p)->(%p)\n", This, p);
2609 *p = variant_bool(This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node));
2610 return S_OK;
2613 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
2615 HTMLElement *This = impl_from_IHTMLElement(iface);
2616 nsresult nsres;
2618 TRACE("(%p)\n", This);
2620 if(!This->html_element) {
2621 FIXME("non-HTML element\n");
2622 return E_NOTIMPL;
2625 nsres = nsIDOMHTMLElement_Click(This->html_element);
2626 if(NS_FAILED(nsres)) {
2627 ERR("Click failed: %08lx\n", nsres);
2628 return E_FAIL;
2631 return S_OK;
2634 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface, IHTMLFiltersCollection **p)
2636 HTMLElement *This = impl_from_IHTMLElement(iface);
2638 TRACE("(%p)->(%p)\n", This, p);
2640 if(!p)
2641 return E_POINTER;
2643 return create_filters_collection(dispex_compat_mode(&This->node.event_target.dispex), p);
2646 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
2648 HTMLElement *This = impl_from_IHTMLElement(iface);
2650 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2652 return set_node_event(&This->node, EVENTID_DRAGSTART, &v);
2655 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
2657 HTMLElement *This = impl_from_IHTMLElement(iface);
2659 TRACE("(%p)->(%p)\n", This, p);
2661 return get_node_event(&This->node, EVENTID_DRAGSTART, p);
2664 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
2666 HTMLElement *This = impl_from_IHTMLElement(iface);
2667 HRESULT hres;
2668 VARIANT var;
2670 TRACE("(%p)->(%p)\n", This, String);
2672 if(!String)
2673 return E_INVALIDARG;
2675 hres = IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, DISPID_VALUE,
2676 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, NULL, &var, NULL, NULL);
2677 if(SUCCEEDED(hres)) {
2678 assert(V_VT(&var) == VT_BSTR);
2679 *String = V_BSTR(&var);
2681 return hres;
2684 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
2686 HTMLElement *This = impl_from_IHTMLElement(iface);
2687 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2688 return E_NOTIMPL;
2691 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
2693 HTMLElement *This = impl_from_IHTMLElement(iface);
2694 FIXME("(%p)->(%p)\n", This, p);
2695 return E_NOTIMPL;
2698 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
2700 HTMLElement *This = impl_from_IHTMLElement(iface);
2701 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2702 return E_NOTIMPL;
2705 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
2707 HTMLElement *This = impl_from_IHTMLElement(iface);
2708 FIXME("(%p)->(%p)\n", This, p);
2709 return E_NOTIMPL;
2712 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
2714 HTMLElement *This = impl_from_IHTMLElement(iface);
2715 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2716 return E_NOTIMPL;
2719 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
2721 HTMLElement *This = impl_from_IHTMLElement(iface);
2722 FIXME("(%p)->(%p)\n", This, p);
2723 return E_NOTIMPL;
2726 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
2728 HTMLElement *This = impl_from_IHTMLElement(iface);
2729 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2730 return E_NOTIMPL;
2733 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
2735 HTMLElement *This = impl_from_IHTMLElement(iface);
2736 FIXME("(%p)->(%p)\n", This, p);
2737 return E_NOTIMPL;
2740 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
2742 HTMLElement *This = impl_from_IHTMLElement(iface);
2743 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2744 return E_NOTIMPL;
2747 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
2749 HTMLElement *This = impl_from_IHTMLElement(iface);
2750 FIXME("(%p)->(%p)\n", This, p);
2751 return E_NOTIMPL;
2754 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
2756 HTMLElement *This = impl_from_IHTMLElement(iface);
2757 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2758 return E_NOTIMPL;
2761 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
2763 HTMLElement *This = impl_from_IHTMLElement(iface);
2764 FIXME("(%p)->(%p)\n", This, p);
2765 return E_NOTIMPL;
2768 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
2770 HTMLElement *This = impl_from_IHTMLElement(iface);
2772 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
2774 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
2777 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
2779 HTMLElement *This = impl_from_IHTMLElement(iface);
2781 TRACE("(%p)->(%p)\n", This, p);
2783 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
2786 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
2788 HTMLElement *This = impl_from_IHTMLElement(iface);
2789 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2790 return E_NOTIMPL;
2793 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
2795 HTMLElement *This = impl_from_IHTMLElement(iface);
2796 FIXME("(%p)->(%p)\n", This, p);
2797 return E_NOTIMPL;
2800 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
2802 HTMLElement *This = impl_from_IHTMLElement(iface);
2803 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2804 return E_NOTIMPL;
2807 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
2809 HTMLElement *This = impl_from_IHTMLElement(iface);
2810 FIXME("(%p)->(%p)\n", This, p);
2811 return E_NOTIMPL;
2814 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
2816 HTMLElement *This = impl_from_IHTMLElement(iface);
2817 nsIDOMNodeList *nsnode_list;
2818 nsresult nsres;
2820 TRACE("(%p)->(%p)\n", This, p);
2822 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
2823 if(NS_FAILED(nsres)) {
2824 ERR("GetChildNodes failed: %08lx\n", nsres);
2825 return E_FAIL;
2828 *p = (IDispatch*)create_collection_from_nodelist(nsnode_list, This->node.doc->document_mode);
2830 nsIDOMNodeList_Release(nsnode_list);
2831 return S_OK;
2834 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
2836 HTMLElement *This = impl_from_IHTMLElement(iface);
2838 TRACE("(%p)->(%p)\n", This, p);
2840 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
2841 return S_OK;
2844 static const IHTMLElementVtbl HTMLElementVtbl = {
2845 HTMLElement_QueryInterface,
2846 HTMLElement_AddRef,
2847 HTMLElement_Release,
2848 HTMLElement_GetTypeInfoCount,
2849 HTMLElement_GetTypeInfo,
2850 HTMLElement_GetIDsOfNames,
2851 HTMLElement_Invoke,
2852 HTMLElement_setAttribute,
2853 HTMLElement_getAttribute,
2854 HTMLElement_removeAttribute,
2855 HTMLElement_put_className,
2856 HTMLElement_get_className,
2857 HTMLElement_put_id,
2858 HTMLElement_get_id,
2859 HTMLElement_get_tagName,
2860 HTMLElement_get_parentElement,
2861 HTMLElement_get_style,
2862 HTMLElement_put_onhelp,
2863 HTMLElement_get_onhelp,
2864 HTMLElement_put_onclick,
2865 HTMLElement_get_onclick,
2866 HTMLElement_put_ondblclick,
2867 HTMLElement_get_ondblclick,
2868 HTMLElement_put_onkeydown,
2869 HTMLElement_get_onkeydown,
2870 HTMLElement_put_onkeyup,
2871 HTMLElement_get_onkeyup,
2872 HTMLElement_put_onkeypress,
2873 HTMLElement_get_onkeypress,
2874 HTMLElement_put_onmouseout,
2875 HTMLElement_get_onmouseout,
2876 HTMLElement_put_onmouseover,
2877 HTMLElement_get_onmouseover,
2878 HTMLElement_put_onmousemove,
2879 HTMLElement_get_onmousemove,
2880 HTMLElement_put_onmousedown,
2881 HTMLElement_get_onmousedown,
2882 HTMLElement_put_onmouseup,
2883 HTMLElement_get_onmouseup,
2884 HTMLElement_get_document,
2885 HTMLElement_put_title,
2886 HTMLElement_get_title,
2887 HTMLElement_put_language,
2888 HTMLElement_get_language,
2889 HTMLElement_put_onselectstart,
2890 HTMLElement_get_onselectstart,
2891 HTMLElement_scrollIntoView,
2892 HTMLElement_contains,
2893 HTMLElement_get_sourceIndex,
2894 HTMLElement_get_recordNumber,
2895 HTMLElement_put_lang,
2896 HTMLElement_get_lang,
2897 HTMLElement_get_offsetLeft,
2898 HTMLElement_get_offsetTop,
2899 HTMLElement_get_offsetWidth,
2900 HTMLElement_get_offsetHeight,
2901 HTMLElement_get_offsetParent,
2902 HTMLElement_put_innerHTML,
2903 HTMLElement_get_innerHTML,
2904 HTMLElement_put_innerText,
2905 HTMLElement_get_innerText,
2906 HTMLElement_put_outerHTML,
2907 HTMLElement_get_outerHTML,
2908 HTMLElement_put_outerText,
2909 HTMLElement_get_outerText,
2910 HTMLElement_insertAdjacentHTML,
2911 HTMLElement_insertAdjacentText,
2912 HTMLElement_get_parentTextEdit,
2913 HTMLElement_get_isTextEdit,
2914 HTMLElement_click,
2915 HTMLElement_get_filters,
2916 HTMLElement_put_ondragstart,
2917 HTMLElement_get_ondragstart,
2918 HTMLElement_toString,
2919 HTMLElement_put_onbeforeupdate,
2920 HTMLElement_get_onbeforeupdate,
2921 HTMLElement_put_onafterupdate,
2922 HTMLElement_get_onafterupdate,
2923 HTMLElement_put_onerrorupdate,
2924 HTMLElement_get_onerrorupdate,
2925 HTMLElement_put_onrowexit,
2926 HTMLElement_get_onrowexit,
2927 HTMLElement_put_onrowenter,
2928 HTMLElement_get_onrowenter,
2929 HTMLElement_put_ondatasetchanged,
2930 HTMLElement_get_ondatasetchanged,
2931 HTMLElement_put_ondataavailable,
2932 HTMLElement_get_ondataavailable,
2933 HTMLElement_put_ondatasetcomplete,
2934 HTMLElement_get_ondatasetcomplete,
2935 HTMLElement_put_onfilterchange,
2936 HTMLElement_get_onfilterchange,
2937 HTMLElement_get_children,
2938 HTMLElement_get_all
2941 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2943 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2946 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2948 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2951 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
2952 REFIID riid, void **ppv)
2954 HTMLElement *This = impl_from_IHTMLElement2(iface);
2955 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2958 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2960 HTMLElement *This = impl_from_IHTMLElement2(iface);
2961 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2964 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2966 HTMLElement *This = impl_from_IHTMLElement2(iface);
2967 return IHTMLElement_Release(&This->IHTMLElement_iface);
2970 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2972 HTMLElement *This = impl_from_IHTMLElement2(iface);
2973 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2976 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2977 LCID lcid, ITypeInfo **ppTInfo)
2979 HTMLElement *This = impl_from_IHTMLElement2(iface);
2980 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2983 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2984 LPOLESTR *rgszNames, UINT cNames,
2985 LCID lcid, DISPID *rgDispId)
2987 HTMLElement *This = impl_from_IHTMLElement2(iface);
2988 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2989 lcid, rgDispId);
2992 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2993 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2994 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2996 HTMLElement *This = impl_from_IHTMLElement2(iface);
2997 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2998 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3001 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
3003 HTMLElement *This = impl_from_IHTMLElement2(iface);
3004 FIXME("(%p)->(%p)\n", This, p);
3005 return E_NOTIMPL;
3008 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
3010 HTMLElement *This = impl_from_IHTMLElement2(iface);
3011 FIXME("(%p)->(%x)\n", This, containerCapture);
3012 return E_NOTIMPL;
3015 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
3017 HTMLElement *This = impl_from_IHTMLElement2(iface);
3018 FIXME("(%p)\n", This);
3019 return E_NOTIMPL;
3022 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
3024 HTMLElement *This = impl_from_IHTMLElement2(iface);
3025 FIXME("(%p)->()\n", This);
3026 return E_NOTIMPL;
3029 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
3031 HTMLElement *This = impl_from_IHTMLElement2(iface);
3032 FIXME("(%p)->(%p)\n", This, p);
3033 return E_NOTIMPL;
3036 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
3037 LONG x, LONG y, BSTR *component)
3039 HTMLElement *This = impl_from_IHTMLElement2(iface);
3040 FIXME("(%p)->(%ld %ld %p)\n", This, x, y, component);
3041 return E_NOTIMPL;
3044 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
3046 HTMLElement *This = impl_from_IHTMLElement2(iface);
3048 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
3050 if(!This->node.doc->content_ready || !This->node.doc->doc_obj->in_place_active)
3051 return E_PENDING;
3053 WARN("stub\n");
3054 return S_OK;
3057 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
3059 HTMLElement *This = impl_from_IHTMLElement2(iface);
3061 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3063 return set_node_event(&This->node, EVENTID_SCROLL, &v);
3066 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
3068 HTMLElement *This = impl_from_IHTMLElement2(iface);
3070 TRACE("(%p)->(%p)\n", This, p);
3072 return get_node_event(&This->node, EVENTID_SCROLL, p);
3075 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
3077 HTMLElement *This = impl_from_IHTMLElement2(iface);
3079 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3081 return set_node_event(&This->node, EVENTID_DRAG, &v);
3084 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
3086 HTMLElement *This = impl_from_IHTMLElement2(iface);
3088 TRACE("(%p)->(%p)\n", This, p);
3090 return get_node_event(&This->node, EVENTID_DRAG, p);
3093 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
3095 HTMLElement *This = impl_from_IHTMLElement2(iface);
3096 FIXME("(%p)->()\n", This);
3097 return E_NOTIMPL;
3100 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
3102 HTMLElement *This = impl_from_IHTMLElement2(iface);
3103 FIXME("(%p)->(%p)\n", This, p);
3104 return E_NOTIMPL;
3107 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
3109 HTMLElement *This = impl_from_IHTMLElement2(iface);
3110 FIXME("(%p)->()\n", This);
3111 return E_NOTIMPL;
3114 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
3116 HTMLElement *This = impl_from_IHTMLElement2(iface);
3117 FIXME("(%p)->(%p)\n", This, p);
3118 return E_NOTIMPL;
3121 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
3123 HTMLElement *This = impl_from_IHTMLElement2(iface);
3124 FIXME("(%p)->()\n", This);
3125 return E_NOTIMPL;
3128 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
3130 HTMLElement *This = impl_from_IHTMLElement2(iface);
3131 FIXME("(%p)->(%p)\n", This, p);
3132 return E_NOTIMPL;
3135 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
3137 HTMLElement *This = impl_from_IHTMLElement2(iface);
3138 FIXME("(%p)->()\n", This);
3139 return E_NOTIMPL;
3142 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
3144 HTMLElement *This = impl_from_IHTMLElement2(iface);
3145 FIXME("(%p)->(%p)\n", This, p);
3146 return E_NOTIMPL;
3149 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
3151 HTMLElement *This = impl_from_IHTMLElement2(iface);
3152 FIXME("(%p)->()\n", This);
3153 return E_NOTIMPL;
3156 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
3158 HTMLElement *This = impl_from_IHTMLElement2(iface);
3159 FIXME("(%p)->(%p)\n", This, p);
3160 return E_NOTIMPL;
3163 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
3165 HTMLElement *This = impl_from_IHTMLElement2(iface);
3166 FIXME("(%p)->()\n", This);
3167 return E_NOTIMPL;
3170 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
3172 HTMLElement *This = impl_from_IHTMLElement2(iface);
3173 FIXME("(%p)->(%p)\n", This, p);
3174 return E_NOTIMPL;
3177 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
3179 HTMLElement *This = impl_from_IHTMLElement2(iface);
3180 FIXME("(%p)->()\n", This);
3181 return E_NOTIMPL;
3184 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
3186 HTMLElement *This = impl_from_IHTMLElement2(iface);
3187 FIXME("(%p)->(%p)\n", This, p);
3188 return E_NOTIMPL;
3191 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
3193 HTMLElement *This = impl_from_IHTMLElement2(iface);
3194 FIXME("(%p)->()\n", This);
3195 return E_NOTIMPL;
3198 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
3200 HTMLElement *This = impl_from_IHTMLElement2(iface);
3201 FIXME("(%p)->(%p)\n", This, p);
3202 return E_NOTIMPL;
3205 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
3207 HTMLElement *This = impl_from_IHTMLElement2(iface);
3208 FIXME("(%p)->()\n", This);
3209 return E_NOTIMPL;
3212 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
3214 HTMLElement *This = impl_from_IHTMLElement2(iface);
3215 FIXME("(%p)->(%p)\n", This, p);
3216 return E_NOTIMPL;
3219 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
3221 HTMLElement *This = impl_from_IHTMLElement2(iface);
3222 FIXME("(%p)->()\n", This);
3223 return E_NOTIMPL;
3226 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
3228 HTMLElement *This = impl_from_IHTMLElement2(iface);
3229 FIXME("(%p)->(%p)\n", This, p);
3230 return E_NOTIMPL;
3233 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
3235 HTMLElement *This = impl_from_IHTMLElement2(iface);
3237 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3239 return set_node_event(&This->node, EVENTID_PASTE, &v);
3242 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
3244 HTMLElement *This = impl_from_IHTMLElement2(iface);
3246 TRACE("(%p)->(%p)\n", This, p);
3248 return get_node_event(&This->node, EVENTID_PASTE, p);
3251 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
3253 HTMLElement *This = impl_from_IHTMLElement2(iface);
3255 TRACE("(%p)->(%p)\n", This, p);
3257 return HTMLCurrentStyle_Create(This, p);
3260 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
3262 HTMLElement *This = impl_from_IHTMLElement2(iface);
3263 FIXME("(%p)->()\n", This);
3264 return E_NOTIMPL;
3267 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
3269 HTMLElement *This = impl_from_IHTMLElement2(iface);
3270 FIXME("(%p)->(%p)\n", This, p);
3271 return E_NOTIMPL;
3274 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
3276 HTMLElement *This = impl_from_IHTMLElement2(iface);
3277 nsIDOMClientRectList *rect_list;
3278 HTMLRectCollection *rects;
3279 nsresult nsres;
3281 TRACE("(%p)->(%p)\n", This, pRectCol);
3283 if(!This->dom_element) {
3284 FIXME("comment element\n");
3285 return E_NOTIMPL;
3288 nsres = nsIDOMElement_GetClientRects(This->dom_element, &rect_list);
3289 if(NS_FAILED(nsres)) {
3290 WARN("GetClientRects failed: %08lx\n", nsres);
3291 return map_nsresult(nsres);
3294 rects = calloc(1, sizeof(*rects));
3295 if(!rects) {
3296 nsIDOMClientRectList_Release(rect_list);
3297 return E_OUTOFMEMORY;
3300 rects->IHTMLRectCollection_iface.lpVtbl = &HTMLRectCollectionVtbl;
3301 rects->ref = 1;
3302 rects->rect_list = rect_list;
3303 init_dispatch(&rects->dispex, (IUnknown*)&rects->IHTMLRectCollection_iface,
3304 &HTMLRectCollection_dispex, dispex_compat_mode(&This->node.event_target.dispex));
3306 *pRectCol = &rects->IHTMLRectCollection_iface;
3307 return S_OK;
3310 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
3312 HTMLElement *This = impl_from_IHTMLElement2(iface);
3313 nsIDOMClientRect *nsrect;
3314 nsresult nsres;
3315 HRESULT hres;
3317 TRACE("(%p)->(%p)\n", This, pRect);
3319 if(!This->dom_element) {
3320 FIXME("comment element\n");
3321 return E_NOTIMPL;
3324 nsres = nsIDOMElement_GetBoundingClientRect(This->dom_element, &nsrect);
3325 if(NS_FAILED(nsres) || !nsrect) {
3326 ERR("GetBoindingClientRect failed: %08lx\n", nsres);
3327 return E_FAIL;
3330 hres = create_html_rect(nsrect, dispex_compat_mode(&This->node.event_target.dispex), pRect);
3332 nsIDOMClientRect_Release(nsrect);
3333 return hres;
3336 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
3337 BSTR expression, BSTR language)
3339 HTMLElement *This = impl_from_IHTMLElement2(iface);
3340 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
3341 debugstr_w(language));
3342 return E_NOTIMPL;
3345 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
3346 VARIANT *expression)
3348 HTMLElement *This = impl_from_IHTMLElement2(iface);
3349 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
3350 return E_NOTIMPL;
3353 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
3354 VARIANT_BOOL *pfSuccess)
3356 HTMLElement *This = impl_from_IHTMLElement2(iface);
3357 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
3358 return E_NOTIMPL;
3361 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
3363 HTMLElement *This = impl_from_IHTMLElement2(iface);
3364 nsresult nsres;
3366 TRACE("(%p)->(%d)\n", This, v);
3368 if(!This->html_element) {
3369 FIXME("non-HTML element\n");
3370 return E_NOTIMPL;
3373 nsres = nsIDOMHTMLElement_SetTabIndex(This->html_element, v);
3374 if(NS_FAILED(nsres))
3375 ERR("GetTabIndex failed: %08lx\n", nsres);
3377 return S_OK;
3380 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
3382 HTMLElement *This = impl_from_IHTMLElement2(iface);
3383 LONG index;
3384 nsresult nsres;
3386 TRACE("(%p)->(%p)\n", This, p);
3388 if(!This->html_element) {
3389 FIXME("non-HTML element\n");
3390 return E_NOTIMPL;
3393 nsres = nsIDOMHTMLElement_GetTabIndex(This->html_element, &index);
3394 if(NS_FAILED(nsres)) {
3395 ERR("GetTabIndex failed: %08lx\n", nsres);
3396 return E_FAIL;
3399 *p = index;
3400 return S_OK;
3403 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
3405 HTMLElement *This = impl_from_IHTMLElement2(iface);
3406 nsresult nsres;
3408 TRACE("(%p)\n", This);
3410 if(!This->html_element) {
3411 FIXME("non-HTML element\n");
3412 return E_NOTIMPL;
3415 nsres = nsIDOMHTMLElement_Focus(This->html_element);
3416 if(NS_FAILED(nsres))
3417 ERR("Focus failed: %08lx\n", nsres);
3419 return S_OK;
3422 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
3424 HTMLElement *This = impl_from_IHTMLElement2(iface);
3425 nsAString nsstr;
3426 nsresult nsres;
3428 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3430 if(!This->html_element) {
3431 FIXME("non-HTML element\n");
3432 return E_NOTIMPL;
3435 nsAString_InitDepend(&nsstr, v);
3436 nsres = nsIDOMHTMLElement_SetAccessKey(This->html_element, &nsstr);
3437 nsAString_Finish(&nsstr);
3438 return map_nsresult(nsres);
3441 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
3443 HTMLElement *This = impl_from_IHTMLElement2(iface);
3444 nsAString nsstr;
3445 nsresult nsres;
3447 TRACE("(%p)->(%p)\n", This, p);
3449 if(!This->html_element) {
3450 FIXME("non-HTML element\n");
3451 return E_NOTIMPL;
3454 nsAString_InitDepend(&nsstr, NULL);
3455 nsres = nsIDOMHTMLElement_GetAccessKey(This->html_element, &nsstr);
3456 return return_nsstr(nsres, &nsstr, p);
3459 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
3461 HTMLElement *This = impl_from_IHTMLElement2(iface);
3463 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3465 return set_node_event(&This->node, EVENTID_BLUR, &v);
3468 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
3470 HTMLElement *This = impl_from_IHTMLElement2(iface);
3472 TRACE("(%p)->(%p)\n", This, p);
3474 return get_node_event(&This->node, EVENTID_BLUR, p);
3477 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
3479 HTMLElement *This = impl_from_IHTMLElement2(iface);
3481 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3483 return set_node_event(&This->node, EVENTID_FOCUS, &v);
3486 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
3488 HTMLElement *This = impl_from_IHTMLElement2(iface);
3490 TRACE("(%p)->(%p)\n", This, p);
3492 return get_node_event(&This->node, EVENTID_FOCUS, p);
3495 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
3497 HTMLElement *This = impl_from_IHTMLElement2(iface);
3499 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3501 return set_node_event(&This->node, EVENTID_RESIZE, &v);
3504 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
3506 HTMLElement *This = impl_from_IHTMLElement2(iface);
3508 TRACE("(%p)->(%p)\n", This, p);
3510 return get_node_event(&This->node, EVENTID_RESIZE, p);
3513 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
3515 HTMLElement *This = impl_from_IHTMLElement2(iface);
3516 nsresult nsres;
3518 TRACE("(%p)\n", This);
3520 if(!This->html_element) {
3521 FIXME("non-HTML element\n");
3522 return E_NOTIMPL;
3525 nsres = nsIDOMHTMLElement_Blur(This->html_element);
3526 if(NS_FAILED(nsres)) {
3527 ERR("Blur failed: %08lx\n", nsres);
3528 return E_FAIL;
3531 return S_OK;
3534 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3536 HTMLElement *This = impl_from_IHTMLElement2(iface);
3537 FIXME("(%p)->(%p)\n", This, pUnk);
3538 return E_NOTIMPL;
3541 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3543 HTMLElement *This = impl_from_IHTMLElement2(iface);
3544 FIXME("(%p)->(%p)\n", This, pUnk);
3545 return E_NOTIMPL;
3548 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
3550 HTMLElement *This = impl_from_IHTMLElement2(iface);
3551 nsresult nsres;
3553 TRACE("(%p)->(%p)\n", This, p);
3555 if(!This->dom_element) {
3556 FIXME("Unimplemented for comment element\n");
3557 return E_NOTIMPL;
3560 nsres = nsIDOMElement_GetClientHeight(This->dom_element, p);
3561 assert(nsres == NS_OK);
3562 return S_OK;
3565 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
3567 HTMLElement *This = impl_from_IHTMLElement2(iface);
3568 nsresult nsres;
3570 TRACE("(%p)->(%p)\n", This, p);
3572 if(!This->dom_element) {
3573 FIXME("comment element\n");
3574 return E_NOTIMPL;
3577 nsres = nsIDOMElement_GetClientWidth(This->dom_element, p);
3578 assert(nsres == NS_OK);
3579 return S_OK;
3582 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
3584 HTMLElement *This = impl_from_IHTMLElement2(iface);
3585 nsresult nsres;
3587 TRACE("(%p)->(%p)\n", This, p);
3589 if(!This->dom_element) {
3590 FIXME("comment element\n");
3591 return E_NOTIMPL;
3594 nsres = nsIDOMElement_GetClientTop(This->dom_element, p);
3595 assert(nsres == NS_OK);
3597 TRACE("*p = %ld\n", *p);
3598 return S_OK;
3601 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
3603 HTMLElement *This = impl_from_IHTMLElement2(iface);
3604 nsresult nsres;
3606 TRACE("(%p)->(%p)\n", This, p);
3608 if(!This->dom_element) {
3609 FIXME("comment element\n");
3610 return E_NOTIMPL;
3613 nsres = nsIDOMElement_GetClientLeft(This->dom_element, p);
3614 assert(nsres == NS_OK);
3616 TRACE("*p = %ld\n", *p);
3617 return S_OK;
3620 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
3621 IDispatch *pDisp, VARIANT_BOOL *pfResult)
3623 HTMLElement *This = impl_from_IHTMLElement2(iface);
3625 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
3627 return attach_event(&This->node.event_target, event, pDisp, pfResult);
3630 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
3632 HTMLElement *This = impl_from_IHTMLElement2(iface);
3634 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
3636 return detach_event(&This->node.event_target, event, pDisp);
3639 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
3641 HTMLElement *This = impl_from_IHTMLElement2(iface);
3642 BSTR str;
3644 TRACE("(%p)->(%p)\n", This, p);
3646 if(This->node.vtbl->get_readystate) {
3647 HRESULT hres;
3649 hres = This->node.vtbl->get_readystate(&This->node, &str);
3650 if(FAILED(hres))
3651 return hres;
3652 }else {
3653 str = SysAllocString(L"complete");
3654 if(!str)
3655 return E_OUTOFMEMORY;
3658 V_VT(p) = VT_BSTR;
3659 V_BSTR(p) = str;
3660 return S_OK;
3663 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
3665 HTMLElement *This = impl_from_IHTMLElement2(iface);
3667 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3669 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
3672 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
3674 HTMLElement *This = impl_from_IHTMLElement2(iface);
3676 TRACE("(%p)->(%p)\n", This, p);
3678 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
3681 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
3683 HTMLElement *This = impl_from_IHTMLElement2(iface);
3684 FIXME("(%p)->()\n", This);
3685 return E_NOTIMPL;
3688 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
3690 HTMLElement *This = impl_from_IHTMLElement2(iface);
3691 FIXME("(%p)->(%p)\n", This, p);
3692 return E_NOTIMPL;
3695 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
3697 HTMLElement *This = impl_from_IHTMLElement2(iface);
3698 FIXME("(%p)->()\n", This);
3699 return E_NOTIMPL;
3702 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
3704 HTMLElement *This = impl_from_IHTMLElement2(iface);
3705 FIXME("(%p)->(%p)\n", This, p);
3706 return E_NOTIMPL;
3709 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
3711 HTMLElement *This = impl_from_IHTMLElement2(iface);
3712 FIXME("(%p)->()\n", This);
3713 return E_NOTIMPL;
3716 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
3718 HTMLElement *This = impl_from_IHTMLElement2(iface);
3719 FIXME("(%p)->(%p)\n", This, p);
3720 return E_NOTIMPL;
3723 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
3725 HTMLElement *This = impl_from_IHTMLElement2(iface);
3726 nsAString nsstr;
3727 nsresult nsres;
3729 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3731 if(!This->html_element) {
3732 FIXME("non-HTML element\n");
3733 return S_OK;
3736 nsAString_InitDepend(&nsstr, v);
3737 nsres = nsIDOMHTMLElement_SetDir(This->html_element, &nsstr);
3738 nsAString_Finish(&nsstr);
3739 if(NS_FAILED(nsres)) {
3740 ERR("SetDir failed: %08lx\n", nsres);
3741 return E_FAIL;
3744 return S_OK;
3747 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
3749 HTMLElement *This = impl_from_IHTMLElement2(iface);
3750 nsAString dir_str;
3751 nsresult nsres;
3753 TRACE("(%p)->(%p)\n", This, p);
3755 if(!This->html_element) {
3756 if(This->dom_element)
3757 FIXME("non-HTML element\n");
3758 *p = NULL;
3759 return S_OK;
3762 nsAString_Init(&dir_str, NULL);
3763 nsres = nsIDOMHTMLElement_GetDir(This->html_element, &dir_str);
3764 return return_nsstr(nsres, &dir_str, p);
3767 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
3769 HTMLElement *This = impl_from_IHTMLElement2(iface);
3770 FIXME("(%p)->(%p)\n", This, range);
3771 return E_NOTIMPL;
3774 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
3776 HTMLElement *This = impl_from_IHTMLElement2(iface);
3777 nsresult nsres;
3779 TRACE("(%p)->(%p)\n", This, p);
3781 if(!This->dom_element) {
3782 FIXME("comment element\n");
3783 return E_NOTIMPL;
3786 nsres = nsIDOMElement_GetScrollHeight(This->dom_element, p);
3787 assert(nsres == NS_OK);
3788 TRACE("*p = %ld\n", *p);
3789 return S_OK;
3792 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
3794 HTMLElement *This = impl_from_IHTMLElement2(iface);
3795 nsresult nsres;
3797 TRACE("(%p)->(%p)\n", This, p);
3799 if(!This->dom_element) {
3800 FIXME("comment element\n");
3801 return E_NOTIMPL;
3804 nsres = nsIDOMElement_GetScrollWidth(This->dom_element, p);
3805 assert(nsres == NS_OK);
3807 TRACE("*p = %ld\n", *p);
3808 return S_OK;
3811 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
3813 HTMLElement *This = impl_from_IHTMLElement2(iface);
3815 TRACE("(%p)->(%ld)\n", This, v);
3817 if(!This->dom_element) {
3818 FIXME("comment element\n");
3819 return E_NOTIMPL;
3822 nsIDOMElement_SetScrollTop(This->dom_element, v);
3823 return S_OK;
3826 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
3828 HTMLElement *This = impl_from_IHTMLElement2(iface);
3829 nsresult nsres;
3831 TRACE("(%p)->(%p)\n", This, p);
3833 if(!This->dom_element) {
3834 FIXME("comment element\n");
3835 return E_NOTIMPL;
3838 nsres = nsIDOMElement_GetScrollTop(This->dom_element, p);
3839 assert(nsres == NS_OK);
3841 TRACE("*p = %ld\n", *p);
3842 return S_OK;
3845 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
3847 HTMLElement *This = impl_from_IHTMLElement2(iface);
3849 TRACE("(%p)->(%ld)\n", This, v);
3851 if(!This->dom_element) {
3852 FIXME("comment element\n");
3853 return E_NOTIMPL;
3856 nsIDOMElement_SetScrollLeft(This->dom_element, v);
3857 return S_OK;
3860 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
3862 HTMLElement *This = impl_from_IHTMLElement2(iface);
3863 nsresult nsres;
3865 TRACE("(%p)->(%p)\n", This, p);
3867 if(!p)
3868 return E_INVALIDARG;
3870 if(!This->dom_element) {
3871 FIXME("comment element\n");
3872 return E_NOTIMPL;
3875 nsres = nsIDOMElement_GetScrollLeft(This->dom_element, p);
3876 assert(nsres == NS_OK);
3877 TRACE("*p = %ld\n", *p);
3878 return S_OK;
3881 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
3883 HTMLElement *This = impl_from_IHTMLElement2(iface);
3884 FIXME("(%p)\n", This);
3885 return E_NOTIMPL;
3888 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
3890 HTMLElement *This = impl_from_IHTMLElement2(iface);
3891 FIXME("(%p)->(%p)\n", This, mergeThis);
3892 return E_NOTIMPL;
3895 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
3897 HTMLElement *This = impl_from_IHTMLElement2(iface);
3899 TRACE("(%p)->()\n", This);
3901 return set_node_event(&This->node, EVENTID_CONTEXTMENU, &v);
3904 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
3906 HTMLElement *This = impl_from_IHTMLElement2(iface);
3908 TRACE("(%p)->(%p)\n", This, p);
3910 return get_node_event(&This->node, EVENTID_CONTEXTMENU, p);
3913 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
3914 IHTMLElement *insertedElement, IHTMLElement **inserted)
3916 HTMLElement *This = impl_from_IHTMLElement2(iface);
3917 HTMLDOMNode *ret_node;
3918 HTMLElement *elem;
3919 HRESULT hres;
3921 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
3923 elem = unsafe_impl_from_IHTMLElement(insertedElement);
3924 if(!elem)
3925 return E_INVALIDARG;
3927 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
3928 if(FAILED(hres))
3929 return hres;
3931 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
3932 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
3933 return hres;
3936 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
3937 BSTR where, IHTMLElement **applied)
3939 HTMLElement *This = impl_from_IHTMLElement2(iface);
3940 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
3941 return E_NOTIMPL;
3944 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
3946 HTMLElement *This = impl_from_IHTMLElement2(iface);
3947 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
3948 return E_NOTIMPL;
3951 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
3952 BSTR newText, BSTR *oldText)
3954 HTMLElement *This = impl_from_IHTMLElement2(iface);
3955 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
3956 return E_NOTIMPL;
3959 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
3961 HTMLElement *This = impl_from_IHTMLElement2(iface);
3962 FIXME("(%p)->(%p)\n", This, p);
3963 return E_NOTIMPL;
3966 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
3967 VARIANT *pvarFactory, LONG *pCookie)
3969 HTMLElement *This = impl_from_IHTMLElement2(iface);
3970 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
3971 return E_NOTIMPL;
3974 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
3975 VARIANT_BOOL *pfResult)
3977 HTMLElement *This = impl_from_IHTMLElement2(iface);
3978 FIXME("(%p)->(%ld %p)\n", This, cookie, pfResult);
3979 return E_NOTIMPL;
3982 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
3984 HTMLElement *This = impl_from_IHTMLElement2(iface);
3986 FIXME("(%p)->(%p): hack\n", This, p);
3988 /* We can't implement correct behavior on top of Gecko (although we could
3989 try a bit harder). Making runtimeStyle behave like regular style is
3990 enough for most use cases. */
3991 if(!This->runtime_style) {
3992 HRESULT hres;
3994 hres = HTMLStyle_Create(This, &This->runtime_style);
3995 if(FAILED(hres))
3996 return hres;
3999 *p = &This->runtime_style->IHTMLStyle_iface;
4000 IHTMLStyle_AddRef(*p);
4001 return S_OK;
4004 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
4006 HTMLElement *This = impl_from_IHTMLElement2(iface);
4007 FIXME("(%p)->(%p)\n", This, p);
4008 return E_NOTIMPL;
4011 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
4013 HTMLElement *This = impl_from_IHTMLElement2(iface);
4014 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
4015 return E_NOTIMPL;
4018 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
4020 HTMLElement *This = impl_from_IHTMLElement2(iface);
4021 FIXME("(%p)->(%p)\n", This, p);
4022 return E_NOTIMPL;
4025 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
4027 HTMLElement *This = impl_from_IHTMLElement2(iface);
4028 FIXME("(%p)->()\n", This);
4029 return E_NOTIMPL;
4032 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
4034 HTMLElement *This = impl_from_IHTMLElement2(iface);
4035 FIXME("(%p)->(%p)\n", This, p);
4036 return E_NOTIMPL;
4039 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
4041 HTMLElement *This = impl_from_IHTMLElement2(iface);
4042 FIXME("(%p)->(%p)\n", This, p);
4043 return E_NOTIMPL;
4046 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
4047 IHTMLElementCollection **pelColl)
4049 HTMLElement *This = impl_from_IHTMLElement2(iface);
4050 nsIDOMHTMLCollection *nscol;
4051 nsAString tag_str;
4052 nsresult nsres;
4054 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
4056 if(!This->dom_element) {
4057 *pelColl = create_collection_from_htmlcol(NULL, This->node.doc->document_mode);
4058 return S_OK;
4061 nsAString_InitDepend(&tag_str, v);
4062 nsres = nsIDOMElement_GetElementsByTagName(This->dom_element, &tag_str, &nscol);
4063 nsAString_Finish(&tag_str);
4064 if(NS_FAILED(nsres)) {
4065 ERR("GetElementByTagName failed: %08lx\n", nsres);
4066 return E_FAIL;
4069 *pelColl = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
4070 nsIDOMHTMLCollection_Release(nscol);
4071 return S_OK;
4074 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
4075 HTMLElement2_QueryInterface,
4076 HTMLElement2_AddRef,
4077 HTMLElement2_Release,
4078 HTMLElement2_GetTypeInfoCount,
4079 HTMLElement2_GetTypeInfo,
4080 HTMLElement2_GetIDsOfNames,
4081 HTMLElement2_Invoke,
4082 HTMLElement2_get_scopeName,
4083 HTMLElement2_setCapture,
4084 HTMLElement2_releaseCapture,
4085 HTMLElement2_put_onlosecapture,
4086 HTMLElement2_get_onlosecapture,
4087 HTMLElement2_componentFromPoint,
4088 HTMLElement2_doScroll,
4089 HTMLElement2_put_onscroll,
4090 HTMLElement2_get_onscroll,
4091 HTMLElement2_put_ondrag,
4092 HTMLElement2_get_ondrag,
4093 HTMLElement2_put_ondragend,
4094 HTMLElement2_get_ondragend,
4095 HTMLElement2_put_ondragenter,
4096 HTMLElement2_get_ondragenter,
4097 HTMLElement2_put_ondragover,
4098 HTMLElement2_get_ondragover,
4099 HTMLElement2_put_ondragleave,
4100 HTMLElement2_get_ondragleave,
4101 HTMLElement2_put_ondrop,
4102 HTMLElement2_get_ondrop,
4103 HTMLElement2_put_onbeforecut,
4104 HTMLElement2_get_onbeforecut,
4105 HTMLElement2_put_oncut,
4106 HTMLElement2_get_oncut,
4107 HTMLElement2_put_onbeforecopy,
4108 HTMLElement2_get_onbeforecopy,
4109 HTMLElement2_put_oncopy,
4110 HTMLElement2_get_oncopy,
4111 HTMLElement2_put_onbeforepaste,
4112 HTMLElement2_get_onbeforepaste,
4113 HTMLElement2_put_onpaste,
4114 HTMLElement2_get_onpaste,
4115 HTMLElement2_get_currentStyle,
4116 HTMLElement2_put_onpropertychange,
4117 HTMLElement2_get_onpropertychange,
4118 HTMLElement2_getClientRects,
4119 HTMLElement2_getBoundingClientRect,
4120 HTMLElement2_setExpression,
4121 HTMLElement2_getExpression,
4122 HTMLElement2_removeExpression,
4123 HTMLElement2_put_tabIndex,
4124 HTMLElement2_get_tabIndex,
4125 HTMLElement2_focus,
4126 HTMLElement2_put_accessKey,
4127 HTMLElement2_get_accessKey,
4128 HTMLElement2_put_onblur,
4129 HTMLElement2_get_onblur,
4130 HTMLElement2_put_onfocus,
4131 HTMLElement2_get_onfocus,
4132 HTMLElement2_put_onresize,
4133 HTMLElement2_get_onresize,
4134 HTMLElement2_blur,
4135 HTMLElement2_addFilter,
4136 HTMLElement2_removeFilter,
4137 HTMLElement2_get_clientHeight,
4138 HTMLElement2_get_clientWidth,
4139 HTMLElement2_get_clientTop,
4140 HTMLElement2_get_clientLeft,
4141 HTMLElement2_attachEvent,
4142 HTMLElement2_detachEvent,
4143 HTMLElement2_get_readyState,
4144 HTMLElement2_put_onreadystatechange,
4145 HTMLElement2_get_onreadystatechange,
4146 HTMLElement2_put_onrowsdelete,
4147 HTMLElement2_get_onrowsdelete,
4148 HTMLElement2_put_onrowsinserted,
4149 HTMLElement2_get_onrowsinserted,
4150 HTMLElement2_put_oncellchange,
4151 HTMLElement2_get_oncellchange,
4152 HTMLElement2_put_dir,
4153 HTMLElement2_get_dir,
4154 HTMLElement2_createControlRange,
4155 HTMLElement2_get_scrollHeight,
4156 HTMLElement2_get_scrollWidth,
4157 HTMLElement2_put_scrollTop,
4158 HTMLElement2_get_scrollTop,
4159 HTMLElement2_put_scrollLeft,
4160 HTMLElement2_get_scrollLeft,
4161 HTMLElement2_clearAttributes,
4162 HTMLElement2_mergeAttributes,
4163 HTMLElement2_put_oncontextmenu,
4164 HTMLElement2_get_oncontextmenu,
4165 HTMLElement2_insertAdjacentElement,
4166 HTMLElement2_applyElement,
4167 HTMLElement2_getAdjacentText,
4168 HTMLElement2_replaceAdjacentText,
4169 HTMLElement2_get_canHandleChildren,
4170 HTMLElement2_addBehavior,
4171 HTMLElement2_removeBehavior,
4172 HTMLElement2_get_runtimeStyle,
4173 HTMLElement2_get_behaviorUrns,
4174 HTMLElement2_put_tagUrn,
4175 HTMLElement2_get_tagUrn,
4176 HTMLElement2_put_onbeforeeditfocus,
4177 HTMLElement2_get_onbeforeeditfocus,
4178 HTMLElement2_get_readyStateValue,
4179 HTMLElement2_getElementsByTagName,
4182 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
4184 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
4187 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
4188 REFIID riid, void **ppv)
4190 HTMLElement *This = impl_from_IHTMLElement3(iface);
4191 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4194 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
4196 HTMLElement *This = impl_from_IHTMLElement3(iface);
4197 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4200 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
4202 HTMLElement *This = impl_from_IHTMLElement3(iface);
4203 return IHTMLElement_Release(&This->IHTMLElement_iface);
4206 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
4208 HTMLElement *This = impl_from_IHTMLElement3(iface);
4209 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4212 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
4213 LCID lcid, ITypeInfo **ppTInfo)
4215 HTMLElement *This = impl_from_IHTMLElement3(iface);
4216 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4219 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
4220 LPOLESTR *rgszNames, UINT cNames,
4221 LCID lcid, DISPID *rgDispId)
4223 HTMLElement *This = impl_from_IHTMLElement3(iface);
4224 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4225 lcid, rgDispId);
4228 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
4229 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4230 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4232 HTMLElement *This = impl_from_IHTMLElement3(iface);
4233 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4234 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4237 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
4239 HTMLElement *This = impl_from_IHTMLElement3(iface);
4240 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
4241 return E_NOTIMPL;
4244 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
4246 HTMLElement *This = impl_from_IHTMLElement3(iface);
4247 FIXME("(%p)->(%p)\n", This, p);
4248 return E_NOTIMPL;
4251 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
4253 HTMLElement *This = impl_from_IHTMLElement3(iface);
4254 FIXME("(%p)->(%p)\n", This, p);
4255 return E_NOTIMPL;
4258 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
4260 HTMLElement *This = impl_from_IHTMLElement3(iface);
4261 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4262 return E_NOTIMPL;
4265 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
4267 HTMLElement *This = impl_from_IHTMLElement3(iface);
4268 FIXME("(%p)->(%p)\n", This, p);
4269 return E_NOTIMPL;
4272 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
4274 HTMLElement *This = impl_from_IHTMLElement3(iface);
4275 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4276 return E_NOTIMPL;
4279 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
4281 HTMLElement *This = impl_from_IHTMLElement3(iface);
4282 FIXME("(%p)->(%p)\n", This, p);
4283 return E_NOTIMPL;
4286 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
4288 HTMLElement *This = impl_from_IHTMLElement3(iface);
4289 FIXME("(%p)->(%x)\n", This, v);
4290 return E_NOTIMPL;
4293 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
4295 HTMLElement *This = impl_from_IHTMLElement3(iface);
4296 FIXME("(%p)->(%p)\n", This, p);
4297 return E_NOTIMPL;
4300 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
4302 HTMLElement *This = impl_from_IHTMLElement3(iface);
4303 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4304 return E_NOTIMPL;
4307 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
4309 HTMLElement *This = impl_from_IHTMLElement3(iface);
4310 FIXME("(%p)->(%p)\n", This, p);
4311 return E_NOTIMPL;
4314 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
4316 HTMLElement *This = impl_from_IHTMLElement3(iface);
4317 FIXME("(%p)\n", This);
4318 return E_NOTIMPL;
4321 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
4323 HTMLElement *This = impl_from_IHTMLElement3(iface);
4324 nsresult nsres;
4325 nsAString str;
4327 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
4329 if(!This->html_element) {
4330 FIXME("non-HTML element\n");
4331 return E_NOTIMPL;
4334 nsAString_InitDepend(&str, v);
4335 nsres = nsIDOMHTMLElement_SetContentEditable(This->html_element, &str);
4336 nsAString_Finish(&str);
4338 if (NS_FAILED(nsres)){
4339 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
4340 return E_FAIL;
4343 return S_OK;
4346 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
4348 HTMLElement *This = impl_from_IHTMLElement3(iface);
4349 nsresult nsres;
4350 nsAString str;
4352 TRACE("(%p)->(%p)\n", This, p);
4354 if(!This->html_element) {
4355 FIXME("non-HTML element\n");
4356 return E_NOTIMPL;
4359 nsAString_Init(&str, NULL);
4360 nsres = nsIDOMHTMLElement_GetContentEditable(This->html_element, &str);
4361 return return_nsstr(nsres, &str, p);
4364 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
4366 HTMLElement *This = impl_from_IHTMLElement3(iface);
4367 nsresult nsres;
4368 cpp_bool r;
4370 TRACE("(%p)->(%p)\n", This, p);
4372 if(!This->html_element) {
4373 FIXME("non-HTML element\n");
4374 return E_NOTIMPL;
4377 nsres = nsIDOMHTMLElement_GetIsContentEditable(This->html_element, &r);
4378 *p = variant_bool(NS_SUCCEEDED(nsres) && r);
4379 return S_OK;
4382 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
4384 HTMLElement *This = impl_from_IHTMLElement3(iface);
4385 FIXME("(%p)->(%x)\n", This, v);
4386 return E_NOTIMPL;
4389 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
4391 HTMLElement *This = impl_from_IHTMLElement3(iface);
4392 FIXME("(%p)->(%p)\n", This, p);
4393 return E_NOTIMPL;
4396 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
4398 HTMLElement *This = impl_from_IHTMLElement3(iface);
4400 TRACE("(%p)->(%x)\n", This, v);
4402 if(This->node.vtbl->put_disabled)
4403 return This->node.vtbl->put_disabled(&This->node, v);
4405 if(!v) return element_remove_attribute(This, L"disabled");
4406 return elem_string_attr_setter(This, L"disabled", L"");
4409 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4411 HTMLElement *This = impl_from_IHTMLElement3(iface);
4413 TRACE("(%p)->(%p)\n", This, p);
4415 if(This->node.vtbl->get_disabled)
4416 return This->node.vtbl->get_disabled(&This->node, p);
4418 *p = variant_bool(element_has_attribute(This, L"disabled"));
4419 return S_OK;
4422 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4424 HTMLElement *This = impl_from_IHTMLElement3(iface);
4425 FIXME("(%p)->(%p)\n", This, p);
4426 return E_NOTIMPL;
4429 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
4431 HTMLElement *This = impl_from_IHTMLElement3(iface);
4432 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4433 return E_NOTIMPL;
4436 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
4438 HTMLElement *This = impl_from_IHTMLElement3(iface);
4439 FIXME("(%p)->(%p)\n", This, p);
4440 return E_NOTIMPL;
4443 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
4445 HTMLElement *This = impl_from_IHTMLElement3(iface);
4446 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4447 return E_NOTIMPL;
4450 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
4452 HTMLElement *This = impl_from_IHTMLElement3(iface);
4453 FIXME("(%p)->(%p)\n", This, p);
4454 return E_NOTIMPL;
4457 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
4458 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
4460 HTMLElement *This = impl_from_IHTMLElement3(iface);
4462 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
4463 pfCancelled);
4465 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
4468 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
4470 HTMLElement *This = impl_from_IHTMLElement3(iface);
4471 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4472 return E_NOTIMPL;
4475 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
4477 HTMLElement *This = impl_from_IHTMLElement3(iface);
4478 FIXME("(%p)->(%p)\n", This, p);
4479 return E_NOTIMPL;
4482 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
4484 HTMLElement *This = impl_from_IHTMLElement3(iface);
4485 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4486 return E_NOTIMPL;
4489 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
4491 HTMLElement *This = impl_from_IHTMLElement3(iface);
4492 FIXME("(%p)->(%p)\n", This, p);
4493 return E_NOTIMPL;
4496 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
4498 HTMLElement *This = impl_from_IHTMLElement3(iface);
4499 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4500 return E_NOTIMPL;
4503 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
4505 HTMLElement *This = impl_from_IHTMLElement3(iface);
4506 FIXME("(%p)->(%p)\n", This, p);
4507 return E_NOTIMPL;
4510 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
4512 HTMLElement *This = impl_from_IHTMLElement3(iface);
4513 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4514 return E_NOTIMPL;
4517 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
4519 HTMLElement *This = impl_from_IHTMLElement3(iface);
4520 FIXME("(%p)->(%p)\n", This, p);
4521 return E_NOTIMPL;
4524 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
4526 HTMLElement *This = impl_from_IHTMLElement3(iface);
4527 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4528 return E_NOTIMPL;
4531 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
4533 HTMLElement *This = impl_from_IHTMLElement3(iface);
4534 FIXME("(%p)->(%p)\n", This, p);
4535 return E_NOTIMPL;
4538 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
4540 HTMLElement *This = impl_from_IHTMLElement3(iface);
4541 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4542 return E_NOTIMPL;
4545 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
4547 HTMLElement *This = impl_from_IHTMLElement3(iface);
4548 FIXME("(%p)->(%p)\n", This, p);
4549 return E_NOTIMPL;
4552 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
4554 HTMLElement *This = impl_from_IHTMLElement3(iface);
4555 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4556 return E_NOTIMPL;
4559 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
4561 HTMLElement *This = impl_from_IHTMLElement3(iface);
4562 FIXME("(%p)->(%p)\n", This, p);
4563 return E_NOTIMPL;
4566 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
4568 HTMLElement *This = impl_from_IHTMLElement3(iface);
4569 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4570 return E_NOTIMPL;
4573 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
4575 HTMLElement *This = impl_from_IHTMLElement3(iface);
4576 FIXME("(%p)->(%p)\n", This, p);
4577 return E_NOTIMPL;
4580 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
4582 HTMLElement *This = impl_from_IHTMLElement3(iface);
4583 FIXME("(%p)->(%p)\n", This, pfRet);
4584 return E_NOTIMPL;
4587 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
4589 HTMLElement *This = impl_from_IHTMLElement3(iface);
4590 FIXME("(%p)->(%p)\n", This, p);
4591 return E_NOTIMPL;
4594 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
4595 HTMLElement3_QueryInterface,
4596 HTMLElement3_AddRef,
4597 HTMLElement3_Release,
4598 HTMLElement3_GetTypeInfoCount,
4599 HTMLElement3_GetTypeInfo,
4600 HTMLElement3_GetIDsOfNames,
4601 HTMLElement3_Invoke,
4602 HTMLElement3_mergeAttributes,
4603 HTMLElement3_get_isMultiLine,
4604 HTMLElement3_get_canHaveHTML,
4605 HTMLElement3_put_onlayoutcomplete,
4606 HTMLElement3_get_onlayoutcomplete,
4607 HTMLElement3_put_onpage,
4608 HTMLElement3_get_onpage,
4609 HTMLElement3_put_inflateBlock,
4610 HTMLElement3_get_inflateBlock,
4611 HTMLElement3_put_onbeforedeactivate,
4612 HTMLElement3_get_onbeforedeactivate,
4613 HTMLElement3_setActive,
4614 HTMLElement3_put_contentEditable,
4615 HTMLElement3_get_contentEditable,
4616 HTMLElement3_get_isContentEditable,
4617 HTMLElement3_put_hideFocus,
4618 HTMLElement3_get_hideFocus,
4619 HTMLElement3_put_disabled,
4620 HTMLElement3_get_disabled,
4621 HTMLElement3_get_isDisabled,
4622 HTMLElement3_put_onmove,
4623 HTMLElement3_get_onmove,
4624 HTMLElement3_put_oncontrolselect,
4625 HTMLElement3_get_oncontrolselect,
4626 HTMLElement3_fireEvent,
4627 HTMLElement3_put_onresizestart,
4628 HTMLElement3_get_onresizestart,
4629 HTMLElement3_put_onresizeend,
4630 HTMLElement3_get_onresizeend,
4631 HTMLElement3_put_onmovestart,
4632 HTMLElement3_get_onmovestart,
4633 HTMLElement3_put_onmoveend,
4634 HTMLElement3_get_onmoveend,
4635 HTMLElement3_put_onmousecenter,
4636 HTMLElement3_get_onmousecenter,
4637 HTMLElement3_put_onmouseleave,
4638 HTMLElement3_get_onmouseleave,
4639 HTMLElement3_put_onactivate,
4640 HTMLElement3_get_onactivate,
4641 HTMLElement3_put_ondeactivate,
4642 HTMLElement3_get_ondeactivate,
4643 HTMLElement3_dragDrop,
4644 HTMLElement3_get_glyphMode
4647 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
4649 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
4652 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
4653 REFIID riid, void **ppv)
4655 HTMLElement *This = impl_from_IHTMLElement4(iface);
4656 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4659 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
4661 HTMLElement *This = impl_from_IHTMLElement4(iface);
4662 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4665 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
4667 HTMLElement *This = impl_from_IHTMLElement4(iface);
4668 return IHTMLElement_Release(&This->IHTMLElement_iface);
4671 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
4673 HTMLElement *This = impl_from_IHTMLElement4(iface);
4674 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4677 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
4678 LCID lcid, ITypeInfo **ppTInfo)
4680 HTMLElement *This = impl_from_IHTMLElement4(iface);
4681 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4684 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
4685 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4687 HTMLElement *This = impl_from_IHTMLElement4(iface);
4688 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4689 lcid, rgDispId);
4692 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
4693 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4695 HTMLElement *This = impl_from_IHTMLElement4(iface);
4696 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4697 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4700 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
4702 HTMLElement *This = impl_from_IHTMLElement4(iface);
4704 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4706 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
4709 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
4711 HTMLElement *This = impl_from_IHTMLElement4(iface);
4713 TRACE("(%p)->(%p)\n", This, p);
4715 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
4718 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
4720 HTMLElement *This = impl_from_IHTMLElement4(iface);
4721 FIXME("(%p)\n", This);
4722 return E_NOTIMPL;
4725 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
4727 HTMLElement *This = impl_from_IHTMLElement4(iface);
4728 HTMLAttributeCollection *attrs;
4729 HRESULT hres;
4731 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
4733 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4734 if(FAILED(hres))
4735 return hres;
4737 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
4738 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4739 return hres;
4742 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4743 IHTMLDOMAttribute **ppretAttribute)
4745 HTMLElement *This = impl_from_IHTMLElement4(iface);
4746 HTMLDOMAttribute *attr, *iter, *replace = NULL;
4747 HTMLAttributeCollection *attrs;
4748 DISPID dispid;
4749 HRESULT hres;
4751 TRACE("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4753 attr = unsafe_impl_from_IHTMLDOMAttribute(pattr);
4754 if(!attr)
4755 return E_INVALIDARG;
4757 if(attr->elem) {
4758 WARN("Tried to set already attached attribute.\n");
4759 return E_INVALIDARG;
4762 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface,
4763 attr->name, fdexNameCaseInsensitive|fdexNameEnsure, &dispid);
4764 if(FAILED(hres))
4765 return hres;
4767 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4768 if(FAILED(hres))
4769 return hres;
4771 LIST_FOR_EACH_ENTRY(iter, &attrs->attrs, HTMLDOMAttribute, entry) {
4772 if(iter->dispid == dispid) {
4773 replace = iter;
4774 break;
4778 if(replace) {
4779 hres = get_elem_attr_value_by_dispid(This, dispid, &replace->value);
4780 if(FAILED(hres)) {
4781 WARN("could not get attr value: %08lx\n", hres);
4782 V_VT(&replace->value) = VT_EMPTY;
4784 if(!replace->name) {
4785 replace->name = attr->name;
4786 attr->name = NULL;
4788 list_add_head(&replace->entry, &attr->entry);
4789 list_remove(&replace->entry);
4790 replace->elem = NULL;
4791 }else {
4792 list_add_tail(&attrs->attrs, &attr->entry);
4795 IHTMLDOMAttribute_AddRef(&attr->IHTMLDOMAttribute_iface);
4796 attr->elem = This;
4797 attr->dispid = dispid;
4799 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4801 hres = set_elem_attr_value_by_dispid(This, dispid, &attr->value);
4802 if(FAILED(hres))
4803 WARN("Could not set attribute value: %08lx\n", hres);
4804 VariantClear(&attr->value);
4806 *ppretAttribute = replace ? &replace->IHTMLDOMAttribute_iface : NULL;
4807 return S_OK;
4810 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4811 IHTMLDOMAttribute **ppretAttribute)
4813 HTMLElement *This = impl_from_IHTMLElement4(iface);
4814 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4815 return E_NOTIMPL;
4818 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
4820 HTMLElement *This = impl_from_IHTMLElement4(iface);
4822 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4824 return set_node_event(&This->node, EVENTID_BEFOREACTIVATE, &v);
4827 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
4829 HTMLElement *This = impl_from_IHTMLElement4(iface);
4831 TRACE("(%p)->(%p)\n", This, p);
4833 return get_node_event(&This->node, EVENTID_BEFOREACTIVATE, p);
4836 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
4838 HTMLElement *This = impl_from_IHTMLElement4(iface);
4840 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4842 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
4845 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
4847 HTMLElement *This = impl_from_IHTMLElement4(iface);
4849 TRACE("(%p)->(%p)\n", This, p);
4851 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
4854 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
4856 HTMLElement *This = impl_from_IHTMLElement4(iface);
4858 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4860 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
4863 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
4865 HTMLElement *This = impl_from_IHTMLElement4(iface);
4867 TRACE("(%p)->(%p)\n", This, p);
4869 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
4872 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
4873 HTMLElement4_QueryInterface,
4874 HTMLElement4_AddRef,
4875 HTMLElement4_Release,
4876 HTMLElement4_GetTypeInfoCount,
4877 HTMLElement4_GetTypeInfo,
4878 HTMLElement4_GetIDsOfNames,
4879 HTMLElement4_Invoke,
4880 HTMLElement4_put_onmousewheel,
4881 HTMLElement4_get_onmousewheel,
4882 HTMLElement4_normalize,
4883 HTMLElement4_getAttributeNode,
4884 HTMLElement4_setAttributeNode,
4885 HTMLElement4_removeAttributeNode,
4886 HTMLElement4_put_onbeforeactivate,
4887 HTMLElement4_get_onbeforeactivate,
4888 HTMLElement4_put_onfocusin,
4889 HTMLElement4_get_onfocusin,
4890 HTMLElement4_put_onfocusout,
4891 HTMLElement4_get_onfocusout
4894 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
4896 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
4899 static HRESULT WINAPI HTMLElement6_QueryInterface(IHTMLElement6 *iface,
4900 REFIID riid, void **ppv)
4902 HTMLElement *This = impl_from_IHTMLElement6(iface);
4903 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4906 static ULONG WINAPI HTMLElement6_AddRef(IHTMLElement6 *iface)
4908 HTMLElement *This = impl_from_IHTMLElement6(iface);
4909 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4912 static ULONG WINAPI HTMLElement6_Release(IHTMLElement6 *iface)
4914 HTMLElement *This = impl_from_IHTMLElement6(iface);
4915 return IHTMLElement_Release(&This->IHTMLElement_iface);
4918 static HRESULT WINAPI HTMLElement6_GetTypeInfoCount(IHTMLElement6 *iface, UINT *pctinfo)
4920 HTMLElement *This = impl_from_IHTMLElement6(iface);
4921 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4924 static HRESULT WINAPI HTMLElement6_GetTypeInfo(IHTMLElement6 *iface, UINT iTInfo,
4925 LCID lcid, ITypeInfo **ppTInfo)
4927 HTMLElement *This = impl_from_IHTMLElement6(iface);
4928 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4931 static HRESULT WINAPI HTMLElement6_GetIDsOfNames(IHTMLElement6 *iface, REFIID riid,
4932 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4934 HTMLElement *This = impl_from_IHTMLElement6(iface);
4935 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4936 lcid, rgDispId);
4939 static HRESULT WINAPI HTMLElement6_Invoke(IHTMLElement6 *iface, DISPID dispIdMember, REFIID riid,
4940 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4942 HTMLElement *This = impl_from_IHTMLElement6(iface);
4943 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4944 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4947 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
4949 HTMLElement *This = impl_from_IHTMLElement6(iface);
4950 nsAString ns_str, name_str, value_str;
4951 nsresult nsres;
4952 HRESULT hres;
4954 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
4956 if(!This->dom_element) {
4957 FIXME("No dom_element\n");
4958 return E_NOTIMPL;
4961 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4962 if(FAILED(hres))
4963 return hres;
4965 nsAString_InitDepend(&name_str, strAttributeName);
4966 nsAString_InitDepend(&value_str, NULL);
4967 nsres = nsIDOMElement_GetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
4968 nsAString_Finish(&ns_str);
4969 nsAString_Finish(&name_str);
4971 hres = return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
4972 if(SUCCEEDED(hres) && V_VT(AttributeValue) == VT_NULL) {
4973 V_VT(AttributeValue) = VT_BSTR;
4974 V_BSTR(AttributeValue) = NULL;
4976 return hres;
4979 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4981 HTMLElement *This = impl_from_IHTMLElement6(iface);
4982 nsAString ns_str, name_str, value_str;
4983 const PRUnichar *ns;
4984 nsresult nsres;
4985 HRESULT hres;
4987 TRACE("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
4989 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4990 if(FAILED(hres))
4991 return hres;
4992 nsAString_GetData(&ns_str, &ns);
4993 if((!ns || !ns[0]) && wcschr(strAttributeName, ':')) {
4994 nsAString_Finish(&ns_str);
4995 /* FIXME: Return NamespaceError */
4996 return E_FAIL;
4999 if(!This->dom_element) {
5000 FIXME("No dom_element\n");
5001 nsAString_Finish(&ns_str);
5002 return E_NOTIMPL;
5005 hres = variant_to_nsstr(pvarAttributeValue, FALSE, &value_str);
5006 if(FAILED(hres)) {
5007 nsAString_Finish(&ns_str);
5008 return hres;
5011 nsAString_InitDepend(&name_str, strAttributeName);
5012 nsres = nsIDOMElement_SetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
5013 nsAString_Finish(&ns_str);
5014 nsAString_Finish(&name_str);
5015 nsAString_Finish(&value_str);
5016 if(NS_FAILED(nsres))
5017 WARN("SetAttributeNS failed: %08lx\n", nsres);
5018 return map_nsresult(nsres);
5021 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
5023 HTMLElement *This = impl_from_IHTMLElement6(iface);
5024 nsAString ns_str, name_str;
5025 nsresult nsres;
5026 HRESULT hres;
5028 TRACE("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
5030 if(!This->dom_element) {
5031 FIXME("No dom_element\n");
5032 return E_NOTIMPL;
5035 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
5036 if(FAILED(hres))
5037 return hres;
5039 nsAString_InitDepend(&name_str, strAttributeName);
5040 nsres = nsIDOMElement_RemoveAttributeNS(This->dom_element, &ns_str, &name_str);
5041 nsAString_Finish(&ns_str);
5042 nsAString_Finish(&name_str);
5043 return map_nsresult(nsres);
5046 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
5048 HTMLElement *This = impl_from_IHTMLElement6(iface);
5049 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
5050 return E_NOTIMPL;
5053 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5055 HTMLElement *This = impl_from_IHTMLElement6(iface);
5056 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
5057 return E_NOTIMPL;
5060 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
5062 HTMLElement *This = impl_from_IHTMLElement6(iface);
5063 nsAString ns_str, name_str;
5064 nsresult nsres;
5065 HRESULT hres;
5066 cpp_bool r;
5068 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
5070 if(!This->dom_element) {
5071 FIXME("No dom_element\n");
5072 return E_NOTIMPL;
5075 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
5076 if(FAILED(hres))
5077 return hres;
5079 nsAString_InitDepend(&name_str, name);
5080 nsres = nsIDOMElement_HasAttributeNS(This->dom_element, &ns_str, &name_str, &r);
5081 nsAString_Finish(&ns_str);
5082 nsAString_Finish(&name_str);
5083 *pfHasAttribute = variant_bool(NS_SUCCEEDED(nsres) && r);
5084 return S_OK;
5087 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
5089 HTMLElement *This = impl_from_IHTMLElement6(iface);
5091 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), AttributeValue);
5093 return IHTMLElement_getAttribute(&This->IHTMLElement_iface, strAttributeName, 0, AttributeValue);
5096 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
5098 HTMLElement *This = impl_from_IHTMLElement6(iface);
5100 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
5102 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, strAttributeName, *pvarAttributeValue, 0);
5105 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
5107 HTMLElement *This = impl_from_IHTMLElement6(iface);
5108 VARIANT_BOOL success;
5110 WARN("(%p)->(%s) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName));
5112 return IHTMLElement_removeAttribute(&This->IHTMLElement_iface, strAttributeName, 0, &success);
5115 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
5117 HTMLElement *This = impl_from_IHTMLElement6(iface);
5118 IHTMLDOMAttribute *attr;
5119 HRESULT hres;
5121 WARN("(%p)->(%s %p) forwarding to IHTMLElement4\n", This, debugstr_w(strAttributeName), ppretAttribute);
5123 hres = IHTMLElement4_getAttributeNode(&This->IHTMLElement4_iface, strAttributeName, &attr);
5124 if(FAILED(hres))
5125 return hres;
5127 if(attr) {
5128 hres = IHTMLDOMAttribute_QueryInterface(attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
5129 IHTMLDOMAttribute_Release(attr);
5130 }else {
5131 *ppretAttribute = NULL;
5133 return hres;
5136 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5138 HTMLElement *This = impl_from_IHTMLElement6(iface);
5139 IHTMLDOMAttribute *attr, *ret_attr;
5140 HRESULT hres;
5142 WARN("(%p)->(%p %p) forwarding to IHTMLElement4\n", This, pattr, ppretAttribute);
5144 hres = IHTMLDOMAttribute2_QueryInterface(pattr, &IID_IHTMLDOMAttribute, (void**)&attr);
5145 if(FAILED(hres))
5146 return hres;
5148 hres = IHTMLElement4_setAttributeNode(&This->IHTMLElement4_iface, attr, &ret_attr);
5149 if(FAILED(hres))
5150 return hres;
5152 if(ret_attr) {
5153 hres = IHTMLDOMAttribute_QueryInterface(ret_attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
5154 IHTMLDOMAttribute_Release(ret_attr);
5155 }else {
5156 *ppretAttribute = NULL;
5158 return hres;
5161 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5163 HTMLElement *This = impl_from_IHTMLElement6(iface);
5164 FIXME("(%p)->()\n", This);
5165 return E_NOTIMPL;
5168 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *p)
5170 HTMLElement *This = impl_from_IHTMLElement6(iface);
5172 TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), p);
5174 *p = element_has_attribute(This, name);
5175 return S_OK;
5178 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
5180 HTMLElement *This = impl_from_IHTMLElement6(iface);
5181 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
5182 return E_NOTIMPL;
5185 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
5187 HTMLElement *This = impl_from_IHTMLElement6(iface);
5189 TRACE("(%p)->(%p)\n", This, p);
5191 return IHTMLElement_get_tagName(&This->IHTMLElement_iface, p);
5194 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
5196 HTMLElement *This = impl_from_IHTMLElement6(iface);
5198 TRACE("(%p)->(%p)\n", This, p);
5200 return IHTMLDOMNode_get_nodeName(&This->node.IHTMLDOMNode_iface, p);
5203 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
5205 HTMLElement *This = impl_from_IHTMLElement6(iface);
5206 nsIDOMHTMLCollection *nscol = NULL;
5207 nsAString nsstr;
5208 nsresult nsres;
5210 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
5212 if(This->dom_element) {
5213 nsAString_InitDepend(&nsstr, v);
5214 nsres = nsIDOMElement_GetElementsByClassName(This->dom_element, &nsstr, &nscol);
5215 nsAString_Finish(&nsstr);
5216 if(NS_FAILED(nsres)) {
5217 ERR("GetElementsByClassName failed: %08lx\n", nsres);
5218 return E_FAIL;
5222 *pel = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
5223 nsIDOMHTMLCollection_Release(nscol);
5224 return S_OK;
5227 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
5229 HTMLElement *This = impl_from_IHTMLElement6(iface);
5230 nsAString nsstr;
5231 cpp_bool b;
5232 nsresult nsres;
5234 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
5236 if(!This->dom_element) {
5237 FIXME("No dom element\n");
5238 return E_UNEXPECTED;
5241 nsAString_InitDepend(&nsstr, v);
5242 nsres = nsIDOMElement_MozMatchesSelector(This->dom_element, &nsstr, &b);
5243 nsAString_Finish(&nsstr);
5244 if(NS_FAILED(nsres)) {
5245 WARN("MozMatchesSelector failed: %08lx\n", nsres);
5246 return map_nsresult(nsres);
5249 *pfMatches = b;
5250 return S_OK;
5253 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
5255 HTMLElement *This = impl_from_IHTMLElement6(iface);
5257 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5259 return set_node_event(&This->node, EVENTID_ABORT, &v);
5262 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
5264 HTMLElement *This = impl_from_IHTMLElement6(iface);
5266 TRACE("(%p)->(%p)\n", This, p);
5268 return get_node_event(&This->node, EVENTID_ABORT, p);
5271 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
5273 HTMLElement *This = impl_from_IHTMLElement6(iface);
5274 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5275 return E_NOTIMPL;
5278 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
5280 HTMLElement *This = impl_from_IHTMLElement6(iface);
5281 FIXME("(%p)->(%p)\n", This, p);
5282 return E_NOTIMPL;
5285 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
5287 HTMLElement *This = impl_from_IHTMLElement6(iface);
5288 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5289 return E_NOTIMPL;
5292 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
5294 HTMLElement *This = impl_from_IHTMLElement6(iface);
5295 FIXME("(%p)->(%p)\n", This, p);
5296 return E_NOTIMPL;
5299 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
5301 HTMLElement *This = impl_from_IHTMLElement6(iface);
5303 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5305 return set_node_event(&This->node, EVENTID_CHANGE, &v);
5308 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
5310 HTMLElement *This = impl_from_IHTMLElement6(iface);
5312 TRACE("(%p)->(%p)\n", This, p);
5314 return get_node_event(&This->node, EVENTID_CHANGE, p);
5317 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
5319 HTMLElement *This = impl_from_IHTMLElement6(iface);
5320 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5321 return E_NOTIMPL;
5324 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
5326 HTMLElement *This = impl_from_IHTMLElement6(iface);
5327 FIXME("(%p)->(%p)\n", This, p);
5328 return E_NOTIMPL;
5331 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
5333 HTMLElement *This = impl_from_IHTMLElement6(iface);
5334 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5335 return E_NOTIMPL;
5338 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
5340 HTMLElement *This = impl_from_IHTMLElement6(iface);
5341 FIXME("(%p)->(%p)\n", This, p);
5342 return E_NOTIMPL;
5345 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
5347 HTMLElement *This = impl_from_IHTMLElement6(iface);
5348 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5349 return E_NOTIMPL;
5352 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
5354 HTMLElement *This = impl_from_IHTMLElement6(iface);
5355 FIXME("(%p)->(%p)\n", This, p);
5356 return E_NOTIMPL;
5359 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
5361 HTMLElement *This = impl_from_IHTMLElement6(iface);
5363 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5365 return set_node_event(&This->node, EVENTID_ERROR, &v);
5368 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
5370 HTMLElement *This = impl_from_IHTMLElement6(iface);
5372 TRACE("(%p)->(%p)\n", This, p);
5374 return get_node_event(&This->node, EVENTID_ERROR, p);
5377 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
5379 HTMLElement *This = impl_from_IHTMLElement6(iface);
5381 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5383 return set_node_event(&This->node, EVENTID_INPUT, &v);
5386 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
5388 HTMLElement *This = impl_from_IHTMLElement6(iface);
5390 TRACE("(%p)->(%p)\n", This, p);
5392 return get_node_event(&This->node, EVENTID_INPUT, p);
5395 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
5397 HTMLElement *This = impl_from_IHTMLElement6(iface);
5399 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5401 return set_node_event(&This->node, EVENTID_LOAD, &v);
5404 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
5406 HTMLElement *This = impl_from_IHTMLElement6(iface);
5408 TRACE("(%p)->(%p)\n", This, p);
5410 return get_node_event(&This->node, EVENTID_LOAD, p);
5413 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
5415 HTMLElement *This = impl_from_IHTMLElement6(iface);
5416 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5417 return E_NOTIMPL;
5420 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
5422 HTMLElement *This = impl_from_IHTMLElement6(iface);
5423 FIXME("(%p)->(%p)\n", This, p);
5424 return E_NOTIMPL;
5427 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
5429 HTMLElement *This = impl_from_IHTMLElement6(iface);
5430 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5431 return E_NOTIMPL;
5434 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
5436 HTMLElement *This = impl_from_IHTMLElement6(iface);
5437 FIXME("(%p)->(%p)\n", This, p);
5438 return E_NOTIMPL;
5441 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
5443 HTMLElement *This = impl_from_IHTMLElement6(iface);
5444 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5445 return E_NOTIMPL;
5448 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
5450 HTMLElement *This = impl_from_IHTMLElement6(iface);
5451 FIXME("(%p)->(%p)\n", This, p);
5452 return E_NOTIMPL;
5455 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
5457 HTMLElement *This = impl_from_IHTMLElement6(iface);
5458 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5459 return E_NOTIMPL;
5462 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
5464 HTMLElement *This = impl_from_IHTMLElement6(iface);
5465 FIXME("(%p)->(%p)\n", This, p);
5466 return E_NOTIMPL;
5469 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
5471 HTMLElement *This = impl_from_IHTMLElement6(iface);
5472 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5473 return E_NOTIMPL;
5476 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
5478 HTMLElement *This = impl_from_IHTMLElement6(iface);
5479 FIXME("(%p)->(%p)\n", This, p);
5480 return E_NOTIMPL;
5483 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
5485 HTMLElement *This = impl_from_IHTMLElement6(iface);
5486 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5487 return E_NOTIMPL;
5490 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
5492 HTMLElement *This = impl_from_IHTMLElement6(iface);
5493 FIXME("(%p)->(%p)\n", This, p);
5494 return E_NOTIMPL;
5497 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
5499 HTMLElement *This = impl_from_IHTMLElement6(iface);
5500 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5501 return E_NOTIMPL;
5504 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
5506 HTMLElement *This = impl_from_IHTMLElement6(iface);
5507 FIXME("(%p)->(%p)\n", This, p);
5508 return E_NOTIMPL;
5511 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
5513 HTMLElement *This = impl_from_IHTMLElement6(iface);
5514 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5515 return E_NOTIMPL;
5518 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
5520 HTMLElement *This = impl_from_IHTMLElement6(iface);
5521 FIXME("(%p)->(%p)\n", This, p);
5522 return E_NOTIMPL;
5525 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
5527 HTMLElement *This = impl_from_IHTMLElement6(iface);
5528 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5529 return E_NOTIMPL;
5532 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
5534 HTMLElement *This = impl_from_IHTMLElement6(iface);
5535 FIXME("(%p)->(%p)\n", This, p);
5536 return E_NOTIMPL;
5539 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
5541 HTMLElement *This = impl_from_IHTMLElement6(iface);
5542 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5543 return E_NOTIMPL;
5546 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
5548 HTMLElement *This = impl_from_IHTMLElement6(iface);
5549 FIXME("(%p)->(%p)\n", This, p);
5550 return E_NOTIMPL;
5553 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
5555 HTMLElement *This = impl_from_IHTMLElement6(iface);
5556 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5557 return E_NOTIMPL;
5560 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
5562 HTMLElement *This = impl_from_IHTMLElement6(iface);
5563 FIXME("(%p)->(%p)\n", This, p);
5564 return E_NOTIMPL;
5567 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
5569 HTMLElement *This = impl_from_IHTMLElement6(iface);
5570 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5571 return E_NOTIMPL;
5574 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
5576 HTMLElement *This = impl_from_IHTMLElement6(iface);
5577 FIXME("(%p)->(%p)\n", This, p);
5578 return E_NOTIMPL;
5581 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
5583 HTMLElement *This = impl_from_IHTMLElement6(iface);
5584 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5585 return E_NOTIMPL;
5588 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
5590 HTMLElement *This = impl_from_IHTMLElement6(iface);
5591 FIXME("(%p)->(%p)\n", This, p);
5592 return E_NOTIMPL;
5595 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
5597 HTMLElement *This = impl_from_IHTMLElement6(iface);
5599 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5601 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
5604 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
5606 HTMLElement *This = impl_from_IHTMLElement6(iface);
5608 TRACE("(%p)->(%p)\n", This, p);
5610 return get_node_event(&This->node, EVENTID_SUBMIT, p);
5613 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
5615 HTMLElement *This = impl_from_IHTMLElement6(iface);
5616 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5617 return E_NOTIMPL;
5620 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
5622 HTMLElement *This = impl_from_IHTMLElement6(iface);
5623 FIXME("(%p)->(%p)\n", This, p);
5624 return E_NOTIMPL;
5627 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
5629 HTMLElement *This = impl_from_IHTMLElement6(iface);
5630 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5631 return E_NOTIMPL;
5634 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
5636 HTMLElement *This = impl_from_IHTMLElement6(iface);
5637 FIXME("(%p)->(%p)\n", This, p);
5638 return E_NOTIMPL;
5641 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
5643 HTMLElement *This = impl_from_IHTMLElement6(iface);
5644 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5645 return E_NOTIMPL;
5648 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
5650 HTMLElement *This = impl_from_IHTMLElement6(iface);
5651 FIXME("(%p)->(%p)\n", This, p);
5652 return E_NOTIMPL;
5655 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
5657 HTMLElement *This = impl_from_IHTMLElement6(iface);
5658 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5659 return E_NOTIMPL;
5662 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
5664 HTMLElement *This = impl_from_IHTMLElement6(iface);
5665 FIXME("(%p)->(%p)\n", This, p);
5666 return E_NOTIMPL;
5669 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
5671 HTMLElement *This = impl_from_IHTMLElement6(iface);
5672 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
5673 return E_NOTIMPL;
5676 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
5677 HTMLElement6_QueryInterface,
5678 HTMLElement6_AddRef,
5679 HTMLElement6_Release,
5680 HTMLElement6_GetTypeInfoCount,
5681 HTMLElement6_GetTypeInfo,
5682 HTMLElement6_GetIDsOfNames,
5683 HTMLElement6_Invoke,
5684 HTMLElement6_getAttributeNS,
5685 HTMLElement6_setAttributeNS,
5686 HTMLElement6_removeAttributeNS,
5687 HTMLElement6_getAttributeNodeNS,
5688 HTMLElement6_setAttributeNodeNS,
5689 HTMLElement6_hasAttributeNS,
5690 HTMLElement6_getAttribute,
5691 HTMLElement6_setAttribute,
5692 HTMLElement6_removeAttribute,
5693 HTMLElement6_getAttributeNode,
5694 HTMLElement6_setAttributeNode,
5695 HTMLElement6_removeAttributeNode,
5696 HTMLElement6_hasAttribute,
5697 HTMLElement6_getElementsByTagNameNS,
5698 HTMLElement6_get_tagName,
5699 HTMLElement6_get_nodeName,
5700 HTMLElement6_getElementsByClassName,
5701 HTMLElement6_msMatchesSelector,
5702 HTMLElement6_put_onabort,
5703 HTMLElement6_get_onabort,
5704 HTMLElement6_put_oncanplay,
5705 HTMLElement6_get_oncanplay,
5706 HTMLElement6_put_oncanplaythrough,
5707 HTMLElement6_get_oncanplaythrough,
5708 HTMLElement6_put_onchange,
5709 HTMLElement6_get_onchange,
5710 HTMLElement6_put_ondurationchange,
5711 HTMLElement6_get_ondurationchange,
5712 HTMLElement6_put_onemptied,
5713 HTMLElement6_get_onemptied,
5714 HTMLElement6_put_onended,
5715 HTMLElement6_get_onended,
5716 HTMLElement6_put_onerror,
5717 HTMLElement6_get_onerror,
5718 HTMLElement6_put_oninput,
5719 HTMLElement6_get_oninput,
5720 HTMLElement6_put_onload,
5721 HTMLElement6_get_onload,
5722 HTMLElement6_put_onloadeddata,
5723 HTMLElement6_get_onloadeddata,
5724 HTMLElement6_put_onloadedmetadata,
5725 HTMLElement6_get_onloadedmetadata,
5726 HTMLElement6_put_onloadstart,
5727 HTMLElement6_get_onloadstart,
5728 HTMLElement6_put_onpause,
5729 HTMLElement6_get_onpause,
5730 HTMLElement6_put_onplay,
5731 HTMLElement6_get_onplay,
5732 HTMLElement6_put_onplaying,
5733 HTMLElement6_get_onplaying,
5734 HTMLElement6_put_onprogress,
5735 HTMLElement6_get_onprogress,
5736 HTMLElement6_put_onratechange,
5737 HTMLElement6_get_onratechange,
5738 HTMLElement6_put_onreset,
5739 HTMLElement6_get_onreset,
5740 HTMLElement6_put_onseeked,
5741 HTMLElement6_get_onseeked,
5742 HTMLElement6_put_onseeking,
5743 HTMLElement6_get_onseeking,
5744 HTMLElement6_put_onselect,
5745 HTMLElement6_get_onselect,
5746 HTMLElement6_put_onstalled,
5747 HTMLElement6_get_onstalled,
5748 HTMLElement6_put_onsubmit,
5749 HTMLElement6_get_onsubmit,
5750 HTMLElement6_put_onsuspend,
5751 HTMLElement6_get_onsuspend,
5752 HTMLElement6_put_ontimeupdate,
5753 HTMLElement6_get_ontimeupdate,
5754 HTMLElement6_put_onvolumechange,
5755 HTMLElement6_get_onvolumechange,
5756 HTMLElement6_put_onwaiting,
5757 HTMLElement6_get_onwaiting,
5758 HTMLElement6_hasAttributes
5761 static inline HTMLElement *impl_from_IHTMLElement7(IHTMLElement7 *iface)
5763 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement7_iface);
5766 static HRESULT WINAPI HTMLElement7_QueryInterface(IHTMLElement7 *iface,
5767 REFIID riid, void **ppv)
5769 HTMLElement *This = impl_from_IHTMLElement7(iface);
5770 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
5773 static ULONG WINAPI HTMLElement7_AddRef(IHTMLElement7 *iface)
5775 HTMLElement *This = impl_from_IHTMLElement7(iface);
5776 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5779 static ULONG WINAPI HTMLElement7_Release(IHTMLElement7 *iface)
5781 HTMLElement *This = impl_from_IHTMLElement7(iface);
5782 return IHTMLElement_Release(&This->IHTMLElement_iface);
5785 static HRESULT WINAPI HTMLElement7_GetTypeInfoCount(IHTMLElement7 *iface, UINT *pctinfo)
5787 HTMLElement *This = impl_from_IHTMLElement7(iface);
5788 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5791 static HRESULT WINAPI HTMLElement7_GetTypeInfo(IHTMLElement7 *iface, UINT iTInfo,
5792 LCID lcid, ITypeInfo **ppTInfo)
5794 HTMLElement *This = impl_from_IHTMLElement7(iface);
5795 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5798 static HRESULT WINAPI HTMLElement7_GetIDsOfNames(IHTMLElement7 *iface, REFIID riid,
5799 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5801 HTMLElement *This = impl_from_IHTMLElement7(iface);
5802 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5803 lcid, rgDispId);
5806 static HRESULT WINAPI HTMLElement7_Invoke(IHTMLElement7 *iface, DISPID dispIdMember, REFIID riid,
5807 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5809 HTMLElement *This = impl_from_IHTMLElement7(iface);
5810 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5811 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5814 static HRESULT WINAPI HTMLElement7_put_onmspointerdown(IHTMLElement7 *iface, VARIANT v)
5816 HTMLElement *This = impl_from_IHTMLElement7(iface);
5817 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5818 return E_NOTIMPL;
5821 static HRESULT WINAPI HTMLElement7_get_onmspointerdown(IHTMLElement7 *iface, VARIANT *p)
5823 HTMLElement *This = impl_from_IHTMLElement7(iface);
5824 FIXME("(%p)->(%p)\n", This, p);
5825 return E_NOTIMPL;
5828 static HRESULT WINAPI HTMLElement7_put_onmspointermove(IHTMLElement7 *iface, VARIANT v)
5830 HTMLElement *This = impl_from_IHTMLElement7(iface);
5831 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5832 return E_NOTIMPL;
5835 static HRESULT WINAPI HTMLElement7_get_onmspointermove(IHTMLElement7 *iface, VARIANT *p)
5837 HTMLElement *This = impl_from_IHTMLElement7(iface);
5838 FIXME("(%p)->(%p)\n", This, p);
5839 return E_NOTIMPL;
5842 static HRESULT WINAPI HTMLElement7_put_onmspointerup(IHTMLElement7 *iface, VARIANT v)
5844 HTMLElement *This = impl_from_IHTMLElement7(iface);
5845 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5846 return E_NOTIMPL;
5849 static HRESULT WINAPI HTMLElement7_get_onmspointerup(IHTMLElement7 *iface, VARIANT *p)
5851 HTMLElement *This = impl_from_IHTMLElement7(iface);
5852 FIXME("(%p)->(%p)\n", This, p);
5853 return E_NOTIMPL;
5856 static HRESULT WINAPI HTMLElement7_put_onmspointerover(IHTMLElement7 *iface, VARIANT v)
5858 HTMLElement *This = impl_from_IHTMLElement7(iface);
5859 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5860 return E_NOTIMPL;
5863 static HRESULT WINAPI HTMLElement7_get_onmspointerover(IHTMLElement7 *iface, VARIANT *p)
5865 HTMLElement *This = impl_from_IHTMLElement7(iface);
5866 FIXME("(%p)->(%p)\n", This, p);
5867 return E_NOTIMPL;
5870 static HRESULT WINAPI HTMLElement7_put_onmspointerout(IHTMLElement7 *iface, VARIANT v)
5872 HTMLElement *This = impl_from_IHTMLElement7(iface);
5873 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5874 return E_NOTIMPL;
5877 static HRESULT WINAPI HTMLElement7_get_onmspointerout(IHTMLElement7 *iface, VARIANT *p)
5879 HTMLElement *This = impl_from_IHTMLElement7(iface);
5880 FIXME("(%p)->(%p)\n", This, p);
5881 return E_NOTIMPL;
5884 static HRESULT WINAPI HTMLElement7_put_onmspointercancel(IHTMLElement7 *iface, VARIANT v)
5886 HTMLElement *This = impl_from_IHTMLElement7(iface);
5887 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5888 return E_NOTIMPL;
5891 static HRESULT WINAPI HTMLElement7_get_onmspointercancel(IHTMLElement7 *iface, VARIANT *p)
5893 HTMLElement *This = impl_from_IHTMLElement7(iface);
5894 FIXME("(%p)->(%p)\n", This, p);
5895 return E_NOTIMPL;
5898 static HRESULT WINAPI HTMLElement7_put_onmspointerhover(IHTMLElement7 *iface, VARIANT v)
5900 HTMLElement *This = impl_from_IHTMLElement7(iface);
5901 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5902 return E_NOTIMPL;
5905 static HRESULT WINAPI HTMLElement7_get_onmspointerhover(IHTMLElement7 *iface, VARIANT *p)
5907 HTMLElement *This = impl_from_IHTMLElement7(iface);
5908 FIXME("(%p)->(%p)\n", This, p);
5909 return E_NOTIMPL;
5912 static HRESULT WINAPI HTMLElement7_put_onmslostpointercapture(IHTMLElement7 *iface, VARIANT v)
5914 HTMLElement *This = impl_from_IHTMLElement7(iface);
5915 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5916 return E_NOTIMPL;
5919 static HRESULT WINAPI HTMLElement7_get_onmslostpointercapture(IHTMLElement7 *iface, VARIANT *p)
5921 HTMLElement *This = impl_from_IHTMLElement7(iface);
5922 FIXME("(%p)->(%p)\n", This, p);
5923 return E_NOTIMPL;
5926 static HRESULT WINAPI HTMLElement7_put_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT v)
5928 HTMLElement *This = impl_from_IHTMLElement7(iface);
5929 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5930 return E_NOTIMPL;
5933 static HRESULT WINAPI HTMLElement7_get_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT *p)
5935 HTMLElement *This = impl_from_IHTMLElement7(iface);
5936 FIXME("(%p)->(%p)\n", This, p);
5937 return E_NOTIMPL;
5940 static HRESULT WINAPI HTMLElement7_put_onmsgesturestart(IHTMLElement7 *iface, VARIANT v)
5942 HTMLElement *This = impl_from_IHTMLElement7(iface);
5943 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5944 return E_NOTIMPL;
5947 static HRESULT WINAPI HTMLElement7_get_onmsgesturestart(IHTMLElement7 *iface, VARIANT *p)
5949 HTMLElement *This = impl_from_IHTMLElement7(iface);
5950 FIXME("(%p)->(%p)\n", This, p);
5951 return E_NOTIMPL;
5954 static HRESULT WINAPI HTMLElement7_put_onmsgesturechange(IHTMLElement7 *iface, VARIANT v)
5956 HTMLElement *This = impl_from_IHTMLElement7(iface);
5957 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5958 return E_NOTIMPL;
5961 static HRESULT WINAPI HTMLElement7_get_onmsgesturechange(IHTMLElement7 *iface, VARIANT *p)
5963 HTMLElement *This = impl_from_IHTMLElement7(iface);
5964 FIXME("(%p)->(%p)\n", This, p);
5965 return E_NOTIMPL;
5968 static HRESULT WINAPI HTMLElement7_put_onmsgestureend(IHTMLElement7 *iface, VARIANT v)
5970 HTMLElement *This = impl_from_IHTMLElement7(iface);
5971 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5972 return E_NOTIMPL;
5975 static HRESULT WINAPI HTMLElement7_get_onmsgestureend(IHTMLElement7 *iface, VARIANT *p)
5977 HTMLElement *This = impl_from_IHTMLElement7(iface);
5978 FIXME("(%p)->(%p)\n", This, p);
5979 return E_NOTIMPL;
5982 static HRESULT WINAPI HTMLElement7_put_onmsgesturehold(IHTMLElement7 *iface, VARIANT v)
5984 HTMLElement *This = impl_from_IHTMLElement7(iface);
5985 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5986 return E_NOTIMPL;
5989 static HRESULT WINAPI HTMLElement7_get_onmsgesturehold(IHTMLElement7 *iface, VARIANT *p)
5991 HTMLElement *This = impl_from_IHTMLElement7(iface);
5992 FIXME("(%p)->(%p)\n", This, p);
5993 return E_NOTIMPL;
5996 static HRESULT WINAPI HTMLElement7_put_onmsgesturetap(IHTMLElement7 *iface, VARIANT v)
5998 HTMLElement *This = impl_from_IHTMLElement7(iface);
5999 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6000 return E_NOTIMPL;
6003 static HRESULT WINAPI HTMLElement7_get_onmsgesturetap(IHTMLElement7 *iface, VARIANT *p)
6005 HTMLElement *This = impl_from_IHTMLElement7(iface);
6006 FIXME("(%p)->(%p)\n", This, p);
6007 return E_NOTIMPL;
6010 static HRESULT WINAPI HTMLElement7_put_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT v)
6012 HTMLElement *This = impl_from_IHTMLElement7(iface);
6013 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6014 return E_NOTIMPL;
6017 static HRESULT WINAPI HTMLElement7_get_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT *p)
6019 HTMLElement *This = impl_from_IHTMLElement7(iface);
6020 FIXME("(%p)->(%p)\n", This, p);
6021 return E_NOTIMPL;
6024 static HRESULT WINAPI HTMLElement7_put_onmsinertiastart(IHTMLElement7 *iface, VARIANT v)
6026 HTMLElement *This = impl_from_IHTMLElement7(iface);
6027 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6028 return E_NOTIMPL;
6031 static HRESULT WINAPI HTMLElement7_get_onmsinertiastart(IHTMLElement7 *iface, VARIANT *p)
6033 HTMLElement *This = impl_from_IHTMLElement7(iface);
6034 FIXME("(%p)->(%p)\n", This, p);
6035 return E_NOTIMPL;
6038 static HRESULT WINAPI HTMLElement7_msSetPointerCapture(IHTMLElement7 *iface, LONG pointer_id)
6040 HTMLElement *This = impl_from_IHTMLElement7(iface);
6041 FIXME("(%p)->(%ld)\n", This, pointer_id);
6042 return E_NOTIMPL;
6045 static HRESULT WINAPI HTMLElement7_msReleasePointerCapture(IHTMLElement7 *iface, LONG pointer_id)
6047 HTMLElement *This = impl_from_IHTMLElement7(iface);
6048 FIXME("(%p)->(%ld)\n", This, pointer_id);
6049 return E_NOTIMPL;
6052 static HRESULT WINAPI HTMLElement7_put_onmstransitionstart(IHTMLElement7 *iface, VARIANT v)
6054 HTMLElement *This = impl_from_IHTMLElement7(iface);
6055 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6056 return E_NOTIMPL;
6059 static HRESULT WINAPI HTMLElement7_get_onmstransitionstart(IHTMLElement7 *iface, VARIANT *p)
6061 HTMLElement *This = impl_from_IHTMLElement7(iface);
6062 FIXME("(%p)->(%p)\n", This, p);
6063 return E_NOTIMPL;
6066 static HRESULT WINAPI HTMLElement7_put_onmstransitionend(IHTMLElement7 *iface, VARIANT v)
6068 HTMLElement *This = impl_from_IHTMLElement7(iface);
6069 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6070 return E_NOTIMPL;
6073 static HRESULT WINAPI HTMLElement7_get_onmstransitionend(IHTMLElement7 *iface, VARIANT *p)
6075 HTMLElement *This = impl_from_IHTMLElement7(iface);
6076 FIXME("(%p)->(%p)\n", This, p);
6077 return E_NOTIMPL;
6080 static HRESULT WINAPI HTMLElement7_put_onmsanimationstart(IHTMLElement7 *iface, VARIANT v)
6082 HTMLElement *This = impl_from_IHTMLElement7(iface);
6083 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6084 return E_NOTIMPL;
6087 static HRESULT WINAPI HTMLElement7_get_onmsanimationstart(IHTMLElement7 *iface, VARIANT *p)
6089 HTMLElement *This = impl_from_IHTMLElement7(iface);
6090 FIXME("(%p)->(%p)\n", This, p);
6091 return E_NOTIMPL;
6094 static HRESULT WINAPI HTMLElement7_put_onmsanimationend(IHTMLElement7 *iface, VARIANT v)
6096 HTMLElement *This = impl_from_IHTMLElement7(iface);
6097 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6098 return E_NOTIMPL;
6101 static HRESULT WINAPI HTMLElement7_get_onmsanimationend(IHTMLElement7 *iface, VARIANT *p)
6103 HTMLElement *This = impl_from_IHTMLElement7(iface);
6104 FIXME("(%p)->(%p)\n", This, p);
6105 return E_NOTIMPL;
6108 static HRESULT WINAPI HTMLElement7_put_onmsanimationiteration(IHTMLElement7 *iface, VARIANT v)
6110 HTMLElement *This = impl_from_IHTMLElement7(iface);
6111 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6112 return E_NOTIMPL;
6115 static HRESULT WINAPI HTMLElement7_get_onmsanimationiteration(IHTMLElement7 *iface, VARIANT *p)
6117 HTMLElement *This = impl_from_IHTMLElement7(iface);
6118 FIXME("(%p)->(%p)\n", This, p);
6119 return E_NOTIMPL;
6122 static HRESULT WINAPI HTMLElement7_put_oninvalid(IHTMLElement7 *iface, VARIANT v)
6124 HTMLElement *This = impl_from_IHTMLElement7(iface);
6125 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6126 return E_NOTIMPL;
6129 static HRESULT WINAPI HTMLElement7_get_oninvalid(IHTMLElement7 *iface, VARIANT *p)
6131 HTMLElement *This = impl_from_IHTMLElement7(iface);
6132 FIXME("(%p)->(%p)\n", This, p);
6133 return E_NOTIMPL;
6136 static HRESULT WINAPI HTMLElement7_put_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR v)
6138 HTMLElement *This = impl_from_IHTMLElement7(iface);
6139 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
6140 return E_NOTIMPL;
6143 static HRESULT WINAPI HTMLElement7_get_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR *p)
6145 HTMLElement *This = impl_from_IHTMLElement7(iface);
6146 FIXME("(%p)->(%p)\n", This, p);
6147 return E_NOTIMPL;
6150 static HRESULT WINAPI HTMLElement7_put_spellcheck(IHTMLElement7 *iface, VARIANT v)
6152 HTMLElement *This = impl_from_IHTMLElement7(iface);
6154 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
6156 if(!This->html_element) {
6157 FIXME("non-HTML element\n");
6158 return E_NOTIMPL;
6161 if(V_VT(&v) != VT_BOOL) {
6162 FIXME("unsupported argument %s\n", debugstr_variant(&v));
6163 return E_NOTIMPL;
6166 return map_nsresult(nsIDOMHTMLElement_SetSpellcheck(This->html_element, !!V_BOOL(&v)));
6169 static HRESULT WINAPI HTMLElement7_get_spellcheck(IHTMLElement7 *iface, VARIANT *p)
6171 HTMLElement *This = impl_from_IHTMLElement7(iface);
6172 cpp_bool spellcheck;
6173 nsresult nsres;
6175 TRACE("(%p)->(%p)\n", This, p);
6177 if(!This->html_element) {
6178 FIXME("non-HTML element\n");
6179 return E_NOTIMPL;
6182 nsres = nsIDOMHTMLElement_GetSpellcheck(This->html_element, &spellcheck);
6183 if(NS_FAILED(nsres))
6184 return map_nsresult(nsres);
6186 V_VT(p) = VT_BOOL;
6187 V_BOOL(p) = spellcheck ? VARIANT_TRUE : VARIANT_FALSE;
6188 return S_OK;
6191 static HRESULT WINAPI HTMLElement7_put_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT v)
6193 HTMLElement *This = impl_from_IHTMLElement7(iface);
6194 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6195 return E_NOTIMPL;
6198 static HRESULT WINAPI HTMLElement7_get_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT *p)
6200 HTMLElement *This = impl_from_IHTMLElement7(iface);
6201 FIXME("(%p)->(%p)\n", This, p);
6202 return E_NOTIMPL;
6205 static HRESULT WINAPI HTMLElement7_put_oncuechange(IHTMLElement7 *iface, VARIANT v)
6207 HTMLElement *This = impl_from_IHTMLElement7(iface);
6208 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6209 return E_NOTIMPL;
6212 static HRESULT WINAPI HTMLElement7_get_oncuechange(IHTMLElement7 *iface, VARIANT *p)
6214 HTMLElement *This = impl_from_IHTMLElement7(iface);
6215 FIXME("(%p)->(%p)\n", This, p);
6216 return E_NOTIMPL;
6219 static const IHTMLElement7Vtbl HTMLElement7Vtbl = {
6220 HTMLElement7_QueryInterface,
6221 HTMLElement7_AddRef,
6222 HTMLElement7_Release,
6223 HTMLElement7_GetTypeInfoCount,
6224 HTMLElement7_GetTypeInfo,
6225 HTMLElement7_GetIDsOfNames,
6226 HTMLElement7_Invoke,
6227 HTMLElement7_put_onmspointerdown,
6228 HTMLElement7_get_onmspointerdown,
6229 HTMLElement7_put_onmspointermove,
6230 HTMLElement7_get_onmspointermove,
6231 HTMLElement7_put_onmspointerup,
6232 HTMLElement7_get_onmspointerup,
6233 HTMLElement7_put_onmspointerover,
6234 HTMLElement7_get_onmspointerover,
6235 HTMLElement7_put_onmspointerout,
6236 HTMLElement7_get_onmspointerout,
6237 HTMLElement7_put_onmspointercancel,
6238 HTMLElement7_get_onmspointercancel,
6239 HTMLElement7_put_onmspointerhover,
6240 HTMLElement7_get_onmspointerhover,
6241 HTMLElement7_put_onmslostpointercapture,
6242 HTMLElement7_get_onmslostpointercapture,
6243 HTMLElement7_put_onmsgotpointercapture,
6244 HTMLElement7_get_onmsgotpointercapture,
6245 HTMLElement7_put_onmsgesturestart,
6246 HTMLElement7_get_onmsgesturestart,
6247 HTMLElement7_put_onmsgesturechange,
6248 HTMLElement7_get_onmsgesturechange,
6249 HTMLElement7_put_onmsgestureend,
6250 HTMLElement7_get_onmsgestureend,
6251 HTMLElement7_put_onmsgesturehold,
6252 HTMLElement7_get_onmsgesturehold,
6253 HTMLElement7_put_onmsgesturetap,
6254 HTMLElement7_get_onmsgesturetap,
6255 HTMLElement7_put_onmsgesturedoubletap,
6256 HTMLElement7_get_onmsgesturedoubletap,
6257 HTMLElement7_put_onmsinertiastart,
6258 HTMLElement7_get_onmsinertiastart,
6259 HTMLElement7_msSetPointerCapture,
6260 HTMLElement7_msReleasePointerCapture,
6261 HTMLElement7_put_onmstransitionstart,
6262 HTMLElement7_get_onmstransitionstart,
6263 HTMLElement7_put_onmstransitionend,
6264 HTMLElement7_get_onmstransitionend,
6265 HTMLElement7_put_onmsanimationstart,
6266 HTMLElement7_get_onmsanimationstart,
6267 HTMLElement7_put_onmsanimationend,
6268 HTMLElement7_get_onmsanimationend,
6269 HTMLElement7_put_onmsanimationiteration,
6270 HTMLElement7_get_onmsanimationiteration,
6271 HTMLElement7_put_oninvalid,
6272 HTMLElement7_get_oninvalid,
6273 HTMLElement7_put_xmsAcceleratorKey,
6274 HTMLElement7_get_xmsAcceleratorKey,
6275 HTMLElement7_put_spellcheck,
6276 HTMLElement7_get_spellcheck,
6277 HTMLElement7_put_onmsmanipulationstatechanged,
6278 HTMLElement7_get_onmsmanipulationstatechanged,
6279 HTMLElement7_put_oncuechange,
6280 HTMLElement7_get_oncuechange
6284 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
6286 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
6289 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
6291 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6292 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6295 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
6297 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6298 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6301 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
6303 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6304 return IHTMLElement_Release(&This->IHTMLElement_iface);
6307 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
6309 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6310 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6313 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
6314 LCID lcid, ITypeInfo **ppTInfo)
6316 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6317 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6320 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
6321 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6323 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6324 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6325 lcid, rgDispId);
6328 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
6329 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6331 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6332 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6333 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6336 HRESULT elem_unique_id(unsigned id, BSTR *p)
6338 WCHAR buf[32];
6340 swprintf(buf, ARRAY_SIZE(buf), L"ms__id%u", id);
6341 *p = SysAllocString(buf);
6342 return *p ? S_OK : E_OUTOFMEMORY;
6345 static void ensure_unique_id(HTMLElement *elem)
6347 if(!elem->unique_id)
6348 elem->unique_id = ++elem->node.doc->unique_id;
6351 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
6353 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6355 TRACE("(%p)->(%p)\n", This, p);
6357 ensure_unique_id(This);
6358 *p = This->unique_id;
6359 return S_OK;
6362 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
6364 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6366 TRACE("(%p)->(%p)\n", This, p);
6368 ensure_unique_id(This);
6369 return elem_unique_id(This->unique_id, p);
6372 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
6373 HTMLUniqueName_QueryInterface,
6374 HTMLUniqueName_AddRef,
6375 HTMLUniqueName_Release,
6376 HTMLUniqueName_GetTypeInfoCount,
6377 HTMLUniqueName_GetTypeInfo,
6378 HTMLUniqueName_GetIDsOfNames,
6379 HTMLUniqueName_Invoke,
6380 HTMLUniqueName_get_uniqueNumber,
6381 HTMLUniqueName_get_uniqueID
6384 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
6386 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
6389 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
6391 HTMLElement *This = impl_from_IElementSelector(iface);
6392 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6395 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
6397 HTMLElement *This = impl_from_IElementSelector(iface);
6398 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6401 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
6403 HTMLElement *This = impl_from_IElementSelector(iface);
6404 return IHTMLElement_Release(&This->IHTMLElement_iface);
6407 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
6409 HTMLElement *This = impl_from_IElementSelector(iface);
6410 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6413 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
6414 LCID lcid, ITypeInfo **ppTInfo)
6416 HTMLElement *This = impl_from_IElementSelector(iface);
6417 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6420 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
6421 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6423 HTMLElement *This = impl_from_IElementSelector(iface);
6424 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
6427 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
6428 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6430 HTMLElement *This = impl_from_IElementSelector(iface);
6431 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
6432 pDispParams, pVarResult, pExcepInfo, puArgErr);
6435 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
6437 HTMLElement *This = impl_from_IElementSelector(iface);
6438 nsIDOMElement *nselem;
6439 HTMLElement *elem;
6440 nsAString nsstr;
6441 nsresult nsres;
6442 HRESULT hres;
6444 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6446 if(!This->dom_element) {
6447 FIXME("comment element\n");
6448 return E_NOTIMPL;
6451 nsAString_InitDepend(&nsstr, v);
6452 nsres = nsIDOMElement_QuerySelector(This->dom_element, &nsstr, &nselem);
6453 nsAString_Finish(&nsstr);
6454 if(NS_FAILED(nsres)) {
6455 WARN("QuerySelector failed: %08lx\n", nsres);
6456 return map_nsresult(nsres);
6459 if(!nselem) {
6460 *pel = NULL;
6461 return S_OK;
6464 hres = get_element(nselem, &elem);
6465 nsIDOMElement_Release(nselem);
6466 if(FAILED(hres))
6467 return hres;
6469 *pel = &elem->IHTMLElement_iface;
6470 return S_OK;
6473 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
6475 HTMLElement *This = impl_from_IElementSelector(iface);
6476 nsIDOMNodeList *node_list;
6477 nsAString nsstr;
6478 nsresult nsres;
6479 HRESULT hres;
6481 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6483 if(!This->dom_element) {
6484 FIXME("comment element\n");
6485 return E_NOTIMPL;
6488 nsAString_InitDepend(&nsstr, v);
6489 nsres = nsIDOMElement_QuerySelectorAll(This->dom_element, &nsstr, &node_list);
6490 nsAString_Finish(&nsstr);
6491 if(NS_FAILED(nsres)) {
6492 WARN("QuerySelectorAll failed: %08lx\n", nsres);
6493 return map_nsresult(nsres);
6496 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
6497 nsIDOMNodeList_Release(node_list);
6498 return hres;
6501 static const IElementSelectorVtbl ElementSelectorVtbl = {
6502 ElementSelector_QueryInterface,
6503 ElementSelector_AddRef,
6504 ElementSelector_Release,
6505 ElementSelector_GetTypeInfoCount,
6506 ElementSelector_GetTypeInfo,
6507 ElementSelector_GetIDsOfNames,
6508 ElementSelector_Invoke,
6509 ElementSelector_querySelector,
6510 ElementSelector_querySelectorAll
6513 static inline HTMLElement *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
6515 return CONTAINING_RECORD(iface, HTMLElement, IProvideMultipleClassInfo_iface);
6518 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
6519 REFIID riid, void **ppv)
6521 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6522 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6525 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
6527 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6528 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6531 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
6533 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6534 return IHTMLElement_Release(&This->IHTMLElement_iface);
6537 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
6539 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6540 TRACE("(%p)->(%p)\n", This, ppTI);
6541 return get_class_typeinfo(This->node.vtbl->clsid, ppTI);
6544 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
6546 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6547 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
6548 return E_NOTIMPL;
6551 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
6553 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6554 FIXME("(%p)->(%p)\n", This, pcti);
6555 *pcti = 1;
6556 return S_OK;
6559 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
6560 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
6562 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6563 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
6564 return E_NOTIMPL;
6567 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
6568 ProvideClassInfo_QueryInterface,
6569 ProvideClassInfo_AddRef,
6570 ProvideClassInfo_Release,
6571 ProvideClassInfo_GetClassInfo,
6572 ProvideClassInfo2_GetGUID,
6573 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
6574 ProvideMultipleClassInfo_GetInfoOfIndex
6577 static inline HTMLElement *impl_from_IElementTraversal(IElementTraversal *iface)
6579 return CONTAINING_RECORD(iface, HTMLElement, IElementTraversal_iface);
6582 static HRESULT WINAPI ElementTraversal_QueryInterface(IElementTraversal *iface, REFIID riid, void **ppv)
6584 HTMLElement *This = impl_from_IElementTraversal(iface);
6585 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6588 static ULONG WINAPI ElementTraversal_AddRef(IElementTraversal *iface)
6590 HTMLElement *This = impl_from_IElementTraversal(iface);
6592 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6595 static ULONG WINAPI ElementTraversal_Release(IElementTraversal *iface)
6597 HTMLElement *This = impl_from_IElementTraversal(iface);
6599 return IHTMLElement_Release(&This->IHTMLElement_iface);
6602 static HRESULT WINAPI ElementTraversal_GetTypeInfoCount(IElementTraversal *iface, UINT *pctinfo)
6604 HTMLElement *This = impl_from_IElementTraversal(iface);
6605 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6608 static HRESULT WINAPI ElementTraversal_GetTypeInfo(IElementTraversal *iface, UINT iTInfo,
6609 LCID lcid, ITypeInfo **ppTInfo)
6611 HTMLElement *This = impl_from_IElementTraversal(iface);
6612 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6615 static HRESULT WINAPI ElementTraversal_GetIDsOfNames(IElementTraversal *iface, REFIID riid,
6616 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6618 HTMLElement *This = impl_from_IElementTraversal(iface);
6619 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6620 lcid, rgDispId);
6623 static HRESULT WINAPI ElementTraversal_Invoke(IElementTraversal *iface, DISPID dispIdMember, REFIID riid,
6624 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6626 HTMLElement *This = impl_from_IElementTraversal(iface);
6627 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6628 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6631 static HRESULT WINAPI ElementTraversal_get_firstElementChild(IElementTraversal *iface, IHTMLElement **p)
6633 HTMLElement *This = impl_from_IElementTraversal(iface);
6634 nsIDOMElement *nselem = NULL;
6635 HTMLElement *elem;
6636 HRESULT hres;
6638 TRACE("(%p)->(%p)\n", This, p);
6640 if(!This->dom_element) {
6641 *p = NULL;
6642 return S_OK;
6645 nsIDOMElement_GetFirstElementChild(This->dom_element, &nselem);
6646 if(!nselem) {
6647 *p = NULL;
6648 return S_OK;
6651 hres = get_element(nselem, &elem);
6652 nsIDOMElement_Release(nselem);
6653 if(FAILED(hres))
6654 return hres;
6656 *p = &elem->IHTMLElement_iface;
6657 return S_OK;
6660 static HRESULT WINAPI ElementTraversal_get_lastElementChild(IElementTraversal *iface, IHTMLElement **p)
6662 HTMLElement *This = impl_from_IElementTraversal(iface);
6663 nsIDOMElement *nselem = NULL;
6664 HTMLElement *elem;
6665 HRESULT hres;
6667 TRACE("(%p)->(%p)\n", This, p);
6669 if(!This->dom_element) {
6670 *p = NULL;
6671 return S_OK;
6674 nsIDOMElement_GetLastElementChild(This->dom_element, &nselem);
6675 if(!nselem) {
6676 *p = NULL;
6677 return S_OK;
6680 hres = get_element(nselem, &elem);
6681 nsIDOMElement_Release(nselem);
6682 if(FAILED(hres))
6683 return hres;
6685 *p = &elem->IHTMLElement_iface;
6686 return S_OK;
6689 static HRESULT WINAPI ElementTraversal_get_previousElementSibling(IElementTraversal *iface, IHTMLElement **p)
6691 HTMLElement *This = impl_from_IElementTraversal(iface);
6692 nsIDOMElement *nselem = NULL;
6693 HTMLElement *elem;
6694 HRESULT hres;
6696 TRACE("(%p)->(%p)\n", This, p);
6698 if(!This->dom_element) {
6699 *p = NULL;
6700 return S_OK;
6703 nsIDOMElement_GetPreviousElementSibling(This->dom_element, &nselem);
6704 if(!nselem) {
6705 *p = NULL;
6706 return S_OK;
6709 hres = get_element(nselem, &elem);
6710 nsIDOMElement_Release(nselem);
6711 if(FAILED(hres))
6712 return hres;
6714 *p = &elem->IHTMLElement_iface;
6715 return S_OK;
6718 static HRESULT WINAPI ElementTraversal_get_nextElementSibling(IElementTraversal *iface, IHTMLElement **p)
6720 HTMLElement *This = impl_from_IElementTraversal(iface);
6721 nsIDOMElement *nselem = NULL;
6722 HTMLElement *elem;
6723 HRESULT hres;
6725 TRACE("(%p)->(%p)\n", This, p);
6727 if(!This->dom_element) {
6728 *p = NULL;
6729 return S_OK;
6732 nsIDOMElement_GetNextElementSibling(This->dom_element, &nselem);
6733 if(!nselem) {
6734 *p = NULL;
6735 return S_OK;
6738 hres = get_element(nselem, &elem);
6739 nsIDOMElement_Release(nselem);
6740 if(FAILED(hres))
6741 return hres;
6743 *p = &elem->IHTMLElement_iface;
6744 return S_OK;
6747 static HRESULT WINAPI ElementTraversal_get_childElementCount(IElementTraversal *iface, LONG *p)
6749 HTMLElement *This = impl_from_IElementTraversal(iface);
6750 UINT32 count = 0;
6752 TRACE("(%p)->(%p)\n", This, p);
6754 if(This->dom_element)
6755 nsIDOMElement_GetChildElementCount(This->dom_element, &count);
6757 *p = count;
6758 return S_OK;
6761 static const IElementTraversalVtbl ElementTraversalVtbl = {
6762 ElementTraversal_QueryInterface,
6763 ElementTraversal_AddRef,
6764 ElementTraversal_Release,
6765 ElementTraversal_GetTypeInfoCount,
6766 ElementTraversal_GetTypeInfo,
6767 ElementTraversal_GetIDsOfNames,
6768 ElementTraversal_Invoke,
6769 ElementTraversal_get_firstElementChild,
6770 ElementTraversal_get_lastElementChild,
6771 ElementTraversal_get_previousElementSibling,
6772 ElementTraversal_get_nextElementSibling,
6773 ElementTraversal_get_childElementCount
6776 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
6778 return CONTAINING_RECORD(iface, HTMLElement, node);
6781 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
6783 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6785 if(IsEqualGUID(&IID_IUnknown, riid)) {
6786 *ppv = &This->IHTMLElement_iface;
6787 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
6788 *ppv = &This->IHTMLElement_iface;
6789 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
6790 *ppv = &This->IHTMLElement_iface;
6791 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
6792 *ppv = &This->IHTMLElement2_iface;
6793 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
6794 *ppv = &This->IHTMLElement3_iface;
6795 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
6796 *ppv = &This->IHTMLElement4_iface;
6797 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
6798 *ppv = &This->IHTMLElement6_iface;
6799 }else if(IsEqualGUID(&IID_IHTMLElement7, riid)) {
6800 *ppv = &This->IHTMLElement7_iface;
6801 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
6802 *ppv = &This->IHTMLUniqueName_iface;
6803 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
6804 *ppv = &This->IElementSelector_iface;
6805 }else if(IsEqualGUID(&IID_IElementTraversal, riid)) {
6806 *ppv = &This->IElementTraversal_iface;
6807 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
6808 *ppv = &This->cp_container.IConnectionPointContainer_iface;
6809 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
6810 *ppv = &This->IProvideMultipleClassInfo_iface;
6811 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
6812 *ppv = &This->IProvideMultipleClassInfo_iface;
6813 }else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid)) {
6814 *ppv = &This->IProvideMultipleClassInfo_iface;
6815 }else if(IsEqualGUID(&IID_IWineHTMLElementPrivate, riid)) {
6816 *ppv = &This->IWineHTMLElementPrivate_iface;
6817 }else {
6818 return HTMLDOMNode_QI(&This->node, riid, ppv);
6821 IUnknown_AddRef((IUnknown*)*ppv);
6822 return S_OK;
6825 void HTMLElement_destructor(HTMLDOMNode *iface)
6827 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6829 ConnectionPointContainer_Destroy(&This->cp_container);
6831 if(This->style) {
6832 This->style->elem = NULL;
6833 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
6835 if(This->runtime_style) {
6836 This->runtime_style->elem = NULL;
6837 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
6839 if(This->attrs) {
6840 HTMLDOMAttribute *attr;
6842 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
6843 attr->elem = NULL;
6845 This->attrs->elem = NULL;
6846 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
6849 free(This->filter);
6851 HTMLDOMNode_destructor(&This->node);
6854 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
6856 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6857 HTMLElement *new_elem;
6858 HRESULT hres;
6860 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
6861 if(FAILED(hres))
6862 return hres;
6864 if(This->filter) {
6865 new_elem->filter = wcsdup(This->filter);
6866 if(!new_elem->filter) {
6867 IHTMLElement_Release(&This->IHTMLElement_iface);
6868 return E_OUTOFMEMORY;
6872 *ret = &new_elem->node;
6873 return S_OK;
6876 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
6878 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6880 switch(eid) {
6881 case EVENTID_KEYDOWN: {
6882 nsIDOMKeyEvent *key_event;
6883 nsresult nsres;
6885 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
6886 if(NS_SUCCEEDED(nsres)) {
6887 UINT32 code = 0;
6889 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
6891 if(code == VK_F1 /* DOM_VK_F1 */) {
6892 DOMEvent *help_event;
6893 HRESULT hres;
6895 TRACE("F1 pressed\n");
6897 hres = create_document_event(This->node.doc, EVENTID_HELP, &help_event);
6898 if(SUCCEEDED(hres)) {
6899 dispatch_event(&This->node.event_target, help_event);
6900 IDOMEvent_Release(&help_event->IDOMEvent_iface);
6902 *prevent_default = TRUE;
6905 nsIDOMKeyEvent_Release(key_event);
6910 return S_OK;
6913 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
6915 const cpc_entry_t HTMLElement_cpc[] = {
6916 HTMLELEMENT_CPC,
6917 {NULL}
6920 static const NodeImplVtbl HTMLElementImplVtbl = {
6921 &CLSID_HTMLUnknownElement,
6922 HTMLElement_QI,
6923 HTMLElement_destructor,
6924 HTMLElement_cpc,
6925 HTMLElement_clone,
6926 HTMLElement_handle_event,
6927 HTMLElement_get_attr_col
6930 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
6932 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
6935 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
6936 DWORD grfdex, DISPID *pid)
6938 HTMLElement *This = impl_from_DispatchEx(dispex);
6940 if(This->node.vtbl->get_dispid)
6941 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
6943 return DISP_E_UNKNOWNNAME;
6946 static HRESULT HTMLElement_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
6948 HTMLElement *This = impl_from_DispatchEx(dispex);
6950 if(This->node.vtbl->get_name)
6951 return This->node.vtbl->get_name(&This->node, id, name);
6953 ERR("(%p): element has no get_name method\n", This);
6954 return DISP_E_MEMBERNOTFOUND;
6957 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
6958 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
6959 IServiceProvider *caller)
6961 HTMLElement *This = impl_from_DispatchEx(dispex);
6963 if(This->node.vtbl->invoke)
6964 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
6965 params, res, ei, caller);
6967 ERR("(%p): element has no invoke method\n", This);
6968 return E_NOTIMPL;
6971 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
6973 HTMLElement *This = impl_from_DispatchEx(dispex);
6974 nsIDOMMozNamedAttrMap *attrs;
6975 nsIDOMAttr *attr;
6976 nsAString nsstr;
6977 const PRUnichar *str;
6978 BSTR name;
6979 VARIANT value;
6980 unsigned i;
6981 UINT32 len;
6982 DISPID id;
6983 nsresult nsres;
6984 HRESULT hres;
6986 if(!This->dom_element)
6987 return S_FALSE;
6989 if(dispex_compat_mode(dispex) >= COMPAT_MODE_IE9)
6990 return S_OK;
6992 nsres = nsIDOMElement_GetAttributes(This->dom_element, &attrs);
6993 if(NS_FAILED(nsres))
6994 return E_FAIL;
6996 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
6997 if(NS_FAILED(nsres)) {
6998 nsIDOMMozNamedAttrMap_Release(attrs);
6999 return E_FAIL;
7002 nsAString_Init(&nsstr, NULL);
7003 for(i=0; i<len; i++) {
7004 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
7005 if(NS_FAILED(nsres))
7006 continue;
7008 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
7009 if(NS_FAILED(nsres)) {
7010 nsIDOMAttr_Release(attr);
7011 continue;
7014 nsAString_GetData(&nsstr, &str);
7015 name = SysAllocString(str);
7016 if(!name) {
7017 nsIDOMAttr_Release(attr);
7018 continue;
7021 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
7022 if(hres != DISP_E_UNKNOWNNAME) {
7023 nsIDOMAttr_Release(attr);
7024 SysFreeString(name);
7025 continue;
7028 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
7029 nsIDOMAttr_Release(attr);
7030 if(NS_FAILED(nsres)) {
7031 SysFreeString(name);
7032 continue;
7035 nsAString_GetData(&nsstr, &str);
7036 V_VT(&value) = VT_BSTR;
7037 if(*str) {
7038 V_BSTR(&value) = SysAllocString(str);
7039 if(!V_BSTR(&value)) {
7040 SysFreeString(name);
7041 continue;
7043 } else
7044 V_BSTR(&value) = NULL;
7046 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
7047 SysFreeString(name);
7048 VariantClear(&value);
7050 nsAString_Finish(&nsstr);
7052 nsIDOMMozNamedAttrMap_Release(attrs);
7053 return S_OK;
7056 static nsISupports *HTMLElement_get_gecko_target(DispatchEx *dispex)
7058 HTMLElement *This = impl_from_DispatchEx(dispex);
7059 return (nsISupports*)This->node.nsnode;
7062 static void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
7064 HTMLElement *This = impl_from_DispatchEx(dispex);
7065 ensure_doc_nsevent_handler(This->node.doc, This->node.nsnode, eid);
7068 static HRESULT HTMLElement_handle_event_default(DispatchEx *dispex, eventid_t eid, nsIDOMEvent *nsevent, BOOL *prevent_default)
7070 HTMLElement *This = impl_from_DispatchEx(dispex);
7072 if(!This->node.vtbl->handle_event)
7073 return S_OK;
7074 return This->node.vtbl->handle_event(&This->node, eid, nsevent, prevent_default);
7077 static EventTarget *HTMLElement_get_parent_event_target(DispatchEx *dispex)
7079 HTMLElement *This = impl_from_DispatchEx(dispex);
7080 HTMLDOMNode *node;
7081 nsIDOMNode *nsnode;
7082 nsresult nsres;
7083 HRESULT hres;
7085 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
7086 assert(nsres == NS_OK);
7087 if(!nsnode)
7088 return NULL;
7090 hres = get_node(nsnode, TRUE, &node);
7091 nsIDOMNode_Release(nsnode);
7092 if(FAILED(hres))
7093 return NULL;
7095 return &node->event_target;
7098 static ConnectionPointContainer *HTMLElement_get_cp_container(DispatchEx *dispex)
7100 HTMLElement *This = impl_from_DispatchEx(dispex);
7101 IConnectionPointContainer_AddRef(&This->cp_container.IConnectionPointContainer_iface);
7102 return &This->cp_container;
7105 static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
7107 HTMLElement *This = impl_from_DispatchEx(dispex);
7108 return default_set_current_event(This->node.doc->window, event);
7111 static HRESULT IHTMLElement6_hasAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7112 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7114 VARIANT args[2];
7115 HRESULT hres;
7116 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7118 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7119 return S_FALSE;
7121 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7122 case VT_EMPTY:
7123 case VT_BSTR:
7124 case VT_NULL:
7125 return S_FALSE;
7126 default:
7127 break;
7130 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7131 if(FAILED(hres))
7132 return hres;
7133 args[0] = dp->rgvarg[dp->cArgs - 2];
7135 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_HASATTRIBUTENS, &new_dp, res, ei, caller);
7136 VariantClear(&args[1]);
7137 return hres;
7140 static HRESULT IHTMLElement6_getAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7141 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7143 VARIANT args[2];
7144 HRESULT hres;
7145 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7147 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7148 return S_FALSE;
7150 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7151 case VT_EMPTY:
7152 case VT_BSTR:
7153 case VT_NULL:
7154 return S_FALSE;
7155 default:
7156 break;
7159 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7160 if(FAILED(hres))
7161 return hres;
7162 args[0] = dp->rgvarg[dp->cArgs - 2];
7164 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_GETATTRIBUTENS, &new_dp, res, ei, caller);
7165 VariantClear(&args[1]);
7166 return hres;
7169 static HRESULT IHTMLElement6_setAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7170 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7172 BOOL ns_conv = FALSE, val_conv = FALSE;
7173 VARIANT args[3];
7174 HRESULT hres;
7175 DISPPARAMS new_dp = { args, NULL, 3, 0 };
7177 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 3 || dp->cNamedArgs)
7178 return S_FALSE;
7180 if(dispex_compat_mode(dispex) < COMPAT_MODE_IE10)
7181 args[2] = dp->rgvarg[dp->cArgs - 1];
7182 else {
7183 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7184 case VT_EMPTY:
7185 case VT_BSTR:
7186 case VT_NULL:
7187 args[2] = dp->rgvarg[dp->cArgs - 1];
7188 break;
7189 default:
7190 hres = change_type(&args[2], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7191 if(FAILED(hres))
7192 return hres;
7193 ns_conv = TRUE;
7194 break;
7198 switch(V_VT(&dp->rgvarg[dp->cArgs - 3])) {
7199 case VT_EMPTY:
7200 case VT_BSTR:
7201 case VT_NULL:
7202 if(!ns_conv)
7203 return S_FALSE;
7204 args[0] = dp->rgvarg[dp->cArgs - 3];
7205 break;
7206 default:
7207 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 3], VT_BSTR, caller);
7208 if(FAILED(hres)) {
7209 if(ns_conv)
7210 VariantClear(&args[2]);
7211 return hres;
7213 val_conv = TRUE;
7214 break;
7217 args[1] = dp->rgvarg[dp->cArgs - 2];
7218 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_SETATTRIBUTENS, &new_dp, res, ei, caller);
7219 if(ns_conv) VariantClear(&args[2]);
7220 if(val_conv) VariantClear(&args[0]);
7221 return hres;
7224 static HRESULT IHTMLElement6_removeAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7225 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7227 VARIANT args[2];
7228 HRESULT hres;
7229 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7231 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7232 return S_FALSE;
7234 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7235 case VT_EMPTY:
7236 case VT_BSTR:
7237 case VT_NULL:
7238 return S_FALSE;
7239 default:
7240 break;
7243 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7244 if(FAILED(hres))
7245 return hres;
7246 args[0] = dp->rgvarg[dp->cArgs - 2];
7248 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, &new_dp, res, ei, caller);
7249 VariantClear(&args[1]);
7250 return hres;
7253 static HRESULT IHTMLElement6_setAttribute_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7254 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7256 VARIANT args[2];
7257 HRESULT hres;
7258 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7260 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7261 return S_FALSE;
7263 switch(V_VT(&dp->rgvarg[dp->cArgs - 2])) {
7264 case VT_EMPTY:
7265 case VT_BSTR:
7266 case VT_NULL:
7267 return S_FALSE;
7268 default:
7269 break;
7272 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 2], VT_BSTR, caller);
7273 if(FAILED(hres))
7274 return hres;
7275 args[1] = dp->rgvarg[dp->cArgs - 1];
7277 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, &new_dp, res, ei, caller);
7278 VariantClear(&args[0]);
7279 return hres;
7282 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
7284 static const dispex_hook_t elem6_ie9_hooks[] = {
7285 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
7286 {DISPID_UNKNOWN}
7288 static const dispex_hook_t elem6_ie10_hooks[] = {
7289 {DISPID_IHTMLELEMENT6_HASATTRIBUTENS, IHTMLElement6_hasAttributeNS_hook},
7290 {DISPID_IHTMLELEMENT6_GETATTRIBUTENS, IHTMLElement6_getAttributeNS_hook},
7291 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
7292 {DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, IHTMLElement6_removeAttributeNS_hook},
7293 {DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, IHTMLElement6_setAttribute_hook},
7294 {DISPID_UNKNOWN}
7296 static const dispex_hook_t elem2_ie11_hooks[] = {
7297 {DISPID_IHTMLELEMENT2_ATTACHEVENT, NULL},
7298 {DISPID_IHTMLELEMENT2_DETACHEVENT, NULL},
7299 {DISPID_IHTMLELEMENT2_DOSCROLL, NULL},
7300 {DISPID_IHTMLELEMENT2_READYSTATE, NULL},
7301 {DISPID_UNKNOWN}
7304 HTMLDOMNode_init_dispex_info(info, mode);
7306 dispex_info_add_interface(info, IHTMLElement2_tid, mode >= COMPAT_MODE_IE11 ? elem2_ie11_hooks : NULL);
7308 if(mode >= COMPAT_MODE_IE8)
7309 dispex_info_add_interface(info, IElementSelector_tid, NULL);
7311 if(mode >= COMPAT_MODE_IE9) {
7312 dispex_info_add_interface(info, IHTMLElement6_tid, mode >= COMPAT_MODE_IE10 ? elem6_ie10_hooks : elem6_ie9_hooks);
7313 dispex_info_add_interface(info, IElementTraversal_tid, NULL);
7316 if(mode >= COMPAT_MODE_IE10)
7318 dispex_info_add_interface(info, IHTMLElement7_tid, NULL);
7319 dispex_info_add_interface(info, IWineHTMLElementPrivate_tid, NULL);
7323 static const tid_t HTMLElement_iface_tids[] = {
7324 HTMLELEMENT_TIDS,
7328 static event_target_vtbl_t HTMLElement_event_target_vtbl = {
7330 NULL,
7331 HTMLElement_get_dispid,
7332 HTMLElement_get_name,
7333 HTMLElement_invoke,
7334 NULL,
7335 NULL,
7336 NULL,
7337 HTMLElement_populate_props
7339 HTMLElement_get_gecko_target,
7340 HTMLElement_bind_event,
7341 HTMLElement_get_parent_event_target,
7342 HTMLElement_handle_event_default,
7343 HTMLElement_get_cp_container,
7344 HTMLElement_set_current_event
7347 struct token_list {
7348 DispatchEx dispex;
7349 IWineDOMTokenList IWineDOMTokenList_iface;
7350 IHTMLElement *element;
7352 LONG ref;
7355 static inline struct token_list *impl_from_IWineDOMTokenList(IWineDOMTokenList *iface)
7357 return CONTAINING_RECORD(iface, struct token_list, IWineDOMTokenList_iface);
7360 static HRESULT WINAPI token_list_QueryInterface(IWineDOMTokenList *iface, REFIID riid, void **ppv)
7362 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7364 TRACE("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
7366 if(IsEqualGUID(&IID_IUnknown, riid)) {
7367 *ppv = &token_list->IWineDOMTokenList_iface;
7368 }else if(IsEqualGUID(&IID_IWineDOMTokenList, riid)) {
7369 *ppv = &token_list->IWineDOMTokenList_iface;
7370 }else if(dispex_query_interface(&token_list->dispex, riid, ppv)) {
7371 return *ppv ? S_OK : E_NOINTERFACE;
7372 }else {
7373 WARN("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
7374 *ppv = NULL;
7375 return E_NOINTERFACE;
7378 IUnknown_AddRef((IUnknown*)*ppv);
7379 return S_OK;
7382 static ULONG WINAPI token_list_AddRef(IWineDOMTokenList *iface)
7384 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7385 LONG ref = InterlockedIncrement(&token_list->ref);
7387 TRACE("(%p) ref=%ld\n", token_list, ref);
7389 return ref;
7392 static ULONG WINAPI token_list_Release(IWineDOMTokenList *iface)
7394 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7395 LONG ref = InterlockedDecrement(&token_list->ref);
7397 TRACE("(%p) ref=%ld\n", token_list, ref);
7399 if(!ref) {
7400 IHTMLElement_Release(token_list->element);
7401 release_dispex(&token_list->dispex);
7402 free(token_list);
7405 return ref;
7408 static HRESULT WINAPI token_list_GetTypeInfoCount(IWineDOMTokenList *iface, UINT *pctinfo)
7410 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7411 FIXME("(%p)->(%p)\n", token_list, pctinfo);
7412 return E_NOTIMPL;
7415 static HRESULT WINAPI token_list_GetTypeInfo(IWineDOMTokenList *iface, UINT iTInfo,
7416 LCID lcid, ITypeInfo **ppTInfo)
7418 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7420 return IDispatchEx_GetTypeInfo(&token_list->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7423 static HRESULT WINAPI token_list_GetIDsOfNames(IWineDOMTokenList *iface, REFIID riid,
7424 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
7426 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7428 return IDispatchEx_GetIDsOfNames(&token_list->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7429 lcid, rgDispId);
7432 static HRESULT WINAPI token_list_Invoke(IWineDOMTokenList *iface, DISPID dispIdMember,
7433 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7434 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7436 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7438 return IDispatchEx_Invoke(&token_list->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
7439 pDispParams, pVarResult, pExcepInfo, puArgErr);
7442 static const WCHAR *find_token(const WCHAR *list, const WCHAR *token, unsigned int token_len)
7444 const WCHAR *ptr, *next;
7446 if (!list || !token)
7447 return NULL;
7449 ptr = list;
7450 while (*ptr)
7452 while (iswspace(*ptr))
7453 ++ptr;
7454 if (!*ptr)
7455 break;
7456 next = ptr + 1;
7457 while (*next && !iswspace(*next))
7458 ++next;
7460 if (next - ptr == token_len && !wcsncmp(ptr, token, token_len))
7461 return ptr;
7462 ptr = next;
7464 return NULL;
7467 static HRESULT token_list_add_remove(IWineDOMTokenList *iface, BSTR token, BOOL remove, VARIANT_BOOL *toggle_ret)
7469 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7470 unsigned int i, len, old_len, new_len;
7471 const WCHAR *old_pos;
7472 BSTR new, old;
7473 HRESULT hr;
7475 TRACE("token_list %p, token %s, remove %#x, toggle_ret %p.\n", token_list, debugstr_w(token), remove, toggle_ret);
7477 len = token ? lstrlenW(token) : 0;
7478 if (!len)
7480 WARN("Empty token.\n");
7481 return E_INVALIDARG;
7484 for (i = 0; i < len; ++i)
7485 if (iswspace(token[i]))
7487 WARN("Token has spaces.\n");
7488 return E_INVALIDARG;
7491 if (FAILED(hr = IHTMLElement_get_className(token_list->element, &old)))
7492 return hr;
7494 TRACE("old %s.\n", debugstr_w(old));
7496 old_pos = find_token(old, token, len);
7497 if (toggle_ret)
7499 remove = !!old_pos;
7500 *toggle_ret = !remove;
7502 else if (!!old_pos != remove)
7504 SysFreeString(old);
7505 return S_OK;
7508 old_len = old ? lstrlenW(old) : 0;
7509 if (remove)
7511 while (old_pos != old && iswspace(old_pos[-1]))
7513 --old_pos;
7514 ++len;
7516 while (iswspace(old_pos[len]))
7517 ++len;
7519 if (old_pos != old && old_pos[len])
7520 --len;
7522 new_len = old_len - len;
7524 else
7526 new_len = old_len + len + !!old_len;
7529 if (!(new = SysAllocStringLen(NULL, new_len)))
7531 ERR("No memory.\n");
7532 SysFreeString(old);
7533 return E_OUTOFMEMORY;
7536 if (remove)
7538 memcpy(new, old, sizeof(*new) * (old_pos - old));
7539 memcpy(new + (old_pos - old), old_pos + len, sizeof(*new) * (old_len - (old_pos - old) - len + 1));
7541 else
7543 memcpy(new, old, sizeof(*new) * old_len);
7544 if (old_len)
7545 new[old_len++]= L' ';
7546 memcpy(new + old_len, token, sizeof(*new) * len);
7547 new[old_len + len] = 0;
7550 SysFreeString(old);
7552 TRACE("new %s.\n", debugstr_w(new));
7554 hr = IHTMLElement_put_className(token_list->element, new);
7555 SysFreeString(new);
7556 return hr;
7559 static HRESULT WINAPI token_list_add(IWineDOMTokenList *iface, BSTR token)
7561 return token_list_add_remove(iface, token, FALSE, NULL);
7564 static HRESULT WINAPI token_list_remove(IWineDOMTokenList *iface, BSTR token)
7566 return token_list_add_remove(iface, token, TRUE, NULL);
7569 static HRESULT WINAPI token_list_toggle(IWineDOMTokenList *iface, BSTR token, VARIANT_BOOL *p)
7571 VARIANT_BOOL tmp;
7572 return token_list_add_remove(iface, token, FALSE, p ? p : &tmp);
7575 static HRESULT WINAPI token_list_contains(IWineDOMTokenList *iface, BSTR token, VARIANT_BOOL *p)
7577 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7578 unsigned len;
7579 HRESULT hres;
7580 BSTR list;
7582 TRACE("(%p)->(%s %p)\n", token_list, debugstr_w(token), p);
7584 if(!token || !*token)
7585 return E_INVALIDARG;
7587 for(len = 0; token[len]; len++)
7588 if(iswspace(token[len]))
7589 return E_INVALIDARG;
7591 hres = IHTMLElement_get_className(token_list->element, &list);
7592 if(FAILED(hres))
7593 return hres;
7595 *p = find_token(list, token, len) ? VARIANT_TRUE : VARIANT_FALSE;
7596 SysFreeString(list);
7597 return S_OK;
7600 static HRESULT WINAPI token_list_get_length(IWineDOMTokenList *iface, LONG *p)
7602 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7603 unsigned length = 0;
7604 const WCHAR *ptr;
7605 HRESULT hres;
7606 BSTR list;
7608 TRACE("(%p)->(%p)\n", token_list, p);
7610 hres = IHTMLElement_get_className(token_list->element, &list);
7611 if(FAILED(hres))
7612 return hres;
7614 if(!list) {
7615 *p = 0;
7616 return S_OK;
7619 ptr = list;
7620 do {
7621 while(iswspace(*ptr))
7622 ptr++;
7623 if(!*ptr)
7624 break;
7625 length++;
7626 ptr++;
7627 while(*ptr && !iswspace(*ptr))
7628 ptr++;
7629 } while(*ptr++);
7631 SysFreeString(list);
7632 *p = length;
7633 return S_OK;
7636 static HRESULT WINAPI token_list_item(IWineDOMTokenList *iface, LONG index, VARIANT *p)
7638 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7639 BSTR list, token = NULL;
7640 unsigned i = 0;
7641 HRESULT hres;
7642 WCHAR *ptr;
7644 TRACE("(%p)->(%ld %p)\n", token_list, index, p);
7646 hres = IHTMLElement_get_className(token_list->element, &list);
7647 if(FAILED(hres))
7648 return hres;
7650 if(!list) {
7651 V_VT(p) = VT_NULL;
7652 return S_OK;
7655 ptr = list;
7656 do {
7657 while(iswspace(*ptr))
7658 ptr++;
7659 if(!*ptr)
7660 break;
7661 if(i == index) {
7662 token = ptr++;
7663 while(*ptr && !iswspace(*ptr))
7664 ptr++;
7665 token = SysAllocStringLen(token, ptr - token);
7666 if(!token) {
7667 SysFreeString(list);
7668 return E_OUTOFMEMORY;
7670 break;
7672 i++;
7673 ptr++;
7674 while(*ptr && !iswspace(*ptr))
7675 ptr++;
7676 } while(*ptr++);
7678 SysFreeString(list);
7679 if(!token)
7680 V_VT(p) = VT_NULL;
7681 else {
7682 V_VT(p) = VT_BSTR;
7683 V_BSTR(p) = token;
7685 return S_OK;
7688 static HRESULT WINAPI token_list_toString(IWineDOMTokenList *iface, BSTR *String)
7690 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7692 TRACE("(%p)->(%p)\n", token_list, String);
7694 return IHTMLElement_get_className(token_list->element, String);
7697 static const IWineDOMTokenListVtbl WineDOMTokenListVtbl = {
7698 token_list_QueryInterface,
7699 token_list_AddRef,
7700 token_list_Release,
7701 token_list_GetTypeInfoCount,
7702 token_list_GetTypeInfo,
7703 token_list_GetIDsOfNames,
7704 token_list_Invoke,
7705 token_list_add,
7706 token_list_remove,
7707 token_list_toggle,
7708 token_list_contains,
7709 token_list_get_length,
7710 token_list_item,
7711 token_list_toString
7714 /* idx can be negative, so offset it halfway through custom dispids */
7715 #define DISPID_TOKENLIST_0 (MSHTML_DISPID_CUSTOM_MIN + (MSHTML_DISPID_CUSTOM_MAX+1 - MSHTML_DISPID_CUSTOM_MIN) / 2)
7717 static inline struct token_list *token_list_from_DispatchEx(DispatchEx *iface)
7719 return CONTAINING_RECORD(iface, struct token_list, dispex);
7722 static HRESULT token_list_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params,
7723 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7725 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7726 HRESULT hres;
7728 switch(flags) {
7729 case DISPATCH_PROPERTYGET:
7730 hres = IHTMLElement_get_className(token_list->element, &V_BSTR(res));
7731 if(FAILED(hres))
7732 return hres;
7733 V_VT(res) = VT_BSTR;
7734 break;
7735 default:
7736 FIXME("Unimplemented flags %x\n", flags);
7737 return E_NOTIMPL;
7740 return S_OK;
7743 static HRESULT token_list_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
7745 WCHAR *end;
7746 LONG idx;
7747 ULONG i;
7749 idx = wcstol(name, &end, 10);
7750 if(*end)
7751 return DISP_E_UNKNOWNNAME;
7753 i = idx + DISPID_TOKENLIST_0 - MSHTML_DISPID_CUSTOM_MIN;
7754 if(i > MSHTML_CUSTOM_DISPID_CNT)
7755 return DISP_E_UNKNOWNNAME;
7757 *dispid = MSHTML_DISPID_CUSTOM_MIN + i;
7758 return S_OK;
7761 static HRESULT token_list_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
7763 LONG idx = id - MSHTML_DISPID_CUSTOM_MIN;
7764 WCHAR buf[12];
7765 UINT len;
7767 len = swprintf(buf, ARRAY_SIZE(buf), L"%d", idx);
7768 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
7771 static HRESULT token_list_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
7772 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7774 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7776 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", token_list, id, lcid, flags, params, res, ei, caller);
7778 switch(flags) {
7779 case DISPATCH_PROPERTYGET:
7780 return token_list_item(&token_list->IWineDOMTokenList_iface, id - DISPID_TOKENLIST_0, res);
7781 case DISPATCH_PROPERTYPUTREF|DISPATCH_PROPERTYPUT:
7782 case DISPATCH_PROPERTYPUTREF:
7783 case DISPATCH_PROPERTYPUT:
7784 /* Ignored by IE */
7785 return S_OK;
7786 case DISPATCH_METHOD|DISPATCH_PROPERTYGET:
7787 case DISPATCH_METHOD:
7788 return MSHTML_E_NOT_FUNC;
7789 default:
7790 break;
7793 return MSHTML_E_INVALID_ACTION;
7796 static const dispex_static_data_vtbl_t token_list_dispex_vtbl = {
7797 token_list_value,
7798 token_list_get_dispid,
7799 token_list_get_name,
7800 token_list_invoke
7803 static const tid_t token_list_iface_tids[] = {
7804 IWineDOMTokenList_tid,
7807 static dispex_static_data_t token_list_dispex = {
7808 L"DOMTokenList",
7809 &token_list_dispex_vtbl,
7810 IWineDOMTokenList_tid,
7811 token_list_iface_tids
7814 static HRESULT create_token_list(compat_mode_t compat_mode, IHTMLElement *element, IWineDOMTokenList **ret)
7816 struct token_list *obj;
7818 obj = calloc(1, sizeof(*obj));
7819 if(!obj)
7821 ERR("No memory.\n");
7822 return E_OUTOFMEMORY;
7825 obj->IWineDOMTokenList_iface.lpVtbl = &WineDOMTokenListVtbl;
7826 obj->ref = 1;
7827 init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineDOMTokenList_iface, &token_list_dispex, compat_mode);
7828 IHTMLElement_AddRef(element);
7829 obj->element = element;
7831 *ret = &obj->IWineDOMTokenList_iface;
7832 return S_OK;
7835 static inline HTMLElement *impl_from_IWineHTMLElementPrivateVtbl(IWineHTMLElementPrivate *iface)
7837 return CONTAINING_RECORD(iface, HTMLElement, IWineHTMLElementPrivate_iface);
7840 static HRESULT WINAPI htmlelement_private_QueryInterface(IWineHTMLElementPrivate *iface,
7841 REFIID riid, void **ppv)
7843 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7845 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
7848 static ULONG WINAPI htmlelement_private_AddRef(IWineHTMLElementPrivate *iface)
7850 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7852 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
7855 static ULONG WINAPI htmlelement_private_Release(IWineHTMLElementPrivate *iface)
7857 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7859 return IHTMLElement_Release(&This->IHTMLElement_iface);
7862 static HRESULT WINAPI htmlelement_private_GetTypeInfoCount(IWineHTMLElementPrivate *iface, UINT *pctinfo)
7864 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7866 return HTMLElement_GetTypeInfoCount(&This->IHTMLElement_iface, pctinfo);
7869 static HRESULT WINAPI htmlelement_private_GetTypeInfo(IWineHTMLElementPrivate *iface, UINT iTInfo,
7870 LCID lcid, ITypeInfo **ppTInfo)
7872 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7874 return HTMLElement_GetTypeInfo(&This->IHTMLElement_iface, iTInfo, lcid, ppTInfo);
7877 static HRESULT WINAPI htmlelement_private_GetIDsOfNames(IWineHTMLElementPrivate *iface, REFIID riid,
7878 LPOLESTR *rgszNames, UINT cNames,
7879 LCID lcid, DISPID *rgDispId)
7881 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7883 return HTMLElement_GetIDsOfNames(&This->IHTMLElement_iface, riid, rgszNames, cNames, lcid,
7884 rgDispId);
7887 static HRESULT WINAPI htmlelement_private_Invoke(IWineHTMLElementPrivate *iface, DISPID dispIdMember,
7888 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7889 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7891 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7893 return HTMLElement_Invoke(&This->IHTMLElement_iface, dispIdMember, riid, lcid, wFlags,
7894 pDispParams, pVarResult, pExcepInfo, puArgErr);
7897 static HRESULT WINAPI htmlelement_private_get_classList(IWineHTMLElementPrivate *iface, IDispatch **class_list)
7899 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7901 TRACE("iface %p, class_list %p.\n", iface, class_list);
7903 return create_token_list(dispex_compat_mode(&This->node.event_target.dispex), &This->IHTMLElement_iface,
7904 (IWineDOMTokenList **)class_list);
7907 static const IWineHTMLElementPrivateVtbl WineHTMLElementPrivateVtbl = {
7908 htmlelement_private_QueryInterface,
7909 htmlelement_private_AddRef,
7910 htmlelement_private_Release,
7911 htmlelement_private_GetTypeInfoCount,
7912 htmlelement_private_GetTypeInfo,
7913 htmlelement_private_GetIDsOfNames,
7914 htmlelement_private_Invoke,
7915 htmlelement_private_get_classList,
7918 static dispex_static_data_t HTMLElement_dispex = {
7919 L"HTMLElement",
7920 &HTMLElement_event_target_vtbl.dispex_vtbl,
7921 DispHTMLUnknownElement_tid,
7922 HTMLElement_iface_tids,
7923 HTMLElement_init_dispex_info
7926 static dispex_static_data_t HTMLUnknownElement_dispex = {
7927 L"HTMLUnknownElement",
7928 &HTMLElement_event_target_vtbl.dispex_vtbl,
7929 DispHTMLUnknownElement_tid,
7930 HTMLElement_iface_tids,
7931 HTMLElement_init_dispex_info
7934 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMElement *nselem, dispex_static_data_t *dispex_data)
7936 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
7937 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
7938 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
7939 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
7940 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
7941 This->IHTMLElement7_iface.lpVtbl = &HTMLElement7Vtbl;
7942 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
7943 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
7944 This->IElementTraversal_iface.lpVtbl = &ElementTraversalVtbl;
7945 This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
7946 This->IWineHTMLElementPrivate_iface.lpVtbl = &WineHTMLElementPrivateVtbl;
7948 if(dispex_data && !dispex_data->vtbl)
7949 dispex_data->vtbl = &HTMLElement_event_target_vtbl.dispex_vtbl;
7951 if(nselem) {
7952 nsIDOMHTMLElement *html_element;
7953 nsresult nsres;
7955 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data ? dispex_data : &HTMLUnknownElement_dispex);
7957 /* No AddRef, share reference with HTMLDOMNode */
7958 assert((nsIDOMNode*)nselem == This->node.nsnode);
7959 This->dom_element = nselem;
7961 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)&html_element);
7962 if(NS_SUCCEEDED(nsres)) {
7963 This->html_element = html_element;
7964 /* share reference with HTMLDOMNode */
7965 assert((nsIDOMNode*)html_element == This->node.nsnode);
7966 nsIDOMHTMLElement_Release(html_element);
7970 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
7973 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
7975 nsIDOMElement *nselem;
7976 nsAString tag_name_str;
7977 const PRUnichar *tag_name;
7978 const tag_desc_t *tag;
7979 HTMLElement *elem;
7980 nsresult nsres;
7981 HRESULT hres;
7983 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
7984 if(NS_FAILED(nsres)) {
7985 ERR("no nsIDOMElement iface\n");
7986 return E_FAIL;
7989 nsAString_Init(&tag_name_str, NULL);
7990 nsIDOMElement_GetTagName(nselem, &tag_name_str);
7992 nsAString_GetData(&tag_name_str, &tag_name);
7994 tag = get_tag_desc(tag_name);
7995 if(tag) {
7996 hres = tag->constructor(doc, nselem, &elem);
7997 }else {
7998 nsIDOMSVGElement *svg_element;
8000 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMSVGElement, (void**)&svg_element);
8001 if(NS_SUCCEEDED(nsres)) {
8002 hres = create_svg_element(doc, svg_element, tag_name, &elem);
8003 nsIDOMSVGElement_Release(svg_element);
8004 }else if(use_generic) {
8005 hres = HTMLGenericElement_Create(doc, nselem, &elem);
8006 }else {
8007 elem = calloc(1, sizeof(HTMLElement));
8008 if(elem) {
8009 elem->node.vtbl = &HTMLElementImplVtbl;
8010 HTMLElement_Init(elem, doc, nselem, &HTMLUnknownElement_dispex);
8011 hres = S_OK;
8012 }else {
8013 hres = E_OUTOFMEMORY;
8018 TRACE("%s ret %p\n", debugstr_w(tag_name), elem);
8020 nsIDOMElement_Release(nselem);
8021 nsAString_Finish(&tag_name_str);
8022 if(FAILED(hres))
8023 return hres;
8025 *ret = elem;
8026 return S_OK;
8029 static HRESULT HTMLElement_Ctor(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
8031 HTMLElement *ret;
8033 ret = calloc(1, sizeof(*ret));
8034 if(!ret)
8035 return E_OUTOFMEMORY;
8037 ret->node.vtbl = &HTMLElementImplVtbl;
8038 HTMLElement_Init(ret, doc, nselem, &HTMLElement_dispex);
8040 *elem = ret;
8041 return S_OK;
8044 HRESULT get_element(nsIDOMElement *nselem, HTMLElement **ret)
8046 HTMLDOMNode *node;
8047 HRESULT hres;
8049 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
8050 if(FAILED(hres))
8051 return hres;
8053 *ret = impl_from_HTMLDOMNode(node);
8054 return S_OK;
8057 /* interface IHTMLFiltersCollection */
8058 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
8060 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8062 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
8064 if(IsEqualGUID(&IID_IUnknown, riid)) {
8065 *ppv = &This->IHTMLFiltersCollection_iface;
8066 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
8067 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
8068 *ppv = &This->IHTMLFiltersCollection_iface;
8069 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
8070 return *ppv ? S_OK : E_NOINTERFACE;
8071 }else {
8072 *ppv = NULL;
8073 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8074 return E_NOINTERFACE;
8077 IUnknown_AddRef((IUnknown*)*ppv);
8078 return S_OK;
8081 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
8083 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8084 LONG ref = InterlockedIncrement(&This->ref);
8086 TRACE("(%p) ref=%ld\n", This, ref);
8088 return ref;
8091 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
8093 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8094 LONG ref = InterlockedDecrement(&This->ref);
8096 TRACE("(%p) ref=%ld\n", This, ref);
8098 if(!ref)
8100 free(This);
8103 return ref;
8106 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
8108 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8109 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8112 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
8113 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
8115 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8116 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8119 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
8120 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
8121 LCID lcid, DISPID *rgDispId)
8123 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8124 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8125 lcid, rgDispId);
8128 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
8129 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
8130 EXCEPINFO *pExcepInfo, UINT *puArgErr)
8132 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8133 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8134 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8137 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
8139 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8141 if(!p)
8142 return E_POINTER;
8144 FIXME("(%p)->(%p) Always returning 0\n", This, p);
8145 *p = 0;
8147 return S_OK;
8150 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
8152 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8153 FIXME("(%p)->(%p)\n", This, p);
8154 return E_NOTIMPL;
8157 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
8159 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
8160 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
8161 return E_NOTIMPL;
8164 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
8165 HTMLFiltersCollection_QueryInterface,
8166 HTMLFiltersCollection_AddRef,
8167 HTMLFiltersCollection_Release,
8168 HTMLFiltersCollection_GetTypeInfoCount,
8169 HTMLFiltersCollection_GetTypeInfo,
8170 HTMLFiltersCollection_GetIDsOfNames,
8171 HTMLFiltersCollection_Invoke,
8172 HTMLFiltersCollection_get_length,
8173 HTMLFiltersCollection_get__newEnum,
8174 HTMLFiltersCollection_item
8177 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
8179 WCHAR *ptr;
8180 int idx = 0;
8182 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
8183 idx = idx*10 + (*ptr-'0');
8184 if(*ptr)
8185 return DISP_E_UNKNOWNNAME;
8187 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
8188 TRACE("ret %lx\n", *dispid);
8189 return S_OK;
8192 static HRESULT HTMLFiltersCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
8194 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
8195 WCHAR buf[11];
8196 UINT len;
8198 len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx);
8199 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
8202 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
8203 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
8205 TRACE("(%p)->(%lx %lx %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
8207 V_VT(res) = VT_DISPATCH;
8208 V_DISPATCH(res) = NULL;
8210 FIXME("always returning NULL\n");
8212 return S_OK;
8215 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
8216 NULL,
8217 HTMLFiltersCollection_get_dispid,
8218 HTMLFiltersCollection_get_name,
8219 HTMLFiltersCollection_invoke,
8220 NULL
8223 static const tid_t HTMLFiltersCollection_iface_tids[] = {
8224 IHTMLFiltersCollection_tid,
8227 static dispex_static_data_t HTMLFiltersCollection_dispex = {
8228 L"FiltersCollection",
8229 &HTMLFiltersCollection_dispex_vtbl,
8230 IHTMLFiltersCollection_tid,
8231 HTMLFiltersCollection_iface_tids
8234 static HRESULT create_filters_collection(compat_mode_t compat_mode, IHTMLFiltersCollection **ret)
8236 HTMLFiltersCollection *collection;
8238 if(!(collection = malloc(sizeof(HTMLFiltersCollection))))
8239 return E_OUTOFMEMORY;
8241 collection->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
8242 collection->ref = 1;
8244 init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLFiltersCollection_iface,
8245 &HTMLFiltersCollection_dispex, min(compat_mode, COMPAT_MODE_IE8));
8247 *ret = &collection->IHTMLFiltersCollection_iface;
8248 return S_OK;
8251 static HRESULT get_attr_dispid_by_relative_idx(HTMLAttributeCollection *This, LONG *idx, DISPID start, DISPID *dispid)
8253 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
8254 DISPID id = start;
8255 LONG len = -1;
8256 HRESULT hres;
8258 FIXME("filter non-enumerable attributes out\n");
8260 while(1) {
8261 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
8262 if(FAILED(hres))
8263 return hres;
8264 else if(hres == S_FALSE)
8265 break;
8267 len++;
8268 if(len == *idx)
8269 break;
8272 if(dispid) {
8273 *dispid = id;
8274 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
8277 *idx = len+1;
8278 return S_OK;
8281 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
8283 return get_attr_dispid_by_relative_idx(This, idx, DISPID_STARTENUM, dispid);
8286 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
8288 HRESULT hres;
8290 if(name[0]>='0' && name[0]<='9') {
8291 WCHAR *end_ptr;
8292 LONG idx;
8294 idx = wcstoul(name, &end_ptr, 10);
8295 if(!*end_ptr) {
8296 hres = get_attr_dispid_by_idx(This, &idx, id);
8297 if(SUCCEEDED(hres))
8298 return hres;
8302 if(!This->elem) {
8303 WARN("NULL elem\n");
8304 return E_UNEXPECTED;
8307 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
8308 name, fdexNameCaseInsensitive, id);
8309 return hres;
8312 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
8314 HTMLDOMAttribute *iter;
8315 LONG pos = 0;
8316 HRESULT hres;
8318 *attr = NULL;
8319 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
8320 if(iter->dispid == id) {
8321 *attr = iter;
8322 break;
8324 pos++;
8327 if(!*attr) {
8328 if(!This->elem) {
8329 WARN("NULL elem\n");
8330 return E_UNEXPECTED;
8333 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, dispex_compat_mode(&This->elem->node.event_target.dispex), attr);
8334 if(FAILED(hres))
8335 return hres;
8338 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
8339 if(list_pos)
8340 *list_pos = pos;
8341 return S_OK;
8344 typedef struct {
8345 IEnumVARIANT IEnumVARIANT_iface;
8347 LONG ref;
8349 ULONG iter;
8350 DISPID iter_dispid;
8351 HTMLAttributeCollection *col;
8352 } HTMLAttributeCollectionEnum;
8354 static inline HTMLAttributeCollectionEnum *HTMLAttributeCollectionEnum_from_IEnumVARIANT(IEnumVARIANT *iface)
8356 return CONTAINING_RECORD(iface, HTMLAttributeCollectionEnum, IEnumVARIANT_iface);
8359 static HRESULT WINAPI HTMLAttributeCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
8361 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8363 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8365 if(IsEqualGUID(riid, &IID_IUnknown)) {
8366 *ppv = &This->IEnumVARIANT_iface;
8367 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
8368 *ppv = &This->IEnumVARIANT_iface;
8369 }else {
8370 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8371 *ppv = NULL;
8372 return E_NOINTERFACE;
8375 IUnknown_AddRef((IUnknown*)*ppv);
8376 return S_OK;
8379 static ULONG WINAPI HTMLAttributeCollectionEnum_AddRef(IEnumVARIANT *iface)
8381 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8382 LONG ref = InterlockedIncrement(&This->ref);
8384 TRACE("(%p) ref=%ld\n", This, ref);
8386 return ref;
8389 static ULONG WINAPI HTMLAttributeCollectionEnum_Release(IEnumVARIANT *iface)
8391 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8392 LONG ref = InterlockedDecrement(&This->ref);
8394 TRACE("(%p) ref=%ld\n", This, ref);
8396 if(!ref) {
8397 IHTMLAttributeCollection_Release(&This->col->IHTMLAttributeCollection_iface);
8398 free(This);
8401 return ref;
8404 static HRESULT WINAPI HTMLAttributeCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
8406 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8407 DISPID tmp, dispid = This->iter_dispid;
8408 HTMLDOMAttribute *attr;
8409 LONG rel_index = 0;
8410 HRESULT hres;
8411 ULONG i;
8413 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
8415 for(i = 0; i < celt; i++) {
8416 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, dispid, &tmp);
8417 if(SUCCEEDED(hres)) {
8418 dispid = tmp;
8419 hres = get_domattr(This->col, dispid, NULL, &attr);
8421 else if(hres == DISP_E_UNKNOWNNAME)
8422 break;
8424 if(FAILED(hres)) {
8425 while(i--)
8426 VariantClear(&rgVar[i]);
8427 return hres;
8430 V_VT(&rgVar[i]) = VT_DISPATCH;
8431 V_DISPATCH(&rgVar[i]) = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
8434 This->iter += i;
8435 This->iter_dispid = dispid;
8436 if(pCeltFetched)
8437 *pCeltFetched = i;
8438 return i == celt ? S_OK : S_FALSE;
8441 static HRESULT WINAPI HTMLAttributeCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
8443 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8444 LONG remaining, rel_index;
8445 DISPID dispid;
8446 HRESULT hres;
8448 TRACE("(%p)->(%lu)\n", This, celt);
8450 if(!celt)
8451 return S_OK;
8453 rel_index = -1;
8454 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, NULL);
8455 if(FAILED(hres))
8456 return hres;
8457 remaining = min(celt, rel_index);
8459 if(remaining) {
8460 rel_index = remaining - 1;
8461 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, &dispid);
8462 if(FAILED(hres))
8463 return hres;
8464 This->iter += remaining;
8465 This->iter_dispid = dispid;
8467 return celt > remaining ? S_FALSE : S_OK;
8470 static HRESULT WINAPI HTMLAttributeCollectionEnum_Reset(IEnumVARIANT *iface)
8472 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8474 TRACE("(%p)->()\n", This);
8476 This->iter = 0;
8477 This->iter_dispid = DISPID_STARTENUM;
8478 return S_OK;
8481 static HRESULT WINAPI HTMLAttributeCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
8483 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8484 FIXME("(%p)->(%p)\n", This, ppEnum);
8485 return E_NOTIMPL;
8488 static const IEnumVARIANTVtbl HTMLAttributeCollectionEnumVtbl = {
8489 HTMLAttributeCollectionEnum_QueryInterface,
8490 HTMLAttributeCollectionEnum_AddRef,
8491 HTMLAttributeCollectionEnum_Release,
8492 HTMLAttributeCollectionEnum_Next,
8493 HTMLAttributeCollectionEnum_Skip,
8494 HTMLAttributeCollectionEnum_Reset,
8495 HTMLAttributeCollectionEnum_Clone
8498 /* interface IHTMLAttributeCollection */
8499 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
8501 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
8504 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
8506 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8508 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8510 if(IsEqualGUID(&IID_IUnknown, riid)) {
8511 *ppv = &This->IHTMLAttributeCollection_iface;
8512 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
8513 *ppv = &This->IHTMLAttributeCollection_iface;
8514 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
8515 *ppv = &This->IHTMLAttributeCollection2_iface;
8516 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
8517 *ppv = &This->IHTMLAttributeCollection3_iface;
8518 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
8519 return *ppv ? S_OK : E_NOINTERFACE;
8520 }else {
8521 *ppv = NULL;
8522 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8523 return E_NOINTERFACE;
8526 IUnknown_AddRef((IUnknown*)*ppv);
8527 return S_OK;
8530 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
8532 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8533 LONG ref = InterlockedIncrement(&This->ref);
8535 TRACE("(%p) ref=%ld\n", This, ref);
8537 return ref;
8540 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
8542 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8543 LONG ref = InterlockedDecrement(&This->ref);
8545 TRACE("(%p) ref=%ld\n", This, ref);
8547 if(!ref) {
8548 while(!list_empty(&This->attrs)) {
8549 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
8551 list_remove(&attr->entry);
8552 attr->elem = NULL;
8553 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8556 free(This);
8559 return ref;
8562 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
8564 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8565 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8568 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
8569 LCID lcid, ITypeInfo **ppTInfo)
8571 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8572 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8575 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
8576 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8578 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8579 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8580 lcid, rgDispId);
8583 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
8584 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8585 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8587 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8588 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8589 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8592 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
8594 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8595 HRESULT hres;
8597 TRACE("(%p)->(%p)\n", This, p);
8599 *p = -1;
8600 hres = get_attr_dispid_by_idx(This, p, NULL);
8601 return hres;
8604 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
8606 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8607 HTMLAttributeCollectionEnum *ret;
8609 TRACE("(%p)->(%p)\n", This, p);
8611 ret = malloc(sizeof(*ret));
8612 if(!ret)
8613 return E_OUTOFMEMORY;
8615 ret->IEnumVARIANT_iface.lpVtbl = &HTMLAttributeCollectionEnumVtbl;
8616 ret->ref = 1;
8617 ret->iter = 0;
8618 ret->iter_dispid = DISPID_STARTENUM;
8620 HTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8621 ret->col = This;
8623 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
8624 return S_OK;
8627 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
8629 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8630 HTMLDOMAttribute *attr;
8631 DISPID id;
8632 HRESULT hres;
8634 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
8636 switch(V_VT(name)) {
8637 case VT_I4:
8638 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
8639 break;
8640 case VT_BSTR:
8641 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
8642 break;
8643 default:
8644 FIXME("unsupported name %s\n", debugstr_variant(name));
8645 hres = E_NOTIMPL;
8647 if(hres == DISP_E_UNKNOWNNAME)
8648 return E_INVALIDARG;
8649 if(FAILED(hres))
8650 return hres;
8652 hres = get_domattr(This, id, NULL, &attr);
8653 if(FAILED(hres))
8654 return hres;
8656 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
8657 return S_OK;
8660 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
8661 HTMLAttributeCollection_QueryInterface,
8662 HTMLAttributeCollection_AddRef,
8663 HTMLAttributeCollection_Release,
8664 HTMLAttributeCollection_GetTypeInfoCount,
8665 HTMLAttributeCollection_GetTypeInfo,
8666 HTMLAttributeCollection_GetIDsOfNames,
8667 HTMLAttributeCollection_Invoke,
8668 HTMLAttributeCollection_get_length,
8669 HTMLAttributeCollection__newEnum,
8670 HTMLAttributeCollection_item
8673 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
8675 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
8678 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
8680 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8681 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
8684 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
8686 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8687 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8690 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
8692 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8693 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
8696 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
8698 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8699 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8702 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
8703 LCID lcid, ITypeInfo **ppTInfo)
8705 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8706 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8709 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
8710 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8712 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8713 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8714 lcid, rgDispId);
8717 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
8718 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8719 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8721 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8722 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8723 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8726 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
8727 IHTMLDOMAttribute **newretNode)
8729 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8730 HTMLDOMAttribute *attr;
8731 DISPID id;
8732 HRESULT hres;
8734 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
8736 hres = get_attr_dispid_by_name(This, bstrName, &id);
8737 if(hres == DISP_E_UNKNOWNNAME) {
8738 *newretNode = NULL;
8739 return S_OK;
8740 } else if(FAILED(hres)) {
8741 return hres;
8744 hres = get_domattr(This, id, NULL, &attr);
8745 if(FAILED(hres))
8746 return hres;
8748 *newretNode = &attr->IHTMLDOMAttribute_iface;
8749 return S_OK;
8752 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
8753 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
8755 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8756 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
8757 return E_NOTIMPL;
8760 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
8761 BSTR bstrName, IHTMLDOMAttribute **newretNode)
8763 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8764 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
8765 return E_NOTIMPL;
8768 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
8769 HTMLAttributeCollection2_QueryInterface,
8770 HTMLAttributeCollection2_AddRef,
8771 HTMLAttributeCollection2_Release,
8772 HTMLAttributeCollection2_GetTypeInfoCount,
8773 HTMLAttributeCollection2_GetTypeInfo,
8774 HTMLAttributeCollection2_GetIDsOfNames,
8775 HTMLAttributeCollection2_Invoke,
8776 HTMLAttributeCollection2_getNamedItem,
8777 HTMLAttributeCollection2_setNamedItem,
8778 HTMLAttributeCollection2_removeNamedItem
8781 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
8783 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
8786 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
8788 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8789 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
8792 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
8794 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8795 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8798 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
8800 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8801 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
8804 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
8806 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8807 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8810 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
8811 LCID lcid, ITypeInfo **ppTInfo)
8813 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8814 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8817 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
8818 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8820 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8821 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8822 lcid, rgDispId);
8825 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
8826 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8827 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8829 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8830 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8831 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8834 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
8835 IHTMLDOMAttribute **ppNodeOut)
8837 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8838 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
8841 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
8842 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
8844 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8845 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
8846 return E_NOTIMPL;
8849 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
8850 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
8852 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8853 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
8854 return E_NOTIMPL;
8857 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
8859 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8860 HTMLDOMAttribute *attr;
8861 DISPID id;
8862 HRESULT hres;
8864 TRACE("(%p)->(%ld %p)\n", This, index, ppNodeOut);
8866 hres = get_attr_dispid_by_idx(This, &index, &id);
8867 if(hres == DISP_E_UNKNOWNNAME)
8868 return E_INVALIDARG;
8869 if(FAILED(hres))
8870 return hres;
8872 hres = get_domattr(This, id, NULL, &attr);
8873 if(FAILED(hres))
8874 return hres;
8876 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
8877 return S_OK;
8880 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
8882 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8883 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
8886 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
8887 HTMLAttributeCollection3_QueryInterface,
8888 HTMLAttributeCollection3_AddRef,
8889 HTMLAttributeCollection3_Release,
8890 HTMLAttributeCollection3_GetTypeInfoCount,
8891 HTMLAttributeCollection3_GetTypeInfo,
8892 HTMLAttributeCollection3_GetIDsOfNames,
8893 HTMLAttributeCollection3_Invoke,
8894 HTMLAttributeCollection3_getNamedItem,
8895 HTMLAttributeCollection3_setNamedItem,
8896 HTMLAttributeCollection3_removeNamedItem,
8897 HTMLAttributeCollection3_item,
8898 HTMLAttributeCollection3_get_length
8901 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
8903 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
8906 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
8908 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8909 HTMLDOMAttribute *attr;
8910 LONG pos;
8911 HRESULT hres;
8913 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(name), flags, dispid);
8915 hres = get_attr_dispid_by_name(This, name, dispid);
8916 if(FAILED(hres))
8917 return hres;
8919 hres = get_domattr(This, *dispid, &pos, &attr);
8920 if(FAILED(hres))
8921 return hres;
8922 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8924 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
8925 return S_OK;
8928 static HRESULT HTMLAttributeCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
8930 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8932 FIXME("(%p)->(%lx %p)\n", This, id, name);
8934 return E_NOTIMPL;
8937 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
8938 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
8940 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8942 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
8944 switch(flags) {
8945 case DISPATCH_PROPERTYGET: {
8946 HTMLDOMAttribute *iter;
8947 DWORD pos;
8949 pos = id-MSHTML_DISPID_CUSTOM_MIN;
8951 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
8952 if(!pos) {
8953 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
8954 V_VT(res) = VT_DISPATCH;
8955 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
8956 return S_OK;
8958 pos--;
8961 WARN("invalid arg\n");
8962 return E_INVALIDARG;
8965 default:
8966 FIXME("unimplemented flags %x\n", flags);
8967 return E_NOTIMPL;
8971 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
8972 NULL,
8973 HTMLAttributeCollection_get_dispid,
8974 HTMLAttributeCollection_get_name,
8975 HTMLAttributeCollection_invoke,
8976 NULL
8979 static const tid_t HTMLAttributeCollection_iface_tids[] = {
8980 IHTMLAttributeCollection_tid,
8981 IHTMLAttributeCollection2_tid,
8982 IHTMLAttributeCollection3_tid,
8986 static dispex_static_data_t HTMLAttributeCollection_dispex = {
8987 L"NamedNodeMap",
8988 &HTMLAttributeCollection_dispex_vtbl,
8989 DispHTMLAttributeCollection_tid,
8990 HTMLAttributeCollection_iface_tids
8993 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
8995 HTMLElement *This = impl_from_HTMLDOMNode(iface);
8997 if(This->attrs) {
8998 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
8999 *ac = This->attrs;
9000 return S_OK;
9003 This->attrs = calloc(1, sizeof(HTMLAttributeCollection));
9004 if(!This->attrs)
9005 return E_OUTOFMEMORY;
9007 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
9008 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
9009 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
9010 This->attrs->ref = 2;
9012 This->attrs->elem = This;
9013 list_init(&This->attrs->attrs);
9014 init_dispatch(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
9015 &HTMLAttributeCollection_dispex, dispex_compat_mode(&iface->event_target.dispex));
9017 *ac = This->attrs;
9018 return S_OK;