mmsystem.dll16: Check for NULL ptr in mmioRename (Coverity).
[wine/multimedia.git] / dlls / mshtml / htmldoc.c
blob291bba530517c554e91c099442e049d6ff6acb45
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_Init(&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);
557 FIXME("(%p)->(%p)\n", This, p);
558 return E_NOTIMPL;
561 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
563 HTMLDocument *This = HTMLDOC_THIS(iface);
565 TRACE("(%p)->(%p)\n", This, p);
567 return IHTMLWindow2_get_location(HTMLWINDOW2(This->window), p);
570 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
572 HTMLDocument *This = HTMLDOC_THIS(iface);
573 FIXME("(%p)->(%p)\n", This, p);
574 return E_NOTIMPL;
577 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
579 HTMLDocument *This = HTMLDOC_THIS(iface);
580 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
581 return E_NOTIMPL;
584 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
586 HTMLDocument *This = HTMLDOC_THIS(iface);
588 static const WCHAR about_blank_url[] =
589 {'a','b','o','u','t',':','b','l','a','n','k',0};
591 TRACE("(%p)->(%p)\n", iface, p);
593 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
594 return *p ? S_OK : E_OUTOFMEMORY;
597 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
599 HTMLDocument *This = HTMLDOC_THIS(iface);
600 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
601 return E_NOTIMPL;
604 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
606 HTMLDocument *This = HTMLDOC_THIS(iface);
607 FIXME("(%p)->(%p)\n", This, p);
608 return E_NOTIMPL;
611 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
613 HTMLDocument *This = HTMLDOC_THIS(iface);
614 BOOL bret;
616 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
618 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
619 if(!bret) {
620 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
621 return HRESULT_FROM_WIN32(GetLastError());
624 return S_OK;
627 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
629 HTMLDocument *This = HTMLDOC_THIS(iface);
630 DWORD size;
631 BOOL bret;
633 TRACE("(%p)->(%p)\n", This, p);
635 size = 0;
636 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
637 if(!bret) {
638 switch(GetLastError()) {
639 case ERROR_INSUFFICIENT_BUFFER:
640 break;
641 case ERROR_NO_MORE_ITEMS:
642 *p = NULL;
643 return S_OK;
644 default:
645 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
646 return HRESULT_FROM_WIN32(GetLastError());
650 if(!size) {
651 *p = NULL;
652 return S_OK;
655 *p = SysAllocStringLen(NULL, size-1);
656 if(!*p)
657 return E_OUTOFMEMORY;
659 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
660 if(!bret) {
661 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
662 return E_FAIL;
665 return S_OK;
668 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
670 HTMLDocument *This = HTMLDOC_THIS(iface);
671 FIXME("(%p)->(%x)\n", This, v);
672 return E_NOTIMPL;
675 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
677 HTMLDocument *This = HTMLDOC_THIS(iface);
678 FIXME("(%p)->(%p)\n", This, p);
679 return E_NOTIMPL;
682 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
684 HTMLDocument *This = HTMLDOC_THIS(iface);
685 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
686 return E_NOTIMPL;
689 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
691 HTMLDocument *This = HTMLDOC_THIS(iface);
692 FIXME("(%p)->(%p)\n", This, p);
693 return E_NOTIMPL;
696 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
698 HTMLDocument *This = HTMLDOC_THIS(iface);
699 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
700 return E_NOTIMPL;
703 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
705 HTMLDocument *This = HTMLDOC_THIS(iface);
706 FIXME("(%p)->(%p)\n", This, p);
707 return E_NOTIMPL;
710 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
712 HTMLDocument *This = HTMLDOC_THIS(iface);
713 FIXME("(%p)->(%p)\n", This, p);
714 return E_NOTIMPL;
717 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
719 HTMLDocument *This = HTMLDOC_THIS(iface);
720 FIXME("(%p)->(%p)\n", This, p);
721 return E_NOTIMPL;
724 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
726 HTMLDocument *This = HTMLDOC_THIS(iface);
727 FIXME("(%p)->(%p)\n", This, p);
728 return E_NOTIMPL;
731 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
733 HTMLDocument *This = HTMLDOC_THIS(iface);
734 FIXME("(%p)->(%p)\n", This, p);
735 return E_NOTIMPL;
738 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
740 HTMLDocument *This = HTMLDOC_THIS(iface);
741 FIXME("(%p)->(%p)\n", This, p);
742 return E_NOTIMPL;
745 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
747 HTMLDocument *This = HTMLDOC_THIS(iface);
748 FIXME("(%p)->(%p)\n", This, p);
749 return E_NOTIMPL;
752 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
754 HTMLDocument *This = HTMLDOC_THIS(iface);
755 FIXME("(%p)->(%p)\n", This, p);
756 return E_NOTIMPL;
759 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
761 HTMLDocument *This = HTMLDOC_THIS(iface);
762 FIXME("(%p)->(%p)\n", This, p);
763 return E_NOTIMPL;
766 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
768 nsAString nsstr;
769 VARIANT *var;
770 ULONG i, argc;
771 nsresult nsres;
772 HRESULT hres;
774 if(!This->doc_node->nsdoc) {
775 WARN("NULL nsdoc\n");
776 return E_UNEXPECTED;
779 if(psarray->cDims != 1) {
780 FIXME("cDims=%d\n", psarray->cDims);
781 return E_INVALIDARG;
784 hres = SafeArrayAccessData(psarray, (void**)&var);
785 if(FAILED(hres)) {
786 WARN("SafeArrayAccessData failed: %08x\n", hres);
787 return hres;
790 nsAString_Init(&nsstr, NULL);
792 argc = psarray->rgsabound[0].cElements;
793 for(i=0; i < argc; i++) {
794 if(V_VT(var+i) == VT_BSTR) {
795 nsAString_SetData(&nsstr, V_BSTR(var+i));
796 if(!ln || i != argc-1)
797 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr);
798 else
799 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr);
800 if(NS_FAILED(nsres))
801 ERR("Write failed: %08x\n", nsres);
802 }else {
803 FIXME("vt=%d\n", V_VT(var+i));
807 nsAString_Finish(&nsstr);
808 SafeArrayUnaccessData(psarray);
810 return S_OK;
813 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
815 HTMLDocument *This = HTMLDOC_THIS(iface);
817 TRACE("(%p)->(%p)\n", iface, psarray);
819 return document_write(This, psarray, FALSE);
822 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
824 HTMLDocument *This = HTMLDOC_THIS(iface);
826 TRACE("(%p)->(%p)\n", This, psarray);
828 return document_write(This, psarray, TRUE);
831 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
832 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
834 HTMLDocument *This = HTMLDOC_THIS(iface);
835 nsresult nsres;
837 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
839 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
840 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
842 if(!This->doc_node->nsdoc) {
843 ERR("!nsdoc\n");
844 return E_NOTIMPL;
847 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
848 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
849 FIXME("unsupported args\n");
851 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc);
852 if(NS_FAILED(nsres)) {
853 ERR("Open failed: %08x\n", nsres);
854 return E_FAIL;
857 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
858 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
859 return S_OK;
862 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
864 HTMLDocument *This = HTMLDOC_THIS(iface);
865 nsresult nsres;
867 TRACE("(%p)\n", This);
869 if(!This->doc_node->nsdoc) {
870 ERR("!nsdoc\n");
871 return E_NOTIMPL;
874 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
875 if(NS_FAILED(nsres)) {
876 ERR("Close failed: %08x\n", nsres);
877 return E_FAIL;
880 return S_OK;
883 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
885 HTMLDocument *This = HTMLDOC_THIS(iface);
886 FIXME("(%p)\n", This);
887 return E_NOTIMPL;
890 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
891 VARIANT_BOOL *pfRet)
893 HTMLDocument *This = HTMLDOC_THIS(iface);
894 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
895 return E_NOTIMPL;
898 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
899 VARIANT_BOOL *pfRet)
901 HTMLDocument *This = HTMLDOC_THIS(iface);
902 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
903 return E_NOTIMPL;
906 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
907 VARIANT_BOOL *pfRet)
909 HTMLDocument *This = HTMLDOC_THIS(iface);
910 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
911 return E_NOTIMPL;
914 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
915 VARIANT_BOOL *pfRet)
917 HTMLDocument *This = HTMLDOC_THIS(iface);
918 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
919 return E_NOTIMPL;
922 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
923 BSTR *pfRet)
925 HTMLDocument *This = HTMLDOC_THIS(iface);
926 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
927 return E_NOTIMPL;
930 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
931 VARIANT *pfRet)
933 HTMLDocument *This = HTMLDOC_THIS(iface);
934 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
935 return E_NOTIMPL;
938 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
939 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
941 HTMLDocument *This = HTMLDOC_THIS(iface);
942 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
943 return E_NOTIMPL;
946 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
947 VARIANT_BOOL *pfRet)
949 HTMLDocument *This = HTMLDOC_THIS(iface);
950 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
951 return E_NOTIMPL;
954 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
955 IHTMLElement **newElem)
957 HTMLDocument *This = HTMLDOC_THIS(iface);
958 nsIDOMHTMLElement *nselem;
959 HTMLElement *elem;
960 HRESULT hres;
962 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
964 hres = create_nselem(This->doc_node, eTag, &nselem);
965 if(FAILED(hres))
966 return hres;
968 elem = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE);
969 nsIDOMHTMLElement_Release(nselem);
971 *newElem = HTMLELEM(elem);
972 IHTMLElement_AddRef(HTMLELEM(elem));
973 return S_OK;
976 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
978 HTMLDocument *This = HTMLDOC_THIS(iface);
979 FIXME("(%p)\n", This);
980 return E_NOTIMPL;
983 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
985 HTMLDocument *This = HTMLDOC_THIS(iface);
986 FIXME("(%p)->(%p)\n", This, p);
987 return E_NOTIMPL;
990 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
992 HTMLDocument *This = HTMLDOC_THIS(iface);
994 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
996 return set_doc_event(This, EVENTID_CLICK, &v);
999 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1001 HTMLDocument *This = HTMLDOC_THIS(iface);
1003 TRACE("(%p)->(%p)\n", This, p);
1005 return get_doc_event(This, EVENTID_CLICK, p);
1008 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1010 HTMLDocument *This = HTMLDOC_THIS(iface);
1011 FIXME("(%p)\n", This);
1012 return E_NOTIMPL;
1015 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1017 HTMLDocument *This = HTMLDOC_THIS(iface);
1018 FIXME("(%p)->(%p)\n", This, p);
1019 return E_NOTIMPL;
1022 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1024 HTMLDocument *This = HTMLDOC_THIS(iface);
1026 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1028 return set_doc_event(This, EVENTID_KEYUP, &v);
1031 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1033 HTMLDocument *This = HTMLDOC_THIS(iface);
1035 TRACE("(%p)->(%p)\n", This, p);
1037 return get_doc_event(This, EVENTID_KEYUP, p);
1040 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1042 HTMLDocument *This = HTMLDOC_THIS(iface);
1044 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1046 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1049 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1051 HTMLDocument *This = HTMLDOC_THIS(iface);
1053 TRACE("(%p)->(%p)\n", This, p);
1055 return get_doc_event(This, EVENTID_KEYDOWN, p);
1058 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1060 HTMLDocument *This = HTMLDOC_THIS(iface);
1061 FIXME("(%p)\n", This);
1062 return E_NOTIMPL;
1065 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1067 HTMLDocument *This = HTMLDOC_THIS(iface);
1068 FIXME("(%p)->(%p)\n", This, p);
1069 return E_NOTIMPL;
1072 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1074 HTMLDocument *This = HTMLDOC_THIS(iface);
1075 FIXME("(%p)\n", This);
1076 return E_NOTIMPL;
1079 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1081 HTMLDocument *This = HTMLDOC_THIS(iface);
1082 FIXME("(%p)->(%p)\n", This, p);
1083 return E_NOTIMPL;
1086 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1088 HTMLDocument *This = HTMLDOC_THIS(iface);
1089 FIXME("(%p)\n", This);
1090 return E_NOTIMPL;
1093 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1095 HTMLDocument *This = HTMLDOC_THIS(iface);
1096 FIXME("(%p)->(%p)\n", This, p);
1097 return E_NOTIMPL;
1100 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1102 HTMLDocument *This = HTMLDOC_THIS(iface);
1103 FIXME("(%p)\n", This);
1104 return E_NOTIMPL;
1107 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1109 HTMLDocument *This = HTMLDOC_THIS(iface);
1110 FIXME("(%p)->(%p)\n", This, p);
1111 return E_NOTIMPL;
1114 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1116 HTMLDocument *This = HTMLDOC_THIS(iface);
1117 FIXME("(%p)\n", This);
1118 return E_NOTIMPL;
1121 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1123 HTMLDocument *This = HTMLDOC_THIS(iface);
1124 FIXME("(%p)->(%p)\n", This, p);
1125 return E_NOTIMPL;
1128 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1130 HTMLDocument *This = HTMLDOC_THIS(iface);
1132 TRACE("(%p)\n", This);
1134 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1137 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1139 HTMLDocument *This = HTMLDOC_THIS(iface);
1141 TRACE("(%p)->(%p)\n", This, p);
1143 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1146 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1148 HTMLDocument *This = HTMLDOC_THIS(iface);
1149 FIXME("(%p)\n", This);
1150 return E_NOTIMPL;
1153 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1155 HTMLDocument *This = HTMLDOC_THIS(iface);
1156 FIXME("(%p)->(%p)\n", This, p);
1157 return E_NOTIMPL;
1160 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1162 HTMLDocument *This = HTMLDOC_THIS(iface);
1163 FIXME("(%p)\n", This);
1164 return E_NOTIMPL;
1167 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1169 HTMLDocument *This = HTMLDOC_THIS(iface);
1170 FIXME("(%p)->(%p)\n", This, p);
1171 return E_NOTIMPL;
1174 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1176 HTMLDocument *This = HTMLDOC_THIS(iface);
1177 FIXME("(%p)\n", This);
1178 return E_NOTIMPL;
1181 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1183 HTMLDocument *This = HTMLDOC_THIS(iface);
1184 FIXME("(%p)->(%p)\n", This, p);
1185 return E_NOTIMPL;
1188 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1190 HTMLDocument *This = HTMLDOC_THIS(iface);
1191 FIXME("(%p)\n", This);
1192 return E_NOTIMPL;
1195 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1197 HTMLDocument *This = HTMLDOC_THIS(iface);
1198 FIXME("(%p)->(%p)\n", This, p);
1199 return E_NOTIMPL;
1202 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1204 HTMLDocument *This = HTMLDOC_THIS(iface);
1206 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1208 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1211 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1213 HTMLDocument *This = HTMLDOC_THIS(iface);
1215 TRACE("(%p)->(%p)\n", This, p);
1217 return get_doc_event(This, EVENTID_DRAGSTART, p);
1220 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1222 HTMLDocument *This = HTMLDOC_THIS(iface);
1224 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1226 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1229 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1231 HTMLDocument *This = HTMLDOC_THIS(iface);
1233 TRACE("(%p)->(%p)\n", This, p);
1235 return get_doc_event(This, EVENTID_SELECTSTART, p);
1238 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1239 IHTMLElement **elementHit)
1241 HTMLDocument *This = HTMLDOC_THIS(iface);
1242 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1243 return E_NOTIMPL;
1246 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1248 HTMLDocument *This = HTMLDOC_THIS(iface);
1250 TRACE("(%p)->(%p)\n", This, p);
1252 *p = HTMLWINDOW2(This->window);
1253 IHTMLWindow2_AddRef(*p);
1254 return S_OK;
1257 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1258 IHTMLStyleSheetsCollection **p)
1260 HTMLDocument *This = HTMLDOC_THIS(iface);
1261 nsIDOMStyleSheetList *nsstylelist;
1262 nsIDOMDocumentStyle *nsdocstyle;
1263 nsresult nsres;
1265 TRACE("(%p)->(%p)\n", This, p);
1267 *p = NULL;
1269 if(!This->doc_node->nsdoc) {
1270 WARN("NULL nsdoc\n");
1271 return E_UNEXPECTED;
1274 nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1275 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1276 nsIDOMDocumentStyle_Release(nsdocstyle);
1277 if(NS_FAILED(nsres)) {
1278 ERR("GetStyleSheets failed: %08x\n", nsres);
1279 return E_FAIL;
1282 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1283 nsIDOMDocumentStyle_Release(nsstylelist);
1285 return S_OK;
1288 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1290 HTMLDocument *This = HTMLDOC_THIS(iface);
1291 FIXME("(%p)\n", This);
1292 return E_NOTIMPL;
1295 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1297 HTMLDocument *This = HTMLDOC_THIS(iface);
1298 FIXME("(%p)->(%p)\n", This, p);
1299 return E_NOTIMPL;
1302 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1304 HTMLDocument *This = HTMLDOC_THIS(iface);
1305 FIXME("(%p)\n", This);
1306 return E_NOTIMPL;
1309 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1311 HTMLDocument *This = HTMLDOC_THIS(iface);
1312 FIXME("(%p)->(%p)\n", This, p);
1313 return E_NOTIMPL;
1316 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1318 HTMLDocument *This = HTMLDOC_THIS(iface);
1319 FIXME("(%p)->(%p)\n", This, String);
1320 return E_NOTIMPL;
1323 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1324 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1326 HTMLDocument *This = HTMLDOC_THIS(iface);
1328 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1330 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1331 return S_OK;
1334 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1335 HTMLDocument_QueryInterface,
1336 HTMLDocument_AddRef,
1337 HTMLDocument_Release,
1338 HTMLDocument_GetTypeInfoCount,
1339 HTMLDocument_GetTypeInfo,
1340 HTMLDocument_GetIDsOfNames,
1341 HTMLDocument_Invoke,
1342 HTMLDocument_get_Script,
1343 HTMLDocument_get_all,
1344 HTMLDocument_get_body,
1345 HTMLDocument_get_activeElement,
1346 HTMLDocument_get_images,
1347 HTMLDocument_get_applets,
1348 HTMLDocument_get_links,
1349 HTMLDocument_get_forms,
1350 HTMLDocument_get_anchors,
1351 HTMLDocument_put_title,
1352 HTMLDocument_get_title,
1353 HTMLDocument_get_scripts,
1354 HTMLDocument_put_designMode,
1355 HTMLDocument_get_designMode,
1356 HTMLDocument_get_selection,
1357 HTMLDocument_get_readyState,
1358 HTMLDocument_get_frames,
1359 HTMLDocument_get_embeds,
1360 HTMLDocument_get_plugins,
1361 HTMLDocument_put_alinkColor,
1362 HTMLDocument_get_alinkColor,
1363 HTMLDocument_put_bgColor,
1364 HTMLDocument_get_bgColor,
1365 HTMLDocument_put_fgColor,
1366 HTMLDocument_get_fgColor,
1367 HTMLDocument_put_linkColor,
1368 HTMLDocument_get_linkColor,
1369 HTMLDocument_put_vlinkColor,
1370 HTMLDocument_get_vlinkColor,
1371 HTMLDocument_get_referrer,
1372 HTMLDocument_get_location,
1373 HTMLDocument_get_lastModified,
1374 HTMLDocument_put_URL,
1375 HTMLDocument_get_URL,
1376 HTMLDocument_put_domain,
1377 HTMLDocument_get_domain,
1378 HTMLDocument_put_cookie,
1379 HTMLDocument_get_cookie,
1380 HTMLDocument_put_expando,
1381 HTMLDocument_get_expando,
1382 HTMLDocument_put_charset,
1383 HTMLDocument_get_charset,
1384 HTMLDocument_put_defaultCharset,
1385 HTMLDocument_get_defaultCharset,
1386 HTMLDocument_get_mimeType,
1387 HTMLDocument_get_fileSize,
1388 HTMLDocument_get_fileCreatedDate,
1389 HTMLDocument_get_fileModifiedDate,
1390 HTMLDocument_get_fileUpdatedDate,
1391 HTMLDocument_get_security,
1392 HTMLDocument_get_protocol,
1393 HTMLDocument_get_nameProp,
1394 HTMLDocument_write,
1395 HTMLDocument_writeln,
1396 HTMLDocument_open,
1397 HTMLDocument_close,
1398 HTMLDocument_clear,
1399 HTMLDocument_queryCommandSupported,
1400 HTMLDocument_queryCommandEnabled,
1401 HTMLDocument_queryCommandState,
1402 HTMLDocument_queryCommandIndeterm,
1403 HTMLDocument_queryCommandText,
1404 HTMLDocument_queryCommandValue,
1405 HTMLDocument_execCommand,
1406 HTMLDocument_execCommandShowHelp,
1407 HTMLDocument_createElement,
1408 HTMLDocument_put_onhelp,
1409 HTMLDocument_get_onhelp,
1410 HTMLDocument_put_onclick,
1411 HTMLDocument_get_onclick,
1412 HTMLDocument_put_ondblclick,
1413 HTMLDocument_get_ondblclick,
1414 HTMLDocument_put_onkeyup,
1415 HTMLDocument_get_onkeyup,
1416 HTMLDocument_put_onkeydown,
1417 HTMLDocument_get_onkeydown,
1418 HTMLDocument_put_onkeypress,
1419 HTMLDocument_get_onkeypress,
1420 HTMLDocument_put_onmouseup,
1421 HTMLDocument_get_onmouseup,
1422 HTMLDocument_put_onmousedown,
1423 HTMLDocument_get_onmousedown,
1424 HTMLDocument_put_onmousemove,
1425 HTMLDocument_get_onmousemove,
1426 HTMLDocument_put_onmouseout,
1427 HTMLDocument_get_onmouseout,
1428 HTMLDocument_put_onmouseover,
1429 HTMLDocument_get_onmouseover,
1430 HTMLDocument_put_onreadystatechange,
1431 HTMLDocument_get_onreadystatechange,
1432 HTMLDocument_put_onafterupdate,
1433 HTMLDocument_get_onafterupdate,
1434 HTMLDocument_put_onrowexit,
1435 HTMLDocument_get_onrowexit,
1436 HTMLDocument_put_onrowenter,
1437 HTMLDocument_get_onrowenter,
1438 HTMLDocument_put_ondragstart,
1439 HTMLDocument_get_ondragstart,
1440 HTMLDocument_put_onselectstart,
1441 HTMLDocument_get_onselectstart,
1442 HTMLDocument_elementFromPoint,
1443 HTMLDocument_get_parentWindow,
1444 HTMLDocument_get_styleSheets,
1445 HTMLDocument_put_onbeforeupdate,
1446 HTMLDocument_get_onbeforeupdate,
1447 HTMLDocument_put_onerrorupdate,
1448 HTMLDocument_get_onerrorupdate,
1449 HTMLDocument_toString,
1450 HTMLDocument_createStyleSheet
1453 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1455 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1457 HTMLDocument *This = SUPPINFO_THIS(iface);
1458 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1461 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1463 HTMLDocument *This = SUPPINFO_THIS(iface);
1464 return IHTMLDocument_AddRef(HTMLDOC(This));
1467 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1469 HTMLDocument *This = SUPPINFO_THIS(iface);
1470 return IHTMLDocument_Release(HTMLDOC(This));
1473 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1475 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1476 return S_FALSE;
1479 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1480 SupportErrorInfo_QueryInterface,
1481 SupportErrorInfo_AddRef,
1482 SupportErrorInfo_Release,
1483 SupportErrorInfo_InterfaceSupportsErrorInfo
1486 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1488 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1490 HTMLDocument *This = DISPEX_THIS(iface);
1492 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1495 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1497 HTMLDocument *This = DISPEX_THIS(iface);
1499 return IHTMLDocument2_AddRef(HTMLDOC(This));
1502 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1504 HTMLDocument *This = DISPEX_THIS(iface);
1506 return IHTMLDocument2_Release(HTMLDOC(This));
1509 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1511 HTMLDocument *This = DISPEX_THIS(iface);
1513 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
1516 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1517 LCID lcid, ITypeInfo **ppTInfo)
1519 HTMLDocument *This = DISPEX_THIS(iface);
1521 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
1524 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1525 LPOLESTR *rgszNames, UINT cNames,
1526 LCID lcid, DISPID *rgDispId)
1528 HTMLDocument *This = DISPEX_THIS(iface);
1530 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
1533 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1534 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1535 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1537 HTMLDocument *This = DISPEX_THIS(iface);
1539 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1540 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1542 switch(dispIdMember) {
1543 case DISPID_READYSTATE:
1544 TRACE("DISPID_READYSTATE\n");
1546 if(!(wFlags & DISPATCH_PROPERTYGET))
1547 return E_INVALIDARG;
1549 V_VT(pVarResult) = VT_I4;
1550 V_I4(pVarResult) = This->window->readystate;
1551 return S_OK;
1554 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
1555 pVarResult, pExcepInfo, puArgErr);
1558 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1560 HTMLDocument *This = DISPEX_THIS(iface);
1562 return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
1565 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1566 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1568 HTMLDocument *This = DISPEX_THIS(iface);
1570 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1573 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1575 HTMLDocument *This = DISPEX_THIS(iface);
1577 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
1580 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1582 HTMLDocument *This = DISPEX_THIS(iface);
1584 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
1587 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1589 HTMLDocument *This = DISPEX_THIS(iface);
1591 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
1594 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1596 HTMLDocument *This = DISPEX_THIS(iface);
1598 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
1601 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1603 HTMLDocument *This = DISPEX_THIS(iface);
1605 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
1608 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1610 HTMLDocument *This = DISPEX_THIS(iface);
1612 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
1615 #undef DISPEX_THIS
1617 static const IDispatchExVtbl DocDispatchExVtbl = {
1618 DocDispatchEx_QueryInterface,
1619 DocDispatchEx_AddRef,
1620 DocDispatchEx_Release,
1621 DocDispatchEx_GetTypeInfoCount,
1622 DocDispatchEx_GetTypeInfo,
1623 DocDispatchEx_GetIDsOfNames,
1624 DocDispatchEx_Invoke,
1625 DocDispatchEx_GetDispID,
1626 DocDispatchEx_InvokeEx,
1627 DocDispatchEx_DeleteMemberByName,
1628 DocDispatchEx_DeleteMemberByDispID,
1629 DocDispatchEx_GetMemberProperties,
1630 DocDispatchEx_GetMemberName,
1631 DocDispatchEx_GetNextDispID,
1632 DocDispatchEx_GetNameSpaceParent
1635 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
1637 *ppv = NULL;
1639 if(IsEqualGUID(&IID_IUnknown, riid)) {
1640 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
1641 *ppv = HTMLDOC(This);
1642 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1643 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv);
1644 *ppv = DISPATCHEX(This);
1645 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
1646 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv);
1647 *ppv = DISPATCHEX(This);
1648 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
1649 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv);
1650 *ppv = HTMLDOC(This);
1651 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
1652 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppv);
1653 *ppv = HTMLDOC(This);
1654 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
1655 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppv);
1656 *ppv = HTMLDOC3(This);
1657 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
1658 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppv);
1659 *ppv = HTMLDOC4(This);
1660 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
1661 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppv);
1662 *ppv = HTMLDOC5(This);
1663 }else if(IsEqualGUID(&IID_IHTMLDocument6, riid)) {
1664 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This, ppv);
1665 *ppv = HTMLDOC6(This);
1666 }else if(IsEqualGUID(&IID_IPersist, riid)) {
1667 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
1668 *ppv = PERSIST(This);
1669 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
1670 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppv);
1671 *ppv = PERSISTMON(This);
1672 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
1673 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppv);
1674 *ppv = PERSISTFILE(This);
1675 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
1676 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppv);
1677 *ppv = MONPROP(This);
1678 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
1679 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppv);
1680 *ppv = OLEOBJ(This);
1681 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
1682 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppv);
1683 *ppv = OLEDOC(This);
1684 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
1685 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppv);
1686 *ppv = DOCVIEW(This);
1687 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
1688 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
1689 *ppv = ACTOBJ(This);
1690 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
1691 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
1692 *ppv = VIEWOBJ(This);
1693 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
1694 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
1695 *ppv = VIEWOBJ2(This);
1696 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
1697 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
1698 *ppv = OLEWIN(This);
1699 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
1700 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
1701 *ppv = INPLACEOBJ(This);
1702 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1703 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppv);
1704 *ppv = INPLACEWIN(This);
1705 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1706 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
1707 *ppv = SERVPROV(This);
1708 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
1709 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppv);
1710 *ppv = CMDTARGET(This);
1711 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
1712 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppv);
1713 *ppv = CONTROL(This);
1714 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
1715 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppv);
1716 *ppv = HLNKTARGET(This);
1717 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1718 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1719 *ppv = CONPTCONT(&This->cp_container);
1720 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
1721 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
1722 *ppv = PERSTRINIT(This);
1723 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
1724 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
1725 *ppv = HTMLDOC(This);
1726 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
1727 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppv);
1728 *ppv = SUPPERRINFO(This);
1729 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
1730 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppv);
1731 *ppv = PERSISTHIST(This);
1732 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
1733 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
1734 *ppv = NULL;
1735 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
1736 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
1737 *ppv = NULL;
1738 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
1739 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
1740 *ppv = NULL;
1741 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
1742 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
1743 *ppv = NULL;
1744 }else {
1745 return FALSE;
1748 if(*ppv)
1749 IUnknown_AddRef((IUnknown*)*ppv);
1750 return TRUE;
1753 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid };
1755 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
1757 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1758 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1759 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1761 doc->unk_impl = unk_impl;
1762 doc->dispex = dispex;
1763 doc->task_magic = get_task_target_magic();
1765 HTMLDocument_HTMLDocument3_Init(doc);
1766 HTMLDocument_HTMLDocument5_Init(doc);
1767 HTMLDocument_Persist_Init(doc);
1768 HTMLDocument_OleCmd_Init(doc);
1769 HTMLDocument_OleObj_Init(doc);
1770 HTMLDocument_View_Init(doc);
1771 HTMLDocument_Window_Init(doc);
1772 HTMLDocument_Service_Init(doc);
1773 HTMLDocument_Hlink_Init(doc);
1775 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1776 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink, NULL);
1777 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data);
1778 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2, NULL);
1781 static void destroy_htmldoc(HTMLDocument *This)
1783 remove_target_tasks(This->task_magic);
1785 ConnectionPointContainer_Destroy(&This->cp_container);
1788 #define HTMLDOCNODE_NODE_THIS(iface) DEFINE_THIS2(HTMLDocumentNode, node, iface)
1790 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1792 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1794 if(htmldoc_qi(&This->basedoc, riid, ppv))
1795 return *ppv ? S_OK : E_NOINTERFACE;
1797 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid)) {
1798 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This, ppv);
1799 *ppv = HOSTSECMGR(This);
1800 }else {
1801 return HTMLDOMNode_QI(&This->node, riid, ppv);
1804 IUnknown_AddRef((IUnknown*)*ppv);
1805 return S_OK;
1808 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
1810 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1812 if(This->nsevent_listener)
1813 release_nsevents(This);
1814 if(This->catmgr)
1815 ICatInformation_Release(This->catmgr);
1816 if(This->secmgr)
1817 IInternetSecurityManager_Release(This->secmgr);
1819 detach_selection(This);
1820 detach_ranges(This);
1821 release_nodes(This);
1823 if(This->nsdoc) {
1824 release_mutation(This);
1825 nsIDOMHTMLDocument_Release(This->nsdoc);
1828 heap_free(This->event_vector);
1829 destroy_htmldoc(&This->basedoc);
1832 #undef HTMLDOCNODE_NODE_THIS
1834 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
1835 HTMLDocumentNode_QI,
1836 HTMLDocumentNode_destructor
1839 static const tid_t HTMLDocumentNode_iface_tids[] = {
1840 IHTMLDOMNode_tid,
1841 IHTMLDOMNode2_tid,
1842 IHTMLDocument2_tid,
1843 IHTMLDocument3_tid,
1844 IHTMLDocument4_tid,
1845 IHTMLDocument5_tid,
1849 static dispex_static_data_t HTMLDocumentNode_dispex = {
1850 NULL,
1851 DispHTMLDocument_tid,
1852 NULL,
1853 HTMLDocumentNode_iface_tids
1856 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret)
1858 HTMLDocumentNode *doc;
1859 HRESULT hres;
1861 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
1862 if(!doc)
1863 return E_OUTOFMEMORY;
1865 doc->basedoc.doc_node = doc;
1866 doc->basedoc.doc_obj = doc_obj;
1868 init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
1869 init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
1870 HTMLDocumentNode_SecMgr_Init(doc);
1871 doc->ref = 1;
1873 doc->basedoc.window = window;
1874 if(window == doc_obj->basedoc.window)
1875 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
1877 nsIDOMHTMLDocument_AddRef(nsdoc);
1878 doc->nsdoc = nsdoc;
1879 init_mutation(doc);
1880 init_nsevents(doc);
1882 list_init(&doc->bindings);
1883 list_init(&doc->selection_list);
1884 list_init(&doc->range_list);
1886 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
1887 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
1888 doc->node.cp_container = &doc->basedoc.cp_container;
1890 hres = CoInternetCreateSecurityManager(NULL, &doc->secmgr, 0);
1891 if(FAILED(hres)) {
1892 htmldoc_release(&doc->basedoc);
1893 return hres;
1896 *ret = doc;
1897 return S_OK;
1900 /**********************************************************
1901 * ICustomDoc implementation
1904 #define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocumentObj, CustomDoc, iface)
1906 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
1908 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1910 if(htmldoc_qi(&This->basedoc, riid, ppv))
1911 return *ppv ? S_OK : E_NOINTERFACE;
1913 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
1914 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
1915 *ppv = CUSTOMDOC(This);
1916 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1917 return *ppv ? S_OK : E_NOINTERFACE;
1918 }else {
1919 FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
1920 *ppv = NULL;
1921 return E_NOINTERFACE;
1924 IUnknown_AddRef((IUnknown*)*ppv);
1925 return S_OK;
1928 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
1930 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1931 ULONG ref = InterlockedIncrement(&This->ref);
1933 TRACE("(%p) ref = %u\n", This, ref);
1935 return ref;
1938 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
1940 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1941 ULONG ref = InterlockedDecrement(&This->ref);
1943 TRACE("(%p) ref = %u\n", This, ref);
1945 if(!ref) {
1946 if(This->basedoc.doc_node) {
1947 This->basedoc.doc_node->basedoc.doc_obj = NULL;
1948 IHTMLDocument2_Release(HTMLDOC(&This->basedoc.doc_node->basedoc));
1950 if(This->basedoc.window) {
1951 This->basedoc.window->doc_obj = NULL;
1952 IHTMLWindow2_Release(HTMLWINDOW2(This->basedoc.window));
1955 if(This->client)
1956 IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL);
1957 if(This->in_place_active)
1958 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(&This->basedoc));
1959 if(This->ipsite)
1960 IOleDocumentView_SetInPlaceSite(DOCVIEW(&This->basedoc), NULL);
1961 if(This->undomgr)
1962 IOleUndoManager_Release(This->undomgr);
1963 if(This->tooltips_hwnd)
1964 DestroyWindow(This->tooltips_hwnd);
1966 if(This->hwnd)
1967 DestroyWindow(This->hwnd);
1968 heap_free(This->mime);
1970 destroy_htmldoc(&This->basedoc);
1971 release_dispex(&This->dispex);
1973 if(This->nscontainer)
1974 NSContainer_Release(This->nscontainer);
1975 heap_free(This);
1978 return ref;
1981 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
1983 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1984 FIXME("(%p)->(%p)\n", This, pUIHandler);
1985 return E_NOTIMPL;
1988 #undef CUSTOMDOC_THIS
1990 static const ICustomDocVtbl CustomDocVtbl = {
1991 CustomDoc_QueryInterface,
1992 CustomDoc_AddRef,
1993 CustomDoc_Release,
1994 CustomDoc_SetUIHandler
1997 static const tid_t HTMLDocumentObj_iface_tids[] = {
1998 IHTMLDocument2_tid,
1999 IHTMLDocument3_tid,
2000 IHTMLDocument4_tid,
2001 IHTMLDocument5_tid,
2004 static dispex_static_data_t HTMLDocumentObj_dispex = {
2005 NULL,
2006 DispHTMLDocument_tid,
2007 NULL,
2008 HTMLDocumentObj_iface_tids
2011 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
2013 HTMLDocumentObj *doc;
2014 nsIDOMWindow *nswindow = NULL;
2015 nsresult nsres;
2016 HRESULT hres;
2018 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2020 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
2021 if(!doc)
2022 return E_OUTOFMEMORY;
2024 init_dispex(&doc->dispex, (IUnknown*)CUSTOMDOC(doc), &HTMLDocumentObj_dispex);
2025 init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc), DISPATCHEX(&doc->dispex));
2027 doc->lpCustomDocVtbl = &CustomDocVtbl;
2028 doc->ref = 1;
2029 doc->basedoc.doc_obj = doc;
2031 doc->usermode = UNKNOWN_USERMODE;
2033 doc->nscontainer = NSContainer_Create(doc, NULL);
2034 if(!doc->nscontainer) {
2035 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2036 htmldoc_release(&doc->basedoc);
2037 return CLASS_E_CLASSNOTAVAILABLE;
2040 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
2041 htmldoc_release(&doc->basedoc);
2042 if(FAILED(hres))
2043 return hres;
2046 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
2047 if(NS_FAILED(nsres))
2048 ERR("GetContentDOMWindow failed: %08x\n", nsres);
2050 hres = HTMLWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
2051 if(nswindow)
2052 nsIDOMWindow_Release(nswindow);
2053 if(FAILED(hres)) {
2054 IHTMLDocument_Release(HTMLDOC(&doc->basedoc));
2055 return hres;
2058 if(!doc->basedoc.doc_node && doc->basedoc.window->doc) {
2059 doc->basedoc.doc_node = doc->basedoc.window->doc;
2060 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
2063 get_thread_hwnd();
2065 return S_OK;