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;
117 TRACE("(%p)->(%p)\n", This, p);
119 if(!This->doc_node->nsdoc) {
120 WARN("NULL nsdoc\n");
124 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
125 if(NS_FAILED(nsres)) {
126 ERR("GetDocumentElement failed: %08x\n", nsres);
135 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
137 *p = create_all_collection(node, TRUE);
138 nsIDOMElement_Release(nselem);
142 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
144 HTMLDocument *This = HTMLDOC_THIS(iface);
145 nsIDOMHTMLElement *nsbody = NULL;
149 TRACE("(%p)->(%p)\n", This, p);
151 if(This->doc_node->nsdoc) {
154 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
155 if(NS_FAILED(nsres)) {
156 TRACE("Could not get body: %08x\n", nsres);
166 hres = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE, &node);
167 nsIDOMHTMLElement_Release(nsbody);
171 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
174 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
176 HTMLDocument *This = HTMLDOC_THIS(iface);
177 FIXME("(%p)->(%p)\n", This, p);
181 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
183 HTMLDocument *This = HTMLDOC_THIS(iface);
184 nsIDOMHTMLCollection *nscoll = NULL;
187 TRACE("(%p)->(%p)\n", This, p);
194 if(!This->doc_node->nsdoc) {
195 WARN("NULL nsdoc\n");
199 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
200 if(NS_FAILED(nsres)) {
201 ERR("GetImages failed: %08x\n", nsres);
206 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
207 nsIDOMElement_Release(nscoll);
213 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
215 HTMLDocument *This = HTMLDOC_THIS(iface);
216 nsIDOMHTMLCollection *nscoll = NULL;
219 TRACE("(%p)->(%p)\n", This, p);
226 if(!This->doc_node->nsdoc) {
227 WARN("NULL nsdoc\n");
231 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
232 if(NS_FAILED(nsres)) {
233 ERR("GetApplets failed: %08x\n", nsres);
238 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
239 nsIDOMElement_Release(nscoll);
245 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
247 HTMLDocument *This = HTMLDOC_THIS(iface);
248 nsIDOMHTMLCollection *nscoll = NULL;
251 TRACE("(%p)->(%p)\n", This, p);
258 if(!This->doc_node->nsdoc) {
259 WARN("NULL nsdoc\n");
263 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
264 if(NS_FAILED(nsres)) {
265 ERR("GetLinks failed: %08x\n", nsres);
270 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
271 nsIDOMElement_Release(nscoll);
277 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
279 HTMLDocument *This = HTMLDOC_THIS(iface);
280 nsIDOMHTMLCollection *nscoll = NULL;
283 TRACE("(%p)->(%p)\n", This, p);
290 if(!This->doc_node->nsdoc) {
291 WARN("NULL nsdoc\n");
295 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
296 if(NS_FAILED(nsres)) {
297 ERR("GetForms failed: %08x\n", nsres);
302 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
303 nsIDOMElement_Release(nscoll);
309 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
311 HTMLDocument *This = HTMLDOC_THIS(iface);
312 nsIDOMHTMLCollection *nscoll = NULL;
315 TRACE("(%p)->(%p)\n", This, p);
322 if(!This->doc_node->nsdoc) {
323 WARN("NULL nsdoc\n");
327 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
328 if(NS_FAILED(nsres)) {
329 ERR("GetAnchors failed: %08x\n", nsres);
334 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
335 nsIDOMElement_Release(nscoll);
341 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
343 HTMLDocument *This = HTMLDOC_THIS(iface);
347 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
349 if(!This->doc_node->nsdoc) {
350 WARN("NULL nsdoc\n");
354 nsAString_InitDepend(&nsstr, v);
355 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
356 nsAString_Finish(&nsstr);
358 ERR("SetTitle failed: %08x\n", nsres);
363 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
365 HTMLDocument *This = HTMLDOC_THIS(iface);
366 const PRUnichar *ret;
370 TRACE("(%p)->(%p)\n", This, p);
372 if(!This->doc_node->nsdoc) {
373 WARN("NULL nsdoc\n");
378 nsAString_Init(&nsstr, NULL);
379 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
380 if (NS_SUCCEEDED(nsres)) {
381 nsAString_GetData(&nsstr, &ret);
382 *p = SysAllocString(ret);
384 nsAString_Finish(&nsstr);
386 if(NS_FAILED(nsres)) {
387 ERR("GetTitle failed: %08x\n", nsres);
394 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
396 HTMLDocument *This = HTMLDOC_THIS(iface);
397 FIXME("(%p)->(%p)\n", This, p);
401 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
403 HTMLDocument *This = HTMLDOC_THIS(iface);
404 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
408 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
410 HTMLDocument *This = HTMLDOC_THIS(iface);
411 static WCHAR szOff[] = {'O','f','f',0};
412 FIXME("(%p)->(%p) always returning Off\n", This, p);
417 *p = SysAllocString(szOff);
422 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
424 HTMLDocument *This = HTMLDOC_THIS(iface);
425 nsISelection *nsselection;
428 TRACE("(%p)->(%p)\n", This, p);
430 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
431 if(NS_FAILED(nsres)) {
432 ERR("GetSelection failed: %08x\n", nsres);
436 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
439 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
441 HTMLDocument *This = HTMLDOC_THIS(iface);
443 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
444 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
445 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
446 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
447 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
449 static const LPCWSTR readystate_str[] = {
457 TRACE("(%p)->(%p)\n", iface, p);
462 *p = SysAllocString(readystate_str[This->window->readystate]);
466 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
468 HTMLDocument *This = HTMLDOC_THIS(iface);
469 FIXME("(%p)->(%p)\n", This, p);
473 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
475 HTMLDocument *This = HTMLDOC_THIS(iface);
476 FIXME("(%p)->(%p)\n", This, p);
480 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
482 HTMLDocument *This = HTMLDOC_THIS(iface);
483 FIXME("(%p)->(%p)\n", This, p);
487 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
489 HTMLDocument *This = HTMLDOC_THIS(iface);
490 FIXME("(%p)\n", This);
494 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
496 HTMLDocument *This = HTMLDOC_THIS(iface);
497 FIXME("(%p)->(%p)\n", This, p);
501 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
503 HTMLDocument *This = HTMLDOC_THIS(iface);
504 FIXME("(%p)\n", This);
508 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
510 HTMLDocument *This = HTMLDOC_THIS(iface);
511 FIXME("(%p)->(%p)\n", This, p);
515 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
517 HTMLDocument *This = HTMLDOC_THIS(iface);
518 FIXME("(%p)\n", This);
522 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
524 HTMLDocument *This = HTMLDOC_THIS(iface);
525 FIXME("(%p)->(%p)\n", This, p);
529 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
531 HTMLDocument *This = HTMLDOC_THIS(iface);
532 FIXME("(%p)->()\n", This);
536 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
538 HTMLDocument *This = HTMLDOC_THIS(iface);
539 FIXME("(%p)->(%p)\n", This, p);
543 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
545 HTMLDocument *This = HTMLDOC_THIS(iface);
546 FIXME("(%p)\n", This);
550 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
552 HTMLDocument *This = HTMLDOC_THIS(iface);
553 FIXME("(%p)->(%p)\n", This, p);
557 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
559 HTMLDocument *This = HTMLDOC_THIS(iface);
561 FIXME("(%p)->(%p)\n", This, p);
567 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
569 HTMLDocument *This = HTMLDOC_THIS(iface);
571 TRACE("(%p)->(%p)\n", This, p);
573 if(!This->doc_node->nsdoc) {
574 WARN("NULL nsdoc\n");
578 return IHTMLWindow2_get_location(HTMLWINDOW2(This->window), p);
581 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
583 HTMLDocument *This = HTMLDOC_THIS(iface);
584 FIXME("(%p)->(%p)\n", This, p);
588 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
590 HTMLDocument *This = HTMLDOC_THIS(iface);
591 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
595 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
597 HTMLDocument *This = HTMLDOC_THIS(iface);
599 static const WCHAR about_blank_url[] =
600 {'a','b','o','u','t',':','b','l','a','n','k',0};
602 TRACE("(%p)->(%p)\n", iface, p);
604 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
605 return *p ? S_OK : E_OUTOFMEMORY;
608 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
610 HTMLDocument *This = HTMLDOC_THIS(iface);
611 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
615 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
617 HTMLDocument *This = HTMLDOC_THIS(iface);
618 FIXME("(%p)->(%p)\n", This, p);
622 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
624 HTMLDocument *This = HTMLDOC_THIS(iface);
627 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
629 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
631 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
632 return HRESULT_FROM_WIN32(GetLastError());
638 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
640 HTMLDocument *This = HTMLDOC_THIS(iface);
644 TRACE("(%p)->(%p)\n", This, p);
647 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
649 switch(GetLastError()) {
650 case ERROR_INSUFFICIENT_BUFFER:
652 case ERROR_NO_MORE_ITEMS:
656 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
657 return HRESULT_FROM_WIN32(GetLastError());
666 *p = SysAllocStringLen(NULL, size-1);
668 return E_OUTOFMEMORY;
670 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
672 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
679 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
681 HTMLDocument *This = HTMLDOC_THIS(iface);
682 FIXME("(%p)->(%x)\n", This, v);
686 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
688 HTMLDocument *This = HTMLDOC_THIS(iface);
689 FIXME("(%p)->(%p)\n", This, p);
693 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
695 HTMLDocument *This = HTMLDOC_THIS(iface);
696 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
700 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
702 HTMLDocument *This = HTMLDOC_THIS(iface);
703 FIXME("(%p)->(%p)\n", This, p);
707 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
709 HTMLDocument *This = HTMLDOC_THIS(iface);
710 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
714 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
716 HTMLDocument *This = HTMLDOC_THIS(iface);
717 FIXME("(%p)->(%p)\n", This, p);
721 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
723 HTMLDocument *This = HTMLDOC_THIS(iface);
724 FIXME("(%p)->(%p)\n", This, p);
728 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
730 HTMLDocument *This = HTMLDOC_THIS(iface);
731 FIXME("(%p)->(%p)\n", This, p);
735 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
737 HTMLDocument *This = HTMLDOC_THIS(iface);
738 FIXME("(%p)->(%p)\n", This, p);
742 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
744 HTMLDocument *This = HTMLDOC_THIS(iface);
745 FIXME("(%p)->(%p)\n", This, p);
749 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
751 HTMLDocument *This = HTMLDOC_THIS(iface);
752 FIXME("(%p)->(%p)\n", This, p);
756 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
758 HTMLDocument *This = HTMLDOC_THIS(iface);
759 FIXME("(%p)->(%p)\n", This, p);
763 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
765 HTMLDocument *This = HTMLDOC_THIS(iface);
766 FIXME("(%p)->(%p)\n", This, p);
770 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
772 HTMLDocument *This = HTMLDOC_THIS(iface);
773 FIXME("(%p)->(%p)\n", This, p);
777 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
785 if(!This->doc_node->nsdoc) {
786 WARN("NULL nsdoc\n");
793 if(psarray->cDims != 1) {
794 FIXME("cDims=%d\n", psarray->cDims);
798 hres = SafeArrayAccessData(psarray, (void**)&var);
800 WARN("SafeArrayAccessData failed: %08x\n", hres);
804 nsAString_Init(&nsstr, NULL);
806 argc = psarray->rgsabound[0].cElements;
807 for(i=0; i < argc; i++) {
808 if(V_VT(var+i) == VT_BSTR) {
809 nsAString_SetData(&nsstr, V_BSTR(var+i));
810 if(!ln || i != argc-1)
811 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr);
813 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr);
815 ERR("Write failed: %08x\n", nsres);
817 FIXME("vt=%d\n", V_VT(var+i));
821 nsAString_Finish(&nsstr);
822 SafeArrayUnaccessData(psarray);
827 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
829 HTMLDocument *This = HTMLDOC_THIS(iface);
831 TRACE("(%p)->(%p)\n", iface, psarray);
833 return document_write(This, psarray, FALSE);
836 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
838 HTMLDocument *This = HTMLDOC_THIS(iface);
840 TRACE("(%p)->(%p)\n", This, psarray);
842 return document_write(This, psarray, TRUE);
845 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
846 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
848 HTMLDocument *This = HTMLDOC_THIS(iface);
851 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
853 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
854 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
856 if(!This->doc_node->nsdoc) {
861 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
862 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
863 FIXME("unsupported args\n");
865 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc);
866 if(NS_FAILED(nsres)) {
867 ERR("Open failed: %08x\n", nsres);
871 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
872 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
876 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
878 HTMLDocument *This = HTMLDOC_THIS(iface);
881 TRACE("(%p)\n", This);
883 if(!This->doc_node->nsdoc) {
888 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
889 if(NS_FAILED(nsres)) {
890 ERR("Close failed: %08x\n", nsres);
897 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
899 HTMLDocument *This = HTMLDOC_THIS(iface);
900 nsIDOMNSHTMLDocument *nsdoc;
903 TRACE("(%p)\n", This);
905 nsres = nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMNSHTMLDocument, (void**)&nsdoc);
906 if(NS_FAILED(nsres)) {
907 ERR("Could not get nsIDOMNSHTMLDocument iface: %08x\n", nsres);
911 nsres = nsIDOMNSHTMLDocument_Clear(nsdoc);
912 nsIDOMNSHTMLDocument_Release(nsdoc);
913 if(NS_FAILED(nsres)) {
914 ERR("Clear failed: %08x\n", nsres);
921 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
924 HTMLDocument *This = HTMLDOC_THIS(iface);
925 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
929 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
932 HTMLDocument *This = HTMLDOC_THIS(iface);
933 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
937 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
940 HTMLDocument *This = HTMLDOC_THIS(iface);
941 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
945 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
948 HTMLDocument *This = HTMLDOC_THIS(iface);
949 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
953 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
956 HTMLDocument *This = HTMLDOC_THIS(iface);
957 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
961 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
964 HTMLDocument *This = HTMLDOC_THIS(iface);
965 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
969 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
970 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
972 HTMLDocument *This = HTMLDOC_THIS(iface);
973 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
977 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
980 HTMLDocument *This = HTMLDOC_THIS(iface);
981 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
985 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
986 IHTMLElement **newElem)
988 HTMLDocument *This = HTMLDOC_THIS(iface);
989 nsIDOMHTMLElement *nselem;
993 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
995 hres = create_nselem(This->doc_node, eTag, &nselem);
999 hres = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE, &elem);
1000 nsIDOMHTMLElement_Release(nselem);
1004 *newElem = HTMLELEM(elem);
1005 IHTMLElement_AddRef(HTMLELEM(elem));
1009 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1011 HTMLDocument *This = HTMLDOC_THIS(iface);
1012 FIXME("(%p)\n", This);
1016 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1018 HTMLDocument *This = HTMLDOC_THIS(iface);
1019 FIXME("(%p)->(%p)\n", This, p);
1023 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1025 HTMLDocument *This = HTMLDOC_THIS(iface);
1027 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1029 return set_doc_event(This, EVENTID_CLICK, &v);
1032 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1034 HTMLDocument *This = HTMLDOC_THIS(iface);
1036 TRACE("(%p)->(%p)\n", This, p);
1038 return get_doc_event(This, EVENTID_CLICK, p);
1041 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1043 HTMLDocument *This = HTMLDOC_THIS(iface);
1044 FIXME("(%p)\n", This);
1048 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1050 HTMLDocument *This = HTMLDOC_THIS(iface);
1051 FIXME("(%p)->(%p)\n", This, p);
1055 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1057 HTMLDocument *This = HTMLDOC_THIS(iface);
1059 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1061 return set_doc_event(This, EVENTID_KEYUP, &v);
1064 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1066 HTMLDocument *This = HTMLDOC_THIS(iface);
1068 TRACE("(%p)->(%p)\n", This, p);
1070 return get_doc_event(This, EVENTID_KEYUP, p);
1073 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1075 HTMLDocument *This = HTMLDOC_THIS(iface);
1077 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1079 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1082 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1084 HTMLDocument *This = HTMLDOC_THIS(iface);
1086 TRACE("(%p)->(%p)\n", This, p);
1088 return get_doc_event(This, EVENTID_KEYDOWN, p);
1091 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1093 HTMLDocument *This = HTMLDOC_THIS(iface);
1094 FIXME("(%p)\n", This);
1098 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1100 HTMLDocument *This = HTMLDOC_THIS(iface);
1101 FIXME("(%p)->(%p)\n", This, p);
1105 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1107 HTMLDocument *This = HTMLDOC_THIS(iface);
1109 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1111 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1114 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1116 HTMLDocument *This = HTMLDOC_THIS(iface);
1118 TRACE("(%p)->(%p)\n", This, p);
1120 return get_doc_event(This, EVENTID_MOUSEUP, p);
1123 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1125 HTMLDocument *This = HTMLDOC_THIS(iface);
1127 TRACE("(%p)->()\n", This);
1129 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1132 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1134 HTMLDocument *This = HTMLDOC_THIS(iface);
1136 TRACE("(%p)->(%p)\n", This, p);
1138 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1141 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1143 HTMLDocument *This = HTMLDOC_THIS(iface);
1144 FIXME("(%p)\n", This);
1148 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1150 HTMLDocument *This = HTMLDOC_THIS(iface);
1151 FIXME("(%p)->(%p)\n", This, p);
1155 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1157 HTMLDocument *This = HTMLDOC_THIS(iface);
1159 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1161 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1164 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1166 HTMLDocument *This = HTMLDOC_THIS(iface);
1168 TRACE("(%p)->(%p)\n", This, p);
1170 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1173 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1175 HTMLDocument *This = HTMLDOC_THIS(iface);
1177 TRACE("(%p)\n", This);
1179 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1182 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1184 HTMLDocument *This = HTMLDOC_THIS(iface);
1186 TRACE("(%p)->(%p)\n", This, p);
1188 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1191 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1193 HTMLDocument *This = HTMLDOC_THIS(iface);
1195 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1197 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1200 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1202 HTMLDocument *This = HTMLDOC_THIS(iface);
1204 TRACE("(%p)->(%p)\n", This, p);
1206 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1209 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1211 HTMLDocument *This = HTMLDOC_THIS(iface);
1212 FIXME("(%p)\n", This);
1216 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1218 HTMLDocument *This = HTMLDOC_THIS(iface);
1219 FIXME("(%p)->(%p)\n", This, p);
1223 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1225 HTMLDocument *This = HTMLDOC_THIS(iface);
1226 FIXME("(%p)\n", This);
1230 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1232 HTMLDocument *This = HTMLDOC_THIS(iface);
1233 FIXME("(%p)->(%p)\n", This, p);
1237 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1239 HTMLDocument *This = HTMLDOC_THIS(iface);
1240 FIXME("(%p)\n", This);
1244 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1246 HTMLDocument *This = HTMLDOC_THIS(iface);
1247 FIXME("(%p)->(%p)\n", This, p);
1251 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1253 HTMLDocument *This = HTMLDOC_THIS(iface);
1255 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1257 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1260 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1262 HTMLDocument *This = HTMLDOC_THIS(iface);
1264 TRACE("(%p)->(%p)\n", This, p);
1266 return get_doc_event(This, EVENTID_DRAGSTART, p);
1269 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1271 HTMLDocument *This = HTMLDOC_THIS(iface);
1273 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1275 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1278 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1280 HTMLDocument *This = HTMLDOC_THIS(iface);
1282 TRACE("(%p)->(%p)\n", This, p);
1284 return get_doc_event(This, EVENTID_SELECTSTART, p);
1287 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1288 IHTMLElement **elementHit)
1290 HTMLDocument *This = HTMLDOC_THIS(iface);
1291 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1295 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1297 HTMLDocument *This = HTMLDOC_THIS(iface);
1299 TRACE("(%p)->(%p)\n", This, p);
1301 *p = HTMLWINDOW2(This->window);
1302 IHTMLWindow2_AddRef(*p);
1306 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1307 IHTMLStyleSheetsCollection **p)
1309 HTMLDocument *This = HTMLDOC_THIS(iface);
1310 nsIDOMStyleSheetList *nsstylelist;
1311 nsIDOMDocumentStyle *nsdocstyle;
1314 TRACE("(%p)->(%p)\n", This, p);
1318 if(!This->doc_node->nsdoc) {
1319 WARN("NULL nsdoc\n");
1320 return E_UNEXPECTED;
1323 nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1324 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1325 nsIDOMDocumentStyle_Release(nsdocstyle);
1326 if(NS_FAILED(nsres)) {
1327 ERR("GetStyleSheets failed: %08x\n", nsres);
1331 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1332 nsIDOMDocumentStyle_Release(nsstylelist);
1337 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1339 HTMLDocument *This = HTMLDOC_THIS(iface);
1340 FIXME("(%p)\n", This);
1344 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1346 HTMLDocument *This = HTMLDOC_THIS(iface);
1347 FIXME("(%p)->(%p)\n", This, p);
1351 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1353 HTMLDocument *This = HTMLDOC_THIS(iface);
1354 FIXME("(%p)\n", This);
1358 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1360 HTMLDocument *This = HTMLDOC_THIS(iface);
1361 FIXME("(%p)->(%p)\n", This, p);
1365 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1367 HTMLDocument *This = HTMLDOC_THIS(iface);
1368 FIXME("(%p)->(%p)\n", This, String);
1372 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1373 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1375 HTMLDocument *This = HTMLDOC_THIS(iface);
1377 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1379 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1383 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1384 HTMLDocument_QueryInterface,
1385 HTMLDocument_AddRef,
1386 HTMLDocument_Release,
1387 HTMLDocument_GetTypeInfoCount,
1388 HTMLDocument_GetTypeInfo,
1389 HTMLDocument_GetIDsOfNames,
1390 HTMLDocument_Invoke,
1391 HTMLDocument_get_Script,
1392 HTMLDocument_get_all,
1393 HTMLDocument_get_body,
1394 HTMLDocument_get_activeElement,
1395 HTMLDocument_get_images,
1396 HTMLDocument_get_applets,
1397 HTMLDocument_get_links,
1398 HTMLDocument_get_forms,
1399 HTMLDocument_get_anchors,
1400 HTMLDocument_put_title,
1401 HTMLDocument_get_title,
1402 HTMLDocument_get_scripts,
1403 HTMLDocument_put_designMode,
1404 HTMLDocument_get_designMode,
1405 HTMLDocument_get_selection,
1406 HTMLDocument_get_readyState,
1407 HTMLDocument_get_frames,
1408 HTMLDocument_get_embeds,
1409 HTMLDocument_get_plugins,
1410 HTMLDocument_put_alinkColor,
1411 HTMLDocument_get_alinkColor,
1412 HTMLDocument_put_bgColor,
1413 HTMLDocument_get_bgColor,
1414 HTMLDocument_put_fgColor,
1415 HTMLDocument_get_fgColor,
1416 HTMLDocument_put_linkColor,
1417 HTMLDocument_get_linkColor,
1418 HTMLDocument_put_vlinkColor,
1419 HTMLDocument_get_vlinkColor,
1420 HTMLDocument_get_referrer,
1421 HTMLDocument_get_location,
1422 HTMLDocument_get_lastModified,
1423 HTMLDocument_put_URL,
1424 HTMLDocument_get_URL,
1425 HTMLDocument_put_domain,
1426 HTMLDocument_get_domain,
1427 HTMLDocument_put_cookie,
1428 HTMLDocument_get_cookie,
1429 HTMLDocument_put_expando,
1430 HTMLDocument_get_expando,
1431 HTMLDocument_put_charset,
1432 HTMLDocument_get_charset,
1433 HTMLDocument_put_defaultCharset,
1434 HTMLDocument_get_defaultCharset,
1435 HTMLDocument_get_mimeType,
1436 HTMLDocument_get_fileSize,
1437 HTMLDocument_get_fileCreatedDate,
1438 HTMLDocument_get_fileModifiedDate,
1439 HTMLDocument_get_fileUpdatedDate,
1440 HTMLDocument_get_security,
1441 HTMLDocument_get_protocol,
1442 HTMLDocument_get_nameProp,
1444 HTMLDocument_writeln,
1448 HTMLDocument_queryCommandSupported,
1449 HTMLDocument_queryCommandEnabled,
1450 HTMLDocument_queryCommandState,
1451 HTMLDocument_queryCommandIndeterm,
1452 HTMLDocument_queryCommandText,
1453 HTMLDocument_queryCommandValue,
1454 HTMLDocument_execCommand,
1455 HTMLDocument_execCommandShowHelp,
1456 HTMLDocument_createElement,
1457 HTMLDocument_put_onhelp,
1458 HTMLDocument_get_onhelp,
1459 HTMLDocument_put_onclick,
1460 HTMLDocument_get_onclick,
1461 HTMLDocument_put_ondblclick,
1462 HTMLDocument_get_ondblclick,
1463 HTMLDocument_put_onkeyup,
1464 HTMLDocument_get_onkeyup,
1465 HTMLDocument_put_onkeydown,
1466 HTMLDocument_get_onkeydown,
1467 HTMLDocument_put_onkeypress,
1468 HTMLDocument_get_onkeypress,
1469 HTMLDocument_put_onmouseup,
1470 HTMLDocument_get_onmouseup,
1471 HTMLDocument_put_onmousedown,
1472 HTMLDocument_get_onmousedown,
1473 HTMLDocument_put_onmousemove,
1474 HTMLDocument_get_onmousemove,
1475 HTMLDocument_put_onmouseout,
1476 HTMLDocument_get_onmouseout,
1477 HTMLDocument_put_onmouseover,
1478 HTMLDocument_get_onmouseover,
1479 HTMLDocument_put_onreadystatechange,
1480 HTMLDocument_get_onreadystatechange,
1481 HTMLDocument_put_onafterupdate,
1482 HTMLDocument_get_onafterupdate,
1483 HTMLDocument_put_onrowexit,
1484 HTMLDocument_get_onrowexit,
1485 HTMLDocument_put_onrowenter,
1486 HTMLDocument_get_onrowenter,
1487 HTMLDocument_put_ondragstart,
1488 HTMLDocument_get_ondragstart,
1489 HTMLDocument_put_onselectstart,
1490 HTMLDocument_get_onselectstart,
1491 HTMLDocument_elementFromPoint,
1492 HTMLDocument_get_parentWindow,
1493 HTMLDocument_get_styleSheets,
1494 HTMLDocument_put_onbeforeupdate,
1495 HTMLDocument_get_onbeforeupdate,
1496 HTMLDocument_put_onerrorupdate,
1497 HTMLDocument_get_onerrorupdate,
1498 HTMLDocument_toString,
1499 HTMLDocument_createStyleSheet
1502 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
1504 HTMLDocument *This = HTMLDOC_THIS(iface);
1507 update_cp_events(This->window, &This->doc_node->node.event_target, cp, This->doc_node->node.nsnode);
1512 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1514 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1516 HTMLDocument *This = SUPPINFO_THIS(iface);
1517 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1520 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1522 HTMLDocument *This = SUPPINFO_THIS(iface);
1523 return IHTMLDocument_AddRef(HTMLDOC(This));
1526 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1528 HTMLDocument *This = SUPPINFO_THIS(iface);
1529 return IHTMLDocument_Release(HTMLDOC(This));
1532 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1534 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1538 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1539 SupportErrorInfo_QueryInterface,
1540 SupportErrorInfo_AddRef,
1541 SupportErrorInfo_Release,
1542 SupportErrorInfo_InterfaceSupportsErrorInfo
1545 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1547 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1549 HTMLDocument *This = DISPEX_THIS(iface);
1551 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1554 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1556 HTMLDocument *This = DISPEX_THIS(iface);
1558 return IHTMLDocument2_AddRef(HTMLDOC(This));
1561 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1563 HTMLDocument *This = DISPEX_THIS(iface);
1565 return IHTMLDocument2_Release(HTMLDOC(This));
1568 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1570 HTMLDocument *This = DISPEX_THIS(iface);
1572 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
1575 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1576 LCID lcid, ITypeInfo **ppTInfo)
1578 HTMLDocument *This = DISPEX_THIS(iface);
1580 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
1583 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1584 LPOLESTR *rgszNames, UINT cNames,
1585 LCID lcid, DISPID *rgDispId)
1587 HTMLDocument *This = DISPEX_THIS(iface);
1589 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
1592 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1593 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1594 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1596 HTMLDocument *This = DISPEX_THIS(iface);
1598 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1599 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1601 switch(dispIdMember) {
1602 case DISPID_READYSTATE:
1603 TRACE("DISPID_READYSTATE\n");
1605 if(!(wFlags & DISPATCH_PROPERTYGET))
1606 return E_INVALIDARG;
1608 V_VT(pVarResult) = VT_I4;
1609 V_I4(pVarResult) = This->window->readystate;
1613 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
1614 pVarResult, pExcepInfo, puArgErr);
1617 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1619 HTMLDocument *This = DISPEX_THIS(iface);
1621 return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
1624 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1625 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1627 HTMLDocument *This = DISPEX_THIS(iface);
1629 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
1630 return IDispatchEx_InvokeEx(DISPATCHEX(This->window), DISPID_IHTMLWINDOW2_LOCATION, lcid, wFlags,
1631 pdp, pvarRes, pei, pspCaller);
1634 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1637 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1639 HTMLDocument *This = DISPEX_THIS(iface);
1641 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
1644 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1646 HTMLDocument *This = DISPEX_THIS(iface);
1648 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
1651 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1653 HTMLDocument *This = DISPEX_THIS(iface);
1655 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
1658 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1660 HTMLDocument *This = DISPEX_THIS(iface);
1662 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
1665 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1667 HTMLDocument *This = DISPEX_THIS(iface);
1669 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
1672 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1674 HTMLDocument *This = DISPEX_THIS(iface);
1676 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
1681 static const IDispatchExVtbl DocDispatchExVtbl = {
1682 DocDispatchEx_QueryInterface,
1683 DocDispatchEx_AddRef,
1684 DocDispatchEx_Release,
1685 DocDispatchEx_GetTypeInfoCount,
1686 DocDispatchEx_GetTypeInfo,
1687 DocDispatchEx_GetIDsOfNames,
1688 DocDispatchEx_Invoke,
1689 DocDispatchEx_GetDispID,
1690 DocDispatchEx_InvokeEx,
1691 DocDispatchEx_DeleteMemberByName,
1692 DocDispatchEx_DeleteMemberByDispID,
1693 DocDispatchEx_GetMemberProperties,
1694 DocDispatchEx_GetMemberName,
1695 DocDispatchEx_GetNextDispID,
1696 DocDispatchEx_GetNameSpaceParent
1699 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
1703 if(IsEqualGUID(&IID_IUnknown, riid)) {
1704 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
1705 *ppv = HTMLDOC(This);
1706 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1707 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv);
1708 *ppv = DISPATCHEX(This);
1709 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
1710 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv);
1711 *ppv = DISPATCHEX(This);
1712 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
1713 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv);
1714 *ppv = HTMLDOC(This);
1715 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
1716 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppv);
1717 *ppv = HTMLDOC(This);
1718 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
1719 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppv);
1720 *ppv = HTMLDOC3(This);
1721 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
1722 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppv);
1723 *ppv = HTMLDOC4(This);
1724 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
1725 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppv);
1726 *ppv = HTMLDOC5(This);
1727 }else if(IsEqualGUID(&IID_IHTMLDocument6, riid)) {
1728 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This, ppv);
1729 *ppv = HTMLDOC6(This);
1730 }else if(IsEqualGUID(&IID_IPersist, riid)) {
1731 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
1732 *ppv = PERSIST(This);
1733 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
1734 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppv);
1735 *ppv = PERSISTMON(This);
1736 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
1737 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppv);
1738 *ppv = PERSISTFILE(This);
1739 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
1740 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppv);
1741 *ppv = MONPROP(This);
1742 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
1743 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppv);
1744 *ppv = OLEOBJ(This);
1745 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
1746 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppv);
1747 *ppv = OLEDOC(This);
1748 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
1749 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppv);
1750 *ppv = DOCVIEW(This);
1751 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
1752 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
1753 *ppv = ACTOBJ(This);
1754 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
1755 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
1756 *ppv = VIEWOBJ(This);
1757 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
1758 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
1759 *ppv = VIEWOBJ2(This);
1760 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
1761 TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This, ppv);
1762 *ppv = VIEWOBJEX(This);
1763 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
1764 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
1765 *ppv = OLEWIN(This);
1766 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
1767 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
1768 *ppv = INPLACEOBJ(This);
1769 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1770 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppv);
1771 *ppv = INPLACEWIN(This);
1772 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1773 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
1774 *ppv = SERVPROV(This);
1775 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
1776 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppv);
1777 *ppv = CMDTARGET(This);
1778 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
1779 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppv);
1780 *ppv = CONTROL(This);
1781 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
1782 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppv);
1783 *ppv = HLNKTARGET(This);
1784 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1785 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1786 *ppv = CONPTCONT(&This->cp_container);
1787 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
1788 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
1789 *ppv = PERSTRINIT(This);
1790 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
1791 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
1792 *ppv = HTMLDOC(This);
1793 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
1794 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppv);
1795 *ppv = SUPPERRINFO(This);
1796 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
1797 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppv);
1798 *ppv = PERSISTHIST(This);
1799 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
1800 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
1802 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
1803 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
1805 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
1806 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
1808 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
1809 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
1811 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
1812 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
1814 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
1815 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
1817 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
1818 TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv);
1819 *ppv = OBJSITE(This);
1825 IUnknown_AddRef((IUnknown*)*ppv);
1829 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
1831 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
1833 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1834 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1835 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1837 doc->unk_impl = unk_impl;
1838 doc->dispex = dispex;
1839 doc->task_magic = get_task_target_magic();
1841 HTMLDocument_HTMLDocument3_Init(doc);
1842 HTMLDocument_HTMLDocument5_Init(doc);
1843 HTMLDocument_Persist_Init(doc);
1844 HTMLDocument_OleCmd_Init(doc);
1845 HTMLDocument_OleObj_Init(doc);
1846 HTMLDocument_View_Init(doc);
1847 HTMLDocument_Window_Init(doc);
1848 HTMLDocument_Service_Init(doc);
1849 HTMLDocument_Hlink_Init(doc);
1851 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1852 ConnectionPoint_Init(&doc->cp_dispatch, &doc->cp_container, &IID_IDispatch, NULL);
1853 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink, NULL);
1854 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data);
1855 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2, NULL);
1858 static void destroy_htmldoc(HTMLDocument *This)
1860 remove_target_tasks(This->task_magic);
1862 ConnectionPointContainer_Destroy(&This->cp_container);
1865 #define HTMLDOCNODE_NODE_THIS(iface) DEFINE_THIS2(HTMLDocumentNode, node, iface)
1867 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1869 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1871 if(htmldoc_qi(&This->basedoc, riid, ppv))
1872 return *ppv ? S_OK : E_NOINTERFACE;
1874 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid)) {
1875 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This, ppv);
1876 *ppv = HOSTSECMGR(This);
1878 return HTMLDOMNode_QI(&This->node, riid, ppv);
1881 IUnknown_AddRef((IUnknown*)*ppv);
1885 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
1887 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1889 if(This->body_event_target)
1890 release_event_target(This->body_event_target);
1891 if(This->nsevent_listener)
1892 release_nsevents(This);
1894 ICatInformation_Release(This->catmgr);
1896 IInternetSecurityManager_Release(This->secmgr);
1898 detach_selection(This);
1899 detach_ranges(This);
1900 release_nodes(This);
1903 release_mutation(This);
1904 nsIDOMHTMLDocument_Release(This->nsdoc);
1907 heap_free(This->event_vector);
1908 destroy_htmldoc(&This->basedoc);
1911 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1913 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1914 FIXME("%p\n", This);
1918 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
1919 HTMLDocumentNode_QI,
1920 HTMLDocumentNode_destructor,
1921 HTMLDocumentNode_clone
1924 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1926 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1927 HTMLDocumentNode *new_node;
1930 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
1934 *ret = &new_node->node;
1938 #undef HTMLDOCNODE_NODE_THIS
1940 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
1941 HTMLDocumentNode_QI,
1942 HTMLDocumentNode_destructor,
1943 HTMLDocumentFragment_clone
1946 static const tid_t HTMLDocumentNode_iface_tids[] = {
1956 static dispex_static_data_t HTMLDocumentNode_dispex = {
1958 DispHTMLDocument_tid,
1960 HTMLDocumentNode_iface_tids
1963 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLWindow *window)
1965 HTMLDocumentNode *doc;
1967 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
1972 doc->basedoc.doc_node = doc;
1973 doc->basedoc.doc_obj = doc_obj;
1974 doc->basedoc.window = window;
1976 init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
1977 init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
1978 HTMLDocumentNode_SecMgr_Init(doc);
1982 list_init(&doc->bindings);
1983 list_init(&doc->selection_list);
1984 list_init(&doc->range_list);
1989 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret)
1991 HTMLDocumentNode *doc;
1994 doc = alloc_doc_node(doc_obj, window);
1996 return E_OUTOFMEMORY;
1998 if(window == doc_obj->basedoc.window)
1999 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
2001 nsIDOMHTMLDocument_AddRef(nsdoc);
2005 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
2006 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
2007 doc->node.cp_container = &doc->basedoc.cp_container;
2009 hres = CoInternetCreateSecurityManager(NULL, &doc->secmgr, 0);
2011 htmldoc_release(&doc->basedoc);
2019 HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
2021 HTMLDocumentNode *doc_frag;
2023 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->basedoc.window);
2025 return E_OUTOFMEMORY;
2027 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
2028 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
2029 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
2031 htmldoc_addref(&doc_frag->basedoc);
2036 /**********************************************************
2037 * ICustomDoc implementation
2040 #define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocumentObj, CustomDoc, iface)
2042 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
2044 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2046 if(htmldoc_qi(&This->basedoc, riid, ppv))
2047 return *ppv ? S_OK : E_NOINTERFACE;
2049 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
2050 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
2051 *ppv = CUSTOMDOC(This);
2052 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2053 return *ppv ? S_OK : E_NOINTERFACE;
2055 FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
2057 return E_NOINTERFACE;
2060 IUnknown_AddRef((IUnknown*)*ppv);
2064 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
2066 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2067 ULONG ref = InterlockedIncrement(&This->ref);
2069 TRACE("(%p) ref = %u\n", This, ref);
2074 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
2076 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2077 ULONG ref = InterlockedDecrement(&This->ref);
2079 TRACE("(%p) ref = %u\n", This, ref);
2082 if(This->basedoc.doc_node) {
2083 This->basedoc.doc_node->basedoc.doc_obj = NULL;
2084 IHTMLDocument2_Release(HTMLDOC(&This->basedoc.doc_node->basedoc));
2086 if(This->basedoc.window) {
2087 This->basedoc.window->doc_obj = NULL;
2088 IHTMLWindow2_Release(HTMLWINDOW2(This->basedoc.window));
2090 if(This->basedoc.advise_holder)
2091 IOleAdviseHolder_Release(This->basedoc.advise_holder);
2094 IAdviseSink_Release(This->view_sink);
2096 IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL);
2098 ICustomDoc_SetUIHandler(CUSTOMDOC(This), NULL);
2099 if(This->in_place_active)
2100 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(&This->basedoc));
2102 IOleDocumentView_SetInPlaceSite(DOCVIEW(&This->basedoc), NULL);
2104 IOleUndoManager_Release(This->undomgr);
2105 if(This->tooltips_hwnd)
2106 DestroyWindow(This->tooltips_hwnd);
2109 DestroyWindow(This->hwnd);
2110 heap_free(This->mime);
2112 destroy_htmldoc(&This->basedoc);
2113 release_dispex(&This->dispex);
2115 if(This->nscontainer)
2116 NSContainer_Release(This->nscontainer);
2123 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
2125 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2126 IOleCommandTarget *cmdtrg;
2129 TRACE("(%p)->(%p)\n", This, pUIHandler);
2131 if(This->custom_hostui && This->hostui == pUIHandler)
2134 This->custom_hostui = TRUE;
2137 IDocHostUIHandler_Release(This->hostui);
2139 IDocHostUIHandler_AddRef(pUIHandler);
2140 This->hostui = pUIHandler;
2144 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
2145 if(SUCCEEDED(hres)) {
2146 FIXME("custom UI handler supports IOleCommandTarget\n");
2147 IOleCommandTarget_Release(cmdtrg);
2153 #undef CUSTOMDOC_THIS
2155 static const ICustomDocVtbl CustomDocVtbl = {
2156 CustomDoc_QueryInterface,
2159 CustomDoc_SetUIHandler
2162 static const tid_t HTMLDocumentObj_iface_tids[] = {
2169 static dispex_static_data_t HTMLDocumentObj_dispex = {
2171 DispHTMLDocument_tid,
2173 HTMLDocumentObj_iface_tids
2176 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
2178 HTMLDocumentObj *doc;
2179 nsIDOMWindow *nswindow = NULL;
2183 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2185 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
2187 return E_OUTOFMEMORY;
2189 init_dispex(&doc->dispex, (IUnknown*)CUSTOMDOC(doc), &HTMLDocumentObj_dispex);
2190 init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc), DISPATCHEX(&doc->dispex));
2192 doc->lpCustomDocVtbl = &CustomDocVtbl;
2194 doc->basedoc.doc_obj = doc;
2196 doc->usermode = UNKNOWN_USERMODE;
2198 doc->nscontainer = NSContainer_Create(doc, NULL);
2199 if(!doc->nscontainer) {
2200 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2201 htmldoc_release(&doc->basedoc);
2202 return CLASS_E_CLASSNOTAVAILABLE;
2205 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
2206 htmldoc_release(&doc->basedoc);
2211 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
2212 if(NS_FAILED(nsres))
2213 ERR("GetContentDOMWindow failed: %08x\n", nsres);
2215 hres = HTMLWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
2217 nsIDOMWindow_Release(nswindow);
2219 IHTMLDocument_Release(HTMLDOC(&doc->basedoc));
2223 if(!doc->basedoc.doc_node && doc->basedoc.window->doc) {
2224 doc->basedoc.doc_node = doc->basedoc.window->doc;
2225 htmldoc_addref(&doc->basedoc.doc_node->basedoc);