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