push cc8bc80451cc24f4d7cf75168b569f0ebfe19547
[wine/hacks.git] / dlls / mshtml / htmldoc.c
blob0b95229329357a503df0ff33e96bde7f0f6f6ab2
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);
219 ConnectionPointContainer_Destroy(&This->cp_container);
221 if(This->nsdoc) {
222 remove_mutation_observer(This->nscontainer, This->nsdoc);
223 nsIDOMHTMLDocument_Release(This->nsdoc);
225 if(This->nscontainer)
226 NSContainer_Release(This->nscontainer);
228 heap_free(This);
231 return ref;
234 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
236 HTMLDocument *This = HTMLDOC_THIS(iface);
238 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
241 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
242 LCID lcid, ITypeInfo **ppTInfo)
244 HTMLDocument *This = HTMLDOC_THIS(iface);
246 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
249 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
250 LPOLESTR *rgszNames, UINT cNames,
251 LCID lcid, DISPID *rgDispId)
253 HTMLDocument *This = HTMLDOC_THIS(iface);
255 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
258 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
259 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
260 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
262 HTMLDocument *This = HTMLDOC_THIS(iface);
264 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
265 pVarResult, pExcepInfo, puArgErr);
268 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
270 HTMLDocument *This = HTMLDOC_THIS(iface);
272 TRACE("(%p)->(%p)\n", This, p);
274 *p = (IDispatch*)HTMLWINDOW2(This->window);
275 IDispatch_AddRef(*p);
276 return S_OK;
279 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
281 HTMLDocument *This = HTMLDOC_THIS(iface);
282 nsIDOMElement *nselem = NULL;
283 nsresult nsres;
285 TRACE("(%p)->(%p)\n", This, p);
287 if(!This->nsdoc) {
288 WARN("NULL nsdoc\n");
289 return E_UNEXPECTED;
292 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
293 if(NS_FAILED(nsres)) {
294 ERR("GetDocumentElement failed: %08x\n", nsres);
295 return E_FAIL;
298 if(nselem) {
299 *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE), TRUE);
300 nsIDOMElement_Release(nselem);
301 }else {
302 *p = NULL;
305 return S_OK;
308 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
310 HTMLDocument *This = HTMLDOC_THIS(iface);
311 nsIDOMHTMLElement *nsbody = NULL;
312 HTMLDOMNode *node;
313 nsresult nsres;
315 TRACE("(%p)->(%p)\n", This, p);
317 if(!This->nsdoc) {
318 WARN("NULL nsdoc\n");
319 return E_UNEXPECTED;
322 nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody);
323 if(NS_FAILED(nsres)) {
324 TRACE("Could not get body: %08x\n", nsres);
325 return E_UNEXPECTED;
328 if(nsbody) {
329 node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
330 nsIDOMHTMLElement_Release(nsbody);
332 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
333 }else {
334 *p = NULL;
337 TRACE("*p = %p\n", *p);
338 return S_OK;
341 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
343 HTMLDocument *This = HTMLDOC_THIS(iface);
344 FIXME("(%p)->(%p)\n", This, p);
345 return E_NOTIMPL;
348 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
350 HTMLDocument *This = HTMLDOC_THIS(iface);
351 nsIDOMHTMLCollection *nscoll = NULL;
352 nsresult nsres;
354 TRACE("(%p)->(%p)\n", This, p);
356 if(!p)
357 return E_INVALIDARG;
359 *p = NULL;
361 if(!This->nsdoc) {
362 WARN("NULL nsdoc\n");
363 return E_UNEXPECTED;
366 nsres = nsIDOMHTMLDocument_GetImages(This->nsdoc, &nscoll);
367 if(NS_FAILED(nsres)) {
368 ERR("GetImages failed: %08x\n", nsres);
369 return E_FAIL;
372 if(nscoll) {
373 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
374 nsIDOMElement_Release(nscoll);
377 return S_OK;
380 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
382 HTMLDocument *This = HTMLDOC_THIS(iface);
383 nsIDOMHTMLCollection *nscoll = NULL;
384 nsresult nsres;
386 TRACE("(%p)->(%p)\n", This, p);
388 if(!p)
389 return E_INVALIDARG;
391 *p = NULL;
393 if(!This->nsdoc) {
394 WARN("NULL nsdoc\n");
395 return E_UNEXPECTED;
398 nsres = nsIDOMHTMLDocument_GetApplets(This->nsdoc, &nscoll);
399 if(NS_FAILED(nsres)) {
400 ERR("GetApplets failed: %08x\n", nsres);
401 return E_FAIL;
404 if(nscoll) {
405 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
406 nsIDOMElement_Release(nscoll);
409 return S_OK;
412 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
414 HTMLDocument *This = HTMLDOC_THIS(iface);
415 nsIDOMHTMLCollection *nscoll = NULL;
416 nsresult nsres;
418 TRACE("(%p)->(%p)\n", This, p);
420 if(!p)
421 return E_INVALIDARG;
423 *p = NULL;
425 if(!This->nsdoc) {
426 WARN("NULL nsdoc\n");
427 return E_UNEXPECTED;
430 nsres = nsIDOMHTMLDocument_GetLinks(This->nsdoc, &nscoll);
431 if(NS_FAILED(nsres)) {
432 ERR("GetLinks failed: %08x\n", nsres);
433 return E_FAIL;
436 if(nscoll) {
437 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
438 nsIDOMElement_Release(nscoll);
441 return S_OK;
444 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
446 HTMLDocument *This = HTMLDOC_THIS(iface);
447 nsIDOMHTMLCollection *nscoll = NULL;
448 nsresult nsres;
450 TRACE("(%p)->(%p)\n", This, p);
452 if(!p)
453 return E_INVALIDARG;
455 *p = NULL;
457 if(!This->nsdoc) {
458 WARN("NULL nsdoc\n");
459 return E_UNEXPECTED;
462 nsres = nsIDOMHTMLDocument_GetForms(This->nsdoc, &nscoll);
463 if(NS_FAILED(nsres)) {
464 ERR("GetForms failed: %08x\n", nsres);
465 return E_FAIL;
468 if(nscoll) {
469 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
470 nsIDOMElement_Release(nscoll);
473 return S_OK;
476 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
478 HTMLDocument *This = HTMLDOC_THIS(iface);
479 nsIDOMHTMLCollection *nscoll = NULL;
480 nsresult nsres;
482 TRACE("(%p)->(%p)\n", This, p);
484 if(!p)
485 return E_INVALIDARG;
487 *p = NULL;
489 if(!This->nsdoc) {
490 WARN("NULL nsdoc\n");
491 return E_UNEXPECTED;
494 nsres = nsIDOMHTMLDocument_GetAnchors(This->nsdoc, &nscoll);
495 if(NS_FAILED(nsres)) {
496 ERR("GetAnchors failed: %08x\n", nsres);
497 return E_FAIL;
500 if(nscoll) {
501 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
502 nsIDOMElement_Release(nscoll);
505 return S_OK;
508 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
510 HTMLDocument *This = HTMLDOC_THIS(iface);
511 nsAString nsstr;
512 nsresult nsres;
514 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
516 if(!This->nsdoc) {
517 WARN("NULL nsdoc\n");
518 return E_UNEXPECTED;
521 nsAString_Init(&nsstr, v);
522 nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr);
523 nsAString_Finish(&nsstr);
524 if(NS_FAILED(nsres))
525 ERR("SetTitle failed: %08x\n", nsres);
527 return S_OK;
530 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
532 HTMLDocument *This = HTMLDOC_THIS(iface);
533 const PRUnichar *ret;
534 nsAString nsstr;
535 nsresult nsres;
537 TRACE("(%p)->(%p)\n", This, p);
539 if(!This->nsdoc) {
540 WARN("NULL nsdoc\n");
541 return E_UNEXPECTED;
545 nsAString_Init(&nsstr, NULL);
546 nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
547 if (NS_SUCCEEDED(nsres)) {
548 nsAString_GetData(&nsstr, &ret);
549 *p = SysAllocString(ret);
551 nsAString_Finish(&nsstr);
553 if(NS_FAILED(nsres)) {
554 ERR("GetTitle failed: %08x\n", nsres);
555 return E_FAIL;
558 return S_OK;
561 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
563 HTMLDocument *This = HTMLDOC_THIS(iface);
564 FIXME("(%p)->(%p)\n", This, p);
565 return E_NOTIMPL;
568 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
570 HTMLDocument *This = HTMLDOC_THIS(iface);
571 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
572 return E_NOTIMPL;
575 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
577 HTMLDocument *This = HTMLDOC_THIS(iface);
578 static WCHAR szOff[] = {'O','f','f',0};
579 FIXME("(%p)->(%p) always returning Off\n", This, p);
581 if(!p)
582 return E_INVALIDARG;
584 *p = SysAllocString(szOff);
586 return S_OK;
589 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
591 HTMLDocument *This = HTMLDOC_THIS(iface);
592 nsISelection *nsselection = NULL;
594 TRACE("(%p)->(%p)\n", This, p);
596 if(This->nscontainer) {
597 nsIDOMWindow *dom_window = NULL;
599 nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
600 if(dom_window) {
601 nsIDOMWindow_GetSelection(dom_window, &nsselection);
602 nsIDOMWindow_Release(dom_window);
606 *p = HTMLSelectionObject_Create(This, nsselection);
607 return S_OK;
610 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
612 HTMLDocument *This = HTMLDOC_THIS(iface);
614 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
615 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
616 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
617 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
618 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
620 static const LPCWSTR readystate_str[] = {
621 wszUninitialized,
622 wszLoading,
623 wszLoaded,
624 wszInteractive,
625 wszComplete
628 TRACE("(%p)->(%p)\n", iface, p);
630 if(!p)
631 return E_POINTER;
633 *p = SysAllocString(readystate_str[This->readystate]);
634 return S_OK;
637 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
639 HTMLDocument *This = HTMLDOC_THIS(iface);
640 FIXME("(%p)->(%p)\n", This, p);
641 return E_NOTIMPL;
644 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
646 HTMLDocument *This = HTMLDOC_THIS(iface);
647 FIXME("(%p)->(%p)\n", This, p);
648 return E_NOTIMPL;
651 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
653 HTMLDocument *This = HTMLDOC_THIS(iface);
654 FIXME("(%p)->(%p)\n", This, p);
655 return E_NOTIMPL;
658 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
660 HTMLDocument *This = HTMLDOC_THIS(iface);
661 FIXME("(%p)\n", This);
662 return E_NOTIMPL;
665 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
667 HTMLDocument *This = HTMLDOC_THIS(iface);
668 FIXME("(%p)->(%p)\n", This, p);
669 return E_NOTIMPL;
672 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
674 HTMLDocument *This = HTMLDOC_THIS(iface);
675 FIXME("(%p)\n", This);
676 return E_NOTIMPL;
679 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
681 HTMLDocument *This = HTMLDOC_THIS(iface);
682 FIXME("(%p)->(%p)\n", This, p);
683 return E_NOTIMPL;
686 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
688 HTMLDocument *This = HTMLDOC_THIS(iface);
689 FIXME("(%p)\n", This);
690 return E_NOTIMPL;
693 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
695 HTMLDocument *This = HTMLDOC_THIS(iface);
696 FIXME("(%p)->(%p)\n", This, p);
697 return E_NOTIMPL;
700 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
702 HTMLDocument *This = HTMLDOC_THIS(iface);
703 FIXME("(%p)->()\n", This);
704 return E_NOTIMPL;
707 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
709 HTMLDocument *This = HTMLDOC_THIS(iface);
710 FIXME("(%p)->(%p)\n", This, p);
711 return E_NOTIMPL;
714 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
716 HTMLDocument *This = HTMLDOC_THIS(iface);
717 FIXME("(%p)\n", This);
718 return E_NOTIMPL;
721 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
723 HTMLDocument *This = HTMLDOC_THIS(iface);
724 FIXME("(%p)->(%p)\n", This, p);
725 return E_NOTIMPL;
728 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
730 HTMLDocument *This = HTMLDOC_THIS(iface);
731 FIXME("(%p)->(%p)\n", This, p);
732 return E_NOTIMPL;
735 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
737 HTMLDocument *This = HTMLDOC_THIS(iface);
739 TRACE("(%p)->(%p)\n", This, p);
741 if(This->location)
742 IHTMLLocation_AddRef(HTMLLOCATION(This->location));
743 else
744 This->location = HTMLLocation_Create(This);
746 *p = HTMLLOCATION(This->location);
747 return S_OK;
750 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
752 HTMLDocument *This = HTMLDOC_THIS(iface);
753 FIXME("(%p)->(%p)\n", This, p);
754 return E_NOTIMPL;
757 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
759 HTMLDocument *This = HTMLDOC_THIS(iface);
760 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
761 return E_NOTIMPL;
764 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
766 HTMLDocument *This = HTMLDOC_THIS(iface);
768 static const WCHAR about_blank_url[] =
769 {'a','b','o','u','t',':','b','l','a','n','k',0};
771 TRACE("(%p)->(%p)\n", iface, p);
773 *p = SysAllocString(This->url ? This->url : about_blank_url);
774 return S_OK;
777 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
779 HTMLDocument *This = HTMLDOC_THIS(iface);
780 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
781 return E_NOTIMPL;
784 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
786 HTMLDocument *This = HTMLDOC_THIS(iface);
787 FIXME("(%p)->(%p)\n", This, p);
788 return E_NOTIMPL;
791 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
793 HTMLDocument *This = HTMLDOC_THIS(iface);
794 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
795 return E_NOTIMPL;
798 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
800 HTMLDocument *This = HTMLDOC_THIS(iface);
801 FIXME("(%p)->(%p)\n", This, p);
802 return E_NOTIMPL;
805 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
807 HTMLDocument *This = HTMLDOC_THIS(iface);
808 FIXME("(%p)->(%x)\n", This, v);
809 return E_NOTIMPL;
812 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
814 HTMLDocument *This = HTMLDOC_THIS(iface);
815 FIXME("(%p)->(%p)\n", This, p);
816 return E_NOTIMPL;
819 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
821 HTMLDocument *This = HTMLDOC_THIS(iface);
822 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
823 return E_NOTIMPL;
826 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
828 HTMLDocument *This = HTMLDOC_THIS(iface);
829 FIXME("(%p)->(%p)\n", This, p);
830 return E_NOTIMPL;
833 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
835 HTMLDocument *This = HTMLDOC_THIS(iface);
836 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
837 return E_NOTIMPL;
840 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
842 HTMLDocument *This = HTMLDOC_THIS(iface);
843 FIXME("(%p)->(%p)\n", This, p);
844 return E_NOTIMPL;
847 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
849 HTMLDocument *This = HTMLDOC_THIS(iface);
850 FIXME("(%p)->(%p)\n", This, p);
851 return E_NOTIMPL;
854 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
856 HTMLDocument *This = HTMLDOC_THIS(iface);
857 FIXME("(%p)->(%p)\n", This, p);
858 return E_NOTIMPL;
861 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
863 HTMLDocument *This = HTMLDOC_THIS(iface);
864 FIXME("(%p)->(%p)\n", This, p);
865 return E_NOTIMPL;
868 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
870 HTMLDocument *This = HTMLDOC_THIS(iface);
871 FIXME("(%p)->(%p)\n", This, p);
872 return E_NOTIMPL;
875 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
877 HTMLDocument *This = HTMLDOC_THIS(iface);
878 FIXME("(%p)->(%p)\n", This, p);
879 return E_NOTIMPL;
882 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
884 HTMLDocument *This = HTMLDOC_THIS(iface);
885 FIXME("(%p)->(%p)\n", This, p);
886 return E_NOTIMPL;
889 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
891 HTMLDocument *This = HTMLDOC_THIS(iface);
892 FIXME("(%p)->(%p)\n", This, p);
893 return E_NOTIMPL;
896 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
898 HTMLDocument *This = HTMLDOC_THIS(iface);
899 FIXME("(%p)->(%p)\n", This, p);
900 return E_NOTIMPL;
903 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
905 HTMLDocument *This = HTMLDOC_THIS(iface);
906 nsAString nsstr;
907 VARIANT *var;
908 ULONG i;
909 nsresult nsres;
910 HRESULT hres;
912 TRACE("(%p)->(%p)\n", iface, psarray);
914 if(!This->nsdoc) {
915 WARN("NULL nsdoc\n");
916 return E_UNEXPECTED;
919 if(psarray->cDims != 1) {
920 FIXME("cDims=%d\n", psarray->cDims);
921 return E_INVALIDARG;
924 hres = SafeArrayAccessData(psarray, (void**)&var);
925 if(FAILED(hres)) {
926 WARN("SafeArrayAccessData failed: %08x\n", hres);
927 return hres;
930 nsAString_Init(&nsstr, NULL);
932 for(i=0; i < psarray->rgsabound[0].cElements; i++) {
933 if(V_VT(var+i) == VT_BSTR) {
934 nsAString_SetData(&nsstr, V_BSTR(var+i));
935 nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
936 if(NS_FAILED(nsres))
937 ERR("Write failed: %08x\n", nsres);
938 }else {
939 FIXME("vt=%d\n", V_VT(var+i));
943 nsAString_Finish(&nsstr);
944 SafeArrayUnaccessData(psarray);
946 return S_OK;
949 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
951 HTMLDocument *This = HTMLDOC_THIS(iface);
952 FIXME("(%p)->(%p)\n", This, psarray);
953 return E_NOTIMPL;
956 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
957 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
959 HTMLDocument *This = HTMLDOC_THIS(iface);
960 nsresult nsres;
962 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
964 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
965 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
967 if(!This->nsdoc) {
968 ERR("!nsdoc\n");
969 return E_NOTIMPL;
972 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
973 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
974 FIXME("unsupported args\n");
976 nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
977 if(NS_FAILED(nsres)) {
978 ERR("Open failed: %08x\n", nsres);
979 return E_FAIL;
982 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
983 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
984 return S_OK;
987 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
989 HTMLDocument *This = HTMLDOC_THIS(iface);
990 nsresult nsres;
992 TRACE("(%p)\n", This);
994 if(!This->nsdoc) {
995 ERR("!nsdoc\n");
996 return E_NOTIMPL;
999 nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
1000 if(NS_FAILED(nsres)) {
1001 ERR("Close failed: %08x\n", nsres);
1002 return E_FAIL;
1005 return S_OK;
1008 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1010 HTMLDocument *This = HTMLDOC_THIS(iface);
1011 FIXME("(%p)\n", This);
1012 return E_NOTIMPL;
1015 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1016 VARIANT_BOOL *pfRet)
1018 HTMLDocument *This = HTMLDOC_THIS(iface);
1019 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1020 return E_NOTIMPL;
1023 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1024 VARIANT_BOOL *pfRet)
1026 HTMLDocument *This = HTMLDOC_THIS(iface);
1027 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1028 return E_NOTIMPL;
1031 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1032 VARIANT_BOOL *pfRet)
1034 HTMLDocument *This = HTMLDOC_THIS(iface);
1035 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1036 return E_NOTIMPL;
1039 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1040 VARIANT_BOOL *pfRet)
1042 HTMLDocument *This = HTMLDOC_THIS(iface);
1043 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1044 return E_NOTIMPL;
1047 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1048 BSTR *pfRet)
1050 HTMLDocument *This = HTMLDOC_THIS(iface);
1051 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1052 return E_NOTIMPL;
1055 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1056 VARIANT *pfRet)
1058 HTMLDocument *This = HTMLDOC_THIS(iface);
1059 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1060 return E_NOTIMPL;
1063 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1064 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1066 HTMLDocument *This = HTMLDOC_THIS(iface);
1067 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
1068 return E_NOTIMPL;
1071 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1072 VARIANT_BOOL *pfRet)
1074 HTMLDocument *This = HTMLDOC_THIS(iface);
1075 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1076 return E_NOTIMPL;
1079 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1080 IHTMLElement **newElem)
1082 HTMLDocument *This = HTMLDOC_THIS(iface);
1083 nsIDOMElement *nselem;
1084 HTMLElement *elem;
1085 nsAString tag_str;
1086 nsresult nsres;
1088 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1090 if(!This->nsdoc) {
1091 WARN("NULL nsdoc\n");
1092 return E_UNEXPECTED;
1095 nsAString_Init(&tag_str, eTag);
1096 nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
1097 nsAString_Finish(&tag_str);
1098 if(NS_FAILED(nsres)) {
1099 ERR("CreateElement failed: %08x\n", nsres);
1100 return E_FAIL;
1103 elem = HTMLElement_Create(This, (nsIDOMNode*)nselem, TRUE);
1104 nsIDOMElement_Release(nselem);
1106 *newElem = HTMLELEM(elem);
1107 IHTMLElement_AddRef(HTMLELEM(elem));
1108 return S_OK;
1111 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1113 HTMLDocument *This = HTMLDOC_THIS(iface);
1114 FIXME("(%p)\n", This);
1115 return E_NOTIMPL;
1118 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1120 HTMLDocument *This = HTMLDOC_THIS(iface);
1121 FIXME("(%p)->(%p)\n", This, p);
1122 return E_NOTIMPL;
1125 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1127 HTMLDocument *This = HTMLDOC_THIS(iface);
1128 FIXME("(%p)\n", This);
1129 return E_NOTIMPL;
1132 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1134 HTMLDocument *This = HTMLDOC_THIS(iface);
1135 FIXME("(%p)->(%p)\n", This, p);
1136 return E_NOTIMPL;
1139 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1141 HTMLDocument *This = HTMLDOC_THIS(iface);
1142 FIXME("(%p)\n", This);
1143 return E_NOTIMPL;
1146 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1148 HTMLDocument *This = HTMLDOC_THIS(iface);
1149 FIXME("(%p)->(%p)\n", This, p);
1150 return E_NOTIMPL;
1153 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1155 HTMLDocument *This = HTMLDOC_THIS(iface);
1157 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1159 return set_doc_event(This, EVENTID_KEYUP, &v);
1162 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1164 HTMLDocument *This = HTMLDOC_THIS(iface);
1166 TRACE("(%p)->(%p)\n", This, p);
1168 return get_doc_event(This, EVENTID_KEYUP, p);
1171 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1173 HTMLDocument *This = HTMLDOC_THIS(iface);
1175 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1177 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1180 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1182 HTMLDocument *This = HTMLDOC_THIS(iface);
1184 TRACE("(%p)->(%p)\n", This, p);
1186 return get_doc_event(This, EVENTID_KEYDOWN, p);
1189 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1191 HTMLDocument *This = HTMLDOC_THIS(iface);
1192 FIXME("(%p)\n", This);
1193 return E_NOTIMPL;
1196 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1198 HTMLDocument *This = HTMLDOC_THIS(iface);
1199 FIXME("(%p)->(%p)\n", This, p);
1200 return E_NOTIMPL;
1203 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1205 HTMLDocument *This = HTMLDOC_THIS(iface);
1206 FIXME("(%p)\n", This);
1207 return E_NOTIMPL;
1210 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1212 HTMLDocument *This = HTMLDOC_THIS(iface);
1213 FIXME("(%p)->(%p)\n", This, p);
1214 return E_NOTIMPL;
1217 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1219 HTMLDocument *This = HTMLDOC_THIS(iface);
1220 FIXME("(%p)\n", This);
1221 return E_NOTIMPL;
1224 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1226 HTMLDocument *This = HTMLDOC_THIS(iface);
1227 FIXME("(%p)->(%p)\n", This, p);
1228 return E_NOTIMPL;
1231 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1233 HTMLDocument *This = HTMLDOC_THIS(iface);
1234 FIXME("(%p)\n", This);
1235 return E_NOTIMPL;
1238 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1240 HTMLDocument *This = HTMLDOC_THIS(iface);
1241 FIXME("(%p)->(%p)\n", This, p);
1242 return E_NOTIMPL;
1245 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1247 HTMLDocument *This = HTMLDOC_THIS(iface);
1248 FIXME("(%p)\n", This);
1249 return E_NOTIMPL;
1252 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1254 HTMLDocument *This = HTMLDOC_THIS(iface);
1255 FIXME("(%p)->(%p)\n", This, p);
1256 return E_NOTIMPL;
1259 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1261 HTMLDocument *This = HTMLDOC_THIS(iface);
1263 TRACE("(%p)\n", This);
1265 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1268 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1270 HTMLDocument *This = HTMLDOC_THIS(iface);
1272 TRACE("(%p)->(%p)\n", This, p);
1274 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1277 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1279 HTMLDocument *This = HTMLDOC_THIS(iface);
1280 FIXME("(%p)\n", This);
1281 return E_NOTIMPL;
1284 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1286 HTMLDocument *This = HTMLDOC_THIS(iface);
1287 FIXME("(%p)->(%p)\n", This, p);
1288 return E_NOTIMPL;
1291 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1293 HTMLDocument *This = HTMLDOC_THIS(iface);
1294 FIXME("(%p)\n", This);
1295 return E_NOTIMPL;
1298 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1300 HTMLDocument *This = HTMLDOC_THIS(iface);
1301 FIXME("(%p)->(%p)\n", This, p);
1302 return E_NOTIMPL;
1305 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1307 HTMLDocument *This = HTMLDOC_THIS(iface);
1308 FIXME("(%p)\n", This);
1309 return E_NOTIMPL;
1312 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1314 HTMLDocument *This = HTMLDOC_THIS(iface);
1315 FIXME("(%p)->(%p)\n", This, p);
1316 return E_NOTIMPL;
1319 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1321 HTMLDocument *This = HTMLDOC_THIS(iface);
1322 FIXME("(%p)\n", This);
1323 return E_NOTIMPL;
1326 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1328 HTMLDocument *This = HTMLDOC_THIS(iface);
1329 FIXME("(%p)->(%p)\n", This, p);
1330 return E_NOTIMPL;
1333 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1335 HTMLDocument *This = HTMLDOC_THIS(iface);
1337 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1339 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1342 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1344 HTMLDocument *This = HTMLDOC_THIS(iface);
1346 TRACE("(%p)->(%p)\n", This, p);
1348 return get_doc_event(This, EVENTID_DRAGSTART, p);
1351 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1353 HTMLDocument *This = HTMLDOC_THIS(iface);
1355 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1357 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1360 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1362 HTMLDocument *This = HTMLDOC_THIS(iface);
1364 TRACE("(%p)->(%p)\n", This, p);
1366 return get_doc_event(This, EVENTID_SELECTSTART, p);
1369 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1370 IHTMLElement **elementHit)
1372 HTMLDocument *This = HTMLDOC_THIS(iface);
1373 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1374 return E_NOTIMPL;
1377 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1379 HTMLDocument *This = HTMLDOC_THIS(iface);
1381 TRACE("(%p)->(%p)\n", This, p);
1383 *p = HTMLWINDOW2(This->window);
1384 IHTMLWindow2_AddRef(*p);
1385 return S_OK;
1388 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1389 IHTMLStyleSheetsCollection **p)
1391 HTMLDocument *This = HTMLDOC_THIS(iface);
1392 nsIDOMStyleSheetList *nsstylelist;
1393 nsIDOMDocumentStyle *nsdocstyle;
1394 nsresult nsres;
1396 TRACE("(%p)->(%p)\n", This, p);
1398 *p = NULL;
1400 if(!This->nsdoc) {
1401 WARN("NULL nsdoc\n");
1402 return E_UNEXPECTED;
1405 nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1406 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1407 nsIDOMDocumentStyle_Release(nsdocstyle);
1408 if(NS_FAILED(nsres)) {
1409 ERR("GetStyleSheets failed: %08x\n", nsres);
1410 return E_FAIL;
1413 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1414 nsIDOMDocumentStyle_Release(nsstylelist);
1416 return S_OK;
1419 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1421 HTMLDocument *This = HTMLDOC_THIS(iface);
1422 FIXME("(%p)\n", This);
1423 return E_NOTIMPL;
1426 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1428 HTMLDocument *This = HTMLDOC_THIS(iface);
1429 FIXME("(%p)->(%p)\n", This, p);
1430 return E_NOTIMPL;
1433 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1435 HTMLDocument *This = HTMLDOC_THIS(iface);
1436 FIXME("(%p)\n", This);
1437 return E_NOTIMPL;
1440 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1442 HTMLDocument *This = HTMLDOC_THIS(iface);
1443 FIXME("(%p)->(%p)\n", This, p);
1444 return E_NOTIMPL;
1447 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1449 HTMLDocument *This = HTMLDOC_THIS(iface);
1450 FIXME("(%p)->(%p)\n", This, String);
1451 return E_NOTIMPL;
1454 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1455 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1457 HTMLDocument *This = HTMLDOC_THIS(iface);
1459 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1461 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1462 return S_OK;
1465 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1466 HTMLDocument_QueryInterface,
1467 HTMLDocument_AddRef,
1468 HTMLDocument_Release,
1469 HTMLDocument_GetTypeInfoCount,
1470 HTMLDocument_GetTypeInfo,
1471 HTMLDocument_GetIDsOfNames,
1472 HTMLDocument_Invoke,
1473 HTMLDocument_get_Script,
1474 HTMLDocument_get_all,
1475 HTMLDocument_get_body,
1476 HTMLDocument_get_activeElement,
1477 HTMLDocument_get_images,
1478 HTMLDocument_get_applets,
1479 HTMLDocument_get_links,
1480 HTMLDocument_get_forms,
1481 HTMLDocument_get_anchors,
1482 HTMLDocument_put_title,
1483 HTMLDocument_get_title,
1484 HTMLDocument_get_scripts,
1485 HTMLDocument_put_designMode,
1486 HTMLDocument_get_designMode,
1487 HTMLDocument_get_selection,
1488 HTMLDocument_get_readyState,
1489 HTMLDocument_get_frames,
1490 HTMLDocument_get_embeds,
1491 HTMLDocument_get_plugins,
1492 HTMLDocument_put_alinkColor,
1493 HTMLDocument_get_alinkColor,
1494 HTMLDocument_put_bgColor,
1495 HTMLDocument_get_bgColor,
1496 HTMLDocument_put_fgColor,
1497 HTMLDocument_get_fgColor,
1498 HTMLDocument_put_linkColor,
1499 HTMLDocument_get_linkColor,
1500 HTMLDocument_put_vlinkColor,
1501 HTMLDocument_get_vlinkColor,
1502 HTMLDocument_get_referrer,
1503 HTMLDocument_get_location,
1504 HTMLDocument_get_lastModified,
1505 HTMLDocument_put_URL,
1506 HTMLDocument_get_URL,
1507 HTMLDocument_put_domain,
1508 HTMLDocument_get_domain,
1509 HTMLDocument_put_cookie,
1510 HTMLDocument_get_cookie,
1511 HTMLDocument_put_expando,
1512 HTMLDocument_get_expando,
1513 HTMLDocument_put_charset,
1514 HTMLDocument_get_charset,
1515 HTMLDocument_put_defaultCharset,
1516 HTMLDocument_get_defaultCharset,
1517 HTMLDocument_get_mimeType,
1518 HTMLDocument_get_fileSize,
1519 HTMLDocument_get_fileCreatedDate,
1520 HTMLDocument_get_fileModifiedDate,
1521 HTMLDocument_get_fileUpdatedDate,
1522 HTMLDocument_get_security,
1523 HTMLDocument_get_protocol,
1524 HTMLDocument_get_nameProp,
1525 HTMLDocument_write,
1526 HTMLDocument_writeln,
1527 HTMLDocument_open,
1528 HTMLDocument_close,
1529 HTMLDocument_clear,
1530 HTMLDocument_queryCommandSupported,
1531 HTMLDocument_queryCommandEnabled,
1532 HTMLDocument_queryCommandState,
1533 HTMLDocument_queryCommandIndeterm,
1534 HTMLDocument_queryCommandText,
1535 HTMLDocument_queryCommandValue,
1536 HTMLDocument_execCommand,
1537 HTMLDocument_execCommandShowHelp,
1538 HTMLDocument_createElement,
1539 HTMLDocument_put_onhelp,
1540 HTMLDocument_get_onhelp,
1541 HTMLDocument_put_onclick,
1542 HTMLDocument_get_onclick,
1543 HTMLDocument_put_ondblclick,
1544 HTMLDocument_get_ondblclick,
1545 HTMLDocument_put_onkeyup,
1546 HTMLDocument_get_onkeyup,
1547 HTMLDocument_put_onkeydown,
1548 HTMLDocument_get_onkeydown,
1549 HTMLDocument_put_onkeypress,
1550 HTMLDocument_get_onkeypress,
1551 HTMLDocument_put_onmouseup,
1552 HTMLDocument_get_onmouseup,
1553 HTMLDocument_put_onmousedown,
1554 HTMLDocument_get_onmousedown,
1555 HTMLDocument_put_onmousemove,
1556 HTMLDocument_get_onmousemove,
1557 HTMLDocument_put_onmouseout,
1558 HTMLDocument_get_onmouseout,
1559 HTMLDocument_put_onmouseover,
1560 HTMLDocument_get_onmouseover,
1561 HTMLDocument_put_onreadystatechange,
1562 HTMLDocument_get_onreadystatechange,
1563 HTMLDocument_put_onafterupdate,
1564 HTMLDocument_get_onafterupdate,
1565 HTMLDocument_put_onrowexit,
1566 HTMLDocument_get_onrowexit,
1567 HTMLDocument_put_onrowenter,
1568 HTMLDocument_get_onrowenter,
1569 HTMLDocument_put_ondragstart,
1570 HTMLDocument_get_ondragstart,
1571 HTMLDocument_put_onselectstart,
1572 HTMLDocument_get_onselectstart,
1573 HTMLDocument_elementFromPoint,
1574 HTMLDocument_get_parentWindow,
1575 HTMLDocument_get_styleSheets,
1576 HTMLDocument_put_onbeforeupdate,
1577 HTMLDocument_get_onbeforeupdate,
1578 HTMLDocument_put_onerrorupdate,
1579 HTMLDocument_get_onerrorupdate,
1580 HTMLDocument_toString,
1581 HTMLDocument_createStyleSheet
1584 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1586 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1588 HTMLDocument *This = SUPPINFO_THIS(iface);
1589 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1592 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1594 HTMLDocument *This = SUPPINFO_THIS(iface);
1595 return IHTMLDocument_AddRef(HTMLDOC(This));
1598 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1600 HTMLDocument *This = SUPPINFO_THIS(iface);
1601 return IHTMLDocument_Release(HTMLDOC(This));
1604 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1606 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1607 return S_FALSE;
1610 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1611 SupportErrorInfo_QueryInterface,
1612 SupportErrorInfo_AddRef,
1613 SupportErrorInfo_Release,
1614 SupportErrorInfo_InterfaceSupportsErrorInfo
1617 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1619 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1621 HTMLDocument *This = DISPEX_THIS(iface);
1623 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1626 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1628 HTMLDocument *This = DISPEX_THIS(iface);
1630 return IHTMLDocument2_AddRef(HTMLDOC(This));
1633 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1635 HTMLDocument *This = DISPEX_THIS(iface);
1637 return IHTMLDocument2_Release(HTMLDOC(This));
1640 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1642 HTMLDocument *This = DISPEX_THIS(iface);
1644 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1647 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1648 LCID lcid, ITypeInfo **ppTInfo)
1650 HTMLDocument *This = DISPEX_THIS(iface);
1652 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1655 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1656 LPOLESTR *rgszNames, UINT cNames,
1657 LCID lcid, DISPID *rgDispId)
1659 HTMLDocument *This = DISPEX_THIS(iface);
1661 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1664 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1665 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1666 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1668 HTMLDocument *This = DISPEX_THIS(iface);
1670 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1671 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1673 switch(dispIdMember) {
1674 case DISPID_READYSTATE:
1675 TRACE("DISPID_READYSTATE\n");
1677 if(!(wFlags & DISPATCH_PROPERTYGET))
1678 return E_INVALIDARG;
1680 V_VT(pVarResult) = VT_I4;
1681 V_I4(pVarResult) = This->readystate;
1682 return S_OK;
1685 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1686 pVarResult, pExcepInfo, puArgErr);
1689 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1691 HTMLDocument *This = DISPEX_THIS(iface);
1693 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1696 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1697 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1699 HTMLDocument *This = DISPEX_THIS(iface);
1701 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1704 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1706 HTMLDocument *This = DISPEX_THIS(iface);
1708 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1711 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1713 HTMLDocument *This = DISPEX_THIS(iface);
1715 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1718 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1720 HTMLDocument *This = DISPEX_THIS(iface);
1722 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1725 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1727 HTMLDocument *This = DISPEX_THIS(iface);
1729 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1732 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1734 HTMLDocument *This = DISPEX_THIS(iface);
1736 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1739 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1741 HTMLDocument *This = DISPEX_THIS(iface);
1743 return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1746 #undef DISPEX_THIS
1748 static const IDispatchExVtbl DocDispatchExVtbl = {
1749 DocDispatchEx_QueryInterface,
1750 DocDispatchEx_AddRef,
1751 DocDispatchEx_Release,
1752 DocDispatchEx_GetTypeInfoCount,
1753 DocDispatchEx_GetTypeInfo,
1754 DocDispatchEx_GetIDsOfNames,
1755 DocDispatchEx_Invoke,
1756 DocDispatchEx_GetDispID,
1757 DocDispatchEx_InvokeEx,
1758 DocDispatchEx_DeleteMemberByName,
1759 DocDispatchEx_DeleteMemberByDispID,
1760 DocDispatchEx_GetMemberProperties,
1761 DocDispatchEx_GetMemberName,
1762 DocDispatchEx_GetNextDispID,
1763 DocDispatchEx_GetNameSpaceParent
1766 static const tid_t HTMLDocument_iface_tids[] = {
1767 IHTMLDocument2_tid,
1768 IHTMLDocument3_tid,
1769 IHTMLDocument4_tid,
1770 IHTMLDocument5_tid,
1773 static dispex_static_data_t HTMLDocument_dispex = {
1774 NULL,
1775 DispHTMLDocument_tid,
1776 NULL,
1777 HTMLDocument_iface_tids
1780 static HRESULT alloc_doc(HTMLDocument **ret)
1782 HTMLDocument *doc;
1784 doc = heap_alloc_zero(sizeof(HTMLDocument));
1785 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1786 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1787 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1788 doc->ref = 1;
1789 doc->readystate = READYSTATE_UNINITIALIZED;
1790 doc->scriptmode = SCRIPTMODE_GECKO;
1792 list_init(&doc->bindings);
1793 list_init(&doc->script_hosts);
1794 list_init(&doc->selection_list);
1795 list_init(&doc->range_list);
1797 HTMLDocument_HTMLDocument3_Init(doc);
1798 HTMLDocument_HTMLDocument5_Init(doc);
1799 HTMLDocument_Persist_Init(doc);
1800 HTMLDocument_OleCmd_Init(doc);
1801 HTMLDocument_OleObj_Init(doc);
1802 HTMLDocument_View_Init(doc);
1803 HTMLDocument_Window_Init(doc);
1804 HTMLDocument_Service_Init(doc);
1805 HTMLDocument_Hlink_Init(doc);
1807 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1808 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
1809 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
1810 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
1812 init_dispex(&doc->dispex, (IUnknown*)HTMLDOC(doc), &HTMLDocument_dispex);
1814 *ret = doc;
1815 return S_OK;
1818 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocument **ret)
1820 HTMLDocument *doc;
1821 HRESULT hres;
1823 hres = alloc_doc(&doc);
1824 if(FAILED(hres))
1825 return hres;
1827 nsIDOMHTMLDocument_AddRef(nsdoc);
1828 doc->nsdoc = nsdoc;
1830 hres = HTMLWindow_Create(doc, NULL, &doc->window);
1831 if(FAILED(hres)) {
1832 IHTMLDocument_Release(HTMLDOC(doc));
1833 return hres;
1836 *ret = doc;
1837 return S_OK;
1840 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1842 HTMLDocument *doc;
1843 nsIDOMWindow *nswindow = NULL;
1844 HRESULT hres;
1846 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1848 hres = alloc_doc(&doc);
1849 if(FAILED(hres))
1850 return hres;
1852 hres = IHTMLDocument_QueryInterface(HTMLDOC(doc), riid, ppvObject);
1853 IHTMLDocument_Release(HTMLDOC(doc));
1854 if(FAILED(hres))
1855 return hres;
1857 doc->nscontainer = NSContainer_Create(doc, NULL);
1858 update_nsdocument(doc);
1860 if(doc->nscontainer) {
1861 nsresult nsres;
1863 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
1864 if(NS_FAILED(nsres))
1865 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1868 hres = HTMLWindow_Create(doc, nswindow, &doc->window);
1869 if(nswindow)
1870 nsIDOMWindow_Release(nswindow);
1871 if(FAILED(hres)) {
1872 IHTMLDocument_Release(HTMLDOC(doc));
1873 return hres;
1876 get_thread_hwnd();
1878 return S_OK;