mshtml: Implement childElementCount for Elements.
[wine.git] / dlls / mshtml / htmlelem.c
blob826d131df77029048a374e1bcb882ee91658a30b
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(nsIDOMHTMLDocument *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 = nsIDOMHTMLDocument_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->nsdoc) {
414 WARN("NULL nsdoc\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 = nsIDOMHTMLDocument_CreateRange(doc->nsdoc, &nsrange);
434 if(NS_FAILED(nsres))
435 return map_nsresult(nsres);
437 if(!(p = heap_alloc(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 heap_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 = heap_alloc((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 = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &str, ret);
471 nsAString_Finish(&str);
472 heap_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->nsdoc) {
492 WARN("NULL nsdoc\n");
493 return E_UNEXPECTED;
496 nsAString_InitDepend(&tag_str, tag);
497 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &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->nsdoc)
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;
533 LONG ref;
535 nsIDOMClientRect *nsrect;
536 } HTMLRect;
538 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
540 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
543 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
545 HTMLRect *This = impl_from_IHTMLRect(iface);
547 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
549 if(IsEqualGUID(&IID_IUnknown, riid)) {
550 *ppv = &This->IHTMLRect_iface;
551 }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
552 *ppv = &This->IHTMLRect_iface;
553 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
554 return *ppv ? S_OK : E_NOINTERFACE;
555 }else {
556 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
557 *ppv = NULL;
558 return E_NOINTERFACE;
561 IUnknown_AddRef((IUnknown*)*ppv);
562 return S_OK;
565 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
567 HTMLRect *This = impl_from_IHTMLRect(iface);
568 LONG ref = InterlockedIncrement(&This->ref);
570 TRACE("(%p) ref=%ld\n", This, ref);
572 return ref;
575 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
577 HTMLRect *This = impl_from_IHTMLRect(iface);
578 LONG ref = InterlockedDecrement(&This->ref);
580 TRACE("(%p) ref=%ld\n", This, ref);
582 if(!ref) {
583 if(This->nsrect)
584 nsIDOMClientRect_Release(This->nsrect);
585 release_dispex(&This->dispex);
586 heap_free(This);
589 return ref;
592 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
594 HTMLRect *This = impl_from_IHTMLRect(iface);
595 FIXME("(%p)->(%p)\n", This, pctinfo);
596 return E_NOTIMPL;
599 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
600 LCID lcid, ITypeInfo **ppTInfo)
602 HTMLRect *This = impl_from_IHTMLRect(iface);
604 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
607 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
608 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
610 HTMLRect *This = impl_from_IHTMLRect(iface);
612 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
613 lcid, rgDispId);
616 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
617 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
618 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
620 HTMLRect *This = impl_from_IHTMLRect(iface);
622 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
623 pDispParams, pVarResult, pExcepInfo, puArgErr);
626 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
628 HTMLRect *This = impl_from_IHTMLRect(iface);
629 FIXME("(%p)->(%ld)\n", This, v);
630 return E_NOTIMPL;
633 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
635 HTMLRect *This = impl_from_IHTMLRect(iface);
636 float left;
637 nsresult nsres;
639 TRACE("(%p)->(%p)\n", This, p);
641 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
642 if(NS_FAILED(nsres)) {
643 ERR("GetLeft failed: %08lx\n", nsres);
644 return E_FAIL;
647 *p = floor(left+0.5);
648 return S_OK;
651 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
653 HTMLRect *This = impl_from_IHTMLRect(iface);
654 FIXME("(%p)->(%ld)\n", This, v);
655 return E_NOTIMPL;
658 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
660 HTMLRect *This = impl_from_IHTMLRect(iface);
661 float top;
662 nsresult nsres;
664 TRACE("(%p)->(%p)\n", This, p);
666 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
667 if(NS_FAILED(nsres)) {
668 ERR("GetTop failed: %08lx\n", nsres);
669 return E_FAIL;
672 *p = floor(top+0.5);
673 return S_OK;
676 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
678 HTMLRect *This = impl_from_IHTMLRect(iface);
679 FIXME("(%p)->(%ld)\n", This, v);
680 return E_NOTIMPL;
683 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
685 HTMLRect *This = impl_from_IHTMLRect(iface);
686 float right;
687 nsresult nsres;
689 TRACE("(%p)->(%p)\n", This, p);
691 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
692 if(NS_FAILED(nsres)) {
693 ERR("GetRight failed: %08lx\n", nsres);
694 return E_FAIL;
697 *p = floor(right+0.5);
698 return S_OK;
701 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
703 HTMLRect *This = impl_from_IHTMLRect(iface);
704 FIXME("(%p)->(%ld)\n", This, v);
705 return E_NOTIMPL;
708 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
710 HTMLRect *This = impl_from_IHTMLRect(iface);
711 float bottom;
712 nsresult nsres;
714 TRACE("(%p)->(%p)\n", This, p);
716 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
717 if(NS_FAILED(nsres)) {
718 ERR("GetBottom failed: %08lx\n", nsres);
719 return E_FAIL;
722 *p = floor(bottom+0.5);
723 return S_OK;
726 static const IHTMLRectVtbl HTMLRectVtbl = {
727 HTMLRect_QueryInterface,
728 HTMLRect_AddRef,
729 HTMLRect_Release,
730 HTMLRect_GetTypeInfoCount,
731 HTMLRect_GetTypeInfo,
732 HTMLRect_GetIDsOfNames,
733 HTMLRect_Invoke,
734 HTMLRect_put_left,
735 HTMLRect_get_left,
736 HTMLRect_put_top,
737 HTMLRect_get_top,
738 HTMLRect_put_right,
739 HTMLRect_get_right,
740 HTMLRect_put_bottom,
741 HTMLRect_get_bottom
744 static const tid_t HTMLRect_iface_tids[] = {
745 IHTMLRect_tid,
748 static dispex_static_data_t HTMLRect_dispex = {
749 L"ClientRect",
750 NULL,
751 IHTMLRect_tid,
752 HTMLRect_iface_tids
755 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, compat_mode_t compat_mode, IHTMLRect **ret)
757 HTMLRect *rect;
759 rect = heap_alloc_zero(sizeof(HTMLRect));
760 if(!rect)
761 return E_OUTOFMEMORY;
763 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
764 rect->ref = 1;
766 init_dispatch(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex, compat_mode);
768 nsIDOMClientRect_AddRef(nsrect);
769 rect->nsrect = nsrect;
771 *ret = &rect->IHTMLRect_iface;
772 return S_OK;
775 typedef struct {
776 DispatchEx dispex;
777 IHTMLRectCollection IHTMLRectCollection_iface;
779 LONG ref;
781 nsIDOMClientRectList *rect_list;
782 } HTMLRectCollection;
784 typedef struct {
785 IEnumVARIANT IEnumVARIANT_iface;
787 LONG ref;
789 ULONG iter;
790 HTMLRectCollection *col;
791 } HTMLRectCollectionEnum;
793 static inline HTMLRectCollectionEnum *HTMLRectCollectionEnum_from_IEnumVARIANT(IEnumVARIANT *iface)
795 return CONTAINING_RECORD(iface, HTMLRectCollectionEnum, IEnumVARIANT_iface);
798 static HRESULT WINAPI HTMLRectCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
800 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
802 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
804 if(IsEqualGUID(riid, &IID_IUnknown)) {
805 *ppv = &This->IEnumVARIANT_iface;
806 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
807 *ppv = &This->IEnumVARIANT_iface;
808 }else {
809 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
810 *ppv = NULL;
811 return E_NOINTERFACE;
814 IUnknown_AddRef((IUnknown*)*ppv);
815 return S_OK;
818 static ULONG WINAPI HTMLRectCollectionEnum_AddRef(IEnumVARIANT *iface)
820 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
821 LONG ref = InterlockedIncrement(&This->ref);
823 TRACE("(%p) ref=%ld\n", This, ref);
825 return ref;
828 static ULONG WINAPI HTMLRectCollectionEnum_Release(IEnumVARIANT *iface)
830 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
831 LONG ref = InterlockedDecrement(&This->ref);
833 TRACE("(%p) ref=%ld\n", This, ref);
835 if(!ref) {
836 IHTMLRectCollection_Release(&This->col->IHTMLRectCollection_iface);
837 heap_free(This);
840 return ref;
843 static HRESULT WINAPI HTMLRectCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
845 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
846 VARIANT index;
847 HRESULT hres;
848 ULONG num, i;
849 UINT32 len;
851 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
853 nsIDOMClientRectList_GetLength(This->col->rect_list, &len);
854 num = min(len - This->iter, celt);
855 V_VT(&index) = VT_I4;
857 for(i = 0; i < num; i++) {
858 V_I4(&index) = This->iter + i;
859 hres = IHTMLRectCollection_item(&This->col->IHTMLRectCollection_iface, &index, &rgVar[i]);
860 if(FAILED(hres)) {
861 while(i--)
862 VariantClear(&rgVar[i]);
863 return hres;
867 This->iter += num;
868 if(pCeltFetched)
869 *pCeltFetched = num;
870 return num == celt ? S_OK : S_FALSE;
873 static HRESULT WINAPI HTMLRectCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
875 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
876 UINT32 len;
878 TRACE("(%p)->(%lu)\n", This, celt);
880 nsIDOMClientRectList_GetLength(This->col->rect_list, &len);
881 if(This->iter + celt > len) {
882 This->iter = len;
883 return S_FALSE;
886 This->iter += celt;
887 return S_OK;
890 static HRESULT WINAPI HTMLRectCollectionEnum_Reset(IEnumVARIANT *iface)
892 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
894 TRACE("(%p)->()\n", This);
896 This->iter = 0;
897 return S_OK;
900 static HRESULT WINAPI HTMLRectCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
902 HTMLRectCollectionEnum *This = HTMLRectCollectionEnum_from_IEnumVARIANT(iface);
903 FIXME("(%p)->(%p)\n", This, ppEnum);
904 return E_NOTIMPL;
907 static const IEnumVARIANTVtbl HTMLRectCollectionEnumVtbl = {
908 HTMLRectCollectionEnum_QueryInterface,
909 HTMLRectCollectionEnum_AddRef,
910 HTMLRectCollectionEnum_Release,
911 HTMLRectCollectionEnum_Next,
912 HTMLRectCollectionEnum_Skip,
913 HTMLRectCollectionEnum_Reset,
914 HTMLRectCollectionEnum_Clone
917 static inline HTMLRectCollection *impl_from_IHTMLRectCollection(IHTMLRectCollection *iface)
919 return CONTAINING_RECORD(iface, HTMLRectCollection, IHTMLRectCollection_iface);
922 static HRESULT WINAPI HTMLRectCollection_QueryInterface(IHTMLRectCollection *iface, REFIID riid, void **ppv)
924 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
926 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
928 if(IsEqualGUID(&IID_IUnknown, riid)) {
929 *ppv = &This->IHTMLRectCollection_iface;
930 }else if(IsEqualGUID(&IID_IHTMLRectCollection, riid)) {
931 *ppv = &This->IHTMLRectCollection_iface;
932 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
933 return *ppv ? S_OK : E_NOINTERFACE;
934 }else {
935 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
936 *ppv = NULL;
937 return E_NOINTERFACE;
940 IUnknown_AddRef((IUnknown*)*ppv);
941 return S_OK;
944 static ULONG WINAPI HTMLRectCollection_AddRef(IHTMLRectCollection *iface)
946 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
947 LONG ref = InterlockedIncrement(&This->ref);
949 TRACE("(%p) ref=%ld\n", This, ref);
951 return ref;
954 static ULONG WINAPI HTMLRectCollection_Release(IHTMLRectCollection *iface)
956 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
957 LONG ref = InterlockedDecrement(&This->ref);
959 TRACE("(%p) ref=%ld\n", This, ref);
961 if(!ref) {
962 if(This->rect_list)
963 nsIDOMClientRectList_Release(This->rect_list);
964 release_dispex(&This->dispex);
965 heap_free(This);
968 return ref;
971 static HRESULT WINAPI HTMLRectCollection_GetTypeInfoCount(IHTMLRectCollection *iface, UINT *pctinfo)
973 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
974 FIXME("(%p)->(%p)\n", This, pctinfo);
975 return E_NOTIMPL;
978 static HRESULT WINAPI HTMLRectCollection_GetTypeInfo(IHTMLRectCollection *iface, UINT iTInfo,
979 LCID lcid, ITypeInfo **ppTInfo)
981 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
982 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
985 static HRESULT WINAPI HTMLRectCollection_GetIDsOfNames(IHTMLRectCollection *iface, REFIID riid,
986 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
988 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
989 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
990 lcid, rgDispId);
993 static HRESULT WINAPI HTMLRectCollection_Invoke(IHTMLRectCollection *iface, DISPID dispIdMember,
994 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
995 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
997 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
998 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
999 pDispParams, pVarResult, pExcepInfo, puArgErr);
1002 static HRESULT WINAPI HTMLRectCollection_get_length(IHTMLRectCollection *iface, LONG *p)
1004 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1005 UINT32 length;
1006 nsresult nsres;
1008 TRACE("(%p)->(%p)\n", This, p);
1010 nsres = nsIDOMClientRectList_GetLength(This->rect_list, &length);
1011 assert(nsres == NS_OK);
1012 *p = length;
1013 return S_OK;
1016 static HRESULT WINAPI HTMLRectCollection_get__newEnum(IHTMLRectCollection *iface, IUnknown **p)
1018 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1019 HTMLRectCollectionEnum *ret;
1021 TRACE("(%p)->(%p)\n", This, p);
1023 ret = heap_alloc(sizeof(*ret));
1024 if(!ret)
1025 return E_OUTOFMEMORY;
1027 ret->IEnumVARIANT_iface.lpVtbl = &HTMLRectCollectionEnumVtbl;
1028 ret->ref = 1;
1029 ret->iter = 0;
1031 HTMLRectCollection_AddRef(&This->IHTMLRectCollection_iface);
1032 ret->col = This;
1034 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
1035 return S_OK;
1038 static HRESULT WINAPI HTMLRectCollection_item(IHTMLRectCollection *iface, VARIANT *index, VARIANT *result)
1040 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
1041 nsIDOMClientRect *nsrect;
1042 IHTMLRect *rect;
1043 nsresult nsres;
1044 HRESULT hres;
1046 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(index), result);
1048 if(V_VT(index) != VT_I4 || V_I4(index) < 0) {
1049 FIXME("Unsupported for %s index\n", debugstr_variant(index));
1050 return E_NOTIMPL;
1053 nsres = nsIDOMClientRectList_Item(This->rect_list, V_I4(index), &nsrect);
1054 if(NS_FAILED(nsres))
1055 return map_nsresult(nsres);
1056 if(!nsrect) {
1057 V_VT(result) = VT_NULL;
1058 return S_OK;
1061 hres = create_html_rect(nsrect, dispex_compat_mode(&This->dispex), &rect);
1062 nsIDOMClientRect_Release(nsrect);
1063 if(FAILED(hres))
1064 return hres;
1066 V_VT(result) = VT_DISPATCH;
1067 V_DISPATCH(result) = (IDispatch *)rect;
1068 return S_OK;
1071 static const IHTMLRectCollectionVtbl HTMLRectCollectionVtbl = {
1072 HTMLRectCollection_QueryInterface,
1073 HTMLRectCollection_AddRef,
1074 HTMLRectCollection_Release,
1075 HTMLRectCollection_GetTypeInfoCount,
1076 HTMLRectCollection_GetTypeInfo,
1077 HTMLRectCollection_GetIDsOfNames,
1078 HTMLRectCollection_Invoke,
1079 HTMLRectCollection_get_length,
1080 HTMLRectCollection_get__newEnum,
1081 HTMLRectCollection_item
1084 static inline HTMLRectCollection *HTMLRectCollection_from_DispatchEx(DispatchEx *iface)
1086 return CONTAINING_RECORD(iface, HTMLRectCollection, dispex);
1089 static HRESULT HTMLRectCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1091 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1092 UINT32 len = 0;
1093 DWORD idx = 0;
1094 WCHAR *ptr;
1096 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
1097 idx = idx*10 + (*ptr-'0');
1098 if(*ptr)
1099 return DISP_E_UNKNOWNNAME;
1101 nsIDOMClientRectList_GetLength(This->rect_list, &len);
1102 if(idx >= len)
1103 return DISP_E_UNKNOWNNAME;
1105 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1106 TRACE("ret %lx\n", *dispid);
1107 return S_OK;
1110 static HRESULT HTMLRectCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1111 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1113 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1115 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
1117 switch(flags) {
1118 case DISPATCH_PROPERTYGET: {
1119 nsIDOMClientRect *rect;
1120 IHTMLRect *html_rect;
1121 nsresult nsres;
1122 HRESULT hres;
1124 nsres = nsIDOMClientRectList_Item(This->rect_list, id - MSHTML_DISPID_CUSTOM_MIN, &rect);
1125 if(NS_FAILED(nsres) || !rect) {
1126 WARN("Unknown item\n");
1127 return DISP_E_UNKNOWNNAME;
1130 hres = create_html_rect(rect, dispex_compat_mode(&This->dispex), &html_rect);
1131 nsIDOMClientRect_Release(rect);
1132 if(FAILED(hres))
1133 return hres;
1135 V_VT(res) = VT_DISPATCH;
1136 V_DISPATCH(res) = (IDispatch*)html_rect;
1137 break;
1140 default:
1141 FIXME("unimplemented flags %x\n", flags);
1142 return E_NOTIMPL;
1145 return S_OK;
1148 static const dispex_static_data_vtbl_t HTMLRectCollection_dispex_vtbl = {
1149 NULL,
1150 HTMLRectCollection_get_dispid,
1151 HTMLRectCollection_invoke,
1152 NULL
1154 static const tid_t HTMLRectCollection_iface_tids[] = {
1155 IHTMLRectCollection_tid,
1158 static dispex_static_data_t HTMLRectCollection_dispex = {
1159 L"ClientRectList",
1160 &HTMLRectCollection_dispex_vtbl,
1161 IHTMLRectCollection_tid,
1162 HTMLRectCollection_iface_tids
1165 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
1166 REFIID riid, void **ppv)
1168 HTMLElement *This = impl_from_IHTMLElement(iface);
1170 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
1173 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
1175 HTMLElement *This = impl_from_IHTMLElement(iface);
1177 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
1180 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
1182 HTMLElement *This = impl_from_IHTMLElement(iface);
1184 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
1187 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
1189 HTMLElement *This = impl_from_IHTMLElement(iface);
1190 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
1193 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
1194 LCID lcid, ITypeInfo **ppTInfo)
1196 HTMLElement *This = impl_from_IHTMLElement(iface);
1197 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1200 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
1201 LPOLESTR *rgszNames, UINT cNames,
1202 LCID lcid, DISPID *rgDispId)
1204 HTMLElement *This = impl_from_IHTMLElement(iface);
1205 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1206 lcid, rgDispId);
1209 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
1210 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1211 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1213 HTMLElement *This = impl_from_IHTMLElement(iface);
1214 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1215 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1218 static inline WCHAR *translate_attr_name(WCHAR *attr_name, compat_mode_t compat_mode)
1220 static WCHAR classNameW[] = L"className";
1221 WCHAR *ret = attr_name;
1223 if(compat_mode >= COMPAT_MODE_IE8 && !wcsicmp(attr_name, L"class"))
1224 ret = classNameW;
1225 return ret;
1228 static HRESULT set_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *v)
1230 DISPID propput_dispid = DISPID_PROPERTYPUT;
1231 DISPPARAMS dp = {v, &propput_dispid, 1, 1};
1232 EXCEPINFO ei;
1234 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
1235 TRACE("Ignoring call on style attribute\n");
1236 return S_OK;
1239 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid,
1240 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
1243 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
1244 VARIANT AttributeValue, LONG lFlags)
1246 HTMLElement *This = impl_from_IHTMLElement(iface);
1247 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1248 nsAString name_str, value_str;
1249 VARIANT val = AttributeValue;
1250 BOOL needs_free = FALSE;
1251 nsresult nsres;
1252 DISPID dispid;
1253 HRESULT hres;
1255 TRACE("(%p)->(%s %s %08lx)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
1257 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1258 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1259 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
1260 if(FAILED(hres))
1261 return hres;
1263 if(compat_mode >= COMPAT_MODE_IE8 && get_dispid_type(dispid) == DISPEXPROP_BUILTIN) {
1264 if(V_VT(&val) != VT_BSTR && V_VT(&val) != VT_NULL) {
1265 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1267 V_VT(&val) = VT_EMPTY;
1268 hres = VariantChangeTypeEx(&val, &AttributeValue, lcid, 0, VT_BSTR);
1269 if(FAILED(hres))
1270 return hres;
1272 if(V_BSTR(&val))
1273 needs_free = TRUE;
1274 else
1275 V_VT(&val) = VT_NULL;
1279 /* className and style are special cases */
1280 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1281 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1282 hres = set_elem_attr_value_by_dispid(This, dispid, &val);
1283 goto done;
1287 hres = variant_to_nsstr(&val, FALSE, &value_str);
1288 if(FAILED(hres))
1289 goto done;
1291 nsAString_InitDepend(&name_str, strAttributeName);
1292 nsres = nsIDOMElement_SetAttribute(This->dom_element, &name_str, &value_str);
1293 nsAString_Finish(&name_str);
1294 nsAString_Finish(&value_str);
1295 if(NS_FAILED(nsres))
1296 WARN("SetAttribute failed: %08lx\n", nsres);
1297 hres = map_nsresult(nsres);
1299 done:
1300 if(needs_free)
1301 SysFreeString(V_BSTR(&val));
1302 return hres;
1305 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *ret)
1307 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
1308 EXCEPINFO excep;
1310 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
1311 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
1314 HRESULT attr_value_to_string(VARIANT *v)
1316 HRESULT hres;
1318 switch(V_VT(v)) {
1319 case VT_BSTR:
1320 break;
1321 case VT_NULL:
1322 V_BSTR(v) = SysAllocString(L"null");
1323 if(!V_BSTR(v))
1324 return E_OUTOFMEMORY;
1325 V_VT(v) = VT_BSTR;
1326 break;
1327 case VT_DISPATCH:
1328 IDispatch_Release(V_DISPATCH(v));
1329 V_VT(v) = VT_BSTR;
1330 V_BSTR(v) = SysAllocString(NULL);
1331 break;
1332 default:
1333 hres = VariantChangeType(v, v, 0, VT_BSTR);
1334 if(FAILED(hres))
1335 return hres;
1338 return S_OK;
1341 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
1342 LONG lFlags, VARIANT *AttributeValue)
1344 HTMLElement *This = impl_from_IHTMLElement(iface);
1345 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1346 nsAString name_str, value_str;
1347 nsresult nsres;
1348 DISPID dispid;
1349 HRESULT hres;
1351 TRACE("(%p)->(%s %08lx %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
1353 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
1354 FIXME("Unsupported flags %lx\n", lFlags);
1356 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1357 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1358 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
1359 if(FAILED(hres)) {
1360 V_VT(AttributeValue) = VT_NULL;
1361 return (hres == DISP_E_UNKNOWNNAME) ? S_OK : hres;
1364 /* className and style are special cases */
1365 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1366 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1367 hres = get_elem_attr_value_by_dispid(This, dispid, AttributeValue);
1368 if(FAILED(hres))
1369 return hres;
1371 if(compat_mode >= COMPAT_MODE_IE8 && V_VT(AttributeValue) != VT_BSTR && V_VT(AttributeValue) != VT_NULL) {
1372 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1374 hres = VariantChangeTypeEx(AttributeValue, AttributeValue, lcid, 0, VT_BSTR);
1375 if(FAILED(hres)) {
1376 VariantClear(AttributeValue);
1377 return hres;
1379 if(!V_BSTR(AttributeValue))
1380 V_VT(AttributeValue) = VT_NULL;
1381 }else if(lFlags & ATTRFLAG_ASSTRING)
1382 hres = attr_value_to_string(AttributeValue);
1383 return hres;
1387 nsAString_InitDepend(&name_str, strAttributeName);
1388 nsAString_InitDepend(&value_str, NULL);
1389 nsres = nsIDOMElement_GetAttribute(This->dom_element, &name_str, &value_str);
1390 nsAString_Finish(&name_str);
1391 return return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
1394 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
1395 LONG lFlags, VARIANT_BOOL *pfSuccess)
1397 HTMLElement *This = impl_from_IHTMLElement(iface);
1398 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1399 DISPID id;
1400 HRESULT hres;
1402 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
1404 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1405 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1406 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
1407 if(hres == DISP_E_UNKNOWNNAME) {
1408 *pfSuccess = VARIANT_FALSE;
1409 return S_OK;
1411 if(FAILED(hres))
1412 return hres;
1414 if(id == DISPID_IHTMLELEMENT_STYLE) {
1415 IHTMLStyle *style;
1417 TRACE("Special case: style\n");
1419 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
1420 if(FAILED(hres))
1421 return hres;
1423 hres = IHTMLStyle_put_cssText(style, NULL);
1424 IHTMLStyle_Release(style);
1425 if(FAILED(hres))
1426 return hres;
1428 if(compat_mode >= COMPAT_MODE_IE8)
1429 element_remove_attribute(This, strAttributeName);
1431 *pfSuccess = VARIANT_TRUE;
1432 return S_OK;
1435 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element || id != DISPID_IHTMLELEMENT_CLASSNAME)
1436 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
1439 *pfSuccess = element_has_attribute(This, strAttributeName);
1440 if(*pfSuccess)
1441 return element_remove_attribute(This, strAttributeName);
1442 return S_OK;
1445 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
1447 HTMLElement *This = impl_from_IHTMLElement(iface);
1448 nsAString classname_str;
1449 nsresult nsres;
1451 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1453 if(!This->dom_element) {
1454 FIXME("comment element\n");
1455 return E_NOTIMPL;
1458 nsAString_InitDepend(&classname_str, v);
1459 nsres = nsIDOMElement_SetClassName(This->dom_element, &classname_str);
1460 nsAString_Finish(&classname_str);
1461 if(NS_FAILED(nsres))
1462 ERR("SetClassName failed: %08lx\n", nsres);
1464 return S_OK;
1467 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
1469 HTMLElement *This = impl_from_IHTMLElement(iface);
1470 nsAString class_str;
1471 nsresult nsres;
1473 TRACE("(%p)->(%p)\n", This, p);
1475 if(!This->dom_element) {
1476 FIXME("comment element\n");
1477 return E_NOTIMPL;
1480 nsAString_Init(&class_str, NULL);
1481 nsres = nsIDOMElement_GetClassName(This->dom_element, &class_str);
1482 return return_nsstr(nsres, &class_str, p);
1485 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
1487 HTMLElement *This = impl_from_IHTMLElement(iface);
1488 nsAString id_str;
1489 nsresult nsres;
1491 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1493 if(!This->dom_element) {
1494 FIXME("comment element\n");
1495 return S_OK;
1498 nsAString_InitDepend(&id_str, v);
1499 nsres = nsIDOMElement_SetId(This->dom_element, &id_str);
1500 nsAString_Finish(&id_str);
1501 if(NS_FAILED(nsres))
1502 ERR("SetId failed: %08lx\n", nsres);
1504 return S_OK;
1507 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
1509 HTMLElement *This = impl_from_IHTMLElement(iface);
1510 nsAString id_str;
1511 nsresult nsres;
1513 TRACE("(%p)->(%p)\n", This, p);
1515 if(!This->dom_element) {
1516 *p = NULL;
1517 return S_OK;
1520 nsAString_Init(&id_str, NULL);
1521 nsres = nsIDOMElement_GetId(This->dom_element, &id_str);
1522 return return_nsstr(nsres, &id_str, p);
1525 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
1527 HTMLElement *This = impl_from_IHTMLElement(iface);
1528 nsAString tag_str;
1529 nsresult nsres;
1531 TRACE("(%p)->(%p)\n", This, p);
1533 if(!This->dom_element) {
1534 TRACE("comment element\n");
1535 *p = SysAllocString(L"!");
1536 return *p ? S_OK : E_OUTOFMEMORY;
1539 nsAString_Init(&tag_str, NULL);
1540 nsres = nsIDOMElement_GetTagName(This->dom_element, &tag_str);
1541 return return_nsstr(nsres, &tag_str, p);
1544 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
1546 HTMLElement *This = impl_from_IHTMLElement(iface);
1547 IHTMLDOMNode *node;
1548 HRESULT hres;
1550 TRACE("(%p)->(%p)\n", This, p);
1552 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
1553 if(FAILED(hres))
1554 return hres;
1556 if(!node) {
1557 *p = NULL;
1558 return S_OK;
1561 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
1562 IHTMLDOMNode_Release(node);
1563 if(FAILED(hres))
1564 *p = NULL;
1566 return S_OK;
1569 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
1571 HTMLElement *This = impl_from_IHTMLElement(iface);
1573 TRACE("(%p)->(%p)\n", This, p);
1575 if(!This->style) {
1576 HRESULT hres;
1578 hres = HTMLStyle_Create(This, &This->style);
1579 if(FAILED(hres))
1580 return hres;
1583 *p = &This->style->IHTMLStyle_iface;
1584 IHTMLStyle_AddRef(*p);
1585 return S_OK;
1588 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
1590 HTMLElement *This = impl_from_IHTMLElement(iface);
1592 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1594 return set_node_event(&This->node, EVENTID_HELP, &v);
1597 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
1599 HTMLElement *This = impl_from_IHTMLElement(iface);
1601 TRACE("(%p)->(%p)\n", This, p);
1603 return get_node_event(&This->node, EVENTID_HELP, p);
1606 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
1608 HTMLElement *This = impl_from_IHTMLElement(iface);
1610 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1612 return set_node_event(&This->node, EVENTID_CLICK, &v);
1615 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
1617 HTMLElement *This = impl_from_IHTMLElement(iface);
1619 TRACE("(%p)->(%p)\n", This, p);
1621 return get_node_event(&This->node, EVENTID_CLICK, p);
1624 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
1626 HTMLElement *This = impl_from_IHTMLElement(iface);
1628 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1630 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
1633 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
1635 HTMLElement *This = impl_from_IHTMLElement(iface);
1637 TRACE("(%p)->(%p)\n", This, p);
1639 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
1642 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
1644 HTMLElement *This = impl_from_IHTMLElement(iface);
1646 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1648 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
1651 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
1653 HTMLElement *This = impl_from_IHTMLElement(iface);
1655 TRACE("(%p)->(%p)\n", This, p);
1657 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
1660 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
1662 HTMLElement *This = impl_from_IHTMLElement(iface);
1664 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1666 return set_node_event(&This->node, EVENTID_KEYUP, &v);
1669 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
1671 HTMLElement *This = impl_from_IHTMLElement(iface);
1673 TRACE("(%p)->(%p)\n", This, p);
1675 return get_node_event(&This->node, EVENTID_KEYUP, p);
1678 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
1680 HTMLElement *This = impl_from_IHTMLElement(iface);
1682 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1684 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
1687 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
1689 HTMLElement *This = impl_from_IHTMLElement(iface);
1691 TRACE("(%p)->(%p)\n", This, p);
1693 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
1696 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
1698 HTMLElement *This = impl_from_IHTMLElement(iface);
1700 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1702 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
1705 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
1707 HTMLElement *This = impl_from_IHTMLElement(iface);
1709 TRACE("(%p)->(%p)\n", This, p);
1711 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1714 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1716 HTMLElement *This = impl_from_IHTMLElement(iface);
1718 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1720 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1723 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1725 HTMLElement *This = impl_from_IHTMLElement(iface);
1727 TRACE("(%p)->(%p)\n", This, p);
1729 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1732 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1734 HTMLElement *This = impl_from_IHTMLElement(iface);
1736 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1738 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1741 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1743 HTMLElement *This = impl_from_IHTMLElement(iface);
1745 TRACE("(%p)->(%p)\n", This, p);
1747 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1750 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1752 HTMLElement *This = impl_from_IHTMLElement(iface);
1754 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1756 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1759 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1761 HTMLElement *This = impl_from_IHTMLElement(iface);
1763 TRACE("(%p)->(%p)\n", This, p);
1765 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1768 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1770 HTMLElement *This = impl_from_IHTMLElement(iface);
1772 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1774 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1777 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1779 HTMLElement *This = impl_from_IHTMLElement(iface);
1781 TRACE("(%p)->(%p)\n", This, p);
1783 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1786 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1788 HTMLElement *This = impl_from_IHTMLElement(iface);
1790 TRACE("(%p)->(%p)\n", This, p);
1792 if(!p)
1793 return E_POINTER;
1795 if(This->node.vtbl->get_document)
1796 return This->node.vtbl->get_document(&This->node, p);
1798 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1799 IDispatch_AddRef(*p);
1800 return S_OK;
1803 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1805 HTMLElement *This = impl_from_IHTMLElement(iface);
1806 nsAString title_str;
1807 nsresult nsres;
1809 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1811 if(!This->dom_element) {
1812 VARIANT *var;
1813 HRESULT hres;
1815 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", TRUE, &var);
1816 if(FAILED(hres))
1817 return hres;
1819 VariantClear(var);
1820 V_VT(var) = VT_BSTR;
1821 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1822 return S_OK;
1825 if(!This->html_element)
1826 return elem_string_attr_setter(This, L"title", v);
1828 nsAString_InitDepend(&title_str, v);
1829 nsres = nsIDOMHTMLElement_SetTitle(This->html_element, &title_str);
1830 nsAString_Finish(&title_str);
1831 if(NS_FAILED(nsres))
1832 ERR("SetTitle failed: %08lx\n", nsres);
1834 return S_OK;
1837 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1839 HTMLElement *This = impl_from_IHTMLElement(iface);
1840 nsAString title_str;
1841 nsresult nsres;
1843 TRACE("(%p)->(%p)\n", This, p);
1845 if(!This->dom_element) {
1846 VARIANT *var;
1847 HRESULT hres;
1849 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", FALSE, &var);
1850 if(hres == DISP_E_UNKNOWNNAME) {
1851 *p = NULL;
1852 }else if(V_VT(var) != VT_BSTR) {
1853 FIXME("title = %s\n", debugstr_variant(var));
1854 return E_FAIL;
1855 }else {
1856 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1859 return S_OK;
1862 if(!This->html_element)
1863 return elem_string_attr_getter(This, L"title", FALSE, p);
1865 nsAString_Init(&title_str, NULL);
1866 nsres = nsIDOMHTMLElement_GetTitle(This->html_element, &title_str);
1867 return return_nsstr(nsres, &title_str, p);
1870 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1872 HTMLElement *This = impl_from_IHTMLElement(iface);
1874 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1876 return elem_string_attr_setter(This, L"language", v);
1879 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1881 HTMLElement *This = impl_from_IHTMLElement(iface);
1883 TRACE("(%p)->(%p)\n", This, p);
1885 return elem_string_attr_getter(This, L"language", TRUE, p);
1888 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1890 HTMLElement *This = impl_from_IHTMLElement(iface);
1892 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1894 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1897 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1899 HTMLElement *This = impl_from_IHTMLElement(iface);
1901 TRACE("(%p)->(%p)\n", This, p);
1903 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1906 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1908 HTMLElement *This = impl_from_IHTMLElement(iface);
1909 cpp_bool start = TRUE;
1910 nsresult nsres;
1912 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1914 switch(V_VT(&varargStart)) {
1915 case VT_EMPTY:
1916 case VT_ERROR:
1917 break;
1918 case VT_BOOL:
1919 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1920 break;
1921 default:
1922 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1925 if(!This->html_element) {
1926 FIXME("non-HTML elements\n");
1927 return E_NOTIMPL;
1930 nsres = nsIDOMHTMLElement_ScrollIntoView(This->html_element, start, 1);
1931 assert(nsres == NS_OK);
1933 return S_OK;
1936 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1937 VARIANT_BOOL *pfResult)
1939 HTMLElement *This = impl_from_IHTMLElement(iface);
1940 cpp_bool result = FALSE;
1942 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1944 if(pChild) {
1945 HTMLElement *child;
1946 nsresult nsres;
1948 child = unsafe_impl_from_IHTMLElement(pChild);
1949 if(!child) {
1950 ERR("not our element\n");
1951 return E_FAIL;
1954 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1955 assert(nsres == NS_OK);
1958 *pfResult = variant_bool(result);
1959 return S_OK;
1962 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1964 HTMLElement *This = impl_from_IHTMLElement(iface);
1966 TRACE("(%p)->(%p)\n", This, p);
1968 return get_elem_source_index(This, p);
1971 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1973 HTMLElement *This = impl_from_IHTMLElement(iface);
1974 FIXME("(%p)->(%p)\n", This, p);
1975 return E_NOTIMPL;
1978 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1980 HTMLElement *This = impl_from_IHTMLElement(iface);
1981 nsAString nsstr;
1982 nsresult nsres;
1984 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1986 if(!This->html_element) {
1987 FIXME("non-HTML element\n");
1988 return E_NOTIMPL;
1991 nsAString_InitDepend(&nsstr, v);
1992 nsres = nsIDOMHTMLElement_SetLang(This->html_element, &nsstr);
1993 nsAString_Finish(&nsstr);
1994 if(NS_FAILED(nsres)) {
1995 ERR("SetLang failed: %08lx\n", nsres);
1996 return E_FAIL;
1999 return S_OK;
2002 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
2004 HTMLElement *This = impl_from_IHTMLElement(iface);
2005 nsAString nsstr;
2006 nsresult nsres;
2008 TRACE("(%p)->(%p)\n", This, p);
2010 if(!This->html_element) {
2011 FIXME("non-HTML element\n");
2012 return E_NOTIMPL;
2015 nsAString_Init(&nsstr, NULL);
2016 nsres = nsIDOMHTMLElement_GetLang(This->html_element, &nsstr);
2017 return return_nsstr(nsres, &nsstr, p);
2020 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
2022 HTMLElement *This = impl_from_IHTMLElement(iface);
2023 nsresult nsres;
2025 TRACE("(%p)->(%p)\n", This, p);
2027 if(!This->html_element) {
2028 FIXME("non-HTML element\n");
2029 return E_NOTIMPL;
2032 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->html_element, p);
2033 if(NS_FAILED(nsres)) {
2034 ERR("GetOffsetLeft failed: %08lx\n", nsres);
2035 return E_FAIL;
2038 return S_OK;
2041 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
2043 HTMLElement *This = impl_from_IHTMLElement(iface);
2044 nsresult nsres;
2046 TRACE("(%p)->(%p)\n", This, p);
2048 if(!This->html_element) {
2049 FIXME("non-HTML element\n");
2050 return E_NOTIMPL;
2053 nsres = nsIDOMHTMLElement_GetOffsetTop(This->html_element, p);
2054 if(NS_FAILED(nsres)) {
2055 ERR("GetOffsetTop failed: %08lx\n", nsres);
2056 return E_FAIL;
2059 return S_OK;
2062 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
2064 HTMLElement *This = impl_from_IHTMLElement(iface);
2065 nsresult nsres;
2067 TRACE("(%p)->(%p)\n", This, p);
2069 if(!This->html_element) {
2070 FIXME("non-HTML element\n");
2071 return E_NOTIMPL;
2074 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->html_element, p);
2075 if(NS_FAILED(nsres)) {
2076 ERR("GetOffsetWidth failed: %08lx\n", nsres);
2077 return E_FAIL;
2080 return S_OK;
2083 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
2085 HTMLElement *This = impl_from_IHTMLElement(iface);
2086 nsresult nsres;
2088 TRACE("(%p)->(%p)\n", This, p);
2090 if(!This->html_element) {
2091 FIXME("non-HTML element\n");
2092 return E_NOTIMPL;
2095 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->html_element, p);
2096 if(NS_FAILED(nsres)) {
2097 ERR("GetOffsetHeight failed: %08lx\n", nsres);
2098 return E_FAIL;
2101 return S_OK;
2104 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
2106 HTMLElement *This = impl_from_IHTMLElement(iface);
2107 nsIDOMElement *nsparent;
2108 HTMLElement *parent;
2109 nsresult nsres;
2110 HRESULT hres;
2112 TRACE("(%p)->(%p)\n", This, p);
2114 if(!This->html_element) {
2115 FIXME("non-HTML element\n");
2116 return E_NOTIMPL;
2119 nsres = nsIDOMHTMLElement_GetOffsetParent(This->html_element, &nsparent);
2120 if(NS_FAILED(nsres)) {
2121 ERR("GetOffsetParent failed: %08lx\n", nsres);
2122 return E_FAIL;
2125 if(!nsparent) {
2126 *p = NULL;
2127 return S_OK;
2130 hres = get_element(nsparent, &parent);
2131 nsIDOMElement_Release(nsparent);
2132 if(FAILED(hres))
2133 return hres;
2135 *p = &parent->IHTMLElement_iface;
2136 return S_OK;
2139 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
2141 HTMLElement *This = impl_from_IHTMLElement(iface);
2142 nsAString html_str;
2143 nsresult nsres;
2145 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2147 if(!This->html_element) {
2148 FIXME("non-HTML element\n");
2149 return E_NOTIMPL;
2152 nsAString_InitDepend(&html_str, v);
2153 nsres = nsIDOMHTMLElement_SetInnerHTML(This->html_element, &html_str);
2154 nsAString_Finish(&html_str);
2155 if(NS_FAILED(nsres)) {
2156 FIXME("SetInnerHtml failed %08lx\n", nsres);
2157 return E_FAIL;
2160 return S_OK;
2163 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
2165 HTMLElement *This = impl_from_IHTMLElement(iface);
2166 nsAString html_str;
2167 nsresult nsres;
2169 TRACE("(%p)->(%p)\n", This, p);
2171 if(!This->html_element) {
2172 FIXME("non-HTML element\n");
2173 return E_NOTIMPL;
2176 nsAString_Init(&html_str, NULL);
2177 nsres = nsIDOMHTMLElement_GetInnerHTML(This->html_element, &html_str);
2178 return return_nsstr(nsres, &html_str, p);
2181 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
2183 HTMLElement *This = impl_from_IHTMLElement(iface);
2184 nsIDOMNode *nschild, *tmp;
2185 nsIDOMText *text_node;
2186 nsAString text_str;
2187 nsresult nsres;
2189 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2191 while(1) {
2192 nsres = nsIDOMElement_GetLastChild(This->dom_element, &nschild);
2193 if(NS_FAILED(nsres)) {
2194 ERR("GetLastChild failed: %08lx\n", nsres);
2195 return E_FAIL;
2197 if(!nschild)
2198 break;
2200 nsres = nsIDOMElement_RemoveChild(This->dom_element, nschild, &tmp);
2201 nsIDOMNode_Release(nschild);
2202 if(NS_FAILED(nsres)) {
2203 ERR("RemoveChild failed: %08lx\n", nsres);
2204 return E_FAIL;
2206 nsIDOMNode_Release(tmp);
2209 nsAString_InitDepend(&text_str, v);
2210 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
2211 nsAString_Finish(&text_str);
2212 if(NS_FAILED(nsres)) {
2213 ERR("CreateTextNode failed: %08lx\n", nsres);
2214 return E_FAIL;
2217 nsres = nsIDOMElement_AppendChild(This->dom_element, (nsIDOMNode*)text_node, &tmp);
2218 if(NS_FAILED(nsres)) {
2219 ERR("AppendChild failed: %08lx\n", nsres);
2220 return E_FAIL;
2223 nsIDOMNode_Release(tmp);
2224 return S_OK;
2227 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
2229 HTMLElement *This = impl_from_IHTMLElement(iface);
2231 TRACE("(%p)->(%p)\n", This, p);
2233 return get_node_text(&This->node, p);
2236 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
2238 HTMLElement *This = impl_from_IHTMLElement(iface);
2240 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2242 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
2245 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
2247 HTMLElement *This = impl_from_IHTMLElement(iface);
2248 nsAString html_str;
2249 HRESULT hres;
2251 WARN("(%p)->(%p) semi-stub\n", This, p);
2253 nsAString_Init(&html_str, NULL);
2254 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
2255 if(SUCCEEDED(hres)) {
2256 const PRUnichar *html;
2258 nsAString_GetData(&html_str, &html);
2259 *p = SysAllocString(html);
2260 if(!*p)
2261 hres = E_OUTOFMEMORY;
2264 nsAString_Finish(&html_str);
2266 TRACE("ret %s\n", debugstr_w(*p));
2267 return hres;
2270 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
2272 HTMLElement *This = impl_from_IHTMLElement(iface);
2273 nsIDOMText *text_node;
2274 nsIDOMRange *range;
2275 nsAString nsstr;
2276 nsresult nsres;
2278 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2280 if(This->node.vtbl->is_settable && !This->node.vtbl->is_settable(&This->node, DISPID_IHTMLELEMENT_OUTERTEXT)) {
2281 WARN("Called on element that does not support setting the property.\n");
2282 return 0x800a0258; /* undocumented error code */
2285 if(!This->node.doc->nsdoc) {
2286 FIXME("NULL nsdoc\n");
2287 return E_FAIL;
2290 nsAString_InitDepend(&nsstr, v);
2291 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &nsstr, &text_node);
2292 nsAString_Finish(&nsstr);
2293 if(NS_FAILED(nsres)) {
2294 ERR("CreateTextNode failed\n");
2295 return E_FAIL;
2298 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
2299 if(NS_SUCCEEDED(nsres)) {
2300 nsres = nsIDOMRange_SelectNode(range, This->node.nsnode);
2301 if(NS_SUCCEEDED(nsres))
2302 nsres = nsIDOMRange_DeleteContents(range);
2303 if(NS_SUCCEEDED(nsres))
2304 nsres = nsIDOMRange_InsertNode(range, (nsIDOMNode*)text_node);
2305 if(NS_SUCCEEDED(nsres))
2306 nsres = nsIDOMRange_SelectNodeContents(range, This->node.nsnode);
2307 if(NS_SUCCEEDED(nsres))
2308 nsres = nsIDOMRange_DeleteContents(range);
2309 nsIDOMRange_Release(range);
2311 nsIDOMText_Release(text_node);
2312 if(NS_FAILED(nsres)) {
2313 ERR("failed to set text: %08lx\n", nsres);
2314 return E_FAIL;
2317 return S_OK;
2320 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
2322 HTMLElement *This = impl_from_IHTMLElement(iface);
2324 TRACE("(%p)->(%p)\n", This, p);
2326 /* getter is the same as innerText */
2327 return IHTMLElement_get_innerText(&This->IHTMLElement_iface, p);
2330 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
2332 nsIDOMNode *ret_nsnode;
2333 nsresult nsres;
2334 HRESULT hres = S_OK;
2336 if (!wcsicmp(where, L"beforebegin")) {
2337 nsIDOMNode *parent;
2339 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2340 if(NS_FAILED(nsres))
2341 return E_FAIL;
2343 if(!parent)
2344 return E_INVALIDARG;
2346 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
2347 nsIDOMNode_Release(parent);
2348 }else if(!wcsicmp(where, L"afterbegin")) {
2349 nsIDOMNode *first_child;
2351 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
2352 if(NS_FAILED(nsres))
2353 return E_FAIL;
2355 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
2356 if(NS_FAILED(nsres))
2357 return E_FAIL;
2359 if (first_child)
2360 nsIDOMNode_Release(first_child);
2361 }else if (!wcsicmp(where, L"beforeend")) {
2362 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
2363 }else if (!wcsicmp(where, L"afterend")) {
2364 nsIDOMNode *next_sibling, *parent;
2366 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2367 if(NS_FAILED(nsres))
2368 return E_FAIL;
2369 if(!parent)
2370 return E_INVALIDARG;
2372 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
2373 if(NS_SUCCEEDED(nsres)) {
2374 if(next_sibling) {
2375 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
2376 nsIDOMNode_Release(next_sibling);
2377 }else {
2378 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
2382 nsIDOMNode_Release(parent);
2383 }else {
2384 ERR("invalid where: %s\n", debugstr_w(where));
2385 return E_INVALIDARG;
2388 if (NS_FAILED(nsres))
2389 return E_FAIL;
2391 if(ret_node)
2392 hres = get_node(ret_nsnode, TRUE, ret_node);
2393 nsIDOMNode_Release(ret_nsnode);
2394 return hres;
2397 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
2398 BSTR html)
2400 HTMLElement *This = impl_from_IHTMLElement(iface);
2401 nsIDOMRange *range;
2402 nsIDOMNode *nsnode;
2403 nsAString ns_html;
2404 nsresult nsres;
2405 HRESULT hr;
2407 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
2409 if(!This->node.doc->nsdoc) {
2410 WARN("NULL nsdoc\n");
2411 return E_UNEXPECTED;
2414 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
2415 if(NS_FAILED(nsres))
2417 ERR("CreateRange failed: %08lx\n", nsres);
2418 return E_FAIL;
2421 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
2423 nsAString_InitDepend(&ns_html, html);
2424 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
2425 nsAString_Finish(&ns_html);
2426 nsIDOMRange_Release(range);
2428 if(NS_FAILED(nsres) || !nsnode)
2430 ERR("CreateTextNode failed: %08lx\n", nsres);
2431 return E_FAIL;
2434 hr = insert_adjacent_node(This, where, nsnode, NULL);
2435 nsIDOMNode_Release(nsnode);
2436 return hr;
2439 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
2440 BSTR text)
2442 HTMLElement *This = impl_from_IHTMLElement(iface);
2443 nsIDOMNode *nsnode;
2444 nsAString ns_text;
2445 nsresult nsres;
2446 HRESULT hr;
2448 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
2450 if(!This->node.doc->nsdoc) {
2451 WARN("NULL nsdoc\n");
2452 return E_UNEXPECTED;
2456 nsAString_InitDepend(&ns_text, text);
2457 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
2458 nsAString_Finish(&ns_text);
2460 if(NS_FAILED(nsres) || !nsnode)
2462 ERR("CreateTextNode failed: %08lx\n", nsres);
2463 return E_FAIL;
2466 hr = insert_adjacent_node(This, where, nsnode, NULL);
2467 nsIDOMNode_Release(nsnode);
2469 return hr;
2472 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
2474 HTMLElement *This = impl_from_IHTMLElement(iface);
2475 FIXME("(%p)->(%p)\n", This, p);
2476 return E_NOTIMPL;
2479 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
2481 HTMLElement *This = impl_from_IHTMLElement(iface);
2483 TRACE("(%p)->(%p)\n", This, p);
2485 *p = variant_bool(This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node));
2486 return S_OK;
2489 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
2491 HTMLElement *This = impl_from_IHTMLElement(iface);
2492 nsresult nsres;
2494 TRACE("(%p)\n", This);
2496 if(!This->html_element) {
2497 FIXME("non-HTML element\n");
2498 return E_NOTIMPL;
2501 nsres = nsIDOMHTMLElement_Click(This->html_element);
2502 if(NS_FAILED(nsres)) {
2503 ERR("Click failed: %08lx\n", nsres);
2504 return E_FAIL;
2507 return S_OK;
2510 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface, IHTMLFiltersCollection **p)
2512 HTMLElement *This = impl_from_IHTMLElement(iface);
2514 TRACE("(%p)->(%p)\n", This, p);
2516 if(!p)
2517 return E_POINTER;
2519 return create_filters_collection(dispex_compat_mode(&This->node.event_target.dispex), p);
2522 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
2524 HTMLElement *This = impl_from_IHTMLElement(iface);
2526 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2528 return set_node_event(&This->node, EVENTID_DRAGSTART, &v);
2531 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
2533 HTMLElement *This = impl_from_IHTMLElement(iface);
2535 TRACE("(%p)->(%p)\n", This, p);
2537 return get_node_event(&This->node, EVENTID_DRAGSTART, p);
2540 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
2542 HTMLElement *This = impl_from_IHTMLElement(iface);
2543 HRESULT hres;
2544 VARIANT var;
2546 TRACE("(%p)->(%p)\n", This, String);
2548 if(!String)
2549 return E_INVALIDARG;
2551 hres = IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, DISPID_VALUE,
2552 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, NULL, &var, NULL, NULL);
2553 if(SUCCEEDED(hres)) {
2554 assert(V_VT(&var) == VT_BSTR);
2555 *String = V_BSTR(&var);
2557 return hres;
2560 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
2562 HTMLElement *This = impl_from_IHTMLElement(iface);
2563 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2564 return E_NOTIMPL;
2567 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
2569 HTMLElement *This = impl_from_IHTMLElement(iface);
2570 FIXME("(%p)->(%p)\n", This, p);
2571 return E_NOTIMPL;
2574 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
2576 HTMLElement *This = impl_from_IHTMLElement(iface);
2577 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2578 return E_NOTIMPL;
2581 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
2583 HTMLElement *This = impl_from_IHTMLElement(iface);
2584 FIXME("(%p)->(%p)\n", This, p);
2585 return E_NOTIMPL;
2588 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
2590 HTMLElement *This = impl_from_IHTMLElement(iface);
2591 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2592 return E_NOTIMPL;
2595 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
2597 HTMLElement *This = impl_from_IHTMLElement(iface);
2598 FIXME("(%p)->(%p)\n", This, p);
2599 return E_NOTIMPL;
2602 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
2604 HTMLElement *This = impl_from_IHTMLElement(iface);
2605 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2606 return E_NOTIMPL;
2609 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
2611 HTMLElement *This = impl_from_IHTMLElement(iface);
2612 FIXME("(%p)->(%p)\n", This, p);
2613 return E_NOTIMPL;
2616 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
2618 HTMLElement *This = impl_from_IHTMLElement(iface);
2619 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2620 return E_NOTIMPL;
2623 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
2625 HTMLElement *This = impl_from_IHTMLElement(iface);
2626 FIXME("(%p)->(%p)\n", This, p);
2627 return E_NOTIMPL;
2630 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
2632 HTMLElement *This = impl_from_IHTMLElement(iface);
2633 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2634 return E_NOTIMPL;
2637 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
2639 HTMLElement *This = impl_from_IHTMLElement(iface);
2640 FIXME("(%p)->(%p)\n", This, p);
2641 return E_NOTIMPL;
2644 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
2646 HTMLElement *This = impl_from_IHTMLElement(iface);
2648 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
2650 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
2653 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
2655 HTMLElement *This = impl_from_IHTMLElement(iface);
2657 TRACE("(%p)->(%p)\n", This, p);
2659 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
2662 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
2664 HTMLElement *This = impl_from_IHTMLElement(iface);
2665 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2666 return E_NOTIMPL;
2669 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
2671 HTMLElement *This = impl_from_IHTMLElement(iface);
2672 FIXME("(%p)->(%p)\n", This, p);
2673 return E_NOTIMPL;
2676 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
2678 HTMLElement *This = impl_from_IHTMLElement(iface);
2679 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2680 return E_NOTIMPL;
2683 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
2685 HTMLElement *This = impl_from_IHTMLElement(iface);
2686 FIXME("(%p)->(%p)\n", This, p);
2687 return E_NOTIMPL;
2690 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
2692 HTMLElement *This = impl_from_IHTMLElement(iface);
2693 nsIDOMNodeList *nsnode_list;
2694 nsresult nsres;
2696 TRACE("(%p)->(%p)\n", This, p);
2698 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
2699 if(NS_FAILED(nsres)) {
2700 ERR("GetChildNodes failed: %08lx\n", nsres);
2701 return E_FAIL;
2704 *p = (IDispatch*)create_collection_from_nodelist(nsnode_list, This->node.doc->document_mode);
2706 nsIDOMNodeList_Release(nsnode_list);
2707 return S_OK;
2710 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
2712 HTMLElement *This = impl_from_IHTMLElement(iface);
2714 TRACE("(%p)->(%p)\n", This, p);
2716 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
2717 return S_OK;
2720 static const IHTMLElementVtbl HTMLElementVtbl = {
2721 HTMLElement_QueryInterface,
2722 HTMLElement_AddRef,
2723 HTMLElement_Release,
2724 HTMLElement_GetTypeInfoCount,
2725 HTMLElement_GetTypeInfo,
2726 HTMLElement_GetIDsOfNames,
2727 HTMLElement_Invoke,
2728 HTMLElement_setAttribute,
2729 HTMLElement_getAttribute,
2730 HTMLElement_removeAttribute,
2731 HTMLElement_put_className,
2732 HTMLElement_get_className,
2733 HTMLElement_put_id,
2734 HTMLElement_get_id,
2735 HTMLElement_get_tagName,
2736 HTMLElement_get_parentElement,
2737 HTMLElement_get_style,
2738 HTMLElement_put_onhelp,
2739 HTMLElement_get_onhelp,
2740 HTMLElement_put_onclick,
2741 HTMLElement_get_onclick,
2742 HTMLElement_put_ondblclick,
2743 HTMLElement_get_ondblclick,
2744 HTMLElement_put_onkeydown,
2745 HTMLElement_get_onkeydown,
2746 HTMLElement_put_onkeyup,
2747 HTMLElement_get_onkeyup,
2748 HTMLElement_put_onkeypress,
2749 HTMLElement_get_onkeypress,
2750 HTMLElement_put_onmouseout,
2751 HTMLElement_get_onmouseout,
2752 HTMLElement_put_onmouseover,
2753 HTMLElement_get_onmouseover,
2754 HTMLElement_put_onmousemove,
2755 HTMLElement_get_onmousemove,
2756 HTMLElement_put_onmousedown,
2757 HTMLElement_get_onmousedown,
2758 HTMLElement_put_onmouseup,
2759 HTMLElement_get_onmouseup,
2760 HTMLElement_get_document,
2761 HTMLElement_put_title,
2762 HTMLElement_get_title,
2763 HTMLElement_put_language,
2764 HTMLElement_get_language,
2765 HTMLElement_put_onselectstart,
2766 HTMLElement_get_onselectstart,
2767 HTMLElement_scrollIntoView,
2768 HTMLElement_contains,
2769 HTMLElement_get_sourceIndex,
2770 HTMLElement_get_recordNumber,
2771 HTMLElement_put_lang,
2772 HTMLElement_get_lang,
2773 HTMLElement_get_offsetLeft,
2774 HTMLElement_get_offsetTop,
2775 HTMLElement_get_offsetWidth,
2776 HTMLElement_get_offsetHeight,
2777 HTMLElement_get_offsetParent,
2778 HTMLElement_put_innerHTML,
2779 HTMLElement_get_innerHTML,
2780 HTMLElement_put_innerText,
2781 HTMLElement_get_innerText,
2782 HTMLElement_put_outerHTML,
2783 HTMLElement_get_outerHTML,
2784 HTMLElement_put_outerText,
2785 HTMLElement_get_outerText,
2786 HTMLElement_insertAdjacentHTML,
2787 HTMLElement_insertAdjacentText,
2788 HTMLElement_get_parentTextEdit,
2789 HTMLElement_get_isTextEdit,
2790 HTMLElement_click,
2791 HTMLElement_get_filters,
2792 HTMLElement_put_ondragstart,
2793 HTMLElement_get_ondragstart,
2794 HTMLElement_toString,
2795 HTMLElement_put_onbeforeupdate,
2796 HTMLElement_get_onbeforeupdate,
2797 HTMLElement_put_onafterupdate,
2798 HTMLElement_get_onafterupdate,
2799 HTMLElement_put_onerrorupdate,
2800 HTMLElement_get_onerrorupdate,
2801 HTMLElement_put_onrowexit,
2802 HTMLElement_get_onrowexit,
2803 HTMLElement_put_onrowenter,
2804 HTMLElement_get_onrowenter,
2805 HTMLElement_put_ondatasetchanged,
2806 HTMLElement_get_ondatasetchanged,
2807 HTMLElement_put_ondataavailable,
2808 HTMLElement_get_ondataavailable,
2809 HTMLElement_put_ondatasetcomplete,
2810 HTMLElement_get_ondatasetcomplete,
2811 HTMLElement_put_onfilterchange,
2812 HTMLElement_get_onfilterchange,
2813 HTMLElement_get_children,
2814 HTMLElement_get_all
2817 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2819 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2822 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2824 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2827 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
2828 REFIID riid, void **ppv)
2830 HTMLElement *This = impl_from_IHTMLElement2(iface);
2831 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2834 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2836 HTMLElement *This = impl_from_IHTMLElement2(iface);
2837 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2840 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2842 HTMLElement *This = impl_from_IHTMLElement2(iface);
2843 return IHTMLElement_Release(&This->IHTMLElement_iface);
2846 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2848 HTMLElement *This = impl_from_IHTMLElement2(iface);
2849 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2852 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2853 LCID lcid, ITypeInfo **ppTInfo)
2855 HTMLElement *This = impl_from_IHTMLElement2(iface);
2856 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2859 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2860 LPOLESTR *rgszNames, UINT cNames,
2861 LCID lcid, DISPID *rgDispId)
2863 HTMLElement *This = impl_from_IHTMLElement2(iface);
2864 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2865 lcid, rgDispId);
2868 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2869 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2870 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2872 HTMLElement *This = impl_from_IHTMLElement2(iface);
2873 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2874 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2877 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2879 HTMLElement *This = impl_from_IHTMLElement2(iface);
2880 FIXME("(%p)->(%p)\n", This, p);
2881 return E_NOTIMPL;
2884 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2886 HTMLElement *This = impl_from_IHTMLElement2(iface);
2887 FIXME("(%p)->(%x)\n", This, containerCapture);
2888 return E_NOTIMPL;
2891 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2893 HTMLElement *This = impl_from_IHTMLElement2(iface);
2894 FIXME("(%p)\n", This);
2895 return E_NOTIMPL;
2898 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2900 HTMLElement *This = impl_from_IHTMLElement2(iface);
2901 FIXME("(%p)->()\n", This);
2902 return E_NOTIMPL;
2905 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2907 HTMLElement *This = impl_from_IHTMLElement2(iface);
2908 FIXME("(%p)->(%p)\n", This, p);
2909 return E_NOTIMPL;
2912 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2913 LONG x, LONG y, BSTR *component)
2915 HTMLElement *This = impl_from_IHTMLElement2(iface);
2916 FIXME("(%p)->(%ld %ld %p)\n", This, x, y, component);
2917 return E_NOTIMPL;
2920 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2922 HTMLElement *This = impl_from_IHTMLElement2(iface);
2924 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2926 if(!This->node.doc->content_ready
2927 || !This->node.doc->basedoc.doc_obj->in_place_active)
2928 return E_PENDING;
2930 WARN("stub\n");
2931 return S_OK;
2934 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2936 HTMLElement *This = impl_from_IHTMLElement2(iface);
2938 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2940 return set_node_event(&This->node, EVENTID_SCROLL, &v);
2943 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2945 HTMLElement *This = impl_from_IHTMLElement2(iface);
2947 TRACE("(%p)->(%p)\n", This, p);
2949 return get_node_event(&This->node, EVENTID_SCROLL, p);
2952 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2954 HTMLElement *This = impl_from_IHTMLElement2(iface);
2956 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2958 return set_node_event(&This->node, EVENTID_DRAG, &v);
2961 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2963 HTMLElement *This = impl_from_IHTMLElement2(iface);
2965 TRACE("(%p)->(%p)\n", This, p);
2967 return get_node_event(&This->node, EVENTID_DRAG, p);
2970 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2972 HTMLElement *This = impl_from_IHTMLElement2(iface);
2973 FIXME("(%p)->()\n", This);
2974 return E_NOTIMPL;
2977 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2979 HTMLElement *This = impl_from_IHTMLElement2(iface);
2980 FIXME("(%p)->(%p)\n", This, p);
2981 return E_NOTIMPL;
2984 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2986 HTMLElement *This = impl_from_IHTMLElement2(iface);
2987 FIXME("(%p)->()\n", This);
2988 return E_NOTIMPL;
2991 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2993 HTMLElement *This = impl_from_IHTMLElement2(iface);
2994 FIXME("(%p)->(%p)\n", This, p);
2995 return E_NOTIMPL;
2998 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
3000 HTMLElement *This = impl_from_IHTMLElement2(iface);
3001 FIXME("(%p)->()\n", This);
3002 return E_NOTIMPL;
3005 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
3007 HTMLElement *This = impl_from_IHTMLElement2(iface);
3008 FIXME("(%p)->(%p)\n", This, p);
3009 return E_NOTIMPL;
3012 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
3014 HTMLElement *This = impl_from_IHTMLElement2(iface);
3015 FIXME("(%p)->()\n", This);
3016 return E_NOTIMPL;
3019 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
3021 HTMLElement *This = impl_from_IHTMLElement2(iface);
3022 FIXME("(%p)->(%p)\n", This, p);
3023 return E_NOTIMPL;
3026 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
3028 HTMLElement *This = impl_from_IHTMLElement2(iface);
3029 FIXME("(%p)->()\n", This);
3030 return E_NOTIMPL;
3033 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
3035 HTMLElement *This = impl_from_IHTMLElement2(iface);
3036 FIXME("(%p)->(%p)\n", This, p);
3037 return E_NOTIMPL;
3040 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
3042 HTMLElement *This = impl_from_IHTMLElement2(iface);
3043 FIXME("(%p)->()\n", This);
3044 return E_NOTIMPL;
3047 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
3049 HTMLElement *This = impl_from_IHTMLElement2(iface);
3050 FIXME("(%p)->(%p)\n", This, p);
3051 return E_NOTIMPL;
3054 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
3056 HTMLElement *This = impl_from_IHTMLElement2(iface);
3057 FIXME("(%p)->()\n", This);
3058 return E_NOTIMPL;
3061 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
3063 HTMLElement *This = impl_from_IHTMLElement2(iface);
3064 FIXME("(%p)->(%p)\n", This, p);
3065 return E_NOTIMPL;
3068 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
3070 HTMLElement *This = impl_from_IHTMLElement2(iface);
3071 FIXME("(%p)->()\n", This);
3072 return E_NOTIMPL;
3075 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
3077 HTMLElement *This = impl_from_IHTMLElement2(iface);
3078 FIXME("(%p)->(%p)\n", This, p);
3079 return E_NOTIMPL;
3082 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
3084 HTMLElement *This = impl_from_IHTMLElement2(iface);
3085 FIXME("(%p)->()\n", This);
3086 return E_NOTIMPL;
3089 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
3091 HTMLElement *This = impl_from_IHTMLElement2(iface);
3092 FIXME("(%p)->(%p)\n", This, p);
3093 return E_NOTIMPL;
3096 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
3098 HTMLElement *This = impl_from_IHTMLElement2(iface);
3099 FIXME("(%p)->()\n", This);
3100 return E_NOTIMPL;
3103 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
3105 HTMLElement *This = impl_from_IHTMLElement2(iface);
3106 FIXME("(%p)->(%p)\n", This, p);
3107 return E_NOTIMPL;
3110 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
3112 HTMLElement *This = impl_from_IHTMLElement2(iface);
3114 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3116 return set_node_event(&This->node, EVENTID_PASTE, &v);
3119 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
3121 HTMLElement *This = impl_from_IHTMLElement2(iface);
3123 TRACE("(%p)->(%p)\n", This, p);
3125 return get_node_event(&This->node, EVENTID_PASTE, p);
3128 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
3130 HTMLElement *This = impl_from_IHTMLElement2(iface);
3132 TRACE("(%p)->(%p)\n", This, p);
3134 return HTMLCurrentStyle_Create(This, p);
3137 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
3139 HTMLElement *This = impl_from_IHTMLElement2(iface);
3140 FIXME("(%p)->()\n", This);
3141 return E_NOTIMPL;
3144 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
3146 HTMLElement *This = impl_from_IHTMLElement2(iface);
3147 FIXME("(%p)->(%p)\n", This, p);
3148 return E_NOTIMPL;
3151 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
3153 HTMLElement *This = impl_from_IHTMLElement2(iface);
3154 nsIDOMClientRectList *rect_list;
3155 HTMLRectCollection *rects;
3156 nsresult nsres;
3158 TRACE("(%p)->(%p)\n", This, pRectCol);
3160 if(!This->dom_element) {
3161 FIXME("comment element\n");
3162 return E_NOTIMPL;
3165 nsres = nsIDOMElement_GetClientRects(This->dom_element, &rect_list);
3166 if(NS_FAILED(nsres)) {
3167 WARN("GetClientRects failed: %08lx\n", nsres);
3168 return map_nsresult(nsres);
3171 rects = heap_alloc_zero(sizeof(*rects));
3172 if(!rects) {
3173 nsIDOMClientRectList_Release(rect_list);
3174 return E_OUTOFMEMORY;
3177 rects->IHTMLRectCollection_iface.lpVtbl = &HTMLRectCollectionVtbl;
3178 rects->ref = 1;
3179 rects->rect_list = rect_list;
3180 init_dispatch(&rects->dispex, (IUnknown*)&rects->IHTMLRectCollection_iface,
3181 &HTMLRectCollection_dispex, dispex_compat_mode(&This->node.event_target.dispex));
3183 *pRectCol = &rects->IHTMLRectCollection_iface;
3184 return S_OK;
3187 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
3189 HTMLElement *This = impl_from_IHTMLElement2(iface);
3190 nsIDOMClientRect *nsrect;
3191 nsresult nsres;
3192 HRESULT hres;
3194 TRACE("(%p)->(%p)\n", This, pRect);
3196 if(!This->dom_element) {
3197 FIXME("comment element\n");
3198 return E_NOTIMPL;
3201 nsres = nsIDOMElement_GetBoundingClientRect(This->dom_element, &nsrect);
3202 if(NS_FAILED(nsres) || !nsrect) {
3203 ERR("GetBoindingClientRect failed: %08lx\n", nsres);
3204 return E_FAIL;
3207 hres = create_html_rect(nsrect, dispex_compat_mode(&This->node.event_target.dispex), pRect);
3209 nsIDOMClientRect_Release(nsrect);
3210 return hres;
3213 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
3214 BSTR expression, BSTR language)
3216 HTMLElement *This = impl_from_IHTMLElement2(iface);
3217 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
3218 debugstr_w(language));
3219 return E_NOTIMPL;
3222 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
3223 VARIANT *expression)
3225 HTMLElement *This = impl_from_IHTMLElement2(iface);
3226 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
3227 return E_NOTIMPL;
3230 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
3231 VARIANT_BOOL *pfSuccess)
3233 HTMLElement *This = impl_from_IHTMLElement2(iface);
3234 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
3235 return E_NOTIMPL;
3238 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
3240 HTMLElement *This = impl_from_IHTMLElement2(iface);
3241 nsresult nsres;
3243 TRACE("(%p)->(%d)\n", This, v);
3245 if(!This->html_element) {
3246 FIXME("non-HTML element\n");
3247 return E_NOTIMPL;
3250 nsres = nsIDOMHTMLElement_SetTabIndex(This->html_element, v);
3251 if(NS_FAILED(nsres))
3252 ERR("GetTabIndex failed: %08lx\n", nsres);
3254 return S_OK;
3257 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
3259 HTMLElement *This = impl_from_IHTMLElement2(iface);
3260 LONG index;
3261 nsresult nsres;
3263 TRACE("(%p)->(%p)\n", This, p);
3265 if(!This->html_element) {
3266 FIXME("non-HTML element\n");
3267 return E_NOTIMPL;
3270 nsres = nsIDOMHTMLElement_GetTabIndex(This->html_element, &index);
3271 if(NS_FAILED(nsres)) {
3272 ERR("GetTabIndex failed: %08lx\n", nsres);
3273 return E_FAIL;
3276 *p = index;
3277 return S_OK;
3280 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
3282 HTMLElement *This = impl_from_IHTMLElement2(iface);
3283 nsresult nsres;
3285 TRACE("(%p)\n", This);
3287 if(!This->html_element) {
3288 FIXME("non-HTML element\n");
3289 return E_NOTIMPL;
3292 nsres = nsIDOMHTMLElement_Focus(This->html_element);
3293 if(NS_FAILED(nsres))
3294 ERR("Focus failed: %08lx\n", nsres);
3296 return S_OK;
3299 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
3301 HTMLElement *This = impl_from_IHTMLElement2(iface);
3302 nsAString nsstr;
3303 nsresult nsres;
3305 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3307 if(!This->html_element) {
3308 FIXME("non-HTML element\n");
3309 return E_NOTIMPL;
3312 nsAString_InitDepend(&nsstr, v);
3313 nsres = nsIDOMHTMLElement_SetAccessKey(This->html_element, &nsstr);
3314 nsAString_Finish(&nsstr);
3315 return map_nsresult(nsres);
3318 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
3320 HTMLElement *This = impl_from_IHTMLElement2(iface);
3321 nsAString nsstr;
3322 nsresult nsres;
3324 TRACE("(%p)->(%p)\n", This, p);
3326 if(!This->html_element) {
3327 FIXME("non-HTML element\n");
3328 return E_NOTIMPL;
3331 nsAString_InitDepend(&nsstr, NULL);
3332 nsres = nsIDOMHTMLElement_GetAccessKey(This->html_element, &nsstr);
3333 return return_nsstr(nsres, &nsstr, p);
3336 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
3338 HTMLElement *This = impl_from_IHTMLElement2(iface);
3340 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3342 return set_node_event(&This->node, EVENTID_BLUR, &v);
3345 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
3347 HTMLElement *This = impl_from_IHTMLElement2(iface);
3349 TRACE("(%p)->(%p)\n", This, p);
3351 return get_node_event(&This->node, EVENTID_BLUR, p);
3354 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
3356 HTMLElement *This = impl_from_IHTMLElement2(iface);
3358 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3360 return set_node_event(&This->node, EVENTID_FOCUS, &v);
3363 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
3365 HTMLElement *This = impl_from_IHTMLElement2(iface);
3367 TRACE("(%p)->(%p)\n", This, p);
3369 return get_node_event(&This->node, EVENTID_FOCUS, p);
3372 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
3374 HTMLElement *This = impl_from_IHTMLElement2(iface);
3376 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3378 return set_node_event(&This->node, EVENTID_RESIZE, &v);
3381 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
3383 HTMLElement *This = impl_from_IHTMLElement2(iface);
3385 TRACE("(%p)->(%p)\n", This, p);
3387 return get_node_event(&This->node, EVENTID_RESIZE, p);
3390 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
3392 HTMLElement *This = impl_from_IHTMLElement2(iface);
3393 nsresult nsres;
3395 TRACE("(%p)\n", This);
3397 if(!This->html_element) {
3398 FIXME("non-HTML element\n");
3399 return E_NOTIMPL;
3402 nsres = nsIDOMHTMLElement_Blur(This->html_element);
3403 if(NS_FAILED(nsres)) {
3404 ERR("Blur failed: %08lx\n", nsres);
3405 return E_FAIL;
3408 return S_OK;
3411 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3413 HTMLElement *This = impl_from_IHTMLElement2(iface);
3414 FIXME("(%p)->(%p)\n", This, pUnk);
3415 return E_NOTIMPL;
3418 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3420 HTMLElement *This = impl_from_IHTMLElement2(iface);
3421 FIXME("(%p)->(%p)\n", This, pUnk);
3422 return E_NOTIMPL;
3425 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
3427 HTMLElement *This = impl_from_IHTMLElement2(iface);
3428 nsresult nsres;
3430 TRACE("(%p)->(%p)\n", This, p);
3432 if(!This->dom_element) {
3433 FIXME("Unimplemented for comment element\n");
3434 return E_NOTIMPL;
3437 nsres = nsIDOMElement_GetClientHeight(This->dom_element, p);
3438 assert(nsres == NS_OK);
3439 return S_OK;
3442 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
3444 HTMLElement *This = impl_from_IHTMLElement2(iface);
3445 nsresult nsres;
3447 TRACE("(%p)->(%p)\n", This, p);
3449 if(!This->dom_element) {
3450 FIXME("comment element\n");
3451 return E_NOTIMPL;
3454 nsres = nsIDOMElement_GetClientWidth(This->dom_element, p);
3455 assert(nsres == NS_OK);
3456 return S_OK;
3459 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
3461 HTMLElement *This = impl_from_IHTMLElement2(iface);
3462 nsresult nsres;
3464 TRACE("(%p)->(%p)\n", This, p);
3466 if(!This->dom_element) {
3467 FIXME("comment element\n");
3468 return E_NOTIMPL;
3471 nsres = nsIDOMElement_GetClientTop(This->dom_element, p);
3472 assert(nsres == NS_OK);
3474 TRACE("*p = %ld\n", *p);
3475 return S_OK;
3478 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
3480 HTMLElement *This = impl_from_IHTMLElement2(iface);
3481 nsresult nsres;
3483 TRACE("(%p)->(%p)\n", This, p);
3485 if(!This->dom_element) {
3486 FIXME("comment element\n");
3487 return E_NOTIMPL;
3490 nsres = nsIDOMElement_GetClientLeft(This->dom_element, p);
3491 assert(nsres == NS_OK);
3493 TRACE("*p = %ld\n", *p);
3494 return S_OK;
3497 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
3498 IDispatch *pDisp, VARIANT_BOOL *pfResult)
3500 HTMLElement *This = impl_from_IHTMLElement2(iface);
3502 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
3504 return attach_event(&This->node.event_target, event, pDisp, pfResult);
3507 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
3509 HTMLElement *This = impl_from_IHTMLElement2(iface);
3511 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
3513 return detach_event(&This->node.event_target, event, pDisp);
3516 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
3518 HTMLElement *This = impl_from_IHTMLElement2(iface);
3519 BSTR str;
3521 TRACE("(%p)->(%p)\n", This, p);
3523 if(This->node.vtbl->get_readystate) {
3524 HRESULT hres;
3526 hres = This->node.vtbl->get_readystate(&This->node, &str);
3527 if(FAILED(hres))
3528 return hres;
3529 }else {
3530 str = SysAllocString(L"complete");
3531 if(!str)
3532 return E_OUTOFMEMORY;
3535 V_VT(p) = VT_BSTR;
3536 V_BSTR(p) = str;
3537 return S_OK;
3540 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
3542 HTMLElement *This = impl_from_IHTMLElement2(iface);
3544 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3546 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
3549 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
3551 HTMLElement *This = impl_from_IHTMLElement2(iface);
3553 TRACE("(%p)->(%p)\n", This, p);
3555 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
3558 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
3560 HTMLElement *This = impl_from_IHTMLElement2(iface);
3561 FIXME("(%p)->()\n", This);
3562 return E_NOTIMPL;
3565 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
3567 HTMLElement *This = impl_from_IHTMLElement2(iface);
3568 FIXME("(%p)->(%p)\n", This, p);
3569 return E_NOTIMPL;
3572 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
3574 HTMLElement *This = impl_from_IHTMLElement2(iface);
3575 FIXME("(%p)->()\n", This);
3576 return E_NOTIMPL;
3579 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
3581 HTMLElement *This = impl_from_IHTMLElement2(iface);
3582 FIXME("(%p)->(%p)\n", This, p);
3583 return E_NOTIMPL;
3586 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
3588 HTMLElement *This = impl_from_IHTMLElement2(iface);
3589 FIXME("(%p)->()\n", This);
3590 return E_NOTIMPL;
3593 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
3595 HTMLElement *This = impl_from_IHTMLElement2(iface);
3596 FIXME("(%p)->(%p)\n", This, p);
3597 return E_NOTIMPL;
3600 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
3602 HTMLElement *This = impl_from_IHTMLElement2(iface);
3603 nsAString nsstr;
3604 nsresult nsres;
3606 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3608 if(!This->html_element) {
3609 FIXME("non-HTML element\n");
3610 return S_OK;
3613 nsAString_InitDepend(&nsstr, v);
3614 nsres = nsIDOMHTMLElement_SetDir(This->html_element, &nsstr);
3615 nsAString_Finish(&nsstr);
3616 if(NS_FAILED(nsres)) {
3617 ERR("SetDir failed: %08lx\n", nsres);
3618 return E_FAIL;
3621 return S_OK;
3624 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
3626 HTMLElement *This = impl_from_IHTMLElement2(iface);
3627 nsAString dir_str;
3628 nsresult nsres;
3630 TRACE("(%p)->(%p)\n", This, p);
3632 if(!This->html_element) {
3633 if(This->dom_element)
3634 FIXME("non-HTML element\n");
3635 *p = NULL;
3636 return S_OK;
3639 nsAString_Init(&dir_str, NULL);
3640 nsres = nsIDOMHTMLElement_GetDir(This->html_element, &dir_str);
3641 return return_nsstr(nsres, &dir_str, p);
3644 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
3646 HTMLElement *This = impl_from_IHTMLElement2(iface);
3647 FIXME("(%p)->(%p)\n", This, range);
3648 return E_NOTIMPL;
3651 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
3653 HTMLElement *This = impl_from_IHTMLElement2(iface);
3654 nsresult nsres;
3656 TRACE("(%p)->(%p)\n", This, p);
3658 if(!This->dom_element) {
3659 FIXME("comment element\n");
3660 return E_NOTIMPL;
3663 nsres = nsIDOMElement_GetScrollHeight(This->dom_element, p);
3664 assert(nsres == NS_OK);
3665 TRACE("*p = %ld\n", *p);
3666 return S_OK;
3669 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
3671 HTMLElement *This = impl_from_IHTMLElement2(iface);
3672 nsresult nsres;
3674 TRACE("(%p)->(%p)\n", This, p);
3676 if(!This->dom_element) {
3677 FIXME("comment element\n");
3678 return E_NOTIMPL;
3681 nsres = nsIDOMElement_GetScrollWidth(This->dom_element, p);
3682 assert(nsres == NS_OK);
3684 TRACE("*p = %ld\n", *p);
3685 return S_OK;
3688 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
3690 HTMLElement *This = impl_from_IHTMLElement2(iface);
3692 TRACE("(%p)->(%ld)\n", This, v);
3694 if(!This->dom_element) {
3695 FIXME("comment element\n");
3696 return E_NOTIMPL;
3699 nsIDOMElement_SetScrollTop(This->dom_element, v);
3700 return S_OK;
3703 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
3705 HTMLElement *This = impl_from_IHTMLElement2(iface);
3706 nsresult nsres;
3708 TRACE("(%p)->(%p)\n", This, p);
3710 if(!This->dom_element) {
3711 FIXME("comment element\n");
3712 return E_NOTIMPL;
3715 nsres = nsIDOMElement_GetScrollTop(This->dom_element, p);
3716 assert(nsres == NS_OK);
3718 TRACE("*p = %ld\n", *p);
3719 return S_OK;
3722 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
3724 HTMLElement *This = impl_from_IHTMLElement2(iface);
3726 TRACE("(%p)->(%ld)\n", This, v);
3728 if(!This->dom_element) {
3729 FIXME("comment element\n");
3730 return E_NOTIMPL;
3733 nsIDOMElement_SetScrollLeft(This->dom_element, v);
3734 return S_OK;
3737 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
3739 HTMLElement *This = impl_from_IHTMLElement2(iface);
3740 nsresult nsres;
3742 TRACE("(%p)->(%p)\n", This, p);
3744 if(!p)
3745 return E_INVALIDARG;
3747 if(!This->dom_element) {
3748 FIXME("comment element\n");
3749 return E_NOTIMPL;
3752 nsres = nsIDOMElement_GetScrollLeft(This->dom_element, p);
3753 assert(nsres == NS_OK);
3754 TRACE("*p = %ld\n", *p);
3755 return S_OK;
3758 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
3760 HTMLElement *This = impl_from_IHTMLElement2(iface);
3761 FIXME("(%p)\n", This);
3762 return E_NOTIMPL;
3765 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
3767 HTMLElement *This = impl_from_IHTMLElement2(iface);
3768 FIXME("(%p)->(%p)\n", This, mergeThis);
3769 return E_NOTIMPL;
3772 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
3774 HTMLElement *This = impl_from_IHTMLElement2(iface);
3776 TRACE("(%p)->()\n", This);
3778 return set_node_event(&This->node, EVENTID_CONTEXTMENU, &v);
3781 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
3783 HTMLElement *This = impl_from_IHTMLElement2(iface);
3785 TRACE("(%p)->(%p)\n", This, p);
3787 return get_node_event(&This->node, EVENTID_CONTEXTMENU, p);
3790 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
3791 IHTMLElement *insertedElement, IHTMLElement **inserted)
3793 HTMLElement *This = impl_from_IHTMLElement2(iface);
3794 HTMLDOMNode *ret_node;
3795 HTMLElement *elem;
3796 HRESULT hres;
3798 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
3800 elem = unsafe_impl_from_IHTMLElement(insertedElement);
3801 if(!elem)
3802 return E_INVALIDARG;
3804 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
3805 if(FAILED(hres))
3806 return hres;
3808 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
3809 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
3810 return hres;
3813 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
3814 BSTR where, IHTMLElement **applied)
3816 HTMLElement *This = impl_from_IHTMLElement2(iface);
3817 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
3818 return E_NOTIMPL;
3821 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
3823 HTMLElement *This = impl_from_IHTMLElement2(iface);
3824 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
3825 return E_NOTIMPL;
3828 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
3829 BSTR newText, BSTR *oldText)
3831 HTMLElement *This = impl_from_IHTMLElement2(iface);
3832 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
3833 return E_NOTIMPL;
3836 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
3838 HTMLElement *This = impl_from_IHTMLElement2(iface);
3839 FIXME("(%p)->(%p)\n", This, p);
3840 return E_NOTIMPL;
3843 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
3844 VARIANT *pvarFactory, LONG *pCookie)
3846 HTMLElement *This = impl_from_IHTMLElement2(iface);
3847 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
3848 return E_NOTIMPL;
3851 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
3852 VARIANT_BOOL *pfResult)
3854 HTMLElement *This = impl_from_IHTMLElement2(iface);
3855 FIXME("(%p)->(%ld %p)\n", This, cookie, pfResult);
3856 return E_NOTIMPL;
3859 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
3861 HTMLElement *This = impl_from_IHTMLElement2(iface);
3863 FIXME("(%p)->(%p): hack\n", This, p);
3865 /* We can't implement correct behavior on top of Gecko (although we could
3866 try a bit harder). Making runtimeStyle behave like regular style is
3867 enough for most use cases. */
3868 if(!This->runtime_style) {
3869 HRESULT hres;
3871 hres = HTMLStyle_Create(This, &This->runtime_style);
3872 if(FAILED(hres))
3873 return hres;
3876 *p = &This->runtime_style->IHTMLStyle_iface;
3877 IHTMLStyle_AddRef(*p);
3878 return S_OK;
3881 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
3883 HTMLElement *This = impl_from_IHTMLElement2(iface);
3884 FIXME("(%p)->(%p)\n", This, p);
3885 return E_NOTIMPL;
3888 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
3890 HTMLElement *This = impl_from_IHTMLElement2(iface);
3891 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3892 return E_NOTIMPL;
3895 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
3897 HTMLElement *This = impl_from_IHTMLElement2(iface);
3898 FIXME("(%p)->(%p)\n", This, p);
3899 return E_NOTIMPL;
3902 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
3904 HTMLElement *This = impl_from_IHTMLElement2(iface);
3905 FIXME("(%p)->()\n", This);
3906 return E_NOTIMPL;
3909 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
3911 HTMLElement *This = impl_from_IHTMLElement2(iface);
3912 FIXME("(%p)->(%p)\n", This, p);
3913 return E_NOTIMPL;
3916 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
3918 HTMLElement *This = impl_from_IHTMLElement2(iface);
3919 FIXME("(%p)->(%p)\n", This, p);
3920 return E_NOTIMPL;
3923 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
3924 IHTMLElementCollection **pelColl)
3926 HTMLElement *This = impl_from_IHTMLElement2(iface);
3927 nsIDOMHTMLCollection *nscol;
3928 nsAString tag_str;
3929 nsresult nsres;
3931 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
3933 if(!This->dom_element) {
3934 *pelColl = create_collection_from_htmlcol(NULL, This->node.doc->document_mode);
3935 return S_OK;
3938 nsAString_InitDepend(&tag_str, v);
3939 nsres = nsIDOMElement_GetElementsByTagName(This->dom_element, &tag_str, &nscol);
3940 nsAString_Finish(&tag_str);
3941 if(NS_FAILED(nsres)) {
3942 ERR("GetElementByTagName failed: %08lx\n", nsres);
3943 return E_FAIL;
3946 *pelColl = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
3947 nsIDOMHTMLCollection_Release(nscol);
3948 return S_OK;
3951 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
3952 HTMLElement2_QueryInterface,
3953 HTMLElement2_AddRef,
3954 HTMLElement2_Release,
3955 HTMLElement2_GetTypeInfoCount,
3956 HTMLElement2_GetTypeInfo,
3957 HTMLElement2_GetIDsOfNames,
3958 HTMLElement2_Invoke,
3959 HTMLElement2_get_scopeName,
3960 HTMLElement2_setCapture,
3961 HTMLElement2_releaseCapture,
3962 HTMLElement2_put_onlosecapture,
3963 HTMLElement2_get_onlosecapture,
3964 HTMLElement2_componentFromPoint,
3965 HTMLElement2_doScroll,
3966 HTMLElement2_put_onscroll,
3967 HTMLElement2_get_onscroll,
3968 HTMLElement2_put_ondrag,
3969 HTMLElement2_get_ondrag,
3970 HTMLElement2_put_ondragend,
3971 HTMLElement2_get_ondragend,
3972 HTMLElement2_put_ondragenter,
3973 HTMLElement2_get_ondragenter,
3974 HTMLElement2_put_ondragover,
3975 HTMLElement2_get_ondragover,
3976 HTMLElement2_put_ondragleave,
3977 HTMLElement2_get_ondragleave,
3978 HTMLElement2_put_ondrop,
3979 HTMLElement2_get_ondrop,
3980 HTMLElement2_put_onbeforecut,
3981 HTMLElement2_get_onbeforecut,
3982 HTMLElement2_put_oncut,
3983 HTMLElement2_get_oncut,
3984 HTMLElement2_put_onbeforecopy,
3985 HTMLElement2_get_onbeforecopy,
3986 HTMLElement2_put_oncopy,
3987 HTMLElement2_get_oncopy,
3988 HTMLElement2_put_onbeforepaste,
3989 HTMLElement2_get_onbeforepaste,
3990 HTMLElement2_put_onpaste,
3991 HTMLElement2_get_onpaste,
3992 HTMLElement2_get_currentStyle,
3993 HTMLElement2_put_onpropertychange,
3994 HTMLElement2_get_onpropertychange,
3995 HTMLElement2_getClientRects,
3996 HTMLElement2_getBoundingClientRect,
3997 HTMLElement2_setExpression,
3998 HTMLElement2_getExpression,
3999 HTMLElement2_removeExpression,
4000 HTMLElement2_put_tabIndex,
4001 HTMLElement2_get_tabIndex,
4002 HTMLElement2_focus,
4003 HTMLElement2_put_accessKey,
4004 HTMLElement2_get_accessKey,
4005 HTMLElement2_put_onblur,
4006 HTMLElement2_get_onblur,
4007 HTMLElement2_put_onfocus,
4008 HTMLElement2_get_onfocus,
4009 HTMLElement2_put_onresize,
4010 HTMLElement2_get_onresize,
4011 HTMLElement2_blur,
4012 HTMLElement2_addFilter,
4013 HTMLElement2_removeFilter,
4014 HTMLElement2_get_clientHeight,
4015 HTMLElement2_get_clientWidth,
4016 HTMLElement2_get_clientTop,
4017 HTMLElement2_get_clientLeft,
4018 HTMLElement2_attachEvent,
4019 HTMLElement2_detachEvent,
4020 HTMLElement2_get_readyState,
4021 HTMLElement2_put_onreadystatechange,
4022 HTMLElement2_get_onreadystatechange,
4023 HTMLElement2_put_onrowsdelete,
4024 HTMLElement2_get_onrowsdelete,
4025 HTMLElement2_put_onrowsinserted,
4026 HTMLElement2_get_onrowsinserted,
4027 HTMLElement2_put_oncellchange,
4028 HTMLElement2_get_oncellchange,
4029 HTMLElement2_put_dir,
4030 HTMLElement2_get_dir,
4031 HTMLElement2_createControlRange,
4032 HTMLElement2_get_scrollHeight,
4033 HTMLElement2_get_scrollWidth,
4034 HTMLElement2_put_scrollTop,
4035 HTMLElement2_get_scrollTop,
4036 HTMLElement2_put_scrollLeft,
4037 HTMLElement2_get_scrollLeft,
4038 HTMLElement2_clearAttributes,
4039 HTMLElement2_mergeAttributes,
4040 HTMLElement2_put_oncontextmenu,
4041 HTMLElement2_get_oncontextmenu,
4042 HTMLElement2_insertAdjacentElement,
4043 HTMLElement2_applyElement,
4044 HTMLElement2_getAdjacentText,
4045 HTMLElement2_replaceAdjacentText,
4046 HTMLElement2_get_canHandleChildren,
4047 HTMLElement2_addBehavior,
4048 HTMLElement2_removeBehavior,
4049 HTMLElement2_get_runtimeStyle,
4050 HTMLElement2_get_behaviorUrns,
4051 HTMLElement2_put_tagUrn,
4052 HTMLElement2_get_tagUrn,
4053 HTMLElement2_put_onbeforeeditfocus,
4054 HTMLElement2_get_onbeforeeditfocus,
4055 HTMLElement2_get_readyStateValue,
4056 HTMLElement2_getElementsByTagName,
4059 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
4061 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
4064 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
4065 REFIID riid, void **ppv)
4067 HTMLElement *This = impl_from_IHTMLElement3(iface);
4068 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4071 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
4073 HTMLElement *This = impl_from_IHTMLElement3(iface);
4074 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4077 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
4079 HTMLElement *This = impl_from_IHTMLElement3(iface);
4080 return IHTMLElement_Release(&This->IHTMLElement_iface);
4083 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
4085 HTMLElement *This = impl_from_IHTMLElement3(iface);
4086 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4089 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
4090 LCID lcid, ITypeInfo **ppTInfo)
4092 HTMLElement *This = impl_from_IHTMLElement3(iface);
4093 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4096 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
4097 LPOLESTR *rgszNames, UINT cNames,
4098 LCID lcid, DISPID *rgDispId)
4100 HTMLElement *This = impl_from_IHTMLElement3(iface);
4101 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4102 lcid, rgDispId);
4105 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
4106 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4107 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4109 HTMLElement *This = impl_from_IHTMLElement3(iface);
4110 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4111 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4114 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
4116 HTMLElement *This = impl_from_IHTMLElement3(iface);
4117 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
4118 return E_NOTIMPL;
4121 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
4123 HTMLElement *This = impl_from_IHTMLElement3(iface);
4124 FIXME("(%p)->(%p)\n", This, p);
4125 return E_NOTIMPL;
4128 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
4130 HTMLElement *This = impl_from_IHTMLElement3(iface);
4131 FIXME("(%p)->(%p)\n", This, p);
4132 return E_NOTIMPL;
4135 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
4137 HTMLElement *This = impl_from_IHTMLElement3(iface);
4138 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4139 return E_NOTIMPL;
4142 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
4144 HTMLElement *This = impl_from_IHTMLElement3(iface);
4145 FIXME("(%p)->(%p)\n", This, p);
4146 return E_NOTIMPL;
4149 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
4151 HTMLElement *This = impl_from_IHTMLElement3(iface);
4152 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4153 return E_NOTIMPL;
4156 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
4158 HTMLElement *This = impl_from_IHTMLElement3(iface);
4159 FIXME("(%p)->(%p)\n", This, p);
4160 return E_NOTIMPL;
4163 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
4165 HTMLElement *This = impl_from_IHTMLElement3(iface);
4166 FIXME("(%p)->(%x)\n", This, v);
4167 return E_NOTIMPL;
4170 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
4172 HTMLElement *This = impl_from_IHTMLElement3(iface);
4173 FIXME("(%p)->(%p)\n", This, p);
4174 return E_NOTIMPL;
4177 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
4179 HTMLElement *This = impl_from_IHTMLElement3(iface);
4180 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4181 return E_NOTIMPL;
4184 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
4186 HTMLElement *This = impl_from_IHTMLElement3(iface);
4187 FIXME("(%p)->(%p)\n", This, p);
4188 return E_NOTIMPL;
4191 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
4193 HTMLElement *This = impl_from_IHTMLElement3(iface);
4194 FIXME("(%p)\n", This);
4195 return E_NOTIMPL;
4198 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
4200 HTMLElement *This = impl_from_IHTMLElement3(iface);
4201 nsresult nsres;
4202 nsAString str;
4204 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
4206 if(!This->html_element) {
4207 FIXME("non-HTML element\n");
4208 return E_NOTIMPL;
4211 nsAString_InitDepend(&str, v);
4212 nsres = nsIDOMHTMLElement_SetContentEditable(This->html_element, &str);
4213 nsAString_Finish(&str);
4215 if (NS_FAILED(nsres)){
4216 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
4217 return E_FAIL;
4220 return S_OK;
4223 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
4225 HTMLElement *This = impl_from_IHTMLElement3(iface);
4226 nsresult nsres;
4227 nsAString str;
4229 TRACE("(%p)->(%p)\n", This, p);
4231 if(!This->html_element) {
4232 FIXME("non-HTML element\n");
4233 return E_NOTIMPL;
4236 nsAString_Init(&str, NULL);
4237 nsres = nsIDOMHTMLElement_GetContentEditable(This->html_element, &str);
4238 return return_nsstr(nsres, &str, p);
4241 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
4243 HTMLElement *This = impl_from_IHTMLElement3(iface);
4244 FIXME("(%p)->(%p)\n", This, p);
4245 return E_NOTIMPL;
4248 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
4250 HTMLElement *This = impl_from_IHTMLElement3(iface);
4251 FIXME("(%p)->(%x)\n", This, v);
4252 return E_NOTIMPL;
4255 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
4257 HTMLElement *This = impl_from_IHTMLElement3(iface);
4258 FIXME("(%p)->(%p)\n", This, p);
4259 return E_NOTIMPL;
4262 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
4264 HTMLElement *This = impl_from_IHTMLElement3(iface);
4266 TRACE("(%p)->(%x)\n", This, v);
4268 if(This->node.vtbl->put_disabled)
4269 return This->node.vtbl->put_disabled(&This->node, v);
4271 if(!v) return element_remove_attribute(This, L"disabled");
4272 return elem_string_attr_setter(This, L"disabled", L"");
4275 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4277 HTMLElement *This = impl_from_IHTMLElement3(iface);
4279 TRACE("(%p)->(%p)\n", This, p);
4281 if(This->node.vtbl->get_disabled)
4282 return This->node.vtbl->get_disabled(&This->node, p);
4284 *p = variant_bool(element_has_attribute(This, L"disabled"));
4285 return S_OK;
4288 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4290 HTMLElement *This = impl_from_IHTMLElement3(iface);
4291 FIXME("(%p)->(%p)\n", This, p);
4292 return E_NOTIMPL;
4295 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
4297 HTMLElement *This = impl_from_IHTMLElement3(iface);
4298 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4299 return E_NOTIMPL;
4302 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
4304 HTMLElement *This = impl_from_IHTMLElement3(iface);
4305 FIXME("(%p)->(%p)\n", This, p);
4306 return E_NOTIMPL;
4309 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
4311 HTMLElement *This = impl_from_IHTMLElement3(iface);
4312 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4313 return E_NOTIMPL;
4316 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
4318 HTMLElement *This = impl_from_IHTMLElement3(iface);
4319 FIXME("(%p)->(%p)\n", This, p);
4320 return E_NOTIMPL;
4323 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
4324 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
4326 HTMLElement *This = impl_from_IHTMLElement3(iface);
4328 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
4329 pfCancelled);
4331 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
4334 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
4336 HTMLElement *This = impl_from_IHTMLElement3(iface);
4337 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4338 return E_NOTIMPL;
4341 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
4343 HTMLElement *This = impl_from_IHTMLElement3(iface);
4344 FIXME("(%p)->(%p)\n", This, p);
4345 return E_NOTIMPL;
4348 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
4350 HTMLElement *This = impl_from_IHTMLElement3(iface);
4351 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4352 return E_NOTIMPL;
4355 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
4357 HTMLElement *This = impl_from_IHTMLElement3(iface);
4358 FIXME("(%p)->(%p)\n", This, p);
4359 return E_NOTIMPL;
4362 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
4364 HTMLElement *This = impl_from_IHTMLElement3(iface);
4365 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4366 return E_NOTIMPL;
4369 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
4371 HTMLElement *This = impl_from_IHTMLElement3(iface);
4372 FIXME("(%p)->(%p)\n", This, p);
4373 return E_NOTIMPL;
4376 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
4378 HTMLElement *This = impl_from_IHTMLElement3(iface);
4379 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4380 return E_NOTIMPL;
4383 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
4385 HTMLElement *This = impl_from_IHTMLElement3(iface);
4386 FIXME("(%p)->(%p)\n", This, p);
4387 return E_NOTIMPL;
4390 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
4392 HTMLElement *This = impl_from_IHTMLElement3(iface);
4393 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4394 return E_NOTIMPL;
4397 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
4399 HTMLElement *This = impl_from_IHTMLElement3(iface);
4400 FIXME("(%p)->(%p)\n", This, p);
4401 return E_NOTIMPL;
4404 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
4406 HTMLElement *This = impl_from_IHTMLElement3(iface);
4407 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4408 return E_NOTIMPL;
4411 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
4413 HTMLElement *This = impl_from_IHTMLElement3(iface);
4414 FIXME("(%p)->(%p)\n", This, p);
4415 return E_NOTIMPL;
4418 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
4420 HTMLElement *This = impl_from_IHTMLElement3(iface);
4421 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4422 return E_NOTIMPL;
4425 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
4427 HTMLElement *This = impl_from_IHTMLElement3(iface);
4428 FIXME("(%p)->(%p)\n", This, p);
4429 return E_NOTIMPL;
4432 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
4434 HTMLElement *This = impl_from_IHTMLElement3(iface);
4435 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4436 return E_NOTIMPL;
4439 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
4441 HTMLElement *This = impl_from_IHTMLElement3(iface);
4442 FIXME("(%p)->(%p)\n", This, p);
4443 return E_NOTIMPL;
4446 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
4448 HTMLElement *This = impl_from_IHTMLElement3(iface);
4449 FIXME("(%p)->(%p)\n", This, pfRet);
4450 return E_NOTIMPL;
4453 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
4455 HTMLElement *This = impl_from_IHTMLElement3(iface);
4456 FIXME("(%p)->(%p)\n", This, p);
4457 return E_NOTIMPL;
4460 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
4461 HTMLElement3_QueryInterface,
4462 HTMLElement3_AddRef,
4463 HTMLElement3_Release,
4464 HTMLElement3_GetTypeInfoCount,
4465 HTMLElement3_GetTypeInfo,
4466 HTMLElement3_GetIDsOfNames,
4467 HTMLElement3_Invoke,
4468 HTMLElement3_mergeAttributes,
4469 HTMLElement3_get_isMultiLine,
4470 HTMLElement3_get_canHaveHTML,
4471 HTMLElement3_put_onlayoutcomplete,
4472 HTMLElement3_get_onlayoutcomplete,
4473 HTMLElement3_put_onpage,
4474 HTMLElement3_get_onpage,
4475 HTMLElement3_put_inflateBlock,
4476 HTMLElement3_get_inflateBlock,
4477 HTMLElement3_put_onbeforedeactivate,
4478 HTMLElement3_get_onbeforedeactivate,
4479 HTMLElement3_setActive,
4480 HTMLElement3_put_contentEditable,
4481 HTMLElement3_get_contentEditable,
4482 HTMLElement3_get_isContentEditable,
4483 HTMLElement3_put_hideFocus,
4484 HTMLElement3_get_hideFocus,
4485 HTMLElement3_put_disabled,
4486 HTMLElement3_get_disabled,
4487 HTMLElement3_get_isDisabled,
4488 HTMLElement3_put_onmove,
4489 HTMLElement3_get_onmove,
4490 HTMLElement3_put_oncontrolselect,
4491 HTMLElement3_get_oncontrolselect,
4492 HTMLElement3_fireEvent,
4493 HTMLElement3_put_onresizestart,
4494 HTMLElement3_get_onresizestart,
4495 HTMLElement3_put_onresizeend,
4496 HTMLElement3_get_onresizeend,
4497 HTMLElement3_put_onmovestart,
4498 HTMLElement3_get_onmovestart,
4499 HTMLElement3_put_onmoveend,
4500 HTMLElement3_get_onmoveend,
4501 HTMLElement3_put_onmousecenter,
4502 HTMLElement3_get_onmousecenter,
4503 HTMLElement3_put_onmouseleave,
4504 HTMLElement3_get_onmouseleave,
4505 HTMLElement3_put_onactivate,
4506 HTMLElement3_get_onactivate,
4507 HTMLElement3_put_ondeactivate,
4508 HTMLElement3_get_ondeactivate,
4509 HTMLElement3_dragDrop,
4510 HTMLElement3_get_glyphMode
4513 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
4515 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
4518 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
4519 REFIID riid, void **ppv)
4521 HTMLElement *This = impl_from_IHTMLElement4(iface);
4522 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4525 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
4527 HTMLElement *This = impl_from_IHTMLElement4(iface);
4528 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4531 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
4533 HTMLElement *This = impl_from_IHTMLElement4(iface);
4534 return IHTMLElement_Release(&This->IHTMLElement_iface);
4537 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
4539 HTMLElement *This = impl_from_IHTMLElement4(iface);
4540 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4543 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
4544 LCID lcid, ITypeInfo **ppTInfo)
4546 HTMLElement *This = impl_from_IHTMLElement4(iface);
4547 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4550 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
4551 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4553 HTMLElement *This = impl_from_IHTMLElement4(iface);
4554 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4555 lcid, rgDispId);
4558 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
4559 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4561 HTMLElement *This = impl_from_IHTMLElement4(iface);
4562 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4563 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4566 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
4568 HTMLElement *This = impl_from_IHTMLElement4(iface);
4570 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4572 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
4575 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
4577 HTMLElement *This = impl_from_IHTMLElement4(iface);
4579 TRACE("(%p)->(%p)\n", This, p);
4581 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
4584 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
4586 HTMLElement *This = impl_from_IHTMLElement4(iface);
4587 FIXME("(%p)\n", This);
4588 return E_NOTIMPL;
4591 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
4593 HTMLElement *This = impl_from_IHTMLElement4(iface);
4594 HTMLAttributeCollection *attrs;
4595 HRESULT hres;
4597 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
4599 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4600 if(FAILED(hres))
4601 return hres;
4603 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
4604 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4605 return hres;
4608 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4609 IHTMLDOMAttribute **ppretAttribute)
4611 HTMLElement *This = impl_from_IHTMLElement4(iface);
4612 HTMLDOMAttribute *attr, *iter, *replace = NULL;
4613 HTMLAttributeCollection *attrs;
4614 DISPID dispid;
4615 HRESULT hres;
4617 TRACE("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4619 attr = unsafe_impl_from_IHTMLDOMAttribute(pattr);
4620 if(!attr)
4621 return E_INVALIDARG;
4623 if(attr->elem) {
4624 WARN("Tried to set already attached attribute.\n");
4625 return E_INVALIDARG;
4628 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface,
4629 attr->name, fdexNameCaseInsensitive|fdexNameEnsure, &dispid);
4630 if(FAILED(hres))
4631 return hres;
4633 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4634 if(FAILED(hres))
4635 return hres;
4637 LIST_FOR_EACH_ENTRY(iter, &attrs->attrs, HTMLDOMAttribute, entry) {
4638 if(iter->dispid == dispid) {
4639 replace = iter;
4640 break;
4644 if(replace) {
4645 hres = get_elem_attr_value_by_dispid(This, dispid, &replace->value);
4646 if(FAILED(hres)) {
4647 WARN("could not get attr value: %08lx\n", hres);
4648 V_VT(&replace->value) = VT_EMPTY;
4650 if(!replace->name) {
4651 replace->name = attr->name;
4652 attr->name = NULL;
4654 list_add_head(&replace->entry, &attr->entry);
4655 list_remove(&replace->entry);
4656 replace->elem = NULL;
4657 }else {
4658 list_add_tail(&attrs->attrs, &attr->entry);
4661 IHTMLDOMAttribute_AddRef(&attr->IHTMLDOMAttribute_iface);
4662 attr->elem = This;
4663 attr->dispid = dispid;
4665 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4667 hres = set_elem_attr_value_by_dispid(This, dispid, &attr->value);
4668 if(FAILED(hres))
4669 WARN("Could not set attribute value: %08lx\n", hres);
4670 VariantClear(&attr->value);
4672 *ppretAttribute = replace ? &replace->IHTMLDOMAttribute_iface : NULL;
4673 return S_OK;
4676 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4677 IHTMLDOMAttribute **ppretAttribute)
4679 HTMLElement *This = impl_from_IHTMLElement4(iface);
4680 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4681 return E_NOTIMPL;
4684 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
4686 HTMLElement *This = impl_from_IHTMLElement4(iface);
4688 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4690 return set_node_event(&This->node, EVENTID_BEFOREACTIVATE, &v);
4693 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
4695 HTMLElement *This = impl_from_IHTMLElement4(iface);
4697 TRACE("(%p)->(%p)\n", This, p);
4699 return get_node_event(&This->node, EVENTID_BEFOREACTIVATE, p);
4702 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
4704 HTMLElement *This = impl_from_IHTMLElement4(iface);
4706 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4708 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
4711 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
4713 HTMLElement *This = impl_from_IHTMLElement4(iface);
4715 TRACE("(%p)->(%p)\n", This, p);
4717 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
4720 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
4722 HTMLElement *This = impl_from_IHTMLElement4(iface);
4724 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4726 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
4729 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
4731 HTMLElement *This = impl_from_IHTMLElement4(iface);
4733 TRACE("(%p)->(%p)\n", This, p);
4735 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
4738 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
4739 HTMLElement4_QueryInterface,
4740 HTMLElement4_AddRef,
4741 HTMLElement4_Release,
4742 HTMLElement4_GetTypeInfoCount,
4743 HTMLElement4_GetTypeInfo,
4744 HTMLElement4_GetIDsOfNames,
4745 HTMLElement4_Invoke,
4746 HTMLElement4_put_onmousewheel,
4747 HTMLElement4_get_onmousewheel,
4748 HTMLElement4_normalize,
4749 HTMLElement4_getAttributeNode,
4750 HTMLElement4_setAttributeNode,
4751 HTMLElement4_removeAttributeNode,
4752 HTMLElement4_put_onbeforeactivate,
4753 HTMLElement4_get_onbeforeactivate,
4754 HTMLElement4_put_onfocusin,
4755 HTMLElement4_get_onfocusin,
4756 HTMLElement4_put_onfocusout,
4757 HTMLElement4_get_onfocusout
4760 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
4762 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
4765 static HRESULT WINAPI HTMLElement6_QueryInterface(IHTMLElement6 *iface,
4766 REFIID riid, void **ppv)
4768 HTMLElement *This = impl_from_IHTMLElement6(iface);
4769 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4772 static ULONG WINAPI HTMLElement6_AddRef(IHTMLElement6 *iface)
4774 HTMLElement *This = impl_from_IHTMLElement6(iface);
4775 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4778 static ULONG WINAPI HTMLElement6_Release(IHTMLElement6 *iface)
4780 HTMLElement *This = impl_from_IHTMLElement6(iface);
4781 return IHTMLElement_Release(&This->IHTMLElement_iface);
4784 static HRESULT WINAPI HTMLElement6_GetTypeInfoCount(IHTMLElement6 *iface, UINT *pctinfo)
4786 HTMLElement *This = impl_from_IHTMLElement6(iface);
4787 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4790 static HRESULT WINAPI HTMLElement6_GetTypeInfo(IHTMLElement6 *iface, UINT iTInfo,
4791 LCID lcid, ITypeInfo **ppTInfo)
4793 HTMLElement *This = impl_from_IHTMLElement6(iface);
4794 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4797 static HRESULT WINAPI HTMLElement6_GetIDsOfNames(IHTMLElement6 *iface, REFIID riid,
4798 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4800 HTMLElement *This = impl_from_IHTMLElement6(iface);
4801 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4802 lcid, rgDispId);
4805 static HRESULT WINAPI HTMLElement6_Invoke(IHTMLElement6 *iface, DISPID dispIdMember, REFIID riid,
4806 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4808 HTMLElement *This = impl_from_IHTMLElement6(iface);
4809 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4810 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4813 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
4815 HTMLElement *This = impl_from_IHTMLElement6(iface);
4816 nsAString ns_str, name_str, value_str;
4817 nsresult nsres;
4818 HRESULT hres;
4820 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
4822 if(!This->dom_element) {
4823 FIXME("No dom_element\n");
4824 return E_NOTIMPL;
4827 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4828 if(FAILED(hres))
4829 return hres;
4831 nsAString_InitDepend(&name_str, strAttributeName);
4832 nsAString_InitDepend(&value_str, NULL);
4833 nsres = nsIDOMElement_GetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
4834 nsAString_Finish(&ns_str);
4835 nsAString_Finish(&name_str);
4837 hres = return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
4838 if(SUCCEEDED(hres) && V_VT(AttributeValue) == VT_NULL) {
4839 V_VT(AttributeValue) = VT_BSTR;
4840 V_BSTR(AttributeValue) = NULL;
4842 return hres;
4845 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4847 HTMLElement *This = impl_from_IHTMLElement6(iface);
4848 nsAString ns_str, name_str, value_str;
4849 const PRUnichar *ns;
4850 nsresult nsres;
4851 HRESULT hres;
4853 TRACE("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
4855 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4856 if(FAILED(hres))
4857 return hres;
4858 nsAString_GetData(&ns_str, &ns);
4859 if((!ns || !ns[0]) && wcschr(strAttributeName, ':')) {
4860 /* FIXME: Return NamespaceError */
4861 return E_FAIL;
4864 if(!This->dom_element) {
4865 FIXME("No dom_element\n");
4866 nsAString_Finish(&ns_str);
4867 return E_NOTIMPL;
4870 hres = variant_to_nsstr(pvarAttributeValue, FALSE, &value_str);
4871 if(FAILED(hres)) {
4872 nsAString_Finish(&ns_str);
4873 return hres;
4876 nsAString_InitDepend(&name_str, strAttributeName);
4877 nsres = nsIDOMElement_SetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
4878 nsAString_Finish(&ns_str);
4879 nsAString_Finish(&name_str);
4880 nsAString_Finish(&value_str);
4881 if(NS_FAILED(nsres))
4882 WARN("SetAttributeNS failed: %08lx\n", nsres);
4883 return map_nsresult(nsres);
4886 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
4888 HTMLElement *This = impl_from_IHTMLElement6(iface);
4889 nsAString ns_str, name_str;
4890 nsresult nsres;
4891 HRESULT hres;
4893 TRACE("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
4895 if(!This->dom_element) {
4896 FIXME("No dom_element\n");
4897 return E_NOTIMPL;
4900 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4901 if(FAILED(hres))
4902 return hres;
4904 nsAString_InitDepend(&name_str, strAttributeName);
4905 nsres = nsIDOMElement_RemoveAttributeNS(This->dom_element, &ns_str, &name_str);
4906 nsAString_Finish(&ns_str);
4907 nsAString_Finish(&name_str);
4908 return map_nsresult(nsres);
4911 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
4913 HTMLElement *This = impl_from_IHTMLElement6(iface);
4914 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
4915 return E_NOTIMPL;
4918 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4920 HTMLElement *This = impl_from_IHTMLElement6(iface);
4921 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4922 return E_NOTIMPL;
4925 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
4927 HTMLElement *This = impl_from_IHTMLElement6(iface);
4928 nsAString ns_str, name_str;
4929 nsresult nsres;
4930 HRESULT hres;
4931 cpp_bool r;
4933 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
4935 if(!This->dom_element) {
4936 FIXME("No dom_element\n");
4937 return E_NOTIMPL;
4940 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4941 if(FAILED(hres))
4942 return hres;
4944 nsAString_InitDepend(&name_str, name);
4945 nsres = nsIDOMElement_HasAttributeNS(This->dom_element, &ns_str, &name_str, &r);
4946 nsAString_Finish(&ns_str);
4947 nsAString_Finish(&name_str);
4948 *pfHasAttribute = variant_bool(NS_SUCCEEDED(nsres) && r);
4949 return S_OK;
4952 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
4954 HTMLElement *This = impl_from_IHTMLElement6(iface);
4956 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), AttributeValue);
4958 return IHTMLElement_getAttribute(&This->IHTMLElement_iface, strAttributeName, 0, AttributeValue);
4961 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4963 HTMLElement *This = impl_from_IHTMLElement6(iface);
4965 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
4967 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, strAttributeName, *pvarAttributeValue, 0);
4970 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
4972 HTMLElement *This = impl_from_IHTMLElement6(iface);
4973 VARIANT_BOOL success;
4975 WARN("(%p)->(%s) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName));
4977 return IHTMLElement_removeAttribute(&This->IHTMLElement_iface, strAttributeName, 0, &success);
4980 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
4982 HTMLElement *This = impl_from_IHTMLElement6(iface);
4983 IHTMLDOMAttribute *attr;
4984 HRESULT hres;
4986 WARN("(%p)->(%s %p) forwarding to IHTMLElement4\n", This, debugstr_w(strAttributeName), ppretAttribute);
4988 hres = IHTMLElement4_getAttributeNode(&This->IHTMLElement4_iface, strAttributeName, &attr);
4989 if(FAILED(hres))
4990 return hres;
4992 if(attr) {
4993 hres = IHTMLDOMAttribute_QueryInterface(attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
4994 IHTMLDOMAttribute_Release(attr);
4995 }else {
4996 *ppretAttribute = NULL;
4998 return hres;
5001 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5003 HTMLElement *This = impl_from_IHTMLElement6(iface);
5004 IHTMLDOMAttribute *attr, *ret_attr;
5005 HRESULT hres;
5007 WARN("(%p)->(%p %p) forwarding to IHTMLElement4\n", This, pattr, ppretAttribute);
5009 hres = IHTMLDOMAttribute2_QueryInterface(pattr, &IID_IHTMLDOMAttribute, (void**)&attr);
5010 if(FAILED(hres))
5011 return hres;
5013 hres = IHTMLElement4_setAttributeNode(&This->IHTMLElement4_iface, attr, &ret_attr);
5014 if(FAILED(hres))
5015 return hres;
5017 if(ret_attr) {
5018 hres = IHTMLDOMAttribute_QueryInterface(ret_attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
5019 IHTMLDOMAttribute_Release(ret_attr);
5020 }else {
5021 *ppretAttribute = NULL;
5023 return hres;
5026 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5028 HTMLElement *This = impl_from_IHTMLElement6(iface);
5029 FIXME("(%p)->()\n", This);
5030 return E_NOTIMPL;
5033 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *p)
5035 HTMLElement *This = impl_from_IHTMLElement6(iface);
5037 TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), p);
5039 *p = element_has_attribute(This, name);
5040 return S_OK;
5043 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
5045 HTMLElement *This = impl_from_IHTMLElement6(iface);
5046 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
5047 return E_NOTIMPL;
5050 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
5052 HTMLElement *This = impl_from_IHTMLElement6(iface);
5054 TRACE("(%p)->(%p)\n", This, p);
5056 return IHTMLElement_get_tagName(&This->IHTMLElement_iface, p);
5059 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
5061 HTMLElement *This = impl_from_IHTMLElement6(iface);
5063 TRACE("(%p)->(%p)\n", This, p);
5065 return IHTMLDOMNode_get_nodeName(&This->node.IHTMLDOMNode_iface, p);
5068 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
5070 HTMLElement *This = impl_from_IHTMLElement6(iface);
5071 nsIDOMHTMLCollection *nscol = NULL;
5072 nsAString nsstr;
5073 nsresult nsres;
5075 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
5077 if(This->dom_element) {
5078 nsAString_InitDepend(&nsstr, v);
5079 nsres = nsIDOMElement_GetElementsByClassName(This->dom_element, &nsstr, &nscol);
5080 nsAString_Finish(&nsstr);
5081 if(NS_FAILED(nsres)) {
5082 ERR("GetElementsByClassName failed: %08lx\n", nsres);
5083 return E_FAIL;
5087 *pel = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
5088 nsIDOMHTMLCollection_Release(nscol);
5089 return S_OK;
5092 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
5094 HTMLElement *This = impl_from_IHTMLElement6(iface);
5095 nsAString nsstr;
5096 cpp_bool b;
5097 nsresult nsres;
5099 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
5101 if(!This->dom_element) {
5102 FIXME("No dom element\n");
5103 return E_UNEXPECTED;
5106 nsAString_InitDepend(&nsstr, v);
5107 nsres = nsIDOMElement_MozMatchesSelector(This->dom_element, &nsstr, &b);
5108 nsAString_Finish(&nsstr);
5109 if(NS_FAILED(nsres)) {
5110 WARN("MozMatchesSelector failed: %08lx\n", nsres);
5111 return map_nsresult(nsres);
5114 *pfMatches = b;
5115 return S_OK;
5118 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
5120 HTMLElement *This = impl_from_IHTMLElement6(iface);
5122 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5124 return set_node_event(&This->node, EVENTID_ABORT, &v);
5127 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
5129 HTMLElement *This = impl_from_IHTMLElement6(iface);
5131 TRACE("(%p)->(%p)\n", This, p);
5133 return get_node_event(&This->node, EVENTID_ABORT, p);
5136 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
5138 HTMLElement *This = impl_from_IHTMLElement6(iface);
5139 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5140 return E_NOTIMPL;
5143 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
5145 HTMLElement *This = impl_from_IHTMLElement6(iface);
5146 FIXME("(%p)->(%p)\n", This, p);
5147 return E_NOTIMPL;
5150 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
5152 HTMLElement *This = impl_from_IHTMLElement6(iface);
5153 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5154 return E_NOTIMPL;
5157 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
5159 HTMLElement *This = impl_from_IHTMLElement6(iface);
5160 FIXME("(%p)->(%p)\n", This, p);
5161 return E_NOTIMPL;
5164 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
5166 HTMLElement *This = impl_from_IHTMLElement6(iface);
5168 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5170 return set_node_event(&This->node, EVENTID_CHANGE, &v);
5173 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
5175 HTMLElement *This = impl_from_IHTMLElement6(iface);
5177 TRACE("(%p)->(%p)\n", This, p);
5179 return get_node_event(&This->node, EVENTID_CHANGE, p);
5182 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
5184 HTMLElement *This = impl_from_IHTMLElement6(iface);
5185 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5186 return E_NOTIMPL;
5189 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
5191 HTMLElement *This = impl_from_IHTMLElement6(iface);
5192 FIXME("(%p)->(%p)\n", This, p);
5193 return E_NOTIMPL;
5196 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
5198 HTMLElement *This = impl_from_IHTMLElement6(iface);
5199 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5200 return E_NOTIMPL;
5203 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
5205 HTMLElement *This = impl_from_IHTMLElement6(iface);
5206 FIXME("(%p)->(%p)\n", This, p);
5207 return E_NOTIMPL;
5210 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
5212 HTMLElement *This = impl_from_IHTMLElement6(iface);
5213 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5214 return E_NOTIMPL;
5217 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
5219 HTMLElement *This = impl_from_IHTMLElement6(iface);
5220 FIXME("(%p)->(%p)\n", This, p);
5221 return E_NOTIMPL;
5224 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
5226 HTMLElement *This = impl_from_IHTMLElement6(iface);
5228 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5230 return set_node_event(&This->node, EVENTID_ERROR, &v);
5233 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
5235 HTMLElement *This = impl_from_IHTMLElement6(iface);
5237 TRACE("(%p)->(%p)\n", This, p);
5239 return get_node_event(&This->node, EVENTID_ERROR, p);
5242 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
5244 HTMLElement *This = impl_from_IHTMLElement6(iface);
5246 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5248 return set_node_event(&This->node, EVENTID_INPUT, &v);
5251 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
5253 HTMLElement *This = impl_from_IHTMLElement6(iface);
5255 TRACE("(%p)->(%p)\n", This, p);
5257 return get_node_event(&This->node, EVENTID_INPUT, p);
5260 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
5262 HTMLElement *This = impl_from_IHTMLElement6(iface);
5264 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5266 return set_node_event(&This->node, EVENTID_LOAD, &v);
5269 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
5271 HTMLElement *This = impl_from_IHTMLElement6(iface);
5273 TRACE("(%p)->(%p)\n", This, p);
5275 return get_node_event(&This->node, EVENTID_LOAD, p);
5278 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
5280 HTMLElement *This = impl_from_IHTMLElement6(iface);
5281 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5282 return E_NOTIMPL;
5285 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
5287 HTMLElement *This = impl_from_IHTMLElement6(iface);
5288 FIXME("(%p)->(%p)\n", This, p);
5289 return E_NOTIMPL;
5292 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
5294 HTMLElement *This = impl_from_IHTMLElement6(iface);
5295 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5296 return E_NOTIMPL;
5299 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
5301 HTMLElement *This = impl_from_IHTMLElement6(iface);
5302 FIXME("(%p)->(%p)\n", This, p);
5303 return E_NOTIMPL;
5306 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
5308 HTMLElement *This = impl_from_IHTMLElement6(iface);
5309 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5310 return E_NOTIMPL;
5313 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
5315 HTMLElement *This = impl_from_IHTMLElement6(iface);
5316 FIXME("(%p)->(%p)\n", This, p);
5317 return E_NOTIMPL;
5320 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
5322 HTMLElement *This = impl_from_IHTMLElement6(iface);
5323 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5324 return E_NOTIMPL;
5327 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
5329 HTMLElement *This = impl_from_IHTMLElement6(iface);
5330 FIXME("(%p)->(%p)\n", This, p);
5331 return E_NOTIMPL;
5334 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
5336 HTMLElement *This = impl_from_IHTMLElement6(iface);
5337 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5338 return E_NOTIMPL;
5341 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
5343 HTMLElement *This = impl_from_IHTMLElement6(iface);
5344 FIXME("(%p)->(%p)\n", This, p);
5345 return E_NOTIMPL;
5348 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
5350 HTMLElement *This = impl_from_IHTMLElement6(iface);
5351 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5352 return E_NOTIMPL;
5355 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
5357 HTMLElement *This = impl_from_IHTMLElement6(iface);
5358 FIXME("(%p)->(%p)\n", This, p);
5359 return E_NOTIMPL;
5362 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
5364 HTMLElement *This = impl_from_IHTMLElement6(iface);
5365 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5366 return E_NOTIMPL;
5369 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
5371 HTMLElement *This = impl_from_IHTMLElement6(iface);
5372 FIXME("(%p)->(%p)\n", This, p);
5373 return E_NOTIMPL;
5376 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
5378 HTMLElement *This = impl_from_IHTMLElement6(iface);
5379 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5380 return E_NOTIMPL;
5383 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
5385 HTMLElement *This = impl_from_IHTMLElement6(iface);
5386 FIXME("(%p)->(%p)\n", This, p);
5387 return E_NOTIMPL;
5390 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
5392 HTMLElement *This = impl_from_IHTMLElement6(iface);
5393 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5394 return E_NOTIMPL;
5397 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
5399 HTMLElement *This = impl_from_IHTMLElement6(iface);
5400 FIXME("(%p)->(%p)\n", This, p);
5401 return E_NOTIMPL;
5404 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
5406 HTMLElement *This = impl_from_IHTMLElement6(iface);
5407 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5408 return E_NOTIMPL;
5411 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
5413 HTMLElement *This = impl_from_IHTMLElement6(iface);
5414 FIXME("(%p)->(%p)\n", This, p);
5415 return E_NOTIMPL;
5418 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
5420 HTMLElement *This = impl_from_IHTMLElement6(iface);
5421 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5422 return E_NOTIMPL;
5425 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
5427 HTMLElement *This = impl_from_IHTMLElement6(iface);
5428 FIXME("(%p)->(%p)\n", This, p);
5429 return E_NOTIMPL;
5432 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
5434 HTMLElement *This = impl_from_IHTMLElement6(iface);
5435 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5436 return E_NOTIMPL;
5439 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
5441 HTMLElement *This = impl_from_IHTMLElement6(iface);
5442 FIXME("(%p)->(%p)\n", This, p);
5443 return E_NOTIMPL;
5446 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
5448 HTMLElement *This = impl_from_IHTMLElement6(iface);
5449 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5450 return E_NOTIMPL;
5453 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
5455 HTMLElement *This = impl_from_IHTMLElement6(iface);
5456 FIXME("(%p)->(%p)\n", This, p);
5457 return E_NOTIMPL;
5460 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
5462 HTMLElement *This = impl_from_IHTMLElement6(iface);
5464 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5466 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
5469 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
5471 HTMLElement *This = impl_from_IHTMLElement6(iface);
5473 TRACE("(%p)->(%p)\n", This, p);
5475 return get_node_event(&This->node, EVENTID_SUBMIT, p);
5478 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
5480 HTMLElement *This = impl_from_IHTMLElement6(iface);
5481 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5482 return E_NOTIMPL;
5485 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
5487 HTMLElement *This = impl_from_IHTMLElement6(iface);
5488 FIXME("(%p)->(%p)\n", This, p);
5489 return E_NOTIMPL;
5492 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
5494 HTMLElement *This = impl_from_IHTMLElement6(iface);
5495 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5496 return E_NOTIMPL;
5499 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
5501 HTMLElement *This = impl_from_IHTMLElement6(iface);
5502 FIXME("(%p)->(%p)\n", This, p);
5503 return E_NOTIMPL;
5506 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
5508 HTMLElement *This = impl_from_IHTMLElement6(iface);
5509 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5510 return E_NOTIMPL;
5513 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
5515 HTMLElement *This = impl_from_IHTMLElement6(iface);
5516 FIXME("(%p)->(%p)\n", This, p);
5517 return E_NOTIMPL;
5520 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
5522 HTMLElement *This = impl_from_IHTMLElement6(iface);
5523 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5524 return E_NOTIMPL;
5527 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
5529 HTMLElement *This = impl_from_IHTMLElement6(iface);
5530 FIXME("(%p)->(%p)\n", This, p);
5531 return E_NOTIMPL;
5534 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
5536 HTMLElement *This = impl_from_IHTMLElement6(iface);
5537 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
5538 return E_NOTIMPL;
5541 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
5542 HTMLElement6_QueryInterface,
5543 HTMLElement6_AddRef,
5544 HTMLElement6_Release,
5545 HTMLElement6_GetTypeInfoCount,
5546 HTMLElement6_GetTypeInfo,
5547 HTMLElement6_GetIDsOfNames,
5548 HTMLElement6_Invoke,
5549 HTMLElement6_getAttributeNS,
5550 HTMLElement6_setAttributeNS,
5551 HTMLElement6_removeAttributeNS,
5552 HTMLElement6_getAttributeNodeNS,
5553 HTMLElement6_setAttributeNodeNS,
5554 HTMLElement6_hasAttributeNS,
5555 HTMLElement6_getAttribute,
5556 HTMLElement6_setAttribute,
5557 HTMLElement6_removeAttribute,
5558 HTMLElement6_getAttributeNode,
5559 HTMLElement6_setAttributeNode,
5560 HTMLElement6_removeAttributeNode,
5561 HTMLElement6_hasAttribute,
5562 HTMLElement6_getElementsByTagNameNS,
5563 HTMLElement6_get_tagName,
5564 HTMLElement6_get_nodeName,
5565 HTMLElement6_getElementsByClassName,
5566 HTMLElement6_msMatchesSelector,
5567 HTMLElement6_put_onabort,
5568 HTMLElement6_get_onabort,
5569 HTMLElement6_put_oncanplay,
5570 HTMLElement6_get_oncanplay,
5571 HTMLElement6_put_oncanplaythrough,
5572 HTMLElement6_get_oncanplaythrough,
5573 HTMLElement6_put_onchange,
5574 HTMLElement6_get_onchange,
5575 HTMLElement6_put_ondurationchange,
5576 HTMLElement6_get_ondurationchange,
5577 HTMLElement6_put_onemptied,
5578 HTMLElement6_get_onemptied,
5579 HTMLElement6_put_onended,
5580 HTMLElement6_get_onended,
5581 HTMLElement6_put_onerror,
5582 HTMLElement6_get_onerror,
5583 HTMLElement6_put_oninput,
5584 HTMLElement6_get_oninput,
5585 HTMLElement6_put_onload,
5586 HTMLElement6_get_onload,
5587 HTMLElement6_put_onloadeddata,
5588 HTMLElement6_get_onloadeddata,
5589 HTMLElement6_put_onloadedmetadata,
5590 HTMLElement6_get_onloadedmetadata,
5591 HTMLElement6_put_onloadstart,
5592 HTMLElement6_get_onloadstart,
5593 HTMLElement6_put_onpause,
5594 HTMLElement6_get_onpause,
5595 HTMLElement6_put_onplay,
5596 HTMLElement6_get_onplay,
5597 HTMLElement6_put_onplaying,
5598 HTMLElement6_get_onplaying,
5599 HTMLElement6_put_onprogress,
5600 HTMLElement6_get_onprogress,
5601 HTMLElement6_put_onratechange,
5602 HTMLElement6_get_onratechange,
5603 HTMLElement6_put_onreset,
5604 HTMLElement6_get_onreset,
5605 HTMLElement6_put_onseeked,
5606 HTMLElement6_get_onseeked,
5607 HTMLElement6_put_onseeking,
5608 HTMLElement6_get_onseeking,
5609 HTMLElement6_put_onselect,
5610 HTMLElement6_get_onselect,
5611 HTMLElement6_put_onstalled,
5612 HTMLElement6_get_onstalled,
5613 HTMLElement6_put_onsubmit,
5614 HTMLElement6_get_onsubmit,
5615 HTMLElement6_put_onsuspend,
5616 HTMLElement6_get_onsuspend,
5617 HTMLElement6_put_ontimeupdate,
5618 HTMLElement6_get_ontimeupdate,
5619 HTMLElement6_put_onvolumechange,
5620 HTMLElement6_get_onvolumechange,
5621 HTMLElement6_put_onwaiting,
5622 HTMLElement6_get_onwaiting,
5623 HTMLElement6_hasAttributes
5626 static inline HTMLElement *impl_from_IHTMLElement7(IHTMLElement7 *iface)
5628 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement7_iface);
5631 static HRESULT WINAPI HTMLElement7_QueryInterface(IHTMLElement7 *iface,
5632 REFIID riid, void **ppv)
5634 HTMLElement *This = impl_from_IHTMLElement7(iface);
5635 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
5638 static ULONG WINAPI HTMLElement7_AddRef(IHTMLElement7 *iface)
5640 HTMLElement *This = impl_from_IHTMLElement7(iface);
5641 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5644 static ULONG WINAPI HTMLElement7_Release(IHTMLElement7 *iface)
5646 HTMLElement *This = impl_from_IHTMLElement7(iface);
5647 return IHTMLElement_Release(&This->IHTMLElement_iface);
5650 static HRESULT WINAPI HTMLElement7_GetTypeInfoCount(IHTMLElement7 *iface, UINT *pctinfo)
5652 HTMLElement *This = impl_from_IHTMLElement7(iface);
5653 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5656 static HRESULT WINAPI HTMLElement7_GetTypeInfo(IHTMLElement7 *iface, UINT iTInfo,
5657 LCID lcid, ITypeInfo **ppTInfo)
5659 HTMLElement *This = impl_from_IHTMLElement7(iface);
5660 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5663 static HRESULT WINAPI HTMLElement7_GetIDsOfNames(IHTMLElement7 *iface, REFIID riid,
5664 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5666 HTMLElement *This = impl_from_IHTMLElement7(iface);
5667 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5668 lcid, rgDispId);
5671 static HRESULT WINAPI HTMLElement7_Invoke(IHTMLElement7 *iface, DISPID dispIdMember, REFIID riid,
5672 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5674 HTMLElement *This = impl_from_IHTMLElement7(iface);
5675 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5676 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5679 static HRESULT WINAPI HTMLElement7_put_onmspointerdown(IHTMLElement7 *iface, VARIANT v)
5681 HTMLElement *This = impl_from_IHTMLElement7(iface);
5682 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5683 return E_NOTIMPL;
5686 static HRESULT WINAPI HTMLElement7_get_onmspointerdown(IHTMLElement7 *iface, VARIANT *p)
5688 HTMLElement *This = impl_from_IHTMLElement7(iface);
5689 FIXME("(%p)->(%p)\n", This, p);
5690 return E_NOTIMPL;
5693 static HRESULT WINAPI HTMLElement7_put_onmspointermove(IHTMLElement7 *iface, VARIANT v)
5695 HTMLElement *This = impl_from_IHTMLElement7(iface);
5696 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5697 return E_NOTIMPL;
5700 static HRESULT WINAPI HTMLElement7_get_onmspointermove(IHTMLElement7 *iface, VARIANT *p)
5702 HTMLElement *This = impl_from_IHTMLElement7(iface);
5703 FIXME("(%p)->(%p)\n", This, p);
5704 return E_NOTIMPL;
5707 static HRESULT WINAPI HTMLElement7_put_onmspointerup(IHTMLElement7 *iface, VARIANT v)
5709 HTMLElement *This = impl_from_IHTMLElement7(iface);
5710 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5711 return E_NOTIMPL;
5714 static HRESULT WINAPI HTMLElement7_get_onmspointerup(IHTMLElement7 *iface, VARIANT *p)
5716 HTMLElement *This = impl_from_IHTMLElement7(iface);
5717 FIXME("(%p)->(%p)\n", This, p);
5718 return E_NOTIMPL;
5721 static HRESULT WINAPI HTMLElement7_put_onmspointerover(IHTMLElement7 *iface, VARIANT v)
5723 HTMLElement *This = impl_from_IHTMLElement7(iface);
5724 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5725 return E_NOTIMPL;
5728 static HRESULT WINAPI HTMLElement7_get_onmspointerover(IHTMLElement7 *iface, VARIANT *p)
5730 HTMLElement *This = impl_from_IHTMLElement7(iface);
5731 FIXME("(%p)->(%p)\n", This, p);
5732 return E_NOTIMPL;
5735 static HRESULT WINAPI HTMLElement7_put_onmspointerout(IHTMLElement7 *iface, VARIANT v)
5737 HTMLElement *This = impl_from_IHTMLElement7(iface);
5738 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5739 return E_NOTIMPL;
5742 static HRESULT WINAPI HTMLElement7_get_onmspointerout(IHTMLElement7 *iface, VARIANT *p)
5744 HTMLElement *This = impl_from_IHTMLElement7(iface);
5745 FIXME("(%p)->(%p)\n", This, p);
5746 return E_NOTIMPL;
5749 static HRESULT WINAPI HTMLElement7_put_onmspointercancel(IHTMLElement7 *iface, VARIANT v)
5751 HTMLElement *This = impl_from_IHTMLElement7(iface);
5752 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5753 return E_NOTIMPL;
5756 static HRESULT WINAPI HTMLElement7_get_onmspointercancel(IHTMLElement7 *iface, VARIANT *p)
5758 HTMLElement *This = impl_from_IHTMLElement7(iface);
5759 FIXME("(%p)->(%p)\n", This, p);
5760 return E_NOTIMPL;
5763 static HRESULT WINAPI HTMLElement7_put_onmspointerhover(IHTMLElement7 *iface, VARIANT v)
5765 HTMLElement *This = impl_from_IHTMLElement7(iface);
5766 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5767 return E_NOTIMPL;
5770 static HRESULT WINAPI HTMLElement7_get_onmspointerhover(IHTMLElement7 *iface, VARIANT *p)
5772 HTMLElement *This = impl_from_IHTMLElement7(iface);
5773 FIXME("(%p)->(%p)\n", This, p);
5774 return E_NOTIMPL;
5777 static HRESULT WINAPI HTMLElement7_put_onmslostpointercapture(IHTMLElement7 *iface, VARIANT v)
5779 HTMLElement *This = impl_from_IHTMLElement7(iface);
5780 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5781 return E_NOTIMPL;
5784 static HRESULT WINAPI HTMLElement7_get_onmslostpointercapture(IHTMLElement7 *iface, VARIANT *p)
5786 HTMLElement *This = impl_from_IHTMLElement7(iface);
5787 FIXME("(%p)->(%p)\n", This, p);
5788 return E_NOTIMPL;
5791 static HRESULT WINAPI HTMLElement7_put_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT v)
5793 HTMLElement *This = impl_from_IHTMLElement7(iface);
5794 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5795 return E_NOTIMPL;
5798 static HRESULT WINAPI HTMLElement7_get_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT *p)
5800 HTMLElement *This = impl_from_IHTMLElement7(iface);
5801 FIXME("(%p)->(%p)\n", This, p);
5802 return E_NOTIMPL;
5805 static HRESULT WINAPI HTMLElement7_put_onmsgesturestart(IHTMLElement7 *iface, VARIANT v)
5807 HTMLElement *This = impl_from_IHTMLElement7(iface);
5808 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5809 return E_NOTIMPL;
5812 static HRESULT WINAPI HTMLElement7_get_onmsgesturestart(IHTMLElement7 *iface, VARIANT *p)
5814 HTMLElement *This = impl_from_IHTMLElement7(iface);
5815 FIXME("(%p)->(%p)\n", This, p);
5816 return E_NOTIMPL;
5819 static HRESULT WINAPI HTMLElement7_put_onmsgesturechange(IHTMLElement7 *iface, VARIANT v)
5821 HTMLElement *This = impl_from_IHTMLElement7(iface);
5822 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5823 return E_NOTIMPL;
5826 static HRESULT WINAPI HTMLElement7_get_onmsgesturechange(IHTMLElement7 *iface, VARIANT *p)
5828 HTMLElement *This = impl_from_IHTMLElement7(iface);
5829 FIXME("(%p)->(%p)\n", This, p);
5830 return E_NOTIMPL;
5833 static HRESULT WINAPI HTMLElement7_put_onmsgestureend(IHTMLElement7 *iface, VARIANT v)
5835 HTMLElement *This = impl_from_IHTMLElement7(iface);
5836 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5837 return E_NOTIMPL;
5840 static HRESULT WINAPI HTMLElement7_get_onmsgestureend(IHTMLElement7 *iface, VARIANT *p)
5842 HTMLElement *This = impl_from_IHTMLElement7(iface);
5843 FIXME("(%p)->(%p)\n", This, p);
5844 return E_NOTIMPL;
5847 static HRESULT WINAPI HTMLElement7_put_onmsgesturehold(IHTMLElement7 *iface, VARIANT v)
5849 HTMLElement *This = impl_from_IHTMLElement7(iface);
5850 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5851 return E_NOTIMPL;
5854 static HRESULT WINAPI HTMLElement7_get_onmsgesturehold(IHTMLElement7 *iface, VARIANT *p)
5856 HTMLElement *This = impl_from_IHTMLElement7(iface);
5857 FIXME("(%p)->(%p)\n", This, p);
5858 return E_NOTIMPL;
5861 static HRESULT WINAPI HTMLElement7_put_onmsgesturetap(IHTMLElement7 *iface, VARIANT v)
5863 HTMLElement *This = impl_from_IHTMLElement7(iface);
5864 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5865 return E_NOTIMPL;
5868 static HRESULT WINAPI HTMLElement7_get_onmsgesturetap(IHTMLElement7 *iface, VARIANT *p)
5870 HTMLElement *This = impl_from_IHTMLElement7(iface);
5871 FIXME("(%p)->(%p)\n", This, p);
5872 return E_NOTIMPL;
5875 static HRESULT WINAPI HTMLElement7_put_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT v)
5877 HTMLElement *This = impl_from_IHTMLElement7(iface);
5878 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5879 return E_NOTIMPL;
5882 static HRESULT WINAPI HTMLElement7_get_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT *p)
5884 HTMLElement *This = impl_from_IHTMLElement7(iface);
5885 FIXME("(%p)->(%p)\n", This, p);
5886 return E_NOTIMPL;
5889 static HRESULT WINAPI HTMLElement7_put_onmsinertiastart(IHTMLElement7 *iface, VARIANT v)
5891 HTMLElement *This = impl_from_IHTMLElement7(iface);
5892 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5893 return E_NOTIMPL;
5896 static HRESULT WINAPI HTMLElement7_get_onmsinertiastart(IHTMLElement7 *iface, VARIANT *p)
5898 HTMLElement *This = impl_from_IHTMLElement7(iface);
5899 FIXME("(%p)->(%p)\n", This, p);
5900 return E_NOTIMPL;
5903 static HRESULT WINAPI HTMLElement7_msSetPointerCapture(IHTMLElement7 *iface, LONG pointer_id)
5905 HTMLElement *This = impl_from_IHTMLElement7(iface);
5906 FIXME("(%p)->(%ld)\n", This, pointer_id);
5907 return E_NOTIMPL;
5910 static HRESULT WINAPI HTMLElement7_msReleasePointerCapture(IHTMLElement7 *iface, LONG pointer_id)
5912 HTMLElement *This = impl_from_IHTMLElement7(iface);
5913 FIXME("(%p)->(%ld)\n", This, pointer_id);
5914 return E_NOTIMPL;
5917 static HRESULT WINAPI HTMLElement7_put_onmstransitionstart(IHTMLElement7 *iface, VARIANT v)
5919 HTMLElement *This = impl_from_IHTMLElement7(iface);
5920 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5921 return E_NOTIMPL;
5924 static HRESULT WINAPI HTMLElement7_get_onmstransitionstart(IHTMLElement7 *iface, VARIANT *p)
5926 HTMLElement *This = impl_from_IHTMLElement7(iface);
5927 FIXME("(%p)->(%p)\n", This, p);
5928 return E_NOTIMPL;
5931 static HRESULT WINAPI HTMLElement7_put_onmstransitionend(IHTMLElement7 *iface, VARIANT v)
5933 HTMLElement *This = impl_from_IHTMLElement7(iface);
5934 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5935 return E_NOTIMPL;
5938 static HRESULT WINAPI HTMLElement7_get_onmstransitionend(IHTMLElement7 *iface, VARIANT *p)
5940 HTMLElement *This = impl_from_IHTMLElement7(iface);
5941 FIXME("(%p)->(%p)\n", This, p);
5942 return E_NOTIMPL;
5945 static HRESULT WINAPI HTMLElement7_put_onmsanimationstart(IHTMLElement7 *iface, VARIANT v)
5947 HTMLElement *This = impl_from_IHTMLElement7(iface);
5948 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5949 return E_NOTIMPL;
5952 static HRESULT WINAPI HTMLElement7_get_onmsanimationstart(IHTMLElement7 *iface, VARIANT *p)
5954 HTMLElement *This = impl_from_IHTMLElement7(iface);
5955 FIXME("(%p)->(%p)\n", This, p);
5956 return E_NOTIMPL;
5959 static HRESULT WINAPI HTMLElement7_put_onmsanimationend(IHTMLElement7 *iface, VARIANT v)
5961 HTMLElement *This = impl_from_IHTMLElement7(iface);
5962 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5963 return E_NOTIMPL;
5966 static HRESULT WINAPI HTMLElement7_get_onmsanimationend(IHTMLElement7 *iface, VARIANT *p)
5968 HTMLElement *This = impl_from_IHTMLElement7(iface);
5969 FIXME("(%p)->(%p)\n", This, p);
5970 return E_NOTIMPL;
5973 static HRESULT WINAPI HTMLElement7_put_onmsanimationiteration(IHTMLElement7 *iface, VARIANT v)
5975 HTMLElement *This = impl_from_IHTMLElement7(iface);
5976 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5977 return E_NOTIMPL;
5980 static HRESULT WINAPI HTMLElement7_get_onmsanimationiteration(IHTMLElement7 *iface, VARIANT *p)
5982 HTMLElement *This = impl_from_IHTMLElement7(iface);
5983 FIXME("(%p)->(%p)\n", This, p);
5984 return E_NOTIMPL;
5987 static HRESULT WINAPI HTMLElement7_put_oninvalid(IHTMLElement7 *iface, VARIANT v)
5989 HTMLElement *This = impl_from_IHTMLElement7(iface);
5990 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5991 return E_NOTIMPL;
5994 static HRESULT WINAPI HTMLElement7_get_oninvalid(IHTMLElement7 *iface, VARIANT *p)
5996 HTMLElement *This = impl_from_IHTMLElement7(iface);
5997 FIXME("(%p)->(%p)\n", This, p);
5998 return E_NOTIMPL;
6001 static HRESULT WINAPI HTMLElement7_put_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR v)
6003 HTMLElement *This = impl_from_IHTMLElement7(iface);
6004 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
6005 return E_NOTIMPL;
6008 static HRESULT WINAPI HTMLElement7_get_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR *p)
6010 HTMLElement *This = impl_from_IHTMLElement7(iface);
6011 FIXME("(%p)->(%p)\n", This, p);
6012 return E_NOTIMPL;
6015 static HRESULT WINAPI HTMLElement7_put_spellcheck(IHTMLElement7 *iface, VARIANT v)
6017 HTMLElement *This = impl_from_IHTMLElement7(iface);
6019 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
6021 if(!This->html_element) {
6022 FIXME("non-HTML element\n");
6023 return E_NOTIMPL;
6026 if(V_VT(&v) != VT_BOOL) {
6027 FIXME("unsupported argument %s\n", debugstr_variant(&v));
6028 return E_NOTIMPL;
6031 return map_nsresult(nsIDOMHTMLElement_SetSpellcheck(This->html_element, !!V_BOOL(&v)));
6034 static HRESULT WINAPI HTMLElement7_get_spellcheck(IHTMLElement7 *iface, VARIANT *p)
6036 HTMLElement *This = impl_from_IHTMLElement7(iface);
6037 cpp_bool spellcheck;
6038 nsresult nsres;
6040 TRACE("(%p)->(%p)\n", This, p);
6042 if(!This->html_element) {
6043 FIXME("non-HTML element\n");
6044 return E_NOTIMPL;
6047 nsres = nsIDOMHTMLElement_GetSpellcheck(This->html_element, &spellcheck);
6048 if(NS_FAILED(nsres))
6049 return map_nsresult(nsres);
6051 V_VT(p) = VT_BOOL;
6052 V_BOOL(p) = spellcheck ? VARIANT_TRUE : VARIANT_FALSE;
6053 return S_OK;
6056 static HRESULT WINAPI HTMLElement7_put_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT v)
6058 HTMLElement *This = impl_from_IHTMLElement7(iface);
6059 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6060 return E_NOTIMPL;
6063 static HRESULT WINAPI HTMLElement7_get_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT *p)
6065 HTMLElement *This = impl_from_IHTMLElement7(iface);
6066 FIXME("(%p)->(%p)\n", This, p);
6067 return E_NOTIMPL;
6070 static HRESULT WINAPI HTMLElement7_put_oncuechange(IHTMLElement7 *iface, VARIANT v)
6072 HTMLElement *This = impl_from_IHTMLElement7(iface);
6073 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6074 return E_NOTIMPL;
6077 static HRESULT WINAPI HTMLElement7_get_oncuechange(IHTMLElement7 *iface, VARIANT *p)
6079 HTMLElement *This = impl_from_IHTMLElement7(iface);
6080 FIXME("(%p)->(%p)\n", This, p);
6081 return E_NOTIMPL;
6084 static const IHTMLElement7Vtbl HTMLElement7Vtbl = {
6085 HTMLElement7_QueryInterface,
6086 HTMLElement7_AddRef,
6087 HTMLElement7_Release,
6088 HTMLElement7_GetTypeInfoCount,
6089 HTMLElement7_GetTypeInfo,
6090 HTMLElement7_GetIDsOfNames,
6091 HTMLElement7_Invoke,
6092 HTMLElement7_put_onmspointerdown,
6093 HTMLElement7_get_onmspointerdown,
6094 HTMLElement7_put_onmspointermove,
6095 HTMLElement7_get_onmspointermove,
6096 HTMLElement7_put_onmspointerup,
6097 HTMLElement7_get_onmspointerup,
6098 HTMLElement7_put_onmspointerover,
6099 HTMLElement7_get_onmspointerover,
6100 HTMLElement7_put_onmspointerout,
6101 HTMLElement7_get_onmspointerout,
6102 HTMLElement7_put_onmspointercancel,
6103 HTMLElement7_get_onmspointercancel,
6104 HTMLElement7_put_onmspointerhover,
6105 HTMLElement7_get_onmspointerhover,
6106 HTMLElement7_put_onmslostpointercapture,
6107 HTMLElement7_get_onmslostpointercapture,
6108 HTMLElement7_put_onmsgotpointercapture,
6109 HTMLElement7_get_onmsgotpointercapture,
6110 HTMLElement7_put_onmsgesturestart,
6111 HTMLElement7_get_onmsgesturestart,
6112 HTMLElement7_put_onmsgesturechange,
6113 HTMLElement7_get_onmsgesturechange,
6114 HTMLElement7_put_onmsgestureend,
6115 HTMLElement7_get_onmsgestureend,
6116 HTMLElement7_put_onmsgesturehold,
6117 HTMLElement7_get_onmsgesturehold,
6118 HTMLElement7_put_onmsgesturetap,
6119 HTMLElement7_get_onmsgesturetap,
6120 HTMLElement7_put_onmsgesturedoubletap,
6121 HTMLElement7_get_onmsgesturedoubletap,
6122 HTMLElement7_put_onmsinertiastart,
6123 HTMLElement7_get_onmsinertiastart,
6124 HTMLElement7_msSetPointerCapture,
6125 HTMLElement7_msReleasePointerCapture,
6126 HTMLElement7_put_onmstransitionstart,
6127 HTMLElement7_get_onmstransitionstart,
6128 HTMLElement7_put_onmstransitionend,
6129 HTMLElement7_get_onmstransitionend,
6130 HTMLElement7_put_onmsanimationstart,
6131 HTMLElement7_get_onmsanimationstart,
6132 HTMLElement7_put_onmsanimationend,
6133 HTMLElement7_get_onmsanimationend,
6134 HTMLElement7_put_onmsanimationiteration,
6135 HTMLElement7_get_onmsanimationiteration,
6136 HTMLElement7_put_oninvalid,
6137 HTMLElement7_get_oninvalid,
6138 HTMLElement7_put_xmsAcceleratorKey,
6139 HTMLElement7_get_xmsAcceleratorKey,
6140 HTMLElement7_put_spellcheck,
6141 HTMLElement7_get_spellcheck,
6142 HTMLElement7_put_onmsmanipulationstatechanged,
6143 HTMLElement7_get_onmsmanipulationstatechanged,
6144 HTMLElement7_put_oncuechange,
6145 HTMLElement7_get_oncuechange
6149 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
6151 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
6154 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
6156 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6157 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6160 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
6162 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6163 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6166 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
6168 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6169 return IHTMLElement_Release(&This->IHTMLElement_iface);
6172 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
6174 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6175 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6178 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
6179 LCID lcid, ITypeInfo **ppTInfo)
6181 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6182 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6185 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
6186 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6188 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6189 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6190 lcid, rgDispId);
6193 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
6194 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6196 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6197 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6198 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6201 HRESULT elem_unique_id(unsigned id, BSTR *p)
6203 WCHAR buf[32];
6205 swprintf(buf, ARRAY_SIZE(buf), L"ms__id%u", id);
6206 *p = SysAllocString(buf);
6207 return *p ? S_OK : E_OUTOFMEMORY;
6210 static void ensure_unique_id(HTMLElement *elem)
6212 if(!elem->unique_id)
6213 elem->unique_id = ++elem->node.doc->unique_id;
6216 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
6218 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6220 TRACE("(%p)->(%p)\n", This, p);
6222 ensure_unique_id(This);
6223 *p = This->unique_id;
6224 return S_OK;
6227 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
6229 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6231 TRACE("(%p)->(%p)\n", This, p);
6233 ensure_unique_id(This);
6234 return elem_unique_id(This->unique_id, p);
6237 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
6238 HTMLUniqueName_QueryInterface,
6239 HTMLUniqueName_AddRef,
6240 HTMLUniqueName_Release,
6241 HTMLUniqueName_GetTypeInfoCount,
6242 HTMLUniqueName_GetTypeInfo,
6243 HTMLUniqueName_GetIDsOfNames,
6244 HTMLUniqueName_Invoke,
6245 HTMLUniqueName_get_uniqueNumber,
6246 HTMLUniqueName_get_uniqueID
6249 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
6251 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
6254 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
6256 HTMLElement *This = impl_from_IElementSelector(iface);
6257 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6260 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
6262 HTMLElement *This = impl_from_IElementSelector(iface);
6263 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6266 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
6268 HTMLElement *This = impl_from_IElementSelector(iface);
6269 return IHTMLElement_Release(&This->IHTMLElement_iface);
6272 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
6274 HTMLElement *This = impl_from_IElementSelector(iface);
6275 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6278 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
6279 LCID lcid, ITypeInfo **ppTInfo)
6281 HTMLElement *This = impl_from_IElementSelector(iface);
6282 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6285 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
6286 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6288 HTMLElement *This = impl_from_IElementSelector(iface);
6289 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
6292 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
6293 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6295 HTMLElement *This = impl_from_IElementSelector(iface);
6296 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
6297 pDispParams, pVarResult, pExcepInfo, puArgErr);
6300 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
6302 HTMLElement *This = impl_from_IElementSelector(iface);
6303 nsIDOMElement *nselem;
6304 HTMLElement *elem;
6305 nsAString nsstr;
6306 nsresult nsres;
6307 HRESULT hres;
6309 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6311 if(!This->dom_element) {
6312 FIXME("comment element\n");
6313 return E_NOTIMPL;
6316 nsAString_InitDepend(&nsstr, v);
6317 nsres = nsIDOMElement_QuerySelector(This->dom_element, &nsstr, &nselem);
6318 nsAString_Finish(&nsstr);
6319 if(NS_FAILED(nsres)) {
6320 ERR("QuerySelector failed: %08lx\n", nsres);
6321 return E_FAIL;
6324 if(!nselem) {
6325 *pel = NULL;
6326 return S_OK;
6329 hres = get_element(nselem, &elem);
6330 nsIDOMElement_Release(nselem);
6331 if(FAILED(hres))
6332 return hres;
6334 *pel = &elem->IHTMLElement_iface;
6335 return S_OK;
6338 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
6340 HTMLElement *This = impl_from_IElementSelector(iface);
6341 nsIDOMNodeList *node_list;
6342 nsAString nsstr;
6343 HRESULT hres;
6345 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6347 if(!This->dom_element) {
6348 FIXME("comment element\n");
6349 return E_NOTIMPL;
6352 nsAString_InitDepend(&nsstr, v);
6353 hres = map_nsresult(nsIDOMElement_QuerySelectorAll(This->dom_element, &nsstr, &node_list));
6354 nsAString_Finish(&nsstr);
6355 if(FAILED(hres)) {
6356 ERR("QuerySelectorAll failed: %08lx\n", hres);
6357 return hres;
6360 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
6361 nsIDOMNodeList_Release(node_list);
6362 return hres;
6365 static const IElementSelectorVtbl ElementSelectorVtbl = {
6366 ElementSelector_QueryInterface,
6367 ElementSelector_AddRef,
6368 ElementSelector_Release,
6369 ElementSelector_GetTypeInfoCount,
6370 ElementSelector_GetTypeInfo,
6371 ElementSelector_GetIDsOfNames,
6372 ElementSelector_Invoke,
6373 ElementSelector_querySelector,
6374 ElementSelector_querySelectorAll
6377 static inline HTMLElement *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
6379 return CONTAINING_RECORD(iface, HTMLElement, IProvideMultipleClassInfo_iface);
6382 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
6383 REFIID riid, void **ppv)
6385 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6386 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6389 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
6391 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6392 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6395 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
6397 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6398 return IHTMLElement_Release(&This->IHTMLElement_iface);
6401 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
6403 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6404 TRACE("(%p)->(%p)\n", This, ppTI);
6405 return get_class_typeinfo(This->node.vtbl->clsid, ppTI);
6408 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
6410 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6411 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
6412 return E_NOTIMPL;
6415 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
6417 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6418 FIXME("(%p)->(%p)\n", This, pcti);
6419 *pcti = 1;
6420 return S_OK;
6423 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
6424 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
6426 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6427 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
6428 return E_NOTIMPL;
6431 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
6432 ProvideClassInfo_QueryInterface,
6433 ProvideClassInfo_AddRef,
6434 ProvideClassInfo_Release,
6435 ProvideClassInfo_GetClassInfo,
6436 ProvideClassInfo2_GetGUID,
6437 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
6438 ProvideMultipleClassInfo_GetInfoOfIndex
6441 static inline HTMLElement *impl_from_IElementTraversal(IElementTraversal *iface)
6443 return CONTAINING_RECORD(iface, HTMLElement, IElementTraversal_iface);
6446 static HRESULT WINAPI ElementTraversal_QueryInterface(IElementTraversal *iface, REFIID riid, void **ppv)
6448 HTMLElement *This = impl_from_IElementTraversal(iface);
6449 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6452 static ULONG WINAPI ElementTraversal_AddRef(IElementTraversal *iface)
6454 HTMLElement *This = impl_from_IElementTraversal(iface);
6456 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6459 static ULONG WINAPI ElementTraversal_Release(IElementTraversal *iface)
6461 HTMLElement *This = impl_from_IElementTraversal(iface);
6463 return IHTMLElement_Release(&This->IHTMLElement_iface);
6466 static HRESULT WINAPI ElementTraversal_GetTypeInfoCount(IElementTraversal *iface, UINT *pctinfo)
6468 HTMLElement *This = impl_from_IElementTraversal(iface);
6469 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6472 static HRESULT WINAPI ElementTraversal_GetTypeInfo(IElementTraversal *iface, UINT iTInfo,
6473 LCID lcid, ITypeInfo **ppTInfo)
6475 HTMLElement *This = impl_from_IElementTraversal(iface);
6476 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6479 static HRESULT WINAPI ElementTraversal_GetIDsOfNames(IElementTraversal *iface, REFIID riid,
6480 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6482 HTMLElement *This = impl_from_IElementTraversal(iface);
6483 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6484 lcid, rgDispId);
6487 static HRESULT WINAPI ElementTraversal_Invoke(IElementTraversal *iface, DISPID dispIdMember, REFIID riid,
6488 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6490 HTMLElement *This = impl_from_IElementTraversal(iface);
6491 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6492 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6495 static HRESULT WINAPI ElementTraversal_get_firstElementChild(IElementTraversal *iface, IHTMLElement **p)
6497 HTMLElement *This = impl_from_IElementTraversal(iface);
6498 nsIDOMElement *nselem = NULL;
6499 HTMLElement *elem;
6500 HRESULT hres;
6502 TRACE("(%p)->(%p)\n", This, p);
6504 if(!This->dom_element) {
6505 *p = NULL;
6506 return S_OK;
6509 nsIDOMElement_GetFirstElementChild(This->dom_element, &nselem);
6510 if(!nselem) {
6511 *p = NULL;
6512 return S_OK;
6515 hres = get_element(nselem, &elem);
6516 nsIDOMElement_Release(nselem);
6517 if(FAILED(hres))
6518 return hres;
6520 *p = &elem->IHTMLElement_iface;
6521 return S_OK;
6524 static HRESULT WINAPI ElementTraversal_get_lastElementChild(IElementTraversal *iface, IHTMLElement **p)
6526 HTMLElement *This = impl_from_IElementTraversal(iface);
6527 nsIDOMElement *nselem = NULL;
6528 HTMLElement *elem;
6529 HRESULT hres;
6531 TRACE("(%p)->(%p)\n", This, p);
6533 if(!This->dom_element) {
6534 *p = NULL;
6535 return S_OK;
6538 nsIDOMElement_GetLastElementChild(This->dom_element, &nselem);
6539 if(!nselem) {
6540 *p = NULL;
6541 return S_OK;
6544 hres = get_element(nselem, &elem);
6545 nsIDOMElement_Release(nselem);
6546 if(FAILED(hres))
6547 return hres;
6549 *p = &elem->IHTMLElement_iface;
6550 return S_OK;
6553 static HRESULT WINAPI ElementTraversal_get_previousElementSibling(IElementTraversal *iface, IHTMLElement **p)
6555 HTMLElement *This = impl_from_IElementTraversal(iface);
6556 nsIDOMElement *nselem = NULL;
6557 HTMLElement *elem;
6558 HRESULT hres;
6560 TRACE("(%p)->(%p)\n", This, p);
6562 if(!This->dom_element) {
6563 *p = NULL;
6564 return S_OK;
6567 nsIDOMElement_GetPreviousElementSibling(This->dom_element, &nselem);
6568 if(!nselem) {
6569 *p = NULL;
6570 return S_OK;
6573 hres = get_element(nselem, &elem);
6574 nsIDOMElement_Release(nselem);
6575 if(FAILED(hres))
6576 return hres;
6578 *p = &elem->IHTMLElement_iface;
6579 return S_OK;
6582 static HRESULT WINAPI ElementTraversal_get_nextElementSibling(IElementTraversal *iface, IHTMLElement **p)
6584 HTMLElement *This = impl_from_IElementTraversal(iface);
6585 nsIDOMElement *nselem = NULL;
6586 HTMLElement *elem;
6587 HRESULT hres;
6589 TRACE("(%p)->(%p)\n", This, p);
6591 if(!This->dom_element) {
6592 *p = NULL;
6593 return S_OK;
6596 nsIDOMElement_GetNextElementSibling(This->dom_element, &nselem);
6597 if(!nselem) {
6598 *p = NULL;
6599 return S_OK;
6602 hres = get_element(nselem, &elem);
6603 nsIDOMElement_Release(nselem);
6604 if(FAILED(hres))
6605 return hres;
6607 *p = &elem->IHTMLElement_iface;
6608 return S_OK;
6611 static HRESULT WINAPI ElementTraversal_get_childElementCount(IElementTraversal *iface, LONG *p)
6613 HTMLElement *This = impl_from_IElementTraversal(iface);
6614 UINT32 count = 0;
6616 TRACE("(%p)->(%p)\n", This, p);
6618 if(This->dom_element)
6619 nsIDOMElement_GetChildElementCount(This->dom_element, &count);
6621 *p = count;
6622 return S_OK;
6625 static const IElementTraversalVtbl ElementTraversalVtbl = {
6626 ElementTraversal_QueryInterface,
6627 ElementTraversal_AddRef,
6628 ElementTraversal_Release,
6629 ElementTraversal_GetTypeInfoCount,
6630 ElementTraversal_GetTypeInfo,
6631 ElementTraversal_GetIDsOfNames,
6632 ElementTraversal_Invoke,
6633 ElementTraversal_get_firstElementChild,
6634 ElementTraversal_get_lastElementChild,
6635 ElementTraversal_get_previousElementSibling,
6636 ElementTraversal_get_nextElementSibling,
6637 ElementTraversal_get_childElementCount
6640 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
6642 return CONTAINING_RECORD(iface, HTMLElement, node);
6645 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
6647 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6649 if(IsEqualGUID(&IID_IUnknown, riid)) {
6650 *ppv = &This->IHTMLElement_iface;
6651 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
6652 *ppv = &This->IHTMLElement_iface;
6653 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
6654 *ppv = &This->IHTMLElement_iface;
6655 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
6656 *ppv = &This->IHTMLElement2_iface;
6657 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
6658 *ppv = &This->IHTMLElement3_iface;
6659 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
6660 *ppv = &This->IHTMLElement4_iface;
6661 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
6662 *ppv = &This->IHTMLElement6_iface;
6663 }else if(IsEqualGUID(&IID_IHTMLElement7, riid)) {
6664 *ppv = &This->IHTMLElement7_iface;
6665 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
6666 *ppv = &This->IHTMLUniqueName_iface;
6667 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
6668 *ppv = &This->IElementSelector_iface;
6669 }else if(IsEqualGUID(&IID_IElementTraversal, riid)) {
6670 *ppv = &This->IElementTraversal_iface;
6671 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
6672 *ppv = &This->cp_container.IConnectionPointContainer_iface;
6673 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
6674 *ppv = &This->IProvideMultipleClassInfo_iface;
6675 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
6676 *ppv = &This->IProvideMultipleClassInfo_iface;
6677 }else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid)) {
6678 *ppv = &This->IProvideMultipleClassInfo_iface;
6679 }else if(IsEqualGUID(&IID_IWineHTMLElementPrivate, riid)) {
6680 *ppv = &This->IWineHTMLElementPrivate_iface;
6681 }else {
6682 return HTMLDOMNode_QI(&This->node, riid, ppv);
6685 IUnknown_AddRef((IUnknown*)*ppv);
6686 return S_OK;
6689 void HTMLElement_destructor(HTMLDOMNode *iface)
6691 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6693 ConnectionPointContainer_Destroy(&This->cp_container);
6695 if(This->style) {
6696 This->style->elem = NULL;
6697 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
6699 if(This->runtime_style) {
6700 This->runtime_style->elem = NULL;
6701 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
6703 if(This->attrs) {
6704 HTMLDOMAttribute *attr;
6706 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
6707 attr->elem = NULL;
6709 This->attrs->elem = NULL;
6710 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
6713 heap_free(This->filter);
6715 HTMLDOMNode_destructor(&This->node);
6718 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
6720 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6721 HTMLElement *new_elem;
6722 HRESULT hres;
6724 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
6725 if(FAILED(hres))
6726 return hres;
6728 if(This->filter) {
6729 new_elem->filter = heap_strdupW(This->filter);
6730 if(!new_elem->filter) {
6731 IHTMLElement_Release(&This->IHTMLElement_iface);
6732 return E_OUTOFMEMORY;
6736 *ret = &new_elem->node;
6737 return S_OK;
6740 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
6742 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6744 switch(eid) {
6745 case EVENTID_KEYDOWN: {
6746 nsIDOMKeyEvent *key_event;
6747 nsresult nsres;
6749 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
6750 if(NS_SUCCEEDED(nsres)) {
6751 UINT32 code = 0;
6753 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
6755 if(code == VK_F1 /* DOM_VK_F1 */) {
6756 DOMEvent *help_event;
6757 HRESULT hres;
6759 TRACE("F1 pressed\n");
6761 hres = create_document_event(This->node.doc, EVENTID_HELP, &help_event);
6762 if(SUCCEEDED(hres)) {
6763 dispatch_event(&This->node.event_target, help_event);
6764 IDOMEvent_Release(&help_event->IDOMEvent_iface);
6766 *prevent_default = TRUE;
6769 nsIDOMKeyEvent_Release(key_event);
6774 return S_OK;
6777 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
6779 const cpc_entry_t HTMLElement_cpc[] = {
6780 HTMLELEMENT_CPC,
6781 {NULL}
6784 static const NodeImplVtbl HTMLElementImplVtbl = {
6785 &CLSID_HTMLUnknownElement,
6786 HTMLElement_QI,
6787 HTMLElement_destructor,
6788 HTMLElement_cpc,
6789 HTMLElement_clone,
6790 HTMLElement_handle_event,
6791 HTMLElement_get_attr_col
6794 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
6796 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
6799 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
6800 DWORD grfdex, DISPID *pid)
6802 HTMLElement *This = impl_from_DispatchEx(dispex);
6804 if(This->node.vtbl->get_dispid)
6805 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
6807 return DISP_E_UNKNOWNNAME;
6810 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
6811 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
6812 IServiceProvider *caller)
6814 HTMLElement *This = impl_from_DispatchEx(dispex);
6816 if(This->node.vtbl->invoke)
6817 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
6818 params, res, ei, caller);
6820 ERR("(%p): element has no invoke method\n", This);
6821 return E_NOTIMPL;
6824 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
6826 HTMLElement *This = impl_from_DispatchEx(dispex);
6827 nsIDOMMozNamedAttrMap *attrs;
6828 nsIDOMAttr *attr;
6829 nsAString nsstr;
6830 const PRUnichar *str;
6831 BSTR name;
6832 VARIANT value;
6833 unsigned i;
6834 UINT32 len;
6835 DISPID id;
6836 nsresult nsres;
6837 HRESULT hres;
6839 if(!This->dom_element)
6840 return S_FALSE;
6842 if(dispex_compat_mode(dispex) >= COMPAT_MODE_IE9)
6843 return S_OK;
6845 nsres = nsIDOMElement_GetAttributes(This->dom_element, &attrs);
6846 if(NS_FAILED(nsres))
6847 return E_FAIL;
6849 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
6850 if(NS_FAILED(nsres)) {
6851 nsIDOMMozNamedAttrMap_Release(attrs);
6852 return E_FAIL;
6855 nsAString_Init(&nsstr, NULL);
6856 for(i=0; i<len; i++) {
6857 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
6858 if(NS_FAILED(nsres))
6859 continue;
6861 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
6862 if(NS_FAILED(nsres)) {
6863 nsIDOMAttr_Release(attr);
6864 continue;
6867 nsAString_GetData(&nsstr, &str);
6868 name = SysAllocString(str);
6869 if(!name) {
6870 nsIDOMAttr_Release(attr);
6871 continue;
6874 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
6875 if(hres != DISP_E_UNKNOWNNAME) {
6876 nsIDOMAttr_Release(attr);
6877 SysFreeString(name);
6878 continue;
6881 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
6882 nsIDOMAttr_Release(attr);
6883 if(NS_FAILED(nsres)) {
6884 SysFreeString(name);
6885 continue;
6888 nsAString_GetData(&nsstr, &str);
6889 V_VT(&value) = VT_BSTR;
6890 if(*str) {
6891 V_BSTR(&value) = SysAllocString(str);
6892 if(!V_BSTR(&value)) {
6893 SysFreeString(name);
6894 continue;
6896 } else
6897 V_BSTR(&value) = NULL;
6899 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
6900 SysFreeString(name);
6901 VariantClear(&value);
6903 nsAString_Finish(&nsstr);
6905 nsIDOMMozNamedAttrMap_Release(attrs);
6906 return S_OK;
6909 static nsISupports *HTMLElement_get_gecko_target(DispatchEx *dispex)
6911 HTMLElement *This = impl_from_DispatchEx(dispex);
6912 return (nsISupports*)This->node.nsnode;
6915 static void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
6917 HTMLElement *This = impl_from_DispatchEx(dispex);
6918 ensure_doc_nsevent_handler(This->node.doc, This->node.nsnode, eid);
6921 static HRESULT HTMLElement_handle_event_default(DispatchEx *dispex, eventid_t eid, nsIDOMEvent *nsevent, BOOL *prevent_default)
6923 HTMLElement *This = impl_from_DispatchEx(dispex);
6925 if(!This->node.vtbl->handle_event)
6926 return S_OK;
6927 return This->node.vtbl->handle_event(&This->node, eid, nsevent, prevent_default);
6930 static EventTarget *HTMLElement_get_parent_event_target(DispatchEx *dispex)
6932 HTMLElement *This = impl_from_DispatchEx(dispex);
6933 HTMLDOMNode *node;
6934 nsIDOMNode *nsnode;
6935 nsresult nsres;
6936 HRESULT hres;
6938 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
6939 assert(nsres == NS_OK);
6940 if(!nsnode)
6941 return NULL;
6943 hres = get_node(nsnode, TRUE, &node);
6944 nsIDOMNode_Release(nsnode);
6945 if(FAILED(hres))
6946 return NULL;
6948 return &node->event_target;
6951 static ConnectionPointContainer *HTMLElement_get_cp_container(DispatchEx *dispex)
6953 HTMLElement *This = impl_from_DispatchEx(dispex);
6954 IConnectionPointContainer_AddRef(&This->cp_container.IConnectionPointContainer_iface);
6955 return &This->cp_container;
6958 static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6960 HTMLElement *This = impl_from_DispatchEx(dispex);
6961 return default_set_current_event(This->node.doc->window, event);
6964 static HRESULT IHTMLElement6_hasAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
6965 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6967 VARIANT args[2];
6968 HRESULT hres;
6969 DISPPARAMS new_dp = { args, NULL, 2, 0 };
6971 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
6972 return S_FALSE;
6974 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
6975 case VT_EMPTY:
6976 case VT_BSTR:
6977 case VT_NULL:
6978 return S_FALSE;
6979 default:
6980 break;
6983 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
6984 if(FAILED(hres))
6985 return hres;
6986 args[0] = dp->rgvarg[dp->cArgs - 2];
6988 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_HASATTRIBUTENS, &new_dp, res, ei, caller);
6989 VariantClear(&args[1]);
6990 return hres;
6993 static HRESULT IHTMLElement6_getAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
6994 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6996 VARIANT args[2];
6997 HRESULT hres;
6998 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7000 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7001 return S_FALSE;
7003 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7004 case VT_EMPTY:
7005 case VT_BSTR:
7006 case VT_NULL:
7007 return S_FALSE;
7008 default:
7009 break;
7012 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7013 if(FAILED(hres))
7014 return hres;
7015 args[0] = dp->rgvarg[dp->cArgs - 2];
7017 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_GETATTRIBUTENS, &new_dp, res, ei, caller);
7018 VariantClear(&args[1]);
7019 return hres;
7022 static HRESULT IHTMLElement6_setAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7023 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7025 BOOL ns_conv = FALSE, val_conv = FALSE;
7026 VARIANT args[3];
7027 HRESULT hres;
7028 DISPPARAMS new_dp = { args, NULL, 3, 0 };
7030 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 3 || dp->cNamedArgs)
7031 return S_FALSE;
7033 if(dispex_compat_mode(dispex) < COMPAT_MODE_IE10)
7034 args[2] = dp->rgvarg[dp->cArgs - 1];
7035 else {
7036 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7037 case VT_EMPTY:
7038 case VT_BSTR:
7039 case VT_NULL:
7040 args[2] = dp->rgvarg[dp->cArgs - 1];
7041 break;
7042 default:
7043 hres = change_type(&args[2], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7044 if(FAILED(hres))
7045 return hres;
7046 ns_conv = TRUE;
7047 break;
7051 switch(V_VT(&dp->rgvarg[dp->cArgs - 3])) {
7052 case VT_EMPTY:
7053 case VT_BSTR:
7054 case VT_NULL:
7055 if(!ns_conv)
7056 return S_FALSE;
7057 args[0] = dp->rgvarg[dp->cArgs - 3];
7058 break;
7059 default:
7060 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 3], VT_BSTR, caller);
7061 if(FAILED(hres)) {
7062 if(ns_conv)
7063 VariantClear(&args[2]);
7064 return hres;
7066 val_conv = TRUE;
7067 break;
7070 args[1] = dp->rgvarg[dp->cArgs - 2];
7071 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_SETATTRIBUTENS, &new_dp, res, ei, caller);
7072 if(ns_conv) VariantClear(&args[2]);
7073 if(val_conv) VariantClear(&args[0]);
7074 return hres;
7077 static HRESULT IHTMLElement6_removeAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7078 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7080 VARIANT args[2];
7081 HRESULT hres;
7082 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7084 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7085 return S_FALSE;
7087 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7088 case VT_EMPTY:
7089 case VT_BSTR:
7090 case VT_NULL:
7091 return S_FALSE;
7092 default:
7093 break;
7096 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7097 if(FAILED(hres))
7098 return hres;
7099 args[0] = dp->rgvarg[dp->cArgs - 2];
7101 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, &new_dp, res, ei, caller);
7102 VariantClear(&args[1]);
7103 return hres;
7106 static HRESULT IHTMLElement6_setAttribute_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7107 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7109 VARIANT args[2];
7110 HRESULT hres;
7111 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7113 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7114 return S_FALSE;
7116 switch(V_VT(&dp->rgvarg[dp->cArgs - 2])) {
7117 case VT_EMPTY:
7118 case VT_BSTR:
7119 case VT_NULL:
7120 return S_FALSE;
7121 default:
7122 break;
7125 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 2], VT_BSTR, caller);
7126 if(FAILED(hres))
7127 return hres;
7128 args[1] = dp->rgvarg[dp->cArgs - 1];
7130 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, &new_dp, res, ei, caller);
7131 VariantClear(&args[0]);
7132 return hres;
7135 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
7137 static const dispex_hook_t elem6_ie9_hooks[] = {
7138 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
7139 {DISPID_UNKNOWN}
7141 static const dispex_hook_t elem6_ie10_hooks[] = {
7142 {DISPID_IHTMLELEMENT6_HASATTRIBUTENS, IHTMLElement6_hasAttributeNS_hook},
7143 {DISPID_IHTMLELEMENT6_GETATTRIBUTENS, IHTMLElement6_getAttributeNS_hook},
7144 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
7145 {DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, IHTMLElement6_removeAttributeNS_hook},
7146 {DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, IHTMLElement6_setAttribute_hook},
7147 {DISPID_UNKNOWN}
7149 static const dispex_hook_t elem2_ie11_hooks[] = {
7150 {DISPID_IHTMLELEMENT2_DOSCROLL, NULL},
7151 {DISPID_IHTMLELEMENT2_READYSTATE, NULL},
7152 {DISPID_UNKNOWN}
7155 HTMLDOMNode_init_dispex_info(info, mode);
7157 dispex_info_add_interface(info, IHTMLElement2_tid, mode >= COMPAT_MODE_IE11 ? elem2_ie11_hooks : NULL);
7159 if(mode >= COMPAT_MODE_IE8)
7160 dispex_info_add_interface(info, IElementSelector_tid, NULL);
7162 if(mode >= COMPAT_MODE_IE9) {
7163 dispex_info_add_interface(info, IHTMLElement6_tid, mode >= COMPAT_MODE_IE10 ? elem6_ie10_hooks : elem6_ie9_hooks);
7164 dispex_info_add_interface(info, IElementTraversal_tid, NULL);
7167 if(mode >= COMPAT_MODE_IE10)
7169 dispex_info_add_interface(info, IHTMLElement7_tid, NULL);
7170 dispex_info_add_interface(info, IWineHTMLElementPrivate_tid, NULL);
7174 static const tid_t HTMLElement_iface_tids[] = {
7175 HTMLELEMENT_TIDS,
7179 static event_target_vtbl_t HTMLElement_event_target_vtbl = {
7181 NULL,
7182 HTMLElement_get_dispid,
7183 HTMLElement_invoke,
7184 NULL,
7185 HTMLElement_populate_props
7187 HTMLElement_get_gecko_target,
7188 HTMLElement_bind_event,
7189 HTMLElement_get_parent_event_target,
7190 HTMLElement_handle_event_default,
7191 HTMLElement_get_cp_container,
7192 HTMLElement_set_current_event
7195 struct token_list {
7196 DispatchEx dispex;
7197 IWineDOMTokenList IWineDOMTokenList_iface;
7198 IHTMLElement *element;
7200 LONG ref;
7203 static inline struct token_list *impl_from_IWineDOMTokenList(IWineDOMTokenList *iface)
7205 return CONTAINING_RECORD(iface, struct token_list, IWineDOMTokenList_iface);
7208 static HRESULT WINAPI token_list_QueryInterface(IWineDOMTokenList *iface, REFIID riid, void **ppv)
7210 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7212 TRACE("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
7214 if(IsEqualGUID(&IID_IUnknown, riid)) {
7215 *ppv = &token_list->IWineDOMTokenList_iface;
7216 }else if(IsEqualGUID(&IID_IWineDOMTokenList, riid)) {
7217 *ppv = &token_list->IWineDOMTokenList_iface;
7218 }else if(dispex_query_interface(&token_list->dispex, riid, ppv)) {
7219 return *ppv ? S_OK : E_NOINTERFACE;
7220 }else {
7221 WARN("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
7222 *ppv = NULL;
7223 return E_NOINTERFACE;
7226 IUnknown_AddRef((IUnknown*)*ppv);
7227 return S_OK;
7230 static ULONG WINAPI token_list_AddRef(IWineDOMTokenList *iface)
7232 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7233 LONG ref = InterlockedIncrement(&token_list->ref);
7235 TRACE("(%p) ref=%ld\n", token_list, ref);
7237 return ref;
7240 static ULONG WINAPI token_list_Release(IWineDOMTokenList *iface)
7242 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7243 LONG ref = InterlockedDecrement(&token_list->ref);
7245 TRACE("(%p) ref=%ld\n", token_list, ref);
7247 if(!ref) {
7248 IHTMLElement_Release(token_list->element);
7249 release_dispex(&token_list->dispex);
7250 heap_free(token_list);
7253 return ref;
7256 static HRESULT WINAPI token_list_GetTypeInfoCount(IWineDOMTokenList *iface, UINT *pctinfo)
7258 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7259 FIXME("(%p)->(%p)\n", token_list, pctinfo);
7260 return E_NOTIMPL;
7263 static HRESULT WINAPI token_list_GetTypeInfo(IWineDOMTokenList *iface, UINT iTInfo,
7264 LCID lcid, ITypeInfo **ppTInfo)
7266 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7268 return IDispatchEx_GetTypeInfo(&token_list->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7271 static HRESULT WINAPI token_list_GetIDsOfNames(IWineDOMTokenList *iface, REFIID riid,
7272 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
7274 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7276 return IDispatchEx_GetIDsOfNames(&token_list->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7277 lcid, rgDispId);
7280 static HRESULT WINAPI token_list_Invoke(IWineDOMTokenList *iface, DISPID dispIdMember,
7281 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7282 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7284 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7286 return IDispatchEx_Invoke(&token_list->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
7287 pDispParams, pVarResult, pExcepInfo, puArgErr);
7290 static const WCHAR *find_token(const WCHAR *list, const WCHAR *token, unsigned int token_len)
7292 const WCHAR *ptr, *next;
7294 if (!list || !token)
7295 return NULL;
7297 ptr = list;
7298 while (*ptr)
7300 while (iswspace(*ptr))
7301 ++ptr;
7302 if (!*ptr)
7303 break;
7304 next = ptr + 1;
7305 while (*next && !iswspace(*next))
7306 ++next;
7308 if (next - ptr == token_len && !wcsncmp(ptr, token, token_len))
7309 return ptr;
7310 ptr = next;
7312 return NULL;
7315 static HRESULT token_list_add_remove(IWineDOMTokenList *iface, BSTR token, BOOL remove)
7317 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7318 unsigned int i, len, old_len, new_len;
7319 const WCHAR *old_pos;
7320 BSTR new, old;
7321 HRESULT hr;
7323 TRACE("iface %p, token %s, remove %#x.\n", iface, debugstr_w(token), remove);
7325 len = token ? lstrlenW(token) : 0;
7326 if (!len)
7328 WARN("Empty token.\n");
7329 return E_INVALIDARG;
7332 for (i = 0; i < len; ++i)
7333 if (iswspace(token[i]))
7335 WARN("Token has spaces.\n");
7336 return E_INVALIDARG;
7339 if (FAILED(hr = IHTMLElement_get_className(token_list->element, &old)))
7340 return hr;
7342 TRACE("old %s.\n", debugstr_w(old));
7344 if (((old_pos = find_token(old, token, len)) && !remove)
7345 || (!old_pos && remove))
7347 SysFreeString(old);
7348 return S_OK;
7351 old_len = old ? lstrlenW(old) : 0;
7352 if (remove)
7354 while (old_pos != old && iswspace(old_pos[-1]))
7356 --old_pos;
7357 ++len;
7359 while (iswspace(old_pos[len]))
7360 ++len;
7362 if (old_pos != old && old_pos[len])
7363 --len;
7365 new_len = old_len - len;
7367 else
7369 new_len = old_len + len + !!old_len;
7372 if (!(new = SysAllocStringLen(NULL, new_len)))
7374 ERR("No memory.\n");
7375 SysFreeString(old);
7376 return E_OUTOFMEMORY;
7379 if (remove)
7381 memcpy(new, old, sizeof(*new) * (old_pos - old));
7382 memcpy(new + (old_pos - old), old_pos + len, sizeof(*new) * (old_len - (old_pos - old) - len + 1));
7384 else
7386 memcpy(new, old, sizeof(*new) * old_len);
7387 if (old_len)
7388 new[old_len++]= L' ';
7389 memcpy(new + old_len, token, sizeof(*new) * len);
7390 new[old_len + len] = 0;
7393 SysFreeString(old);
7395 TRACE("new %s.\n", debugstr_w(new));
7397 hr = IHTMLElement_put_className(token_list->element, new);
7398 SysFreeString(new);
7399 return hr;
7402 static HRESULT WINAPI token_list_add(IWineDOMTokenList *iface, BSTR token)
7404 return token_list_add_remove(iface, token, FALSE);
7407 static HRESULT WINAPI token_list_remove(IWineDOMTokenList *iface, BSTR token)
7409 return token_list_add_remove(iface, token, TRUE);
7412 static HRESULT WINAPI token_list_toString(IWineDOMTokenList *iface, BSTR *String)
7414 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7416 TRACE("(%p)->(%p)\n", token_list, String);
7418 return IHTMLElement_get_className(token_list->element, String);
7421 static const IWineDOMTokenListVtbl WineDOMTokenListVtbl = {
7422 token_list_QueryInterface,
7423 token_list_AddRef,
7424 token_list_Release,
7425 token_list_GetTypeInfoCount,
7426 token_list_GetTypeInfo,
7427 token_list_GetIDsOfNames,
7428 token_list_Invoke,
7429 token_list_add,
7430 token_list_remove,
7431 token_list_toString
7434 static inline struct token_list *token_list_from_DispatchEx(DispatchEx *iface)
7436 return CONTAINING_RECORD(iface, struct token_list, dispex);
7439 static HRESULT token_list_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params,
7440 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7442 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7443 HRESULT hres;
7445 switch(flags) {
7446 case DISPATCH_PROPERTYGET:
7447 hres = IHTMLElement_get_className(token_list->element, &V_BSTR(res));
7448 if(FAILED(hres))
7449 return hres;
7450 V_VT(res) = VT_BSTR;
7451 break;
7452 default:
7453 FIXME("Unimplemented flags %x\n", flags);
7454 return E_NOTIMPL;
7457 return S_OK;
7460 static const dispex_static_data_vtbl_t token_list_dispex_vtbl = {
7461 token_list_value
7464 static const tid_t token_list_iface_tids[] = {
7465 IWineDOMTokenList_tid,
7468 static dispex_static_data_t token_list_dispex = {
7469 L"DOMTokenList",
7470 &token_list_dispex_vtbl,
7471 IWineDOMTokenList_tid,
7472 token_list_iface_tids
7475 static HRESULT create_token_list(compat_mode_t compat_mode, IHTMLElement *element, IWineDOMTokenList **ret)
7477 struct token_list *obj;
7479 obj = heap_alloc_zero(sizeof(*obj));
7480 if(!obj)
7482 ERR("No memory.\n");
7483 return E_OUTOFMEMORY;
7486 obj->IWineDOMTokenList_iface.lpVtbl = &WineDOMTokenListVtbl;
7487 obj->ref = 1;
7488 init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineDOMTokenList_iface, &token_list_dispex, compat_mode);
7489 IHTMLElement_AddRef(element);
7490 obj->element = element;
7492 *ret = &obj->IWineDOMTokenList_iface;
7493 return S_OK;
7496 static inline HTMLElement *impl_from_IWineHTMLElementPrivateVtbl(IWineHTMLElementPrivate *iface)
7498 return CONTAINING_RECORD(iface, HTMLElement, IWineHTMLElementPrivate_iface);
7501 static HRESULT WINAPI htmlelement_private_QueryInterface(IWineHTMLElementPrivate *iface,
7502 REFIID riid, void **ppv)
7504 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7506 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
7509 static ULONG WINAPI htmlelement_private_AddRef(IWineHTMLElementPrivate *iface)
7511 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7513 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
7516 static ULONG WINAPI htmlelement_private_Release(IWineHTMLElementPrivate *iface)
7518 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7520 return IHTMLElement_Release(&This->IHTMLElement_iface);
7523 static HRESULT WINAPI htmlelement_private_GetTypeInfoCount(IWineHTMLElementPrivate *iface, UINT *pctinfo)
7525 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7527 return HTMLElement_GetTypeInfoCount(&This->IHTMLElement_iface, pctinfo);
7530 static HRESULT WINAPI htmlelement_private_GetTypeInfo(IWineHTMLElementPrivate *iface, UINT iTInfo,
7531 LCID lcid, ITypeInfo **ppTInfo)
7533 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7535 return HTMLElement_GetTypeInfo(&This->IHTMLElement_iface, iTInfo, lcid, ppTInfo);
7538 static HRESULT WINAPI htmlelement_private_GetIDsOfNames(IWineHTMLElementPrivate *iface, REFIID riid,
7539 LPOLESTR *rgszNames, UINT cNames,
7540 LCID lcid, DISPID *rgDispId)
7542 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7544 return HTMLElement_GetIDsOfNames(&This->IHTMLElement_iface, riid, rgszNames, cNames, lcid,
7545 rgDispId);
7548 static HRESULT WINAPI htmlelement_private_Invoke(IWineHTMLElementPrivate *iface, DISPID dispIdMember,
7549 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7550 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7552 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7554 return HTMLElement_Invoke(&This->IHTMLElement_iface, dispIdMember, riid, lcid, wFlags,
7555 pDispParams, pVarResult, pExcepInfo, puArgErr);
7558 static HRESULT WINAPI htmlelement_private_get_classList(IWineHTMLElementPrivate *iface, IDispatch **class_list)
7560 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7562 TRACE("iface %p, class_list %p.\n", iface, class_list);
7564 return create_token_list(dispex_compat_mode(&This->node.event_target.dispex), &This->IHTMLElement_iface,
7565 (IWineDOMTokenList **)class_list);
7568 static const IWineHTMLElementPrivateVtbl WineHTMLElementPrivateVtbl = {
7569 htmlelement_private_QueryInterface,
7570 htmlelement_private_AddRef,
7571 htmlelement_private_Release,
7572 htmlelement_private_GetTypeInfoCount,
7573 htmlelement_private_GetTypeInfo,
7574 htmlelement_private_GetIDsOfNames,
7575 htmlelement_private_Invoke,
7576 htmlelement_private_get_classList,
7579 static dispex_static_data_t HTMLElement_dispex = {
7580 L"HTMLElement",
7581 &HTMLElement_event_target_vtbl.dispex_vtbl,
7582 DispHTMLUnknownElement_tid,
7583 HTMLElement_iface_tids,
7584 HTMLElement_init_dispex_info
7587 static dispex_static_data_t HTMLUnknownElement_dispex = {
7588 L"HTMLUnknownElement",
7589 &HTMLElement_event_target_vtbl.dispex_vtbl,
7590 DispHTMLUnknownElement_tid,
7591 HTMLElement_iface_tids,
7592 HTMLElement_init_dispex_info
7595 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMElement *nselem, dispex_static_data_t *dispex_data)
7597 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
7598 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
7599 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
7600 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
7601 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
7602 This->IHTMLElement7_iface.lpVtbl = &HTMLElement7Vtbl;
7603 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
7604 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
7605 This->IElementTraversal_iface.lpVtbl = &ElementTraversalVtbl;
7606 This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
7607 This->IWineHTMLElementPrivate_iface.lpVtbl = &WineHTMLElementPrivateVtbl;
7609 if(dispex_data && !dispex_data->vtbl)
7610 dispex_data->vtbl = &HTMLElement_event_target_vtbl.dispex_vtbl;
7612 if(nselem) {
7613 nsIDOMHTMLElement *html_element;
7614 nsresult nsres;
7616 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data ? dispex_data : &HTMLUnknownElement_dispex);
7618 /* No AddRef, share reference with HTMLDOMNode */
7619 assert((nsIDOMNode*)nselem == This->node.nsnode);
7620 This->dom_element = nselem;
7622 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)&html_element);
7623 if(NS_SUCCEEDED(nsres)) {
7624 This->html_element = html_element;
7625 /* share reference with HTMLDOMNode */
7626 assert((nsIDOMNode*)html_element == This->node.nsnode);
7627 nsIDOMHTMLElement_Release(html_element);
7631 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
7634 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
7636 nsIDOMElement *nselem;
7637 nsAString tag_name_str;
7638 const PRUnichar *tag_name;
7639 const tag_desc_t *tag;
7640 HTMLElement *elem;
7641 nsresult nsres;
7642 HRESULT hres;
7644 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
7645 if(NS_FAILED(nsres)) {
7646 ERR("no nsIDOMElement iface\n");
7647 return E_FAIL;
7650 nsAString_Init(&tag_name_str, NULL);
7651 nsIDOMElement_GetTagName(nselem, &tag_name_str);
7653 nsAString_GetData(&tag_name_str, &tag_name);
7655 tag = get_tag_desc(tag_name);
7656 if(tag) {
7657 hres = tag->constructor(doc, nselem, &elem);
7658 }else {
7659 nsIDOMSVGElement *svg_element;
7661 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMSVGElement, (void**)&svg_element);
7662 if(NS_SUCCEEDED(nsres)) {
7663 hres = create_svg_element(doc, svg_element, tag_name, &elem);
7664 nsIDOMSVGElement_Release(svg_element);
7665 }else if(use_generic) {
7666 hres = HTMLGenericElement_Create(doc, nselem, &elem);
7667 }else {
7668 elem = heap_alloc_zero(sizeof(HTMLElement));
7669 if(elem) {
7670 elem->node.vtbl = &HTMLElementImplVtbl;
7671 HTMLElement_Init(elem, doc, nselem, &HTMLUnknownElement_dispex);
7672 hres = S_OK;
7673 }else {
7674 hres = E_OUTOFMEMORY;
7679 TRACE("%s ret %p\n", debugstr_w(tag_name), elem);
7681 nsIDOMElement_Release(nselem);
7682 nsAString_Finish(&tag_name_str);
7683 if(FAILED(hres))
7684 return hres;
7686 *ret = elem;
7687 return S_OK;
7690 static HRESULT HTMLElement_Ctor(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
7692 HTMLElement *ret;
7694 ret = heap_alloc_zero(sizeof(*ret));
7695 if(!ret)
7696 return E_OUTOFMEMORY;
7698 ret->node.vtbl = &HTMLElementImplVtbl;
7699 HTMLElement_Init(ret, doc, nselem, &HTMLElement_dispex);
7701 *elem = ret;
7702 return S_OK;
7705 HRESULT get_element(nsIDOMElement *nselem, HTMLElement **ret)
7707 HTMLDOMNode *node;
7708 HRESULT hres;
7710 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
7711 if(FAILED(hres))
7712 return hres;
7714 *ret = impl_from_HTMLDOMNode(node);
7715 return S_OK;
7718 /* interface IHTMLFiltersCollection */
7719 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
7721 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7723 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
7725 if(IsEqualGUID(&IID_IUnknown, riid)) {
7726 *ppv = &This->IHTMLFiltersCollection_iface;
7727 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
7728 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
7729 *ppv = &This->IHTMLFiltersCollection_iface;
7730 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
7731 return *ppv ? S_OK : E_NOINTERFACE;
7732 }else {
7733 *ppv = NULL;
7734 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
7735 return E_NOINTERFACE;
7738 IUnknown_AddRef((IUnknown*)*ppv);
7739 return S_OK;
7742 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
7744 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7745 LONG ref = InterlockedIncrement(&This->ref);
7747 TRACE("(%p) ref=%ld\n", This, ref);
7749 return ref;
7752 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
7754 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7755 LONG ref = InterlockedDecrement(&This->ref);
7757 TRACE("(%p) ref=%ld\n", This, ref);
7759 if(!ref)
7761 heap_free(This);
7764 return ref;
7767 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
7769 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7770 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
7773 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
7774 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
7776 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7777 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7780 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
7781 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
7782 LCID lcid, DISPID *rgDispId)
7784 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7785 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7786 lcid, rgDispId);
7789 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
7790 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
7791 EXCEPINFO *pExcepInfo, UINT *puArgErr)
7793 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7794 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
7795 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
7798 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
7800 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7802 if(!p)
7803 return E_POINTER;
7805 FIXME("(%p)->(%p) Always returning 0\n", This, p);
7806 *p = 0;
7808 return S_OK;
7811 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
7813 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7814 FIXME("(%p)->(%p)\n", This, p);
7815 return E_NOTIMPL;
7818 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
7820 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7821 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
7822 return E_NOTIMPL;
7825 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
7826 HTMLFiltersCollection_QueryInterface,
7827 HTMLFiltersCollection_AddRef,
7828 HTMLFiltersCollection_Release,
7829 HTMLFiltersCollection_GetTypeInfoCount,
7830 HTMLFiltersCollection_GetTypeInfo,
7831 HTMLFiltersCollection_GetIDsOfNames,
7832 HTMLFiltersCollection_Invoke,
7833 HTMLFiltersCollection_get_length,
7834 HTMLFiltersCollection_get__newEnum,
7835 HTMLFiltersCollection_item
7838 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
7840 WCHAR *ptr;
7841 int idx = 0;
7843 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
7844 idx = idx*10 + (*ptr-'0');
7845 if(*ptr)
7846 return DISP_E_UNKNOWNNAME;
7848 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
7849 TRACE("ret %lx\n", *dispid);
7850 return S_OK;
7853 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
7854 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7856 TRACE("(%p)->(%lx %lx %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
7858 V_VT(res) = VT_DISPATCH;
7859 V_DISPATCH(res) = NULL;
7861 FIXME("always returning NULL\n");
7863 return S_OK;
7866 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
7867 NULL,
7868 HTMLFiltersCollection_get_dispid,
7869 HTMLFiltersCollection_invoke,
7870 NULL
7873 static const tid_t HTMLFiltersCollection_iface_tids[] = {
7874 IHTMLFiltersCollection_tid,
7877 static dispex_static_data_t HTMLFiltersCollection_dispex = {
7878 L"FiltersCollection",
7879 &HTMLFiltersCollection_dispex_vtbl,
7880 IHTMLFiltersCollection_tid,
7881 HTMLFiltersCollection_iface_tids
7884 static HRESULT create_filters_collection(compat_mode_t compat_mode, IHTMLFiltersCollection **ret)
7886 HTMLFiltersCollection *collection;
7888 if(!(collection = heap_alloc(sizeof(HTMLFiltersCollection))))
7889 return E_OUTOFMEMORY;
7891 collection->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
7892 collection->ref = 1;
7894 init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLFiltersCollection_iface,
7895 &HTMLFiltersCollection_dispex, min(compat_mode, COMPAT_MODE_IE8));
7897 *ret = &collection->IHTMLFiltersCollection_iface;
7898 return S_OK;
7901 static HRESULT get_attr_dispid_by_relative_idx(HTMLAttributeCollection *This, LONG *idx, DISPID start, DISPID *dispid)
7903 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
7904 DISPID id = start;
7905 LONG len = -1;
7906 HRESULT hres;
7908 FIXME("filter non-enumerable attributes out\n");
7910 while(1) {
7911 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
7912 if(FAILED(hres))
7913 return hres;
7914 else if(hres == S_FALSE)
7915 break;
7917 len++;
7918 if(len == *idx)
7919 break;
7922 if(dispid) {
7923 *dispid = id;
7924 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
7927 *idx = len+1;
7928 return S_OK;
7931 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
7933 return get_attr_dispid_by_relative_idx(This, idx, DISPID_STARTENUM, dispid);
7936 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
7938 HRESULT hres;
7940 if(name[0]>='0' && name[0]<='9') {
7941 WCHAR *end_ptr;
7942 LONG idx;
7944 idx = wcstoul(name, &end_ptr, 10);
7945 if(!*end_ptr) {
7946 hres = get_attr_dispid_by_idx(This, &idx, id);
7947 if(SUCCEEDED(hres))
7948 return hres;
7952 if(!This->elem) {
7953 WARN("NULL elem\n");
7954 return E_UNEXPECTED;
7957 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
7958 name, fdexNameCaseInsensitive, id);
7959 return hres;
7962 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
7964 HTMLDOMAttribute *iter;
7965 LONG pos = 0;
7966 HRESULT hres;
7968 *attr = NULL;
7969 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
7970 if(iter->dispid == id) {
7971 *attr = iter;
7972 break;
7974 pos++;
7977 if(!*attr) {
7978 if(!This->elem) {
7979 WARN("NULL elem\n");
7980 return E_UNEXPECTED;
7983 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, dispex_compat_mode(&This->elem->node.event_target.dispex), attr);
7984 if(FAILED(hres))
7985 return hres;
7988 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
7989 if(list_pos)
7990 *list_pos = pos;
7991 return S_OK;
7994 typedef struct {
7995 IEnumVARIANT IEnumVARIANT_iface;
7997 LONG ref;
7999 ULONG iter;
8000 DISPID iter_dispid;
8001 HTMLAttributeCollection *col;
8002 } HTMLAttributeCollectionEnum;
8004 static inline HTMLAttributeCollectionEnum *HTMLAttributeCollectionEnum_from_IEnumVARIANT(IEnumVARIANT *iface)
8006 return CONTAINING_RECORD(iface, HTMLAttributeCollectionEnum, IEnumVARIANT_iface);
8009 static HRESULT WINAPI HTMLAttributeCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
8011 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8013 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8015 if(IsEqualGUID(riid, &IID_IUnknown)) {
8016 *ppv = &This->IEnumVARIANT_iface;
8017 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
8018 *ppv = &This->IEnumVARIANT_iface;
8019 }else {
8020 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8021 *ppv = NULL;
8022 return E_NOINTERFACE;
8025 IUnknown_AddRef((IUnknown*)*ppv);
8026 return S_OK;
8029 static ULONG WINAPI HTMLAttributeCollectionEnum_AddRef(IEnumVARIANT *iface)
8031 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8032 LONG ref = InterlockedIncrement(&This->ref);
8034 TRACE("(%p) ref=%ld\n", This, ref);
8036 return ref;
8039 static ULONG WINAPI HTMLAttributeCollectionEnum_Release(IEnumVARIANT *iface)
8041 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8042 LONG ref = InterlockedDecrement(&This->ref);
8044 TRACE("(%p) ref=%ld\n", This, ref);
8046 if(!ref) {
8047 IHTMLAttributeCollection_Release(&This->col->IHTMLAttributeCollection_iface);
8048 heap_free(This);
8051 return ref;
8054 static HRESULT WINAPI HTMLAttributeCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
8056 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8057 DISPID tmp, dispid = This->iter_dispid;
8058 HTMLDOMAttribute *attr;
8059 LONG rel_index = 0;
8060 HRESULT hres;
8061 ULONG i;
8063 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
8065 for(i = 0; i < celt; i++) {
8066 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, dispid, &tmp);
8067 if(SUCCEEDED(hres)) {
8068 dispid = tmp;
8069 hres = get_domattr(This->col, dispid, NULL, &attr);
8071 else if(hres == DISP_E_UNKNOWNNAME)
8072 break;
8074 if(FAILED(hres)) {
8075 while(i--)
8076 VariantClear(&rgVar[i]);
8077 return hres;
8080 V_VT(&rgVar[i]) = VT_DISPATCH;
8081 V_DISPATCH(&rgVar[i]) = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
8084 This->iter += i;
8085 This->iter_dispid = dispid;
8086 if(pCeltFetched)
8087 *pCeltFetched = i;
8088 return i == celt ? S_OK : S_FALSE;
8091 static HRESULT WINAPI HTMLAttributeCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
8093 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8094 LONG remaining, rel_index;
8095 DISPID dispid;
8096 HRESULT hres;
8098 TRACE("(%p)->(%lu)\n", This, celt);
8100 if(!celt)
8101 return S_OK;
8103 rel_index = -1;
8104 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, NULL);
8105 if(FAILED(hres))
8106 return hres;
8107 remaining = min(celt, rel_index);
8109 if(remaining) {
8110 rel_index = remaining - 1;
8111 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, &dispid);
8112 if(FAILED(hres))
8113 return hres;
8114 This->iter += remaining;
8115 This->iter_dispid = dispid;
8117 return celt > remaining ? S_FALSE : S_OK;
8120 static HRESULT WINAPI HTMLAttributeCollectionEnum_Reset(IEnumVARIANT *iface)
8122 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8124 TRACE("(%p)->()\n", This);
8126 This->iter = 0;
8127 This->iter_dispid = DISPID_STARTENUM;
8128 return S_OK;
8131 static HRESULT WINAPI HTMLAttributeCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
8133 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8134 FIXME("(%p)->(%p)\n", This, ppEnum);
8135 return E_NOTIMPL;
8138 static const IEnumVARIANTVtbl HTMLAttributeCollectionEnumVtbl = {
8139 HTMLAttributeCollectionEnum_QueryInterface,
8140 HTMLAttributeCollectionEnum_AddRef,
8141 HTMLAttributeCollectionEnum_Release,
8142 HTMLAttributeCollectionEnum_Next,
8143 HTMLAttributeCollectionEnum_Skip,
8144 HTMLAttributeCollectionEnum_Reset,
8145 HTMLAttributeCollectionEnum_Clone
8148 /* interface IHTMLAttributeCollection */
8149 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
8151 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
8154 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
8156 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8158 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8160 if(IsEqualGUID(&IID_IUnknown, riid)) {
8161 *ppv = &This->IHTMLAttributeCollection_iface;
8162 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
8163 *ppv = &This->IHTMLAttributeCollection_iface;
8164 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
8165 *ppv = &This->IHTMLAttributeCollection2_iface;
8166 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
8167 *ppv = &This->IHTMLAttributeCollection3_iface;
8168 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
8169 return *ppv ? S_OK : E_NOINTERFACE;
8170 }else {
8171 *ppv = NULL;
8172 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8173 return E_NOINTERFACE;
8176 IUnknown_AddRef((IUnknown*)*ppv);
8177 return S_OK;
8180 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
8182 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8183 LONG ref = InterlockedIncrement(&This->ref);
8185 TRACE("(%p) ref=%ld\n", This, ref);
8187 return ref;
8190 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
8192 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8193 LONG ref = InterlockedDecrement(&This->ref);
8195 TRACE("(%p) ref=%ld\n", This, ref);
8197 if(!ref) {
8198 while(!list_empty(&This->attrs)) {
8199 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
8201 list_remove(&attr->entry);
8202 attr->elem = NULL;
8203 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8206 heap_free(This);
8209 return ref;
8212 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
8214 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8215 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8218 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
8219 LCID lcid, ITypeInfo **ppTInfo)
8221 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8222 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8225 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
8226 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8228 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8229 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8230 lcid, rgDispId);
8233 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
8234 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8235 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8237 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8238 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8239 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8242 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
8244 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8245 HRESULT hres;
8247 TRACE("(%p)->(%p)\n", This, p);
8249 *p = -1;
8250 hres = get_attr_dispid_by_idx(This, p, NULL);
8251 return hres;
8254 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
8256 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8257 HTMLAttributeCollectionEnum *ret;
8259 TRACE("(%p)->(%p)\n", This, p);
8261 ret = heap_alloc(sizeof(*ret));
8262 if(!ret)
8263 return E_OUTOFMEMORY;
8265 ret->IEnumVARIANT_iface.lpVtbl = &HTMLAttributeCollectionEnumVtbl;
8266 ret->ref = 1;
8267 ret->iter = 0;
8268 ret->iter_dispid = DISPID_STARTENUM;
8270 HTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8271 ret->col = This;
8273 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
8274 return S_OK;
8277 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
8279 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8280 HTMLDOMAttribute *attr;
8281 DISPID id;
8282 HRESULT hres;
8284 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
8286 switch(V_VT(name)) {
8287 case VT_I4:
8288 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
8289 break;
8290 case VT_BSTR:
8291 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
8292 break;
8293 default:
8294 FIXME("unsupported name %s\n", debugstr_variant(name));
8295 hres = E_NOTIMPL;
8297 if(hres == DISP_E_UNKNOWNNAME)
8298 return E_INVALIDARG;
8299 if(FAILED(hres))
8300 return hres;
8302 hres = get_domattr(This, id, NULL, &attr);
8303 if(FAILED(hres))
8304 return hres;
8306 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
8307 return S_OK;
8310 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
8311 HTMLAttributeCollection_QueryInterface,
8312 HTMLAttributeCollection_AddRef,
8313 HTMLAttributeCollection_Release,
8314 HTMLAttributeCollection_GetTypeInfoCount,
8315 HTMLAttributeCollection_GetTypeInfo,
8316 HTMLAttributeCollection_GetIDsOfNames,
8317 HTMLAttributeCollection_Invoke,
8318 HTMLAttributeCollection_get_length,
8319 HTMLAttributeCollection__newEnum,
8320 HTMLAttributeCollection_item
8323 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
8325 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
8328 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
8330 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8331 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
8334 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
8336 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8337 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8340 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
8342 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8343 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
8346 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
8348 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8349 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8352 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
8353 LCID lcid, ITypeInfo **ppTInfo)
8355 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8356 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8359 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
8360 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8362 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8363 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8364 lcid, rgDispId);
8367 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
8368 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8369 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8371 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8372 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8373 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8376 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
8377 IHTMLDOMAttribute **newretNode)
8379 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8380 HTMLDOMAttribute *attr;
8381 DISPID id;
8382 HRESULT hres;
8384 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
8386 hres = get_attr_dispid_by_name(This, bstrName, &id);
8387 if(hres == DISP_E_UNKNOWNNAME) {
8388 *newretNode = NULL;
8389 return S_OK;
8390 } else if(FAILED(hres)) {
8391 return hres;
8394 hres = get_domattr(This, id, NULL, &attr);
8395 if(FAILED(hres))
8396 return hres;
8398 *newretNode = &attr->IHTMLDOMAttribute_iface;
8399 return S_OK;
8402 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
8403 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
8405 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8406 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
8407 return E_NOTIMPL;
8410 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
8411 BSTR bstrName, IHTMLDOMAttribute **newretNode)
8413 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8414 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
8415 return E_NOTIMPL;
8418 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
8419 HTMLAttributeCollection2_QueryInterface,
8420 HTMLAttributeCollection2_AddRef,
8421 HTMLAttributeCollection2_Release,
8422 HTMLAttributeCollection2_GetTypeInfoCount,
8423 HTMLAttributeCollection2_GetTypeInfo,
8424 HTMLAttributeCollection2_GetIDsOfNames,
8425 HTMLAttributeCollection2_Invoke,
8426 HTMLAttributeCollection2_getNamedItem,
8427 HTMLAttributeCollection2_setNamedItem,
8428 HTMLAttributeCollection2_removeNamedItem
8431 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
8433 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
8436 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
8438 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8439 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
8442 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
8444 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8445 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8448 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
8450 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8451 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
8454 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
8456 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8457 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8460 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
8461 LCID lcid, ITypeInfo **ppTInfo)
8463 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8464 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8467 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
8468 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8470 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8471 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8472 lcid, rgDispId);
8475 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
8476 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8477 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8479 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8480 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8481 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8484 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
8485 IHTMLDOMAttribute **ppNodeOut)
8487 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8488 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
8491 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
8492 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
8494 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8495 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
8496 return E_NOTIMPL;
8499 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
8500 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
8502 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8503 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
8504 return E_NOTIMPL;
8507 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
8509 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8510 HTMLDOMAttribute *attr;
8511 DISPID id;
8512 HRESULT hres;
8514 TRACE("(%p)->(%ld %p)\n", This, index, ppNodeOut);
8516 hres = get_attr_dispid_by_idx(This, &index, &id);
8517 if(hres == DISP_E_UNKNOWNNAME)
8518 return E_INVALIDARG;
8519 if(FAILED(hres))
8520 return hres;
8522 hres = get_domattr(This, id, NULL, &attr);
8523 if(FAILED(hres))
8524 return hres;
8526 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
8527 return S_OK;
8530 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
8532 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8533 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
8536 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
8537 HTMLAttributeCollection3_QueryInterface,
8538 HTMLAttributeCollection3_AddRef,
8539 HTMLAttributeCollection3_Release,
8540 HTMLAttributeCollection3_GetTypeInfoCount,
8541 HTMLAttributeCollection3_GetTypeInfo,
8542 HTMLAttributeCollection3_GetIDsOfNames,
8543 HTMLAttributeCollection3_Invoke,
8544 HTMLAttributeCollection3_getNamedItem,
8545 HTMLAttributeCollection3_setNamedItem,
8546 HTMLAttributeCollection3_removeNamedItem,
8547 HTMLAttributeCollection3_item,
8548 HTMLAttributeCollection3_get_length
8551 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
8553 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
8556 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
8558 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8559 HTMLDOMAttribute *attr;
8560 LONG pos;
8561 HRESULT hres;
8563 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(name), flags, dispid);
8565 hres = get_attr_dispid_by_name(This, name, dispid);
8566 if(FAILED(hres))
8567 return hres;
8569 hres = get_domattr(This, *dispid, &pos, &attr);
8570 if(FAILED(hres))
8571 return hres;
8572 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8574 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
8575 return S_OK;
8578 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
8579 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
8581 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8583 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
8585 switch(flags) {
8586 case DISPATCH_PROPERTYGET: {
8587 HTMLDOMAttribute *iter;
8588 DWORD pos;
8590 pos = id-MSHTML_DISPID_CUSTOM_MIN;
8592 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
8593 if(!pos) {
8594 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
8595 V_VT(res) = VT_DISPATCH;
8596 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
8597 return S_OK;
8599 pos--;
8602 WARN("invalid arg\n");
8603 return E_INVALIDARG;
8606 default:
8607 FIXME("unimplemented flags %x\n", flags);
8608 return E_NOTIMPL;
8612 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
8613 NULL,
8614 HTMLAttributeCollection_get_dispid,
8615 HTMLAttributeCollection_invoke,
8616 NULL
8619 static const tid_t HTMLAttributeCollection_iface_tids[] = {
8620 IHTMLAttributeCollection_tid,
8621 IHTMLAttributeCollection2_tid,
8622 IHTMLAttributeCollection3_tid,
8626 static dispex_static_data_t HTMLAttributeCollection_dispex = {
8627 L"NamedNodeMap",
8628 &HTMLAttributeCollection_dispex_vtbl,
8629 DispHTMLAttributeCollection_tid,
8630 HTMLAttributeCollection_iface_tids
8633 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
8635 HTMLElement *This = impl_from_HTMLDOMNode(iface);
8637 if(This->attrs) {
8638 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
8639 *ac = This->attrs;
8640 return S_OK;
8643 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
8644 if(!This->attrs)
8645 return E_OUTOFMEMORY;
8647 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
8648 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
8649 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
8650 This->attrs->ref = 2;
8652 This->attrs->elem = This;
8653 list_init(&This->attrs->attrs);
8654 init_dispatch(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
8655 &HTMLAttributeCollection_dispex, dispex_compat_mode(&iface->event_target.dispex));
8657 *ac = This->attrs;
8658 return S_OK;