msctf: Correct handling if NULL for pdimFocus in ITfThreadMgr::SetFocus.
[wine/multimedia.git] / dlls / mshtml / htmldoc.c
blob9e32b27707bb130e548ad3c7476297908bc38765
1 /*
2 * Copyright 2005 Jacek Caban
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.
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.
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
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "perhist.h"
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
35 #include "htmlevent.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
41 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppvObject)
43 HTMLDocument *This = HTMLDOC_THIS(iface);
45 *ppvObject = NULL;
46 if(IsEqualGUID(&IID_IUnknown, riid)) {
47 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppvObject);
48 *ppvObject = HTMLDOC(This);
49 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
50 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppvObject);
51 *ppvObject = DISPATCHEX(This);
52 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
53 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppvObject);
54 *ppvObject = DISPATCHEX(This);
55 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
56 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppvObject);
57 *ppvObject = HTMLDOC(This);
58 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
59 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppvObject);
60 *ppvObject = HTMLDOC(This);
61 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
62 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppvObject);
63 *ppvObject = HTMLDOC3(This);
64 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
65 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppvObject);
66 *ppvObject = HTMLDOC4(This);
67 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
68 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppvObject);
69 *ppvObject = HTMLDOC5(This);
70 }else if(IsEqualGUID(&IID_IPersist, riid)) {
71 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppvObject);
72 *ppvObject = PERSIST(This);
73 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
74 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppvObject);
75 *ppvObject = PERSISTMON(This);
76 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
77 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppvObject);
78 *ppvObject = PERSISTFILE(This);
79 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
80 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppvObject);
81 *ppvObject = MONPROP(This);
82 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
83 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppvObject);
84 *ppvObject = OLEOBJ(This);
85 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
86 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppvObject);
87 *ppvObject = OLEDOC(This);
88 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
89 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppvObject);
90 *ppvObject = DOCVIEW(This);
91 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
92 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppvObject);
93 *ppvObject = ACTOBJ(This);
94 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
95 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppvObject);
96 *ppvObject = VIEWOBJ(This);
97 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
98 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppvObject);
99 *ppvObject = VIEWOBJ2(This);
100 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
101 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppvObject);
102 *ppvObject = OLEWIN(This);
103 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
104 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppvObject);
105 *ppvObject = INPLACEOBJ(This);
106 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
107 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppvObject);
108 *ppvObject = INPLACEWIN(This);
109 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
110 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppvObject);
111 *ppvObject = SERVPROV(This);
112 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
113 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppvObject);
114 *ppvObject = CMDTARGET(This);
115 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
116 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppvObject);
117 *ppvObject = CONTROL(This);
118 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
119 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppvObject);
120 *ppvObject = HLNKTARGET(This);
121 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
122 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppvObject);
123 *ppvObject = CONPTCONT(&This->cp_container);
124 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
125 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppvObject);
126 *ppvObject = PERSTRINIT(This);
127 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
128 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppvObject);
129 *ppvObject = CUSTOMDOC(This);
130 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
131 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppvObject);
132 *ppvObject = HTMLDOC(This);
133 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
134 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppvObject);
135 *ppvObject = SUPPERRINFO(This);
136 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
137 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppvObject);
138 *ppvObject = PERSISTHIST(This);
139 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
140 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppvObject);
141 return E_NOINTERFACE;
142 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
143 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppvObject);
144 return E_NOINTERFACE;
145 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
146 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppvObject);
147 return E_NOINTERFACE;
148 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
149 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppvObject);
150 return E_NOINTERFACE;
151 }else if(dispex_query_interface(&This->dispex, riid, ppvObject)) {
152 return *ppvObject ? S_OK : E_NOINTERFACE;
155 if(*ppvObject) {
156 IHTMLDocument2_AddRef(iface);
157 return S_OK;
160 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppvObject);
161 return E_NOINTERFACE;
164 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
166 HTMLDocument *This = HTMLDOC_THIS(iface);
167 ULONG ref = InterlockedIncrement(&This->ref);
168 TRACE("(%p) ref = %u\n", This, ref);
169 return ref;
172 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
174 HTMLDocument *This = HTMLDOC_THIS(iface);
175 ULONG ref = InterlockedDecrement(&This->ref);
177 TRACE("(%p) ref = %u\n", This, ref);
179 if(!ref) {
180 remove_doc_tasks(This);
181 release_script_hosts(This);
183 if(This->client)
184 IOleObject_SetClientSite(OLEOBJ(This), NULL);
185 if(This->in_place_active)
186 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
187 if(This->ipsite)
188 IOleDocumentView_SetInPlaceSite(DOCVIEW(This), NULL);
189 if(This->undomgr)
190 IOleUndoManager_Release(This->undomgr);
192 set_document_bscallback(This, NULL);
193 set_current_mon(This, NULL);
195 if(This->tooltips_hwnd)
196 DestroyWindow(This->tooltips_hwnd);
197 if(This->hwnd)
198 DestroyWindow(This->hwnd);
200 if(This->option_factory) {
201 This->option_factory->doc = NULL;
202 IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
205 if(This->location)
206 This->location->doc = NULL;
208 if(This->window)
209 IHTMLWindow2_Release(HTMLWINDOW2(This->window));
211 if(This->event_target)
212 release_event_target(This->event_target);
214 heap_free(This->mime);
215 detach_selection(This);
216 detach_ranges(This);
217 release_nodes(This);
218 release_dispex(&This->dispex);
220 ConnectionPointContainer_Destroy(&This->cp_container);
222 if(This->nsdoc) {
223 remove_mutation_observer(This->nscontainer, This->nsdoc);
224 nsIDOMHTMLDocument_Release(This->nsdoc);
226 if(This->nscontainer)
227 NSContainer_Release(This->nscontainer);
229 heap_free(This);
232 return ref;
235 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
237 HTMLDocument *This = HTMLDOC_THIS(iface);
239 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
242 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
243 LCID lcid, ITypeInfo **ppTInfo)
245 HTMLDocument *This = HTMLDOC_THIS(iface);
247 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
250 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
251 LPOLESTR *rgszNames, UINT cNames,
252 LCID lcid, DISPID *rgDispId)
254 HTMLDocument *This = HTMLDOC_THIS(iface);
256 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
259 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
260 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
261 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
263 HTMLDocument *This = HTMLDOC_THIS(iface);
265 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
266 pVarResult, pExcepInfo, puArgErr);
269 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
271 HTMLDocument *This = HTMLDOC_THIS(iface);
273 TRACE("(%p)->(%p)\n", This, p);
275 *p = (IDispatch*)HTMLWINDOW2(This->window);
276 IDispatch_AddRef(*p);
277 return S_OK;
280 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
282 HTMLDocument *This = HTMLDOC_THIS(iface);
283 nsIDOMElement *nselem = NULL;
284 nsresult nsres;
286 TRACE("(%p)->(%p)\n", This, p);
288 if(!This->nsdoc) {
289 WARN("NULL nsdoc\n");
290 return E_UNEXPECTED;
293 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
294 if(NS_FAILED(nsres)) {
295 ERR("GetDocumentElement failed: %08x\n", nsres);
296 return E_FAIL;
299 if(nselem) {
300 *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE), TRUE);
301 nsIDOMElement_Release(nselem);
302 }else {
303 *p = NULL;
306 return S_OK;
309 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
311 HTMLDocument *This = HTMLDOC_THIS(iface);
312 nsIDOMHTMLElement *nsbody = NULL;
313 HTMLDOMNode *node;
314 nsresult nsres;
316 TRACE("(%p)->(%p)\n", This, p);
318 if(!This->nsdoc) {
319 WARN("NULL nsdoc\n");
320 return E_UNEXPECTED;
323 nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody);
324 if(NS_FAILED(nsres)) {
325 TRACE("Could not get body: %08x\n", nsres);
326 return E_UNEXPECTED;
329 if(nsbody) {
330 node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
331 nsIDOMHTMLElement_Release(nsbody);
333 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
334 }else {
335 *p = NULL;
338 TRACE("*p = %p\n", *p);
339 return S_OK;
342 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
344 HTMLDocument *This = HTMLDOC_THIS(iface);
345 FIXME("(%p)->(%p)\n", This, p);
346 return E_NOTIMPL;
349 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
351 HTMLDocument *This = HTMLDOC_THIS(iface);
352 nsIDOMHTMLCollection *nscoll = NULL;
353 nsresult nsres;
355 TRACE("(%p)->(%p)\n", This, p);
357 if(!p)
358 return E_INVALIDARG;
360 *p = NULL;
362 if(!This->nsdoc) {
363 WARN("NULL nsdoc\n");
364 return E_UNEXPECTED;
367 nsres = nsIDOMHTMLDocument_GetImages(This->nsdoc, &nscoll);
368 if(NS_FAILED(nsres)) {
369 ERR("GetImages failed: %08x\n", nsres);
370 return E_FAIL;
373 if(nscoll) {
374 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
375 nsIDOMElement_Release(nscoll);
378 return S_OK;
381 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
383 HTMLDocument *This = HTMLDOC_THIS(iface);
384 nsIDOMHTMLCollection *nscoll = NULL;
385 nsresult nsres;
387 TRACE("(%p)->(%p)\n", This, p);
389 if(!p)
390 return E_INVALIDARG;
392 *p = NULL;
394 if(!This->nsdoc) {
395 WARN("NULL nsdoc\n");
396 return E_UNEXPECTED;
399 nsres = nsIDOMHTMLDocument_GetApplets(This->nsdoc, &nscoll);
400 if(NS_FAILED(nsres)) {
401 ERR("GetApplets failed: %08x\n", nsres);
402 return E_FAIL;
405 if(nscoll) {
406 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
407 nsIDOMElement_Release(nscoll);
410 return S_OK;
413 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
415 HTMLDocument *This = HTMLDOC_THIS(iface);
416 nsIDOMHTMLCollection *nscoll = NULL;
417 nsresult nsres;
419 TRACE("(%p)->(%p)\n", This, p);
421 if(!p)
422 return E_INVALIDARG;
424 *p = NULL;
426 if(!This->nsdoc) {
427 WARN("NULL nsdoc\n");
428 return E_UNEXPECTED;
431 nsres = nsIDOMHTMLDocument_GetLinks(This->nsdoc, &nscoll);
432 if(NS_FAILED(nsres)) {
433 ERR("GetLinks failed: %08x\n", nsres);
434 return E_FAIL;
437 if(nscoll) {
438 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
439 nsIDOMElement_Release(nscoll);
442 return S_OK;
445 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
447 HTMLDocument *This = HTMLDOC_THIS(iface);
448 nsIDOMHTMLCollection *nscoll = NULL;
449 nsresult nsres;
451 TRACE("(%p)->(%p)\n", This, p);
453 if(!p)
454 return E_INVALIDARG;
456 *p = NULL;
458 if(!This->nsdoc) {
459 WARN("NULL nsdoc\n");
460 return E_UNEXPECTED;
463 nsres = nsIDOMHTMLDocument_GetForms(This->nsdoc, &nscoll);
464 if(NS_FAILED(nsres)) {
465 ERR("GetForms failed: %08x\n", nsres);
466 return E_FAIL;
469 if(nscoll) {
470 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
471 nsIDOMElement_Release(nscoll);
474 return S_OK;
477 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
479 HTMLDocument *This = HTMLDOC_THIS(iface);
480 nsIDOMHTMLCollection *nscoll = NULL;
481 nsresult nsres;
483 TRACE("(%p)->(%p)\n", This, p);
485 if(!p)
486 return E_INVALIDARG;
488 *p = NULL;
490 if(!This->nsdoc) {
491 WARN("NULL nsdoc\n");
492 return E_UNEXPECTED;
495 nsres = nsIDOMHTMLDocument_GetAnchors(This->nsdoc, &nscoll);
496 if(NS_FAILED(nsres)) {
497 ERR("GetAnchors failed: %08x\n", nsres);
498 return E_FAIL;
501 if(nscoll) {
502 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
503 nsIDOMElement_Release(nscoll);
506 return S_OK;
509 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
511 HTMLDocument *This = HTMLDOC_THIS(iface);
512 nsAString nsstr;
513 nsresult nsres;
515 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
517 if(!This->nsdoc) {
518 WARN("NULL nsdoc\n");
519 return E_UNEXPECTED;
522 nsAString_Init(&nsstr, v);
523 nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr);
524 nsAString_Finish(&nsstr);
525 if(NS_FAILED(nsres))
526 ERR("SetTitle failed: %08x\n", nsres);
528 return S_OK;
531 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
533 HTMLDocument *This = HTMLDOC_THIS(iface);
534 const PRUnichar *ret;
535 nsAString nsstr;
536 nsresult nsres;
538 TRACE("(%p)->(%p)\n", This, p);
540 if(!This->nsdoc) {
541 WARN("NULL nsdoc\n");
542 return E_UNEXPECTED;
546 nsAString_Init(&nsstr, NULL);
547 nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
548 if (NS_SUCCEEDED(nsres)) {
549 nsAString_GetData(&nsstr, &ret);
550 *p = SysAllocString(ret);
552 nsAString_Finish(&nsstr);
554 if(NS_FAILED(nsres)) {
555 ERR("GetTitle failed: %08x\n", nsres);
556 return E_FAIL;
559 return S_OK;
562 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
564 HTMLDocument *This = HTMLDOC_THIS(iface);
565 FIXME("(%p)->(%p)\n", This, p);
566 return E_NOTIMPL;
569 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
571 HTMLDocument *This = HTMLDOC_THIS(iface);
572 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
573 return E_NOTIMPL;
576 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
578 HTMLDocument *This = HTMLDOC_THIS(iface);
579 static WCHAR szOff[] = {'O','f','f',0};
580 FIXME("(%p)->(%p) always returning Off\n", This, p);
582 if(!p)
583 return E_INVALIDARG;
585 *p = SysAllocString(szOff);
587 return S_OK;
590 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
592 HTMLDocument *This = HTMLDOC_THIS(iface);
593 nsISelection *nsselection = NULL;
595 TRACE("(%p)->(%p)\n", This, p);
597 if(This->nscontainer) {
598 nsIDOMWindow *dom_window = NULL;
600 nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
601 if(dom_window) {
602 nsIDOMWindow_GetSelection(dom_window, &nsselection);
603 nsIDOMWindow_Release(dom_window);
607 *p = HTMLSelectionObject_Create(This, nsselection);
608 return S_OK;
611 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
613 HTMLDocument *This = HTMLDOC_THIS(iface);
615 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
616 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
617 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
618 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
619 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
621 static const LPCWSTR readystate_str[] = {
622 wszUninitialized,
623 wszLoading,
624 wszLoaded,
625 wszInteractive,
626 wszComplete
629 TRACE("(%p)->(%p)\n", iface, p);
631 if(!p)
632 return E_POINTER;
634 *p = SysAllocString(readystate_str[This->readystate]);
635 return S_OK;
638 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
640 HTMLDocument *This = HTMLDOC_THIS(iface);
641 FIXME("(%p)->(%p)\n", This, p);
642 return E_NOTIMPL;
645 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
647 HTMLDocument *This = HTMLDOC_THIS(iface);
648 FIXME("(%p)->(%p)\n", This, p);
649 return E_NOTIMPL;
652 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
654 HTMLDocument *This = HTMLDOC_THIS(iface);
655 FIXME("(%p)->(%p)\n", This, p);
656 return E_NOTIMPL;
659 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
661 HTMLDocument *This = HTMLDOC_THIS(iface);
662 FIXME("(%p)\n", This);
663 return E_NOTIMPL;
666 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
668 HTMLDocument *This = HTMLDOC_THIS(iface);
669 FIXME("(%p)->(%p)\n", This, p);
670 return E_NOTIMPL;
673 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
675 HTMLDocument *This = HTMLDOC_THIS(iface);
676 FIXME("(%p)\n", This);
677 return E_NOTIMPL;
680 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
682 HTMLDocument *This = HTMLDOC_THIS(iface);
683 FIXME("(%p)->(%p)\n", This, p);
684 return E_NOTIMPL;
687 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
689 HTMLDocument *This = HTMLDOC_THIS(iface);
690 FIXME("(%p)\n", This);
691 return E_NOTIMPL;
694 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
696 HTMLDocument *This = HTMLDOC_THIS(iface);
697 FIXME("(%p)->(%p)\n", This, p);
698 return E_NOTIMPL;
701 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
703 HTMLDocument *This = HTMLDOC_THIS(iface);
704 FIXME("(%p)->()\n", This);
705 return E_NOTIMPL;
708 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
710 HTMLDocument *This = HTMLDOC_THIS(iface);
711 FIXME("(%p)->(%p)\n", This, p);
712 return E_NOTIMPL;
715 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
717 HTMLDocument *This = HTMLDOC_THIS(iface);
718 FIXME("(%p)\n", This);
719 return E_NOTIMPL;
722 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
724 HTMLDocument *This = HTMLDOC_THIS(iface);
725 FIXME("(%p)->(%p)\n", This, p);
726 return E_NOTIMPL;
729 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
731 HTMLDocument *This = HTMLDOC_THIS(iface);
732 FIXME("(%p)->(%p)\n", This, p);
733 return E_NOTIMPL;
736 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
738 HTMLDocument *This = HTMLDOC_THIS(iface);
740 TRACE("(%p)->(%p)\n", This, p);
742 if(This->location)
743 IHTMLLocation_AddRef(HTMLLOCATION(This->location));
744 else
745 This->location = HTMLLocation_Create(This);
747 *p = HTMLLOCATION(This->location);
748 return S_OK;
751 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
753 HTMLDocument *This = HTMLDOC_THIS(iface);
754 FIXME("(%p)->(%p)\n", This, p);
755 return E_NOTIMPL;
758 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
760 HTMLDocument *This = HTMLDOC_THIS(iface);
761 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
762 return E_NOTIMPL;
765 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
767 HTMLDocument *This = HTMLDOC_THIS(iface);
769 static const WCHAR about_blank_url[] =
770 {'a','b','o','u','t',':','b','l','a','n','k',0};
772 TRACE("(%p)->(%p)\n", iface, p);
774 *p = SysAllocString(This->url ? This->url : about_blank_url);
775 return S_OK;
778 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
780 HTMLDocument *This = HTMLDOC_THIS(iface);
781 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
782 return E_NOTIMPL;
785 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
787 HTMLDocument *This = HTMLDOC_THIS(iface);
788 FIXME("(%p)->(%p)\n", This, p);
789 return E_NOTIMPL;
792 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
794 HTMLDocument *This = HTMLDOC_THIS(iface);
795 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
796 return E_NOTIMPL;
799 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
801 HTMLDocument *This = HTMLDOC_THIS(iface);
802 FIXME("(%p)->(%p)\n", This, p);
803 return E_NOTIMPL;
806 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
808 HTMLDocument *This = HTMLDOC_THIS(iface);
809 FIXME("(%p)->(%x)\n", This, v);
810 return E_NOTIMPL;
813 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
815 HTMLDocument *This = HTMLDOC_THIS(iface);
816 FIXME("(%p)->(%p)\n", This, p);
817 return E_NOTIMPL;
820 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
822 HTMLDocument *This = HTMLDOC_THIS(iface);
823 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
824 return E_NOTIMPL;
827 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
829 HTMLDocument *This = HTMLDOC_THIS(iface);
830 FIXME("(%p)->(%p)\n", This, p);
831 return E_NOTIMPL;
834 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
836 HTMLDocument *This = HTMLDOC_THIS(iface);
837 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
838 return E_NOTIMPL;
841 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
843 HTMLDocument *This = HTMLDOC_THIS(iface);
844 FIXME("(%p)->(%p)\n", This, p);
845 return E_NOTIMPL;
848 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
850 HTMLDocument *This = HTMLDOC_THIS(iface);
851 FIXME("(%p)->(%p)\n", This, p);
852 return E_NOTIMPL;
855 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
857 HTMLDocument *This = HTMLDOC_THIS(iface);
858 FIXME("(%p)->(%p)\n", This, p);
859 return E_NOTIMPL;
862 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
864 HTMLDocument *This = HTMLDOC_THIS(iface);
865 FIXME("(%p)->(%p)\n", This, p);
866 return E_NOTIMPL;
869 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
871 HTMLDocument *This = HTMLDOC_THIS(iface);
872 FIXME("(%p)->(%p)\n", This, p);
873 return E_NOTIMPL;
876 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
878 HTMLDocument *This = HTMLDOC_THIS(iface);
879 FIXME("(%p)->(%p)\n", This, p);
880 return E_NOTIMPL;
883 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
885 HTMLDocument *This = HTMLDOC_THIS(iface);
886 FIXME("(%p)->(%p)\n", This, p);
887 return E_NOTIMPL;
890 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
892 HTMLDocument *This = HTMLDOC_THIS(iface);
893 FIXME("(%p)->(%p)\n", This, p);
894 return E_NOTIMPL;
897 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
899 HTMLDocument *This = HTMLDOC_THIS(iface);
900 FIXME("(%p)->(%p)\n", This, p);
901 return E_NOTIMPL;
904 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
906 HTMLDocument *This = HTMLDOC_THIS(iface);
907 nsAString nsstr;
908 VARIANT *var;
909 ULONG i;
910 nsresult nsres;
911 HRESULT hres;
913 TRACE("(%p)->(%p)\n", iface, psarray);
915 if(!This->nsdoc) {
916 WARN("NULL nsdoc\n");
917 return E_UNEXPECTED;
920 if(psarray->cDims != 1) {
921 FIXME("cDims=%d\n", psarray->cDims);
922 return E_INVALIDARG;
925 hres = SafeArrayAccessData(psarray, (void**)&var);
926 if(FAILED(hres)) {
927 WARN("SafeArrayAccessData failed: %08x\n", hres);
928 return hres;
931 nsAString_Init(&nsstr, NULL);
933 for(i=0; i < psarray->rgsabound[0].cElements; i++) {
934 if(V_VT(var+i) == VT_BSTR) {
935 nsAString_SetData(&nsstr, V_BSTR(var+i));
936 nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
937 if(NS_FAILED(nsres))
938 ERR("Write failed: %08x\n", nsres);
939 }else {
940 FIXME("vt=%d\n", V_VT(var+i));
944 nsAString_Finish(&nsstr);
945 SafeArrayUnaccessData(psarray);
947 return S_OK;
950 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
952 HTMLDocument *This = HTMLDOC_THIS(iface);
953 FIXME("(%p)->(%p)\n", This, psarray);
954 return E_NOTIMPL;
957 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
958 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
960 HTMLDocument *This = HTMLDOC_THIS(iface);
961 nsresult nsres;
963 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
965 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
966 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
968 if(!This->nsdoc) {
969 ERR("!nsdoc\n");
970 return E_NOTIMPL;
973 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
974 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
975 FIXME("unsupported args\n");
977 nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
978 if(NS_FAILED(nsres)) {
979 ERR("Open failed: %08x\n", nsres);
980 return E_FAIL;
983 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
984 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
985 return S_OK;
988 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
990 HTMLDocument *This = HTMLDOC_THIS(iface);
991 nsresult nsres;
993 TRACE("(%p)\n", This);
995 if(!This->nsdoc) {
996 ERR("!nsdoc\n");
997 return E_NOTIMPL;
1000 nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
1001 if(NS_FAILED(nsres)) {
1002 ERR("Close failed: %08x\n", nsres);
1003 return E_FAIL;
1006 return S_OK;
1009 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1011 HTMLDocument *This = HTMLDOC_THIS(iface);
1012 FIXME("(%p)\n", This);
1013 return E_NOTIMPL;
1016 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1017 VARIANT_BOOL *pfRet)
1019 HTMLDocument *This = HTMLDOC_THIS(iface);
1020 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1021 return E_NOTIMPL;
1024 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1025 VARIANT_BOOL *pfRet)
1027 HTMLDocument *This = HTMLDOC_THIS(iface);
1028 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1029 return E_NOTIMPL;
1032 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1033 VARIANT_BOOL *pfRet)
1035 HTMLDocument *This = HTMLDOC_THIS(iface);
1036 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1037 return E_NOTIMPL;
1040 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1041 VARIANT_BOOL *pfRet)
1043 HTMLDocument *This = HTMLDOC_THIS(iface);
1044 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1045 return E_NOTIMPL;
1048 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1049 BSTR *pfRet)
1051 HTMLDocument *This = HTMLDOC_THIS(iface);
1052 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1053 return E_NOTIMPL;
1056 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1057 VARIANT *pfRet)
1059 HTMLDocument *This = HTMLDOC_THIS(iface);
1060 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1061 return E_NOTIMPL;
1064 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1065 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1067 HTMLDocument *This = HTMLDOC_THIS(iface);
1068 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
1069 return E_NOTIMPL;
1072 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1073 VARIANT_BOOL *pfRet)
1075 HTMLDocument *This = HTMLDOC_THIS(iface);
1076 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1077 return E_NOTIMPL;
1080 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1081 IHTMLElement **newElem)
1083 HTMLDocument *This = HTMLDOC_THIS(iface);
1084 nsIDOMElement *nselem;
1085 HTMLElement *elem;
1086 nsAString tag_str;
1087 nsresult nsres;
1089 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1091 if(!This->nsdoc) {
1092 WARN("NULL nsdoc\n");
1093 return E_UNEXPECTED;
1096 nsAString_Init(&tag_str, eTag);
1097 nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
1098 nsAString_Finish(&tag_str);
1099 if(NS_FAILED(nsres)) {
1100 ERR("CreateElement failed: %08x\n", nsres);
1101 return E_FAIL;
1104 elem = HTMLElement_Create(This, (nsIDOMNode*)nselem, TRUE);
1105 nsIDOMElement_Release(nselem);
1107 *newElem = HTMLELEM(elem);
1108 IHTMLElement_AddRef(HTMLELEM(elem));
1109 return S_OK;
1112 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1114 HTMLDocument *This = HTMLDOC_THIS(iface);
1115 FIXME("(%p)\n", This);
1116 return E_NOTIMPL;
1119 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1121 HTMLDocument *This = HTMLDOC_THIS(iface);
1122 FIXME("(%p)->(%p)\n", This, p);
1123 return E_NOTIMPL;
1126 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1128 HTMLDocument *This = HTMLDOC_THIS(iface);
1129 FIXME("(%p)\n", This);
1130 return E_NOTIMPL;
1133 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1135 HTMLDocument *This = HTMLDOC_THIS(iface);
1136 FIXME("(%p)->(%p)\n", This, p);
1137 return E_NOTIMPL;
1140 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1142 HTMLDocument *This = HTMLDOC_THIS(iface);
1143 FIXME("(%p)\n", This);
1144 return E_NOTIMPL;
1147 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1149 HTMLDocument *This = HTMLDOC_THIS(iface);
1150 FIXME("(%p)->(%p)\n", This, p);
1151 return E_NOTIMPL;
1154 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1156 HTMLDocument *This = HTMLDOC_THIS(iface);
1158 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1160 return set_doc_event(This, EVENTID_KEYUP, &v);
1163 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1165 HTMLDocument *This = HTMLDOC_THIS(iface);
1167 TRACE("(%p)->(%p)\n", This, p);
1169 return get_doc_event(This, EVENTID_KEYUP, p);
1172 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1174 HTMLDocument *This = HTMLDOC_THIS(iface);
1176 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1178 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1181 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1183 HTMLDocument *This = HTMLDOC_THIS(iface);
1185 TRACE("(%p)->(%p)\n", This, p);
1187 return get_doc_event(This, EVENTID_KEYDOWN, p);
1190 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1192 HTMLDocument *This = HTMLDOC_THIS(iface);
1193 FIXME("(%p)\n", This);
1194 return E_NOTIMPL;
1197 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1199 HTMLDocument *This = HTMLDOC_THIS(iface);
1200 FIXME("(%p)->(%p)\n", This, p);
1201 return E_NOTIMPL;
1204 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1206 HTMLDocument *This = HTMLDOC_THIS(iface);
1207 FIXME("(%p)\n", This);
1208 return E_NOTIMPL;
1211 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1213 HTMLDocument *This = HTMLDOC_THIS(iface);
1214 FIXME("(%p)->(%p)\n", This, p);
1215 return E_NOTIMPL;
1218 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1220 HTMLDocument *This = HTMLDOC_THIS(iface);
1221 FIXME("(%p)\n", This);
1222 return E_NOTIMPL;
1225 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1227 HTMLDocument *This = HTMLDOC_THIS(iface);
1228 FIXME("(%p)->(%p)\n", This, p);
1229 return E_NOTIMPL;
1232 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1234 HTMLDocument *This = HTMLDOC_THIS(iface);
1235 FIXME("(%p)\n", This);
1236 return E_NOTIMPL;
1239 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1241 HTMLDocument *This = HTMLDOC_THIS(iface);
1242 FIXME("(%p)->(%p)\n", This, p);
1243 return E_NOTIMPL;
1246 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1248 HTMLDocument *This = HTMLDOC_THIS(iface);
1249 FIXME("(%p)\n", This);
1250 return E_NOTIMPL;
1253 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1255 HTMLDocument *This = HTMLDOC_THIS(iface);
1256 FIXME("(%p)->(%p)\n", This, p);
1257 return E_NOTIMPL;
1260 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1262 HTMLDocument *This = HTMLDOC_THIS(iface);
1264 TRACE("(%p)\n", This);
1266 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1269 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1271 HTMLDocument *This = HTMLDOC_THIS(iface);
1273 TRACE("(%p)->(%p)\n", This, p);
1275 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1278 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1280 HTMLDocument *This = HTMLDOC_THIS(iface);
1281 FIXME("(%p)\n", This);
1282 return E_NOTIMPL;
1285 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1287 HTMLDocument *This = HTMLDOC_THIS(iface);
1288 FIXME("(%p)->(%p)\n", This, p);
1289 return E_NOTIMPL;
1292 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1294 HTMLDocument *This = HTMLDOC_THIS(iface);
1295 FIXME("(%p)\n", This);
1296 return E_NOTIMPL;
1299 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1301 HTMLDocument *This = HTMLDOC_THIS(iface);
1302 FIXME("(%p)->(%p)\n", This, p);
1303 return E_NOTIMPL;
1306 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1308 HTMLDocument *This = HTMLDOC_THIS(iface);
1309 FIXME("(%p)\n", This);
1310 return E_NOTIMPL;
1313 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1315 HTMLDocument *This = HTMLDOC_THIS(iface);
1316 FIXME("(%p)->(%p)\n", This, p);
1317 return E_NOTIMPL;
1320 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1322 HTMLDocument *This = HTMLDOC_THIS(iface);
1323 FIXME("(%p)\n", This);
1324 return E_NOTIMPL;
1327 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1329 HTMLDocument *This = HTMLDOC_THIS(iface);
1330 FIXME("(%p)->(%p)\n", This, p);
1331 return E_NOTIMPL;
1334 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1336 HTMLDocument *This = HTMLDOC_THIS(iface);
1338 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1340 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1343 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1345 HTMLDocument *This = HTMLDOC_THIS(iface);
1347 TRACE("(%p)->(%p)\n", This, p);
1349 return get_doc_event(This, EVENTID_DRAGSTART, p);
1352 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1354 HTMLDocument *This = HTMLDOC_THIS(iface);
1356 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1358 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1361 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1363 HTMLDocument *This = HTMLDOC_THIS(iface);
1365 TRACE("(%p)->(%p)\n", This, p);
1367 return get_doc_event(This, EVENTID_SELECTSTART, p);
1370 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1371 IHTMLElement **elementHit)
1373 HTMLDocument *This = HTMLDOC_THIS(iface);
1374 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1375 return E_NOTIMPL;
1378 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1380 HTMLDocument *This = HTMLDOC_THIS(iface);
1382 TRACE("(%p)->(%p)\n", This, p);
1384 *p = HTMLWINDOW2(This->window);
1385 IHTMLWindow2_AddRef(*p);
1386 return S_OK;
1389 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1390 IHTMLStyleSheetsCollection **p)
1392 HTMLDocument *This = HTMLDOC_THIS(iface);
1393 nsIDOMStyleSheetList *nsstylelist;
1394 nsIDOMDocumentStyle *nsdocstyle;
1395 nsresult nsres;
1397 TRACE("(%p)->(%p)\n", This, p);
1399 *p = NULL;
1401 if(!This->nsdoc) {
1402 WARN("NULL nsdoc\n");
1403 return E_UNEXPECTED;
1406 nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1407 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1408 nsIDOMDocumentStyle_Release(nsdocstyle);
1409 if(NS_FAILED(nsres)) {
1410 ERR("GetStyleSheets failed: %08x\n", nsres);
1411 return E_FAIL;
1414 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1415 nsIDOMDocumentStyle_Release(nsstylelist);
1417 return S_OK;
1420 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1422 HTMLDocument *This = HTMLDOC_THIS(iface);
1423 FIXME("(%p)\n", This);
1424 return E_NOTIMPL;
1427 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1429 HTMLDocument *This = HTMLDOC_THIS(iface);
1430 FIXME("(%p)->(%p)\n", This, p);
1431 return E_NOTIMPL;
1434 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1436 HTMLDocument *This = HTMLDOC_THIS(iface);
1437 FIXME("(%p)\n", This);
1438 return E_NOTIMPL;
1441 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1443 HTMLDocument *This = HTMLDOC_THIS(iface);
1444 FIXME("(%p)->(%p)\n", This, p);
1445 return E_NOTIMPL;
1448 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1450 HTMLDocument *This = HTMLDOC_THIS(iface);
1451 FIXME("(%p)->(%p)\n", This, String);
1452 return E_NOTIMPL;
1455 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1456 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1458 HTMLDocument *This = HTMLDOC_THIS(iface);
1460 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1462 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1463 return S_OK;
1466 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1467 HTMLDocument_QueryInterface,
1468 HTMLDocument_AddRef,
1469 HTMLDocument_Release,
1470 HTMLDocument_GetTypeInfoCount,
1471 HTMLDocument_GetTypeInfo,
1472 HTMLDocument_GetIDsOfNames,
1473 HTMLDocument_Invoke,
1474 HTMLDocument_get_Script,
1475 HTMLDocument_get_all,
1476 HTMLDocument_get_body,
1477 HTMLDocument_get_activeElement,
1478 HTMLDocument_get_images,
1479 HTMLDocument_get_applets,
1480 HTMLDocument_get_links,
1481 HTMLDocument_get_forms,
1482 HTMLDocument_get_anchors,
1483 HTMLDocument_put_title,
1484 HTMLDocument_get_title,
1485 HTMLDocument_get_scripts,
1486 HTMLDocument_put_designMode,
1487 HTMLDocument_get_designMode,
1488 HTMLDocument_get_selection,
1489 HTMLDocument_get_readyState,
1490 HTMLDocument_get_frames,
1491 HTMLDocument_get_embeds,
1492 HTMLDocument_get_plugins,
1493 HTMLDocument_put_alinkColor,
1494 HTMLDocument_get_alinkColor,
1495 HTMLDocument_put_bgColor,
1496 HTMLDocument_get_bgColor,
1497 HTMLDocument_put_fgColor,
1498 HTMLDocument_get_fgColor,
1499 HTMLDocument_put_linkColor,
1500 HTMLDocument_get_linkColor,
1501 HTMLDocument_put_vlinkColor,
1502 HTMLDocument_get_vlinkColor,
1503 HTMLDocument_get_referrer,
1504 HTMLDocument_get_location,
1505 HTMLDocument_get_lastModified,
1506 HTMLDocument_put_URL,
1507 HTMLDocument_get_URL,
1508 HTMLDocument_put_domain,
1509 HTMLDocument_get_domain,
1510 HTMLDocument_put_cookie,
1511 HTMLDocument_get_cookie,
1512 HTMLDocument_put_expando,
1513 HTMLDocument_get_expando,
1514 HTMLDocument_put_charset,
1515 HTMLDocument_get_charset,
1516 HTMLDocument_put_defaultCharset,
1517 HTMLDocument_get_defaultCharset,
1518 HTMLDocument_get_mimeType,
1519 HTMLDocument_get_fileSize,
1520 HTMLDocument_get_fileCreatedDate,
1521 HTMLDocument_get_fileModifiedDate,
1522 HTMLDocument_get_fileUpdatedDate,
1523 HTMLDocument_get_security,
1524 HTMLDocument_get_protocol,
1525 HTMLDocument_get_nameProp,
1526 HTMLDocument_write,
1527 HTMLDocument_writeln,
1528 HTMLDocument_open,
1529 HTMLDocument_close,
1530 HTMLDocument_clear,
1531 HTMLDocument_queryCommandSupported,
1532 HTMLDocument_queryCommandEnabled,
1533 HTMLDocument_queryCommandState,
1534 HTMLDocument_queryCommandIndeterm,
1535 HTMLDocument_queryCommandText,
1536 HTMLDocument_queryCommandValue,
1537 HTMLDocument_execCommand,
1538 HTMLDocument_execCommandShowHelp,
1539 HTMLDocument_createElement,
1540 HTMLDocument_put_onhelp,
1541 HTMLDocument_get_onhelp,
1542 HTMLDocument_put_onclick,
1543 HTMLDocument_get_onclick,
1544 HTMLDocument_put_ondblclick,
1545 HTMLDocument_get_ondblclick,
1546 HTMLDocument_put_onkeyup,
1547 HTMLDocument_get_onkeyup,
1548 HTMLDocument_put_onkeydown,
1549 HTMLDocument_get_onkeydown,
1550 HTMLDocument_put_onkeypress,
1551 HTMLDocument_get_onkeypress,
1552 HTMLDocument_put_onmouseup,
1553 HTMLDocument_get_onmouseup,
1554 HTMLDocument_put_onmousedown,
1555 HTMLDocument_get_onmousedown,
1556 HTMLDocument_put_onmousemove,
1557 HTMLDocument_get_onmousemove,
1558 HTMLDocument_put_onmouseout,
1559 HTMLDocument_get_onmouseout,
1560 HTMLDocument_put_onmouseover,
1561 HTMLDocument_get_onmouseover,
1562 HTMLDocument_put_onreadystatechange,
1563 HTMLDocument_get_onreadystatechange,
1564 HTMLDocument_put_onafterupdate,
1565 HTMLDocument_get_onafterupdate,
1566 HTMLDocument_put_onrowexit,
1567 HTMLDocument_get_onrowexit,
1568 HTMLDocument_put_onrowenter,
1569 HTMLDocument_get_onrowenter,
1570 HTMLDocument_put_ondragstart,
1571 HTMLDocument_get_ondragstart,
1572 HTMLDocument_put_onselectstart,
1573 HTMLDocument_get_onselectstart,
1574 HTMLDocument_elementFromPoint,
1575 HTMLDocument_get_parentWindow,
1576 HTMLDocument_get_styleSheets,
1577 HTMLDocument_put_onbeforeupdate,
1578 HTMLDocument_get_onbeforeupdate,
1579 HTMLDocument_put_onerrorupdate,
1580 HTMLDocument_get_onerrorupdate,
1581 HTMLDocument_toString,
1582 HTMLDocument_createStyleSheet
1585 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1587 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1589 HTMLDocument *This = SUPPINFO_THIS(iface);
1590 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1593 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1595 HTMLDocument *This = SUPPINFO_THIS(iface);
1596 return IHTMLDocument_AddRef(HTMLDOC(This));
1599 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1601 HTMLDocument *This = SUPPINFO_THIS(iface);
1602 return IHTMLDocument_Release(HTMLDOC(This));
1605 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1607 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1608 return S_FALSE;
1611 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1612 SupportErrorInfo_QueryInterface,
1613 SupportErrorInfo_AddRef,
1614 SupportErrorInfo_Release,
1615 SupportErrorInfo_InterfaceSupportsErrorInfo
1618 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1620 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1622 HTMLDocument *This = DISPEX_THIS(iface);
1624 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1627 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1629 HTMLDocument *This = DISPEX_THIS(iface);
1631 return IHTMLDocument2_AddRef(HTMLDOC(This));
1634 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1636 HTMLDocument *This = DISPEX_THIS(iface);
1638 return IHTMLDocument2_Release(HTMLDOC(This));
1641 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1643 HTMLDocument *This = DISPEX_THIS(iface);
1645 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1648 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1649 LCID lcid, ITypeInfo **ppTInfo)
1651 HTMLDocument *This = DISPEX_THIS(iface);
1653 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1656 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1657 LPOLESTR *rgszNames, UINT cNames,
1658 LCID lcid, DISPID *rgDispId)
1660 HTMLDocument *This = DISPEX_THIS(iface);
1662 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1665 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1666 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1667 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1669 HTMLDocument *This = DISPEX_THIS(iface);
1671 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1672 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1674 switch(dispIdMember) {
1675 case DISPID_READYSTATE:
1676 TRACE("DISPID_READYSTATE\n");
1678 if(!(wFlags & DISPATCH_PROPERTYGET))
1679 return E_INVALIDARG;
1681 V_VT(pVarResult) = VT_I4;
1682 V_I4(pVarResult) = This->readystate;
1683 return S_OK;
1686 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1687 pVarResult, pExcepInfo, puArgErr);
1690 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1692 HTMLDocument *This = DISPEX_THIS(iface);
1694 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1697 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1698 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1700 HTMLDocument *This = DISPEX_THIS(iface);
1702 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1705 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1707 HTMLDocument *This = DISPEX_THIS(iface);
1709 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1712 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1714 HTMLDocument *This = DISPEX_THIS(iface);
1716 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1719 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1721 HTMLDocument *This = DISPEX_THIS(iface);
1723 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1726 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1728 HTMLDocument *This = DISPEX_THIS(iface);
1730 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1733 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1735 HTMLDocument *This = DISPEX_THIS(iface);
1737 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1740 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1742 HTMLDocument *This = DISPEX_THIS(iface);
1744 return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1747 #undef DISPEX_THIS
1749 static const IDispatchExVtbl DocDispatchExVtbl = {
1750 DocDispatchEx_QueryInterface,
1751 DocDispatchEx_AddRef,
1752 DocDispatchEx_Release,
1753 DocDispatchEx_GetTypeInfoCount,
1754 DocDispatchEx_GetTypeInfo,
1755 DocDispatchEx_GetIDsOfNames,
1756 DocDispatchEx_Invoke,
1757 DocDispatchEx_GetDispID,
1758 DocDispatchEx_InvokeEx,
1759 DocDispatchEx_DeleteMemberByName,
1760 DocDispatchEx_DeleteMemberByDispID,
1761 DocDispatchEx_GetMemberProperties,
1762 DocDispatchEx_GetMemberName,
1763 DocDispatchEx_GetNextDispID,
1764 DocDispatchEx_GetNameSpaceParent
1767 static const tid_t HTMLDocument_iface_tids[] = {
1768 IHTMLDocument2_tid,
1769 IHTMLDocument3_tid,
1770 IHTMLDocument4_tid,
1771 IHTMLDocument5_tid,
1774 static dispex_static_data_t HTMLDocument_dispex = {
1775 NULL,
1776 DispHTMLDocument_tid,
1777 NULL,
1778 HTMLDocument_iface_tids
1781 static HRESULT alloc_doc(HTMLDocument **ret)
1783 HTMLDocument *doc;
1785 doc = heap_alloc_zero(sizeof(HTMLDocument));
1786 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1787 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1788 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1789 doc->ref = 1;
1790 doc->readystate = READYSTATE_UNINITIALIZED;
1791 doc->scriptmode = SCRIPTMODE_GECKO;
1793 list_init(&doc->bindings);
1794 list_init(&doc->script_hosts);
1795 list_init(&doc->selection_list);
1796 list_init(&doc->range_list);
1798 HTMLDocument_HTMLDocument3_Init(doc);
1799 HTMLDocument_HTMLDocument5_Init(doc);
1800 HTMLDocument_Persist_Init(doc);
1801 HTMLDocument_OleCmd_Init(doc);
1802 HTMLDocument_OleObj_Init(doc);
1803 HTMLDocument_View_Init(doc);
1804 HTMLDocument_Window_Init(doc);
1805 HTMLDocument_Service_Init(doc);
1806 HTMLDocument_Hlink_Init(doc);
1808 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1809 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
1810 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
1811 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
1813 init_dispex(&doc->dispex, (IUnknown*)HTMLDOC(doc), &HTMLDocument_dispex);
1815 *ret = doc;
1816 return S_OK;
1819 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocument **ret)
1821 HTMLDocument *doc;
1822 HRESULT hres;
1824 hres = alloc_doc(&doc);
1825 if(FAILED(hres))
1826 return hres;
1828 nsIDOMHTMLDocument_AddRef(nsdoc);
1829 doc->nsdoc = nsdoc;
1831 hres = HTMLWindow_Create(doc, NULL, &doc->window);
1832 if(FAILED(hres)) {
1833 IHTMLDocument_Release(HTMLDOC(doc));
1834 return hres;
1837 *ret = doc;
1838 return S_OK;
1841 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1843 HTMLDocument *doc;
1844 nsIDOMWindow *nswindow = NULL;
1845 HRESULT hres;
1847 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1849 hres = alloc_doc(&doc);
1850 if(FAILED(hres))
1851 return hres;
1853 hres = IHTMLDocument_QueryInterface(HTMLDOC(doc), riid, ppvObject);
1854 IHTMLDocument_Release(HTMLDOC(doc));
1855 if(FAILED(hres))
1856 return hres;
1858 doc->nscontainer = NSContainer_Create(doc, NULL);
1859 update_nsdocument(doc);
1861 if(doc->nscontainer) {
1862 nsresult nsres;
1864 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
1865 if(NS_FAILED(nsres))
1866 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1869 hres = HTMLWindow_Create(doc, nswindow, &doc->window);
1870 if(nswindow)
1871 nsIDOMWindow_Release(nswindow);
1872 if(FAILED(hres)) {
1873 IHTMLDocument_Release(HTMLDOC(doc));
1874 return hres;
1877 get_thread_hwnd();
1879 return S_OK;