push 9cc132ec6c678833a0b16cc6a61d52a23f072314
[wine/hacks.git] / dlls / mshtml / htmldoc.c
blob61476328dd10b81e95f3f2c4c1a7766b9a506f03
1 /*
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
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "wininet.h"
30 #include "ole2.h"
31 #include "perhist.h"
32 #include "mshtmdid.h"
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
37 #include "htmlevent.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
43 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
45 HTMLDocument *This = HTMLDOC_THIS(iface);
47 return htmldoc_query_interface(This, riid, ppv);
50 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
52 HTMLDocument *This = HTMLDOC_THIS(iface);
54 return htmldoc_addref(This);
57 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
59 HTMLDocument *This = HTMLDOC_THIS(iface);
61 return htmldoc_release(This);
64 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
66 HTMLDocument *This = HTMLDOC_THIS(iface);
68 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
71 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
72 LCID lcid, ITypeInfo **ppTInfo)
74 HTMLDocument *This = HTMLDOC_THIS(iface);
76 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
79 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
80 LPOLESTR *rgszNames, UINT cNames,
81 LCID lcid, DISPID *rgDispId)
83 HTMLDocument *This = HTMLDOC_THIS(iface);
85 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
88 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
89 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
90 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
92 HTMLDocument *This = HTMLDOC_THIS(iface);
94 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
95 pVarResult, pExcepInfo, puArgErr);
98 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
100 HTMLDocument *This = HTMLDOC_THIS(iface);
102 TRACE("(%p)->(%p)\n", This, p);
104 *p = (IDispatch*)HTMLWINDOW2(This->window);
105 IDispatch_AddRef(*p);
106 return S_OK;
109 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
111 HTMLDocument *This = HTMLDOC_THIS(iface);
112 nsIDOMElement *nselem = NULL;
113 nsresult nsres;
115 TRACE("(%p)->(%p)\n", This, p);
117 if(!This->doc_node->nsdoc) {
118 WARN("NULL nsdoc\n");
119 return E_UNEXPECTED;
122 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
123 if(NS_FAILED(nsres)) {
124 ERR("GetDocumentElement failed: %08x\n", nsres);
125 return E_FAIL;
128 if(nselem) {
129 *p = create_all_collection(get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE), TRUE);
130 nsIDOMElement_Release(nselem);
131 }else {
132 *p = NULL;
135 return S_OK;
138 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
140 HTMLDocument *This = HTMLDOC_THIS(iface);
141 nsIDOMHTMLElement *nsbody = NULL;
142 HTMLDOMNode *node;
143 nsresult nsres;
145 TRACE("(%p)->(%p)\n", This, p);
147 if(!This->doc_node->nsdoc) {
148 WARN("NULL nsdoc\n");
149 return E_UNEXPECTED;
152 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
153 if(NS_FAILED(nsres)) {
154 TRACE("Could not get body: %08x\n", nsres);
155 return E_UNEXPECTED;
158 if(nsbody) {
159 node = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE);
160 nsIDOMHTMLElement_Release(nsbody);
162 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
163 }else {
164 *p = NULL;
167 TRACE("*p = %p\n", *p);
168 return S_OK;
171 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
173 HTMLDocument *This = HTMLDOC_THIS(iface);
174 FIXME("(%p)->(%p)\n", This, p);
175 return E_NOTIMPL;
178 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
180 HTMLDocument *This = HTMLDOC_THIS(iface);
181 nsIDOMHTMLCollection *nscoll = NULL;
182 nsresult nsres;
184 TRACE("(%p)->(%p)\n", This, p);
186 if(!p)
187 return E_INVALIDARG;
189 *p = NULL;
191 if(!This->doc_node->nsdoc) {
192 WARN("NULL nsdoc\n");
193 return E_UNEXPECTED;
196 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
197 if(NS_FAILED(nsres)) {
198 ERR("GetImages failed: %08x\n", nsres);
199 return E_FAIL;
202 if(nscoll) {
203 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
204 nsIDOMElement_Release(nscoll);
207 return S_OK;
210 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
212 HTMLDocument *This = HTMLDOC_THIS(iface);
213 nsIDOMHTMLCollection *nscoll = NULL;
214 nsresult nsres;
216 TRACE("(%p)->(%p)\n", This, p);
218 if(!p)
219 return E_INVALIDARG;
221 *p = NULL;
223 if(!This->doc_node->nsdoc) {
224 WARN("NULL nsdoc\n");
225 return E_UNEXPECTED;
228 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
229 if(NS_FAILED(nsres)) {
230 ERR("GetApplets failed: %08x\n", nsres);
231 return E_FAIL;
234 if(nscoll) {
235 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
236 nsIDOMElement_Release(nscoll);
239 return S_OK;
242 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
244 HTMLDocument *This = HTMLDOC_THIS(iface);
245 nsIDOMHTMLCollection *nscoll = NULL;
246 nsresult nsres;
248 TRACE("(%p)->(%p)\n", This, p);
250 if(!p)
251 return E_INVALIDARG;
253 *p = NULL;
255 if(!This->doc_node->nsdoc) {
256 WARN("NULL nsdoc\n");
257 return E_UNEXPECTED;
260 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
261 if(NS_FAILED(nsres)) {
262 ERR("GetLinks failed: %08x\n", nsres);
263 return E_FAIL;
266 if(nscoll) {
267 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
268 nsIDOMElement_Release(nscoll);
271 return S_OK;
274 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
276 HTMLDocument *This = HTMLDOC_THIS(iface);
277 nsIDOMHTMLCollection *nscoll = NULL;
278 nsresult nsres;
280 TRACE("(%p)->(%p)\n", This, p);
282 if(!p)
283 return E_INVALIDARG;
285 *p = NULL;
287 if(!This->doc_node->nsdoc) {
288 WARN("NULL nsdoc\n");
289 return E_UNEXPECTED;
292 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
293 if(NS_FAILED(nsres)) {
294 ERR("GetForms failed: %08x\n", nsres);
295 return E_FAIL;
298 if(nscoll) {
299 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
300 nsIDOMElement_Release(nscoll);
303 return S_OK;
306 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
308 HTMLDocument *This = HTMLDOC_THIS(iface);
309 nsIDOMHTMLCollection *nscoll = NULL;
310 nsresult nsres;
312 TRACE("(%p)->(%p)\n", This, p);
314 if(!p)
315 return E_INVALIDARG;
317 *p = NULL;
319 if(!This->doc_node->nsdoc) {
320 WARN("NULL nsdoc\n");
321 return E_UNEXPECTED;
324 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
325 if(NS_FAILED(nsres)) {
326 ERR("GetAnchors failed: %08x\n", nsres);
327 return E_FAIL;
330 if(nscoll) {
331 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
332 nsIDOMElement_Release(nscoll);
335 return S_OK;
338 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
340 HTMLDocument *This = HTMLDOC_THIS(iface);
341 nsAString nsstr;
342 nsresult nsres;
344 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
346 if(!This->doc_node->nsdoc) {
347 WARN("NULL nsdoc\n");
348 return E_UNEXPECTED;
351 nsAString_InitDepend(&nsstr, v);
352 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
353 nsAString_Finish(&nsstr);
354 if(NS_FAILED(nsres))
355 ERR("SetTitle failed: %08x\n", nsres);
357 return S_OK;
360 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
362 HTMLDocument *This = HTMLDOC_THIS(iface);
363 const PRUnichar *ret;
364 nsAString nsstr;
365 nsresult nsres;
367 TRACE("(%p)->(%p)\n", This, p);
369 if(!This->doc_node->nsdoc) {
370 WARN("NULL nsdoc\n");
371 return E_UNEXPECTED;
375 nsAString_Init(&nsstr, NULL);
376 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
377 if (NS_SUCCEEDED(nsres)) {
378 nsAString_GetData(&nsstr, &ret);
379 *p = SysAllocString(ret);
381 nsAString_Finish(&nsstr);
383 if(NS_FAILED(nsres)) {
384 ERR("GetTitle failed: %08x\n", nsres);
385 return E_FAIL;
388 return S_OK;
391 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
393 HTMLDocument *This = HTMLDOC_THIS(iface);
394 FIXME("(%p)->(%p)\n", This, p);
395 return E_NOTIMPL;
398 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
400 HTMLDocument *This = HTMLDOC_THIS(iface);
401 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
402 return E_NOTIMPL;
405 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
407 HTMLDocument *This = HTMLDOC_THIS(iface);
408 static WCHAR szOff[] = {'O','f','f',0};
409 FIXME("(%p)->(%p) always returning Off\n", This, p);
411 if(!p)
412 return E_INVALIDARG;
414 *p = SysAllocString(szOff);
416 return S_OK;
419 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
421 HTMLDocument *This = HTMLDOC_THIS(iface);
422 nsISelection *nsselection;
423 nsresult nsres;
425 TRACE("(%p)->(%p)\n", This, p);
427 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
428 if(NS_FAILED(nsres)) {
429 ERR("GetSelection failed: %08x\n", nsres);
430 return E_FAIL;
433 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
436 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
438 HTMLDocument *This = HTMLDOC_THIS(iface);
440 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
441 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
442 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
443 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
444 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
446 static const LPCWSTR readystate_str[] = {
447 wszUninitialized,
448 wszLoading,
449 wszLoaded,
450 wszInteractive,
451 wszComplete
454 TRACE("(%p)->(%p)\n", iface, p);
456 if(!p)
457 return E_POINTER;
459 *p = SysAllocString(readystate_str[This->window->readystate]);
460 return S_OK;
463 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
465 HTMLDocument *This = HTMLDOC_THIS(iface);
466 FIXME("(%p)->(%p)\n", This, p);
467 return E_NOTIMPL;
470 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
472 HTMLDocument *This = HTMLDOC_THIS(iface);
473 FIXME("(%p)->(%p)\n", This, p);
474 return E_NOTIMPL;
477 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
479 HTMLDocument *This = HTMLDOC_THIS(iface);
480 FIXME("(%p)->(%p)\n", This, p);
481 return E_NOTIMPL;
484 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
486 HTMLDocument *This = HTMLDOC_THIS(iface);
487 FIXME("(%p)\n", This);
488 return E_NOTIMPL;
491 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
493 HTMLDocument *This = HTMLDOC_THIS(iface);
494 FIXME("(%p)->(%p)\n", This, p);
495 return E_NOTIMPL;
498 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
500 HTMLDocument *This = HTMLDOC_THIS(iface);
501 FIXME("(%p)\n", This);
502 return E_NOTIMPL;
505 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
507 HTMLDocument *This = HTMLDOC_THIS(iface);
508 FIXME("(%p)->(%p)\n", This, p);
509 return E_NOTIMPL;
512 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
514 HTMLDocument *This = HTMLDOC_THIS(iface);
515 FIXME("(%p)\n", This);
516 return E_NOTIMPL;
519 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
521 HTMLDocument *This = HTMLDOC_THIS(iface);
522 FIXME("(%p)->(%p)\n", This, p);
523 return E_NOTIMPL;
526 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
528 HTMLDocument *This = HTMLDOC_THIS(iface);
529 FIXME("(%p)->()\n", This);
530 return E_NOTIMPL;
533 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
535 HTMLDocument *This = HTMLDOC_THIS(iface);
536 FIXME("(%p)->(%p)\n", This, p);
537 return E_NOTIMPL;
540 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
542 HTMLDocument *This = HTMLDOC_THIS(iface);
543 FIXME("(%p)\n", This);
544 return E_NOTIMPL;
547 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
549 HTMLDocument *This = HTMLDOC_THIS(iface);
550 FIXME("(%p)->(%p)\n", This, p);
551 return E_NOTIMPL;
554 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
556 HTMLDocument *This = HTMLDOC_THIS(iface);
558 FIXME("(%p)->(%p)\n", This, p);
560 *p = NULL;
561 return S_OK;
564 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
566 HTMLDocument *This = HTMLDOC_THIS(iface);
568 TRACE("(%p)->(%p)\n", This, p);
570 return IHTMLWindow2_get_location(HTMLWINDOW2(This->window), p);
573 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
575 HTMLDocument *This = HTMLDOC_THIS(iface);
576 FIXME("(%p)->(%p)\n", This, p);
577 return E_NOTIMPL;
580 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
582 HTMLDocument *This = HTMLDOC_THIS(iface);
583 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
584 return E_NOTIMPL;
587 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
589 HTMLDocument *This = HTMLDOC_THIS(iface);
591 static const WCHAR about_blank_url[] =
592 {'a','b','o','u','t',':','b','l','a','n','k',0};
594 TRACE("(%p)->(%p)\n", iface, p);
596 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
597 return *p ? S_OK : E_OUTOFMEMORY;
600 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
602 HTMLDocument *This = HTMLDOC_THIS(iface);
603 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
604 return E_NOTIMPL;
607 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
609 HTMLDocument *This = HTMLDOC_THIS(iface);
610 FIXME("(%p)->(%p)\n", This, p);
611 return E_NOTIMPL;
614 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
616 HTMLDocument *This = HTMLDOC_THIS(iface);
617 BOOL bret;
619 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
621 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
622 if(!bret) {
623 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
624 return HRESULT_FROM_WIN32(GetLastError());
627 return S_OK;
630 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
632 HTMLDocument *This = HTMLDOC_THIS(iface);
633 DWORD size;
634 BOOL bret;
636 TRACE("(%p)->(%p)\n", This, p);
638 size = 0;
639 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
640 if(!bret) {
641 switch(GetLastError()) {
642 case ERROR_INSUFFICIENT_BUFFER:
643 break;
644 case ERROR_NO_MORE_ITEMS:
645 *p = NULL;
646 return S_OK;
647 default:
648 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
649 return HRESULT_FROM_WIN32(GetLastError());
653 if(!size) {
654 *p = NULL;
655 return S_OK;
658 *p = SysAllocStringLen(NULL, size-1);
659 if(!*p)
660 return E_OUTOFMEMORY;
662 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
663 if(!bret) {
664 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
665 return E_FAIL;
668 return S_OK;
671 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
673 HTMLDocument *This = HTMLDOC_THIS(iface);
674 FIXME("(%p)->(%x)\n", This, v);
675 return E_NOTIMPL;
678 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
680 HTMLDocument *This = HTMLDOC_THIS(iface);
681 FIXME("(%p)->(%p)\n", This, p);
682 return E_NOTIMPL;
685 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
687 HTMLDocument *This = HTMLDOC_THIS(iface);
688 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
689 return E_NOTIMPL;
692 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
694 HTMLDocument *This = HTMLDOC_THIS(iface);
695 FIXME("(%p)->(%p)\n", This, p);
696 return E_NOTIMPL;
699 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
701 HTMLDocument *This = HTMLDOC_THIS(iface);
702 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
703 return E_NOTIMPL;
706 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
708 HTMLDocument *This = HTMLDOC_THIS(iface);
709 FIXME("(%p)->(%p)\n", This, p);
710 return E_NOTIMPL;
713 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
715 HTMLDocument *This = HTMLDOC_THIS(iface);
716 FIXME("(%p)->(%p)\n", This, p);
717 return E_NOTIMPL;
720 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
722 HTMLDocument *This = HTMLDOC_THIS(iface);
723 FIXME("(%p)->(%p)\n", This, p);
724 return E_NOTIMPL;
727 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
729 HTMLDocument *This = HTMLDOC_THIS(iface);
730 FIXME("(%p)->(%p)\n", This, p);
731 return E_NOTIMPL;
734 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
736 HTMLDocument *This = HTMLDOC_THIS(iface);
737 FIXME("(%p)->(%p)\n", This, p);
738 return E_NOTIMPL;
741 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
743 HTMLDocument *This = HTMLDOC_THIS(iface);
744 FIXME("(%p)->(%p)\n", This, p);
745 return E_NOTIMPL;
748 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
750 HTMLDocument *This = HTMLDOC_THIS(iface);
751 FIXME("(%p)->(%p)\n", This, p);
752 return E_NOTIMPL;
755 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
757 HTMLDocument *This = HTMLDOC_THIS(iface);
758 FIXME("(%p)->(%p)\n", This, p);
759 return E_NOTIMPL;
762 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
764 HTMLDocument *This = HTMLDOC_THIS(iface);
765 FIXME("(%p)->(%p)\n", This, p);
766 return E_NOTIMPL;
769 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
771 nsAString nsstr;
772 VARIANT *var;
773 ULONG i, argc;
774 nsresult nsres;
775 HRESULT hres;
777 if(!This->doc_node->nsdoc) {
778 WARN("NULL nsdoc\n");
779 return E_UNEXPECTED;
782 if (!psarray)
783 return S_OK;
785 if(psarray->cDims != 1) {
786 FIXME("cDims=%d\n", psarray->cDims);
787 return E_INVALIDARG;
790 hres = SafeArrayAccessData(psarray, (void**)&var);
791 if(FAILED(hres)) {
792 WARN("SafeArrayAccessData failed: %08x\n", hres);
793 return hres;
796 nsAString_Init(&nsstr, NULL);
798 argc = psarray->rgsabound[0].cElements;
799 for(i=0; i < argc; i++) {
800 if(V_VT(var+i) == VT_BSTR) {
801 nsAString_SetData(&nsstr, V_BSTR(var+i));
802 if(!ln || i != argc-1)
803 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr);
804 else
805 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr);
806 if(NS_FAILED(nsres))
807 ERR("Write failed: %08x\n", nsres);
808 }else {
809 FIXME("vt=%d\n", V_VT(var+i));
813 nsAString_Finish(&nsstr);
814 SafeArrayUnaccessData(psarray);
816 return S_OK;
819 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
821 HTMLDocument *This = HTMLDOC_THIS(iface);
823 TRACE("(%p)->(%p)\n", iface, psarray);
825 return document_write(This, psarray, FALSE);
828 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
830 HTMLDocument *This = HTMLDOC_THIS(iface);
832 TRACE("(%p)->(%p)\n", This, psarray);
834 return document_write(This, psarray, TRUE);
837 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
838 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
840 HTMLDocument *This = HTMLDOC_THIS(iface);
841 nsresult nsres;
843 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
845 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
846 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
848 if(!This->doc_node->nsdoc) {
849 ERR("!nsdoc\n");
850 return E_NOTIMPL;
853 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
854 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
855 FIXME("unsupported args\n");
857 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc);
858 if(NS_FAILED(nsres)) {
859 ERR("Open failed: %08x\n", nsres);
860 return E_FAIL;
863 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
864 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
865 return S_OK;
868 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
870 HTMLDocument *This = HTMLDOC_THIS(iface);
871 nsresult nsres;
873 TRACE("(%p)\n", This);
875 if(!This->doc_node->nsdoc) {
876 ERR("!nsdoc\n");
877 return E_NOTIMPL;
880 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
881 if(NS_FAILED(nsres)) {
882 ERR("Close failed: %08x\n", nsres);
883 return E_FAIL;
886 return S_OK;
889 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
891 HTMLDocument *This = HTMLDOC_THIS(iface);
892 nsIDOMNSHTMLDocument *nsdoc;
893 nsresult nsres;
895 TRACE("(%p)\n", This);
897 nsres = nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMNSHTMLDocument, (void**)&nsdoc);
898 if(NS_FAILED(nsres)) {
899 ERR("Could not get nsIDOMNSHTMLDocument iface: %08x\n", nsres);
900 return E_FAIL;
903 nsres = nsIDOMNSHTMLDocument_Clear(nsdoc);
904 nsIDOMNSHTMLDocument_Release(nsdoc);
905 if(NS_FAILED(nsres)) {
906 ERR("Clear failed: %08x\n", nsres);
907 return E_FAIL;
910 return S_OK;
913 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
914 VARIANT_BOOL *pfRet)
916 HTMLDocument *This = HTMLDOC_THIS(iface);
917 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
918 return E_NOTIMPL;
921 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
922 VARIANT_BOOL *pfRet)
924 HTMLDocument *This = HTMLDOC_THIS(iface);
925 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
926 return E_NOTIMPL;
929 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
930 VARIANT_BOOL *pfRet)
932 HTMLDocument *This = HTMLDOC_THIS(iface);
933 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
934 return E_NOTIMPL;
937 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
938 VARIANT_BOOL *pfRet)
940 HTMLDocument *This = HTMLDOC_THIS(iface);
941 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
942 return E_NOTIMPL;
945 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
946 BSTR *pfRet)
948 HTMLDocument *This = HTMLDOC_THIS(iface);
949 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
950 return E_NOTIMPL;
953 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
954 VARIANT *pfRet)
956 HTMLDocument *This = HTMLDOC_THIS(iface);
957 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
958 return E_NOTIMPL;
961 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
962 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
964 HTMLDocument *This = HTMLDOC_THIS(iface);
965 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
966 return E_NOTIMPL;
969 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
970 VARIANT_BOOL *pfRet)
972 HTMLDocument *This = HTMLDOC_THIS(iface);
973 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
974 return E_NOTIMPL;
977 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
978 IHTMLElement **newElem)
980 HTMLDocument *This = HTMLDOC_THIS(iface);
981 nsIDOMHTMLElement *nselem;
982 HTMLElement *elem;
983 HRESULT hres;
985 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
987 hres = create_nselem(This->doc_node, eTag, &nselem);
988 if(FAILED(hres))
989 return hres;
991 elem = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE);
992 nsIDOMHTMLElement_Release(nselem);
994 *newElem = HTMLELEM(elem);
995 IHTMLElement_AddRef(HTMLELEM(elem));
996 return S_OK;
999 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1001 HTMLDocument *This = HTMLDOC_THIS(iface);
1002 FIXME("(%p)\n", This);
1003 return E_NOTIMPL;
1006 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1008 HTMLDocument *This = HTMLDOC_THIS(iface);
1009 FIXME("(%p)->(%p)\n", This, p);
1010 return E_NOTIMPL;
1013 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1015 HTMLDocument *This = HTMLDOC_THIS(iface);
1017 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1019 return set_doc_event(This, EVENTID_CLICK, &v);
1022 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1024 HTMLDocument *This = HTMLDOC_THIS(iface);
1026 TRACE("(%p)->(%p)\n", This, p);
1028 return get_doc_event(This, EVENTID_CLICK, p);
1031 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1033 HTMLDocument *This = HTMLDOC_THIS(iface);
1034 FIXME("(%p)\n", This);
1035 return E_NOTIMPL;
1038 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1040 HTMLDocument *This = HTMLDOC_THIS(iface);
1041 FIXME("(%p)->(%p)\n", This, p);
1042 return E_NOTIMPL;
1045 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1047 HTMLDocument *This = HTMLDOC_THIS(iface);
1049 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1051 return set_doc_event(This, EVENTID_KEYUP, &v);
1054 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1056 HTMLDocument *This = HTMLDOC_THIS(iface);
1058 TRACE("(%p)->(%p)\n", This, p);
1060 return get_doc_event(This, EVENTID_KEYUP, p);
1063 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1065 HTMLDocument *This = HTMLDOC_THIS(iface);
1067 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1069 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1072 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1074 HTMLDocument *This = HTMLDOC_THIS(iface);
1076 TRACE("(%p)->(%p)\n", This, p);
1078 return get_doc_event(This, EVENTID_KEYDOWN, p);
1081 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1083 HTMLDocument *This = HTMLDOC_THIS(iface);
1084 FIXME("(%p)\n", This);
1085 return E_NOTIMPL;
1088 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1090 HTMLDocument *This = HTMLDOC_THIS(iface);
1091 FIXME("(%p)->(%p)\n", This, p);
1092 return E_NOTIMPL;
1095 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1097 HTMLDocument *This = HTMLDOC_THIS(iface);
1099 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1101 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1104 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1106 HTMLDocument *This = HTMLDOC_THIS(iface);
1108 TRACE("(%p)->(%p)\n", This, p);
1110 return get_doc_event(This, EVENTID_MOUSEUP, p);
1113 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1115 HTMLDocument *This = HTMLDOC_THIS(iface);
1117 TRACE("(%p)->()\n", This);
1119 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1122 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1124 HTMLDocument *This = HTMLDOC_THIS(iface);
1126 TRACE("(%p)->(%p)\n", This, p);
1128 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1131 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1133 HTMLDocument *This = HTMLDOC_THIS(iface);
1134 FIXME("(%p)\n", This);
1135 return E_NOTIMPL;
1138 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1140 HTMLDocument *This = HTMLDOC_THIS(iface);
1141 FIXME("(%p)->(%p)\n", This, p);
1142 return E_NOTIMPL;
1145 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1147 HTMLDocument *This = HTMLDOC_THIS(iface);
1149 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1151 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1154 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1156 HTMLDocument *This = HTMLDOC_THIS(iface);
1158 TRACE("(%p)->(%p)\n", This, p);
1160 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1163 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1165 HTMLDocument *This = HTMLDOC_THIS(iface);
1167 TRACE("(%p)\n", This);
1169 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1172 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1174 HTMLDocument *This = HTMLDOC_THIS(iface);
1176 TRACE("(%p)->(%p)\n", This, p);
1178 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1181 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1183 HTMLDocument *This = HTMLDOC_THIS(iface);
1185 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1187 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1190 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1192 HTMLDocument *This = HTMLDOC_THIS(iface);
1194 TRACE("(%p)->(%p)\n", This, p);
1196 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1199 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1201 HTMLDocument *This = HTMLDOC_THIS(iface);
1202 FIXME("(%p)\n", This);
1203 return E_NOTIMPL;
1206 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1208 HTMLDocument *This = HTMLDOC_THIS(iface);
1209 FIXME("(%p)->(%p)\n", This, p);
1210 return E_NOTIMPL;
1213 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1215 HTMLDocument *This = HTMLDOC_THIS(iface);
1216 FIXME("(%p)\n", This);
1217 return E_NOTIMPL;
1220 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1222 HTMLDocument *This = HTMLDOC_THIS(iface);
1223 FIXME("(%p)->(%p)\n", This, p);
1224 return E_NOTIMPL;
1227 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1229 HTMLDocument *This = HTMLDOC_THIS(iface);
1230 FIXME("(%p)\n", This);
1231 return E_NOTIMPL;
1234 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1236 HTMLDocument *This = HTMLDOC_THIS(iface);
1237 FIXME("(%p)->(%p)\n", This, p);
1238 return E_NOTIMPL;
1241 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1243 HTMLDocument *This = HTMLDOC_THIS(iface);
1245 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1247 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1250 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1252 HTMLDocument *This = HTMLDOC_THIS(iface);
1254 TRACE("(%p)->(%p)\n", This, p);
1256 return get_doc_event(This, EVENTID_DRAGSTART, p);
1259 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1261 HTMLDocument *This = HTMLDOC_THIS(iface);
1263 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1265 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1268 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1270 HTMLDocument *This = HTMLDOC_THIS(iface);
1272 TRACE("(%p)->(%p)\n", This, p);
1274 return get_doc_event(This, EVENTID_SELECTSTART, p);
1277 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1278 IHTMLElement **elementHit)
1280 HTMLDocument *This = HTMLDOC_THIS(iface);
1281 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1282 return E_NOTIMPL;
1285 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1287 HTMLDocument *This = HTMLDOC_THIS(iface);
1289 TRACE("(%p)->(%p)\n", This, p);
1291 *p = HTMLWINDOW2(This->window);
1292 IHTMLWindow2_AddRef(*p);
1293 return S_OK;
1296 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1297 IHTMLStyleSheetsCollection **p)
1299 HTMLDocument *This = HTMLDOC_THIS(iface);
1300 nsIDOMStyleSheetList *nsstylelist;
1301 nsIDOMDocumentStyle *nsdocstyle;
1302 nsresult nsres;
1304 TRACE("(%p)->(%p)\n", This, p);
1306 *p = NULL;
1308 if(!This->doc_node->nsdoc) {
1309 WARN("NULL nsdoc\n");
1310 return E_UNEXPECTED;
1313 nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1314 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1315 nsIDOMDocumentStyle_Release(nsdocstyle);
1316 if(NS_FAILED(nsres)) {
1317 ERR("GetStyleSheets failed: %08x\n", nsres);
1318 return E_FAIL;
1321 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1322 nsIDOMDocumentStyle_Release(nsstylelist);
1324 return S_OK;
1327 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1329 HTMLDocument *This = HTMLDOC_THIS(iface);
1330 FIXME("(%p)\n", This);
1331 return E_NOTIMPL;
1334 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1336 HTMLDocument *This = HTMLDOC_THIS(iface);
1337 FIXME("(%p)->(%p)\n", This, p);
1338 return E_NOTIMPL;
1341 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1343 HTMLDocument *This = HTMLDOC_THIS(iface);
1344 FIXME("(%p)\n", This);
1345 return E_NOTIMPL;
1348 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1350 HTMLDocument *This = HTMLDOC_THIS(iface);
1351 FIXME("(%p)->(%p)\n", This, p);
1352 return E_NOTIMPL;
1355 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1357 HTMLDocument *This = HTMLDOC_THIS(iface);
1358 FIXME("(%p)->(%p)\n", This, String);
1359 return E_NOTIMPL;
1362 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1363 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1365 HTMLDocument *This = HTMLDOC_THIS(iface);
1367 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1369 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1370 return S_OK;
1373 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1374 HTMLDocument_QueryInterface,
1375 HTMLDocument_AddRef,
1376 HTMLDocument_Release,
1377 HTMLDocument_GetTypeInfoCount,
1378 HTMLDocument_GetTypeInfo,
1379 HTMLDocument_GetIDsOfNames,
1380 HTMLDocument_Invoke,
1381 HTMLDocument_get_Script,
1382 HTMLDocument_get_all,
1383 HTMLDocument_get_body,
1384 HTMLDocument_get_activeElement,
1385 HTMLDocument_get_images,
1386 HTMLDocument_get_applets,
1387 HTMLDocument_get_links,
1388 HTMLDocument_get_forms,
1389 HTMLDocument_get_anchors,
1390 HTMLDocument_put_title,
1391 HTMLDocument_get_title,
1392 HTMLDocument_get_scripts,
1393 HTMLDocument_put_designMode,
1394 HTMLDocument_get_designMode,
1395 HTMLDocument_get_selection,
1396 HTMLDocument_get_readyState,
1397 HTMLDocument_get_frames,
1398 HTMLDocument_get_embeds,
1399 HTMLDocument_get_plugins,
1400 HTMLDocument_put_alinkColor,
1401 HTMLDocument_get_alinkColor,
1402 HTMLDocument_put_bgColor,
1403 HTMLDocument_get_bgColor,
1404 HTMLDocument_put_fgColor,
1405 HTMLDocument_get_fgColor,
1406 HTMLDocument_put_linkColor,
1407 HTMLDocument_get_linkColor,
1408 HTMLDocument_put_vlinkColor,
1409 HTMLDocument_get_vlinkColor,
1410 HTMLDocument_get_referrer,
1411 HTMLDocument_get_location,
1412 HTMLDocument_get_lastModified,
1413 HTMLDocument_put_URL,
1414 HTMLDocument_get_URL,
1415 HTMLDocument_put_domain,
1416 HTMLDocument_get_domain,
1417 HTMLDocument_put_cookie,
1418 HTMLDocument_get_cookie,
1419 HTMLDocument_put_expando,
1420 HTMLDocument_get_expando,
1421 HTMLDocument_put_charset,
1422 HTMLDocument_get_charset,
1423 HTMLDocument_put_defaultCharset,
1424 HTMLDocument_get_defaultCharset,
1425 HTMLDocument_get_mimeType,
1426 HTMLDocument_get_fileSize,
1427 HTMLDocument_get_fileCreatedDate,
1428 HTMLDocument_get_fileModifiedDate,
1429 HTMLDocument_get_fileUpdatedDate,
1430 HTMLDocument_get_security,
1431 HTMLDocument_get_protocol,
1432 HTMLDocument_get_nameProp,
1433 HTMLDocument_write,
1434 HTMLDocument_writeln,
1435 HTMLDocument_open,
1436 HTMLDocument_close,
1437 HTMLDocument_clear,
1438 HTMLDocument_queryCommandSupported,
1439 HTMLDocument_queryCommandEnabled,
1440 HTMLDocument_queryCommandState,
1441 HTMLDocument_queryCommandIndeterm,
1442 HTMLDocument_queryCommandText,
1443 HTMLDocument_queryCommandValue,
1444 HTMLDocument_execCommand,
1445 HTMLDocument_execCommandShowHelp,
1446 HTMLDocument_createElement,
1447 HTMLDocument_put_onhelp,
1448 HTMLDocument_get_onhelp,
1449 HTMLDocument_put_onclick,
1450 HTMLDocument_get_onclick,
1451 HTMLDocument_put_ondblclick,
1452 HTMLDocument_get_ondblclick,
1453 HTMLDocument_put_onkeyup,
1454 HTMLDocument_get_onkeyup,
1455 HTMLDocument_put_onkeydown,
1456 HTMLDocument_get_onkeydown,
1457 HTMLDocument_put_onkeypress,
1458 HTMLDocument_get_onkeypress,
1459 HTMLDocument_put_onmouseup,
1460 HTMLDocument_get_onmouseup,
1461 HTMLDocument_put_onmousedown,
1462 HTMLDocument_get_onmousedown,
1463 HTMLDocument_put_onmousemove,
1464 HTMLDocument_get_onmousemove,
1465 HTMLDocument_put_onmouseout,
1466 HTMLDocument_get_onmouseout,
1467 HTMLDocument_put_onmouseover,
1468 HTMLDocument_get_onmouseover,
1469 HTMLDocument_put_onreadystatechange,
1470 HTMLDocument_get_onreadystatechange,
1471 HTMLDocument_put_onafterupdate,
1472 HTMLDocument_get_onafterupdate,
1473 HTMLDocument_put_onrowexit,
1474 HTMLDocument_get_onrowexit,
1475 HTMLDocument_put_onrowenter,
1476 HTMLDocument_get_onrowenter,
1477 HTMLDocument_put_ondragstart,
1478 HTMLDocument_get_ondragstart,
1479 HTMLDocument_put_onselectstart,
1480 HTMLDocument_get_onselectstart,
1481 HTMLDocument_elementFromPoint,
1482 HTMLDocument_get_parentWindow,
1483 HTMLDocument_get_styleSheets,
1484 HTMLDocument_put_onbeforeupdate,
1485 HTMLDocument_get_onbeforeupdate,
1486 HTMLDocument_put_onerrorupdate,
1487 HTMLDocument_get_onerrorupdate,
1488 HTMLDocument_toString,
1489 HTMLDocument_createStyleSheet
1492 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
1494 HTMLDocument *This = HTMLDOC_THIS(iface);
1496 if(This->window)
1497 update_cp_events(This->window, &This->doc_node->node.event_target, cp, This->doc_node->node.nsnode);
1500 #undef HTMLDOC_THIS
1502 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1504 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1506 HTMLDocument *This = SUPPINFO_THIS(iface);
1507 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1510 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1512 HTMLDocument *This = SUPPINFO_THIS(iface);
1513 return IHTMLDocument_AddRef(HTMLDOC(This));
1516 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1518 HTMLDocument *This = SUPPINFO_THIS(iface);
1519 return IHTMLDocument_Release(HTMLDOC(This));
1522 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1524 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1525 return S_FALSE;
1528 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1529 SupportErrorInfo_QueryInterface,
1530 SupportErrorInfo_AddRef,
1531 SupportErrorInfo_Release,
1532 SupportErrorInfo_InterfaceSupportsErrorInfo
1535 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1537 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1539 HTMLDocument *This = DISPEX_THIS(iface);
1541 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1544 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1546 HTMLDocument *This = DISPEX_THIS(iface);
1548 return IHTMLDocument2_AddRef(HTMLDOC(This));
1551 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1553 HTMLDocument *This = DISPEX_THIS(iface);
1555 return IHTMLDocument2_Release(HTMLDOC(This));
1558 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1560 HTMLDocument *This = DISPEX_THIS(iface);
1562 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
1565 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1566 LCID lcid, ITypeInfo **ppTInfo)
1568 HTMLDocument *This = DISPEX_THIS(iface);
1570 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
1573 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1574 LPOLESTR *rgszNames, UINT cNames,
1575 LCID lcid, DISPID *rgDispId)
1577 HTMLDocument *This = DISPEX_THIS(iface);
1579 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
1582 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1583 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1584 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1586 HTMLDocument *This = DISPEX_THIS(iface);
1588 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1589 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1591 switch(dispIdMember) {
1592 case DISPID_READYSTATE:
1593 TRACE("DISPID_READYSTATE\n");
1595 if(!(wFlags & DISPATCH_PROPERTYGET))
1596 return E_INVALIDARG;
1598 V_VT(pVarResult) = VT_I4;
1599 V_I4(pVarResult) = This->window->readystate;
1600 return S_OK;
1603 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
1604 pVarResult, pExcepInfo, puArgErr);
1607 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1609 HTMLDocument *This = DISPEX_THIS(iface);
1611 return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
1614 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1615 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1617 HTMLDocument *This = DISPEX_THIS(iface);
1619 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
1620 return IDispatchEx_InvokeEx(DISPATCHEX(This->window), DISPID_IHTMLWINDOW2_LOCATION, lcid, wFlags,
1621 pdp, pvarRes, pei, pspCaller);
1624 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1627 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1629 HTMLDocument *This = DISPEX_THIS(iface);
1631 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
1634 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1636 HTMLDocument *This = DISPEX_THIS(iface);
1638 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
1641 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1643 HTMLDocument *This = DISPEX_THIS(iface);
1645 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
1648 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1650 HTMLDocument *This = DISPEX_THIS(iface);
1652 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
1655 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1657 HTMLDocument *This = DISPEX_THIS(iface);
1659 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
1662 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1664 HTMLDocument *This = DISPEX_THIS(iface);
1666 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
1669 #undef DISPEX_THIS
1671 static const IDispatchExVtbl DocDispatchExVtbl = {
1672 DocDispatchEx_QueryInterface,
1673 DocDispatchEx_AddRef,
1674 DocDispatchEx_Release,
1675 DocDispatchEx_GetTypeInfoCount,
1676 DocDispatchEx_GetTypeInfo,
1677 DocDispatchEx_GetIDsOfNames,
1678 DocDispatchEx_Invoke,
1679 DocDispatchEx_GetDispID,
1680 DocDispatchEx_InvokeEx,
1681 DocDispatchEx_DeleteMemberByName,
1682 DocDispatchEx_DeleteMemberByDispID,
1683 DocDispatchEx_GetMemberProperties,
1684 DocDispatchEx_GetMemberName,
1685 DocDispatchEx_GetNextDispID,
1686 DocDispatchEx_GetNameSpaceParent
1689 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
1691 *ppv = NULL;
1693 if(IsEqualGUID(&IID_IUnknown, riid)) {
1694 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
1695 *ppv = HTMLDOC(This);
1696 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1697 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv);
1698 *ppv = DISPATCHEX(This);
1699 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
1700 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv);
1701 *ppv = DISPATCHEX(This);
1702 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
1703 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv);
1704 *ppv = HTMLDOC(This);
1705 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
1706 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppv);
1707 *ppv = HTMLDOC(This);
1708 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
1709 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppv);
1710 *ppv = HTMLDOC3(This);
1711 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
1712 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppv);
1713 *ppv = HTMLDOC4(This);
1714 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
1715 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppv);
1716 *ppv = HTMLDOC5(This);
1717 }else if(IsEqualGUID(&IID_IHTMLDocument6, riid)) {
1718 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This, ppv);
1719 *ppv = HTMLDOC6(This);
1720 }else if(IsEqualGUID(&IID_IPersist, riid)) {
1721 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
1722 *ppv = PERSIST(This);
1723 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
1724 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppv);
1725 *ppv = PERSISTMON(This);
1726 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
1727 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppv);
1728 *ppv = PERSISTFILE(This);
1729 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
1730 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppv);
1731 *ppv = MONPROP(This);
1732 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
1733 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppv);
1734 *ppv = OLEOBJ(This);
1735 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
1736 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppv);
1737 *ppv = OLEDOC(This);
1738 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
1739 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppv);
1740 *ppv = DOCVIEW(This);
1741 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
1742 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
1743 *ppv = ACTOBJ(This);
1744 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
1745 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
1746 *ppv = VIEWOBJ(This);
1747 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
1748 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
1749 *ppv = VIEWOBJ2(This);
1750 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
1751 TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This, ppv);
1752 *ppv = VIEWOBJEX(This);
1753 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
1754 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
1755 *ppv = OLEWIN(This);
1756 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
1757 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
1758 *ppv = INPLACEOBJ(This);
1759 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1760 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppv);
1761 *ppv = INPLACEWIN(This);
1762 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1763 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
1764 *ppv = SERVPROV(This);
1765 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
1766 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppv);
1767 *ppv = CMDTARGET(This);
1768 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
1769 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppv);
1770 *ppv = CONTROL(This);
1771 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
1772 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppv);
1773 *ppv = HLNKTARGET(This);
1774 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1775 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1776 *ppv = CONPTCONT(&This->cp_container);
1777 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
1778 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
1779 *ppv = PERSTRINIT(This);
1780 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
1781 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
1782 *ppv = HTMLDOC(This);
1783 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
1784 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppv);
1785 *ppv = SUPPERRINFO(This);
1786 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
1787 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppv);
1788 *ppv = PERSISTHIST(This);
1789 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
1790 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
1791 *ppv = NULL;
1792 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
1793 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
1794 *ppv = NULL;
1795 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
1796 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
1797 *ppv = NULL;
1798 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
1799 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
1800 *ppv = NULL;
1801 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
1802 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
1803 *ppv = NULL;
1804 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
1805 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
1806 *ppv = NULL;
1807 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
1808 TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv);
1809 *ppv = OBJSITE(This);
1810 }else {
1811 return FALSE;
1814 if(*ppv)
1815 IUnknown_AddRef((IUnknown*)*ppv);
1816 return TRUE;
1819 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
1821 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
1823 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1824 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1825 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1827 doc->unk_impl = unk_impl;
1828 doc->dispex = dispex;
1829 doc->task_magic = get_task_target_magic();
1831 HTMLDocument_HTMLDocument3_Init(doc);
1832 HTMLDocument_HTMLDocument5_Init(doc);
1833 HTMLDocument_Persist_Init(doc);
1834 HTMLDocument_OleCmd_Init(doc);
1835 HTMLDocument_OleObj_Init(doc);
1836 HTMLDocument_View_Init(doc);
1837 HTMLDocument_Window_Init(doc);
1838 HTMLDocument_Service_Init(doc);
1839 HTMLDocument_Hlink_Init(doc);
1841 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1842 ConnectionPoint_Init(&doc->cp_dispatch, &doc->cp_container, &IID_IDispatch, NULL);
1843 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink, NULL);
1844 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data);
1845 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2, NULL);
1848 static void destroy_htmldoc(HTMLDocument *This)
1850 remove_target_tasks(This->task_magic);
1852 ConnectionPointContainer_Destroy(&This->cp_container);
1855 #define HTMLDOCNODE_NODE_THIS(iface) DEFINE_THIS2(HTMLDocumentNode, node, iface)
1857 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1859 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1861 if(htmldoc_qi(&This->basedoc, riid, ppv))
1862 return *ppv ? S_OK : E_NOINTERFACE;
1864 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid)) {
1865 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This, ppv);
1866 *ppv = HOSTSECMGR(This);
1867 }else {
1868 return HTMLDOMNode_QI(&This->node, riid, ppv);
1871 IUnknown_AddRef((IUnknown*)*ppv);
1872 return S_OK;
1875 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
1877 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1879 if(This->body_event_target)
1880 release_event_target(This->body_event_target);
1881 if(This->nsevent_listener)
1882 release_nsevents(This);
1883 if(This->catmgr)
1884 ICatInformation_Release(This->catmgr);
1885 if(This->secmgr)
1886 IInternetSecurityManager_Release(This->secmgr);
1888 detach_selection(This);
1889 detach_ranges(This);
1890 release_nodes(This);
1892 if(This->nsdoc) {
1893 release_mutation(This);
1894 nsIDOMHTMLDocument_Release(This->nsdoc);
1897 heap_free(This->event_vector);
1898 destroy_htmldoc(&This->basedoc);
1901 #undef HTMLDOCNODE_NODE_THIS
1903 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
1904 HTMLDocumentNode_QI,
1905 HTMLDocumentNode_destructor
1908 static const tid_t HTMLDocumentNode_iface_tids[] = {
1909 IHTMLDOMNode_tid,
1910 IHTMLDOMNode2_tid,
1911 IHTMLDocument2_tid,
1912 IHTMLDocument3_tid,
1913 IHTMLDocument4_tid,
1914 IHTMLDocument5_tid,
1918 static dispex_static_data_t HTMLDocumentNode_dispex = {
1919 NULL,
1920 DispHTMLDocument_tid,
1921 NULL,
1922 HTMLDocumentNode_iface_tids
1925 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret)
1927 HTMLDocumentNode *doc;
1928 HRESULT hres;
1930 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
1931 if(!doc)
1932 return E_OUTOFMEMORY;
1934 doc->basedoc.doc_node = doc;
1935 doc->basedoc.doc_obj = doc_obj;
1937 init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
1938 init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
1939 HTMLDocumentNode_SecMgr_Init(doc);
1940 doc->ref = 1;
1942 doc->basedoc.window = window;
1943 if(window == doc_obj->basedoc.window)
1944 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
1946 nsIDOMHTMLDocument_AddRef(nsdoc);
1947 doc->nsdoc = nsdoc;
1948 init_mutation(doc);
1949 init_nsevents(doc);
1951 list_init(&doc->bindings);
1952 list_init(&doc->selection_list);
1953 list_init(&doc->range_list);
1955 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
1956 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
1957 doc->node.cp_container = &doc->basedoc.cp_container;
1959 hres = CoInternetCreateSecurityManager(NULL, &doc->secmgr, 0);
1960 if(FAILED(hres)) {
1961 htmldoc_release(&doc->basedoc);
1962 return hres;
1965 *ret = doc;
1966 return S_OK;
1969 /**********************************************************
1970 * ICustomDoc implementation
1973 #define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocumentObj, CustomDoc, iface)
1975 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
1977 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1979 if(htmldoc_qi(&This->basedoc, riid, ppv))
1980 return *ppv ? S_OK : E_NOINTERFACE;
1982 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
1983 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
1984 *ppv = CUSTOMDOC(This);
1985 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1986 return *ppv ? S_OK : E_NOINTERFACE;
1987 }else {
1988 FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
1989 *ppv = NULL;
1990 return E_NOINTERFACE;
1993 IUnknown_AddRef((IUnknown*)*ppv);
1994 return S_OK;
1997 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
1999 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2000 ULONG ref = InterlockedIncrement(&This->ref);
2002 TRACE("(%p) ref = %u\n", This, ref);
2004 return ref;
2007 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
2009 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2010 ULONG ref = InterlockedDecrement(&This->ref);
2012 TRACE("(%p) ref = %u\n", This, ref);
2014 if(!ref) {
2015 if(This->basedoc.doc_node) {
2016 This->basedoc.doc_node->basedoc.doc_obj = NULL;
2017 IHTMLDocument2_Release(HTMLDOC(&This->basedoc.doc_node->basedoc));
2019 if(This->basedoc.window) {
2020 This->basedoc.window->doc_obj = NULL;
2021 IHTMLWindow2_Release(HTMLWINDOW2(This->basedoc.window));
2023 if(This->basedoc.advise_holder)
2024 IOleAdviseHolder_Release(This->basedoc.advise_holder);
2026 if(This->view_sink)
2027 IAdviseSink_Release(This->view_sink);
2028 if(This->client)
2029 IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL);
2030 if(This->in_place_active)
2031 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(&This->basedoc));
2032 if(This->ipsite)
2033 IOleDocumentView_SetInPlaceSite(DOCVIEW(&This->basedoc), NULL);
2034 if(This->undomgr)
2035 IOleUndoManager_Release(This->undomgr);
2036 if(This->tooltips_hwnd)
2037 DestroyWindow(This->tooltips_hwnd);
2039 if(This->hwnd)
2040 DestroyWindow(This->hwnd);
2041 heap_free(This->mime);
2043 destroy_htmldoc(&This->basedoc);
2044 release_dispex(&This->dispex);
2046 if(This->nscontainer)
2047 NSContainer_Release(This->nscontainer);
2048 heap_free(This);
2051 return ref;
2054 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
2056 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
2057 FIXME("(%p)->(%p)\n", This, pUIHandler);
2058 return E_NOTIMPL;
2061 #undef CUSTOMDOC_THIS
2063 static const ICustomDocVtbl CustomDocVtbl = {
2064 CustomDoc_QueryInterface,
2065 CustomDoc_AddRef,
2066 CustomDoc_Release,
2067 CustomDoc_SetUIHandler
2070 static const tid_t HTMLDocumentObj_iface_tids[] = {
2071 IHTMLDocument2_tid,
2072 IHTMLDocument3_tid,
2073 IHTMLDocument4_tid,
2074 IHTMLDocument5_tid,
2077 static dispex_static_data_t HTMLDocumentObj_dispex = {
2078 NULL,
2079 DispHTMLDocument_tid,
2080 NULL,
2081 HTMLDocumentObj_iface_tids
2084 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
2086 HTMLDocumentObj *doc;
2087 nsIDOMWindow *nswindow = NULL;
2088 nsresult nsres;
2089 HRESULT hres;
2091 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2093 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
2094 if(!doc)
2095 return E_OUTOFMEMORY;
2097 init_dispex(&doc->dispex, (IUnknown*)CUSTOMDOC(doc), &HTMLDocumentObj_dispex);
2098 init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc), DISPATCHEX(&doc->dispex));
2100 doc->lpCustomDocVtbl = &CustomDocVtbl;
2101 doc->ref = 1;
2102 doc->basedoc.doc_obj = doc;
2104 doc->usermode = UNKNOWN_USERMODE;
2106 doc->nscontainer = NSContainer_Create(doc, NULL);
2107 if(!doc->nscontainer) {
2108 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2109 htmldoc_release(&doc->basedoc);
2110 return CLASS_E_CLASSNOTAVAILABLE;
2113 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
2114 htmldoc_release(&doc->basedoc);
2115 if(FAILED(hres))
2116 return hres;
2119 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
2120 if(NS_FAILED(nsres))
2121 ERR("GetContentDOMWindow failed: %08x\n", nsres);
2123 hres = HTMLWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
2124 if(nswindow)
2125 nsIDOMWindow_Release(nswindow);
2126 if(FAILED(hres)) {
2127 IHTMLDocument_Release(HTMLDOC(&doc->basedoc));
2128 return hres;
2131 if(!doc->basedoc.doc_node && doc->basedoc.window->doc) {
2132 doc->basedoc.doc_node = doc->basedoc.window->doc;
2133 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
2136 get_thread_hwnd();
2138 return S_OK;