mshtml: Added script execution time 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 #include "wine/unicode.h"
31
32 #include "mshtml_private.h"
33 #include "htmlevent.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     nsIDOMNSElement *nselem;
618     nsIDOMClientRect *nsrect;
619     nsresult nsres;
620     HRESULT hres;
621
622     TRACE("(%p)->(%p)\n", This, pRect);
623
624     nsres = nsIDOMHTMLElement_QueryInterface(This->node.nsnode, &IID_nsIDOMNSElement,
625             (void**)&nselem);
626     if(NS_FAILED(nsres)) {
627         ERR("Could not get nsIDOMNSElement iface: %08x\n", nsres);
628         return E_FAIL;
629     }
630
631     nsres = nsIDOMNSElement_GetBoundingClientRect(nselem, &nsrect);
632     nsIDOMNSElement_Release(nselem);
633     if(NS_FAILED(nsres) || !nsrect) {
634         ERR("GetBoindingClientRect failed: %08x\n", nsres);
635         return E_FAIL;
636     }
637
638     hres = create_html_rect(nsrect, pRect);
639
640     nsIDOMClientRect_Release(nsrect);
641     return hres;
642 }
643
644 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
645                                                  BSTR expression, BSTR language)
646 {
647     HTMLElement *This = impl_from_IHTMLElement2(iface);
648     FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
649           debugstr_w(language));
650     return E_NOTIMPL;
651 }
652
653 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
654                                                  VARIANT *expression)
655 {
656     HTMLElement *This = impl_from_IHTMLElement2(iface);
657     FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
658     return E_NOTIMPL;
659 }
660
661 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
662                                                     VARIANT_BOOL *pfSuccess)
663 {
664     HTMLElement *This = impl_from_IHTMLElement2(iface);
665     FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
666     return E_NOTIMPL;
667 }
668
669 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
670 {
671     HTMLElement *This = impl_from_IHTMLElement2(iface);
672     nsIDOMNSHTMLElement *nselem;
673     nsresult nsres;
674
675     TRACE("(%p)->(%d)\n", This, v);
676
677     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
678     if(NS_FAILED(nsres)) {
679         ERR("Could not get nsIDOMHTMLNSElement: %08x\n", nsres);
680         return S_OK;
681     }
682
683     nsres = nsIDOMNSHTMLElement_SetTabIndex(nselem, v);
684     nsIDOMNSHTMLElement_Release(nselem);
685     if(NS_FAILED(nsres))
686         ERR("GetTabIndex failed: %08x\n", nsres);
687
688     return S_OK;
689 }
690
691 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
692 {
693     HTMLElement *This = impl_from_IHTMLElement2(iface);
694     nsIDOMNSHTMLElement *nselem;
695     PRInt32 index = 0;
696     nsresult nsres;
697
698     TRACE("(%p)->(%p)\n", This, p);
699
700     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
701     if(NS_FAILED(nsres)) {
702         ERR("Could not get nsIDOMHTMLNSElement: %08x\n", nsres);
703         return E_FAIL;
704     }
705
706     nsres = nsIDOMNSHTMLElement_GetTabIndex(nselem, &index);
707     nsIDOMNSHTMLElement_Release(nselem);
708     if(NS_FAILED(nsres)) {
709         ERR("GetTabIndex failed: %08x\n", nsres);
710         return E_FAIL;
711     }
712
713     *p = index;
714     return S_OK;
715 }
716
717 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
718 {
719     HTMLElement *This = impl_from_IHTMLElement2(iface);
720     nsIDOMNSHTMLElement *nselem;
721     nsresult nsres;
722
723     TRACE("(%p)\n", This);
724
725     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
726     if(NS_SUCCEEDED(nsres)) {
727         nsIDOMNSHTMLElement_Focus(nselem);
728         nsIDOMNSHTMLElement_Release(nselem);
729     }else {
730         ERR("Could not get nsIDOMHTMLNSElement: %08x\n", nsres);
731     }
732
733     return S_OK;
734 }
735
736 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
737 {
738     HTMLElement *This = impl_from_IHTMLElement2(iface);
739     VARIANT var;
740
741     static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
742
743     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
744
745     V_VT(&var) = VT_BSTR;
746     V_BSTR(&var) = v;
747     return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
748 }
749
750 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
751 {
752     HTMLElement *This = impl_from_IHTMLElement2(iface);
753     FIXME("(%p)->(%p)\n", This, p);
754     return E_NOTIMPL;
755 }
756
757 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
758 {
759     HTMLElement *This = impl_from_IHTMLElement2(iface);
760
761     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
762
763     return set_node_event(&This->node, EVENTID_BLUR, &v);
764 }
765
766 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
767 {
768     HTMLElement *This = impl_from_IHTMLElement2(iface);
769
770     TRACE("(%p)->(%p)\n", This, p);
771
772     return get_node_event(&This->node, EVENTID_BLUR, p);
773 }
774
775 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
776 {
777     HTMLElement *This = impl_from_IHTMLElement2(iface);
778
779     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
780
781     return set_node_event(&This->node, EVENTID_FOCUS, &v);
782 }
783
784 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
785 {
786     HTMLElement *This = impl_from_IHTMLElement2(iface);
787
788     TRACE("(%p)->(%p)\n", This, p);
789
790     return get_node_event(&This->node, EVENTID_FOCUS, p);
791 }
792
793 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
794 {
795     HTMLElement *This = impl_from_IHTMLElement2(iface);
796     FIXME("(%p)->()\n", This);
797     return E_NOTIMPL;
798 }
799
800 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
801 {
802     HTMLElement *This = impl_from_IHTMLElement2(iface);
803     FIXME("(%p)->(%p)\n", This, p);
804     return E_NOTIMPL;
805 }
806
807 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
808 {
809     HTMLElement *This = impl_from_IHTMLElement2(iface);
810     FIXME("(%p)\n", This);
811     return E_NOTIMPL;
812 }
813
814 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
815 {
816     HTMLElement *This = impl_from_IHTMLElement2(iface);
817     FIXME("(%p)->(%p)\n", This, pUnk);
818     return E_NOTIMPL;
819 }
820
821 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
822 {
823     HTMLElement *This = impl_from_IHTMLElement2(iface);
824     FIXME("(%p)->(%p)\n", This, pUnk);
825     return E_NOTIMPL;
826 }
827
828 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
829 {
830     HTMLElement *This = impl_from_IHTMLElement2(iface);
831     nsIDOMNSElement *nselem;
832     PRInt32 height=0;
833     nsresult nsres;
834
835     TRACE("(%p)->(%p)\n", This, p);
836
837     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
838     if(NS_SUCCEEDED(nsres)) {
839         nsIDOMNSElement_GetClientHeight(nselem, &height);
840         nsIDOMNSElement_Release(nselem);
841     }else {
842         ERR("Could not get nsIDOMNSElement: %08x\n", nsres);
843     }
844
845     *p = height;
846     return S_OK;
847 }
848
849 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
850 {
851     HTMLElement *This = impl_from_IHTMLElement2(iface);
852     nsIDOMNSElement *nselem;
853     PRInt32 width=0;
854     nsresult nsres;
855
856     TRACE("(%p)->(%p)\n", This, p);
857
858     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
859     if(NS_SUCCEEDED(nsres)) {
860         nsIDOMNSElement_GetClientWidth(nselem, &width);
861         nsIDOMNSElement_Release(nselem);
862     }else {
863         ERR("Could not get nsIDOMNSElement: %08x\n", nsres);
864     }
865
866     *p = width;
867     return S_OK;
868 }
869
870 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
871 {
872     HTMLElement *This = impl_from_IHTMLElement2(iface);
873     nsIDOMNSElement *nselem;
874     PRInt32 client_top = 0;
875     nsresult nsres;
876
877     TRACE("(%p)->(%p)\n", This, p);
878
879     nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
880     if(NS_SUCCEEDED(nsres)) {
881         nsres = nsIDOMNSElement_GetClientTop(nselem, &client_top);
882         nsIDOMNSElement_Release(nselem);
883         if(NS_FAILED(nsres))
884             ERR("GetScrollHeight failed: %08x\n", nsres);
885     }else {
886         ERR("Could not get nsIDOMNSElement interface: %08x\n", nsres);
887     }
888
889     *p = client_top;
890     TRACE("*p = %d\n", *p);
891     return S_OK;
892 }
893
894 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
895 {
896     HTMLElement *This = impl_from_IHTMLElement2(iface);
897     nsIDOMNSElement *nselem;
898     PRInt32 client_left = 0;
899     nsresult nsres;
900
901     TRACE("(%p)->(%p)\n", This, p);
902
903     nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
904     if(NS_SUCCEEDED(nsres)) {
905         nsres = nsIDOMNSElement_GetClientLeft(nselem, &client_left);
906         nsIDOMNSElement_Release(nselem);
907         if(NS_FAILED(nsres))
908             ERR("GetScrollHeight failed: %08x\n", nsres);
909     }else {
910         ERR("Could not get nsIDOMNSElement interface: %08x\n", nsres);
911     }
912
913     *p = client_left;
914     TRACE("*p = %d\n", *p);
915     return S_OK;
916 }
917
918 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
919                                                IDispatch *pDisp, VARIANT_BOOL *pfResult)
920 {
921     HTMLElement *This = impl_from_IHTMLElement2(iface);
922
923     TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
924
925     return attach_event(get_node_event_target(&This->node), This->node.nsnode, &This->node.doc->basedoc, event, pDisp, pfResult);
926 }
927
928 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
929 {
930     HTMLElement *This = impl_from_IHTMLElement2(iface);
931
932     TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
933
934     return detach_event(*get_node_event_target(&This->node), &This->node.doc->basedoc, event, pDisp);
935 }
936
937 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
938 {
939     HTMLElement *This = impl_from_IHTMLElement2(iface);
940     BSTR str;
941
942     TRACE("(%p)->(%p)\n", This, p);
943
944     if(This->node.vtbl->get_readystate) {
945         HRESULT hres;
946
947         hres = This->node.vtbl->get_readystate(&This->node, &str);
948         if(FAILED(hres))
949             return hres;
950     }else {
951         static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
952
953         str = SysAllocString(completeW);
954         if(!str)
955             return E_OUTOFMEMORY;
956     }
957
958     V_VT(p) = VT_BSTR;
959     V_BSTR(p) = str;
960     return S_OK;
961 }
962
963 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
964 {
965     HTMLElement *This = impl_from_IHTMLElement2(iface);
966
967     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
968
969     return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
970 }
971
972 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
973 {
974     HTMLElement *This = impl_from_IHTMLElement2(iface);
975
976     TRACE("(%p)->(%p)\n", This, p);
977
978     return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
979 }
980
981 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
982 {
983     HTMLElement *This = impl_from_IHTMLElement2(iface);
984     FIXME("(%p)->()\n", This);
985     return E_NOTIMPL;
986 }
987
988 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
989 {
990     HTMLElement *This = impl_from_IHTMLElement2(iface);
991     FIXME("(%p)->(%p)\n", This, p);
992     return E_NOTIMPL;
993 }
994
995 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
996 {
997     HTMLElement *This = impl_from_IHTMLElement2(iface);
998     FIXME("(%p)->()\n", This);
999     return E_NOTIMPL;
1000 }
1001
1002 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
1003 {
1004     HTMLElement *This = impl_from_IHTMLElement2(iface);
1005     FIXME("(%p)->(%p)\n", This, p);
1006     return E_NOTIMPL;
1007 }
1008
1009 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
1010 {
1011     HTMLElement *This = impl_from_IHTMLElement2(iface);
1012     FIXME("(%p)->()\n", This);
1013     return E_NOTIMPL;
1014 }
1015
1016 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
1017 {
1018     HTMLElement *This = impl_from_IHTMLElement2(iface);
1019     FIXME("(%p)->(%p)\n", This, p);
1020     return E_NOTIMPL;
1021 }
1022
1023 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
1024 {
1025     HTMLElement *This = impl_from_IHTMLElement2(iface);
1026     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1027     return E_NOTIMPL;
1028 }
1029
1030 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
1031 {
1032     HTMLElement *This = impl_from_IHTMLElement2(iface);
1033
1034     TRACE("(%p)->(%p)\n", This, p);
1035
1036     *p = NULL;
1037
1038     if(This->nselem) {
1039         nsAString dir_str;
1040         nsresult nsres;
1041
1042         nsAString_Init(&dir_str, NULL);
1043
1044         nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
1045         if(NS_SUCCEEDED(nsres)) {
1046             const PRUnichar *dir;
1047             nsAString_GetData(&dir_str, &dir);
1048             if(*dir)
1049                 *p = SysAllocString(dir);
1050         }else {
1051             ERR("GetDir failed: %08x\n", nsres);
1052         }
1053
1054         nsAString_Finish(&dir_str);
1055     }
1056
1057     TRACE("ret %s\n", debugstr_w(*p));
1058     return S_OK;
1059 }
1060
1061 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
1062 {
1063     HTMLElement *This = impl_from_IHTMLElement2(iface);
1064     FIXME("(%p)->(%p)\n", This, range);
1065     return E_NOTIMPL;
1066 }
1067
1068 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
1069 {
1070     HTMLElement *This = impl_from_IHTMLElement2(iface);
1071     nsIDOMNSElement *nselem;
1072     PRInt32 height = 0;
1073     nsresult nsres;
1074
1075     TRACE("(%p)->(%p)\n", This, p);
1076
1077     nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
1078     if(NS_SUCCEEDED(nsres)) {
1079         nsres = nsIDOMNSElement_GetScrollHeight(nselem, &height);
1080         nsIDOMNSElement_Release(nselem);
1081         if(NS_FAILED(nsres))
1082             ERR("GetScrollHeight failed: %08x\n", nsres);
1083     }else {
1084         ERR("Could not get nsIDOMNSElement interface: %08x\n", nsres);
1085     }
1086
1087     *p = height;
1088     TRACE("*p = %d\n", *p);
1089
1090     return S_OK;
1091 }
1092
1093 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
1094 {
1095     HTMLElement *This = impl_from_IHTMLElement2(iface);
1096     nsIDOMNSElement *nselem;
1097     PRInt32 width = 0;
1098     nsresult nsres;
1099
1100     TRACE("(%p)->(%p)\n", This, p);
1101
1102     nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
1103     if(NS_SUCCEEDED(nsres)) {
1104         nsres = nsIDOMNSElement_GetScrollWidth(nselem, &width);
1105         nsIDOMNSElement_Release(nselem);
1106         if(NS_FAILED(nsres))
1107             ERR("GetScrollWidth failed: %08x\n", nsres);
1108     }else {
1109         ERR("Could not get nsIDOMNSElement interface: %08x\n", nsres);
1110     }
1111
1112     *p = width;
1113     TRACE("*p = %d\n", *p);
1114
1115     return S_OK;
1116 }
1117
1118 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
1119 {
1120     HTMLElement *This = impl_from_IHTMLElement2(iface);
1121     nsIDOMNSElement *nselem;
1122     nsresult nsres;
1123
1124     TRACE("(%p)->(%d)\n", This, v);
1125
1126     if(!This->nselem) {
1127         FIXME("NULL nselem\n");
1128         return E_NOTIMPL;
1129     }
1130
1131     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
1132     if(NS_SUCCEEDED(nsres)) {
1133         nsIDOMNSElement_SetScrollTop(nselem, v);
1134         nsIDOMNSElement_Release(nselem);
1135     }else {
1136         ERR("Could not get nsIDOMNSElement interface: %08x\n", nsres);
1137     }
1138
1139     return S_OK;
1140 }
1141
1142 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
1143 {
1144     HTMLElement *This = impl_from_IHTMLElement2(iface);
1145     nsIDOMNSElement *nselem;
1146     PRInt32 top = 0;
1147     nsresult nsres;
1148
1149     TRACE("(%p)->(%p)\n", This, p);
1150
1151     nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
1152     if(NS_SUCCEEDED(nsres)) {
1153         nsres = nsIDOMNSElement_GetScrollTop(nselem, &top);
1154         nsIDOMNSElement_Release(nselem);
1155         if(NS_FAILED(nsres))
1156             ERR("GetScrollTop failed: %08x\n", nsres);
1157     }else {
1158         ERR("Could not get nsIDOMNSElement interface: %08x\n", nsres);
1159     }
1160
1161     *p = top;
1162     TRACE("*p = %d\n", *p);
1163
1164     return S_OK;
1165 }
1166
1167 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
1168 {
1169     HTMLElement *This = impl_from_IHTMLElement2(iface);
1170     nsIDOMNSElement *nselem;
1171     nsresult nsres;
1172
1173     TRACE("(%p)->(%d)\n", This, v);
1174
1175     if(!This->nselem) {
1176         FIXME("NULL nselem\n");
1177         return E_NOTIMPL;
1178     }
1179
1180     nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
1181     if(NS_SUCCEEDED(nsres)) {
1182         nsIDOMNSElement_SetScrollLeft(nselem, v);
1183         nsIDOMNSElement_Release(nselem);
1184     }else {
1185         ERR("Could not get nsIDOMNSElement interface: %08x\n", nsres);
1186     }
1187
1188     return S_OK;
1189 }
1190
1191 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
1192 {
1193     HTMLElement *This = impl_from_IHTMLElement2(iface);
1194     nsIDOMNSElement *nselem;
1195     PRInt32 left = 0;
1196     nsresult nsres;
1197
1198     TRACE("(%p)->(%p)\n", This, p);
1199
1200     if(!p)
1201         return E_INVALIDARG;
1202
1203     if(!This->nselem)
1204     {
1205         FIXME("NULL nselem\n");
1206         return E_NOTIMPL;
1207     }
1208
1209     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSElement, (void**)&nselem);
1210     if(NS_SUCCEEDED(nsres))
1211     {
1212         nsres = nsIDOMNSElement_GetScrollLeft(nselem, &left);
1213         nsIDOMNSElement_Release(nselem);
1214         if(NS_FAILED(nsres))
1215             left = 0;
1216     }
1217
1218     *p = left;
1219     TRACE("*p = %d\n", *p);
1220
1221     return S_OK;
1222 }
1223
1224 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
1225 {
1226     HTMLElement *This = impl_from_IHTMLElement2(iface);
1227     FIXME("(%p)\n", This);
1228     return E_NOTIMPL;
1229 }
1230
1231 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
1232 {
1233     HTMLElement *This = impl_from_IHTMLElement2(iface);
1234     FIXME("(%p)->(%p)\n", This, mergeThis);
1235     return E_NOTIMPL;
1236 }
1237
1238 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
1239 {
1240     HTMLElement *This = impl_from_IHTMLElement2(iface);
1241     FIXME("(%p)->()\n", This);
1242     return E_NOTIMPL;
1243 }
1244
1245 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
1246 {
1247     HTMLElement *This = impl_from_IHTMLElement2(iface);
1248     FIXME("(%p)->(%p)\n", This, p);
1249     return E_NOTIMPL;
1250 }
1251
1252 static HRESULT WINAPI HTMLElement2_insertAdjecentElement(IHTMLElement2 *iface, BSTR where,
1253         IHTMLElement *insertedElement, IHTMLElement **inserted)
1254 {
1255     HTMLElement *This = impl_from_IHTMLElement2(iface);
1256     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
1257     return E_NOTIMPL;
1258 }
1259
1260 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
1261                                                 BSTR where, IHTMLElement **applied)
1262 {
1263     HTMLElement *This = impl_from_IHTMLElement2(iface);
1264     FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
1265     return E_NOTIMPL;
1266 }
1267
1268 static HRESULT WINAPI HTMLElement2_getAdjecentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
1269 {
1270     HTMLElement *This = impl_from_IHTMLElement2(iface);
1271     FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
1272     return E_NOTIMPL;
1273 }
1274
1275 static HRESULT WINAPI HTMLElement2_replaceAdjecentText(IHTMLElement2 *iface, BSTR where,
1276                                                        BSTR newText, BSTR *oldText)
1277 {
1278     HTMLElement *This = impl_from_IHTMLElement2(iface);
1279     FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
1280     return E_NOTIMPL;
1281 }
1282
1283 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
1284 {
1285     HTMLElement *This = impl_from_IHTMLElement2(iface);
1286     FIXME("(%p)->(%p)\n", This, p);
1287     return E_NOTIMPL;
1288 }
1289
1290 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
1291                                                VARIANT *pvarFactory, LONG *pCookie)
1292 {
1293     HTMLElement *This = impl_from_IHTMLElement2(iface);
1294     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
1295     return E_NOTIMPL;
1296 }
1297
1298 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
1299                                                   VARIANT_BOOL *pfResult)
1300 {
1301     HTMLElement *This = impl_from_IHTMLElement2(iface);
1302     FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
1303     return E_NOTIMPL;
1304 }
1305
1306 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
1307 {
1308     HTMLElement *This = impl_from_IHTMLElement2(iface);
1309     FIXME("(%p)->(%p)\n", This, p);
1310     return E_NOTIMPL;
1311 }
1312
1313 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
1314 {
1315     HTMLElement *This = impl_from_IHTMLElement2(iface);
1316     FIXME("(%p)->(%p)\n", This, p);
1317     return E_NOTIMPL;
1318 }
1319
1320 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
1321 {
1322     HTMLElement *This = impl_from_IHTMLElement2(iface);
1323     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1324     return E_NOTIMPL;
1325 }
1326
1327 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
1328 {
1329     HTMLElement *This = impl_from_IHTMLElement2(iface);
1330     FIXME("(%p)->(%p)\n", This, p);
1331     return E_NOTIMPL;
1332 }
1333
1334 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
1335 {
1336     HTMLElement *This = impl_from_IHTMLElement2(iface);
1337     FIXME("(%p)->()\n", This);
1338     return E_NOTIMPL;
1339 }
1340
1341 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
1342 {
1343     HTMLElement *This = impl_from_IHTMLElement2(iface);
1344     FIXME("(%p)->(%p)\n", This, p);
1345     return E_NOTIMPL;
1346 }
1347
1348 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
1349 {
1350     HTMLElement *This = impl_from_IHTMLElement2(iface);
1351     FIXME("(%p)->(%p)\n", This, p);
1352     return E_NOTIMPL;
1353 }
1354
1355 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
1356                                                        IHTMLElementCollection **pelColl)
1357 {
1358     HTMLElement *This = impl_from_IHTMLElement2(iface);
1359     nsIDOMNodeList *nslist;
1360     nsAString tag_str;
1361     nsresult nsres;
1362
1363     TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
1364
1365     nsAString_InitDepend(&tag_str, v);
1366     nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nslist);
1367     nsAString_Finish(&tag_str);
1368     if(NS_FAILED(nsres)) {
1369         ERR("GetElementByTagName failed: %08x\n", nsres);
1370         return E_FAIL;
1371     }
1372
1373     *pelColl = create_collection_from_nodelist(This->node.doc,
1374             (IUnknown*)&This->IHTMLElement_iface, nslist);
1375     nsIDOMNodeList_Release(nslist);
1376     return S_OK;
1377 }
1378
1379 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
1380     HTMLElement2_QueryInterface,
1381     HTMLElement2_AddRef,
1382     HTMLElement2_Release,
1383     HTMLElement2_GetTypeInfoCount,
1384     HTMLElement2_GetTypeInfo,
1385     HTMLElement2_GetIDsOfNames,
1386     HTMLElement2_Invoke,
1387     HTMLElement2_get_scopeName,
1388     HTMLElement2_setCapture,
1389     HTMLElement2_releaseCapture,
1390     HTMLElement2_put_onlosecapture,
1391     HTMLElement2_get_onlosecapture,
1392     HTMLElement2_componentFromPoint,
1393     HTMLElement2_doScroll,
1394     HTMLElement2_put_onscroll,
1395     HTMLElement2_get_onscroll,
1396     HTMLElement2_put_ondrag,
1397     HTMLElement2_get_ondrag,
1398     HTMLElement2_put_ondragend,
1399     HTMLElement2_get_ondragend,
1400     HTMLElement2_put_ondragenter,
1401     HTMLElement2_get_ondragenter,
1402     HTMLElement2_put_ondragover,
1403     HTMLElement2_get_ondragover,
1404     HTMLElement2_put_ondragleave,
1405     HTMLElement2_get_ondragleave,
1406     HTMLElement2_put_ondrop,
1407     HTMLElement2_get_ondrop,
1408     HTMLElement2_put_onbeforecut,
1409     HTMLElement2_get_onbeforecut,
1410     HTMLElement2_put_oncut,
1411     HTMLElement2_get_oncut,
1412     HTMLElement2_put_onbeforecopy,
1413     HTMLElement2_get_onbeforecopy,
1414     HTMLElement2_put_oncopy,
1415     HTMLElement2_get_oncopy,
1416     HTMLElement2_put_onbeforepaste,
1417     HTMLElement2_get_onbeforepaste,
1418     HTMLElement2_put_onpaste,
1419     HTMLElement2_get_onpaste,
1420     HTMLElement2_get_currentStyle,
1421     HTMLElement2_put_onpropertychange,
1422     HTMLElement2_get_onpropertychange,
1423     HTMLElement2_getClientRects,
1424     HTMLElement2_getBoundingClientRect,
1425     HTMLElement2_setExpression,
1426     HTMLElement2_getExpression,
1427     HTMLElement2_removeExpression,
1428     HTMLElement2_put_tabIndex,
1429     HTMLElement2_get_tabIndex,
1430     HTMLElement2_focus,
1431     HTMLElement2_put_accessKey,
1432     HTMLElement2_get_accessKey,
1433     HTMLElement2_put_onblur,
1434     HTMLElement2_get_onblur,
1435     HTMLElement2_put_onfocus,
1436     HTMLElement2_get_onfocus,
1437     HTMLElement2_put_onresize,
1438     HTMLElement2_get_onresize,
1439     HTMLElement2_blur,
1440     HTMLElement2_addFilter,
1441     HTMLElement2_removeFilter,
1442     HTMLElement2_get_clientHeight,
1443     HTMLElement2_get_clientWidth,
1444     HTMLElement2_get_clientTop,
1445     HTMLElement2_get_clientLeft,
1446     HTMLElement2_attachEvent,
1447     HTMLElement2_detachEvent,
1448     HTMLElement2_get_readyState,
1449     HTMLElement2_put_onreadystatechange,
1450     HTMLElement2_get_onreadystatechange,
1451     HTMLElement2_put_onrowsdelete,
1452     HTMLElement2_get_onrowsdelete,
1453     HTMLElement2_put_onrowsinserted,
1454     HTMLElement2_get_onrowsinserted,
1455     HTMLElement2_put_oncellchange,
1456     HTMLElement2_get_oncellchange,
1457     HTMLElement2_put_dir,
1458     HTMLElement2_get_dir,
1459     HTMLElement2_createControlRange,
1460     HTMLElement2_get_scrollHeight,
1461     HTMLElement2_get_scrollWidth,
1462     HTMLElement2_put_scrollTop,
1463     HTMLElement2_get_scrollTop,
1464     HTMLElement2_put_scrollLeft,
1465     HTMLElement2_get_scrollLeft,
1466     HTMLElement2_clearAttributes,
1467     HTMLElement2_mergeAttributes,
1468     HTMLElement2_put_oncontextmenu,
1469     HTMLElement2_get_oncontextmenu,
1470     HTMLElement2_insertAdjecentElement,
1471     HTMLElement2_applyElement,
1472     HTMLElement2_getAdjecentText,
1473     HTMLElement2_replaceAdjecentText,
1474     HTMLElement2_get_canHandleChildren,
1475     HTMLElement2_addBehavior,
1476     HTMLElement2_removeBehavior,
1477     HTMLElement2_get_runtimeStyle,
1478     HTMLElement2_get_behaviorUrns,
1479     HTMLElement2_put_tagUrn,
1480     HTMLElement2_get_tagUrn,
1481     HTMLElement2_put_onbeforeeditfocus,
1482     HTMLElement2_get_onbeforeeditfocus,
1483     HTMLElement2_get_readyStateValue,
1484     HTMLElement2_getElementsByTagName,
1485 };
1486
1487 void HTMLElement2_Init(HTMLElement *This)
1488 {
1489     This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
1490 }