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"
38 #include "pluginhost.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
42 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
44 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
46 HTMLDocument *This = HTMLDOC_THIS(iface);
48 return htmldoc_query_interface(This, riid, ppv);
51 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
53 HTMLDocument *This = HTMLDOC_THIS(iface);
55 return htmldoc_addref(This);
58 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
60 HTMLDocument *This = HTMLDOC_THIS(iface);
62 return htmldoc_release(This);
65 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
67 HTMLDocument *This = HTMLDOC_THIS(iface);
69 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
72 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
73 LCID lcid, ITypeInfo **ppTInfo)
75 HTMLDocument *This = HTMLDOC_THIS(iface);
77 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
80 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
81 LPOLESTR *rgszNames, UINT cNames,
82 LCID lcid, DISPID *rgDispId)
84 HTMLDocument *This = HTMLDOC_THIS(iface);
86 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
89 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
90 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
91 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
93 HTMLDocument *This = HTMLDOC_THIS(iface);
95 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
96 pVarResult, pExcepInfo, puArgErr);
99 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
101 HTMLDocument *This = HTMLDOC_THIS(iface);
103 TRACE("(%p)->(%p)\n", This, p);
105 *p = (IDispatch*)HTMLWINDOW2(This->window);
106 IDispatch_AddRef(*p);
110 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
112 HTMLDocument *This = HTMLDOC_THIS(iface);
113 nsIDOMElement *nselem = NULL;
118 TRACE("(%p)->(%p)\n", This, p);
120 if(!This->doc_node->nsdoc) {
121 WARN("NULL nsdoc\n");
125 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
126 if(NS_FAILED(nsres)) {
127 ERR("GetDocumentElement failed: %08x\n", nsres);
136 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
138 *p = create_all_collection(node, TRUE);
139 nsIDOMElement_Release(nselem);
143 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
145 HTMLDocument *This = HTMLDOC_THIS(iface);
146 nsIDOMHTMLElement *nsbody = NULL;
150 TRACE("(%p)->(%p)\n", This, p);
152 if(This->doc_node->nsdoc) {
155 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
156 if(NS_FAILED(nsres)) {
157 TRACE("Could not get body: %08x\n", nsres);
167 hres = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE, &node);
168 nsIDOMHTMLElement_Release(nsbody);
172 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
175 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
177 HTMLDocument *This = HTMLDOC_THIS(iface);
178 FIXME("(%p)->(%p)\n", This, p);
182 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
184 HTMLDocument *This = HTMLDOC_THIS(iface);
185 nsIDOMHTMLCollection *nscoll = NULL;
188 TRACE("(%p)->(%p)\n", This, p);
195 if(!This->doc_node->nsdoc) {
196 WARN("NULL nsdoc\n");
200 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
201 if(NS_FAILED(nsres)) {
202 ERR("GetImages failed: %08x\n", nsres);
207 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
208 nsIDOMElement_Release(nscoll);
214 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
216 HTMLDocument *This = HTMLDOC_THIS(iface);
217 nsIDOMHTMLCollection *nscoll = NULL;
220 TRACE("(%p)->(%p)\n", This, p);
227 if(!This->doc_node->nsdoc) {
228 WARN("NULL nsdoc\n");
232 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
233 if(NS_FAILED(nsres)) {
234 ERR("GetApplets failed: %08x\n", nsres);
239 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
240 nsIDOMElement_Release(nscoll);
246 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
248 HTMLDocument *This = HTMLDOC_THIS(iface);
249 nsIDOMHTMLCollection *nscoll = NULL;
252 TRACE("(%p)->(%p)\n", This, p);
259 if(!This->doc_node->nsdoc) {
260 WARN("NULL nsdoc\n");
264 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
265 if(NS_FAILED(nsres)) {
266 ERR("GetLinks failed: %08x\n", nsres);
271 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
272 nsIDOMElement_Release(nscoll);
278 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
280 HTMLDocument *This = HTMLDOC_THIS(iface);
281 nsIDOMHTMLCollection *nscoll = NULL;
284 TRACE("(%p)->(%p)\n", This, p);
291 if(!This->doc_node->nsdoc) {
292 WARN("NULL nsdoc\n");
296 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
297 if(NS_FAILED(nsres)) {
298 ERR("GetForms failed: %08x\n", nsres);
303 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
304 nsIDOMElement_Release(nscoll);
310 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
312 HTMLDocument *This = HTMLDOC_THIS(iface);
313 nsIDOMHTMLCollection *nscoll = NULL;
316 TRACE("(%p)->(%p)\n", This, p);
323 if(!This->doc_node->nsdoc) {
324 WARN("NULL nsdoc\n");
328 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
329 if(NS_FAILED(nsres)) {
330 ERR("GetAnchors failed: %08x\n", nsres);
335 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
336 nsIDOMElement_Release(nscoll);
342 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
344 HTMLDocument *This = HTMLDOC_THIS(iface);
348 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
350 if(!This->doc_node->nsdoc) {
351 WARN("NULL nsdoc\n");
355 nsAString_InitDepend(&nsstr, v);
356 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
357 nsAString_Finish(&nsstr);
359 ERR("SetTitle failed: %08x\n", nsres);
364 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
366 HTMLDocument *This = HTMLDOC_THIS(iface);
367 const PRUnichar *ret;
371 TRACE("(%p)->(%p)\n", This, p);
373 if(!This->doc_node->nsdoc) {
374 WARN("NULL nsdoc\n");
379 nsAString_Init(&nsstr, NULL);
380 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
381 if (NS_SUCCEEDED(nsres)) {
382 nsAString_GetData(&nsstr, &ret);
383 *p = SysAllocString(ret);
385 nsAString_Finish(&nsstr);
387 if(NS_FAILED(nsres)) {
388 ERR("GetTitle failed: %08x\n", nsres);
395 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
397 HTMLDocument *This = HTMLDOC_THIS(iface);
398 FIXME("(%p)->(%p)\n", This, p);
402 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
404 HTMLDocument *This = HTMLDOC_THIS(iface);
405 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
409 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
411 HTMLDocument *This = HTMLDOC_THIS(iface);
412 static WCHAR szOff[] = {'O','f','f',0};
413 FIXME("(%p)->(%p) always returning Off\n", This, p);
418 *p = SysAllocString(szOff);
423 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
425 HTMLDocument *This = HTMLDOC_THIS(iface);
426 nsISelection *nsselection;
429 TRACE("(%p)->(%p)\n", This, p);
431 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
432 if(NS_FAILED(nsres)) {
433 ERR("GetSelection failed: %08x\n", nsres);
437 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
440 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
442 HTMLDocument *This = HTMLDOC_THIS(iface);
444 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
445 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
446 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
447 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
448 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
450 static const LPCWSTR readystate_str[] = {
458 TRACE("(%p)->(%p)\n", iface, p);
463 *p = SysAllocString(readystate_str[This->window->readystate]);
467 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
469 HTMLDocument *This = HTMLDOC_THIS(iface);
470 FIXME("(%p)->(%p)\n", This, p);
474 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
476 HTMLDocument *This = HTMLDOC_THIS(iface);
477 FIXME("(%p)->(%p)\n", This, p);
481 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
483 HTMLDocument *This = HTMLDOC_THIS(iface);
484 FIXME("(%p)->(%p)\n", This, p);
488 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
490 HTMLDocument *This = HTMLDOC_THIS(iface);
491 FIXME("(%p)\n", This);
495 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
497 HTMLDocument *This = HTMLDOC_THIS(iface);
498 FIXME("(%p)->(%p)\n", This, p);
502 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
504 HTMLDocument *This = HTMLDOC_THIS(iface);
505 FIXME("(%p)\n", This);
509 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
511 HTMLDocument *This = HTMLDOC_THIS(iface);
512 FIXME("(%p)->(%p)\n", This, p);
516 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
518 HTMLDocument *This = HTMLDOC_THIS(iface);
519 FIXME("(%p)\n", This);
523 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
525 HTMLDocument *This = HTMLDOC_THIS(iface);
526 FIXME("(%p)->(%p)\n", This, p);
530 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
532 HTMLDocument *This = HTMLDOC_THIS(iface);
533 FIXME("(%p)->()\n", This);
537 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
539 HTMLDocument *This = HTMLDOC_THIS(iface);
540 FIXME("(%p)->(%p)\n", This, p);
544 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
546 HTMLDocument *This = HTMLDOC_THIS(iface);
547 FIXME("(%p)\n", This);
551 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
553 HTMLDocument *This = HTMLDOC_THIS(iface);
554 FIXME("(%p)->(%p)\n", This, p);
558 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
560 HTMLDocument *This = HTMLDOC_THIS(iface);
562 FIXME("(%p)->(%p)\n", This, p);
568 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
570 HTMLDocument *This = HTMLDOC_THIS(iface);
572 TRACE("(%p)->(%p)\n", This, p);
574 if(!This->doc_node->nsdoc) {
575 WARN("NULL nsdoc\n");
579 return IHTMLWindow2_get_location(HTMLWINDOW2(This->window), p);
582 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
584 HTMLDocument *This = HTMLDOC_THIS(iface);
585 FIXME("(%p)->(%p)\n", This, p);
589 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
591 HTMLDocument *This = HTMLDOC_THIS(iface);
592 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
596 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
598 HTMLDocument *This = HTMLDOC_THIS(iface);
600 static const WCHAR about_blank_url[] =
601 {'a','b','o','u','t',':','b','l','a','n','k',0};
603 TRACE("(%p)->(%p)\n", iface, p);
605 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
606 return *p ? S_OK : E_OUTOFMEMORY;
609 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
611 HTMLDocument *This = HTMLDOC_THIS(iface);
612 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
616 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
618 HTMLDocument *This = HTMLDOC_THIS(iface);
619 FIXME("(%p)->(%p)\n", This, p);
623 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
625 HTMLDocument *This = HTMLDOC_THIS(iface);
628 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
630 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
632 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
633 return HRESULT_FROM_WIN32(GetLastError());
639 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
641 HTMLDocument *This = HTMLDOC_THIS(iface);
645 TRACE("(%p)->(%p)\n", This, p);
648 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
650 switch(GetLastError()) {
651 case ERROR_INSUFFICIENT_BUFFER:
653 case ERROR_NO_MORE_ITEMS:
657 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
658 return HRESULT_FROM_WIN32(GetLastError());
667 *p = SysAllocStringLen(NULL, size-1);
669 return E_OUTOFMEMORY;
671 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
673 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
680 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
682 HTMLDocument *This = HTMLDOC_THIS(iface);
683 FIXME("(%p)->(%x)\n", This, v);
687 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
689 HTMLDocument *This = HTMLDOC_THIS(iface);
690 FIXME("(%p)->(%p)\n", This, p);
694 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
696 HTMLDocument *This = HTMLDOC_THIS(iface);
697 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
701 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
703 HTMLDocument *This = HTMLDOC_THIS(iface);
704 FIXME("(%p)->(%p)\n", This, p);
708 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
710 HTMLDocument *This = HTMLDOC_THIS(iface);
711 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
715 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
717 HTMLDocument *This = HTMLDOC_THIS(iface);
718 FIXME("(%p)->(%p)\n", This, p);
722 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
724 HTMLDocument *This = HTMLDOC_THIS(iface);
725 FIXME("(%p)->(%p)\n", This, p);
729 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
731 HTMLDocument *This = HTMLDOC_THIS(iface);
732 FIXME("(%p)->(%p)\n", This, p);
736 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
738 HTMLDocument *This = HTMLDOC_THIS(iface);
739 FIXME("(%p)->(%p)\n", This, p);
743 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
745 HTMLDocument *This = HTMLDOC_THIS(iface);
746 FIXME("(%p)->(%p)\n", This, p);
750 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
752 HTMLDocument *This = HTMLDOC_THIS(iface);
753 FIXME("(%p)->(%p)\n", This, p);
757 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
759 HTMLDocument *This = HTMLDOC_THIS(iface);
760 FIXME("(%p)->(%p)\n", This, p);
764 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
766 HTMLDocument *This = HTMLDOC_THIS(iface);
767 FIXME("(%p)->(%p)\n", This, p);
771 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
773 HTMLDocument *This = HTMLDOC_THIS(iface);
774 FIXME("(%p)->(%p)\n", This, p);
778 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
786 if(!This->doc_node->nsdoc) {
787 WARN("NULL nsdoc\n");
794 if(psarray->cDims != 1) {
795 FIXME("cDims=%d\n", psarray->cDims);
799 hres = SafeArrayAccessData(psarray, (void**)&var);
801 WARN("SafeArrayAccessData failed: %08x\n", hres);
805 nsAString_Init(&nsstr, NULL);
807 argc = psarray->rgsabound[0].cElements;
808 for(i=0; i < argc; i++) {
809 if(V_VT(var+i) == VT_BSTR) {
810 nsAString_SetData(&nsstr, V_BSTR(var+i));
811 if(!ln || i != argc-1)
812 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr);
814 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr);
816 ERR("Write failed: %08x\n", nsres);
818 FIXME("vt=%d\n", V_VT(var+i));
822 nsAString_Finish(&nsstr);
823 SafeArrayUnaccessData(psarray);
828 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
830 HTMLDocument *This = HTMLDOC_THIS(iface);
832 TRACE("(%p)->(%p)\n", iface, psarray);
834 return document_write(This, psarray, FALSE);
837 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
839 HTMLDocument *This = HTMLDOC_THIS(iface);
841 TRACE("(%p)->(%p)\n", This, psarray);
843 return document_write(This, psarray, TRUE);
846 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
847 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
849 HTMLDocument *This = HTMLDOC_THIS(iface);
852 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
854 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
855 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
857 if(!This->doc_node->nsdoc) {
862 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
863 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
864 FIXME("unsupported args\n");
866 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc);
867 if(NS_FAILED(nsres)) {
868 ERR("Open failed: %08x\n", nsres);
872 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
873 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
877 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
879 HTMLDocument *This = HTMLDOC_THIS(iface);
882 TRACE("(%p)\n", This);
884 if(!This->doc_node->nsdoc) {
889 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
890 if(NS_FAILED(nsres)) {
891 ERR("Close failed: %08x\n", nsres);
898 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
900 HTMLDocument *This = HTMLDOC_THIS(iface);
901 nsIDOMNSHTMLDocument *nsdoc;
904 TRACE("(%p)\n", This);
906 nsres = nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMNSHTMLDocument, (void**)&nsdoc);
907 if(NS_FAILED(nsres)) {
908 ERR("Could not get nsIDOMNSHTMLDocument iface: %08x\n", nsres);
912 nsres = nsIDOMNSHTMLDocument_Clear(nsdoc);
913 nsIDOMNSHTMLDocument_Release(nsdoc);
914 if(NS_FAILED(nsres)) {
915 ERR("Clear failed: %08x\n", nsres);
922 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
925 HTMLDocument *This = HTMLDOC_THIS(iface);
926 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
930 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
933 HTMLDocument *This = HTMLDOC_THIS(iface);
934 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
938 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
941 HTMLDocument *This = HTMLDOC_THIS(iface);
942 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
946 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
949 HTMLDocument *This = HTMLDOC_THIS(iface);
950 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
954 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
957 HTMLDocument *This = HTMLDOC_THIS(iface);
958 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
962 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
965 HTMLDocument *This = HTMLDOC_THIS(iface);
966 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
970 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
971 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
973 HTMLDocument *This = HTMLDOC_THIS(iface);
974 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
978 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
981 HTMLDocument *This = HTMLDOC_THIS(iface);
982 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
986 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
987 IHTMLElement **newElem)
989 HTMLDocument *This = HTMLDOC_THIS(iface);
990 nsIDOMHTMLElement *nselem;
994 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
996 hres = create_nselem(This->doc_node, eTag, &nselem);
1000 hres = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE, &elem);
1001 nsIDOMHTMLElement_Release(nselem);
1005 *newElem = HTMLELEM(elem);
1006 IHTMLElement_AddRef(HTMLELEM(elem));
1010 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1012 HTMLDocument *This = HTMLDOC_THIS(iface);
1013 FIXME("(%p)\n", This);
1017 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1019 HTMLDocument *This = HTMLDOC_THIS(iface);
1020 FIXME("(%p)->(%p)\n", This, p);
1024 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1026 HTMLDocument *This = HTMLDOC_THIS(iface);
1028 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1030 return set_doc_event(This, EVENTID_CLICK, &v);
1033 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1035 HTMLDocument *This = HTMLDOC_THIS(iface);
1037 TRACE("(%p)->(%p)\n", This, p);
1039 return get_doc_event(This, EVENTID_CLICK, p);
1042 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1044 HTMLDocument *This = HTMLDOC_THIS(iface);
1045 FIXME("(%p)\n", This);
1049 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1051 HTMLDocument *This = HTMLDOC_THIS(iface);
1052 FIXME("(%p)->(%p)\n", This, p);
1056 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1058 HTMLDocument *This = HTMLDOC_THIS(iface);
1060 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1062 return set_doc_event(This, EVENTID_KEYUP, &v);
1065 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1067 HTMLDocument *This = HTMLDOC_THIS(iface);
1069 TRACE("(%p)->(%p)\n", This, p);
1071 return get_doc_event(This, EVENTID_KEYUP, p);
1074 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1076 HTMLDocument *This = HTMLDOC_THIS(iface);
1078 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1080 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1083 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1085 HTMLDocument *This = HTMLDOC_THIS(iface);
1087 TRACE("(%p)->(%p)\n", This, p);
1089 return get_doc_event(This, EVENTID_KEYDOWN, p);
1092 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1094 HTMLDocument *This = HTMLDOC_THIS(iface);
1095 FIXME("(%p)\n", This);
1099 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1101 HTMLDocument *This = HTMLDOC_THIS(iface);
1102 FIXME("(%p)->(%p)\n", This, p);
1106 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1108 HTMLDocument *This = HTMLDOC_THIS(iface);
1110 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1112 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1115 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1117 HTMLDocument *This = HTMLDOC_THIS(iface);
1119 TRACE("(%p)->(%p)\n", This, p);
1121 return get_doc_event(This, EVENTID_MOUSEUP, p);
1124 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1126 HTMLDocument *This = HTMLDOC_THIS(iface);
1128 TRACE("(%p)->()\n", This);
1130 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1133 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1135 HTMLDocument *This = HTMLDOC_THIS(iface);
1137 TRACE("(%p)->(%p)\n", This, p);
1139 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1142 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1144 HTMLDocument *This = HTMLDOC_THIS(iface);
1145 FIXME("(%p)\n", This);
1149 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1151 HTMLDocument *This = HTMLDOC_THIS(iface);
1152 FIXME("(%p)->(%p)\n", This, p);
1156 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1158 HTMLDocument *This = HTMLDOC_THIS(iface);
1160 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1162 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1165 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1167 HTMLDocument *This = HTMLDOC_THIS(iface);
1169 TRACE("(%p)->(%p)\n", This, p);
1171 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1174 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1176 HTMLDocument *This = HTMLDOC_THIS(iface);
1178 TRACE("(%p)\n", This);
1180 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1183 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1185 HTMLDocument *This = HTMLDOC_THIS(iface);
1187 TRACE("(%p)->(%p)\n", This, p);
1189 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1192 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1194 HTMLDocument *This = HTMLDOC_THIS(iface);
1196 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1198 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1201 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1203 HTMLDocument *This = HTMLDOC_THIS(iface);
1205 TRACE("(%p)->(%p)\n", This, p);
1207 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1210 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1212 HTMLDocument *This = HTMLDOC_THIS(iface);
1213 FIXME("(%p)\n", This);
1217 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1219 HTMLDocument *This = HTMLDOC_THIS(iface);
1220 FIXME("(%p)->(%p)\n", This, p);
1224 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1226 HTMLDocument *This = HTMLDOC_THIS(iface);
1227 FIXME("(%p)\n", This);
1231 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1233 HTMLDocument *This = HTMLDOC_THIS(iface);
1234 FIXME("(%p)->(%p)\n", This, p);
1238 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1240 HTMLDocument *This = HTMLDOC_THIS(iface);
1241 FIXME("(%p)\n", This);
1245 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1247 HTMLDocument *This = HTMLDOC_THIS(iface);
1248 FIXME("(%p)->(%p)\n", This, p);
1252 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1254 HTMLDocument *This = HTMLDOC_THIS(iface);
1256 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1258 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1261 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1263 HTMLDocument *This = HTMLDOC_THIS(iface);
1265 TRACE("(%p)->(%p)\n", This, p);
1267 return get_doc_event(This, EVENTID_DRAGSTART, p);
1270 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1272 HTMLDocument *This = HTMLDOC_THIS(iface);
1274 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1276 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1279 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1281 HTMLDocument *This = HTMLDOC_THIS(iface);
1283 TRACE("(%p)->(%p)\n", This, p);
1285 return get_doc_event(This, EVENTID_SELECTSTART, p);
1288 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1289 IHTMLElement **elementHit)
1291 HTMLDocument *This = HTMLDOC_THIS(iface);
1292 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1296 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1298 HTMLDocument *This = HTMLDOC_THIS(iface);
1300 TRACE("(%p)->(%p)\n", This, p);
1302 *p = HTMLWINDOW2(This->window);
1303 IHTMLWindow2_AddRef(*p);
1307 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1308 IHTMLStyleSheetsCollection **p)
1310 HTMLDocument *This = HTMLDOC_THIS(iface);
1311 nsIDOMStyleSheetList *nsstylelist;
1312 nsIDOMDocumentStyle *nsdocstyle;
1315 TRACE("(%p)->(%p)\n", This, p);
1319 if(!This->doc_node->nsdoc) {
1320 WARN("NULL nsdoc\n");
1321 return E_UNEXPECTED;
1324 nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1325 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1326 nsIDOMDocumentStyle_Release(nsdocstyle);
1327 if(NS_FAILED(nsres)) {
1328 ERR("GetStyleSheets failed: %08x\n", nsres);
1332 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1333 nsIDOMDocumentStyle_Release(nsstylelist);
1338 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1340 HTMLDocument *This = HTMLDOC_THIS(iface);
1341 FIXME("(%p)\n", This);
1345 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1347 HTMLDocument *This = HTMLDOC_THIS(iface);
1348 FIXME("(%p)->(%p)\n", This, p);
1352 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1354 HTMLDocument *This = HTMLDOC_THIS(iface);
1355 FIXME("(%p)\n", This);
1359 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1361 HTMLDocument *This = HTMLDOC_THIS(iface);
1362 FIXME("(%p)->(%p)\n", This, p);
1366 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1368 HTMLDocument *This = HTMLDOC_THIS(iface);
1369 FIXME("(%p)->(%p)\n", This, String);
1373 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1374 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1376 HTMLDocument *This = HTMLDOC_THIS(iface);
1378 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1380 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1384 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1385 HTMLDocument_QueryInterface,
1386 HTMLDocument_AddRef,
1387 HTMLDocument_Release,
1388 HTMLDocument_GetTypeInfoCount,
1389 HTMLDocument_GetTypeInfo,
1390 HTMLDocument_GetIDsOfNames,
1391 HTMLDocument_Invoke,
1392 HTMLDocument_get_Script,
1393 HTMLDocument_get_all,
1394 HTMLDocument_get_body,
1395 HTMLDocument_get_activeElement,
1396 HTMLDocument_get_images,
1397 HTMLDocument_get_applets,
1398 HTMLDocument_get_links,
1399 HTMLDocument_get_forms,
1400 HTMLDocument_get_anchors,
1401 HTMLDocument_put_title,
1402 HTMLDocument_get_title,
1403 HTMLDocument_get_scripts,
1404 HTMLDocument_put_designMode,
1405 HTMLDocument_get_designMode,
1406 HTMLDocument_get_selection,
1407 HTMLDocument_get_readyState,
1408 HTMLDocument_get_frames,
1409 HTMLDocument_get_embeds,
1410 HTMLDocument_get_plugins,
1411 HTMLDocument_put_alinkColor,
1412 HTMLDocument_get_alinkColor,
1413 HTMLDocument_put_bgColor,
1414 HTMLDocument_get_bgColor,
1415 HTMLDocument_put_fgColor,
1416 HTMLDocument_get_fgColor,
1417 HTMLDocument_put_linkColor,
1418 HTMLDocument_get_linkColor,
1419 HTMLDocument_put_vlinkColor,
1420 HTMLDocument_get_vlinkColor,
1421 HTMLDocument_get_referrer,
1422 HTMLDocument_get_location,
1423 HTMLDocument_get_lastModified,
1424 HTMLDocument_put_URL,
1425 HTMLDocument_get_URL,
1426 HTMLDocument_put_domain,
1427 HTMLDocument_get_domain,
1428 HTMLDocument_put_cookie,
1429 HTMLDocument_get_cookie,
1430 HTMLDocument_put_expando,
1431 HTMLDocument_get_expando,
1432 HTMLDocument_put_charset,
1433 HTMLDocument_get_charset,
1434 HTMLDocument_put_defaultCharset,
1435 HTMLDocument_get_defaultCharset,
1436 HTMLDocument_get_mimeType,
1437 HTMLDocument_get_fileSize,
1438 HTMLDocument_get_fileCreatedDate,
1439 HTMLDocument_get_fileModifiedDate,
1440 HTMLDocument_get_fileUpdatedDate,
1441 HTMLDocument_get_security,
1442 HTMLDocument_get_protocol,
1443 HTMLDocument_get_nameProp,
1445 HTMLDocument_writeln,
1449 HTMLDocument_queryCommandSupported,
1450 HTMLDocument_queryCommandEnabled,
1451 HTMLDocument_queryCommandState,
1452 HTMLDocument_queryCommandIndeterm,
1453 HTMLDocument_queryCommandText,
1454 HTMLDocument_queryCommandValue,
1455 HTMLDocument_execCommand,
1456 HTMLDocument_execCommandShowHelp,
1457 HTMLDocument_createElement,
1458 HTMLDocument_put_onhelp,
1459 HTMLDocument_get_onhelp,
1460 HTMLDocument_put_onclick,
1461 HTMLDocument_get_onclick,
1462 HTMLDocument_put_ondblclick,
1463 HTMLDocument_get_ondblclick,
1464 HTMLDocument_put_onkeyup,
1465 HTMLDocument_get_onkeyup,
1466 HTMLDocument_put_onkeydown,
1467 HTMLDocument_get_onkeydown,
1468 HTMLDocument_put_onkeypress,
1469 HTMLDocument_get_onkeypress,
1470 HTMLDocument_put_onmouseup,
1471 HTMLDocument_get_onmouseup,
1472 HTMLDocument_put_onmousedown,
1473 HTMLDocument_get_onmousedown,
1474 HTMLDocument_put_onmousemove,
1475 HTMLDocument_get_onmousemove,
1476 HTMLDocument_put_onmouseout,
1477 HTMLDocument_get_onmouseout,
1478 HTMLDocument_put_onmouseover,
1479 HTMLDocument_get_onmouseover,
1480 HTMLDocument_put_onreadystatechange,
1481 HTMLDocument_get_onreadystatechange,
1482 HTMLDocument_put_onafterupdate,
1483 HTMLDocument_get_onafterupdate,
1484 HTMLDocument_put_onrowexit,
1485 HTMLDocument_get_onrowexit,
1486 HTMLDocument_put_onrowenter,
1487 HTMLDocument_get_onrowenter,
1488 HTMLDocument_put_ondragstart,
1489 HTMLDocument_get_ondragstart,
1490 HTMLDocument_put_onselectstart,
1491 HTMLDocument_get_onselectstart,
1492 HTMLDocument_elementFromPoint,
1493 HTMLDocument_get_parentWindow,
1494 HTMLDocument_get_styleSheets,
1495 HTMLDocument_put_onbeforeupdate,
1496 HTMLDocument_get_onbeforeupdate,
1497 HTMLDocument_put_onerrorupdate,
1498 HTMLDocument_get_onerrorupdate,
1499 HTMLDocument_toString,
1500 HTMLDocument_createStyleSheet
1503 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
1505 HTMLDocument *This = HTMLDOC_THIS(iface);
1508 update_cp_events(This->window, &This->doc_node->node.event_target, cp, This->doc_node->node.nsnode);
1513 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1515 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1517 HTMLDocument *This = SUPPINFO_THIS(iface);
1518 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1521 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1523 HTMLDocument *This = SUPPINFO_THIS(iface);
1524 return IHTMLDocument_AddRef(HTMLDOC(This));
1527 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1529 HTMLDocument *This = SUPPINFO_THIS(iface);
1530 return IHTMLDocument_Release(HTMLDOC(This));
1533 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1535 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1539 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1540 SupportErrorInfo_QueryInterface,
1541 SupportErrorInfo_AddRef,
1542 SupportErrorInfo_Release,
1543 SupportErrorInfo_InterfaceSupportsErrorInfo
1546 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1548 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1550 HTMLDocument *This = DISPEX_THIS(iface);
1552 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1555 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1557 HTMLDocument *This = DISPEX_THIS(iface);
1559 return IHTMLDocument2_AddRef(HTMLDOC(This));
1562 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1564 HTMLDocument *This = DISPEX_THIS(iface);
1566 return IHTMLDocument2_Release(HTMLDOC(This));
1569 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1571 HTMLDocument *This = DISPEX_THIS(iface);
1573 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
1576 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1577 LCID lcid, ITypeInfo **ppTInfo)
1579 HTMLDocument *This = DISPEX_THIS(iface);
1581 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
1584 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1585 LPOLESTR *rgszNames, UINT cNames,
1586 LCID lcid, DISPID *rgDispId)
1588 HTMLDocument *This = DISPEX_THIS(iface);
1590 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
1593 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1594 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1595 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1597 HTMLDocument *This = DISPEX_THIS(iface);
1599 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1600 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1602 switch(dispIdMember) {
1603 case DISPID_READYSTATE:
1604 TRACE("DISPID_READYSTATE\n");
1606 if(!(wFlags & DISPATCH_PROPERTYGET))
1607 return E_INVALIDARG;
1609 V_VT(pVarResult) = VT_I4;
1610 V_I4(pVarResult) = This->window->readystate;
1614 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
1615 pVarResult, pExcepInfo, puArgErr);
1618 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1620 HTMLDocument *This = DISPEX_THIS(iface);
1622 return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
1625 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1626 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1628 HTMLDocument *This = DISPEX_THIS(iface);
1630 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
1631 return IDispatchEx_InvokeEx(DISPATCHEX(This->window), DISPID_IHTMLWINDOW2_LOCATION, lcid, wFlags,
1632 pdp, pvarRes, pei, pspCaller);
1635 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1638 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1640 HTMLDocument *This = DISPEX_THIS(iface);
1642 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
1645 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1647 HTMLDocument *This = DISPEX_THIS(iface);
1649 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
1652 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1654 HTMLDocument *This = DISPEX_THIS(iface);
1656 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
1659 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1661 HTMLDocument *This = DISPEX_THIS(iface);
1663 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
1666 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1668 HTMLDocument *This = DISPEX_THIS(iface);
1670 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
1673 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1675 HTMLDocument *This = DISPEX_THIS(iface);
1677 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
1682 static const IDispatchExVtbl DocDispatchExVtbl = {
1683 DocDispatchEx_QueryInterface,
1684 DocDispatchEx_AddRef,
1685 DocDispatchEx_Release,
1686 DocDispatchEx_GetTypeInfoCount,
1687 DocDispatchEx_GetTypeInfo,
1688 DocDispatchEx_GetIDsOfNames,
1689 DocDispatchEx_Invoke,
1690 DocDispatchEx_GetDispID,
1691 DocDispatchEx_InvokeEx,
1692 DocDispatchEx_DeleteMemberByName,
1693 DocDispatchEx_DeleteMemberByDispID,
1694 DocDispatchEx_GetMemberProperties,
1695 DocDispatchEx_GetMemberName,
1696 DocDispatchEx_GetNextDispID,
1697 DocDispatchEx_GetNameSpaceParent
1700 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
1704 if(IsEqualGUID(&IID_IUnknown, riid)) {
1705 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
1706 *ppv = HTMLDOC(This);
1707 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1708 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv);
1709 *ppv = DISPATCHEX(This);
1710 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
1711 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv);
1712 *ppv = DISPATCHEX(This);
1713 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
1714 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv);
1715 *ppv = HTMLDOC(This);
1716 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
1717 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppv);
1718 *ppv = HTMLDOC(This);
1719 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
1720 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppv);
1721 *ppv = HTMLDOC3(This);
1722 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
1723 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppv);
1724 *ppv = HTMLDOC4(This);
1725 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
1726 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppv);
1727 *ppv = HTMLDOC5(This);
1728 }else if(IsEqualGUID(&IID_IHTMLDocument6, riid)) {
1729 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This, ppv);
1730 *ppv = HTMLDOC6(This);
1731 }else if(IsEqualGUID(&IID_IPersist, riid)) {
1732 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
1733 *ppv = PERSIST(This);
1734 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
1735 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppv);
1736 *ppv = PERSISTMON(This);
1737 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
1738 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppv);
1739 *ppv = PERSISTFILE(This);
1740 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
1741 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppv);
1742 *ppv = MONPROP(This);
1743 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
1744 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppv);
1745 *ppv = OLEOBJ(This);
1746 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
1747 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppv);
1748 *ppv = OLEDOC(This);
1749 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
1750 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppv);
1751 *ppv = DOCVIEW(This);
1752 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
1753 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
1754 *ppv = ACTOBJ(This);
1755 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
1756 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
1757 *ppv = VIEWOBJ(This);
1758 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
1759 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
1760 *ppv = VIEWOBJ2(This);
1761 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
1762 TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This, ppv);
1763 *ppv = VIEWOBJEX(This);
1764 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
1765 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
1766 *ppv = OLEWIN(This);
1767 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
1768 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
1769 *ppv = INPLACEOBJ(This);
1770 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1771 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppv);
1772 *ppv = INPLACEWIN(This);
1773 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1774 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
1775 *ppv = SERVPROV(This);
1776 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
1777 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppv);
1778 *ppv = CMDTARGET(This);
1779 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
1780 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppv);
1781 *ppv = CONTROL(This);
1782 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
1783 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppv);
1784 *ppv = HLNKTARGET(This);
1785 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1786 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1787 *ppv = CONPTCONT(&This->cp_container);
1788 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
1789 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
1790 *ppv = PERSTRINIT(This);
1791 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
1792 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
1793 *ppv = HTMLDOC(This);
1794 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
1795 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppv);
1796 *ppv = SUPPERRINFO(This);
1797 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
1798 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppv);
1799 *ppv = PERSISTHIST(This);
1800 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
1801 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
1803 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
1804 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
1806 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
1807 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
1809 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
1810 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
1812 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
1813 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
1815 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
1816 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
1818 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
1819 TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv);
1820 *ppv = OBJSITE(This);
1826 IUnknown_AddRef((IUnknown*)*ppv);
1830 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
1832 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
1834 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1835 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1836 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1838 doc->unk_impl = unk_impl;
1839 doc->dispex = dispex;
1840 doc->task_magic = get_task_target_magic();
1842 HTMLDocument_HTMLDocument3_Init(doc);
1843 HTMLDocument_HTMLDocument5_Init(doc);
1844 HTMLDocument_Persist_Init(doc);
1845 HTMLDocument_OleCmd_Init(doc);
1846 HTMLDocument_OleObj_Init(doc);
1847 HTMLDocument_View_Init(doc);
1848 HTMLDocument_Window_Init(doc);
1849 HTMLDocument_Service_Init(doc);
1850 HTMLDocument_Hlink_Init(doc);
1852 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1853 ConnectionPoint_Init(&doc->cp_dispatch, &doc->cp_container, &IID_IDispatch, NULL);
1854 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink, NULL);
1855 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data);
1856 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2, NULL);
1859 static void destroy_htmldoc(HTMLDocument *This)
1861 remove_target_tasks(This->task_magic);
1863 ConnectionPointContainer_Destroy(&This->cp_container);
1866 #define HTMLDOCNODE_NODE_THIS(iface) DEFINE_THIS2(HTMLDocumentNode, node, iface)
1868 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1870 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1872 if(htmldoc_qi(&This->basedoc, riid, ppv))
1873 return *ppv ? S_OK : E_NOINTERFACE;
1875 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid)) {
1876 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This, ppv);
1877 *ppv = HOSTSECMGR(This);
1879 return HTMLDOMNode_QI(&This->node, riid, ppv);
1882 IUnknown_AddRef((IUnknown*)*ppv);
1886 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
1888 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1890 if(This->body_event_target)
1891 release_event_target(This->body_event_target);
1892 if(This->nsevent_listener)
1893 release_nsevents(This);
1895 ICatInformation_Release(This->catmgr);
1897 IInternetSecurityManager_Release(This->secmgr);
1899 detach_selection(This);
1900 detach_ranges(This);
1901 release_nodes(This);
1903 while(!list_empty(&This->plugin_hosts))
1904 detach_plugin_host(LIST_ENTRY(list_head(&This->plugin_hosts), PluginHost, entry));
1907 release_mutation(This);
1908 nsIDOMHTMLDocument_Release(This->nsdoc);
1911 heap_free(This->event_vector);
1912 destroy_htmldoc(&This->basedoc);
1915 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1917 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1918 FIXME("%p\n", This);
1922 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
1923 HTMLDocumentNode_QI,
1924 HTMLDocumentNode_destructor,
1925 HTMLDocumentNode_clone
1928 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1930 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1931 HTMLDocumentNode *new_node;
1934 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
1938 *ret = &new_node->node;
1942 #undef HTMLDOCNODE_NODE_THIS
1944 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
1945 HTMLDocumentNode_QI,
1946 HTMLDocumentNode_destructor,
1947 HTMLDocumentFragment_clone
1950 static const tid_t HTMLDocumentNode_iface_tids[] = {
1960 static dispex_static_data_t HTMLDocumentNode_dispex = {
1962 DispHTMLDocument_tid,
1964 HTMLDocumentNode_iface_tids
1967 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLWindow *window)
1969 HTMLDocumentNode *doc;
1971 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
1976 doc->basedoc.doc_node = doc;
1977 doc->basedoc.doc_obj = doc_obj;
1978 doc->basedoc.window = window;
1980 init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
1981 init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
1982 HTMLDocumentNode_SecMgr_Init(doc);
1986 list_init(&doc->bindings);
1987 list_init(&doc->selection_list);
1988 list_init(&doc->range_list);
1989 list_init(&doc->plugin_hosts);
1994 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret)
1996 HTMLDocumentNode *doc;
1999 doc = alloc_doc_node(doc_obj, window);
2001 return E_OUTOFMEMORY;
2003 if(window == doc_obj->basedoc.window)
2004 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
2006 nsIDOMHTMLDocument_AddRef(nsdoc);
2010 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
2011 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
2012 doc->node.cp_container = &doc->basedoc.cp_container;
2014 hres = CoInternetCreateSecurityManager(NULL, &doc->secmgr, 0);
2016 htmldoc_release(&doc->basedoc);
2024 HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
2026 HTMLDocumentNode *doc_frag;
2028 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->basedoc.window);
2030 return E_OUTOFMEMORY;
2032 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
2033 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
2034 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
2036 htmldoc_addref(&doc_frag->basedoc);
2041 /**********************************************************
2042 * ICustomDoc implementation
2045 #define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocumentObj, CustomDoc, iface)
2047 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
2049 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2051 if(htmldoc_qi(&This->basedoc, riid, ppv))
2052 return *ppv ? S_OK : E_NOINTERFACE;
2054 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
2055 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
2056 *ppv = CUSTOMDOC(This);
2057 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2058 return *ppv ? S_OK : E_NOINTERFACE;
2060 FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
2062 return E_NOINTERFACE;
2065 IUnknown_AddRef((IUnknown*)*ppv);
2069 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
2071 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2072 ULONG ref = InterlockedIncrement(&This->ref);
2074 TRACE("(%p) ref = %u\n", This, ref);
2079 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
2081 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2082 ULONG ref = InterlockedDecrement(&This->ref);
2084 TRACE("(%p) ref = %u\n", This, ref);
2087 if(This->basedoc.doc_node) {
2088 This->basedoc.doc_node->basedoc.doc_obj = NULL;
2089 IHTMLDocument2_Release(HTMLDOC(&This->basedoc.doc_node->basedoc));
2091 if(This->basedoc.window) {
2092 This->basedoc.window->doc_obj = NULL;
2093 IHTMLWindow2_Release(HTMLWINDOW2(This->basedoc.window));
2095 if(This->basedoc.advise_holder)
2096 IOleAdviseHolder_Release(This->basedoc.advise_holder);
2099 IAdviseSink_Release(This->view_sink);
2101 IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL);
2103 ICustomDoc_SetUIHandler(CUSTOMDOC(This), NULL);
2104 if(This->in_place_active)
2105 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(&This->basedoc));
2107 IOleDocumentView_SetInPlaceSite(DOCVIEW(&This->basedoc), NULL);
2109 IOleUndoManager_Release(This->undomgr);
2110 if(This->tooltips_hwnd)
2111 DestroyWindow(This->tooltips_hwnd);
2114 DestroyWindow(This->hwnd);
2115 heap_free(This->mime);
2117 destroy_htmldoc(&This->basedoc);
2118 release_dispex(&This->dispex);
2120 if(This->nscontainer)
2121 NSContainer_Release(This->nscontainer);
2128 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
2130 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2131 IOleCommandTarget *cmdtrg;
2134 TRACE("(%p)->(%p)\n", This, pUIHandler);
2136 if(This->custom_hostui && This->hostui == pUIHandler)
2139 This->custom_hostui = TRUE;
2142 IDocHostUIHandler_Release(This->hostui);
2144 IDocHostUIHandler_AddRef(pUIHandler);
2145 This->hostui = pUIHandler;
2149 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
2150 if(SUCCEEDED(hres)) {
2151 FIXME("custom UI handler supports IOleCommandTarget\n");
2152 IOleCommandTarget_Release(cmdtrg);
2158 #undef CUSTOMDOC_THIS
2160 static const ICustomDocVtbl CustomDocVtbl = {
2161 CustomDoc_QueryInterface,
2164 CustomDoc_SetUIHandler
2167 static const tid_t HTMLDocumentObj_iface_tids[] = {
2174 static dispex_static_data_t HTMLDocumentObj_dispex = {
2176 DispHTMLDocument_tid,
2178 HTMLDocumentObj_iface_tids
2181 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
2183 HTMLDocumentObj *doc;
2184 nsIDOMWindow *nswindow = NULL;
2188 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2190 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
2192 return E_OUTOFMEMORY;
2194 init_dispex(&doc->dispex, (IUnknown*)CUSTOMDOC(doc), &HTMLDocumentObj_dispex);
2195 init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc), DISPATCHEX(&doc->dispex));
2197 doc->lpCustomDocVtbl = &CustomDocVtbl;
2199 doc->basedoc.doc_obj = doc;
2201 doc->usermode = UNKNOWN_USERMODE;
2203 doc->nscontainer = NSContainer_Create(doc, NULL);
2204 if(!doc->nscontainer) {
2205 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2206 htmldoc_release(&doc->basedoc);
2207 return CLASS_E_CLASSNOTAVAILABLE;
2210 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
2211 htmldoc_release(&doc->basedoc);
2216 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
2217 if(NS_FAILED(nsres))
2218 ERR("GetContentDOMWindow failed: %08x\n", nsres);
2220 hres = HTMLWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
2222 nsIDOMWindow_Release(nswindow);
2224 IHTMLDocument_Release(HTMLDOC(&doc->basedoc));
2228 if(!doc->basedoc.doc_node && doc->basedoc.window->doc) {
2229 doc->basedoc.doc_node = doc->basedoc.window->doc;
2230 htmldoc_addref(&doc->basedoc.doc_node->basedoc);