mshtml: Store nsIDOMCSSStyleDeclaration in HTMLCurrentStyle.
[wine] / dlls / mshtml / htmlelem2.c
1 /*
2  * Copyright 2006 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
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27
28 #include "wine/debug.h"
29 #include "wine/unicode.h"
30
31 #include "mshtml_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34
35 #define HTMLELEM2_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement2, iface)
36
37 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
38                                                   REFIID riid, void **ppv)
39 {
40     HTMLElement *This = HTMLELEM2_THIS(iface);
41     return IHTMLElement_QueryInterface(HTMLELEM(This), riid, ppv);
42 }
43
44 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
45 {
46     HTMLElement *This = HTMLELEM2_THIS(iface);
47     return IHTMLElement_AddRef(HTMLELEM(This));
48 }
49
50 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
51 {
52     HTMLElement *This = HTMLELEM2_THIS(iface);
53     return IHTMLElement_Release(HTMLELEM(This));
54 }
55
56 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
57 {
58     HTMLElement *This = HTMLELEM2_THIS(iface);
59     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->node.dispex), pctinfo);
60 }
61
62 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
63                                                LCID lcid, ITypeInfo **ppTInfo)
64 {
65     HTMLElement *This = HTMLELEM2_THIS(iface);
66     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->node.dispex), iTInfo, lcid, ppTInfo);
67 }
68
69 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
70                                                 LPOLESTR *rgszNames, UINT cNames,
71                                                 LCID lcid, DISPID *rgDispId)
72 {
73     HTMLElement *This = HTMLELEM2_THIS(iface);
74     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
75 }
76
77 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
78                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
79                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
80 {
81     HTMLElement *This = HTMLELEM2_THIS(iface);
82     return IDispatchEx_Invoke(DISPATCHEX(&This->node.dispex), dispIdMember, riid, lcid,
83             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
84 }
85
86 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
87 {
88     HTMLElement *This = HTMLELEM2_THIS(iface);
89     FIXME("(%p)->(%p)\n", This, p);
90     return E_NOTIMPL;
91 }
92
93 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
94 {
95     HTMLElement *This = HTMLELEM2_THIS(iface);
96     FIXME("(%p)->(%x)\n", This, containerCapture);
97     return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
101 {
102     HTMLElement *This = HTMLELEM2_THIS(iface);
103     FIXME("(%p)\n", This);
104     return E_NOTIMPL;
105 }
106
107 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
108 {
109     HTMLElement *This = HTMLELEM2_THIS(iface);
110     FIXME("(%p)->()\n", This);
111     return E_NOTIMPL;
112 }
113
114 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
115 {
116     HTMLElement *This = HTMLELEM2_THIS(iface);
117     FIXME("(%p)->(%p)\n", This, p);
118     return E_NOTIMPL;
119 }
120
121 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
122                                                       long x, long y, BSTR *component)
123 {
124     HTMLElement *This = HTMLELEM2_THIS(iface);
125     FIXME("(%p)->(%ld %ld %p)\n", This, x, y, component);
126     return E_NOTIMPL;
127 }
128
129 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
130 {
131     HTMLElement *This = HTMLELEM2_THIS(iface);
132     FIXME("(%p)->()\n", This);
133     return E_NOTIMPL;
134 }
135
136 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
137 {
138     HTMLElement *This = HTMLELEM2_THIS(iface);
139     FIXME("(%p)->()\n", This);
140     return E_NOTIMPL;
141 }
142
143 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
144 {
145     HTMLElement *This = HTMLELEM2_THIS(iface);
146     FIXME("(%p)->(%p)\n", This, p);
147     return E_NOTIMPL;
148 }
149
150 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
151 {
152     HTMLElement *This = HTMLELEM2_THIS(iface);
153     FIXME("(%p)->()\n", This);
154     return E_NOTIMPL;
155 }
156
157 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
158 {
159     HTMLElement *This = HTMLELEM2_THIS(iface);
160     FIXME("(%p)->(%p)\n", This, p);
161     return E_NOTIMPL;
162 }
163
164 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
165 {
166     HTMLElement *This = HTMLELEM2_THIS(iface);
167     FIXME("(%p)->()\n", This);
168     return E_NOTIMPL;
169 }
170
171 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
172 {
173     HTMLElement *This = HTMLELEM2_THIS(iface);
174     FIXME("(%p)->(%p)\n", This, p);
175     return E_NOTIMPL;
176 }
177
178 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
179 {
180     HTMLElement *This = HTMLELEM2_THIS(iface);
181     FIXME("(%p)->()\n", This);
182     return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
186 {
187     HTMLElement *This = HTMLELEM2_THIS(iface);
188     FIXME("(%p)->(%p)\n", This, p);
189     return E_NOTIMPL;
190 }
191
192 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
193 {
194     HTMLElement *This = HTMLELEM2_THIS(iface);
195     FIXME("(%p)->()\n", This);
196     return E_NOTIMPL;
197 }
198
199 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
200 {
201     HTMLElement *This = HTMLELEM2_THIS(iface);
202     FIXME("(%p)->(%p)\n", This, p);
203     return E_NOTIMPL;
204 }
205
206 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
207 {
208     HTMLElement *This = HTMLELEM2_THIS(iface);
209     FIXME("(%p)->()\n", This);
210     return E_NOTIMPL;
211 }
212
213 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
214 {
215     HTMLElement *This = HTMLELEM2_THIS(iface);
216     FIXME("(%p)->(%p)\n", This, p);
217     return E_NOTIMPL;
218 }
219
220 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
221 {
222     HTMLElement *This = HTMLELEM2_THIS(iface);
223     FIXME("(%p)->()\n", This);
224     return E_NOTIMPL;
225 }
226
227 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
228 {
229     HTMLElement *This = HTMLELEM2_THIS(iface);
230     FIXME("(%p)->(%p)\n", This, p);
231     return E_NOTIMPL;
232 }
233
234 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
235 {
236     HTMLElement *This = HTMLELEM2_THIS(iface);
237     FIXME("(%p)->()\n", This);
238     return E_NOTIMPL;
239 }
240
241 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
242 {
243     HTMLElement *This = HTMLELEM2_THIS(iface);
244     FIXME("(%p)->(%p)\n", This, p);
245     return E_NOTIMPL;
246 }
247
248 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
249 {
250     HTMLElement *This = HTMLELEM2_THIS(iface);
251     FIXME("(%p)->()\n", This);
252     return E_NOTIMPL;
253 }
254
255 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
256 {
257     HTMLElement *This = HTMLELEM2_THIS(iface);
258     FIXME("(%p)->(%p)\n", This, p);
259     return E_NOTIMPL;
260 }
261
262 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
263 {
264     HTMLElement *This = HTMLELEM2_THIS(iface);
265     FIXME("(%p)->()\n", This);
266     return E_NOTIMPL;
267 }
268
269 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
270 {
271     HTMLElement *This = HTMLELEM2_THIS(iface);
272     FIXME("(%p)->(%p)\n", This, p);
273     return E_NOTIMPL;
274 }
275
276 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
277 {
278     HTMLElement *This = HTMLELEM2_THIS(iface);
279     FIXME("(%p)->()\n", This);
280     return E_NOTIMPL;
281 }
282
283 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
284 {
285     HTMLElement *This = HTMLELEM2_THIS(iface);
286     FIXME("(%p)->(%p)\n", This, p);
287     return E_NOTIMPL;
288 }
289
290 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
291 {
292     HTMLElement *This = HTMLELEM2_THIS(iface);
293     FIXME("(%p)->()\n", This);
294     return E_NOTIMPL;
295 }
296
297 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
298 {
299     HTMLElement *This = HTMLELEM2_THIS(iface);
300     FIXME("(%p)->(%p)\n", This, p);
301     return E_NOTIMPL;
302 }
303
304 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
305 {
306     HTMLElement *This = HTMLELEM2_THIS(iface);
307     FIXME("(%p)->()\n", This);
308     return E_NOTIMPL;
309 }
310
311 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
312 {
313     HTMLElement *This = HTMLELEM2_THIS(iface);
314     FIXME("(%p)->(%p)\n", This, p);
315     return E_NOTIMPL;
316 }
317
318 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
319 {
320     HTMLElement *This = HTMLELEM2_THIS(iface);
321
322     TRACE("(%p)->(%p)\n", This, p);
323
324     return HTMLCurrentStyle_Create(This, p);
325 }
326
327 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
328 {
329     HTMLElement *This = HTMLELEM2_THIS(iface);
330     FIXME("(%p)->()\n", This);
331     return E_NOTIMPL;
332 }
333
334 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
335 {
336     HTMLElement *This = HTMLELEM2_THIS(iface);
337     FIXME("(%p)->(%p)\n", This, p);
338     return E_NOTIMPL;
339 }
340
341 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
342 {
343     HTMLElement *This = HTMLELEM2_THIS(iface);
344     FIXME("(%p)->(%p)\n", This, pRectCol);
345     return E_NOTIMPL;
346 }
347
348 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
349 {
350     HTMLElement *This = HTMLELEM2_THIS(iface);
351     FIXME("(%p)->(%p)\n", This, pRect);
352     return E_NOTIMPL;
353 }
354
355 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
356                                                  BSTR expression, BSTR language)
357 {
358     HTMLElement *This = HTMLELEM2_THIS(iface);
359     FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
360           debugstr_w(language));
361     return E_NOTIMPL;
362 }
363
364 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
365                                                  VARIANT *expression)
366 {
367     HTMLElement *This = HTMLELEM2_THIS(iface);
368     FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
369     return E_NOTIMPL;
370 }
371
372 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
373                                                     VARIANT_BOOL *pfSuccess)
374 {
375     HTMLElement *This = HTMLELEM2_THIS(iface);
376     FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
377     return E_NOTIMPL;
378 }
379
380 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
381 {
382     HTMLElement *This = HTMLELEM2_THIS(iface);
383     nsIDOMNSHTMLElement *nselem;
384     nsresult nsres;
385
386     TRACE("(%p)->(%d)\n", This, v);
387
388     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
389     if(NS_FAILED(nsres)) {
390         ERR("Could not get nsIDOMHTMLNSElement: %08x\n", nsres);
391         return S_OK;
392     }
393
394     nsres = nsIDOMNSHTMLElement_SetTabIndex(nselem, v);
395     nsIDOMNSHTMLElement_Release(nselem);
396     if(NS_FAILED(nsres))
397         ERR("GetTabIndex failed: %08x\n", nsres);
398
399     return S_OK;
400 }
401
402 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
403 {
404     HTMLElement *This = HTMLELEM2_THIS(iface);
405     nsIDOMNSHTMLElement *nselem;
406     PRInt32 index = 0;
407     nsresult nsres;
408
409     TRACE("(%p)->(%p)\n", This, p);
410
411     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
412     if(NS_FAILED(nsres)) {
413         ERR("Could not get nsIDOMHTMLNSElement: %08x\n", nsres);
414         return E_FAIL;
415     }
416
417     nsres = nsIDOMNSHTMLElement_GetTabIndex(nselem, &index);
418     nsIDOMNSHTMLElement_Release(nselem);
419     if(NS_FAILED(nsres)) {
420         ERR("GetTabIndex failed: %08x\n", nsres);
421         return E_FAIL;
422     }
423
424     *p = index;
425     return S_OK;
426 }
427
428 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
429 {
430     HTMLElement *This = HTMLELEM2_THIS(iface);
431     nsIDOMNSHTMLElement *nselem;
432     nsresult nsres;
433
434     TRACE("(%p)\n", This);
435
436     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
437     if(NS_SUCCEEDED(nsres)) {
438         nsIDOMNSHTMLElement_focus(nselem);
439         nsIDOMNSHTMLElement_Release(nselem);
440     }else {
441         ERR("Could not get nsIDOMHTMLNSElement: %08x\n", nsres);
442     }
443
444     return S_OK;
445 }
446
447 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
448 {
449     HTMLElement *This = HTMLELEM2_THIS(iface);
450     VARIANT var;
451
452     static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
453
454     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
455
456     V_VT(&var) = VT_BSTR;
457     V_BSTR(&var) = v;
458     return IHTMLElement_setAttribute(HTMLELEM(This), accessKeyW, var, 0);
459 }
460
461 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
462 {
463     HTMLElement *This = HTMLELEM2_THIS(iface);
464     FIXME("(%p)->(%p)\n", This, p);
465     return E_NOTIMPL;
466 }
467
468 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
469 {
470     HTMLElement *This = HTMLELEM2_THIS(iface);
471     FIXME("(%p)->()\n", This);
472     return E_NOTIMPL;
473 }
474
475 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
476 {
477     HTMLElement *This = HTMLELEM2_THIS(iface);
478     FIXME("(%p)->(%p)\n", This, p);
479     return E_NOTIMPL;
480 }
481
482 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
483 {
484     HTMLElement *This = HTMLELEM2_THIS(iface);
485     FIXME("(%p)->()\n", This);
486     return E_NOTIMPL;
487 }
488
489 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
490 {
491     HTMLElement *This = HTMLELEM2_THIS(iface);
492     FIXME("(%p)->(%p)\n", This, p);
493     return E_NOTIMPL;
494 }
495
496 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
497 {
498     HTMLElement *This = HTMLELEM2_THIS(iface);
499     FIXME("(%p)->()\n", This);
500     return E_NOTIMPL;
501 }
502
503 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
504 {
505     HTMLElement *This = HTMLELEM2_THIS(iface);
506     FIXME("(%p)->(%p)\n", This, p);
507     return E_NOTIMPL;
508 }
509
510 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
511 {
512     HTMLElement *This = HTMLELEM2_THIS(iface);
513     FIXME("(%p)\n", This);
514     return E_NOTIMPL;
515 }
516
517 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
518 {
519     HTMLElement *This = HTMLELEM2_THIS(iface);
520     FIXME("(%p)->(%p)\n", This, pUnk);
521     return E_NOTIMPL;
522 }
523
524 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
525 {
526     HTMLElement *This = HTMLELEM2_THIS(iface);
527     FIXME("(%p)->(%p)\n", This, pUnk);
528     return E_NOTIMPL;
529 }
530
531 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, long *p)
532 {
533     HTMLElement *This = HTMLELEM2_THIS(iface);
534     nsIDOMNSHTMLElement *nselem;
535     PRInt32 height=0;
536     nsresult nsres;
537
538     TRACE("(%p)->(%p)\n", This, p);
539
540     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
541     if(NS_SUCCEEDED(nsres)) {
542         nsIDOMNSHTMLElement_GetClientHeight(nselem, &height);
543         nsIDOMNSHTMLElement_Release(nselem);
544     }else {
545         ERR("Could not get nsIDOMHTMLNSElement: %08x\n", nsres);
546     }
547
548     *p = height;
549     return S_OK;
550 }
551
552 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, long *p)
553 {
554     HTMLElement *This = HTMLELEM2_THIS(iface);
555     nsIDOMNSHTMLElement *nselem;
556     PRInt32 width=0;
557     nsresult nsres;
558
559     TRACE("(%p)->(%p)\n", This, p);
560
561     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
562     if(NS_SUCCEEDED(nsres)) {
563         nsIDOMNSHTMLElement_GetClientWidth(nselem, &width);
564         nsIDOMNSHTMLElement_Release(nselem);
565     }else {
566         ERR("Could not get nsIDOMHTMLNSElement: %08x\n", nsres);
567     }
568
569     *p = width;
570     return S_OK;
571 }
572
573 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, long *p)
574 {
575     HTMLElement *This = HTMLELEM2_THIS(iface);
576     FIXME("(%p)->(%p)\n", This, p);
577     return E_NOTIMPL;
578 }
579
580 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, long *p)
581 {
582     HTMLElement *This = HTMLELEM2_THIS(iface);
583     FIXME("(%p)->(%p)\n", This, p);
584     return E_NOTIMPL;
585 }
586
587 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
588                                                IDispatch *pDisp, VARIANT_BOOL *pfResult)
589 {
590     HTMLElement *This = HTMLELEM2_THIS(iface);
591     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
592     return E_NOTIMPL;
593 }
594
595 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
596 {
597     HTMLElement *This = HTMLELEM2_THIS(iface);
598     FIXME("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
599     return E_NOTIMPL;
600 }
601
602 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
603 {
604     HTMLElement *This = HTMLELEM2_THIS(iface);
605     FIXME("(%p)->(%p)\n", This, p);
606     return E_NOTIMPL;
607 }
608
609 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
610 {
611     HTMLElement *This = HTMLELEM2_THIS(iface);
612     FIXME("(%p)->()\n", This);
613     return E_NOTIMPL;
614 }
615
616 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
617 {
618     HTMLElement *This = HTMLELEM2_THIS(iface);
619     FIXME("(%p)->(%p)\n", This, p);
620     return E_NOTIMPL;
621 }
622
623 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
624 {
625     HTMLElement *This = HTMLELEM2_THIS(iface);
626     FIXME("(%p)->()\n", This);
627     return E_NOTIMPL;
628 }
629
630 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
631 {
632     HTMLElement *This = HTMLELEM2_THIS(iface);
633     FIXME("(%p)->(%p)\n", This, p);
634     return E_NOTIMPL;
635 }
636
637 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
638 {
639     HTMLElement *This = HTMLELEM2_THIS(iface);
640     FIXME("(%p)->()\n", This);
641     return E_NOTIMPL;
642 }
643
644 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
645 {
646     HTMLElement *This = HTMLELEM2_THIS(iface);
647     FIXME("(%p)->(%p)\n", This, p);
648     return E_NOTIMPL;
649 }
650
651 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
652 {
653     HTMLElement *This = HTMLELEM2_THIS(iface);
654     FIXME("(%p)->()\n", This);
655     return E_NOTIMPL;
656 }
657
658 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
659 {
660     HTMLElement *This = HTMLELEM2_THIS(iface);
661     FIXME("(%p)->(%p)\n", This, p);
662     return E_NOTIMPL;
663 }
664
665 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
666 {
667     HTMLElement *This = HTMLELEM2_THIS(iface);
668     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
669     return E_NOTIMPL;
670 }
671
672 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
673 {
674     HTMLElement *This = HTMLELEM2_THIS(iface);
675
676     TRACE("(%p)->(%p)\n", This, p);
677
678     *p = NULL;
679
680     if(This->nselem) {
681         nsAString dir_str;
682         nsresult nsres;
683
684         nsAString_Init(&dir_str, NULL);
685
686         nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
687         if(NS_SUCCEEDED(nsres)) {
688             const PRUnichar *dir;
689             nsAString_GetData(&dir_str, &dir);
690             if(*dir)
691                 *p = SysAllocString(dir);
692         }else {
693             ERR("GetDir failed: %08x\n", nsres);
694         }
695
696         nsAString_Finish(&dir_str);
697     }
698
699     TRACE("ret %s\n", debugstr_w(*p));
700     return S_OK;
701 }
702
703 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
704 {
705     HTMLElement *This = HTMLELEM2_THIS(iface);
706     FIXME("(%p)->(%p)\n", This, range);
707     return E_NOTIMPL;
708 }
709
710 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, long *p)
711 {
712     HTMLElement *This = HTMLELEM2_THIS(iface);
713     nsIDOMNSHTMLElement *nselem;
714     PRInt32 height = 0;
715     nsresult nsres;
716
717     TRACE("(%p)->(%p)\n", This, p);
718
719     nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
720     if(NS_SUCCEEDED(nsres)) {
721         nsres = nsIDOMNSHTMLElement_GetScrollHeight(nselem, &height);
722         nsIDOMNSHTMLElement_Release(nselem);
723         if(NS_FAILED(nsres))
724             ERR("GetScrollHeight failed: %08x\n", nsres);
725     }else {
726         ERR("Could not get nsIDOMNSHTMLElement interface: %08x\n", nsres);
727     }
728
729     *p = height;
730     TRACE("*p = %ld\n", *p);
731
732     return S_OK;
733 }
734
735 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, long *p)
736 {
737     HTMLElement *This = HTMLELEM2_THIS(iface);
738     nsIDOMNSHTMLElement *nselem;
739     PRInt32 width = 0;
740     nsresult nsres;
741
742     TRACE("(%p)->(%p)\n", This, p);
743
744     nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
745     if(NS_SUCCEEDED(nsres)) {
746         nsres = nsIDOMNSHTMLElement_GetScrollWidth(nselem, &width);
747         nsIDOMNSHTMLElement_Release(nselem);
748         if(NS_FAILED(nsres))
749             ERR("GetScrollWidth failed: %08x\n", nsres);
750     }else {
751         ERR("Could not get nsIDOMNSHTMLElement interface: %08x\n", nsres);
752     }
753
754     *p = width;
755     TRACE("*p = %ld\n", *p);
756
757     return S_OK;
758 }
759
760 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, long v)
761 {
762     HTMLElement *This = HTMLELEM2_THIS(iface);
763     nsIDOMNSHTMLElement *nselem;
764     nsresult nsres;
765
766     TRACE("(%p)->(%ld)\n", This, v);
767
768     if(!This->nselem) {
769         FIXME("NULL nselem\n");
770         return E_NOTIMPL;
771     }
772
773     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
774     if(NS_SUCCEEDED(nsres)) {
775         nsIDOMNSHTMLElement_SetScrollTop(nselem, v);
776         nsIDOMNSHTMLElement_Release(nselem);
777     }else {
778         ERR("Could not get nsIDOMNSHTMLElement interface: %08x\n", nsres);
779     }
780
781     return S_OK;
782 }
783
784 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, long *p)
785 {
786     HTMLElement *This = HTMLELEM2_THIS(iface);
787     nsIDOMNSHTMLElement *nselem;
788     PRInt32 top = 0;
789     nsresult nsres;
790
791     TRACE("(%p)->(%p)\n", This, p);
792
793     nsres = nsIDOMElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
794     if(NS_SUCCEEDED(nsres)) {
795         nsres = nsIDOMNSHTMLElement_GetScrollTop(nselem, &top);
796         nsIDOMNSHTMLElement_Release(nselem);
797         if(NS_FAILED(nsres))
798             ERR("GetScrollTop failed: %08x\n", nsres);
799     }else {
800         ERR("Could not get nsIDOMNSHTMLElement interface: %08x\n", nsres);
801     }
802
803     *p = top;
804     TRACE("*p = %ld\n", *p);
805
806     return S_OK;
807 }
808
809 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, long v)
810 {
811     HTMLElement *This = HTMLELEM2_THIS(iface);
812     nsIDOMNSHTMLElement *nselem;
813     nsresult nsres;
814
815     TRACE("(%p)->(%ld)\n", This, v);
816
817     if(!This->nselem) {
818         FIXME("NULL nselem\n");
819         return E_NOTIMPL;
820     }
821
822     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
823     if(NS_SUCCEEDED(nsres)) {
824         nsIDOMNSHTMLElement_SetScrollLeft(nselem, v);
825         nsIDOMNSHTMLElement_Release(nselem);
826     }else {
827         ERR("Could not get nsIDOMNSHTMLElement interface: %08x\n", nsres);
828     }
829
830     return S_OK;
831 }
832
833 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, long *p)
834 {
835     HTMLElement *This = HTMLELEM2_THIS(iface);
836     nsIDOMNSHTMLElement *nselem;
837     PRInt32 left = 0;
838     nsresult nsres;
839
840     TRACE("(%p)->(%p)\n", This, p);
841
842     if(!p)
843         return E_INVALIDARG;
844
845     if(!This->nselem)
846     {
847         FIXME("NULL nselem\n");
848         return E_NOTIMPL;
849     }
850
851     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
852     if(NS_SUCCEEDED(nsres))
853     {
854         nsres = nsIDOMNSHTMLElement_GetScrollLeft(nselem, &left);
855         nsIDOMNSHTMLElement_Release(nselem);
856         if(NS_FAILED(nsres))
857             left = 0;
858     }
859
860     *p = left;
861     TRACE("*p = %ld\n", *p);
862
863     return S_OK;
864 }
865
866 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
867 {
868     HTMLElement *This = HTMLELEM2_THIS(iface);
869     FIXME("(%p)\n", This);
870     return E_NOTIMPL;
871 }
872
873 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
874 {
875     HTMLElement *This = HTMLELEM2_THIS(iface);
876     FIXME("(%p)->(%p)\n", This, mergeThis);
877     return E_NOTIMPL;
878 }
879
880 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
881 {
882     HTMLElement *This = HTMLELEM2_THIS(iface);
883     FIXME("(%p)->()\n", This);
884     return E_NOTIMPL;
885 }
886
887 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
888 {
889     HTMLElement *This = HTMLELEM2_THIS(iface);
890     FIXME("(%p)->(%p)\n", This, p);
891     return E_NOTIMPL;
892 }
893
894 static HRESULT WINAPI HTMLElement2_insertAdjecentElement(IHTMLElement2 *iface, BSTR where,
895         IHTMLElement *insertedElement, IHTMLElement **inserted)
896 {
897     HTMLElement *This = HTMLELEM2_THIS(iface);
898     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
899     return E_NOTIMPL;
900 }
901
902 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
903                                                 BSTR where, IHTMLElement **applied)
904 {
905     HTMLElement *This = HTMLELEM2_THIS(iface);
906     FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
907     return E_NOTIMPL;
908 }
909
910 static HRESULT WINAPI HTMLElement2_getAdjecentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
911 {
912     HTMLElement *This = HTMLELEM2_THIS(iface);
913     FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
914     return E_NOTIMPL;
915 }
916
917 static HRESULT WINAPI HTMLElement2_replaceAdjecentText(IHTMLElement2 *iface, BSTR where,
918                                                        BSTR newText, BSTR *oldText)
919 {
920     HTMLElement *This = HTMLELEM2_THIS(iface);
921     FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
922     return E_NOTIMPL;
923 }
924
925 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
926 {
927     HTMLElement *This = HTMLELEM2_THIS(iface);
928     FIXME("(%p)->(%p)\n", This, p);
929     return E_NOTIMPL;
930 }
931
932 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
933                                                VARIANT *pvarFactory, long *pCookie)
934 {
935     HTMLElement *This = HTMLELEM2_THIS(iface);
936     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
937     return E_NOTIMPL;
938 }
939
940 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, long cookie,
941                                                   VARIANT_BOOL *pfResult)
942 {
943     HTMLElement *This = HTMLELEM2_THIS(iface);
944     FIXME("(%p)->(%ld %p)\n", This, cookie, pfResult);
945     return E_NOTIMPL;
946 }
947
948 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
949 {
950     HTMLElement *This = HTMLELEM2_THIS(iface);
951     FIXME("(%p)->(%p)\n", This, p);
952     return E_NOTIMPL;
953 }
954
955 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
956 {
957     HTMLElement *This = HTMLELEM2_THIS(iface);
958     FIXME("(%p)->(%p)\n", This, p);
959     return E_NOTIMPL;
960 }
961
962 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
963 {
964     HTMLElement *This = HTMLELEM2_THIS(iface);
965     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
966     return E_NOTIMPL;
967 }
968
969 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
970 {
971     HTMLElement *This = HTMLELEM2_THIS(iface);
972     FIXME("(%p)->(%p)\n", This, p);
973     return E_NOTIMPL;
974 }
975
976 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
977 {
978     HTMLElement *This = HTMLELEM2_THIS(iface);
979     FIXME("(%p)->()\n", This);
980     return E_NOTIMPL;
981 }
982
983 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(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_get_readyStateValue(IHTMLElement2 *iface, long *p)
991 {
992     HTMLElement *This = HTMLELEM2_THIS(iface);
993     FIXME("(%p)->(%p)\n", This, p);
994     return E_NOTIMPL;
995 }
996
997 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
998                                                        IHTMLElementCollection **pelColl)
999 {
1000     HTMLElement *This = HTMLELEM2_THIS(iface);
1001     nsIDOMNodeList *nslist;
1002     nsAString tag_str;
1003     nsresult nsres;
1004
1005     TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
1006
1007     nsAString_Init(&tag_str, v);
1008     nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nslist);
1009     nsAString_Finish(&tag_str);
1010     if(NS_FAILED(nsres)) {
1011         ERR("GetElementByTagName failed: %08x\n", nsres);
1012         return E_FAIL;
1013     }
1014
1015     *pelColl = create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nslist);
1016     nsIDOMNodeList_Release(nslist);
1017     return S_OK;
1018 }
1019
1020 #undef HTMLELEM2_THIS
1021
1022 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
1023     HTMLElement2_QueryInterface,
1024     HTMLElement2_AddRef,
1025     HTMLElement2_Release,
1026     HTMLElement2_GetTypeInfoCount,
1027     HTMLElement2_GetTypeInfo,
1028     HTMLElement2_GetIDsOfNames,
1029     HTMLElement2_Invoke,
1030     HTMLElement2_get_scopeName,
1031     HTMLElement2_setCapture,
1032     HTMLElement2_releaseCapture,
1033     HTMLElement2_put_onlosecapture,
1034     HTMLElement2_get_onlosecapture,
1035     HTMLElement2_componentFromPoint,
1036     HTMLElement2_doScroll,
1037     HTMLElement2_put_onscroll,
1038     HTMLElement2_get_onscroll,
1039     HTMLElement2_put_ondrag,
1040     HTMLElement2_get_ondrag,
1041     HTMLElement2_put_ondragend,
1042     HTMLElement2_get_ondragend,
1043     HTMLElement2_put_ondragenter,
1044     HTMLElement2_get_ondragenter,
1045     HTMLElement2_put_ondragover,
1046     HTMLElement2_get_ondragover,
1047     HTMLElement2_put_ondragleave,
1048     HTMLElement2_get_ondragleave,
1049     HTMLElement2_put_ondrop,
1050     HTMLElement2_get_ondrop,
1051     HTMLElement2_put_onbeforecut,
1052     HTMLElement2_get_onbeforecut,
1053     HTMLElement2_put_oncut,
1054     HTMLElement2_get_oncut,
1055     HTMLElement2_put_onbeforecopy,
1056     HTMLElement2_get_onbeforecopy,
1057     HTMLElement2_put_oncopy,
1058     HTMLElement2_get_oncopy,
1059     HTMLElement2_put_onbeforepaste,
1060     HTMLElement2_get_onbeforepaste,
1061     HTMLElement2_put_onpaste,
1062     HTMLElement2_get_onpaste,
1063     HTMLElement2_get_currentStyle,
1064     HTMLElement2_put_onpropertychange,
1065     HTMLElement2_get_onpropertychange,
1066     HTMLElement2_getClientRects,
1067     HTMLElement2_getBoundingClientRect,
1068     HTMLElement2_setExpression,
1069     HTMLElement2_getExpression,
1070     HTMLElement2_removeExpression,
1071     HTMLElement2_put_tabIndex,
1072     HTMLElement2_get_tabIndex,
1073     HTMLElement2_focus,
1074     HTMLElement2_put_accessKey,
1075     HTMLElement2_get_accessKey,
1076     HTMLElement2_put_onblur,
1077     HTMLElement2_get_onblur,
1078     HTMLElement2_put_onfocus,
1079     HTMLElement2_get_onfocus,
1080     HTMLElement2_put_onresize,
1081     HTMLElement2_get_onresize,
1082     HTMLElement2_blur,
1083     HTMLElement2_addFilter,
1084     HTMLElement2_removeFilter,
1085     HTMLElement2_get_clientHeight,
1086     HTMLElement2_get_clientWidth,
1087     HTMLElement2_get_clientTop,
1088     HTMLElement2_get_clientLeft,
1089     HTMLElement2_attachEvent,
1090     HTMLElement2_detachEvent,
1091     HTMLElement2_get_readyState,
1092     HTMLElement2_put_onreadystatechange,
1093     HTMLElement2_get_onreadystatechange,
1094     HTMLElement2_put_onrowsdelete,
1095     HTMLElement2_get_onrowsdelete,
1096     HTMLElement2_put_onrowsinserted,
1097     HTMLElement2_get_onrowsinserted,
1098     HTMLElement2_put_oncellchange,
1099     HTMLElement2_get_oncellchange,
1100     HTMLElement2_put_dir,
1101     HTMLElement2_get_dir,
1102     HTMLElement2_createControlRange,
1103     HTMLElement2_get_scrollHeight,
1104     HTMLElement2_get_scrollWidth,
1105     HTMLElement2_put_scrollTop,
1106     HTMLElement2_get_scrollTop,
1107     HTMLElement2_put_scrollLeft,
1108     HTMLElement2_get_scrollLeft,
1109     HTMLElement2_clearAttributes,
1110     HTMLElement2_mergeAttributes,
1111     HTMLElement2_put_oncontextmenu,
1112     HTMLElement2_get_oncontextmenu,
1113     HTMLElement2_insertAdjecentElement,
1114     HTMLElement2_applyElement,
1115     HTMLElement2_getAdjecentText,
1116     HTMLElement2_replaceAdjecentText,
1117     HTMLElement2_get_canHandleChildren,
1118     HTMLElement2_addBehavior,
1119     HTMLElement2_removeBehavior,
1120     HTMLElement2_get_runtimeStyle,
1121     HTMLElement2_get_behaviorUrns,
1122     HTMLElement2_put_tagUrn,
1123     HTMLElement2_get_tagUrn,
1124     HTMLElement2_put_onbeforeeditfocus,
1125     HTMLElement2_get_onbeforeeditfocus,
1126     HTMLElement2_get_readyStateValue,
1127     HTMLElement2_getElementsByTagName,
1128 };
1129
1130 void HTMLElement2_Init(HTMLElement *This)
1131 {
1132     This->lpHTMLElement2Vtbl = &HTMLElement2Vtbl;
1133 }