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