mshtml: Don't use IHTMLControlElement in IDispatchEx implementations.
[wine] / dlls / mshtml / htmldoc.c
1 /*
2  * Copyright 2005 Jacek Caban
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 HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
38
39 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppvObject)
40 {
41     HTMLDocument *This = HTMLDOC_THIS(iface);
42
43     *ppvObject = NULL;
44     if(IsEqualGUID(&IID_IUnknown, riid)) {
45         TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppvObject);
46         *ppvObject = HTMLDOC(This);
47     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
48         TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppvObject);
49         *ppvObject = DISPATCHEX(This);
50     }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
51         TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppvObject);
52         *ppvObject = DISPATCHEX(This);
53     }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
54         TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppvObject);
55         *ppvObject = HTMLDOC(This);
56     }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
57         TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppvObject);
58         *ppvObject = HTMLDOC(This);
59     }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
60         TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppvObject);
61         *ppvObject = HTMLDOC3(This);
62     }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
63         TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppvObject);
64         *ppvObject = HTMLDOC4(This);
65     }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
66         TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppvObject);
67         *ppvObject = HTMLDOC5(This);
68     }else if(IsEqualGUID(&IID_IPersist, riid)) {
69         TRACE("(%p)->(IID_IPersist, %p)\n", This, ppvObject);
70         *ppvObject = PERSIST(This);
71     }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
72         TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppvObject);
73         *ppvObject = PERSISTMON(This);
74     }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
75         TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppvObject);
76         *ppvObject = PERSISTFILE(This);
77     }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
78         TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppvObject);
79         *ppvObject = MONPROP(This);
80     }else if(IsEqualGUID(&IID_IOleObject, riid)) {
81         TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppvObject);
82         *ppvObject = OLEOBJ(This);
83     }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
84         TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppvObject);
85         *ppvObject = OLEDOC(This);
86     }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
87         TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppvObject);
88         *ppvObject = DOCVIEW(This);
89     }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
90         TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppvObject);
91         *ppvObject = ACTOBJ(This);
92     }else if(IsEqualGUID(&IID_IViewObject, riid)) {
93         TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppvObject);
94         *ppvObject = VIEWOBJ(This);
95     }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
96         TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppvObject);
97         *ppvObject = VIEWOBJ2(This);
98     }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
99         TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppvObject);
100         *ppvObject = OLEWIN(This);
101     }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
102         TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppvObject);
103         *ppvObject = INPLACEOBJ(This);
104     }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
105         TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppvObject);
106         *ppvObject = INPLACEWIN(This);
107     }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
108         TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppvObject);
109         *ppvObject = SERVPROV(This);
110     }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
111         TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppvObject);
112         *ppvObject = CMDTARGET(This);
113     }else if(IsEqualGUID(&IID_IOleControl, riid)) {
114         TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppvObject);
115         *ppvObject = CONTROL(This);
116     }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
117         TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppvObject);
118         *ppvObject = HLNKTARGET(This);
119     }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
120         TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppvObject);
121         *ppvObject = CONPTCONT(&This->cp_container);
122     }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
123         TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppvObject);
124         *ppvObject = PERSTRINIT(This);
125     }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
126         TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppvObject);
127         *ppvObject = CUSTOMDOC(This);
128     }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
129         TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppvObject);
130         *ppvObject = HTMLDOC(This);
131     }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
132         FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppvObject);
133         return E_NOINTERFACE;
134     }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
135         TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppvObject);
136         return E_NOINTERFACE;
137     }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
138         TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppvObject);
139         return E_NOINTERFACE;
140     }else if(dispex_query_interface(&This->dispex, riid, ppvObject)) {
141         return *ppvObject ? S_OK : E_NOINTERFACE;
142     }
143
144     if(*ppvObject) {
145         IHTMLDocument2_AddRef(iface);
146         return S_OK;
147     }
148
149     FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppvObject);
150     return E_NOINTERFACE;
151 }
152
153 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
154 {
155     HTMLDocument *This = HTMLDOC_THIS(iface);
156     ULONG ref = InterlockedIncrement(&This->ref);
157     TRACE("(%p) ref = %u\n", This, ref);
158     return ref;
159 }
160
161 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
162 {
163     HTMLDocument *This = HTMLDOC_THIS(iface);
164     ULONG ref = InterlockedDecrement(&This->ref);
165
166     TRACE("(%p) ref = %u\n", This, ref);
167
168     if(!ref) {
169         remove_doc_tasks(This);
170         release_script_hosts(This);
171
172         if(This->client)
173             IOleObject_SetClientSite(OLEOBJ(This), NULL);
174         if(This->in_place_active)
175             IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
176         if(This->ipsite)
177             IOleDocumentView_SetInPlaceSite(DOCVIEW(This), NULL);
178         if(This->undomgr)
179             IOleUndoManager_Release(This->undomgr);
180
181         set_document_bscallback(This, NULL);
182         set_current_mon(This, NULL);
183
184         if(This->tooltips_hwnd)
185             DestroyWindow(This->tooltips_hwnd);
186         if(This->hwnd)
187             DestroyWindow(This->hwnd);
188
189         if(This->option_factory) {
190             This->option_factory->doc = NULL;
191             IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
192         }
193
194         if(This->location)
195             This->location->doc = NULL;
196
197         if(This->window)
198             IHTMLWindow2_Release(HTMLWINDOW2(This->window));
199
200         heap_free(This->mime);
201         detach_selection(This);
202         detach_ranges(This);
203         release_nodes(This);
204
205         ConnectionPointContainer_Destroy(&This->cp_container);
206
207         if(This->nscontainer)
208             NSContainer_Release(This->nscontainer);
209
210         heap_free(This);
211
212         UNLOCK_MODULE();
213     }
214
215     return ref;
216 }
217
218 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
219 {
220     HTMLDocument *This = HTMLDOC_THIS(iface);
221
222     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
223 }
224
225 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
226                                                 LCID lcid, ITypeInfo **ppTInfo)
227 {
228     HTMLDocument *This = HTMLDOC_THIS(iface);
229
230     return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
231 }
232
233 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
234                                                 LPOLESTR *rgszNames, UINT cNames,
235                                                 LCID lcid, DISPID *rgDispId)
236 {
237     HTMLDocument *This = HTMLDOC_THIS(iface);
238
239     return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
240 }
241
242 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
243                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
244                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
245 {
246     HTMLDocument *This = HTMLDOC_THIS(iface);
247
248     return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
249             pVarResult, pExcepInfo, puArgErr);
250 }
251
252 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
253 {
254     HTMLDocument *This = HTMLDOC_THIS(iface);
255
256     TRACE("(%p)->(%p)\n", This, p);
257
258     *p = (IDispatch*)HTMLWINDOW2(This->window);
259     IDispatch_AddRef(*p);
260     return S_OK;
261 }
262
263 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
264 {
265     HTMLDocument *This = HTMLDOC_THIS(iface);
266     nsIDOMDocument *nsdoc = NULL;
267     nsIDOMElement *nselem = NULL;
268     nsresult nsres;
269
270     TRACE("(%p)->(%p)\n", This, p);
271
272     if(!This->nscontainer) {
273         *p = NULL;
274         return S_OK;
275     }
276
277     nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
278     if(NS_FAILED(nsres))
279         ERR("GetDocument failed: %08x\n", nsres);
280
281     if(nsdoc) {
282         nsres = nsIDOMHTMLDocument_GetDocumentElement(nsdoc, &nselem);
283         if(NS_FAILED(nsres))
284             ERR("GetDocumentElement failed: %08x\n", nsres);
285     }
286
287     if(!nselem) {
288         *p = NULL;
289         return S_OK;
290     }
291
292     *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE));
293
294     nsIDOMElement_Release(nselem);
295     return S_OK;
296 }
297
298 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
299 {
300     HTMLDocument *This = HTMLDOC_THIS(iface);
301     nsIDOMDocument *nsdoc;
302     nsIDOMHTMLDocument *nshtmldoc;
303     nsIDOMHTMLElement *nsbody = NULL;
304     HTMLDOMNode *node;
305     nsresult nsres;
306
307     TRACE("(%p)->(%p)\n", This, p);
308
309     *p = NULL;
310
311     if(!This->nscontainer)
312         return S_OK;
313
314     nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
315     if(NS_FAILED(nsres)) {
316         ERR("GetDocument failed: %08x\n", nsres);
317         return S_OK;
318     }
319
320     if(NS_FAILED(nsres) || !nsdoc) 
321         return S_OK;
322
323     nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
324     nsIDOMDocument_Release(nsdoc);
325
326     nsres = nsIDOMHTMLDocument_GetBody(nshtmldoc, &nsbody);
327     nsIDOMHTMLDocument_Release(nshtmldoc);
328
329     if(NS_FAILED(nsres) || !nsbody) {
330         TRACE("Could not get body: %08x\n", nsres);
331         return S_OK;
332     }
333
334     node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
335     nsIDOMHTMLElement_Release(nsbody);
336
337     IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
338
339     TRACE("*p = %p\n", *p);
340     return S_OK;
341 }
342
343 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
344 {
345     HTMLDocument *This = HTMLDOC_THIS(iface);
346     FIXME("(%p)->(%p)\n", This, p);
347     return E_NOTIMPL;
348 }
349
350 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
351 {
352     HTMLDocument *This = HTMLDOC_THIS(iface);
353     FIXME("(%p)->(%p)\n", This, p);
354     return E_NOTIMPL;
355 }
356
357 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
358 {
359     HTMLDocument *This = HTMLDOC_THIS(iface);
360     FIXME("(%p)->(%p)\n", This, p);
361     return E_NOTIMPL;
362 }
363
364 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
365 {
366     HTMLDocument *This = HTMLDOC_THIS(iface);
367     FIXME("(%p)->(%p)\n", This, p);
368     return E_NOTIMPL;
369 }
370
371 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
372 {
373     HTMLDocument *This = HTMLDOC_THIS(iface);
374     FIXME("(%p)->(%p)\n", This, p);
375     return E_NOTIMPL;
376 }
377
378 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
379 {
380     HTMLDocument *This = HTMLDOC_THIS(iface);
381     FIXME("(%p)->(%p)\n", This, p);
382     return E_NOTIMPL;
383 }
384
385 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
386 {
387     HTMLDocument *This = HTMLDOC_THIS(iface);
388     nsIDOMHTMLDocument *nshtmldoc;
389     nsIDOMDocument *nsdoc;
390     nsAString nsstr;
391     nsresult nsres;
392
393     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
394
395     if(!This->nscontainer)
396         return E_FAIL;
397
398     nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
399     if(NS_FAILED(nsres) || !nsdoc) {
400         ERR("GetDocument failed: %08x\n", nsres);
401         return E_FAIL;
402     }
403
404     nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
405     nsIDOMDocument_Release(nsdoc);
406
407     nsAString_Init(&nsstr, v);
408     nsres = nsIDOMHTMLDocument_SetTitle(nshtmldoc, &nsstr);
409     nsIDOMHTMLDocument_Release(nshtmldoc);
410     nsAString_Finish(&nsstr);
411     if(NS_FAILED(nsres))
412         ERR("SetTitle failed: %08x\n", nsres);
413
414     return S_OK;
415 }
416
417 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
418 {
419     HTMLDocument *This = HTMLDOC_THIS(iface);
420     nsIDOMHTMLDocument *nshtmldoc;
421     nsIDOMDocument *nsdoc;
422     const PRUnichar *ret;
423     nsAString nsstr;
424     nsresult nsres;
425
426     TRACE("(%p)->(%p)\n", This, p);
427
428     if(!This->nscontainer)
429         return E_FAIL;
430
431     nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
432     if(NS_FAILED(nsres) || !nsdoc) {
433         ERR("GetDocument failed: %08x\n", nsres);
434         return E_FAIL;
435     }
436
437     nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
438     nsIDOMDocument_Release(nsdoc);
439
440     nsAString_Init(&nsstr, NULL);
441
442     nsres = nsIDOMHTMLDocument_GetTitle(nshtmldoc, &nsstr);
443     nsIDOMHTMLDocument_Release(nshtmldoc);
444     if (NS_FAILED(nsres))
445         ERR("GetTitle failed: %08x\n", nsres);
446
447     nsAString_GetData(&nsstr, &ret);
448     *p = SysAllocString(ret);
449     nsAString_Finish(&nsstr);
450
451     return S_OK;
452 }
453
454 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
455 {
456     HTMLDocument *This = HTMLDOC_THIS(iface);
457     FIXME("(%p)->(%p)\n", This, p);
458     return E_NOTIMPL;
459 }
460
461 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
462 {
463     HTMLDocument *This = HTMLDOC_THIS(iface);
464     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
465     return E_NOTIMPL;
466 }
467
468 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
469 {
470     HTMLDocument *This = HTMLDOC_THIS(iface);
471     FIXME("(%p)->(%p)\n", This, p);
472     return E_NOTIMPL;
473 }
474
475 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
476 {
477     HTMLDocument *This = HTMLDOC_THIS(iface);
478     nsISelection *nsselection = NULL;
479
480     TRACE("(%p)->(%p)\n", This, p);
481
482     if(This->nscontainer) {
483         nsIDOMWindow *dom_window = NULL;
484
485         nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
486         if(dom_window) {
487             nsIDOMWindow_GetSelection(dom_window, &nsselection);
488             nsIDOMWindow_Release(dom_window);
489         }
490     }
491
492     *p = HTMLSelectionObject_Create(This, nsselection);
493     return S_OK;
494 }
495
496 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
497 {
498     HTMLDocument *This = HTMLDOC_THIS(iface);
499
500     static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
501     static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
502     static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
503     static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
504     static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
505
506     static const LPCWSTR readystate_str[] = {
507         wszUninitialized,
508         wszLoading,
509         wszLoaded,
510         wszInteractive,
511         wszComplete
512     };
513
514     TRACE("(%p)->(%p)\n", iface, p);
515
516     if(!p)
517         return E_POINTER;
518
519     *p = SysAllocString(readystate_str[This->readystate]);
520     return S_OK;
521 }
522
523 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
524 {
525     HTMLDocument *This = HTMLDOC_THIS(iface);
526     FIXME("(%p)->(%p)\n", This, p);
527     return E_NOTIMPL;
528 }
529
530 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
531 {
532     HTMLDocument *This = HTMLDOC_THIS(iface);
533     FIXME("(%p)->(%p)\n", This, p);
534     return E_NOTIMPL;
535 }
536
537 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
538 {
539     HTMLDocument *This = HTMLDOC_THIS(iface);
540     FIXME("(%p)->(%p)\n", This, p);
541     return E_NOTIMPL;
542 }
543
544 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
545 {
546     HTMLDocument *This = HTMLDOC_THIS(iface);
547     FIXME("(%p)\n", This);
548     return E_NOTIMPL;
549 }
550
551 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
552 {
553     HTMLDocument *This = HTMLDOC_THIS(iface);
554     FIXME("(%p)->(%p)\n", This, p);
555     return E_NOTIMPL;
556 }
557
558 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
559 {
560     HTMLDocument *This = HTMLDOC_THIS(iface);
561     FIXME("(%p)\n", This);
562     return E_NOTIMPL;
563 }
564
565 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
566 {
567     HTMLDocument *This = HTMLDOC_THIS(iface);
568     FIXME("(%p)->(%p)\n", This, p);
569     return E_NOTIMPL;
570 }
571
572 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
573 {
574     HTMLDocument *This = HTMLDOC_THIS(iface);
575     FIXME("(%p)\n", This);
576     return E_NOTIMPL;
577 }
578
579 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
580 {
581     HTMLDocument *This = HTMLDOC_THIS(iface);
582     FIXME("(%p)->(%p)\n", This, p);
583     return E_NOTIMPL;
584 }
585
586 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
587 {
588     HTMLDocument *This = HTMLDOC_THIS(iface);
589     FIXME("(%p)->()\n", This);
590     return E_NOTIMPL;
591 }
592
593 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
594 {
595     HTMLDocument *This = HTMLDOC_THIS(iface);
596     FIXME("(%p)->(%p)\n", This, p);
597     return E_NOTIMPL;
598 }
599
600 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
601 {
602     HTMLDocument *This = HTMLDOC_THIS(iface);
603     FIXME("(%p)\n", This);
604     return E_NOTIMPL;
605 }
606
607 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
608 {
609     HTMLDocument *This = HTMLDOC_THIS(iface);
610     FIXME("(%p)->(%p)\n", This, p);
611     return E_NOTIMPL;
612 }
613
614 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
615 {
616     HTMLDocument *This = HTMLDOC_THIS(iface);
617     FIXME("(%p)->(%p)\n", This, p);
618     return E_NOTIMPL;
619 }
620
621 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
622 {
623     HTMLDocument *This = HTMLDOC_THIS(iface);
624
625     TRACE("(%p)->(%p)\n", This, p);
626
627     if(This->location)
628         IHTMLLocation_AddRef(HTMLLOCATION(This->location));
629     else
630         This->location = HTMLLocation_Create(This);
631
632     *p = HTMLLOCATION(This->location);
633     return S_OK;
634 }
635
636 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
637 {
638     HTMLDocument *This = HTMLDOC_THIS(iface);
639     FIXME("(%p)->(%p)\n", This, p);
640     return E_NOTIMPL;
641 }
642
643 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
644 {
645     HTMLDocument *This = HTMLDOC_THIS(iface);
646     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
647     return E_NOTIMPL;
648 }
649
650 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
651 {
652     HTMLDocument *This = HTMLDOC_THIS(iface);
653
654     static const WCHAR about_blank_url[] =
655         {'a','b','o','u','t',':','b','l','a','n','k',0};
656
657     TRACE("(%p)->(%p)\n", iface, p);
658
659     *p = SysAllocString(This->url ? This->url : about_blank_url);
660     return S_OK;
661 }
662
663 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
664 {
665     HTMLDocument *This = HTMLDOC_THIS(iface);
666     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
667     return E_NOTIMPL;
668 }
669
670 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
671 {
672     HTMLDocument *This = HTMLDOC_THIS(iface);
673     FIXME("(%p)->(%p)\n", This, p);
674     return E_NOTIMPL;
675 }
676
677 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
678 {
679     HTMLDocument *This = HTMLDOC_THIS(iface);
680     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
681     return E_NOTIMPL;
682 }
683
684 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
685 {
686     HTMLDocument *This = HTMLDOC_THIS(iface);
687     FIXME("(%p)->(%p)\n", This, p);
688     return E_NOTIMPL;
689 }
690
691 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
692 {
693     HTMLDocument *This = HTMLDOC_THIS(iface);
694     FIXME("(%p)->(%x)\n", This, v);
695     return E_NOTIMPL;
696 }
697
698 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
699 {
700     HTMLDocument *This = HTMLDOC_THIS(iface);
701     FIXME("(%p)->(%p)\n", This, p);
702     return E_NOTIMPL;
703 }
704
705 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
706 {
707     HTMLDocument *This = HTMLDOC_THIS(iface);
708     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
709     return E_NOTIMPL;
710 }
711
712 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
713 {
714     HTMLDocument *This = HTMLDOC_THIS(iface);
715     FIXME("(%p)->(%p)\n", This, p);
716     return E_NOTIMPL;
717 }
718
719 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
720 {
721     HTMLDocument *This = HTMLDOC_THIS(iface);
722     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
723     return E_NOTIMPL;
724 }
725
726 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
727 {
728     HTMLDocument *This = HTMLDOC_THIS(iface);
729     FIXME("(%p)->(%p)\n", This, p);
730     return E_NOTIMPL;
731 }
732
733 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
734 {
735     HTMLDocument *This = HTMLDOC_THIS(iface);
736     FIXME("(%p)->(%p)\n", This, p);
737     return E_NOTIMPL;
738 }
739
740 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
741 {
742     HTMLDocument *This = HTMLDOC_THIS(iface);
743     FIXME("(%p)->(%p)\n", This, p);
744     return E_NOTIMPL;
745 }
746
747 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
748 {
749     HTMLDocument *This = HTMLDOC_THIS(iface);
750     FIXME("(%p)->(%p)\n", This, p);
751     return E_NOTIMPL;
752 }
753
754 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
755 {
756     HTMLDocument *This = HTMLDOC_THIS(iface);
757     FIXME("(%p)->(%p)\n", This, p);
758     return E_NOTIMPL;
759 }
760
761 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
762 {
763     HTMLDocument *This = HTMLDOC_THIS(iface);
764     FIXME("(%p)->(%p)\n", This, p);
765     return E_NOTIMPL;
766 }
767
768 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
769 {
770     HTMLDocument *This = HTMLDOC_THIS(iface);
771     FIXME("(%p)->(%p)\n", This, p);
772     return E_NOTIMPL;
773 }
774
775 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
776 {
777     HTMLDocument *This = HTMLDOC_THIS(iface);
778     FIXME("(%p)->(%p)\n", This, p);
779     return E_NOTIMPL;
780 }
781
782 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
783 {
784     HTMLDocument *This = HTMLDOC_THIS(iface);
785     FIXME("(%p)->(%p)\n", This, p);
786     return E_NOTIMPL;
787 }
788
789 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
790 {
791     HTMLDocument *This = HTMLDOC_THIS(iface);
792     nsIDOMDocument *domdoc;
793     nsIDOMHTMLDocument *nsdoc;
794     nsAString nsstr;
795     VARIANT *var;
796     int i;
797     nsresult nsres;
798     HRESULT hres;
799
800     TRACE("(%p)->(%p)\n", iface, psarray);
801
802     if(psarray->cDims != 1) {
803         FIXME("cDims=%d\n", psarray->cDims);
804         return E_INVALIDARG;
805     }
806
807     if(!This->nscontainer)
808         return S_OK;
809
810     nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &domdoc);
811     if(NS_FAILED(nsres)) {
812         ERR("GetDocument failed: %08x\n", nsres);
813         return S_OK;
814     }
815
816     nsres = nsIDOMDocument_QueryInterface(domdoc, &IID_nsIDOMHTMLDocument, (void**)&nsdoc);
817     nsIDOMDocument_Release(domdoc);
818     if(NS_FAILED(nsres))
819         return S_OK;
820
821     hres = SafeArrayAccessData(psarray, (void**)&var);
822     if(FAILED(hres)) {
823         WARN("SafeArrayAccessData failed: %08x\n", hres);
824         nsIDOMHTMLDocument_Release(nsdoc);
825         return hres;
826     }
827
828     nsAString_Init(&nsstr, NULL);
829
830     for(i=0; i < psarray->rgsabound[0].cElements; i++) {
831         if(V_VT(var+i) == VT_BSTR) {
832             nsAString_SetData(&nsstr, V_BSTR(var+i));
833             nsres = nsIDOMHTMLDocument_Write(nsdoc, &nsstr);
834             if(NS_FAILED(nsres))
835                 ERR("Write failed: %08x\n", nsres);
836         }else {
837             FIXME("vt=%d\n", V_VT(var+i));
838         }
839     }
840
841     nsAString_Finish(&nsstr);
842     SafeArrayUnaccessData(psarray);
843     nsIDOMHTMLDocument_Release(nsdoc);
844
845     return S_OK;
846 }
847
848 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
849 {
850     HTMLDocument *This = HTMLDOC_THIS(iface);
851     FIXME("(%p)->(%p)\n", This, psarray);
852     return E_NOTIMPL;
853 }
854
855 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
856                         VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
857 {
858     HTMLDocument *This = HTMLDOC_THIS(iface);
859     FIXME("(%p)->(%s %p)\n", This, debugstr_w(url), pomWindowResult);
860     return E_NOTIMPL;
861 }
862
863 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
864 {
865     HTMLDocument *This = HTMLDOC_THIS(iface);
866     FIXME("(%p)\n", This);
867     return E_NOTIMPL;
868 }
869
870 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
871 {
872     HTMLDocument *This = HTMLDOC_THIS(iface);
873     FIXME("(%p)\n", This);
874     return E_NOTIMPL;
875 }
876
877 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
878                                                         VARIANT_BOOL *pfRet)
879 {
880     HTMLDocument *This = HTMLDOC_THIS(iface);
881     FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
882     return E_NOTIMPL;
883 }
884
885 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
886                                                         VARIANT_BOOL *pfRet)
887 {
888     HTMLDocument *This = HTMLDOC_THIS(iface);
889     FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
890     return E_NOTIMPL;
891 }
892
893 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
894                                                         VARIANT_BOOL *pfRet)
895 {
896     HTMLDocument *This = HTMLDOC_THIS(iface);
897     FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
898     return E_NOTIMPL;
899 }
900
901 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
902                                                         VARIANT_BOOL *pfRet)
903 {
904     HTMLDocument *This = HTMLDOC_THIS(iface);
905     FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
906     return E_NOTIMPL;
907 }
908
909 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
910                                                         BSTR *pfRet)
911 {
912     HTMLDocument *This = HTMLDOC_THIS(iface);
913     FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
914     return E_NOTIMPL;
915 }
916
917 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
918                                                         VARIANT *pfRet)
919 {
920     HTMLDocument *This = HTMLDOC_THIS(iface);
921     FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
922     return E_NOTIMPL;
923 }
924
925 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
926                                 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
927 {
928     HTMLDocument *This = HTMLDOC_THIS(iface);
929     FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
930     return E_NOTIMPL;
931 }
932
933 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
934                                                         VARIANT_BOOL *pfRet)
935 {
936     HTMLDocument *This = HTMLDOC_THIS(iface);
937     FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
938     return E_NOTIMPL;
939 }
940
941 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
942                                                  IHTMLElement **newElem)
943 {
944     HTMLDocument *This = HTMLDOC_THIS(iface);
945     nsIDOMDocument *nsdoc;
946     nsIDOMElement *nselem;
947     HTMLElement *elem;
948     nsAString tag_str;
949     nsresult nsres;
950
951     TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
952
953     nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
954
955     nsAString_Init(&tag_str, eTag);
956     nsres = nsIDOMDocument_CreateElement(nsdoc, &tag_str, &nselem);
957     nsAString_Finish(&tag_str);
958     nsIDOMDocument_Release(nsdoc);
959     if(NS_FAILED(nsres)) {
960         ERR("CreateElement failed: %08x\n", nsres);
961         return E_FAIL;
962     }
963
964     elem = HTMLElement_Create(This, (nsIDOMNode*)nselem, TRUE);
965     nsIDOMElement_Release(nselem);
966
967     *newElem = HTMLELEM(elem);
968     IHTMLElement_AddRef(HTMLELEM(elem));
969     return S_OK;
970 }
971
972 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
973 {
974     HTMLDocument *This = HTMLDOC_THIS(iface);
975     FIXME("(%p)\n", This);
976     return E_NOTIMPL;
977 }
978
979 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
980 {
981     HTMLDocument *This = HTMLDOC_THIS(iface);
982     FIXME("(%p)->(%p)\n", This, p);
983     return E_NOTIMPL;
984 }
985
986 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
987 {
988     HTMLDocument *This = HTMLDOC_THIS(iface);
989     FIXME("(%p)\n", This);
990     return E_NOTIMPL;
991 }
992
993 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
994 {
995     HTMLDocument *This = HTMLDOC_THIS(iface);
996     FIXME("(%p)->(%p)\n", This, p);
997     return E_NOTIMPL;
998 }
999
1000 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1001 {
1002     HTMLDocument *This = HTMLDOC_THIS(iface);
1003     FIXME("(%p)\n", This);
1004     return E_NOTIMPL;
1005 }
1006
1007 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1008 {
1009     HTMLDocument *This = HTMLDOC_THIS(iface);
1010     FIXME("(%p)->(%p)\n", This, p);
1011     return E_NOTIMPL;
1012 }
1013
1014 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1015 {
1016     HTMLDocument *This = HTMLDOC_THIS(iface);
1017     FIXME("(%p)\n", This);
1018     return E_NOTIMPL;
1019 }
1020
1021 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1022 {
1023     HTMLDocument *This = HTMLDOC_THIS(iface);
1024     FIXME("(%p)->(%p)\n", This, p);
1025     return E_NOTIMPL;
1026 }
1027
1028 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1029 {
1030     HTMLDocument *This = HTMLDOC_THIS(iface);
1031     FIXME("(%p)\n", This);
1032     return E_NOTIMPL;
1033 }
1034
1035 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1036 {
1037     HTMLDocument *This = HTMLDOC_THIS(iface);
1038     FIXME("(%p)->(%p)\n", This, p);
1039     return E_NOTIMPL;
1040 }
1041
1042 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1043 {
1044     HTMLDocument *This = HTMLDOC_THIS(iface);
1045     FIXME("(%p)\n", This);
1046     return E_NOTIMPL;
1047 }
1048
1049 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1050 {
1051     HTMLDocument *This = HTMLDOC_THIS(iface);
1052     FIXME("(%p)->(%p)\n", This, p);
1053     return E_NOTIMPL;
1054 }
1055
1056 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1057 {
1058     HTMLDocument *This = HTMLDOC_THIS(iface);
1059     FIXME("(%p)\n", This);
1060     return E_NOTIMPL;
1061 }
1062
1063 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1064 {
1065     HTMLDocument *This = HTMLDOC_THIS(iface);
1066     FIXME("(%p)->(%p)\n", This, p);
1067     return E_NOTIMPL;
1068 }
1069
1070 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1071 {
1072     HTMLDocument *This = HTMLDOC_THIS(iface);
1073     FIXME("(%p)\n", This);
1074     return E_NOTIMPL;
1075 }
1076
1077 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1078 {
1079     HTMLDocument *This = HTMLDOC_THIS(iface);
1080     FIXME("(%p)->(%p)\n", This, p);
1081     return E_NOTIMPL;
1082 }
1083
1084 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1085 {
1086     HTMLDocument *This = HTMLDOC_THIS(iface);
1087     FIXME("(%p)\n", This);
1088     return E_NOTIMPL;
1089 }
1090
1091 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1092 {
1093     HTMLDocument *This = HTMLDOC_THIS(iface);
1094     FIXME("(%p)->(%p)\n", This, p);
1095     return E_NOTIMPL;
1096 }
1097
1098 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1099 {
1100     HTMLDocument *This = HTMLDOC_THIS(iface);
1101     FIXME("(%p)\n", This);
1102     return E_NOTIMPL;
1103 }
1104
1105 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1106 {
1107     HTMLDocument *This = HTMLDOC_THIS(iface);
1108     FIXME("(%p)->(%p)\n", This, p);
1109     return E_NOTIMPL;
1110 }
1111
1112 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1113 {
1114     HTMLDocument *This = HTMLDOC_THIS(iface);
1115     FIXME("(%p)\n", This);
1116     return E_NOTIMPL;
1117 }
1118
1119 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1120 {
1121     HTMLDocument *This = HTMLDOC_THIS(iface);
1122     FIXME("(%p)->(%p)\n", This, p);
1123     return E_NOTIMPL;
1124 }
1125
1126 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1127 {
1128     HTMLDocument *This = HTMLDOC_THIS(iface);
1129     FIXME("(%p)\n", This);
1130     return E_NOTIMPL;
1131 }
1132
1133 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1134 {
1135     HTMLDocument *This = HTMLDOC_THIS(iface);
1136     FIXME("(%p)->(%p)\n", This, p);
1137     return E_NOTIMPL;
1138 }
1139
1140 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1141 {
1142     HTMLDocument *This = HTMLDOC_THIS(iface);
1143     FIXME("(%p)\n", This);
1144     return E_NOTIMPL;
1145 }
1146
1147 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1148 {
1149     HTMLDocument *This = HTMLDOC_THIS(iface);
1150     FIXME("(%p)->(%p)\n", This, p);
1151     return E_NOTIMPL;
1152 }
1153
1154 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1155 {
1156     HTMLDocument *This = HTMLDOC_THIS(iface);
1157     FIXME("(%p)\n", This);
1158     return E_NOTIMPL;
1159 }
1160
1161 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1162 {
1163     HTMLDocument *This = HTMLDOC_THIS(iface);
1164     FIXME("(%p)->(%p)\n", This, p);
1165     return E_NOTIMPL;
1166 }
1167
1168 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1169 {
1170     HTMLDocument *This = HTMLDOC_THIS(iface);
1171     FIXME("(%p)\n", This);
1172     return E_NOTIMPL;
1173 }
1174
1175 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1176 {
1177     HTMLDocument *This = HTMLDOC_THIS(iface);
1178     FIXME("(%p)->(%p)\n", This, p);
1179     return E_NOTIMPL;
1180 }
1181
1182 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1183 {
1184     HTMLDocument *This = HTMLDOC_THIS(iface);
1185     FIXME("(%p)\n", This);
1186     return E_NOTIMPL;
1187 }
1188
1189 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1190 {
1191     HTMLDocument *This = HTMLDOC_THIS(iface);
1192     FIXME("(%p)->(%p)\n", This, p);
1193     return E_NOTIMPL;
1194 }
1195
1196 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1197 {
1198     HTMLDocument *This = HTMLDOC_THIS(iface);
1199     FIXME("(%p)\n", This);
1200     return E_NOTIMPL;
1201 }
1202
1203 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1204 {
1205     HTMLDocument *This = HTMLDOC_THIS(iface);
1206     FIXME("(%p)->(%p)\n", This, p);
1207     return E_NOTIMPL;
1208 }
1209
1210 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, long x, long y,
1211                                                         IHTMLElement **elementHit)
1212 {
1213     HTMLDocument *This = HTMLDOC_THIS(iface);
1214     FIXME("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1215     return E_NOTIMPL;
1216 }
1217
1218 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1219 {
1220     HTMLDocument *This = HTMLDOC_THIS(iface);
1221
1222     TRACE("(%p)->(%p)\n", This, p);
1223
1224     *p = HTMLWINDOW2(This->window);
1225     IHTMLWindow2_AddRef(*p);
1226     return S_OK;
1227 }
1228
1229 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1230                                                    IHTMLStyleSheetsCollection **p)
1231 {
1232     HTMLDocument *This = HTMLDOC_THIS(iface);
1233     nsIDOMStyleSheetList *nsstylelist;
1234     nsIDOMDocumentStyle *nsdocstyle;
1235     nsIDOMDocument *nsdoc;
1236     nsresult nsres;
1237
1238     TRACE("(%p)->(%p)\n", This, p);
1239
1240     *p = NULL;
1241
1242     if(!This->nscontainer)
1243         return S_OK;
1244
1245     nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
1246     if(NS_FAILED(nsres)) {
1247         ERR("GetDocument failed: %08x\n", nsres);
1248         return S_OK;
1249     }
1250
1251     if(NS_FAILED(nsres) || !nsdoc)
1252         return S_OK;
1253
1254     nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1255     nsIDOMDocument_Release(nsdoc);
1256
1257     nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1258     nsIDOMDocumentStyle_Release(nsdocstyle);
1259
1260     *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1261     nsIDOMDocumentStyle_Release(nsstylelist);
1262
1263     return S_OK;
1264 }
1265
1266 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1267 {
1268     HTMLDocument *This = HTMLDOC_THIS(iface);
1269     FIXME("(%p)\n", This);
1270     return E_NOTIMPL;
1271 }
1272
1273 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1274 {
1275     HTMLDocument *This = HTMLDOC_THIS(iface);
1276     FIXME("(%p)->(%p)\n", This, p);
1277     return E_NOTIMPL;
1278 }
1279
1280 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1281 {
1282     HTMLDocument *This = HTMLDOC_THIS(iface);
1283     FIXME("(%p)\n", This);
1284     return E_NOTIMPL;
1285 }
1286
1287 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1288 {
1289     HTMLDocument *This = HTMLDOC_THIS(iface);
1290     FIXME("(%p)->(%p)\n", This, p);
1291     return E_NOTIMPL;
1292 }
1293
1294 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1295 {
1296     HTMLDocument *This = HTMLDOC_THIS(iface);
1297     FIXME("(%p)->(%p)\n", This, String);
1298     return E_NOTIMPL;
1299 }
1300
1301 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1302                                             long lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1303 {
1304     HTMLDocument *This = HTMLDOC_THIS(iface);
1305
1306     FIXME("(%p)->(%s %ld %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1307
1308     *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1309     return S_OK;
1310 }
1311
1312 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1313     HTMLDocument_QueryInterface,
1314     HTMLDocument_AddRef,
1315     HTMLDocument_Release,
1316     HTMLDocument_GetTypeInfoCount,
1317     HTMLDocument_GetTypeInfo,
1318     HTMLDocument_GetIDsOfNames,
1319     HTMLDocument_Invoke,
1320     HTMLDocument_get_Script,
1321     HTMLDocument_get_all,
1322     HTMLDocument_get_body,
1323     HTMLDocument_get_activeElement,
1324     HTMLDocument_get_images,
1325     HTMLDocument_get_applets,
1326     HTMLDocument_get_links,
1327     HTMLDocument_get_forms,
1328     HTMLDocument_get_anchors,
1329     HTMLDocument_put_title,
1330     HTMLDocument_get_title,
1331     HTMLDocument_get_scripts,
1332     HTMLDocument_put_designMode,
1333     HTMLDocument_get_designMode,
1334     HTMLDocument_get_selection,
1335     HTMLDocument_get_readyState,
1336     HTMLDocument_get_frames,
1337     HTMLDocument_get_embeds,
1338     HTMLDocument_get_plugins,
1339     HTMLDocument_put_alinkColor,
1340     HTMLDocument_get_alinkColor,
1341     HTMLDocument_put_bgColor,
1342     HTMLDocument_get_bgColor,
1343     HTMLDocument_put_fgColor,
1344     HTMLDocument_get_fgColor,
1345     HTMLDocument_put_linkColor,
1346     HTMLDocument_get_linkColor,
1347     HTMLDocument_put_vlinkColor,
1348     HTMLDocument_get_vlinkColor,
1349     HTMLDocument_get_referrer,
1350     HTMLDocument_get_location,
1351     HTMLDocument_get_lastModified,
1352     HTMLDocument_put_URL,
1353     HTMLDocument_get_URL,
1354     HTMLDocument_put_domain,
1355     HTMLDocument_get_domain,
1356     HTMLDocument_put_cookie,
1357     HTMLDocument_get_cookie,
1358     HTMLDocument_put_expando,
1359     HTMLDocument_get_expando,
1360     HTMLDocument_put_charset,
1361     HTMLDocument_get_charset,
1362     HTMLDocument_put_defaultCharset,
1363     HTMLDocument_get_defaultCharset,
1364     HTMLDocument_get_mimeType,
1365     HTMLDocument_get_fileSize,
1366     HTMLDocument_get_fileCreatedDate,
1367     HTMLDocument_get_fileModifiedDate,
1368     HTMLDocument_get_fileUpdatedDate,
1369     HTMLDocument_get_security,
1370     HTMLDocument_get_protocol,
1371     HTMLDocument_get_nameProp,
1372     HTMLDocument_write,
1373     HTMLDocument_writeln,
1374     HTMLDocument_open,
1375     HTMLDocument_close,
1376     HTMLDocument_clear,
1377     HTMLDocument_queryCommandSupported,
1378     HTMLDocument_queryCommandEnabled,
1379     HTMLDocument_queryCommandState,
1380     HTMLDocument_queryCommandIndeterm,
1381     HTMLDocument_queryCommandText,
1382     HTMLDocument_queryCommandValue,
1383     HTMLDocument_execCommand,
1384     HTMLDocument_execCommandShowHelp,
1385     HTMLDocument_createElement,
1386     HTMLDocument_put_onhelp,
1387     HTMLDocument_get_onhelp,
1388     HTMLDocument_put_onclick,
1389     HTMLDocument_get_onclick,
1390     HTMLDocument_put_ondblclick,
1391     HTMLDocument_get_ondblclick,
1392     HTMLDocument_put_onkeyup,
1393     HTMLDocument_get_onkeyup,
1394     HTMLDocument_put_onkeydown,
1395     HTMLDocument_get_onkeydown,
1396     HTMLDocument_put_onkeypress,
1397     HTMLDocument_get_onkeypress,
1398     HTMLDocument_put_onmouseup,
1399     HTMLDocument_get_onmouseup,
1400     HTMLDocument_put_onmousedown,
1401     HTMLDocument_get_onmousedown,
1402     HTMLDocument_put_onmousemove,
1403     HTMLDocument_get_onmousemove,
1404     HTMLDocument_put_onmouseout,
1405     HTMLDocument_get_onmouseout,
1406     HTMLDocument_put_onmouseover,
1407     HTMLDocument_get_onmouseover,
1408     HTMLDocument_put_onreadystatechange,
1409     HTMLDocument_get_onreadystatechange,
1410     HTMLDocument_put_onafterupdate,
1411     HTMLDocument_get_onafterupdate,
1412     HTMLDocument_put_onrowexit,
1413     HTMLDocument_get_onrowexit,
1414     HTMLDocument_put_onrowenter,
1415     HTMLDocument_get_onrowenter,
1416     HTMLDocument_put_ondragstart,
1417     HTMLDocument_get_ondragstart,
1418     HTMLDocument_put_onselectstart,
1419     HTMLDocument_get_onselectstart,
1420     HTMLDocument_elementFromPoint,
1421     HTMLDocument_get_parentWindow,
1422     HTMLDocument_get_styleSheets,
1423     HTMLDocument_put_onbeforeupdate,
1424     HTMLDocument_get_onbeforeupdate,
1425     HTMLDocument_put_onerrorupdate,
1426     HTMLDocument_get_onerrorupdate,
1427     HTMLDocument_toString,
1428     HTMLDocument_createStyleSheet
1429 };
1430
1431 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1432
1433 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1434 {
1435     HTMLDocument *This = DISPEX_THIS(iface);
1436
1437     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1438 }
1439
1440 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1441 {
1442     HTMLDocument *This = DISPEX_THIS(iface);
1443
1444     return IHTMLDocument2_AddRef(HTMLDOC(This));
1445 }
1446
1447 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1448 {
1449     HTMLDocument *This = DISPEX_THIS(iface);
1450
1451     return IHTMLDocument2_Release(HTMLDOC(This));
1452 }
1453
1454 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1455 {
1456     HTMLDocument *This = DISPEX_THIS(iface);
1457
1458     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1459 }
1460
1461 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1462                                                LCID lcid, ITypeInfo **ppTInfo)
1463 {
1464     HTMLDocument *This = DISPEX_THIS(iface);
1465
1466     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1467 }
1468
1469 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1470                                                  LPOLESTR *rgszNames, UINT cNames,
1471                                                  LCID lcid, DISPID *rgDispId)
1472 {
1473     HTMLDocument *This = DISPEX_THIS(iface);
1474
1475     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1476 }
1477
1478 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1479                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1480                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1481 {
1482     HTMLDocument *This = DISPEX_THIS(iface);
1483
1484     TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1485           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1486
1487     switch(dispIdMember) {
1488     case DISPID_READYSTATE:
1489         TRACE("DISPID_READYSTATE\n");
1490
1491         if(!(wFlags & DISPATCH_PROPERTYGET))
1492             return E_INVALIDARG;
1493
1494         V_VT(pVarResult) = VT_I4;
1495         V_I4(pVarResult) = This->readystate;
1496         return S_OK;
1497     }
1498
1499     return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1500                               pVarResult, pExcepInfo, puArgErr);
1501 }
1502
1503 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1504 {
1505     HTMLDocument *This = DISPEX_THIS(iface);
1506
1507     return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1508 }
1509
1510 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1511         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1512 {
1513     HTMLDocument *This = DISPEX_THIS(iface);
1514
1515     return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1516 }
1517
1518 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1519 {
1520     HTMLDocument *This = DISPEX_THIS(iface);
1521
1522     return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1523 }
1524
1525 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1526 {
1527     HTMLDocument *This = DISPEX_THIS(iface);
1528
1529     return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1530 }
1531
1532 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1533 {
1534     HTMLDocument *This = DISPEX_THIS(iface);
1535
1536     return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1537 }
1538
1539 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1540 {
1541     HTMLDocument *This = DISPEX_THIS(iface);
1542
1543     return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1544 }
1545
1546 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1547 {
1548     HTMLDocument *This = DISPEX_THIS(iface);
1549
1550     return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1551 }
1552
1553 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1554 {
1555     HTMLDocument *This = DISPEX_THIS(iface);
1556
1557     return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1558 }
1559
1560 #undef DISPEX_THIS
1561
1562 static const IDispatchExVtbl DocDispatchExVtbl = {
1563     DocDispatchEx_QueryInterface,
1564     DocDispatchEx_AddRef,
1565     DocDispatchEx_Release,
1566     DocDispatchEx_GetTypeInfoCount,
1567     DocDispatchEx_GetTypeInfo,
1568     DocDispatchEx_GetIDsOfNames,
1569     DocDispatchEx_Invoke,
1570     DocDispatchEx_GetDispID,
1571     DocDispatchEx_InvokeEx,
1572     DocDispatchEx_DeleteMemberByName,
1573     DocDispatchEx_DeleteMemberByDispID,
1574     DocDispatchEx_GetMemberProperties,
1575     DocDispatchEx_GetMemberName,
1576     DocDispatchEx_GetNextDispID,
1577     DocDispatchEx_GetNameSpaceParent
1578 };
1579
1580 static const tid_t HTMLDocument_iface_tids[] = {
1581     IHTMLDocument2_tid,
1582     IHTMLDocument3_tid,
1583     IHTMLDocument4_tid,
1584     IHTMLDocument5_tid,
1585     0
1586 };
1587 static dispex_static_data_t HTMLDocument_dispex = {
1588     NULL,
1589     DispHTMLDocument_tid,
1590     NULL,
1591     HTMLDocument_iface_tids
1592 };
1593
1594 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1595 {
1596     HTMLDocument *ret;
1597     HRESULT hres;
1598
1599     TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1600
1601     ret = heap_alloc_zero(sizeof(HTMLDocument));
1602     ret->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1603     ret->lpIDispatchExVtbl = &DocDispatchExVtbl;
1604     ret->ref = 0;
1605     ret->readystate = READYSTATE_UNINITIALIZED;
1606     ret->scriptmode = SCRIPTMODE_GECKO;
1607
1608     list_init(&ret->bindings);
1609     list_init(&ret->script_hosts);
1610     list_init(&ret->selection_list);
1611     list_init(&ret->range_list);
1612
1613     hres = IHTMLDocument_QueryInterface(HTMLDOC(ret), riid, ppvObject);
1614     if(FAILED(hres)) {
1615         heap_free(ret);
1616         return hres;
1617     }
1618
1619     LOCK_MODULE();
1620
1621     HTMLDocument_HTMLDocument3_Init(ret);
1622     HTMLDocument_HTMLDocument5_Init(ret);
1623     HTMLDocument_Persist_Init(ret);
1624     HTMLDocument_OleCmd_Init(ret);
1625     HTMLDocument_OleObj_Init(ret);
1626     HTMLDocument_View_Init(ret);
1627     HTMLDocument_Window_Init(ret);
1628     HTMLDocument_Service_Init(ret);
1629     HTMLDocument_Hlink_Init(ret);
1630
1631     ConnectionPointContainer_Init(&ret->cp_container, (IUnknown*)HTMLDOC(ret));
1632     ConnectionPoint_Init(&ret->cp_propnotif, &ret->cp_container, &IID_IPropertyNotifySink);
1633     ConnectionPoint_Init(&ret->cp_htmldocevents, &ret->cp_container, &DIID_HTMLDocumentEvents);
1634     ConnectionPoint_Init(&ret->cp_htmldocevents2, &ret->cp_container, &DIID_HTMLDocumentEvents2);
1635
1636     init_dispex(&ret->dispex, (IUnknown*)HTMLDOC(ret), &HTMLDocument_dispex);
1637
1638     ret->nscontainer = NSContainer_Create(ret, NULL);
1639     ret->window = HTMLWindow_Create(ret);
1640
1641     get_thread_hwnd();
1642
1643     return hres;
1644 }