dbghelp/dwarf: Don't unmap the fmap of a DWZ module twice.
[wine.git] / dlls / mshtml / htmlelem.c
blobd54f729b2e52857e6754ca9d137af8f6783df16c
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: %08x\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: %08x\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: %08x\n", nsres);
216 hres = E_FAIL;
217 }else if(nstmp) {
218 nsIDOMNode_Release(nstmp);
220 }else {
221 ERR("GetParentNode failed: %08x\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: %08x\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: %08x\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: %08x\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=%d\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=%d\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)->(%d)\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: %08x\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)->(%d)\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: %08x\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)->(%d)\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: %08x\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)->(%d)\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: %08x\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 static inline HTMLRectCollection *impl_from_IHTMLRectCollection(IHTMLRectCollection *iface)
786 return CONTAINING_RECORD(iface, HTMLRectCollection, IHTMLRectCollection_iface);
789 static HRESULT WINAPI HTMLRectCollection_QueryInterface(IHTMLRectCollection *iface, REFIID riid, void **ppv)
791 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
793 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
795 if(IsEqualGUID(&IID_IUnknown, riid)) {
796 *ppv = &This->IHTMLRectCollection_iface;
797 }else if(IsEqualGUID(&IID_IHTMLRectCollection, riid)) {
798 *ppv = &This->IHTMLRectCollection_iface;
799 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
800 return *ppv ? S_OK : E_NOINTERFACE;
801 }else {
802 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
803 *ppv = NULL;
804 return E_NOINTERFACE;
807 IUnknown_AddRef((IUnknown*)*ppv);
808 return S_OK;
811 static ULONG WINAPI HTMLRectCollection_AddRef(IHTMLRectCollection *iface)
813 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
814 LONG ref = InterlockedIncrement(&This->ref);
816 TRACE("(%p) ref=%d\n", This, ref);
818 return ref;
821 static ULONG WINAPI HTMLRectCollection_Release(IHTMLRectCollection *iface)
823 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
824 LONG ref = InterlockedDecrement(&This->ref);
826 TRACE("(%p) ref=%d\n", This, ref);
828 if(!ref) {
829 if(This->rect_list)
830 nsIDOMClientRectList_Release(This->rect_list);
831 release_dispex(&This->dispex);
832 heap_free(This);
835 return ref;
838 static HRESULT WINAPI HTMLRectCollection_GetTypeInfoCount(IHTMLRectCollection *iface, UINT *pctinfo)
840 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
841 FIXME("(%p)->(%p)\n", This, pctinfo);
842 return E_NOTIMPL;
845 static HRESULT WINAPI HTMLRectCollection_GetTypeInfo(IHTMLRectCollection *iface, UINT iTInfo,
846 LCID lcid, ITypeInfo **ppTInfo)
848 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
849 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
852 static HRESULT WINAPI HTMLRectCollection_GetIDsOfNames(IHTMLRectCollection *iface, REFIID riid,
853 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
855 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
856 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
857 lcid, rgDispId);
860 static HRESULT WINAPI HTMLRectCollection_Invoke(IHTMLRectCollection *iface, DISPID dispIdMember,
861 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
862 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
864 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
865 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
866 pDispParams, pVarResult, pExcepInfo, puArgErr);
869 static HRESULT WINAPI HTMLRectCollection_get_length(IHTMLRectCollection *iface, LONG *p)
871 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
872 UINT32 length;
873 nsresult nsres;
875 TRACE("(%p)->(%p)\n", This, p);
877 nsres = nsIDOMClientRectList_GetLength(This->rect_list, &length);
878 assert(nsres == NS_OK);
879 *p = length;
880 return S_OK;
883 static HRESULT WINAPI HTMLRectCollection_get__newEnum(IHTMLRectCollection *iface, IUnknown **p)
885 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
886 FIXME("(%p)->(%p)\n", This, p);
887 return E_NOTIMPL;
890 static HRESULT WINAPI HTMLRectCollection_item(IHTMLRectCollection *iface, VARIANT *index, VARIANT *result)
892 HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface);
893 nsIDOMClientRect *nsrect;
894 IHTMLRect *rect;
895 nsresult nsres;
896 HRESULT hres;
898 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(index), result);
900 if(V_VT(index) != VT_I4 || V_I4(index) < 0) {
901 FIXME("Unsupported for %s index\n", debugstr_variant(index));
902 return E_NOTIMPL;
905 nsres = nsIDOMClientRectList_Item(This->rect_list, V_I4(index), &nsrect);
906 if(NS_FAILED(nsres))
907 return map_nsresult(nsres);
908 if(!nsrect) {
909 V_VT(result) = VT_NULL;
910 return S_OK;
913 hres = create_html_rect(nsrect, dispex_compat_mode(&This->dispex), &rect);
914 nsIDOMClientRect_Release(nsrect);
915 if(FAILED(hres))
916 return hres;
918 V_VT(result) = VT_DISPATCH;
919 V_DISPATCH(result) = (IDispatch *)rect;
920 return S_OK;
923 static const IHTMLRectCollectionVtbl HTMLRectCollectionVtbl = {
924 HTMLRectCollection_QueryInterface,
925 HTMLRectCollection_AddRef,
926 HTMLRectCollection_Release,
927 HTMLRectCollection_GetTypeInfoCount,
928 HTMLRectCollection_GetTypeInfo,
929 HTMLRectCollection_GetIDsOfNames,
930 HTMLRectCollection_Invoke,
931 HTMLRectCollection_get_length,
932 HTMLRectCollection_get__newEnum,
933 HTMLRectCollection_item
936 static inline HTMLRectCollection *HTMLRectCollection_from_DispatchEx(DispatchEx *iface)
938 return CONTAINING_RECORD(iface, HTMLRectCollection, dispex);
941 static HRESULT HTMLRectCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
943 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
944 UINT32 len = 0;
945 DWORD idx = 0;
946 WCHAR *ptr;
948 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
949 idx = idx*10 + (*ptr-'0');
950 if(*ptr)
951 return DISP_E_UNKNOWNNAME;
953 nsIDOMClientRectList_GetLength(This->rect_list, &len);
954 if(idx >= len)
955 return DISP_E_UNKNOWNNAME;
957 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
958 TRACE("ret %x\n", *dispid);
959 return S_OK;
962 static HRESULT HTMLRectCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
963 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
965 HTMLRectCollection *This = HTMLRectCollection_from_DispatchEx(dispex);
967 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
969 switch(flags) {
970 case DISPATCH_PROPERTYGET: {
971 nsIDOMClientRect *rect;
972 IHTMLRect *html_rect;
973 nsresult nsres;
974 HRESULT hres;
976 nsres = nsIDOMClientRectList_Item(This->rect_list, id - MSHTML_DISPID_CUSTOM_MIN, &rect);
977 if(NS_FAILED(nsres) || !rect) {
978 WARN("Unknown item\n");
979 return DISP_E_UNKNOWNNAME;
982 hres = create_html_rect(rect, dispex_compat_mode(&This->dispex), &html_rect);
983 nsIDOMClientRect_Release(rect);
984 if(FAILED(hres))
985 return hres;
987 V_VT(res) = VT_DISPATCH;
988 V_DISPATCH(res) = (IDispatch*)html_rect;
989 break;
992 default:
993 FIXME("unimplemented flags %x\n", flags);
994 return E_NOTIMPL;
997 return S_OK;
1000 static const dispex_static_data_vtbl_t HTMLRectCollection_dispex_vtbl = {
1001 NULL,
1002 HTMLRectCollection_get_dispid,
1003 HTMLRectCollection_invoke,
1004 NULL
1006 static const tid_t HTMLRectCollection_iface_tids[] = {
1007 IHTMLRectCollection_tid,
1010 static dispex_static_data_t HTMLRectCollection_dispex = {
1011 L"ClientRectList",
1012 &HTMLRectCollection_dispex_vtbl,
1013 IHTMLRectCollection_tid,
1014 HTMLRectCollection_iface_tids
1017 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
1018 REFIID riid, void **ppv)
1020 HTMLElement *This = impl_from_IHTMLElement(iface);
1022 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
1025 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
1027 HTMLElement *This = impl_from_IHTMLElement(iface);
1029 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
1032 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
1034 HTMLElement *This = impl_from_IHTMLElement(iface);
1036 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
1039 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
1041 HTMLElement *This = impl_from_IHTMLElement(iface);
1042 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
1045 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
1046 LCID lcid, ITypeInfo **ppTInfo)
1048 HTMLElement *This = impl_from_IHTMLElement(iface);
1049 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1052 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
1053 LPOLESTR *rgszNames, UINT cNames,
1054 LCID lcid, DISPID *rgDispId)
1056 HTMLElement *This = impl_from_IHTMLElement(iface);
1057 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1058 lcid, rgDispId);
1061 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
1062 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1063 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1065 HTMLElement *This = impl_from_IHTMLElement(iface);
1066 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1067 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1070 static HRESULT set_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *v)
1072 DISPID propput_dispid = DISPID_PROPERTYPUT;
1073 DISPPARAMS dp = {v, &propput_dispid, 1, 1};
1074 EXCEPINFO ei;
1076 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
1077 TRACE("Ignoring call on style attribute\n");
1078 return S_OK;
1081 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid,
1082 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
1085 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
1086 VARIANT AttributeValue, LONG lFlags)
1088 HTMLElement *This = impl_from_IHTMLElement(iface);
1089 DISPID dispid;
1090 HRESULT hres;
1092 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
1094 if(This->dom_element && dispex_compat_mode(&This->node.event_target.dispex) >= COMPAT_MODE_IE8) {
1095 nsAString name_str, value_str;
1096 nsresult nsres;
1098 hres = variant_to_nsstr(&AttributeValue, FALSE, &value_str);
1099 if(FAILED(hres))
1100 return hres;
1102 nsAString_InitDepend(&name_str, strAttributeName);
1103 nsres = nsIDOMElement_SetAttribute(This->dom_element, &name_str, &value_str);
1104 nsAString_Finish(&name_str);
1105 nsAString_Finish(&value_str);
1106 if(NS_FAILED(nsres))
1107 WARN("SetAttribute failed: %08x\n", nsres);
1108 return map_nsresult(nsres);
1111 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
1112 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
1113 if(FAILED(hres))
1114 return hres;
1116 return set_elem_attr_value_by_dispid(This, dispid, &AttributeValue);
1119 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *ret)
1121 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
1122 EXCEPINFO excep;
1124 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
1125 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
1128 HRESULT attr_value_to_string(VARIANT *v)
1130 HRESULT hres;
1132 switch(V_VT(v)) {
1133 case VT_BSTR:
1134 break;
1135 case VT_NULL:
1136 V_BSTR(v) = SysAllocString(L"null");
1137 if(!V_BSTR(v))
1138 return E_OUTOFMEMORY;
1139 V_VT(v) = VT_BSTR;
1140 break;
1141 case VT_DISPATCH:
1142 IDispatch_Release(V_DISPATCH(v));
1143 V_VT(v) = VT_BSTR;
1144 V_BSTR(v) = SysAllocString(NULL);
1145 break;
1146 default:
1147 hres = VariantChangeType(v, v, 0, VT_BSTR);
1148 if(FAILED(hres))
1149 return hres;
1152 return S_OK;
1155 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
1156 LONG lFlags, VARIANT *AttributeValue)
1158 HTMLElement *This = impl_from_IHTMLElement(iface);
1159 DISPID dispid;
1160 HRESULT hres;
1162 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
1164 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
1165 FIXME("Unsupported flags %x\n", lFlags);
1167 if(This->dom_element && dispex_compat_mode(&This->node.event_target.dispex) >= COMPAT_MODE_IE8) {
1168 nsAString name_str, value_str;
1169 nsresult nsres;
1171 nsAString_InitDepend(&name_str, strAttributeName);
1172 nsAString_InitDepend(&value_str, NULL);
1173 nsres = nsIDOMElement_GetAttribute(This->dom_element, &name_str, &value_str);
1174 nsAString_Finish(&name_str);
1175 return return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
1178 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
1179 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
1180 if(hres == DISP_E_UNKNOWNNAME) {
1181 V_VT(AttributeValue) = VT_NULL;
1182 return S_OK;
1185 if(FAILED(hres)) {
1186 V_VT(AttributeValue) = VT_NULL;
1187 return hres;
1190 hres = get_elem_attr_value_by_dispid(This, dispid, AttributeValue);
1191 if(SUCCEEDED(hres) && (lFlags & ATTRFLAG_ASSTRING))
1192 hres = attr_value_to_string(AttributeValue);
1193 return hres;
1196 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
1197 LONG lFlags, VARIANT_BOOL *pfSuccess)
1199 HTMLElement *This = impl_from_IHTMLElement(iface);
1200 DISPID id;
1201 HRESULT hres;
1203 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
1205 if(dispex_compat_mode(&This->node.event_target.dispex) >= COMPAT_MODE_IE8) {
1206 *pfSuccess = element_has_attribute(This, strAttributeName);
1207 if(*pfSuccess)
1208 return element_remove_attribute(This, strAttributeName);
1209 return S_OK;
1212 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
1213 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
1214 if(hres == DISP_E_UNKNOWNNAME) {
1215 *pfSuccess = VARIANT_FALSE;
1216 return S_OK;
1218 if(FAILED(hres))
1219 return hres;
1221 if(id == DISPID_IHTMLELEMENT_STYLE) {
1222 IHTMLStyle *style;
1224 TRACE("Special case: style\n");
1226 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
1227 if(FAILED(hres))
1228 return hres;
1230 hres = IHTMLStyle_put_cssText(style, NULL);
1231 IHTMLStyle_Release(style);
1232 if(FAILED(hres))
1233 return hres;
1235 *pfSuccess = VARIANT_TRUE;
1236 return S_OK;
1239 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
1242 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
1244 HTMLElement *This = impl_from_IHTMLElement(iface);
1245 nsAString classname_str;
1246 nsresult nsres;
1248 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1250 if(!This->dom_element) {
1251 FIXME("comment element\n");
1252 return E_NOTIMPL;
1255 nsAString_InitDepend(&classname_str, v);
1256 nsres = nsIDOMElement_SetClassName(This->dom_element, &classname_str);
1257 nsAString_Finish(&classname_str);
1258 if(NS_FAILED(nsres))
1259 ERR("SetClassName failed: %08x\n", nsres);
1261 return S_OK;
1264 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
1266 HTMLElement *This = impl_from_IHTMLElement(iface);
1267 nsAString class_str;
1268 nsresult nsres;
1270 TRACE("(%p)->(%p)\n", This, p);
1272 if(!This->dom_element) {
1273 FIXME("comment element\n");
1274 return E_NOTIMPL;
1277 nsAString_Init(&class_str, NULL);
1278 nsres = nsIDOMElement_GetClassName(This->dom_element, &class_str);
1279 return return_nsstr(nsres, &class_str, p);
1282 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
1284 HTMLElement *This = impl_from_IHTMLElement(iface);
1285 nsAString id_str;
1286 nsresult nsres;
1288 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1290 if(!This->dom_element) {
1291 FIXME("comment element\n");
1292 return S_OK;
1295 nsAString_InitDepend(&id_str, v);
1296 nsres = nsIDOMElement_SetId(This->dom_element, &id_str);
1297 nsAString_Finish(&id_str);
1298 if(NS_FAILED(nsres))
1299 ERR("SetId failed: %08x\n", nsres);
1301 return S_OK;
1304 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
1306 HTMLElement *This = impl_from_IHTMLElement(iface);
1307 nsAString id_str;
1308 nsresult nsres;
1310 TRACE("(%p)->(%p)\n", This, p);
1312 if(!This->dom_element) {
1313 *p = NULL;
1314 return S_OK;
1317 nsAString_Init(&id_str, NULL);
1318 nsres = nsIDOMElement_GetId(This->dom_element, &id_str);
1319 return return_nsstr(nsres, &id_str, p);
1322 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
1324 HTMLElement *This = impl_from_IHTMLElement(iface);
1325 nsAString tag_str;
1326 nsresult nsres;
1328 TRACE("(%p)->(%p)\n", This, p);
1330 if(!This->dom_element) {
1331 TRACE("comment element\n");
1332 *p = SysAllocString(L"!");
1333 return *p ? S_OK : E_OUTOFMEMORY;
1336 nsAString_Init(&tag_str, NULL);
1337 nsres = nsIDOMElement_GetTagName(This->dom_element, &tag_str);
1338 return return_nsstr(nsres, &tag_str, p);
1341 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
1343 HTMLElement *This = impl_from_IHTMLElement(iface);
1344 IHTMLDOMNode *node;
1345 HRESULT hres;
1347 TRACE("(%p)->(%p)\n", This, p);
1349 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
1350 if(FAILED(hres))
1351 return hres;
1353 if(!node) {
1354 *p = NULL;
1355 return S_OK;
1358 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
1359 IHTMLDOMNode_Release(node);
1360 if(FAILED(hres))
1361 *p = NULL;
1363 return S_OK;
1366 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
1368 HTMLElement *This = impl_from_IHTMLElement(iface);
1370 TRACE("(%p)->(%p)\n", This, p);
1372 if(!This->style) {
1373 HRESULT hres;
1375 hres = HTMLStyle_Create(This, &This->style);
1376 if(FAILED(hres))
1377 return hres;
1380 *p = &This->style->IHTMLStyle_iface;
1381 IHTMLStyle_AddRef(*p);
1382 return S_OK;
1385 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
1387 HTMLElement *This = impl_from_IHTMLElement(iface);
1389 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1391 return set_node_event(&This->node, EVENTID_HELP, &v);
1394 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
1396 HTMLElement *This = impl_from_IHTMLElement(iface);
1398 TRACE("(%p)->(%p)\n", This, p);
1400 return get_node_event(&This->node, EVENTID_HELP, p);
1403 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
1405 HTMLElement *This = impl_from_IHTMLElement(iface);
1407 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1409 return set_node_event(&This->node, EVENTID_CLICK, &v);
1412 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
1414 HTMLElement *This = impl_from_IHTMLElement(iface);
1416 TRACE("(%p)->(%p)\n", This, p);
1418 return get_node_event(&This->node, EVENTID_CLICK, p);
1421 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
1423 HTMLElement *This = impl_from_IHTMLElement(iface);
1425 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1427 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
1430 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
1432 HTMLElement *This = impl_from_IHTMLElement(iface);
1434 TRACE("(%p)->(%p)\n", This, p);
1436 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
1439 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
1441 HTMLElement *This = impl_from_IHTMLElement(iface);
1443 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1445 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
1448 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
1450 HTMLElement *This = impl_from_IHTMLElement(iface);
1452 TRACE("(%p)->(%p)\n", This, p);
1454 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
1457 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
1459 HTMLElement *This = impl_from_IHTMLElement(iface);
1461 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1463 return set_node_event(&This->node, EVENTID_KEYUP, &v);
1466 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
1468 HTMLElement *This = impl_from_IHTMLElement(iface);
1470 TRACE("(%p)->(%p)\n", This, p);
1472 return get_node_event(&This->node, EVENTID_KEYUP, p);
1475 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
1477 HTMLElement *This = impl_from_IHTMLElement(iface);
1479 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1481 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
1484 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
1486 HTMLElement *This = impl_from_IHTMLElement(iface);
1488 TRACE("(%p)->(%p)\n", This, p);
1490 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
1493 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
1495 HTMLElement *This = impl_from_IHTMLElement(iface);
1497 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1499 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
1502 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
1504 HTMLElement *This = impl_from_IHTMLElement(iface);
1506 TRACE("(%p)->(%p)\n", This, p);
1508 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1511 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1513 HTMLElement *This = impl_from_IHTMLElement(iface);
1515 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1517 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1520 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1522 HTMLElement *This = impl_from_IHTMLElement(iface);
1524 TRACE("(%p)->(%p)\n", This, p);
1526 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1529 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1531 HTMLElement *This = impl_from_IHTMLElement(iface);
1533 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1535 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1538 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1540 HTMLElement *This = impl_from_IHTMLElement(iface);
1542 TRACE("(%p)->(%p)\n", This, p);
1544 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1547 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1549 HTMLElement *This = impl_from_IHTMLElement(iface);
1551 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1553 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1556 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1558 HTMLElement *This = impl_from_IHTMLElement(iface);
1560 TRACE("(%p)->(%p)\n", This, p);
1562 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1565 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1567 HTMLElement *This = impl_from_IHTMLElement(iface);
1569 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1571 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1574 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1576 HTMLElement *This = impl_from_IHTMLElement(iface);
1578 TRACE("(%p)->(%p)\n", This, p);
1580 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1583 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1585 HTMLElement *This = impl_from_IHTMLElement(iface);
1587 TRACE("(%p)->(%p)\n", This, p);
1589 if(!p)
1590 return E_POINTER;
1592 if(This->node.vtbl->get_document)
1593 return This->node.vtbl->get_document(&This->node, p);
1595 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1596 IDispatch_AddRef(*p);
1597 return S_OK;
1600 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1602 HTMLElement *This = impl_from_IHTMLElement(iface);
1603 nsAString title_str;
1604 nsresult nsres;
1606 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1608 if(!This->dom_element) {
1609 VARIANT *var;
1610 HRESULT hres;
1612 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", TRUE, &var);
1613 if(FAILED(hres))
1614 return hres;
1616 VariantClear(var);
1617 V_VT(var) = VT_BSTR;
1618 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1619 return S_OK;
1622 if(!This->html_element)
1623 return elem_string_attr_setter(This, L"title", v);
1625 nsAString_InitDepend(&title_str, v);
1626 nsres = nsIDOMHTMLElement_SetTitle(This->html_element, &title_str);
1627 nsAString_Finish(&title_str);
1628 if(NS_FAILED(nsres))
1629 ERR("SetTitle failed: %08x\n", nsres);
1631 return S_OK;
1634 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1636 HTMLElement *This = impl_from_IHTMLElement(iface);
1637 nsAString title_str;
1638 nsresult nsres;
1640 TRACE("(%p)->(%p)\n", This, p);
1642 if(!This->dom_element) {
1643 VARIANT *var;
1644 HRESULT hres;
1646 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, L"title", FALSE, &var);
1647 if(hres == DISP_E_UNKNOWNNAME) {
1648 *p = NULL;
1649 }else if(V_VT(var) != VT_BSTR) {
1650 FIXME("title = %s\n", debugstr_variant(var));
1651 return E_FAIL;
1652 }else {
1653 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1656 return S_OK;
1659 if(!This->html_element)
1660 return elem_string_attr_getter(This, L"title", FALSE, p);
1662 nsAString_Init(&title_str, NULL);
1663 nsres = nsIDOMHTMLElement_GetTitle(This->html_element, &title_str);
1664 return return_nsstr(nsres, &title_str, p);
1667 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1669 HTMLElement *This = impl_from_IHTMLElement(iface);
1671 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1673 return elem_string_attr_setter(This, L"language", v);
1676 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1678 HTMLElement *This = impl_from_IHTMLElement(iface);
1680 TRACE("(%p)->(%p)\n", This, p);
1682 return elem_string_attr_getter(This, L"language", TRUE, p);
1685 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1687 HTMLElement *This = impl_from_IHTMLElement(iface);
1689 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1691 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1694 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1696 HTMLElement *This = impl_from_IHTMLElement(iface);
1698 TRACE("(%p)->(%p)\n", This, p);
1700 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1703 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1705 HTMLElement *This = impl_from_IHTMLElement(iface);
1706 cpp_bool start = TRUE;
1707 nsresult nsres;
1709 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1711 switch(V_VT(&varargStart)) {
1712 case VT_EMPTY:
1713 case VT_ERROR:
1714 break;
1715 case VT_BOOL:
1716 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1717 break;
1718 default:
1719 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1722 if(!This->html_element) {
1723 FIXME("non-HTML elements\n");
1724 return E_NOTIMPL;
1727 nsres = nsIDOMHTMLElement_ScrollIntoView(This->html_element, start, 1);
1728 assert(nsres == NS_OK);
1730 return S_OK;
1733 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1734 VARIANT_BOOL *pfResult)
1736 HTMLElement *This = impl_from_IHTMLElement(iface);
1737 cpp_bool result = FALSE;
1739 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1741 if(pChild) {
1742 HTMLElement *child;
1743 nsresult nsres;
1745 child = unsafe_impl_from_IHTMLElement(pChild);
1746 if(!child) {
1747 ERR("not our element\n");
1748 return E_FAIL;
1751 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1752 assert(nsres == NS_OK);
1755 *pfResult = variant_bool(result);
1756 return S_OK;
1759 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1761 HTMLElement *This = impl_from_IHTMLElement(iface);
1763 TRACE("(%p)->(%p)\n", This, p);
1765 return get_elem_source_index(This, p);
1768 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1770 HTMLElement *This = impl_from_IHTMLElement(iface);
1771 FIXME("(%p)->(%p)\n", This, p);
1772 return E_NOTIMPL;
1775 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1777 HTMLElement *This = impl_from_IHTMLElement(iface);
1778 nsAString nsstr;
1779 nsresult nsres;
1781 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1783 if(!This->html_element) {
1784 FIXME("non-HTML element\n");
1785 return E_NOTIMPL;
1788 nsAString_InitDepend(&nsstr, v);
1789 nsres = nsIDOMHTMLElement_SetLang(This->html_element, &nsstr);
1790 nsAString_Finish(&nsstr);
1791 if(NS_FAILED(nsres)) {
1792 ERR("SetLang failed: %08x\n", nsres);
1793 return E_FAIL;
1796 return S_OK;
1799 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
1801 HTMLElement *This = impl_from_IHTMLElement(iface);
1802 nsAString nsstr;
1803 nsresult nsres;
1805 TRACE("(%p)->(%p)\n", This, p);
1807 if(!This->html_element) {
1808 FIXME("non-HTML element\n");
1809 return E_NOTIMPL;
1812 nsAString_Init(&nsstr, NULL);
1813 nsres = nsIDOMHTMLElement_GetLang(This->html_element, &nsstr);
1814 return return_nsstr(nsres, &nsstr, p);
1817 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
1819 HTMLElement *This = impl_from_IHTMLElement(iface);
1820 nsresult nsres;
1822 TRACE("(%p)->(%p)\n", This, p);
1824 if(!This->html_element) {
1825 FIXME("non-HTML element\n");
1826 return E_NOTIMPL;
1829 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->html_element, p);
1830 if(NS_FAILED(nsres)) {
1831 ERR("GetOffsetLeft failed: %08x\n", nsres);
1832 return E_FAIL;
1835 return S_OK;
1838 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
1840 HTMLElement *This = impl_from_IHTMLElement(iface);
1841 nsresult nsres;
1843 TRACE("(%p)->(%p)\n", This, p);
1845 if(!This->html_element) {
1846 FIXME("non-HTML element\n");
1847 return E_NOTIMPL;
1850 nsres = nsIDOMHTMLElement_GetOffsetTop(This->html_element, p);
1851 if(NS_FAILED(nsres)) {
1852 ERR("GetOffsetTop failed: %08x\n", nsres);
1853 return E_FAIL;
1856 return S_OK;
1859 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
1861 HTMLElement *This = impl_from_IHTMLElement(iface);
1862 nsresult nsres;
1864 TRACE("(%p)->(%p)\n", This, p);
1866 if(!This->html_element) {
1867 FIXME("non-HTML element\n");
1868 return E_NOTIMPL;
1871 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->html_element, p);
1872 if(NS_FAILED(nsres)) {
1873 ERR("GetOffsetWidth failed: %08x\n", nsres);
1874 return E_FAIL;
1877 return S_OK;
1880 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
1882 HTMLElement *This = impl_from_IHTMLElement(iface);
1883 nsresult nsres;
1885 TRACE("(%p)->(%p)\n", This, p);
1887 if(!This->html_element) {
1888 FIXME("non-HTML element\n");
1889 return E_NOTIMPL;
1892 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->html_element, p);
1893 if(NS_FAILED(nsres)) {
1894 ERR("GetOffsetHeight failed: %08x\n", nsres);
1895 return E_FAIL;
1898 return S_OK;
1901 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
1903 HTMLElement *This = impl_from_IHTMLElement(iface);
1904 nsIDOMElement *nsparent;
1905 HTMLElement *parent;
1906 nsresult nsres;
1907 HRESULT hres;
1909 TRACE("(%p)->(%p)\n", This, p);
1911 if(!This->html_element) {
1912 FIXME("non-HTML element\n");
1913 return E_NOTIMPL;
1916 nsres = nsIDOMHTMLElement_GetOffsetParent(This->html_element, &nsparent);
1917 if(NS_FAILED(nsres)) {
1918 ERR("GetOffsetParent failed: %08x\n", nsres);
1919 return E_FAIL;
1922 if(!nsparent) {
1923 *p = NULL;
1924 return S_OK;
1927 hres = get_element(nsparent, &parent);
1928 nsIDOMElement_Release(nsparent);
1929 if(FAILED(hres))
1930 return hres;
1932 *p = &parent->IHTMLElement_iface;
1933 return S_OK;
1936 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1938 HTMLElement *This = impl_from_IHTMLElement(iface);
1939 nsAString html_str;
1940 nsresult nsres;
1942 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1944 if(!This->html_element) {
1945 FIXME("non-HTML element\n");
1946 return E_NOTIMPL;
1949 nsAString_InitDepend(&html_str, v);
1950 nsres = nsIDOMHTMLElement_SetInnerHTML(This->html_element, &html_str);
1951 nsAString_Finish(&html_str);
1952 if(NS_FAILED(nsres)) {
1953 FIXME("SetInnerHtml failed %08x\n", nsres);
1954 return E_FAIL;
1957 return S_OK;
1960 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1962 HTMLElement *This = impl_from_IHTMLElement(iface);
1963 nsAString html_str;
1964 nsresult nsres;
1966 TRACE("(%p)->(%p)\n", This, p);
1968 if(!This->html_element) {
1969 FIXME("non-HTML element\n");
1970 return E_NOTIMPL;
1973 nsAString_Init(&html_str, NULL);
1974 nsres = nsIDOMHTMLElement_GetInnerHTML(This->html_element, &html_str);
1975 return return_nsstr(nsres, &html_str, p);
1978 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1980 HTMLElement *This = impl_from_IHTMLElement(iface);
1981 nsIDOMNode *nschild, *tmp;
1982 nsIDOMText *text_node;
1983 nsAString text_str;
1984 nsresult nsres;
1986 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1988 while(1) {
1989 nsres = nsIDOMElement_GetLastChild(This->dom_element, &nschild);
1990 if(NS_FAILED(nsres)) {
1991 ERR("GetLastChild failed: %08x\n", nsres);
1992 return E_FAIL;
1994 if(!nschild)
1995 break;
1997 nsres = nsIDOMElement_RemoveChild(This->dom_element, nschild, &tmp);
1998 nsIDOMNode_Release(nschild);
1999 if(NS_FAILED(nsres)) {
2000 ERR("RemoveChild failed: %08x\n", nsres);
2001 return E_FAIL;
2003 nsIDOMNode_Release(tmp);
2006 nsAString_InitDepend(&text_str, v);
2007 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
2008 nsAString_Finish(&text_str);
2009 if(NS_FAILED(nsres)) {
2010 ERR("CreateTextNode failed: %08x\n", nsres);
2011 return E_FAIL;
2014 nsres = nsIDOMElement_AppendChild(This->dom_element, (nsIDOMNode*)text_node, &tmp);
2015 if(NS_FAILED(nsres)) {
2016 ERR("AppendChild failed: %08x\n", nsres);
2017 return E_FAIL;
2020 nsIDOMNode_Release(tmp);
2021 return S_OK;
2024 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
2026 HTMLElement *This = impl_from_IHTMLElement(iface);
2028 TRACE("(%p)->(%p)\n", This, p);
2030 return get_node_text(&This->node, p);
2033 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
2035 HTMLElement *This = impl_from_IHTMLElement(iface);
2037 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2039 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
2042 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
2044 HTMLElement *This = impl_from_IHTMLElement(iface);
2045 nsAString html_str;
2046 HRESULT hres;
2048 WARN("(%p)->(%p) semi-stub\n", This, p);
2050 nsAString_Init(&html_str, NULL);
2051 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
2052 if(SUCCEEDED(hres)) {
2053 const PRUnichar *html;
2055 nsAString_GetData(&html_str, &html);
2056 *p = SysAllocString(html);
2057 if(!*p)
2058 hres = E_OUTOFMEMORY;
2061 nsAString_Finish(&html_str);
2063 TRACE("ret %s\n", debugstr_w(*p));
2064 return hres;
2067 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
2069 HTMLElement *This = impl_from_IHTMLElement(iface);
2070 nsIDOMText *text_node;
2071 nsIDOMRange *range;
2072 nsAString nsstr;
2073 nsresult nsres;
2075 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2077 if(This->node.vtbl->is_settable && !This->node.vtbl->is_settable(&This->node, DISPID_IHTMLELEMENT_OUTERTEXT)) {
2078 WARN("Called on element that does not support setting the property.\n");
2079 return 0x800a0258; /* undocumented error code */
2082 if(!This->node.doc->nsdoc) {
2083 FIXME("NULL nsdoc\n");
2084 return E_FAIL;
2087 nsAString_InitDepend(&nsstr, v);
2088 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &nsstr, &text_node);
2089 nsAString_Finish(&nsstr);
2090 if(NS_FAILED(nsres)) {
2091 ERR("CreateTextNode failed\n");
2092 return E_FAIL;
2095 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
2096 if(NS_SUCCEEDED(nsres)) {
2097 nsres = nsIDOMRange_SelectNode(range, This->node.nsnode);
2098 if(NS_SUCCEEDED(nsres))
2099 nsres = nsIDOMRange_DeleteContents(range);
2100 if(NS_SUCCEEDED(nsres))
2101 nsres = nsIDOMRange_InsertNode(range, (nsIDOMNode*)text_node);
2102 if(NS_SUCCEEDED(nsres))
2103 nsres = nsIDOMRange_SelectNodeContents(range, This->node.nsnode);
2104 if(NS_SUCCEEDED(nsres))
2105 nsres = nsIDOMRange_DeleteContents(range);
2106 nsIDOMRange_Release(range);
2108 nsIDOMText_Release(text_node);
2109 if(NS_FAILED(nsres)) {
2110 ERR("failed to set text: %08x\n", nsres);
2111 return E_FAIL;
2114 return S_OK;
2117 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
2119 HTMLElement *This = impl_from_IHTMLElement(iface);
2121 TRACE("(%p)->(%p)\n", This, p);
2123 /* getter is the same as innerText */
2124 return IHTMLElement_get_innerText(&This->IHTMLElement_iface, p);
2127 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
2129 nsIDOMNode *ret_nsnode;
2130 nsresult nsres;
2131 HRESULT hres = S_OK;
2133 if (!wcsicmp(where, L"beforebegin")) {
2134 nsIDOMNode *parent;
2136 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2137 if(NS_FAILED(nsres))
2138 return E_FAIL;
2140 if(!parent)
2141 return E_INVALIDARG;
2143 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
2144 nsIDOMNode_Release(parent);
2145 }else if(!wcsicmp(where, L"afterbegin")) {
2146 nsIDOMNode *first_child;
2148 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
2149 if(NS_FAILED(nsres))
2150 return E_FAIL;
2152 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
2153 if(NS_FAILED(nsres))
2154 return E_FAIL;
2156 if (first_child)
2157 nsIDOMNode_Release(first_child);
2158 }else if (!wcsicmp(where, L"beforeend")) {
2159 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
2160 }else if (!wcsicmp(where, L"afterend")) {
2161 nsIDOMNode *next_sibling, *parent;
2163 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
2164 if(NS_FAILED(nsres))
2165 return E_FAIL;
2166 if(!parent)
2167 return E_INVALIDARG;
2169 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
2170 if(NS_SUCCEEDED(nsres)) {
2171 if(next_sibling) {
2172 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
2173 nsIDOMNode_Release(next_sibling);
2174 }else {
2175 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
2179 nsIDOMNode_Release(parent);
2180 }else {
2181 ERR("invalid where: %s\n", debugstr_w(where));
2182 return E_INVALIDARG;
2185 if (NS_FAILED(nsres))
2186 return E_FAIL;
2188 if(ret_node)
2189 hres = get_node(ret_nsnode, TRUE, ret_node);
2190 nsIDOMNode_Release(ret_nsnode);
2191 return hres;
2194 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
2195 BSTR html)
2197 HTMLElement *This = impl_from_IHTMLElement(iface);
2198 nsIDOMRange *range;
2199 nsIDOMNode *nsnode;
2200 nsAString ns_html;
2201 nsresult nsres;
2202 HRESULT hr;
2204 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
2206 if(!This->node.doc->nsdoc) {
2207 WARN("NULL nsdoc\n");
2208 return E_UNEXPECTED;
2211 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
2212 if(NS_FAILED(nsres))
2214 ERR("CreateRange failed: %08x\n", nsres);
2215 return E_FAIL;
2218 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
2220 nsAString_InitDepend(&ns_html, html);
2221 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
2222 nsAString_Finish(&ns_html);
2223 nsIDOMRange_Release(range);
2225 if(NS_FAILED(nsres) || !nsnode)
2227 ERR("CreateTextNode failed: %08x\n", nsres);
2228 return E_FAIL;
2231 hr = insert_adjacent_node(This, where, nsnode, NULL);
2232 nsIDOMNode_Release(nsnode);
2233 return hr;
2236 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
2237 BSTR text)
2239 HTMLElement *This = impl_from_IHTMLElement(iface);
2240 nsIDOMNode *nsnode;
2241 nsAString ns_text;
2242 nsresult nsres;
2243 HRESULT hr;
2245 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
2247 if(!This->node.doc->nsdoc) {
2248 WARN("NULL nsdoc\n");
2249 return E_UNEXPECTED;
2253 nsAString_InitDepend(&ns_text, text);
2254 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
2255 nsAString_Finish(&ns_text);
2257 if(NS_FAILED(nsres) || !nsnode)
2259 ERR("CreateTextNode failed: %08x\n", nsres);
2260 return E_FAIL;
2263 hr = insert_adjacent_node(This, where, nsnode, NULL);
2264 nsIDOMNode_Release(nsnode);
2266 return hr;
2269 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
2271 HTMLElement *This = impl_from_IHTMLElement(iface);
2272 FIXME("(%p)->(%p)\n", This, p);
2273 return E_NOTIMPL;
2276 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
2278 HTMLElement *This = impl_from_IHTMLElement(iface);
2280 TRACE("(%p)->(%p)\n", This, p);
2282 *p = variant_bool(This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node));
2283 return S_OK;
2286 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
2288 HTMLElement *This = impl_from_IHTMLElement(iface);
2289 nsresult nsres;
2291 TRACE("(%p)\n", This);
2293 if(!This->html_element) {
2294 FIXME("non-HTML element\n");
2295 return E_NOTIMPL;
2298 nsres = nsIDOMHTMLElement_Click(This->html_element);
2299 if(NS_FAILED(nsres)) {
2300 ERR("Click failed: %08x\n", nsres);
2301 return E_FAIL;
2304 return S_OK;
2307 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface, IHTMLFiltersCollection **p)
2309 HTMLElement *This = impl_from_IHTMLElement(iface);
2311 TRACE("(%p)->(%p)\n", This, p);
2313 if(!p)
2314 return E_POINTER;
2316 return create_filters_collection(dispex_compat_mode(&This->node.event_target.dispex), p);
2319 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
2321 HTMLElement *This = impl_from_IHTMLElement(iface);
2323 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2325 return set_node_event(&This->node, EVENTID_DRAGSTART, &v);
2328 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
2330 HTMLElement *This = impl_from_IHTMLElement(iface);
2332 TRACE("(%p)->(%p)\n", This, p);
2334 return get_node_event(&This->node, EVENTID_DRAGSTART, p);
2337 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
2339 HTMLElement *This = impl_from_IHTMLElement(iface);
2340 HRESULT hres;
2341 VARIANT var;
2343 TRACE("(%p)->(%p)\n", This, String);
2345 if(!String)
2346 return E_INVALIDARG;
2348 hres = IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, DISPID_VALUE,
2349 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, NULL, &var, NULL, NULL);
2350 if(SUCCEEDED(hres)) {
2351 assert(V_VT(&var) == VT_BSTR);
2352 *String = V_BSTR(&var);
2354 return hres;
2357 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
2359 HTMLElement *This = impl_from_IHTMLElement(iface);
2360 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2361 return E_NOTIMPL;
2364 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
2366 HTMLElement *This = impl_from_IHTMLElement(iface);
2367 FIXME("(%p)->(%p)\n", This, p);
2368 return E_NOTIMPL;
2371 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
2373 HTMLElement *This = impl_from_IHTMLElement(iface);
2374 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2375 return E_NOTIMPL;
2378 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
2380 HTMLElement *This = impl_from_IHTMLElement(iface);
2381 FIXME("(%p)->(%p)\n", This, p);
2382 return E_NOTIMPL;
2385 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
2387 HTMLElement *This = impl_from_IHTMLElement(iface);
2388 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2389 return E_NOTIMPL;
2392 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
2394 HTMLElement *This = impl_from_IHTMLElement(iface);
2395 FIXME("(%p)->(%p)\n", This, p);
2396 return E_NOTIMPL;
2399 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
2401 HTMLElement *This = impl_from_IHTMLElement(iface);
2402 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2403 return E_NOTIMPL;
2406 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
2408 HTMLElement *This = impl_from_IHTMLElement(iface);
2409 FIXME("(%p)->(%p)\n", This, p);
2410 return E_NOTIMPL;
2413 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
2415 HTMLElement *This = impl_from_IHTMLElement(iface);
2416 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2417 return E_NOTIMPL;
2420 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
2422 HTMLElement *This = impl_from_IHTMLElement(iface);
2423 FIXME("(%p)->(%p)\n", This, p);
2424 return E_NOTIMPL;
2427 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
2429 HTMLElement *This = impl_from_IHTMLElement(iface);
2430 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2431 return E_NOTIMPL;
2434 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
2436 HTMLElement *This = impl_from_IHTMLElement(iface);
2437 FIXME("(%p)->(%p)\n", This, p);
2438 return E_NOTIMPL;
2441 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
2443 HTMLElement *This = impl_from_IHTMLElement(iface);
2445 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
2447 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
2450 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
2452 HTMLElement *This = impl_from_IHTMLElement(iface);
2454 TRACE("(%p)->(%p)\n", This, p);
2456 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
2459 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
2461 HTMLElement *This = impl_from_IHTMLElement(iface);
2462 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2463 return E_NOTIMPL;
2466 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
2468 HTMLElement *This = impl_from_IHTMLElement(iface);
2469 FIXME("(%p)->(%p)\n", This, p);
2470 return E_NOTIMPL;
2473 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
2475 HTMLElement *This = impl_from_IHTMLElement(iface);
2476 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2477 return E_NOTIMPL;
2480 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
2482 HTMLElement *This = impl_from_IHTMLElement(iface);
2483 FIXME("(%p)->(%p)\n", This, p);
2484 return E_NOTIMPL;
2487 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
2489 HTMLElement *This = impl_from_IHTMLElement(iface);
2490 nsIDOMNodeList *nsnode_list;
2491 nsresult nsres;
2493 TRACE("(%p)->(%p)\n", This, p);
2495 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
2496 if(NS_FAILED(nsres)) {
2497 ERR("GetChildNodes failed: %08x\n", nsres);
2498 return E_FAIL;
2501 *p = (IDispatch*)create_collection_from_nodelist(nsnode_list, This->node.doc->document_mode);
2503 nsIDOMNodeList_Release(nsnode_list);
2504 return S_OK;
2507 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
2509 HTMLElement *This = impl_from_IHTMLElement(iface);
2511 TRACE("(%p)->(%p)\n", This, p);
2513 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
2514 return S_OK;
2517 static const IHTMLElementVtbl HTMLElementVtbl = {
2518 HTMLElement_QueryInterface,
2519 HTMLElement_AddRef,
2520 HTMLElement_Release,
2521 HTMLElement_GetTypeInfoCount,
2522 HTMLElement_GetTypeInfo,
2523 HTMLElement_GetIDsOfNames,
2524 HTMLElement_Invoke,
2525 HTMLElement_setAttribute,
2526 HTMLElement_getAttribute,
2527 HTMLElement_removeAttribute,
2528 HTMLElement_put_className,
2529 HTMLElement_get_className,
2530 HTMLElement_put_id,
2531 HTMLElement_get_id,
2532 HTMLElement_get_tagName,
2533 HTMLElement_get_parentElement,
2534 HTMLElement_get_style,
2535 HTMLElement_put_onhelp,
2536 HTMLElement_get_onhelp,
2537 HTMLElement_put_onclick,
2538 HTMLElement_get_onclick,
2539 HTMLElement_put_ondblclick,
2540 HTMLElement_get_ondblclick,
2541 HTMLElement_put_onkeydown,
2542 HTMLElement_get_onkeydown,
2543 HTMLElement_put_onkeyup,
2544 HTMLElement_get_onkeyup,
2545 HTMLElement_put_onkeypress,
2546 HTMLElement_get_onkeypress,
2547 HTMLElement_put_onmouseout,
2548 HTMLElement_get_onmouseout,
2549 HTMLElement_put_onmouseover,
2550 HTMLElement_get_onmouseover,
2551 HTMLElement_put_onmousemove,
2552 HTMLElement_get_onmousemove,
2553 HTMLElement_put_onmousedown,
2554 HTMLElement_get_onmousedown,
2555 HTMLElement_put_onmouseup,
2556 HTMLElement_get_onmouseup,
2557 HTMLElement_get_document,
2558 HTMLElement_put_title,
2559 HTMLElement_get_title,
2560 HTMLElement_put_language,
2561 HTMLElement_get_language,
2562 HTMLElement_put_onselectstart,
2563 HTMLElement_get_onselectstart,
2564 HTMLElement_scrollIntoView,
2565 HTMLElement_contains,
2566 HTMLElement_get_sourceIndex,
2567 HTMLElement_get_recordNumber,
2568 HTMLElement_put_lang,
2569 HTMLElement_get_lang,
2570 HTMLElement_get_offsetLeft,
2571 HTMLElement_get_offsetTop,
2572 HTMLElement_get_offsetWidth,
2573 HTMLElement_get_offsetHeight,
2574 HTMLElement_get_offsetParent,
2575 HTMLElement_put_innerHTML,
2576 HTMLElement_get_innerHTML,
2577 HTMLElement_put_innerText,
2578 HTMLElement_get_innerText,
2579 HTMLElement_put_outerHTML,
2580 HTMLElement_get_outerHTML,
2581 HTMLElement_put_outerText,
2582 HTMLElement_get_outerText,
2583 HTMLElement_insertAdjacentHTML,
2584 HTMLElement_insertAdjacentText,
2585 HTMLElement_get_parentTextEdit,
2586 HTMLElement_get_isTextEdit,
2587 HTMLElement_click,
2588 HTMLElement_get_filters,
2589 HTMLElement_put_ondragstart,
2590 HTMLElement_get_ondragstart,
2591 HTMLElement_toString,
2592 HTMLElement_put_onbeforeupdate,
2593 HTMLElement_get_onbeforeupdate,
2594 HTMLElement_put_onafterupdate,
2595 HTMLElement_get_onafterupdate,
2596 HTMLElement_put_onerrorupdate,
2597 HTMLElement_get_onerrorupdate,
2598 HTMLElement_put_onrowexit,
2599 HTMLElement_get_onrowexit,
2600 HTMLElement_put_onrowenter,
2601 HTMLElement_get_onrowenter,
2602 HTMLElement_put_ondatasetchanged,
2603 HTMLElement_get_ondatasetchanged,
2604 HTMLElement_put_ondataavailable,
2605 HTMLElement_get_ondataavailable,
2606 HTMLElement_put_ondatasetcomplete,
2607 HTMLElement_get_ondatasetcomplete,
2608 HTMLElement_put_onfilterchange,
2609 HTMLElement_get_onfilterchange,
2610 HTMLElement_get_children,
2611 HTMLElement_get_all
2614 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2616 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2619 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2621 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2624 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
2625 REFIID riid, void **ppv)
2627 HTMLElement *This = impl_from_IHTMLElement2(iface);
2628 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2631 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2633 HTMLElement *This = impl_from_IHTMLElement2(iface);
2634 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2637 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2639 HTMLElement *This = impl_from_IHTMLElement2(iface);
2640 return IHTMLElement_Release(&This->IHTMLElement_iface);
2643 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2645 HTMLElement *This = impl_from_IHTMLElement2(iface);
2646 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2649 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2650 LCID lcid, ITypeInfo **ppTInfo)
2652 HTMLElement *This = impl_from_IHTMLElement2(iface);
2653 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2656 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2657 LPOLESTR *rgszNames, UINT cNames,
2658 LCID lcid, DISPID *rgDispId)
2660 HTMLElement *This = impl_from_IHTMLElement2(iface);
2661 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2662 lcid, rgDispId);
2665 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2666 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2667 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2669 HTMLElement *This = impl_from_IHTMLElement2(iface);
2670 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2671 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2674 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2676 HTMLElement *This = impl_from_IHTMLElement2(iface);
2677 FIXME("(%p)->(%p)\n", This, p);
2678 return E_NOTIMPL;
2681 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2683 HTMLElement *This = impl_from_IHTMLElement2(iface);
2684 FIXME("(%p)->(%x)\n", This, containerCapture);
2685 return E_NOTIMPL;
2688 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2690 HTMLElement *This = impl_from_IHTMLElement2(iface);
2691 FIXME("(%p)\n", This);
2692 return E_NOTIMPL;
2695 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2697 HTMLElement *This = impl_from_IHTMLElement2(iface);
2698 FIXME("(%p)->()\n", This);
2699 return E_NOTIMPL;
2702 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2704 HTMLElement *This = impl_from_IHTMLElement2(iface);
2705 FIXME("(%p)->(%p)\n", This, p);
2706 return E_NOTIMPL;
2709 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2710 LONG x, LONG y, BSTR *component)
2712 HTMLElement *This = impl_from_IHTMLElement2(iface);
2713 FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
2714 return E_NOTIMPL;
2717 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2719 HTMLElement *This = impl_from_IHTMLElement2(iface);
2721 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2723 if(!This->node.doc->content_ready
2724 || !This->node.doc->basedoc.doc_obj->in_place_active)
2725 return E_PENDING;
2727 WARN("stub\n");
2728 return S_OK;
2731 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2733 HTMLElement *This = impl_from_IHTMLElement2(iface);
2735 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2737 return set_node_event(&This->node, EVENTID_SCROLL, &v);
2740 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2742 HTMLElement *This = impl_from_IHTMLElement2(iface);
2744 TRACE("(%p)->(%p)\n", This, p);
2746 return get_node_event(&This->node, EVENTID_SCROLL, p);
2749 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2751 HTMLElement *This = impl_from_IHTMLElement2(iface);
2753 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2755 return set_node_event(&This->node, EVENTID_DRAG, &v);
2758 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2760 HTMLElement *This = impl_from_IHTMLElement2(iface);
2762 TRACE("(%p)->(%p)\n", This, p);
2764 return get_node_event(&This->node, EVENTID_DRAG, p);
2767 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2769 HTMLElement *This = impl_from_IHTMLElement2(iface);
2770 FIXME("(%p)->()\n", This);
2771 return E_NOTIMPL;
2774 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2776 HTMLElement *This = impl_from_IHTMLElement2(iface);
2777 FIXME("(%p)->(%p)\n", This, p);
2778 return E_NOTIMPL;
2781 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2783 HTMLElement *This = impl_from_IHTMLElement2(iface);
2784 FIXME("(%p)->()\n", This);
2785 return E_NOTIMPL;
2788 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2790 HTMLElement *This = impl_from_IHTMLElement2(iface);
2791 FIXME("(%p)->(%p)\n", This, p);
2792 return E_NOTIMPL;
2795 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2797 HTMLElement *This = impl_from_IHTMLElement2(iface);
2798 FIXME("(%p)->()\n", This);
2799 return E_NOTIMPL;
2802 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2804 HTMLElement *This = impl_from_IHTMLElement2(iface);
2805 FIXME("(%p)->(%p)\n", This, p);
2806 return E_NOTIMPL;
2809 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2811 HTMLElement *This = impl_from_IHTMLElement2(iface);
2812 FIXME("(%p)->()\n", This);
2813 return E_NOTIMPL;
2816 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2818 HTMLElement *This = impl_from_IHTMLElement2(iface);
2819 FIXME("(%p)->(%p)\n", This, p);
2820 return E_NOTIMPL;
2823 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2825 HTMLElement *This = impl_from_IHTMLElement2(iface);
2826 FIXME("(%p)->()\n", This);
2827 return E_NOTIMPL;
2830 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2832 HTMLElement *This = impl_from_IHTMLElement2(iface);
2833 FIXME("(%p)->(%p)\n", This, p);
2834 return E_NOTIMPL;
2837 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2839 HTMLElement *This = impl_from_IHTMLElement2(iface);
2840 FIXME("(%p)->()\n", This);
2841 return E_NOTIMPL;
2844 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2846 HTMLElement *This = impl_from_IHTMLElement2(iface);
2847 FIXME("(%p)->(%p)\n", This, p);
2848 return E_NOTIMPL;
2851 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2853 HTMLElement *This = impl_from_IHTMLElement2(iface);
2854 FIXME("(%p)->()\n", This);
2855 return E_NOTIMPL;
2858 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2860 HTMLElement *This = impl_from_IHTMLElement2(iface);
2861 FIXME("(%p)->(%p)\n", This, p);
2862 return E_NOTIMPL;
2865 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2867 HTMLElement *This = impl_from_IHTMLElement2(iface);
2868 FIXME("(%p)->()\n", This);
2869 return E_NOTIMPL;
2872 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2874 HTMLElement *This = impl_from_IHTMLElement2(iface);
2875 FIXME("(%p)->(%p)\n", This, p);
2876 return E_NOTIMPL;
2879 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2881 HTMLElement *This = impl_from_IHTMLElement2(iface);
2882 FIXME("(%p)->()\n", This);
2883 return E_NOTIMPL;
2886 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2888 HTMLElement *This = impl_from_IHTMLElement2(iface);
2889 FIXME("(%p)->(%p)\n", This, p);
2890 return E_NOTIMPL;
2893 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2895 HTMLElement *This = impl_from_IHTMLElement2(iface);
2896 FIXME("(%p)->()\n", This);
2897 return E_NOTIMPL;
2900 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2902 HTMLElement *This = impl_from_IHTMLElement2(iface);
2903 FIXME("(%p)->(%p)\n", This, p);
2904 return E_NOTIMPL;
2907 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2909 HTMLElement *This = impl_from_IHTMLElement2(iface);
2911 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2913 return set_node_event(&This->node, EVENTID_PASTE, &v);
2916 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
2918 HTMLElement *This = impl_from_IHTMLElement2(iface);
2920 TRACE("(%p)->(%p)\n", This, p);
2922 return get_node_event(&This->node, EVENTID_PASTE, p);
2925 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
2927 HTMLElement *This = impl_from_IHTMLElement2(iface);
2929 TRACE("(%p)->(%p)\n", This, p);
2931 return HTMLCurrentStyle_Create(This, p);
2934 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
2936 HTMLElement *This = impl_from_IHTMLElement2(iface);
2937 FIXME("(%p)->()\n", This);
2938 return E_NOTIMPL;
2941 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
2943 HTMLElement *This = impl_from_IHTMLElement2(iface);
2944 FIXME("(%p)->(%p)\n", This, p);
2945 return E_NOTIMPL;
2948 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
2950 HTMLElement *This = impl_from_IHTMLElement2(iface);
2951 nsIDOMClientRectList *rect_list;
2952 HTMLRectCollection *rects;
2953 nsresult nsres;
2955 TRACE("(%p)->(%p)\n", This, pRectCol);
2957 if(!This->dom_element) {
2958 FIXME("comment element\n");
2959 return E_NOTIMPL;
2962 nsres = nsIDOMElement_GetClientRects(This->dom_element, &rect_list);
2963 if(NS_FAILED(nsres)) {
2964 WARN("GetClientRects failed: %08x\n", nsres);
2965 return map_nsresult(nsres);
2968 rects = heap_alloc_zero(sizeof(*rects));
2969 if(!rects) {
2970 nsIDOMClientRectList_Release(rect_list);
2971 return E_OUTOFMEMORY;
2974 rects->IHTMLRectCollection_iface.lpVtbl = &HTMLRectCollectionVtbl;
2975 rects->ref = 1;
2976 rects->rect_list = rect_list;
2977 init_dispatch(&rects->dispex, (IUnknown*)&rects->IHTMLRectCollection_iface,
2978 &HTMLRectCollection_dispex, dispex_compat_mode(&This->node.event_target.dispex));
2980 *pRectCol = &rects->IHTMLRectCollection_iface;
2981 return S_OK;
2984 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
2986 HTMLElement *This = impl_from_IHTMLElement2(iface);
2987 nsIDOMClientRect *nsrect;
2988 nsresult nsres;
2989 HRESULT hres;
2991 TRACE("(%p)->(%p)\n", This, pRect);
2993 if(!This->dom_element) {
2994 FIXME("comment element\n");
2995 return E_NOTIMPL;
2998 nsres = nsIDOMElement_GetBoundingClientRect(This->dom_element, &nsrect);
2999 if(NS_FAILED(nsres) || !nsrect) {
3000 ERR("GetBoindingClientRect failed: %08x\n", nsres);
3001 return E_FAIL;
3004 hres = create_html_rect(nsrect, dispex_compat_mode(&This->node.event_target.dispex), pRect);
3006 nsIDOMClientRect_Release(nsrect);
3007 return hres;
3010 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
3011 BSTR expression, BSTR language)
3013 HTMLElement *This = impl_from_IHTMLElement2(iface);
3014 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
3015 debugstr_w(language));
3016 return E_NOTIMPL;
3019 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
3020 VARIANT *expression)
3022 HTMLElement *This = impl_from_IHTMLElement2(iface);
3023 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
3024 return E_NOTIMPL;
3027 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
3028 VARIANT_BOOL *pfSuccess)
3030 HTMLElement *This = impl_from_IHTMLElement2(iface);
3031 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
3032 return E_NOTIMPL;
3035 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
3037 HTMLElement *This = impl_from_IHTMLElement2(iface);
3038 nsresult nsres;
3040 TRACE("(%p)->(%d)\n", This, v);
3042 if(!This->html_element) {
3043 FIXME("non-HTML element\n");
3044 return E_NOTIMPL;
3047 nsres = nsIDOMHTMLElement_SetTabIndex(This->html_element, v);
3048 if(NS_FAILED(nsres))
3049 ERR("GetTabIndex failed: %08x\n", nsres);
3051 return S_OK;
3054 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
3056 HTMLElement *This = impl_from_IHTMLElement2(iface);
3057 LONG index;
3058 nsresult nsres;
3060 TRACE("(%p)->(%p)\n", This, p);
3062 if(!This->html_element) {
3063 FIXME("non-HTML element\n");
3064 return E_NOTIMPL;
3067 nsres = nsIDOMHTMLElement_GetTabIndex(This->html_element, &index);
3068 if(NS_FAILED(nsres)) {
3069 ERR("GetTabIndex failed: %08x\n", nsres);
3070 return E_FAIL;
3073 *p = index;
3074 return S_OK;
3077 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
3079 HTMLElement *This = impl_from_IHTMLElement2(iface);
3080 nsresult nsres;
3082 TRACE("(%p)\n", This);
3084 if(!This->html_element) {
3085 FIXME("non-HTML element\n");
3086 return E_NOTIMPL;
3089 nsres = nsIDOMHTMLElement_Focus(This->html_element);
3090 if(NS_FAILED(nsres))
3091 ERR("Focus failed: %08x\n", nsres);
3093 return S_OK;
3096 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
3098 HTMLElement *This = impl_from_IHTMLElement2(iface);
3099 nsAString nsstr;
3100 nsresult nsres;
3102 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3104 if(!This->html_element) {
3105 FIXME("non-HTML element\n");
3106 return E_NOTIMPL;
3109 nsAString_InitDepend(&nsstr, v);
3110 nsres = nsIDOMHTMLElement_SetAccessKey(This->html_element, &nsstr);
3111 nsAString_Finish(&nsstr);
3112 return map_nsresult(nsres);
3115 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
3117 HTMLElement *This = impl_from_IHTMLElement2(iface);
3118 nsAString nsstr;
3119 nsresult nsres;
3121 TRACE("(%p)->(%p)\n", This, p);
3123 if(!This->html_element) {
3124 FIXME("non-HTML element\n");
3125 return E_NOTIMPL;
3128 nsAString_InitDepend(&nsstr, NULL);
3129 nsres = nsIDOMHTMLElement_GetAccessKey(This->html_element, &nsstr);
3130 return return_nsstr(nsres, &nsstr, p);
3133 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
3135 HTMLElement *This = impl_from_IHTMLElement2(iface);
3137 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3139 return set_node_event(&This->node, EVENTID_BLUR, &v);
3142 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
3144 HTMLElement *This = impl_from_IHTMLElement2(iface);
3146 TRACE("(%p)->(%p)\n", This, p);
3148 return get_node_event(&This->node, EVENTID_BLUR, p);
3151 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
3153 HTMLElement *This = impl_from_IHTMLElement2(iface);
3155 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3157 return set_node_event(&This->node, EVENTID_FOCUS, &v);
3160 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
3162 HTMLElement *This = impl_from_IHTMLElement2(iface);
3164 TRACE("(%p)->(%p)\n", This, p);
3166 return get_node_event(&This->node, EVENTID_FOCUS, p);
3169 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
3171 HTMLElement *This = impl_from_IHTMLElement2(iface);
3173 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3175 return set_node_event(&This->node, EVENTID_RESIZE, &v);
3178 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
3180 HTMLElement *This = impl_from_IHTMLElement2(iface);
3182 TRACE("(%p)->(%p)\n", This, p);
3184 return get_node_event(&This->node, EVENTID_RESIZE, p);
3187 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
3189 HTMLElement *This = impl_from_IHTMLElement2(iface);
3190 nsresult nsres;
3192 TRACE("(%p)\n", This);
3194 if(!This->html_element) {
3195 FIXME("non-HTML element\n");
3196 return E_NOTIMPL;
3199 nsres = nsIDOMHTMLElement_Blur(This->html_element);
3200 if(NS_FAILED(nsres)) {
3201 ERR("Blur failed: %08x\n", nsres);
3202 return E_FAIL;
3205 return S_OK;
3208 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3210 HTMLElement *This = impl_from_IHTMLElement2(iface);
3211 FIXME("(%p)->(%p)\n", This, pUnk);
3212 return E_NOTIMPL;
3215 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
3217 HTMLElement *This = impl_from_IHTMLElement2(iface);
3218 FIXME("(%p)->(%p)\n", This, pUnk);
3219 return E_NOTIMPL;
3222 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
3224 HTMLElement *This = impl_from_IHTMLElement2(iface);
3225 nsresult nsres;
3227 TRACE("(%p)->(%p)\n", This, p);
3229 if(!This->dom_element) {
3230 FIXME("Unimplemented for comment element\n");
3231 return E_NOTIMPL;
3234 nsres = nsIDOMElement_GetClientHeight(This->dom_element, p);
3235 assert(nsres == NS_OK);
3236 return S_OK;
3239 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
3241 HTMLElement *This = impl_from_IHTMLElement2(iface);
3242 nsresult nsres;
3244 TRACE("(%p)->(%p)\n", This, p);
3246 if(!This->dom_element) {
3247 FIXME("comment element\n");
3248 return E_NOTIMPL;
3251 nsres = nsIDOMElement_GetClientWidth(This->dom_element, p);
3252 assert(nsres == NS_OK);
3253 return S_OK;
3256 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
3258 HTMLElement *This = impl_from_IHTMLElement2(iface);
3259 nsresult nsres;
3261 TRACE("(%p)->(%p)\n", This, p);
3263 if(!This->dom_element) {
3264 FIXME("comment element\n");
3265 return E_NOTIMPL;
3268 nsres = nsIDOMElement_GetClientTop(This->dom_element, p);
3269 assert(nsres == NS_OK);
3271 TRACE("*p = %d\n", *p);
3272 return S_OK;
3275 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
3277 HTMLElement *This = impl_from_IHTMLElement2(iface);
3278 nsresult nsres;
3280 TRACE("(%p)->(%p)\n", This, p);
3282 if(!This->dom_element) {
3283 FIXME("comment element\n");
3284 return E_NOTIMPL;
3287 nsres = nsIDOMElement_GetClientLeft(This->dom_element, p);
3288 assert(nsres == NS_OK);
3290 TRACE("*p = %d\n", *p);
3291 return S_OK;
3294 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
3295 IDispatch *pDisp, VARIANT_BOOL *pfResult)
3297 HTMLElement *This = impl_from_IHTMLElement2(iface);
3299 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
3301 return attach_event(&This->node.event_target, event, pDisp, pfResult);
3304 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
3306 HTMLElement *This = impl_from_IHTMLElement2(iface);
3308 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
3310 return detach_event(&This->node.event_target, event, pDisp);
3313 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
3315 HTMLElement *This = impl_from_IHTMLElement2(iface);
3316 BSTR str;
3318 TRACE("(%p)->(%p)\n", This, p);
3320 if(This->node.vtbl->get_readystate) {
3321 HRESULT hres;
3323 hres = This->node.vtbl->get_readystate(&This->node, &str);
3324 if(FAILED(hres))
3325 return hres;
3326 }else {
3327 str = SysAllocString(L"complete");
3328 if(!str)
3329 return E_OUTOFMEMORY;
3332 V_VT(p) = VT_BSTR;
3333 V_BSTR(p) = str;
3334 return S_OK;
3337 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
3339 HTMLElement *This = impl_from_IHTMLElement2(iface);
3341 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3343 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
3346 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
3348 HTMLElement *This = impl_from_IHTMLElement2(iface);
3350 TRACE("(%p)->(%p)\n", This, p);
3352 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
3355 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
3357 HTMLElement *This = impl_from_IHTMLElement2(iface);
3358 FIXME("(%p)->()\n", This);
3359 return E_NOTIMPL;
3362 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
3364 HTMLElement *This = impl_from_IHTMLElement2(iface);
3365 FIXME("(%p)->(%p)\n", This, p);
3366 return E_NOTIMPL;
3369 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
3371 HTMLElement *This = impl_from_IHTMLElement2(iface);
3372 FIXME("(%p)->()\n", This);
3373 return E_NOTIMPL;
3376 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
3378 HTMLElement *This = impl_from_IHTMLElement2(iface);
3379 FIXME("(%p)->(%p)\n", This, p);
3380 return E_NOTIMPL;
3383 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
3385 HTMLElement *This = impl_from_IHTMLElement2(iface);
3386 FIXME("(%p)->()\n", This);
3387 return E_NOTIMPL;
3390 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
3392 HTMLElement *This = impl_from_IHTMLElement2(iface);
3393 FIXME("(%p)->(%p)\n", This, p);
3394 return E_NOTIMPL;
3397 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
3399 HTMLElement *This = impl_from_IHTMLElement2(iface);
3400 nsAString nsstr;
3401 nsresult nsres;
3403 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3405 if(!This->html_element) {
3406 FIXME("non-HTML element\n");
3407 return S_OK;
3410 nsAString_InitDepend(&nsstr, v);
3411 nsres = nsIDOMHTMLElement_SetDir(This->html_element, &nsstr);
3412 nsAString_Finish(&nsstr);
3413 if(NS_FAILED(nsres)) {
3414 ERR("SetDir failed: %08x\n", nsres);
3415 return E_FAIL;
3418 return S_OK;
3421 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
3423 HTMLElement *This = impl_from_IHTMLElement2(iface);
3424 nsAString dir_str;
3425 nsresult nsres;
3427 TRACE("(%p)->(%p)\n", This, p);
3429 if(!This->html_element) {
3430 if(This->dom_element)
3431 FIXME("non-HTML element\n");
3432 *p = NULL;
3433 return S_OK;
3436 nsAString_Init(&dir_str, NULL);
3437 nsres = nsIDOMHTMLElement_GetDir(This->html_element, &dir_str);
3438 return return_nsstr(nsres, &dir_str, p);
3441 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
3443 HTMLElement *This = impl_from_IHTMLElement2(iface);
3444 FIXME("(%p)->(%p)\n", This, range);
3445 return E_NOTIMPL;
3448 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
3450 HTMLElement *This = impl_from_IHTMLElement2(iface);
3451 nsresult nsres;
3453 TRACE("(%p)->(%p)\n", This, p);
3455 if(!This->dom_element) {
3456 FIXME("comment element\n");
3457 return E_NOTIMPL;
3460 nsres = nsIDOMElement_GetScrollHeight(This->dom_element, p);
3461 assert(nsres == NS_OK);
3462 TRACE("*p = %d\n", *p);
3463 return S_OK;
3466 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
3468 HTMLElement *This = impl_from_IHTMLElement2(iface);
3469 nsresult nsres;
3471 TRACE("(%p)->(%p)\n", This, p);
3473 if(!This->dom_element) {
3474 FIXME("comment element\n");
3475 return E_NOTIMPL;
3478 nsres = nsIDOMElement_GetScrollWidth(This->dom_element, p);
3479 assert(nsres == NS_OK);
3481 TRACE("*p = %d\n", *p);
3482 return S_OK;
3485 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
3487 HTMLElement *This = impl_from_IHTMLElement2(iface);
3489 TRACE("(%p)->(%d)\n", This, v);
3491 if(!This->dom_element) {
3492 FIXME("comment element\n");
3493 return E_NOTIMPL;
3496 nsIDOMElement_SetScrollTop(This->dom_element, v);
3497 return S_OK;
3500 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
3502 HTMLElement *This = impl_from_IHTMLElement2(iface);
3503 nsresult nsres;
3505 TRACE("(%p)->(%p)\n", This, p);
3507 if(!This->dom_element) {
3508 FIXME("comment element\n");
3509 return E_NOTIMPL;
3512 nsres = nsIDOMElement_GetScrollTop(This->dom_element, p);
3513 assert(nsres == NS_OK);
3515 TRACE("*p = %d\n", *p);
3516 return S_OK;
3519 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
3521 HTMLElement *This = impl_from_IHTMLElement2(iface);
3523 TRACE("(%p)->(%d)\n", This, v);
3525 if(!This->dom_element) {
3526 FIXME("comment element\n");
3527 return E_NOTIMPL;
3530 nsIDOMElement_SetScrollLeft(This->dom_element, v);
3531 return S_OK;
3534 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
3536 HTMLElement *This = impl_from_IHTMLElement2(iface);
3537 nsresult nsres;
3539 TRACE("(%p)->(%p)\n", This, p);
3541 if(!p)
3542 return E_INVALIDARG;
3544 if(!This->dom_element) {
3545 FIXME("comment element\n");
3546 return E_NOTIMPL;
3549 nsres = nsIDOMElement_GetScrollLeft(This->dom_element, p);
3550 assert(nsres == NS_OK);
3551 TRACE("*p = %d\n", *p);
3552 return S_OK;
3555 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
3557 HTMLElement *This = impl_from_IHTMLElement2(iface);
3558 FIXME("(%p)\n", This);
3559 return E_NOTIMPL;
3562 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
3564 HTMLElement *This = impl_from_IHTMLElement2(iface);
3565 FIXME("(%p)->(%p)\n", This, mergeThis);
3566 return E_NOTIMPL;
3569 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
3571 HTMLElement *This = impl_from_IHTMLElement2(iface);
3573 TRACE("(%p)->()\n", This);
3575 return set_node_event(&This->node, EVENTID_CONTEXTMENU, &v);
3578 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
3580 HTMLElement *This = impl_from_IHTMLElement2(iface);
3582 TRACE("(%p)->(%p)\n", This, p);
3584 return get_node_event(&This->node, EVENTID_CONTEXTMENU, p);
3587 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
3588 IHTMLElement *insertedElement, IHTMLElement **inserted)
3590 HTMLElement *This = impl_from_IHTMLElement2(iface);
3591 HTMLDOMNode *ret_node;
3592 HTMLElement *elem;
3593 HRESULT hres;
3595 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
3597 elem = unsafe_impl_from_IHTMLElement(insertedElement);
3598 if(!elem)
3599 return E_INVALIDARG;
3601 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
3602 if(FAILED(hres))
3603 return hres;
3605 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
3606 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
3607 return hres;
3610 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
3611 BSTR where, IHTMLElement **applied)
3613 HTMLElement *This = impl_from_IHTMLElement2(iface);
3614 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
3615 return E_NOTIMPL;
3618 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
3620 HTMLElement *This = impl_from_IHTMLElement2(iface);
3621 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
3622 return E_NOTIMPL;
3625 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
3626 BSTR newText, BSTR *oldText)
3628 HTMLElement *This = impl_from_IHTMLElement2(iface);
3629 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
3630 return E_NOTIMPL;
3633 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
3635 HTMLElement *This = impl_from_IHTMLElement2(iface);
3636 FIXME("(%p)->(%p)\n", This, p);
3637 return E_NOTIMPL;
3640 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
3641 VARIANT *pvarFactory, LONG *pCookie)
3643 HTMLElement *This = impl_from_IHTMLElement2(iface);
3644 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
3645 return E_NOTIMPL;
3648 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
3649 VARIANT_BOOL *pfResult)
3651 HTMLElement *This = impl_from_IHTMLElement2(iface);
3652 FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
3653 return E_NOTIMPL;
3656 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
3658 HTMLElement *This = impl_from_IHTMLElement2(iface);
3660 FIXME("(%p)->(%p): hack\n", This, p);
3662 /* We can't implement correct behavior on top of Gecko (although we could
3663 try a bit harder). Making runtimeStyle behave like regular style is
3664 enough for most use cases. */
3665 if(!This->runtime_style) {
3666 HRESULT hres;
3668 hres = HTMLStyle_Create(This, &This->runtime_style);
3669 if(FAILED(hres))
3670 return hres;
3673 *p = &This->runtime_style->IHTMLStyle_iface;
3674 IHTMLStyle_AddRef(*p);
3675 return S_OK;
3678 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
3680 HTMLElement *This = impl_from_IHTMLElement2(iface);
3681 FIXME("(%p)->(%p)\n", This, p);
3682 return E_NOTIMPL;
3685 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
3687 HTMLElement *This = impl_from_IHTMLElement2(iface);
3688 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3689 return E_NOTIMPL;
3692 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
3694 HTMLElement *This = impl_from_IHTMLElement2(iface);
3695 FIXME("(%p)->(%p)\n", This, p);
3696 return E_NOTIMPL;
3699 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
3701 HTMLElement *This = impl_from_IHTMLElement2(iface);
3702 FIXME("(%p)->()\n", This);
3703 return E_NOTIMPL;
3706 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
3708 HTMLElement *This = impl_from_IHTMLElement2(iface);
3709 FIXME("(%p)->(%p)\n", This, p);
3710 return E_NOTIMPL;
3713 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
3715 HTMLElement *This = impl_from_IHTMLElement2(iface);
3716 FIXME("(%p)->(%p)\n", This, p);
3717 return E_NOTIMPL;
3720 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
3721 IHTMLElementCollection **pelColl)
3723 HTMLElement *This = impl_from_IHTMLElement2(iface);
3724 nsIDOMHTMLCollection *nscol;
3725 nsAString tag_str;
3726 nsresult nsres;
3728 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
3730 if(!This->dom_element) {
3731 *pelColl = create_collection_from_htmlcol(NULL, This->node.doc->document_mode);
3732 return S_OK;
3735 nsAString_InitDepend(&tag_str, v);
3736 nsres = nsIDOMElement_GetElementsByTagName(This->dom_element, &tag_str, &nscol);
3737 nsAString_Finish(&tag_str);
3738 if(NS_FAILED(nsres)) {
3739 ERR("GetElementByTagName failed: %08x\n", nsres);
3740 return E_FAIL;
3743 *pelColl = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
3744 nsIDOMHTMLCollection_Release(nscol);
3745 return S_OK;
3748 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
3749 HTMLElement2_QueryInterface,
3750 HTMLElement2_AddRef,
3751 HTMLElement2_Release,
3752 HTMLElement2_GetTypeInfoCount,
3753 HTMLElement2_GetTypeInfo,
3754 HTMLElement2_GetIDsOfNames,
3755 HTMLElement2_Invoke,
3756 HTMLElement2_get_scopeName,
3757 HTMLElement2_setCapture,
3758 HTMLElement2_releaseCapture,
3759 HTMLElement2_put_onlosecapture,
3760 HTMLElement2_get_onlosecapture,
3761 HTMLElement2_componentFromPoint,
3762 HTMLElement2_doScroll,
3763 HTMLElement2_put_onscroll,
3764 HTMLElement2_get_onscroll,
3765 HTMLElement2_put_ondrag,
3766 HTMLElement2_get_ondrag,
3767 HTMLElement2_put_ondragend,
3768 HTMLElement2_get_ondragend,
3769 HTMLElement2_put_ondragenter,
3770 HTMLElement2_get_ondragenter,
3771 HTMLElement2_put_ondragover,
3772 HTMLElement2_get_ondragover,
3773 HTMLElement2_put_ondragleave,
3774 HTMLElement2_get_ondragleave,
3775 HTMLElement2_put_ondrop,
3776 HTMLElement2_get_ondrop,
3777 HTMLElement2_put_onbeforecut,
3778 HTMLElement2_get_onbeforecut,
3779 HTMLElement2_put_oncut,
3780 HTMLElement2_get_oncut,
3781 HTMLElement2_put_onbeforecopy,
3782 HTMLElement2_get_onbeforecopy,
3783 HTMLElement2_put_oncopy,
3784 HTMLElement2_get_oncopy,
3785 HTMLElement2_put_onbeforepaste,
3786 HTMLElement2_get_onbeforepaste,
3787 HTMLElement2_put_onpaste,
3788 HTMLElement2_get_onpaste,
3789 HTMLElement2_get_currentStyle,
3790 HTMLElement2_put_onpropertychange,
3791 HTMLElement2_get_onpropertychange,
3792 HTMLElement2_getClientRects,
3793 HTMLElement2_getBoundingClientRect,
3794 HTMLElement2_setExpression,
3795 HTMLElement2_getExpression,
3796 HTMLElement2_removeExpression,
3797 HTMLElement2_put_tabIndex,
3798 HTMLElement2_get_tabIndex,
3799 HTMLElement2_focus,
3800 HTMLElement2_put_accessKey,
3801 HTMLElement2_get_accessKey,
3802 HTMLElement2_put_onblur,
3803 HTMLElement2_get_onblur,
3804 HTMLElement2_put_onfocus,
3805 HTMLElement2_get_onfocus,
3806 HTMLElement2_put_onresize,
3807 HTMLElement2_get_onresize,
3808 HTMLElement2_blur,
3809 HTMLElement2_addFilter,
3810 HTMLElement2_removeFilter,
3811 HTMLElement2_get_clientHeight,
3812 HTMLElement2_get_clientWidth,
3813 HTMLElement2_get_clientTop,
3814 HTMLElement2_get_clientLeft,
3815 HTMLElement2_attachEvent,
3816 HTMLElement2_detachEvent,
3817 HTMLElement2_get_readyState,
3818 HTMLElement2_put_onreadystatechange,
3819 HTMLElement2_get_onreadystatechange,
3820 HTMLElement2_put_onrowsdelete,
3821 HTMLElement2_get_onrowsdelete,
3822 HTMLElement2_put_onrowsinserted,
3823 HTMLElement2_get_onrowsinserted,
3824 HTMLElement2_put_oncellchange,
3825 HTMLElement2_get_oncellchange,
3826 HTMLElement2_put_dir,
3827 HTMLElement2_get_dir,
3828 HTMLElement2_createControlRange,
3829 HTMLElement2_get_scrollHeight,
3830 HTMLElement2_get_scrollWidth,
3831 HTMLElement2_put_scrollTop,
3832 HTMLElement2_get_scrollTop,
3833 HTMLElement2_put_scrollLeft,
3834 HTMLElement2_get_scrollLeft,
3835 HTMLElement2_clearAttributes,
3836 HTMLElement2_mergeAttributes,
3837 HTMLElement2_put_oncontextmenu,
3838 HTMLElement2_get_oncontextmenu,
3839 HTMLElement2_insertAdjacentElement,
3840 HTMLElement2_applyElement,
3841 HTMLElement2_getAdjacentText,
3842 HTMLElement2_replaceAdjacentText,
3843 HTMLElement2_get_canHandleChildren,
3844 HTMLElement2_addBehavior,
3845 HTMLElement2_removeBehavior,
3846 HTMLElement2_get_runtimeStyle,
3847 HTMLElement2_get_behaviorUrns,
3848 HTMLElement2_put_tagUrn,
3849 HTMLElement2_get_tagUrn,
3850 HTMLElement2_put_onbeforeeditfocus,
3851 HTMLElement2_get_onbeforeeditfocus,
3852 HTMLElement2_get_readyStateValue,
3853 HTMLElement2_getElementsByTagName,
3856 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3858 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3861 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
3862 REFIID riid, void **ppv)
3864 HTMLElement *This = impl_from_IHTMLElement3(iface);
3865 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3868 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
3870 HTMLElement *This = impl_from_IHTMLElement3(iface);
3871 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3874 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
3876 HTMLElement *This = impl_from_IHTMLElement3(iface);
3877 return IHTMLElement_Release(&This->IHTMLElement_iface);
3880 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
3882 HTMLElement *This = impl_from_IHTMLElement3(iface);
3883 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3886 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
3887 LCID lcid, ITypeInfo **ppTInfo)
3889 HTMLElement *This = impl_from_IHTMLElement3(iface);
3890 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3893 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
3894 LPOLESTR *rgszNames, UINT cNames,
3895 LCID lcid, DISPID *rgDispId)
3897 HTMLElement *This = impl_from_IHTMLElement3(iface);
3898 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3899 lcid, rgDispId);
3902 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
3903 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3904 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3906 HTMLElement *This = impl_from_IHTMLElement3(iface);
3907 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3908 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3911 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3913 HTMLElement *This = impl_from_IHTMLElement3(iface);
3914 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3915 return E_NOTIMPL;
3918 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3920 HTMLElement *This = impl_from_IHTMLElement3(iface);
3921 FIXME("(%p)->(%p)\n", This, p);
3922 return E_NOTIMPL;
3925 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3927 HTMLElement *This = impl_from_IHTMLElement3(iface);
3928 FIXME("(%p)->(%p)\n", This, p);
3929 return E_NOTIMPL;
3932 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3934 HTMLElement *This = impl_from_IHTMLElement3(iface);
3935 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3936 return E_NOTIMPL;
3939 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3941 HTMLElement *This = impl_from_IHTMLElement3(iface);
3942 FIXME("(%p)->(%p)\n", This, p);
3943 return E_NOTIMPL;
3946 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3948 HTMLElement *This = impl_from_IHTMLElement3(iface);
3949 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3950 return E_NOTIMPL;
3953 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3955 HTMLElement *This = impl_from_IHTMLElement3(iface);
3956 FIXME("(%p)->(%p)\n", This, p);
3957 return E_NOTIMPL;
3960 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
3962 HTMLElement *This = impl_from_IHTMLElement3(iface);
3963 FIXME("(%p)->(%x)\n", This, v);
3964 return E_NOTIMPL;
3967 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
3969 HTMLElement *This = impl_from_IHTMLElement3(iface);
3970 FIXME("(%p)->(%p)\n", This, p);
3971 return E_NOTIMPL;
3974 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
3976 HTMLElement *This = impl_from_IHTMLElement3(iface);
3977 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3978 return E_NOTIMPL;
3981 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
3983 HTMLElement *This = impl_from_IHTMLElement3(iface);
3984 FIXME("(%p)->(%p)\n", This, p);
3985 return E_NOTIMPL;
3988 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
3990 HTMLElement *This = impl_from_IHTMLElement3(iface);
3991 FIXME("(%p)\n", This);
3992 return E_NOTIMPL;
3995 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
3997 HTMLElement *This = impl_from_IHTMLElement3(iface);
3998 nsresult nsres;
3999 nsAString str;
4001 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
4003 if(!This->html_element) {
4004 FIXME("non-HTML element\n");
4005 return E_NOTIMPL;
4008 nsAString_InitDepend(&str, v);
4009 nsres = nsIDOMHTMLElement_SetContentEditable(This->html_element, &str);
4010 nsAString_Finish(&str);
4012 if (NS_FAILED(nsres)){
4013 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
4014 return E_FAIL;
4017 return S_OK;
4020 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
4022 HTMLElement *This = impl_from_IHTMLElement3(iface);
4023 nsresult nsres;
4024 nsAString str;
4026 TRACE("(%p)->(%p)\n", This, p);
4028 if(!This->html_element) {
4029 FIXME("non-HTML element\n");
4030 return E_NOTIMPL;
4033 nsAString_Init(&str, NULL);
4034 nsres = nsIDOMHTMLElement_GetContentEditable(This->html_element, &str);
4035 return return_nsstr(nsres, &str, p);
4038 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
4040 HTMLElement *This = impl_from_IHTMLElement3(iface);
4041 FIXME("(%p)->(%p)\n", This, p);
4042 return E_NOTIMPL;
4045 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
4047 HTMLElement *This = impl_from_IHTMLElement3(iface);
4048 FIXME("(%p)->(%x)\n", This, v);
4049 return E_NOTIMPL;
4052 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
4054 HTMLElement *This = impl_from_IHTMLElement3(iface);
4055 FIXME("(%p)->(%p)\n", This, p);
4056 return E_NOTIMPL;
4059 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
4061 HTMLElement *This = impl_from_IHTMLElement3(iface);
4063 TRACE("(%p)->(%x)\n", This, v);
4065 if(This->node.vtbl->put_disabled)
4066 return This->node.vtbl->put_disabled(&This->node, v);
4068 if(!v) return element_remove_attribute(This, L"disabled");
4069 return elem_string_attr_setter(This, L"disabled", L"");
4072 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4074 HTMLElement *This = impl_from_IHTMLElement3(iface);
4076 TRACE("(%p)->(%p)\n", This, p);
4078 if(This->node.vtbl->get_disabled)
4079 return This->node.vtbl->get_disabled(&This->node, p);
4081 *p = variant_bool(element_has_attribute(This, L"disabled"));
4082 return S_OK;
4085 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
4087 HTMLElement *This = impl_from_IHTMLElement3(iface);
4088 FIXME("(%p)->(%p)\n", This, p);
4089 return E_NOTIMPL;
4092 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
4094 HTMLElement *This = impl_from_IHTMLElement3(iface);
4095 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4096 return E_NOTIMPL;
4099 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
4101 HTMLElement *This = impl_from_IHTMLElement3(iface);
4102 FIXME("(%p)->(%p)\n", This, p);
4103 return E_NOTIMPL;
4106 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
4108 HTMLElement *This = impl_from_IHTMLElement3(iface);
4109 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4110 return E_NOTIMPL;
4113 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
4115 HTMLElement *This = impl_from_IHTMLElement3(iface);
4116 FIXME("(%p)->(%p)\n", This, p);
4117 return E_NOTIMPL;
4120 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
4121 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
4123 HTMLElement *This = impl_from_IHTMLElement3(iface);
4125 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
4126 pfCancelled);
4128 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
4131 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
4133 HTMLElement *This = impl_from_IHTMLElement3(iface);
4134 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4135 return E_NOTIMPL;
4138 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
4140 HTMLElement *This = impl_from_IHTMLElement3(iface);
4141 FIXME("(%p)->(%p)\n", This, p);
4142 return E_NOTIMPL;
4145 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
4147 HTMLElement *This = impl_from_IHTMLElement3(iface);
4148 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4149 return E_NOTIMPL;
4152 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
4154 HTMLElement *This = impl_from_IHTMLElement3(iface);
4155 FIXME("(%p)->(%p)\n", This, p);
4156 return E_NOTIMPL;
4159 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
4161 HTMLElement *This = impl_from_IHTMLElement3(iface);
4162 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4163 return E_NOTIMPL;
4166 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
4168 HTMLElement *This = impl_from_IHTMLElement3(iface);
4169 FIXME("(%p)->(%p)\n", This, p);
4170 return E_NOTIMPL;
4173 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
4175 HTMLElement *This = impl_from_IHTMLElement3(iface);
4176 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4177 return E_NOTIMPL;
4180 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
4182 HTMLElement *This = impl_from_IHTMLElement3(iface);
4183 FIXME("(%p)->(%p)\n", This, p);
4184 return E_NOTIMPL;
4187 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
4189 HTMLElement *This = impl_from_IHTMLElement3(iface);
4190 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4191 return E_NOTIMPL;
4194 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
4196 HTMLElement *This = impl_from_IHTMLElement3(iface);
4197 FIXME("(%p)->(%p)\n", This, p);
4198 return E_NOTIMPL;
4201 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
4203 HTMLElement *This = impl_from_IHTMLElement3(iface);
4204 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4205 return E_NOTIMPL;
4208 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
4210 HTMLElement *This = impl_from_IHTMLElement3(iface);
4211 FIXME("(%p)->(%p)\n", This, p);
4212 return E_NOTIMPL;
4215 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
4217 HTMLElement *This = impl_from_IHTMLElement3(iface);
4218 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4219 return E_NOTIMPL;
4222 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
4224 HTMLElement *This = impl_from_IHTMLElement3(iface);
4225 FIXME("(%p)->(%p)\n", This, p);
4226 return E_NOTIMPL;
4229 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
4231 HTMLElement *This = impl_from_IHTMLElement3(iface);
4232 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4233 return E_NOTIMPL;
4236 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
4238 HTMLElement *This = impl_from_IHTMLElement3(iface);
4239 FIXME("(%p)->(%p)\n", This, p);
4240 return E_NOTIMPL;
4243 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
4245 HTMLElement *This = impl_from_IHTMLElement3(iface);
4246 FIXME("(%p)->(%p)\n", This, pfRet);
4247 return E_NOTIMPL;
4250 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
4252 HTMLElement *This = impl_from_IHTMLElement3(iface);
4253 FIXME("(%p)->(%p)\n", This, p);
4254 return E_NOTIMPL;
4257 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
4258 HTMLElement3_QueryInterface,
4259 HTMLElement3_AddRef,
4260 HTMLElement3_Release,
4261 HTMLElement3_GetTypeInfoCount,
4262 HTMLElement3_GetTypeInfo,
4263 HTMLElement3_GetIDsOfNames,
4264 HTMLElement3_Invoke,
4265 HTMLElement3_mergeAttributes,
4266 HTMLElement3_get_isMultiLine,
4267 HTMLElement3_get_canHaveHTML,
4268 HTMLElement3_put_onlayoutcomplete,
4269 HTMLElement3_get_onlayoutcomplete,
4270 HTMLElement3_put_onpage,
4271 HTMLElement3_get_onpage,
4272 HTMLElement3_put_inflateBlock,
4273 HTMLElement3_get_inflateBlock,
4274 HTMLElement3_put_onbeforedeactivate,
4275 HTMLElement3_get_onbeforedeactivate,
4276 HTMLElement3_setActive,
4277 HTMLElement3_put_contentEditable,
4278 HTMLElement3_get_contentEditable,
4279 HTMLElement3_get_isContentEditable,
4280 HTMLElement3_put_hideFocus,
4281 HTMLElement3_get_hideFocus,
4282 HTMLElement3_put_disabled,
4283 HTMLElement3_get_disabled,
4284 HTMLElement3_get_isDisabled,
4285 HTMLElement3_put_onmove,
4286 HTMLElement3_get_onmove,
4287 HTMLElement3_put_oncontrolselect,
4288 HTMLElement3_get_oncontrolselect,
4289 HTMLElement3_fireEvent,
4290 HTMLElement3_put_onresizestart,
4291 HTMLElement3_get_onresizestart,
4292 HTMLElement3_put_onresizeend,
4293 HTMLElement3_get_onresizeend,
4294 HTMLElement3_put_onmovestart,
4295 HTMLElement3_get_onmovestart,
4296 HTMLElement3_put_onmoveend,
4297 HTMLElement3_get_onmoveend,
4298 HTMLElement3_put_onmousecenter,
4299 HTMLElement3_get_onmousecenter,
4300 HTMLElement3_put_onmouseleave,
4301 HTMLElement3_get_onmouseleave,
4302 HTMLElement3_put_onactivate,
4303 HTMLElement3_get_onactivate,
4304 HTMLElement3_put_ondeactivate,
4305 HTMLElement3_get_ondeactivate,
4306 HTMLElement3_dragDrop,
4307 HTMLElement3_get_glyphMode
4310 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
4312 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
4315 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
4316 REFIID riid, void **ppv)
4318 HTMLElement *This = impl_from_IHTMLElement4(iface);
4319 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4322 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
4324 HTMLElement *This = impl_from_IHTMLElement4(iface);
4325 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4328 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
4330 HTMLElement *This = impl_from_IHTMLElement4(iface);
4331 return IHTMLElement_Release(&This->IHTMLElement_iface);
4334 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
4336 HTMLElement *This = impl_from_IHTMLElement4(iface);
4337 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4340 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
4341 LCID lcid, ITypeInfo **ppTInfo)
4343 HTMLElement *This = impl_from_IHTMLElement4(iface);
4344 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4347 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
4348 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4350 HTMLElement *This = impl_from_IHTMLElement4(iface);
4351 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4352 lcid, rgDispId);
4355 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
4356 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4358 HTMLElement *This = impl_from_IHTMLElement4(iface);
4359 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4360 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4363 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
4365 HTMLElement *This = impl_from_IHTMLElement4(iface);
4367 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4369 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
4372 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
4374 HTMLElement *This = impl_from_IHTMLElement4(iface);
4376 TRACE("(%p)->(%p)\n", This, p);
4378 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
4381 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
4383 HTMLElement *This = impl_from_IHTMLElement4(iface);
4384 FIXME("(%p)\n", This);
4385 return E_NOTIMPL;
4388 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
4390 HTMLElement *This = impl_from_IHTMLElement4(iface);
4391 HTMLAttributeCollection *attrs;
4392 HRESULT hres;
4394 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
4396 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4397 if(FAILED(hres))
4398 return hres;
4400 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
4401 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4402 return hres;
4405 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4406 IHTMLDOMAttribute **ppretAttribute)
4408 HTMLElement *This = impl_from_IHTMLElement4(iface);
4409 HTMLDOMAttribute *attr, *iter, *replace = NULL;
4410 HTMLAttributeCollection *attrs;
4411 DISPID dispid;
4412 HRESULT hres;
4414 TRACE("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4416 attr = unsafe_impl_from_IHTMLDOMAttribute(pattr);
4417 if(!attr)
4418 return E_INVALIDARG;
4420 if(attr->elem) {
4421 WARN("Tried to set already attached attribute.\n");
4422 return E_INVALIDARG;
4425 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface,
4426 attr->name, fdexNameCaseInsensitive|fdexNameEnsure, &dispid);
4427 if(FAILED(hres))
4428 return hres;
4430 hres = HTMLElement_get_attr_col(&This->node, &attrs);
4431 if(FAILED(hres))
4432 return hres;
4434 LIST_FOR_EACH_ENTRY(iter, &attrs->attrs, HTMLDOMAttribute, entry) {
4435 if(iter->dispid == dispid) {
4436 replace = iter;
4437 break;
4441 if(replace) {
4442 hres = get_elem_attr_value_by_dispid(This, dispid, &replace->value);
4443 if(FAILED(hres)) {
4444 WARN("could not get attr value: %08x\n", hres);
4445 V_VT(&replace->value) = VT_EMPTY;
4447 if(!replace->name) {
4448 replace->name = attr->name;
4449 attr->name = NULL;
4451 list_add_head(&replace->entry, &attr->entry);
4452 list_remove(&replace->entry);
4453 replace->elem = NULL;
4454 }else {
4455 list_add_tail(&attrs->attrs, &attr->entry);
4458 IHTMLDOMAttribute_AddRef(&attr->IHTMLDOMAttribute_iface);
4459 attr->elem = This;
4460 attr->dispid = dispid;
4462 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
4464 hres = set_elem_attr_value_by_dispid(This, dispid, &attr->value);
4465 if(FAILED(hres))
4466 WARN("Could not set attribute value: %08x\n", hres);
4467 VariantClear(&attr->value);
4469 *ppretAttribute = replace ? &replace->IHTMLDOMAttribute_iface : NULL;
4470 return S_OK;
4473 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
4474 IHTMLDOMAttribute **ppretAttribute)
4476 HTMLElement *This = impl_from_IHTMLElement4(iface);
4477 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4478 return E_NOTIMPL;
4481 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
4483 HTMLElement *This = impl_from_IHTMLElement4(iface);
4485 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4487 return set_node_event(&This->node, EVENTID_BEFOREACTIVATE, &v);
4490 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
4492 HTMLElement *This = impl_from_IHTMLElement4(iface);
4494 TRACE("(%p)->(%p)\n", This, p);
4496 return get_node_event(&This->node, EVENTID_BEFOREACTIVATE, p);
4499 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
4501 HTMLElement *This = impl_from_IHTMLElement4(iface);
4503 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4505 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
4508 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
4510 HTMLElement *This = impl_from_IHTMLElement4(iface);
4512 TRACE("(%p)->(%p)\n", This, p);
4514 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
4517 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
4519 HTMLElement *This = impl_from_IHTMLElement4(iface);
4521 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4523 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
4526 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
4528 HTMLElement *This = impl_from_IHTMLElement4(iface);
4530 TRACE("(%p)->(%p)\n", This, p);
4532 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
4535 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
4536 HTMLElement4_QueryInterface,
4537 HTMLElement4_AddRef,
4538 HTMLElement4_Release,
4539 HTMLElement4_GetTypeInfoCount,
4540 HTMLElement4_GetTypeInfo,
4541 HTMLElement4_GetIDsOfNames,
4542 HTMLElement4_Invoke,
4543 HTMLElement4_put_onmousewheel,
4544 HTMLElement4_get_onmousewheel,
4545 HTMLElement4_normalize,
4546 HTMLElement4_getAttributeNode,
4547 HTMLElement4_setAttributeNode,
4548 HTMLElement4_removeAttributeNode,
4549 HTMLElement4_put_onbeforeactivate,
4550 HTMLElement4_get_onbeforeactivate,
4551 HTMLElement4_put_onfocusin,
4552 HTMLElement4_get_onfocusin,
4553 HTMLElement4_put_onfocusout,
4554 HTMLElement4_get_onfocusout
4557 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
4559 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
4562 static HRESULT WINAPI HTMLElement6_QueryInterface(IHTMLElement6 *iface,
4563 REFIID riid, void **ppv)
4565 HTMLElement *This = impl_from_IHTMLElement6(iface);
4566 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4569 static ULONG WINAPI HTMLElement6_AddRef(IHTMLElement6 *iface)
4571 HTMLElement *This = impl_from_IHTMLElement6(iface);
4572 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4575 static ULONG WINAPI HTMLElement6_Release(IHTMLElement6 *iface)
4577 HTMLElement *This = impl_from_IHTMLElement6(iface);
4578 return IHTMLElement_Release(&This->IHTMLElement_iface);
4581 static HRESULT WINAPI HTMLElement6_GetTypeInfoCount(IHTMLElement6 *iface, UINT *pctinfo)
4583 HTMLElement *This = impl_from_IHTMLElement6(iface);
4584 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4587 static HRESULT WINAPI HTMLElement6_GetTypeInfo(IHTMLElement6 *iface, UINT iTInfo,
4588 LCID lcid, ITypeInfo **ppTInfo)
4590 HTMLElement *This = impl_from_IHTMLElement6(iface);
4591 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4594 static HRESULT WINAPI HTMLElement6_GetIDsOfNames(IHTMLElement6 *iface, REFIID riid,
4595 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4597 HTMLElement *This = impl_from_IHTMLElement6(iface);
4598 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4599 lcid, rgDispId);
4602 static HRESULT WINAPI HTMLElement6_Invoke(IHTMLElement6 *iface, DISPID dispIdMember, REFIID riid,
4603 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4605 HTMLElement *This = impl_from_IHTMLElement6(iface);
4606 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4607 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4610 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
4612 HTMLElement *This = impl_from_IHTMLElement6(iface);
4613 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
4614 return E_NOTIMPL;
4617 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4619 HTMLElement *This = impl_from_IHTMLElement6(iface);
4620 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
4621 return E_NOTIMPL;
4624 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
4626 HTMLElement *This = impl_from_IHTMLElement6(iface);
4627 FIXME("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
4628 return E_NOTIMPL;
4631 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
4633 HTMLElement *This = impl_from_IHTMLElement6(iface);
4634 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
4635 return E_NOTIMPL;
4638 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4640 HTMLElement *This = impl_from_IHTMLElement6(iface);
4641 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4642 return E_NOTIMPL;
4645 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
4647 HTMLElement *This = impl_from_IHTMLElement6(iface);
4648 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
4649 return E_NOTIMPL;
4652 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
4654 HTMLElement *This = impl_from_IHTMLElement6(iface);
4656 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), AttributeValue);
4658 return IHTMLElement_getAttribute(&This->IHTMLElement_iface, strAttributeName, 0, AttributeValue);
4661 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4663 HTMLElement *This = impl_from_IHTMLElement6(iface);
4665 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
4667 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, strAttributeName, *pvarAttributeValue, 0);
4670 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
4672 HTMLElement *This = impl_from_IHTMLElement6(iface);
4673 VARIANT_BOOL success;
4675 WARN("(%p)->(%s) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName));
4677 return IHTMLElement_removeAttribute(&This->IHTMLElement_iface, strAttributeName, 0, &success);
4680 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
4682 HTMLElement *This = impl_from_IHTMLElement6(iface);
4683 IHTMLDOMAttribute *attr;
4684 HRESULT hres;
4686 WARN("(%p)->(%s %p) forwarding to IHTMLElement4\n", This, debugstr_w(strAttributeName), ppretAttribute);
4688 hres = IHTMLElement4_getAttributeNode(&This->IHTMLElement4_iface, strAttributeName, &attr);
4689 if(FAILED(hres))
4690 return hres;
4692 if(attr) {
4693 hres = IHTMLDOMAttribute_QueryInterface(attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
4694 IHTMLDOMAttribute_Release(attr);
4695 }else {
4696 *ppretAttribute = NULL;
4698 return hres;
4701 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4703 HTMLElement *This = impl_from_IHTMLElement6(iface);
4704 IHTMLDOMAttribute *attr, *ret_attr;
4705 HRESULT hres;
4707 WARN("(%p)->(%p %p) forwarding to IHTMLElement4\n", This, pattr, ppretAttribute);
4709 hres = IHTMLDOMAttribute2_QueryInterface(pattr, &IID_IHTMLDOMAttribute, (void**)&attr);
4710 if(FAILED(hres))
4711 return hres;
4713 hres = IHTMLElement4_setAttributeNode(&This->IHTMLElement4_iface, attr, &ret_attr);
4714 if(FAILED(hres))
4715 return hres;
4717 if(ret_attr) {
4718 hres = IHTMLDOMAttribute_QueryInterface(ret_attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
4719 IHTMLDOMAttribute_Release(ret_attr);
4720 }else {
4721 *ppretAttribute = NULL;
4723 return hres;
4726 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4728 HTMLElement *This = impl_from_IHTMLElement6(iface);
4729 FIXME("(%p)->()\n", This);
4730 return E_NOTIMPL;
4733 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *p)
4735 HTMLElement *This = impl_from_IHTMLElement6(iface);
4737 TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), p);
4739 *p = element_has_attribute(This, name);
4740 return S_OK;
4743 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
4745 HTMLElement *This = impl_from_IHTMLElement6(iface);
4746 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
4747 return E_NOTIMPL;
4750 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
4752 HTMLElement *This = impl_from_IHTMLElement6(iface);
4754 TRACE("(%p)->(%p)\n", This, p);
4756 return IHTMLElement_get_tagName(&This->IHTMLElement_iface, p);
4759 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
4761 HTMLElement *This = impl_from_IHTMLElement6(iface);
4763 TRACE("(%p)->(%p)\n", This, p);
4765 return IHTMLDOMNode_get_nodeName(&This->node.IHTMLDOMNode_iface, p);
4768 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
4770 HTMLElement *This = impl_from_IHTMLElement6(iface);
4771 nsIDOMHTMLCollection *nscol = NULL;
4772 nsAString nsstr;
4773 nsresult nsres;
4775 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4777 if(This->dom_element) {
4778 nsAString_InitDepend(&nsstr, v);
4779 nsres = nsIDOMElement_GetElementsByClassName(This->dom_element, &nsstr, &nscol);
4780 nsAString_Finish(&nsstr);
4781 if(NS_FAILED(nsres)) {
4782 ERR("GetElementsByClassName failed: %08x\n", nsres);
4783 return E_FAIL;
4787 *pel = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
4788 nsIDOMHTMLCollection_Release(nscol);
4789 return S_OK;
4792 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
4794 HTMLElement *This = impl_from_IHTMLElement6(iface);
4795 nsAString nsstr;
4796 cpp_bool b;
4797 nsresult nsres;
4799 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
4801 if(!This->dom_element) {
4802 FIXME("No dom element\n");
4803 return E_UNEXPECTED;
4806 nsAString_InitDepend(&nsstr, v);
4807 nsres = nsIDOMElement_MozMatchesSelector(This->dom_element, &nsstr, &b);
4808 nsAString_Finish(&nsstr);
4809 if(NS_FAILED(nsres)) {
4810 WARN("MozMatchesSelector failed: %08x\n", nsres);
4811 return map_nsresult(nsres);
4814 *pfMatches = b;
4815 return S_OK;
4818 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
4820 HTMLElement *This = impl_from_IHTMLElement6(iface);
4822 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4824 return set_node_event(&This->node, EVENTID_ABORT, &v);
4827 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
4829 HTMLElement *This = impl_from_IHTMLElement6(iface);
4831 TRACE("(%p)->(%p)\n", This, p);
4833 return get_node_event(&This->node, EVENTID_ABORT, p);
4836 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
4838 HTMLElement *This = impl_from_IHTMLElement6(iface);
4839 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4840 return E_NOTIMPL;
4843 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
4845 HTMLElement *This = impl_from_IHTMLElement6(iface);
4846 FIXME("(%p)->(%p)\n", This, p);
4847 return E_NOTIMPL;
4850 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
4852 HTMLElement *This = impl_from_IHTMLElement6(iface);
4853 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4854 return E_NOTIMPL;
4857 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
4859 HTMLElement *This = impl_from_IHTMLElement6(iface);
4860 FIXME("(%p)->(%p)\n", This, p);
4861 return E_NOTIMPL;
4864 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
4866 HTMLElement *This = impl_from_IHTMLElement6(iface);
4868 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4870 return set_node_event(&This->node, EVENTID_CHANGE, &v);
4873 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
4875 HTMLElement *This = impl_from_IHTMLElement6(iface);
4877 TRACE("(%p)->(%p)\n", This, p);
4879 return get_node_event(&This->node, EVENTID_CHANGE, p);
4882 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
4884 HTMLElement *This = impl_from_IHTMLElement6(iface);
4885 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4886 return E_NOTIMPL;
4889 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
4891 HTMLElement *This = impl_from_IHTMLElement6(iface);
4892 FIXME("(%p)->(%p)\n", This, p);
4893 return E_NOTIMPL;
4896 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
4898 HTMLElement *This = impl_from_IHTMLElement6(iface);
4899 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4900 return E_NOTIMPL;
4903 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
4905 HTMLElement *This = impl_from_IHTMLElement6(iface);
4906 FIXME("(%p)->(%p)\n", This, p);
4907 return E_NOTIMPL;
4910 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
4912 HTMLElement *This = impl_from_IHTMLElement6(iface);
4913 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4914 return E_NOTIMPL;
4917 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
4919 HTMLElement *This = impl_from_IHTMLElement6(iface);
4920 FIXME("(%p)->(%p)\n", This, p);
4921 return E_NOTIMPL;
4924 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
4926 HTMLElement *This = impl_from_IHTMLElement6(iface);
4928 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4930 return set_node_event(&This->node, EVENTID_ERROR, &v);
4933 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
4935 HTMLElement *This = impl_from_IHTMLElement6(iface);
4937 TRACE("(%p)->(%p)\n", This, p);
4939 return get_node_event(&This->node, EVENTID_ERROR, p);
4942 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
4944 HTMLElement *This = impl_from_IHTMLElement6(iface);
4946 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4948 return set_node_event(&This->node, EVENTID_INPUT, &v);
4951 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
4953 HTMLElement *This = impl_from_IHTMLElement6(iface);
4955 TRACE("(%p)->(%p)\n", This, p);
4957 return get_node_event(&This->node, EVENTID_INPUT, p);
4960 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
4962 HTMLElement *This = impl_from_IHTMLElement6(iface);
4964 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4966 return set_node_event(&This->node, EVENTID_LOAD, &v);
4969 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
4971 HTMLElement *This = impl_from_IHTMLElement6(iface);
4973 TRACE("(%p)->(%p)\n", This, p);
4975 return get_node_event(&This->node, EVENTID_LOAD, p);
4978 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
4980 HTMLElement *This = impl_from_IHTMLElement6(iface);
4981 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4982 return E_NOTIMPL;
4985 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
4987 HTMLElement *This = impl_from_IHTMLElement6(iface);
4988 FIXME("(%p)->(%p)\n", This, p);
4989 return E_NOTIMPL;
4992 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
4994 HTMLElement *This = impl_from_IHTMLElement6(iface);
4995 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4996 return E_NOTIMPL;
4999 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
5001 HTMLElement *This = impl_from_IHTMLElement6(iface);
5002 FIXME("(%p)->(%p)\n", This, p);
5003 return E_NOTIMPL;
5006 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
5008 HTMLElement *This = impl_from_IHTMLElement6(iface);
5009 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5010 return E_NOTIMPL;
5013 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
5015 HTMLElement *This = impl_from_IHTMLElement6(iface);
5016 FIXME("(%p)->(%p)\n", This, p);
5017 return E_NOTIMPL;
5020 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
5022 HTMLElement *This = impl_from_IHTMLElement6(iface);
5023 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5024 return E_NOTIMPL;
5027 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
5029 HTMLElement *This = impl_from_IHTMLElement6(iface);
5030 FIXME("(%p)->(%p)\n", This, p);
5031 return E_NOTIMPL;
5034 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
5036 HTMLElement *This = impl_from_IHTMLElement6(iface);
5037 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5038 return E_NOTIMPL;
5041 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
5043 HTMLElement *This = impl_from_IHTMLElement6(iface);
5044 FIXME("(%p)->(%p)\n", This, p);
5045 return E_NOTIMPL;
5048 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
5050 HTMLElement *This = impl_from_IHTMLElement6(iface);
5051 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5052 return E_NOTIMPL;
5055 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
5057 HTMLElement *This = impl_from_IHTMLElement6(iface);
5058 FIXME("(%p)->(%p)\n", This, p);
5059 return E_NOTIMPL;
5062 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
5064 HTMLElement *This = impl_from_IHTMLElement6(iface);
5065 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5066 return E_NOTIMPL;
5069 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
5071 HTMLElement *This = impl_from_IHTMLElement6(iface);
5072 FIXME("(%p)->(%p)\n", This, p);
5073 return E_NOTIMPL;
5076 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
5078 HTMLElement *This = impl_from_IHTMLElement6(iface);
5079 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5080 return E_NOTIMPL;
5083 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
5085 HTMLElement *This = impl_from_IHTMLElement6(iface);
5086 FIXME("(%p)->(%p)\n", This, p);
5087 return E_NOTIMPL;
5090 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
5092 HTMLElement *This = impl_from_IHTMLElement6(iface);
5093 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5094 return E_NOTIMPL;
5097 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
5099 HTMLElement *This = impl_from_IHTMLElement6(iface);
5100 FIXME("(%p)->(%p)\n", This, p);
5101 return E_NOTIMPL;
5104 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
5106 HTMLElement *This = impl_from_IHTMLElement6(iface);
5107 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5108 return E_NOTIMPL;
5111 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
5113 HTMLElement *This = impl_from_IHTMLElement6(iface);
5114 FIXME("(%p)->(%p)\n", This, p);
5115 return E_NOTIMPL;
5118 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
5120 HTMLElement *This = impl_from_IHTMLElement6(iface);
5121 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5122 return E_NOTIMPL;
5125 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
5127 HTMLElement *This = impl_from_IHTMLElement6(iface);
5128 FIXME("(%p)->(%p)\n", This, p);
5129 return E_NOTIMPL;
5132 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
5134 HTMLElement *This = impl_from_IHTMLElement6(iface);
5135 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5136 return E_NOTIMPL;
5139 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
5141 HTMLElement *This = impl_from_IHTMLElement6(iface);
5142 FIXME("(%p)->(%p)\n", This, p);
5143 return E_NOTIMPL;
5146 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
5148 HTMLElement *This = impl_from_IHTMLElement6(iface);
5149 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5150 return E_NOTIMPL;
5153 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
5155 HTMLElement *This = impl_from_IHTMLElement6(iface);
5156 FIXME("(%p)->(%p)\n", This, p);
5157 return E_NOTIMPL;
5160 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
5162 HTMLElement *This = impl_from_IHTMLElement6(iface);
5164 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5166 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
5169 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
5171 HTMLElement *This = impl_from_IHTMLElement6(iface);
5173 TRACE("(%p)->(%p)\n", This, p);
5175 return get_node_event(&This->node, EVENTID_SUBMIT, p);
5178 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
5180 HTMLElement *This = impl_from_IHTMLElement6(iface);
5181 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5182 return E_NOTIMPL;
5185 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
5187 HTMLElement *This = impl_from_IHTMLElement6(iface);
5188 FIXME("(%p)->(%p)\n", This, p);
5189 return E_NOTIMPL;
5192 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
5194 HTMLElement *This = impl_from_IHTMLElement6(iface);
5195 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5196 return E_NOTIMPL;
5199 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
5201 HTMLElement *This = impl_from_IHTMLElement6(iface);
5202 FIXME("(%p)->(%p)\n", This, p);
5203 return E_NOTIMPL;
5206 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
5208 HTMLElement *This = impl_from_IHTMLElement6(iface);
5209 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5210 return E_NOTIMPL;
5213 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
5215 HTMLElement *This = impl_from_IHTMLElement6(iface);
5216 FIXME("(%p)->(%p)\n", This, p);
5217 return E_NOTIMPL;
5220 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
5222 HTMLElement *This = impl_from_IHTMLElement6(iface);
5223 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5224 return E_NOTIMPL;
5227 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
5229 HTMLElement *This = impl_from_IHTMLElement6(iface);
5230 FIXME("(%p)->(%p)\n", This, p);
5231 return E_NOTIMPL;
5234 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
5236 HTMLElement *This = impl_from_IHTMLElement6(iface);
5237 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
5238 return E_NOTIMPL;
5241 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
5242 HTMLElement6_QueryInterface,
5243 HTMLElement6_AddRef,
5244 HTMLElement6_Release,
5245 HTMLElement6_GetTypeInfoCount,
5246 HTMLElement6_GetTypeInfo,
5247 HTMLElement6_GetIDsOfNames,
5248 HTMLElement6_Invoke,
5249 HTMLElement6_getAttributeNS,
5250 HTMLElement6_setAttributeNS,
5251 HTMLElement6_removeAttributeNS,
5252 HTMLElement6_getAttributeNodeNS,
5253 HTMLElement6_setAttributeNodeNS,
5254 HTMLElement6_hasAttributeNS,
5255 HTMLElement6_getAttribute,
5256 HTMLElement6_setAttribute,
5257 HTMLElement6_removeAttribute,
5258 HTMLElement6_getAttributeNode,
5259 HTMLElement6_setAttributeNode,
5260 HTMLElement6_removeAttributeNode,
5261 HTMLElement6_hasAttribute,
5262 HTMLElement6_getElementsByTagNameNS,
5263 HTMLElement6_get_tagName,
5264 HTMLElement6_get_nodeName,
5265 HTMLElement6_getElementsByClassName,
5266 HTMLElement6_msMatchesSelector,
5267 HTMLElement6_put_onabort,
5268 HTMLElement6_get_onabort,
5269 HTMLElement6_put_oncanplay,
5270 HTMLElement6_get_oncanplay,
5271 HTMLElement6_put_oncanplaythrough,
5272 HTMLElement6_get_oncanplaythrough,
5273 HTMLElement6_put_onchange,
5274 HTMLElement6_get_onchange,
5275 HTMLElement6_put_ondurationchange,
5276 HTMLElement6_get_ondurationchange,
5277 HTMLElement6_put_onemptied,
5278 HTMLElement6_get_onemptied,
5279 HTMLElement6_put_onended,
5280 HTMLElement6_get_onended,
5281 HTMLElement6_put_onerror,
5282 HTMLElement6_get_onerror,
5283 HTMLElement6_put_oninput,
5284 HTMLElement6_get_oninput,
5285 HTMLElement6_put_onload,
5286 HTMLElement6_get_onload,
5287 HTMLElement6_put_onloadeddata,
5288 HTMLElement6_get_onloadeddata,
5289 HTMLElement6_put_onloadedmetadata,
5290 HTMLElement6_get_onloadedmetadata,
5291 HTMLElement6_put_onloadstart,
5292 HTMLElement6_get_onloadstart,
5293 HTMLElement6_put_onpause,
5294 HTMLElement6_get_onpause,
5295 HTMLElement6_put_onplay,
5296 HTMLElement6_get_onplay,
5297 HTMLElement6_put_onplaying,
5298 HTMLElement6_get_onplaying,
5299 HTMLElement6_put_onprogress,
5300 HTMLElement6_get_onprogress,
5301 HTMLElement6_put_onratechange,
5302 HTMLElement6_get_onratechange,
5303 HTMLElement6_put_onreset,
5304 HTMLElement6_get_onreset,
5305 HTMLElement6_put_onseeked,
5306 HTMLElement6_get_onseeked,
5307 HTMLElement6_put_onseeking,
5308 HTMLElement6_get_onseeking,
5309 HTMLElement6_put_onselect,
5310 HTMLElement6_get_onselect,
5311 HTMLElement6_put_onstalled,
5312 HTMLElement6_get_onstalled,
5313 HTMLElement6_put_onsubmit,
5314 HTMLElement6_get_onsubmit,
5315 HTMLElement6_put_onsuspend,
5316 HTMLElement6_get_onsuspend,
5317 HTMLElement6_put_ontimeupdate,
5318 HTMLElement6_get_ontimeupdate,
5319 HTMLElement6_put_onvolumechange,
5320 HTMLElement6_get_onvolumechange,
5321 HTMLElement6_put_onwaiting,
5322 HTMLElement6_get_onwaiting,
5323 HTMLElement6_hasAttributes
5326 static inline HTMLElement *impl_from_IHTMLElement7(IHTMLElement7 *iface)
5328 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement7_iface);
5331 static HRESULT WINAPI HTMLElement7_QueryInterface(IHTMLElement7 *iface,
5332 REFIID riid, void **ppv)
5334 HTMLElement *This = impl_from_IHTMLElement7(iface);
5335 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
5338 static ULONG WINAPI HTMLElement7_AddRef(IHTMLElement7 *iface)
5340 HTMLElement *This = impl_from_IHTMLElement7(iface);
5341 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5344 static ULONG WINAPI HTMLElement7_Release(IHTMLElement7 *iface)
5346 HTMLElement *This = impl_from_IHTMLElement7(iface);
5347 return IHTMLElement_Release(&This->IHTMLElement_iface);
5350 static HRESULT WINAPI HTMLElement7_GetTypeInfoCount(IHTMLElement7 *iface, UINT *pctinfo)
5352 HTMLElement *This = impl_from_IHTMLElement7(iface);
5353 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5356 static HRESULT WINAPI HTMLElement7_GetTypeInfo(IHTMLElement7 *iface, UINT iTInfo,
5357 LCID lcid, ITypeInfo **ppTInfo)
5359 HTMLElement *This = impl_from_IHTMLElement7(iface);
5360 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5363 static HRESULT WINAPI HTMLElement7_GetIDsOfNames(IHTMLElement7 *iface, REFIID riid,
5364 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5366 HTMLElement *This = impl_from_IHTMLElement7(iface);
5367 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5368 lcid, rgDispId);
5371 static HRESULT WINAPI HTMLElement7_Invoke(IHTMLElement7 *iface, DISPID dispIdMember, REFIID riid,
5372 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5374 HTMLElement *This = impl_from_IHTMLElement7(iface);
5375 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5376 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5379 static HRESULT WINAPI HTMLElement7_put_onmspointerdown(IHTMLElement7 *iface, VARIANT v)
5381 HTMLElement *This = impl_from_IHTMLElement7(iface);
5382 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5383 return E_NOTIMPL;
5386 static HRESULT WINAPI HTMLElement7_get_onmspointerdown(IHTMLElement7 *iface, VARIANT *p)
5388 HTMLElement *This = impl_from_IHTMLElement7(iface);
5389 FIXME("(%p)->(%p)\n", This, p);
5390 return E_NOTIMPL;
5393 static HRESULT WINAPI HTMLElement7_put_onmspointermove(IHTMLElement7 *iface, VARIANT v)
5395 HTMLElement *This = impl_from_IHTMLElement7(iface);
5396 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5397 return E_NOTIMPL;
5400 static HRESULT WINAPI HTMLElement7_get_onmspointermove(IHTMLElement7 *iface, VARIANT *p)
5402 HTMLElement *This = impl_from_IHTMLElement7(iface);
5403 FIXME("(%p)->(%p)\n", This, p);
5404 return E_NOTIMPL;
5407 static HRESULT WINAPI HTMLElement7_put_onmspointerup(IHTMLElement7 *iface, VARIANT v)
5409 HTMLElement *This = impl_from_IHTMLElement7(iface);
5410 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5411 return E_NOTIMPL;
5414 static HRESULT WINAPI HTMLElement7_get_onmspointerup(IHTMLElement7 *iface, VARIANT *p)
5416 HTMLElement *This = impl_from_IHTMLElement7(iface);
5417 FIXME("(%p)->(%p)\n", This, p);
5418 return E_NOTIMPL;
5421 static HRESULT WINAPI HTMLElement7_put_onmspointerover(IHTMLElement7 *iface, VARIANT v)
5423 HTMLElement *This = impl_from_IHTMLElement7(iface);
5424 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5425 return E_NOTIMPL;
5428 static HRESULT WINAPI HTMLElement7_get_onmspointerover(IHTMLElement7 *iface, VARIANT *p)
5430 HTMLElement *This = impl_from_IHTMLElement7(iface);
5431 FIXME("(%p)->(%p)\n", This, p);
5432 return E_NOTIMPL;
5435 static HRESULT WINAPI HTMLElement7_put_onmspointerout(IHTMLElement7 *iface, VARIANT v)
5437 HTMLElement *This = impl_from_IHTMLElement7(iface);
5438 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5439 return E_NOTIMPL;
5442 static HRESULT WINAPI HTMLElement7_get_onmspointerout(IHTMLElement7 *iface, VARIANT *p)
5444 HTMLElement *This = impl_from_IHTMLElement7(iface);
5445 FIXME("(%p)->(%p)\n", This, p);
5446 return E_NOTIMPL;
5449 static HRESULT WINAPI HTMLElement7_put_onmspointercancel(IHTMLElement7 *iface, VARIANT v)
5451 HTMLElement *This = impl_from_IHTMLElement7(iface);
5452 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5453 return E_NOTIMPL;
5456 static HRESULT WINAPI HTMLElement7_get_onmspointercancel(IHTMLElement7 *iface, VARIANT *p)
5458 HTMLElement *This = impl_from_IHTMLElement7(iface);
5459 FIXME("(%p)->(%p)\n", This, p);
5460 return E_NOTIMPL;
5463 static HRESULT WINAPI HTMLElement7_put_onmspointerhover(IHTMLElement7 *iface, VARIANT v)
5465 HTMLElement *This = impl_from_IHTMLElement7(iface);
5466 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5467 return E_NOTIMPL;
5470 static HRESULT WINAPI HTMLElement7_get_onmspointerhover(IHTMLElement7 *iface, VARIANT *p)
5472 HTMLElement *This = impl_from_IHTMLElement7(iface);
5473 FIXME("(%p)->(%p)\n", This, p);
5474 return E_NOTIMPL;
5477 static HRESULT WINAPI HTMLElement7_put_onmslostpointercapture(IHTMLElement7 *iface, VARIANT v)
5479 HTMLElement *This = impl_from_IHTMLElement7(iface);
5480 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5481 return E_NOTIMPL;
5484 static HRESULT WINAPI HTMLElement7_get_onmslostpointercapture(IHTMLElement7 *iface, VARIANT *p)
5486 HTMLElement *This = impl_from_IHTMLElement7(iface);
5487 FIXME("(%p)->(%p)\n", This, p);
5488 return E_NOTIMPL;
5491 static HRESULT WINAPI HTMLElement7_put_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT v)
5493 HTMLElement *This = impl_from_IHTMLElement7(iface);
5494 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5495 return E_NOTIMPL;
5498 static HRESULT WINAPI HTMLElement7_get_onmsgotpointercapture(IHTMLElement7 *iface, VARIANT *p)
5500 HTMLElement *This = impl_from_IHTMLElement7(iface);
5501 FIXME("(%p)->(%p)\n", This, p);
5502 return E_NOTIMPL;
5505 static HRESULT WINAPI HTMLElement7_put_onmsgesturestart(IHTMLElement7 *iface, VARIANT v)
5507 HTMLElement *This = impl_from_IHTMLElement7(iface);
5508 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5509 return E_NOTIMPL;
5512 static HRESULT WINAPI HTMLElement7_get_onmsgesturestart(IHTMLElement7 *iface, VARIANT *p)
5514 HTMLElement *This = impl_from_IHTMLElement7(iface);
5515 FIXME("(%p)->(%p)\n", This, p);
5516 return E_NOTIMPL;
5519 static HRESULT WINAPI HTMLElement7_put_onmsgesturechange(IHTMLElement7 *iface, VARIANT v)
5521 HTMLElement *This = impl_from_IHTMLElement7(iface);
5522 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5523 return E_NOTIMPL;
5526 static HRESULT WINAPI HTMLElement7_get_onmsgesturechange(IHTMLElement7 *iface, VARIANT *p)
5528 HTMLElement *This = impl_from_IHTMLElement7(iface);
5529 FIXME("(%p)->(%p)\n", This, p);
5530 return E_NOTIMPL;
5533 static HRESULT WINAPI HTMLElement7_put_onmsgestureend(IHTMLElement7 *iface, VARIANT v)
5535 HTMLElement *This = impl_from_IHTMLElement7(iface);
5536 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5537 return E_NOTIMPL;
5540 static HRESULT WINAPI HTMLElement7_get_onmsgestureend(IHTMLElement7 *iface, VARIANT *p)
5542 HTMLElement *This = impl_from_IHTMLElement7(iface);
5543 FIXME("(%p)->(%p)\n", This, p);
5544 return E_NOTIMPL;
5547 static HRESULT WINAPI HTMLElement7_put_onmsgesturehold(IHTMLElement7 *iface, VARIANT v)
5549 HTMLElement *This = impl_from_IHTMLElement7(iface);
5550 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5551 return E_NOTIMPL;
5554 static HRESULT WINAPI HTMLElement7_get_onmsgesturehold(IHTMLElement7 *iface, VARIANT *p)
5556 HTMLElement *This = impl_from_IHTMLElement7(iface);
5557 FIXME("(%p)->(%p)\n", This, p);
5558 return E_NOTIMPL;
5561 static HRESULT WINAPI HTMLElement7_put_onmsgesturetap(IHTMLElement7 *iface, VARIANT v)
5563 HTMLElement *This = impl_from_IHTMLElement7(iface);
5564 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5565 return E_NOTIMPL;
5568 static HRESULT WINAPI HTMLElement7_get_onmsgesturetap(IHTMLElement7 *iface, VARIANT *p)
5570 HTMLElement *This = impl_from_IHTMLElement7(iface);
5571 FIXME("(%p)->(%p)\n", This, p);
5572 return E_NOTIMPL;
5575 static HRESULT WINAPI HTMLElement7_put_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT v)
5577 HTMLElement *This = impl_from_IHTMLElement7(iface);
5578 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5579 return E_NOTIMPL;
5582 static HRESULT WINAPI HTMLElement7_get_onmsgesturedoubletap(IHTMLElement7 *iface, VARIANT *p)
5584 HTMLElement *This = impl_from_IHTMLElement7(iface);
5585 FIXME("(%p)->(%p)\n", This, p);
5586 return E_NOTIMPL;
5589 static HRESULT WINAPI HTMLElement7_put_onmsinertiastart(IHTMLElement7 *iface, VARIANT v)
5591 HTMLElement *This = impl_from_IHTMLElement7(iface);
5592 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5593 return E_NOTIMPL;
5596 static HRESULT WINAPI HTMLElement7_get_onmsinertiastart(IHTMLElement7 *iface, VARIANT *p)
5598 HTMLElement *This = impl_from_IHTMLElement7(iface);
5599 FIXME("(%p)->(%p)\n", This, p);
5600 return E_NOTIMPL;
5603 static HRESULT WINAPI HTMLElement7_msSetPointerCapture(IHTMLElement7 *iface, LONG pointer_id)
5605 HTMLElement *This = impl_from_IHTMLElement7(iface);
5606 FIXME("(%p)->(%d)\n", This, pointer_id);
5607 return E_NOTIMPL;
5610 static HRESULT WINAPI HTMLElement7_msReleasePointerCapture(IHTMLElement7 *iface, LONG pointer_id)
5612 HTMLElement *This = impl_from_IHTMLElement7(iface);
5613 FIXME("(%p)->(%d)\n", This, pointer_id);
5614 return E_NOTIMPL;
5617 static HRESULT WINAPI HTMLElement7_put_onmstransitionstart(IHTMLElement7 *iface, VARIANT v)
5619 HTMLElement *This = impl_from_IHTMLElement7(iface);
5620 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5621 return E_NOTIMPL;
5624 static HRESULT WINAPI HTMLElement7_get_onmstransitionstart(IHTMLElement7 *iface, VARIANT *p)
5626 HTMLElement *This = impl_from_IHTMLElement7(iface);
5627 FIXME("(%p)->(%p)\n", This, p);
5628 return E_NOTIMPL;
5631 static HRESULT WINAPI HTMLElement7_put_onmstransitionend(IHTMLElement7 *iface, VARIANT v)
5633 HTMLElement *This = impl_from_IHTMLElement7(iface);
5634 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5635 return E_NOTIMPL;
5638 static HRESULT WINAPI HTMLElement7_get_onmstransitionend(IHTMLElement7 *iface, VARIANT *p)
5640 HTMLElement *This = impl_from_IHTMLElement7(iface);
5641 FIXME("(%p)->(%p)\n", This, p);
5642 return E_NOTIMPL;
5645 static HRESULT WINAPI HTMLElement7_put_onmsanimationstart(IHTMLElement7 *iface, VARIANT v)
5647 HTMLElement *This = impl_from_IHTMLElement7(iface);
5648 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5649 return E_NOTIMPL;
5652 static HRESULT WINAPI HTMLElement7_get_onmsanimationstart(IHTMLElement7 *iface, VARIANT *p)
5654 HTMLElement *This = impl_from_IHTMLElement7(iface);
5655 FIXME("(%p)->(%p)\n", This, p);
5656 return E_NOTIMPL;
5659 static HRESULT WINAPI HTMLElement7_put_onmsanimationend(IHTMLElement7 *iface, VARIANT v)
5661 HTMLElement *This = impl_from_IHTMLElement7(iface);
5662 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5663 return E_NOTIMPL;
5666 static HRESULT WINAPI HTMLElement7_get_onmsanimationend(IHTMLElement7 *iface, VARIANT *p)
5668 HTMLElement *This = impl_from_IHTMLElement7(iface);
5669 FIXME("(%p)->(%p)\n", This, p);
5670 return E_NOTIMPL;
5673 static HRESULT WINAPI HTMLElement7_put_onmsanimationiteration(IHTMLElement7 *iface, VARIANT v)
5675 HTMLElement *This = impl_from_IHTMLElement7(iface);
5676 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5677 return E_NOTIMPL;
5680 static HRESULT WINAPI HTMLElement7_get_onmsanimationiteration(IHTMLElement7 *iface, VARIANT *p)
5682 HTMLElement *This = impl_from_IHTMLElement7(iface);
5683 FIXME("(%p)->(%p)\n", This, p);
5684 return E_NOTIMPL;
5687 static HRESULT WINAPI HTMLElement7_put_oninvalid(IHTMLElement7 *iface, VARIANT v)
5689 HTMLElement *This = impl_from_IHTMLElement7(iface);
5690 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5691 return E_NOTIMPL;
5694 static HRESULT WINAPI HTMLElement7_get_oninvalid(IHTMLElement7 *iface, VARIANT *p)
5696 HTMLElement *This = impl_from_IHTMLElement7(iface);
5697 FIXME("(%p)->(%p)\n", This, p);
5698 return E_NOTIMPL;
5701 static HRESULT WINAPI HTMLElement7_put_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR v)
5703 HTMLElement *This = impl_from_IHTMLElement7(iface);
5704 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
5705 return E_NOTIMPL;
5708 static HRESULT WINAPI HTMLElement7_get_xmsAcceleratorKey(IHTMLElement7 *iface, BSTR *p)
5710 HTMLElement *This = impl_from_IHTMLElement7(iface);
5711 FIXME("(%p)->(%p)\n", This, p);
5712 return E_NOTIMPL;
5715 static HRESULT WINAPI HTMLElement7_put_spellcheck(IHTMLElement7 *iface, VARIANT v)
5717 HTMLElement *This = impl_from_IHTMLElement7(iface);
5719 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
5721 if(!This->html_element) {
5722 FIXME("non-HTML element\n");
5723 return E_NOTIMPL;
5726 if(V_VT(&v) != VT_BOOL) {
5727 FIXME("unsupported argument %s\n", debugstr_variant(&v));
5728 return E_NOTIMPL;
5731 return map_nsresult(nsIDOMHTMLElement_SetSpellcheck(This->html_element, !!V_BOOL(&v)));
5734 static HRESULT WINAPI HTMLElement7_get_spellcheck(IHTMLElement7 *iface, VARIANT *p)
5736 HTMLElement *This = impl_from_IHTMLElement7(iface);
5737 cpp_bool spellcheck;
5738 nsresult nsres;
5740 TRACE("(%p)->(%p)\n", This, p);
5742 if(!This->html_element) {
5743 FIXME("non-HTML element\n");
5744 return E_NOTIMPL;
5747 nsres = nsIDOMHTMLElement_GetSpellcheck(This->html_element, &spellcheck);
5748 if(NS_FAILED(nsres))
5749 return map_nsresult(nsres);
5751 V_VT(p) = VT_BOOL;
5752 V_BOOL(p) = spellcheck ? VARIANT_TRUE : VARIANT_FALSE;
5753 return S_OK;
5756 static HRESULT WINAPI HTMLElement7_put_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT v)
5758 HTMLElement *This = impl_from_IHTMLElement7(iface);
5759 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5760 return E_NOTIMPL;
5763 static HRESULT WINAPI HTMLElement7_get_onmsmanipulationstatechanged(IHTMLElement7 *iface, VARIANT *p)
5765 HTMLElement *This = impl_from_IHTMLElement7(iface);
5766 FIXME("(%p)->(%p)\n", This, p);
5767 return E_NOTIMPL;
5770 static HRESULT WINAPI HTMLElement7_put_oncuechange(IHTMLElement7 *iface, VARIANT v)
5772 HTMLElement *This = impl_from_IHTMLElement7(iface);
5773 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
5774 return E_NOTIMPL;
5777 static HRESULT WINAPI HTMLElement7_get_oncuechange(IHTMLElement7 *iface, VARIANT *p)
5779 HTMLElement *This = impl_from_IHTMLElement7(iface);
5780 FIXME("(%p)->(%p)\n", This, p);
5781 return E_NOTIMPL;
5784 static const IHTMLElement7Vtbl HTMLElement7Vtbl = {
5785 HTMLElement7_QueryInterface,
5786 HTMLElement7_AddRef,
5787 HTMLElement7_Release,
5788 HTMLElement7_GetTypeInfoCount,
5789 HTMLElement7_GetTypeInfo,
5790 HTMLElement7_GetIDsOfNames,
5791 HTMLElement7_Invoke,
5792 HTMLElement7_put_onmspointerdown,
5793 HTMLElement7_get_onmspointerdown,
5794 HTMLElement7_put_onmspointermove,
5795 HTMLElement7_get_onmspointermove,
5796 HTMLElement7_put_onmspointerup,
5797 HTMLElement7_get_onmspointerup,
5798 HTMLElement7_put_onmspointerover,
5799 HTMLElement7_get_onmspointerover,
5800 HTMLElement7_put_onmspointerout,
5801 HTMLElement7_get_onmspointerout,
5802 HTMLElement7_put_onmspointercancel,
5803 HTMLElement7_get_onmspointercancel,
5804 HTMLElement7_put_onmspointerhover,
5805 HTMLElement7_get_onmspointerhover,
5806 HTMLElement7_put_onmslostpointercapture,
5807 HTMLElement7_get_onmslostpointercapture,
5808 HTMLElement7_put_onmsgotpointercapture,
5809 HTMLElement7_get_onmsgotpointercapture,
5810 HTMLElement7_put_onmsgesturestart,
5811 HTMLElement7_get_onmsgesturestart,
5812 HTMLElement7_put_onmsgesturechange,
5813 HTMLElement7_get_onmsgesturechange,
5814 HTMLElement7_put_onmsgestureend,
5815 HTMLElement7_get_onmsgestureend,
5816 HTMLElement7_put_onmsgesturehold,
5817 HTMLElement7_get_onmsgesturehold,
5818 HTMLElement7_put_onmsgesturetap,
5819 HTMLElement7_get_onmsgesturetap,
5820 HTMLElement7_put_onmsgesturedoubletap,
5821 HTMLElement7_get_onmsgesturedoubletap,
5822 HTMLElement7_put_onmsinertiastart,
5823 HTMLElement7_get_onmsinertiastart,
5824 HTMLElement7_msSetPointerCapture,
5825 HTMLElement7_msReleasePointerCapture,
5826 HTMLElement7_put_onmstransitionstart,
5827 HTMLElement7_get_onmstransitionstart,
5828 HTMLElement7_put_onmstransitionend,
5829 HTMLElement7_get_onmstransitionend,
5830 HTMLElement7_put_onmsanimationstart,
5831 HTMLElement7_get_onmsanimationstart,
5832 HTMLElement7_put_onmsanimationend,
5833 HTMLElement7_get_onmsanimationend,
5834 HTMLElement7_put_onmsanimationiteration,
5835 HTMLElement7_get_onmsanimationiteration,
5836 HTMLElement7_put_oninvalid,
5837 HTMLElement7_get_oninvalid,
5838 HTMLElement7_put_xmsAcceleratorKey,
5839 HTMLElement7_get_xmsAcceleratorKey,
5840 HTMLElement7_put_spellcheck,
5841 HTMLElement7_get_spellcheck,
5842 HTMLElement7_put_onmsmanipulationstatechanged,
5843 HTMLElement7_get_onmsmanipulationstatechanged,
5844 HTMLElement7_put_oncuechange,
5845 HTMLElement7_get_oncuechange
5849 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
5851 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
5854 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
5856 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5857 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
5860 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
5862 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5863 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5866 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
5868 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5869 return IHTMLElement_Release(&This->IHTMLElement_iface);
5872 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
5874 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5875 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5878 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
5879 LCID lcid, ITypeInfo **ppTInfo)
5881 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5882 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5885 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
5886 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5888 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5889 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5890 lcid, rgDispId);
5893 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
5894 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5896 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5897 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5898 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5901 HRESULT elem_unique_id(unsigned id, BSTR *p)
5903 WCHAR buf[32];
5905 swprintf(buf, ARRAY_SIZE(buf), L"ms__id%u", id);
5906 *p = SysAllocString(buf);
5907 return *p ? S_OK : E_OUTOFMEMORY;
5910 static void ensure_unique_id(HTMLElement *elem)
5912 if(!elem->unique_id)
5913 elem->unique_id = ++elem->node.doc->unique_id;
5916 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
5918 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5920 TRACE("(%p)->(%p)\n", This, p);
5922 ensure_unique_id(This);
5923 *p = This->unique_id;
5924 return S_OK;
5927 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
5929 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
5931 TRACE("(%p)->(%p)\n", This, p);
5933 ensure_unique_id(This);
5934 return elem_unique_id(This->unique_id, p);
5937 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
5938 HTMLUniqueName_QueryInterface,
5939 HTMLUniqueName_AddRef,
5940 HTMLUniqueName_Release,
5941 HTMLUniqueName_GetTypeInfoCount,
5942 HTMLUniqueName_GetTypeInfo,
5943 HTMLUniqueName_GetIDsOfNames,
5944 HTMLUniqueName_Invoke,
5945 HTMLUniqueName_get_uniqueNumber,
5946 HTMLUniqueName_get_uniqueID
5949 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
5951 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
5954 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
5956 HTMLElement *This = impl_from_IElementSelector(iface);
5957 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
5960 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
5962 HTMLElement *This = impl_from_IElementSelector(iface);
5963 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5966 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
5968 HTMLElement *This = impl_from_IElementSelector(iface);
5969 return IHTMLElement_Release(&This->IHTMLElement_iface);
5972 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
5974 HTMLElement *This = impl_from_IElementSelector(iface);
5975 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5978 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
5979 LCID lcid, ITypeInfo **ppTInfo)
5981 HTMLElement *This = impl_from_IElementSelector(iface);
5982 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5985 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
5986 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5988 HTMLElement *This = impl_from_IElementSelector(iface);
5989 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
5992 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
5993 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5995 HTMLElement *This = impl_from_IElementSelector(iface);
5996 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5997 pDispParams, pVarResult, pExcepInfo, puArgErr);
6000 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
6002 HTMLElement *This = impl_from_IElementSelector(iface);
6003 nsIDOMElement *nselem;
6004 HTMLElement *elem;
6005 nsAString nsstr;
6006 nsresult nsres;
6007 HRESULT hres;
6009 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6011 if(!This->dom_element) {
6012 FIXME("comment element\n");
6013 return E_NOTIMPL;
6016 nsAString_InitDepend(&nsstr, v);
6017 nsres = nsIDOMElement_QuerySelector(This->dom_element, &nsstr, &nselem);
6018 nsAString_Finish(&nsstr);
6019 if(NS_FAILED(nsres)) {
6020 ERR("QuerySelector failed: %08x\n", nsres);
6021 return E_FAIL;
6024 if(!nselem) {
6025 *pel = NULL;
6026 return S_OK;
6029 hres = get_element(nselem, &elem);
6030 nsIDOMElement_Release(nselem);
6031 if(FAILED(hres))
6032 return hres;
6034 *pel = &elem->IHTMLElement_iface;
6035 return S_OK;
6038 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
6040 HTMLElement *This = impl_from_IElementSelector(iface);
6041 nsIDOMNodeList *node_list;
6042 nsAString nsstr;
6043 HRESULT hres;
6045 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
6047 if(!This->dom_element) {
6048 FIXME("comment element\n");
6049 return E_NOTIMPL;
6052 nsAString_InitDepend(&nsstr, v);
6053 hres = map_nsresult(nsIDOMElement_QuerySelectorAll(This->dom_element, &nsstr, &node_list));
6054 nsAString_Finish(&nsstr);
6055 if(FAILED(hres)) {
6056 ERR("QuerySelectorAll failed: %08x\n", hres);
6057 return hres;
6060 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
6061 nsIDOMNodeList_Release(node_list);
6062 return hres;
6065 static const IElementSelectorVtbl ElementSelectorVtbl = {
6066 ElementSelector_QueryInterface,
6067 ElementSelector_AddRef,
6068 ElementSelector_Release,
6069 ElementSelector_GetTypeInfoCount,
6070 ElementSelector_GetTypeInfo,
6071 ElementSelector_GetIDsOfNames,
6072 ElementSelector_Invoke,
6073 ElementSelector_querySelector,
6074 ElementSelector_querySelectorAll
6077 static inline HTMLElement *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
6079 return CONTAINING_RECORD(iface, HTMLElement, IProvideMultipleClassInfo_iface);
6082 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
6083 REFIID riid, void **ppv)
6085 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6086 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6089 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
6091 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6092 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6095 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
6097 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6098 return IHTMLElement_Release(&This->IHTMLElement_iface);
6101 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
6103 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6104 TRACE("(%p)->(%p)\n", This, ppTI);
6105 return get_class_typeinfo(This->node.vtbl->clsid, ppTI);
6108 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
6110 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6111 FIXME("(%p)->(%u %p)\n", This, dwGuidKind, pGUID);
6112 return E_NOTIMPL;
6115 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
6117 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6118 FIXME("(%p)->(%p)\n", This, pcti);
6119 *pcti = 1;
6120 return S_OK;
6123 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
6124 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
6126 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
6127 FIXME("(%p)->(%u %x %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
6128 return E_NOTIMPL;
6131 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
6132 ProvideClassInfo_QueryInterface,
6133 ProvideClassInfo_AddRef,
6134 ProvideClassInfo_Release,
6135 ProvideClassInfo_GetClassInfo,
6136 ProvideClassInfo2_GetGUID,
6137 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
6138 ProvideMultipleClassInfo_GetInfoOfIndex
6141 static inline HTMLElement *impl_from_IElementTraversal(IElementTraversal *iface)
6143 return CONTAINING_RECORD(iface, HTMLElement, IElementTraversal_iface);
6146 static HRESULT WINAPI ElementTraversal_QueryInterface(IElementTraversal *iface, REFIID riid, void **ppv)
6148 HTMLElement *This = impl_from_IElementTraversal(iface);
6149 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6152 static ULONG WINAPI ElementTraversal_AddRef(IElementTraversal *iface)
6154 HTMLElement *This = impl_from_IElementTraversal(iface);
6156 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6159 static ULONG WINAPI ElementTraversal_Release(IElementTraversal *iface)
6161 HTMLElement *This = impl_from_IElementTraversal(iface);
6163 return IHTMLElement_Release(&This->IHTMLElement_iface);
6166 static HRESULT WINAPI ElementTraversal_GetTypeInfoCount(IElementTraversal *iface, UINT *pctinfo)
6168 HTMLElement *This = impl_from_IElementTraversal(iface);
6169 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
6172 static HRESULT WINAPI ElementTraversal_GetTypeInfo(IElementTraversal *iface, UINT iTInfo,
6173 LCID lcid, ITypeInfo **ppTInfo)
6175 HTMLElement *This = impl_from_IElementTraversal(iface);
6176 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6179 static HRESULT WINAPI ElementTraversal_GetIDsOfNames(IElementTraversal *iface, REFIID riid,
6180 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6182 HTMLElement *This = impl_from_IElementTraversal(iface);
6183 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6184 lcid, rgDispId);
6187 static HRESULT WINAPI ElementTraversal_Invoke(IElementTraversal *iface, DISPID dispIdMember, REFIID riid,
6188 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6190 HTMLElement *This = impl_from_IElementTraversal(iface);
6191 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6192 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6195 static HRESULT WINAPI ElementTraversal_get_firstElementChild(IElementTraversal *iface, IHTMLElement **p)
6197 HTMLElement *This = impl_from_IElementTraversal(iface);
6198 nsIDOMElement *nselem = NULL;
6199 HTMLElement *elem;
6200 HRESULT hres;
6202 TRACE("(%p)->(%p)\n", This, p);
6204 if(!This->dom_element) {
6205 *p = NULL;
6206 return S_OK;
6209 nsIDOMElement_GetFirstElementChild(This->dom_element, &nselem);
6210 if(!nselem) {
6211 *p = NULL;
6212 return S_OK;
6215 hres = get_element(nselem, &elem);
6216 nsIDOMElement_Release(nselem);
6217 if(FAILED(hres))
6218 return hres;
6220 *p = &elem->IHTMLElement_iface;
6221 return S_OK;
6224 static HRESULT WINAPI ElementTraversal_get_lastElementChild(IElementTraversal *iface, IHTMLElement **p)
6226 HTMLElement *This = impl_from_IElementTraversal(iface);
6227 FIXME("(%p)->(%p)\n", This, p);
6228 return E_NOTIMPL;
6231 static HRESULT WINAPI ElementTraversal_get_previousElementSibling(IElementTraversal *iface, IHTMLElement **p)
6233 HTMLElement *This = impl_from_IElementTraversal(iface);
6234 FIXME("(%p)->(%p)\n", This, p);
6235 return E_NOTIMPL;
6238 static HRESULT WINAPI ElementTraversal_get_nextElementSibling(IElementTraversal *iface, IHTMLElement **p)
6240 HTMLElement *This = impl_from_IElementTraversal(iface);
6241 FIXME("(%p)->(%p)\n", This, p);
6242 return E_NOTIMPL;
6245 static HRESULT WINAPI ElementTraversal_get_childElementCount(IElementTraversal *iface, LONG *p)
6247 HTMLElement *This = impl_from_IElementTraversal(iface);
6248 FIXME("(%p)->(%p)\n", This, p);
6249 return E_NOTIMPL;
6252 static const IElementTraversalVtbl ElementTraversalVtbl = {
6253 ElementTraversal_QueryInterface,
6254 ElementTraversal_AddRef,
6255 ElementTraversal_Release,
6256 ElementTraversal_GetTypeInfoCount,
6257 ElementTraversal_GetTypeInfo,
6258 ElementTraversal_GetIDsOfNames,
6259 ElementTraversal_Invoke,
6260 ElementTraversal_get_firstElementChild,
6261 ElementTraversal_get_lastElementChild,
6262 ElementTraversal_get_previousElementSibling,
6263 ElementTraversal_get_nextElementSibling,
6264 ElementTraversal_get_childElementCount
6267 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
6269 return CONTAINING_RECORD(iface, HTMLElement, node);
6272 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
6274 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6276 if(IsEqualGUID(&IID_IUnknown, riid)) {
6277 *ppv = &This->IHTMLElement_iface;
6278 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
6279 *ppv = &This->IHTMLElement_iface;
6280 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
6281 *ppv = &This->IHTMLElement_iface;
6282 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
6283 *ppv = &This->IHTMLElement2_iface;
6284 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
6285 *ppv = &This->IHTMLElement3_iface;
6286 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
6287 *ppv = &This->IHTMLElement4_iface;
6288 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
6289 *ppv = &This->IHTMLElement6_iface;
6290 }else if(IsEqualGUID(&IID_IHTMLElement7, riid)) {
6291 *ppv = &This->IHTMLElement7_iface;
6292 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
6293 *ppv = &This->IHTMLUniqueName_iface;
6294 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
6295 *ppv = &This->IElementSelector_iface;
6296 }else if(IsEqualGUID(&IID_IElementTraversal, riid)) {
6297 *ppv = &This->IElementTraversal_iface;
6298 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
6299 *ppv = &This->cp_container.IConnectionPointContainer_iface;
6300 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
6301 *ppv = &This->IProvideMultipleClassInfo_iface;
6302 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
6303 *ppv = &This->IProvideMultipleClassInfo_iface;
6304 }else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid)) {
6305 *ppv = &This->IProvideMultipleClassInfo_iface;
6306 }else if(IsEqualGUID(&IID_IWineHTMLElementPrivate, riid)) {
6307 *ppv = &This->IWineHTMLElementPrivate_iface;
6308 }else {
6309 return HTMLDOMNode_QI(&This->node, riid, ppv);
6312 IUnknown_AddRef((IUnknown*)*ppv);
6313 return S_OK;
6316 void HTMLElement_destructor(HTMLDOMNode *iface)
6318 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6320 ConnectionPointContainer_Destroy(&This->cp_container);
6322 if(This->style) {
6323 This->style->elem = NULL;
6324 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
6326 if(This->runtime_style) {
6327 This->runtime_style->elem = NULL;
6328 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
6330 if(This->attrs) {
6331 HTMLDOMAttribute *attr;
6333 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
6334 attr->elem = NULL;
6336 This->attrs->elem = NULL;
6337 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
6340 heap_free(This->filter);
6342 HTMLDOMNode_destructor(&This->node);
6345 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
6347 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6348 HTMLElement *new_elem;
6349 HRESULT hres;
6351 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
6352 if(FAILED(hres))
6353 return hres;
6355 if(This->filter) {
6356 new_elem->filter = heap_strdupW(This->filter);
6357 if(!new_elem->filter) {
6358 IHTMLElement_Release(&This->IHTMLElement_iface);
6359 return E_OUTOFMEMORY;
6363 *ret = &new_elem->node;
6364 return S_OK;
6367 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
6369 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6371 switch(eid) {
6372 case EVENTID_KEYDOWN: {
6373 nsIDOMKeyEvent *key_event;
6374 nsresult nsres;
6376 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
6377 if(NS_SUCCEEDED(nsres)) {
6378 UINT32 code = 0;
6380 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
6382 if(code == VK_F1 /* DOM_VK_F1 */) {
6383 DOMEvent *help_event;
6384 HRESULT hres;
6386 TRACE("F1 pressed\n");
6388 hres = create_document_event(This->node.doc, EVENTID_HELP, &help_event);
6389 if(SUCCEEDED(hres)) {
6390 dispatch_event(&This->node.event_target, help_event);
6391 IDOMEvent_Release(&help_event->IDOMEvent_iface);
6393 *prevent_default = TRUE;
6396 nsIDOMKeyEvent_Release(key_event);
6401 return S_OK;
6404 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
6406 const cpc_entry_t HTMLElement_cpc[] = {
6407 HTMLELEMENT_CPC,
6408 {NULL}
6411 static const NodeImplVtbl HTMLElementImplVtbl = {
6412 &CLSID_HTMLUnknownElement,
6413 HTMLElement_QI,
6414 HTMLElement_destructor,
6415 HTMLElement_cpc,
6416 HTMLElement_clone,
6417 HTMLElement_handle_event,
6418 HTMLElement_get_attr_col
6421 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
6423 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
6426 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
6427 DWORD grfdex, DISPID *pid)
6429 HTMLElement *This = impl_from_DispatchEx(dispex);
6431 if(This->node.vtbl->get_dispid)
6432 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
6434 return DISP_E_UNKNOWNNAME;
6437 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
6438 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
6439 IServiceProvider *caller)
6441 HTMLElement *This = impl_from_DispatchEx(dispex);
6443 if(This->node.vtbl->invoke)
6444 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
6445 params, res, ei, caller);
6447 ERR("(%p): element has no invoke method\n", This);
6448 return E_NOTIMPL;
6451 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
6453 HTMLElement *This = impl_from_DispatchEx(dispex);
6454 nsIDOMMozNamedAttrMap *attrs;
6455 nsIDOMAttr *attr;
6456 nsAString nsstr;
6457 const PRUnichar *str;
6458 BSTR name;
6459 VARIANT value;
6460 unsigned i;
6461 UINT32 len;
6462 DISPID id;
6463 nsresult nsres;
6464 HRESULT hres;
6466 if(!This->dom_element)
6467 return S_FALSE;
6469 nsres = nsIDOMElement_GetAttributes(This->dom_element, &attrs);
6470 if(NS_FAILED(nsres))
6471 return E_FAIL;
6473 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
6474 if(NS_FAILED(nsres)) {
6475 nsIDOMMozNamedAttrMap_Release(attrs);
6476 return E_FAIL;
6479 nsAString_Init(&nsstr, NULL);
6480 for(i=0; i<len; i++) {
6481 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
6482 if(NS_FAILED(nsres))
6483 continue;
6485 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
6486 if(NS_FAILED(nsres)) {
6487 nsIDOMAttr_Release(attr);
6488 continue;
6491 nsAString_GetData(&nsstr, &str);
6492 name = SysAllocString(str);
6493 if(!name) {
6494 nsIDOMAttr_Release(attr);
6495 continue;
6498 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
6499 if(hres != DISP_E_UNKNOWNNAME) {
6500 nsIDOMAttr_Release(attr);
6501 SysFreeString(name);
6502 continue;
6505 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
6506 nsIDOMAttr_Release(attr);
6507 if(NS_FAILED(nsres)) {
6508 SysFreeString(name);
6509 continue;
6512 nsAString_GetData(&nsstr, &str);
6513 V_VT(&value) = VT_BSTR;
6514 if(*str) {
6515 V_BSTR(&value) = SysAllocString(str);
6516 if(!V_BSTR(&value)) {
6517 SysFreeString(name);
6518 continue;
6520 } else
6521 V_BSTR(&value) = NULL;
6523 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
6524 SysFreeString(name);
6525 VariantClear(&value);
6527 nsAString_Finish(&nsstr);
6529 nsIDOMMozNamedAttrMap_Release(attrs);
6530 return S_OK;
6533 static nsISupports *HTMLElement_get_gecko_target(DispatchEx *dispex)
6535 HTMLElement *This = impl_from_DispatchEx(dispex);
6536 return (nsISupports*)This->node.nsnode;
6539 static void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
6541 HTMLElement *This = impl_from_DispatchEx(dispex);
6542 ensure_doc_nsevent_handler(This->node.doc, This->node.nsnode, eid);
6545 static HRESULT HTMLElement_handle_event_default(DispatchEx *dispex, eventid_t eid, nsIDOMEvent *nsevent, BOOL *prevent_default)
6547 HTMLElement *This = impl_from_DispatchEx(dispex);
6549 if(!This->node.vtbl->handle_event)
6550 return S_OK;
6551 return This->node.vtbl->handle_event(&This->node, eid, nsevent, prevent_default);
6554 static EventTarget *HTMLElement_get_parent_event_target(DispatchEx *dispex)
6556 HTMLElement *This = impl_from_DispatchEx(dispex);
6557 HTMLDOMNode *node;
6558 nsIDOMNode *nsnode;
6559 nsresult nsres;
6560 HRESULT hres;
6562 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
6563 assert(nsres == NS_OK);
6564 if(!nsnode)
6565 return NULL;
6567 hres = get_node(nsnode, TRUE, &node);
6568 nsIDOMNode_Release(nsnode);
6569 if(FAILED(hres))
6570 return NULL;
6572 return &node->event_target;
6575 static ConnectionPointContainer *HTMLElement_get_cp_container(DispatchEx *dispex)
6577 HTMLElement *This = impl_from_DispatchEx(dispex);
6578 IConnectionPointContainer_AddRef(&This->cp_container.IConnectionPointContainer_iface);
6579 return &This->cp_container;
6582 static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6584 HTMLElement *This = impl_from_DispatchEx(dispex);
6585 return default_set_current_event(This->node.doc->window, event);
6588 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6590 static const dispex_hook_t elem2_ie11_hooks[] = {
6591 {DISPID_IHTMLELEMENT2_DOSCROLL, NULL},
6592 {DISPID_IHTMLELEMENT2_READYSTATE, NULL},
6593 {DISPID_UNKNOWN}
6596 HTMLDOMNode_init_dispex_info(info, mode);
6598 dispex_info_add_interface(info, IHTMLElement2_tid, mode >= COMPAT_MODE_IE11 ? elem2_ie11_hooks : NULL);
6600 if(mode >= COMPAT_MODE_IE8)
6601 dispex_info_add_interface(info, IElementSelector_tid, NULL);
6603 if(mode >= COMPAT_MODE_IE9) {
6604 dispex_info_add_interface(info, IHTMLElement6_tid, NULL);
6605 dispex_info_add_interface(info, IElementTraversal_tid, NULL);
6608 if(mode >= COMPAT_MODE_IE10)
6610 dispex_info_add_interface(info, IHTMLElement7_tid, NULL);
6611 dispex_info_add_interface(info, IWineHTMLElementPrivate_tid, NULL);
6615 static const tid_t HTMLElement_iface_tids[] = {
6616 HTMLELEMENT_TIDS,
6620 static event_target_vtbl_t HTMLElement_event_target_vtbl = {
6622 NULL,
6623 HTMLElement_get_dispid,
6624 HTMLElement_invoke,
6625 NULL,
6626 HTMLElement_populate_props
6628 HTMLElement_get_gecko_target,
6629 HTMLElement_bind_event,
6630 HTMLElement_get_parent_event_target,
6631 HTMLElement_handle_event_default,
6632 HTMLElement_get_cp_container,
6633 HTMLElement_set_current_event
6636 struct token_list {
6637 DispatchEx dispex;
6638 IWineDOMTokenList IWineDOMTokenList_iface;
6639 IHTMLElement *element;
6641 LONG ref;
6644 static inline struct token_list *impl_from_IWineDOMTokenList(IWineDOMTokenList *iface)
6646 return CONTAINING_RECORD(iface, struct token_list, IWineDOMTokenList_iface);
6649 static HRESULT WINAPI token_list_QueryInterface(IWineDOMTokenList *iface, REFIID riid, void **ppv)
6651 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6653 TRACE("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
6655 if(IsEqualGUID(&IID_IUnknown, riid)) {
6656 *ppv = &token_list->IWineDOMTokenList_iface;
6657 }else if(IsEqualGUID(&IID_IWineDOMTokenList, riid)) {
6658 *ppv = &token_list->IWineDOMTokenList_iface;
6659 }else if(dispex_query_interface(&token_list->dispex, riid, ppv)) {
6660 return *ppv ? S_OK : E_NOINTERFACE;
6661 }else {
6662 WARN("(%p)->(%s %p)\n", token_list, debugstr_mshtml_guid(riid), ppv);
6663 *ppv = NULL;
6664 return E_NOINTERFACE;
6667 IUnknown_AddRef((IUnknown*)*ppv);
6668 return S_OK;
6671 static ULONG WINAPI token_list_AddRef(IWineDOMTokenList *iface)
6673 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6674 LONG ref = InterlockedIncrement(&token_list->ref);
6676 TRACE("(%p) ref=%d\n", token_list, ref);
6678 return ref;
6681 static ULONG WINAPI token_list_Release(IWineDOMTokenList *iface)
6683 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6684 LONG ref = InterlockedDecrement(&token_list->ref);
6686 TRACE("(%p) ref=%d\n", token_list, ref);
6688 if(!ref) {
6689 IHTMLElement_Release(token_list->element);
6690 release_dispex(&token_list->dispex);
6691 heap_free(token_list);
6694 return ref;
6697 static HRESULT WINAPI token_list_GetTypeInfoCount(IWineDOMTokenList *iface, UINT *pctinfo)
6699 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6700 FIXME("(%p)->(%p)\n", token_list, pctinfo);
6701 return E_NOTIMPL;
6704 static HRESULT WINAPI token_list_GetTypeInfo(IWineDOMTokenList *iface, UINT iTInfo,
6705 LCID lcid, ITypeInfo **ppTInfo)
6707 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6709 return IDispatchEx_GetTypeInfo(&token_list->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6712 static HRESULT WINAPI token_list_GetIDsOfNames(IWineDOMTokenList *iface, REFIID riid,
6713 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6715 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6717 return IDispatchEx_GetIDsOfNames(&token_list->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6718 lcid, rgDispId);
6721 static HRESULT WINAPI token_list_Invoke(IWineDOMTokenList *iface, DISPID dispIdMember,
6722 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
6723 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6725 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6727 return IDispatchEx_Invoke(&token_list->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
6728 pDispParams, pVarResult, pExcepInfo, puArgErr);
6731 static const WCHAR *find_token(const WCHAR *list, const WCHAR *token, unsigned int token_len)
6733 const WCHAR *ptr, *next;
6735 if (!list || !token)
6736 return NULL;
6738 ptr = list;
6739 while (*ptr)
6741 while (iswspace(*ptr))
6742 ++ptr;
6743 if (!*ptr)
6744 break;
6745 next = ptr + 1;
6746 while (*next && !iswspace(*next))
6747 ++next;
6749 if (next - ptr == token_len && !wcsncmp(ptr, token, token_len))
6750 return ptr;
6751 ptr = next;
6753 return NULL;
6756 static HRESULT token_list_add_remove(IWineDOMTokenList *iface, BSTR token, BOOL remove)
6758 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6759 unsigned int i, len, old_len, new_len;
6760 const WCHAR *old_pos;
6761 BSTR new, old;
6762 HRESULT hr;
6764 TRACE("iface %p, token %s, remove %#x.\n", iface, debugstr_w(token), remove);
6766 len = token ? lstrlenW(token) : 0;
6767 if (!len)
6769 WARN("Empty token.\n");
6770 return E_INVALIDARG;
6773 for (i = 0; i < len; ++i)
6774 if (iswspace(token[i]))
6776 WARN("Token has spaces.\n");
6777 return E_INVALIDARG;
6780 if (FAILED(hr = IHTMLElement_get_className(token_list->element, &old)))
6781 return hr;
6783 TRACE("old %s.\n", debugstr_w(old));
6785 if (((old_pos = find_token(old, token, len)) && !remove)
6786 || (!old_pos && remove))
6788 SysFreeString(old);
6789 return S_OK;
6792 old_len = old ? lstrlenW(old) : 0;
6793 if (remove)
6795 while (old_pos != old && iswspace(old_pos[-1]))
6797 --old_pos;
6798 ++len;
6800 while (iswspace(old_pos[len]))
6801 ++len;
6803 if (old_pos != old && old_pos[len])
6804 --len;
6806 new_len = old_len - len;
6808 else
6810 new_len = old_len + len + !!old_len;
6813 if (!(new = SysAllocStringLen(NULL, new_len)))
6815 ERR("No memory.\n");
6816 SysFreeString(old);
6817 return E_OUTOFMEMORY;
6820 if (remove)
6822 memcpy(new, old, sizeof(*new) * (old_pos - old));
6823 memcpy(new + (old_pos - old), old_pos + len, sizeof(*new) * (old_len - (old_pos - old) - len + 1));
6825 else
6827 memcpy(new, old, sizeof(*new) * old_len);
6828 if (old_len)
6829 new[old_len++]= L' ';
6830 memcpy(new + old_len, token, sizeof(*new) * len);
6831 new[old_len + len] = 0;
6834 SysFreeString(old);
6836 TRACE("new %s.\n", debugstr_w(new));
6838 hr = IHTMLElement_put_className(token_list->element, new);
6839 SysFreeString(new);
6840 return hr;
6843 static HRESULT WINAPI token_list_add(IWineDOMTokenList *iface, BSTR token)
6845 return token_list_add_remove(iface, token, FALSE);
6848 static HRESULT WINAPI token_list_remove(IWineDOMTokenList *iface, BSTR token)
6850 return token_list_add_remove(iface, token, TRUE);
6853 static HRESULT WINAPI token_list_toString(IWineDOMTokenList *iface, BSTR *String)
6855 struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
6857 TRACE("(%p)->(%p)\n", token_list, String);
6859 return IHTMLElement_get_className(token_list->element, String);
6862 static const IWineDOMTokenListVtbl WineDOMTokenListVtbl = {
6863 token_list_QueryInterface,
6864 token_list_AddRef,
6865 token_list_Release,
6866 token_list_GetTypeInfoCount,
6867 token_list_GetTypeInfo,
6868 token_list_GetIDsOfNames,
6869 token_list_Invoke,
6870 token_list_add,
6871 token_list_remove,
6872 token_list_toString
6875 static inline struct token_list *token_list_from_DispatchEx(DispatchEx *iface)
6877 return CONTAINING_RECORD(iface, struct token_list, dispex);
6880 static HRESULT token_list_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params,
6881 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6883 struct token_list *token_list = token_list_from_DispatchEx(dispex);
6884 HRESULT hres;
6886 switch(flags) {
6887 case DISPATCH_PROPERTYGET:
6888 hres = IHTMLElement_get_className(token_list->element, &V_BSTR(res));
6889 if(FAILED(hres))
6890 return hres;
6891 V_VT(res) = VT_BSTR;
6892 break;
6893 default:
6894 FIXME("Unimplemented flags %x\n", flags);
6895 return E_NOTIMPL;
6898 return S_OK;
6901 static const dispex_static_data_vtbl_t token_list_dispex_vtbl = {
6902 token_list_value
6905 static const tid_t token_list_iface_tids[] = {
6906 IWineDOMTokenList_tid,
6909 static dispex_static_data_t token_list_dispex = {
6910 L"DOMTokenList",
6911 &token_list_dispex_vtbl,
6912 IWineDOMTokenList_tid,
6913 token_list_iface_tids
6916 static HRESULT create_token_list(compat_mode_t compat_mode, IHTMLElement *element, IWineDOMTokenList **ret)
6918 struct token_list *obj;
6920 obj = heap_alloc_zero(sizeof(*obj));
6921 if(!obj)
6923 ERR("No memory.\n");
6924 return E_OUTOFMEMORY;
6927 obj->IWineDOMTokenList_iface.lpVtbl = &WineDOMTokenListVtbl;
6928 obj->ref = 1;
6929 init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineDOMTokenList_iface, &token_list_dispex, compat_mode);
6930 IHTMLElement_AddRef(element);
6931 obj->element = element;
6933 *ret = &obj->IWineDOMTokenList_iface;
6934 return S_OK;
6937 static inline HTMLElement *impl_from_IWineHTMLElementPrivateVtbl(IWineHTMLElementPrivate *iface)
6939 return CONTAINING_RECORD(iface, HTMLElement, IWineHTMLElementPrivate_iface);
6942 static HRESULT WINAPI htmlelement_private_QueryInterface(IWineHTMLElementPrivate *iface,
6943 REFIID riid, void **ppv)
6945 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
6947 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
6950 static ULONG WINAPI htmlelement_private_AddRef(IWineHTMLElementPrivate *iface)
6952 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
6954 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
6957 static ULONG WINAPI htmlelement_private_Release(IWineHTMLElementPrivate *iface)
6959 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
6961 return IHTMLElement_Release(&This->IHTMLElement_iface);
6964 static HRESULT WINAPI htmlelement_private_GetTypeInfoCount(IWineHTMLElementPrivate *iface, UINT *pctinfo)
6966 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
6968 return HTMLElement_GetTypeInfoCount(&This->IHTMLElement_iface, pctinfo);
6971 static HRESULT WINAPI htmlelement_private_GetTypeInfo(IWineHTMLElementPrivate *iface, UINT iTInfo,
6972 LCID lcid, ITypeInfo **ppTInfo)
6974 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
6976 return HTMLElement_GetTypeInfo(&This->IHTMLElement_iface, iTInfo, lcid, ppTInfo);
6979 static HRESULT WINAPI htmlelement_private_GetIDsOfNames(IWineHTMLElementPrivate *iface, REFIID riid,
6980 LPOLESTR *rgszNames, UINT cNames,
6981 LCID lcid, DISPID *rgDispId)
6983 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
6985 return HTMLElement_GetIDsOfNames(&This->IHTMLElement_iface, riid, rgszNames, cNames, lcid,
6986 rgDispId);
6989 static HRESULT WINAPI htmlelement_private_Invoke(IWineHTMLElementPrivate *iface, DISPID dispIdMember,
6990 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
6991 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6993 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
6995 return HTMLElement_Invoke(&This->IHTMLElement_iface, dispIdMember, riid, lcid, wFlags,
6996 pDispParams, pVarResult, pExcepInfo, puArgErr);
6999 static HRESULT WINAPI htmlelement_private_get_classList(IWineHTMLElementPrivate *iface, IDispatch **class_list)
7001 HTMLElement *This = impl_from_IWineHTMLElementPrivateVtbl(iface);
7003 TRACE("iface %p, class_list %p.\n", iface, class_list);
7005 return create_token_list(dispex_compat_mode(&This->node.event_target.dispex), &This->IHTMLElement_iface,
7006 (IWineDOMTokenList **)class_list);
7009 static const IWineHTMLElementPrivateVtbl WineHTMLElementPrivateVtbl = {
7010 htmlelement_private_QueryInterface,
7011 htmlelement_private_AddRef,
7012 htmlelement_private_Release,
7013 htmlelement_private_GetTypeInfoCount,
7014 htmlelement_private_GetTypeInfo,
7015 htmlelement_private_GetIDsOfNames,
7016 htmlelement_private_Invoke,
7017 htmlelement_private_get_classList,
7020 static dispex_static_data_t HTMLElement_dispex = {
7021 L"HTMLElement",
7022 &HTMLElement_event_target_vtbl.dispex_vtbl,
7023 DispHTMLUnknownElement_tid,
7024 HTMLElement_iface_tids,
7025 HTMLElement_init_dispex_info
7028 static dispex_static_data_t HTMLUnknownElement_dispex = {
7029 L"HTMLUnknownElement",
7030 &HTMLElement_event_target_vtbl.dispex_vtbl,
7031 DispHTMLUnknownElement_tid,
7032 HTMLElement_iface_tids,
7033 HTMLElement_init_dispex_info
7036 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMElement *nselem, dispex_static_data_t *dispex_data)
7038 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
7039 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
7040 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
7041 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
7042 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
7043 This->IHTMLElement7_iface.lpVtbl = &HTMLElement7Vtbl;
7044 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
7045 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
7046 This->IElementTraversal_iface.lpVtbl = &ElementTraversalVtbl;
7047 This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
7048 This->IWineHTMLElementPrivate_iface.lpVtbl = &WineHTMLElementPrivateVtbl;
7050 if(dispex_data && !dispex_data->vtbl)
7051 dispex_data->vtbl = &HTMLElement_event_target_vtbl.dispex_vtbl;
7053 if(nselem) {
7054 nsIDOMHTMLElement *html_element;
7055 nsresult nsres;
7057 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data ? dispex_data : &HTMLUnknownElement_dispex);
7059 /* No AddRef, share reference with HTMLDOMNode */
7060 assert((nsIDOMNode*)nselem == This->node.nsnode);
7061 This->dom_element = nselem;
7063 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)&html_element);
7064 if(NS_SUCCEEDED(nsres)) {
7065 This->html_element = html_element;
7066 /* share reference with HTMLDOMNode */
7067 assert((nsIDOMNode*)html_element == This->node.nsnode);
7068 nsIDOMHTMLElement_Release(html_element);
7072 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
7075 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
7077 nsIDOMElement *nselem;
7078 nsAString tag_name_str;
7079 const PRUnichar *tag_name;
7080 const tag_desc_t *tag;
7081 HTMLElement *elem;
7082 nsresult nsres;
7083 HRESULT hres;
7085 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
7086 if(NS_FAILED(nsres)) {
7087 ERR("no nsIDOMElement iface\n");
7088 return E_FAIL;
7091 nsAString_Init(&tag_name_str, NULL);
7092 nsIDOMElement_GetTagName(nselem, &tag_name_str);
7094 nsAString_GetData(&tag_name_str, &tag_name);
7096 tag = get_tag_desc(tag_name);
7097 if(tag) {
7098 hres = tag->constructor(doc, nselem, &elem);
7099 }else {
7100 nsIDOMSVGElement *svg_element;
7102 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMSVGElement, (void**)&svg_element);
7103 if(NS_SUCCEEDED(nsres)) {
7104 hres = create_svg_element(doc, svg_element, tag_name, &elem);
7105 nsIDOMSVGElement_Release(svg_element);
7106 }else if(use_generic) {
7107 hres = HTMLGenericElement_Create(doc, nselem, &elem);
7108 }else {
7109 elem = heap_alloc_zero(sizeof(HTMLElement));
7110 if(elem) {
7111 elem->node.vtbl = &HTMLElementImplVtbl;
7112 HTMLElement_Init(elem, doc, nselem, &HTMLUnknownElement_dispex);
7113 hres = S_OK;
7114 }else {
7115 hres = E_OUTOFMEMORY;
7120 TRACE("%s ret %p\n", debugstr_w(tag_name), elem);
7122 nsIDOMElement_Release(nselem);
7123 nsAString_Finish(&tag_name_str);
7124 if(FAILED(hres))
7125 return hres;
7127 *ret = elem;
7128 return S_OK;
7131 static HRESULT HTMLElement_Ctor(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
7133 HTMLElement *ret;
7135 ret = heap_alloc_zero(sizeof(*ret));
7136 if(!ret)
7137 return E_OUTOFMEMORY;
7139 ret->node.vtbl = &HTMLElementImplVtbl;
7140 HTMLElement_Init(ret, doc, nselem, &HTMLElement_dispex);
7142 *elem = ret;
7143 return S_OK;
7146 HRESULT get_element(nsIDOMElement *nselem, HTMLElement **ret)
7148 HTMLDOMNode *node;
7149 HRESULT hres;
7151 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
7152 if(FAILED(hres))
7153 return hres;
7155 *ret = impl_from_HTMLDOMNode(node);
7156 return S_OK;
7159 /* interface IHTMLFiltersCollection */
7160 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
7162 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7164 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
7166 if(IsEqualGUID(&IID_IUnknown, riid)) {
7167 *ppv = &This->IHTMLFiltersCollection_iface;
7168 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
7169 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
7170 *ppv = &This->IHTMLFiltersCollection_iface;
7171 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
7172 return *ppv ? S_OK : E_NOINTERFACE;
7173 }else {
7174 *ppv = NULL;
7175 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
7176 return E_NOINTERFACE;
7179 IUnknown_AddRef((IUnknown*)*ppv);
7180 return S_OK;
7183 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
7185 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7186 LONG ref = InterlockedIncrement(&This->ref);
7188 TRACE("(%p) ref=%d\n", This, ref);
7190 return ref;
7193 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
7195 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7196 LONG ref = InterlockedDecrement(&This->ref);
7198 TRACE("(%p) ref=%d\n", This, ref);
7200 if(!ref)
7202 heap_free(This);
7205 return ref;
7208 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
7210 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7211 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
7214 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
7215 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
7217 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7218 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7221 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
7222 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
7223 LCID lcid, DISPID *rgDispId)
7225 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7226 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7227 lcid, rgDispId);
7230 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
7231 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
7232 EXCEPINFO *pExcepInfo, UINT *puArgErr)
7234 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7235 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
7236 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
7239 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
7241 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7243 if(!p)
7244 return E_POINTER;
7246 FIXME("(%p)->(%p) Always returning 0\n", This, p);
7247 *p = 0;
7249 return S_OK;
7252 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
7254 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7255 FIXME("(%p)->(%p)\n", This, p);
7256 return E_NOTIMPL;
7259 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
7261 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
7262 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
7263 return E_NOTIMPL;
7266 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
7267 HTMLFiltersCollection_QueryInterface,
7268 HTMLFiltersCollection_AddRef,
7269 HTMLFiltersCollection_Release,
7270 HTMLFiltersCollection_GetTypeInfoCount,
7271 HTMLFiltersCollection_GetTypeInfo,
7272 HTMLFiltersCollection_GetIDsOfNames,
7273 HTMLFiltersCollection_Invoke,
7274 HTMLFiltersCollection_get_length,
7275 HTMLFiltersCollection_get__newEnum,
7276 HTMLFiltersCollection_item
7279 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
7281 WCHAR *ptr;
7282 int idx = 0;
7284 for(ptr = name; *ptr && is_digit(*ptr); ptr++)
7285 idx = idx*10 + (*ptr-'0');
7286 if(*ptr)
7287 return DISP_E_UNKNOWNNAME;
7289 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
7290 TRACE("ret %x\n", *dispid);
7291 return S_OK;
7294 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
7295 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7297 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
7299 V_VT(res) = VT_DISPATCH;
7300 V_DISPATCH(res) = NULL;
7302 FIXME("always returning NULL\n");
7304 return S_OK;
7307 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
7308 NULL,
7309 HTMLFiltersCollection_get_dispid,
7310 HTMLFiltersCollection_invoke,
7311 NULL
7314 static const tid_t HTMLFiltersCollection_iface_tids[] = {
7315 IHTMLFiltersCollection_tid,
7318 static dispex_static_data_t HTMLFiltersCollection_dispex = {
7319 L"FiltersCollection",
7320 &HTMLFiltersCollection_dispex_vtbl,
7321 IHTMLFiltersCollection_tid,
7322 HTMLFiltersCollection_iface_tids
7325 static HRESULT create_filters_collection(compat_mode_t compat_mode, IHTMLFiltersCollection **ret)
7327 HTMLFiltersCollection *collection;
7329 if(!(collection = heap_alloc(sizeof(HTMLFiltersCollection))))
7330 return E_OUTOFMEMORY;
7332 collection->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
7333 collection->ref = 1;
7335 init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLFiltersCollection_iface,
7336 &HTMLFiltersCollection_dispex, min(compat_mode, COMPAT_MODE_IE8));
7338 *ret = &collection->IHTMLFiltersCollection_iface;
7339 return S_OK;
7342 /* interface IHTMLAttributeCollection */
7343 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
7345 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
7348 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
7350 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7352 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
7354 if(IsEqualGUID(&IID_IUnknown, riid)) {
7355 *ppv = &This->IHTMLAttributeCollection_iface;
7356 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
7357 *ppv = &This->IHTMLAttributeCollection_iface;
7358 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
7359 *ppv = &This->IHTMLAttributeCollection2_iface;
7360 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
7361 *ppv = &This->IHTMLAttributeCollection3_iface;
7362 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
7363 return *ppv ? S_OK : E_NOINTERFACE;
7364 }else {
7365 *ppv = NULL;
7366 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
7367 return E_NOINTERFACE;
7370 IUnknown_AddRef((IUnknown*)*ppv);
7371 return S_OK;
7374 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
7376 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7377 LONG ref = InterlockedIncrement(&This->ref);
7379 TRACE("(%p) ref=%d\n", This, ref);
7381 return ref;
7384 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
7386 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7387 LONG ref = InterlockedDecrement(&This->ref);
7389 TRACE("(%p) ref=%d\n", This, ref);
7391 if(!ref) {
7392 while(!list_empty(&This->attrs)) {
7393 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
7395 list_remove(&attr->entry);
7396 attr->elem = NULL;
7397 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
7400 heap_free(This);
7403 return ref;
7406 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
7408 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7409 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
7412 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
7413 LCID lcid, ITypeInfo **ppTInfo)
7415 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7416 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7419 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
7420 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
7422 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7423 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7424 lcid, rgDispId);
7427 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
7428 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7429 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7431 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7432 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
7433 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
7436 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
7438 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
7439 DISPID id = DISPID_STARTENUM;
7440 LONG len = -1;
7441 HRESULT hres;
7443 FIXME("filter non-enumerable attributes out\n");
7445 while(1) {
7446 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
7447 if(FAILED(hres))
7448 return hres;
7449 else if(hres == S_FALSE)
7450 break;
7452 len++;
7453 if(len == *idx)
7454 break;
7457 if(dispid) {
7458 *dispid = id;
7459 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
7462 *idx = len+1;
7463 return S_OK;
7466 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
7468 HRESULT hres;
7470 if(name[0]>='0' && name[0]<='9') {
7471 WCHAR *end_ptr;
7472 LONG idx;
7474 idx = wcstoul(name, &end_ptr, 10);
7475 if(!*end_ptr) {
7476 hres = get_attr_dispid_by_idx(This, &idx, id);
7477 if(SUCCEEDED(hres))
7478 return hres;
7482 if(!This->elem) {
7483 WARN("NULL elem\n");
7484 return E_UNEXPECTED;
7487 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
7488 name, fdexNameCaseInsensitive, id);
7489 return hres;
7492 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
7494 HTMLDOMAttribute *iter;
7495 LONG pos = 0;
7496 HRESULT hres;
7498 *attr = NULL;
7499 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
7500 if(iter->dispid == id) {
7501 *attr = iter;
7502 break;
7504 pos++;
7507 if(!*attr) {
7508 if(!This->elem) {
7509 WARN("NULL elem\n");
7510 return E_UNEXPECTED;
7513 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, dispex_compat_mode(&This->elem->node.event_target.dispex), attr);
7514 if(FAILED(hres))
7515 return hres;
7518 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
7519 if(list_pos)
7520 *list_pos = pos;
7521 return S_OK;
7524 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
7526 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7527 HRESULT hres;
7529 TRACE("(%p)->(%p)\n", This, p);
7531 *p = -1;
7532 hres = get_attr_dispid_by_idx(This, p, NULL);
7533 return hres;
7536 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
7538 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7539 FIXME("(%p)->(%p)\n", This, p);
7540 return E_NOTIMPL;
7543 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
7545 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
7546 HTMLDOMAttribute *attr;
7547 DISPID id;
7548 HRESULT hres;
7550 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
7552 switch(V_VT(name)) {
7553 case VT_I4:
7554 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
7555 break;
7556 case VT_BSTR:
7557 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
7558 break;
7559 default:
7560 FIXME("unsupported name %s\n", debugstr_variant(name));
7561 hres = E_NOTIMPL;
7563 if(hres == DISP_E_UNKNOWNNAME)
7564 return E_INVALIDARG;
7565 if(FAILED(hres))
7566 return hres;
7568 hres = get_domattr(This, id, NULL, &attr);
7569 if(FAILED(hres))
7570 return hres;
7572 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
7573 return S_OK;
7576 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
7577 HTMLAttributeCollection_QueryInterface,
7578 HTMLAttributeCollection_AddRef,
7579 HTMLAttributeCollection_Release,
7580 HTMLAttributeCollection_GetTypeInfoCount,
7581 HTMLAttributeCollection_GetTypeInfo,
7582 HTMLAttributeCollection_GetIDsOfNames,
7583 HTMLAttributeCollection_Invoke,
7584 HTMLAttributeCollection_get_length,
7585 HTMLAttributeCollection__newEnum,
7586 HTMLAttributeCollection_item
7589 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
7591 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
7594 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
7596 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7597 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
7600 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
7602 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7603 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
7606 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
7608 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7609 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
7612 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
7614 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7615 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
7618 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
7619 LCID lcid, ITypeInfo **ppTInfo)
7621 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7622 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7625 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
7626 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
7628 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7629 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7630 lcid, rgDispId);
7633 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
7634 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7635 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7637 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7638 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
7639 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
7642 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
7643 IHTMLDOMAttribute **newretNode)
7645 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7646 HTMLDOMAttribute *attr;
7647 DISPID id;
7648 HRESULT hres;
7650 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
7652 hres = get_attr_dispid_by_name(This, bstrName, &id);
7653 if(hres == DISP_E_UNKNOWNNAME) {
7654 *newretNode = NULL;
7655 return S_OK;
7656 } else if(FAILED(hres)) {
7657 return hres;
7660 hres = get_domattr(This, id, NULL, &attr);
7661 if(FAILED(hres))
7662 return hres;
7664 *newretNode = &attr->IHTMLDOMAttribute_iface;
7665 return S_OK;
7668 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
7669 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
7671 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7672 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
7673 return E_NOTIMPL;
7676 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
7677 BSTR bstrName, IHTMLDOMAttribute **newretNode)
7679 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
7680 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
7681 return E_NOTIMPL;
7684 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
7685 HTMLAttributeCollection2_QueryInterface,
7686 HTMLAttributeCollection2_AddRef,
7687 HTMLAttributeCollection2_Release,
7688 HTMLAttributeCollection2_GetTypeInfoCount,
7689 HTMLAttributeCollection2_GetTypeInfo,
7690 HTMLAttributeCollection2_GetIDsOfNames,
7691 HTMLAttributeCollection2_Invoke,
7692 HTMLAttributeCollection2_getNamedItem,
7693 HTMLAttributeCollection2_setNamedItem,
7694 HTMLAttributeCollection2_removeNamedItem
7697 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
7699 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
7702 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
7704 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7705 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
7708 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
7710 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7711 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
7714 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
7716 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7717 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
7720 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
7722 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7723 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
7726 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
7727 LCID lcid, ITypeInfo **ppTInfo)
7729 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7730 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
7733 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
7734 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
7736 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7737 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
7738 lcid, rgDispId);
7741 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
7742 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
7743 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
7745 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7746 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
7747 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
7750 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
7751 IHTMLDOMAttribute **ppNodeOut)
7753 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7754 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
7757 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
7758 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
7760 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7761 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
7762 return E_NOTIMPL;
7765 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
7766 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
7768 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7769 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
7770 return E_NOTIMPL;
7773 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
7775 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7776 HTMLDOMAttribute *attr;
7777 DISPID id;
7778 HRESULT hres;
7780 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
7782 hres = get_attr_dispid_by_idx(This, &index, &id);
7783 if(hres == DISP_E_UNKNOWNNAME)
7784 return E_INVALIDARG;
7785 if(FAILED(hres))
7786 return hres;
7788 hres = get_domattr(This, id, NULL, &attr);
7789 if(FAILED(hres))
7790 return hres;
7792 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
7793 return S_OK;
7796 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
7798 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
7799 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
7802 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
7803 HTMLAttributeCollection3_QueryInterface,
7804 HTMLAttributeCollection3_AddRef,
7805 HTMLAttributeCollection3_Release,
7806 HTMLAttributeCollection3_GetTypeInfoCount,
7807 HTMLAttributeCollection3_GetTypeInfo,
7808 HTMLAttributeCollection3_GetIDsOfNames,
7809 HTMLAttributeCollection3_Invoke,
7810 HTMLAttributeCollection3_getNamedItem,
7811 HTMLAttributeCollection3_setNamedItem,
7812 HTMLAttributeCollection3_removeNamedItem,
7813 HTMLAttributeCollection3_item,
7814 HTMLAttributeCollection3_get_length
7817 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
7819 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
7822 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
7824 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
7825 HTMLDOMAttribute *attr;
7826 LONG pos;
7827 HRESULT hres;
7829 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
7831 hres = get_attr_dispid_by_name(This, name, dispid);
7832 if(FAILED(hres))
7833 return hres;
7835 hres = get_domattr(This, *dispid, &pos, &attr);
7836 if(FAILED(hres))
7837 return hres;
7838 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
7840 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
7841 return S_OK;
7844 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
7845 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
7847 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
7849 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
7851 switch(flags) {
7852 case DISPATCH_PROPERTYGET: {
7853 HTMLDOMAttribute *iter;
7854 DWORD pos;
7856 pos = id-MSHTML_DISPID_CUSTOM_MIN;
7858 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
7859 if(!pos) {
7860 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
7861 V_VT(res) = VT_DISPATCH;
7862 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
7863 return S_OK;
7865 pos--;
7868 WARN("invalid arg\n");
7869 return E_INVALIDARG;
7872 default:
7873 FIXME("unimplemented flags %x\n", flags);
7874 return E_NOTIMPL;
7878 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
7879 NULL,
7880 HTMLAttributeCollection_get_dispid,
7881 HTMLAttributeCollection_invoke,
7882 NULL
7885 static const tid_t HTMLAttributeCollection_iface_tids[] = {
7886 IHTMLAttributeCollection_tid,
7887 IHTMLAttributeCollection2_tid,
7888 IHTMLAttributeCollection3_tid,
7892 static dispex_static_data_t HTMLAttributeCollection_dispex = {
7893 L"NamedNodeMap",
7894 &HTMLAttributeCollection_dispex_vtbl,
7895 DispHTMLAttributeCollection_tid,
7896 HTMLAttributeCollection_iface_tids
7899 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
7901 HTMLElement *This = impl_from_HTMLDOMNode(iface);
7903 if(This->attrs) {
7904 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
7905 *ac = This->attrs;
7906 return S_OK;
7909 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
7910 if(!This->attrs)
7911 return E_OUTOFMEMORY;
7913 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
7914 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
7915 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
7916 This->attrs->ref = 2;
7918 This->attrs->elem = This;
7919 list_init(&This->attrs->attrs);
7920 init_dispatch(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
7921 &HTMLAttributeCollection_dispex, dispex_compat_mode(&iface->event_target.dispex));
7923 *ac = This->attrs;
7924 return S_OK;