mshtml: Use node's IDispatchEx implementation in HTMLDocumentNode.
[wine/multimedia.git] / dlls / mshtml / htmldoc.c
blobe3fde658b980da2e272037c18f5613f3251a5003
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"
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
35 #include "htmlevent.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
41 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
43 HTMLDocument *This = HTMLDOC_THIS(iface);
45 return htmldoc_query_interface(This, riid, ppv);
48 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
50 HTMLDocument *This = HTMLDOC_THIS(iface);
52 return htmldoc_addref(This);
55 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
57 HTMLDocument *This = HTMLDOC_THIS(iface);
59 return htmldoc_release(This);
62 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
64 HTMLDocument *This = HTMLDOC_THIS(iface);
66 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
69 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
70 LCID lcid, ITypeInfo **ppTInfo)
72 HTMLDocument *This = HTMLDOC_THIS(iface);
74 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
77 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
78 LPOLESTR *rgszNames, UINT cNames,
79 LCID lcid, DISPID *rgDispId)
81 HTMLDocument *This = HTMLDOC_THIS(iface);
83 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
86 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
87 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
88 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
90 HTMLDocument *This = HTMLDOC_THIS(iface);
92 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
93 pVarResult, pExcepInfo, puArgErr);
96 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
98 HTMLDocument *This = HTMLDOC_THIS(iface);
100 TRACE("(%p)->(%p)\n", This, p);
102 *p = (IDispatch*)HTMLWINDOW2(This->window);
103 IDispatch_AddRef(*p);
104 return S_OK;
107 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
109 HTMLDocument *This = HTMLDOC_THIS(iface);
110 nsIDOMElement *nselem = NULL;
111 nsresult nsres;
113 TRACE("(%p)->(%p)\n", This, p);
115 if(!This->nsdoc) {
116 WARN("NULL nsdoc\n");
117 return E_UNEXPECTED;
120 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
121 if(NS_FAILED(nsres)) {
122 ERR("GetDocumentElement failed: %08x\n", nsres);
123 return E_FAIL;
126 if(nselem) {
127 *p = create_all_collection(get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE), TRUE);
128 nsIDOMElement_Release(nselem);
129 }else {
130 *p = NULL;
133 return S_OK;
136 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
138 HTMLDocument *This = HTMLDOC_THIS(iface);
139 nsIDOMHTMLElement *nsbody = NULL;
140 HTMLDOMNode *node;
141 nsresult nsres;
143 TRACE("(%p)->(%p)\n", This, p);
145 if(!This->nsdoc) {
146 WARN("NULL nsdoc\n");
147 return E_UNEXPECTED;
150 nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody);
151 if(NS_FAILED(nsres)) {
152 TRACE("Could not get body: %08x\n", nsres);
153 return E_UNEXPECTED;
156 if(nsbody) {
157 node = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE);
158 nsIDOMHTMLElement_Release(nsbody);
160 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
161 }else {
162 *p = NULL;
165 TRACE("*p = %p\n", *p);
166 return S_OK;
169 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
171 HTMLDocument *This = HTMLDOC_THIS(iface);
172 FIXME("(%p)->(%p)\n", This, p);
173 return E_NOTIMPL;
176 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
178 HTMLDocument *This = HTMLDOC_THIS(iface);
179 nsIDOMHTMLCollection *nscoll = NULL;
180 nsresult nsres;
182 TRACE("(%p)->(%p)\n", This, p);
184 if(!p)
185 return E_INVALIDARG;
187 *p = NULL;
189 if(!This->nsdoc) {
190 WARN("NULL nsdoc\n");
191 return E_UNEXPECTED;
194 nsres = nsIDOMHTMLDocument_GetImages(This->nsdoc, &nscoll);
195 if(NS_FAILED(nsres)) {
196 ERR("GetImages failed: %08x\n", nsres);
197 return E_FAIL;
200 if(nscoll) {
201 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
202 nsIDOMElement_Release(nscoll);
205 return S_OK;
208 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
210 HTMLDocument *This = HTMLDOC_THIS(iface);
211 nsIDOMHTMLCollection *nscoll = NULL;
212 nsresult nsres;
214 TRACE("(%p)->(%p)\n", This, p);
216 if(!p)
217 return E_INVALIDARG;
219 *p = NULL;
221 if(!This->nsdoc) {
222 WARN("NULL nsdoc\n");
223 return E_UNEXPECTED;
226 nsres = nsIDOMHTMLDocument_GetApplets(This->nsdoc, &nscoll);
227 if(NS_FAILED(nsres)) {
228 ERR("GetApplets failed: %08x\n", nsres);
229 return E_FAIL;
232 if(nscoll) {
233 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
234 nsIDOMElement_Release(nscoll);
237 return S_OK;
240 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
242 HTMLDocument *This = HTMLDOC_THIS(iface);
243 nsIDOMHTMLCollection *nscoll = NULL;
244 nsresult nsres;
246 TRACE("(%p)->(%p)\n", This, p);
248 if(!p)
249 return E_INVALIDARG;
251 *p = NULL;
253 if(!This->nsdoc) {
254 WARN("NULL nsdoc\n");
255 return E_UNEXPECTED;
258 nsres = nsIDOMHTMLDocument_GetLinks(This->nsdoc, &nscoll);
259 if(NS_FAILED(nsres)) {
260 ERR("GetLinks failed: %08x\n", nsres);
261 return E_FAIL;
264 if(nscoll) {
265 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
266 nsIDOMElement_Release(nscoll);
269 return S_OK;
272 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
274 HTMLDocument *This = HTMLDOC_THIS(iface);
275 nsIDOMHTMLCollection *nscoll = NULL;
276 nsresult nsres;
278 TRACE("(%p)->(%p)\n", This, p);
280 if(!p)
281 return E_INVALIDARG;
283 *p = NULL;
285 if(!This->nsdoc) {
286 WARN("NULL nsdoc\n");
287 return E_UNEXPECTED;
290 nsres = nsIDOMHTMLDocument_GetForms(This->nsdoc, &nscoll);
291 if(NS_FAILED(nsres)) {
292 ERR("GetForms failed: %08x\n", nsres);
293 return E_FAIL;
296 if(nscoll) {
297 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
298 nsIDOMElement_Release(nscoll);
301 return S_OK;
304 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
306 HTMLDocument *This = HTMLDOC_THIS(iface);
307 nsIDOMHTMLCollection *nscoll = NULL;
308 nsresult nsres;
310 TRACE("(%p)->(%p)\n", This, p);
312 if(!p)
313 return E_INVALIDARG;
315 *p = NULL;
317 if(!This->nsdoc) {
318 WARN("NULL nsdoc\n");
319 return E_UNEXPECTED;
322 nsres = nsIDOMHTMLDocument_GetAnchors(This->nsdoc, &nscoll);
323 if(NS_FAILED(nsres)) {
324 ERR("GetAnchors failed: %08x\n", nsres);
325 return E_FAIL;
328 if(nscoll) {
329 *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)HTMLDOC(This), nscoll);
330 nsIDOMElement_Release(nscoll);
333 return S_OK;
336 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
338 HTMLDocument *This = HTMLDOC_THIS(iface);
339 nsAString nsstr;
340 nsresult nsres;
342 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
344 if(!This->nsdoc) {
345 WARN("NULL nsdoc\n");
346 return E_UNEXPECTED;
349 nsAString_Init(&nsstr, v);
350 nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr);
351 nsAString_Finish(&nsstr);
352 if(NS_FAILED(nsres))
353 ERR("SetTitle failed: %08x\n", nsres);
355 return S_OK;
358 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
360 HTMLDocument *This = HTMLDOC_THIS(iface);
361 const PRUnichar *ret;
362 nsAString nsstr;
363 nsresult nsres;
365 TRACE("(%p)->(%p)\n", This, p);
367 if(!This->nsdoc) {
368 WARN("NULL nsdoc\n");
369 return E_UNEXPECTED;
373 nsAString_Init(&nsstr, NULL);
374 nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
375 if (NS_SUCCEEDED(nsres)) {
376 nsAString_GetData(&nsstr, &ret);
377 *p = SysAllocString(ret);
379 nsAString_Finish(&nsstr);
381 if(NS_FAILED(nsres)) {
382 ERR("GetTitle failed: %08x\n", nsres);
383 return E_FAIL;
386 return S_OK;
389 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
391 HTMLDocument *This = HTMLDOC_THIS(iface);
392 FIXME("(%p)->(%p)\n", This, p);
393 return E_NOTIMPL;
396 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
398 HTMLDocument *This = HTMLDOC_THIS(iface);
399 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
400 return E_NOTIMPL;
403 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
405 HTMLDocument *This = HTMLDOC_THIS(iface);
406 static WCHAR szOff[] = {'O','f','f',0};
407 FIXME("(%p)->(%p) always returning Off\n", This, p);
409 if(!p)
410 return E_INVALIDARG;
412 *p = SysAllocString(szOff);
414 return S_OK;
417 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
419 HTMLDocument *This = HTMLDOC_THIS(iface);
420 nsISelection *nsselection;
421 nsresult nsres;
423 TRACE("(%p)->(%p)\n", This, p);
425 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
426 if(NS_FAILED(nsres)) {
427 ERR("GetSelection failed: %08x\n", nsres);
428 return E_FAIL;
431 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
434 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
436 HTMLDocument *This = HTMLDOC_THIS(iface);
438 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
439 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
440 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
441 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
442 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
444 static const LPCWSTR readystate_str[] = {
445 wszUninitialized,
446 wszLoading,
447 wszLoaded,
448 wszInteractive,
449 wszComplete
452 TRACE("(%p)->(%p)\n", iface, p);
454 if(!p)
455 return E_POINTER;
457 *p = SysAllocString(readystate_str[This->doc_obj->readystate]);
458 return S_OK;
461 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
463 HTMLDocument *This = HTMLDOC_THIS(iface);
464 FIXME("(%p)->(%p)\n", This, p);
465 return E_NOTIMPL;
468 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
470 HTMLDocument *This = HTMLDOC_THIS(iface);
471 FIXME("(%p)->(%p)\n", This, p);
472 return E_NOTIMPL;
475 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
477 HTMLDocument *This = HTMLDOC_THIS(iface);
478 FIXME("(%p)->(%p)\n", This, p);
479 return E_NOTIMPL;
482 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
484 HTMLDocument *This = HTMLDOC_THIS(iface);
485 FIXME("(%p)\n", This);
486 return E_NOTIMPL;
489 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
491 HTMLDocument *This = HTMLDOC_THIS(iface);
492 FIXME("(%p)->(%p)\n", This, p);
493 return E_NOTIMPL;
496 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
498 HTMLDocument *This = HTMLDOC_THIS(iface);
499 FIXME("(%p)\n", This);
500 return E_NOTIMPL;
503 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
505 HTMLDocument *This = HTMLDOC_THIS(iface);
506 FIXME("(%p)->(%p)\n", This, p);
507 return E_NOTIMPL;
510 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
512 HTMLDocument *This = HTMLDOC_THIS(iface);
513 FIXME("(%p)\n", This);
514 return E_NOTIMPL;
517 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
519 HTMLDocument *This = HTMLDOC_THIS(iface);
520 FIXME("(%p)->(%p)\n", This, p);
521 return E_NOTIMPL;
524 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
526 HTMLDocument *This = HTMLDOC_THIS(iface);
527 FIXME("(%p)->()\n", This);
528 return E_NOTIMPL;
531 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
533 HTMLDocument *This = HTMLDOC_THIS(iface);
534 FIXME("(%p)->(%p)\n", This, p);
535 return E_NOTIMPL;
538 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
540 HTMLDocument *This = HTMLDOC_THIS(iface);
541 FIXME("(%p)\n", This);
542 return E_NOTIMPL;
545 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
547 HTMLDocument *This = HTMLDOC_THIS(iface);
548 FIXME("(%p)->(%p)\n", This, p);
549 return E_NOTIMPL;
552 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
554 HTMLDocument *This = HTMLDOC_THIS(iface);
555 FIXME("(%p)->(%p)\n", This, p);
556 return E_NOTIMPL;
559 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
561 HTMLDocument *This = HTMLDOC_THIS(iface);
563 TRACE("(%p)->(%p)\n", This, p);
565 return IHTMLWindow2_get_location(HTMLWINDOW2(This->window), p);
568 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
570 HTMLDocument *This = HTMLDOC_THIS(iface);
571 FIXME("(%p)->(%p)\n", This, p);
572 return E_NOTIMPL;
575 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
577 HTMLDocument *This = HTMLDOC_THIS(iface);
578 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
579 return E_NOTIMPL;
582 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
584 HTMLDocument *This = HTMLDOC_THIS(iface);
586 static const WCHAR about_blank_url[] =
587 {'a','b','o','u','t',':','b','l','a','n','k',0};
589 TRACE("(%p)->(%p)\n", iface, p);
591 *p = SysAllocString(This->doc_obj->url ? This->doc_obj->url : about_blank_url);
592 return *p ? S_OK : E_OUTOFMEMORY;
595 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
597 HTMLDocument *This = HTMLDOC_THIS(iface);
598 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
599 return E_NOTIMPL;
602 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
604 HTMLDocument *This = HTMLDOC_THIS(iface);
605 FIXME("(%p)->(%p)\n", This, p);
606 return E_NOTIMPL;
609 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
611 HTMLDocument *This = HTMLDOC_THIS(iface);
612 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
613 return E_NOTIMPL;
616 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
618 HTMLDocument *This = HTMLDOC_THIS(iface);
619 FIXME("(%p)->(%p)\n", This, p);
620 return E_NOTIMPL;
623 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
625 HTMLDocument *This = HTMLDOC_THIS(iface);
626 FIXME("(%p)->(%x)\n", This, v);
627 return E_NOTIMPL;
630 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
632 HTMLDocument *This = HTMLDOC_THIS(iface);
633 FIXME("(%p)->(%p)\n", This, p);
634 return E_NOTIMPL;
637 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
639 HTMLDocument *This = HTMLDOC_THIS(iface);
640 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
641 return E_NOTIMPL;
644 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
646 HTMLDocument *This = HTMLDOC_THIS(iface);
647 FIXME("(%p)->(%p)\n", This, p);
648 return E_NOTIMPL;
651 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
653 HTMLDocument *This = HTMLDOC_THIS(iface);
654 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
655 return E_NOTIMPL;
658 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
660 HTMLDocument *This = HTMLDOC_THIS(iface);
661 FIXME("(%p)->(%p)\n", This, p);
662 return E_NOTIMPL;
665 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
667 HTMLDocument *This = HTMLDOC_THIS(iface);
668 FIXME("(%p)->(%p)\n", This, p);
669 return E_NOTIMPL;
672 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
674 HTMLDocument *This = HTMLDOC_THIS(iface);
675 FIXME("(%p)->(%p)\n", This, p);
676 return E_NOTIMPL;
679 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
681 HTMLDocument *This = HTMLDOC_THIS(iface);
682 FIXME("(%p)->(%p)\n", This, p);
683 return E_NOTIMPL;
686 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
688 HTMLDocument *This = HTMLDOC_THIS(iface);
689 FIXME("(%p)->(%p)\n", This, p);
690 return E_NOTIMPL;
693 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
695 HTMLDocument *This = HTMLDOC_THIS(iface);
696 FIXME("(%p)->(%p)\n", This, p);
697 return E_NOTIMPL;
700 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
702 HTMLDocument *This = HTMLDOC_THIS(iface);
703 FIXME("(%p)->(%p)\n", This, p);
704 return E_NOTIMPL;
707 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
709 HTMLDocument *This = HTMLDOC_THIS(iface);
710 FIXME("(%p)->(%p)\n", This, p);
711 return E_NOTIMPL;
714 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
716 HTMLDocument *This = HTMLDOC_THIS(iface);
717 FIXME("(%p)->(%p)\n", This, p);
718 return E_NOTIMPL;
721 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
723 nsAString nsstr;
724 VARIANT *var;
725 ULONG i, argc;
726 nsresult nsres;
727 HRESULT hres;
729 if(!This->nsdoc) {
730 WARN("NULL nsdoc\n");
731 return E_UNEXPECTED;
734 if(psarray->cDims != 1) {
735 FIXME("cDims=%d\n", psarray->cDims);
736 return E_INVALIDARG;
739 hres = SafeArrayAccessData(psarray, (void**)&var);
740 if(FAILED(hres)) {
741 WARN("SafeArrayAccessData failed: %08x\n", hres);
742 return hres;
745 nsAString_Init(&nsstr, NULL);
747 argc = psarray->rgsabound[0].cElements;
748 for(i=0; i < argc; i++) {
749 if(V_VT(var+i) == VT_BSTR) {
750 nsAString_SetData(&nsstr, V_BSTR(var+i));
751 if(!ln || i != argc-1)
752 nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
753 else
754 nsres = nsIDOMHTMLDocument_Writeln(This->nsdoc, &nsstr);
755 if(NS_FAILED(nsres))
756 ERR("Write failed: %08x\n", nsres);
757 }else {
758 FIXME("vt=%d\n", V_VT(var+i));
762 nsAString_Finish(&nsstr);
763 SafeArrayUnaccessData(psarray);
765 return S_OK;
768 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
770 HTMLDocument *This = HTMLDOC_THIS(iface);
772 TRACE("(%p)->(%p)\n", iface, psarray);
774 return document_write(This, psarray, FALSE);
777 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
779 HTMLDocument *This = HTMLDOC_THIS(iface);
781 TRACE("(%p)->(%p)\n", This, psarray);
783 return document_write(This, psarray, TRUE);
786 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
787 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
789 HTMLDocument *This = HTMLDOC_THIS(iface);
790 nsresult nsres;
792 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
794 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
795 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
797 if(!This->nsdoc) {
798 ERR("!nsdoc\n");
799 return E_NOTIMPL;
802 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
803 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
804 FIXME("unsupported args\n");
806 nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
807 if(NS_FAILED(nsres)) {
808 ERR("Open failed: %08x\n", nsres);
809 return E_FAIL;
812 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
813 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
814 return S_OK;
817 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
819 HTMLDocument *This = HTMLDOC_THIS(iface);
820 nsresult nsres;
822 TRACE("(%p)\n", This);
824 if(!This->nsdoc) {
825 ERR("!nsdoc\n");
826 return E_NOTIMPL;
829 nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
830 if(NS_FAILED(nsres)) {
831 ERR("Close failed: %08x\n", nsres);
832 return E_FAIL;
835 return S_OK;
838 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
840 HTMLDocument *This = HTMLDOC_THIS(iface);
841 FIXME("(%p)\n", This);
842 return E_NOTIMPL;
845 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
846 VARIANT_BOOL *pfRet)
848 HTMLDocument *This = HTMLDOC_THIS(iface);
849 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
850 return E_NOTIMPL;
853 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
854 VARIANT_BOOL *pfRet)
856 HTMLDocument *This = HTMLDOC_THIS(iface);
857 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
858 return E_NOTIMPL;
861 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
862 VARIANT_BOOL *pfRet)
864 HTMLDocument *This = HTMLDOC_THIS(iface);
865 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
866 return E_NOTIMPL;
869 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
870 VARIANT_BOOL *pfRet)
872 HTMLDocument *This = HTMLDOC_THIS(iface);
873 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
874 return E_NOTIMPL;
877 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
878 BSTR *pfRet)
880 HTMLDocument *This = HTMLDOC_THIS(iface);
881 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
882 return E_NOTIMPL;
885 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
886 VARIANT *pfRet)
888 HTMLDocument *This = HTMLDOC_THIS(iface);
889 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
890 return E_NOTIMPL;
893 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
894 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
896 HTMLDocument *This = HTMLDOC_THIS(iface);
897 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
898 return E_NOTIMPL;
901 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
902 VARIANT_BOOL *pfRet)
904 HTMLDocument *This = HTMLDOC_THIS(iface);
905 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
906 return E_NOTIMPL;
909 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
910 IHTMLElement **newElem)
912 HTMLDocument *This = HTMLDOC_THIS(iface);
913 nsIDOMElement *nselem;
914 HTMLElement *elem;
915 nsAString tag_str;
916 nsresult nsres;
918 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
920 if(!This->nsdoc) {
921 WARN("NULL nsdoc\n");
922 return E_UNEXPECTED;
925 nsAString_Init(&tag_str, eTag);
926 nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
927 nsAString_Finish(&tag_str);
928 if(NS_FAILED(nsres)) {
929 ERR("CreateElement failed: %08x\n", nsres);
930 return E_FAIL;
933 elem = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE);
934 nsIDOMElement_Release(nselem);
936 *newElem = HTMLELEM(elem);
937 IHTMLElement_AddRef(HTMLELEM(elem));
938 return S_OK;
941 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
943 HTMLDocument *This = HTMLDOC_THIS(iface);
944 FIXME("(%p)\n", This);
945 return E_NOTIMPL;
948 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
950 HTMLDocument *This = HTMLDOC_THIS(iface);
951 FIXME("(%p)->(%p)\n", This, p);
952 return E_NOTIMPL;
955 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
957 HTMLDocument *This = HTMLDOC_THIS(iface);
959 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
961 return set_doc_event(This, EVENTID_CLICK, &v);
964 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
966 HTMLDocument *This = HTMLDOC_THIS(iface);
968 TRACE("(%p)->(%p)\n", This, p);
970 return get_doc_event(This, EVENTID_CLICK, p);
973 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
975 HTMLDocument *This = HTMLDOC_THIS(iface);
976 FIXME("(%p)\n", This);
977 return E_NOTIMPL;
980 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
982 HTMLDocument *This = HTMLDOC_THIS(iface);
983 FIXME("(%p)->(%p)\n", This, p);
984 return E_NOTIMPL;
987 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
989 HTMLDocument *This = HTMLDOC_THIS(iface);
991 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
993 return set_doc_event(This, EVENTID_KEYUP, &v);
996 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
998 HTMLDocument *This = HTMLDOC_THIS(iface);
1000 TRACE("(%p)->(%p)\n", This, p);
1002 return get_doc_event(This, EVENTID_KEYUP, p);
1005 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1007 HTMLDocument *This = HTMLDOC_THIS(iface);
1009 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1011 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1014 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1016 HTMLDocument *This = HTMLDOC_THIS(iface);
1018 TRACE("(%p)->(%p)\n", This, p);
1020 return get_doc_event(This, EVENTID_KEYDOWN, p);
1023 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1025 HTMLDocument *This = HTMLDOC_THIS(iface);
1026 FIXME("(%p)\n", This);
1027 return E_NOTIMPL;
1030 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1032 HTMLDocument *This = HTMLDOC_THIS(iface);
1033 FIXME("(%p)->(%p)\n", This, p);
1034 return E_NOTIMPL;
1037 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1039 HTMLDocument *This = HTMLDOC_THIS(iface);
1040 FIXME("(%p)\n", This);
1041 return E_NOTIMPL;
1044 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1046 HTMLDocument *This = HTMLDOC_THIS(iface);
1047 FIXME("(%p)->(%p)\n", This, p);
1048 return E_NOTIMPL;
1051 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1053 HTMLDocument *This = HTMLDOC_THIS(iface);
1054 FIXME("(%p)\n", This);
1055 return E_NOTIMPL;
1058 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1060 HTMLDocument *This = HTMLDOC_THIS(iface);
1061 FIXME("(%p)->(%p)\n", This, p);
1062 return E_NOTIMPL;
1065 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1067 HTMLDocument *This = HTMLDOC_THIS(iface);
1068 FIXME("(%p)\n", This);
1069 return E_NOTIMPL;
1072 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1074 HTMLDocument *This = HTMLDOC_THIS(iface);
1075 FIXME("(%p)->(%p)\n", This, p);
1076 return E_NOTIMPL;
1079 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1081 HTMLDocument *This = HTMLDOC_THIS(iface);
1082 FIXME("(%p)\n", This);
1083 return E_NOTIMPL;
1086 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1088 HTMLDocument *This = HTMLDOC_THIS(iface);
1089 FIXME("(%p)->(%p)\n", This, p);
1090 return E_NOTIMPL;
1093 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1095 HTMLDocument *This = HTMLDOC_THIS(iface);
1097 TRACE("(%p)\n", This);
1099 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1102 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1104 HTMLDocument *This = HTMLDOC_THIS(iface);
1106 TRACE("(%p)->(%p)\n", This, p);
1108 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1111 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1113 HTMLDocument *This = HTMLDOC_THIS(iface);
1114 FIXME("(%p)\n", This);
1115 return E_NOTIMPL;
1118 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1120 HTMLDocument *This = HTMLDOC_THIS(iface);
1121 FIXME("(%p)->(%p)\n", This, p);
1122 return E_NOTIMPL;
1125 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1127 HTMLDocument *This = HTMLDOC_THIS(iface);
1128 FIXME("(%p)\n", This);
1129 return E_NOTIMPL;
1132 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1134 HTMLDocument *This = HTMLDOC_THIS(iface);
1135 FIXME("(%p)->(%p)\n", This, p);
1136 return E_NOTIMPL;
1139 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1141 HTMLDocument *This = HTMLDOC_THIS(iface);
1142 FIXME("(%p)\n", This);
1143 return E_NOTIMPL;
1146 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1148 HTMLDocument *This = HTMLDOC_THIS(iface);
1149 FIXME("(%p)->(%p)\n", This, p);
1150 return E_NOTIMPL;
1153 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1155 HTMLDocument *This = HTMLDOC_THIS(iface);
1156 FIXME("(%p)\n", This);
1157 return E_NOTIMPL;
1160 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1162 HTMLDocument *This = HTMLDOC_THIS(iface);
1163 FIXME("(%p)->(%p)\n", This, p);
1164 return E_NOTIMPL;
1167 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1169 HTMLDocument *This = HTMLDOC_THIS(iface);
1171 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1173 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1176 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1178 HTMLDocument *This = HTMLDOC_THIS(iface);
1180 TRACE("(%p)->(%p)\n", This, p);
1182 return get_doc_event(This, EVENTID_DRAGSTART, p);
1185 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1187 HTMLDocument *This = HTMLDOC_THIS(iface);
1189 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1191 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1194 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1196 HTMLDocument *This = HTMLDOC_THIS(iface);
1198 TRACE("(%p)->(%p)\n", This, p);
1200 return get_doc_event(This, EVENTID_SELECTSTART, p);
1203 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1204 IHTMLElement **elementHit)
1206 HTMLDocument *This = HTMLDOC_THIS(iface);
1207 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1208 return E_NOTIMPL;
1211 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1213 HTMLDocument *This = HTMLDOC_THIS(iface);
1215 TRACE("(%p)->(%p)\n", This, p);
1217 *p = HTMLWINDOW2(This->window);
1218 IHTMLWindow2_AddRef(*p);
1219 return S_OK;
1222 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1223 IHTMLStyleSheetsCollection **p)
1225 HTMLDocument *This = HTMLDOC_THIS(iface);
1226 nsIDOMStyleSheetList *nsstylelist;
1227 nsIDOMDocumentStyle *nsdocstyle;
1228 nsresult nsres;
1230 TRACE("(%p)->(%p)\n", This, p);
1232 *p = NULL;
1234 if(!This->nsdoc) {
1235 WARN("NULL nsdoc\n");
1236 return E_UNEXPECTED;
1239 nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1240 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1241 nsIDOMDocumentStyle_Release(nsdocstyle);
1242 if(NS_FAILED(nsres)) {
1243 ERR("GetStyleSheets failed: %08x\n", nsres);
1244 return E_FAIL;
1247 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1248 nsIDOMDocumentStyle_Release(nsstylelist);
1250 return S_OK;
1253 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1255 HTMLDocument *This = HTMLDOC_THIS(iface);
1256 FIXME("(%p)\n", This);
1257 return E_NOTIMPL;
1260 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1262 HTMLDocument *This = HTMLDOC_THIS(iface);
1263 FIXME("(%p)->(%p)\n", This, p);
1264 return E_NOTIMPL;
1267 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1269 HTMLDocument *This = HTMLDOC_THIS(iface);
1270 FIXME("(%p)\n", This);
1271 return E_NOTIMPL;
1274 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1276 HTMLDocument *This = HTMLDOC_THIS(iface);
1277 FIXME("(%p)->(%p)\n", This, p);
1278 return E_NOTIMPL;
1281 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1283 HTMLDocument *This = HTMLDOC_THIS(iface);
1284 FIXME("(%p)->(%p)\n", This, String);
1285 return E_NOTIMPL;
1288 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1289 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1291 HTMLDocument *This = HTMLDOC_THIS(iface);
1293 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1295 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1296 return S_OK;
1299 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1300 HTMLDocument_QueryInterface,
1301 HTMLDocument_AddRef,
1302 HTMLDocument_Release,
1303 HTMLDocument_GetTypeInfoCount,
1304 HTMLDocument_GetTypeInfo,
1305 HTMLDocument_GetIDsOfNames,
1306 HTMLDocument_Invoke,
1307 HTMLDocument_get_Script,
1308 HTMLDocument_get_all,
1309 HTMLDocument_get_body,
1310 HTMLDocument_get_activeElement,
1311 HTMLDocument_get_images,
1312 HTMLDocument_get_applets,
1313 HTMLDocument_get_links,
1314 HTMLDocument_get_forms,
1315 HTMLDocument_get_anchors,
1316 HTMLDocument_put_title,
1317 HTMLDocument_get_title,
1318 HTMLDocument_get_scripts,
1319 HTMLDocument_put_designMode,
1320 HTMLDocument_get_designMode,
1321 HTMLDocument_get_selection,
1322 HTMLDocument_get_readyState,
1323 HTMLDocument_get_frames,
1324 HTMLDocument_get_embeds,
1325 HTMLDocument_get_plugins,
1326 HTMLDocument_put_alinkColor,
1327 HTMLDocument_get_alinkColor,
1328 HTMLDocument_put_bgColor,
1329 HTMLDocument_get_bgColor,
1330 HTMLDocument_put_fgColor,
1331 HTMLDocument_get_fgColor,
1332 HTMLDocument_put_linkColor,
1333 HTMLDocument_get_linkColor,
1334 HTMLDocument_put_vlinkColor,
1335 HTMLDocument_get_vlinkColor,
1336 HTMLDocument_get_referrer,
1337 HTMLDocument_get_location,
1338 HTMLDocument_get_lastModified,
1339 HTMLDocument_put_URL,
1340 HTMLDocument_get_URL,
1341 HTMLDocument_put_domain,
1342 HTMLDocument_get_domain,
1343 HTMLDocument_put_cookie,
1344 HTMLDocument_get_cookie,
1345 HTMLDocument_put_expando,
1346 HTMLDocument_get_expando,
1347 HTMLDocument_put_charset,
1348 HTMLDocument_get_charset,
1349 HTMLDocument_put_defaultCharset,
1350 HTMLDocument_get_defaultCharset,
1351 HTMLDocument_get_mimeType,
1352 HTMLDocument_get_fileSize,
1353 HTMLDocument_get_fileCreatedDate,
1354 HTMLDocument_get_fileModifiedDate,
1355 HTMLDocument_get_fileUpdatedDate,
1356 HTMLDocument_get_security,
1357 HTMLDocument_get_protocol,
1358 HTMLDocument_get_nameProp,
1359 HTMLDocument_write,
1360 HTMLDocument_writeln,
1361 HTMLDocument_open,
1362 HTMLDocument_close,
1363 HTMLDocument_clear,
1364 HTMLDocument_queryCommandSupported,
1365 HTMLDocument_queryCommandEnabled,
1366 HTMLDocument_queryCommandState,
1367 HTMLDocument_queryCommandIndeterm,
1368 HTMLDocument_queryCommandText,
1369 HTMLDocument_queryCommandValue,
1370 HTMLDocument_execCommand,
1371 HTMLDocument_execCommandShowHelp,
1372 HTMLDocument_createElement,
1373 HTMLDocument_put_onhelp,
1374 HTMLDocument_get_onhelp,
1375 HTMLDocument_put_onclick,
1376 HTMLDocument_get_onclick,
1377 HTMLDocument_put_ondblclick,
1378 HTMLDocument_get_ondblclick,
1379 HTMLDocument_put_onkeyup,
1380 HTMLDocument_get_onkeyup,
1381 HTMLDocument_put_onkeydown,
1382 HTMLDocument_get_onkeydown,
1383 HTMLDocument_put_onkeypress,
1384 HTMLDocument_get_onkeypress,
1385 HTMLDocument_put_onmouseup,
1386 HTMLDocument_get_onmouseup,
1387 HTMLDocument_put_onmousedown,
1388 HTMLDocument_get_onmousedown,
1389 HTMLDocument_put_onmousemove,
1390 HTMLDocument_get_onmousemove,
1391 HTMLDocument_put_onmouseout,
1392 HTMLDocument_get_onmouseout,
1393 HTMLDocument_put_onmouseover,
1394 HTMLDocument_get_onmouseover,
1395 HTMLDocument_put_onreadystatechange,
1396 HTMLDocument_get_onreadystatechange,
1397 HTMLDocument_put_onafterupdate,
1398 HTMLDocument_get_onafterupdate,
1399 HTMLDocument_put_onrowexit,
1400 HTMLDocument_get_onrowexit,
1401 HTMLDocument_put_onrowenter,
1402 HTMLDocument_get_onrowenter,
1403 HTMLDocument_put_ondragstart,
1404 HTMLDocument_get_ondragstart,
1405 HTMLDocument_put_onselectstart,
1406 HTMLDocument_get_onselectstart,
1407 HTMLDocument_elementFromPoint,
1408 HTMLDocument_get_parentWindow,
1409 HTMLDocument_get_styleSheets,
1410 HTMLDocument_put_onbeforeupdate,
1411 HTMLDocument_get_onbeforeupdate,
1412 HTMLDocument_put_onerrorupdate,
1413 HTMLDocument_get_onerrorupdate,
1414 HTMLDocument_toString,
1415 HTMLDocument_createStyleSheet
1418 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1420 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1422 HTMLDocument *This = SUPPINFO_THIS(iface);
1423 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1426 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1428 HTMLDocument *This = SUPPINFO_THIS(iface);
1429 return IHTMLDocument_AddRef(HTMLDOC(This));
1432 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1434 HTMLDocument *This = SUPPINFO_THIS(iface);
1435 return IHTMLDocument_Release(HTMLDOC(This));
1438 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1440 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1441 return S_FALSE;
1444 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1445 SupportErrorInfo_QueryInterface,
1446 SupportErrorInfo_AddRef,
1447 SupportErrorInfo_Release,
1448 SupportErrorInfo_InterfaceSupportsErrorInfo
1451 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1453 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1455 HTMLDocument *This = DISPEX_THIS(iface);
1457 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1460 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1462 HTMLDocument *This = DISPEX_THIS(iface);
1464 return IHTMLDocument2_AddRef(HTMLDOC(This));
1467 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1469 HTMLDocument *This = DISPEX_THIS(iface);
1471 return IHTMLDocument2_Release(HTMLDOC(This));
1474 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1476 HTMLDocument *This = DISPEX_THIS(iface);
1478 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
1481 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1482 LCID lcid, ITypeInfo **ppTInfo)
1484 HTMLDocument *This = DISPEX_THIS(iface);
1486 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
1489 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1490 LPOLESTR *rgszNames, UINT cNames,
1491 LCID lcid, DISPID *rgDispId)
1493 HTMLDocument *This = DISPEX_THIS(iface);
1495 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
1498 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1499 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1500 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1502 HTMLDocument *This = DISPEX_THIS(iface);
1504 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1505 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1507 switch(dispIdMember) {
1508 case DISPID_READYSTATE:
1509 TRACE("DISPID_READYSTATE\n");
1511 if(!(wFlags & DISPATCH_PROPERTYGET))
1512 return E_INVALIDARG;
1514 V_VT(pVarResult) = VT_I4;
1515 V_I4(pVarResult) = This->doc_obj->readystate;
1516 return S_OK;
1519 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
1520 pVarResult, pExcepInfo, puArgErr);
1523 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1525 HTMLDocument *This = DISPEX_THIS(iface);
1527 return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
1530 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1531 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1533 HTMLDocument *This = DISPEX_THIS(iface);
1535 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1538 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1540 HTMLDocument *This = DISPEX_THIS(iface);
1542 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
1545 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1547 HTMLDocument *This = DISPEX_THIS(iface);
1549 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
1552 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1554 HTMLDocument *This = DISPEX_THIS(iface);
1556 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
1559 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1561 HTMLDocument *This = DISPEX_THIS(iface);
1563 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
1566 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1568 HTMLDocument *This = DISPEX_THIS(iface);
1570 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
1573 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1575 HTMLDocument *This = DISPEX_THIS(iface);
1577 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
1580 #undef DISPEX_THIS
1582 static const IDispatchExVtbl DocDispatchExVtbl = {
1583 DocDispatchEx_QueryInterface,
1584 DocDispatchEx_AddRef,
1585 DocDispatchEx_Release,
1586 DocDispatchEx_GetTypeInfoCount,
1587 DocDispatchEx_GetTypeInfo,
1588 DocDispatchEx_GetIDsOfNames,
1589 DocDispatchEx_Invoke,
1590 DocDispatchEx_GetDispID,
1591 DocDispatchEx_InvokeEx,
1592 DocDispatchEx_DeleteMemberByName,
1593 DocDispatchEx_DeleteMemberByDispID,
1594 DocDispatchEx_GetMemberProperties,
1595 DocDispatchEx_GetMemberName,
1596 DocDispatchEx_GetNextDispID,
1597 DocDispatchEx_GetNameSpaceParent
1600 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
1602 *ppv = NULL;
1604 if(IsEqualGUID(&IID_IUnknown, riid)) {
1605 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
1606 *ppv = HTMLDOC(This);
1607 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1608 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv);
1609 *ppv = DISPATCHEX(This);
1610 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
1611 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv);
1612 *ppv = DISPATCHEX(This);
1613 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
1614 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv);
1615 *ppv = HTMLDOC(This);
1616 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
1617 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppv);
1618 *ppv = HTMLDOC(This);
1619 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
1620 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppv);
1621 *ppv = HTMLDOC3(This);
1622 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
1623 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppv);
1624 *ppv = HTMLDOC4(This);
1625 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
1626 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppv);
1627 *ppv = HTMLDOC5(This);
1628 }else if(IsEqualGUID(&IID_IPersist, riid)) {
1629 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
1630 *ppv = PERSIST(This);
1631 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
1632 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppv);
1633 *ppv = PERSISTMON(This);
1634 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
1635 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppv);
1636 *ppv = PERSISTFILE(This);
1637 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
1638 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppv);
1639 *ppv = MONPROP(This);
1640 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
1641 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppv);
1642 *ppv = OLEOBJ(This);
1643 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
1644 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppv);
1645 *ppv = OLEDOC(This);
1646 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
1647 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppv);
1648 *ppv = DOCVIEW(This);
1649 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
1650 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
1651 *ppv = ACTOBJ(This);
1652 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
1653 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
1654 *ppv = VIEWOBJ(This);
1655 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
1656 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
1657 *ppv = VIEWOBJ2(This);
1658 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
1659 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
1660 *ppv = OLEWIN(This);
1661 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
1662 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
1663 *ppv = INPLACEOBJ(This);
1664 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1665 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppv);
1666 *ppv = INPLACEWIN(This);
1667 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1668 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
1669 *ppv = SERVPROV(This);
1670 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
1671 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppv);
1672 *ppv = CMDTARGET(This);
1673 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
1674 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppv);
1675 *ppv = CONTROL(This);
1676 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
1677 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppv);
1678 *ppv = HLNKTARGET(This);
1679 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1680 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1681 *ppv = CONPTCONT(&This->cp_container);
1682 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
1683 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
1684 *ppv = PERSTRINIT(This);
1685 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
1686 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
1687 *ppv = HTMLDOC(This);
1688 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
1689 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppv);
1690 *ppv = SUPPERRINFO(This);
1691 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
1692 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppv);
1693 *ppv = PERSISTHIST(This);
1694 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
1695 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
1696 *ppv = NULL;
1697 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
1698 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
1699 *ppv = NULL;
1700 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
1701 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
1702 *ppv = NULL;
1703 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
1704 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
1705 *ppv = NULL;
1706 }else {
1707 return FALSE;
1710 if(*ppv)
1711 IUnknown_AddRef((IUnknown*)*ppv);
1712 return TRUE;
1715 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
1717 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1718 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1719 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1721 doc->unk_impl = unk_impl;
1722 doc->dispex = dispex;
1724 HTMLDocument_HTMLDocument3_Init(doc);
1725 HTMLDocument_HTMLDocument5_Init(doc);
1726 HTMLDocument_Persist_Init(doc);
1727 HTMLDocument_OleCmd_Init(doc);
1728 HTMLDocument_OleObj_Init(doc);
1729 HTMLDocument_View_Init(doc);
1730 HTMLDocument_Window_Init(doc);
1731 HTMLDocument_Service_Init(doc);
1732 HTMLDocument_Hlink_Init(doc);
1734 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1735 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
1736 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
1737 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
1740 static void destroy_htmldoc(HTMLDocument *This)
1742 remove_doc_tasks(This);
1744 if(This->event_target)
1745 release_event_target(This->event_target);
1747 ConnectionPointContainer_Destroy(&This->cp_container);
1749 if(This->nsdoc)
1750 nsIDOMHTMLDocument_Release(This->nsdoc);
1753 #define HTMLDOCNODE_NODE_THIS(iface) DEFINE_THIS2(HTMLDocumentNode, node, iface)
1755 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1757 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1759 if(htmldoc_qi(&This->basedoc, riid, ppv))
1760 return *ppv ? S_OK : E_NOINTERFACE;
1762 return HTMLDOMNode_QI(&This->node, riid, ppv);
1765 void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
1767 HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
1769 detach_selection(This);
1770 detach_ranges(This);
1771 release_nodes(This);
1772 destroy_htmldoc(&This->basedoc);
1775 #undef HTMLDOCNODE_NODE_THIS
1777 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
1778 HTMLDocumentNode_QI,
1779 HTMLDocumentNode_destructor
1782 static const tid_t HTMLDocumentNode_iface_tids[] = {
1783 IHTMLDOMNode_tid,
1784 IHTMLDOMNode2_tid,
1785 IHTMLDocument2_tid,
1786 IHTMLDocument3_tid,
1787 IHTMLDocument4_tid,
1788 IHTMLDocument5_tid,
1792 static dispex_static_data_t HTMLDocumentNode_dispex = {
1793 NULL,
1794 DispHTMLDocument_tid,
1795 NULL,
1796 HTMLDocumentNode_iface_tids
1799 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret)
1801 HTMLDocumentNode *doc;
1803 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
1804 if(!doc)
1805 return E_OUTOFMEMORY;
1807 doc->basedoc.doc_node = doc;
1808 doc->basedoc.doc_obj = doc_obj;
1810 init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
1811 init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
1812 doc->ref = 1;
1814 nsIDOMHTMLDocument_AddRef(nsdoc);
1815 doc->basedoc.nsdoc = nsdoc;
1817 doc->basedoc.window = window;
1819 list_init(&doc->selection_list);
1820 list_init(&doc->range_list);
1822 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
1823 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
1825 *ret = doc;
1826 return S_OK;
1829 /**********************************************************
1830 * ICustomDoc implementation
1833 #define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocumentObj, CustomDoc, iface)
1835 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
1837 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1839 if(htmldoc_qi(&This->basedoc, riid, ppv))
1840 return *ppv ? S_OK : E_NOINTERFACE;
1842 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
1843 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
1844 *ppv = CUSTOMDOC(This);
1845 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1846 return *ppv ? S_OK : E_NOINTERFACE;
1847 }else {
1848 FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
1849 *ppv = NULL;
1850 return E_NOINTERFACE;
1853 IUnknown_AddRef((IUnknown*)*ppv);
1854 return S_OK;
1857 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
1859 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1860 ULONG ref = InterlockedIncrement(&This->ref);
1862 TRACE("(%p) ref = %u\n", This, ref);
1864 return ref;
1867 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
1869 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1870 ULONG ref = InterlockedDecrement(&This->ref);
1872 TRACE("(%p) ref = %u\n", This, ref);
1874 if(!ref) {
1875 set_document_bscallback(&This->basedoc, NULL);
1876 set_current_mon(&This->basedoc, NULL);
1877 if(This->basedoc.doc_node) {
1878 This->basedoc.doc_node->basedoc.doc_obj = NULL;
1879 IHTMLDocument2_Release(HTMLDOC(&This->basedoc.doc_node->basedoc));
1881 if(This->basedoc.window) {
1882 This->basedoc.window->doc_obj = NULL;
1883 IHTMLWindow2_Release(HTMLWINDOW2(This->basedoc.window));
1886 if(This->client)
1887 IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL);
1888 if(This->in_place_active)
1889 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(&This->basedoc));
1890 if(This->ipsite)
1891 IOleDocumentView_SetInPlaceSite(DOCVIEW(&This->basedoc), NULL);
1892 if(This->undomgr)
1893 IOleUndoManager_Release(This->undomgr);
1894 if(This->tooltips_hwnd)
1895 DestroyWindow(This->tooltips_hwnd);
1897 if(This->hwnd)
1898 DestroyWindow(This->hwnd);
1899 heap_free(This->mime);
1901 destroy_htmldoc(&This->basedoc);
1902 release_dispex(&This->dispex);
1904 if(This->basedoc.nsdoc)
1905 remove_mutation_observer(This->nscontainer, This->basedoc.nsdoc);
1906 if(This->nscontainer)
1907 NSContainer_Release(This->nscontainer);
1908 heap_free(This);
1911 return ref;
1914 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
1916 HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
1917 FIXME("(%p)->(%p)\n", This, pUIHandler);
1918 return E_NOTIMPL;
1921 #undef CUSTOMDOC_THIS
1923 static const ICustomDocVtbl CustomDocVtbl = {
1924 CustomDoc_QueryInterface,
1925 CustomDoc_AddRef,
1926 CustomDoc_Release,
1927 CustomDoc_SetUIHandler
1930 static const tid_t HTMLDocumentObj_iface_tids[] = {
1931 IHTMLDocument2_tid,
1932 IHTMLDocument3_tid,
1933 IHTMLDocument4_tid,
1934 IHTMLDocument5_tid,
1937 static dispex_static_data_t HTMLDocumentObj_dispex = {
1938 NULL,
1939 DispHTMLDocument_tid,
1940 NULL,
1941 HTMLDocumentObj_iface_tids
1944 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1946 HTMLDocumentObj *doc;
1947 nsIDOMWindow *nswindow = NULL;
1948 HRESULT hres;
1950 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1952 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
1953 if(!doc)
1954 return E_OUTOFMEMORY;
1956 init_dispex(&doc->dispex, (IUnknown*)CUSTOMDOC(doc), &HTMLDocumentObj_dispex);
1957 init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc), DISPATCHEX(&doc->dispex));
1959 doc->lpCustomDocVtbl = &CustomDocVtbl;
1960 doc->ref = 1;
1961 doc->basedoc.doc_obj = doc;
1963 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
1964 htmldoc_release(&doc->basedoc);
1965 if(FAILED(hres))
1966 return hres;
1968 doc->nscontainer = NSContainer_Create(doc, NULL);
1969 list_init(&doc->bindings);
1970 doc->usermode = UNKNOWN_USERMODE;
1971 doc->readystate = READYSTATE_UNINITIALIZED;
1973 if(doc->nscontainer) {
1974 nsresult nsres;
1976 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
1977 if(NS_FAILED(nsres))
1978 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1981 hres = HTMLWindow_Create(doc, nswindow, &doc->basedoc.window);
1982 if(nswindow)
1983 nsIDOMWindow_Release(nswindow);
1984 if(FAILED(hres)) {
1985 IHTMLDocument_Release(HTMLDOC(&doc->basedoc));
1986 return hres;
1989 update_nsdocument(doc);
1990 get_thread_hwnd();
1992 return S_OK;