1 /*
2 * Copyright 2006-2010 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #include "mshtml_private.h"
20
21 static const WCHAR aW[] = {'A',0};
22 static const WCHAR areaW[] = {'A','R','E','A',0};
23 static const WCHAR bodyW[] = {'B','O','D','Y',0};
24 static const WCHAR buttonW[] = {'B','U','T','T','O','N',0};
25 static const WCHAR embedW[] = {'E','M','B','E','D',0};
26 static const WCHAR formW[] = {'F','O','R','M',0};
27 static const WCHAR frameW[] = {'F','R','A','M','E',0};
28 static const WCHAR headW[] = {'H','E','A','D',0};
29 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
30 static const WCHAR imgW[] = {'I','M','G',0};
31 static const WCHAR inputW[] = {'I','N','P','U','T',0};
32 static const WCHAR labelW[] = {'L','A','B','E','L',0};
33 static const WCHAR linkW[] = {'L','I','N','K',0};
34 static const WCHAR metaW[] = {'M','E','T','A',0};
35 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
36 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
37 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
38 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
39 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
40 static const WCHAR tableW[] = {'T','A','B','L','E',0};
41 static const WCHAR tdW[] = {'T','D',0};
42 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
43 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
44 static const WCHAR trW[] = {'T','R',0};
45
46 typedef struct {
47 const WCHAR *name;
48 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
49 } tag_desc_t;
50
51 static const tag_desc_t tag_descs[] = {
52 {aW, HTMLAnchorElement_Create},
53 {areaW, HTMLAreaElement_Create},
54 {bodyW, HTMLBodyElement_Create},
55 {buttonW, HTMLButtonElement_Create},
56 {embedW, HTMLEmbedElement_Create},
57 {formW, HTMLFormElement_Create},
58 {frameW, HTMLFrameElement_Create},
59 {headW, HTMLHeadElement_Create},
60 {iframeW, HTMLIFrame_Create},
61 {imgW, HTMLImgElement_Create},
62 {inputW, HTMLInputElement_Create},
63 {labelW, HTMLLabelElement_Create},
64 {linkW, HTMLLinkElement_Create},
65 {metaW, HTMLMetaElement_Create},
66 {objectW, HTMLObjectElement_Create},
67 {optionW, HTMLOptionElement_Create},
68 {scriptW, HTMLScriptElement_Create},
69 {selectW, HTMLSelectElement_Create},
70 {styleW, HTMLStyleElement_Create},
71 {tableW, HTMLTable_Create},
72 {tdW, HTMLTableCell_Create},
73 {textareaW, HTMLTextAreaElement_Create},
74 {title_tagW, HTMLTitleElement_Create},
75 {trW, HTMLTableRow_Create}
76 };
77
get_tag_desc(const WCHAR * tag_name)78 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
79 {
80 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
81 int r;
82
83 while(min <= max) {
84 i = (min+max)/2;
85 r = strcmpW(tag_name, tag_descs[i].name);
86 if(!r)
87 return tag_descs+i;
88
89 if(r < 0)
90 max = i-1;
91 else
92 min = i+1;
93 }
94
95 return NULL;
96 }
97
replace_node_by_html(nsIDOMHTMLDocument * nsdoc,nsIDOMNode * nsnode,const WCHAR * html)98 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
99 {
100 nsIDOMDocumentFragment *nsfragment;
101 nsIDOMNode *nsparent;
102 nsIDOMRange *range;
103 nsAString html_str;
104 nsresult nsres;
105 HRESULT hres = S_OK;
106
107 nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range);
108 if(NS_FAILED(nsres)) {
109 ERR("CreateRange failed: %08x\n", nsres);
110 return E_FAIL;
111 }
112
113 nsAString_InitDepend(&html_str, html);
114 nsIDOMRange_CreateContextualFragment(range, &html_str, &nsfragment);
115 nsIDOMRange_Release(range);
116 nsAString_Finish(&html_str);
117 if(NS_FAILED(nsres)) {
118 ERR("CreateContextualFragment failed: %08x\n", nsres);
119 return E_FAIL;
120 }
121
122 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
123 if(NS_SUCCEEDED(nsres) && nsparent) {
124 nsIDOMNode *nstmp;
125
126 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
127 nsIDOMNode_Release(nsparent);
128 if(NS_FAILED(nsres)) {
129 ERR("ReplaceChild failed: %08x\n", nsres);
130 hres = E_FAIL;
131 }else if(nstmp) {
132 nsIDOMNode_Release(nstmp);
133 }
134 }else {
135 ERR("GetParentNode failed: %08x\n", nsres);
136 hres = E_FAIL;
137 }
138
139 nsIDOMDocumentFragment_Release(nsfragment);
140 return hres;
141 }
142
get_elem_attr_value(nsIDOMHTMLElement * nselem,const WCHAR * name,nsAString * val_str,const PRUnichar ** val)143 nsresult get_elem_attr_value(nsIDOMHTMLElement *nselem, const WCHAR *name, nsAString *val_str, const PRUnichar **val)
144 {
145 nsAString name_str;
146 nsresult nsres;
147
148 nsAString_InitDepend(&name_str, name);
149 nsAString_Init(val_str, NULL);
150 nsres = nsIDOMHTMLElement_GetAttribute(nselem, &name_str, val_str);
151 nsAString_Finish(&name_str);
152 if(NS_FAILED(nsres)) {
153 ERR("GetAttribute(%s) failed: %08x\n", debugstr_w(name), nsres);
154 nsAString_Finish(val_str);
155 return nsres;
156 }
157
158 nsAString_GetData(val_str, val);
159 return NS_OK;
160 }
161
elem_string_attr_getter(HTMLElement * elem,const WCHAR * name,BOOL use_null,BSTR * p)162 HRESULT elem_string_attr_getter(HTMLElement *elem, const WCHAR *name, BOOL use_null, BSTR *p)
163 {
164 const PRUnichar *val;
165 nsAString val_str;
166 nsresult nsres;
167 HRESULT hres = S_OK;
168
169 nsres = get_elem_attr_value(elem->nselem, name, &val_str, &val);
170 if(NS_FAILED(nsres))
171 return E_FAIL;
172
173 TRACE("%s: returning %s\n", debugstr_w(name), debugstr_w(val));
174
175 if(*val || !use_null) {
176 *p = SysAllocString(val);
177 if(!*p)
178 hres = E_OUTOFMEMORY;
179 }else {
180 *p = NULL;
181 }
182 nsAString_Finish(&val_str);
183 return hres;
184 }
185
elem_string_attr_setter(HTMLElement * elem,const WCHAR * name,const WCHAR * value)186 HRESULT elem_string_attr_setter(HTMLElement *elem, const WCHAR *name, const WCHAR *value)
187 {
188 nsAString name_str, val_str;
189 nsresult nsres;
190
191 nsAString_InitDepend(&name_str, name);
192 nsAString_InitDepend(&val_str, value);
193 nsres = nsIDOMHTMLElement_SetAttribute(elem->nselem, &name_str, &val_str);
194 nsAString_Finish(&name_str);
195 nsAString_Finish(&val_str);
196
197 if(NS_FAILED(nsres)) {
198 WARN("SetAttribute failed: %08x\n", nsres);
199 return E_FAIL;
200 }
201
202 return S_OK;
203 }
204
get_readystate_string(READYSTATE readystate,BSTR * p)205 HRESULT get_readystate_string(READYSTATE readystate, BSTR *p)
206 {
207 static const WCHAR uninitializedW[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
208 static const WCHAR loadingW[] = {'l','o','a','d','i','n','g',0};
209 static const WCHAR loadedW[] = {'l','o','a','d','e','d',0};
210 static const WCHAR interactiveW[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
211 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
212
213 static const LPCWSTR readystate_strs[] = {
214 uninitializedW,
215 loadingW,
216 loadedW,
217 interactiveW,
218 completeW
219 };
220
221 assert(readystate <= READYSTATE_COMPLETE);
222 *p = SysAllocString(readystate_strs[readystate]);
223 return *p ? S_OK : E_OUTOFMEMORY;
224 }
225
226 typedef struct
227 {
228 DispatchEx dispex;
229 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
230
231 LONG ref;
232 } HTMLFiltersCollection;
233
impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection * iface)234 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
235 {
236 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
237 }
238
239 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
240
impl_from_IHTMLElement(IHTMLElement * iface)241 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
242 {
243 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
244 }
245
create_nselem(HTMLDocumentNode * doc,const WCHAR * tag,nsIDOMHTMLElement ** ret)246 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
247 {
248 nsIDOMElement *nselem;
249 nsAString tag_str;
250 nsresult nsres;
251
252 if(!doc->nsdoc) {
253 WARN("NULL nsdoc\n");
254 return E_UNEXPECTED;
255 }
256
257 nsAString_InitDepend(&tag_str, tag);
258 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
259 nsAString_Finish(&tag_str);
260 if(NS_FAILED(nsres)) {
261 ERR("CreateElement failed: %08x\n", nsres);
262 return E_FAIL;
263 }
264
265 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
266 nsIDOMElement_Release(nselem);
267 if(NS_FAILED(nsres)) {
268 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
269 return E_FAIL;
270 }
271
272 return S_OK;
273 }
274
create_element(HTMLDocumentNode * doc,const WCHAR * tag,HTMLElement ** ret)275 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
276 {
277 nsIDOMHTMLElement *nselem;
278 HRESULT hres;
279
280 /* Use owner doc if called on document fragment */
281 if(!doc->nsdoc)
282 doc = doc->node.doc;
283
284 hres = create_nselem(doc, tag, &nselem);
285 if(FAILED(hres))
286 return hres;
287
288 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
289 nsIDOMHTMLElement_Release(nselem);
290 return hres;
291 }
292
293 typedef struct {
294 DispatchEx dispex;
295 IHTMLRect IHTMLRect_iface;
296
297 LONG ref;
298
299 nsIDOMClientRect *nsrect;
300 } HTMLRect;
301
impl_from_IHTMLRect(IHTMLRect * iface)302 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
303 {
304 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
305 }
306
HTMLRect_QueryInterface(IHTMLRect * iface,REFIID riid,void ** ppv)307 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
308 {
309 HTMLRect *This = impl_from_IHTMLRect(iface);
310
311 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
312
313 if(IsEqualGUID(&IID_IUnknown, riid)) {
314 *ppv = &This->IHTMLRect_iface;
315 }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
316 *ppv = &This->IHTMLRect_iface;
317 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
318 return *ppv ? S_OK : E_NOINTERFACE;
319 }else {
320 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
321 *ppv = NULL;
322 return E_NOINTERFACE;
323 }
324
325 IUnknown_AddRef((IUnknown*)*ppv);
326 return S_OK;
327 }
328
HTMLRect_AddRef(IHTMLRect * iface)329 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
330 {
331 HTMLRect *This = impl_from_IHTMLRect(iface);
332 LONG ref = InterlockedIncrement(&This->ref);
333
334 TRACE("(%p) ref=%d\n", This, ref);
335
336 return ref;
337 }
338
HTMLRect_Release(IHTMLRect * iface)339 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
340 {
341 HTMLRect *This = impl_from_IHTMLRect(iface);
342 LONG ref = InterlockedDecrement(&This->ref);
343
344 TRACE("(%p) ref=%d\n", This, ref);
345
346 if(!ref) {
347 if(This->nsrect)
348 nsIDOMClientRect_Release(This->nsrect);
349 heap_free(This);
350 }
351
352 return ref;
353 }
354
HTMLRect_GetTypeInfoCount(IHTMLRect * iface,UINT * pctinfo)355 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
356 {
357 HTMLRect *This = impl_from_IHTMLRect(iface);
358 FIXME("(%p)->(%p)\n", This, pctinfo);
359 return E_NOTIMPL;
360 }
361
HTMLRect_GetTypeInfo(IHTMLRect * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)362 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
363 LCID lcid, ITypeInfo **ppTInfo)
364 {
365 HTMLRect *This = impl_from_IHTMLRect(iface);
366
367 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
368 }
369
HTMLRect_GetIDsOfNames(IHTMLRect * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)370 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
371 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
372 {
373 HTMLRect *This = impl_from_IHTMLRect(iface);
374
375 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
376 lcid, rgDispId);
377 }
378
HTMLRect_Invoke(IHTMLRect * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)379 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
380 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
381 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
382 {
383 HTMLRect *This = impl_from_IHTMLRect(iface);
384
385 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
386 pDispParams, pVarResult, pExcepInfo, puArgErr);
387 }
388
HTMLRect_put_left(IHTMLRect * iface,LONG v)389 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
390 {
391 HTMLRect *This = impl_from_IHTMLRect(iface);
392 FIXME("(%p)->(%d)\n", This, v);
393 return E_NOTIMPL;
394 }
395
HTMLRect_get_left(IHTMLRect * iface,LONG * p)396 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
397 {
398 HTMLRect *This = impl_from_IHTMLRect(iface);
399 float left;
400 nsresult nsres;
401
402 TRACE("(%p)->(%p)\n", This, p);
403
404 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
405 if(NS_FAILED(nsres)) {
406 ERR("GetLeft failed: %08x\n", nsres);
407 return E_FAIL;
408 }
409
410 *p = floor(left+0.5);
411 return S_OK;
412 }
413
HTMLRect_put_top(IHTMLRect * iface,LONG v)414 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
415 {
416 HTMLRect *This = impl_from_IHTMLRect(iface);
417 FIXME("(%p)->(%d)\n", This, v);
418 return E_NOTIMPL;
419 }
420
HTMLRect_get_top(IHTMLRect * iface,LONG * p)421 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
422 {
423 HTMLRect *This = impl_from_IHTMLRect(iface);
424 float top;
425 nsresult nsres;
426
427 TRACE("(%p)->(%p)\n", This, p);
428
429 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
430 if(NS_FAILED(nsres)) {
431 ERR("GetTop failed: %08x\n", nsres);
432 return E_FAIL;
433 }
434
435 *p = floor(top+0.5);
436 return S_OK;
437 }
438
HTMLRect_put_right(IHTMLRect * iface,LONG v)439 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
440 {
441 HTMLRect *This = impl_from_IHTMLRect(iface);
442 FIXME("(%p)->(%d)\n", This, v);
443 return E_NOTIMPL;
444 }
445
HTMLRect_get_right(IHTMLRect * iface,LONG * p)446 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
447 {
448 HTMLRect *This = impl_from_IHTMLRect(iface);
449 float right;
450 nsresult nsres;
451
452 TRACE("(%p)->(%p)\n", This, p);
453
454 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
455 if(NS_FAILED(nsres)) {
456 ERR("GetRight failed: %08x\n", nsres);
457 return E_FAIL;
458 }
459
460 *p = floor(right+0.5);
461 return S_OK;
462 }
463
HTMLRect_put_bottom(IHTMLRect * iface,LONG v)464 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
465 {
466 HTMLRect *This = impl_from_IHTMLRect(iface);
467 FIXME("(%p)->(%d)\n", This, v);
468 return E_NOTIMPL;
469 }
470
HTMLRect_get_bottom(IHTMLRect * iface,LONG * p)471 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
472 {
473 HTMLRect *This = impl_from_IHTMLRect(iface);
474 float bottom;
475 nsresult nsres;
476
477 TRACE("(%p)->(%p)\n", This, p);
478
479 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
480 if(NS_FAILED(nsres)) {
481 ERR("GetBottom failed: %08x\n", nsres);
482 return E_FAIL;
483 }
484
485 *p = floor(bottom+0.5);
486 return S_OK;
487 }
488
489 static const IHTMLRectVtbl HTMLRectVtbl = {
490 HTMLRect_QueryInterface,
491 HTMLRect_AddRef,
492 HTMLRect_Release,
493 HTMLRect_GetTypeInfoCount,
494 HTMLRect_GetTypeInfo,
495 HTMLRect_GetIDsOfNames,
496 HTMLRect_Invoke,
497 HTMLRect_put_left,
498 HTMLRect_get_left,
499 HTMLRect_put_top,
500 HTMLRect_get_top,
501 HTMLRect_put_right,
502 HTMLRect_get_right,
503 HTMLRect_put_bottom,
504 HTMLRect_get_bottom
505 };
506
507 static const tid_t HTMLRect_iface_tids[] = {
508 IHTMLRect_tid,
509 0
510 };
511 static dispex_static_data_t HTMLRect_dispex = {
512 NULL,
513 IHTMLRect_tid,
514 NULL,
515 HTMLRect_iface_tids
516 };
517
create_html_rect(nsIDOMClientRect * nsrect,IHTMLRect ** ret)518 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, IHTMLRect **ret)
519 {
520 HTMLRect *rect;
521
522 rect = heap_alloc_zero(sizeof(HTMLRect));
523 if(!rect)
524 return E_OUTOFMEMORY;
525
526 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
527 rect->ref = 1;
528
529 init_dispex(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex);
530
531 nsIDOMClientRect_AddRef(nsrect);
532 rect->nsrect = nsrect;
533
534 *ret = &rect->IHTMLRect_iface;
535 return S_OK;
536 }
537
HTMLElement_QueryInterface(IHTMLElement * iface,REFIID riid,void ** ppv)538 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
539 REFIID riid, void **ppv)
540 {
541 HTMLElement *This = impl_from_IHTMLElement(iface);
542
543 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
544 }
545
HTMLElement_AddRef(IHTMLElement * iface)546 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
547 {
548 HTMLElement *This = impl_from_IHTMLElement(iface);
549
550 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
551 }
552
HTMLElement_Release(IHTMLElement * iface)553 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
554 {
555 HTMLElement *This = impl_from_IHTMLElement(iface);
556
557 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
558 }
559
HTMLElement_GetTypeInfoCount(IHTMLElement * iface,UINT * pctinfo)560 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
561 {
562 HTMLElement *This = impl_from_IHTMLElement(iface);
563 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
564 }
565
HTMLElement_GetTypeInfo(IHTMLElement * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)566 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
567 LCID lcid, ITypeInfo **ppTInfo)
568 {
569 HTMLElement *This = impl_from_IHTMLElement(iface);
570 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
571 }
572
HTMLElement_GetIDsOfNames(IHTMLElement * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)573 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
574 LPOLESTR *rgszNames, UINT cNames,
575 LCID lcid, DISPID *rgDispId)
576 {
577 HTMLElement *This = impl_from_IHTMLElement(iface);
578 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
579 lcid, rgDispId);
580 }
581
HTMLElement_Invoke(IHTMLElement * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)582 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
583 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
584 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
585 {
586 HTMLElement *This = impl_from_IHTMLElement(iface);
587 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
588 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
589 }
590
HTMLElement_setAttribute(IHTMLElement * iface,BSTR strAttributeName,VARIANT AttributeValue,LONG lFlags)591 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
592 VARIANT AttributeValue, LONG lFlags)
593 {
594 HTMLElement *This = impl_from_IHTMLElement(iface);
595 HRESULT hres;
596 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
597 DISPPARAMS dispParams;
598 EXCEPINFO excep;
599
600 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
601
602 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
603 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
604 if(FAILED(hres))
605 return hres;
606
607 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
608 TRACE("Ignoring call on style attribute\n");
609 return S_OK;
610 }
611
612 dispParams.cArgs = 1;
613 dispParams.cNamedArgs = 1;
614 dispParams.rgdispidNamedArgs = &dispidNamed;
615 dispParams.rgvarg = &AttributeValue;
616
617 return IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, dispid,
618 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
619 }
620
get_elem_attr_value_by_dispid(HTMLElement * elem,DISPID dispid,DWORD flags,VARIANT * ret)621 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, DWORD flags, VARIANT *ret)
622 {
623 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
624 EXCEPINFO excep;
625 HRESULT hres;
626
627 hres = IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
628 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
629 if(FAILED(hres))
630 return hres;
631
632 if(flags & ATTRFLAG_ASSTRING) {
633 switch(V_VT(ret)) {
634 case VT_BSTR:
635 break;
636 case VT_DISPATCH:
637 IDispatch_Release(V_DISPATCH(ret));
638 V_VT(ret) = VT_BSTR;
639 V_BSTR(ret) = SysAllocString(NULL);
640 break;
641 default:
642 hres = VariantChangeType(ret, ret, 0, VT_BSTR);
643 if(FAILED(hres))
644 return hres;
645 }
646 }
647
648 return S_OK;
649 }
650
HTMLElement_getAttribute(IHTMLElement * iface,BSTR strAttributeName,LONG lFlags,VARIANT * AttributeValue)651 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
652 LONG lFlags, VARIANT *AttributeValue)
653 {
654 HTMLElement *This = impl_from_IHTMLElement(iface);
655 DISPID dispid;
656 HRESULT hres;
657
658 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
659
660 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
661 FIXME("Unsupported flags %x\n", lFlags);
662
663 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
664 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
665 if(hres == DISP_E_UNKNOWNNAME) {
666 V_VT(AttributeValue) = VT_NULL;
667 return S_OK;
668 }
669
670 if(FAILED(hres)) {
671 V_VT(AttributeValue) = VT_NULL;
672 return hres;
673 }
674
675 return get_elem_attr_value_by_dispid(This, dispid, lFlags, AttributeValue);
676 }
677
HTMLElement_removeAttribute(IHTMLElement * iface,BSTR strAttributeName,LONG lFlags,VARIANT_BOOL * pfSuccess)678 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
679 LONG lFlags, VARIANT_BOOL *pfSuccess)
680 {
681 HTMLElement *This = impl_from_IHTMLElement(iface);
682 DISPID id;
683 HRESULT hres;
684
685 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
686
687 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
688 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
689 if(hres == DISP_E_UNKNOWNNAME) {
690 *pfSuccess = VARIANT_FALSE;
691 return S_OK;
692 }
693 if(FAILED(hres))
694 return hres;
695
696 if(id == DISPID_IHTMLELEMENT_STYLE) {
697 IHTMLStyle *style;
698
699 TRACE("Special case: style\n");
700
701 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
702 if(FAILED(hres))
703 return hres;
704
705 hres = IHTMLStyle_put_cssText(style, NULL);
706 IHTMLStyle_Release(style);
707 if(FAILED(hres))
708 return hres;
709
710 *pfSuccess = VARIANT_TRUE;
711 return S_OK;
712 }
713
714 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
715 }
716
HTMLElement_put_className(IHTMLElement * iface,BSTR v)717 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
718 {
719 HTMLElement *This = impl_from_IHTMLElement(iface);
720 nsAString classname_str;
721 nsresult nsres;
722
723 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
724
725 if(!This->nselem) {
726 FIXME("NULL nselem\n");
727 return E_NOTIMPL;
728 }
729
730 nsAString_InitDepend(&classname_str, v);
731 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
732 nsAString_Finish(&classname_str);
733 if(NS_FAILED(nsres))
734 ERR("SetClassName failed: %08x\n", nsres);
735
736 return S_OK;
737 }
738
HTMLElement_get_className(IHTMLElement * iface,BSTR * p)739 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
740 {
741 HTMLElement *This = impl_from_IHTMLElement(iface);
742 nsAString class_str;
743 nsresult nsres;
744
745 TRACE("(%p)->(%p)\n", This, p);
746
747 if(!This->nselem) {
748 FIXME("NULL nselem\n");
749 return E_NOTIMPL;
750 }
751
752 nsAString_Init(&class_str, NULL);
753 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
754 return return_nsstr(nsres, &class_str, p);
755 }
756
HTMLElement_put_id(IHTMLElement * iface,BSTR v)757 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
758 {
759 HTMLElement *This = impl_from_IHTMLElement(iface);
760 nsAString id_str;
761 nsresult nsres;
762
763 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
764
765 if(!This->nselem) {
766 FIXME("nselem == NULL\n");
767 return S_OK;
768 }
769
770 nsAString_InitDepend(&id_str, v);
771 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
772 nsAString_Finish(&id_str);
773 if(NS_FAILED(nsres))
774 ERR("SetId failed: %08x\n", nsres);
775
776 return S_OK;
777 }
778
HTMLElement_get_id(IHTMLElement * iface,BSTR * p)779 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
780 {
781 HTMLElement *This = impl_from_IHTMLElement(iface);
782 nsAString id_str;
783 nsresult nsres;
784
785 TRACE("(%p)->(%p)\n", This, p);
786
787 if(!This->nselem) {
788 *p = NULL;
789 return S_OK;
790 }
791
792 nsAString_Init(&id_str, NULL);
793 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
794 return return_nsstr(nsres, &id_str, p);
795 }
796
HTMLElement_get_tagName(IHTMLElement * iface,BSTR * p)797 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
798 {
799 HTMLElement *This = impl_from_IHTMLElement(iface);
800 nsAString tag_str;
801 nsresult nsres;
802
803 TRACE("(%p)->(%p)\n", This, p);
804
805 if(!This->nselem) {
806 static const WCHAR comment_tagW[] = {'!',0};
807
808 WARN("NULL nselem, assuming comment\n");
809
810 *p = SysAllocString(comment_tagW);
811 return *p ? S_OK : E_OUTOFMEMORY;
812 }
813
814 nsAString_Init(&tag_str, NULL);
815 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
816 return return_nsstr(nsres, &tag_str, p);
817 }
818
HTMLElement_get_parentElement(IHTMLElement * iface,IHTMLElement ** p)819 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
820 {
821 HTMLElement *This = impl_from_IHTMLElement(iface);
822 IHTMLDOMNode *node;
823 HRESULT hres;
824
825 TRACE("(%p)->(%p)\n", This, p);
826
827 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
828 if(FAILED(hres))
829 return hres;
830
831 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
832 IHTMLDOMNode_Release(node);
833 if(FAILED(hres))
834 *p = NULL;
835
836 return S_OK;
837 }
838
HTMLElement_get_style(IHTMLElement * iface,IHTMLStyle ** p)839 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
840 {
841 HTMLElement *This = impl_from_IHTMLElement(iface);
842
843 TRACE("(%p)->(%p)\n", This, p);
844
845 if(!This->style) {
846 HRESULT hres;
847
848 hres = HTMLStyle_Create(This, &This->style);
849 if(FAILED(hres))
850 return hres;
851 }
852
853 *p = &This->style->IHTMLStyle_iface;
854 IHTMLStyle_AddRef(*p);
855 return S_OK;
856 }
857
HTMLElement_put_onhelp(IHTMLElement * iface,VARIANT v)858 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
859 {
860 HTMLElement *This = impl_from_IHTMLElement(iface);
861 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
862 return E_NOTIMPL;
863 }
864
HTMLElement_get_onhelp(IHTMLElement * iface,VARIANT * p)865 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
866 {
867 HTMLElement *This = impl_from_IHTMLElement(iface);
868 FIXME("(%p)->(%p)\n", This, p);
869 return E_NOTIMPL;
870 }
871
HTMLElement_put_onclick(IHTMLElement * iface,VARIANT v)872 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
873 {
874 HTMLElement *This = impl_from_IHTMLElement(iface);
875
876 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
877
878 return set_node_event(&This->node, EVENTID_CLICK, &v);
879 }
880
HTMLElement_get_onclick(IHTMLElement * iface,VARIANT * p)881 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
882 {
883 HTMLElement *This = impl_from_IHTMLElement(iface);
884
885 TRACE("(%p)->(%p)\n", This, p);
886
887 return get_node_event(&This->node, EVENTID_CLICK, p);
888 }
889
HTMLElement_put_ondblclick(IHTMLElement * iface,VARIANT v)890 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
891 {
892 HTMLElement *This = impl_from_IHTMLElement(iface);
893
894 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
895
896 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
897 }
898
HTMLElement_get_ondblclick(IHTMLElement * iface,VARIANT * p)899 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
900 {
901 HTMLElement *This = impl_from_IHTMLElement(iface);
902
903 TRACE("(%p)->(%p)\n", This, p);
904
905 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
906 }
907
HTMLElement_put_onkeydown(IHTMLElement * iface,VARIANT v)908 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
909 {
910 HTMLElement *This = impl_from_IHTMLElement(iface);
911
912 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
913
914 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
915 }
916
HTMLElement_get_onkeydown(IHTMLElement * iface,VARIANT * p)917 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
918 {
919 HTMLElement *This = impl_from_IHTMLElement(iface);
920
921 TRACE("(%p)->(%p)\n", This, p);
922
923 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
924 }
925
HTMLElement_put_onkeyup(IHTMLElement * iface,VARIANT v)926 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
927 {
928 HTMLElement *This = impl_from_IHTMLElement(iface);
929
930 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
931
932 return set_node_event(&This->node, EVENTID_KEYUP, &v);
933 }
934
HTMLElement_get_onkeyup(IHTMLElement * iface,VARIANT * p)935 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
936 {
937 HTMLElement *This = impl_from_IHTMLElement(iface);
938 FIXME("(%p)->(%p)\n", This, p);
939 return E_NOTIMPL;
940 }
941
HTMLElement_put_onkeypress(IHTMLElement * iface,VARIANT v)942 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
943 {
944 HTMLElement *This = impl_from_IHTMLElement(iface);
945
946 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
947
948 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
949 }
950
HTMLElement_get_onkeypress(IHTMLElement * iface,VARIANT * p)951 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
952 {
953 HTMLElement *This = impl_from_IHTMLElement(iface);
954
955 TRACE("(%p)->(%p)\n", This, p);
956
957 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
958 }
959
HTMLElement_put_onmouseout(IHTMLElement * iface,VARIANT v)960 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
961 {
962 HTMLElement *This = impl_from_IHTMLElement(iface);
963
964 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
965
966 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
967 }
968
HTMLElement_get_onmouseout(IHTMLElement * iface,VARIANT * p)969 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
970 {
971 HTMLElement *This = impl_from_IHTMLElement(iface);
972
973 TRACE("(%p)->(%p)\n", This, p);
974
975 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
976 }
977
HTMLElement_put_onmouseover(IHTMLElement * iface,VARIANT v)978 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
979 {
980 HTMLElement *This = impl_from_IHTMLElement(iface);
981
982 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
983
984 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
985 }
986
HTMLElement_get_onmouseover(IHTMLElement * iface,VARIANT * p)987 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
988 {
989 HTMLElement *This = impl_from_IHTMLElement(iface);
990
991 TRACE("(%p)->(%p)\n", This, p);
992
993 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
994 }
995
HTMLElement_put_onmousemove(IHTMLElement * iface,VARIANT v)996 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
997 {
998 HTMLElement *This = impl_from_IHTMLElement(iface);
999
1000 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1001
1002 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1003 }
1004
HTMLElement_get_onmousemove(IHTMLElement * iface,VARIANT * p)1005 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1006 {
1007 HTMLElement *This = impl_from_IHTMLElement(iface);
1008
1009 TRACE("(%p)->(%p)\n", This, p);
1010
1011 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1012 }
1013
HTMLElement_put_onmousedown(IHTMLElement * iface,VARIANT v)1014 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1015 {
1016 HTMLElement *This = impl_from_IHTMLElement(iface);
1017
1018 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1019
1020 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1021 }
1022
HTMLElement_get_onmousedown(IHTMLElement * iface,VARIANT * p)1023 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1024 {
1025 HTMLElement *This = impl_from_IHTMLElement(iface);
1026
1027 TRACE("(%p)->(%p)\n", This, p);
1028
1029 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1030 }
1031
HTMLElement_put_onmouseup(IHTMLElement * iface,VARIANT v)1032 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1033 {
1034 HTMLElement *This = impl_from_IHTMLElement(iface);
1035
1036 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1037
1038 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1039 }
1040
HTMLElement_get_onmouseup(IHTMLElement * iface,VARIANT * p)1041 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1042 {
1043 HTMLElement *This = impl_from_IHTMLElement(iface);
1044
1045 TRACE("(%p)->(%p)\n", This, p);
1046
1047 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1048 }
1049
HTMLElement_get_document(IHTMLElement * iface,IDispatch ** p)1050 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1051 {
1052 HTMLElement *This = impl_from_IHTMLElement(iface);
1053
1054 TRACE("(%p)->(%p)\n", This, p);
1055
1056 if(!p)
1057 return E_POINTER;
1058
1059 if(This->node.vtbl->get_document)
1060 return This->node.vtbl->get_document(&This->node, p);
1061
1062 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1063 IDispatch_AddRef(*p);
1064 return S_OK;
1065 }
1066
1067 static const WCHAR titleW[] = {'t','i','t','l','e',0};
1068
HTMLElement_put_title(IHTMLElement * iface,BSTR v)1069 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1070 {
1071 HTMLElement *This = impl_from_IHTMLElement(iface);
1072 nsAString title_str;
1073 nsresult nsres;
1074
1075 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1076
1077 if(!This->nselem) {
1078 VARIANT *var;
1079 HRESULT hres;
1080
1081 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, TRUE, &var);
1082 if(FAILED(hres))
1083 return hres;
1084
1085 VariantClear(var);
1086 V_VT(var) = VT_BSTR;
1087 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1088 return S_OK;
1089 }
1090
1091 nsAString_InitDepend(&title_str, v);
1092 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
1093 nsAString_Finish(&title_str);
1094 if(NS_FAILED(nsres))
1095 ERR("SetTitle failed: %08x\n", nsres);
1096
1097 return S_OK;
1098 }
1099
HTMLElement_get_title(IHTMLElement * iface,BSTR * p)1100 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1101 {
1102 HTMLElement *This = impl_from_IHTMLElement(iface);
1103 nsAString title_str;
1104 nsresult nsres;
1105
1106 TRACE("(%p)->(%p)\n", This, p);
1107
1108 if(!This->nselem) {
1109 VARIANT *var;
1110 HRESULT hres;
1111
1112 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, FALSE, &var);
1113 if(hres == DISP_E_UNKNOWNNAME) {
1114 *p = NULL;
1115 }else if(V_VT(var) != VT_BSTR) {
1116 FIXME("title = %s\n", debugstr_variant(var));
1117 return E_FAIL;
1118 }else {
1119 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1120 }
1121
1122 return S_OK;
1123 }
1124
1125 nsAString_Init(&title_str, NULL);
1126 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
1127 return return_nsstr(nsres, &title_str, p);
1128 }
1129
1130 static const WCHAR languageW[] = {'l','a','n','g','u','a','g','e',0};
1131
HTMLElement_put_language(IHTMLElement * iface,BSTR v)1132 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1133 {
1134 HTMLElement *This = impl_from_IHTMLElement(iface);
1135
1136 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1137
1138 return elem_string_attr_setter(This, languageW, v);
1139 }
1140
HTMLElement_get_language(IHTMLElement * iface,BSTR * p)1141 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1142 {
1143 HTMLElement *This = impl_from_IHTMLElement(iface);
1144
1145 TRACE("(%p)->(%p)\n", This, p);
1146
1147 return elem_string_attr_getter(This, languageW, TRUE, p);
1148 }
1149
HTMLElement_put_onselectstart(IHTMLElement * iface,VARIANT v)1150 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1151 {
1152 HTMLElement *This = impl_from_IHTMLElement(iface);
1153
1154 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1155
1156 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1157 }
1158
HTMLElement_get_onselectstart(IHTMLElement * iface,VARIANT * p)1159 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1160 {
1161 HTMLElement *This = impl_from_IHTMLElement(iface);
1162
1163 TRACE("(%p)->(%p)\n", This, p);
1164
1165 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1166 }
1167
HTMLElement_scrollIntoView(IHTMLElement * iface,VARIANT varargStart)1168 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1169 {
1170 HTMLElement *This = impl_from_IHTMLElement(iface);
1171 cpp_bool start = TRUE;
1172 nsresult nsres;
1173
1174 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1175
1176 switch(V_VT(&varargStart)) {
1177 case VT_EMPTY:
1178 case VT_ERROR:
1179 break;
1180 case VT_BOOL:
1181 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1182 break;
1183 default:
1184 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1185 }
1186
1187 if(!This->nselem) {
1188 FIXME("Unsupported for comments\n");
1189 return E_NOTIMPL;
1190 }
1191
1192 nsres = nsIDOMHTMLElement_ScrollIntoView(This->nselem, start, 1);
1193 assert(nsres == NS_OK);
1194
1195 return S_OK;
1196 }
1197
HTMLElement_contains(IHTMLElement * iface,IHTMLElement * pChild,VARIANT_BOOL * pfResult)1198 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1199 VARIANT_BOOL *pfResult)
1200 {
1201 HTMLElement *This = impl_from_IHTMLElement(iface);
1202 cpp_bool result = FALSE;
1203
1204 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1205
1206 if(pChild) {
1207 HTMLElement *child;
1208 nsresult nsres;
1209
1210 child = unsafe_impl_from_IHTMLElement(pChild);
1211 if(!child) {
1212 ERR("not our element\n");
1213 return E_FAIL;
1214 }
1215
1216 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1217 assert(nsres == NS_OK);
1218 }
1219
1220 *pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
1221 return S_OK;
1222 }
1223
HTMLElement_get_sourceIndex(IHTMLElement * iface,LONG * p)1224 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1225 {
1226 HTMLElement *This = impl_from_IHTMLElement(iface);
1227
1228 TRACE("(%p)->(%p)\n", This, p);
1229
1230 return get_elem_source_index(This, p);
1231 }
1232
HTMLElement_get_recordNumber(IHTMLElement * iface,VARIANT * p)1233 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1234 {
1235 HTMLElement *This = impl_from_IHTMLElement(iface);
1236 FIXME("(%p)->(%p)\n", This, p);
1237 return E_NOTIMPL;
1238 }
1239
HTMLElement_put_lang(IHTMLElement * iface,BSTR v)1240 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1241 {
1242 HTMLElement *This = impl_from_IHTMLElement(iface);
1243 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1244 return E_NOTIMPL;
1245 }
1246
HTMLElement_get_lang(IHTMLElement * iface,BSTR * p)1247 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
1248 {
1249 HTMLElement *This = impl_from_IHTMLElement(iface);
1250 FIXME("(%p)->(%p)\n", This, p);
1251 return E_NOTIMPL;
1252 }
1253
HTMLElement_get_offsetLeft(IHTMLElement * iface,LONG * p)1254 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
1255 {
1256 HTMLElement *This = impl_from_IHTMLElement(iface);
1257 nsresult nsres;
1258
1259 TRACE("(%p)->(%p)\n", This, p);
1260
1261 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, p);
1262 if(NS_FAILED(nsres)) {
1263 ERR("GetOffsetLeft failed: %08x\n", nsres);
1264 return E_FAIL;
1265 }
1266
1267 return S_OK;
1268 }
1269
HTMLElement_get_offsetTop(IHTMLElement * iface,LONG * p)1270 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
1271 {
1272 HTMLElement *This = impl_from_IHTMLElement(iface);
1273 nsresult nsres;
1274
1275 TRACE("(%p)->(%p)\n", This, p);
1276
1277 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, p);
1278 if(NS_FAILED(nsres)) {
1279 ERR("GetOffsetTop failed: %08x\n", nsres);
1280 return E_FAIL;
1281 }
1282
1283 return S_OK;
1284 }
1285
HTMLElement_get_offsetWidth(IHTMLElement * iface,LONG * p)1286 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
1287 {
1288 HTMLElement *This = impl_from_IHTMLElement(iface);
1289 nsresult nsres;
1290
1291 TRACE("(%p)->(%p)\n", This, p);
1292
1293 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, p);
1294 if(NS_FAILED(nsres)) {
1295 ERR("GetOffsetWidth failed: %08x\n", nsres);
1296 return E_FAIL;
1297 }
1298
1299 return S_OK;
1300 }
1301
HTMLElement_get_offsetHeight(IHTMLElement * iface,LONG * p)1302 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
1303 {
1304 HTMLElement *This = impl_from_IHTMLElement(iface);
1305 nsresult nsres;
1306
1307 TRACE("(%p)->(%p)\n", This, p);
1308
1309 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, p);
1310 if(NS_FAILED(nsres)) {
1311 ERR("GetOffsetHeight failed: %08x\n", nsres);
1312 return E_FAIL;
1313 }
1314
1315 return S_OK;
1316 }
1317
HTMLElement_get_offsetParent(IHTMLElement * iface,IHTMLElement ** p)1318 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
1319 {
1320 HTMLElement *This = impl_from_IHTMLElement(iface);
1321 nsIDOMElement *nsparent;
1322 nsresult nsres;
1323 HRESULT hres;
1324
1325 TRACE("(%p)->(%p)\n", This, p);
1326
1327 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
1328 if(NS_FAILED(nsres)) {
1329 ERR("GetOffsetParent failed: %08x\n", nsres);
1330 return E_FAIL;
1331 }
1332
1333 if(nsparent) {
1334 HTMLDOMNode *node;
1335
1336 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
1337 nsIDOMElement_Release(nsparent);
1338 if(FAILED(hres))
1339 return hres;
1340
1341 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
1342 node_release(node);
1343 }else {
1344 *p = NULL;
1345 hres = S_OK;
1346 }
1347
1348 return hres;
1349 }
1350
HTMLElement_put_innerHTML(IHTMLElement * iface,BSTR v)1351 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1352 {
1353 HTMLElement *This = impl_from_IHTMLElement(iface);
1354 nsAString html_str;
1355 nsresult nsres;
1356
1357 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1358
1359 if(!This->nselem) {
1360 FIXME("NULL nselem\n");
1361 return E_NOTIMPL;
1362 }
1363
1364 nsAString_InitDepend(&html_str, v);
1365 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
1366 nsAString_Finish(&html_str);
1367 if(NS_FAILED(nsres)) {
1368 FIXME("SetInnerHtml failed %08x\n", nsres);
1369 return E_FAIL;
1370 }
1371
1372 return S_OK;
1373 }
1374
HTMLElement_get_innerHTML(IHTMLElement * iface,BSTR * p)1375 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1376 {
1377 HTMLElement *This = impl_from_IHTMLElement(iface);
1378 nsAString html_str;
1379 nsresult nsres;
1380
1381 TRACE("(%p)->(%p)\n", This, p);
1382
1383 if(!This->nselem) {
1384 FIXME("NULL nselem\n");
1385 return E_NOTIMPL;
1386 }
1387
1388 nsAString_Init(&html_str, NULL);
1389 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
1390 return return_nsstr(nsres, &html_str, p);
1391 }
1392
HTMLElement_put_innerText(IHTMLElement * iface,BSTR v)1393 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1394 {
1395 HTMLElement *This = impl_from_IHTMLElement(iface);
1396 nsIDOMNode *nschild, *tmp;
1397 nsIDOMText *text_node;
1398 nsAString text_str;
1399 nsresult nsres;
1400
1401 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1402
1403 while(1) {
1404 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1405 if(NS_FAILED(nsres)) {
1406 ERR("GetLastChild failed: %08x\n", nsres);
1407 return E_FAIL;
1408 }
1409 if(!nschild)
1410 break;
1411
1412 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1413 nsIDOMNode_Release(nschild);
1414 if(NS_FAILED(nsres)) {
1415 ERR("RemoveChild failed: %08x\n", nsres);
1416 return E_FAIL;
1417 }
1418 nsIDOMNode_Release(tmp);
1419 }
1420
1421 nsAString_InitDepend(&text_str, v);
1422 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1423 nsAString_Finish(&text_str);
1424 if(NS_FAILED(nsres)) {
1425 ERR("CreateTextNode failed: %08x\n", nsres);
1426 return E_FAIL;
1427 }
1428
1429 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1430 if(NS_FAILED(nsres)) {
1431 ERR("AppendChild failed: %08x\n", nsres);
1432 return E_FAIL;
1433 }
1434
1435 nsIDOMNode_Release(tmp);
1436 return S_OK;
1437 }
1438
HTMLElement_get_innerText(IHTMLElement * iface,BSTR * p)1439 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1440 {
1441 HTMLElement *This = impl_from_IHTMLElement(iface);
1442
1443 TRACE("(%p)->(%p)\n", This, p);
1444
1445 return get_node_text(&This->node, p);
1446 }
1447
HTMLElement_put_outerHTML(IHTMLElement * iface,BSTR v)1448 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1449 {
1450 HTMLElement *This = impl_from_IHTMLElement(iface);
1451
1452 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1453
1454 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1455 }
1456
HTMLElement_get_outerHTML(IHTMLElement * iface,BSTR * p)1457 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1458 {
1459 HTMLElement *This = impl_from_IHTMLElement(iface);
1460 nsAString html_str;
1461 HRESULT hres;
1462
1463 WARN("(%p)->(%p) semi-stub\n", This, p);
1464
1465 nsAString_Init(&html_str, NULL);
1466 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1467 if(SUCCEEDED(hres)) {
1468 const PRUnichar *html;
1469
1470 nsAString_GetData(&html_str, &html);
1471 *p = SysAllocString(html);
1472 if(!*p)
1473 hres = E_OUTOFMEMORY;
1474 }
1475
1476 nsAString_Finish(&html_str);
1477
1478 TRACE("ret %s\n", debugstr_w(*p));
1479 return hres;
1480 }
1481
HTMLElement_put_outerText(IHTMLElement * iface,BSTR v)1482 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1483 {
1484 HTMLElement *This = impl_from_IHTMLElement(iface);
1485 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1486 return E_NOTIMPL;
1487 }
1488
HTMLElement_get_outerText(IHTMLElement * iface,BSTR * p)1489 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1490 {
1491 HTMLElement *This = impl_from_IHTMLElement(iface);
1492 FIXME("(%p)->(%p)\n", This, p);
1493 return E_NOTIMPL;
1494 }
1495
insert_adjacent_node(HTMLElement * This,const WCHAR * where,nsIDOMNode * nsnode,HTMLDOMNode ** ret_node)1496 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
1497 {
1498 nsIDOMNode *ret_nsnode;
1499 nsresult nsres;
1500 HRESULT hres = S_OK;
1501
1502 static const WCHAR beforebeginW[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1503 static const WCHAR afterbeginW[] = {'a','f','t','e','r','b','e','g','i','n',0};
1504 static const WCHAR beforeendW[] = {'b','e','f','o','r','e','e','n','d',0};
1505 static const WCHAR afterendW[] = {'a','f','t','e','r','e','n','d',0};
1506
1507 if (!strcmpiW(where, beforebeginW)) {
1508 nsIDOMNode *parent;
1509
1510 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1511 if(NS_FAILED(nsres))
1512 return E_FAIL;
1513
1514 if(!parent)
1515 return E_INVALIDARG;
1516
1517 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
1518 nsIDOMNode_Release(parent);
1519 }else if(!strcmpiW(where, afterbeginW)) {
1520 nsIDOMNode *first_child;
1521
1522 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1523 if(NS_FAILED(nsres))
1524 return E_FAIL;
1525
1526 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
1527 if(NS_FAILED(nsres))
1528 return E_FAIL;
1529
1530 if (first_child)
1531 nsIDOMNode_Release(first_child);
1532 }else if (!strcmpiW(where, beforeendW)) {
1533 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
1534 }else if (!strcmpiW(where, afterendW)) {
1535 nsIDOMNode *next_sibling, *parent;
1536
1537 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1538 if(NS_FAILED(nsres))
1539 return E_FAIL;
1540 if(!parent)
1541 return E_INVALIDARG;
1542
1543 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1544 if(NS_SUCCEEDED(nsres)) {
1545 if(next_sibling) {
1546 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
1547 nsIDOMNode_Release(next_sibling);
1548 }else {
1549 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
1550 }
1551 }
1552
1553 nsIDOMNode_Release(parent);
1554 }else {
1555 ERR("invalid where: %s\n", debugstr_w(where));
1556 return E_INVALIDARG;
1557 }
1558
1559 if (NS_FAILED(nsres))
1560 return E_FAIL;
1561
1562 if(ret_node)
1563 hres = get_node(This->node.doc, ret_nsnode, TRUE, ret_node);
1564 nsIDOMNode_Release(ret_nsnode);
1565 return hres;
1566 }
1567
HTMLElement_insertAdjacentHTML(IHTMLElement * iface,BSTR where,BSTR html)1568 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1569 BSTR html)
1570 {
1571 HTMLElement *This = impl_from_IHTMLElement(iface);
1572 nsIDOMRange *range;
1573 nsIDOMNode *nsnode;
1574 nsAString ns_html;
1575 nsresult nsres;
1576 HRESULT hr;
1577
1578 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1579
1580 if(!This->node.doc->nsdoc) {
1581 WARN("NULL nsdoc\n");
1582 return E_UNEXPECTED;
1583 }
1584
1585 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1586 if(NS_FAILED(nsres))
1587 {
1588 ERR("CreateRange failed: %08x\n", nsres);
1589 return E_FAIL;
1590 }
1591
1592 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1593
1594 nsAString_InitDepend(&ns_html, html);
1595 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1596 nsAString_Finish(&ns_html);
1597 nsIDOMRange_Release(range);
1598
1599 if(NS_FAILED(nsres) || !nsnode)
1600 {
1601 ERR("CreateTextNode failed: %08x\n", nsres);
1602 return E_FAIL;
1603 }
1604
1605 hr = insert_adjacent_node(This, where, nsnode, NULL);
1606 nsIDOMNode_Release(nsnode);
1607 return hr;
1608 }
1609
HTMLElement_insertAdjacentText(IHTMLElement * iface,BSTR where,BSTR text)1610 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1611 BSTR text)
1612 {
1613 HTMLElement *This = impl_from_IHTMLElement(iface);
1614 nsIDOMNode *nsnode;
1615 nsAString ns_text;
1616 nsresult nsres;
1617 HRESULT hr;
1618
1619 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1620
1621 if(!This->node.doc->nsdoc) {
1622 WARN("NULL nsdoc\n");
1623 return E_UNEXPECTED;
1624 }
1625
1626
1627 nsAString_InitDepend(&ns_text, text);
1628 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1629 nsAString_Finish(&ns_text);
1630
1631 if(NS_FAILED(nsres) || !nsnode)
1632 {
1633 ERR("CreateTextNode failed: %08x\n", nsres);
1634 return E_FAIL;
1635 }
1636
1637 hr = insert_adjacent_node(This, where, nsnode, NULL);
1638 nsIDOMNode_Release(nsnode);
1639
1640 return hr;
1641 }
1642
HTMLElement_get_parentTextEdit(IHTMLElement * iface,IHTMLElement ** p)1643 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1644 {
1645 HTMLElement *This = impl_from_IHTMLElement(iface);
1646 FIXME("(%p)->(%p)\n", This, p);
1647 return E_NOTIMPL;
1648 }
1649
HTMLElement_get_isTextEdit(IHTMLElement * iface,VARIANT_BOOL * p)1650 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1651 {
1652 HTMLElement *This = impl_from_IHTMLElement(iface);
1653
1654 TRACE("(%p)->(%p)\n", This, p);
1655
1656 *p = This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node)
1657 ? VARIANT_TRUE : VARIANT_FALSE;
1658 return S_OK;
1659 }
1660
HTMLElement_click(IHTMLElement * iface)1661 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1662 {
1663 HTMLElement *This = impl_from_IHTMLElement(iface);
1664
1665 TRACE("(%p)\n", This);
1666
1667 return call_fire_event(&This->node, EVENTID_CLICK);
1668 }
1669
HTMLElement_get_filters(IHTMLElement * iface,IHTMLFiltersCollection ** p)1670 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1671 IHTMLFiltersCollection **p)
1672 {
1673 HTMLElement *This = impl_from_IHTMLElement(iface);
1674 TRACE("(%p)->(%p)\n", This, p);
1675
1676 if(!p)
1677 return E_POINTER;
1678
1679 *p = HTMLFiltersCollection_Create();
1680
1681 return S_OK;
1682 }
1683
HTMLElement_put_ondragstart(IHTMLElement * iface,VARIANT v)1684 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1685 {
1686 HTMLElement *This = impl_from_IHTMLElement(iface);
1687 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1688 return E_NOTIMPL;
1689 }
1690
HTMLElement_get_ondragstart(IHTMLElement * iface,VARIANT * p)1691 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1692 {
1693 HTMLElement *This = impl_from_IHTMLElement(iface);
1694 FIXME("(%p)->(%p)\n", This, p);
1695 return E_NOTIMPL;
1696 }
1697
HTMLElement_toString(IHTMLElement * iface,BSTR * String)1698 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1699 {
1700 HTMLElement *This = impl_from_IHTMLElement(iface);
1701 FIXME("(%p)->(%p)\n", This, String);
1702 return E_NOTIMPL;
1703 }
1704
HTMLElement_put_onbeforeupdate(IHTMLElement * iface,VARIANT v)1705 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1706 {
1707 HTMLElement *This = impl_from_IHTMLElement(iface);
1708 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1709 return E_NOTIMPL;
1710 }
1711
HTMLElement_get_onbeforeupdate(IHTMLElement * iface,VARIANT * p)1712 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1713 {
1714 HTMLElement *This = impl_from_IHTMLElement(iface);
1715 FIXME("(%p)->(%p)\n", This, p);
1716 return E_NOTIMPL;
1717 }
1718
HTMLElement_put_onafterupdate(IHTMLElement * iface,VARIANT v)1719 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1720 {
1721 HTMLElement *This = impl_from_IHTMLElement(iface);
1722 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1723 return E_NOTIMPL;
1724 }
1725
HTMLElement_get_onafterupdate(IHTMLElement * iface,VARIANT * p)1726 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1727 {
1728 HTMLElement *This = impl_from_IHTMLElement(iface);
1729 FIXME("(%p)->(%p)\n", This, p);
1730 return E_NOTIMPL;
1731 }
1732
HTMLElement_put_onerrorupdate(IHTMLElement * iface,VARIANT v)1733 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1734 {
1735 HTMLElement *This = impl_from_IHTMLElement(iface);
1736 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1737 return E_NOTIMPL;
1738 }
1739
HTMLElement_get_onerrorupdate(IHTMLElement * iface,VARIANT * p)1740 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1741 {
1742 HTMLElement *This = impl_from_IHTMLElement(iface);
1743 FIXME("(%p)->(%p)\n", This, p);
1744 return E_NOTIMPL;
1745 }
1746
HTMLElement_put_onrowexit(IHTMLElement * iface,VARIANT v)1747 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1748 {
1749 HTMLElement *This = impl_from_IHTMLElement(iface);
1750 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1751 return E_NOTIMPL;
1752 }
1753
HTMLElement_get_onrowexit(IHTMLElement * iface,VARIANT * p)1754 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1755 {
1756 HTMLElement *This = impl_from_IHTMLElement(iface);
1757 FIXME("(%p)->(%p)\n", This, p);
1758 return E_NOTIMPL;
1759 }
1760
HTMLElement_put_onrowenter(IHTMLElement * iface,VARIANT v)1761 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1762 {
1763 HTMLElement *This = impl_from_IHTMLElement(iface);
1764 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1765 return E_NOTIMPL;
1766 }
1767
HTMLElement_get_onrowenter(IHTMLElement * iface,VARIANT * p)1768 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1769 {
1770 HTMLElement *This = impl_from_IHTMLElement(iface);
1771 FIXME("(%p)->(%p)\n", This, p);
1772 return E_NOTIMPL;
1773 }
1774
HTMLElement_put_ondatasetchanged(IHTMLElement * iface,VARIANT v)1775 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1776 {
1777 HTMLElement *This = impl_from_IHTMLElement(iface);
1778 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1779 return E_NOTIMPL;
1780 }
1781
HTMLElement_get_ondatasetchanged(IHTMLElement * iface,VARIANT * p)1782 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1783 {
1784 HTMLElement *This = impl_from_IHTMLElement(iface);
1785 FIXME("(%p)->(%p)\n", This, p);
1786 return E_NOTIMPL;
1787 }
1788
HTMLElement_put_ondataavailable(IHTMLElement * iface,VARIANT v)1789 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1790 {
1791 HTMLElement *This = impl_from_IHTMLElement(iface);
1792
1793 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1794
1795 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1796 }
1797
HTMLElement_get_ondataavailable(IHTMLElement * iface,VARIANT * p)1798 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1799 {
1800 HTMLElement *This = impl_from_IHTMLElement(iface);
1801
1802 TRACE("(%p)->(%p)\n", This, p);
1803
1804 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1805 }
1806
HTMLElement_put_ondatasetcomplete(IHTMLElement * iface,VARIANT v)1807 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1808 {
1809 HTMLElement *This = impl_from_IHTMLElement(iface);
1810 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1811 return E_NOTIMPL;
1812 }
1813
HTMLElement_get_ondatasetcomplete(IHTMLElement * iface,VARIANT * p)1814 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1815 {
1816 HTMLElement *This = impl_from_IHTMLElement(iface);
1817 FIXME("(%p)->(%p)\n", This, p);
1818 return E_NOTIMPL;
1819 }
1820
HTMLElement_put_onfilterchange(IHTMLElement * iface,VARIANT v)1821 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1822 {
1823 HTMLElement *This = impl_from_IHTMLElement(iface);
1824 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1825 return E_NOTIMPL;
1826 }
1827
HTMLElement_get_onfilterchange(IHTMLElement * iface,VARIANT * p)1828 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1829 {
1830 HTMLElement *This = impl_from_IHTMLElement(iface);
1831 FIXME("(%p)->(%p)\n", This, p);
1832 return E_NOTIMPL;
1833 }
1834
HTMLElement_get_children(IHTMLElement * iface,IDispatch ** p)1835 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1836 {
1837 HTMLElement *This = impl_from_IHTMLElement(iface);
1838 nsIDOMNodeList *nsnode_list;
1839 nsresult nsres;
1840
1841 TRACE("(%p)->(%p)\n", This, p);
1842
1843 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1844 if(NS_FAILED(nsres)) {
1845 ERR("GetChildNodes failed: %08x\n", nsres);
1846 return E_FAIL;
1847 }
1848
1849 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1850
1851 nsIDOMNodeList_Release(nsnode_list);
1852 return S_OK;
1853 }
1854
HTMLElement_get_all(IHTMLElement * iface,IDispatch ** p)1855 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1856 {
1857 HTMLElement *This = impl_from_IHTMLElement(iface);
1858
1859 TRACE("(%p)->(%p)\n", This, p);
1860
1861 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1862 return S_OK;
1863 }
1864
1865 static const IHTMLElementVtbl HTMLElementVtbl = {
1866 HTMLElement_QueryInterface,
1867 HTMLElement_AddRef,
1868 HTMLElement_Release,
1869 HTMLElement_GetTypeInfoCount,
1870 HTMLElement_GetTypeInfo,
1871 HTMLElement_GetIDsOfNames,
1872 HTMLElement_Invoke,
1873 HTMLElement_setAttribute,
1874 HTMLElement_getAttribute,
1875 HTMLElement_removeAttribute,
1876 HTMLElement_put_className,
1877 HTMLElement_get_className,
1878 HTMLElement_put_id,
1879 HTMLElement_get_id,
1880 HTMLElement_get_tagName,
1881 HTMLElement_get_parentElement,
1882 HTMLElement_get_style,
1883 HTMLElement_put_onhelp,
1884 HTMLElement_get_onhelp,
1885 HTMLElement_put_onclick,
1886 HTMLElement_get_onclick,
1887 HTMLElement_put_ondblclick,
1888 HTMLElement_get_ondblclick,
1889 HTMLElement_put_onkeydown,
1890 HTMLElement_get_onkeydown,
1891 HTMLElement_put_onkeyup,
1892 HTMLElement_get_onkeyup,
1893 HTMLElement_put_onkeypress,
1894 HTMLElement_get_onkeypress,
1895 HTMLElement_put_onmouseout,
1896 HTMLElement_get_onmouseout,
1897 HTMLElement_put_onmouseover,
1898 HTMLElement_get_onmouseover,
1899 HTMLElement_put_onmousemove,
1900 HTMLElement_get_onmousemove,
1901 HTMLElement_put_onmousedown,
1902 HTMLElement_get_onmousedown,
1903 HTMLElement_put_onmouseup,
1904 HTMLElement_get_onmouseup,
1905 HTMLElement_get_document,
1906 HTMLElement_put_title,
1907 HTMLElement_get_title,
1908 HTMLElement_put_language,
1909 HTMLElement_get_language,
1910 HTMLElement_put_onselectstart,
1911 HTMLElement_get_onselectstart,
1912 HTMLElement_scrollIntoView,
1913 HTMLElement_contains,
1914 HTMLElement_get_sourceIndex,
1915 HTMLElement_get_recordNumber,
1916 HTMLElement_put_lang,
1917 HTMLElement_get_lang,
1918 HTMLElement_get_offsetLeft,
1919 HTMLElement_get_offsetTop,
1920 HTMLElement_get_offsetWidth,
1921 HTMLElement_get_offsetHeight,
1922 HTMLElement_get_offsetParent,
1923 HTMLElement_put_innerHTML,
1924 HTMLElement_get_innerHTML,
1925 HTMLElement_put_innerText,
1926 HTMLElement_get_innerText,
1927 HTMLElement_put_outerHTML,
1928 HTMLElement_get_outerHTML,
1929 HTMLElement_put_outerText,
1930 HTMLElement_get_outerText,
1931 HTMLElement_insertAdjacentHTML,
1932 HTMLElement_insertAdjacentText,
1933 HTMLElement_get_parentTextEdit,
1934 HTMLElement_get_isTextEdit,
1935 HTMLElement_click,
1936 HTMLElement_get_filters,
1937 HTMLElement_put_ondragstart,
1938 HTMLElement_get_ondragstart,
1939 HTMLElement_toString,
1940 HTMLElement_put_onbeforeupdate,
1941 HTMLElement_get_onbeforeupdate,
1942 HTMLElement_put_onafterupdate,
1943 HTMLElement_get_onafterupdate,
1944 HTMLElement_put_onerrorupdate,
1945 HTMLElement_get_onerrorupdate,
1946 HTMLElement_put_onrowexit,
1947 HTMLElement_get_onrowexit,
1948 HTMLElement_put_onrowenter,
1949 HTMLElement_get_onrowenter,
1950 HTMLElement_put_ondatasetchanged,
1951 HTMLElement_get_ondatasetchanged,
1952 HTMLElement_put_ondataavailable,
1953 HTMLElement_get_ondataavailable,
1954 HTMLElement_put_ondatasetcomplete,
1955 HTMLElement_get_ondatasetcomplete,
1956 HTMLElement_put_onfilterchange,
1957 HTMLElement_get_onfilterchange,
1958 HTMLElement_get_children,
1959 HTMLElement_get_all
1960 };
1961
unsafe_impl_from_IHTMLElement(IHTMLElement * iface)1962 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
1963 {
1964 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
1965 }
1966
impl_from_IHTMLElement2(IHTMLElement2 * iface)1967 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
1968 {
1969 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
1970 }
1971
HTMLElement2_QueryInterface(IHTMLElement2 * iface,REFIID riid,void ** ppv)1972 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
1973 REFIID riid, void **ppv)
1974 {
1975 HTMLElement *This = impl_from_IHTMLElement2(iface);
1976 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
1977 }
1978
HTMLElement2_AddRef(IHTMLElement2 * iface)1979 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
1980 {
1981 HTMLElement *This = impl_from_IHTMLElement2(iface);
1982 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
1983 }
1984
HTMLElement2_Release(IHTMLElement2 * iface)1985 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
1986 {
1987 HTMLElement *This = impl_from_IHTMLElement2(iface);
1988 return IHTMLElement_Release(&This->IHTMLElement_iface);
1989 }
1990
HTMLElement2_GetTypeInfoCount(IHTMLElement2 * iface,UINT * pctinfo)1991 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
1992 {
1993 HTMLElement *This = impl_from_IHTMLElement2(iface);
1994 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
1995 }
1996
HTMLElement2_GetTypeInfo(IHTMLElement2 * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)1997 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
1998 LCID lcid, ITypeInfo **ppTInfo)
1999 {
2000 HTMLElement *This = impl_from_IHTMLElement2(iface);
2001 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2002 }
2003
HTMLElement2_GetIDsOfNames(IHTMLElement2 * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)2004 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2005 LPOLESTR *rgszNames, UINT cNames,
2006 LCID lcid, DISPID *rgDispId)
2007 {
2008 HTMLElement *This = impl_from_IHTMLElement2(iface);
2009 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2010 lcid, rgDispId);
2011 }
2012
HTMLElement2_Invoke(IHTMLElement2 * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)2013 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2014 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2015 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2016 {
2017 HTMLElement *This = impl_from_IHTMLElement2(iface);
2018 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2019 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2020 }
2021
HTMLElement2_get_scopeName(IHTMLElement2 * iface,BSTR * p)2022 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2023 {
2024 HTMLElement *This = impl_from_IHTMLElement2(iface);
2025 FIXME("(%p)->(%p)\n", This, p);
2026 return E_NOTIMPL;
2027 }
2028
HTMLElement2_setCapture(IHTMLElement2 * iface,VARIANT_BOOL containerCapture)2029 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2030 {
2031 HTMLElement *This = impl_from_IHTMLElement2(iface);
2032 FIXME("(%p)->(%x)\n", This, containerCapture);
2033 return E_NOTIMPL;
2034 }
2035
HTMLElement2_releaseCapture(IHTMLElement2 * iface)2036 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2037 {
2038 HTMLElement *This = impl_from_IHTMLElement2(iface);
2039 FIXME("(%p)\n", This);
2040 return E_NOTIMPL;
2041 }
2042
HTMLElement2_put_onlosecapture(IHTMLElement2 * iface,VARIANT v)2043 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2044 {
2045 HTMLElement *This = impl_from_IHTMLElement2(iface);
2046 FIXME("(%p)->()\n", This);
2047 return E_NOTIMPL;
2048 }
2049
HTMLElement2_get_onlosecapture(IHTMLElement2 * iface,VARIANT * p)2050 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2051 {
2052 HTMLElement *This = impl_from_IHTMLElement2(iface);
2053 FIXME("(%p)->(%p)\n", This, p);
2054 return E_NOTIMPL;
2055 }
2056
HTMLElement2_componentFromPoint(IHTMLElement2 * iface,LONG x,LONG y,BSTR * component)2057 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2058 LONG x, LONG y, BSTR *component)
2059 {
2060 HTMLElement *This = impl_from_IHTMLElement2(iface);
2061 FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
2062 return E_NOTIMPL;
2063 }
2064
HTMLElement2_doScroll(IHTMLElement2 * iface,VARIANT component)2065 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2066 {
2067 HTMLElement *This = impl_from_IHTMLElement2(iface);
2068
2069 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2070
2071 if(!This->node.doc->content_ready
2072 || !This->node.doc->basedoc.doc_obj->in_place_active)
2073 return E_PENDING;
2074
2075 WARN("stub\n");
2076 return S_OK;
2077 }
2078
HTMLElement2_put_onscroll(IHTMLElement2 * iface,VARIANT v)2079 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2080 {
2081 HTMLElement *This = impl_from_IHTMLElement2(iface);
2082 FIXME("(%p)->()\n", This);
2083 return E_NOTIMPL;
2084 }
2085
HTMLElement2_get_onscroll(IHTMLElement2 * iface,VARIANT * p)2086 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2087 {
2088 HTMLElement *This = impl_from_IHTMLElement2(iface);
2089 FIXME("(%p)->(%p)\n", This, p);
2090 return E_NOTIMPL;
2091 }
2092
HTMLElement2_put_ondrag(IHTMLElement2 * iface,VARIANT v)2093 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2094 {
2095 HTMLElement *This = impl_from_IHTMLElement2(iface);
2096
2097 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2098
2099 return set_node_event(&This->node, EVENTID_DRAG, &v);
2100 }
2101
HTMLElement2_get_ondrag(IHTMLElement2 * iface,VARIANT * p)2102 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2103 {
2104 HTMLElement *This = impl_from_IHTMLElement2(iface);
2105
2106 TRACE("(%p)->(%p)\n", This, p);
2107
2108 return get_node_event(&This->node, EVENTID_DRAG, p);
2109 }
2110
HTMLElement2_put_ondragend(IHTMLElement2 * iface,VARIANT v)2111 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2112 {
2113 HTMLElement *This = impl_from_IHTMLElement2(iface);
2114 FIXME("(%p)->()\n", This);
2115 return E_NOTIMPL;
2116 }
2117
HTMLElement2_get_ondragend(IHTMLElement2 * iface,VARIANT * p)2118 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2119 {
2120 HTMLElement *This = impl_from_IHTMLElement2(iface);
2121 FIXME("(%p)->(%p)\n", This, p);
2122 return E_NOTIMPL;
2123 }
2124
HTMLElement2_put_ondragenter(IHTMLElement2 * iface,VARIANT v)2125 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2126 {
2127 HTMLElement *This = impl_from_IHTMLElement2(iface);
2128 FIXME("(%p)->()\n", This);
2129 return E_NOTIMPL;
2130 }
2131
HTMLElement2_get_ondragenter(IHTMLElement2 * iface,VARIANT * p)2132 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2133 {
2134 HTMLElement *This = impl_from_IHTMLElement2(iface);
2135 FIXME("(%p)->(%p)\n", This, p);
2136 return E_NOTIMPL;
2137 }
2138
HTMLElement2_put_ondragover(IHTMLElement2 * iface,VARIANT v)2139 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2140 {
2141 HTMLElement *This = impl_from_IHTMLElement2(iface);
2142 FIXME("(%p)->()\n", This);
2143 return E_NOTIMPL;
2144 }
2145
HTMLElement2_get_ondragover(IHTMLElement2 * iface,VARIANT * p)2146 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2147 {
2148 HTMLElement *This = impl_from_IHTMLElement2(iface);
2149 FIXME("(%p)->(%p)\n", This, p);
2150 return E_NOTIMPL;
2151 }
2152
HTMLElement2_put_ondragleave(IHTMLElement2 * iface,VARIANT v)2153 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2154 {
2155 HTMLElement *This = impl_from_IHTMLElement2(iface);
2156 FIXME("(%p)->()\n", This);
2157 return E_NOTIMPL;
2158 }
2159
HTMLElement2_get_ondragleave(IHTMLElement2 * iface,VARIANT * p)2160 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2161 {
2162 HTMLElement *This = impl_from_IHTMLElement2(iface);
2163 FIXME("(%p)->(%p)\n", This, p);
2164 return E_NOTIMPL;
2165 }
2166
HTMLElement2_put_ondrop(IHTMLElement2 * iface,VARIANT v)2167 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2168 {
2169 HTMLElement *This = impl_from_IHTMLElement2(iface);
2170 FIXME("(%p)->()\n", This);
2171 return E_NOTIMPL;
2172 }
2173
HTMLElement2_get_ondrop(IHTMLElement2 * iface,VARIANT * p)2174 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2175 {
2176 HTMLElement *This = impl_from_IHTMLElement2(iface);
2177 FIXME("(%p)->(%p)\n", This, p);
2178 return E_NOTIMPL;
2179 }
2180
HTMLElement2_put_onbeforecut(IHTMLElement2 * iface,VARIANT v)2181 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2182 {
2183 HTMLElement *This = impl_from_IHTMLElement2(iface);
2184 FIXME("(%p)->()\n", This);
2185 return E_NOTIMPL;
2186 }
2187
HTMLElement2_get_onbeforecut(IHTMLElement2 * iface,VARIANT * p)2188 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2189 {
2190 HTMLElement *This = impl_from_IHTMLElement2(iface);
2191 FIXME("(%p)->(%p)\n", This, p);
2192 return E_NOTIMPL;
2193 }
2194
HTMLElement2_put_oncut(IHTMLElement2 * iface,VARIANT v)2195 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2196 {
2197 HTMLElement *This = impl_from_IHTMLElement2(iface);
2198 FIXME("(%p)->()\n", This);
2199 return E_NOTIMPL;
2200 }
2201
HTMLElement2_get_oncut(IHTMLElement2 * iface,VARIANT * p)2202 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2203 {
2204 HTMLElement *This = impl_from_IHTMLElement2(iface);
2205 FIXME("(%p)->(%p)\n", This, p);
2206 return E_NOTIMPL;
2207 }
2208
HTMLElement2_put_onbeforecopy(IHTMLElement2 * iface,VARIANT v)2209 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2210 {
2211 HTMLElement *This = impl_from_IHTMLElement2(iface);
2212 FIXME("(%p)->()\n", This);
2213 return E_NOTIMPL;
2214 }
2215
HTMLElement2_get_onbeforecopy(IHTMLElement2 * iface,VARIANT * p)2216 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2217 {
2218 HTMLElement *This = impl_from_IHTMLElement2(iface);
2219 FIXME("(%p)->(%p)\n", This, p);
2220 return E_NOTIMPL;
2221 }
2222
HTMLElement2_put_oncopy(IHTMLElement2 * iface,VARIANT v)2223 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2224 {
2225 HTMLElement *This = impl_from_IHTMLElement2(iface);
2226 FIXME("(%p)->()\n", This);
2227 return E_NOTIMPL;
2228 }
2229
HTMLElement2_get_oncopy(IHTMLElement2 * iface,VARIANT * p)2230 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2231 {
2232 HTMLElement *This = impl_from_IHTMLElement2(iface);
2233 FIXME("(%p)->(%p)\n", This, p);
2234 return E_NOTIMPL;
2235 }
2236
HTMLElement2_put_onbeforepaste(IHTMLElement2 * iface,VARIANT v)2237 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2238 {
2239 HTMLElement *This = impl_from_IHTMLElement2(iface);
2240 FIXME("(%p)->()\n", This);
2241 return E_NOTIMPL;
2242 }
2243
HTMLElement2_get_onbeforepaste(IHTMLElement2 * iface,VARIANT * p)2244 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2245 {
2246 HTMLElement *This = impl_from_IHTMLElement2(iface);
2247 FIXME("(%p)->(%p)\n", This, p);
2248 return E_NOTIMPL;
2249 }
2250
HTMLElement2_put_onpaste(IHTMLElement2 * iface,VARIANT v)2251 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2252 {
2253 HTMLElement *This = impl_from_IHTMLElement2(iface);
2254
2255 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2256
2257 return set_node_event(&This->node, EVENTID_PASTE, &v);
2258 }
2259
HTMLElement2_get_onpaste(IHTMLElement2 * iface,VARIANT * p)2260 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
2261 {
2262 HTMLElement *This = impl_from_IHTMLElement2(iface);
2263
2264 TRACE("(%p)->(%p)\n", This, p);
2265
2266 return get_node_event(&This->node, EVENTID_PASTE, p);
2267 }
2268
HTMLElement2_get_currentStyle(IHTMLElement2 * iface,IHTMLCurrentStyle ** p)2269 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
2270 {
2271 HTMLElement *This = impl_from_IHTMLElement2(iface);
2272
2273 TRACE("(%p)->(%p)\n", This, p);
2274
2275 return HTMLCurrentStyle_Create(This, p);
2276 }
2277
HTMLElement2_put_onpropertychange(IHTMLElement2 * iface,VARIANT v)2278 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
2279 {
2280 HTMLElement *This = impl_from_IHTMLElement2(iface);
2281 FIXME("(%p)->()\n", This);
2282 return E_NOTIMPL;
2283 }
2284
HTMLElement2_get_onpropertychange(IHTMLElement2 * iface,VARIANT * p)2285 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
2286 {
2287 HTMLElement *This = impl_from_IHTMLElement2(iface);
2288 FIXME("(%p)->(%p)\n", This, p);
2289 return E_NOTIMPL;
2290 }
2291
HTMLElement2_getClientRects(IHTMLElement2 * iface,IHTMLRectCollection ** pRectCol)2292 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
2293 {
2294 HTMLElement *This = impl_from_IHTMLElement2(iface);
2295 FIXME("(%p)->(%p)\n", This, pRectCol);
2296 return E_NOTIMPL;
2297 }
2298
HTMLElement2_getBoundingClientRect(IHTMLElement2 * iface,IHTMLRect ** pRect)2299 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
2300 {
2301 HTMLElement *This = impl_from_IHTMLElement2(iface);
2302 nsIDOMClientRect *nsrect;
2303 nsresult nsres;
2304 HRESULT hres;
2305
2306 TRACE("(%p)->(%p)\n", This, pRect);
2307
2308 nsres = nsIDOMHTMLElement_GetBoundingClientRect(This->nselem, &nsrect);
2309 if(NS_FAILED(nsres) || !nsrect) {
2310 ERR("GetBoindingClientRect failed: %08x\n", nsres);
2311 return E_FAIL;
2312 }
2313
2314 hres = create_html_rect(nsrect, pRect);
2315
2316 nsIDOMClientRect_Release(nsrect);
2317 return hres;
2318 }
2319
HTMLElement2_setExpression(IHTMLElement2 * iface,BSTR propname,BSTR expression,BSTR language)2320 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
2321 BSTR expression, BSTR language)
2322 {
2323 HTMLElement *This = impl_from_IHTMLElement2(iface);
2324 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
2325 debugstr_w(language));
2326 return E_NOTIMPL;
2327 }
2328
HTMLElement2_getExpression(IHTMLElement2 * iface,BSTR propname,VARIANT * expression)2329 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
2330 VARIANT *expression)
2331 {
2332 HTMLElement *This = impl_from_IHTMLElement2(iface);
2333 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
2334 return E_NOTIMPL;
2335 }
2336
HTMLElement2_removeExpression(IHTMLElement2 * iface,BSTR propname,VARIANT_BOOL * pfSuccess)2337 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
2338 VARIANT_BOOL *pfSuccess)
2339 {
2340 HTMLElement *This = impl_from_IHTMLElement2(iface);
2341 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
2342 return E_NOTIMPL;
2343 }
2344
HTMLElement2_put_tabIndex(IHTMLElement2 * iface,short v)2345 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
2346 {
2347 HTMLElement *This = impl_from_IHTMLElement2(iface);
2348 nsresult nsres;
2349
2350 TRACE("(%p)->(%d)\n", This, v);
2351
2352 nsres = nsIDOMHTMLElement_SetTabIndex(This->nselem, v);
2353 if(NS_FAILED(nsres))
2354 ERR("GetTabIndex failed: %08x\n", nsres);
2355
2356 return S_OK;
2357 }
2358
HTMLElement2_get_tabIndex(IHTMLElement2 * iface,short * p)2359 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
2360 {
2361 HTMLElement *This = impl_from_IHTMLElement2(iface);
2362 LONG index;
2363 nsresult nsres;
2364
2365 TRACE("(%p)->(%p)\n", This, p);
2366
2367 nsres = nsIDOMHTMLElement_GetTabIndex(This->nselem, &index);
2368 if(NS_FAILED(nsres)) {
2369 ERR("GetTabIndex failed: %08x\n", nsres);
2370 return E_FAIL;
2371 }
2372
2373 *p = index;
2374 return S_OK;
2375 }
2376
HTMLElement2_focus(IHTMLElement2 * iface)2377 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
2378 {
2379 HTMLElement *This = impl_from_IHTMLElement2(iface);
2380 nsresult nsres;
2381
2382 TRACE("(%p)\n", This);
2383
2384 nsres = nsIDOMHTMLElement_Focus(This->nselem);
2385 if(NS_FAILED(nsres))
2386 ERR("Focus failed: %08x\n", nsres);
2387
2388 return S_OK;
2389 }
2390
HTMLElement2_put_accessKey(IHTMLElement2 * iface,BSTR v)2391 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
2392 {
2393 HTMLElement *This = impl_from_IHTMLElement2(iface);
2394 VARIANT var;
2395
2396 static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
2397
2398 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2399
2400 V_VT(&var) = VT_BSTR;
2401 V_BSTR(&var) = v;
2402 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
2403 }
2404
HTMLElement2_get_accessKey(IHTMLElement2 * iface,BSTR * p)2405 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
2406 {
2407 HTMLElement *This = impl_from_IHTMLElement2(iface);
2408 FIXME("(%p)->(%p)\n", This, p);
2409 return E_NOTIMPL;
2410 }
2411
HTMLElement2_put_onblur(IHTMLElement2 * iface,VARIANT v)2412 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
2413 {
2414 HTMLElement *This = impl_from_IHTMLElement2(iface);
2415
2416 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2417
2418 return set_node_event(&This->node, EVENTID_BLUR, &v);
2419 }
2420
HTMLElement2_get_onblur(IHTMLElement2 * iface,VARIANT * p)2421 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
2422 {
2423 HTMLElement *This = impl_from_IHTMLElement2(iface);
2424
2425 TRACE("(%p)->(%p)\n", This, p);
2426
2427 return get_node_event(&This->node, EVENTID_BLUR, p);
2428 }
2429
HTMLElement2_put_onfocus(IHTMLElement2 * iface,VARIANT v)2430 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
2431 {
2432 HTMLElement *This = impl_from_IHTMLElement2(iface);
2433
2434 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2435
2436 return set_node_event(&This->node, EVENTID_FOCUS, &v);
2437 }
2438
HTMLElement2_get_onfocus(IHTMLElement2 * iface,VARIANT * p)2439 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
2440 {
2441 HTMLElement *This = impl_from_IHTMLElement2(iface);
2442
2443 TRACE("(%p)->(%p)\n", This, p);
2444
2445 return get_node_event(&This->node, EVENTID_FOCUS, p);
2446 }
2447
HTMLElement2_put_onresize(IHTMLElement2 * iface,VARIANT v)2448 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
2449 {
2450 HTMLElement *This = impl_from_IHTMLElement2(iface);
2451 FIXME("(%p)->()\n", This);
2452 return E_NOTIMPL;
2453 }
2454
HTMLElement2_get_onresize(IHTMLElement2 * iface,VARIANT * p)2455 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
2456 {
2457 HTMLElement *This = impl_from_IHTMLElement2(iface);
2458 FIXME("(%p)->(%p)\n", This, p);
2459 return E_NOTIMPL;
2460 }
2461
HTMLElement2_blur(IHTMLElement2 * iface)2462 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
2463 {
2464 HTMLElement *This = impl_from_IHTMLElement2(iface);
2465 nsresult nsres;
2466
2467 TRACE("(%p)\n", This);
2468
2469 nsres = nsIDOMHTMLElement_Blur(This->nselem);
2470 if(NS_FAILED(nsres)) {
2471 ERR("Blur failed: %08x\n", nsres);
2472 return E_FAIL;
2473 }
2474
2475 return S_OK;
2476 }
2477
HTMLElement2_addFilter(IHTMLElement2 * iface,IUnknown * pUnk)2478 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2479 {
2480 HTMLElement *This = impl_from_IHTMLElement2(iface);
2481 FIXME("(%p)->(%p)\n", This, pUnk);
2482 return E_NOTIMPL;
2483 }
2484
HTMLElement2_removeFilter(IHTMLElement2 * iface,IUnknown * pUnk)2485 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2486 {
2487 HTMLElement *This = impl_from_IHTMLElement2(iface);
2488 FIXME("(%p)->(%p)\n", This, pUnk);
2489 return E_NOTIMPL;
2490 }
2491
HTMLElement2_get_clientHeight(IHTMLElement2 * iface,LONG * p)2492 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
2493 {
2494 HTMLElement *This = impl_from_IHTMLElement2(iface);
2495 nsresult nsres;
2496
2497 TRACE("(%p)->(%p)\n", This, p);
2498
2499 nsres = nsIDOMHTMLElement_GetClientHeight(This->nselem, p);
2500 assert(nsres == NS_OK);
2501 return S_OK;
2502 }
2503
HTMLElement2_get_clientWidth(IHTMLElement2 * iface,LONG * p)2504 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
2505 {
2506 HTMLElement *This = impl_from_IHTMLElement2(iface);
2507 nsresult nsres;
2508
2509 TRACE("(%p)->(%p)\n", This, p);
2510
2511 nsres = nsIDOMHTMLElement_GetClientWidth(This->nselem, p);
2512 assert(nsres == NS_OK);
2513 return S_OK;
2514 }
2515
HTMLElement2_get_clientTop(IHTMLElement2 * iface,LONG * p)2516 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
2517 {
2518 HTMLElement *This = impl_from_IHTMLElement2(iface);
2519 nsresult nsres;
2520
2521 TRACE("(%p)->(%p)\n", This, p);
2522
2523 nsres = nsIDOMHTMLElement_GetClientTop(This->nselem, p);
2524 assert(nsres == NS_OK);
2525
2526 TRACE("*p = %d\n", *p);
2527 return S_OK;
2528 }
2529
HTMLElement2_get_clientLeft(IHTMLElement2 * iface,LONG * p)2530 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
2531 {
2532 HTMLElement *This = impl_from_IHTMLElement2(iface);
2533 nsresult nsres;
2534
2535 TRACE("(%p)->(%p)\n", This, p);
2536
2537 nsres = nsIDOMHTMLElement_GetClientLeft(This->nselem, p);
2538 assert(nsres == NS_OK);
2539
2540 TRACE("*p = %d\n", *p);
2541 return S_OK;
2542 }
2543
HTMLElement2_attachEvent(IHTMLElement2 * iface,BSTR event,IDispatch * pDisp,VARIANT_BOOL * pfResult)2544 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
2545 IDispatch *pDisp, VARIANT_BOOL *pfResult)
2546 {
2547 HTMLElement *This = impl_from_IHTMLElement2(iface);
2548
2549 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2550
2551 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2552 }
2553
HTMLElement2_detachEvent(IHTMLElement2 * iface,BSTR event,IDispatch * pDisp)2554 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
2555 {
2556 HTMLElement *This = impl_from_IHTMLElement2(iface);
2557
2558 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2559
2560 return detach_event(&This->node.event_target, event, pDisp);
2561 }
2562
HTMLElement2_get_readyState(IHTMLElement2 * iface,VARIANT * p)2563 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
2564 {
2565 HTMLElement *This = impl_from_IHTMLElement2(iface);
2566 BSTR str;
2567
2568 TRACE("(%p)->(%p)\n", This, p);
2569
2570 if(This->node.vtbl->get_readystate) {
2571 HRESULT hres;
2572
2573 hres = This->node.vtbl->get_readystate(&This->node, &str);
2574 if(FAILED(hres))
2575 return hres;
2576 }else {
2577 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
2578
2579 str = SysAllocString(completeW);
2580 if(!str)
2581 return E_OUTOFMEMORY;
2582 }
2583
2584 V_VT(p) = VT_BSTR;
2585 V_BSTR(p) = str;
2586 return S_OK;
2587 }
2588
HTMLElement2_put_onreadystatechange(IHTMLElement2 * iface,VARIANT v)2589 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
2590 {
2591 HTMLElement *This = impl_from_IHTMLElement2(iface);
2592
2593 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2594
2595 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
2596 }
2597
HTMLElement2_get_onreadystatechange(IHTMLElement2 * iface,VARIANT * p)2598 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
2599 {
2600 HTMLElement *This = impl_from_IHTMLElement2(iface);
2601
2602 TRACE("(%p)->(%p)\n", This, p);
2603
2604 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
2605 }
2606
HTMLElement2_put_onrowsdelete(IHTMLElement2 * iface,VARIANT v)2607 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
2608 {
2609 HTMLElement *This = impl_from_IHTMLElement2(iface);
2610 FIXME("(%p)->()\n", This);
2611 return E_NOTIMPL;
2612 }
2613
HTMLElement2_get_onrowsdelete(IHTMLElement2 * iface,VARIANT * p)2614 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
2615 {
2616 HTMLElement *This = impl_from_IHTMLElement2(iface);
2617 FIXME("(%p)->(%p)\n", This, p);
2618 return E_NOTIMPL;
2619 }
2620
HTMLElement2_put_onrowsinserted(IHTMLElement2 * iface,VARIANT v)2621 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
2622 {
2623 HTMLElement *This = impl_from_IHTMLElement2(iface);
2624 FIXME("(%p)->()\n", This);
2625 return E_NOTIMPL;
2626 }
2627
HTMLElement2_get_onrowsinserted(IHTMLElement2 * iface,VARIANT * p)2628 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
2629 {
2630 HTMLElement *This = impl_from_IHTMLElement2(iface);
2631 FIXME("(%p)->(%p)\n", This, p);
2632 return E_NOTIMPL;
2633 }
2634
HTMLElement2_put_oncellchange(IHTMLElement2 * iface,VARIANT v)2635 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
2636 {
2637 HTMLElement *This = impl_from_IHTMLElement2(iface);
2638 FIXME("(%p)->()\n", This);
2639 return E_NOTIMPL;
2640 }
2641
HTMLElement2_get_oncellchange(IHTMLElement2 * iface,VARIANT * p)2642 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
2643 {
2644 HTMLElement *This = impl_from_IHTMLElement2(iface);
2645 FIXME("(%p)->(%p)\n", This, p);
2646 return E_NOTIMPL;
2647 }
2648
HTMLElement2_put_dir(IHTMLElement2 * iface,BSTR v)2649 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
2650 {
2651 HTMLElement *This = impl_from_IHTMLElement2(iface);
2652 nsAString nsstr;
2653 nsresult nsres;
2654
2655 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2656
2657 if(!This->nselem) {
2658 FIXME("Unsupported for comment nodes.\n");
2659 return S_OK;
2660 }
2661
2662 nsAString_InitDepend(&nsstr, v);
2663 nsres = nsIDOMHTMLElement_SetDir(This->nselem, &nsstr);
2664 nsAString_Finish(&nsstr);
2665 if(NS_FAILED(nsres)) {
2666 ERR("SetDir failed: %08x\n", nsres);
2667 return E_FAIL;
2668 }
2669
2670 return S_OK;
2671 }
2672
HTMLElement2_get_dir(IHTMLElement2 * iface,BSTR * p)2673 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
2674 {
2675 HTMLElement *This = impl_from_IHTMLElement2(iface);
2676 nsAString dir_str;
2677 nsresult nsres;
2678
2679 TRACE("(%p)->(%p)\n", This, p);
2680
2681 if(!This->nselem) {
2682 *p = NULL;
2683 return S_OK;
2684 }
2685
2686 nsAString_Init(&dir_str, NULL);
2687 nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
2688 return return_nsstr(nsres, &dir_str, p);
2689 }
2690
HTMLElement2_createControlRange(IHTMLElement2 * iface,IDispatch ** range)2691 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
2692 {
2693 HTMLElement *This = impl_from_IHTMLElement2(iface);
2694 FIXME("(%p)->(%p)\n", This, range);
2695 return E_NOTIMPL;
2696 }
2697
HTMLElement2_get_scrollHeight(IHTMLElement2 * iface,LONG * p)2698 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
2699 {
2700 HTMLElement *This = impl_from_IHTMLElement2(iface);
2701 nsresult nsres;
2702
2703 TRACE("(%p)->(%p)\n", This, p);
2704
2705 nsres = nsIDOMHTMLElement_GetScrollHeight(This->nselem, p);
2706 assert(nsres == NS_OK);
2707
2708 TRACE("*p = %d\n", *p);
2709 return S_OK;
2710 }
2711
HTMLElement2_get_scrollWidth(IHTMLElement2 * iface,LONG * p)2712 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
2713 {
2714 HTMLElement *This = impl_from_IHTMLElement2(iface);
2715 nsresult nsres;
2716
2717 TRACE("(%p)->(%p)\n", This, p);
2718
2719 nsres = nsIDOMHTMLElement_GetScrollWidth(This->nselem, p);
2720 assert(nsres == NS_OK);
2721
2722 TRACE("*p = %d\n", *p);
2723 return S_OK;
2724 }
2725
HTMLElement2_put_scrollTop(IHTMLElement2 * iface,LONG v)2726 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
2727 {
2728 HTMLElement *This = impl_from_IHTMLElement2(iface);
2729
2730 TRACE("(%p)->(%d)\n", This, v);
2731
2732 if(!This->nselem) {
2733 FIXME("NULL nselem\n");
2734 return E_NOTIMPL;
2735 }
2736
2737 nsIDOMHTMLElement_SetScrollTop(This->nselem, v);
2738 return S_OK;
2739 }
2740
HTMLElement2_get_scrollTop(IHTMLElement2 * iface,LONG * p)2741 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
2742 {
2743 HTMLElement *This = impl_from_IHTMLElement2(iface);
2744 nsresult nsres;
2745
2746 TRACE("(%p)->(%p)\n", This, p);
2747
2748 nsres = nsIDOMHTMLElement_GetScrollTop(This->nselem, p);
2749 assert(nsres == NS_OK);
2750
2751 TRACE("*p = %d\n", *p);
2752 return S_OK;
2753 }
2754
HTMLElement2_put_scrollLeft(IHTMLElement2 * iface,LONG v)2755 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
2756 {
2757 HTMLElement *This = impl_from_IHTMLElement2(iface);
2758
2759 TRACE("(%p)->(%d)\n", This, v);
2760
2761 if(!This->nselem) {
2762 FIXME("NULL nselem\n");
2763 return E_NOTIMPL;
2764 }
2765
2766 nsIDOMHTMLElement_SetScrollLeft(This->nselem, v);
2767 return S_OK;
2768 }
2769
HTMLElement2_get_scrollLeft(IHTMLElement2 * iface,LONG * p)2770 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
2771 {
2772 HTMLElement *This = impl_from_IHTMLElement2(iface);
2773 nsresult nsres;
2774
2775 TRACE("(%p)->(%p)\n", This, p);
2776
2777 if(!p)
2778 return E_INVALIDARG;
2779
2780 if(!This->nselem)
2781 {
2782 FIXME("NULL nselem\n");
2783 return E_NOTIMPL;
2784 }
2785
2786 nsres = nsIDOMHTMLElement_GetScrollLeft(This->nselem, p);
2787 assert(nsres == NS_OK);
2788
2789 TRACE("*p = %d\n", *p);
2790 return S_OK;
2791 }
2792
HTMLElement2_clearAttributes(IHTMLElement2 * iface)2793 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
2794 {
2795 HTMLElement *This = impl_from_IHTMLElement2(iface);
2796 FIXME("(%p)\n", This);
2797 return E_NOTIMPL;
2798 }
2799
HTMLElement2_mergeAttributes(IHTMLElement2 * iface,IHTMLElement * mergeThis)2800 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
2801 {
2802 HTMLElement *This = impl_from_IHTMLElement2(iface);
2803 FIXME("(%p)->(%p)\n", This, mergeThis);
2804 return E_NOTIMPL;
2805 }
2806
HTMLElement2_put_oncontextmenu(IHTMLElement2 * iface,VARIANT v)2807 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
2808 {
2809 HTMLElement *This = impl_from_IHTMLElement2(iface);
2810 FIXME("(%p)->()\n", This);
2811 return E_NOTIMPL;
2812 }
2813
HTMLElement2_get_oncontextmenu(IHTMLElement2 * iface,VARIANT * p)2814 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
2815 {
2816 HTMLElement *This = impl_from_IHTMLElement2(iface);
2817 FIXME("(%p)->(%p)\n", This, p);
2818 return E_NOTIMPL;
2819 }
2820
HTMLElement2_insertAdjacentElement(IHTMLElement2 * iface,BSTR where,IHTMLElement * insertedElement,IHTMLElement ** inserted)2821 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
2822 IHTMLElement *insertedElement, IHTMLElement **inserted)
2823 {
2824 HTMLElement *This = impl_from_IHTMLElement2(iface);
2825 HTMLDOMNode *ret_node;
2826 HTMLElement *elem;
2827 HRESULT hres;
2828
2829 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
2830
2831 elem = unsafe_impl_from_IHTMLElement(insertedElement);
2832 if(!elem)
2833 return E_INVALIDARG;
2834
2835 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
2836 if(FAILED(hres))
2837 return hres;
2838
2839 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
2840 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
2841 return hres;
2842 }
2843
HTMLElement2_applyElement(IHTMLElement2 * iface,IHTMLElement * apply,BSTR where,IHTMLElement ** applied)2844 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
2845 BSTR where, IHTMLElement **applied)
2846 {
2847 HTMLElement *This = impl_from_IHTMLElement2(iface);
2848 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
2849 return E_NOTIMPL;
2850 }
2851
HTMLElement2_getAdjacentText(IHTMLElement2 * iface,BSTR where,BSTR * text)2852 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
2853 {
2854 HTMLElement *This = impl_from_IHTMLElement2(iface);
2855 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
2856 return E_NOTIMPL;
2857 }
2858
HTMLElement2_replaceAdjacentText(IHTMLElement2 * iface,BSTR where,BSTR newText,BSTR * oldText)2859 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
2860 BSTR newText, BSTR *oldText)
2861 {
2862 HTMLElement *This = impl_from_IHTMLElement2(iface);
2863 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
2864 return E_NOTIMPL;
2865 }
2866
HTMLElement2_get_canHandleChildren(IHTMLElement2 * iface,VARIANT_BOOL * p)2867 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
2868 {
2869 HTMLElement *This = impl_from_IHTMLElement2(iface);
2870 FIXME("(%p)->(%p)\n", This, p);
2871 return E_NOTIMPL;
2872 }
2873
HTMLElement2_addBehavior(IHTMLElement2 * iface,BSTR bstrUrl,VARIANT * pvarFactory,LONG * pCookie)2874 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
2875 VARIANT *pvarFactory, LONG *pCookie)
2876 {
2877 HTMLElement *This = impl_from_IHTMLElement2(iface);
2878 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
2879 return E_NOTIMPL;
2880 }
2881
HTMLElement2_removeBehavior(IHTMLElement2 * iface,LONG cookie,VARIANT_BOOL * pfResult)2882 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
2883 VARIANT_BOOL *pfResult)
2884 {
2885 HTMLElement *This = impl_from_IHTMLElement2(iface);
2886 FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
2887 return E_NOTIMPL;
2888 }
2889
HTMLElement2_get_runtimeStyle(IHTMLElement2 * iface,IHTMLStyle ** p)2890 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
2891 {
2892 HTMLElement *This = impl_from_IHTMLElement2(iface);
2893
2894 FIXME("(%p)->(%p): hack\n", This, p);
2895
2896 /* We can't implement correct behavior on top of Gecko (although we could
2897 try a bit harder). Making runtimeStyle behave like regular style is
2898 enough for most use cases. */
2899 if(!This->runtime_style) {
2900 HRESULT hres;
2901
2902 hres = HTMLStyle_Create(This, &This->runtime_style);
2903 if(FAILED(hres))
2904 return hres;
2905 }
2906
2907 *p = &This->runtime_style->IHTMLStyle_iface;
2908 IHTMLStyle_AddRef(*p);
2909 return S_OK;
2910 }
2911
HTMLElement2_get_behaviorUrns(IHTMLElement2 * iface,IDispatch ** p)2912 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
2913 {
2914 HTMLElement *This = impl_from_IHTMLElement2(iface);
2915 FIXME("(%p)->(%p)\n", This, p);
2916 return E_NOTIMPL;
2917 }
2918
HTMLElement2_put_tagUrn(IHTMLElement2 * iface,BSTR v)2919 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
2920 {
2921 HTMLElement *This = impl_from_IHTMLElement2(iface);
2922 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2923 return E_NOTIMPL;
2924 }
2925
HTMLElement2_get_tagUrn(IHTMLElement2 * iface,BSTR * p)2926 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
2927 {
2928 HTMLElement *This = impl_from_IHTMLElement2(iface);
2929 FIXME("(%p)->(%p)\n", This, p);
2930 return E_NOTIMPL;
2931 }
2932
HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 * iface,VARIANT vv)2933 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
2934 {
2935 HTMLElement *This = impl_from_IHTMLElement2(iface);
2936 FIXME("(%p)->()\n", This);
2937 return E_NOTIMPL;
2938 }
2939
HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 * iface,VARIANT * p)2940 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
2941 {
2942 HTMLElement *This = impl_from_IHTMLElement2(iface);
2943 FIXME("(%p)->(%p)\n", This, p);
2944 return E_NOTIMPL;
2945 }
2946
HTMLElement2_get_readyStateValue(IHTMLElement2 * iface,LONG * p)2947 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
2948 {
2949 HTMLElement *This = impl_from_IHTMLElement2(iface);
2950 FIXME("(%p)->(%p)\n", This, p);
2951 return E_NOTIMPL;
2952 }
2953
HTMLElement2_getElementsByTagName(IHTMLElement2 * iface,BSTR v,IHTMLElementCollection ** pelColl)2954 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
2955 IHTMLElementCollection **pelColl)
2956 {
2957 HTMLElement *This = impl_from_IHTMLElement2(iface);
2958 nsIDOMHTMLCollection *nscol;
2959 nsAString tag_str;
2960 nsresult nsres;
2961
2962 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2963
2964 nsAString_InitDepend(&tag_str, v);
2965 nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nscol);
2966 nsAString_Finish(&tag_str);
2967 if(NS_FAILED(nsres)) {
2968 ERR("GetElementByTagName failed: %08x\n", nsres);
2969 return E_FAIL;
2970 }
2971
2972 *pelColl = create_collection_from_htmlcol(This->node.doc, nscol);
2973 nsIDOMHTMLCollection_Release(nscol);
2974 return S_OK;
2975 }
2976
2977 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
2978 HTMLElement2_QueryInterface,
2979 HTMLElement2_AddRef,
2980 HTMLElement2_Release,
2981 HTMLElement2_GetTypeInfoCount,
2982 HTMLElement2_GetTypeInfo,
2983 HTMLElement2_GetIDsOfNames,
2984 HTMLElement2_Invoke,
2985 HTMLElement2_get_scopeName,
2986 HTMLElement2_setCapture,
2987 HTMLElement2_releaseCapture,
2988 HTMLElement2_put_onlosecapture,
2989 HTMLElement2_get_onlosecapture,
2990 HTMLElement2_componentFromPoint,
2991 HTMLElement2_doScroll,
2992 HTMLElement2_put_onscroll,
2993 HTMLElement2_get_onscroll,
2994 HTMLElement2_put_ondrag,
2995 HTMLElement2_get_ondrag,
2996 HTMLElement2_put_ondragend,
2997 HTMLElement2_get_ondragend,
2998 HTMLElement2_put_ondragenter,
2999 HTMLElement2_get_ondragenter,
3000 HTMLElement2_put_ondragover,
3001 HTMLElement2_get_ondragover,
3002 HTMLElement2_put_ondragleave,
3003 HTMLElement2_get_ondragleave,
3004 HTMLElement2_put_ondrop,
3005 HTMLElement2_get_ondrop,
3006 HTMLElement2_put_onbeforecut,
3007 HTMLElement2_get_onbeforecut,
3008 HTMLElement2_put_oncut,
3009 HTMLElement2_get_oncut,
3010 HTMLElement2_put_onbeforecopy,
3011 HTMLElement2_get_onbeforecopy,
3012 HTMLElement2_put_oncopy,
3013 HTMLElement2_get_oncopy,
3014 HTMLElement2_put_onbeforepaste,
3015 HTMLElement2_get_onbeforepaste,
3016 HTMLElement2_put_onpaste,
3017 HTMLElement2_get_onpaste,
3018 HTMLElement2_get_currentStyle,
3019 HTMLElement2_put_onpropertychange,
3020 HTMLElement2_get_onpropertychange,
3021 HTMLElement2_getClientRects,
3022 HTMLElement2_getBoundingClientRect,
3023 HTMLElement2_setExpression,
3024 HTMLElement2_getExpression,
3025 HTMLElement2_removeExpression,
3026 HTMLElement2_put_tabIndex,
3027 HTMLElement2_get_tabIndex,
3028 HTMLElement2_focus,
3029 HTMLElement2_put_accessKey,
3030 HTMLElement2_get_accessKey,
3031 HTMLElement2_put_onblur,
3032 HTMLElement2_get_onblur,
3033 HTMLElement2_put_onfocus,
3034 HTMLElement2_get_onfocus,
3035 HTMLElement2_put_onresize,
3036 HTMLElement2_get_onresize,
3037 HTMLElement2_blur,
3038 HTMLElement2_addFilter,
3039 HTMLElement2_removeFilter,
3040 HTMLElement2_get_clientHeight,
3041 HTMLElement2_get_clientWidth,
3042 HTMLElement2_get_clientTop,
3043 HTMLElement2_get_clientLeft,
3044 HTMLElement2_attachEvent,
3045 HTMLElement2_detachEvent,
3046 HTMLElement2_get_readyState,
3047 HTMLElement2_put_onreadystatechange,
3048 HTMLElement2_get_onreadystatechange,
3049 HTMLElement2_put_onrowsdelete,
3050 HTMLElement2_get_onrowsdelete,
3051 HTMLElement2_put_onrowsinserted,
3052 HTMLElement2_get_onrowsinserted,
3053 HTMLElement2_put_oncellchange,
3054 HTMLElement2_get_oncellchange,
3055 HTMLElement2_put_dir,
3056 HTMLElement2_get_dir,
3057 HTMLElement2_createControlRange,
3058 HTMLElement2_get_scrollHeight,
3059 HTMLElement2_get_scrollWidth,
3060 HTMLElement2_put_scrollTop,
3061 HTMLElement2_get_scrollTop,
3062 HTMLElement2_put_scrollLeft,
3063 HTMLElement2_get_scrollLeft,
3064 HTMLElement2_clearAttributes,
3065 HTMLElement2_mergeAttributes,
3066 HTMLElement2_put_oncontextmenu,
3067 HTMLElement2_get_oncontextmenu,
3068 HTMLElement2_insertAdjacentElement,
3069 HTMLElement2_applyElement,
3070 HTMLElement2_getAdjacentText,
3071 HTMLElement2_replaceAdjacentText,
3072 HTMLElement2_get_canHandleChildren,
3073 HTMLElement2_addBehavior,
3074 HTMLElement2_removeBehavior,
3075 HTMLElement2_get_runtimeStyle,
3076 HTMLElement2_get_behaviorUrns,
3077 HTMLElement2_put_tagUrn,
3078 HTMLElement2_get_tagUrn,
3079 HTMLElement2_put_onbeforeeditfocus,
3080 HTMLElement2_get_onbeforeeditfocus,
3081 HTMLElement2_get_readyStateValue,
3082 HTMLElement2_getElementsByTagName,
3083 };
3084
impl_from_IHTMLElement3(IHTMLElement3 * iface)3085 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3086 {
3087 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3088 }
3089
HTMLElement3_QueryInterface(IHTMLElement3 * iface,REFIID riid,void ** ppv)3090 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
3091 REFIID riid, void **ppv)
3092 {
3093 HTMLElement *This = impl_from_IHTMLElement3(iface);
3094 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3095 }
3096
HTMLElement3_AddRef(IHTMLElement3 * iface)3097 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
3098 {
3099 HTMLElement *This = impl_from_IHTMLElement3(iface);
3100 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3101 }
3102
HTMLElement3_Release(IHTMLElement3 * iface)3103 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
3104 {
3105 HTMLElement *This = impl_from_IHTMLElement3(iface);
3106 return IHTMLElement_Release(&This->IHTMLElement_iface);
3107 }
3108
HTMLElement3_GetTypeInfoCount(IHTMLElement3 * iface,UINT * pctinfo)3109 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
3110 {
3111 HTMLElement *This = impl_from_IHTMLElement3(iface);
3112 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3113 }
3114
HTMLElement3_GetTypeInfo(IHTMLElement3 * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)3115 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
3116 LCID lcid, ITypeInfo **ppTInfo)
3117 {
3118 HTMLElement *This = impl_from_IHTMLElement3(iface);
3119 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3120 }
3121
HTMLElement3_GetIDsOfNames(IHTMLElement3 * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)3122 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
3123 LPOLESTR *rgszNames, UINT cNames,
3124 LCID lcid, DISPID *rgDispId)
3125 {
3126 HTMLElement *This = impl_from_IHTMLElement3(iface);
3127 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3128 lcid, rgDispId);
3129 }
3130
HTMLElement3_Invoke(IHTMLElement3 * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)3131 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
3132 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3133 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3134 {
3135 HTMLElement *This = impl_from_IHTMLElement3(iface);
3136 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3137 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3138 }
3139
HTMLElement3_mergeAttributes(IHTMLElement3 * iface,IHTMLElement * mergeThis,VARIANT * pvarFlags)3140 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3141 {
3142 HTMLElement *This = impl_from_IHTMLElement3(iface);
3143 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3144 return E_NOTIMPL;
3145 }
3146
HTMLElement3_get_isMultiLine(IHTMLElement3 * iface,VARIANT_BOOL * p)3147 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3148 {
3149 HTMLElement *This = impl_from_IHTMLElement3(iface);
3150 FIXME("(%p)->(%p)\n", This, p);
3151 return E_NOTIMPL;
3152 }
3153
HTMLElement3_get_canHaveHTML(IHTMLElement3 * iface,VARIANT_BOOL * p)3154 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3155 {
3156 HTMLElement *This = impl_from_IHTMLElement3(iface);
3157 FIXME("(%p)->(%p)\n", This, p);
3158 return E_NOTIMPL;
3159 }
3160
HTMLElement3_put_onlayoutcomplete(IHTMLElement3 * iface,VARIANT v)3161 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3162 {
3163 HTMLElement *This = impl_from_IHTMLElement3(iface);
3164 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3165 return E_NOTIMPL;
3166 }
3167
HTMLElement3_get_onlayoutcomplete(IHTMLElement3 * iface,VARIANT * p)3168 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3169 {
3170 HTMLElement *This = impl_from_IHTMLElement3(iface);
3171 FIXME("(%p)->(%p)\n", This, p);
3172 return E_NOTIMPL;
3173 }
3174
HTMLElement3_put_onpage(IHTMLElement3 * iface,VARIANT v)3175 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3176 {
3177 HTMLElement *This = impl_from_IHTMLElement3(iface);
3178 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3179 return E_NOTIMPL;
3180 }
3181
HTMLElement3_get_onpage(IHTMLElement3 * iface,VARIANT * p)3182 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3183 {
3184 HTMLElement *This = impl_from_IHTMLElement3(iface);
3185 FIXME("(%p)->(%p)\n", This, p);
3186 return E_NOTIMPL;
3187 }
3188
HTMLElement3_put_inflateBlock(IHTMLElement3 * iface,VARIANT_BOOL v)3189 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
3190 {
3191 HTMLElement *This = impl_from_IHTMLElement3(iface);
3192 FIXME("(%p)->(%x)\n", This, v);
3193 return E_NOTIMPL;
3194 }
3195
HTMLElement3_get_inflateBlock(IHTMLElement3 * iface,VARIANT_BOOL * p)3196 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
3197 {
3198 HTMLElement *This = impl_from_IHTMLElement3(iface);
3199 FIXME("(%p)->(%p)\n", This, p);
3200 return E_NOTIMPL;
3201 }
3202
HTMLElement3_put_onbeforedeactivate(IHTMLElement3 * iface,VARIANT v)3203 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
3204 {
3205 HTMLElement *This = impl_from_IHTMLElement3(iface);
3206 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3207 return E_NOTIMPL;
3208 }
3209
HTMLElement3_get_onbeforedeactivate(IHTMLElement3 * iface,VARIANT * p)3210 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
3211 {
3212 HTMLElement *This = impl_from_IHTMLElement3(iface);
3213 FIXME("(%p)->(%p)\n", This, p);
3214 return E_NOTIMPL;
3215 }
3216
HTMLElement3_setActive(IHTMLElement3 * iface)3217 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
3218 {
3219 HTMLElement *This = impl_from_IHTMLElement3(iface);
3220 FIXME("(%p)\n", This);
3221 return E_NOTIMPL;
3222 }
3223
HTMLElement3_put_contentEditable(IHTMLElement3 * iface,BSTR v)3224 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
3225 {
3226 HTMLElement *This = impl_from_IHTMLElement3(iface);
3227 nsresult nsres;
3228 nsAString str;
3229
3230 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3231
3232 nsAString_InitDepend(&str, v);
3233 nsres = nsIDOMHTMLElement_SetContentEditable(This->nselem, &str);
3234 nsAString_Finish(&str);
3235
3236 if (NS_FAILED(nsres)){
3237 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
3238 return E_FAIL;
3239 }
3240
3241 return S_OK;
3242 }
3243
HTMLElement3_get_contentEditable(IHTMLElement3 * iface,BSTR * p)3244 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
3245 {
3246 HTMLElement *This = impl_from_IHTMLElement3(iface);
3247 nsresult nsres;
3248 nsAString str;
3249
3250 TRACE("(%p)->(%p)\n", This, p);
3251
3252 nsAString_Init(&str, NULL);
3253 nsres = nsIDOMHTMLElement_GetContentEditable(This->nselem, &str);
3254 return return_nsstr(nsres, &str, p);
3255 }
3256
HTMLElement3_get_isContentEditable(IHTMLElement3 * iface,VARIANT_BOOL * p)3257 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
3258 {
3259 HTMLElement *This = impl_from_IHTMLElement3(iface);
3260 FIXME("(%p)->(%p)\n", This, p);
3261 return E_NOTIMPL;
3262 }
3263
HTMLElement3_put_hideFocus(IHTMLElement3 * iface,VARIANT_BOOL v)3264 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
3265 {
3266 HTMLElement *This = impl_from_IHTMLElement3(iface);
3267 FIXME("(%p)->(%x)\n", This, v);
3268 return E_NOTIMPL;
3269 }
3270
HTMLElement3_get_hideFocus(IHTMLElement3 * iface,VARIANT_BOOL * p)3271 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
3272 {
3273 HTMLElement *This = impl_from_IHTMLElement3(iface);
3274 FIXME("(%p)->(%p)\n", This, p);
3275 return E_NOTIMPL;
3276 }
3277
3278 static const WCHAR disabledW[] = {'d','i','s','a','b','l','e','d',0};
3279
HTMLElement3_put_disabled(IHTMLElement3 * iface,VARIANT_BOOL v)3280 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
3281 {
3282 HTMLElement *This = impl_from_IHTMLElement3(iface);
3283 VARIANT *var;
3284 HRESULT hres;
3285
3286 TRACE("(%p)->(%x)\n", This, v);
3287
3288 if(This->node.vtbl->put_disabled)
3289 return This->node.vtbl->put_disabled(&This->node, v);
3290
3291 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, TRUE, &var);
3292 if(FAILED(hres))
3293 return hres;
3294
3295 VariantClear(var);
3296 V_VT(var) = VT_BOOL;
3297 V_BOOL(var) = v;
3298 return S_OK;
3299 }
3300
HTMLElement3_get_disabled(IHTMLElement3 * iface,VARIANT_BOOL * p)3301 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3302 {
3303 HTMLElement *This = impl_from_IHTMLElement3(iface);
3304 VARIANT *var;
3305 HRESULT hres;
3306
3307 TRACE("(%p)->(%p)\n", This, p);
3308
3309 if(This->node.vtbl->get_disabled)
3310 return This->node.vtbl->get_disabled(&This->node, p);
3311
3312 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, FALSE, &var);
3313 if(hres == DISP_E_UNKNOWNNAME) {
3314 *p = VARIANT_FALSE;
3315 return S_OK;
3316 }
3317 if(FAILED(hres))
3318 return hres;
3319
3320 if(V_VT(var) != VT_BOOL) {
3321 FIXME("value is %s\n", debugstr_variant(var));
3322 return E_NOTIMPL;
3323 }
3324
3325 *p = V_BOOL(var);
3326 return S_OK;
3327 }
3328
HTMLElement3_get_isDisabled(IHTMLElement3 * iface,VARIANT_BOOL * p)3329 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3330 {
3331 HTMLElement *This = impl_from_IHTMLElement3(iface);
3332 FIXME("(%p)->(%p)\n", This, p);
3333 return E_NOTIMPL;
3334 }
3335
HTMLElement3_put_onmove(IHTMLElement3 * iface,VARIANT v)3336 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
3337 {
3338 HTMLElement *This = impl_from_IHTMLElement3(iface);
3339 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3340 return E_NOTIMPL;
3341 }
3342
HTMLElement3_get_onmove(IHTMLElement3 * iface,VARIANT * p)3343 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
3344 {
3345 HTMLElement *This = impl_from_IHTMLElement3(iface);
3346 FIXME("(%p)->(%p)\n", This, p);
3347 return E_NOTIMPL;
3348 }
3349
HTMLElement3_put_oncontrolselect(IHTMLElement3 * iface,VARIANT v)3350 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
3351 {
3352 HTMLElement *This = impl_from_IHTMLElement3(iface);
3353 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3354 return E_NOTIMPL;
3355 }
3356
HTMLElement3_get_oncontrolselect(IHTMLElement3 * iface,VARIANT * p)3357 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
3358 {
3359 HTMLElement *This = impl_from_IHTMLElement3(iface);
3360 FIXME("(%p)->(%p)\n", This, p);
3361 return E_NOTIMPL;
3362 }
3363
HTMLElement3_fireEvent(IHTMLElement3 * iface,BSTR bstrEventName,VARIANT * pvarEventObject,VARIANT_BOOL * pfCancelled)3364 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
3365 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
3366 {
3367 HTMLElement *This = impl_from_IHTMLElement3(iface);
3368
3369 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
3370 pfCancelled);
3371
3372 return dispatch_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
3373 }
3374
HTMLElement3_put_onresizestart(IHTMLElement3 * iface,VARIANT v)3375 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
3376 {
3377 HTMLElement *This = impl_from_IHTMLElement3(iface);
3378 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3379 return E_NOTIMPL;
3380 }
3381
HTMLElement3_get_onresizestart(IHTMLElement3 * iface,VARIANT * p)3382 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
3383 {
3384 HTMLElement *This = impl_from_IHTMLElement3(iface);
3385 FIXME("(%p)->(%p)\n", This, p);
3386 return E_NOTIMPL;
3387 }
3388
HTMLElement3_put_onresizeend(IHTMLElement3 * iface,VARIANT v)3389 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
3390 {
3391 HTMLElement *This = impl_from_IHTMLElement3(iface);
3392 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3393 return E_NOTIMPL;
3394 }
3395
HTMLElement3_get_onresizeend(IHTMLElement3 * iface,VARIANT * p)3396 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
3397 {
3398 HTMLElement *This = impl_from_IHTMLElement3(iface);
3399 FIXME("(%p)->(%p)\n", This, p);
3400 return E_NOTIMPL;
3401 }
3402
HTMLElement3_put_onmovestart(IHTMLElement3 * iface,VARIANT v)3403 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
3404 {
3405 HTMLElement *This = impl_from_IHTMLElement3(iface);
3406 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3407 return E_NOTIMPL;
3408 }
3409
HTMLElement3_get_onmovestart(IHTMLElement3 * iface,VARIANT * p)3410 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
3411 {
3412 HTMLElement *This = impl_from_IHTMLElement3(iface);
3413 FIXME("(%p)->(%p)\n", This, p);
3414 return E_NOTIMPL;
3415 }
3416
HTMLElement3_put_onmoveend(IHTMLElement3 * iface,VARIANT v)3417 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
3418 {
3419 HTMLElement *This = impl_from_IHTMLElement3(iface);
3420 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3421 return E_NOTIMPL;
3422 }
3423
HTMLElement3_get_onmoveend(IHTMLElement3 * iface,VARIANT * p)3424 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
3425 {
3426 HTMLElement *This = impl_from_IHTMLElement3(iface);
3427 FIXME("(%p)->(%p)\n", This, p);
3428 return E_NOTIMPL;
3429 }
3430
HTMLElement3_put_onmousecenter(IHTMLElement3 * iface,VARIANT v)3431 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
3432 {
3433 HTMLElement *This = impl_from_IHTMLElement3(iface);
3434 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3435 return E_NOTIMPL;
3436 }
3437
HTMLElement3_get_onmousecenter(IHTMLElement3 * iface,VARIANT * p)3438 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
3439 {
3440 HTMLElement *This = impl_from_IHTMLElement3(iface);
3441 FIXME("(%p)->(%p)\n", This, p);
3442 return E_NOTIMPL;
3443 }
3444
HTMLElement3_put_onmouseleave(IHTMLElement3 * iface,VARIANT v)3445 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
3446 {
3447 HTMLElement *This = impl_from_IHTMLElement3(iface);
3448 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3449 return E_NOTIMPL;
3450 }
3451
HTMLElement3_get_onmouseleave(IHTMLElement3 * iface,VARIANT * p)3452 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
3453 {
3454 HTMLElement *This = impl_from_IHTMLElement3(iface);
3455 FIXME("(%p)->(%p)\n", This, p);
3456 return E_NOTIMPL;
3457 }
3458
HTMLElement3_put_onactivate(IHTMLElement3 * iface,VARIANT v)3459 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
3460 {
3461 HTMLElement *This = impl_from_IHTMLElement3(iface);
3462 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3463 return E_NOTIMPL;
3464 }
3465
HTMLElement3_get_onactivate(IHTMLElement3 * iface,VARIANT * p)3466 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
3467 {
3468 HTMLElement *This = impl_from_IHTMLElement3(iface);
3469 FIXME("(%p)->(%p)\n", This, p);
3470 return E_NOTIMPL;
3471 }
3472
HTMLElement3_put_ondeactivate(IHTMLElement3 * iface,VARIANT v)3473 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
3474 {
3475 HTMLElement *This = impl_from_IHTMLElement3(iface);
3476 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3477 return E_NOTIMPL;
3478 }
3479
HTMLElement3_get_ondeactivate(IHTMLElement3 * iface,VARIANT * p)3480 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
3481 {
3482 HTMLElement *This = impl_from_IHTMLElement3(iface);
3483 FIXME("(%p)->(%p)\n", This, p);
3484 return E_NOTIMPL;
3485 }
3486
HTMLElement3_dragDrop(IHTMLElement3 * iface,VARIANT_BOOL * pfRet)3487 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
3488 {
3489 HTMLElement *This = impl_from_IHTMLElement3(iface);
3490 FIXME("(%p)->(%p)\n", This, pfRet);
3491 return E_NOTIMPL;
3492 }
3493
HTMLElement3_get_glyphMode(IHTMLElement3 * iface,LONG * p)3494 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
3495 {
3496 HTMLElement *This = impl_from_IHTMLElement3(iface);
3497 FIXME("(%p)->(%p)\n", This, p);
3498 return E_NOTIMPL;
3499 }
3500
3501 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
3502 HTMLElement3_QueryInterface,
3503 HTMLElement3_AddRef,
3504 HTMLElement3_Release,
3505 HTMLElement3_GetTypeInfoCount,
3506 HTMLElement3_GetTypeInfo,
3507 HTMLElement3_GetIDsOfNames,
3508 HTMLElement3_Invoke,
3509 HTMLElement3_mergeAttributes,
3510 HTMLElement3_get_isMultiLine,
3511 HTMLElement3_get_canHaveHTML,
3512 HTMLElement3_put_onlayoutcomplete,
3513 HTMLElement3_get_onlayoutcomplete,
3514 HTMLElement3_put_onpage,
3515 HTMLElement3_get_onpage,
3516 HTMLElement3_put_inflateBlock,
3517 HTMLElement3_get_inflateBlock,
3518 HTMLElement3_put_onbeforedeactivate,
3519 HTMLElement3_get_onbeforedeactivate,
3520 HTMLElement3_setActive,
3521 HTMLElement3_put_contentEditable,
3522 HTMLElement3_get_contentEditable,
3523 HTMLElement3_get_isContentEditable,
3524 HTMLElement3_put_hideFocus,
3525 HTMLElement3_get_hideFocus,
3526 HTMLElement3_put_disabled,
3527 HTMLElement3_get_disabled,
3528 HTMLElement3_get_isDisabled,
3529 HTMLElement3_put_onmove,
3530 HTMLElement3_get_onmove,
3531 HTMLElement3_put_oncontrolselect,
3532 HTMLElement3_get_oncontrolselect,
3533 HTMLElement3_fireEvent,
3534 HTMLElement3_put_onresizestart,
3535 HTMLElement3_get_onresizestart,
3536 HTMLElement3_put_onresizeend,
3537 HTMLElement3_get_onresizeend,
3538 HTMLElement3_put_onmovestart,
3539 HTMLElement3_get_onmovestart,
3540 HTMLElement3_put_onmoveend,
3541 HTMLElement3_get_onmoveend,
3542 HTMLElement3_put_onmousecenter,
3543 HTMLElement3_get_onmousecenter,
3544 HTMLElement3_put_onmouseleave,
3545 HTMLElement3_get_onmouseleave,
3546 HTMLElement3_put_onactivate,
3547 HTMLElement3_get_onactivate,
3548 HTMLElement3_put_ondeactivate,
3549 HTMLElement3_get_ondeactivate,
3550 HTMLElement3_dragDrop,
3551 HTMLElement3_get_glyphMode
3552 };
3553
impl_from_IHTMLElement4(IHTMLElement4 * iface)3554 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
3555 {
3556 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
3557 }
3558
HTMLElement4_QueryInterface(IHTMLElement4 * iface,REFIID riid,void ** ppv)3559 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
3560 REFIID riid, void **ppv)
3561 {
3562 HTMLElement *This = impl_from_IHTMLElement4(iface);
3563 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3564 }
3565
HTMLElement4_AddRef(IHTMLElement4 * iface)3566 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
3567 {
3568 HTMLElement *This = impl_from_IHTMLElement4(iface);
3569 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3570 }
3571
HTMLElement4_Release(IHTMLElement4 * iface)3572 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
3573 {
3574 HTMLElement *This = impl_from_IHTMLElement4(iface);
3575 return IHTMLElement_Release(&This->IHTMLElement_iface);
3576 }
3577
HTMLElement4_GetTypeInfoCount(IHTMLElement4 * iface,UINT * pctinfo)3578 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
3579 {
3580 HTMLElement *This = impl_from_IHTMLElement4(iface);
3581 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3582 }
3583
HTMLElement4_GetTypeInfo(IHTMLElement4 * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)3584 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
3585 LCID lcid, ITypeInfo **ppTInfo)
3586 {
3587 HTMLElement *This = impl_from_IHTMLElement4(iface);
3588 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3589 }
3590
HTMLElement4_GetIDsOfNames(IHTMLElement4 * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)3591 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
3592 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3593 {
3594 HTMLElement *This = impl_from_IHTMLElement4(iface);
3595 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3596 lcid, rgDispId);
3597 }
3598
HTMLElement4_Invoke(IHTMLElement4 * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)3599 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
3600 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3601 {
3602 HTMLElement *This = impl_from_IHTMLElement4(iface);
3603 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3604 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3605 }
3606
HTMLElement4_put_onmousewheel(IHTMLElement4 * iface,VARIANT v)3607 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
3608 {
3609 HTMLElement *This = impl_from_IHTMLElement4(iface);
3610
3611 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3612
3613 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
3614 }
3615
HTMLElement4_get_onmousewheel(IHTMLElement4 * iface,VARIANT * p)3616 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
3617 {
3618 HTMLElement *This = impl_from_IHTMLElement4(iface);
3619
3620 TRACE("(%p)->(%p)\n", This, p);
3621
3622 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
3623 }
3624
HTMLElement4_normalize(IHTMLElement4 * iface)3625 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
3626 {
3627 HTMLElement *This = impl_from_IHTMLElement4(iface);
3628 FIXME("(%p)\n", This);
3629 return E_NOTIMPL;
3630 }
3631
HTMLElement4_getAttributeNode(IHTMLElement4 * iface,BSTR bstrname,IHTMLDOMAttribute ** ppAttribute)3632 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
3633 {
3634 HTMLElement *This = impl_from_IHTMLElement4(iface);
3635 HTMLAttributeCollection *attrs;
3636 HRESULT hres;
3637
3638 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
3639
3640 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3641 if(FAILED(hres))
3642 return hres;
3643
3644 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
3645 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3646 return hres;
3647 }
3648
HTMLElement4_setAttributeNode(IHTMLElement4 * iface,IHTMLDOMAttribute * pattr,IHTMLDOMAttribute ** ppretAttribute)3649 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3650 IHTMLDOMAttribute **ppretAttribute)
3651 {
3652 HTMLElement *This = impl_from_IHTMLElement4(iface);
3653 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3654 return E_NOTIMPL;
3655 }
3656
HTMLElement4_removeAttributeNode(IHTMLElement4 * iface,IHTMLDOMAttribute * pattr,IHTMLDOMAttribute ** ppretAttribute)3657 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3658 IHTMLDOMAttribute **ppretAttribute)
3659 {
3660 HTMLElement *This = impl_from_IHTMLElement4(iface);
3661 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3662 return E_NOTIMPL;
3663 }
3664
HTMLElement4_put_onbeforeactivate(IHTMLElement4 * iface,VARIANT v)3665 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
3666 {
3667 HTMLElement *This = impl_from_IHTMLElement4(iface);
3668 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3669 return E_NOTIMPL;
3670 }
3671
HTMLElement4_get_onbeforeactivate(IHTMLElement4 * iface,VARIANT * p)3672 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
3673 {
3674 HTMLElement *This = impl_from_IHTMLElement4(iface);
3675 FIXME("(%p)->(%p)\n", This, p);
3676 return E_NOTIMPL;
3677 }
3678
HTMLElement4_put_onfocusin(IHTMLElement4 * iface,VARIANT v)3679 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
3680 {
3681 HTMLElement *This = impl_from_IHTMLElement4(iface);
3682
3683 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3684
3685 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
3686 }
3687
HTMLElement4_get_onfocusin(IHTMLElement4 * iface,VARIANT * p)3688 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
3689 {
3690 HTMLElement *This = impl_from_IHTMLElement4(iface);
3691
3692 TRACE("(%p)->(%p)\n", This, p);
3693
3694 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
3695 }
3696
HTMLElement4_put_onfocusout(IHTMLElement4 * iface,VARIANT v)3697 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
3698 {
3699 HTMLElement *This = impl_from_IHTMLElement4(iface);
3700 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3701 return E_NOTIMPL;
3702 }
3703
HTMLElement4_get_onfocusout(IHTMLElement4 * iface,VARIANT * p)3704 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
3705 {
3706 HTMLElement *This = impl_from_IHTMLElement4(iface);
3707 FIXME("(%p)->(%p)\n", This, p);
3708 return E_NOTIMPL;
3709 }
3710
3711 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
3712 HTMLElement4_QueryInterface,
3713 HTMLElement4_AddRef,
3714 HTMLElement4_Release,
3715 HTMLElement4_GetTypeInfoCount,
3716 HTMLElement4_GetTypeInfo,
3717 HTMLElement4_GetIDsOfNames,
3718 HTMLElement4_Invoke,
3719 HTMLElement4_put_onmousewheel,
3720 HTMLElement4_get_onmousewheel,
3721 HTMLElement4_normalize,
3722 HTMLElement4_getAttributeNode,
3723 HTMLElement4_setAttributeNode,
3724 HTMLElement4_removeAttributeNode,
3725 HTMLElement4_put_onbeforeactivate,
3726 HTMLElement4_get_onbeforeactivate,
3727 HTMLElement4_put_onfocusin,
3728 HTMLElement4_get_onfocusin,
3729 HTMLElement4_put_onfocusout,
3730 HTMLElement4_get_onfocusout
3731 };
3732
impl_from_HTMLDOMNode(HTMLDOMNode * iface)3733 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
3734 {
3735 return CONTAINING_RECORD(iface, HTMLElement, node);
3736 }
3737
HTMLElement_QI(HTMLDOMNode * iface,REFIID riid,void ** ppv)3738 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
3739 {
3740 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3741
3742 if(IsEqualGUID(&IID_IUnknown, riid)) {
3743 *ppv = &This->IHTMLElement_iface;
3744 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
3745 *ppv = &This->IHTMLElement_iface;
3746 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
3747 *ppv = &This->IHTMLElement_iface;
3748 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
3749 *ppv = &This->IHTMLElement2_iface;
3750 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
3751 *ppv = &This->IHTMLElement3_iface;
3752 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
3753 *ppv = &This->IHTMLElement4_iface;
3754 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
3755 *ppv = &This->cp_container.IConnectionPointContainer_iface;
3756 }else {
3757 return HTMLDOMNode_QI(&This->node, riid, ppv);
3758 }
3759
3760 IUnknown_AddRef((IUnknown*)*ppv);
3761 return S_OK;
3762 }
3763
HTMLElement_destructor(HTMLDOMNode * iface)3764 void HTMLElement_destructor(HTMLDOMNode *iface)
3765 {
3766 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3767
3768 ConnectionPointContainer_Destroy(&This->cp_container);
3769
3770 if(This->style) {
3771 This->style->elem = NULL;
3772 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
3773 }
3774 if(This->runtime_style) {
3775 This->runtime_style->elem = NULL;
3776 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
3777 }
3778 if(This->attrs) {
3779 HTMLDOMAttribute *attr;
3780
3781 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
3782 attr->elem = NULL;
3783
3784 This->attrs->elem = NULL;
3785 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
3786 }
3787
3788 heap_free(This->filter);
3789
3790 HTMLDOMNode_destructor(&This->node);
3791 }
3792
HTMLElement_clone(HTMLDOMNode * iface,nsIDOMNode * nsnode,HTMLDOMNode ** ret)3793 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
3794 {
3795 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3796 HTMLElement *new_elem;
3797 HRESULT hres;
3798
3799 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
3800 if(FAILED(hres))
3801 return hres;
3802
3803 if(This->filter) {
3804 new_elem->filter = heap_strdupW(This->filter);
3805 if(!new_elem->filter) {
3806 IHTMLElement_Release(&This->IHTMLElement_iface);
3807 return E_OUTOFMEMORY;
3808 }
3809 }
3810
3811 *ret = &new_elem->node;
3812 return S_OK;
3813 }
3814
HTMLElement_handle_event(HTMLDOMNode * iface,DWORD eid,nsIDOMEvent * event,BOOL * prevent_default)3815 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
3816 {
3817 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3818
3819 switch(eid) {
3820 case EVENTID_KEYDOWN: {
3821 nsIDOMKeyEvent *key_event;
3822 nsresult nsres;
3823
3824 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
3825 if(NS_SUCCEEDED(nsres)) {
3826 UINT32 code = 0;
3827
3828 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
3829
3830 switch(code) {
3831 case VK_F1: /* DOM_VK_F1 */
3832 TRACE("F1 pressed\n");
3833 fire_event(This->node.doc, EVENTID_HELP, TRUE, This->node.nsnode, NULL, NULL);
3834 *prevent_default = TRUE;
3835 }
3836
3837 nsIDOMKeyEvent_Release(key_event);
3838 }
3839 }
3840 }
3841
3842 return S_OK;
3843 }
3844
3845 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
3846
3847 const cpc_entry_t HTMLElement_cpc[] = {
3848 HTMLELEMENT_CPC,
3849 {NULL}
3850 };
3851
3852 static const NodeImplVtbl HTMLElementImplVtbl = {
3853 HTMLElement_QI,
3854 HTMLElement_destructor,
3855 HTMLElement_cpc,
3856 HTMLElement_clone,
3857 HTMLElement_handle_event,
3858 HTMLElement_get_attr_col
3859 };
3860
impl_from_DispatchEx(DispatchEx * iface)3861 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
3862 {
3863 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
3864 }
3865
HTMLElement_get_dispid(DispatchEx * dispex,BSTR name,DWORD grfdex,DISPID * pid)3866 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
3867 DWORD grfdex, DISPID *pid)
3868 {
3869 HTMLElement *This = impl_from_DispatchEx(dispex);
3870
3871 if(This->node.vtbl->get_dispid)
3872 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
3873
3874 return DISP_E_UNKNOWNNAME;
3875 }
3876
HTMLElement_invoke(DispatchEx * dispex,DISPID id,LCID lcid,WORD flags,DISPPARAMS * params,VARIANT * res,EXCEPINFO * ei,IServiceProvider * caller)3877 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
3878 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
3879 IServiceProvider *caller)
3880 {
3881 HTMLElement *This = impl_from_DispatchEx(dispex);
3882
3883 if(This->node.vtbl->invoke)
3884 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
3885 params, res, ei, caller);
3886
3887 ERR("(%p): element has no invoke method\n", This);
3888 return E_NOTIMPL;
3889 }
3890
HTMLElement_populate_props(DispatchEx * dispex)3891 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
3892 {
3893 HTMLElement *This = impl_from_DispatchEx(dispex);
3894 nsIDOMMozNamedAttrMap *attrs;
3895 nsIDOMAttr *attr;
3896 nsAString nsstr;
3897 const PRUnichar *str;
3898 BSTR name;
3899 VARIANT value;
3900 unsigned i;
3901 UINT32 len;
3902 DISPID id;
3903 nsresult nsres;
3904 HRESULT hres;
3905
3906 if(!This->nselem)
3907 return S_FALSE;
3908
3909 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
3910 if(NS_FAILED(nsres))
3911 return E_FAIL;
3912
3913 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
3914 if(NS_FAILED(nsres)) {
3915 nsIDOMMozNamedAttrMap_Release(attrs);
3916 return E_FAIL;
3917 }
3918
3919 nsAString_Init(&nsstr, NULL);
3920 for(i=0; i<len; i++) {
3921 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
3922 if(NS_FAILED(nsres))
3923 continue;
3924
3925 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
3926 if(NS_FAILED(nsres)) {
3927 nsIDOMAttr_Release(attr);
3928 continue;
3929 }
3930
3931 nsAString_GetData(&nsstr, &str);
3932 name = SysAllocString(str);
3933 if(!name) {
3934 nsIDOMAttr_Release(attr);
3935 continue;
3936 }
3937
3938 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
3939 if(hres != DISP_E_UNKNOWNNAME) {
3940 nsIDOMAttr_Release(attr);
3941 SysFreeString(name);
3942 continue;
3943 }
3944
3945 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
3946 nsIDOMAttr_Release(attr);
3947 if(NS_FAILED(nsres)) {
3948 SysFreeString(name);
3949 continue;
3950 }
3951
3952 nsAString_GetData(&nsstr, &str);
3953 V_VT(&value) = VT_BSTR;
3954 if(*str) {
3955 V_BSTR(&value) = SysAllocString(str);
3956 if(!V_BSTR(&value)) {
3957 SysFreeString(name);
3958 continue;
3959 }
3960 } else
3961 V_BSTR(&value) = NULL;
3962
3963 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
3964 SysFreeString(name);
3965 VariantClear(&value);
3966 }
3967 nsAString_Finish(&nsstr);
3968
3969 nsIDOMMozNamedAttrMap_Release(attrs);
3970 return S_OK;
3971 }
3972
HTMLElement_get_event_target_ptr(DispatchEx * dispex)3973 static event_target_t **HTMLElement_get_event_target_ptr(DispatchEx *dispex)
3974 {
3975 HTMLElement *This = impl_from_DispatchEx(dispex);
3976 return This->node.vtbl->get_event_target_ptr
3977 ? This->node.vtbl->get_event_target_ptr(&This->node)
3978 : &This->node.event_target.ptr;
3979 }
3980
HTMLElement_bind_event(DispatchEx * dispex,int eid)3981 static void HTMLElement_bind_event(DispatchEx *dispex, int eid)
3982 {
3983 HTMLElement *This = impl_from_DispatchEx(dispex);
3984 This->node.doc->node.event_target.dispex.data->vtbl->bind_event(&This->node.doc->node.event_target.dispex, eid);
3985 }
3986
3987 static const tid_t HTMLElement_iface_tids[] = {
3988 HTMLELEMENT_TIDS,
3989 0
3990 };
3991
3992 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
3993 NULL,
3994 HTMLElement_get_dispid,
3995 HTMLElement_invoke,
3996 HTMLElement_populate_props,
3997 HTMLElement_get_event_target_ptr,
3998 HTMLElement_bind_event
3999 };
4000
4001 static dispex_static_data_t HTMLElement_dispex = {
4002 &HTMLElement_dispex_vtbl,
4003 DispHTMLUnknownElement_tid,
4004 NULL,
4005 HTMLElement_iface_tids
4006 };
4007
HTMLElement_Init(HTMLElement * This,HTMLDocumentNode * doc,nsIDOMHTMLElement * nselem,dispex_static_data_t * dispex_data)4008 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
4009 {
4010 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
4011 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
4012 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
4013 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
4014
4015 if(dispex_data && !dispex_data->vtbl)
4016 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
4017 init_dispex(&This->node.event_target.dispex, (IUnknown*)&This->IHTMLElement_iface,
4018 dispex_data ? dispex_data : &HTMLElement_dispex);
4019
4020 if(nselem) {
4021 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
4022
4023 /* No AddRef, share reference with HTMLDOMNode */
4024 assert((nsIDOMNode*)nselem == This->node.nsnode);
4025 This->nselem = nselem;
4026 }
4027
4028 This->node.cp_container = &This->cp_container;
4029 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
4030 }
4031
HTMLElement_Create(HTMLDocumentNode * doc,nsIDOMNode * nsnode,BOOL use_generic,HTMLElement ** ret)4032 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
4033 {
4034 nsIDOMHTMLElement *nselem;
4035 nsAString class_name_str;
4036 const PRUnichar *class_name;
4037 const tag_desc_t *tag;
4038 HTMLElement *elem;
4039 nsresult nsres;
4040 HRESULT hres;
4041
4042 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
4043 if(NS_FAILED(nsres))
4044 return E_FAIL;
4045
4046 nsAString_Init(&class_name_str, NULL);
4047 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
4048
4049 nsAString_GetData(&class_name_str, &class_name);
4050
4051 tag = get_tag_desc(class_name);
4052 if(tag) {
4053 hres = tag->constructor(doc, nselem, &elem);
4054 }else if(use_generic) {
4055 hres = HTMLGenericElement_Create(doc, nselem, &elem);
4056 }else {
4057 elem = heap_alloc_zero(sizeof(HTMLElement));
4058 if(elem) {
4059 elem->node.vtbl = &HTMLElementImplVtbl;
4060 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
4061 hres = S_OK;
4062 }else {
4063 hres = E_OUTOFMEMORY;
4064 }
4065 }
4066
4067 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
4068
4069 nsIDOMHTMLElement_Release(nselem);
4070 nsAString_Finish(&class_name_str);
4071 if(FAILED(hres))
4072 return hres;
4073
4074 *ret = elem;
4075 return S_OK;
4076 }
4077
get_elem(HTMLDocumentNode * doc,nsIDOMElement * nselem,HTMLElement ** ret)4078 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
4079 {
4080 HTMLDOMNode *node;
4081 HRESULT hres;
4082
4083 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
4084 if(FAILED(hres))
4085 return hres;
4086
4087 *ret = impl_from_HTMLDOMNode(node);
4088 return S_OK;
4089 }
4090
4091 /* interface IHTMLFiltersCollection */
HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection * iface,REFIID riid,void ** ppv)4092 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
4093 {
4094 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4095
4096 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
4097
4098 if(IsEqualGUID(&IID_IUnknown, riid)) {
4099 *ppv = &This->IHTMLFiltersCollection_iface;
4100 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
4101 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
4102 *ppv = &This->IHTMLFiltersCollection_iface;
4103 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4104 return *ppv ? S_OK : E_NOINTERFACE;
4105 }else {
4106 *ppv = NULL;
4107 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4108 return E_NOINTERFACE;
4109 }
4110
4111 IUnknown_AddRef((IUnknown*)*ppv);
4112 return S_OK;
4113 }
4114
HTMLFiltersCollection_AddRef(IHTMLFiltersCollection * iface)4115 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
4116 {
4117 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4118 LONG ref = InterlockedIncrement(&This->ref);
4119
4120 TRACE("(%p) ref=%d\n", This, ref);
4121
4122 return ref;
4123 }
4124
HTMLFiltersCollection_Release(IHTMLFiltersCollection * iface)4125 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
4126 {
4127 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4128 LONG ref = InterlockedDecrement(&This->ref);
4129
4130 TRACE("(%p) ref=%d\n", This, ref);
4131
4132 if(!ref)
4133 {
4134 heap_free(This);
4135 }
4136
4137 return ref;
4138 }
4139
HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection * iface,UINT * pctinfo)4140 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
4141 {
4142 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4143 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4144 }
4145
HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)4146 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
4147 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
4148 {
4149 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4150 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4151 }
4152
HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)4153 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
4154 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
4155 LCID lcid, DISPID *rgDispId)
4156 {
4157 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4158 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4159 lcid, rgDispId);
4160 }
4161
HTMLFiltersCollection_Invoke(IHTMLFiltersCollection * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)4162 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
4163 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
4164 EXCEPINFO *pExcepInfo, UINT *puArgErr)
4165 {
4166 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4167 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4168 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4169 }
4170
HTMLFiltersCollection_get_length(IHTMLFiltersCollection * iface,LONG * p)4171 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
4172 {
4173 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4174
4175 if(!p)
4176 return E_POINTER;
4177
4178 FIXME("(%p)->(%p) Always returning 0\n", This, p);
4179 *p = 0;
4180
4181 return S_OK;
4182 }
4183
HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection * iface,IUnknown ** p)4184 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
4185 {
4186 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4187 FIXME("(%p)->(%p)\n", This, p);
4188 return E_NOTIMPL;
4189 }
4190
HTMLFiltersCollection_item(IHTMLFiltersCollection * iface,VARIANT * pvarIndex,VARIANT * pvarResult)4191 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
4192 {
4193 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4194 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
4195 return E_NOTIMPL;
4196 }
4197
4198 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
4199 HTMLFiltersCollection_QueryInterface,
4200 HTMLFiltersCollection_AddRef,
4201 HTMLFiltersCollection_Release,
4202 HTMLFiltersCollection_GetTypeInfoCount,
4203 HTMLFiltersCollection_GetTypeInfo,
4204 HTMLFiltersCollection_GetIDsOfNames,
4205 HTMLFiltersCollection_Invoke,
4206 HTMLFiltersCollection_get_length,
4207 HTMLFiltersCollection_get__newEnum,
4208 HTMLFiltersCollection_item
4209 };
4210
HTMLFiltersCollection_get_dispid(DispatchEx * dispex,BSTR name,DWORD flags,DISPID * dispid)4211 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4212 {
4213 WCHAR *ptr;
4214 int idx = 0;
4215
4216 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
4217 idx = idx*10 + (*ptr-'0');
4218 if(*ptr)
4219 return DISP_E_UNKNOWNNAME;
4220
4221 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
4222 TRACE("ret %x\n", *dispid);
4223 return S_OK;
4224 }
4225
HTMLFiltersCollection_invoke(DispatchEx * dispex,DISPID id,LCID lcid,WORD flags,DISPPARAMS * params,VARIANT * res,EXCEPINFO * ei,IServiceProvider * caller)4226 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4227 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4228 {
4229 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
4230
4231 V_VT(res) = VT_DISPATCH;
4232 V_DISPATCH(res) = NULL;
4233
4234 FIXME("always returning NULL\n");
4235
4236 return S_OK;
4237 }
4238
4239 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
4240 NULL,
4241 HTMLFiltersCollection_get_dispid,
4242 HTMLFiltersCollection_invoke,
4243 NULL
4244 };
4245
4246 static const tid_t HTMLFiltersCollection_iface_tids[] = {
4247 IHTMLFiltersCollection_tid,
4248 0
4249 };
4250 static dispex_static_data_t HTMLFiltersCollection_dispex = {
4251 &HTMLFiltersCollection_dispex_vtbl,
4252 IHTMLFiltersCollection_tid,
4253 NULL,
4254 HTMLFiltersCollection_iface_tids
4255 };
4256
HTMLFiltersCollection_Create(void)4257 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
4258 {
4259 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
4260
4261 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
4262 ret->ref = 1;
4263
4264 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
4265 &HTMLFiltersCollection_dispex);
4266
4267 return &ret->IHTMLFiltersCollection_iface;
4268 }
4269
4270 /* interface IHTMLAttributeCollection */
impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection * iface)4271 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
4272 {
4273 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
4274 }
4275
HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection * iface,REFIID riid,void ** ppv)4276 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
4277 {
4278 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4279
4280 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4281
4282 if(IsEqualGUID(&IID_IUnknown, riid)) {
4283 *ppv = &This->IHTMLAttributeCollection_iface;
4284 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
4285 *ppv = &This->IHTMLAttributeCollection_iface;
4286 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
4287 *ppv = &This->IHTMLAttributeCollection2_iface;
4288 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
4289 *ppv = &This->IHTMLAttributeCollection3_iface;
4290 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4291 return *ppv ? S_OK : E_NOINTERFACE;
4292 }else {
4293 *ppv = NULL;
4294 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4295 return E_NOINTERFACE;
4296 }
4297
4298 IUnknown_AddRef((IUnknown*)*ppv);
4299 return S_OK;
4300 }
4301
HTMLAttributeCollection_AddRef(IHTMLAttributeCollection * iface)4302 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
4303 {
4304 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4305 LONG ref = InterlockedIncrement(&This->ref);
4306
4307 TRACE("(%p) ref=%d\n", This, ref);
4308
4309 return ref;
4310 }
4311
HTMLAttributeCollection_Release(IHTMLAttributeCollection * iface)4312 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
4313 {
4314 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4315 LONG ref = InterlockedDecrement(&This->ref);
4316
4317 TRACE("(%p) ref=%d\n", This, ref);
4318
4319 if(!ref) {
4320 while(!list_empty(&This->attrs)) {
4321 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
4322
4323 list_remove(&attr->entry);
4324 attr->elem = NULL;
4325 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4326 }
4327
4328 heap_free(This);
4329 }
4330
4331 return ref;
4332 }
4333
HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection * iface,UINT * pctinfo)4334 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
4335 {
4336 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4337 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4338 }
4339
HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)4340 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
4341 LCID lcid, ITypeInfo **ppTInfo)
4342 {
4343 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4344 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4345 }
4346
HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)4347 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
4348 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4349 {
4350 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4351 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4352 lcid, rgDispId);
4353 }
4354
HTMLAttributeCollection_Invoke(IHTMLAttributeCollection * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)4355 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
4356 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4357 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4358 {
4359 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4360 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4361 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4362 }
4363
get_attr_dispid_by_idx(HTMLAttributeCollection * This,LONG * idx,DISPID * dispid)4364 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
4365 {
4366 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
4367 DISPID id = DISPID_STARTENUM;
4368 LONG len = -1;
4369 HRESULT hres;
4370
4371 FIXME("filter non-enumerable attributes out\n");
4372
4373 while(1) {
4374 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
4375 if(FAILED(hres))
4376 return hres;
4377 else if(hres == S_FALSE)
4378 break;
4379
4380 len++;
4381 if(len == *idx)
4382 break;
4383 }
4384
4385 if(dispid) {
4386 *dispid = id;
4387 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
4388 }
4389
4390 *idx = len+1;
4391 return S_OK;
4392 }
4393
get_attr_dispid_by_name(HTMLAttributeCollection * This,BSTR name,DISPID * id)4394 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
4395 {
4396 HRESULT hres;
4397
4398 if(name[0]>='0' && name[0]<='9') {
4399 WCHAR *end_ptr;
4400 LONG idx;
4401
4402 idx = strtoulW(name, &end_ptr, 10);
4403 if(!*end_ptr) {
4404 hres = get_attr_dispid_by_idx(This, &idx, id);
4405 if(SUCCEEDED(hres))
4406 return hres;
4407 }
4408 }
4409
4410 if(!This->elem) {
4411 WARN("NULL elem\n");
4412 return E_UNEXPECTED;
4413 }
4414
4415 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
4416 name, fdexNameCaseInsensitive, id);
4417 return hres;
4418 }
4419
get_domattr(HTMLAttributeCollection * This,DISPID id,LONG * list_pos,HTMLDOMAttribute ** attr)4420 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
4421 {
4422 HTMLDOMAttribute *iter;
4423 LONG pos = 0;
4424 HRESULT hres;
4425
4426 *attr = NULL;
4427 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4428 if(iter->dispid == id) {
4429 *attr = iter;
4430 break;
4431 }
4432 pos++;
4433 }
4434
4435 if(!*attr) {
4436 if(!This->elem) {
4437 WARN("NULL elem\n");
4438 return E_UNEXPECTED;
4439 }
4440
4441 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
4442 if(FAILED(hres))
4443 return hres;
4444 }
4445
4446 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
4447 if(list_pos)
4448 *list_pos = pos;
4449 return S_OK;
4450 }
4451
HTMLAttributeCollection_get_length(IHTMLAttributeCollection * iface,LONG * p)4452 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
4453 {
4454 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4455 HRESULT hres;
4456
4457 TRACE("(%p)->(%p)\n", This, p);
4458
4459 *p = -1;
4460 hres = get_attr_dispid_by_idx(This, p, NULL);
4461 return hres;
4462 }
4463
HTMLAttributeCollection__newEnum(IHTMLAttributeCollection * iface,IUnknown ** p)4464 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
4465 {
4466 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4467 FIXME("(%p)->(%p)\n", This, p);
4468 return E_NOTIMPL;
4469 }
4470
HTMLAttributeCollection_item(IHTMLAttributeCollection * iface,VARIANT * name,IDispatch ** ppItem)4471 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
4472 {
4473 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4474 HTMLDOMAttribute *attr;
4475 DISPID id;
4476 HRESULT hres;
4477
4478 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
4479
4480 switch(V_VT(name)) {
4481 case VT_I4:
4482 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
4483 break;
4484 case VT_BSTR:
4485 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
4486 break;
4487 default:
4488 FIXME("unsupported name %s\n", debugstr_variant(name));
4489 hres = E_NOTIMPL;
4490 }
4491 if(hres == DISP_E_UNKNOWNNAME)
4492 return E_INVALIDARG;
4493 if(FAILED(hres))
4494 return hres;
4495
4496 hres = get_domattr(This, id, NULL, &attr);
4497 if(FAILED(hres))
4498 return hres;
4499
4500 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
4501 return S_OK;
4502 }
4503
4504 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
4505 HTMLAttributeCollection_QueryInterface,
4506 HTMLAttributeCollection_AddRef,
4507 HTMLAttributeCollection_Release,
4508 HTMLAttributeCollection_GetTypeInfoCount,
4509 HTMLAttributeCollection_GetTypeInfo,
4510 HTMLAttributeCollection_GetIDsOfNames,
4511 HTMLAttributeCollection_Invoke,
4512 HTMLAttributeCollection_get_length,
4513 HTMLAttributeCollection__newEnum,
4514 HTMLAttributeCollection_item
4515 };
4516
impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 * iface)4517 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
4518 {
4519 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
4520 }
4521
HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 * iface,REFIID riid,void ** ppv)4522 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
4523 {
4524 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4525 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4526 }
4527
HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 * iface)4528 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
4529 {
4530 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4531 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4532 }
4533
HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 * iface)4534 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
4535 {
4536 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4537 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4538 }
4539
HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 * iface,UINT * pctinfo)4540 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
4541 {
4542 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4543 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4544 }
4545
HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)4546 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
4547 LCID lcid, ITypeInfo **ppTInfo)
4548 {
4549 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4550 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4551 }
4552
HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)4553 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
4554 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4555 {
4556 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4557 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4558 lcid, rgDispId);
4559 }
4560
HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)4561 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
4562 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4563 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4564 {
4565 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4566 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4567 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4568 }
4569
HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 * iface,BSTR bstrName,IHTMLDOMAttribute ** newretNode)4570 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
4571 IHTMLDOMAttribute **newretNode)
4572 {
4573 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4574 HTMLDOMAttribute *attr;
4575 DISPID id;
4576 HRESULT hres;
4577
4578 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4579
4580 hres = get_attr_dispid_by_name(This, bstrName, &id);
4581 if(hres == DISP_E_UNKNOWNNAME) {
4582 *newretNode = NULL;
4583 return S_OK;
4584 } else if(FAILED(hres)) {
4585 return hres;
4586 }
4587
4588 hres = get_domattr(This, id, NULL, &attr);
4589 if(FAILED(hres))
4590 return hres;
4591
4592 *newretNode = &attr->IHTMLDOMAttribute_iface;
4593 return S_OK;
4594 }
4595
HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 * iface,IHTMLDOMAttribute * ppNode,IHTMLDOMAttribute ** newretNode)4596 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
4597 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
4598 {
4599 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4600 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
4601 return E_NOTIMPL;
4602 }
4603
HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 * iface,BSTR bstrName,IHTMLDOMAttribute ** newretNode)4604 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
4605 BSTR bstrName, IHTMLDOMAttribute **newretNode)
4606 {
4607 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4608 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4609 return E_NOTIMPL;
4610 }
4611
4612 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
4613 HTMLAttributeCollection2_QueryInterface,
4614 HTMLAttributeCollection2_AddRef,
4615 HTMLAttributeCollection2_Release,
4616 HTMLAttributeCollection2_GetTypeInfoCount,
4617 HTMLAttributeCollection2_GetTypeInfo,
4618 HTMLAttributeCollection2_GetIDsOfNames,
4619 HTMLAttributeCollection2_Invoke,
4620 HTMLAttributeCollection2_getNamedItem,
4621 HTMLAttributeCollection2_setNamedItem,
4622 HTMLAttributeCollection2_removeNamedItem
4623 };
4624
impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 * iface)4625 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
4626 {
4627 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
4628 }
4629
HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 * iface,REFIID riid,void ** ppv)4630 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
4631 {
4632 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4633 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4634 }
4635
HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 * iface)4636 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
4637 {
4638 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4639 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4640 }
4641
HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 * iface)4642 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
4643 {
4644 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4645 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4646 }
4647
HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 * iface,UINT * pctinfo)4648 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
4649 {
4650 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4651 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4652 }
4653
HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)4654 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
4655 LCID lcid, ITypeInfo **ppTInfo)
4656 {
4657 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4658 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4659 }
4660
HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)4661 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
4662 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4663 {
4664 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4665 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4666 lcid, rgDispId);
4667 }
4668
HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)4669 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
4670 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4671 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4672 {
4673 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4674 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4675 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4676 }
4677
HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 * iface,BSTR bstrName,IHTMLDOMAttribute ** ppNodeOut)4678 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
4679 IHTMLDOMAttribute **ppNodeOut)
4680 {
4681 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4682 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
4683 }
4684
HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 * iface,IHTMLDOMAttribute * pNodeIn,IHTMLDOMAttribute ** ppNodeOut)4685 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
4686 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
4687 {
4688 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4689 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
4690 return E_NOTIMPL;
4691 }
4692
HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 * iface,BSTR bstrName,IHTMLDOMAttribute ** ppNodeOut)4693 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
4694 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
4695 {
4696 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4697 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
4698 return E_NOTIMPL;
4699 }
4700
HTMLAttributeCollection3_item(IHTMLAttributeCollection3 * iface,LONG index,IHTMLDOMAttribute ** ppNodeOut)4701 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
4702 {
4703 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4704 HTMLDOMAttribute *attr;
4705 DISPID id;
4706 HRESULT hres;
4707
4708 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
4709
4710 hres = get_attr_dispid_by_idx(This, &index, &id);
4711 if(hres == DISP_E_UNKNOWNNAME)
4712 return E_INVALIDARG;
4713 if(FAILED(hres))
4714 return hres;
4715
4716 hres = get_domattr(This, id, NULL, &attr);
4717 if(FAILED(hres))
4718 return hres;
4719
4720 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
4721 return S_OK;
4722 }
4723
HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 * iface,LONG * p)4724 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
4725 {
4726 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4727 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
4728 }
4729
4730 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
4731 HTMLAttributeCollection3_QueryInterface,
4732 HTMLAttributeCollection3_AddRef,
4733 HTMLAttributeCollection3_Release,
4734 HTMLAttributeCollection3_GetTypeInfoCount,
4735 HTMLAttributeCollection3_GetTypeInfo,
4736 HTMLAttributeCollection3_GetIDsOfNames,
4737 HTMLAttributeCollection3_Invoke,
4738 HTMLAttributeCollection3_getNamedItem,
4739 HTMLAttributeCollection3_setNamedItem,
4740 HTMLAttributeCollection3_removeNamedItem,
4741 HTMLAttributeCollection3_item,
4742 HTMLAttributeCollection3_get_length
4743 };
4744
HTMLAttributeCollection_from_DispatchEx(DispatchEx * iface)4745 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
4746 {
4747 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
4748 }
4749
HTMLAttributeCollection_get_dispid(DispatchEx * dispex,BSTR name,DWORD flags,DISPID * dispid)4750 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4751 {
4752 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4753 HTMLDOMAttribute *attr;
4754 LONG pos;
4755 HRESULT hres;
4756
4757 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
4758
4759 hres = get_attr_dispid_by_name(This, name, dispid);
4760 if(FAILED(hres))
4761 return hres;
4762
4763 hres = get_domattr(This, *dispid, &pos, &attr);
4764 if(FAILED(hres))
4765 return hres;
4766 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4767
4768 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
4769 return S_OK;
4770 }
4771
HTMLAttributeCollection_invoke(DispatchEx * dispex,DISPID id,LCID lcid,WORD flags,DISPPARAMS * params,VARIANT * res,EXCEPINFO * ei,IServiceProvider * caller)4772 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
4773 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4774 {
4775 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4776
4777 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
4778
4779 switch(flags) {
4780 case DISPATCH_PROPERTYGET: {
4781 HTMLDOMAttribute *iter;
4782 DWORD pos;
4783
4784 pos = id-MSHTML_DISPID_CUSTOM_MIN;
4785
4786 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4787 if(!pos) {
4788 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
4789 V_VT(res) = VT_DISPATCH;
4790 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
4791 return S_OK;
4792 }
4793 pos--;
4794 }
4795
4796 WARN("invalid arg\n");
4797 return E_INVALIDARG;
4798 }
4799
4800 default:
4801 FIXME("unimplemented flags %x\n", flags);
4802 return E_NOTIMPL;
4803 }
4804 }
4805
4806 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
4807 NULL,
4808 HTMLAttributeCollection_get_dispid,
4809 HTMLAttributeCollection_invoke,
4810 NULL
4811 };
4812
4813 static const tid_t HTMLAttributeCollection_iface_tids[] = {
4814 IHTMLAttributeCollection_tid,
4815 IHTMLAttributeCollection2_tid,
4816 IHTMLAttributeCollection3_tid,
4817 0
4818 };
4819
4820 static dispex_static_data_t HTMLAttributeCollection_dispex = {
4821 &HTMLAttributeCollection_dispex_vtbl,
4822 DispHTMLAttributeCollection_tid,
4823 NULL,
4824 HTMLAttributeCollection_iface_tids
4825 };
4826
HTMLElement_get_attr_col(HTMLDOMNode * iface,HTMLAttributeCollection ** ac)4827 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
4828 {
4829 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4830
4831 if(This->attrs) {
4832 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
4833 *ac = This->attrs;
4834 return S_OK;
4835 }
4836
4837 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
4838 if(!This->attrs)
4839 return E_OUTOFMEMORY;
4840
4841 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
4842 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
4843 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
4844 This->attrs->ref = 2;
4845
4846 This->attrs->elem = This;
4847 list_init(&This->attrs->attrs);
4848 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
4849 &HTMLAttributeCollection_dispex);
4850
4851 *ac = This->attrs;
4852 return S_OK;
4853 }
4854