wined3d: Destroy the Vulkan command pool after cleaning up resources.
[wine.git] / dlls / mshtml / htmlelem.c
blob856f55da6c7b6318241d46cab53a2d5273578c94
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_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
1112 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1113 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
1114 UINT32 len = 0;
1115 WCHAR buf[11];
1117 nsIDOMClientRectList_GetLength(This->rect_list, &len);
1118 if(idx >= len)
1119 return DISP_E_MEMBERNOTFOUND;
1121 len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx);
1122 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
1125 static HRESULT HTMLRectCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1126 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1128 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
1130 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
1132 switch(flags) {
1133 case DISPATCH_PROPERTYGET: {
1134 nsIDOMClientRect *rect;
1135 IHTMLRect *html_rect;
1136 nsresult nsres;
1137 HRESULT hres;
1139 nsres = nsIDOMClientRectList_Item(This->rect_list, id - MSHTML_DISPID_CUSTOM_MIN, &rect);
1140 if(NS_FAILED(nsres) || !rect) {
1141 WARN("Unknown item\n");
1142 return DISP_E_MEMBERNOTFOUND;
1145 hres = create_html_rect(rect, dispex_compat_mode(&This->dispex), &html_rect);
1146 nsIDOMClientRect_Release(rect);
1147 if(FAILED(hres))
1148 return hres;
1150 V_VT(res) = VT_DISPATCH;
1151 V_DISPATCH(res) = (IDispatch*)html_rect;
1152 break;
1155 default:
1156 FIXME("unimplemented flags %x\n", flags);
1157 return E_NOTIMPL;
1160 return S_OK;
1163 static const dispex_static_data_vtbl_t HTMLRectCollection_dispex_vtbl = {
1164 NULL,
1165 HTMLRectCollection_get_dispid,
1166 HTMLRectCollection_get_name,
1167 HTMLRectCollection_invoke,
1168 NULL
1170 static const tid_t HTMLRectCollection_iface_tids[] = {
1171 IHTMLRectCollection_tid,
1174 static dispex_static_data_t HTMLRectCollection_dispex = {
1175 L"ClientRectList",
1176 &HTMLRectCollection_dispex_vtbl,
1177 IHTMLRectCollection_tid,
1178 HTMLRectCollection_iface_tids
1181 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
1182 REFIID riid, void **ppv)
1184 HTMLElement *This = impl_from_IHTMLElement(iface);
1186 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
1189 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
1191 HTMLElement *This = impl_from_IHTMLElement(iface);
1193 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
1196 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
1198 HTMLElement *This = impl_from_IHTMLElement(iface);
1200 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
1203 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
1205 HTMLElement *This = impl_from_IHTMLElement(iface);
1206 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
1209 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
1210 LCID lcid, ITypeInfo **ppTInfo)
1212 HTMLElement *This = impl_from_IHTMLElement(iface);
1213 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1216 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
1217 LPOLESTR *rgszNames, UINT cNames,
1218 LCID lcid, DISPID *rgDispId)
1220 HTMLElement *This = impl_from_IHTMLElement(iface);
1221 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1222 lcid, rgDispId);
1225 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
1226 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1227 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1229 HTMLElement *This = impl_from_IHTMLElement(iface);
1230 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1231 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1234 static inline WCHAR *translate_attr_name(WCHAR *attr_name, compat_mode_t compat_mode)
1236 static WCHAR classNameW[] = L"className";
1237 WCHAR *ret = attr_name;
1239 if(compat_mode >= COMPAT_MODE_IE8 && !wcsicmp(attr_name, L"class"))
1240 ret = classNameW;
1241 return ret;
1244 static HRESULT set_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *v)
1246 DISPID propput_dispid = DISPID_PROPERTYPUT;
1247 DISPPARAMS dp = {v, &propput_dispid, 1, 1};
1248 EXCEPINFO ei;
1250 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
1251 TRACE("Ignoring call on style attribute\n");
1252 return S_OK;
1255 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid,
1256 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
1259 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
1260 VARIANT AttributeValue, LONG lFlags)
1262 HTMLElement *This = impl_from_IHTMLElement(iface);
1263 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1264 nsAString name_str, value_str;
1265 VARIANT val = AttributeValue;
1266 BOOL needs_free = FALSE;
1267 nsresult nsres;
1268 DISPID dispid;
1269 HRESULT hres;
1271 TRACE("(%p)->(%s %s %08lx)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
1273 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1274 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1275 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
1276 if(FAILED(hres))
1277 return hres;
1279 if(compat_mode >= COMPAT_MODE_IE8 && get_dispid_type(dispid) == DISPEXPROP_BUILTIN) {
1280 if(V_VT(&val) != VT_BSTR && V_VT(&val) != VT_NULL) {
1281 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1283 V_VT(&val) = VT_EMPTY;
1284 hres = VariantChangeTypeEx(&val, &AttributeValue, lcid, 0, VT_BSTR);
1285 if(FAILED(hres))
1286 return hres;
1288 if(V_BSTR(&val))
1289 needs_free = TRUE;
1290 else
1291 V_VT(&val) = VT_NULL;
1295 /* className and style are special cases */
1296 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1297 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1298 hres = set_elem_attr_value_by_dispid(This, dispid, &val);
1299 goto done;
1303 hres = variant_to_nsstr(&val, FALSE, &value_str);
1304 if(FAILED(hres))
1305 goto done;
1307 nsAString_InitDepend(&name_str, strAttributeName);
1308 nsres = nsIDOMElement_SetAttribute(This->dom_element, &name_str, &value_str);
1309 nsAString_Finish(&name_str);
1310 nsAString_Finish(&value_str);
1311 if(NS_FAILED(nsres))
1312 WARN("SetAttribute failed: %08lx\n", nsres);
1313 hres = map_nsresult(nsres);
1315 done:
1316 if(needs_free)
1317 SysFreeString(V_BSTR(&val));
1318 return hres;
1321 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *ret)
1323 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
1324 EXCEPINFO excep;
1326 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
1327 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
1330 HRESULT attr_value_to_string(VARIANT *v)
1332 HRESULT hres;
1334 switch(V_VT(v)) {
1335 case VT_BSTR:
1336 break;
1337 case VT_NULL:
1338 V_BSTR(v) = SysAllocString(L"null");
1339 if(!V_BSTR(v))
1340 return E_OUTOFMEMORY;
1341 V_VT(v) = VT_BSTR;
1342 break;
1343 case VT_DISPATCH:
1344 IDispatch_Release(V_DISPATCH(v));
1345 V_VT(v) = VT_BSTR;
1346 V_BSTR(v) = SysAllocString(NULL);
1347 break;
1348 default:
1349 hres = VariantChangeType(v, v, 0, VT_BSTR);
1350 if(FAILED(hres))
1351 return hres;
1354 return S_OK;
1357 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
1358 LONG lFlags, VARIANT *AttributeValue)
1360 HTMLElement *This = impl_from_IHTMLElement(iface);
1361 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1362 nsAString name_str, value_str;
1363 nsresult nsres;
1364 DISPID dispid;
1365 HRESULT hres;
1367 TRACE("(%p)->(%s %08lx %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
1369 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
1370 FIXME("Unsupported flags %lx\n", lFlags);
1372 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1373 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1374 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
1375 if(FAILED(hres)) {
1376 V_VT(AttributeValue) = VT_NULL;
1377 return (hres == DISP_E_UNKNOWNNAME) ? S_OK : hres;
1380 /* className and style are special cases */
1381 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element ||
1382 (dispid != DISPID_IHTMLELEMENT_CLASSNAME && dispid != DISPID_IHTMLELEMENT_STYLE)) {
1383 hres = get_elem_attr_value_by_dispid(This, dispid, AttributeValue);
1384 if(FAILED(hres))
1385 return hres;
1387 if(compat_mode >= COMPAT_MODE_IE8 && V_VT(AttributeValue) != VT_BSTR && V_VT(AttributeValue) != VT_NULL) {
1388 LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
1390 hres = VariantChangeTypeEx(AttributeValue, AttributeValue, lcid, 0, VT_BSTR);
1391 if(FAILED(hres)) {
1392 VariantClear(AttributeValue);
1393 return hres;
1395 if(!V_BSTR(AttributeValue))
1396 V_VT(AttributeValue) = VT_NULL;
1397 }else if(lFlags & ATTRFLAG_ASSTRING)
1398 hres = attr_value_to_string(AttributeValue);
1399 return hres;
1403 nsAString_InitDepend(&name_str, strAttributeName);
1404 nsAString_InitDepend(&value_str, NULL);
1405 nsres = nsIDOMElement_GetAttribute(This->dom_element, &name_str, &value_str);
1406 nsAString_Finish(&name_str);
1407 return return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
1410 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
1411 LONG lFlags, VARIANT_BOOL *pfSuccess)
1413 HTMLElement *This = impl_from_IHTMLElement(iface);
1414 compat_mode_t compat_mode = dispex_compat_mode(&This->node.event_target.dispex);
1415 DISPID id;
1416 HRESULT hres;
1418 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
1420 if(compat_mode < COMPAT_MODE_IE9 || !This->dom_element) {
1421 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, translate_attr_name(strAttributeName, compat_mode),
1422 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
1423 if(hres == DISP_E_UNKNOWNNAME) {
1424 *pfSuccess = VARIANT_FALSE;
1425 return S_OK;
1427 if(FAILED(hres))
1428 return hres;
1430 if(id == DISPID_IHTMLELEMENT_STYLE) {
1431 IHTMLStyle *style;
1433 TRACE("Special case: style\n");
1435 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
1436 if(FAILED(hres))
1437 return hres;
1439 hres = IHTMLStyle_put_cssText(style, NULL);
1440 IHTMLStyle_Release(style);
1441 if(FAILED(hres))
1442 return hres;
1444 if(compat_mode >= COMPAT_MODE_IE8)
1445 element_remove_attribute(This, strAttributeName);
1447 *pfSuccess = VARIANT_TRUE;
1448 return S_OK;
1451 if(compat_mode != COMPAT_MODE_IE8 || !This->dom_element || id != DISPID_IHTMLELEMENT_CLASSNAME)
1452 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
1455 *pfSuccess = element_has_attribute(This, strAttributeName);
1456 if(*pfSuccess)
1457 return element_remove_attribute(This, strAttributeName);
1458 return S_OK;
1461 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
1463 HTMLElement *This = impl_from_IHTMLElement(iface);
1464 nsAString classname_str;
1465 nsresult nsres;
1467 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1469 if(!This->dom_element) {
1470 FIXME("comment element\n");
1471 return E_NOTIMPL;
1474 nsAString_InitDepend(&classname_str, v);
1475 nsres = nsIDOMElement_SetClassName(This->dom_element, &classname_str);
1476 nsAString_Finish(&classname_str);
1477 if(NS_FAILED(nsres))
1478 ERR("SetClassName failed: %08lx\n", nsres);
1480 return S_OK;
1483 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
1485 HTMLElement *This = impl_from_IHTMLElement(iface);
1486 nsAString class_str;
1487 nsresult nsres;
1489 TRACE("(%p)->(%p)\n", This, p);
1491 if(!This->dom_element) {
1492 FIXME("comment element\n");
1493 return E_NOTIMPL;
1496 nsAString_Init(&class_str, NULL);
1497 nsres = nsIDOMElement_GetClassName(This->dom_element, &class_str);
1498 return return_nsstr(nsres, &class_str, p);
1501 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
1503 HTMLElement *This = impl_from_IHTMLElement(iface);
1504 nsAString id_str;
1505 nsresult nsres;
1507 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1509 if(!This->dom_element) {
1510 FIXME("comment element\n");
1511 return S_OK;
1514 nsAString_InitDepend(&id_str, v);
1515 nsres = nsIDOMElement_SetId(This->dom_element, &id_str);
1516 nsAString_Finish(&id_str);
1517 if(NS_FAILED(nsres))
1518 ERR("SetId failed: %08lx\n", nsres);
1520 return S_OK;
1523 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
1525 HTMLElement *This = impl_from_IHTMLElement(iface);
1526 nsAString id_str;
1527 nsresult nsres;
1529 TRACE("(%p)->(%p)\n", This, p);
1531 if(!This->dom_element) {
1532 *p = NULL;
1533 return S_OK;
1536 nsAString_Init(&id_str, NULL);
1537 nsres = nsIDOMElement_GetId(This->dom_element, &id_str);
1538 return return_nsstr(nsres, &id_str, p);
1541 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
1543 HTMLElement *This = impl_from_IHTMLElement(iface);
1544 nsAString tag_str;
1545 nsresult nsres;
1547 TRACE("(%p)->(%p)\n", This, p);
1549 if(!This->dom_element) {
1550 TRACE("comment element\n");
1551 *p = SysAllocString(L"!");
1552 return *p ? S_OK : E_OUTOFMEMORY;
1555 nsAString_Init(&tag_str, NULL);
1556 nsres = nsIDOMElement_GetTagName(This->dom_element, &tag_str);
1557 return return_nsstr(nsres, &tag_str, p);
1560 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
1562 HTMLElement *This = impl_from_IHTMLElement(iface);
1563 IHTMLDOMNode *node;
1564 HRESULT hres;
1566 TRACE("(%p)->(%p)\n", This, p);
1568 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
1569 if(FAILED(hres))
1570 return hres;
1572 if(!node) {
1573 *p = NULL;
1574 return S_OK;
1577 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
1578 IHTMLDOMNode_Release(node);
1579 if(FAILED(hres))
1580 *p = NULL;
1582 return S_OK;
1585 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
1587 HTMLElement *This = impl_from_IHTMLElement(iface);
1589 TRACE("(%p)->(%p)\n", This, p);
1591 if(!This->style) {
1592 HRESULT hres;
1594 hres = HTMLStyle_Create(This, &This->style);
1595 if(FAILED(hres))
1596 return hres;
1599 *p = &This->style->IHTMLStyle_iface;
1600 IHTMLStyle_AddRef(*p);
1601 return S_OK;
1604 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
1606 HTMLElement *This = impl_from_IHTMLElement(iface);
1608 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1610 return set_node_event(&This->node, EVENTID_HELP, &v);
1613 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
1615 HTMLElement *This = impl_from_IHTMLElement(iface);
1617 TRACE("(%p)->(%p)\n", This, p);
1619 return get_node_event(&This->node, EVENTID_HELP, p);
1622 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
1624 HTMLElement *This = impl_from_IHTMLElement(iface);
1626 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1628 return set_node_event(&This->node, EVENTID_CLICK, &v);
1631 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
1633 HTMLElement *This = impl_from_IHTMLElement(iface);
1635 TRACE("(%p)->(%p)\n", This, p);
1637 return get_node_event(&This->node, EVENTID_CLICK, p);
1640 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
1642 HTMLElement *This = impl_from_IHTMLElement(iface);
1644 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1646 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
1649 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
1651 HTMLElement *This = impl_from_IHTMLElement(iface);
1653 TRACE("(%p)->(%p)\n", This, p);
1655 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
1658 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
1660 HTMLElement *This = impl_from_IHTMLElement(iface);
1662 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1664 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
1667 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
1669 HTMLElement *This = impl_from_IHTMLElement(iface);
1671 TRACE("(%p)->(%p)\n", This, p);
1673 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
1676 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
1678 HTMLElement *This = impl_from_IHTMLElement(iface);
1680 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1682 return set_node_event(&This->node, EVENTID_KEYUP, &v);
1685 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
1687 HTMLElement *This = impl_from_IHTMLElement(iface);
1689 TRACE("(%p)->(%p)\n", This, p);
1691 return get_node_event(&This->node, EVENTID_KEYUP, p);
1694 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
1696 HTMLElement *This = impl_from_IHTMLElement(iface);
1698 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1700 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
1703 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
1705 HTMLElement *This = impl_from_IHTMLElement(iface);
1707 TRACE("(%p)->(%p)\n", This, p);
1709 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
1712 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
1714 HTMLElement *This = impl_from_IHTMLElement(iface);
1716 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1718 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
1721 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
1723 HTMLElement *This = impl_from_IHTMLElement(iface);
1725 TRACE("(%p)->(%p)\n", This, p);
1727 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1730 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1732 HTMLElement *This = impl_from_IHTMLElement(iface);
1734 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1736 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1739 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1741 HTMLElement *This = impl_from_IHTMLElement(iface);
1743 TRACE("(%p)->(%p)\n", This, p);
1745 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1748 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1750 HTMLElement *This = impl_from_IHTMLElement(iface);
1752 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1754 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1757 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1759 HTMLElement *This = impl_from_IHTMLElement(iface);
1761 TRACE("(%p)->(%p)\n", This, p);
1763 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1766 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1768 HTMLElement *This = impl_from_IHTMLElement(iface);
1770 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1772 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1775 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1777 HTMLElement *This = impl_from_IHTMLElement(iface);
1779 TRACE("(%p)->(%p)\n", This, p);
1781 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1784 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1786 HTMLElement *This = impl_from_IHTMLElement(iface);
1788 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1790 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1793 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1795 HTMLElement *This = impl_from_IHTMLElement(iface);
1797 TRACE("(%p)->(%p)\n", This, p);
1799 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1802 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1804 HTMLElement *This = impl_from_IHTMLElement(iface);
1806 TRACE("(%p)->(%p)\n", This, p);
1808 if(!p)
1809 return E_POINTER;
1811 if(This->node.vtbl->get_document)
1812 return This->node.vtbl->get_document(&This->node, p);
1814 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1815 IDispatch_AddRef(*p);
1816 return S_OK;
1819 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1821 HTMLElement *This = impl_from_IHTMLElement(iface);
1822 nsAString title_str;
1823 nsresult nsres;
1825 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1827 if(!This->dom_element) {
1828 VARIANT *var;
1829 HRESULT hres;
1831 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", TRUE, &var);
1832 if(FAILED(hres))
1833 return hres;
1835 VariantClear(var);
1836 V_VT(var) = VT_BSTR;
1837 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1838 return S_OK;
1841 if(!This->html_element)
1842 return elem_string_attr_setter(This, L"title", v);
1844 nsAString_InitDepend(&title_str, v);
1845 nsres = nsIDOMHTMLElement_SetTitle(This->html_element, &title_str);
1846 nsAString_Finish(&title_str);
1847 if(NS_FAILED(nsres))
1848 ERR("SetTitle failed: %08lx\n", nsres);
1850 return S_OK;
1853 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1855 HTMLElement *This = impl_from_IHTMLElement(iface);
1856 nsAString title_str;
1857 nsresult nsres;
1859 TRACE("(%p)->(%p)\n", This, p);
1861 if(!This->dom_element) {
1862 VARIANT *var;
1863 HRESULT hres;
1865 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", FALSE, &var);
1866 if(hres == DISP_E_UNKNOWNNAME) {
1867 *p = NULL;
1868 }else if(V_VT(var) != VT_BSTR) {
1869 FIXME("title = %s\n", debugstr_variant(var));
1870 return E_FAIL;
1871 }else {
1872 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1875 return S_OK;
1878 if(!This->html_element)
1879 return elem_string_attr_getter(This, L"title", FALSE, p);
1881 nsAString_Init(&title_str, NULL);
1882 nsres = nsIDOMHTMLElement_GetTitle(This->html_element, &title_str);
1883 return return_nsstr(nsres, &title_str, p);
1886 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1888 HTMLElement *This = impl_from_IHTMLElement(iface);
1890 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1892 return elem_string_attr_setter(This, L"language", v);
1895 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1897 HTMLElement *This = impl_from_IHTMLElement(iface);
1899 TRACE("(%p)->(%p)\n", This, p);
1901 return elem_string_attr_getter(This, L"language", TRUE, p);
1904 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1906 HTMLElement *This = impl_from_IHTMLElement(iface);
1908 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1910 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1913 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1915 HTMLElement *This = impl_from_IHTMLElement(iface);
1917 TRACE("(%p)->(%p)\n", This, p);
1919 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1922 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1924 HTMLElement *This = impl_from_IHTMLElement(iface);
1925 cpp_bool start = TRUE;
1926 nsresult nsres;
1928 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1930 switch(V_VT(&varargStart)) {
1931 case VT_EMPTY:
1932 case VT_ERROR:
1933 break;
1934 case VT_BOOL:
1935 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1936 break;
1937 default:
1938 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1941 if(!This->html_element) {
1942 FIXME("non-HTML elements\n");
1943 return E_NOTIMPL;
1946 nsres = nsIDOMHTMLElement_ScrollIntoView(This->html_element, start, 1);
1947 assert(nsres == NS_OK);
1949 return S_OK;
1952 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1953 VARIANT_BOOL *pfResult)
1955 HTMLElement *This = impl_from_IHTMLElement(iface);
1956 cpp_bool result = FALSE;
1958 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1960 if(pChild) {
1961 HTMLElement *child;
1962 nsresult nsres;
1964 child = unsafe_impl_from_IHTMLElement(pChild);
1965 if(!child) {
1966 ERR("not our element\n");
1967 return E_FAIL;
1970 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1971 assert(nsres == NS_OK);
1974 *pfResult = variant_bool(result);
1975 return S_OK;
1978 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1980 HTMLElement *This = impl_from_IHTMLElement(iface);
1982 TRACE("(%p)->(%p)\n", This, p);
1984 return get_elem_source_index(This, p);
1987 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1989 HTMLElement *This = impl_from_IHTMLElement(iface);
1990 FIXME("(%p)->(%p)\n", This, p);
1991 return E_NOTIMPL;
1994 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1996 HTMLElement *This = impl_from_IHTMLElement(iface);
1997 nsAString nsstr;
1998 nsresult nsres;
2000 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2002 if(!This->html_element) {
2003 FIXME("non-HTML element\n");
2004 return E_NOTIMPL;
2007 nsAString_InitDepend(&nsstr, v);
2008 nsres = nsIDOMHTMLElement_SetLang(This->html_element, &nsstr);
2009 nsAString_Finish(&nsstr);
2010 if(NS_FAILED(nsres)) {
2011 ERR("SetLang failed: %08lx\n", nsres);
2012 return E_FAIL;
2015 return S_OK;
2018 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
2020 HTMLElement *This = impl_from_IHTMLElement(iface);
2021 nsAString nsstr;
2022 nsresult nsres;
2024 TRACE("(%p)->(%p)\n", This, p);
2026 if(!This->html_element) {
2027 FIXME("non-HTML element\n");
2028 return E_NOTIMPL;
2031 nsAString_Init(&nsstr, NULL);
2032 nsres = nsIDOMHTMLElement_GetLang(This->html_element, &nsstr);
2033 return return_nsstr(nsres, &nsstr, p);
2036 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
2038 HTMLElement *This = impl_from_IHTMLElement(iface);
2039 nsresult nsres;
2041 TRACE("(%p)->(%p)\n", This, p);
2043 if(!This->html_element) {
2044 FIXME("non-HTML element\n");
2045 return E_NOTIMPL;
2048 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->html_element, p);
2049 if(NS_FAILED(nsres)) {
2050 ERR("GetOffsetLeft failed: %08lx\n", nsres);
2051 return E_FAIL;
2054 return S_OK;
2057 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
2059 HTMLElement *This = impl_from_IHTMLElement(iface);
2060 nsresult nsres;
2062 TRACE("(%p)->(%p)\n", This, p);
2064 if(!This->html_element) {
2065 FIXME("non-HTML element\n");
2066 return E_NOTIMPL;
2069 nsres = nsIDOMHTMLElement_GetOffsetTop(This->html_element, p);
2070 if(NS_FAILED(nsres)) {
2071 ERR("GetOffsetTop failed: %08lx\n", nsres);
2072 return E_FAIL;
2075 return S_OK;
2078 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
2080 HTMLElement *This = impl_from_IHTMLElement(iface);
2081 nsresult nsres;
2083 TRACE("(%p)->(%p)\n", This, p);
2085 if(!This->html_element) {
2086 FIXME("non-HTML element\n");
2087 return E_NOTIMPL;
2090 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->html_element, p);
2091 if(NS_FAILED(nsres)) {
2092 ERR("GetOffsetWidth failed: %08lx\n", nsres);
2093 return E_FAIL;
2096 return S_OK;
2099 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
2101 HTMLElement *This = impl_from_IHTMLElement(iface);
2102 nsresult nsres;
2104 TRACE("(%p)->(%p)\n", This, p);
2106 if(!This->html_element) {
2107 FIXME("non-HTML element\n");
2108 return E_NOTIMPL;
2111 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->html_element, p);
2112 if(NS_FAILED(nsres)) {
2113 ERR("GetOffsetHeight failed: %08lx\n", nsres);
2114 return E_FAIL;
2117 return S_OK;
2120 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
2122 HTMLElement *This = impl_from_IHTMLElement(iface);
2123 nsIDOMElement *nsparent;
2124 HTMLElement *parent;
2125 nsresult nsres;
2126 HRESULT hres;
2128 TRACE("(%p)->(%p)\n", This, p);
2130 if(!This->html_element) {
2131 FIXME("non-HTML element\n");
2132 return E_NOTIMPL;
2135 nsres = nsIDOMHTMLElement_GetOffsetParent(This->html_element, &nsparent);
2136 if(NS_FAILED(nsres)) {
2137 ERR("GetOffsetParent failed: %08lx\n", nsres);
2138 return E_FAIL;
2141 if(!nsparent) {
2142 *p = NULL;
2143 return S_OK;
2146 hres = get_element(nsparent, &parent);
2147 nsIDOMElement_Release(nsparent);
2148 if(FAILED(hres))
2149 return hres;
2151 *p = &parent->IHTMLElement_iface;
2152 return S_OK;
2155 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
2157 HTMLElement *This = impl_from_IHTMLElement(iface);
2158 nsAString html_str;
2159 nsresult nsres;
2161 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2163 if(!This->html_element) {
2164 FIXME("non-HTML element\n");
2165 return E_NOTIMPL;
2168 nsAString_InitDepend(&html_str, v);
2169 nsres = nsIDOMHTMLElement_SetInnerHTML(This->html_element, &html_str);
2170 nsAString_Finish(&html_str);
2171 if(NS_FAILED(nsres)) {
2172 FIXME("SetInnerHtml failed %08lx\n", nsres);
2173 return E_FAIL;
2176 return S_OK;
2179 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
2181 HTMLElement *This = impl_from_IHTMLElement(iface);
2182 nsAString html_str;
2183 nsresult nsres;
2185 TRACE("(%p)->(%p)\n", This, p);
2187 if(!This->html_element) {
2188 FIXME("non-HTML element\n");
2189 return E_NOTIMPL;
2192 nsAString_Init(&html_str, NULL);
2193 nsres = nsIDOMHTMLElement_GetInnerHTML(This->html_element, &html_str);
2194 return return_nsstr(nsres, &html_str, p);
2197 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
2199 HTMLElement *This = impl_from_IHTMLElement(iface);
2200 nsIDOMNode *nschild, *tmp;
2201 nsIDOMText *text_node;
2202 nsAString text_str;
2203 nsresult nsres;
2205 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2207 while(1) {
2208 nsres = nsIDOMElement_GetLastChild(This->dom_element, &nschild);
2209 if(NS_FAILED(nsres)) {
2210 ERR("GetLastChild failed: %08lx\n", nsres);
2211 return E_FAIL;
2213 if(!nschild)
2214 break;
2216 nsres = nsIDOMElement_RemoveChild(This->dom_element, nschild, &tmp);
2217 nsIDOMNode_Release(nschild);
2218 if(NS_FAILED(nsres)) {
2219 ERR("RemoveChild failed: %08lx\n", nsres);
2220 return E_FAIL;
2222 nsIDOMNode_Release(tmp);
2225 nsAString_InitDepend(&text_str, v);
2226 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
2227 nsAString_Finish(&text_str);
2228 if(NS_FAILED(nsres)) {
2229 ERR("CreateTextNode failed: %08lx\n", nsres);
2230 return E_FAIL;
2233 nsres = nsIDOMElement_AppendChild(This->dom_element, (nsIDOMNode*)text_node, &tmp);
2234 if(NS_FAILED(nsres)) {
2235 ERR("AppendChild failed: %08lx\n", nsres);
2236 return E_FAIL;
2239 nsIDOMNode_Release(tmp);
2240 return S_OK;
2243 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
2245 HTMLElement *This = impl_from_IHTMLElement(iface);
2247 TRACE("(%p)->(%p)\n", This, p);
2249 return get_node_text(&This->node, p);
2252 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
2254 HTMLElement *This = impl_from_IHTMLElement(iface);
2256 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2258 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
2261 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
2263 HTMLElement *This = impl_from_IHTMLElement(iface);
2264 nsAString html_str;
2265 HRESULT hres;
2267 WARN("(%p)->(%p) semi-stub\n", This, p);
2269 nsAString_Init(&html_str, NULL);
2270 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
2271 if(SUCCEEDED(hres)) {
2272 const PRUnichar *html;
2274 nsAString_GetData(&html_str, &html);
2275 *p = SysAllocString(html);
2276 if(!*p)
2277 hres = E_OUTOFMEMORY;
2280 nsAString_Finish(&html_str);
2282 TRACE("ret %s\n", debugstr_w(*p));
2283 return hres;
2286 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
2288 HTMLElement *This = impl_from_IHTMLElement(iface);
2289 nsIDOMText *text_node;
2290 nsIDOMRange *range;
2291 nsAString nsstr;
2292 nsresult nsres;
2294 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2296 if(This->node.vtbl->is_settable && !This->node.vtbl->is_settable(&This->node, DISPID_IHTMLELEMENT_OUTERTEXT)) {
2297 WARN("Called on element that does not support setting the property.\n");
2298 return 0x800a0258; /* undocumented error code */
2301 if(!This->node.doc->nsdoc) {
2302 FIXME("NULL nsdoc\n");
2303 return E_FAIL;
2306 nsAString_InitDepend(&nsstr, v);
2307 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &nsstr, &text_node);
2308 nsAString_Finish(&nsstr);
2309 if(NS_FAILED(nsres)) {
2310 ERR("CreateTextNode failed\n");
2311 return E_FAIL;
2314 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
2315 if(NS_SUCCEEDED(nsres)) {
2316 nsres = nsIDOMRange_SelectNode(range, This->node.nsnode);
2317 if(NS_SUCCEEDED(nsres))
2318 nsres = nsIDOMRange_DeleteContents(range);
2319 if(NS_SUCCEEDED(nsres))
2320 nsres = nsIDOMRange_InsertNode(range, (nsIDOMNode*)text_node);
2321 if(NS_SUCCEEDED(nsres))
2322 nsres = nsIDOMRange_SelectNodeContents(range, This->node.nsnode);
2323 if(NS_SUCCEEDED(nsres))
2324 nsres = nsIDOMRange_DeleteContents(range);
2325 nsIDOMRange_Release(range);
2327 nsIDOMText_Release(text_node);
2328 if(NS_FAILED(nsres)) {
2329 ERR("failed to set text: %08lx\n", nsres);
2330 return E_FAIL;
2333 return S_OK;
2336 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
2338 HTMLElement *This = impl_from_IHTMLElement(iface);
2340 TRACE("(%p)->(%p)\n", This, p);
2342 /* getter is the same as innerText */
2343 return IHTMLElement_get_innerText(&This->IHTMLElement_iface, p);
2346 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
2348 nsIDOMNode *ret_nsnode;
2349 nsresult nsres;
2350 HRESULT hres = S_OK;
2352 if (!wcsicmp(where, L"beforebegin")) {
2353 nsIDOMNode *parent;
2355 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2356 if(NS_FAILED(nsres))
2357 return E_FAIL;
2359 if(!parent)
2360 return E_INVALIDARG;
2362 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
2363 nsIDOMNode_Release(parent);
2364 }else if(!wcsicmp(where, L"afterbegin")) {
2365 nsIDOMNode *first_child;
2367 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
2368 if(NS_FAILED(nsres))
2369 return E_FAIL;
2371 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
2372 if(NS_FAILED(nsres))
2373 return E_FAIL;
2375 if (first_child)
2376 nsIDOMNode_Release(first_child);
2377 }else if (!wcsicmp(where, L"beforeend")) {
2378 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
2379 }else if (!wcsicmp(where, L"afterend")) {
2380 nsIDOMNode *next_sibling, *parent;
2382 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2383 if(NS_FAILED(nsres))
2384 return E_FAIL;
2385 if(!parent)
2386 return E_INVALIDARG;
2388 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
2389 if(NS_SUCCEEDED(nsres)) {
2390 if(next_sibling) {
2391 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
2392 nsIDOMNode_Release(next_sibling);
2393 }else {
2394 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
2398 nsIDOMNode_Release(parent);
2399 }else {
2400 ERR("invalid where: %s\n", debugstr_w(where));
2401 return E_INVALIDARG;
2404 if (NS_FAILED(nsres))
2405 return E_FAIL;
2407 if(ret_node)
2408 hres = get_node(ret_nsnode, TRUE, ret_node);
2409 nsIDOMNode_Release(ret_nsnode);
2410 return hres;
2413 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
2414 BSTR html)
2416 HTMLElement *This = impl_from_IHTMLElement(iface);
2417 nsIDOMRange *range;
2418 nsIDOMNode *nsnode;
2419 nsAString ns_html;
2420 nsresult nsres;
2421 HRESULT hr;
2423 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
2425 if(!This->node.doc->nsdoc) {
2426 WARN("NULL nsdoc\n");
2427 return E_UNEXPECTED;
2430 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
2431 if(NS_FAILED(nsres))
2433 ERR("CreateRange failed: %08lx\n", nsres);
2434 return E_FAIL;
2437 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
2439 nsAString_InitDepend(&ns_html, html);
2440 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
2441 nsAString_Finish(&ns_html);
2442 nsIDOMRange_Release(range);
2444 if(NS_FAILED(nsres) || !nsnode)
2446 ERR("CreateTextNode failed: %08lx\n", nsres);
2447 return E_FAIL;
2450 hr = insert_adjacent_node(This, where, nsnode, NULL);
2451 nsIDOMNode_Release(nsnode);
2452 return hr;
2455 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
2456 BSTR text)
2458 HTMLElement *This = impl_from_IHTMLElement(iface);
2459 nsIDOMNode *nsnode;
2460 nsAString ns_text;
2461 nsresult nsres;
2462 HRESULT hr;
2464 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
2466 if(!This->node.doc->nsdoc) {
2467 WARN("NULL nsdoc\n");
2468 return E_UNEXPECTED;
2472 nsAString_InitDepend(&ns_text, text);
2473 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
2474 nsAString_Finish(&ns_text);
2476 if(NS_FAILED(nsres) || !nsnode)
2478 ERR("CreateTextNode failed: %08lx\n", nsres);
2479 return E_FAIL;
2482 hr = insert_adjacent_node(This, where, nsnode, NULL);
2483 nsIDOMNode_Release(nsnode);
2485 return hr;
2488 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
2490 HTMLElement *This = impl_from_IHTMLElement(iface);
2491 FIXME("(%p)->(%p)\n", This, p);
2492 return E_NOTIMPL;
2495 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
2497 HTMLElement *This = impl_from_IHTMLElement(iface);
2499 TRACE("(%p)->(%p)\n", This, p);
2501 *p = variant_bool(This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node));
2502 return S_OK;
2505 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
2507 HTMLElement *This = impl_from_IHTMLElement(iface);
2508 nsresult nsres;
2510 TRACE("(%p)\n", This);
2512 if(!This->html_element) {
2513 FIXME("non-HTML element\n");
2514 return E_NOTIMPL;
2517 nsres = nsIDOMHTMLElement_Click(This->html_element);
2518 if(NS_FAILED(nsres)) {
2519 ERR("Click failed: %08lx\n", nsres);
2520 return E_FAIL;
2523 return S_OK;
2526 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface, IHTMLFiltersCollection **p)
2528 HTMLElement *This = impl_from_IHTMLElement(iface);
2530 TRACE("(%p)->(%p)\n", This, p);
2532 if(!p)
2533 return E_POINTER;
2535 return create_filters_collection(dispex_compat_mode(&This->node.event_target.dispex), p);
2538 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
2540 HTMLElement *This = impl_from_IHTMLElement(iface);
2542 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2544 return set_node_event(&This->node, EVENTID_DRAGSTART, &v);
2547 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
2549 HTMLElement *This = impl_from_IHTMLElement(iface);
2551 TRACE("(%p)->(%p)\n", This, p);
2553 return get_node_event(&This->node, EVENTID_DRAGSTART, p);
2556 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
2558 HTMLElement *This = impl_from_IHTMLElement(iface);
2559 HRESULT hres;
2560 VARIANT var;
2562 TRACE("(%p)->(%p)\n", This, String);
2564 if(!String)
2565 return E_INVALIDARG;
2567 hres = IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, DISPID_VALUE,
2568 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, NULL, &var, NULL, NULL);
2569 if(SUCCEEDED(hres)) {
2570 assert(V_VT(&var) == VT_BSTR);
2571 *String = V_BSTR(&var);
2573 return hres;
2576 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
2578 HTMLElement *This = impl_from_IHTMLElement(iface);
2579 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2580 return E_NOTIMPL;
2583 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
2585 HTMLElement *This = impl_from_IHTMLElement(iface);
2586 FIXME("(%p)->(%p)\n", This, p);
2587 return E_NOTIMPL;
2590 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
2592 HTMLElement *This = impl_from_IHTMLElement(iface);
2593 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2594 return E_NOTIMPL;
2597 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
2599 HTMLElement *This = impl_from_IHTMLElement(iface);
2600 FIXME("(%p)->(%p)\n", This, p);
2601 return E_NOTIMPL;
2604 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
2606 HTMLElement *This = impl_from_IHTMLElement(iface);
2607 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2608 return E_NOTIMPL;
2611 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
2613 HTMLElement *This = impl_from_IHTMLElement(iface);
2614 FIXME("(%p)->(%p)\n", This, p);
2615 return E_NOTIMPL;
2618 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
2620 HTMLElement *This = impl_from_IHTMLElement(iface);
2621 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2622 return E_NOTIMPL;
2625 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
2627 HTMLElement *This = impl_from_IHTMLElement(iface);
2628 FIXME("(%p)->(%p)\n", This, p);
2629 return E_NOTIMPL;
2632 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
2634 HTMLElement *This = impl_from_IHTMLElement(iface);
2635 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2636 return E_NOTIMPL;
2639 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
2641 HTMLElement *This = impl_from_IHTMLElement(iface);
2642 FIXME("(%p)->(%p)\n", This, p);
2643 return E_NOTIMPL;
2646 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
2648 HTMLElement *This = impl_from_IHTMLElement(iface);
2649 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2650 return E_NOTIMPL;
2653 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
2655 HTMLElement *This = impl_from_IHTMLElement(iface);
2656 FIXME("(%p)->(%p)\n", This, p);
2657 return E_NOTIMPL;
2660 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
2662 HTMLElement *This = impl_from_IHTMLElement(iface);
2664 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
2666 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
2669 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
2671 HTMLElement *This = impl_from_IHTMLElement(iface);
2673 TRACE("(%p)->(%p)\n", This, p);
2675 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
2678 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
2680 HTMLElement *This = impl_from_IHTMLElement(iface);
2681 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2682 return E_NOTIMPL;
2685 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
2687 HTMLElement *This = impl_from_IHTMLElement(iface);
2688 FIXME("(%p)->(%p)\n", This, p);
2689 return E_NOTIMPL;
2692 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
2694 HTMLElement *This = impl_from_IHTMLElement(iface);
2695 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2696 return E_NOTIMPL;
2699 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
2701 HTMLElement *This = impl_from_IHTMLElement(iface);
2702 FIXME("(%p)->(%p)\n", This, p);
2703 return E_NOTIMPL;
2706 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
2708 HTMLElement *This = impl_from_IHTMLElement(iface);
2709 nsIDOMNodeList *nsnode_list;
2710 nsresult nsres;
2712 TRACE("(%p)->(%p)\n", This, p);
2714 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
2715 if(NS_FAILED(nsres)) {
2716 ERR("GetChildNodes failed: %08lx\n", nsres);
2717 return E_FAIL;
2720 *p = (IDispatch*)create_collection_from_nodelist(nsnode_list, This->node.doc->document_mode);
2722 nsIDOMNodeList_Release(nsnode_list);
2723 return S_OK;
2726 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
2728 HTMLElement *This = impl_from_IHTMLElement(iface);
2730 TRACE("(%p)->(%p)\n", This, p);
2732 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
2733 return S_OK;
2736 static const IHTMLElementVtbl HTMLElementVtbl = {
2737 HTMLElement_QueryInterface,
2738 HTMLElement_AddRef,
2739 HTMLElement_Release,
2740 HTMLElement_GetTypeInfoCount,
2741 HTMLElement_GetTypeInfo,
2742 HTMLElement_GetIDsOfNames,
2743 HTMLElement_Invoke,
2744 HTMLElement_setAttribute,
2745 HTMLElement_getAttribute,
2746 HTMLElement_removeAttribute,
2747 HTMLElement_put_className,
2748 HTMLElement_get_className,
2749 HTMLElement_put_id,
2750 HTMLElement_get_id,
2751 HTMLElement_get_tagName,
2752 HTMLElement_get_parentElement,
2753 HTMLElement_get_style,
2754 HTMLElement_put_onhelp,
2755 HTMLElement_get_onhelp,
2756 HTMLElement_put_onclick,
2757 HTMLElement_get_onclick,
2758 HTMLElement_put_ondblclick,
2759 HTMLElement_get_ondblclick,
2760 HTMLElement_put_onkeydown,
2761 HTMLElement_get_onkeydown,
2762 HTMLElement_put_onkeyup,
2763 HTMLElement_get_onkeyup,
2764 HTMLElement_put_onkeypress,
2765 HTMLElement_get_onkeypress,
2766 HTMLElement_put_onmouseout,
2767 HTMLElement_get_onmouseout,
2768 HTMLElement_put_onmouseover,
2769 HTMLElement_get_onmouseover,
2770 HTMLElement_put_onmousemove,
2771 HTMLElement_get_onmousemove,
2772 HTMLElement_put_onmousedown,
2773 HTMLElement_get_onmousedown,
2774 HTMLElement_put_onmouseup,
2775 HTMLElement_get_onmouseup,
2776 HTMLElement_get_document,
2777 HTMLElement_put_title,
2778 HTMLElement_get_title,
2779 HTMLElement_put_language,
2780 HTMLElement_get_language,
2781 HTMLElement_put_onselectstart,
2782 HTMLElement_get_onselectstart,
2783 HTMLElement_scrollIntoView,
2784 HTMLElement_contains,
2785 HTMLElement_get_sourceIndex,
2786 HTMLElement_get_recordNumber,
2787 HTMLElement_put_lang,
2788 HTMLElement_get_lang,
2789 HTMLElement_get_offsetLeft,
2790 HTMLElement_get_offsetTop,
2791 HTMLElement_get_offsetWidth,
2792 HTMLElement_get_offsetHeight,
2793 HTMLElement_get_offsetParent,
2794 HTMLElement_put_innerHTML,
2795 HTMLElement_get_innerHTML,
2796 HTMLElement_put_innerText,
2797 HTMLElement_get_innerText,
2798 HTMLElement_put_outerHTML,
2799 HTMLElement_get_outerHTML,
2800 HTMLElement_put_outerText,
2801 HTMLElement_get_outerText,
2802 HTMLElement_insertAdjacentHTML,
2803 HTMLElement_insertAdjacentText,
2804 HTMLElement_get_parentTextEdit,
2805 HTMLElement_get_isTextEdit,
2806 HTMLElement_click,
2807 HTMLElement_get_filters,
2808 HTMLElement_put_ondragstart,
2809 HTMLElement_get_ondragstart,
2810 HTMLElement_toString,
2811 HTMLElement_put_onbeforeupdate,
2812 HTMLElement_get_onbeforeupdate,
2813 HTMLElement_put_onafterupdate,
2814 HTMLElement_get_onafterupdate,
2815 HTMLElement_put_onerrorupdate,
2816 HTMLElement_get_onerrorupdate,
2817 HTMLElement_put_onrowexit,
2818 HTMLElement_get_onrowexit,
2819 HTMLElement_put_onrowenter,
2820 HTMLElement_get_onrowenter,
2821 HTMLElement_put_ondatasetchanged,
2822 HTMLElement_get_ondatasetchanged,
2823 HTMLElement_put_ondataavailable,
2824 HTMLElement_get_ondataavailable,
2825 HTMLElement_put_ondatasetcomplete,
2826 HTMLElement_get_ondatasetcomplete,
2827 HTMLElement_put_onfilterchange,
2828 HTMLElement_get_onfilterchange,
2829 HTMLElement_get_children,
2830 HTMLElement_get_all
2833 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2835 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2838 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2840 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2843 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
2844 REFIID riid, void **ppv)
2846 HTMLElement *This = impl_from_IHTMLElement2(iface);
2847 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2850 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2852 HTMLElement *This = impl_from_IHTMLElement2(iface);
2853 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2856 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2858 HTMLElement *This = impl_from_IHTMLElement2(iface);
2859 return IHTMLElement_Release(&This->IHTMLElement_iface);
2862 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2864 HTMLElement *This = impl_from_IHTMLElement2(iface);
2865 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2868 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2869 LCID lcid, ITypeInfo **ppTInfo)
2871 HTMLElement *This = impl_from_IHTMLElement2(iface);
2872 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2875 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2876 LPOLESTR *rgszNames, UINT cNames,
2877 LCID lcid, DISPID *rgDispId)
2879 HTMLElement *This = impl_from_IHTMLElement2(iface);
2880 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2881 lcid, rgDispId);
2884 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2885 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2886 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2888 HTMLElement *This = impl_from_IHTMLElement2(iface);
2889 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2890 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2893 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2895 HTMLElement *This = impl_from_IHTMLElement2(iface);
2896 FIXME("(%p)->(%p)\n", This, p);
2897 return E_NOTIMPL;
2900 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2902 HTMLElement *This = impl_from_IHTMLElement2(iface);
2903 FIXME("(%p)->(%x)\n", This, containerCapture);
2904 return E_NOTIMPL;
2907 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2909 HTMLElement *This = impl_from_IHTMLElement2(iface);
2910 FIXME("(%p)\n", This);
2911 return E_NOTIMPL;
2914 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2916 HTMLElement *This = impl_from_IHTMLElement2(iface);
2917 FIXME("(%p)->()\n", This);
2918 return E_NOTIMPL;
2921 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2923 HTMLElement *This = impl_from_IHTMLElement2(iface);
2924 FIXME("(%p)->(%p)\n", This, p);
2925 return E_NOTIMPL;
2928 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2929 LONG x, LONG y, BSTR *component)
2931 HTMLElement *This = impl_from_IHTMLElement2(iface);
2932 FIXME("(%p)->(%ld %ld %p)\n", This, x, y, component);
2933 return E_NOTIMPL;
2936 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2938 HTMLElement *This = impl_from_IHTMLElement2(iface);
2940 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2942 if(!This->node.doc->content_ready
2943 || !This->node.doc->basedoc.doc_obj->in_place_active)
2944 return E_PENDING;
2946 WARN("stub\n");
2947 return S_OK;
2950 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2952 HTMLElement *This = impl_from_IHTMLElement2(iface);
2954 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2956 return set_node_event(&This->node, EVENTID_SCROLL, &v);
2959 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2961 HTMLElement *This = impl_from_IHTMLElement2(iface);
2963 TRACE("(%p)->(%p)\n", This, p);
2965 return get_node_event(&This->node, EVENTID_SCROLL, p);
2968 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2970 HTMLElement *This = impl_from_IHTMLElement2(iface);
2972 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2974 return set_node_event(&This->node, EVENTID_DRAG, &v);
2977 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2979 HTMLElement *This = impl_from_IHTMLElement2(iface);
2981 TRACE("(%p)->(%p)\n", This, p);
2983 return get_node_event(&This->node, EVENTID_DRAG, p);
2986 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2988 HTMLElement *This = impl_from_IHTMLElement2(iface);
2989 FIXME("(%p)->()\n", This);
2990 return E_NOTIMPL;
2993 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2995 HTMLElement *This = impl_from_IHTMLElement2(iface);
2996 FIXME("(%p)->(%p)\n", This, p);
2997 return E_NOTIMPL;
3000 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
3002 HTMLElement *This = impl_from_IHTMLElement2(iface);
3003 FIXME("(%p)->()\n", This);
3004 return E_NOTIMPL;
3007 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
3009 HTMLElement *This = impl_from_IHTMLElement2(iface);
3010 FIXME("(%p)->(%p)\n", This, p);
3011 return E_NOTIMPL;
3014 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
3016 HTMLElement *This = impl_from_IHTMLElement2(iface);
3017 FIXME("(%p)->()\n", This);
3018 return E_NOTIMPL;
3021 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
3023 HTMLElement *This = impl_from_IHTMLElement2(iface);
3024 FIXME("(%p)->(%p)\n", This, p);
3025 return E_NOTIMPL;
3028 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
3030 HTMLElement *This = impl_from_IHTMLElement2(iface);
3031 FIXME("(%p)->()\n", This);
3032 return E_NOTIMPL;
3035 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
3037 HTMLElement *This = impl_from_IHTMLElement2(iface);
3038 FIXME("(%p)->(%p)\n", This, p);
3039 return E_NOTIMPL;
3042 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
3044 HTMLElement *This = impl_from_IHTMLElement2(iface);
3045 FIXME("(%p)->()\n", This);
3046 return E_NOTIMPL;
3049 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
3051 HTMLElement *This = impl_from_IHTMLElement2(iface);
3052 FIXME("(%p)->(%p)\n", This, p);
3053 return E_NOTIMPL;
3056 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
3058 HTMLElement *This = impl_from_IHTMLElement2(iface);
3059 FIXME("(%p)->()\n", This);
3060 return E_NOTIMPL;
3063 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
3065 HTMLElement *This = impl_from_IHTMLElement2(iface);
3066 FIXME("(%p)->(%p)\n", This, p);
3067 return E_NOTIMPL;
3070 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
3072 HTMLElement *This = impl_from_IHTMLElement2(iface);
3073 FIXME("(%p)->()\n", This);
3074 return E_NOTIMPL;
3077 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
3079 HTMLElement *This = impl_from_IHTMLElement2(iface);
3080 FIXME("(%p)->(%p)\n", This, p);
3081 return E_NOTIMPL;
3084 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
3086 HTMLElement *This = impl_from_IHTMLElement2(iface);
3087 FIXME("(%p)->()\n", This);
3088 return E_NOTIMPL;
3091 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
3093 HTMLElement *This = impl_from_IHTMLElement2(iface);
3094 FIXME("(%p)->(%p)\n", This, p);
3095 return E_NOTIMPL;
3098 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
3100 HTMLElement *This = impl_from_IHTMLElement2(iface);
3101 FIXME("(%p)->()\n", This);
3102 return E_NOTIMPL;
3105 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
3107 HTMLElement *This = impl_from_IHTMLElement2(iface);
3108 FIXME("(%p)->(%p)\n", This, p);
3109 return E_NOTIMPL;
3112 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
3114 HTMLElement *This = impl_from_IHTMLElement2(iface);
3115 FIXME("(%p)->()\n", This);
3116 return E_NOTIMPL;
3119 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
3121 HTMLElement *This = impl_from_IHTMLElement2(iface);
3122 FIXME("(%p)->(%p)\n", This, p);
3123 return E_NOTIMPL;
3126 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
3128 HTMLElement *This = impl_from_IHTMLElement2(iface);
3130 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3132 return set_node_event(&This->node, EVENTID_PASTE, &v);
3135 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
3137 HTMLElement *This = impl_from_IHTMLElement2(iface);
3139 TRACE("(%p)->(%p)\n", This, p);
3141 return get_node_event(&This->node, EVENTID_PASTE, p);
3144 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
3146 HTMLElement *This = impl_from_IHTMLElement2(iface);
3148 TRACE("(%p)->(%p)\n", This, p);
3150 return HTMLCurrentStyle_Create(This, p);
3153 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
3155 HTMLElement *This = impl_from_IHTMLElement2(iface);
3156 FIXME("(%p)->()\n", This);
3157 return E_NOTIMPL;
3160 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
3162 HTMLElement *This = impl_from_IHTMLElement2(iface);
3163 FIXME("(%p)->(%p)\n", This, p);
3164 return E_NOTIMPL;
3167 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
3169 HTMLElement *This = impl_from_IHTMLElement2(iface);
3170 nsIDOMClientRectList *rect_list;
3171 HTMLRectCollection *rects;
3172 nsresult nsres;
3174 TRACE("(%p)->(%p)\n", This, pRectCol);
3176 if(!This->dom_element) {
3177 FIXME("comment element\n");
3178 return E_NOTIMPL;
3181 nsres = nsIDOMElement_GetClientRects(This->dom_element, &rect_list);
3182 if(NS_FAILED(nsres)) {
3183 WARN("GetClientRects failed: %08lx\n", nsres);
3184 return map_nsresult(nsres);
3187 rects = heap_alloc_zero(sizeof(*rects));
3188 if(!rects) {
3189 nsIDOMClientRectList_Release(rect_list);
3190 return E_OUTOFMEMORY;
3193 rects->IHTMLRectCollection_iface.lpVtbl = &HTMLRectCollectionVtbl;
3194 rects->ref = 1;
3195 rects->rect_list = rect_list;
3196 init_dispatch(&rects->dispex, (IUnknown*)&rects->IHTMLRectCollection_iface,
3197 &HTMLRectCollection_dispex, dispex_compat_mode(&This->node.event_target.dispex));
3199 *pRectCol = &rects->IHTMLRectCollection_iface;
3200 return S_OK;
3203 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
3205 HTMLElement *This = impl_from_IHTMLElement2(iface);
3206 nsIDOMClientRect *nsrect;
3207 nsresult nsres;
3208 HRESULT hres;
3210 TRACE("(%p)->(%p)\n", This, pRect);
3212 if(!This->dom_element) {
3213 FIXME("comment element\n");
3214 return E_NOTIMPL;
3217 nsres = nsIDOMElement_GetBoundingClientRect(This->dom_element, &nsrect);
3218 if(NS_FAILED(nsres) || !nsrect) {
3219 ERR("GetBoindingClientRect failed: %08lx\n", nsres);
3220 return E_FAIL;
3223 hres = create_html_rect(nsrect, dispex_compat_mode(&This->node.event_target.dispex), pRect);
3225 nsIDOMClientRect_Release(nsrect);
3226 return hres;
3229 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
3230 BSTR expression, BSTR language)
3232 HTMLElement *This = impl_from_IHTMLElement2(iface);
3233 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
3234 debugstr_w(language));
3235 return E_NOTIMPL;
3238 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
3239 VARIANT *expression)
3241 HTMLElement *This = impl_from_IHTMLElement2(iface);
3242 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
3243 return E_NOTIMPL;
3246 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
3247 VARIANT_BOOL *pfSuccess)
3249 HTMLElement *This = impl_from_IHTMLElement2(iface);
3250 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
3251 return E_NOTIMPL;
3254 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
3256 HTMLElement *This = impl_from_IHTMLElement2(iface);
3257 nsresult nsres;
3259 TRACE("(%p)->(%d)\n", This, v);
3261 if(!This->html_element) {
3262 FIXME("non-HTML element\n");
3263 return E_NOTIMPL;
3266 nsres = nsIDOMHTMLElement_SetTabIndex(This->html_element, v);
3267 if(NS_FAILED(nsres))
3268 ERR("GetTabIndex failed: %08lx\n", nsres);
3270 return S_OK;
3273 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
3275 HTMLElement *This = impl_from_IHTMLElement2(iface);
3276 LONG index;
3277 nsresult nsres;
3279 TRACE("(%p)->(%p)\n", This, p);
3281 if(!This->html_element) {
3282 FIXME("non-HTML element\n");
3283 return E_NOTIMPL;
3286 nsres = nsIDOMHTMLElement_GetTabIndex(This->html_element, &index);
3287 if(NS_FAILED(nsres)) {
3288 ERR("GetTabIndex failed: %08lx\n", nsres);
3289 return E_FAIL;
3292 *p = index;
3293 return S_OK;
3296 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
3298 HTMLElement *This = impl_from_IHTMLElement2(iface);
3299 nsresult nsres;
3301 TRACE("(%p)\n", This);
3303 if(!This->html_element) {
3304 FIXME("non-HTML element\n");
3305 return E_NOTIMPL;
3308 nsres = nsIDOMHTMLElement_Focus(This->html_element);
3309 if(NS_FAILED(nsres))
3310 ERR("Focus failed: %08lx\n", nsres);
3312 return S_OK;
3315 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
3317 HTMLElement *This = impl_from_IHTMLElement2(iface);
3318 nsAString nsstr;
3319 nsresult nsres;
3321 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3323 if(!This->html_element) {
3324 FIXME("non-HTML element\n");
3325 return E_NOTIMPL;
3328 nsAString_InitDepend(&nsstr, v);
3329 nsres = nsIDOMHTMLElement_SetAccessKey(This->html_element, &nsstr);
3330 nsAString_Finish(&nsstr);
3331 return map_nsresult(nsres);
3334 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
3336 HTMLElement *This = impl_from_IHTMLElement2(iface);
3337 nsAString nsstr;
3338 nsresult nsres;
3340 TRACE("(%p)->(%p)\n", This, p);
3342 if(!This->html_element) {
3343 FIXME("non-HTML element\n");
3344 return E_NOTIMPL;
3347 nsAString_InitDepend(&nsstr, NULL);
3348 nsres = nsIDOMHTMLElement_GetAccessKey(This->html_element, &nsstr);
3349 return return_nsstr(nsres, &nsstr, p);
3352 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
3354 HTMLElement *This = impl_from_IHTMLElement2(iface);
3356 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3358 return set_node_event(&This->node, EVENTID_BLUR, &v);
3361 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
3363 HTMLElement *This = impl_from_IHTMLElement2(iface);
3365 TRACE("(%p)->(%p)\n", This, p);
3367 return get_node_event(&This->node, EVENTID_BLUR, p);
3370 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
3372 HTMLElement *This = impl_from_IHTMLElement2(iface);
3374 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3376 return set_node_event(&This->node, EVENTID_FOCUS, &v);
3379 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
3381 HTMLElement *This = impl_from_IHTMLElement2(iface);
3383 TRACE("(%p)->(%p)\n", This, p);
3385 return get_node_event(&This->node, EVENTID_FOCUS, p);
3388 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
3390 HTMLElement *This = impl_from_IHTMLElement2(iface);
3392 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3394 return set_node_event(&This->node, EVENTID_RESIZE, &v);
3397 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
3399 HTMLElement *This = impl_from_IHTMLElement2(iface);
3401 TRACE("(%p)->(%p)\n", This, p);
3403 return get_node_event(&This->node, EVENTID_RESIZE, p);
3406 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
3408 HTMLElement *This = impl_from_IHTMLElement2(iface);
3409 nsresult nsres;
3411 TRACE("(%p)\n", This);
3413 if(!This->html_element) {
3414 FIXME("non-HTML element\n");
3415 return E_NOTIMPL;
3418 nsres = nsIDOMHTMLElement_Blur(This->html_element);
3419 if(NS_FAILED(nsres)) {
3420 ERR("Blur failed: %08lx\n", nsres);
3421 return E_FAIL;
3424 return S_OK;
3427 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3429 HTMLElement *This = impl_from_IHTMLElement2(iface);
3430 FIXME("(%p)->(%p)\n", This, pUnk);
3431 return E_NOTIMPL;
3434 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3436 HTMLElement *This = impl_from_IHTMLElement2(iface);
3437 FIXME("(%p)->(%p)\n", This, pUnk);
3438 return E_NOTIMPL;
3441 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
3443 HTMLElement *This = impl_from_IHTMLElement2(iface);
3444 nsresult nsres;
3446 TRACE("(%p)->(%p)\n", This, p);
3448 if(!This->dom_element) {
3449 FIXME("Unimplemented for comment element\n");
3450 return E_NOTIMPL;
3453 nsres = nsIDOMElement_GetClientHeight(This->dom_element, p);
3454 assert(nsres == NS_OK);
3455 return S_OK;
3458 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
3460 HTMLElement *This = impl_from_IHTMLElement2(iface);
3461 nsresult nsres;
3463 TRACE("(%p)->(%p)\n", This, p);
3465 if(!This->dom_element) {
3466 FIXME("comment element\n");
3467 return E_NOTIMPL;
3470 nsres = nsIDOMElement_GetClientWidth(This->dom_element, p);
3471 assert(nsres == NS_OK);
3472 return S_OK;
3475 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
3477 HTMLElement *This = impl_from_IHTMLElement2(iface);
3478 nsresult nsres;
3480 TRACE("(%p)->(%p)\n", This, p);
3482 if(!This->dom_element) {
3483 FIXME("comment element\n");
3484 return E_NOTIMPL;
3487 nsres = nsIDOMElement_GetClientTop(This->dom_element, p);
3488 assert(nsres == NS_OK);
3490 TRACE("*p = %ld\n", *p);
3491 return S_OK;
3494 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
3496 HTMLElement *This = impl_from_IHTMLElement2(iface);
3497 nsresult nsres;
3499 TRACE("(%p)->(%p)\n", This, p);
3501 if(!This->dom_element) {
3502 FIXME("comment element\n");
3503 return E_NOTIMPL;
3506 nsres = nsIDOMElement_GetClientLeft(This->dom_element, p);
3507 assert(nsres == NS_OK);
3509 TRACE("*p = %ld\n", *p);
3510 return S_OK;
3513 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
3514 IDispatch *pDisp, VARIANT_BOOL *pfResult)
3516 HTMLElement *This = impl_from_IHTMLElement2(iface);
3518 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
3520 return attach_event(&This->node.event_target, event, pDisp, pfResult);
3523 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
3525 HTMLElement *This = impl_from_IHTMLElement2(iface);
3527 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
3529 return detach_event(&This->node.event_target, event, pDisp);
3532 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
3534 HTMLElement *This = impl_from_IHTMLElement2(iface);
3535 BSTR str;
3537 TRACE("(%p)->(%p)\n", This, p);
3539 if(This->node.vtbl->get_readystate) {
3540 HRESULT hres;
3542 hres = This->node.vtbl->get_readystate(&This->node, &str);
3543 if(FAILED(hres))
3544 return hres;
3545 }else {
3546 str = SysAllocString(L"complete");
3547 if(!str)
3548 return E_OUTOFMEMORY;
3551 V_VT(p) = VT_BSTR;
3552 V_BSTR(p) = str;
3553 return S_OK;
3556 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
3558 HTMLElement *This = impl_from_IHTMLElement2(iface);
3560 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3562 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
3565 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
3567 HTMLElement *This = impl_from_IHTMLElement2(iface);
3569 TRACE("(%p)->(%p)\n", This, p);
3571 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
3574 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
3576 HTMLElement *This = impl_from_IHTMLElement2(iface);
3577 FIXME("(%p)->()\n", This);
3578 return E_NOTIMPL;
3581 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
3583 HTMLElement *This = impl_from_IHTMLElement2(iface);
3584 FIXME("(%p)->(%p)\n", This, p);
3585 return E_NOTIMPL;
3588 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
3590 HTMLElement *This = impl_from_IHTMLElement2(iface);
3591 FIXME("(%p)->()\n", This);
3592 return E_NOTIMPL;
3595 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
3597 HTMLElement *This = impl_from_IHTMLElement2(iface);
3598 FIXME("(%p)->(%p)\n", This, p);
3599 return E_NOTIMPL;
3602 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
3604 HTMLElement *This = impl_from_IHTMLElement2(iface);
3605 FIXME("(%p)->()\n", This);
3606 return E_NOTIMPL;
3609 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
3611 HTMLElement *This = impl_from_IHTMLElement2(iface);
3612 FIXME("(%p)->(%p)\n", This, p);
3613 return E_NOTIMPL;
3616 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
3618 HTMLElement *This = impl_from_IHTMLElement2(iface);
3619 nsAString nsstr;
3620 nsresult nsres;
3622 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3624 if(!This->html_element) {
3625 FIXME("non-HTML element\n");
3626 return S_OK;
3629 nsAString_InitDepend(&nsstr, v);
3630 nsres = nsIDOMHTMLElement_SetDir(This->html_element, &nsstr);
3631 nsAString_Finish(&nsstr);
3632 if(NS_FAILED(nsres)) {
3633 ERR("SetDir failed: %08lx\n", nsres);
3634 return E_FAIL;
3637 return S_OK;
3640 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
3642 HTMLElement *This = impl_from_IHTMLElement2(iface);
3643 nsAString dir_str;
3644 nsresult nsres;
3646 TRACE("(%p)->(%p)\n", This, p);
3648 if(!This->html_element) {
3649 if(This->dom_element)
3650 FIXME("non-HTML element\n");
3651 *p = NULL;
3652 return S_OK;
3655 nsAString_Init(&dir_str, NULL);
3656 nsres = nsIDOMHTMLElement_GetDir(This->html_element, &dir_str);
3657 return return_nsstr(nsres, &dir_str, p);
3660 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
3662 HTMLElement *This = impl_from_IHTMLElement2(iface);
3663 FIXME("(%p)->(%p)\n", This, range);
3664 return E_NOTIMPL;
3667 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
3669 HTMLElement *This = impl_from_IHTMLElement2(iface);
3670 nsresult nsres;
3672 TRACE("(%p)->(%p)\n", This, p);
3674 if(!This->dom_element) {
3675 FIXME("comment element\n");
3676 return E_NOTIMPL;
3679 nsres = nsIDOMElement_GetScrollHeight(This->dom_element, p);
3680 assert(nsres == NS_OK);
3681 TRACE("*p = %ld\n", *p);
3682 return S_OK;
3685 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
3687 HTMLElement *This = impl_from_IHTMLElement2(iface);
3688 nsresult nsres;
3690 TRACE("(%p)->(%p)\n", This, p);
3692 if(!This->dom_element) {
3693 FIXME("comment element\n");
3694 return E_NOTIMPL;
3697 nsres = nsIDOMElement_GetScrollWidth(This->dom_element, p);
3698 assert(nsres == NS_OK);
3700 TRACE("*p = %ld\n", *p);
3701 return S_OK;
3704 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
3706 HTMLElement *This = impl_from_IHTMLElement2(iface);
3708 TRACE("(%p)->(%ld)\n", This, v);
3710 if(!This->dom_element) {
3711 FIXME("comment element\n");
3712 return E_NOTIMPL;
3715 nsIDOMElement_SetScrollTop(This->dom_element, v);
3716 return S_OK;
3719 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
3721 HTMLElement *This = impl_from_IHTMLElement2(iface);
3722 nsresult nsres;
3724 TRACE("(%p)->(%p)\n", This, p);
3726 if(!This->dom_element) {
3727 FIXME("comment element\n");
3728 return E_NOTIMPL;
3731 nsres = nsIDOMElement_GetScrollTop(This->dom_element, p);
3732 assert(nsres == NS_OK);
3734 TRACE("*p = %ld\n", *p);
3735 return S_OK;
3738 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
3740 HTMLElement *This = impl_from_IHTMLElement2(iface);
3742 TRACE("(%p)->(%ld)\n", This, v);
3744 if(!This->dom_element) {
3745 FIXME("comment element\n");
3746 return E_NOTIMPL;
3749 nsIDOMElement_SetScrollLeft(This->dom_element, v);
3750 return S_OK;
3753 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
3755 HTMLElement *This = impl_from_IHTMLElement2(iface);
3756 nsresult nsres;
3758 TRACE("(%p)->(%p)\n", This, p);
3760 if(!p)
3761 return E_INVALIDARG;
3763 if(!This->dom_element) {
3764 FIXME("comment element\n");
3765 return E_NOTIMPL;
3768 nsres = nsIDOMElement_GetScrollLeft(This->dom_element, p);
3769 assert(nsres == NS_OK);
3770 TRACE("*p = %ld\n", *p);
3771 return S_OK;
3774 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
3776 HTMLElement *This = impl_from_IHTMLElement2(iface);
3777 FIXME("(%p)\n", This);
3778 return E_NOTIMPL;
3781 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
3783 HTMLElement *This = impl_from_IHTMLElement2(iface);
3784 FIXME("(%p)->(%p)\n", This, mergeThis);
3785 return E_NOTIMPL;
3788 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
3790 HTMLElement *This = impl_from_IHTMLElement2(iface);
3792 TRACE("(%p)->()\n", This);
3794 return set_node_event(&This->node, EVENTID_CONTEXTMENU, &v);
3797 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
3799 HTMLElement *This = impl_from_IHTMLElement2(iface);
3801 TRACE("(%p)->(%p)\n", This, p);
3803 return get_node_event(&This->node, EVENTID_CONTEXTMENU, p);
3806 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
3807 IHTMLElement *insertedElement, IHTMLElement **inserted)
3809 HTMLElement *This = impl_from_IHTMLElement2(iface);
3810 HTMLDOMNode *ret_node;
3811 HTMLElement *elem;
3812 HRESULT hres;
3814 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
3816 elem = unsafe_impl_from_IHTMLElement(insertedElement);
3817 if(!elem)
3818 return E_INVALIDARG;
3820 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
3821 if(FAILED(hres))
3822 return hres;
3824 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
3825 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
3826 return hres;
3829 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
3830 BSTR where, IHTMLElement **applied)
3832 HTMLElement *This = impl_from_IHTMLElement2(iface);
3833 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
3834 return E_NOTIMPL;
3837 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
3839 HTMLElement *This = impl_from_IHTMLElement2(iface);
3840 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
3841 return E_NOTIMPL;
3844 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
3845 BSTR newText, BSTR *oldText)
3847 HTMLElement *This = impl_from_IHTMLElement2(iface);
3848 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
3849 return E_NOTIMPL;
3852 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
3854 HTMLElement *This = impl_from_IHTMLElement2(iface);
3855 FIXME("(%p)->(%p)\n", This, p);
3856 return E_NOTIMPL;
3859 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
3860 VARIANT *pvarFactory, LONG *pCookie)
3862 HTMLElement *This = impl_from_IHTMLElement2(iface);
3863 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
3864 return E_NOTIMPL;
3867 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
3868 VARIANT_BOOL *pfResult)
3870 HTMLElement *This = impl_from_IHTMLElement2(iface);
3871 FIXME("(%p)->(%ld %p)\n", This, cookie, pfResult);
3872 return E_NOTIMPL;
3875 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
3877 HTMLElement *This = impl_from_IHTMLElement2(iface);
3879 FIXME("(%p)->(%p): hack\n", This, p);
3881 /* We can't implement correct behavior on top of Gecko (although we could
3882 try a bit harder). Making runtimeStyle behave like regular style is
3883 enough for most use cases. */
3884 if(!This->runtime_style) {
3885 HRESULT hres;
3887 hres = HTMLStyle_Create(This, &This->runtime_style);
3888 if(FAILED(hres))
3889 return hres;
3892 *p = &This->runtime_style->IHTMLStyle_iface;
3893 IHTMLStyle_AddRef(*p);
3894 return S_OK;
3897 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
3899 HTMLElement *This = impl_from_IHTMLElement2(iface);
3900 FIXME("(%p)->(%p)\n", This, p);
3901 return E_NOTIMPL;
3904 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
3906 HTMLElement *This = impl_from_IHTMLElement2(iface);
3907 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3908 return E_NOTIMPL;
3911 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
3913 HTMLElement *This = impl_from_IHTMLElement2(iface);
3914 FIXME("(%p)->(%p)\n", This, p);
3915 return E_NOTIMPL;
3918 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
3920 HTMLElement *This = impl_from_IHTMLElement2(iface);
3921 FIXME("(%p)->()\n", This);
3922 return E_NOTIMPL;
3925 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
3927 HTMLElement *This = impl_from_IHTMLElement2(iface);
3928 FIXME("(%p)->(%p)\n", This, p);
3929 return E_NOTIMPL;
3932 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
3934 HTMLElement *This = impl_from_IHTMLElement2(iface);
3935 FIXME("(%p)->(%p)\n", This, p);
3936 return E_NOTIMPL;
3939 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
3940 IHTMLElementCollection **pelColl)
3942 HTMLElement *This = impl_from_IHTMLElement2(iface);
3943 nsIDOMHTMLCollection *nscol;
3944 nsAString tag_str;
3945 nsresult nsres;
3947 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
3949 if(!This->dom_element) {
3950 *pelColl = create_collection_from_htmlcol(NULL, This->node.doc->document_mode);
3951 return S_OK;
3954 nsAString_InitDepend(&tag_str, v);
3955 nsres = nsIDOMElement_GetElementsByTagName(This->dom_element, &tag_str, &nscol);
3956 nsAString_Finish(&tag_str);
3957 if(NS_FAILED(nsres)) {
3958 ERR("GetElementByTagName failed: %08lx\n", nsres);
3959 return E_FAIL;
3962 *pelColl = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
3963 nsIDOMHTMLCollection_Release(nscol);
3964 return S_OK;
3967 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
3968 HTMLElement2_QueryInterface,
3969 HTMLElement2_AddRef,
3970 HTMLElement2_Release,
3971 HTMLElement2_GetTypeInfoCount,
3972 HTMLElement2_GetTypeInfo,
3973 HTMLElement2_GetIDsOfNames,
3974 HTMLElement2_Invoke,
3975 HTMLElement2_get_scopeName,
3976 HTMLElement2_setCapture,
3977 HTMLElement2_releaseCapture,
3978 HTMLElement2_put_onlosecapture,
3979 HTMLElement2_get_onlosecapture,
3980 HTMLElement2_componentFromPoint,
3981 HTMLElement2_doScroll,
3982 HTMLElement2_put_onscroll,
3983 HTMLElement2_get_onscroll,
3984 HTMLElement2_put_ondrag,
3985 HTMLElement2_get_ondrag,
3986 HTMLElement2_put_ondragend,
3987 HTMLElement2_get_ondragend,
3988 HTMLElement2_put_ondragenter,
3989 HTMLElement2_get_ondragenter,
3990 HTMLElement2_put_ondragover,
3991 HTMLElement2_get_ondragover,
3992 HTMLElement2_put_ondragleave,
3993 HTMLElement2_get_ondragleave,
3994 HTMLElement2_put_ondrop,
3995 HTMLElement2_get_ondrop,
3996 HTMLElement2_put_onbeforecut,
3997 HTMLElement2_get_onbeforecut,
3998 HTMLElement2_put_oncut,
3999 HTMLElement2_get_oncut,
4000 HTMLElement2_put_onbeforecopy,
4001 HTMLElement2_get_onbeforecopy,
4002 HTMLElement2_put_oncopy,
4003 HTMLElement2_get_oncopy,
4004 HTMLElement2_put_onbeforepaste,
4005 HTMLElement2_get_onbeforepaste,
4006 HTMLElement2_put_onpaste,
4007 HTMLElement2_get_onpaste,
4008 HTMLElement2_get_currentStyle,
4009 HTMLElement2_put_onpropertychange,
4010 HTMLElement2_get_onpropertychange,
4011 HTMLElement2_getClientRects,
4012 HTMLElement2_getBoundingClientRect,
4013 HTMLElement2_setExpression,
4014 HTMLElement2_getExpression,
4015 HTMLElement2_removeExpression,
4016 HTMLElement2_put_tabIndex,
4017 HTMLElement2_get_tabIndex,
4018 HTMLElement2_focus,
4019 HTMLElement2_put_accessKey,
4020 HTMLElement2_get_accessKey,
4021 HTMLElement2_put_onblur,
4022 HTMLElement2_get_onblur,
4023 HTMLElement2_put_onfocus,
4024 HTMLElement2_get_onfocus,
4025 HTMLElement2_put_onresize,
4026 HTMLElement2_get_onresize,
4027 HTMLElement2_blur,
4028 HTMLElement2_addFilter,
4029 HTMLElement2_removeFilter,
4030 HTMLElement2_get_clientHeight,
4031 HTMLElement2_get_clientWidth,
4032 HTMLElement2_get_clientTop,
4033 HTMLElement2_get_clientLeft,
4034 HTMLElement2_attachEvent,
4035 HTMLElement2_detachEvent,
4036 HTMLElement2_get_readyState,
4037 HTMLElement2_put_onreadystatechange,
4038 HTMLElement2_get_onreadystatechange,
4039 HTMLElement2_put_onrowsdelete,
4040 HTMLElement2_get_onrowsdelete,
4041 HTMLElement2_put_onrowsinserted,
4042 HTMLElement2_get_onrowsinserted,
4043 HTMLElement2_put_oncellchange,
4044 HTMLElement2_get_oncellchange,
4045 HTMLElement2_put_dir,
4046 HTMLElement2_get_dir,
4047 HTMLElement2_createControlRange,
4048 HTMLElement2_get_scrollHeight,
4049 HTMLElement2_get_scrollWidth,
4050 HTMLElement2_put_scrollTop,
4051 HTMLElement2_get_scrollTop,
4052 HTMLElement2_put_scrollLeft,
4053 HTMLElement2_get_scrollLeft,
4054 HTMLElement2_clearAttributes,
4055 HTMLElement2_mergeAttributes,
4056 HTMLElement2_put_oncontextmenu,
4057 HTMLElement2_get_oncontextmenu,
4058 HTMLElement2_insertAdjacentElement,
4059 HTMLElement2_applyElement,
4060 HTMLElement2_getAdjacentText,
4061 HTMLElement2_replaceAdjacentText,
4062 HTMLElement2_get_canHandleChildren,
4063 HTMLElement2_addBehavior,
4064 HTMLElement2_removeBehavior,
4065 HTMLElement2_get_runtimeStyle,
4066 HTMLElement2_get_behaviorUrns,
4067 HTMLElement2_put_tagUrn,
4068 HTMLElement2_get_tagUrn,
4069 HTMLElement2_put_onbeforeeditfocus,
4070 HTMLElement2_get_onbeforeeditfocus,
4071 HTMLElement2_get_readyStateValue,
4072 HTMLElement2_getElementsByTagName,
4075 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
4077 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
4080 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
4081 REFIID riid, void **ppv)
4083 HTMLElement *This = impl_from_IHTMLElement3(iface);
4084 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4087 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
4089 HTMLElement *This = impl_from_IHTMLElement3(iface);
4090 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4093 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
4095 HTMLElement *This = impl_from_IHTMLElement3(iface);
4096 return IHTMLElement_Release(&This->IHTMLElement_iface);
4099 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
4101 HTMLElement *This = impl_from_IHTMLElement3(iface);
4102 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4105 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
4106 LCID lcid, ITypeInfo **ppTInfo)
4108 HTMLElement *This = impl_from_IHTMLElement3(iface);
4109 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4112 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
4113 LPOLESTR *rgszNames, UINT cNames,
4114 LCID lcid, DISPID *rgDispId)
4116 HTMLElement *This = impl_from_IHTMLElement3(iface);
4117 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4118 lcid, rgDispId);
4121 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
4122 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4123 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4125 HTMLElement *This = impl_from_IHTMLElement3(iface);
4126 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4127 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4130 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
4132 HTMLElement *This = impl_from_IHTMLElement3(iface);
4133 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
4134 return E_NOTIMPL;
4137 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
4139 HTMLElement *This = impl_from_IHTMLElement3(iface);
4140 FIXME("(%p)->(%p)\n", This, p);
4141 return E_NOTIMPL;
4144 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
4146 HTMLElement *This = impl_from_IHTMLElement3(iface);
4147 FIXME("(%p)->(%p)\n", This, p);
4148 return E_NOTIMPL;
4151 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
4153 HTMLElement *This = impl_from_IHTMLElement3(iface);
4154 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4155 return E_NOTIMPL;
4158 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
4160 HTMLElement *This = impl_from_IHTMLElement3(iface);
4161 FIXME("(%p)->(%p)\n", This, p);
4162 return E_NOTIMPL;
4165 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
4167 HTMLElement *This = impl_from_IHTMLElement3(iface);
4168 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4169 return E_NOTIMPL;
4172 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
4174 HTMLElement *This = impl_from_IHTMLElement3(iface);
4175 FIXME("(%p)->(%p)\n", This, p);
4176 return E_NOTIMPL;
4179 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
4181 HTMLElement *This = impl_from_IHTMLElement3(iface);
4182 FIXME("(%p)->(%x)\n", This, v);
4183 return E_NOTIMPL;
4186 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
4188 HTMLElement *This = impl_from_IHTMLElement3(iface);
4189 FIXME("(%p)->(%p)\n", This, p);
4190 return E_NOTIMPL;
4193 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
4195 HTMLElement *This = impl_from_IHTMLElement3(iface);
4196 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4197 return E_NOTIMPL;
4200 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
4202 HTMLElement *This = impl_from_IHTMLElement3(iface);
4203 FIXME("(%p)->(%p)\n", This, p);
4204 return E_NOTIMPL;
4207 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
4209 HTMLElement *This = impl_from_IHTMLElement3(iface);
4210 FIXME("(%p)\n", This);
4211 return E_NOTIMPL;
4214 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
4216 HTMLElement *This = impl_from_IHTMLElement3(iface);
4217 nsresult nsres;
4218 nsAString str;
4220 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
4222 if(!This->html_element) {
4223 FIXME("non-HTML element\n");
4224 return E_NOTIMPL;
4227 nsAString_InitDepend(&str, v);
4228 nsres = nsIDOMHTMLElement_SetContentEditable(This->html_element, &str);
4229 nsAString_Finish(&str);
4231 if (NS_FAILED(nsres)){
4232 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
4233 return E_FAIL;
4236 return S_OK;
4239 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
4241 HTMLElement *This = impl_from_IHTMLElement3(iface);
4242 nsresult nsres;
4243 nsAString str;
4245 TRACE("(%p)->(%p)\n", This, p);
4247 if(!This->html_element) {
4248 FIXME("non-HTML element\n");
4249 return E_NOTIMPL;
4252 nsAString_Init(&str, NULL);
4253 nsres = nsIDOMHTMLElement_GetContentEditable(This->html_element, &str);
4254 return return_nsstr(nsres, &str, p);
4257 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
4259 HTMLElement *This = impl_from_IHTMLElement3(iface);
4260 FIXME("(%p)->(%p)\n", This, p);
4261 return E_NOTIMPL;
4264 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
4266 HTMLElement *This = impl_from_IHTMLElement3(iface);
4267 FIXME("(%p)->(%x)\n", This, v);
4268 return E_NOTIMPL;
4271 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
4273 HTMLElement *This = impl_from_IHTMLElement3(iface);
4274 FIXME("(%p)->(%p)\n", This, p);
4275 return E_NOTIMPL;
4278 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
4280 HTMLElement *This = impl_from_IHTMLElement3(iface);
4282 TRACE("(%p)->(%x)\n", This, v);
4284 if(This->node.vtbl->put_disabled)
4285 return This->node.vtbl->put_disabled(&This->node, v);
4287 if(!v) return element_remove_attribute(This, L"disabled");
4288 return elem_string_attr_setter(This, L"disabled", L"");
4291 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4293 HTMLElement *This = impl_from_IHTMLElement3(iface);
4295 TRACE("(%p)->(%p)\n", This, p);
4297 if(This->node.vtbl->get_disabled)
4298 return This->node.vtbl->get_disabled(&This->node, p);
4300 *p = variant_bool(element_has_attribute(This, L"disabled"));
4301 return S_OK;
4304 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4306 HTMLElement *This = impl_from_IHTMLElement3(iface);
4307 FIXME("(%p)->(%p)\n", This, p);
4308 return E_NOTIMPL;
4311 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
4313 HTMLElement *This = impl_from_IHTMLElement3(iface);
4314 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4315 return E_NOTIMPL;
4318 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
4320 HTMLElement *This = impl_from_IHTMLElement3(iface);
4321 FIXME("(%p)->(%p)\n", This, p);
4322 return E_NOTIMPL;
4325 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
4327 HTMLElement *This = impl_from_IHTMLElement3(iface);
4328 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4329 return E_NOTIMPL;
4332 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
4334 HTMLElement *This = impl_from_IHTMLElement3(iface);
4335 FIXME("(%p)->(%p)\n", This, p);
4336 return E_NOTIMPL;
4339 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
4340 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
4342 HTMLElement *This = impl_from_IHTMLElement3(iface);
4344 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
4345 pfCancelled);
4347 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
4350 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
4352 HTMLElement *This = impl_from_IHTMLElement3(iface);
4353 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4354 return E_NOTIMPL;
4357 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
4359 HTMLElement *This = impl_from_IHTMLElement3(iface);
4360 FIXME("(%p)->(%p)\n", This, p);
4361 return E_NOTIMPL;
4364 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
4366 HTMLElement *This = impl_from_IHTMLElement3(iface);
4367 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4368 return E_NOTIMPL;
4371 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
4373 HTMLElement *This = impl_from_IHTMLElement3(iface);
4374 FIXME("(%p)->(%p)\n", This, p);
4375 return E_NOTIMPL;
4378 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
4380 HTMLElement *This = impl_from_IHTMLElement3(iface);
4381 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4382 return E_NOTIMPL;
4385 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
4387 HTMLElement *This = impl_from_IHTMLElement3(iface);
4388 FIXME("(%p)->(%p)\n", This, p);
4389 return E_NOTIMPL;
4392 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
4394 HTMLElement *This = impl_from_IHTMLElement3(iface);
4395 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4396 return E_NOTIMPL;
4399 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
4401 HTMLElement *This = impl_from_IHTMLElement3(iface);
4402 FIXME("(%p)->(%p)\n", This, p);
4403 return E_NOTIMPL;
4406 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
4408 HTMLElement *This = impl_from_IHTMLElement3(iface);
4409 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4410 return E_NOTIMPL;
4413 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
4415 HTMLElement *This = impl_from_IHTMLElement3(iface);
4416 FIXME("(%p)->(%p)\n", This, p);
4417 return E_NOTIMPL;
4420 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
4422 HTMLElement *This = impl_from_IHTMLElement3(iface);
4423 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4424 return E_NOTIMPL;
4427 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
4429 HTMLElement *This = impl_from_IHTMLElement3(iface);
4430 FIXME("(%p)->(%p)\n", This, p);
4431 return E_NOTIMPL;
4434 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
4436 HTMLElement *This = impl_from_IHTMLElement3(iface);
4437 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4438 return E_NOTIMPL;
4441 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
4443 HTMLElement *This = impl_from_IHTMLElement3(iface);
4444 FIXME("(%p)->(%p)\n", This, p);
4445 return E_NOTIMPL;
4448 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
4450 HTMLElement *This = impl_from_IHTMLElement3(iface);
4451 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4452 return E_NOTIMPL;
4455 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
4457 HTMLElement *This = impl_from_IHTMLElement3(iface);
4458 FIXME("(%p)->(%p)\n", This, p);
4459 return E_NOTIMPL;
4462 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
4464 HTMLElement *This = impl_from_IHTMLElement3(iface);
4465 FIXME("(%p)->(%p)\n", This, pfRet);
4466 return E_NOTIMPL;
4469 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
4471 HTMLElement *This = impl_from_IHTMLElement3(iface);
4472 FIXME("(%p)->(%p)\n", This, p);
4473 return E_NOTIMPL;
4476 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
4477 HTMLElement3_QueryInterface,
4478 HTMLElement3_AddRef,
4479 HTMLElement3_Release,
4480 HTMLElement3_GetTypeInfoCount,
4481 HTMLElement3_GetTypeInfo,
4482 HTMLElement3_GetIDsOfNames,
4483 HTMLElement3_Invoke,
4484 HTMLElement3_mergeAttributes,
4485 HTMLElement3_get_isMultiLine,
4486 HTMLElement3_get_canHaveHTML,
4487 HTMLElement3_put_onlayoutcomplete,
4488 HTMLElement3_get_onlayoutcomplete,
4489 HTMLElement3_put_onpage,
4490 HTMLElement3_get_onpage,
4491 HTMLElement3_put_inflateBlock,
4492 HTMLElement3_get_inflateBlock,
4493 HTMLElement3_put_onbeforedeactivate,
4494 HTMLElement3_get_onbeforedeactivate,
4495 HTMLElement3_setActive,
4496 HTMLElement3_put_contentEditable,
4497 HTMLElement3_get_contentEditable,
4498 HTMLElement3_get_isContentEditable,
4499 HTMLElement3_put_hideFocus,
4500 HTMLElement3_get_hideFocus,
4501 HTMLElement3_put_disabled,
4502 HTMLElement3_get_disabled,
4503 HTMLElement3_get_isDisabled,
4504 HTMLElement3_put_onmove,
4505 HTMLElement3_get_onmove,
4506 HTMLElement3_put_oncontrolselect,
4507 HTMLElement3_get_oncontrolselect,
4508 HTMLElement3_fireEvent,
4509 HTMLElement3_put_onresizestart,
4510 HTMLElement3_get_onresizestart,
4511 HTMLElement3_put_onresizeend,
4512 HTMLElement3_get_onresizeend,
4513 HTMLElement3_put_onmovestart,
4514 HTMLElement3_get_onmovestart,
4515 HTMLElement3_put_onmoveend,
4516 HTMLElement3_get_onmoveend,
4517 HTMLElement3_put_onmousecenter,
4518 HTMLElement3_get_onmousecenter,
4519 HTMLElement3_put_onmouseleave,
4520 HTMLElement3_get_onmouseleave,
4521 HTMLElement3_put_onactivate,
4522 HTMLElement3_get_onactivate,
4523 HTMLElement3_put_ondeactivate,
4524 HTMLElement3_get_ondeactivate,
4525 HTMLElement3_dragDrop,
4526 HTMLElement3_get_glyphMode
4529 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
4531 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
4534 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
4535 REFIID riid, void **ppv)
4537 HTMLElement *This = impl_from_IHTMLElement4(iface);
4538 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4541 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
4543 HTMLElement *This = impl_from_IHTMLElement4(iface);
4544 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4547 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
4549 HTMLElement *This = impl_from_IHTMLElement4(iface);
4550 return IHTMLElement_Release(&This->IHTMLElement_iface);
4553 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
4555 HTMLElement *This = impl_from_IHTMLElement4(iface);
4556 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4559 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
4560 LCID lcid, ITypeInfo **ppTInfo)
4562 HTMLElement *This = impl_from_IHTMLElement4(iface);
4563 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4566 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
4567 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4569 HTMLElement *This = impl_from_IHTMLElement4(iface);
4570 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4571 lcid, rgDispId);
4574 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
4575 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4577 HTMLElement *This = impl_from_IHTMLElement4(iface);
4578 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4579 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4582 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
4584 HTMLElement *This = impl_from_IHTMLElement4(iface);
4586 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4588 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
4591 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
4593 HTMLElement *This = impl_from_IHTMLElement4(iface);
4595 TRACE("(%p)->(%p)\n", This, p);
4597 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
4600 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
4602 HTMLElement *This = impl_from_IHTMLElement4(iface);
4603 FIXME("(%p)\n", This);
4604 return E_NOTIMPL;
4607 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
4609 HTMLElement *This = impl_from_IHTMLElement4(iface);
4610 HTMLAttributeCollection *attrs;
4611 HRESULT hres;
4613 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
4615 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4616 if(FAILED(hres))
4617 return hres;
4619 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
4620 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4621 return hres;
4624 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4625 IHTMLDOMAttribute **ppretAttribute)
4627 HTMLElement *This = impl_from_IHTMLElement4(iface);
4628 HTMLDOMAttribute *attr, *iter, *replace = NULL;
4629 HTMLAttributeCollection *attrs;
4630 DISPID dispid;
4631 HRESULT hres;
4633 TRACE("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4635 attr = unsafe_impl_from_IHTMLDOMAttribute(pattr);
4636 if(!attr)
4637 return E_INVALIDARG;
4639 if(attr->elem) {
4640 WARN("Tried to set already attached attribute.\n");
4641 return E_INVALIDARG;
4644 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface,
4645 attr->name, fdexNameCaseInsensitive|fdexNameEnsure, &dispid);
4646 if(FAILED(hres))
4647 return hres;
4649 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4650 if(FAILED(hres))
4651 return hres;
4653 LIST_FOR_EACH_ENTRY(iter, &attrs->attrs, HTMLDOMAttribute, entry) {
4654 if(iter->dispid == dispid) {
4655 replace = iter;
4656 break;
4660 if(replace) {
4661 hres = get_elem_attr_value_by_dispid(This, dispid, &replace->value);
4662 if(FAILED(hres)) {
4663 WARN("could not get attr value: %08lx\n", hres);
4664 V_VT(&replace->value) = VT_EMPTY;
4666 if(!replace->name) {
4667 replace->name = attr->name;
4668 attr->name = NULL;
4670 list_add_head(&replace->entry, &attr->entry);
4671 list_remove(&replace->entry);
4672 replace->elem = NULL;
4673 }else {
4674 list_add_tail(&attrs->attrs, &attr->entry);
4677 IHTMLDOMAttribute_AddRef(&attr->IHTMLDOMAttribute_iface);
4678 attr->elem = This;
4679 attr->dispid = dispid;
4681 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4683 hres = set_elem_attr_value_by_dispid(This, dispid, &attr->value);
4684 if(FAILED(hres))
4685 WARN("Could not set attribute value: %08lx\n", hres);
4686 VariantClear(&attr->value);
4688 *ppretAttribute = replace ? &replace->IHTMLDOMAttribute_iface : NULL;
4689 return S_OK;
4692 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4693 IHTMLDOMAttribute **ppretAttribute)
4695 HTMLElement *This = impl_from_IHTMLElement4(iface);
4696 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4697 return E_NOTIMPL;
4700 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
4702 HTMLElement *This = impl_from_IHTMLElement4(iface);
4704 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4706 return set_node_event(&This->node, EVENTID_BEFOREACTIVATE, &v);
4709 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
4711 HTMLElement *This = impl_from_IHTMLElement4(iface);
4713 TRACE("(%p)->(%p)\n", This, p);
4715 return get_node_event(&This->node, EVENTID_BEFOREACTIVATE, p);
4718 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
4720 HTMLElement *This = impl_from_IHTMLElement4(iface);
4722 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4724 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
4727 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
4729 HTMLElement *This = impl_from_IHTMLElement4(iface);
4731 TRACE("(%p)->(%p)\n", This, p);
4733 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
4736 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
4738 HTMLElement *This = impl_from_IHTMLElement4(iface);
4740 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4742 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
4745 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
4747 HTMLElement *This = impl_from_IHTMLElement4(iface);
4749 TRACE("(%p)->(%p)\n", This, p);
4751 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
4754 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
4755 HTMLElement4_QueryInterface,
4756 HTMLElement4_AddRef,
4757 HTMLElement4_Release,
4758 HTMLElement4_GetTypeInfoCount,
4759 HTMLElement4_GetTypeInfo,
4760 HTMLElement4_GetIDsOfNames,
4761 HTMLElement4_Invoke,
4762 HTMLElement4_put_onmousewheel,
4763 HTMLElement4_get_onmousewheel,
4764 HTMLElement4_normalize,
4765 HTMLElement4_getAttributeNode,
4766 HTMLElement4_setAttributeNode,
4767 HTMLElement4_removeAttributeNode,
4768 HTMLElement4_put_onbeforeactivate,
4769 HTMLElement4_get_onbeforeactivate,
4770 HTMLElement4_put_onfocusin,
4771 HTMLElement4_get_onfocusin,
4772 HTMLElement4_put_onfocusout,
4773 HTMLElement4_get_onfocusout
4776 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
4778 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
4781 static HRESULT WINAPI HTMLElement6_QueryInterface(IHTMLElement6 *iface,
4782 REFIID riid, void **ppv)
4784 HTMLElement *This = impl_from_IHTMLElement6(iface);
4785 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4788 static ULONG WINAPI HTMLElement6_AddRef(IHTMLElement6 *iface)
4790 HTMLElement *This = impl_from_IHTMLElement6(iface);
4791 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4794 static ULONG WINAPI HTMLElement6_Release(IHTMLElement6 *iface)
4796 HTMLElement *This = impl_from_IHTMLElement6(iface);
4797 return IHTMLElement_Release(&This->IHTMLElement_iface);
4800 static HRESULT WINAPI HTMLElement6_GetTypeInfoCount(IHTMLElement6 *iface, UINT *pctinfo)
4802 HTMLElement *This = impl_from_IHTMLElement6(iface);
4803 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4806 static HRESULT WINAPI HTMLElement6_GetTypeInfo(IHTMLElement6 *iface, UINT iTInfo,
4807 LCID lcid, ITypeInfo **ppTInfo)
4809 HTMLElement *This = impl_from_IHTMLElement6(iface);
4810 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4813 static HRESULT WINAPI HTMLElement6_GetIDsOfNames(IHTMLElement6 *iface, REFIID riid,
4814 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4816 HTMLElement *This = impl_from_IHTMLElement6(iface);
4817 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4818 lcid, rgDispId);
4821 static HRESULT WINAPI HTMLElement6_Invoke(IHTMLElement6 *iface, DISPID dispIdMember, REFIID riid,
4822 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4824 HTMLElement *This = impl_from_IHTMLElement6(iface);
4825 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4826 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4829 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
4831 HTMLElement *This = impl_from_IHTMLElement6(iface);
4832 nsAString ns_str, name_str, value_str;
4833 nsresult nsres;
4834 HRESULT hres;
4836 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
4838 if(!This->dom_element) {
4839 FIXME("No dom_element\n");
4840 return E_NOTIMPL;
4843 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4844 if(FAILED(hres))
4845 return hres;
4847 nsAString_InitDepend(&name_str, strAttributeName);
4848 nsAString_InitDepend(&value_str, NULL);
4849 nsres = nsIDOMElement_GetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
4850 nsAString_Finish(&ns_str);
4851 nsAString_Finish(&name_str);
4853 hres = return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
4854 if(SUCCEEDED(hres) && V_VT(AttributeValue) == VT_NULL) {
4855 V_VT(AttributeValue) = VT_BSTR;
4856 V_BSTR(AttributeValue) = NULL;
4858 return hres;
4861 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4863 HTMLElement *This = impl_from_IHTMLElement6(iface);
4864 nsAString ns_str, name_str, value_str;
4865 const PRUnichar *ns;
4866 nsresult nsres;
4867 HRESULT hres;
4869 TRACE("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
4871 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4872 if(FAILED(hres))
4873 return hres;
4874 nsAString_GetData(&ns_str, &ns);
4875 if((!ns || !ns[0]) && wcschr(strAttributeName, ':')) {
4876 nsAString_Finish(&ns_str);
4877 /* FIXME: Return NamespaceError */
4878 return E_FAIL;
4881 if(!This->dom_element) {
4882 FIXME("No dom_element\n");
4883 nsAString_Finish(&ns_str);
4884 return E_NOTIMPL;
4887 hres = variant_to_nsstr(pvarAttributeValue, FALSE, &value_str);
4888 if(FAILED(hres)) {
4889 nsAString_Finish(&ns_str);
4890 return hres;
4893 nsAString_InitDepend(&name_str, strAttributeName);
4894 nsres = nsIDOMElement_SetAttributeNS(This->dom_element, &ns_str, &name_str, &value_str);
4895 nsAString_Finish(&ns_str);
4896 nsAString_Finish(&name_str);
4897 nsAString_Finish(&value_str);
4898 if(NS_FAILED(nsres))
4899 WARN("SetAttributeNS failed: %08lx\n", nsres);
4900 return map_nsresult(nsres);
4903 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
4905 HTMLElement *This = impl_from_IHTMLElement6(iface);
4906 nsAString ns_str, name_str;
4907 nsresult nsres;
4908 HRESULT hres;
4910 TRACE("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
4912 if(!This->dom_element) {
4913 FIXME("No dom_element\n");
4914 return E_NOTIMPL;
4917 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4918 if(FAILED(hres))
4919 return hres;
4921 nsAString_InitDepend(&name_str, strAttributeName);
4922 nsres = nsIDOMElement_RemoveAttributeNS(This->dom_element, &ns_str, &name_str);
4923 nsAString_Finish(&ns_str);
4924 nsAString_Finish(&name_str);
4925 return map_nsresult(nsres);
4928 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
4930 HTMLElement *This = impl_from_IHTMLElement6(iface);
4931 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
4932 return E_NOTIMPL;
4935 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4937 HTMLElement *This = impl_from_IHTMLElement6(iface);
4938 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4939 return E_NOTIMPL;
4942 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
4944 HTMLElement *This = impl_from_IHTMLElement6(iface);
4945 nsAString ns_str, name_str;
4946 nsresult nsres;
4947 HRESULT hres;
4948 cpp_bool r;
4950 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
4952 if(!This->dom_element) {
4953 FIXME("No dom_element\n");
4954 return E_NOTIMPL;
4957 hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
4958 if(FAILED(hres))
4959 return hres;
4961 nsAString_InitDepend(&name_str, name);
4962 nsres = nsIDOMElement_HasAttributeNS(This->dom_element, &ns_str, &name_str, &r);
4963 nsAString_Finish(&ns_str);
4964 nsAString_Finish(&name_str);
4965 *pfHasAttribute = variant_bool(NS_SUCCEEDED(nsres) && r);
4966 return S_OK;
4969 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
4971 HTMLElement *This = impl_from_IHTMLElement6(iface);
4973 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), AttributeValue);
4975 return IHTMLElement_getAttribute(&This->IHTMLElement_iface, strAttributeName, 0, AttributeValue);
4978 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4980 HTMLElement *This = impl_from_IHTMLElement6(iface);
4982 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
4984 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, strAttributeName, *pvarAttributeValue, 0);
4987 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
4989 HTMLElement *This = impl_from_IHTMLElement6(iface);
4990 VARIANT_BOOL success;
4992 WARN("(%p)->(%s) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName));
4994 return IHTMLElement_removeAttribute(&This->IHTMLElement_iface, strAttributeName, 0, &success);
4997 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
4999 HTMLElement *This = impl_from_IHTMLElement6(iface);
5000 IHTMLDOMAttribute *attr;
5001 HRESULT hres;
5003 WARN("(%p)->(%s %p) forwarding to IHTMLElement4\n", This, debugstr_w(strAttributeName), ppretAttribute);
5005 hres = IHTMLElement4_getAttributeNode(&This->IHTMLElement4_iface, strAttributeName, &attr);
5006 if(FAILED(hres))
5007 return hres;
5009 if(attr) {
5010 hres = IHTMLDOMAttribute_QueryInterface(attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
5011 IHTMLDOMAttribute_Release(attr);
5012 }else {
5013 *ppretAttribute = NULL;
5015 return hres;
5018 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5020 HTMLElement *This = impl_from_IHTMLElement6(iface);
5021 IHTMLDOMAttribute *attr, *ret_attr;
5022 HRESULT hres;
5024 WARN("(%p)->(%p %p) forwarding to IHTMLElement4\n", This, pattr, ppretAttribute);
5026 hres = IHTMLDOMAttribute2_QueryInterface(pattr, &IID_IHTMLDOMAttribute, (void**)&attr);
5027 if(FAILED(hres))
5028 return hres;
5030 hres = IHTMLElement4_setAttributeNode(&This->IHTMLElement4_iface, attr, &ret_attr);
5031 if(FAILED(hres))
5032 return hres;
5034 if(ret_attr) {
5035 hres = IHTMLDOMAttribute_QueryInterface(ret_attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
5036 IHTMLDOMAttribute_Release(ret_attr);
5037 }else {
5038 *ppretAttribute = NULL;
5040 return hres;
5043 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
5045 HTMLElement *This = impl_from_IHTMLElement6(iface);
5046 FIXME("(%p)->()\n", This);
5047 return E_NOTIMPL;
5050 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *p)
5052 HTMLElement *This = impl_from_IHTMLElement6(iface);
5054 TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), p);
5056 *p = element_has_attribute(This, name);
5057 return S_OK;
5060 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
5062 HTMLElement *This = impl_from_IHTMLElement6(iface);
5063 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
5064 return E_NOTIMPL;
5067 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
5069 HTMLElement *This = impl_from_IHTMLElement6(iface);
5071 TRACE("(%p)->(%p)\n", This, p);
5073 return IHTMLElement_get_tagName(&This->IHTMLElement_iface, p);
5076 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
5078 HTMLElement *This = impl_from_IHTMLElement6(iface);
5080 TRACE("(%p)->(%p)\n", This, p);
5082 return IHTMLDOMNode_get_nodeName(&This->node.IHTMLDOMNode_iface, p);
5085 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
5087 HTMLElement *This = impl_from_IHTMLElement6(iface);
5088 nsIDOMHTMLCollection *nscol = NULL;
5089 nsAString nsstr;
5090 nsresult nsres;
5092 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
5094 if(This->dom_element) {
5095 nsAString_InitDepend(&nsstr, v);
5096 nsres = nsIDOMElement_GetElementsByClassName(This->dom_element, &nsstr, &nscol);
5097 nsAString_Finish(&nsstr);
5098 if(NS_FAILED(nsres)) {
5099 ERR("GetElementsByClassName failed: %08lx\n", nsres);
5100 return E_FAIL;
5104 *pel = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
5105 nsIDOMHTMLCollection_Release(nscol);
5106 return S_OK;
5109 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
5111 HTMLElement *This = impl_from_IHTMLElement6(iface);
5112 nsAString nsstr;
5113 cpp_bool b;
5114 nsresult nsres;
5116 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
5118 if(!This->dom_element) {
5119 FIXME("No dom element\n");
5120 return E_UNEXPECTED;
5123 nsAString_InitDepend(&nsstr, v);
5124 nsres = nsIDOMElement_MozMatchesSelector(This->dom_element, &nsstr, &b);
5125 nsAString_Finish(&nsstr);
5126 if(NS_FAILED(nsres)) {
5127 WARN("MozMatchesSelector failed: %08lx\n", nsres);
5128 return map_nsresult(nsres);
5131 *pfMatches = b;
5132 return S_OK;
5135 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
5137 HTMLElement *This = impl_from_IHTMLElement6(iface);
5139 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5141 return set_node_event(&This->node, EVENTID_ABORT, &v);
5144 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
5146 HTMLElement *This = impl_from_IHTMLElement6(iface);
5148 TRACE("(%p)->(%p)\n", This, p);
5150 return get_node_event(&This->node, EVENTID_ABORT, p);
5153 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
5155 HTMLElement *This = impl_from_IHTMLElement6(iface);
5156 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5157 return E_NOTIMPL;
5160 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
5162 HTMLElement *This = impl_from_IHTMLElement6(iface);
5163 FIXME("(%p)->(%p)\n", This, p);
5164 return E_NOTIMPL;
5167 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
5169 HTMLElement *This = impl_from_IHTMLElement6(iface);
5170 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5171 return E_NOTIMPL;
5174 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
5176 HTMLElement *This = impl_from_IHTMLElement6(iface);
5177 FIXME("(%p)->(%p)\n", This, p);
5178 return E_NOTIMPL;
5181 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
5183 HTMLElement *This = impl_from_IHTMLElement6(iface);
5185 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5187 return set_node_event(&This->node, EVENTID_CHANGE, &v);
5190 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
5192 HTMLElement *This = impl_from_IHTMLElement6(iface);
5194 TRACE("(%p)->(%p)\n", This, p);
5196 return get_node_event(&This->node, EVENTID_CHANGE, p);
5199 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
5201 HTMLElement *This = impl_from_IHTMLElement6(iface);
5202 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5203 return E_NOTIMPL;
5206 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
5208 HTMLElement *This = impl_from_IHTMLElement6(iface);
5209 FIXME("(%p)->(%p)\n", This, p);
5210 return E_NOTIMPL;
5213 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
5215 HTMLElement *This = impl_from_IHTMLElement6(iface);
5216 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5217 return E_NOTIMPL;
5220 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
5222 HTMLElement *This = impl_from_IHTMLElement6(iface);
5223 FIXME("(%p)->(%p)\n", This, p);
5224 return E_NOTIMPL;
5227 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
5229 HTMLElement *This = impl_from_IHTMLElement6(iface);
5230 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5231 return E_NOTIMPL;
5234 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
5236 HTMLElement *This = impl_from_IHTMLElement6(iface);
5237 FIXME("(%p)->(%p)\n", This, p);
5238 return E_NOTIMPL;
5241 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
5243 HTMLElement *This = impl_from_IHTMLElement6(iface);
5245 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5247 return set_node_event(&This->node, EVENTID_ERROR, &v);
5250 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
5252 HTMLElement *This = impl_from_IHTMLElement6(iface);
5254 TRACE("(%p)->(%p)\n", This, p);
5256 return get_node_event(&This->node, EVENTID_ERROR, p);
5259 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
5261 HTMLElement *This = impl_from_IHTMLElement6(iface);
5263 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5265 return set_node_event(&This->node, EVENTID_INPUT, &v);
5268 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
5270 HTMLElement *This = impl_from_IHTMLElement6(iface);
5272 TRACE("(%p)->(%p)\n", This, p);
5274 return get_node_event(&This->node, EVENTID_INPUT, p);
5277 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
5279 HTMLElement *This = impl_from_IHTMLElement6(iface);
5281 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5283 return set_node_event(&This->node, EVENTID_LOAD, &v);
5286 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
5288 HTMLElement *This = impl_from_IHTMLElement6(iface);
5290 TRACE("(%p)->(%p)\n", This, p);
5292 return get_node_event(&This->node, EVENTID_LOAD, p);
5295 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
5297 HTMLElement *This = impl_from_IHTMLElement6(iface);
5298 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5299 return E_NOTIMPL;
5302 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
5304 HTMLElement *This = impl_from_IHTMLElement6(iface);
5305 FIXME("(%p)->(%p)\n", This, p);
5306 return E_NOTIMPL;
5309 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
5311 HTMLElement *This = impl_from_IHTMLElement6(iface);
5312 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5313 return E_NOTIMPL;
5316 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
5318 HTMLElement *This = impl_from_IHTMLElement6(iface);
5319 FIXME("(%p)->(%p)\n", This, p);
5320 return E_NOTIMPL;
5323 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
5325 HTMLElement *This = impl_from_IHTMLElement6(iface);
5326 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5327 return E_NOTIMPL;
5330 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
5332 HTMLElement *This = impl_from_IHTMLElement6(iface);
5333 FIXME("(%p)->(%p)\n", This, p);
5334 return E_NOTIMPL;
5337 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
5339 HTMLElement *This = impl_from_IHTMLElement6(iface);
5340 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5341 return E_NOTIMPL;
5344 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
5346 HTMLElement *This = impl_from_IHTMLElement6(iface);
5347 FIXME("(%p)->(%p)\n", This, p);
5348 return E_NOTIMPL;
5351 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
5353 HTMLElement *This = impl_from_IHTMLElement6(iface);
5354 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5355 return E_NOTIMPL;
5358 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
5360 HTMLElement *This = impl_from_IHTMLElement6(iface);
5361 FIXME("(%p)->(%p)\n", This, p);
5362 return E_NOTIMPL;
5365 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
5367 HTMLElement *This = impl_from_IHTMLElement6(iface);
5368 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5369 return E_NOTIMPL;
5372 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
5374 HTMLElement *This = impl_from_IHTMLElement6(iface);
5375 FIXME("(%p)->(%p)\n", This, p);
5376 return E_NOTIMPL;
5379 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
5381 HTMLElement *This = impl_from_IHTMLElement6(iface);
5382 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5383 return E_NOTIMPL;
5386 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
5388 HTMLElement *This = impl_from_IHTMLElement6(iface);
5389 FIXME("(%p)->(%p)\n", This, p);
5390 return E_NOTIMPL;
5393 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
5395 HTMLElement *This = impl_from_IHTMLElement6(iface);
5396 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5397 return E_NOTIMPL;
5400 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
5402 HTMLElement *This = impl_from_IHTMLElement6(iface);
5403 FIXME("(%p)->(%p)\n", This, p);
5404 return E_NOTIMPL;
5407 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
5409 HTMLElement *This = impl_from_IHTMLElement6(iface);
5410 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5411 return E_NOTIMPL;
5414 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
5416 HTMLElement *This = impl_from_IHTMLElement6(iface);
5417 FIXME("(%p)->(%p)\n", This, p);
5418 return E_NOTIMPL;
5421 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
5423 HTMLElement *This = impl_from_IHTMLElement6(iface);
5424 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5425 return E_NOTIMPL;
5428 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
5430 HTMLElement *This = impl_from_IHTMLElement6(iface);
5431 FIXME("(%p)->(%p)\n", This, p);
5432 return E_NOTIMPL;
5435 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
5437 HTMLElement *This = impl_from_IHTMLElement6(iface);
5438 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5439 return E_NOTIMPL;
5442 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
5444 HTMLElement *This = impl_from_IHTMLElement6(iface);
5445 FIXME("(%p)->(%p)\n", This, p);
5446 return E_NOTIMPL;
5449 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
5451 HTMLElement *This = impl_from_IHTMLElement6(iface);
5452 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5453 return E_NOTIMPL;
5456 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
5458 HTMLElement *This = impl_from_IHTMLElement6(iface);
5459 FIXME("(%p)->(%p)\n", This, p);
5460 return E_NOTIMPL;
5463 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
5465 HTMLElement *This = impl_from_IHTMLElement6(iface);
5466 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5467 return E_NOTIMPL;
5470 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
5472 HTMLElement *This = impl_from_IHTMLElement6(iface);
5473 FIXME("(%p)->(%p)\n", This, p);
5474 return E_NOTIMPL;
5477 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
5479 HTMLElement *This = impl_from_IHTMLElement6(iface);
5481 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5483 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
5486 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
5488 HTMLElement *This = impl_from_IHTMLElement6(iface);
5490 TRACE("(%p)->(%p)\n", This, p);
5492 return get_node_event(&This->node, EVENTID_SUBMIT, p);
5495 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
5497 HTMLElement *This = impl_from_IHTMLElement6(iface);
5498 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5499 return E_NOTIMPL;
5502 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
5504 HTMLElement *This = impl_from_IHTMLElement6(iface);
5505 FIXME("(%p)->(%p)\n", This, p);
5506 return E_NOTIMPL;
5509 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
5511 HTMLElement *This = impl_from_IHTMLElement6(iface);
5512 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5513 return E_NOTIMPL;
5516 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
5518 HTMLElement *This = impl_from_IHTMLElement6(iface);
5519 FIXME("(%p)->(%p)\n", This, p);
5520 return E_NOTIMPL;
5523 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
5525 HTMLElement *This = impl_from_IHTMLElement6(iface);
5526 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5527 return E_NOTIMPL;
5530 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
5532 HTMLElement *This = impl_from_IHTMLElement6(iface);
5533 FIXME("(%p)->(%p)\n", This, p);
5534 return E_NOTIMPL;
5537 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
5539 HTMLElement *This = impl_from_IHTMLElement6(iface);
5540 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5541 return E_NOTIMPL;
5544 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
5546 HTMLElement *This = impl_from_IHTMLElement6(iface);
5547 FIXME("(%p)->(%p)\n", This, p);
5548 return E_NOTIMPL;
5551 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
5553 HTMLElement *This = impl_from_IHTMLElement6(iface);
5554 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
5555 return E_NOTIMPL;
5558 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
5559 HTMLElement6_QueryInterface,
5560 HTMLElement6_AddRef,
5561 HTMLElement6_Release,
5562 HTMLElement6_GetTypeInfoCount,
5563 HTMLElement6_GetTypeInfo,
5564 HTMLElement6_GetIDsOfNames,
5565 HTMLElement6_Invoke,
5566 HTMLElement6_getAttributeNS,
5567 HTMLElement6_setAttributeNS,
5568 HTMLElement6_removeAttributeNS,
5569 HTMLElement6_getAttributeNodeNS,
5570 HTMLElement6_setAttributeNodeNS,
5571 HTMLElement6_hasAttributeNS,
5572 HTMLElement6_getAttribute,
5573 HTMLElement6_setAttribute,
5574 HTMLElement6_removeAttribute,
5575 HTMLElement6_getAttributeNode,
5576 HTMLElement6_setAttributeNode,
5577 HTMLElement6_removeAttributeNode,
5578 HTMLElement6_hasAttribute,
5579 HTMLElement6_getElementsByTagNameNS,
5580 HTMLElement6_get_tagName,
5581 HTMLElement6_get_nodeName,
5582 HTMLElement6_getElementsByClassName,
5583 HTMLElement6_msMatchesSelector,
5584 HTMLElement6_put_onabort,
5585 HTMLElement6_get_onabort,
5586 HTMLElement6_put_oncanplay,
5587 HTMLElement6_get_oncanplay,
5588 HTMLElement6_put_oncanplaythrough,
5589 HTMLElement6_get_oncanplaythrough,
5590 HTMLElement6_put_onchange,
5591 HTMLElement6_get_onchange,
5592 HTMLElement6_put_ondurationchange,
5593 HTMLElement6_get_ondurationchange,
5594 HTMLElement6_put_onemptied,
5595 HTMLElement6_get_onemptied,
5596 HTMLElement6_put_onended,
5597 HTMLElement6_get_onended,
5598 HTMLElement6_put_onerror,
5599 HTMLElement6_get_onerror,
5600 HTMLElement6_put_oninput,
5601 HTMLElement6_get_oninput,
5602 HTMLElement6_put_onload,
5603 HTMLElement6_get_onload,
5604 HTMLElement6_put_onloadeddata,
5605 HTMLElement6_get_onloadeddata,
5606 HTMLElement6_put_onloadedmetadata,
5607 HTMLElement6_get_onloadedmetadata,
5608 HTMLElement6_put_onloadstart,
5609 HTMLElement6_get_onloadstart,
5610 HTMLElement6_put_onpause,
5611 HTMLElement6_get_onpause,
5612 HTMLElement6_put_onplay,
5613 HTMLElement6_get_onplay,
5614 HTMLElement6_put_onplaying,
5615 HTMLElement6_get_onplaying,
5616 HTMLElement6_put_onprogress,
5617 HTMLElement6_get_onprogress,
5618 HTMLElement6_put_onratechange,
5619 HTMLElement6_get_onratechange,
5620 HTMLElement6_put_onreset,
5621 HTMLElement6_get_onreset,
5622 HTMLElement6_put_onseeked,
5623 HTMLElement6_get_onseeked,
5624 HTMLElement6_put_onseeking,
5625 HTMLElement6_get_onseeking,
5626 HTMLElement6_put_onselect,
5627 HTMLElement6_get_onselect,
5628 HTMLElement6_put_onstalled,
5629 HTMLElement6_get_onstalled,
5630 HTMLElement6_put_onsubmit,
5631 HTMLElement6_get_onsubmit,
5632 HTMLElement6_put_onsuspend,
5633 HTMLElement6_get_onsuspend,
5634 HTMLElement6_put_ontimeupdate,
5635 HTMLElement6_get_ontimeupdate,
5636 HTMLElement6_put_onvolumechange,
5637 HTMLElement6_get_onvolumechange,
5638 HTMLElement6_put_onwaiting,
5639 HTMLElement6_get_onwaiting,
5640 HTMLElement6_hasAttributes
5643 static inline HTMLElement *impl_from_IHTMLElement7(IHTMLElement7 *iface)
5645 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement7_iface);
5648 static HRESULT WINAPI HTMLElement7_QueryInterface(IHTMLElement7 *iface,
5649 REFIID riid, void **ppv)
5651 HTMLElement *This = impl_from_IHTMLElement7(iface);
5652 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
5655 static ULONG WINAPI HTMLElement7_AddRef(IHTMLElement7 *iface)
5657 HTMLElement *This = impl_from_IHTMLElement7(iface);
5658 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5661 static ULONG WINAPI HTMLElement7_Release(IHTMLElement7 *iface)
5663 HTMLElement *This = impl_from_IHTMLElement7(iface);
5664 return IHTMLElement_Release(&This->IHTMLElement_iface);
5667 static HRESULT WINAPI HTMLElement7_GetTypeInfoCount(IHTMLElement7 *iface, UINT *pctinfo)
5669 HTMLElement *This = impl_from_IHTMLElement7(iface);
5670 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5673 static HRESULT WINAPI HTMLElement7_GetTypeInfo(IHTMLElement7 *iface, UINT iTInfo,
5674 LCID lcid, ITypeInfo **ppTInfo)
5676 HTMLElement *This = impl_from_IHTMLElement7(iface);
5677 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5680 static HRESULT WINAPI HTMLElement7_GetIDsOfNames(IHTMLElement7 *iface, REFIID riid,
5681 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5683 HTMLElement *This = impl_from_IHTMLElement7(iface);
5684 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5685 lcid, rgDispId);
5688 static HRESULT WINAPI HTMLElement7_Invoke(IHTMLElement7 *iface, DISPID dispIdMember, REFIID riid,
5689 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5691 HTMLElement *This = impl_from_IHTMLElement7(iface);
5692 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5693 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5696 static HRESULT WINAPI HTMLElement7_put_onmspointerdown(IHTMLElement7 *iface, VARIANT v)
5698 HTMLElement *This = impl_from_IHTMLElement7(iface);
5699 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5700 return E_NOTIMPL;
5703 static HRESULT WINAPI HTMLElement7_get_onmspointerdown(IHTMLElement7 *iface, VARIANT *p)
5705 HTMLElement *This = impl_from_IHTMLElement7(iface);
5706 FIXME("(%p)->(%p)\n", This, p);
5707 return E_NOTIMPL;
5710 static HRESULT WINAPI HTMLElement7_put_onmspointermove(IHTMLElement7 *iface, VARIANT v)
5712 HTMLElement *This = impl_from_IHTMLElement7(iface);
5713 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5714 return E_NOTIMPL;
5717 static HRESULT WINAPI HTMLElement7_get_onmspointermove(IHTMLElement7 *iface, VARIANT *p)
5719 HTMLElement *This = impl_from_IHTMLElement7(iface);
5720 FIXME("(%p)->(%p)\n", This, p);
5721 return E_NOTIMPL;
5724 static HRESULT WINAPI HTMLElement7_put_onmspointerup(IHTMLElement7 *iface, VARIANT v)
5726 HTMLElement *This = impl_from_IHTMLElement7(iface);
5727 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5728 return E_NOTIMPL;
5731 static HRESULT WINAPI HTMLElement7_get_onmspointerup(IHTMLElement7 *iface, VARIANT *p)
5733 HTMLElement *This = impl_from_IHTMLElement7(iface);
5734 FIXME("(%p)->(%p)\n", This, p);
5735 return E_NOTIMPL;
5738 static HRESULT WINAPI HTMLElement7_put_onmspointerover(IHTMLElement7 *iface, VARIANT v)
5740 HTMLElement *This = impl_from_IHTMLElement7(iface);
5741 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5742 return E_NOTIMPL;
5745 static HRESULT WINAPI HTMLElement7_get_onmspointerover(IHTMLElement7 *iface, VARIANT *p)
5747 HTMLElement *This = impl_from_IHTMLElement7(iface);
5748 FIXME("(%p)->(%p)\n", This, p);
5749 return E_NOTIMPL;
5752 static HRESULT WINAPI HTMLElement7_put_onmspointerout(IHTMLElement7 *iface, VARIANT v)
5754 HTMLElement *This = impl_from_IHTMLElement7(iface);
5755 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5756 return E_NOTIMPL;
5759 static HRESULT WINAPI HTMLElement7_get_onmspointerout(IHTMLElement7 *iface, VARIANT *p)
5761 HTMLElement *This = impl_from_IHTMLElement7(iface);
5762 FIXME("(%p)->(%p)\n", This, p);
5763 return E_NOTIMPL;
5766 static HRESULT WINAPI HTMLElement7_put_onmspointercancel(IHTMLElement7 *iface, VARIANT v)
5768 HTMLElement *This = impl_from_IHTMLElement7(iface);
5769 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5770 return E_NOTIMPL;
5773 static HRESULT WINAPI HTMLElement7_get_onmspointercancel(IHTMLElement7 *iface, VARIANT *p)
5775 HTMLElement *This = impl_from_IHTMLElement7(iface);
5776 FIXME("(%p)->(%p)\n", This, p);
5777 return E_NOTIMPL;
5780 static HRESULT WINAPI HTMLElement7_put_onmspointerhover(IHTMLElement7 *iface, VARIANT v)
5782 HTMLElement *This = impl_from_IHTMLElement7(iface);
5783 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5784 return E_NOTIMPL;
5787 static HRESULT WINAPI HTMLElement7_get_onmspointerhover(IHTMLElement7 *iface, VARIANT *p)
5789 HTMLElement *This = impl_from_IHTMLElement7(iface);
5790 FIXME("(%p)->(%p)\n", This, p);
5791 return E_NOTIMPL;
5794 static HRESULT WINAPI HTMLElement7_put_onmslostpointercapture(IHTMLElement7 *iface, VARIANT v)
5796 HTMLElement *This = impl_from_IHTMLElement7(iface);
5797 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5798 return E_NOTIMPL;
5801 static HRESULT WINAPI HTMLElement7_get_onmslostpointercapture(IHTMLElement7 *iface, VARIANT *p)
5803 HTMLElement *This = impl_from_IHTMLElement7(iface);
5804 FIXME("(%p)->(%p)\n", This, p);
5805 return E_NOTIMPL;
5808 static HRESULT WINAPI HTMLElement7_put_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT v)
5810 HTMLElement *This = impl_from_IHTMLElement7(iface);
5811 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5812 return E_NOTIMPL;
5815 static HRESULT WINAPI HTMLElement7_get_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT *p)
5817 HTMLElement *This = impl_from_IHTMLElement7(iface);
5818 FIXME("(%p)->(%p)\n", This, p);
5819 return E_NOTIMPL;
5822 static HRESULT WINAPI HTMLElement7_put_onmsgesturestart(IHTMLElement7 *iface, VARIANT v)
5824 HTMLElement *This = impl_from_IHTMLElement7(iface);
5825 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5826 return E_NOTIMPL;
5829 static HRESULT WINAPI HTMLElement7_get_onmsgesturestart(IHTMLElement7 *iface, VARIANT *p)
5831 HTMLElement *This = impl_from_IHTMLElement7(iface);
5832 FIXME("(%p)->(%p)\n", This, p);
5833 return E_NOTIMPL;
5836 static HRESULT WINAPI HTMLElement7_put_onmsgesturechange(IHTMLElement7 *iface, VARIANT v)
5838 HTMLElement *This = impl_from_IHTMLElement7(iface);
5839 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5840 return E_NOTIMPL;
5843 static HRESULT WINAPI HTMLElement7_get_onmsgesturechange(IHTMLElement7 *iface, VARIANT *p)
5845 HTMLElement *This = impl_from_IHTMLElement7(iface);
5846 FIXME("(%p)->(%p)\n", This, p);
5847 return E_NOTIMPL;
5850 static HRESULT WINAPI HTMLElement7_put_onmsgestureend(IHTMLElement7 *iface, VARIANT v)
5852 HTMLElement *This = impl_from_IHTMLElement7(iface);
5853 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5854 return E_NOTIMPL;
5857 static HRESULT WINAPI HTMLElement7_get_onmsgestureend(IHTMLElement7 *iface, VARIANT *p)
5859 HTMLElement *This = impl_from_IHTMLElement7(iface);
5860 FIXME("(%p)->(%p)\n", This, p);
5861 return E_NOTIMPL;
5864 static HRESULT WINAPI HTMLElement7_put_onmsgesturehold(IHTMLElement7 *iface, VARIANT v)
5866 HTMLElement *This = impl_from_IHTMLElement7(iface);
5867 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5868 return E_NOTIMPL;
5871 static HRESULT WINAPI HTMLElement7_get_onmsgesturehold(IHTMLElement7 *iface, VARIANT *p)
5873 HTMLElement *This = impl_from_IHTMLElement7(iface);
5874 FIXME("(%p)->(%p)\n", This, p);
5875 return E_NOTIMPL;
5878 static HRESULT WINAPI HTMLElement7_put_onmsgesturetap(IHTMLElement7 *iface, VARIANT v)
5880 HTMLElement *This = impl_from_IHTMLElement7(iface);
5881 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5882 return E_NOTIMPL;
5885 static HRESULT WINAPI HTMLElement7_get_onmsgesturetap(IHTMLElement7 *iface, VARIANT *p)
5887 HTMLElement *This = impl_from_IHTMLElement7(iface);
5888 FIXME("(%p)->(%p)\n", This, p);
5889 return E_NOTIMPL;
5892 static HRESULT WINAPI HTMLElement7_put_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT v)
5894 HTMLElement *This = impl_from_IHTMLElement7(iface);
5895 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5896 return E_NOTIMPL;
5899 static HRESULT WINAPI HTMLElement7_get_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT *p)
5901 HTMLElement *This = impl_from_IHTMLElement7(iface);
5902 FIXME("(%p)->(%p)\n", This, p);
5903 return E_NOTIMPL;
5906 static HRESULT WINAPI HTMLElement7_put_onmsinertiastart(IHTMLElement7 *iface, VARIANT v)
5908 HTMLElement *This = impl_from_IHTMLElement7(iface);
5909 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5910 return E_NOTIMPL;
5913 static HRESULT WINAPI HTMLElement7_get_onmsinertiastart(IHTMLElement7 *iface, VARIANT *p)
5915 HTMLElement *This = impl_from_IHTMLElement7(iface);
5916 FIXME("(%p)->(%p)\n", This, p);
5917 return E_NOTIMPL;
5920 static HRESULT WINAPI HTMLElement7_msSetPointerCapture(IHTMLElement7 *iface, LONG pointer_id)
5922 HTMLElement *This = impl_from_IHTMLElement7(iface);
5923 FIXME("(%p)->(%ld)\n", This, pointer_id);
5924 return E_NOTIMPL;
5927 static HRESULT WINAPI HTMLElement7_msReleasePointerCapture(IHTMLElement7 *iface, LONG pointer_id)
5929 HTMLElement *This = impl_from_IHTMLElement7(iface);
5930 FIXME("(%p)->(%ld)\n", This, pointer_id);
5931 return E_NOTIMPL;
5934 static HRESULT WINAPI HTMLElement7_put_onmstransitionstart(IHTMLElement7 *iface, VARIANT v)
5936 HTMLElement *This = impl_from_IHTMLElement7(iface);
5937 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5938 return E_NOTIMPL;
5941 static HRESULT WINAPI HTMLElement7_get_onmstransitionstart(IHTMLElement7 *iface, VARIANT *p)
5943 HTMLElement *This = impl_from_IHTMLElement7(iface);
5944 FIXME("(%p)->(%p)\n", This, p);
5945 return E_NOTIMPL;
5948 static HRESULT WINAPI HTMLElement7_put_onmstransitionend(IHTMLElement7 *iface, VARIANT v)
5950 HTMLElement *This = impl_from_IHTMLElement7(iface);
5951 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5952 return E_NOTIMPL;
5955 static HRESULT WINAPI HTMLElement7_get_onmstransitionend(IHTMLElement7 *iface, VARIANT *p)
5957 HTMLElement *This = impl_from_IHTMLElement7(iface);
5958 FIXME("(%p)->(%p)\n", This, p);
5959 return E_NOTIMPL;
5962 static HRESULT WINAPI HTMLElement7_put_onmsanimationstart(IHTMLElement7 *iface, VARIANT v)
5964 HTMLElement *This = impl_from_IHTMLElement7(iface);
5965 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5966 return E_NOTIMPL;
5969 static HRESULT WINAPI HTMLElement7_get_onmsanimationstart(IHTMLElement7 *iface, VARIANT *p)
5971 HTMLElement *This = impl_from_IHTMLElement7(iface);
5972 FIXME("(%p)->(%p)\n", This, p);
5973 return E_NOTIMPL;
5976 static HRESULT WINAPI HTMLElement7_put_onmsanimationend(IHTMLElement7 *iface, VARIANT v)
5978 HTMLElement *This = impl_from_IHTMLElement7(iface);
5979 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5980 return E_NOTIMPL;
5983 static HRESULT WINAPI HTMLElement7_get_onmsanimationend(IHTMLElement7 *iface, VARIANT *p)
5985 HTMLElement *This = impl_from_IHTMLElement7(iface);
5986 FIXME("(%p)->(%p)\n", This, p);
5987 return E_NOTIMPL;
5990 static HRESULT WINAPI HTMLElement7_put_onmsanimationiteration(IHTMLElement7 *iface, VARIANT v)
5992 HTMLElement *This = impl_from_IHTMLElement7(iface);
5993 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5994 return E_NOTIMPL;
5997 static HRESULT WINAPI HTMLElement7_get_onmsanimationiteration(IHTMLElement7 *iface, VARIANT *p)
5999 HTMLElement *This = impl_from_IHTMLElement7(iface);
6000 FIXME("(%p)->(%p)\n", This, p);
6001 return E_NOTIMPL;
6004 static HRESULT WINAPI HTMLElement7_put_oninvalid(IHTMLElement7 *iface, VARIANT v)
6006 HTMLElement *This = impl_from_IHTMLElement7(iface);
6007 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6008 return E_NOTIMPL;
6011 static HRESULT WINAPI HTMLElement7_get_oninvalid(IHTMLElement7 *iface, VARIANT *p)
6013 HTMLElement *This = impl_from_IHTMLElement7(iface);
6014 FIXME("(%p)->(%p)\n", This, p);
6015 return E_NOTIMPL;
6018 static HRESULT WINAPI HTMLElement7_put_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR v)
6020 HTMLElement *This = impl_from_IHTMLElement7(iface);
6021 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
6022 return E_NOTIMPL;
6025 static HRESULT WINAPI HTMLElement7_get_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR *p)
6027 HTMLElement *This = impl_from_IHTMLElement7(iface);
6028 FIXME("(%p)->(%p)\n", This, p);
6029 return E_NOTIMPL;
6032 static HRESULT WINAPI HTMLElement7_put_spellcheck(IHTMLElement7 *iface, VARIANT v)
6034 HTMLElement *This = impl_from_IHTMLElement7(iface);
6036 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
6038 if(!This->html_element) {
6039 FIXME("non-HTML element\n");
6040 return E_NOTIMPL;
6043 if(V_VT(&v) != VT_BOOL) {
6044 FIXME("unsupported argument %s\n", debugstr_variant(&v));
6045 return E_NOTIMPL;
6048 return map_nsresult(nsIDOMHTMLElement_SetSpellcheck(This->html_element, !!V_BOOL(&v)));
6051 static HRESULT WINAPI HTMLElement7_get_spellcheck(IHTMLElement7 *iface, VARIANT *p)
6053 HTMLElement *This = impl_from_IHTMLElement7(iface);
6054 cpp_bool spellcheck;
6055 nsresult nsres;
6057 TRACE("(%p)->(%p)\n", This, p);
6059 if(!This->html_element) {
6060 FIXME("non-HTML element\n");
6061 return E_NOTIMPL;
6064 nsres = nsIDOMHTMLElement_GetSpellcheck(This->html_element, &spellcheck);
6065 if(NS_FAILED(nsres))
6066 return map_nsresult(nsres);
6068 V_VT(p) = VT_BOOL;
6069 V_BOOL(p) = spellcheck ? VARIANT_TRUE : VARIANT_FALSE;
6070 return S_OK;
6073 static HRESULT WINAPI HTMLElement7_put_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT v)
6075 HTMLElement *This = impl_from_IHTMLElement7(iface);
6076 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6077 return E_NOTIMPL;
6080 static HRESULT WINAPI HTMLElement7_get_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT *p)
6082 HTMLElement *This = impl_from_IHTMLElement7(iface);
6083 FIXME("(%p)->(%p)\n", This, p);
6084 return E_NOTIMPL;
6087 static HRESULT WINAPI HTMLElement7_put_oncuechange(IHTMLElement7 *iface, VARIANT v)
6089 HTMLElement *This = impl_from_IHTMLElement7(iface);
6090 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
6091 return E_NOTIMPL;
6094 static HRESULT WINAPI HTMLElement7_get_oncuechange(IHTMLElement7 *iface, VARIANT *p)
6096 HTMLElement *This = impl_from_IHTMLElement7(iface);
6097 FIXME("(%p)->(%p)\n", This, p);
6098 return E_NOTIMPL;
6101 static const IHTMLElement7Vtbl HTMLElement7Vtbl = {
6102 HTMLElement7_QueryInterface,
6103 HTMLElement7_AddRef,
6104 HTMLElement7_Release,
6105 HTMLElement7_GetTypeInfoCount,
6106 HTMLElement7_GetTypeInfo,
6107 HTMLElement7_GetIDsOfNames,
6108 HTMLElement7_Invoke,
6109 HTMLElement7_put_onmspointerdown,
6110 HTMLElement7_get_onmspointerdown,
6111 HTMLElement7_put_onmspointermove,
6112 HTMLElement7_get_onmspointermove,
6113 HTMLElement7_put_onmspointerup,
6114 HTMLElement7_get_onmspointerup,
6115 HTMLElement7_put_onmspointerover,
6116 HTMLElement7_get_onmspointerover,
6117 HTMLElement7_put_onmspointerout,
6118 HTMLElement7_get_onmspointerout,
6119 HTMLElement7_put_onmspointercancel,
6120 HTMLElement7_get_onmspointercancel,
6121 HTMLElement7_put_onmspointerhover,
6122 HTMLElement7_get_onmspointerhover,
6123 HTMLElement7_put_onmslostpointercapture,
6124 HTMLElement7_get_onmslostpointercapture,
6125 HTMLElement7_put_onmsgotpointercapture,
6126 HTMLElement7_get_onmsgotpointercapture,
6127 HTMLElement7_put_onmsgesturestart,
6128 HTMLElement7_get_onmsgesturestart,
6129 HTMLElement7_put_onmsgesturechange,
6130 HTMLElement7_get_onmsgesturechange,
6131 HTMLElement7_put_onmsgestureend,
6132 HTMLElement7_get_onmsgestureend,
6133 HTMLElement7_put_onmsgesturehold,
6134 HTMLElement7_get_onmsgesturehold,
6135 HTMLElement7_put_onmsgesturetap,
6136 HTMLElement7_get_onmsgesturetap,
6137 HTMLElement7_put_onmsgesturedoubletap,
6138 HTMLElement7_get_onmsgesturedoubletap,
6139 HTMLElement7_put_onmsinertiastart,
6140 HTMLElement7_get_onmsinertiastart,
6141 HTMLElement7_msSetPointerCapture,
6142 HTMLElement7_msReleasePointerCapture,
6143 HTMLElement7_put_onmstransitionstart,
6144 HTMLElement7_get_onmstransitionstart,
6145 HTMLElement7_put_onmstransitionend,
6146 HTMLElement7_get_onmstransitionend,
6147 HTMLElement7_put_onmsanimationstart,
6148 HTMLElement7_get_onmsanimationstart,
6149 HTMLElement7_put_onmsanimationend,
6150 HTMLElement7_get_onmsanimationend,
6151 HTMLElement7_put_onmsanimationiteration,
6152 HTMLElement7_get_onmsanimationiteration,
6153 HTMLElement7_put_oninvalid,
6154 HTMLElement7_get_oninvalid,
6155 HTMLElement7_put_xmsAcceleratorKey,
6156 HTMLElement7_get_xmsAcceleratorKey,
6157 HTMLElement7_put_spellcheck,
6158 HTMLElement7_get_spellcheck,
6159 HTMLElement7_put_onmsmanipulationstatechanged,
6160 HTMLElement7_get_onmsmanipulationstatechanged,
6161 HTMLElement7_put_oncuechange,
6162 HTMLElement7_get_oncuechange
6166 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
6168 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
6171 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
6173 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6174 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6177 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
6179 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6180 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6183 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
6185 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6186 return IHTMLElement_Release(&This->IHTMLElement_iface);
6189 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
6191 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6192 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6195 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
6196 LCID lcid, ITypeInfo **ppTInfo)
6198 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6199 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6202 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
6203 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6205 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6206 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6207 lcid, rgDispId);
6210 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
6211 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6213 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6214 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6215 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6218 HRESULT elem_unique_id(unsigned id, BSTR *p)
6220 WCHAR buf[32];
6222 swprintf(buf, ARRAY_SIZE(buf), L"ms__id%u", id);
6223 *p = SysAllocString(buf);
6224 return *p ? S_OK : E_OUTOFMEMORY;
6227 static void ensure_unique_id(HTMLElement *elem)
6229 if(!elem->unique_id)
6230 elem->unique_id = ++elem->node.doc->unique_id;
6233 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
6235 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6237 TRACE("(%p)->(%p)\n", This, p);
6239 ensure_unique_id(This);
6240 *p = This->unique_id;
6241 return S_OK;
6244 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
6246 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
6248 TRACE("(%p)->(%p)\n", This, p);
6250 ensure_unique_id(This);
6251 return elem_unique_id(This->unique_id, p);
6254 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
6255 HTMLUniqueName_QueryInterface,
6256 HTMLUniqueName_AddRef,
6257 HTMLUniqueName_Release,
6258 HTMLUniqueName_GetTypeInfoCount,
6259 HTMLUniqueName_GetTypeInfo,
6260 HTMLUniqueName_GetIDsOfNames,
6261 HTMLUniqueName_Invoke,
6262 HTMLUniqueName_get_uniqueNumber,
6263 HTMLUniqueName_get_uniqueID
6266 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
6268 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
6271 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
6273 HTMLElement *This = impl_from_IElementSelector(iface);
6274 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6277 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
6279 HTMLElement *This = impl_from_IElementSelector(iface);
6280 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6283 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
6285 HTMLElement *This = impl_from_IElementSelector(iface);
6286 return IHTMLElement_Release(&This->IHTMLElement_iface);
6289 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
6291 HTMLElement *This = impl_from_IElementSelector(iface);
6292 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6295 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
6296 LCID lcid, ITypeInfo **ppTInfo)
6298 HTMLElement *This = impl_from_IElementSelector(iface);
6299 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6302 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
6303 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6305 HTMLElement *This = impl_from_IElementSelector(iface);
6306 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
6309 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
6310 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6312 HTMLElement *This = impl_from_IElementSelector(iface);
6313 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
6314 pDispParams, pVarResult, pExcepInfo, puArgErr);
6317 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
6319 HTMLElement *This = impl_from_IElementSelector(iface);
6320 nsIDOMElement *nselem;
6321 HTMLElement *elem;
6322 nsAString nsstr;
6323 nsresult nsres;
6324 HRESULT hres;
6326 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6328 if(!This->dom_element) {
6329 FIXME("comment element\n");
6330 return E_NOTIMPL;
6333 nsAString_InitDepend(&nsstr, v);
6334 nsres = nsIDOMElement_QuerySelector(This->dom_element, &nsstr, &nselem);
6335 nsAString_Finish(&nsstr);
6336 if(NS_FAILED(nsres)) {
6337 ERR("QuerySelector failed: %08lx\n", nsres);
6338 return E_FAIL;
6341 if(!nselem) {
6342 *pel = NULL;
6343 return S_OK;
6346 hres = get_element(nselem, &elem);
6347 nsIDOMElement_Release(nselem);
6348 if(FAILED(hres))
6349 return hres;
6351 *pel = &elem->IHTMLElement_iface;
6352 return S_OK;
6355 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
6357 HTMLElement *This = impl_from_IElementSelector(iface);
6358 nsIDOMNodeList *node_list;
6359 nsAString nsstr;
6360 HRESULT hres;
6362 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6364 if(!This->dom_element) {
6365 FIXME("comment element\n");
6366 return E_NOTIMPL;
6369 nsAString_InitDepend(&nsstr, v);
6370 hres = map_nsresult(nsIDOMElement_QuerySelectorAll(This->dom_element, &nsstr, &node_list));
6371 nsAString_Finish(&nsstr);
6372 if(FAILED(hres)) {
6373 ERR("QuerySelectorAll failed: %08lx\n", hres);
6374 return hres;
6377 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
6378 nsIDOMNodeList_Release(node_list);
6379 return hres;
6382 static const IElementSelectorVtbl ElementSelectorVtbl = {
6383 ElementSelector_QueryInterface,
6384 ElementSelector_AddRef,
6385 ElementSelector_Release,
6386 ElementSelector_GetTypeInfoCount,
6387 ElementSelector_GetTypeInfo,
6388 ElementSelector_GetIDsOfNames,
6389 ElementSelector_Invoke,
6390 ElementSelector_querySelector,
6391 ElementSelector_querySelectorAll
6394 static inline HTMLElement *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
6396 return CONTAINING_RECORD(iface, HTMLElement, IProvideMultipleClassInfo_iface);
6399 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
6400 REFIID riid, void **ppv)
6402 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6403 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6406 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
6408 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6409 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6412 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
6414 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6415 return IHTMLElement_Release(&This->IHTMLElement_iface);
6418 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
6420 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6421 TRACE("(%p)->(%p)\n", This, ppTI);
6422 return get_class_typeinfo(This->node.vtbl->clsid, ppTI);
6425 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
6427 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6428 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
6429 return E_NOTIMPL;
6432 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
6434 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6435 FIXME("(%p)->(%p)\n", This, pcti);
6436 *pcti = 1;
6437 return S_OK;
6440 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
6441 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
6443 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6444 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
6445 return E_NOTIMPL;
6448 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
6449 ProvideClassInfo_QueryInterface,
6450 ProvideClassInfo_AddRef,
6451 ProvideClassInfo_Release,
6452 ProvideClassInfo_GetClassInfo,
6453 ProvideClassInfo2_GetGUID,
6454 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
6455 ProvideMultipleClassInfo_GetInfoOfIndex
6458 static inline HTMLElement *impl_from_IElementTraversal(IElementTraversal *iface)
6460 return CONTAINING_RECORD(iface, HTMLElement, IElementTraversal_iface);
6463 static HRESULT WINAPI ElementTraversal_QueryInterface(IElementTraversal *iface, REFIID riid, void **ppv)
6465 HTMLElement *This = impl_from_IElementTraversal(iface);
6466 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6469 static ULONG WINAPI ElementTraversal_AddRef(IElementTraversal *iface)
6471 HTMLElement *This = impl_from_IElementTraversal(iface);
6473 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6476 static ULONG WINAPI ElementTraversal_Release(IElementTraversal *iface)
6478 HTMLElement *This = impl_from_IElementTraversal(iface);
6480 return IHTMLElement_Release(&This->IHTMLElement_iface);
6483 static HRESULT WINAPI ElementTraversal_GetTypeInfoCount(IElementTraversal *iface, UINT *pctinfo)
6485 HTMLElement *This = impl_from_IElementTraversal(iface);
6486 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6489 static HRESULT WINAPI ElementTraversal_GetTypeInfo(IElementTraversal *iface, UINT iTInfo,
6490 LCID lcid, ITypeInfo **ppTInfo)
6492 HTMLElement *This = impl_from_IElementTraversal(iface);
6493 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6496 static HRESULT WINAPI ElementTraversal_GetIDsOfNames(IElementTraversal *iface, REFIID riid,
6497 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6499 HTMLElement *This = impl_from_IElementTraversal(iface);
6500 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6501 lcid, rgDispId);
6504 static HRESULT WINAPI ElementTraversal_Invoke(IElementTraversal *iface, DISPID dispIdMember, REFIID riid,
6505 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6507 HTMLElement *This = impl_from_IElementTraversal(iface);
6508 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6509 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6512 static HRESULT WINAPI ElementTraversal_get_firstElementChild(IElementTraversal *iface, IHTMLElement **p)
6514 HTMLElement *This = impl_from_IElementTraversal(iface);
6515 nsIDOMElement *nselem = NULL;
6516 HTMLElement *elem;
6517 HRESULT hres;
6519 TRACE("(%p)->(%p)\n", This, p);
6521 if(!This->dom_element) {
6522 *p = NULL;
6523 return S_OK;
6526 nsIDOMElement_GetFirstElementChild(This->dom_element, &nselem);
6527 if(!nselem) {
6528 *p = NULL;
6529 return S_OK;
6532 hres = get_element(nselem, &elem);
6533 nsIDOMElement_Release(nselem);
6534 if(FAILED(hres))
6535 return hres;
6537 *p = &elem->IHTMLElement_iface;
6538 return S_OK;
6541 static HRESULT WINAPI ElementTraversal_get_lastElementChild(IElementTraversal *iface, IHTMLElement **p)
6543 HTMLElement *This = impl_from_IElementTraversal(iface);
6544 nsIDOMElement *nselem = NULL;
6545 HTMLElement *elem;
6546 HRESULT hres;
6548 TRACE("(%p)->(%p)\n", This, p);
6550 if(!This->dom_element) {
6551 *p = NULL;
6552 return S_OK;
6555 nsIDOMElement_GetLastElementChild(This->dom_element, &nselem);
6556 if(!nselem) {
6557 *p = NULL;
6558 return S_OK;
6561 hres = get_element(nselem, &elem);
6562 nsIDOMElement_Release(nselem);
6563 if(FAILED(hres))
6564 return hres;
6566 *p = &elem->IHTMLElement_iface;
6567 return S_OK;
6570 static HRESULT WINAPI ElementTraversal_get_previousElementSibling(IElementTraversal *iface, IHTMLElement **p)
6572 HTMLElement *This = impl_from_IElementTraversal(iface);
6573 nsIDOMElement *nselem = NULL;
6574 HTMLElement *elem;
6575 HRESULT hres;
6577 TRACE("(%p)->(%p)\n", This, p);
6579 if(!This->dom_element) {
6580 *p = NULL;
6581 return S_OK;
6584 nsIDOMElement_GetPreviousElementSibling(This->dom_element, &nselem);
6585 if(!nselem) {
6586 *p = NULL;
6587 return S_OK;
6590 hres = get_element(nselem, &elem);
6591 nsIDOMElement_Release(nselem);
6592 if(FAILED(hres))
6593 return hres;
6595 *p = &elem->IHTMLElement_iface;
6596 return S_OK;
6599 static HRESULT WINAPI ElementTraversal_get_nextElementSibling(IElementTraversal *iface, IHTMLElement **p)
6601 HTMLElement *This = impl_from_IElementTraversal(iface);
6602 nsIDOMElement *nselem = NULL;
6603 HTMLElement *elem;
6604 HRESULT hres;
6606 TRACE("(%p)->(%p)\n", This, p);
6608 if(!This->dom_element) {
6609 *p = NULL;
6610 return S_OK;
6613 nsIDOMElement_GetNextElementSibling(This->dom_element, &nselem);
6614 if(!nselem) {
6615 *p = NULL;
6616 return S_OK;
6619 hres = get_element(nselem, &elem);
6620 nsIDOMElement_Release(nselem);
6621 if(FAILED(hres))
6622 return hres;
6624 *p = &elem->IHTMLElement_iface;
6625 return S_OK;
6628 static HRESULT WINAPI ElementTraversal_get_childElementCount(IElementTraversal *iface, LONG *p)
6630 HTMLElement *This = impl_from_IElementTraversal(iface);
6631 UINT32 count = 0;
6633 TRACE("(%p)->(%p)\n", This, p);
6635 if(This->dom_element)
6636 nsIDOMElement_GetChildElementCount(This->dom_element, &count);
6638 *p = count;
6639 return S_OK;
6642 static const IElementTraversalVtbl ElementTraversalVtbl = {
6643 ElementTraversal_QueryInterface,
6644 ElementTraversal_AddRef,
6645 ElementTraversal_Release,
6646 ElementTraversal_GetTypeInfoCount,
6647 ElementTraversal_GetTypeInfo,
6648 ElementTraversal_GetIDsOfNames,
6649 ElementTraversal_Invoke,
6650 ElementTraversal_get_firstElementChild,
6651 ElementTraversal_get_lastElementChild,
6652 ElementTraversal_get_previousElementSibling,
6653 ElementTraversal_get_nextElementSibling,
6654 ElementTraversal_get_childElementCount
6657 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
6659 return CONTAINING_RECORD(iface, HTMLElement, node);
6662 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
6664 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6666 if(IsEqualGUID(&IID_IUnknown, riid)) {
6667 *ppv = &This->IHTMLElement_iface;
6668 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
6669 *ppv = &This->IHTMLElement_iface;
6670 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
6671 *ppv = &This->IHTMLElement_iface;
6672 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
6673 *ppv = &This->IHTMLElement2_iface;
6674 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
6675 *ppv = &This->IHTMLElement3_iface;
6676 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
6677 *ppv = &This->IHTMLElement4_iface;
6678 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
6679 *ppv = &This->IHTMLElement6_iface;
6680 }else if(IsEqualGUID(&IID_IHTMLElement7, riid)) {
6681 *ppv = &This->IHTMLElement7_iface;
6682 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
6683 *ppv = &This->IHTMLUniqueName_iface;
6684 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
6685 *ppv = &This->IElementSelector_iface;
6686 }else if(IsEqualGUID(&IID_IElementTraversal, riid)) {
6687 *ppv = &This->IElementTraversal_iface;
6688 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
6689 *ppv = &This->cp_container.IConnectionPointContainer_iface;
6690 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
6691 *ppv = &This->IProvideMultipleClassInfo_iface;
6692 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
6693 *ppv = &This->IProvideMultipleClassInfo_iface;
6694 }else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid)) {
6695 *ppv = &This->IProvideMultipleClassInfo_iface;
6696 }else if(IsEqualGUID(&IID_IWineHTMLElementPrivate, riid)) {
6697 *ppv = &This->IWineHTMLElementPrivate_iface;
6698 }else {
6699 return HTMLDOMNode_QI(&This->node, riid, ppv);
6702 IUnknown_AddRef((IUnknown*)*ppv);
6703 return S_OK;
6706 void HTMLElement_destructor(HTMLDOMNode *iface)
6708 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6710 ConnectionPointContainer_Destroy(&This->cp_container);
6712 if(This->style) {
6713 This->style->elem = NULL;
6714 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
6716 if(This->runtime_style) {
6717 This->runtime_style->elem = NULL;
6718 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
6720 if(This->attrs) {
6721 HTMLDOMAttribute *attr;
6723 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
6724 attr->elem = NULL;
6726 This->attrs->elem = NULL;
6727 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
6730 heap_free(This->filter);
6732 HTMLDOMNode_destructor(&This->node);
6735 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
6737 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6738 HTMLElement *new_elem;
6739 HRESULT hres;
6741 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
6742 if(FAILED(hres))
6743 return hres;
6745 if(This->filter) {
6746 new_elem->filter = heap_strdupW(This->filter);
6747 if(!new_elem->filter) {
6748 IHTMLElement_Release(&This->IHTMLElement_iface);
6749 return E_OUTOFMEMORY;
6753 *ret = &new_elem->node;
6754 return S_OK;
6757 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
6759 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6761 switch(eid) {
6762 case EVENTID_KEYDOWN: {
6763 nsIDOMKeyEvent *key_event;
6764 nsresult nsres;
6766 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
6767 if(NS_SUCCEEDED(nsres)) {
6768 UINT32 code = 0;
6770 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
6772 if(code == VK_F1 /* DOM_VK_F1 */) {
6773 DOMEvent *help_event;
6774 HRESULT hres;
6776 TRACE("F1 pressed\n");
6778 hres = create_document_event(This->node.doc, EVENTID_HELP, &help_event);
6779 if(SUCCEEDED(hres)) {
6780 dispatch_event(&This->node.event_target, help_event);
6781 IDOMEvent_Release(&help_event->IDOMEvent_iface);
6783 *prevent_default = TRUE;
6786 nsIDOMKeyEvent_Release(key_event);
6791 return S_OK;
6794 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
6796 const cpc_entry_t HTMLElement_cpc[] = {
6797 HTMLELEMENT_CPC,
6798 {NULL}
6801 static const NodeImplVtbl HTMLElementImplVtbl = {
6802 &CLSID_HTMLUnknownElement,
6803 HTMLElement_QI,
6804 HTMLElement_destructor,
6805 HTMLElement_cpc,
6806 HTMLElement_clone,
6807 HTMLElement_handle_event,
6808 HTMLElement_get_attr_col
6811 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
6813 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
6816 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
6817 DWORD grfdex, DISPID *pid)
6819 HTMLElement *This = impl_from_DispatchEx(dispex);
6821 if(This->node.vtbl->get_dispid)
6822 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
6824 return DISP_E_UNKNOWNNAME;
6827 static HRESULT HTMLElement_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
6829 HTMLElement *This = impl_from_DispatchEx(dispex);
6831 if(This->node.vtbl->get_name)
6832 return This->node.vtbl->get_name(&This->node, id, name);
6834 ERR("(%p): element has no get_name method\n", This);
6835 return DISP_E_MEMBERNOTFOUND;
6838 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
6839 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
6840 IServiceProvider *caller)
6842 HTMLElement *This = impl_from_DispatchEx(dispex);
6844 if(This->node.vtbl->invoke)
6845 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
6846 params, res, ei, caller);
6848 ERR("(%p): element has no invoke method\n", This);
6849 return E_NOTIMPL;
6852 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
6854 HTMLElement *This = impl_from_DispatchEx(dispex);
6855 nsIDOMMozNamedAttrMap *attrs;
6856 nsIDOMAttr *attr;
6857 nsAString nsstr;
6858 const PRUnichar *str;
6859 BSTR name;
6860 VARIANT value;
6861 unsigned i;
6862 UINT32 len;
6863 DISPID id;
6864 nsresult nsres;
6865 HRESULT hres;
6867 if(!This->dom_element)
6868 return S_FALSE;
6870 if(dispex_compat_mode(dispex) >= COMPAT_MODE_IE9)
6871 return S_OK;
6873 nsres = nsIDOMElement_GetAttributes(This->dom_element, &attrs);
6874 if(NS_FAILED(nsres))
6875 return E_FAIL;
6877 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
6878 if(NS_FAILED(nsres)) {
6879 nsIDOMMozNamedAttrMap_Release(attrs);
6880 return E_FAIL;
6883 nsAString_Init(&nsstr, NULL);
6884 for(i=0; i<len; i++) {
6885 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
6886 if(NS_FAILED(nsres))
6887 continue;
6889 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
6890 if(NS_FAILED(nsres)) {
6891 nsIDOMAttr_Release(attr);
6892 continue;
6895 nsAString_GetData(&nsstr, &str);
6896 name = SysAllocString(str);
6897 if(!name) {
6898 nsIDOMAttr_Release(attr);
6899 continue;
6902 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
6903 if(hres != DISP_E_UNKNOWNNAME) {
6904 nsIDOMAttr_Release(attr);
6905 SysFreeString(name);
6906 continue;
6909 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
6910 nsIDOMAttr_Release(attr);
6911 if(NS_FAILED(nsres)) {
6912 SysFreeString(name);
6913 continue;
6916 nsAString_GetData(&nsstr, &str);
6917 V_VT(&value) = VT_BSTR;
6918 if(*str) {
6919 V_BSTR(&value) = SysAllocString(str);
6920 if(!V_BSTR(&value)) {
6921 SysFreeString(name);
6922 continue;
6924 } else
6925 V_BSTR(&value) = NULL;
6927 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
6928 SysFreeString(name);
6929 VariantClear(&value);
6931 nsAString_Finish(&nsstr);
6933 nsIDOMMozNamedAttrMap_Release(attrs);
6934 return S_OK;
6937 static nsISupports *HTMLElement_get_gecko_target(DispatchEx *dispex)
6939 HTMLElement *This = impl_from_DispatchEx(dispex);
6940 return (nsISupports*)This->node.nsnode;
6943 static void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
6945 HTMLElement *This = impl_from_DispatchEx(dispex);
6946 ensure_doc_nsevent_handler(This->node.doc, This->node.nsnode, eid);
6949 static HRESULT HTMLElement_handle_event_default(DispatchEx *dispex, eventid_t eid, nsIDOMEvent *nsevent, BOOL *prevent_default)
6951 HTMLElement *This = impl_from_DispatchEx(dispex);
6953 if(!This->node.vtbl->handle_event)
6954 return S_OK;
6955 return This->node.vtbl->handle_event(&This->node, eid, nsevent, prevent_default);
6958 static EventTarget *HTMLElement_get_parent_event_target(DispatchEx *dispex)
6960 HTMLElement *This = impl_from_DispatchEx(dispex);
6961 HTMLDOMNode *node;
6962 nsIDOMNode *nsnode;
6963 nsresult nsres;
6964 HRESULT hres;
6966 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
6967 assert(nsres == NS_OK);
6968 if(!nsnode)
6969 return NULL;
6971 hres = get_node(nsnode, TRUE, &node);
6972 nsIDOMNode_Release(nsnode);
6973 if(FAILED(hres))
6974 return NULL;
6976 return &node->event_target;
6979 static ConnectionPointContainer *HTMLElement_get_cp_container(DispatchEx *dispex)
6981 HTMLElement *This = impl_from_DispatchEx(dispex);
6982 IConnectionPointContainer_AddRef(&This->cp_container.IConnectionPointContainer_iface);
6983 return &This->cp_container;
6986 static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6988 HTMLElement *This = impl_from_DispatchEx(dispex);
6989 return default_set_current_event(This->node.doc->window, event);
6992 static HRESULT IHTMLElement6_hasAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
6993 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6995 VARIANT args[2];
6996 HRESULT hres;
6997 DISPPARAMS new_dp = { args, NULL, 2, 0 };
6999 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7000 return S_FALSE;
7002 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7003 case VT_EMPTY:
7004 case VT_BSTR:
7005 case VT_NULL:
7006 return S_FALSE;
7007 default:
7008 break;
7011 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7012 if(FAILED(hres))
7013 return hres;
7014 args[0] = dp->rgvarg[dp->cArgs - 2];
7016 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_HASATTRIBUTENS, &new_dp, res, ei, caller);
7017 VariantClear(&args[1]);
7018 return hres;
7021 static HRESULT IHTMLElement6_getAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7022 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7024 VARIANT args[2];
7025 HRESULT hres;
7026 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7028 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7029 return S_FALSE;
7031 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7032 case VT_EMPTY:
7033 case VT_BSTR:
7034 case VT_NULL:
7035 return S_FALSE;
7036 default:
7037 break;
7040 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7041 if(FAILED(hres))
7042 return hres;
7043 args[0] = dp->rgvarg[dp->cArgs - 2];
7045 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_GETATTRIBUTENS, &new_dp, res, ei, caller);
7046 VariantClear(&args[1]);
7047 return hres;
7050 static HRESULT IHTMLElement6_setAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7051 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7053 BOOL ns_conv = FALSE, val_conv = FALSE;
7054 VARIANT args[3];
7055 HRESULT hres;
7056 DISPPARAMS new_dp = { args, NULL, 3, 0 };
7058 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 3 || dp->cNamedArgs)
7059 return S_FALSE;
7061 if(dispex_compat_mode(dispex) < COMPAT_MODE_IE10)
7062 args[2] = dp->rgvarg[dp->cArgs - 1];
7063 else {
7064 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7065 case VT_EMPTY:
7066 case VT_BSTR:
7067 case VT_NULL:
7068 args[2] = dp->rgvarg[dp->cArgs - 1];
7069 break;
7070 default:
7071 hres = change_type(&args[2], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7072 if(FAILED(hres))
7073 return hres;
7074 ns_conv = TRUE;
7075 break;
7079 switch(V_VT(&dp->rgvarg[dp->cArgs - 3])) {
7080 case VT_EMPTY:
7081 case VT_BSTR:
7082 case VT_NULL:
7083 if(!ns_conv)
7084 return S_FALSE;
7085 args[0] = dp->rgvarg[dp->cArgs - 3];
7086 break;
7087 default:
7088 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 3], VT_BSTR, caller);
7089 if(FAILED(hres)) {
7090 if(ns_conv)
7091 VariantClear(&args[2]);
7092 return hres;
7094 val_conv = TRUE;
7095 break;
7098 args[1] = dp->rgvarg[dp->cArgs - 2];
7099 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_SETATTRIBUTENS, &new_dp, res, ei, caller);
7100 if(ns_conv) VariantClear(&args[2]);
7101 if(val_conv) VariantClear(&args[0]);
7102 return hres;
7105 static HRESULT IHTMLElement6_removeAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7106 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7108 VARIANT args[2];
7109 HRESULT hres;
7110 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7112 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7113 return S_FALSE;
7115 switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
7116 case VT_EMPTY:
7117 case VT_BSTR:
7118 case VT_NULL:
7119 return S_FALSE;
7120 default:
7121 break;
7124 hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
7125 if(FAILED(hres))
7126 return hres;
7127 args[0] = dp->rgvarg[dp->cArgs - 2];
7129 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, &new_dp, res, ei, caller);
7130 VariantClear(&args[1]);
7131 return hres;
7134 static HRESULT IHTMLElement6_setAttribute_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
7135 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7137 VARIANT args[2];
7138 HRESULT hres;
7139 DISPPARAMS new_dp = { args, NULL, 2, 0 };
7141 if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
7142 return S_FALSE;
7144 switch(V_VT(&dp->rgvarg[dp->cArgs - 2])) {
7145 case VT_EMPTY:
7146 case VT_BSTR:
7147 case VT_NULL:
7148 return S_FALSE;
7149 default:
7150 break;
7153 hres = change_type(&args[0], &dp->rgvarg[dp->cArgs - 2], VT_BSTR, caller);
7154 if(FAILED(hres))
7155 return hres;
7156 args[1] = dp->rgvarg[dp->cArgs - 1];
7158 hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, &new_dp, res, ei, caller);
7159 VariantClear(&args[0]);
7160 return hres;
7163 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
7165 static const dispex_hook_t elem6_ie9_hooks[] = {
7166 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
7167 {DISPID_UNKNOWN}
7169 static const dispex_hook_t elem6_ie10_hooks[] = {
7170 {DISPID_IHTMLELEMENT6_HASATTRIBUTENS, IHTMLElement6_hasAttributeNS_hook},
7171 {DISPID_IHTMLELEMENT6_GETATTRIBUTENS, IHTMLElement6_getAttributeNS_hook},
7172 {DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
7173 {DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, IHTMLElement6_removeAttributeNS_hook},
7174 {DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, IHTMLElement6_setAttribute_hook},
7175 {DISPID_UNKNOWN}
7177 static const dispex_hook_t elem2_ie11_hooks[] = {
7178 {DISPID_IHTMLELEMENT2_DOSCROLL, NULL},
7179 {DISPID_IHTMLELEMENT2_READYSTATE, NULL},
7180 {DISPID_UNKNOWN}
7183 HTMLDOMNode_init_dispex_info(info, mode);
7185 dispex_info_add_interface(info, IHTMLElement2_tid, mode >= COMPAT_MODE_IE11 ? elem2_ie11_hooks : NULL);
7187 if(mode >= COMPAT_MODE_IE8)
7188 dispex_info_add_interface(info, IElementSelector_tid, NULL);
7190 if(mode >= COMPAT_MODE_IE9) {
7191 dispex_info_add_interface(info, IHTMLElement6_tid, mode >= COMPAT_MODE_IE10 ? elem6_ie10_hooks : elem6_ie9_hooks);
7192 dispex_info_add_interface(info, IElementTraversal_tid, NULL);
7195 if(mode >= COMPAT_MODE_IE10)
7197 dispex_info_add_interface(info, IHTMLElement7_tid, NULL);
7198 dispex_info_add_interface(info, IWineHTMLElementPrivate_tid, NULL);
7202 static const tid_t HTMLElement_iface_tids[] = {
7203 HTMLELEMENT_TIDS,
7207 static event_target_vtbl_t HTMLElement_event_target_vtbl = {
7209 NULL,
7210 HTMLElement_get_dispid,
7211 HTMLElement_get_name,
7212 HTMLElement_invoke,
7213 NULL,
7214 NULL,
7215 NULL,
7216 HTMLElement_populate_props
7218 HTMLElement_get_gecko_target,
7219 HTMLElement_bind_event,
7220 HTMLElement_get_parent_event_target,
7221 HTMLElement_handle_event_default,
7222 HTMLElement_get_cp_container,
7223 HTMLElement_set_current_event
7226 struct token_list {
7227 DispatchEx dispex;
7228 IWineDOMTokenList IWineDOMTokenList_iface;
7229 IHTMLElement *element;
7231 LONG ref;
7234 static inline struct token_list *impl_from_IWineDOMTokenList(IWineDOMTokenList *iface)
7236 return CONTAINING_RECORD(iface, struct token_list, IWineDOMTokenList_iface);
7239 static HRESULT WINAPI token_list_QueryInterface(IWineDOMTokenList *iface, REFIID riid, void **ppv)
7241 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7243 TRACE("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
7245 if(IsEqualGUID(&IID_IUnknown, riid)) {
7246 *ppv = &token_list->IWineDOMTokenList_iface;
7247 }else if(IsEqualGUID(&IID_IWineDOMTokenList, riid)) {
7248 *ppv = &token_list->IWineDOMTokenList_iface;
7249 }else if(dispex_query_interface(&token_list->dispex, riid, ppv)) {
7250 return *ppv ? S_OK : E_NOINTERFACE;
7251 }else {
7252 WARN("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
7253 *ppv = NULL;
7254 return E_NOINTERFACE;
7257 IUnknown_AddRef((IUnknown*)*ppv);
7258 return S_OK;
7261 static ULONG WINAPI token_list_AddRef(IWineDOMTokenList *iface)
7263 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7264 LONG ref = InterlockedIncrement(&token_list->ref);
7266 TRACE("(%p) ref=%ld\n", token_list, ref);
7268 return ref;
7271 static ULONG WINAPI token_list_Release(IWineDOMTokenList *iface)
7273 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7274 LONG ref = InterlockedDecrement(&token_list->ref);
7276 TRACE("(%p) ref=%ld\n", token_list, ref);
7278 if(!ref) {
7279 IHTMLElement_Release(token_list->element);
7280 release_dispex(&token_list->dispex);
7281 heap_free(token_list);
7284 return ref;
7287 static HRESULT WINAPI token_list_GetTypeInfoCount(IWineDOMTokenList *iface, UINT *pctinfo)
7289 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7290 FIXME("(%p)->(%p)\n", token_list, pctinfo);
7291 return E_NOTIMPL;
7294 static HRESULT WINAPI token_list_GetTypeInfo(IWineDOMTokenList *iface, UINT iTInfo,
7295 LCID lcid, ITypeInfo **ppTInfo)
7297 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7299 return IDispatchEx_GetTypeInfo(&token_list->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7302 static HRESULT WINAPI token_list_GetIDsOfNames(IWineDOMTokenList *iface, REFIID riid,
7303 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
7305 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7307 return IDispatchEx_GetIDsOfNames(&token_list->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7308 lcid, rgDispId);
7311 static HRESULT WINAPI token_list_Invoke(IWineDOMTokenList *iface, DISPID dispIdMember,
7312 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7313 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7315 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7317 return IDispatchEx_Invoke(&token_list->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
7318 pDispParams, pVarResult, pExcepInfo, puArgErr);
7321 static const WCHAR *find_token(const WCHAR *list, const WCHAR *token, unsigned int token_len)
7323 const WCHAR *ptr, *next;
7325 if (!list || !token)
7326 return NULL;
7328 ptr = list;
7329 while (*ptr)
7331 while (iswspace(*ptr))
7332 ++ptr;
7333 if (!*ptr)
7334 break;
7335 next = ptr + 1;
7336 while (*next && !iswspace(*next))
7337 ++next;
7339 if (next - ptr == token_len && !wcsncmp(ptr, token, token_len))
7340 return ptr;
7341 ptr = next;
7343 return NULL;
7346 static HRESULT token_list_add_remove(IWineDOMTokenList *iface, BSTR token, BOOL remove)
7348 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7349 unsigned int i, len, old_len, new_len;
7350 const WCHAR *old_pos;
7351 BSTR new, old;
7352 HRESULT hr;
7354 TRACE("iface %p, token %s, remove %#x.\n", iface, debugstr_w(token), remove);
7356 len = token ? lstrlenW(token) : 0;
7357 if (!len)
7359 WARN("Empty token.\n");
7360 return E_INVALIDARG;
7363 for (i = 0; i < len; ++i)
7364 if (iswspace(token[i]))
7366 WARN("Token has spaces.\n");
7367 return E_INVALIDARG;
7370 if (FAILED(hr = IHTMLElement_get_className(token_list->element, &old)))
7371 return hr;
7373 TRACE("old %s.\n", debugstr_w(old));
7375 if (((old_pos = find_token(old, token, len)) && !remove)
7376 || (!old_pos && remove))
7378 SysFreeString(old);
7379 return S_OK;
7382 old_len = old ? lstrlenW(old) : 0;
7383 if (remove)
7385 while (old_pos != old && iswspace(old_pos[-1]))
7387 --old_pos;
7388 ++len;
7390 while (iswspace(old_pos[len]))
7391 ++len;
7393 if (old_pos != old && old_pos[len])
7394 --len;
7396 new_len = old_len - len;
7398 else
7400 new_len = old_len + len + !!old_len;
7403 if (!(new = SysAllocStringLen(NULL, new_len)))
7405 ERR("No memory.\n");
7406 SysFreeString(old);
7407 return E_OUTOFMEMORY;
7410 if (remove)
7412 memcpy(new, old, sizeof(*new) * (old_pos - old));
7413 memcpy(new + (old_pos - old), old_pos + len, sizeof(*new) * (old_len - (old_pos - old) - len + 1));
7415 else
7417 memcpy(new, old, sizeof(*new) * old_len);
7418 if (old_len)
7419 new[old_len++]= L' ';
7420 memcpy(new + old_len, token, sizeof(*new) * len);
7421 new[old_len + len] = 0;
7424 SysFreeString(old);
7426 TRACE("new %s.\n", debugstr_w(new));
7428 hr = IHTMLElement_put_className(token_list->element, new);
7429 SysFreeString(new);
7430 return hr;
7433 static HRESULT WINAPI token_list_add(IWineDOMTokenList *iface, BSTR token)
7435 return token_list_add_remove(iface, token, FALSE);
7438 static HRESULT WINAPI token_list_remove(IWineDOMTokenList *iface, BSTR token)
7440 return token_list_add_remove(iface, token, TRUE);
7443 static HRESULT WINAPI token_list_toString(IWineDOMTokenList *iface, BSTR *String)
7445 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
7447 TRACE("(%p)->(%p)\n", token_list, String);
7449 return IHTMLElement_get_className(token_list->element, String);
7452 static const IWineDOMTokenListVtbl WineDOMTokenListVtbl = {
7453 token_list_QueryInterface,
7454 token_list_AddRef,
7455 token_list_Release,
7456 token_list_GetTypeInfoCount,
7457 token_list_GetTypeInfo,
7458 token_list_GetIDsOfNames,
7459 token_list_Invoke,
7460 token_list_add,
7461 token_list_remove,
7462 token_list_toString
7465 static inline struct token_list *token_list_from_DispatchEx(DispatchEx *iface)
7467 return CONTAINING_RECORD(iface, struct token_list, dispex);
7470 static HRESULT token_list_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params,
7471 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7473 struct token_list *token_list = token_list_from_DispatchEx(dispex);
7474 HRESULT hres;
7476 switch(flags) {
7477 case DISPATCH_PROPERTYGET:
7478 hres = IHTMLElement_get_className(token_list->element, &V_BSTR(res));
7479 if(FAILED(hres))
7480 return hres;
7481 V_VT(res) = VT_BSTR;
7482 break;
7483 default:
7484 FIXME("Unimplemented flags %x\n", flags);
7485 return E_NOTIMPL;
7488 return S_OK;
7491 static const dispex_static_data_vtbl_t token_list_dispex_vtbl = {
7492 token_list_value
7495 static const tid_t token_list_iface_tids[] = {
7496 IWineDOMTokenList_tid,
7499 static dispex_static_data_t token_list_dispex = {
7500 L"DOMTokenList",
7501 &token_list_dispex_vtbl,
7502 IWineDOMTokenList_tid,
7503 token_list_iface_tids
7506 static HRESULT create_token_list(compat_mode_t compat_mode, IHTMLElement *element, IWineDOMTokenList **ret)
7508 struct token_list *obj;
7510 obj = heap_alloc_zero(sizeof(*obj));
7511 if(!obj)
7513 ERR("No memory.\n");
7514 return E_OUTOFMEMORY;
7517 obj->IWineDOMTokenList_iface.lpVtbl = &WineDOMTokenListVtbl;
7518 obj->ref = 1;
7519 init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineDOMTokenList_iface, &token_list_dispex, compat_mode);
7520 IHTMLElement_AddRef(element);
7521 obj->element = element;
7523 *ret = &obj->IWineDOMTokenList_iface;
7524 return S_OK;
7527 static inline HTMLElement *impl_from_IWineHTMLElementPrivateVtbl(IWineHTMLElementPrivate *iface)
7529 return CONTAINING_RECORD(iface, HTMLElement, IWineHTMLElementPrivate_iface);
7532 static HRESULT WINAPI htmlelement_private_QueryInterface(IWineHTMLElementPrivate *iface,
7533 REFIID riid, void **ppv)
7535 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7537 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
7540 static ULONG WINAPI htmlelement_private_AddRef(IWineHTMLElementPrivate *iface)
7542 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7544 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
7547 static ULONG WINAPI htmlelement_private_Release(IWineHTMLElementPrivate *iface)
7549 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7551 return IHTMLElement_Release(&This->IHTMLElement_iface);
7554 static HRESULT WINAPI htmlelement_private_GetTypeInfoCount(IWineHTMLElementPrivate *iface, UINT *pctinfo)
7556 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7558 return HTMLElement_GetTypeInfoCount(&This->IHTMLElement_iface, pctinfo);
7561 static HRESULT WINAPI htmlelement_private_GetTypeInfo(IWineHTMLElementPrivate *iface, UINT iTInfo,
7562 LCID lcid, ITypeInfo **ppTInfo)
7564 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7566 return HTMLElement_GetTypeInfo(&This->IHTMLElement_iface, iTInfo, lcid, ppTInfo);
7569 static HRESULT WINAPI htmlelement_private_GetIDsOfNames(IWineHTMLElementPrivate *iface, REFIID riid,
7570 LPOLESTR *rgszNames, UINT cNames,
7571 LCID lcid, DISPID *rgDispId)
7573 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7575 return HTMLElement_GetIDsOfNames(&This->IHTMLElement_iface, riid, rgszNames, cNames, lcid,
7576 rgDispId);
7579 static HRESULT WINAPI htmlelement_private_Invoke(IWineHTMLElementPrivate *iface, DISPID dispIdMember,
7580 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7581 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7583 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7585 return HTMLElement_Invoke(&This->IHTMLElement_iface, dispIdMember, riid, lcid, wFlags,
7586 pDispParams, pVarResult, pExcepInfo, puArgErr);
7589 static HRESULT WINAPI htmlelement_private_get_classList(IWineHTMLElementPrivate *iface, IDispatch **class_list)
7591 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7593 TRACE("iface %p, class_list %p.\n", iface, class_list);
7595 return create_token_list(dispex_compat_mode(&This->node.event_target.dispex), &This->IHTMLElement_iface,
7596 (IWineDOMTokenList **)class_list);
7599 static const IWineHTMLElementPrivateVtbl WineHTMLElementPrivateVtbl = {
7600 htmlelement_private_QueryInterface,
7601 htmlelement_private_AddRef,
7602 htmlelement_private_Release,
7603 htmlelement_private_GetTypeInfoCount,
7604 htmlelement_private_GetTypeInfo,
7605 htmlelement_private_GetIDsOfNames,
7606 htmlelement_private_Invoke,
7607 htmlelement_private_get_classList,
7610 static dispex_static_data_t HTMLElement_dispex = {
7611 L"HTMLElement",
7612 &HTMLElement_event_target_vtbl.dispex_vtbl,
7613 DispHTMLUnknownElement_tid,
7614 HTMLElement_iface_tids,
7615 HTMLElement_init_dispex_info
7618 static dispex_static_data_t HTMLUnknownElement_dispex = {
7619 L"HTMLUnknownElement",
7620 &HTMLElement_event_target_vtbl.dispex_vtbl,
7621 DispHTMLUnknownElement_tid,
7622 HTMLElement_iface_tids,
7623 HTMLElement_init_dispex_info
7626 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMElement *nselem, dispex_static_data_t *dispex_data)
7628 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
7629 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
7630 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
7631 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
7632 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
7633 This->IHTMLElement7_iface.lpVtbl = &HTMLElement7Vtbl;
7634 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
7635 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
7636 This->IElementTraversal_iface.lpVtbl = &ElementTraversalVtbl;
7637 This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
7638 This->IWineHTMLElementPrivate_iface.lpVtbl = &WineHTMLElementPrivateVtbl;
7640 if(dispex_data && !dispex_data->vtbl)
7641 dispex_data->vtbl = &HTMLElement_event_target_vtbl.dispex_vtbl;
7643 if(nselem) {
7644 nsIDOMHTMLElement *html_element;
7645 nsresult nsres;
7647 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data ? dispex_data : &HTMLUnknownElement_dispex);
7649 /* No AddRef, share reference with HTMLDOMNode */
7650 assert((nsIDOMNode*)nselem == This->node.nsnode);
7651 This->dom_element = nselem;
7653 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)&html_element);
7654 if(NS_SUCCEEDED(nsres)) {
7655 This->html_element = html_element;
7656 /* share reference with HTMLDOMNode */
7657 assert((nsIDOMNode*)html_element == This->node.nsnode);
7658 nsIDOMHTMLElement_Release(html_element);
7662 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
7665 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
7667 nsIDOMElement *nselem;
7668 nsAString tag_name_str;
7669 const PRUnichar *tag_name;
7670 const tag_desc_t *tag;
7671 HTMLElement *elem;
7672 nsresult nsres;
7673 HRESULT hres;
7675 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
7676 if(NS_FAILED(nsres)) {
7677 ERR("no nsIDOMElement iface\n");
7678 return E_FAIL;
7681 nsAString_Init(&tag_name_str, NULL);
7682 nsIDOMElement_GetTagName(nselem, &tag_name_str);
7684 nsAString_GetData(&tag_name_str, &tag_name);
7686 tag = get_tag_desc(tag_name);
7687 if(tag) {
7688 hres = tag->constructor(doc, nselem, &elem);
7689 }else {
7690 nsIDOMSVGElement *svg_element;
7692 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMSVGElement, (void**)&svg_element);
7693 if(NS_SUCCEEDED(nsres)) {
7694 hres = create_svg_element(doc, svg_element, tag_name, &elem);
7695 nsIDOMSVGElement_Release(svg_element);
7696 }else if(use_generic) {
7697 hres = HTMLGenericElement_Create(doc, nselem, &elem);
7698 }else {
7699 elem = heap_alloc_zero(sizeof(HTMLElement));
7700 if(elem) {
7701 elem->node.vtbl = &HTMLElementImplVtbl;
7702 HTMLElement_Init(elem, doc, nselem, &HTMLUnknownElement_dispex);
7703 hres = S_OK;
7704 }else {
7705 hres = E_OUTOFMEMORY;
7710 TRACE("%s ret %p\n", debugstr_w(tag_name), elem);
7712 nsIDOMElement_Release(nselem);
7713 nsAString_Finish(&tag_name_str);
7714 if(FAILED(hres))
7715 return hres;
7717 *ret = elem;
7718 return S_OK;
7721 static HRESULT HTMLElement_Ctor(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
7723 HTMLElement *ret;
7725 ret = heap_alloc_zero(sizeof(*ret));
7726 if(!ret)
7727 return E_OUTOFMEMORY;
7729 ret->node.vtbl = &HTMLElementImplVtbl;
7730 HTMLElement_Init(ret, doc, nselem, &HTMLElement_dispex);
7732 *elem = ret;
7733 return S_OK;
7736 HRESULT get_element(nsIDOMElement *nselem, HTMLElement **ret)
7738 HTMLDOMNode *node;
7739 HRESULT hres;
7741 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
7742 if(FAILED(hres))
7743 return hres;
7745 *ret = impl_from_HTMLDOMNode(node);
7746 return S_OK;
7749 /* interface IHTMLFiltersCollection */
7750 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
7752 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7754 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
7756 if(IsEqualGUID(&IID_IUnknown, riid)) {
7757 *ppv = &This->IHTMLFiltersCollection_iface;
7758 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
7759 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
7760 *ppv = &This->IHTMLFiltersCollection_iface;
7761 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
7762 return *ppv ? S_OK : E_NOINTERFACE;
7763 }else {
7764 *ppv = NULL;
7765 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
7766 return E_NOINTERFACE;
7769 IUnknown_AddRef((IUnknown*)*ppv);
7770 return S_OK;
7773 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
7775 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7776 LONG ref = InterlockedIncrement(&This->ref);
7778 TRACE("(%p) ref=%ld\n", This, ref);
7780 return ref;
7783 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
7785 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7786 LONG ref = InterlockedDecrement(&This->ref);
7788 TRACE("(%p) ref=%ld\n", This, ref);
7790 if(!ref)
7792 heap_free(This);
7795 return ref;
7798 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
7800 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7801 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
7804 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
7805 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
7807 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7808 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7811 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
7812 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
7813 LCID lcid, DISPID *rgDispId)
7815 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7816 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7817 lcid, rgDispId);
7820 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
7821 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
7822 EXCEPINFO *pExcepInfo, UINT *puArgErr)
7824 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7825 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
7826 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
7829 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
7831 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7833 if(!p)
7834 return E_POINTER;
7836 FIXME("(%p)->(%p) Always returning 0\n", This, p);
7837 *p = 0;
7839 return S_OK;
7842 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
7844 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7845 FIXME("(%p)->(%p)\n", This, p);
7846 return E_NOTIMPL;
7849 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
7851 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7852 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
7853 return E_NOTIMPL;
7856 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
7857 HTMLFiltersCollection_QueryInterface,
7858 HTMLFiltersCollection_AddRef,
7859 HTMLFiltersCollection_Release,
7860 HTMLFiltersCollection_GetTypeInfoCount,
7861 HTMLFiltersCollection_GetTypeInfo,
7862 HTMLFiltersCollection_GetIDsOfNames,
7863 HTMLFiltersCollection_Invoke,
7864 HTMLFiltersCollection_get_length,
7865 HTMLFiltersCollection_get__newEnum,
7866 HTMLFiltersCollection_item
7869 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
7871 WCHAR *ptr;
7872 int idx = 0;
7874 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
7875 idx = idx*10 + (*ptr-'0');
7876 if(*ptr)
7877 return DISP_E_UNKNOWNNAME;
7879 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
7880 TRACE("ret %lx\n", *dispid);
7881 return S_OK;
7884 static HRESULT HTMLFiltersCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
7886 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
7887 WCHAR buf[11];
7888 UINT len;
7890 len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx);
7891 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
7894 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
7895 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7897 TRACE("(%p)->(%lx %lx %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
7899 V_VT(res) = VT_DISPATCH;
7900 V_DISPATCH(res) = NULL;
7902 FIXME("always returning NULL\n");
7904 return S_OK;
7907 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
7908 NULL,
7909 HTMLFiltersCollection_get_dispid,
7910 HTMLFiltersCollection_get_name,
7911 HTMLFiltersCollection_invoke,
7912 NULL
7915 static const tid_t HTMLFiltersCollection_iface_tids[] = {
7916 IHTMLFiltersCollection_tid,
7919 static dispex_static_data_t HTMLFiltersCollection_dispex = {
7920 L"FiltersCollection",
7921 &HTMLFiltersCollection_dispex_vtbl,
7922 IHTMLFiltersCollection_tid,
7923 HTMLFiltersCollection_iface_tids
7926 static HRESULT create_filters_collection(compat_mode_t compat_mode, IHTMLFiltersCollection **ret)
7928 HTMLFiltersCollection *collection;
7930 if(!(collection = heap_alloc(sizeof(HTMLFiltersCollection))))
7931 return E_OUTOFMEMORY;
7933 collection->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
7934 collection->ref = 1;
7936 init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLFiltersCollection_iface,
7937 &HTMLFiltersCollection_dispex, min(compat_mode, COMPAT_MODE_IE8));
7939 *ret = &collection->IHTMLFiltersCollection_iface;
7940 return S_OK;
7943 static HRESULT get_attr_dispid_by_relative_idx(HTMLAttributeCollection *This, LONG *idx, DISPID start, DISPID *dispid)
7945 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
7946 DISPID id = start;
7947 LONG len = -1;
7948 HRESULT hres;
7950 FIXME("filter non-enumerable attributes out\n");
7952 while(1) {
7953 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
7954 if(FAILED(hres))
7955 return hres;
7956 else if(hres == S_FALSE)
7957 break;
7959 len++;
7960 if(len == *idx)
7961 break;
7964 if(dispid) {
7965 *dispid = id;
7966 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
7969 *idx = len+1;
7970 return S_OK;
7973 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
7975 return get_attr_dispid_by_relative_idx(This, idx, DISPID_STARTENUM, dispid);
7978 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
7980 HRESULT hres;
7982 if(name[0]>='0' && name[0]<='9') {
7983 WCHAR *end_ptr;
7984 LONG idx;
7986 idx = wcstoul(name, &end_ptr, 10);
7987 if(!*end_ptr) {
7988 hres = get_attr_dispid_by_idx(This, &idx, id);
7989 if(SUCCEEDED(hres))
7990 return hres;
7994 if(!This->elem) {
7995 WARN("NULL elem\n");
7996 return E_UNEXPECTED;
7999 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
8000 name, fdexNameCaseInsensitive, id);
8001 return hres;
8004 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
8006 HTMLDOMAttribute *iter;
8007 LONG pos = 0;
8008 HRESULT hres;
8010 *attr = NULL;
8011 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
8012 if(iter->dispid == id) {
8013 *attr = iter;
8014 break;
8016 pos++;
8019 if(!*attr) {
8020 if(!This->elem) {
8021 WARN("NULL elem\n");
8022 return E_UNEXPECTED;
8025 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, dispex_compat_mode(&This->elem->node.event_target.dispex), attr);
8026 if(FAILED(hres))
8027 return hres;
8030 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
8031 if(list_pos)
8032 *list_pos = pos;
8033 return S_OK;
8036 typedef struct {
8037 IEnumVARIANT IEnumVARIANT_iface;
8039 LONG ref;
8041 ULONG iter;
8042 DISPID iter_dispid;
8043 HTMLAttributeCollection *col;
8044 } HTMLAttributeCollectionEnum;
8046 static inline HTMLAttributeCollectionEnum *HTMLAttributeCollectionEnum_from_IEnumVARIANT(IEnumVARIANT *iface)
8048 return CONTAINING_RECORD(iface, HTMLAttributeCollectionEnum, IEnumVARIANT_iface);
8051 static HRESULT WINAPI HTMLAttributeCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
8053 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8055 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8057 if(IsEqualGUID(riid, &IID_IUnknown)) {
8058 *ppv = &This->IEnumVARIANT_iface;
8059 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
8060 *ppv = &This->IEnumVARIANT_iface;
8061 }else {
8062 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8063 *ppv = NULL;
8064 return E_NOINTERFACE;
8067 IUnknown_AddRef((IUnknown*)*ppv);
8068 return S_OK;
8071 static ULONG WINAPI HTMLAttributeCollectionEnum_AddRef(IEnumVARIANT *iface)
8073 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8074 LONG ref = InterlockedIncrement(&This->ref);
8076 TRACE("(%p) ref=%ld\n", This, ref);
8078 return ref;
8081 static ULONG WINAPI HTMLAttributeCollectionEnum_Release(IEnumVARIANT *iface)
8083 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8084 LONG ref = InterlockedDecrement(&This->ref);
8086 TRACE("(%p) ref=%ld\n", This, ref);
8088 if(!ref) {
8089 IHTMLAttributeCollection_Release(&This->col->IHTMLAttributeCollection_iface);
8090 heap_free(This);
8093 return ref;
8096 static HRESULT WINAPI HTMLAttributeCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
8098 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8099 DISPID tmp, dispid = This->iter_dispid;
8100 HTMLDOMAttribute *attr;
8101 LONG rel_index = 0;
8102 HRESULT hres;
8103 ULONG i;
8105 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
8107 for(i = 0; i < celt; i++) {
8108 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, dispid, &tmp);
8109 if(SUCCEEDED(hres)) {
8110 dispid = tmp;
8111 hres = get_domattr(This->col, dispid, NULL, &attr);
8113 else if(hres == DISP_E_UNKNOWNNAME)
8114 break;
8116 if(FAILED(hres)) {
8117 while(i--)
8118 VariantClear(&rgVar[i]);
8119 return hres;
8122 V_VT(&rgVar[i]) = VT_DISPATCH;
8123 V_DISPATCH(&rgVar[i]) = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
8126 This->iter += i;
8127 This->iter_dispid = dispid;
8128 if(pCeltFetched)
8129 *pCeltFetched = i;
8130 return i == celt ? S_OK : S_FALSE;
8133 static HRESULT WINAPI HTMLAttributeCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
8135 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8136 LONG remaining, rel_index;
8137 DISPID dispid;
8138 HRESULT hres;
8140 TRACE("(%p)->(%lu)\n", This, celt);
8142 if(!celt)
8143 return S_OK;
8145 rel_index = -1;
8146 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, NULL);
8147 if(FAILED(hres))
8148 return hres;
8149 remaining = min(celt, rel_index);
8151 if(remaining) {
8152 rel_index = remaining - 1;
8153 hres = get_attr_dispid_by_relative_idx(This->col, &rel_index, This->iter_dispid, &dispid);
8154 if(FAILED(hres))
8155 return hres;
8156 This->iter += remaining;
8157 This->iter_dispid = dispid;
8159 return celt > remaining ? S_FALSE : S_OK;
8162 static HRESULT WINAPI HTMLAttributeCollectionEnum_Reset(IEnumVARIANT *iface)
8164 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8166 TRACE("(%p)->()\n", This);
8168 This->iter = 0;
8169 This->iter_dispid = DISPID_STARTENUM;
8170 return S_OK;
8173 static HRESULT WINAPI HTMLAttributeCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
8175 HTMLAttributeCollectionEnum *This = HTMLAttributeCollectionEnum_from_IEnumVARIANT(iface);
8176 FIXME("(%p)->(%p)\n", This, ppEnum);
8177 return E_NOTIMPL;
8180 static const IEnumVARIANTVtbl HTMLAttributeCollectionEnumVtbl = {
8181 HTMLAttributeCollectionEnum_QueryInterface,
8182 HTMLAttributeCollectionEnum_AddRef,
8183 HTMLAttributeCollectionEnum_Release,
8184 HTMLAttributeCollectionEnum_Next,
8185 HTMLAttributeCollectionEnum_Skip,
8186 HTMLAttributeCollectionEnum_Reset,
8187 HTMLAttributeCollectionEnum_Clone
8190 /* interface IHTMLAttributeCollection */
8191 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
8193 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
8196 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
8198 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8200 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8202 if(IsEqualGUID(&IID_IUnknown, riid)) {
8203 *ppv = &This->IHTMLAttributeCollection_iface;
8204 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
8205 *ppv = &This->IHTMLAttributeCollection_iface;
8206 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
8207 *ppv = &This->IHTMLAttributeCollection2_iface;
8208 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
8209 *ppv = &This->IHTMLAttributeCollection3_iface;
8210 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
8211 return *ppv ? S_OK : E_NOINTERFACE;
8212 }else {
8213 *ppv = NULL;
8214 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
8215 return E_NOINTERFACE;
8218 IUnknown_AddRef((IUnknown*)*ppv);
8219 return S_OK;
8222 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
8224 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8225 LONG ref = InterlockedIncrement(&This->ref);
8227 TRACE("(%p) ref=%ld\n", This, ref);
8229 return ref;
8232 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
8234 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8235 LONG ref = InterlockedDecrement(&This->ref);
8237 TRACE("(%p) ref=%ld\n", This, ref);
8239 if(!ref) {
8240 while(!list_empty(&This->attrs)) {
8241 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
8243 list_remove(&attr->entry);
8244 attr->elem = NULL;
8245 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8248 heap_free(This);
8251 return ref;
8254 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
8256 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8257 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8260 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
8261 LCID lcid, ITypeInfo **ppTInfo)
8263 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8264 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8267 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
8268 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8270 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8271 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8272 lcid, rgDispId);
8275 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
8276 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8277 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8279 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8280 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8281 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8284 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
8286 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8287 HRESULT hres;
8289 TRACE("(%p)->(%p)\n", This, p);
8291 *p = -1;
8292 hres = get_attr_dispid_by_idx(This, p, NULL);
8293 return hres;
8296 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
8298 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8299 HTMLAttributeCollectionEnum *ret;
8301 TRACE("(%p)->(%p)\n", This, p);
8303 ret = heap_alloc(sizeof(*ret));
8304 if(!ret)
8305 return E_OUTOFMEMORY;
8307 ret->IEnumVARIANT_iface.lpVtbl = &HTMLAttributeCollectionEnumVtbl;
8308 ret->ref = 1;
8309 ret->iter = 0;
8310 ret->iter_dispid = DISPID_STARTENUM;
8312 HTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8313 ret->col = This;
8315 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
8316 return S_OK;
8319 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
8321 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
8322 HTMLDOMAttribute *attr;
8323 DISPID id;
8324 HRESULT hres;
8326 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
8328 switch(V_VT(name)) {
8329 case VT_I4:
8330 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
8331 break;
8332 case VT_BSTR:
8333 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
8334 break;
8335 default:
8336 FIXME("unsupported name %s\n", debugstr_variant(name));
8337 hres = E_NOTIMPL;
8339 if(hres == DISP_E_UNKNOWNNAME)
8340 return E_INVALIDARG;
8341 if(FAILED(hres))
8342 return hres;
8344 hres = get_domattr(This, id, NULL, &attr);
8345 if(FAILED(hres))
8346 return hres;
8348 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
8349 return S_OK;
8352 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
8353 HTMLAttributeCollection_QueryInterface,
8354 HTMLAttributeCollection_AddRef,
8355 HTMLAttributeCollection_Release,
8356 HTMLAttributeCollection_GetTypeInfoCount,
8357 HTMLAttributeCollection_GetTypeInfo,
8358 HTMLAttributeCollection_GetIDsOfNames,
8359 HTMLAttributeCollection_Invoke,
8360 HTMLAttributeCollection_get_length,
8361 HTMLAttributeCollection__newEnum,
8362 HTMLAttributeCollection_item
8365 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
8367 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
8370 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
8372 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8373 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
8376 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
8378 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8379 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8382 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
8384 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8385 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
8388 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
8390 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8391 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8394 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
8395 LCID lcid, ITypeInfo **ppTInfo)
8397 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8398 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8401 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
8402 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8404 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8405 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8406 lcid, rgDispId);
8409 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
8410 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8411 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8413 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8414 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8415 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8418 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
8419 IHTMLDOMAttribute **newretNode)
8421 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8422 HTMLDOMAttribute *attr;
8423 DISPID id;
8424 HRESULT hres;
8426 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
8428 hres = get_attr_dispid_by_name(This, bstrName, &id);
8429 if(hres == DISP_E_UNKNOWNNAME) {
8430 *newretNode = NULL;
8431 return S_OK;
8432 } else if(FAILED(hres)) {
8433 return hres;
8436 hres = get_domattr(This, id, NULL, &attr);
8437 if(FAILED(hres))
8438 return hres;
8440 *newretNode = &attr->IHTMLDOMAttribute_iface;
8441 return S_OK;
8444 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
8445 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
8447 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8448 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
8449 return E_NOTIMPL;
8452 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
8453 BSTR bstrName, IHTMLDOMAttribute **newretNode)
8455 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
8456 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
8457 return E_NOTIMPL;
8460 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
8461 HTMLAttributeCollection2_QueryInterface,
8462 HTMLAttributeCollection2_AddRef,
8463 HTMLAttributeCollection2_Release,
8464 HTMLAttributeCollection2_GetTypeInfoCount,
8465 HTMLAttributeCollection2_GetTypeInfo,
8466 HTMLAttributeCollection2_GetIDsOfNames,
8467 HTMLAttributeCollection2_Invoke,
8468 HTMLAttributeCollection2_getNamedItem,
8469 HTMLAttributeCollection2_setNamedItem,
8470 HTMLAttributeCollection2_removeNamedItem
8473 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
8475 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
8478 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
8480 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8481 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
8484 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
8486 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8487 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
8490 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
8492 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8493 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
8496 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
8498 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8499 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
8502 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
8503 LCID lcid, ITypeInfo **ppTInfo)
8505 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8506 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
8509 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
8510 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
8512 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8513 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
8514 lcid, rgDispId);
8517 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
8518 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
8519 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
8521 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8522 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
8523 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
8526 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
8527 IHTMLDOMAttribute **ppNodeOut)
8529 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8530 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
8533 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
8534 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
8536 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8537 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
8538 return E_NOTIMPL;
8541 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
8542 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
8544 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8545 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
8546 return E_NOTIMPL;
8549 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
8551 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8552 HTMLDOMAttribute *attr;
8553 DISPID id;
8554 HRESULT hres;
8556 TRACE("(%p)->(%ld %p)\n", This, index, ppNodeOut);
8558 hres = get_attr_dispid_by_idx(This, &index, &id);
8559 if(hres == DISP_E_UNKNOWNNAME)
8560 return E_INVALIDARG;
8561 if(FAILED(hres))
8562 return hres;
8564 hres = get_domattr(This, id, NULL, &attr);
8565 if(FAILED(hres))
8566 return hres;
8568 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
8569 return S_OK;
8572 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
8574 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
8575 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
8578 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
8579 HTMLAttributeCollection3_QueryInterface,
8580 HTMLAttributeCollection3_AddRef,
8581 HTMLAttributeCollection3_Release,
8582 HTMLAttributeCollection3_GetTypeInfoCount,
8583 HTMLAttributeCollection3_GetTypeInfo,
8584 HTMLAttributeCollection3_GetIDsOfNames,
8585 HTMLAttributeCollection3_Invoke,
8586 HTMLAttributeCollection3_getNamedItem,
8587 HTMLAttributeCollection3_setNamedItem,
8588 HTMLAttributeCollection3_removeNamedItem,
8589 HTMLAttributeCollection3_item,
8590 HTMLAttributeCollection3_get_length
8593 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
8595 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
8598 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
8600 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8601 HTMLDOMAttribute *attr;
8602 LONG pos;
8603 HRESULT hres;
8605 TRACE("(%p)->(%s %lx %p)\n", This, debugstr_w(name), flags, dispid);
8607 hres = get_attr_dispid_by_name(This, name, dispid);
8608 if(FAILED(hres))
8609 return hres;
8611 hres = get_domattr(This, *dispid, &pos, &attr);
8612 if(FAILED(hres))
8613 return hres;
8614 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
8616 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
8617 return S_OK;
8620 static HRESULT HTMLAttributeCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
8622 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8624 FIXME("(%p)->(%lx %p)\n", This, id, name);
8626 return E_NOTIMPL;
8629 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
8630 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
8632 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
8634 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
8636 switch(flags) {
8637 case DISPATCH_PROPERTYGET: {
8638 HTMLDOMAttribute *iter;
8639 DWORD pos;
8641 pos = id-MSHTML_DISPID_CUSTOM_MIN;
8643 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
8644 if(!pos) {
8645 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
8646 V_VT(res) = VT_DISPATCH;
8647 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
8648 return S_OK;
8650 pos--;
8653 WARN("invalid arg\n");
8654 return E_INVALIDARG;
8657 default:
8658 FIXME("unimplemented flags %x\n", flags);
8659 return E_NOTIMPL;
8663 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
8664 NULL,
8665 HTMLAttributeCollection_get_dispid,
8666 HTMLAttributeCollection_get_name,
8667 HTMLAttributeCollection_invoke,
8668 NULL
8671 static const tid_t HTMLAttributeCollection_iface_tids[] = {
8672 IHTMLAttributeCollection_tid,
8673 IHTMLAttributeCollection2_tid,
8674 IHTMLAttributeCollection3_tid,
8678 static dispex_static_data_t HTMLAttributeCollection_dispex = {
8679 L"NamedNodeMap",
8680 &HTMLAttributeCollection_dispex_vtbl,
8681 DispHTMLAttributeCollection_tid,
8682 HTMLAttributeCollection_iface_tids
8685 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
8687 HTMLElement *This = impl_from_HTMLDOMNode(iface);
8689 if(This->attrs) {
8690 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
8691 *ac = This->attrs;
8692 return S_OK;
8695 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
8696 if(!This->attrs)
8697 return E_OUTOFMEMORY;
8699 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
8700 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
8701 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
8702 This->attrs->ref = 2;
8704 This->attrs->elem = This;
8705 list_init(&This->attrs->attrs);
8706 init_dispatch(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
8707 &HTMLAttributeCollection_dispex, dispex_compat_mode(&iface->event_target.dispex));
8709 *ac = This->attrs;
8710 return S_OK;