mshtml: Add support for IHTMLStyle3 interface.
[wine] / dlls / mshtml / htmldoc3.c
1 /*
2  * Copyright 2005 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 "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30
31 #include "wine/debug.h"
32
33 #include "mshtml_private.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 #define HTMLDOC3_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument3, iface)
38
39 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
40                                                   REFIID riid, void **ppv)
41 {
42     HTMLDocument *This = HTMLDOC3_THIS(iface);
43     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
44 }
45
46 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
47 {
48     HTMLDocument *This = HTMLDOC3_THIS(iface);
49     return IHTMLDocument2_AddRef(HTMLDOC(This));
50 }
51
52 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
53 {
54     HTMLDocument *This = HTMLDOC3_THIS(iface);
55     return IHTMLDocument2_Release(HTMLDOC(This));
56 }
57
58 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
59 {
60     HTMLDocument *This = HTMLDOC3_THIS(iface);
61     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
62 }
63
64 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
65                                                 LCID lcid, ITypeInfo **ppTInfo)
66 {
67     HTMLDocument *This = HTMLDOC3_THIS(iface);
68     return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
69 }
70
71 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
72                                                 LPOLESTR *rgszNames, UINT cNames,
73                                                 LCID lcid, DISPID *rgDispId)
74 {
75     HTMLDocument *This = HTMLDOC3_THIS(iface);
76     return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
77 }
78
79 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
80                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
81                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
82 {
83     HTMLDocument *This = HTMLDOC3_THIS(iface);
84     return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
85             pVarResult, pExcepInfo, puArgErr);
86 }
87
88 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
89 {
90     HTMLDocument *This = HTMLDOC3_THIS(iface);
91     FIXME("(%p)\n", This);
92     return E_NOTIMPL;
93 }
94
95 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
96 {
97     HTMLDocument *This = HTMLDOC3_THIS(iface);
98     FIXME("(%p)->(%x)\n", This, fForce);
99     return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
103                                                    IHTMLDOMNode **newTextNode)
104 {
105     HTMLDocument *This = HTMLDOC3_THIS(iface);
106     nsIDOMText *nstext;
107     HTMLDOMNode *node;
108     nsAString text_str;
109     nsresult nsres;
110
111     TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
112
113     if(!This->nsdoc) {
114         WARN("NULL nsdoc\n");
115         return E_UNEXPECTED;
116     }
117
118     nsAString_Init(&text_str, text);
119     nsres = nsIDOMHTMLDocument_CreateTextNode(This->nsdoc, &text_str, &nstext);
120     nsAString_Finish(&text_str);
121     if(NS_FAILED(nsres)) {
122         ERR("CreateTextNode failed: %08x\n", nsres);
123         return E_FAIL;
124     }
125
126     node = HTMLDOMTextNode_Create(This, (nsIDOMNode*)nstext);
127     nsIDOMElement_Release(nstext);
128
129     *newTextNode = HTMLDOMNODE(node);
130     IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
131     return S_OK;
132 }
133
134 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
135 {
136     HTMLDocument *This = HTMLDOC3_THIS(iface);
137     nsIDOMElement *nselem = NULL;
138     HTMLDOMNode *node;
139     nsresult nsres;
140
141     TRACE("(%p)->(%p)\n", This, p);
142
143     if(!This->nsdoc) {
144         WARN("NULL nsdoc\n");
145         return E_UNEXPECTED;
146     }
147
148     nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
149     if(NS_FAILED(nsres)) {
150         ERR("GetDocumentElement failed: %08x\n", nsres);
151         return E_FAIL;
152     }
153
154     if(nselem) {
155         node = get_node(This, (nsIDOMNode *)nselem, TRUE);
156         nsIDOMElement_Release(nselem);
157         IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
158     }else {
159         *p = NULL;
160     }
161
162     return S_OK;
163 }
164
165 static HRESULT WINAPI HTMLDocument3_uniqueID(IHTMLDocument3 *iface, BSTR *p)
166 {
167     HTMLDocument *This = HTMLDOC3_THIS(iface);
168     FIXME("(%p)->(%p)\n", This, p);
169     return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
173                                                 IDispatch* pDisp, VARIANT_BOOL *pfResult)
174 {
175     HTMLDocument *This = HTMLDOC3_THIS(iface);
176     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
177     return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
181                                                 IDispatch *pDisp)
182 {
183     HTMLDocument *This = HTMLDOC3_THIS(iface);
184     FIXME("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
185     return E_NOTIMPL;
186 }
187
188 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
189 {
190     HTMLDocument *This = HTMLDOC3_THIS(iface);
191     FIXME("(%p)->()\n", This);
192     return E_NOTIMPL;
193 }
194
195 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
196 {
197     HTMLDocument *This = HTMLDOC3_THIS(iface);
198     FIXME("(%p)->(%p)\n", This, p);
199     return E_NOTIMPL;
200 }
201
202 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
203 {
204     HTMLDocument *This = HTMLDOC3_THIS(iface);
205     FIXME("(%p)->()\n", This);
206     return E_NOTIMPL;
207 }
208
209 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
210 {
211     HTMLDocument *This = HTMLDOC3_THIS(iface);
212     FIXME("(%p)->(%p)\n", This, p);
213     return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
217 {
218     HTMLDocument *This = HTMLDOC3_THIS(iface);
219     FIXME("(%p)->()\n", This);
220     return E_NOTIMPL;
221 }
222
223 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
224 {
225     HTMLDocument *This = HTMLDOC3_THIS(iface);
226     FIXME("(%p)->(%p)\n", This, p);
227     return E_NOTIMPL;
228 }
229
230 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
231 {
232     HTMLDocument *This = HTMLDOC3_THIS(iface);
233     FIXME("(%p)->()\n", This);
234     return E_NOTIMPL;
235 }
236
237 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
238 {
239     HTMLDocument *This = HTMLDOC3_THIS(iface);
240     FIXME("(%p)->(%p)\n", This, p);
241     return E_NOTIMPL;
242 }
243
244 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
245 {
246     HTMLDocument *This = HTMLDOC3_THIS(iface);
247     FIXME("(%p)->()\n", This);
248     return E_NOTIMPL;
249 }
250
251 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
252 {
253     HTMLDocument *This = HTMLDOC3_THIS(iface);
254     FIXME("(%p)->(%p)\n", This, p);
255     return E_NOTIMPL;
256 }
257
258 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
259 {
260     HTMLDocument *This = HTMLDOC3_THIS(iface);
261     FIXME("(%p)->()\n", This);
262     return E_NOTIMPL;
263 }
264
265 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
266 {
267     HTMLDocument *This = HTMLDOC3_THIS(iface);
268     FIXME("(%p)->(%p)\n", This, p);
269     return E_NOTIMPL;
270 }
271
272 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
273 {
274     HTMLDocument *This = HTMLDOC3_THIS(iface);
275     FIXME("(%p)->()\n", This);
276     return E_NOTIMPL;
277 }
278
279 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
280 {
281     HTMLDocument *This = HTMLDOC3_THIS(iface);
282     FIXME("(%p)->(%p)\n", This, p);
283     return E_NOTIMPL;
284 }
285
286 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
287 {
288     HTMLDocument *This = HTMLDOC3_THIS(iface);
289     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
290     return E_NOTIMPL;
291 }
292
293 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
294 {
295     HTMLDocument *This = HTMLDOC3_THIS(iface);
296     FIXME("(%p)->(%p)\n", This, p);
297     return E_NOTIMPL;
298 }
299
300 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
301 {
302     HTMLDocument *This = HTMLDOC3_THIS(iface);
303     FIXME("(%p)->()\n", This);
304     return E_NOTIMPL;
305 }
306
307 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
308 {
309     HTMLDocument *This = HTMLDOC3_THIS(iface);
310     FIXME("(%p)->(%p)\n", This, p);
311     return E_NOTIMPL;
312 }
313
314 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
315 {
316     HTMLDocument *This = HTMLDOC3_THIS(iface);
317     FIXME("(%p)->()\n", This);
318     return E_NOTIMPL;
319 }
320
321 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
322 {
323     HTMLDocument *This = HTMLDOC3_THIS(iface);
324     FIXME("(%p)->(%p)\n", This, p);
325     return E_NOTIMPL;
326 }
327
328 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
329                                                            IHTMLDocument2 **ppNewDoc)
330 {
331     HTMLDocument *This = HTMLDOC3_THIS(iface);
332     FIXME("(%p)->(%p)\n", This, ppNewDoc);
333     return E_NOTIMPL;
334 }
335
336 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
337                                                        IHTMLDocument2 **p)
338 {
339     HTMLDocument *This = HTMLDOC3_THIS(iface);
340     FIXME("(%p)->(%p)\n", This, p);
341     return E_NOTIMPL;
342 }
343
344 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
345                                                        VARIANT_BOOL v)
346 {
347     HTMLDocument *This = HTMLDOC3_THIS(iface);
348     FIXME("(%p)->(%x)\n", This, v);
349     return E_NOTIMPL;
350 }
351
352 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
353                                                        VARIANT_BOOL *p)
354 {
355     HTMLDocument *This = HTMLDOC3_THIS(iface);
356     FIXME("(%p)->(%p)\n", This, p);
357     return E_NOTIMPL;
358 }
359
360 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
361 {
362     HTMLDocument *This = HTMLDOC3_THIS(iface);
363     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
364     return E_NOTIMPL;
365 }
366
367 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
368 {
369     HTMLDocument *This = HTMLDOC3_THIS(iface);
370     FIXME("(%p)->(%p)\n", This, p);
371     return E_NOTIMPL;
372 }
373
374 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
375 {
376     HTMLDocument *This = HTMLDOC3_THIS(iface);
377     FIXME("(%p)->(%p)\n", This, p);
378     return E_NOTIMPL;
379 }
380
381 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
382                                                            VARIANT_BOOL v)
383 {
384     HTMLDocument *This = HTMLDOC3_THIS(iface);
385     FIXME("(%p)->()\n", This);
386     return E_NOTIMPL;
387 }
388
389 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
390                                                            VARIANT_BOOL *p)
391 {
392     HTMLDocument *This = HTMLDOC3_THIS(iface);
393     FIXME("(%p)->(%p)\n", This, p);
394     return E_NOTIMPL;
395 }
396
397 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
398 {
399     HTMLDocument *This = HTMLDOC3_THIS(iface);
400     FIXME("(%p)->()\n", This);
401     return E_NOTIMPL;
402 }
403
404 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
405 {
406     HTMLDocument *This = HTMLDOC3_THIS(iface);
407     FIXME("(%p)->(%p)\n", This, p);
408     return E_NOTIMPL;
409 }
410
411 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
412                                                       IHTMLElementCollection **ppelColl)
413 {
414     HTMLDocument *This = HTMLDOC3_THIS(iface);
415     FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
416     return E_NOTIMPL;
417 }
418
419
420 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
421                                                    IHTMLElement **pel)
422 {
423     HTMLDocument *This = HTMLDOC3_THIS(iface);
424     nsIDOMElement *nselem;
425     HTMLDOMNode *node;
426     nsAString id_str;
427     nsresult nsres;
428
429     TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
430
431     if(!This->nsdoc) {
432         WARN("NULL nsdoc\n");
433         return E_UNEXPECTED;
434     }
435
436     nsAString_Init(&id_str, v);
437     nsres = nsIDOMHTMLDocument_GetElementById(This->nsdoc, &id_str, &nselem);
438     nsAString_Finish(&id_str);
439     if(FAILED(nsres)) {
440         ERR("GetElementById failed: %08x\n", nsres);
441         return E_FAIL;
442     }
443
444     if(nselem) {
445         node = get_node(This, (nsIDOMNode*)nselem, TRUE);
446         nsIDOMElement_Release(nselem);
447
448         IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)pel);
449     }else {
450         *pel = NULL;
451     }
452
453     return S_OK;
454 }
455
456
457 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
458                                                          IHTMLElementCollection **pelColl)
459 {
460     HTMLDocument *This = HTMLDOC3_THIS(iface);
461     nsIDOMNodeList *nslist;
462     nsAString id_str, ns_str;
463     nsresult nsres;
464     static const WCHAR str[] = {'*',0};
465
466     TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
467
468     if(!This->nsdoc) {
469         WARN("NULL nsdoc\n");
470         return E_UNEXPECTED;
471     }
472
473     nsAString_Init(&id_str, v);
474     nsAString_Init(&ns_str, str);
475     nsres = nsIDOMHTMLDocument_GetElementsByTagNameNS(This->nsdoc, &ns_str, &id_str, &nslist);
476     nsAString_Finish(&id_str);
477     nsAString_Finish(&ns_str);
478     if(FAILED(nsres)) {
479         ERR("GetElementByName failed: %08x\n", nsres);
480         return E_FAIL;
481     }
482
483     *pelColl = (IHTMLElementCollection*)create_collection_from_nodelist(This, (IUnknown*)HTMLDOC3(This), nslist);
484     nsIDOMNodeList_Release(nslist);
485
486     return S_OK;
487 }
488
489 #undef HTMLDOC3_THIS
490
491 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
492     HTMLDocument3_QueryInterface,
493     HTMLDocument3_AddRef,
494     HTMLDocument3_Release,
495     HTMLDocument3_GetTypeInfoCount,
496     HTMLDocument3_GetTypeInfo,
497     HTMLDocument3_GetIDsOfNames,
498     HTMLDocument3_Invoke,
499     HTMLDocument3_releaseCapture,
500     HTMLDocument3_recalc,
501     HTMLDocument3_createTextNode,
502     HTMLDocument3_get_documentElement,
503     HTMLDocument3_uniqueID,
504     HTMLDocument3_attachEvent,
505     HTMLDocument3_detachEvent,
506     HTMLDocument3_put_onrowsdelete,
507     HTMLDocument3_get_onrowsdelete,
508     HTMLDocument3_put_onrowsinserted,
509     HTMLDocument3_get_onrowsinserted,
510     HTMLDocument3_put_oncellchange,
511     HTMLDocument3_get_oncellchange,
512     HTMLDocument3_put_ondatasetchanged,
513     HTMLDocument3_get_ondatasetchanged,
514     HTMLDocument3_put_ondataavailable,
515     HTMLDocument3_get_ondataavailable,
516     HTMLDocument3_put_ondatasetcomplete,
517     HTMLDocument3_get_ondatasetcomplete,
518     HTMLDocument3_put_onpropertychange,
519     HTMLDocument3_get_onpropertychange,
520     HTMLDocument3_put_dir,
521     HTMLDocument3_get_dir,
522     HTMLDocument3_put_oncontextmenu,
523     HTMLDocument3_get_oncontextmenu,
524     HTMLDocument3_put_onstop,
525     HTMLDocument3_get_onstop,
526     HTMLDocument3_createDocumentFragment,
527     HTMLDocument3_get_parentDocument,
528     HTMLDocument3_put_enableDownload,
529     HTMLDocument3_get_enableDownload,
530     HTMLDocument3_put_baseUrl,
531     HTMLDocument3_get_baseUrl,
532     HTMLDocument3_get_childNodes,
533     HTMLDocument3_put_inheritStyleSheets,
534     HTMLDocument3_get_inheritStyleSheets,
535     HTMLDocument3_put_onbeforeeditfocus,
536     HTMLDocument3_get_onbeforeeditfocus,
537     HTMLDocument3_getElementsByName,
538     HTMLDocument3_getElementById,
539     HTMLDocument3_getElementsByTagName
540 };
541
542 #define HTMLDOC4_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument4, iface)
543
544 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
545                                                    REFIID riid, void **ppv)
546 {
547     HTMLDocument *This = HTMLDOC4_THIS(iface);
548     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
549 }
550
551 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
552 {
553     HTMLDocument *This = HTMLDOC4_THIS(iface);
554     return IHTMLDocument2_AddRef(HTMLDOC(This));
555 }
556
557 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
558 {
559     HTMLDocument *This = HTMLDOC4_THIS(iface);
560     return IHTMLDocument2_Release(HTMLDOC(This));
561 }
562
563 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
564 {
565     HTMLDocument *This = HTMLDOC4_THIS(iface);
566     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
567 }
568
569 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
570                                                 LCID lcid, ITypeInfo **ppTInfo)
571 {
572     HTMLDocument *This = HTMLDOC4_THIS(iface);
573     return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
574 }
575
576 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
577                                                 LPOLESTR *rgszNames, UINT cNames,
578                                                 LCID lcid, DISPID *rgDispId)
579 {
580     HTMLDocument *This = HTMLDOC4_THIS(iface);
581     return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
582 }
583
584 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
585                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
586                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
587 {
588     HTMLDocument *This = HTMLDOC4_THIS(iface);
589     return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
590             pVarResult, pExcepInfo, puArgErr);
591 }
592
593 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
594 {
595     HTMLDocument *This = HTMLDOC4_THIS(iface);
596     nsIDOMNSHTMLElement *nselem;
597     nsIDOMHTMLElement *nsbody;
598     nsresult nsres;
599
600     TRACE("(%p)->()\n", This);
601
602     nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody);
603     if(NS_FAILED(nsres) || !nsbody) {
604         ERR("GetBody failed: %08x\n", nsres);
605         return E_FAIL;
606     }
607
608     nsres = nsIDOMHTMLElement_QueryInterface(nsbody, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
609     nsIDOMHTMLElement_Release(nsbody);
610     if(NS_FAILED(nsres)) {
611         ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
612         return E_FAIL;
613     }
614
615     nsres = nsIDOMNSHTMLElement_focus(nselem);
616     nsIDOMNSHTMLElement_Release(nselem);
617     if(NS_FAILED(nsres)) {
618         ERR("Focus failed: %08x\n", nsres);
619         return E_FAIL;
620     }
621
622     return S_OK;
623 }
624
625 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
626 {
627     HTMLDocument *This = HTMLDOC4_THIS(iface);
628     FIXME("(%p)->(%p)\n", This, pfFocus);
629     return E_NOTIMPL;
630 }
631
632 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
633 {
634     HTMLDocument *This = HTMLDOC4_THIS(iface);
635     FIXME("(%p)->(v)\n", This);
636     return E_NOTIMPL;
637 }
638
639 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
640 {
641     HTMLDocument *This = HTMLDOC4_THIS(iface);
642     FIXME("(%p)->(%p)\n", This, p);
643     return E_NOTIMPL;
644 }
645
646 static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
647 {
648     HTMLDocument *This = HTMLDOC4_THIS(iface);
649     FIXME("(%p)->(%p)\n", This, p);
650     return E_NOTIMPL;
651 }
652
653 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
654         BSTR bstrOptions, IHTMLDocument2 **newDoc)
655 {
656     HTMLDocument *This = HTMLDOC4_THIS(iface);
657     FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
658     return E_NOTIMPL;
659 }
660
661 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
662 {
663     HTMLDocument *This = HTMLDOC4_THIS(iface);
664     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
665     return E_NOTIMPL;
666 }
667
668 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
669 {
670     HTMLDocument *This = HTMLDOC4_THIS(iface);
671     FIXME("(%p)->(%p)\n", This, p);
672     return E_NOTIMPL;
673 }
674
675 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
676         VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
677 {
678     HTMLDocument *This = HTMLDOC4_THIS(iface);
679     FIXME("(%p)->(%p %p)\n", This, pvarEventObject, ppEventObj);
680     return E_NOTIMPL;
681 }
682
683 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
684         VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
685 {
686     HTMLDocument *This = HTMLDOC4_THIS(iface);
687     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
688     return E_NOTIMPL;
689 }
690
691 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
692         IHTMLRenderStyle **ppIHTMLRenderStyle)
693 {
694     HTMLDocument *This = HTMLDOC4_THIS(iface);
695     FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
696     return E_NOTIMPL;
697 }
698
699 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
700 {
701     HTMLDocument *This = HTMLDOC4_THIS(iface);
702     FIXME("(%p)->(v)\n", This);
703     return E_NOTIMPL;
704 }
705
706 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
707 {
708     HTMLDocument *This = HTMLDOC4_THIS(iface);
709     FIXME("(%p)->(%p)\n", This, p);
710     return E_NOTIMPL;
711 }
712
713 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
714 {
715     HTMLDocument *This = HTMLDOC4_THIS(iface);
716     FIXME("(%p)->(%p)\n", This, p);
717     return E_NOTIMPL;
718 }
719
720 #undef HTMLDOC4_THIS
721
722 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
723     HTMLDocument4_QueryInterface,
724     HTMLDocument4_AddRef,
725     HTMLDocument4_Release,
726     HTMLDocument4_GetTypeInfoCount,
727     HTMLDocument4_GetTypeInfo,
728     HTMLDocument4_GetIDsOfNames,
729     HTMLDocument4_Invoke,
730     HTMLDocument4_focus,
731     HTMLDocument4_hasFocus,
732     HTMLDocument4_put_onselectionchange,
733     HTMLDocument4_get_onselectionchange,
734     HTMLDocument4_get_namespace,
735     HTMLDocument4_createDocumentFromUrl,
736     HTMLDocument4_put_media,
737     HTMLDocument4_get_media,
738     HTMLDocument4_createEventObject,
739     HTMLDocument4_fireEvent,
740     HTMLDocument4_createRenderStyle,
741     HTMLDocument4_put_oncontrolselect,
742     HTMLDocument4_get_oncontrolselect,
743     HTMLDocument4_get_URLEncoded
744 };
745
746 void HTMLDocument_HTMLDocument3_Init(HTMLDocument *This)
747 {
748     This->lpHTMLDocument3Vtbl = &HTMLDocument3Vtbl;
749     This->lpHTMLDocument4Vtbl = &HTMLDocument4Vtbl;
750 }