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
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
38 #include "htmlevent.h"
39 #include "pluginhost.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
43 static inline HTMLDocument *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
45 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument2_iface);
48 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
50 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
52 return htmldoc_query_interface(This, riid, ppv);
55 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
57 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
59 return htmldoc_addref(This);
62 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
64 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
66 return htmldoc_release(This);
69 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
71 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
73 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
76 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
77 LCID lcid, ITypeInfo **ppTInfo)
79 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
81 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
84 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
85 LPOLESTR *rgszNames, UINT cNames,
86 LCID lcid, DISPID *rgDispId)
88 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
90 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
94 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
95 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
96 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
98 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
100 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
101 pDispParams, pVarResult, pExcepInfo, puArgErr);
104 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
106 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
108 TRACE("(%p)->(%p)\n", This, p);
110 *p = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
111 IDispatch_AddRef(*p);
115 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
117 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
118 nsIDOMElement *nselem = NULL;
123 TRACE("(%p)->(%p)\n", This, p);
125 if(!This->doc_node->nsdoc) {
126 WARN("NULL nsdoc\n");
130 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
131 if(NS_FAILED(nsres)) {
132 ERR("GetDocumentElement failed: %08x\n", nsres);
141 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
142 nsIDOMElement_Release(nselem);
146 *p = create_all_collection(node, TRUE);
151 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
153 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
154 nsIDOMHTMLElement *nsbody = NULL;
158 TRACE("(%p)->(%p)\n", This, p);
160 if(This->doc_node->nsdoc) {
163 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
164 if(NS_FAILED(nsres)) {
165 TRACE("Could not get body: %08x\n", nsres);
175 hres = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE, &node);
176 nsIDOMHTMLElement_Release(nsbody);
180 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
185 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
187 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
188 FIXME("(%p)->(%p)\n", This, p);
192 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
194 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
195 nsIDOMHTMLCollection *nscoll = NULL;
198 TRACE("(%p)->(%p)\n", This, p);
205 if(!This->doc_node->nsdoc) {
206 WARN("NULL nsdoc\n");
210 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
211 if(NS_FAILED(nsres)) {
212 ERR("GetImages failed: %08x\n", nsres);
217 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
218 nsIDOMHTMLCollection_Release(nscoll);
224 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
226 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
227 nsIDOMHTMLCollection *nscoll = NULL;
230 TRACE("(%p)->(%p)\n", This, p);
237 if(!This->doc_node->nsdoc) {
238 WARN("NULL nsdoc\n");
242 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
243 if(NS_FAILED(nsres)) {
244 ERR("GetApplets failed: %08x\n", nsres);
249 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
250 nsIDOMHTMLCollection_Release(nscoll);
256 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
258 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
259 nsIDOMHTMLCollection *nscoll = NULL;
262 TRACE("(%p)->(%p)\n", This, p);
269 if(!This->doc_node->nsdoc) {
270 WARN("NULL nsdoc\n");
274 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
275 if(NS_FAILED(nsres)) {
276 ERR("GetLinks failed: %08x\n", nsres);
281 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
282 nsIDOMHTMLCollection_Release(nscoll);
288 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
290 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
291 nsIDOMHTMLCollection *nscoll = NULL;
294 TRACE("(%p)->(%p)\n", This, p);
301 if(!This->doc_node->nsdoc) {
302 WARN("NULL nsdoc\n");
306 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
307 if(NS_FAILED(nsres)) {
308 ERR("GetForms failed: %08x\n", nsres);
313 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
314 nsIDOMHTMLCollection_Release(nscoll);
320 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
322 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
323 nsIDOMHTMLCollection *nscoll = NULL;
326 TRACE("(%p)->(%p)\n", This, p);
333 if(!This->doc_node->nsdoc) {
334 WARN("NULL nsdoc\n");
338 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
339 if(NS_FAILED(nsres)) {
340 ERR("GetAnchors failed: %08x\n", nsres);
345 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
346 nsIDOMHTMLCollection_Release(nscoll);
352 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
354 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
358 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
360 if(!This->doc_node->nsdoc) {
361 WARN("NULL nsdoc\n");
365 nsAString_InitDepend(&nsstr, v);
366 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
367 nsAString_Finish(&nsstr);
369 ERR("SetTitle failed: %08x\n", nsres);
374 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
376 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
377 const PRUnichar *ret;
381 TRACE("(%p)->(%p)\n", This, p);
383 if(!This->doc_node->nsdoc) {
384 WARN("NULL nsdoc\n");
389 nsAString_Init(&nsstr, NULL);
390 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
391 if (NS_SUCCEEDED(nsres)) {
392 nsAString_GetData(&nsstr, &ret);
393 *p = SysAllocString(ret);
395 nsAString_Finish(&nsstr);
397 if(NS_FAILED(nsres)) {
398 ERR("GetTitle failed: %08x\n", nsres);
405 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
407 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
408 FIXME("(%p)->(%p)\n", This, p);
412 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
414 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
415 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
419 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
421 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
422 static WCHAR szOff[] = {'O','f','f',0};
423 FIXME("(%p)->(%p) always returning Off\n", This, p);
428 *p = SysAllocString(szOff);
433 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
435 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
436 nsISelection *nsselection;
439 TRACE("(%p)->(%p)\n", This, p);
441 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
442 if(NS_FAILED(nsres)) {
443 ERR("GetSelection failed: %08x\n", nsres);
447 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
450 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
452 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
454 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
455 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
456 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
457 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
458 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
460 static const LPCWSTR readystate_str[] = {
468 TRACE("(%p)->(%p)\n", iface, p);
473 *p = SysAllocString(readystate_str[This->window->readystate]);
477 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
479 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
481 TRACE("(%p)->(%p)\n", This, p);
483 return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p);
486 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
488 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
489 FIXME("(%p)->(%p)\n", This, p);
493 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
495 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
496 FIXME("(%p)->(%p)\n", This, p);
500 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
502 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
503 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
507 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
509 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
510 FIXME("(%p)->(%p)\n", This, p);
514 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
516 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
517 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
521 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
523 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
524 FIXME("(%p)->(%p)\n", This, p);
528 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
530 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
531 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
535 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
537 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
538 FIXME("(%p)->(%p)\n", This, p);
542 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
544 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
545 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
549 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
551 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
552 FIXME("(%p)->(%p)\n", This, p);
556 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
558 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
559 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
563 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
565 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
566 FIXME("(%p)->(%p)\n", This, p);
570 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
572 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
574 FIXME("(%p)->(%p)\n", This, p);
580 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
582 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
584 TRACE("(%p)->(%p)\n", This, p);
586 if(!This->doc_node->nsdoc) {
587 WARN("NULL nsdoc\n");
591 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
594 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
596 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
597 FIXME("(%p)->(%p)\n", This, p);
601 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
603 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
605 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
608 FIXME("No window available\n");
612 return navigate_url(This->window, v, This->window->uri);
615 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
617 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
619 static const WCHAR about_blank_url[] =
620 {'a','b','o','u','t',':','b','l','a','n','k',0};
622 TRACE("(%p)->(%p)\n", iface, p);
624 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
625 return *p ? S_OK : E_OUTOFMEMORY;
628 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
630 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
631 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
635 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
637 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
640 TRACE("(%p)->(%p)\n", This, p);
642 if(!This->window || !This->window->uri) {
643 FIXME("No current URI\n");
647 hres = IUri_GetHost(This->window->uri, p);
648 return FAILED(hres) ? hres : S_OK;
651 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
653 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
656 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
658 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
660 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
661 return HRESULT_FROM_WIN32(GetLastError());
667 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
669 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
673 TRACE("(%p)->(%p)\n", This, p);
676 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
678 switch(GetLastError()) {
679 case ERROR_INSUFFICIENT_BUFFER:
681 case ERROR_NO_MORE_ITEMS:
685 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
686 return HRESULT_FROM_WIN32(GetLastError());
695 *p = SysAllocStringLen(NULL, size-1);
697 return E_OUTOFMEMORY;
699 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
701 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
708 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
710 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
711 FIXME("(%p)->(%x)\n", This, v);
715 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
717 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
718 FIXME("(%p)->(%p)\n", This, p);
722 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
724 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
725 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
729 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
731 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
732 nsAString charset_str;
735 TRACE("(%p)->(%p)\n", This, p);
737 if(!This->doc_node->nsdoc) {
738 FIXME("NULL nsdoc\n");
742 nsAString_Init(&charset_str, NULL);
743 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
744 return return_nsstr(nsres, &charset_str, p);
747 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
749 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
750 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
754 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
756 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
757 FIXME("(%p)->(%p)\n", This, p);
761 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
763 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
764 FIXME("(%p)->(%p)\n", This, p);
768 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
770 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
771 FIXME("(%p)->(%p)\n", This, p);
775 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
777 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
778 FIXME("(%p)->(%p)\n", This, p);
782 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
784 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
785 FIXME("(%p)->(%p)\n", This, p);
789 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
791 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
792 FIXME("(%p)->(%p)\n", This, p);
796 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
798 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
799 FIXME("(%p)->(%p)\n", This, p);
803 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
805 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
806 FIXME("(%p)->(%p)\n", This, p);
810 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
812 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
813 FIXME("(%p)->(%p)\n", This, p);
817 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
825 if(!This->doc_node->nsdoc) {
826 WARN("NULL nsdoc\n");
833 if(psarray->cDims != 1) {
834 FIXME("cDims=%d\n", psarray->cDims);
838 hres = SafeArrayAccessData(psarray, (void**)&var);
840 WARN("SafeArrayAccessData failed: %08x\n", hres);
844 V_VT(&tmp) = VT_EMPTY;
846 argc = psarray->rgsabound[0].cElements;
847 for(i=0; i < argc; i++) {
848 if(V_VT(var+i) == VT_BSTR) {
849 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
851 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
853 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
856 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
859 if(!ln || i != argc-1)
860 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, NULL /* FIXME! */);
862 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, NULL /* FIXME! */);
863 nsAString_Finish(&nsstr);
864 if(V_VT(var+i) != VT_BSTR)
866 if(NS_FAILED(nsres)) {
867 ERR("Write failed: %08x\n", nsres);
873 SafeArrayUnaccessData(psarray);
878 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
880 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
882 TRACE("(%p)->(%p)\n", iface, psarray);
884 return document_write(This, psarray, FALSE);
887 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
889 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
891 TRACE("(%p)->(%p)\n", This, psarray);
893 return document_write(This, psarray, TRUE);
896 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
897 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
899 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
903 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
905 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
906 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
908 if(!This->doc_node->nsdoc) {
913 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
914 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
915 FIXME("unsupported args\n");
917 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL, NULL, 0, &tmp);
918 if(NS_FAILED(nsres)) {
919 ERR("Open failed: %08x\n", nsres);
924 nsISupports_Release(tmp);
926 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
927 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
931 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
933 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
936 TRACE("(%p)\n", This);
938 if(!This->doc_node->nsdoc) {
943 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
944 if(NS_FAILED(nsres)) {
945 ERR("Close failed: %08x\n", nsres);
952 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
954 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
957 TRACE("(%p)\n", This);
959 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
960 if(NS_FAILED(nsres)) {
961 ERR("Clear failed: %08x\n", nsres);
968 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
971 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
972 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
976 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
979 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
980 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
984 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
987 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
988 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
992 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
995 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
996 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1000 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1003 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1004 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1008 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1011 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1012 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1016 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1017 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1019 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1020 FIXME("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1024 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1025 VARIANT_BOOL *pfRet)
1027 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1028 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1032 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1033 IHTMLElement **newElem)
1035 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1036 HTMLDocumentNode *doc_node;
1037 nsIDOMHTMLElement *nselem;
1041 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1043 /* Use owner doc if called on document fragment */
1044 doc_node = This->doc_node;
1045 if(!doc_node->nsdoc)
1046 doc_node = doc_node->node.doc;
1048 hres = create_nselem(doc_node, eTag, &nselem);
1052 hres = HTMLElement_Create(doc_node, (nsIDOMNode*)nselem, TRUE, &elem);
1053 nsIDOMHTMLElement_Release(nselem);
1057 *newElem = &elem->IHTMLElement_iface;
1061 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1063 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1064 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1068 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1070 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1071 FIXME("(%p)->(%p)\n", This, p);
1075 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1077 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1079 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1081 return set_doc_event(This, EVENTID_CLICK, &v);
1084 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1086 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1088 TRACE("(%p)->(%p)\n", This, p);
1090 return get_doc_event(This, EVENTID_CLICK, p);
1093 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1095 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1096 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1100 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1102 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1103 FIXME("(%p)->(%p)\n", This, p);
1107 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1109 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1111 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1113 return set_doc_event(This, EVENTID_KEYUP, &v);
1116 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1118 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1120 TRACE("(%p)->(%p)\n", This, p);
1122 return get_doc_event(This, EVENTID_KEYUP, p);
1125 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1127 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1129 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1131 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1134 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1136 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1138 TRACE("(%p)->(%p)\n", This, p);
1140 return get_doc_event(This, EVENTID_KEYDOWN, p);
1143 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1145 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1147 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1149 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1152 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1154 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1156 TRACE("(%p)->(%p)\n", This, p);
1158 return get_doc_event(This, EVENTID_KEYPRESS, p);
1161 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1163 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1165 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1167 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1170 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1172 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1174 TRACE("(%p)->(%p)\n", This, p);
1176 return get_doc_event(This, EVENTID_MOUSEUP, p);
1179 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1181 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1183 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1185 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1188 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1190 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1192 TRACE("(%p)->(%p)\n", This, p);
1194 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1197 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1199 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1201 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1203 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1206 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1208 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1210 TRACE("(%p)->(%p)\n", This, p);
1212 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1215 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1217 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1219 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1221 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1224 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1226 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1228 TRACE("(%p)->(%p)\n", This, p);
1230 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1233 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1235 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1237 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1239 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1242 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1244 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1246 TRACE("(%p)->(%p)\n", This, p);
1248 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1251 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1253 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1255 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1257 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1260 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1262 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1264 TRACE("(%p)->(%p)\n", This, p);
1266 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1269 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1271 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1272 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1276 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1278 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1279 FIXME("(%p)->(%p)\n", This, p);
1283 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1285 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1286 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1290 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1292 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1293 FIXME("(%p)->(%p)\n", This, p);
1297 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1299 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1300 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1304 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1306 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1307 FIXME("(%p)->(%p)\n", This, p);
1311 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1313 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1315 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1317 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1320 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1322 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1324 TRACE("(%p)->(%p)\n", This, p);
1326 return get_doc_event(This, EVENTID_DRAGSTART, p);
1329 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1331 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1333 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1335 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1338 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1340 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1342 TRACE("(%p)->(%p)\n", This, p);
1344 return get_doc_event(This, EVENTID_SELECTSTART, p);
1347 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1348 IHTMLElement **elementHit)
1350 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1351 nsIDOMElement *nselem;
1356 TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1358 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1359 if(NS_FAILED(nsres)) {
1360 ERR("ElementFromPoint failed: %08x\n", nsres);
1369 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
1370 nsIDOMElement_Release(nselem);
1374 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)elementHit);
1379 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1381 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1383 TRACE("(%p)->(%p)\n", This, p);
1385 *p = &This->window->base.IHTMLWindow2_iface;
1386 IHTMLWindow2_AddRef(*p);
1390 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1391 IHTMLStyleSheetsCollection **p)
1393 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1394 nsIDOMStyleSheetList *nsstylelist;
1397 TRACE("(%p)->(%p)\n", This, p);
1401 if(!This->doc_node->nsdoc) {
1402 WARN("NULL nsdoc\n");
1403 return E_UNEXPECTED;
1406 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1407 if(NS_FAILED(nsres)) {
1408 ERR("GetStyleSheets failed: %08x\n", nsres);
1412 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1413 nsIDOMStyleSheetList_Release(nsstylelist);
1418 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1420 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1421 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1425 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1427 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1428 FIXME("(%p)->(%p)\n", This, p);
1432 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1434 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1435 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1439 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1441 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1442 FIXME("(%p)->(%p)\n", This, p);
1446 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1448 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1449 FIXME("(%p)->(%p)\n", This, String);
1453 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1454 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1456 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1458 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1460 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1464 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1465 HTMLDocument_QueryInterface,
1466 HTMLDocument_AddRef,
1467 HTMLDocument_Release,
1468 HTMLDocument_GetTypeInfoCount,
1469 HTMLDocument_GetTypeInfo,
1470 HTMLDocument_GetIDsOfNames,
1471 HTMLDocument_Invoke,
1472 HTMLDocument_get_Script,
1473 HTMLDocument_get_all,
1474 HTMLDocument_get_body,
1475 HTMLDocument_get_activeElement,
1476 HTMLDocument_get_images,
1477 HTMLDocument_get_applets,
1478 HTMLDocument_get_links,
1479 HTMLDocument_get_forms,
1480 HTMLDocument_get_anchors,
1481 HTMLDocument_put_title,
1482 HTMLDocument_get_title,
1483 HTMLDocument_get_scripts,
1484 HTMLDocument_put_designMode,
1485 HTMLDocument_get_designMode,
1486 HTMLDocument_get_selection,
1487 HTMLDocument_get_readyState,
1488 HTMLDocument_get_frames,
1489 HTMLDocument_get_embeds,
1490 HTMLDocument_get_plugins,
1491 HTMLDocument_put_alinkColor,
1492 HTMLDocument_get_alinkColor,
1493 HTMLDocument_put_bgColor,
1494 HTMLDocument_get_bgColor,
1495 HTMLDocument_put_fgColor,
1496 HTMLDocument_get_fgColor,
1497 HTMLDocument_put_linkColor,
1498 HTMLDocument_get_linkColor,
1499 HTMLDocument_put_vlinkColor,
1500 HTMLDocument_get_vlinkColor,
1501 HTMLDocument_get_referrer,
1502 HTMLDocument_get_location,
1503 HTMLDocument_get_lastModified,
1504 HTMLDocument_put_URL,
1505 HTMLDocument_get_URL,
1506 HTMLDocument_put_domain,
1507 HTMLDocument_get_domain,
1508 HTMLDocument_put_cookie,
1509 HTMLDocument_get_cookie,
1510 HTMLDocument_put_expando,
1511 HTMLDocument_get_expando,
1512 HTMLDocument_put_charset,
1513 HTMLDocument_get_charset,
1514 HTMLDocument_put_defaultCharset,
1515 HTMLDocument_get_defaultCharset,
1516 HTMLDocument_get_mimeType,
1517 HTMLDocument_get_fileSize,
1518 HTMLDocument_get_fileCreatedDate,
1519 HTMLDocument_get_fileModifiedDate,
1520 HTMLDocument_get_fileUpdatedDate,
1521 HTMLDocument_get_security,
1522 HTMLDocument_get_protocol,
1523 HTMLDocument_get_nameProp,
1525 HTMLDocument_writeln,
1529 HTMLDocument_queryCommandSupported,
1530 HTMLDocument_queryCommandEnabled,
1531 HTMLDocument_queryCommandState,
1532 HTMLDocument_queryCommandIndeterm,
1533 HTMLDocument_queryCommandText,
1534 HTMLDocument_queryCommandValue,
1535 HTMLDocument_execCommand,
1536 HTMLDocument_execCommandShowHelp,
1537 HTMLDocument_createElement,
1538 HTMLDocument_put_onhelp,
1539 HTMLDocument_get_onhelp,
1540 HTMLDocument_put_onclick,
1541 HTMLDocument_get_onclick,
1542 HTMLDocument_put_ondblclick,
1543 HTMLDocument_get_ondblclick,
1544 HTMLDocument_put_onkeyup,
1545 HTMLDocument_get_onkeyup,
1546 HTMLDocument_put_onkeydown,
1547 HTMLDocument_get_onkeydown,
1548 HTMLDocument_put_onkeypress,
1549 HTMLDocument_get_onkeypress,
1550 HTMLDocument_put_onmouseup,
1551 HTMLDocument_get_onmouseup,
1552 HTMLDocument_put_onmousedown,
1553 HTMLDocument_get_onmousedown,
1554 HTMLDocument_put_onmousemove,
1555 HTMLDocument_get_onmousemove,
1556 HTMLDocument_put_onmouseout,
1557 HTMLDocument_get_onmouseout,
1558 HTMLDocument_put_onmouseover,
1559 HTMLDocument_get_onmouseover,
1560 HTMLDocument_put_onreadystatechange,
1561 HTMLDocument_get_onreadystatechange,
1562 HTMLDocument_put_onafterupdate,
1563 HTMLDocument_get_onafterupdate,
1564 HTMLDocument_put_onrowexit,
1565 HTMLDocument_get_onrowexit,
1566 HTMLDocument_put_onrowenter,
1567 HTMLDocument_get_onrowenter,
1568 HTMLDocument_put_ondragstart,
1569 HTMLDocument_get_ondragstart,
1570 HTMLDocument_put_onselectstart,
1571 HTMLDocument_get_onselectstart,
1572 HTMLDocument_elementFromPoint,
1573 HTMLDocument_get_parentWindow,
1574 HTMLDocument_get_styleSheets,
1575 HTMLDocument_put_onbeforeupdate,
1576 HTMLDocument_get_onbeforeupdate,
1577 HTMLDocument_put_onerrorupdate,
1578 HTMLDocument_get_onerrorupdate,
1579 HTMLDocument_toString,
1580 HTMLDocument_createStyleSheet
1583 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
1585 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
1588 update_cp_events(This->window->base.inner_window, &This->doc_node->node.event_target, cp, This->doc_node->node.nsnode);
1591 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
1593 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
1596 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1598 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
1599 return htmldoc_query_interface(This, riid, ppv);
1602 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1604 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
1605 return htmldoc_addref(This);
1608 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1610 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
1611 return htmldoc_release(This);
1614 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1616 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1620 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1621 SupportErrorInfo_QueryInterface,
1622 SupportErrorInfo_AddRef,
1623 SupportErrorInfo_Release,
1624 SupportErrorInfo_InterfaceSupportsErrorInfo
1627 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
1629 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
1632 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
1634 nsIDOMNodeList *node_list;
1641 return DISP_E_UNKNOWNNAME;
1643 nsAString_InitDepend(&name_str, name);
1644 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
1645 nsAString_Finish(&name_str);
1646 if(NS_FAILED(nsres))
1649 nsres = nsIDOMNodeList_GetLength(node_list, &len);
1650 nsIDOMNodeList_Release(node_list);
1651 if(NS_FAILED(nsres))
1655 return DISP_E_UNKNOWNNAME;
1657 for(i=0; i < This->elem_vars_cnt; i++) {
1658 if(!strcmpW(name, This->elem_vars[i])) {
1659 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
1664 if(This->elem_vars_cnt == This->elem_vars_size) {
1667 if(This->elem_vars_size) {
1668 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
1670 return E_OUTOFMEMORY;
1671 This->elem_vars_size *= 2;
1673 new_vars = heap_alloc(16*sizeof(WCHAR*));
1675 return E_OUTOFMEMORY;
1676 This->elem_vars_size = 16;
1679 This->elem_vars = new_vars;
1682 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
1683 if(!This->elem_vars[This->elem_vars_cnt])
1684 return E_OUTOFMEMORY;
1686 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
1690 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1692 HTMLDocument *This = impl_from_IDispatchEx(iface);
1694 return htmldoc_query_interface(This, riid, ppv);
1697 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1699 HTMLDocument *This = impl_from_IDispatchEx(iface);
1701 return htmldoc_addref(This);
1704 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1706 HTMLDocument *This = impl_from_IDispatchEx(iface);
1708 return htmldoc_release(This);
1711 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1713 HTMLDocument *This = impl_from_IDispatchEx(iface);
1715 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
1718 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1719 LCID lcid, ITypeInfo **ppTInfo)
1721 HTMLDocument *This = impl_from_IDispatchEx(iface);
1723 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
1726 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1727 LPOLESTR *rgszNames, UINT cNames,
1728 LCID lcid, DISPID *rgDispId)
1730 HTMLDocument *This = impl_from_IDispatchEx(iface);
1732 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
1735 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1736 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1737 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1739 HTMLDocument *This = impl_from_IDispatchEx(iface);
1741 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1742 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1744 switch(dispIdMember) {
1745 case DISPID_READYSTATE:
1746 TRACE("DISPID_READYSTATE\n");
1748 if(!(wFlags & DISPATCH_PROPERTYGET))
1749 return E_INVALIDARG;
1751 V_VT(pVarResult) = VT_I4;
1752 V_I4(pVarResult) = This->window->readystate;
1756 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
1757 pVarResult, pExcepInfo, puArgErr);
1760 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1762 HTMLDocument *This = impl_from_IDispatchEx(iface);
1765 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
1766 if(hres != DISP_E_UNKNOWNNAME)
1769 return dispid_from_elem_name(This->doc_node, bstrName, pid);
1772 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1773 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1775 HTMLDocument *This = impl_from_IDispatchEx(iface);
1777 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
1778 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
1779 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1782 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1785 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1787 HTMLDocument *This = impl_from_IDispatchEx(iface);
1789 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
1792 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1794 HTMLDocument *This = impl_from_IDispatchEx(iface);
1796 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
1799 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1801 HTMLDocument *This = impl_from_IDispatchEx(iface);
1803 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
1806 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1808 HTMLDocument *This = impl_from_IDispatchEx(iface);
1810 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
1813 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1815 HTMLDocument *This = impl_from_IDispatchEx(iface);
1817 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
1820 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1822 HTMLDocument *This = impl_from_IDispatchEx(iface);
1824 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
1827 static const IDispatchExVtbl DocDispatchExVtbl = {
1828 DocDispatchEx_QueryInterface,
1829 DocDispatchEx_AddRef,
1830 DocDispatchEx_Release,
1831 DocDispatchEx_GetTypeInfoCount,
1832 DocDispatchEx_GetTypeInfo,
1833 DocDispatchEx_GetIDsOfNames,
1834 DocDispatchEx_Invoke,
1835 DocDispatchEx_GetDispID,
1836 DocDispatchEx_InvokeEx,
1837 DocDispatchEx_DeleteMemberByName,
1838 DocDispatchEx_DeleteMemberByDispID,
1839 DocDispatchEx_GetMemberProperties,
1840 DocDispatchEx_GetMemberName,
1841 DocDispatchEx_GetNextDispID,
1842 DocDispatchEx_GetNameSpaceParent
1845 static inline HTMLDocument *impl_from_IProvideClassInfo(IProvideClassInfo *iface)
1847 return CONTAINING_RECORD(iface, HTMLDocument, IProvideClassInfo_iface);
1850 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideClassInfo *iface,
1851 REFIID riid, void **ppv)
1853 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
1854 return htmldoc_query_interface(This, riid, ppv);
1857 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideClassInfo *iface)
1859 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
1860 return htmldoc_addref(This);
1863 static ULONG WINAPI ProvideClassInfo_Release(IProvideClassInfo *iface)
1865 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
1866 return htmldoc_release(This);
1869 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideClassInfo* iface,
1872 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
1873 TRACE("(%p)->(%p)\n", This, ppTI);
1874 return get_htmldoc_classinfo(ppTI);
1877 static const IProvideClassInfoVtbl ProvideClassInfoVtbl = {
1878 ProvideClassInfo_QueryInterface,
1879 ProvideClassInfo_AddRef,
1880 ProvideClassInfo_Release,
1881 ProvideClassInfo_GetClassInfo
1884 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
1888 if(IsEqualGUID(&IID_IUnknown, riid)) {
1889 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
1890 *ppv = &This->IHTMLDocument2_iface;
1891 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1892 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv);
1893 *ppv = &This->IDispatchEx_iface;
1894 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
1895 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv);
1896 *ppv = &This->IDispatchEx_iface;
1897 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
1898 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv);
1899 *ppv = &This->IHTMLDocument2_iface;
1900 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
1901 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppv);
1902 *ppv = &This->IHTMLDocument2_iface;
1903 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
1904 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppv);
1905 *ppv = &This->IHTMLDocument3_iface;
1906 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
1907 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppv);
1908 *ppv = &This->IHTMLDocument4_iface;
1909 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
1910 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppv);
1911 *ppv = &This->IHTMLDocument5_iface;
1912 }else if(IsEqualGUID(&IID_IHTMLDocument6, riid)) {
1913 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This, ppv);
1914 *ppv = &This->IHTMLDocument6_iface;
1915 }else if(IsEqualGUID(&IID_IPersist, riid)) {
1916 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
1917 *ppv = &This->IPersistFile_iface;
1918 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
1919 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppv);
1920 *ppv = &This->IPersistMoniker_iface;
1921 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
1922 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppv);
1923 *ppv = &This->IPersistFile_iface;
1924 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
1925 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppv);
1926 *ppv = &This->IMonikerProp_iface;
1927 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
1928 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppv);
1929 *ppv = &This->IOleObject_iface;
1930 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
1931 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppv);
1932 *ppv = &This->IOleDocument_iface;
1933 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
1934 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppv);
1935 *ppv = &This->IOleDocumentView_iface;
1936 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
1937 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
1938 *ppv = &This->IOleInPlaceActiveObject_iface;
1939 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
1940 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
1941 *ppv = &This->IViewObjectEx_iface;
1942 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
1943 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
1944 *ppv = &This->IViewObjectEx_iface;
1945 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
1946 TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This, ppv);
1947 *ppv = &This->IViewObjectEx_iface;
1948 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
1949 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
1950 *ppv = &This->IOleInPlaceActiveObject_iface;
1951 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
1952 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
1953 *ppv = &This->IOleInPlaceObjectWindowless_iface;
1954 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1955 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppv);
1956 *ppv = &This->IOleInPlaceObjectWindowless_iface;
1957 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1958 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
1959 *ppv = &This->IServiceProvider_iface;
1960 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
1961 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppv);
1962 *ppv = &This->IOleCommandTarget_iface;
1963 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
1964 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppv);
1965 *ppv = &This->IOleControl_iface;
1966 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
1967 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppv);
1968 *ppv = &This->IHlinkTarget_iface;
1969 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1970 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1971 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1972 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
1973 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
1974 *ppv = &This->IPersistStreamInit_iface;
1975 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
1976 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
1977 *ppv = &This->IHTMLDocument2_iface;
1978 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
1979 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppv);
1980 *ppv = &This->ISupportErrorInfo_iface;
1981 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
1982 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppv);
1983 *ppv = &This->IPersistHistory_iface;
1984 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
1985 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
1987 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
1988 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
1990 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
1991 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
1993 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
1994 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
1996 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
1997 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
1999 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
2000 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
2002 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
2003 TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv);
2004 *ppv = &This->IObjectWithSite_iface;
2005 }else if(IsEqualGUID(&IID_IOleContainer, riid)) {
2006 TRACE("(%p)->(IID_IOleContainer %p)\n", This, ppv);
2007 *ppv = &This->IOleContainer_iface;
2008 }else if(IsEqualGUID(&IID_IObjectSafety, riid)) {
2009 TRACE("(%p)->(IID_IObjectSafety %p)\n", This, ppv);
2010 *ppv = &This->IObjectSafety_iface;
2011 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
2012 TRACE("(%p)->(IID_IProvideClassInfo, %p)\n", This, ppv);
2013 *ppv = &This->IProvideClassInfo_iface;
2019 IUnknown_AddRef((IUnknown*)*ppv);
2023 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
2025 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
2027 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
2028 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
2029 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
2030 doc->IProvideClassInfo_iface.lpVtbl = &ProvideClassInfoVtbl;
2032 doc->unk_impl = unk_impl;
2033 doc->dispex = dispex;
2034 doc->task_magic = get_task_target_magic();
2036 HTMLDocument_HTMLDocument3_Init(doc);
2037 HTMLDocument_HTMLDocument5_Init(doc);
2038 HTMLDocument_Persist_Init(doc);
2039 HTMLDocument_OleCmd_Init(doc);
2040 HTMLDocument_OleObj_Init(doc);
2041 HTMLDocument_View_Init(doc);
2042 HTMLDocument_Window_Init(doc);
2043 HTMLDocument_Service_Init(doc);
2044 HTMLDocument_Hlink_Init(doc);
2046 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface);
2047 ConnectionPoint_Init(&doc->cp_dispatch, &doc->cp_container, &IID_IDispatch, &HTMLDocumentEvents_data);
2048 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink, NULL);
2049 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data);
2050 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2, NULL);
2053 static void destroy_htmldoc(HTMLDocument *This)
2055 remove_target_tasks(This->task_magic);
2057 ConnectionPointContainer_Destroy(&This->cp_container);
2060 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
2062 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
2065 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
2067 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
2069 if(htmldoc_qi(&This->basedoc, riid, ppv))
2070 return *ppv ? S_OK : E_NOINTERFACE;
2072 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid)) {
2073 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This, ppv);
2074 *ppv = &This->IInternetHostSecurityManager_iface;
2076 return HTMLDOMNode_QI(&This->node, riid, ppv);
2079 IUnknown_AddRef((IUnknown*)*ppv);
2083 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
2085 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
2088 for(i=0; i < This->elem_vars_cnt; i++)
2089 heap_free(This->elem_vars[i]);
2090 heap_free(This->elem_vars);
2092 detach_events(This);
2093 if(This->body_event_target)
2094 release_event_target(This->body_event_target);
2096 ICatInformation_Release(This->catmgr);
2098 detach_selection(This);
2099 detach_ranges(This);
2101 while(!list_empty(&This->plugin_hosts))
2102 detach_plugin_host(LIST_ENTRY(list_head(&This->plugin_hosts), PluginHost, entry));
2105 assert(!This->window);
2106 release_document_mutation(This);
2107 nsIDOMHTMLDocument_Release(This->nsdoc);
2108 }else if(This->window) {
2109 /* document fragments own reference to inner window */
2110 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
2111 This->window = NULL;
2114 heap_free(This->event_vector);
2115 destroy_htmldoc(&This->basedoc);
2118 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
2120 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
2121 FIXME("%p\n", This);
2125 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
2127 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
2130 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
2133 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
2135 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
2138 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
2140 release_document_mutation(This);
2142 nsIDOMHTMLDocument_Release(nsdoc);
2143 This->window = NULL;
2147 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
2148 HTMLDocumentNode_QI,
2149 HTMLDocumentNode_destructor,
2150 HTMLDocumentNode_clone,
2162 HTMLDocumentNode_traverse,
2163 HTMLDocumentNode_unlink
2166 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
2168 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
2169 HTMLDocumentNode *new_node;
2172 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
2176 *ret = &new_node->node;
2180 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
2182 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.dispex);
2185 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2186 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2188 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
2189 nsIDOMNodeList *node_list;
2197 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
2198 FIXME("unsupported flags %x\n", flags);
2202 i = id - MSHTML_DISPID_CUSTOM_MIN;
2204 if(!This->nsdoc || i >= This->elem_vars_cnt)
2205 return DISP_E_UNKNOWNNAME;
2207 nsAString_InitDepend(&name_str, This->elem_vars[i]);
2208 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
2209 nsAString_Finish(&name_str);
2210 if(NS_FAILED(nsres))
2213 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
2214 nsIDOMNodeList_Release(node_list);
2215 if(NS_FAILED(nsres) || !nsnode)
2216 return DISP_E_UNKNOWNNAME;
2218 hres = get_node(This, nsnode, TRUE, &node);
2222 V_VT(res) = VT_DISPATCH;
2223 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
2228 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl = {
2231 HTMLDocumentNode_invoke,
2235 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
2236 HTMLDocumentNode_QI,
2237 HTMLDocumentNode_destructor,
2238 HTMLDocumentFragment_clone
2241 static const tid_t HTMLDocumentNode_iface_tids[] = {
2251 static dispex_static_data_t HTMLDocumentNode_dispex = {
2252 &HTMLDocumentNode_dispex_vtbl,
2253 DispHTMLDocument_tid,
2255 HTMLDocumentNode_iface_tids
2258 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
2260 HTMLDocumentNode *doc;
2262 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
2267 doc->basedoc.doc_node = doc;
2268 doc->basedoc.doc_obj = doc_obj;
2269 doc->basedoc.window = window->base.outer_window;
2270 doc->window = window;
2272 init_dispex(&doc->node.dispex, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
2273 &HTMLDocumentNode_dispex);
2274 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
2275 &doc->node.dispex.IDispatchEx_iface);
2276 HTMLDocumentNode_SecMgr_Init(doc);
2278 list_init(&doc->selection_list);
2279 list_init(&doc->range_list);
2280 list_init(&doc->plugin_hosts);
2285 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLInnerWindow *window, HTMLDocumentNode **ret)
2287 HTMLDocumentNode *doc;
2289 doc = alloc_doc_node(doc_obj, window);
2291 return E_OUTOFMEMORY;
2293 if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
2294 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
2296 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
2298 nsIDOMHTMLDocument_AddRef(nsdoc);
2301 init_document_mutation(doc);
2302 doc_init_events(doc);
2304 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
2305 doc->node.cp_container = &doc->basedoc.cp_container;
2311 HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
2313 HTMLDocumentNode *doc_frag;
2315 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
2317 return E_OUTOFMEMORY;
2319 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
2321 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
2322 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
2323 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
2329 /**********************************************************
2330 * ICustomDoc implementation
2333 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
2335 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
2338 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
2340 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
2342 if(htmldoc_qi(&This->basedoc, riid, ppv))
2343 return *ppv ? S_OK : E_NOINTERFACE;
2345 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
2346 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
2347 *ppv = &This->ICustomDoc_iface;
2348 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
2349 TRACE("(%p)->(IID_ITargetContainer %p)\n", This, ppv);
2350 *ppv = &This->ITargetContainer_iface;
2351 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2352 return *ppv ? S_OK : E_NOINTERFACE;
2354 FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
2356 return E_NOINTERFACE;
2359 IUnknown_AddRef((IUnknown*)*ppv);
2363 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
2365 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
2366 ULONG ref = InterlockedIncrement(&This->ref);
2368 TRACE("(%p) ref = %u\n", This, ref);
2373 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
2375 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
2376 ULONG ref = InterlockedDecrement(&This->ref);
2378 TRACE("(%p) ref = %u\n", This, ref);
2381 nsIDOMWindowUtils *window_utils = NULL;
2383 if(This->basedoc.window && This->basedoc.window->nswindow)
2384 get_nsinterface((nsISupports*)This->basedoc.window->nswindow, &IID_nsIDOMWindowUtils, (void**)&window_utils);
2386 if(This->basedoc.doc_node) {
2387 This->basedoc.doc_node->basedoc.doc_obj = NULL;
2388 htmldoc_release(&This->basedoc.doc_node->basedoc);
2390 if(This->basedoc.window) {
2391 This->basedoc.window->doc_obj = NULL;
2392 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
2394 if(This->basedoc.advise_holder)
2395 IOleAdviseHolder_Release(This->basedoc.advise_holder);
2398 IAdviseSink_Release(This->view_sink);
2400 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
2402 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
2403 if(This->in_place_active)
2404 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
2406 IOleDocumentView_SetInPlaceSite(&This->basedoc.IOleDocumentView_iface, NULL);
2408 IOleUndoManager_Release(This->undomgr);
2409 if(This->tooltips_hwnd)
2410 DestroyWindow(This->tooltips_hwnd);
2413 DestroyWindow(This->hwnd);
2414 heap_free(This->mime);
2416 destroy_htmldoc(&This->basedoc);
2417 release_dispex(&This->dispex);
2419 if(This->nscontainer)
2420 NSContainer_Release(This->nscontainer);
2423 /* Force cycle collection */
2425 nsIDOMWindowUtils_CycleCollect(window_utils, NULL, 0);
2426 nsIDOMWindowUtils_Release(window_utils);
2433 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
2435 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
2436 IOleCommandTarget *cmdtrg;
2439 TRACE("(%p)->(%p)\n", This, pUIHandler);
2441 if(This->custom_hostui && This->hostui == pUIHandler)
2444 This->custom_hostui = TRUE;
2447 IDocHostUIHandler_Release(This->hostui);
2449 IDocHostUIHandler_AddRef(pUIHandler);
2450 This->hostui = pUIHandler;
2454 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
2455 if(SUCCEEDED(hres)) {
2456 FIXME("custom UI handler supports IOleCommandTarget\n");
2457 IOleCommandTarget_Release(cmdtrg);
2463 static const ICustomDocVtbl CustomDocVtbl = {
2464 CustomDoc_QueryInterface,
2467 CustomDoc_SetUIHandler
2470 static const tid_t HTMLDocumentObj_iface_tids[] = {
2477 static dispex_static_data_t HTMLDocumentObj_dispex = {
2479 DispHTMLDocument_tid,
2481 HTMLDocumentObj_iface_tids
2484 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
2486 HTMLDocumentObj *doc;
2487 nsIDOMWindow *nswindow = NULL;
2491 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2493 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
2495 return E_OUTOFMEMORY;
2497 init_dispex(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex);
2498 init_doc(&doc->basedoc, (IUnknown*)&doc->ICustomDoc_iface, &doc->dispex.IDispatchEx_iface);
2499 TargetContainer_Init(doc);
2501 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
2503 doc->basedoc.doc_obj = doc;
2505 doc->usermode = UNKNOWN_USERMODE;
2507 init_binding_ui(doc);
2509 hres = create_nscontainer(doc, &doc->nscontainer);
2511 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2512 htmldoc_release(&doc->basedoc);
2516 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
2517 htmldoc_release(&doc->basedoc);
2521 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
2522 if(NS_FAILED(nsres))
2523 ERR("GetContentDOMWindow failed: %08x\n", nsres);
2525 hres = HTMLOuterWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
2527 nsIDOMWindow_Release(nswindow);
2529 htmldoc_release(&doc->basedoc);
2533 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
2534 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
2535 htmldoc_addref(&doc->basedoc.doc_node->basedoc);