2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
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
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
37 #include "htmlevent.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
43 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
45 HTMLDocument *This = HTMLDOC_THIS(iface);
47 return htmldoc_query_interface(This, riid, ppv);
50 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
52 HTMLDocument *This = HTMLDOC_THIS(iface);
54 return htmldoc_addref(This);
57 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
59 HTMLDocument *This = HTMLDOC_THIS(iface);
61 return htmldoc_release(This);
64 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
66 HTMLDocument *This = HTMLDOC_THIS(iface);
68 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
71 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
72 LCID lcid, ITypeInfo **ppTInfo)
74 HTMLDocument *This = HTMLDOC_THIS(iface);
76 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
79 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
80 LPOLESTR *rgszNames, UINT cNames,
81 LCID lcid, DISPID *rgDispId)
83 HTMLDocument *This = HTMLDOC_THIS(iface);
85 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
88 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
89 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
90 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
92 HTMLDocument *This = HTMLDOC_THIS(iface);
94 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
95 pVarResult, pExcepInfo, puArgErr);
98 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
100 HTMLDocument *This = HTMLDOC_THIS(iface);
102 TRACE("(%p)->(%p)\n", This, p);
104 *p = (IDispatch*)HTMLWINDOW2(This->window);
105 IDispatch_AddRef(*p);
109 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
111 HTMLDocument *This = HTMLDOC_THIS(iface);
112 nsIDOMElement *nselem = NULL;
115 TRACE("(%p)->(%p)\n", This, p);
117 if(!This->doc_node->nsdoc) {
118 WARN("NULL nsdoc\n");
122 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
123 if(NS_FAILED(nsres)) {
124 ERR("GetDocumentElement failed: %08x\n", nsres);
129 *p = create_all_collection(get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE), TRUE);
130 nsIDOMElement_Release(nselem);
138 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
140 HTMLDocument *This = HTMLDOC_THIS(iface);
141 nsIDOMHTMLElement *nsbody = NULL;
144 TRACE("(%p)->(%p)\n", This, p);
146 if(This->doc_node->nsdoc) {
149 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
150 if(NS_FAILED(nsres)) {
151 TRACE("Could not get body: %08x\n", nsres);
157 node = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE);
158 nsIDOMHTMLElement_Release(nsbody);
160 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
165 TRACE("*p = %p\n", *p);
169 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
171 HTMLDocument *This = HTMLDOC_THIS(iface);
172 FIXME("(%p)->(%p)\n", This, p);
176 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
178 HTMLDocument *This = HTMLDOC_THIS(iface);
179 nsIDOMHTMLCollection *nscoll = NULL;
182 TRACE("(%p)->(%p)\n", This, p);
189 if(!This->doc_node->nsdoc) {
190 WARN("NULL nsdoc\n");
194 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
195 if(NS_FAILED(nsres)) {
196 ERR("GetImages failed: %08x\n", nsres);
201 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
202 nsIDOMElement_Release(nscoll);
208 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
210 HTMLDocument *This = HTMLDOC_THIS(iface);
211 nsIDOMHTMLCollection *nscoll = NULL;
214 TRACE("(%p)->(%p)\n", This, p);
221 if(!This->doc_node->nsdoc) {
222 WARN("NULL nsdoc\n");
226 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
227 if(NS_FAILED(nsres)) {
228 ERR("GetApplets failed: %08x\n", nsres);
233 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
234 nsIDOMElement_Release(nscoll);
240 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
242 HTMLDocument *This = HTMLDOC_THIS(iface);
243 nsIDOMHTMLCollection *nscoll = NULL;
246 TRACE("(%p)->(%p)\n", This, p);
253 if(!This->doc_node->nsdoc) {
254 WARN("NULL nsdoc\n");
258 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
259 if(NS_FAILED(nsres)) {
260 ERR("GetLinks failed: %08x\n", nsres);
265 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
266 nsIDOMElement_Release(nscoll);
272 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
274 HTMLDocument *This = HTMLDOC_THIS(iface);
275 nsIDOMHTMLCollection *nscoll = NULL;
278 TRACE("(%p)->(%p)\n", This, p);
285 if(!This->doc_node->nsdoc) {
286 WARN("NULL nsdoc\n");
290 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
291 if(NS_FAILED(nsres)) {
292 ERR("GetForms failed: %08x\n", nsres);
297 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
298 nsIDOMElement_Release(nscoll);
304 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
306 HTMLDocument *This = HTMLDOC_THIS(iface);
307 nsIDOMHTMLCollection *nscoll = NULL;
310 TRACE("(%p)->(%p)\n", This, p);
317 if(!This->doc_node->nsdoc) {
318 WARN("NULL nsdoc\n");
322 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
323 if(NS_FAILED(nsres)) {
324 ERR("GetAnchors failed: %08x\n", nsres);
329 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
330 nsIDOMElement_Release(nscoll);
336 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
338 HTMLDocument *This = HTMLDOC_THIS(iface);
342 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
344 if(!This->doc_node->nsdoc) {
345 WARN("NULL nsdoc\n");
349 nsAString_InitDepend(&nsstr, v);
350 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
351 nsAString_Finish(&nsstr);
353 ERR("SetTitle failed: %08x\n", nsres);
358 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
360 HTMLDocument *This = HTMLDOC_THIS(iface);
361 const PRUnichar *ret;
365 TRACE("(%p)->(%p)\n", This, p);
367 if(!This->doc_node->nsdoc) {
368 WARN("NULL nsdoc\n");
373 nsAString_Init(&nsstr, NULL);
374 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
375 if (NS_SUCCEEDED(nsres)) {
376 nsAString_GetData(&nsstr, &ret);
377 *p = SysAllocString(ret);
379 nsAString_Finish(&nsstr);
381 if(NS_FAILED(nsres)) {
382 ERR("GetTitle failed: %08x\n", nsres);
389 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
391 HTMLDocument *This = HTMLDOC_THIS(iface);
392 FIXME("(%p)->(%p)\n", This, p);
396 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
398 HTMLDocument *This = HTMLDOC_THIS(iface);
399 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
403 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
405 HTMLDocument *This = HTMLDOC_THIS(iface);
406 static WCHAR szOff[] = {'O','f','f',0};
407 FIXME("(%p)->(%p) always returning Off\n", This, p);
412 *p = SysAllocString(szOff);
417 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
419 HTMLDocument *This = HTMLDOC_THIS(iface);
420 nsISelection *nsselection;
423 TRACE("(%p)->(%p)\n", This, p);
425 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
426 if(NS_FAILED(nsres)) {
427 ERR("GetSelection failed: %08x\n", nsres);
431 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
434 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
436 HTMLDocument *This = HTMLDOC_THIS(iface);
438 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
439 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
440 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
441 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
442 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
444 static const LPCWSTR readystate_str[] = {
452 TRACE("(%p)->(%p)\n", iface, p);
457 *p = SysAllocString(readystate_str[This->window->readystate]);
461 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
463 HTMLDocument *This = HTMLDOC_THIS(iface);
464 FIXME("(%p)->(%p)\n", This, p);
468 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
470 HTMLDocument *This = HTMLDOC_THIS(iface);
471 FIXME("(%p)->(%p)\n", This, p);
475 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
477 HTMLDocument *This = HTMLDOC_THIS(iface);
478 FIXME("(%p)->(%p)\n", This, p);
482 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
484 HTMLDocument *This = HTMLDOC_THIS(iface);
485 FIXME("(%p)\n", This);
489 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
491 HTMLDocument *This = HTMLDOC_THIS(iface);
492 FIXME("(%p)->(%p)\n", This, p);
496 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
498 HTMLDocument *This = HTMLDOC_THIS(iface);
499 FIXME("(%p)\n", This);
503 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
505 HTMLDocument *This = HTMLDOC_THIS(iface);
506 FIXME("(%p)->(%p)\n", This, p);
510 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
512 HTMLDocument *This = HTMLDOC_THIS(iface);
513 FIXME("(%p)\n", This);
517 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
519 HTMLDocument *This = HTMLDOC_THIS(iface);
520 FIXME("(%p)->(%p)\n", This, p);
524 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
526 HTMLDocument *This = HTMLDOC_THIS(iface);
527 FIXME("(%p)->()\n", This);
531 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
533 HTMLDocument *This = HTMLDOC_THIS(iface);
534 FIXME("(%p)->(%p)\n", This, p);
538 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
540 HTMLDocument *This = HTMLDOC_THIS(iface);
541 FIXME("(%p)\n", This);
545 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
547 HTMLDocument *This = HTMLDOC_THIS(iface);
548 FIXME("(%p)->(%p)\n", This, p);
552 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
554 HTMLDocument *This = HTMLDOC_THIS(iface);
556 FIXME("(%p)->(%p)\n", This, p);
562 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
564 HTMLDocument *This = HTMLDOC_THIS(iface);
566 TRACE("(%p)->(%p)\n", This, p);
568 if(!This->doc_node->nsdoc) {
569 WARN("NULL nsdoc\n");
573 return IHTMLWindow2_get_location(HTMLWINDOW2(This->window), p);
576 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
578 HTMLDocument *This = HTMLDOC_THIS(iface);
579 FIXME("(%p)->(%p)\n", This, p);
583 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
585 HTMLDocument *This = HTMLDOC_THIS(iface);
586 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
590 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
592 HTMLDocument *This = HTMLDOC_THIS(iface);
594 static const WCHAR about_blank_url[] =
595 {'a','b','o','u','t',':','b','l','a','n','k',0};
597 TRACE("(%p)->(%p)\n", iface, p);
599 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
600 return *p ? S_OK : E_OUTOFMEMORY;
603 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
605 HTMLDocument *This = HTMLDOC_THIS(iface);
606 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
610 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
612 HTMLDocument *This = HTMLDOC_THIS(iface);
613 FIXME("(%p)->(%p)\n", This, p);
617 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
619 HTMLDocument *This = HTMLDOC_THIS(iface);
622 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
624 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
626 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
627 return HRESULT_FROM_WIN32(GetLastError());
633 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
635 HTMLDocument *This = HTMLDOC_THIS(iface);
639 TRACE("(%p)->(%p)\n", This, p);
642 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
644 switch(GetLastError()) {
645 case ERROR_INSUFFICIENT_BUFFER:
647 case ERROR_NO_MORE_ITEMS:
651 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
652 return HRESULT_FROM_WIN32(GetLastError());
661 *p = SysAllocStringLen(NULL, size-1);
663 return E_OUTOFMEMORY;
665 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
667 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
674 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
676 HTMLDocument *This = HTMLDOC_THIS(iface);
677 FIXME("(%p)->(%x)\n", This, v);
681 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
683 HTMLDocument *This = HTMLDOC_THIS(iface);
684 FIXME("(%p)->(%p)\n", This, p);
688 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
690 HTMLDocument *This = HTMLDOC_THIS(iface);
691 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
695 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
697 HTMLDocument *This = HTMLDOC_THIS(iface);
698 FIXME("(%p)->(%p)\n", This, p);
702 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
704 HTMLDocument *This = HTMLDOC_THIS(iface);
705 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
709 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
711 HTMLDocument *This = HTMLDOC_THIS(iface);
712 FIXME("(%p)->(%p)\n", This, p);
716 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
718 HTMLDocument *This = HTMLDOC_THIS(iface);
719 FIXME("(%p)->(%p)\n", This, p);
723 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
725 HTMLDocument *This = HTMLDOC_THIS(iface);
726 FIXME("(%p)->(%p)\n", This, p);
730 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
732 HTMLDocument *This = HTMLDOC_THIS(iface);
733 FIXME("(%p)->(%p)\n", This, p);
737 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
739 HTMLDocument *This = HTMLDOC_THIS(iface);
740 FIXME("(%p)->(%p)\n", This, p);
744 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
746 HTMLDocument *This = HTMLDOC_THIS(iface);
747 FIXME("(%p)->(%p)\n", This, p);
751 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
753 HTMLDocument *This = HTMLDOC_THIS(iface);
754 FIXME("(%p)->(%p)\n", This, p);
758 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
760 HTMLDocument *This = HTMLDOC_THIS(iface);
761 FIXME("(%p)->(%p)\n", This, p);
765 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
767 HTMLDocument *This = HTMLDOC_THIS(iface);
768 FIXME("(%p)->(%p)\n", This, p);
772 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
780 if(!This->doc_node->nsdoc) {
781 WARN("NULL nsdoc\n");
788 if(psarray->cDims != 1) {
789 FIXME("cDims=%d\n", psarray->cDims);
793 hres = SafeArrayAccessData(psarray, (void**)&var);
795 WARN("SafeArrayAccessData failed: %08x\n", hres);
799 nsAString_Init(&nsstr, NULL);
801 argc = psarray->rgsabound[0].cElements;
802 for(i=0; i < argc; i++) {
803 if(V_VT(var+i) == VT_BSTR) {
804 nsAString_SetData(&nsstr, V_BSTR(var+i));
805 if(!ln || i != argc-1)
806 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr);
808 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr);
810 ERR("Write failed: %08x\n", nsres);
812 FIXME("vt=%d\n", V_VT(var+i));
816 nsAString_Finish(&nsstr);
817 SafeArrayUnaccessData(psarray);
822 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
824 HTMLDocument *This = HTMLDOC_THIS(iface);
826 TRACE("(%p)->(%p)\n", iface, psarray);
828 return document_write(This, psarray, FALSE);
831 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
833 HTMLDocument *This = HTMLDOC_THIS(iface);
835 TRACE("(%p)->(%p)\n", This, psarray);
837 return document_write(This, psarray, TRUE);
840 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
841 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
843 HTMLDocument *This = HTMLDOC_THIS(iface);
846 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
848 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
849 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
851 if(!This->doc_node->nsdoc) {
856 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
857 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
858 FIXME("unsupported args\n");
860 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc);
861 if(NS_FAILED(nsres)) {
862 ERR("Open failed: %08x\n", nsres);
866 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
867 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
871 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
873 HTMLDocument *This = HTMLDOC_THIS(iface);
876 TRACE("(%p)\n", This);
878 if(!This->doc_node->nsdoc) {
883 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
884 if(NS_FAILED(nsres)) {
885 ERR("Close failed: %08x\n", nsres);
892 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
894 HTMLDocument *This = HTMLDOC_THIS(iface);
895 nsIDOMNSHTMLDocument *nsdoc;
898 TRACE("(%p)\n", This);
900 nsres = nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMNSHTMLDocument, (void**)&nsdoc);
901 if(NS_FAILED(nsres)) {
902 ERR("Could not get nsIDOMNSHTMLDocument iface: %08x\n", nsres);
906 nsres = nsIDOMNSHTMLDocument_Clear(nsdoc);
907 nsIDOMNSHTMLDocument_Release(nsdoc);
908 if(NS_FAILED(nsres)) {
909 ERR("Clear failed: %08x\n", nsres);
916 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
919 HTMLDocument *This = HTMLDOC_THIS(iface);
920 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
924 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
927 HTMLDocument *This = HTMLDOC_THIS(iface);
928 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
932 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
935 HTMLDocument *This = HTMLDOC_THIS(iface);
936 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
940 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
943 HTMLDocument *This = HTMLDOC_THIS(iface);
944 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
948 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
951 HTMLDocument *This = HTMLDOC_THIS(iface);
952 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
956 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
959 HTMLDocument *This = HTMLDOC_THIS(iface);
960 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
964 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
965 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
967 HTMLDocument *This = HTMLDOC_THIS(iface);
968 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
972 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
975 HTMLDocument *This = HTMLDOC_THIS(iface);
976 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
980 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
981 IHTMLElement **newElem)
983 HTMLDocument *This = HTMLDOC_THIS(iface);
984 nsIDOMHTMLElement *nselem;
988 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
990 hres = create_nselem(This->doc_node, eTag, &nselem);
994 elem = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE);
995 nsIDOMHTMLElement_Release(nselem);
997 *newElem = HTMLELEM(elem);
998 IHTMLElement_AddRef(HTMLELEM(elem));
1002 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1004 HTMLDocument *This = HTMLDOC_THIS(iface);
1005 FIXME("(%p)\n", This);
1009 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1011 HTMLDocument *This = HTMLDOC_THIS(iface);
1012 FIXME("(%p)->(%p)\n", This, p);
1016 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1018 HTMLDocument *This = HTMLDOC_THIS(iface);
1020 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1022 return set_doc_event(This, EVENTID_CLICK, &v);
1025 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1027 HTMLDocument *This = HTMLDOC_THIS(iface);
1029 TRACE("(%p)->(%p)\n", This, p);
1031 return get_doc_event(This, EVENTID_CLICK, p);
1034 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1036 HTMLDocument *This = HTMLDOC_THIS(iface);
1037 FIXME("(%p)\n", This);
1041 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1043 HTMLDocument *This = HTMLDOC_THIS(iface);
1044 FIXME("(%p)->(%p)\n", This, p);
1048 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1050 HTMLDocument *This = HTMLDOC_THIS(iface);
1052 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1054 return set_doc_event(This, EVENTID_KEYUP, &v);
1057 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1059 HTMLDocument *This = HTMLDOC_THIS(iface);
1061 TRACE("(%p)->(%p)\n", This, p);
1063 return get_doc_event(This, EVENTID_KEYUP, p);
1066 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1068 HTMLDocument *This = HTMLDOC_THIS(iface);
1070 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1072 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1075 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1077 HTMLDocument *This = HTMLDOC_THIS(iface);
1079 TRACE("(%p)->(%p)\n", This, p);
1081 return get_doc_event(This, EVENTID_KEYDOWN, p);
1084 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1086 HTMLDocument *This = HTMLDOC_THIS(iface);
1087 FIXME("(%p)\n", This);
1091 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1093 HTMLDocument *This = HTMLDOC_THIS(iface);
1094 FIXME("(%p)->(%p)\n", This, p);
1098 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1100 HTMLDocument *This = HTMLDOC_THIS(iface);
1102 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1104 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1107 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1109 HTMLDocument *This = HTMLDOC_THIS(iface);
1111 TRACE("(%p)->(%p)\n", This, p);
1113 return get_doc_event(This, EVENTID_MOUSEUP, p);
1116 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1118 HTMLDocument *This = HTMLDOC_THIS(iface);
1120 TRACE("(%p)->()\n", This);
1122 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1125 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1127 HTMLDocument *This = HTMLDOC_THIS(iface);
1129 TRACE("(%p)->(%p)\n", This, p);
1131 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1134 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1136 HTMLDocument *This = HTMLDOC_THIS(iface);
1137 FIXME("(%p)\n", This);
1141 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1143 HTMLDocument *This = HTMLDOC_THIS(iface);
1144 FIXME("(%p)->(%p)\n", This, p);
1148 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1150 HTMLDocument *This = HTMLDOC_THIS(iface);
1152 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1154 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1157 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1159 HTMLDocument *This = HTMLDOC_THIS(iface);
1161 TRACE("(%p)->(%p)\n", This, p);
1163 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1166 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1168 HTMLDocument *This = HTMLDOC_THIS(iface);
1170 TRACE("(%p)\n", This);
1172 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1175 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1177 HTMLDocument *This = HTMLDOC_THIS(iface);
1179 TRACE("(%p)->(%p)\n", This, p);
1181 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1184 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1186 HTMLDocument *This = HTMLDOC_THIS(iface);
1188 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1190 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1193 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1195 HTMLDocument *This = HTMLDOC_THIS(iface);
1197 TRACE("(%p)->(%p)\n", This, p);
1199 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1202 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1204 HTMLDocument *This = HTMLDOC_THIS(iface);
1205 FIXME("(%p)\n", This);
1209 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1211 HTMLDocument *This = HTMLDOC_THIS(iface);
1212 FIXME("(%p)->(%p)\n", This, p);
1216 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1218 HTMLDocument *This = HTMLDOC_THIS(iface);
1219 FIXME("(%p)\n", This);
1223 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1225 HTMLDocument *This = HTMLDOC_THIS(iface);
1226 FIXME("(%p)->(%p)\n", This, p);
1230 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1232 HTMLDocument *This = HTMLDOC_THIS(iface);
1233 FIXME("(%p)\n", This);
1237 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1239 HTMLDocument *This = HTMLDOC_THIS(iface);
1240 FIXME("(%p)->(%p)\n", This, p);
1244 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1246 HTMLDocument *This = HTMLDOC_THIS(iface);
1248 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1250 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1253 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1255 HTMLDocument *This = HTMLDOC_THIS(iface);
1257 TRACE("(%p)->(%p)\n", This, p);
1259 return get_doc_event(This, EVENTID_DRAGSTART, p);
1262 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1264 HTMLDocument *This = HTMLDOC_THIS(iface);
1266 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1268 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1271 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1273 HTMLDocument *This = HTMLDOC_THIS(iface);
1275 TRACE("(%p)->(%p)\n", This, p);
1277 return get_doc_event(This, EVENTID_SELECTSTART, p);
1280 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1281 IHTMLElement **elementHit)
1283 HTMLDocument *This = HTMLDOC_THIS(iface);
1284 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1288 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1290 HTMLDocument *This = HTMLDOC_THIS(iface);
1292 TRACE("(%p)->(%p)\n", This, p);
1294 *p = HTMLWINDOW2(This->window);
1295 IHTMLWindow2_AddRef(*p);
1299 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1300 IHTMLStyleSheetsCollection **p)
1302 HTMLDocument *This = HTMLDOC_THIS(iface);
1303 nsIDOMStyleSheetList *nsstylelist;
1304 nsIDOMDocumentStyle *nsdocstyle;
1307 TRACE("(%p)->(%p)\n", This, p);
1311 if(!This->doc_node->nsdoc) {
1312 WARN("NULL nsdoc\n");
1313 return E_UNEXPECTED;
1316 nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1317 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1318 nsIDOMDocumentStyle_Release(nsdocstyle);
1319 if(NS_FAILED(nsres)) {
1320 ERR("GetStyleSheets failed: %08x\n", nsres);
1324 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1325 nsIDOMDocumentStyle_Release(nsstylelist);
1330 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1332 HTMLDocument *This = HTMLDOC_THIS(iface);
1333 FIXME("(%p)\n", This);
1337 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1339 HTMLDocument *This = HTMLDOC_THIS(iface);
1340 FIXME("(%p)->(%p)\n", This, p);
1344 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1346 HTMLDocument *This = HTMLDOC_THIS(iface);
1347 FIXME("(%p)\n", This);
1351 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1353 HTMLDocument *This = HTMLDOC_THIS(iface);
1354 FIXME("(%p)->(%p)\n", This, p);
1358 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1360 HTMLDocument *This = HTMLDOC_THIS(iface);
1361 FIXME("(%p)->(%p)\n", This, String);
1365 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1366 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1368 HTMLDocument *This = HTMLDOC_THIS(iface);
1370 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1372 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1376 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1377 HTMLDocument_QueryInterface,
1378 HTMLDocument_AddRef,
1379 HTMLDocument_Release,
1380 HTMLDocument_GetTypeInfoCount,
1381 HTMLDocument_GetTypeInfo,
1382 HTMLDocument_GetIDsOfNames,
1383 HTMLDocument_Invoke,
1384 HTMLDocument_get_Script,
1385 HTMLDocument_get_all,
1386 HTMLDocument_get_body,
1387 HTMLDocument_get_activeElement,
1388 HTMLDocument_get_images,
1389 HTMLDocument_get_applets,
1390 HTMLDocument_get_links,
1391 HTMLDocument_get_forms,
1392 HTMLDocument_get_anchors,
1393 HTMLDocument_put_title,
1394 HTMLDocument_get_title,
1395 HTMLDocument_get_scripts,
1396 HTMLDocument_put_designMode,
1397 HTMLDocument_get_designMode,
1398 HTMLDocument_get_selection,
1399 HTMLDocument_get_readyState,
1400 HTMLDocument_get_frames,
1401 HTMLDocument_get_embeds,
1402 HTMLDocument_get_plugins,
1403 HTMLDocument_put_alinkColor,
1404 HTMLDocument_get_alinkColor,
1405 HTMLDocument_put_bgColor,
1406 HTMLDocument_get_bgColor,
1407 HTMLDocument_put_fgColor,
1408 HTMLDocument_get_fgColor,
1409 HTMLDocument_put_linkColor,
1410 HTMLDocument_get_linkColor,
1411 HTMLDocument_put_vlinkColor,
1412 HTMLDocument_get_vlinkColor,
1413 HTMLDocument_get_referrer,
1414 HTMLDocument_get_location,
1415 HTMLDocument_get_lastModified,
1416 HTMLDocument_put_URL,
1417 HTMLDocument_get_URL,
1418 HTMLDocument_put_domain,
1419 HTMLDocument_get_domain,
1420 HTMLDocument_put_cookie,
1421 HTMLDocument_get_cookie,
1422 HTMLDocument_put_expando,
1423 HTMLDocument_get_expando,
1424 HTMLDocument_put_charset,
1425 HTMLDocument_get_charset,
1426 HTMLDocument_put_defaultCharset,
1427 HTMLDocument_get_defaultCharset,
1428 HTMLDocument_get_mimeType,
1429 HTMLDocument_get_fileSize,
1430 HTMLDocument_get_fileCreatedDate,
1431 HTMLDocument_get_fileModifiedDate,
1432 HTMLDocument_get_fileUpdatedDate,
1433 HTMLDocument_get_security,
1434 HTMLDocument_get_protocol,
1435 HTMLDocument_get_nameProp,
1437 HTMLDocument_writeln,
1441 HTMLDocument_queryCommandSupported,
1442 HTMLDocument_queryCommandEnabled,
1443 HTMLDocument_queryCommandState,
1444 HTMLDocument_queryCommandIndeterm,
1445 HTMLDocument_queryCommandText,
1446 HTMLDocument_queryCommandValue,
1447 HTMLDocument_execCommand,
1448 HTMLDocument_execCommandShowHelp,
1449 HTMLDocument_createElement,
1450 HTMLDocument_put_onhelp,
1451 HTMLDocument_get_onhelp,
1452 HTMLDocument_put_onclick,
1453 HTMLDocument_get_onclick,
1454 HTMLDocument_put_ondblclick,
1455 HTMLDocument_get_ondblclick,
1456 HTMLDocument_put_onkeyup,
1457 HTMLDocument_get_onkeyup,
1458 HTMLDocument_put_onkeydown,
1459 HTMLDocument_get_onkeydown,
1460 HTMLDocument_put_onkeypress,
1461 HTMLDocument_get_onkeypress,
1462 HTMLDocument_put_onmouseup,
1463 HTMLDocument_get_onmouseup,
1464 HTMLDocument_put_onmousedown,
1465 HTMLDocument_get_onmousedown,
1466 HTMLDocument_put_onmousemove,
1467 HTMLDocument_get_onmousemove,
1468 HTMLDocument_put_onmouseout,
1469 HTMLDocument_get_onmouseout,
1470 HTMLDocument_put_onmouseover,
1471 HTMLDocument_get_onmouseover,
1472 HTMLDocument_put_onreadystatechange,
1473 HTMLDocument_get_onreadystatechange,
1474 HTMLDocument_put_onafterupdate,
1475 HTMLDocument_get_onafterupdate,
1476 HTMLDocument_put_onrowexit,
1477 HTMLDocument_get_onrowexit,
1478 HTMLDocument_put_onrowenter,
1479 HTMLDocument_get_onrowenter,
1480 HTMLDocument_put_ondragstart,
1481 HTMLDocument_get_ondragstart,
1482 HTMLDocument_put_onselectstart,
1483 HTMLDocument_get_onselectstart,
1484 HTMLDocument_elementFromPoint,
1485 HTMLDocument_get_parentWindow,
1486 HTMLDocument_get_styleSheets,
1487 HTMLDocument_put_onbeforeupdate,
1488 HTMLDocument_get_onbeforeupdate,
1489 HTMLDocument_put_onerrorupdate,
1490 HTMLDocument_get_onerrorupdate,
1491 HTMLDocument_toString,
1492 HTMLDocument_createStyleSheet
1495 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
1497 HTMLDocument *This = HTMLDOC_THIS(iface);
1500 update_cp_events(This->window, &This->doc_node->node.event_target, cp, This->doc_node->node.nsnode);
1505 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1507 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1509 HTMLDocument *This = SUPPINFO_THIS(iface);
1510 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1513 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1515 HTMLDocument *This = SUPPINFO_THIS(iface);
1516 return IHTMLDocument_AddRef(HTMLDOC(This));
1519 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1521 HTMLDocument *This = SUPPINFO_THIS(iface);
1522 return IHTMLDocument_Release(HTMLDOC(This));
1525 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1527 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1531 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1532 SupportErrorInfo_QueryInterface,
1533 SupportErrorInfo_AddRef,
1534 SupportErrorInfo_Release,
1535 SupportErrorInfo_InterfaceSupportsErrorInfo
1538 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1540 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1542 HTMLDocument *This = DISPEX_THIS(iface);
1544 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1547 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1549 HTMLDocument *This = DISPEX_THIS(iface);
1551 return IHTMLDocument2_AddRef(HTMLDOC(This));
1554 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1556 HTMLDocument *This = DISPEX_THIS(iface);
1558 return IHTMLDocument2_Release(HTMLDOC(This));
1561 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1563 HTMLDocument *This = DISPEX_THIS(iface);
1565 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
1568 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1569 LCID lcid, ITypeInfo **ppTInfo)
1571 HTMLDocument *This = DISPEX_THIS(iface);
1573 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
1576 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1577 LPOLESTR *rgszNames, UINT cNames,
1578 LCID lcid, DISPID *rgDispId)
1580 HTMLDocument *This = DISPEX_THIS(iface);
1582 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
1585 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1586 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1587 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1589 HTMLDocument *This = DISPEX_THIS(iface);
1591 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1592 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1594 switch(dispIdMember) {
1595 case DISPID_READYSTATE:
1596 TRACE("DISPID_READYSTATE\n");
1598 if(!(wFlags & DISPATCH_PROPERTYGET))
1599 return E_INVALIDARG;
1601 V_VT(pVarResult) = VT_I4;
1602 V_I4(pVarResult) = This->window->readystate;
1606 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
1607 pVarResult, pExcepInfo, puArgErr);
1610 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1612 HTMLDocument *This = DISPEX_THIS(iface);
1614 return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
1617 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1618 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1620 HTMLDocument *This = DISPEX_THIS(iface);
1622 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
1623 return IDispatchEx_InvokeEx(DISPATCHEX(This->window), DISPID_IHTMLWINDOW2_LOCATION, lcid, wFlags,
1624 pdp, pvarRes, pei, pspCaller);
1627 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1630 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1632 HTMLDocument *This = DISPEX_THIS(iface);
1634 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
1637 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1639 HTMLDocument *This = DISPEX_THIS(iface);
1641 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
1644 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1646 HTMLDocument *This = DISPEX_THIS(iface);
1648 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
1651 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1653 HTMLDocument *This = DISPEX_THIS(iface);
1655 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
1658 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1660 HTMLDocument *This = DISPEX_THIS(iface);
1662 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
1665 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1667 HTMLDocument *This = DISPEX_THIS(iface);
1669 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
1674 static const IDispatchExVtbl DocDispatchExVtbl = {
1675 DocDispatchEx_QueryInterface,
1676 DocDispatchEx_AddRef,
1677 DocDispatchEx_Release,
1678 DocDispatchEx_GetTypeInfoCount,
1679 DocDispatchEx_GetTypeInfo,
1680 DocDispatchEx_GetIDsOfNames,
1681 DocDispatchEx_Invoke,
1682 DocDispatchEx_GetDispID,
1683 DocDispatchEx_InvokeEx,
1684 DocDispatchEx_DeleteMemberByName,
1685 DocDispatchEx_DeleteMemberByDispID,
1686 DocDispatchEx_GetMemberProperties,
1687 DocDispatchEx_GetMemberName,
1688 DocDispatchEx_GetNextDispID,
1689 DocDispatchEx_GetNameSpaceParent
1692 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
1696 if(IsEqualGUID(&IID_IUnknown, riid)) {
1697 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
1698 *ppv = HTMLDOC(This);
1699 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1700 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv);
1701 *ppv = DISPATCHEX(This);
1702 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
1703 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv);
1704 *ppv = DISPATCHEX(This);
1705 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
1706 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv);
1707 *ppv = HTMLDOC(This);
1708 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
1709 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppv);
1710 *ppv = HTMLDOC(This);
1711 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
1712 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppv);
1713 *ppv = HTMLDOC3(This);
1714 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
1715 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppv);
1716 *ppv = HTMLDOC4(This);
1717 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
1718 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppv);
1719 *ppv = HTMLDOC5(This);
1720 }else if(IsEqualGUID(&IID_IHTMLDocument6, riid)) {
1721 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This, ppv);
1722 *ppv = HTMLDOC6(This);
1723 }else if(IsEqualGUID(&IID_IPersist, riid)) {
1724 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
1725 *ppv = PERSIST(This);
1726 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
1727 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppv);
1728 *ppv = PERSISTMON(This);
1729 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
1730 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppv);
1731 *ppv = PERSISTFILE(This);
1732 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
1733 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppv);
1734 *ppv = MONPROP(This);
1735 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
1736 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppv);
1737 *ppv = OLEOBJ(This);
1738 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
1739 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppv);
1740 *ppv = OLEDOC(This);
1741 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
1742 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppv);
1743 *ppv = DOCVIEW(This);
1744 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
1745 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
1746 *ppv = ACTOBJ(This);
1747 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
1748 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
1749 *ppv = VIEWOBJ(This);
1750 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
1751 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
1752 *ppv = VIEWOBJ2(This);
1753 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
1754 TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This, ppv);
1755 *ppv = VIEWOBJEX(This);
1756 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
1757 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
1758 *ppv = OLEWIN(This);
1759 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
1760 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
1761 *ppv = INPLACEOBJ(This);
1762 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1763 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppv);
1764 *ppv = INPLACEWIN(This);
1765 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1766 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
1767 *ppv = SERVPROV(This);
1768 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
1769 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppv);
1770 *ppv = CMDTARGET(This);
1771 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
1772 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppv);
1773 *ppv = CONTROL(This);
1774 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
1775 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppv);
1776 *ppv = HLNKTARGET(This);
1777 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1778 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1779 *ppv = CONPTCONT(&This->cp_container);
1780 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
1781 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
1782 *ppv = PERSTRINIT(This);
1783 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
1784 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
1785 *ppv = HTMLDOC(This);
1786 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
1787 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppv);
1788 *ppv = SUPPERRINFO(This);
1789 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
1790 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppv);
1791 *ppv = PERSISTHIST(This);
1792 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
1793 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
1795 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
1796 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
1798 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
1799 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
1801 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
1802 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
1804 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
1805 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
1807 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
1808 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
1810 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
1811 TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv);
1812 *ppv = OBJSITE(This);
1818 IUnknown_AddRef((IUnknown*)*ppv);
1822 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
1824 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
1826 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1827 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1828 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1830 doc->unk_impl = unk_impl;
1831 doc->dispex = dispex;
1832 doc->task_magic = get_task_target_magic();
1834 HTMLDocument_HTMLDocument3_Init(doc);
1835 HTMLDocument_HTMLDocument5_Init(doc);
1836 HTMLDocument_Persist_Init(doc);
1837 HTMLDocument_OleCmd_Init(doc);
1838 HTMLDocument_OleObj_Init(doc);
1839 HTMLDocument_View_Init(doc);
1840 HTMLDocument_Window_Init(doc);
1841 HTMLDocument_Service_Init(doc);
1842 HTMLDocument_Hlink_Init(doc);
1844 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1845 ConnectionPoint_Init(&doc->cp_dispatch, &doc->cp_container, &IID_IDispatch, NULL);
1846 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink, NULL);
1847 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data);
1848 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2, NULL);
1851 static void destroy_htmldoc(HTMLDocument *This)
1853 remove_target_tasks(This->task_magic);
1855 ConnectionPointContainer_Destroy(&This->cp_container);
1858 #define HTMLDOCNODE_NODE_THIS(iface) DEFINE_THIS2(HTMLDocumentNode, node, iface)
1860 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1862 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1864 if(htmldoc_qi(&This->basedoc, riid, ppv))
1865 return *ppv ? S_OK : E_NOINTERFACE;
1867 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid)) {
1868 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This, ppv);
1869 *ppv = HOSTSECMGR(This);
1871 return HTMLDOMNode_QI(&This->node, riid, ppv);
1874 IUnknown_AddRef((IUnknown*)*ppv);
1878 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
1880 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1882 if(This->body_event_target)
1883 release_event_target(This->body_event_target);
1884 if(This->nsevent_listener)
1885 release_nsevents(This);
1887 ICatInformation_Release(This->catmgr);
1889 IInternetSecurityManager_Release(This->secmgr);
1891 detach_selection(This);
1892 detach_ranges(This);
1893 release_nodes(This);
1896 release_mutation(This);
1897 nsIDOMHTMLDocument_Release(This->nsdoc);
1900 heap_free(This->event_vector);
1901 destroy_htmldoc(&This->basedoc);
1904 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1906 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1907 FIXME("%p\n", This);
1911 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
1912 HTMLDocumentNode_QI,
1913 HTMLDocumentNode_destructor,
1914 HTMLDocumentNode_clone
1917 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1919 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1920 HTMLDocumentNode *new_node;
1923 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
1927 *ret = &new_node->node;
1931 #undef HTMLDOCNODE_NODE_THIS
1933 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
1934 HTMLDocumentNode_QI,
1935 HTMLDocumentNode_destructor,
1936 HTMLDocumentFragment_clone
1939 static const tid_t HTMLDocumentNode_iface_tids[] = {
1949 static dispex_static_data_t HTMLDocumentNode_dispex = {
1951 DispHTMLDocument_tid,
1953 HTMLDocumentNode_iface_tids
1956 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLWindow *window)
1958 HTMLDocumentNode *doc;
1960 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
1965 doc->basedoc.doc_node = doc;
1966 doc->basedoc.doc_obj = doc_obj;
1967 doc->basedoc.window = window;
1969 init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
1970 init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
1971 HTMLDocumentNode_SecMgr_Init(doc);
1975 list_init(&doc->bindings);
1976 list_init(&doc->selection_list);
1977 list_init(&doc->range_list);
1982 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret)
1984 HTMLDocumentNode *doc;
1987 doc = alloc_doc_node(doc_obj, window);
1989 return E_OUTOFMEMORY;
1991 if(window == doc_obj->basedoc.window)
1992 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
1994 nsIDOMHTMLDocument_AddRef(nsdoc);
1998 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
1999 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
2000 doc->node.cp_container = &doc->basedoc.cp_container;
2002 hres = CoInternetCreateSecurityManager(NULL, &doc->secmgr, 0);
2004 htmldoc_release(&doc->basedoc);
2012 HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
2014 HTMLDocumentNode *doc_frag;
2016 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->basedoc.window);
2018 return E_OUTOFMEMORY;
2020 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
2021 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
2022 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
2024 htmldoc_addref(&doc_frag->basedoc);
2029 /**********************************************************
2030 * ICustomDoc implementation
2033 #define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocumentObj, CustomDoc, iface)
2035 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
2037 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2039 if(htmldoc_qi(&This->basedoc, riid, ppv))
2040 return *ppv ? S_OK : E_NOINTERFACE;
2042 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
2043 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
2044 *ppv = CUSTOMDOC(This);
2045 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2046 return *ppv ? S_OK : E_NOINTERFACE;
2048 FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
2050 return E_NOINTERFACE;
2053 IUnknown_AddRef((IUnknown*)*ppv);
2057 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
2059 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2060 ULONG ref = InterlockedIncrement(&This->ref);
2062 TRACE("(%p) ref = %u\n", This, ref);
2067 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
2069 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2070 ULONG ref = InterlockedDecrement(&This->ref);
2072 TRACE("(%p) ref = %u\n", This, ref);
2075 if(This->basedoc.doc_node) {
2076 This->basedoc.doc_node->basedoc.doc_obj = NULL;
2077 IHTMLDocument2_Release(HTMLDOC(&This->basedoc.doc_node->basedoc));
2079 if(This->basedoc.window) {
2080 This->basedoc.window->doc_obj = NULL;
2081 IHTMLWindow2_Release(HTMLWINDOW2(This->basedoc.window));
2083 if(This->basedoc.advise_holder)
2084 IOleAdviseHolder_Release(This->basedoc.advise_holder);
2087 IAdviseSink_Release(This->view_sink);
2089 IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL);
2090 if(This->in_place_active)
2091 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(&This->basedoc));
2093 IOleDocumentView_SetInPlaceSite(DOCVIEW(&This->basedoc), NULL);
2095 IOleUndoManager_Release(This->undomgr);
2096 if(This->tooltips_hwnd)
2097 DestroyWindow(This->tooltips_hwnd);
2100 DestroyWindow(This->hwnd);
2101 heap_free(This->mime);
2103 destroy_htmldoc(&This->basedoc);
2104 release_dispex(&This->dispex);
2106 if(This->nscontainer)
2107 NSContainer_Release(This->nscontainer);
2114 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
2116 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2117 FIXME("(%p)->(%p)\n", This, pUIHandler);
2121 #undef CUSTOMDOC_THIS
2123 static const ICustomDocVtbl CustomDocVtbl = {
2124 CustomDoc_QueryInterface,
2127 CustomDoc_SetUIHandler
2130 static const tid_t HTMLDocumentObj_iface_tids[] = {
2137 static dispex_static_data_t HTMLDocumentObj_dispex = {
2139 DispHTMLDocument_tid,
2141 HTMLDocumentObj_iface_tids
2144 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
2146 HTMLDocumentObj *doc;
2147 nsIDOMWindow *nswindow = NULL;
2151 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2153 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
2155 return E_OUTOFMEMORY;
2157 init_dispex(&doc->dispex, (IUnknown*)CUSTOMDOC(doc), &HTMLDocumentObj_dispex);
2158 init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc), DISPATCHEX(&doc->dispex));
2160 doc->lpCustomDocVtbl = &CustomDocVtbl;
2162 doc->basedoc.doc_obj = doc;
2164 doc->usermode = UNKNOWN_USERMODE;
2166 doc->nscontainer = NSContainer_Create(doc, NULL);
2167 if(!doc->nscontainer) {
2168 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2169 htmldoc_release(&doc->basedoc);
2170 return CLASS_E_CLASSNOTAVAILABLE;
2173 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
2174 htmldoc_release(&doc->basedoc);
2179 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
2180 if(NS_FAILED(nsres))
2181 ERR("GetContentDOMWindow failed: %08x\n", nsres);
2183 hres = HTMLWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
2185 nsIDOMWindow_Release(nswindow);
2187 IHTMLDocument_Release(HTMLDOC(&doc->basedoc));
2191 if(!doc->basedoc.doc_node && doc->basedoc.window->doc) {
2192 doc->basedoc.doc_node = doc->basedoc.window->doc;
2193 htmldoc_addref(&doc->basedoc.doc_node->basedoc);