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