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