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 elem = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE);
1000 nsIDOMHTMLElement_Release(nselem);
1002 *newElem = HTMLELEM(elem);
1003 IHTMLElement_AddRef(HTMLELEM(elem));
1007 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1009 HTMLDocument *This = HTMLDOC_THIS(iface);
1010 FIXME("(%p)\n", This);
1014 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1016 HTMLDocument *This = HTMLDOC_THIS(iface);
1017 FIXME("(%p)->(%p)\n", This, p);
1021 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1023 HTMLDocument *This = HTMLDOC_THIS(iface);
1025 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1027 return set_doc_event(This, EVENTID_CLICK, &v);
1030 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1032 HTMLDocument *This = HTMLDOC_THIS(iface);
1034 TRACE("(%p)->(%p)\n", This, p);
1036 return get_doc_event(This, EVENTID_CLICK, p);
1039 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1041 HTMLDocument *This = HTMLDOC_THIS(iface);
1042 FIXME("(%p)\n", This);
1046 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1048 HTMLDocument *This = HTMLDOC_THIS(iface);
1049 FIXME("(%p)->(%p)\n", This, p);
1053 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1055 HTMLDocument *This = HTMLDOC_THIS(iface);
1057 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1059 return set_doc_event(This, EVENTID_KEYUP, &v);
1062 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1064 HTMLDocument *This = HTMLDOC_THIS(iface);
1066 TRACE("(%p)->(%p)\n", This, p);
1068 return get_doc_event(This, EVENTID_KEYUP, p);
1071 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1073 HTMLDocument *This = HTMLDOC_THIS(iface);
1075 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1077 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1080 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1082 HTMLDocument *This = HTMLDOC_THIS(iface);
1084 TRACE("(%p)->(%p)\n", This, p);
1086 return get_doc_event(This, EVENTID_KEYDOWN, p);
1089 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1091 HTMLDocument *This = HTMLDOC_THIS(iface);
1092 FIXME("(%p)\n", This);
1096 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1098 HTMLDocument *This = HTMLDOC_THIS(iface);
1099 FIXME("(%p)->(%p)\n", This, p);
1103 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1105 HTMLDocument *This = HTMLDOC_THIS(iface);
1107 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1109 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1112 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1114 HTMLDocument *This = HTMLDOC_THIS(iface);
1116 TRACE("(%p)->(%p)\n", This, p);
1118 return get_doc_event(This, EVENTID_MOUSEUP, p);
1121 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1123 HTMLDocument *This = HTMLDOC_THIS(iface);
1125 TRACE("(%p)->()\n", This);
1127 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1130 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1132 HTMLDocument *This = HTMLDOC_THIS(iface);
1134 TRACE("(%p)->(%p)\n", This, p);
1136 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1139 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1141 HTMLDocument *This = HTMLDOC_THIS(iface);
1142 FIXME("(%p)\n", This);
1146 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1148 HTMLDocument *This = HTMLDOC_THIS(iface);
1149 FIXME("(%p)->(%p)\n", This, p);
1153 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1155 HTMLDocument *This = HTMLDOC_THIS(iface);
1157 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1159 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1162 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1164 HTMLDocument *This = HTMLDOC_THIS(iface);
1166 TRACE("(%p)->(%p)\n", This, p);
1168 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1171 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1173 HTMLDocument *This = HTMLDOC_THIS(iface);
1175 TRACE("(%p)\n", This);
1177 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1180 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1182 HTMLDocument *This = HTMLDOC_THIS(iface);
1184 TRACE("(%p)->(%p)\n", This, p);
1186 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1189 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1191 HTMLDocument *This = HTMLDOC_THIS(iface);
1193 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1195 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1198 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1200 HTMLDocument *This = HTMLDOC_THIS(iface);
1202 TRACE("(%p)->(%p)\n", This, p);
1204 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1207 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1209 HTMLDocument *This = HTMLDOC_THIS(iface);
1210 FIXME("(%p)\n", This);
1214 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1216 HTMLDocument *This = HTMLDOC_THIS(iface);
1217 FIXME("(%p)->(%p)\n", This, p);
1221 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1223 HTMLDocument *This = HTMLDOC_THIS(iface);
1224 FIXME("(%p)\n", This);
1228 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1230 HTMLDocument *This = HTMLDOC_THIS(iface);
1231 FIXME("(%p)->(%p)\n", This, p);
1235 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1237 HTMLDocument *This = HTMLDOC_THIS(iface);
1238 FIXME("(%p)\n", This);
1242 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1244 HTMLDocument *This = HTMLDOC_THIS(iface);
1245 FIXME("(%p)->(%p)\n", This, p);
1249 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1251 HTMLDocument *This = HTMLDOC_THIS(iface);
1253 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1255 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1258 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1260 HTMLDocument *This = HTMLDOC_THIS(iface);
1262 TRACE("(%p)->(%p)\n", This, p);
1264 return get_doc_event(This, EVENTID_DRAGSTART, p);
1267 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1269 HTMLDocument *This = HTMLDOC_THIS(iface);
1271 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1273 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1276 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1278 HTMLDocument *This = HTMLDOC_THIS(iface);
1280 TRACE("(%p)->(%p)\n", This, p);
1282 return get_doc_event(This, EVENTID_SELECTSTART, p);
1285 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1286 IHTMLElement **elementHit)
1288 HTMLDocument *This = HTMLDOC_THIS(iface);
1289 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1293 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1295 HTMLDocument *This = HTMLDOC_THIS(iface);
1297 TRACE("(%p)->(%p)\n", This, p);
1299 *p = HTMLWINDOW2(This->window);
1300 IHTMLWindow2_AddRef(*p);
1304 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1305 IHTMLStyleSheetsCollection **p)
1307 HTMLDocument *This = HTMLDOC_THIS(iface);
1308 nsIDOMStyleSheetList *nsstylelist;
1309 nsIDOMDocumentStyle *nsdocstyle;
1312 TRACE("(%p)->(%p)\n", This, p);
1316 if(!This->doc_node->nsdoc) {
1317 WARN("NULL nsdoc\n");
1318 return E_UNEXPECTED;
1321 nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1322 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1323 nsIDOMDocumentStyle_Release(nsdocstyle);
1324 if(NS_FAILED(nsres)) {
1325 ERR("GetStyleSheets failed: %08x\n", nsres);
1329 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1330 nsIDOMDocumentStyle_Release(nsstylelist);
1335 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1337 HTMLDocument *This = HTMLDOC_THIS(iface);
1338 FIXME("(%p)\n", This);
1342 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1344 HTMLDocument *This = HTMLDOC_THIS(iface);
1345 FIXME("(%p)->(%p)\n", This, p);
1349 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1351 HTMLDocument *This = HTMLDOC_THIS(iface);
1352 FIXME("(%p)\n", This);
1356 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1358 HTMLDocument *This = HTMLDOC_THIS(iface);
1359 FIXME("(%p)->(%p)\n", This, p);
1363 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1365 HTMLDocument *This = HTMLDOC_THIS(iface);
1366 FIXME("(%p)->(%p)\n", This, String);
1370 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1371 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1373 HTMLDocument *This = HTMLDOC_THIS(iface);
1375 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1377 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1381 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1382 HTMLDocument_QueryInterface,
1383 HTMLDocument_AddRef,
1384 HTMLDocument_Release,
1385 HTMLDocument_GetTypeInfoCount,
1386 HTMLDocument_GetTypeInfo,
1387 HTMLDocument_GetIDsOfNames,
1388 HTMLDocument_Invoke,
1389 HTMLDocument_get_Script,
1390 HTMLDocument_get_all,
1391 HTMLDocument_get_body,
1392 HTMLDocument_get_activeElement,
1393 HTMLDocument_get_images,
1394 HTMLDocument_get_applets,
1395 HTMLDocument_get_links,
1396 HTMLDocument_get_forms,
1397 HTMLDocument_get_anchors,
1398 HTMLDocument_put_title,
1399 HTMLDocument_get_title,
1400 HTMLDocument_get_scripts,
1401 HTMLDocument_put_designMode,
1402 HTMLDocument_get_designMode,
1403 HTMLDocument_get_selection,
1404 HTMLDocument_get_readyState,
1405 HTMLDocument_get_frames,
1406 HTMLDocument_get_embeds,
1407 HTMLDocument_get_plugins,
1408 HTMLDocument_put_alinkColor,
1409 HTMLDocument_get_alinkColor,
1410 HTMLDocument_put_bgColor,
1411 HTMLDocument_get_bgColor,
1412 HTMLDocument_put_fgColor,
1413 HTMLDocument_get_fgColor,
1414 HTMLDocument_put_linkColor,
1415 HTMLDocument_get_linkColor,
1416 HTMLDocument_put_vlinkColor,
1417 HTMLDocument_get_vlinkColor,
1418 HTMLDocument_get_referrer,
1419 HTMLDocument_get_location,
1420 HTMLDocument_get_lastModified,
1421 HTMLDocument_put_URL,
1422 HTMLDocument_get_URL,
1423 HTMLDocument_put_domain,
1424 HTMLDocument_get_domain,
1425 HTMLDocument_put_cookie,
1426 HTMLDocument_get_cookie,
1427 HTMLDocument_put_expando,
1428 HTMLDocument_get_expando,
1429 HTMLDocument_put_charset,
1430 HTMLDocument_get_charset,
1431 HTMLDocument_put_defaultCharset,
1432 HTMLDocument_get_defaultCharset,
1433 HTMLDocument_get_mimeType,
1434 HTMLDocument_get_fileSize,
1435 HTMLDocument_get_fileCreatedDate,
1436 HTMLDocument_get_fileModifiedDate,
1437 HTMLDocument_get_fileUpdatedDate,
1438 HTMLDocument_get_security,
1439 HTMLDocument_get_protocol,
1440 HTMLDocument_get_nameProp,
1442 HTMLDocument_writeln,
1446 HTMLDocument_queryCommandSupported,
1447 HTMLDocument_queryCommandEnabled,
1448 HTMLDocument_queryCommandState,
1449 HTMLDocument_queryCommandIndeterm,
1450 HTMLDocument_queryCommandText,
1451 HTMLDocument_queryCommandValue,
1452 HTMLDocument_execCommand,
1453 HTMLDocument_execCommandShowHelp,
1454 HTMLDocument_createElement,
1455 HTMLDocument_put_onhelp,
1456 HTMLDocument_get_onhelp,
1457 HTMLDocument_put_onclick,
1458 HTMLDocument_get_onclick,
1459 HTMLDocument_put_ondblclick,
1460 HTMLDocument_get_ondblclick,
1461 HTMLDocument_put_onkeyup,
1462 HTMLDocument_get_onkeyup,
1463 HTMLDocument_put_onkeydown,
1464 HTMLDocument_get_onkeydown,
1465 HTMLDocument_put_onkeypress,
1466 HTMLDocument_get_onkeypress,
1467 HTMLDocument_put_onmouseup,
1468 HTMLDocument_get_onmouseup,
1469 HTMLDocument_put_onmousedown,
1470 HTMLDocument_get_onmousedown,
1471 HTMLDocument_put_onmousemove,
1472 HTMLDocument_get_onmousemove,
1473 HTMLDocument_put_onmouseout,
1474 HTMLDocument_get_onmouseout,
1475 HTMLDocument_put_onmouseover,
1476 HTMLDocument_get_onmouseover,
1477 HTMLDocument_put_onreadystatechange,
1478 HTMLDocument_get_onreadystatechange,
1479 HTMLDocument_put_onafterupdate,
1480 HTMLDocument_get_onafterupdate,
1481 HTMLDocument_put_onrowexit,
1482 HTMLDocument_get_onrowexit,
1483 HTMLDocument_put_onrowenter,
1484 HTMLDocument_get_onrowenter,
1485 HTMLDocument_put_ondragstart,
1486 HTMLDocument_get_ondragstart,
1487 HTMLDocument_put_onselectstart,
1488 HTMLDocument_get_onselectstart,
1489 HTMLDocument_elementFromPoint,
1490 HTMLDocument_get_parentWindow,
1491 HTMLDocument_get_styleSheets,
1492 HTMLDocument_put_onbeforeupdate,
1493 HTMLDocument_get_onbeforeupdate,
1494 HTMLDocument_put_onerrorupdate,
1495 HTMLDocument_get_onerrorupdate,
1496 HTMLDocument_toString,
1497 HTMLDocument_createStyleSheet
1500 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
1502 HTMLDocument *This = HTMLDOC_THIS(iface);
1505 update_cp_events(This->window, &This->doc_node->node.event_target, cp, This->doc_node->node.nsnode);
1510 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1512 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1514 HTMLDocument *This = SUPPINFO_THIS(iface);
1515 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1518 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1520 HTMLDocument *This = SUPPINFO_THIS(iface);
1521 return IHTMLDocument_AddRef(HTMLDOC(This));
1524 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1526 HTMLDocument *This = SUPPINFO_THIS(iface);
1527 return IHTMLDocument_Release(HTMLDOC(This));
1530 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1532 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1536 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1537 SupportErrorInfo_QueryInterface,
1538 SupportErrorInfo_AddRef,
1539 SupportErrorInfo_Release,
1540 SupportErrorInfo_InterfaceSupportsErrorInfo
1543 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1545 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1547 HTMLDocument *This = DISPEX_THIS(iface);
1549 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1552 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1554 HTMLDocument *This = DISPEX_THIS(iface);
1556 return IHTMLDocument2_AddRef(HTMLDOC(This));
1559 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1561 HTMLDocument *This = DISPEX_THIS(iface);
1563 return IHTMLDocument2_Release(HTMLDOC(This));
1566 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1568 HTMLDocument *This = DISPEX_THIS(iface);
1570 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
1573 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1574 LCID lcid, ITypeInfo **ppTInfo)
1576 HTMLDocument *This = DISPEX_THIS(iface);
1578 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
1581 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1582 LPOLESTR *rgszNames, UINT cNames,
1583 LCID lcid, DISPID *rgDispId)
1585 HTMLDocument *This = DISPEX_THIS(iface);
1587 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
1590 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1591 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1592 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1594 HTMLDocument *This = DISPEX_THIS(iface);
1596 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1597 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1599 switch(dispIdMember) {
1600 case DISPID_READYSTATE:
1601 TRACE("DISPID_READYSTATE\n");
1603 if(!(wFlags & DISPATCH_PROPERTYGET))
1604 return E_INVALIDARG;
1606 V_VT(pVarResult) = VT_I4;
1607 V_I4(pVarResult) = This->window->readystate;
1611 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
1612 pVarResult, pExcepInfo, puArgErr);
1615 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1617 HTMLDocument *This = DISPEX_THIS(iface);
1619 return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
1622 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1623 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1625 HTMLDocument *This = DISPEX_THIS(iface);
1627 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
1628 return IDispatchEx_InvokeEx(DISPATCHEX(This->window), DISPID_IHTMLWINDOW2_LOCATION, lcid, wFlags,
1629 pdp, pvarRes, pei, pspCaller);
1632 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1635 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1637 HTMLDocument *This = DISPEX_THIS(iface);
1639 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
1642 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1644 HTMLDocument *This = DISPEX_THIS(iface);
1646 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
1649 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1651 HTMLDocument *This = DISPEX_THIS(iface);
1653 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
1656 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1658 HTMLDocument *This = DISPEX_THIS(iface);
1660 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
1663 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1665 HTMLDocument *This = DISPEX_THIS(iface);
1667 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
1670 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1672 HTMLDocument *This = DISPEX_THIS(iface);
1674 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
1679 static const IDispatchExVtbl DocDispatchExVtbl = {
1680 DocDispatchEx_QueryInterface,
1681 DocDispatchEx_AddRef,
1682 DocDispatchEx_Release,
1683 DocDispatchEx_GetTypeInfoCount,
1684 DocDispatchEx_GetTypeInfo,
1685 DocDispatchEx_GetIDsOfNames,
1686 DocDispatchEx_Invoke,
1687 DocDispatchEx_GetDispID,
1688 DocDispatchEx_InvokeEx,
1689 DocDispatchEx_DeleteMemberByName,
1690 DocDispatchEx_DeleteMemberByDispID,
1691 DocDispatchEx_GetMemberProperties,
1692 DocDispatchEx_GetMemberName,
1693 DocDispatchEx_GetNextDispID,
1694 DocDispatchEx_GetNameSpaceParent
1697 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
1701 if(IsEqualGUID(&IID_IUnknown, riid)) {
1702 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
1703 *ppv = HTMLDOC(This);
1704 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1705 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv);
1706 *ppv = DISPATCHEX(This);
1707 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
1708 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv);
1709 *ppv = DISPATCHEX(This);
1710 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
1711 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv);
1712 *ppv = HTMLDOC(This);
1713 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
1714 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppv);
1715 *ppv = HTMLDOC(This);
1716 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
1717 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppv);
1718 *ppv = HTMLDOC3(This);
1719 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
1720 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppv);
1721 *ppv = HTMLDOC4(This);
1722 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
1723 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppv);
1724 *ppv = HTMLDOC5(This);
1725 }else if(IsEqualGUID(&IID_IHTMLDocument6, riid)) {
1726 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This, ppv);
1727 *ppv = HTMLDOC6(This);
1728 }else if(IsEqualGUID(&IID_IPersist, riid)) {
1729 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
1730 *ppv = PERSIST(This);
1731 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
1732 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppv);
1733 *ppv = PERSISTMON(This);
1734 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
1735 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppv);
1736 *ppv = PERSISTFILE(This);
1737 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
1738 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppv);
1739 *ppv = MONPROP(This);
1740 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
1741 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppv);
1742 *ppv = OLEOBJ(This);
1743 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
1744 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppv);
1745 *ppv = OLEDOC(This);
1746 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
1747 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppv);
1748 *ppv = DOCVIEW(This);
1749 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
1750 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
1751 *ppv = ACTOBJ(This);
1752 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
1753 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
1754 *ppv = VIEWOBJ(This);
1755 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
1756 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
1757 *ppv = VIEWOBJ2(This);
1758 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
1759 TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This, ppv);
1760 *ppv = VIEWOBJEX(This);
1761 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
1762 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
1763 *ppv = OLEWIN(This);
1764 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
1765 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
1766 *ppv = INPLACEOBJ(This);
1767 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1768 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppv);
1769 *ppv = INPLACEWIN(This);
1770 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1771 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
1772 *ppv = SERVPROV(This);
1773 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
1774 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppv);
1775 *ppv = CMDTARGET(This);
1776 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
1777 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppv);
1778 *ppv = CONTROL(This);
1779 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
1780 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppv);
1781 *ppv = HLNKTARGET(This);
1782 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1783 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1784 *ppv = CONPTCONT(&This->cp_container);
1785 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
1786 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
1787 *ppv = PERSTRINIT(This);
1788 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
1789 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
1790 *ppv = HTMLDOC(This);
1791 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
1792 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppv);
1793 *ppv = SUPPERRINFO(This);
1794 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
1795 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppv);
1796 *ppv = PERSISTHIST(This);
1797 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
1798 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
1800 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
1801 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
1803 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
1804 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
1806 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
1807 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
1809 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
1810 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
1812 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
1813 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
1815 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
1816 TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv);
1817 *ppv = OBJSITE(This);
1823 IUnknown_AddRef((IUnknown*)*ppv);
1827 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
1829 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
1831 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1832 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1833 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1835 doc->unk_impl = unk_impl;
1836 doc->dispex = dispex;
1837 doc->task_magic = get_task_target_magic();
1839 HTMLDocument_HTMLDocument3_Init(doc);
1840 HTMLDocument_HTMLDocument5_Init(doc);
1841 HTMLDocument_Persist_Init(doc);
1842 HTMLDocument_OleCmd_Init(doc);
1843 HTMLDocument_OleObj_Init(doc);
1844 HTMLDocument_View_Init(doc);
1845 HTMLDocument_Window_Init(doc);
1846 HTMLDocument_Service_Init(doc);
1847 HTMLDocument_Hlink_Init(doc);
1849 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1850 ConnectionPoint_Init(&doc->cp_dispatch, &doc->cp_container, &IID_IDispatch, NULL);
1851 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink, NULL);
1852 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data);
1853 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2, NULL);
1856 static void destroy_htmldoc(HTMLDocument *This)
1858 remove_target_tasks(This->task_magic);
1860 ConnectionPointContainer_Destroy(&This->cp_container);
1863 #define HTMLDOCNODE_NODE_THIS(iface) DEFINE_THIS2(HTMLDocumentNode, node, iface)
1865 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1867 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1869 if(htmldoc_qi(&This->basedoc, riid, ppv))
1870 return *ppv ? S_OK : E_NOINTERFACE;
1872 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid)) {
1873 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This, ppv);
1874 *ppv = HOSTSECMGR(This);
1876 return HTMLDOMNode_QI(&This->node, riid, ppv);
1879 IUnknown_AddRef((IUnknown*)*ppv);
1883 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
1885 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1887 if(This->body_event_target)
1888 release_event_target(This->body_event_target);
1889 if(This->nsevent_listener)
1890 release_nsevents(This);
1892 ICatInformation_Release(This->catmgr);
1894 IInternetSecurityManager_Release(This->secmgr);
1896 detach_selection(This);
1897 detach_ranges(This);
1898 release_nodes(This);
1901 release_mutation(This);
1902 nsIDOMHTMLDocument_Release(This->nsdoc);
1905 heap_free(This->event_vector);
1906 destroy_htmldoc(&This->basedoc);
1909 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1911 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1912 FIXME("%p\n", This);
1916 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
1917 HTMLDocumentNode_QI,
1918 HTMLDocumentNode_destructor,
1919 HTMLDocumentNode_clone
1922 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1924 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1925 HTMLDocumentNode *new_node;
1928 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
1932 *ret = &new_node->node;
1936 #undef HTMLDOCNODE_NODE_THIS
1938 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
1939 HTMLDocumentNode_QI,
1940 HTMLDocumentNode_destructor,
1941 HTMLDocumentFragment_clone
1944 static const tid_t HTMLDocumentNode_iface_tids[] = {
1954 static dispex_static_data_t HTMLDocumentNode_dispex = {
1956 DispHTMLDocument_tid,
1958 HTMLDocumentNode_iface_tids
1961 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLWindow *window)
1963 HTMLDocumentNode *doc;
1965 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
1970 doc->basedoc.doc_node = doc;
1971 doc->basedoc.doc_obj = doc_obj;
1972 doc->basedoc.window = window;
1974 init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
1975 init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
1976 HTMLDocumentNode_SecMgr_Init(doc);
1980 list_init(&doc->bindings);
1981 list_init(&doc->selection_list);
1982 list_init(&doc->range_list);
1987 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret)
1989 HTMLDocumentNode *doc;
1992 doc = alloc_doc_node(doc_obj, window);
1994 return E_OUTOFMEMORY;
1996 if(window == doc_obj->basedoc.window)
1997 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
1999 nsIDOMHTMLDocument_AddRef(nsdoc);
2003 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
2004 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
2005 doc->node.cp_container = &doc->basedoc.cp_container;
2007 hres = CoInternetCreateSecurityManager(NULL, &doc->secmgr, 0);
2009 htmldoc_release(&doc->basedoc);
2017 HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
2019 HTMLDocumentNode *doc_frag;
2021 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->basedoc.window);
2023 return E_OUTOFMEMORY;
2025 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
2026 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
2027 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
2029 htmldoc_addref(&doc_frag->basedoc);
2034 /**********************************************************
2035 * ICustomDoc implementation
2038 #define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocumentObj, CustomDoc, iface)
2040 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
2042 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2044 if(htmldoc_qi(&This->basedoc, riid, ppv))
2045 return *ppv ? S_OK : E_NOINTERFACE;
2047 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
2048 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
2049 *ppv = CUSTOMDOC(This);
2050 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2051 return *ppv ? S_OK : E_NOINTERFACE;
2053 FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
2055 return E_NOINTERFACE;
2058 IUnknown_AddRef((IUnknown*)*ppv);
2062 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
2064 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2065 ULONG ref = InterlockedIncrement(&This->ref);
2067 TRACE("(%p) ref = %u\n", This, ref);
2072 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
2074 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2075 ULONG ref = InterlockedDecrement(&This->ref);
2077 TRACE("(%p) ref = %u\n", This, ref);
2080 if(This->basedoc.doc_node) {
2081 This->basedoc.doc_node->basedoc.doc_obj = NULL;
2082 IHTMLDocument2_Release(HTMLDOC(&This->basedoc.doc_node->basedoc));
2084 if(This->basedoc.window) {
2085 This->basedoc.window->doc_obj = NULL;
2086 IHTMLWindow2_Release(HTMLWINDOW2(This->basedoc.window));
2088 if(This->basedoc.advise_holder)
2089 IOleAdviseHolder_Release(This->basedoc.advise_holder);
2092 IAdviseSink_Release(This->view_sink);
2094 IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL);
2096 ICustomDoc_SetUIHandler(CUSTOMDOC(This), NULL);
2097 if(This->in_place_active)
2098 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(&This->basedoc));
2100 IOleDocumentView_SetInPlaceSite(DOCVIEW(&This->basedoc), NULL);
2102 IOleUndoManager_Release(This->undomgr);
2103 if(This->tooltips_hwnd)
2104 DestroyWindow(This->tooltips_hwnd);
2107 DestroyWindow(This->hwnd);
2108 heap_free(This->mime);
2110 destroy_htmldoc(&This->basedoc);
2111 release_dispex(&This->dispex);
2113 if(This->nscontainer)
2114 NSContainer_Release(This->nscontainer);
2121 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
2123 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2124 IOleCommandTarget *cmdtrg;
2127 TRACE("(%p)->(%p)\n", This, pUIHandler);
2129 if(This->custom_hostui && This->hostui == pUIHandler)
2132 This->custom_hostui = TRUE;
2135 IDocHostUIHandler_Release(This->hostui);
2137 IDocHostUIHandler_AddRef(pUIHandler);
2138 This->hostui = pUIHandler;
2142 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
2143 if(SUCCEEDED(hres)) {
2144 FIXME("custom UI handler supports IOleCommandTarget\n");
2145 IOleCommandTarget_Release(cmdtrg);
2151 #undef CUSTOMDOC_THIS
2153 static const ICustomDocVtbl CustomDocVtbl = {
2154 CustomDoc_QueryInterface,
2157 CustomDoc_SetUIHandler
2160 static const tid_t HTMLDocumentObj_iface_tids[] = {
2167 static dispex_static_data_t HTMLDocumentObj_dispex = {
2169 DispHTMLDocument_tid,
2171 HTMLDocumentObj_iface_tids
2174 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
2176 HTMLDocumentObj *doc;
2177 nsIDOMWindow *nswindow = NULL;
2181 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2183 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
2185 return E_OUTOFMEMORY;
2187 init_dispex(&doc->dispex, (IUnknown*)CUSTOMDOC(doc), &HTMLDocumentObj_dispex);
2188 init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc), DISPATCHEX(&doc->dispex));
2190 doc->lpCustomDocVtbl = &CustomDocVtbl;
2192 doc->basedoc.doc_obj = doc;
2194 doc->usermode = UNKNOWN_USERMODE;
2196 doc->nscontainer = NSContainer_Create(doc, NULL);
2197 if(!doc->nscontainer) {
2198 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2199 htmldoc_release(&doc->basedoc);
2200 return CLASS_E_CLASSNOTAVAILABLE;
2203 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
2204 htmldoc_release(&doc->basedoc);
2209 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
2210 if(NS_FAILED(nsres))
2211 ERR("GetContentDOMWindow failed: %08x\n", nsres);
2213 hres = HTMLWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
2215 nsIDOMWindow_Release(nswindow);
2217 IHTMLDocument_Release(HTMLDOC(&doc->basedoc));
2221 if(!doc->basedoc.doc_node && doc->basedoc.window->doc) {
2222 doc->basedoc.doc_node = doc->basedoc.window->doc;
2223 htmldoc_addref(&doc->basedoc.doc_node->basedoc);