mshtml: Added noscript tag handling tests.
[wine] / dlls / mshtml / htmlelem2.c
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 <stdarg.h>
20 #include <math.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28
29 #include "wine/debug.h"
30
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
33 #include "htmlstyle.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 typedef struct {
38     DispatchEx dispex;
39     IHTMLRect IHTMLRect_iface;
40
41     LONG ref;
42
43     nsIDOMClientRect *nsrect;
44 } HTMLRect;
45
46 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
47 {
48     return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
49 }
50
51 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
52 {
53     HTMLRect *This = impl_from_IHTMLRect(iface);
54
55     if(IsEqualGUID(&IID_IUnknown, riid)) {
56         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
57         *ppv = &This->IHTMLRect_iface;
58     }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
59         TRACE("(%p)->(IID_IHTMLRect %p)\n", This, ppv);
60         *ppv = &This->IHTMLRect_iface;
61     }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
62         return *ppv ? S_OK : E_NOINTERFACE;
63     }else {
64         FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
65         *ppv = NULL;
66         return E_NOINTERFACE;
67     }
68
69     IUnknown_AddRef((IUnknown*)*ppv);
70     return S_OK;
71 }
72
73 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
74 {
75     HTMLRect *This = impl_from_IHTMLRect(iface);
76     LONG ref = InterlockedIncrement(&This->ref);
77
78     TRACE("(%p) ref=%d\n", This, ref);
79
80     return ref;
81 }
82
83 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
84 {
85     HTMLRect *This = impl_from_IHTMLRect(iface);
86     LONG ref = InterlockedDecrement(&This->ref);
87
88     TRACE("(%p) ref=%d\n", This, ref);
89
90     if(!ref) {
91         if(This->nsrect)
92             nsIDOMClientRect_Release(This->nsrect);
93         heap_free(This);
94     }
95
96     return ref;
97 }
98
99 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
100 {
101     HTMLRect *This = impl_from_IHTMLRect(iface);
102     FIXME("(%p)->(%p)\n", This, pctinfo);
103     return E_NOTIMPL;
104 }
105
106 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
107         LCID lcid, ITypeInfo **ppTInfo)
108 {
109     HTMLRect *This = impl_from_IHTMLRect(iface);
110
111     return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
112 }
113
114 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
115         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
116 {
117     HTMLRect *This = impl_from_IHTMLRect(iface);
118
119     return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
120             lcid, rgDispId);
121 }
122
123 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
124         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
125         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
126 {
127     HTMLRect *This = impl_from_IHTMLRect(iface);
128
129     return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
130             pDispParams, pVarResult, pExcepInfo, puArgErr);
131 }
132
133 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
134 {
135     HTMLRect *This = impl_from_IHTMLRect(iface);
136     FIXME("(%p)->(%d)\n", This, v);
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
141 {
142     HTMLRect *This = impl_from_IHTMLRect(iface);
143     float left;
144     nsresult nsres;
145
146     TRACE("(%p)->(%p)\n", This, p);
147
148     nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
149     if(NS_FAILED(nsres)) {
150         ERR("GetLeft failed: %08x\n", nsres);
151         return E_FAIL;
152     }
153
154     *p = floor(left+0.5);
155     return S_OK;
156 }
157
158 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
159 {
160     HTMLRect *This = impl_from_IHTMLRect(iface);
161     FIXME("(%p)->(%d)\n", This, v);
162     return E_NOTIMPL;
163 }
164
165 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
166 {
167     HTMLRect *This = impl_from_IHTMLRect(iface);
168     float top;
169     nsresult nsres;
170
171     TRACE("(%p)->(%p)\n", This, p);
172
173     nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
174     if(NS_FAILED(nsres)) {
175         ERR("GetTop failed: %08x\n", nsres);
176         return E_FAIL;
177     }
178
179     *p = floor(top+0.5);
180     return S_OK;
181 }
182
183 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
184 {
185     HTMLRect *This = impl_from_IHTMLRect(iface);
186     FIXME("(%p)->(%d)\n", This, v);
187     return E_NOTIMPL;
188 }
189
190 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
191 {
192     HTMLRect *This = impl_from_IHTMLRect(iface);
193     float right;
194     nsresult nsres;
195
196     TRACE("(%p)->(%p)\n", This, p);
197
198     nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
199     if(NS_FAILED(nsres)) {
200         ERR("GetRight failed: %08x\n", nsres);
201         return E_FAIL;
202     }
203
204     *p = floor(right+0.5);
205     return S_OK;
206 }
207
208 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
209 {
210     HTMLRect *This = impl_from_IHTMLRect(iface);
211     FIXME("(%p)->(%d)\n", This, v);
212     return E_NOTIMPL;
213 }
214
215 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
216 {
217     HTMLRect *This = impl_from_IHTMLRect(iface);
218     float bottom;
219     nsresult nsres;
220
221     TRACE("(%p)->(%p)\n", This, p);
222
223     nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
224     if(NS_FAILED(nsres)) {
225         ERR("GetBottom failed: %08x\n", nsres);
226         return E_FAIL;
227     }
228
229     *p = floor(bottom+0.5);
230     return S_OK;
231 }
232
233 static const IHTMLRectVtbl HTMLRectVtbl = {
234     HTMLRect_QueryInterface,
235     HTMLRect_AddRef,
236     HTMLRect_Release,
237     HTMLRect_GetTypeInfoCount,
238     HTMLRect_GetTypeInfo,
239     HTMLRect_GetIDsOfNames,
240     HTMLRect_Invoke,
241     HTMLRect_put_left,
242     HTMLRect_get_left,
243     HTMLRect_put_top,
244     HTMLRect_get_top,
245     HTMLRect_put_right,
246     HTMLRect_get_right,
247     HTMLRect_put_bottom,
248     HTMLRect_get_bottom
249 };
250
251 static const tid_t HTMLRect_iface_tids[] = {
252     IHTMLRect_tid,
253     0
254 };
255 static dispex_static_data_t HTMLRect_dispex = {
256     NULL,
257     IHTMLRect_tid,
258     NULL,
259     HTMLRect_iface_tids
260 };
261
262 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, IHTMLRect **ret)
263 {
264     HTMLRect *rect;
265
266     rect = heap_alloc_zero(sizeof(HTMLRect));
267     if(!rect)
268         return E_OUTOFMEMORY;
269
270     rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
271     rect->ref = 1;
272
273     init_dispex(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex);
274
275     nsIDOMClientRect_AddRef(nsrect);
276     rect->nsrect = nsrect;
277
278     *ret = &rect->IHTMLRect_iface;
279     return S_OK;
280 }
281
282 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
283 {
284     return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
285 }
286
287 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
288                                                   REFIID riid, void **ppv)
289 {
290     HTMLElement *This = impl_from_IHTMLElement2(iface);
291     return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
292 }
293
294 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
295 {
296     HTMLElement *This = impl_from_IHTMLElement2(iface);
297     return IHTMLElement_AddRef(&This->IHTMLElement_iface);
298 }
299
300 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
301 {
302     HTMLElement *This = impl_from_IHTMLElement2(iface);
303     return IHTMLElement_Release(&This->IHTMLElement_iface);
304 }
305
306 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
307 {
308     HTMLElement *This = impl_from_IHTMLElement2(iface);
309     return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
310 }
311
312 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
313                                                LCID lcid, ITypeInfo **ppTInfo)
314 {
315     HTMLElement *This = impl_from_IHTMLElement2(iface);
316     return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
317 }
318
319 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
320                                                 LPOLESTR *rgszNames, UINT cNames,
321                                                 LCID lcid, DISPID *rgDispId)
322 {
323     HTMLElement *This = impl_from_IHTMLElement2(iface);
324     return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
325             lcid, rgDispId);
326 }
327
328 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
329                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
330                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
331 {
332     HTMLElement *This = impl_from_IHTMLElement2(iface);
333     return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
334             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
335 }
336
337 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
338 {
339     HTMLElement *This = impl_from_IHTMLElement2(iface);
340     FIXME("(%p)->(%p)\n", This, p);
341     return E_NOTIMPL;
342 }
343
344 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
345 {
346     HTMLElement *This = impl_from_IHTMLElement2(iface);
347     FIXME("(%p)->(%x)\n", This, containerCapture);
348     return E_NOTIMPL;
349 }
350
351 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
352 {
353     HTMLElement *This = impl_from_IHTMLElement2(iface);
354     FIXME("(%p)\n", This);
355     return E_NOTIMPL;
356 }
357
358 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
359 {
360     HTMLElement *This = impl_from_IHTMLElement2(iface);
361     FIXME("(%p)->()\n", This);
362     return E_NOTIMPL;
363 }
364
365 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
366 {
367     HTMLElement *This = impl_from_IHTMLElement2(iface);
368     FIXME("(%p)->(%p)\n", This, p);
369     return E_NOTIMPL;
370 }
371
372 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
373                                                       LONG x, LONG y, BSTR *component)
374 {
375     HTMLElement *This = impl_from_IHTMLElement2(iface);
376     FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
377     return E_NOTIMPL;
378 }
379
380 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
381 {
382     HTMLElement *This = impl_from_IHTMLElement2(iface);
383
384     TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
385
386     if(!This->node.doc->content_ready
387        || !This->node.doc->basedoc.doc_obj->in_place_active)
388         return E_PENDING;
389
390     WARN("stub\n");
391     return S_OK;
392 }
393
394 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
395 {
396     HTMLElement *This = impl_from_IHTMLElement2(iface);
397     FIXME("(%p)->()\n", This);
398     return E_NOTIMPL;
399 }
400
401 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
402 {
403     HTMLElement *This = impl_from_IHTMLElement2(iface);
404     FIXME("(%p)->(%p)\n", This, p);
405     return E_NOTIMPL;
406 }
407
408 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
409 {
410     HTMLElement *This = impl_from_IHTMLElement2(iface);
411
412     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
413
414     return set_node_event(&This->node, EVENTID_DRAG, &v);
415 }
416
417 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
418 {
419     HTMLElement *This = impl_from_IHTMLElement2(iface);
420
421     TRACE("(%p)->(%p)\n", This, p);
422
423     return get_node_event(&This->node, EVENTID_DRAG, p);
424 }
425
426 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
427 {
428     HTMLElement *This = impl_from_IHTMLElement2(iface);
429     FIXME("(%p)->()\n", This);
430     return E_NOTIMPL;
431 }
432
433 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
434 {
435     HTMLElement *This = impl_from_IHTMLElement2(iface);
436     FIXME("(%p)->(%p)\n", This, p);
437     return E_NOTIMPL;
438 }
439
440 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
441 {
442     HTMLElement *This = impl_from_IHTMLElement2(iface);
443     FIXME("(%p)->()\n", This);
444     return E_NOTIMPL;
445 }
446
447 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
448 {
449     HTMLElement *This = impl_from_IHTMLElement2(iface);
450     FIXME("(%p)->(%p)\n", This, p);
451     return E_NOTIMPL;
452 }
453
454 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
455 {
456     HTMLElement *This = impl_from_IHTMLElement2(iface);
457     FIXME("(%p)->()\n", This);
458     return E_NOTIMPL;
459 }
460
461 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
462 {
463     HTMLElement *This = impl_from_IHTMLElement2(iface);
464     FIXME("(%p)->(%p)\n", This, p);
465     return E_NOTIMPL;
466 }
467
468 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
469 {
470     HTMLElement *This = impl_from_IHTMLElement2(iface);
471     FIXME("(%p)->()\n", This);
472     return E_NOTIMPL;
473 }
474
475 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
476 {
477     HTMLElement *This = impl_from_IHTMLElement2(iface);
478     FIXME("(%p)->(%p)\n", This, p);
479     return E_NOTIMPL;
480 }
481
482 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
483 {
484     HTMLElement *This = impl_from_IHTMLElement2(iface);
485     FIXME("(%p)->()\n", This);
486     return E_NOTIMPL;
487 }
488
489 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
490 {
491     HTMLElement *This = impl_from_IHTMLElement2(iface);
492     FIXME("(%p)->(%p)\n", This, p);
493     return E_NOTIMPL;
494 }
495
496 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
497 {
498     HTMLElement *This = impl_from_IHTMLElement2(iface);
499     FIXME("(%p)->()\n", This);
500     return E_NOTIMPL;
501 }
502
503 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
504 {
505     HTMLElement *This = impl_from_IHTMLElement2(iface);
506     FIXME("(%p)->(%p)\n", This, p);
507     return E_NOTIMPL;
508 }
509
510 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
511 {
512     HTMLElement *This = impl_from_IHTMLElement2(iface);
513     FIXME("(%p)->()\n", This);
514     return E_NOTIMPL;
515 }
516
517 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
518 {
519     HTMLElement *This = impl_from_IHTMLElement2(iface);
520     FIXME("(%p)->(%p)\n", This, p);
521     return E_NOTIMPL;
522 }
523
524 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
525 {
526     HTMLElement *This = impl_from_IHTMLElement2(iface);
527     FIXME("(%p)->()\n", This);
528     return E_NOTIMPL;
529 }
530
531 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
532 {
533     HTMLElement *This = impl_from_IHTMLElement2(iface);
534     FIXME("(%p)->(%p)\n", This, p);
535     return E_NOTIMPL;
536 }
537
538 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
539 {
540     HTMLElement *This = impl_from_IHTMLElement2(iface);
541     FIXME("(%p)->()\n", This);
542     return E_NOTIMPL;
543 }
544
545 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
546 {
547     HTMLElement *This = impl_from_IHTMLElement2(iface);
548     FIXME("(%p)->(%p)\n", This, p);
549     return E_NOTIMPL;
550 }
551
552 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
553 {
554     HTMLElement *This = impl_from_IHTMLElement2(iface);
555     FIXME("(%p)->()\n", This);
556     return E_NOTIMPL;
557 }
558
559 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
560 {
561     HTMLElement *This = impl_from_IHTMLElement2(iface);
562     FIXME("(%p)->(%p)\n", This, p);
563     return E_NOTIMPL;
564 }
565
566 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
567 {
568     HTMLElement *This = impl_from_IHTMLElement2(iface);
569
570     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
571
572     return set_node_event(&This->node, EVENTID_PASTE, &v);
573 }
574
575 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
576 {
577     HTMLElement *This = impl_from_IHTMLElement2(iface);
578
579     TRACE("(%p)->(%p)\n", This, p);
580
581     return get_node_event(&This->node, EVENTID_PASTE, p);
582 }
583
584 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
585 {
586     HTMLElement *This = impl_from_IHTMLElement2(iface);
587
588     TRACE("(%p)->(%p)\n", This, p);
589
590     return HTMLCurrentStyle_Create(This, p);
591 }
592
593 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
594 {
595     HTMLElement *This = impl_from_IHTMLElement2(iface);
596     FIXME("(%p)->()\n", This);
597     return E_NOTIMPL;
598 }
599
600 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
601 {
602     HTMLElement *This = impl_from_IHTMLElement2(iface);
603     FIXME("(%p)->(%p)\n", This, p);
604     return E_NOTIMPL;
605 }
606
607 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
608 {
609     HTMLElement *This = impl_from_IHTMLElement2(iface);
610     FIXME("(%p)->(%p)\n", This, pRectCol);
611     return E_NOTIMPL;
612 }
613
614 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
615 {
616     HTMLElement *This = impl_from_IHTMLElement2(iface);
617     nsIDOMClientRect *nsrect;
618     nsresult nsres;
619     HRESULT hres;
620
621     TRACE("(%p)->(%p)\n", This, pRect);
622
623     nsres = nsIDOMHTMLElement_GetBoundingClientRect(This->nselem, &nsrect);
624     if(NS_FAILED(nsres) || !nsrect) {
625         ERR("GetBoindingClientRect failed: %08x\n", nsres);
626         return E_FAIL;
627     }
628
629     hres = create_html_rect(nsrect, pRect);
630
631     nsIDOMClientRect_Release(nsrect);
632     return hres;
633 }
634
635 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
636                                                  BSTR expression, BSTR language)
637 {
638     HTMLElement *This = impl_from_IHTMLElement2(iface);
639     FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
640           debugstr_w(language));
641     return E_NOTIMPL;
642 }
643
644 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
645                                                  VARIANT *expression)
646 {
647     HTMLElement *This = impl_from_IHTMLElement2(iface);
648     FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
649     return E_NOTIMPL;
650 }
651
652 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
653                                                     VARIANT_BOOL *pfSuccess)
654 {
655     HTMLElement *This = impl_from_IHTMLElement2(iface);
656     FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
657     return E_NOTIMPL;
658 }
659
660 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
661 {
662     HTMLElement *This = impl_from_IHTMLElement2(iface);
663     nsresult nsres;
664
665     TRACE("(%p)->(%d)\n", This, v);
666
667     nsres = nsIDOMHTMLElement_SetTabIndex(This->nselem, v);
668     if(NS_FAILED(nsres))
669         ERR("GetTabIndex failed: %08x\n", nsres);
670
671     return S_OK;
672 }
673
674 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
675 {
676     HTMLElement *This = impl_from_IHTMLElement2(iface);
677     PRInt32 index = 0;
678     nsresult nsres;
679
680     TRACE("(%p)->(%p)\n", This, p);
681
682     nsres = nsIDOMHTMLElement_GetTabIndex(This->nselem, &index);
683     if(NS_FAILED(nsres)) {
684         ERR("GetTabIndex failed: %08x\n", nsres);
685         return E_FAIL;
686     }
687
688     *p = index;
689     return S_OK;
690 }
691
692 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
693 {
694     HTMLElement *This = impl_from_IHTMLElement2(iface);
695     nsresult nsres;
696
697     TRACE("(%p)\n", This);
698
699     nsres = nsIDOMHTMLElement_Focus(This->nselem);
700     if(NS_FAILED(nsres))
701         ERR("Focus failed: %08x\n", nsres);
702
703     return S_OK;
704 }
705
706 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
707 {
708     HTMLElement *This = impl_from_IHTMLElement2(iface);
709     VARIANT var;
710
711     static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
712
713     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
714
715     V_VT(&var) = VT_BSTR;
716     V_BSTR(&var) = v;
717     return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
718 }
719
720 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
721 {
722     HTMLElement *This = impl_from_IHTMLElement2(iface);
723     FIXME("(%p)->(%p)\n", This, p);
724     return E_NOTIMPL;
725 }
726
727 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
728 {
729     HTMLElement *This = impl_from_IHTMLElement2(iface);
730
731     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
732
733     return set_node_event(&This->node, EVENTID_BLUR, &v);
734 }
735
736 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
737 {
738     HTMLElement *This = impl_from_IHTMLElement2(iface);
739
740     TRACE("(%p)->(%p)\n", This, p);
741
742     return get_node_event(&This->node, EVENTID_BLUR, p);
743 }
744
745 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
746 {
747     HTMLElement *This = impl_from_IHTMLElement2(iface);
748
749     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
750
751     return set_node_event(&This->node, EVENTID_FOCUS, &v);
752 }
753
754 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
755 {
756     HTMLElement *This = impl_from_IHTMLElement2(iface);
757
758     TRACE("(%p)->(%p)\n", This, p);
759
760     return get_node_event(&This->node, EVENTID_FOCUS, p);
761 }
762
763 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
764 {
765     HTMLElement *This = impl_from_IHTMLElement2(iface);
766     FIXME("(%p)->()\n", This);
767     return E_NOTIMPL;
768 }
769
770 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
771 {
772     HTMLElement *This = impl_from_IHTMLElement2(iface);
773     FIXME("(%p)->(%p)\n", This, p);
774     return E_NOTIMPL;
775 }
776
777 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
778 {
779     HTMLElement *This = impl_from_IHTMLElement2(iface);
780     nsresult nsres;
781
782     TRACE("(%p)\n", This);
783
784     nsres = nsIDOMHTMLElement_Blur(This->nselem);
785     if(NS_FAILED(nsres)) {
786         ERR("Blur failed: %08x\n", nsres);
787         return E_FAIL;
788     }
789
790     return S_OK;
791 }
792
793 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
794 {
795     HTMLElement *This = impl_from_IHTMLElement2(iface);
796     FIXME("(%p)->(%p)\n", This, pUnk);
797     return E_NOTIMPL;
798 }
799
800 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
801 {
802     HTMLElement *This = impl_from_IHTMLElement2(iface);
803     FIXME("(%p)->(%p)\n", This, pUnk);
804     return E_NOTIMPL;
805 }
806
807 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
808 {
809     HTMLElement *This = impl_from_IHTMLElement2(iface);
810     PRInt32 height=0;
811
812     TRACE("(%p)->(%p)\n", This, p);
813
814     nsIDOMHTMLElement_GetClientHeight(This->nselem, &height);
815
816     *p = height;
817     return S_OK;
818 }
819
820 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
821 {
822     HTMLElement *This = impl_from_IHTMLElement2(iface);
823     PRInt32 width=0;
824
825     TRACE("(%p)->(%p)\n", This, p);
826
827     nsIDOMHTMLElement_GetClientWidth(This->nselem, &width);
828
829     *p = width;
830     return S_OK;
831 }
832
833 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
834 {
835     HTMLElement *This = impl_from_IHTMLElement2(iface);
836     PRInt32 client_top = 0;
837     nsresult nsres;
838
839     TRACE("(%p)->(%p)\n", This, p);
840
841     nsres = nsIDOMHTMLElement_GetClientTop(This->nselem, &client_top);
842     if(NS_FAILED(nsres))
843         ERR("GetScrollHeight failed: %08x\n", nsres);
844
845     *p = client_top;
846     TRACE("*p = %d\n", *p);
847     return S_OK;
848 }
849
850 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
851 {
852     HTMLElement *This = impl_from_IHTMLElement2(iface);
853     PRInt32 client_left = 0;
854     nsresult nsres;
855
856     TRACE("(%p)->(%p)\n", This, p);
857
858     nsres = nsIDOMHTMLElement_GetClientLeft(This->nselem, &client_left);
859     if(NS_FAILED(nsres))
860         ERR("GetScrollHeight failed: %08x\n", nsres);
861
862     *p = client_left;
863     TRACE("*p = %d\n", *p);
864     return S_OK;
865 }
866
867 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
868                                                IDispatch *pDisp, VARIANT_BOOL *pfResult)
869 {
870     HTMLElement *This = impl_from_IHTMLElement2(iface);
871
872     TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
873
874     return attach_event(get_node_event_target(&This->node), This->node.nsnode, &This->node.doc->basedoc, event, pDisp, pfResult);
875 }
876
877 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
878 {
879     HTMLElement *This = impl_from_IHTMLElement2(iface);
880
881     TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
882
883     return detach_event(*get_node_event_target(&This->node), &This->node.doc->basedoc, event, pDisp);
884 }
885
886 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
887 {
888     HTMLElement *This = impl_from_IHTMLElement2(iface);
889     BSTR str;
890
891     TRACE("(%p)->(%p)\n", This, p);
892
893     if(This->node.vtbl->get_readystate) {
894         HRESULT hres;
895
896         hres = This->node.vtbl->get_readystate(&This->node, &str);
897         if(FAILED(hres))
898             return hres;
899     }else {
900         static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
901
902         str = SysAllocString(completeW);
903         if(!str)
904             return E_OUTOFMEMORY;
905     }
906
907     V_VT(p) = VT_BSTR;
908     V_BSTR(p) = str;
909     return S_OK;
910 }
911
912 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
913 {
914     HTMLElement *This = impl_from_IHTMLElement2(iface);
915
916     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
917
918     return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
919 }
920
921 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
922 {
923     HTMLElement *This = impl_from_IHTMLElement2(iface);
924
925     TRACE("(%p)->(%p)\n", This, p);
926
927     return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
928 }
929
930 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
931 {
932     HTMLElement *This = impl_from_IHTMLElement2(iface);
933     FIXME("(%p)->()\n", This);
934     return E_NOTIMPL;
935 }
936
937 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
938 {
939     HTMLElement *This = impl_from_IHTMLElement2(iface);
940     FIXME("(%p)->(%p)\n", This, p);
941     return E_NOTIMPL;
942 }
943
944 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
945 {
946     HTMLElement *This = impl_from_IHTMLElement2(iface);
947     FIXME("(%p)->()\n", This);
948     return E_NOTIMPL;
949 }
950
951 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
952 {
953     HTMLElement *This = impl_from_IHTMLElement2(iface);
954     FIXME("(%p)->(%p)\n", This, p);
955     return E_NOTIMPL;
956 }
957
958 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
959 {
960     HTMLElement *This = impl_from_IHTMLElement2(iface);
961     FIXME("(%p)->()\n", This);
962     return E_NOTIMPL;
963 }
964
965 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
966 {
967     HTMLElement *This = impl_from_IHTMLElement2(iface);
968     FIXME("(%p)->(%p)\n", This, p);
969     return E_NOTIMPL;
970 }
971
972 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
973 {
974     HTMLElement *This = impl_from_IHTMLElement2(iface);
975     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
976     return E_NOTIMPL;
977 }
978
979 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
980 {
981     HTMLElement *This = impl_from_IHTMLElement2(iface);
982     nsAString dir_str;
983     nsresult nsres;
984
985     TRACE("(%p)->(%p)\n", This, p);
986
987     if(!This->nselem) {
988         *p = NULL;
989         return S_OK;
990     }
991
992     nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
993     return return_nsstr(nsres, &dir_str, p);
994 }
995
996 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
997 {
998     HTMLElement *This = impl_from_IHTMLElement2(iface);
999     FIXME("(%p)->(%p)\n", This, range);
1000     return E_NOTIMPL;
1001 }
1002
1003 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
1004 {
1005     HTMLElement *This = impl_from_IHTMLElement2(iface);
1006     PRInt32 height = 0;
1007     nsresult nsres;
1008
1009     TRACE("(%p)->(%p)\n", This, p);
1010
1011     nsres = nsIDOMHTMLElement_GetScrollHeight(This->nselem, &height);
1012     if(NS_FAILED(nsres))
1013         ERR("GetScrollHeight failed: %08x\n", nsres);
1014
1015     *p = height;
1016     TRACE("*p = %d\n", *p);
1017     return S_OK;
1018 }
1019
1020 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
1021 {
1022     HTMLElement *This = impl_from_IHTMLElement2(iface);
1023     PRInt32 width = 0;
1024     nsresult nsres;
1025
1026     TRACE("(%p)->(%p)\n", This, p);
1027
1028     nsres = nsIDOMHTMLElement_GetScrollWidth(This->nselem, &width);
1029     if(NS_FAILED(nsres))
1030         ERR("GetScrollWidth failed: %08x\n", nsres);
1031
1032     *p = width;
1033     TRACE("*p = %d\n", *p);
1034     return S_OK;
1035 }
1036
1037 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
1038 {
1039     HTMLElement *This = impl_from_IHTMLElement2(iface);
1040
1041     TRACE("(%p)->(%d)\n", This, v);
1042
1043     if(!This->nselem) {
1044         FIXME("NULL nselem\n");
1045         return E_NOTIMPL;
1046     }
1047
1048     nsIDOMHTMLElement_SetScrollTop(This->nselem, v);
1049     return S_OK;
1050 }
1051
1052 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
1053 {
1054     HTMLElement *This = impl_from_IHTMLElement2(iface);
1055     PRInt32 top = 0;
1056     nsresult nsres;
1057
1058     TRACE("(%p)->(%p)\n", This, p);
1059
1060     nsres = nsIDOMHTMLElement_GetScrollTop(This->nselem, &top);
1061     if(NS_FAILED(nsres))
1062         ERR("GetScrollTop failed: %08x\n", nsres);
1063
1064     *p = top;
1065     TRACE("*p = %d\n", *p);
1066     return S_OK;
1067 }
1068
1069 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
1070 {
1071     HTMLElement *This = impl_from_IHTMLElement2(iface);
1072
1073     TRACE("(%p)->(%d)\n", This, v);
1074
1075     if(!This->nselem) {
1076         FIXME("NULL nselem\n");
1077         return E_NOTIMPL;
1078     }
1079
1080     nsIDOMHTMLElement_SetScrollLeft(This->nselem, v);
1081     return S_OK;
1082 }
1083
1084 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
1085 {
1086     HTMLElement *This = impl_from_IHTMLElement2(iface);
1087     PRInt32 left = 0;
1088
1089     TRACE("(%p)->(%p)\n", This, p);
1090
1091     if(!p)
1092         return E_INVALIDARG;
1093
1094     if(!This->nselem)
1095     {
1096         FIXME("NULL nselem\n");
1097         return E_NOTIMPL;
1098     }
1099
1100     nsIDOMHTMLElement_GetScrollLeft(This->nselem, &left);
1101
1102     *p = left;
1103     TRACE("*p = %d\n", *p);
1104     return S_OK;
1105 }
1106
1107 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
1108 {
1109     HTMLElement *This = impl_from_IHTMLElement2(iface);
1110     FIXME("(%p)\n", This);
1111     return E_NOTIMPL;
1112 }
1113
1114 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
1115 {
1116     HTMLElement *This = impl_from_IHTMLElement2(iface);
1117     FIXME("(%p)->(%p)\n", This, mergeThis);
1118     return E_NOTIMPL;
1119 }
1120
1121 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
1122 {
1123     HTMLElement *This = impl_from_IHTMLElement2(iface);
1124     FIXME("(%p)->()\n", This);
1125     return E_NOTIMPL;
1126 }
1127
1128 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
1129 {
1130     HTMLElement *This = impl_from_IHTMLElement2(iface);
1131     FIXME("(%p)->(%p)\n", This, p);
1132     return E_NOTIMPL;
1133 }
1134
1135 static HRESULT WINAPI HTMLElement2_insertAdjecentElement(IHTMLElement2 *iface, BSTR where,
1136         IHTMLElement *insertedElement, IHTMLElement **inserted)
1137 {
1138     HTMLElement *This = impl_from_IHTMLElement2(iface);
1139     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
1140     return E_NOTIMPL;
1141 }
1142
1143 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
1144                                                 BSTR where, IHTMLElement **applied)
1145 {
1146     HTMLElement *This = impl_from_IHTMLElement2(iface);
1147     FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
1148     return E_NOTIMPL;
1149 }
1150
1151 static HRESULT WINAPI HTMLElement2_getAdjecentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
1152 {
1153     HTMLElement *This = impl_from_IHTMLElement2(iface);
1154     FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
1155     return E_NOTIMPL;
1156 }
1157
1158 static HRESULT WINAPI HTMLElement2_replaceAdjecentText(IHTMLElement2 *iface, BSTR where,
1159                                                        BSTR newText, BSTR *oldText)
1160 {
1161     HTMLElement *This = impl_from_IHTMLElement2(iface);
1162     FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
1163     return E_NOTIMPL;
1164 }
1165
1166 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
1167 {
1168     HTMLElement *This = impl_from_IHTMLElement2(iface);
1169     FIXME("(%p)->(%p)\n", This, p);
1170     return E_NOTIMPL;
1171 }
1172
1173 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
1174                                                VARIANT *pvarFactory, LONG *pCookie)
1175 {
1176     HTMLElement *This = impl_from_IHTMLElement2(iface);
1177     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
1178     return E_NOTIMPL;
1179 }
1180
1181 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
1182                                                   VARIANT_BOOL *pfResult)
1183 {
1184     HTMLElement *This = impl_from_IHTMLElement2(iface);
1185     FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
1186     return E_NOTIMPL;
1187 }
1188
1189 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
1190 {
1191     HTMLElement *This = impl_from_IHTMLElement2(iface);
1192
1193     FIXME("(%p)->(%p): hack\n", This, p);
1194
1195     /* We can't implement correct behavior on top of Gecko (although we could
1196        try a bit harder). Making runtimeStyle behave like regular style is
1197        enough for most use cases. */
1198     if(!This->runtime_style) {
1199         HRESULT hres;
1200
1201         hres = HTMLStyle_Create(This, &This->runtime_style);
1202         if(FAILED(hres))
1203             return hres;
1204     }
1205
1206     *p = &This->runtime_style->IHTMLStyle_iface;
1207     IHTMLStyle_AddRef(*p);
1208     return S_OK;
1209 }
1210
1211 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
1212 {
1213     HTMLElement *This = impl_from_IHTMLElement2(iface);
1214     FIXME("(%p)->(%p)\n", This, p);
1215     return E_NOTIMPL;
1216 }
1217
1218 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
1219 {
1220     HTMLElement *This = impl_from_IHTMLElement2(iface);
1221     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1222     return E_NOTIMPL;
1223 }
1224
1225 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
1226 {
1227     HTMLElement *This = impl_from_IHTMLElement2(iface);
1228     FIXME("(%p)->(%p)\n", This, p);
1229     return E_NOTIMPL;
1230 }
1231
1232 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
1233 {
1234     HTMLElement *This = impl_from_IHTMLElement2(iface);
1235     FIXME("(%p)->()\n", This);
1236     return E_NOTIMPL;
1237 }
1238
1239 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
1240 {
1241     HTMLElement *This = impl_from_IHTMLElement2(iface);
1242     FIXME("(%p)->(%p)\n", This, p);
1243     return E_NOTIMPL;
1244 }
1245
1246 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
1247 {
1248     HTMLElement *This = impl_from_IHTMLElement2(iface);
1249     FIXME("(%p)->(%p)\n", This, p);
1250     return E_NOTIMPL;
1251 }
1252
1253 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
1254                                                        IHTMLElementCollection **pelColl)
1255 {
1256     HTMLElement *This = impl_from_IHTMLElement2(iface);
1257     nsIDOMNodeList *nslist;
1258     nsAString tag_str;
1259     nsresult nsres;
1260
1261     TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
1262
1263     nsAString_InitDepend(&tag_str, v);
1264     nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nslist);
1265     nsAString_Finish(&tag_str);
1266     if(NS_FAILED(nsres)) {
1267         ERR("GetElementByTagName failed: %08x\n", nsres);
1268         return E_FAIL;
1269     }
1270
1271     *pelColl = create_collection_from_nodelist(This->node.doc, nslist);
1272     nsIDOMNodeList_Release(nslist);
1273     return S_OK;
1274 }
1275
1276 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
1277     HTMLElement2_QueryInterface,
1278     HTMLElement2_AddRef,
1279     HTMLElement2_Release,
1280     HTMLElement2_GetTypeInfoCount,
1281     HTMLElement2_GetTypeInfo,
1282     HTMLElement2_GetIDsOfNames,
1283     HTMLElement2_Invoke,
1284     HTMLElement2_get_scopeName,
1285     HTMLElement2_setCapture,
1286     HTMLElement2_releaseCapture,
1287     HTMLElement2_put_onlosecapture,
1288     HTMLElement2_get_onlosecapture,
1289     HTMLElement2_componentFromPoint,
1290     HTMLElement2_doScroll,
1291     HTMLElement2_put_onscroll,
1292     HTMLElement2_get_onscroll,
1293     HTMLElement2_put_ondrag,
1294     HTMLElement2_get_ondrag,
1295     HTMLElement2_put_ondragend,
1296     HTMLElement2_get_ondragend,
1297     HTMLElement2_put_ondragenter,
1298     HTMLElement2_get_ondragenter,
1299     HTMLElement2_put_ondragover,
1300     HTMLElement2_get_ondragover,
1301     HTMLElement2_put_ondragleave,
1302     HTMLElement2_get_ondragleave,
1303     HTMLElement2_put_ondrop,
1304     HTMLElement2_get_ondrop,
1305     HTMLElement2_put_onbeforecut,
1306     HTMLElement2_get_onbeforecut,
1307     HTMLElement2_put_oncut,
1308     HTMLElement2_get_oncut,
1309     HTMLElement2_put_onbeforecopy,
1310     HTMLElement2_get_onbeforecopy,
1311     HTMLElement2_put_oncopy,
1312     HTMLElement2_get_oncopy,
1313     HTMLElement2_put_onbeforepaste,
1314     HTMLElement2_get_onbeforepaste,
1315     HTMLElement2_put_onpaste,
1316     HTMLElement2_get_onpaste,
1317     HTMLElement2_get_currentStyle,
1318     HTMLElement2_put_onpropertychange,
1319     HTMLElement2_get_onpropertychange,
1320     HTMLElement2_getClientRects,
1321     HTMLElement2_getBoundingClientRect,
1322     HTMLElement2_setExpression,
1323     HTMLElement2_getExpression,
1324     HTMLElement2_removeExpression,
1325     HTMLElement2_put_tabIndex,
1326     HTMLElement2_get_tabIndex,
1327     HTMLElement2_focus,
1328     HTMLElement2_put_accessKey,
1329     HTMLElement2_get_accessKey,
1330     HTMLElement2_put_onblur,
1331     HTMLElement2_get_onblur,
1332     HTMLElement2_put_onfocus,
1333     HTMLElement2_get_onfocus,
1334     HTMLElement2_put_onresize,
1335     HTMLElement2_get_onresize,
1336     HTMLElement2_blur,
1337     HTMLElement2_addFilter,
1338     HTMLElement2_removeFilter,
1339     HTMLElement2_get_clientHeight,
1340     HTMLElement2_get_clientWidth,
1341     HTMLElement2_get_clientTop,
1342     HTMLElement2_get_clientLeft,
1343     HTMLElement2_attachEvent,
1344     HTMLElement2_detachEvent,
1345     HTMLElement2_get_readyState,
1346     HTMLElement2_put_onreadystatechange,
1347     HTMLElement2_get_onreadystatechange,
1348     HTMLElement2_put_onrowsdelete,
1349     HTMLElement2_get_onrowsdelete,
1350     HTMLElement2_put_onrowsinserted,
1351     HTMLElement2_get_onrowsinserted,
1352     HTMLElement2_put_oncellchange,
1353     HTMLElement2_get_oncellchange,
1354     HTMLElement2_put_dir,
1355     HTMLElement2_get_dir,
1356     HTMLElement2_createControlRange,
1357     HTMLElement2_get_scrollHeight,
1358     HTMLElement2_get_scrollWidth,
1359     HTMLElement2_put_scrollTop,
1360     HTMLElement2_get_scrollTop,
1361     HTMLElement2_put_scrollLeft,
1362     HTMLElement2_get_scrollLeft,
1363     HTMLElement2_clearAttributes,
1364     HTMLElement2_mergeAttributes,
1365     HTMLElement2_put_oncontextmenu,
1366     HTMLElement2_get_oncontextmenu,
1367     HTMLElement2_insertAdjecentElement,
1368     HTMLElement2_applyElement,
1369     HTMLElement2_getAdjecentText,
1370     HTMLElement2_replaceAdjecentText,
1371     HTMLElement2_get_canHandleChildren,
1372     HTMLElement2_addBehavior,
1373     HTMLElement2_removeBehavior,
1374     HTMLElement2_get_runtimeStyle,
1375     HTMLElement2_get_behaviorUrns,
1376     HTMLElement2_put_tagUrn,
1377     HTMLElement2_get_tagUrn,
1378     HTMLElement2_put_onbeforeeditfocus,
1379     HTMLElement2_get_onbeforeeditfocus,
1380     HTMLElement2_get_readyStateValue,
1381     HTMLElement2_getElementsByTagName,
1382 };
1383
1384 void HTMLElement2_Init(HTMLElement *This)
1385 {
1386     This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
1387 }