push 8b07bf1f08b23b9893a622b47d2be359556765b1
[wine/hacks.git] / dlls / mshtml / htmldoc.c
blobef3085e3faba84a03c6099d86a172b12f77e4224
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 "ole2.h"
30 #include "perhist.h"
31 #include "mshtmdid.h"
33 #include "wine/debug.h"
35 #include "mshtml_private.h"
36 #include "htmlevent.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
40 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
42 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
44 HTMLDocument *This = HTMLDOC_THIS(iface);
46 return htmldoc_query_interface(This, riid, ppv);
49 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
51 HTMLDocument *This = HTMLDOC_THIS(iface);
53 return htmldoc_addref(This);
56 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
58 HTMLDocument *This = HTMLDOC_THIS(iface);
60 return htmldoc_release(This);
63 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
65 HTMLDocument *This = HTMLDOC_THIS(iface);
67 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
70 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
71 LCID lcid, ITypeInfo **ppTInfo)
73 HTMLDocument *This = HTMLDOC_THIS(iface);
75 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
78 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
79 LPOLESTR *rgszNames, UINT cNames,
80 LCID lcid, DISPID *rgDispId)
82 HTMLDocument *This = HTMLDOC_THIS(iface);
84 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
87 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
88 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
89 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
91 HTMLDocument *This = HTMLDOC_THIS(iface);
93 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
94 pVarResult, pExcepInfo, puArgErr);
97 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
99 HTMLDocument *This = HTMLDOC_THIS(iface);
101 TRACE("(%p)->(%p)\n", This, p);
103 *p = (IDispatch*)HTMLWINDOW2(This->window);
104 IDispatch_AddRef(*p);
105 return S_OK;
108 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
110 HTMLDocument *This = HTMLDOC_THIS(iface);
111 nsIDOMElement *nselem = NULL;
112 nsresult nsres;
114 TRACE("(%p)->(%p)\n", This, p);
116 if(!This->nsdoc) {
117 WARN("NULL nsdoc\n");
118 return E_UNEXPECTED;
121 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
122 if(NS_FAILED(nsres)) {
123 ERR("GetDocumentElement failed: %08x\n", nsres);
124 return E_FAIL;
127 if(nselem) {
128 *p = create_all_collection(get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE), TRUE);
129 nsIDOMElement_Release(nselem);
130 }else {
131 *p = NULL;
134 return S_OK;
137 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
139 HTMLDocument *This = HTMLDOC_THIS(iface);
140 nsIDOMHTMLElement *nsbody = NULL;
141 HTMLDOMNode *node;
142 nsresult nsres;
144 TRACE("(%p)->(%p)\n", This, p);
146 if(!This->nsdoc) {
147 WARN("NULL nsdoc\n");
148 return E_UNEXPECTED;
151 nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody);
152 if(NS_FAILED(nsres)) {
153 TRACE("Could not get body: %08x\n", nsres);
154 return E_UNEXPECTED;
157 if(nsbody) {
158 node = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE);
159 nsIDOMHTMLElement_Release(nsbody);
161 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
162 }else {
163 *p = NULL;
166 TRACE("*p = %p\n", *p);
167 return S_OK;
170 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
172 HTMLDocument *This = HTMLDOC_THIS(iface);
173 FIXME("(%p)->(%p)\n", This, p);
174 return E_NOTIMPL;
177 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
179 HTMLDocument *This = HTMLDOC_THIS(iface);
180 nsIDOMHTMLCollection *nscoll = NULL;
181 nsresult nsres;
183 TRACE("(%p)->(%p)\n", This, p);
185 if(!p)
186 return E_INVALIDARG;
188 *p = NULL;
190 if(!This->nsdoc) {
191 WARN("NULL nsdoc\n");
192 return E_UNEXPECTED;
195 nsres = nsIDOMHTMLDocument_GetImages(This->nsdoc, &nscoll);
196 if(NS_FAILED(nsres)) {
197 ERR("GetImages failed: %08x\n", nsres);
198 return E_FAIL;
201 if(nscoll) {
202 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
203 nsIDOMElement_Release(nscoll);
206 return S_OK;
209 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
211 HTMLDocument *This = HTMLDOC_THIS(iface);
212 nsIDOMHTMLCollection *nscoll = NULL;
213 nsresult nsres;
215 TRACE("(%p)->(%p)\n", This, p);
217 if(!p)
218 return E_INVALIDARG;
220 *p = NULL;
222 if(!This->nsdoc) {
223 WARN("NULL nsdoc\n");
224 return E_UNEXPECTED;
227 nsres = nsIDOMHTMLDocument_GetApplets(This->nsdoc, &nscoll);
228 if(NS_FAILED(nsres)) {
229 ERR("GetApplets failed: %08x\n", nsres);
230 return E_FAIL;
233 if(nscoll) {
234 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
235 nsIDOMElement_Release(nscoll);
238 return S_OK;
241 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
243 HTMLDocument *This = HTMLDOC_THIS(iface);
244 nsIDOMHTMLCollection *nscoll = NULL;
245 nsresult nsres;
247 TRACE("(%p)->(%p)\n", This, p);
249 if(!p)
250 return E_INVALIDARG;
252 *p = NULL;
254 if(!This->nsdoc) {
255 WARN("NULL nsdoc\n");
256 return E_UNEXPECTED;
259 nsres = nsIDOMHTMLDocument_GetLinks(This->nsdoc, &nscoll);
260 if(NS_FAILED(nsres)) {
261 ERR("GetLinks failed: %08x\n", nsres);
262 return E_FAIL;
265 if(nscoll) {
266 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
267 nsIDOMElement_Release(nscoll);
270 return S_OK;
273 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
275 HTMLDocument *This = HTMLDOC_THIS(iface);
276 nsIDOMHTMLCollection *nscoll = NULL;
277 nsresult nsres;
279 TRACE("(%p)->(%p)\n", This, p);
281 if(!p)
282 return E_INVALIDARG;
284 *p = NULL;
286 if(!This->nsdoc) {
287 WARN("NULL nsdoc\n");
288 return E_UNEXPECTED;
291 nsres = nsIDOMHTMLDocument_GetForms(This->nsdoc, &nscoll);
292 if(NS_FAILED(nsres)) {
293 ERR("GetForms failed: %08x\n", nsres);
294 return E_FAIL;
297 if(nscoll) {
298 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
299 nsIDOMElement_Release(nscoll);
302 return S_OK;
305 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
307 HTMLDocument *This = HTMLDOC_THIS(iface);
308 nsIDOMHTMLCollection *nscoll = NULL;
309 nsresult nsres;
311 TRACE("(%p)->(%p)\n", This, p);
313 if(!p)
314 return E_INVALIDARG;
316 *p = NULL;
318 if(!This->nsdoc) {
319 WARN("NULL nsdoc\n");
320 return E_UNEXPECTED;
323 nsres = nsIDOMHTMLDocument_GetAnchors(This->nsdoc, &nscoll);
324 if(NS_FAILED(nsres)) {
325 ERR("GetAnchors failed: %08x\n", nsres);
326 return E_FAIL;
329 if(nscoll) {
330 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
331 nsIDOMElement_Release(nscoll);
334 return S_OK;
337 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
339 HTMLDocument *This = HTMLDOC_THIS(iface);
340 nsAString nsstr;
341 nsresult nsres;
343 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
345 if(!This->nsdoc) {
346 WARN("NULL nsdoc\n");
347 return E_UNEXPECTED;
350 nsAString_Init(&nsstr, v);
351 nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr);
352 nsAString_Finish(&nsstr);
353 if(NS_FAILED(nsres))
354 ERR("SetTitle failed: %08x\n", nsres);
356 return S_OK;
359 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
361 HTMLDocument *This = HTMLDOC_THIS(iface);
362 const PRUnichar *ret;
363 nsAString nsstr;
364 nsresult nsres;
366 TRACE("(%p)->(%p)\n", This, p);
368 if(!This->nsdoc) {
369 WARN("NULL nsdoc\n");
370 return E_UNEXPECTED;
374 nsAString_Init(&nsstr, NULL);
375 nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
376 if (NS_SUCCEEDED(nsres)) {
377 nsAString_GetData(&nsstr, &ret);
378 *p = SysAllocString(ret);
380 nsAString_Finish(&nsstr);
382 if(NS_FAILED(nsres)) {
383 ERR("GetTitle failed: %08x\n", nsres);
384 return E_FAIL;
387 return S_OK;
390 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
392 HTMLDocument *This = HTMLDOC_THIS(iface);
393 FIXME("(%p)->(%p)\n", This, p);
394 return E_NOTIMPL;
397 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
399 HTMLDocument *This = HTMLDOC_THIS(iface);
400 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
401 return E_NOTIMPL;
404 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
406 HTMLDocument *This = HTMLDOC_THIS(iface);
407 static WCHAR szOff[] = {'O','f','f',0};
408 FIXME("(%p)->(%p) always returning Off\n", This, p);
410 if(!p)
411 return E_INVALIDARG;
413 *p = SysAllocString(szOff);
415 return S_OK;
418 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
420 HTMLDocument *This = HTMLDOC_THIS(iface);
421 nsISelection *nsselection;
422 nsresult nsres;
424 TRACE("(%p)->(%p)\n", This, p);
426 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
427 if(NS_FAILED(nsres)) {
428 ERR("GetSelection failed: %08x\n", nsres);
429 return E_FAIL;
432 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
435 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
437 HTMLDocument *This = HTMLDOC_THIS(iface);
439 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
440 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
441 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
442 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
443 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
445 static const LPCWSTR readystate_str[] = {
446 wszUninitialized,
447 wszLoading,
448 wszLoaded,
449 wszInteractive,
450 wszComplete
453 TRACE("(%p)->(%p)\n", iface, p);
455 if(!p)
456 return E_POINTER;
458 *p = SysAllocString(readystate_str[This->doc_obj->readystate]);
459 return S_OK;
462 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
464 HTMLDocument *This = HTMLDOC_THIS(iface);
465 FIXME("(%p)->(%p)\n", This, p);
466 return E_NOTIMPL;
469 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
471 HTMLDocument *This = HTMLDOC_THIS(iface);
472 FIXME("(%p)->(%p)\n", This, p);
473 return E_NOTIMPL;
476 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
478 HTMLDocument *This = HTMLDOC_THIS(iface);
479 FIXME("(%p)->(%p)\n", This, p);
480 return E_NOTIMPL;
483 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
485 HTMLDocument *This = HTMLDOC_THIS(iface);
486 FIXME("(%p)\n", This);
487 return E_NOTIMPL;
490 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
492 HTMLDocument *This = HTMLDOC_THIS(iface);
493 FIXME("(%p)->(%p)\n", This, p);
494 return E_NOTIMPL;
497 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
499 HTMLDocument *This = HTMLDOC_THIS(iface);
500 FIXME("(%p)\n", This);
501 return E_NOTIMPL;
504 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
506 HTMLDocument *This = HTMLDOC_THIS(iface);
507 FIXME("(%p)->(%p)\n", This, p);
508 return E_NOTIMPL;
511 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
513 HTMLDocument *This = HTMLDOC_THIS(iface);
514 FIXME("(%p)\n", This);
515 return E_NOTIMPL;
518 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
520 HTMLDocument *This = HTMLDOC_THIS(iface);
521 FIXME("(%p)->(%p)\n", This, p);
522 return E_NOTIMPL;
525 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
527 HTMLDocument *This = HTMLDOC_THIS(iface);
528 FIXME("(%p)->()\n", This);
529 return E_NOTIMPL;
532 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
534 HTMLDocument *This = HTMLDOC_THIS(iface);
535 FIXME("(%p)->(%p)\n", This, p);
536 return E_NOTIMPL;
539 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
541 HTMLDocument *This = HTMLDOC_THIS(iface);
542 FIXME("(%p)\n", This);
543 return E_NOTIMPL;
546 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
548 HTMLDocument *This = HTMLDOC_THIS(iface);
549 FIXME("(%p)->(%p)\n", This, p);
550 return E_NOTIMPL;
553 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
555 HTMLDocument *This = HTMLDOC_THIS(iface);
556 FIXME("(%p)->(%p)\n", This, p);
557 return E_NOTIMPL;
560 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
562 HTMLDocument *This = HTMLDOC_THIS(iface);
564 TRACE("(%p)->(%p)\n", This, p);
566 return IHTMLWindow2_get_location(HTMLWINDOW2(This->window), p);
569 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
571 HTMLDocument *This = HTMLDOC_THIS(iface);
572 FIXME("(%p)->(%p)\n", This, p);
573 return E_NOTIMPL;
576 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
578 HTMLDocument *This = HTMLDOC_THIS(iface);
579 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
580 return E_NOTIMPL;
583 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
585 HTMLDocument *This = HTMLDOC_THIS(iface);
587 static const WCHAR about_blank_url[] =
588 {'a','b','o','u','t',':','b','l','a','n','k',0};
590 TRACE("(%p)->(%p)\n", iface, p);
592 *p = SysAllocString(This->doc_obj->url ? This->doc_obj->url : about_blank_url);
593 return *p ? S_OK : E_OUTOFMEMORY;
596 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
598 HTMLDocument *This = HTMLDOC_THIS(iface);
599 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
600 return E_NOTIMPL;
603 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
605 HTMLDocument *This = HTMLDOC_THIS(iface);
606 FIXME("(%p)->(%p)\n", This, p);
607 return E_NOTIMPL;
610 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
612 HTMLDocument *This = HTMLDOC_THIS(iface);
613 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
614 return E_NOTIMPL;
617 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
619 HTMLDocument *This = HTMLDOC_THIS(iface);
620 FIXME("(%p)->(%p)\n", This, p);
621 return E_NOTIMPL;
624 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
626 HTMLDocument *This = HTMLDOC_THIS(iface);
627 FIXME("(%p)->(%x)\n", This, v);
628 return E_NOTIMPL;
631 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
633 HTMLDocument *This = HTMLDOC_THIS(iface);
634 FIXME("(%p)->(%p)\n", This, p);
635 return E_NOTIMPL;
638 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
640 HTMLDocument *This = HTMLDOC_THIS(iface);
641 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
642 return E_NOTIMPL;
645 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
647 HTMLDocument *This = HTMLDOC_THIS(iface);
648 FIXME("(%p)->(%p)\n", This, p);
649 return E_NOTIMPL;
652 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
654 HTMLDocument *This = HTMLDOC_THIS(iface);
655 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
656 return E_NOTIMPL;
659 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
661 HTMLDocument *This = HTMLDOC_THIS(iface);
662 FIXME("(%p)->(%p)\n", This, p);
663 return E_NOTIMPL;
666 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
668 HTMLDocument *This = HTMLDOC_THIS(iface);
669 FIXME("(%p)->(%p)\n", This, p);
670 return E_NOTIMPL;
673 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
675 HTMLDocument *This = HTMLDOC_THIS(iface);
676 FIXME("(%p)->(%p)\n", This, p);
677 return E_NOTIMPL;
680 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
682 HTMLDocument *This = HTMLDOC_THIS(iface);
683 FIXME("(%p)->(%p)\n", This, p);
684 return E_NOTIMPL;
687 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
689 HTMLDocument *This = HTMLDOC_THIS(iface);
690 FIXME("(%p)->(%p)\n", This, p);
691 return E_NOTIMPL;
694 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
696 HTMLDocument *This = HTMLDOC_THIS(iface);
697 FIXME("(%p)->(%p)\n", This, p);
698 return E_NOTIMPL;
701 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
703 HTMLDocument *This = HTMLDOC_THIS(iface);
704 FIXME("(%p)->(%p)\n", This, p);
705 return E_NOTIMPL;
708 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
710 HTMLDocument *This = HTMLDOC_THIS(iface);
711 FIXME("(%p)->(%p)\n", This, p);
712 return E_NOTIMPL;
715 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
717 HTMLDocument *This = HTMLDOC_THIS(iface);
718 FIXME("(%p)->(%p)\n", This, p);
719 return E_NOTIMPL;
722 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
724 nsAString nsstr;
725 VARIANT *var;
726 ULONG i, argc;
727 nsresult nsres;
728 HRESULT hres;
730 if(!This->nsdoc) {
731 WARN("NULL nsdoc\n");
732 return E_UNEXPECTED;
735 if(psarray->cDims != 1) {
736 FIXME("cDims=%d\n", psarray->cDims);
737 return E_INVALIDARG;
740 hres = SafeArrayAccessData(psarray, (void**)&var);
741 if(FAILED(hres)) {
742 WARN("SafeArrayAccessData failed: %08x\n", hres);
743 return hres;
746 nsAString_Init(&nsstr, NULL);
748 argc = psarray->rgsabound[0].cElements;
749 for(i=0; i < argc; i++) {
750 if(V_VT(var+i) == VT_BSTR) {
751 nsAString_SetData(&nsstr, V_BSTR(var+i));
752 if(!ln || i != argc-1)
753 nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
754 else
755 nsres = nsIDOMHTMLDocument_Writeln(This->nsdoc, &nsstr);
756 if(NS_FAILED(nsres))
757 ERR("Write failed: %08x\n", nsres);
758 }else {
759 FIXME("vt=%d\n", V_VT(var+i));
763 nsAString_Finish(&nsstr);
764 SafeArrayUnaccessData(psarray);
766 return S_OK;
769 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
771 HTMLDocument *This = HTMLDOC_THIS(iface);
773 TRACE("(%p)->(%p)\n", iface, psarray);
775 return document_write(This, psarray, FALSE);
778 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
780 HTMLDocument *This = HTMLDOC_THIS(iface);
782 TRACE("(%p)->(%p)\n", This, psarray);
784 return document_write(This, psarray, TRUE);
787 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
788 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
790 HTMLDocument *This = HTMLDOC_THIS(iface);
791 nsresult nsres;
793 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
795 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
796 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
798 if(!This->nsdoc) {
799 ERR("!nsdoc\n");
800 return E_NOTIMPL;
803 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
804 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
805 FIXME("unsupported args\n");
807 nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
808 if(NS_FAILED(nsres)) {
809 ERR("Open failed: %08x\n", nsres);
810 return E_FAIL;
813 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
814 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
815 return S_OK;
818 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
820 HTMLDocument *This = HTMLDOC_THIS(iface);
821 nsresult nsres;
823 TRACE("(%p)\n", This);
825 if(!This->nsdoc) {
826 ERR("!nsdoc\n");
827 return E_NOTIMPL;
830 nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
831 if(NS_FAILED(nsres)) {
832 ERR("Close failed: %08x\n", nsres);
833 return E_FAIL;
836 return S_OK;
839 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
841 HTMLDocument *This = HTMLDOC_THIS(iface);
842 FIXME("(%p)\n", This);
843 return E_NOTIMPL;
846 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
847 VARIANT_BOOL *pfRet)
849 HTMLDocument *This = HTMLDOC_THIS(iface);
850 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
851 return E_NOTIMPL;
854 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
855 VARIANT_BOOL *pfRet)
857 HTMLDocument *This = HTMLDOC_THIS(iface);
858 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
859 return E_NOTIMPL;
862 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
863 VARIANT_BOOL *pfRet)
865 HTMLDocument *This = HTMLDOC_THIS(iface);
866 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
867 return E_NOTIMPL;
870 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
871 VARIANT_BOOL *pfRet)
873 HTMLDocument *This = HTMLDOC_THIS(iface);
874 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
875 return E_NOTIMPL;
878 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
879 BSTR *pfRet)
881 HTMLDocument *This = HTMLDOC_THIS(iface);
882 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
883 return E_NOTIMPL;
886 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
887 VARIANT *pfRet)
889 HTMLDocument *This = HTMLDOC_THIS(iface);
890 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
891 return E_NOTIMPL;
894 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
895 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
897 HTMLDocument *This = HTMLDOC_THIS(iface);
898 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
899 return E_NOTIMPL;
902 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
903 VARIANT_BOOL *pfRet)
905 HTMLDocument *This = HTMLDOC_THIS(iface);
906 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
907 return E_NOTIMPL;
910 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
911 IHTMLElement **newElem)
913 HTMLDocument *This = HTMLDOC_THIS(iface);
914 nsIDOMElement *nselem;
915 HTMLElement *elem;
916 nsAString tag_str;
917 nsresult nsres;
919 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
921 if(!This->nsdoc) {
922 WARN("NULL nsdoc\n");
923 return E_UNEXPECTED;
926 nsAString_Init(&tag_str, eTag);
927 nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
928 nsAString_Finish(&tag_str);
929 if(NS_FAILED(nsres)) {
930 ERR("CreateElement failed: %08x\n", nsres);
931 return E_FAIL;
934 elem = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE);
935 nsIDOMElement_Release(nselem);
937 *newElem = HTMLELEM(elem);
938 IHTMLElement_AddRef(HTMLELEM(elem));
939 return S_OK;
942 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
944 HTMLDocument *This = HTMLDOC_THIS(iface);
945 FIXME("(%p)\n", This);
946 return E_NOTIMPL;
949 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
951 HTMLDocument *This = HTMLDOC_THIS(iface);
952 FIXME("(%p)->(%p)\n", This, p);
953 return E_NOTIMPL;
956 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
958 HTMLDocument *This = HTMLDOC_THIS(iface);
960 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
962 return set_doc_event(This, EVENTID_CLICK, &v);
965 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
967 HTMLDocument *This = HTMLDOC_THIS(iface);
969 TRACE("(%p)->(%p)\n", This, p);
971 return get_doc_event(This, EVENTID_CLICK, p);
974 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
976 HTMLDocument *This = HTMLDOC_THIS(iface);
977 FIXME("(%p)\n", This);
978 return E_NOTIMPL;
981 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
983 HTMLDocument *This = HTMLDOC_THIS(iface);
984 FIXME("(%p)->(%p)\n", This, p);
985 return E_NOTIMPL;
988 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
990 HTMLDocument *This = HTMLDOC_THIS(iface);
992 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
994 return set_doc_event(This, EVENTID_KEYUP, &v);
997 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
999 HTMLDocument *This = HTMLDOC_THIS(iface);
1001 TRACE("(%p)->(%p)\n", This, p);
1003 return get_doc_event(This, EVENTID_KEYUP, p);
1006 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1008 HTMLDocument *This = HTMLDOC_THIS(iface);
1010 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1012 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1015 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1017 HTMLDocument *This = HTMLDOC_THIS(iface);
1019 TRACE("(%p)->(%p)\n", This, p);
1021 return get_doc_event(This, EVENTID_KEYDOWN, p);
1024 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1026 HTMLDocument *This = HTMLDOC_THIS(iface);
1027 FIXME("(%p)\n", This);
1028 return E_NOTIMPL;
1031 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1033 HTMLDocument *This = HTMLDOC_THIS(iface);
1034 FIXME("(%p)->(%p)\n", This, p);
1035 return E_NOTIMPL;
1038 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1040 HTMLDocument *This = HTMLDOC_THIS(iface);
1041 FIXME("(%p)\n", This);
1042 return E_NOTIMPL;
1045 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1047 HTMLDocument *This = HTMLDOC_THIS(iface);
1048 FIXME("(%p)->(%p)\n", This, p);
1049 return E_NOTIMPL;
1052 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1054 HTMLDocument *This = HTMLDOC_THIS(iface);
1055 FIXME("(%p)\n", This);
1056 return E_NOTIMPL;
1059 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1061 HTMLDocument *This = HTMLDOC_THIS(iface);
1062 FIXME("(%p)->(%p)\n", This, p);
1063 return E_NOTIMPL;
1066 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1068 HTMLDocument *This = HTMLDOC_THIS(iface);
1069 FIXME("(%p)\n", This);
1070 return E_NOTIMPL;
1073 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1075 HTMLDocument *This = HTMLDOC_THIS(iface);
1076 FIXME("(%p)->(%p)\n", This, p);
1077 return E_NOTIMPL;
1080 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1082 HTMLDocument *This = HTMLDOC_THIS(iface);
1083 FIXME("(%p)\n", This);
1084 return E_NOTIMPL;
1087 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1089 HTMLDocument *This = HTMLDOC_THIS(iface);
1090 FIXME("(%p)->(%p)\n", This, p);
1091 return E_NOTIMPL;
1094 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1096 HTMLDocument *This = HTMLDOC_THIS(iface);
1098 TRACE("(%p)\n", This);
1100 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1103 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1105 HTMLDocument *This = HTMLDOC_THIS(iface);
1107 TRACE("(%p)->(%p)\n", This, p);
1109 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1112 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1114 HTMLDocument *This = HTMLDOC_THIS(iface);
1115 FIXME("(%p)\n", This);
1116 return E_NOTIMPL;
1119 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1121 HTMLDocument *This = HTMLDOC_THIS(iface);
1122 FIXME("(%p)->(%p)\n", This, p);
1123 return E_NOTIMPL;
1126 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1128 HTMLDocument *This = HTMLDOC_THIS(iface);
1129 FIXME("(%p)\n", This);
1130 return E_NOTIMPL;
1133 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1135 HTMLDocument *This = HTMLDOC_THIS(iface);
1136 FIXME("(%p)->(%p)\n", This, p);
1137 return E_NOTIMPL;
1140 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1142 HTMLDocument *This = HTMLDOC_THIS(iface);
1143 FIXME("(%p)\n", This);
1144 return E_NOTIMPL;
1147 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1149 HTMLDocument *This = HTMLDOC_THIS(iface);
1150 FIXME("(%p)->(%p)\n", This, p);
1151 return E_NOTIMPL;
1154 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1156 HTMLDocument *This = HTMLDOC_THIS(iface);
1157 FIXME("(%p)\n", This);
1158 return E_NOTIMPL;
1161 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1163 HTMLDocument *This = HTMLDOC_THIS(iface);
1164 FIXME("(%p)->(%p)\n", This, p);
1165 return E_NOTIMPL;
1168 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1170 HTMLDocument *This = HTMLDOC_THIS(iface);
1172 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1174 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1177 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1179 HTMLDocument *This = HTMLDOC_THIS(iface);
1181 TRACE("(%p)->(%p)\n", This, p);
1183 return get_doc_event(This, EVENTID_DRAGSTART, p);
1186 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1188 HTMLDocument *This = HTMLDOC_THIS(iface);
1190 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1192 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1195 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1197 HTMLDocument *This = HTMLDOC_THIS(iface);
1199 TRACE("(%p)->(%p)\n", This, p);
1201 return get_doc_event(This, EVENTID_SELECTSTART, p);
1204 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1205 IHTMLElement **elementHit)
1207 HTMLDocument *This = HTMLDOC_THIS(iface);
1208 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1209 return E_NOTIMPL;
1212 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1214 HTMLDocument *This = HTMLDOC_THIS(iface);
1216 TRACE("(%p)->(%p)\n", This, p);
1218 *p = HTMLWINDOW2(This->window);
1219 IHTMLWindow2_AddRef(*p);
1220 return S_OK;
1223 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1224 IHTMLStyleSheetsCollection **p)
1226 HTMLDocument *This = HTMLDOC_THIS(iface);
1227 nsIDOMStyleSheetList *nsstylelist;
1228 nsIDOMDocumentStyle *nsdocstyle;
1229 nsresult nsres;
1231 TRACE("(%p)->(%p)\n", This, p);
1233 *p = NULL;
1235 if(!This->nsdoc) {
1236 WARN("NULL nsdoc\n");
1237 return E_UNEXPECTED;
1240 nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1241 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1242 nsIDOMDocumentStyle_Release(nsdocstyle);
1243 if(NS_FAILED(nsres)) {
1244 ERR("GetStyleSheets failed: %08x\n", nsres);
1245 return E_FAIL;
1248 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1249 nsIDOMDocumentStyle_Release(nsstylelist);
1251 return S_OK;
1254 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1256 HTMLDocument *This = HTMLDOC_THIS(iface);
1257 FIXME("(%p)\n", This);
1258 return E_NOTIMPL;
1261 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1263 HTMLDocument *This = HTMLDOC_THIS(iface);
1264 FIXME("(%p)->(%p)\n", This, p);
1265 return E_NOTIMPL;
1268 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1270 HTMLDocument *This = HTMLDOC_THIS(iface);
1271 FIXME("(%p)\n", This);
1272 return E_NOTIMPL;
1275 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1277 HTMLDocument *This = HTMLDOC_THIS(iface);
1278 FIXME("(%p)->(%p)\n", This, p);
1279 return E_NOTIMPL;
1282 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1284 HTMLDocument *This = HTMLDOC_THIS(iface);
1285 FIXME("(%p)->(%p)\n", This, String);
1286 return E_NOTIMPL;
1289 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1290 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1292 HTMLDocument *This = HTMLDOC_THIS(iface);
1294 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1296 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1297 return S_OK;
1300 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1301 HTMLDocument_QueryInterface,
1302 HTMLDocument_AddRef,
1303 HTMLDocument_Release,
1304 HTMLDocument_GetTypeInfoCount,
1305 HTMLDocument_GetTypeInfo,
1306 HTMLDocument_GetIDsOfNames,
1307 HTMLDocument_Invoke,
1308 HTMLDocument_get_Script,
1309 HTMLDocument_get_all,
1310 HTMLDocument_get_body,
1311 HTMLDocument_get_activeElement,
1312 HTMLDocument_get_images,
1313 HTMLDocument_get_applets,
1314 HTMLDocument_get_links,
1315 HTMLDocument_get_forms,
1316 HTMLDocument_get_anchors,
1317 HTMLDocument_put_title,
1318 HTMLDocument_get_title,
1319 HTMLDocument_get_scripts,
1320 HTMLDocument_put_designMode,
1321 HTMLDocument_get_designMode,
1322 HTMLDocument_get_selection,
1323 HTMLDocument_get_readyState,
1324 HTMLDocument_get_frames,
1325 HTMLDocument_get_embeds,
1326 HTMLDocument_get_plugins,
1327 HTMLDocument_put_alinkColor,
1328 HTMLDocument_get_alinkColor,
1329 HTMLDocument_put_bgColor,
1330 HTMLDocument_get_bgColor,
1331 HTMLDocument_put_fgColor,
1332 HTMLDocument_get_fgColor,
1333 HTMLDocument_put_linkColor,
1334 HTMLDocument_get_linkColor,
1335 HTMLDocument_put_vlinkColor,
1336 HTMLDocument_get_vlinkColor,
1337 HTMLDocument_get_referrer,
1338 HTMLDocument_get_location,
1339 HTMLDocument_get_lastModified,
1340 HTMLDocument_put_URL,
1341 HTMLDocument_get_URL,
1342 HTMLDocument_put_domain,
1343 HTMLDocument_get_domain,
1344 HTMLDocument_put_cookie,
1345 HTMLDocument_get_cookie,
1346 HTMLDocument_put_expando,
1347 HTMLDocument_get_expando,
1348 HTMLDocument_put_charset,
1349 HTMLDocument_get_charset,
1350 HTMLDocument_put_defaultCharset,
1351 HTMLDocument_get_defaultCharset,
1352 HTMLDocument_get_mimeType,
1353 HTMLDocument_get_fileSize,
1354 HTMLDocument_get_fileCreatedDate,
1355 HTMLDocument_get_fileModifiedDate,
1356 HTMLDocument_get_fileUpdatedDate,
1357 HTMLDocument_get_security,
1358 HTMLDocument_get_protocol,
1359 HTMLDocument_get_nameProp,
1360 HTMLDocument_write,
1361 HTMLDocument_writeln,
1362 HTMLDocument_open,
1363 HTMLDocument_close,
1364 HTMLDocument_clear,
1365 HTMLDocument_queryCommandSupported,
1366 HTMLDocument_queryCommandEnabled,
1367 HTMLDocument_queryCommandState,
1368 HTMLDocument_queryCommandIndeterm,
1369 HTMLDocument_queryCommandText,
1370 HTMLDocument_queryCommandValue,
1371 HTMLDocument_execCommand,
1372 HTMLDocument_execCommandShowHelp,
1373 HTMLDocument_createElement,
1374 HTMLDocument_put_onhelp,
1375 HTMLDocument_get_onhelp,
1376 HTMLDocument_put_onclick,
1377 HTMLDocument_get_onclick,
1378 HTMLDocument_put_ondblclick,
1379 HTMLDocument_get_ondblclick,
1380 HTMLDocument_put_onkeyup,
1381 HTMLDocument_get_onkeyup,
1382 HTMLDocument_put_onkeydown,
1383 HTMLDocument_get_onkeydown,
1384 HTMLDocument_put_onkeypress,
1385 HTMLDocument_get_onkeypress,
1386 HTMLDocument_put_onmouseup,
1387 HTMLDocument_get_onmouseup,
1388 HTMLDocument_put_onmousedown,
1389 HTMLDocument_get_onmousedown,
1390 HTMLDocument_put_onmousemove,
1391 HTMLDocument_get_onmousemove,
1392 HTMLDocument_put_onmouseout,
1393 HTMLDocument_get_onmouseout,
1394 HTMLDocument_put_onmouseover,
1395 HTMLDocument_get_onmouseover,
1396 HTMLDocument_put_onreadystatechange,
1397 HTMLDocument_get_onreadystatechange,
1398 HTMLDocument_put_onafterupdate,
1399 HTMLDocument_get_onafterupdate,
1400 HTMLDocument_put_onrowexit,
1401 HTMLDocument_get_onrowexit,
1402 HTMLDocument_put_onrowenter,
1403 HTMLDocument_get_onrowenter,
1404 HTMLDocument_put_ondragstart,
1405 HTMLDocument_get_ondragstart,
1406 HTMLDocument_put_onselectstart,
1407 HTMLDocument_get_onselectstart,
1408 HTMLDocument_elementFromPoint,
1409 HTMLDocument_get_parentWindow,
1410 HTMLDocument_get_styleSheets,
1411 HTMLDocument_put_onbeforeupdate,
1412 HTMLDocument_get_onbeforeupdate,
1413 HTMLDocument_put_onerrorupdate,
1414 HTMLDocument_get_onerrorupdate,
1415 HTMLDocument_toString,
1416 HTMLDocument_createStyleSheet
1419 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1421 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1423 HTMLDocument *This = SUPPINFO_THIS(iface);
1424 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1427 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1429 HTMLDocument *This = SUPPINFO_THIS(iface);
1430 return IHTMLDocument_AddRef(HTMLDOC(This));
1433 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1435 HTMLDocument *This = SUPPINFO_THIS(iface);
1436 return IHTMLDocument_Release(HTMLDOC(This));
1439 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1441 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1442 return S_FALSE;
1445 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1446 SupportErrorInfo_QueryInterface,
1447 SupportErrorInfo_AddRef,
1448 SupportErrorInfo_Release,
1449 SupportErrorInfo_InterfaceSupportsErrorInfo
1452 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1454 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1456 HTMLDocument *This = DISPEX_THIS(iface);
1458 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1461 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1463 HTMLDocument *This = DISPEX_THIS(iface);
1465 return IHTMLDocument2_AddRef(HTMLDOC(This));
1468 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1470 HTMLDocument *This = DISPEX_THIS(iface);
1472 return IHTMLDocument2_Release(HTMLDOC(This));
1475 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1477 HTMLDocument *This = DISPEX_THIS(iface);
1479 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
1482 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1483 LCID lcid, ITypeInfo **ppTInfo)
1485 HTMLDocument *This = DISPEX_THIS(iface);
1487 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
1490 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1491 LPOLESTR *rgszNames, UINT cNames,
1492 LCID lcid, DISPID *rgDispId)
1494 HTMLDocument *This = DISPEX_THIS(iface);
1496 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
1499 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1500 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1501 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1503 HTMLDocument *This = DISPEX_THIS(iface);
1505 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1506 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1508 switch(dispIdMember) {
1509 case DISPID_READYSTATE:
1510 TRACE("DISPID_READYSTATE\n");
1512 if(!(wFlags & DISPATCH_PROPERTYGET))
1513 return E_INVALIDARG;
1515 V_VT(pVarResult) = VT_I4;
1516 V_I4(pVarResult) = This->doc_obj->readystate;
1517 return S_OK;
1520 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
1521 pVarResult, pExcepInfo, puArgErr);
1524 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1526 HTMLDocument *This = DISPEX_THIS(iface);
1528 return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
1531 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1532 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1534 HTMLDocument *This = DISPEX_THIS(iface);
1536 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1539 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1541 HTMLDocument *This = DISPEX_THIS(iface);
1543 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
1546 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1548 HTMLDocument *This = DISPEX_THIS(iface);
1550 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
1553 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1555 HTMLDocument *This = DISPEX_THIS(iface);
1557 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
1560 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1562 HTMLDocument *This = DISPEX_THIS(iface);
1564 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
1567 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1569 HTMLDocument *This = DISPEX_THIS(iface);
1571 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
1574 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1576 HTMLDocument *This = DISPEX_THIS(iface);
1578 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
1581 #undef DISPEX_THIS
1583 static const IDispatchExVtbl DocDispatchExVtbl = {
1584 DocDispatchEx_QueryInterface,
1585 DocDispatchEx_AddRef,
1586 DocDispatchEx_Release,
1587 DocDispatchEx_GetTypeInfoCount,
1588 DocDispatchEx_GetTypeInfo,
1589 DocDispatchEx_GetIDsOfNames,
1590 DocDispatchEx_Invoke,
1591 DocDispatchEx_GetDispID,
1592 DocDispatchEx_InvokeEx,
1593 DocDispatchEx_DeleteMemberByName,
1594 DocDispatchEx_DeleteMemberByDispID,
1595 DocDispatchEx_GetMemberProperties,
1596 DocDispatchEx_GetMemberName,
1597 DocDispatchEx_GetNextDispID,
1598 DocDispatchEx_GetNameSpaceParent
1601 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
1603 *ppv = NULL;
1605 if(IsEqualGUID(&IID_IUnknown, riid)) {
1606 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
1607 *ppv = HTMLDOC(This);
1608 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1609 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv);
1610 *ppv = DISPATCHEX(This);
1611 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
1612 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv);
1613 *ppv = DISPATCHEX(This);
1614 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
1615 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv);
1616 *ppv = HTMLDOC(This);
1617 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
1618 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppv);
1619 *ppv = HTMLDOC(This);
1620 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
1621 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppv);
1622 *ppv = HTMLDOC3(This);
1623 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
1624 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppv);
1625 *ppv = HTMLDOC4(This);
1626 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
1627 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppv);
1628 *ppv = HTMLDOC5(This);
1629 }else if(IsEqualGUID(&IID_IHTMLDocument6, riid)) {
1630 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This, ppv);
1631 *ppv = HTMLDOC6(This);
1632 }else if(IsEqualGUID(&IID_IPersist, riid)) {
1633 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
1634 *ppv = PERSIST(This);
1635 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
1636 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppv);
1637 *ppv = PERSISTMON(This);
1638 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
1639 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppv);
1640 *ppv = PERSISTFILE(This);
1641 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
1642 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppv);
1643 *ppv = MONPROP(This);
1644 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
1645 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppv);
1646 *ppv = OLEOBJ(This);
1647 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
1648 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppv);
1649 *ppv = OLEDOC(This);
1650 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
1651 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppv);
1652 *ppv = DOCVIEW(This);
1653 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
1654 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
1655 *ppv = ACTOBJ(This);
1656 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
1657 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
1658 *ppv = VIEWOBJ(This);
1659 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
1660 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
1661 *ppv = VIEWOBJ2(This);
1662 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
1663 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
1664 *ppv = OLEWIN(This);
1665 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
1666 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
1667 *ppv = INPLACEOBJ(This);
1668 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1669 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppv);
1670 *ppv = INPLACEWIN(This);
1671 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1672 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
1673 *ppv = SERVPROV(This);
1674 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
1675 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppv);
1676 *ppv = CMDTARGET(This);
1677 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
1678 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppv);
1679 *ppv = CONTROL(This);
1680 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
1681 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppv);
1682 *ppv = HLNKTARGET(This);
1683 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1684 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1685 *ppv = CONPTCONT(&This->cp_container);
1686 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
1687 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
1688 *ppv = PERSTRINIT(This);
1689 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
1690 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
1691 *ppv = HTMLDOC(This);
1692 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
1693 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppv);
1694 *ppv = SUPPERRINFO(This);
1695 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
1696 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppv);
1697 *ppv = PERSISTHIST(This);
1698 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
1699 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
1700 *ppv = NULL;
1701 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
1702 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
1703 *ppv = NULL;
1704 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
1705 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
1706 *ppv = NULL;
1707 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
1708 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
1709 *ppv = NULL;
1710 }else {
1711 return FALSE;
1714 if(*ppv)
1715 IUnknown_AddRef((IUnknown*)*ppv);
1716 return TRUE;
1719 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
1721 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1722 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1723 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1725 doc->unk_impl = unk_impl;
1726 doc->dispex = dispex;
1728 HTMLDocument_HTMLDocument3_Init(doc);
1729 HTMLDocument_HTMLDocument5_Init(doc);
1730 HTMLDocument_Persist_Init(doc);
1731 HTMLDocument_OleCmd_Init(doc);
1732 HTMLDocument_OleObj_Init(doc);
1733 HTMLDocument_View_Init(doc);
1734 HTMLDocument_Window_Init(doc);
1735 HTMLDocument_Service_Init(doc);
1736 HTMLDocument_Hlink_Init(doc);
1738 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1739 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
1740 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
1741 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
1744 static void destroy_htmldoc(HTMLDocument *This)
1746 remove_doc_tasks(This);
1748 ConnectionPointContainer_Destroy(&This->cp_container);
1750 if(This->nsdoc)
1751 nsIDOMHTMLDocument_Release(This->nsdoc);
1754 #define HTMLDOCNODE_NODE_THIS(iface) DEFINE_THIS2(HTMLDocumentNode, node, iface)
1756 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1758 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1760 if(htmldoc_qi(&This->basedoc, riid, ppv))
1761 return *ppv ? S_OK : E_NOINTERFACE;
1763 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid)) {
1764 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This, ppv);
1765 *ppv = HOSTSECMGR(This);
1766 }else {
1767 return HTMLDOMNode_QI(&This->node, riid, ppv);
1770 IUnknown_AddRef((IUnknown*)*ppv);
1771 return S_OK;
1774 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
1776 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1778 if(This->secmgr)
1779 IInternetSecurityManager_Release(This->secmgr);
1781 detach_selection(This);
1782 detach_ranges(This);
1783 release_nodes(This);
1784 destroy_htmldoc(&This->basedoc);
1787 #undef HTMLDOCNODE_NODE_THIS
1789 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
1790 HTMLDocumentNode_QI,
1791 HTMLDocumentNode_destructor
1794 static const tid_t HTMLDocumentNode_iface_tids[] = {
1795 IHTMLDOMNode_tid,
1796 IHTMLDOMNode2_tid,
1797 IHTMLDocument2_tid,
1798 IHTMLDocument3_tid,
1799 IHTMLDocument4_tid,
1800 IHTMLDocument5_tid,
1804 static dispex_static_data_t HTMLDocumentNode_dispex = {
1805 NULL,
1806 DispHTMLDocument_tid,
1807 NULL,
1808 HTMLDocumentNode_iface_tids
1811 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret)
1813 HTMLDocumentNode *doc;
1814 HRESULT hres;
1816 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
1817 if(!doc)
1818 return E_OUTOFMEMORY;
1820 doc->basedoc.doc_node = doc;
1821 doc->basedoc.doc_obj = doc_obj;
1823 init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
1824 init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
1825 HTMLDocumentNode_SecMgr_Init(doc);
1826 doc->ref = 1;
1828 nsIDOMHTMLDocument_AddRef(nsdoc);
1829 doc->basedoc.nsdoc = nsdoc;
1831 doc->basedoc.window = window;
1833 list_init(&doc->selection_list);
1834 list_init(&doc->range_list);
1836 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
1837 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
1839 hres = CoInternetCreateSecurityManager(NULL, &doc->secmgr, 0);
1840 if(FAILED(hres)) {
1841 htmldoc_release(&doc->basedoc);
1842 return hres;
1845 *ret = doc;
1846 return S_OK;
1849 /**********************************************************
1850 * ICustomDoc implementation
1853 #define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocumentObj, CustomDoc, iface)
1855 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
1857 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1859 if(htmldoc_qi(&This->basedoc, riid, ppv))
1860 return *ppv ? S_OK : E_NOINTERFACE;
1862 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
1863 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
1864 *ppv = CUSTOMDOC(This);
1865 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1866 return *ppv ? S_OK : E_NOINTERFACE;
1867 }else {
1868 FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
1869 *ppv = NULL;
1870 return E_NOINTERFACE;
1873 IUnknown_AddRef((IUnknown*)*ppv);
1874 return S_OK;
1877 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
1879 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1880 ULONG ref = InterlockedIncrement(&This->ref);
1882 TRACE("(%p) ref = %u\n", This, ref);
1884 return ref;
1887 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
1889 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1890 ULONG ref = InterlockedDecrement(&This->ref);
1892 TRACE("(%p) ref = %u\n", This, ref);
1894 if(!ref) {
1895 set_document_bscallback(&This->basedoc, NULL);
1896 set_current_mon(&This->basedoc, NULL);
1897 if(This->basedoc.doc_node) {
1898 This->basedoc.doc_node->basedoc.doc_obj = NULL;
1899 IHTMLDocument2_Release(HTMLDOC(&This->basedoc.doc_node->basedoc));
1901 if(This->basedoc.window) {
1902 This->basedoc.window->doc_obj = NULL;
1903 IHTMLWindow2_Release(HTMLWINDOW2(This->basedoc.window));
1906 if(This->client)
1907 IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL);
1908 if(This->in_place_active)
1909 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(&This->basedoc));
1910 if(This->ipsite)
1911 IOleDocumentView_SetInPlaceSite(DOCVIEW(&This->basedoc), NULL);
1912 if(This->undomgr)
1913 IOleUndoManager_Release(This->undomgr);
1914 if(This->tooltips_hwnd)
1915 DestroyWindow(This->tooltips_hwnd);
1917 if(This->hwnd)
1918 DestroyWindow(This->hwnd);
1919 heap_free(This->mime);
1921 destroy_htmldoc(&This->basedoc);
1922 release_dispex(&This->dispex);
1924 if(This->basedoc.nsdoc)
1925 remove_mutation_observer(This->nscontainer, This->basedoc.nsdoc);
1926 if(This->nscontainer)
1927 NSContainer_Release(This->nscontainer);
1928 heap_free(This);
1931 return ref;
1934 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
1936 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1937 FIXME("(%p)->(%p)\n", This, pUIHandler);
1938 return E_NOTIMPL;
1941 #undef CUSTOMDOC_THIS
1943 static const ICustomDocVtbl CustomDocVtbl = {
1944 CustomDoc_QueryInterface,
1945 CustomDoc_AddRef,
1946 CustomDoc_Release,
1947 CustomDoc_SetUIHandler
1950 static const tid_t HTMLDocumentObj_iface_tids[] = {
1951 IHTMLDocument2_tid,
1952 IHTMLDocument3_tid,
1953 IHTMLDocument4_tid,
1954 IHTMLDocument5_tid,
1957 static dispex_static_data_t HTMLDocumentObj_dispex = {
1958 NULL,
1959 DispHTMLDocument_tid,
1960 NULL,
1961 HTMLDocumentObj_iface_tids
1964 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1966 HTMLDocumentObj *doc;
1967 nsIDOMWindow *nswindow = NULL;
1968 HRESULT hres;
1970 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1972 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
1973 if(!doc)
1974 return E_OUTOFMEMORY;
1976 init_dispex(&doc->dispex, (IUnknown*)CUSTOMDOC(doc), &HTMLDocumentObj_dispex);
1977 init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc), DISPATCHEX(&doc->dispex));
1979 doc->lpCustomDocVtbl = &CustomDocVtbl;
1980 doc->ref = 1;
1981 doc->basedoc.doc_obj = doc;
1983 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
1984 htmldoc_release(&doc->basedoc);
1985 if(FAILED(hres))
1986 return hres;
1988 doc->nscontainer = NSContainer_Create(doc, NULL);
1989 list_init(&doc->bindings);
1990 doc->usermode = UNKNOWN_USERMODE;
1991 doc->readystate = READYSTATE_UNINITIALIZED;
1993 if(doc->nscontainer) {
1994 nsresult nsres;
1996 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
1997 if(NS_FAILED(nsres))
1998 ERR("GetContentDOMWindow failed: %08x\n", nsres);
2001 hres = HTMLWindow_Create(doc, nswindow, &doc->basedoc.window);
2002 if(nswindow)
2003 nsIDOMWindow_Release(nswindow);
2004 if(FAILED(hres)) {
2005 IHTMLDocument_Release(HTMLDOC(&doc->basedoc));
2006 return hres;
2009 update_nsdocument(doc);
2010 get_thread_hwnd();
2012 return S_OK;