2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
38 #include "htmlevent.h"
39 #include "pluginhost.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
44 static inline HTMLDocument
*impl_from_IHTMLDocument2(IHTMLDocument2
*iface
)
46 return CONTAINING_RECORD(iface
, HTMLDocument
, IHTMLDocument2_iface
);
49 static HRESULT WINAPI
HTMLDocument_QueryInterface(IHTMLDocument2
*iface
, REFIID riid
, void **ppv
)
51 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
53 return htmldoc_query_interface(This
, riid
, ppv
);
56 static ULONG WINAPI
HTMLDocument_AddRef(IHTMLDocument2
*iface
)
58 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
60 return htmldoc_addref(This
);
63 static ULONG WINAPI
HTMLDocument_Release(IHTMLDocument2
*iface
)
65 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
67 return htmldoc_release(This
);
70 static HRESULT WINAPI
HTMLDocument_GetTypeInfoCount(IHTMLDocument2
*iface
, UINT
*pctinfo
)
72 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
74 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
77 static HRESULT WINAPI
HTMLDocument_GetTypeInfo(IHTMLDocument2
*iface
, UINT iTInfo
,
78 LCID lcid
, ITypeInfo
**ppTInfo
)
80 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
82 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
85 static HRESULT WINAPI
HTMLDocument_GetIDsOfNames(IHTMLDocument2
*iface
, REFIID riid
,
86 LPOLESTR
*rgszNames
, UINT cNames
,
87 LCID lcid
, DISPID
*rgDispId
)
89 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
91 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
95 static HRESULT WINAPI
HTMLDocument_Invoke(IHTMLDocument2
*iface
, DISPID dispIdMember
,
96 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
97 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
99 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
101 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
102 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
105 static HRESULT WINAPI
HTMLDocument_get_Script(IHTMLDocument2
*iface
, IDispatch
**p
)
107 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
109 TRACE("(%p)->(%p)\n", This
, p
);
111 *p
= (IDispatch
*)&This
->window
->base
.IHTMLWindow2_iface
;
112 IDispatch_AddRef(*p
);
116 static HRESULT WINAPI
HTMLDocument_get_all(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
118 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
119 nsIDOMElement
*nselem
= NULL
;
124 TRACE("(%p)->(%p)\n", This
, p
);
126 if(!This
->doc_node
->nsdoc
) {
127 WARN("NULL nsdoc\n");
131 nsres
= nsIDOMHTMLDocument_GetDocumentElement(This
->doc_node
->nsdoc
, &nselem
);
132 if(NS_FAILED(nsres
)) {
133 ERR("GetDocumentElement failed: %08x\n", nsres
);
142 hres
= get_node(This
->doc_node
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
143 nsIDOMElement_Release(nselem
);
147 *p
= create_all_collection(node
, TRUE
);
152 static HRESULT WINAPI
HTMLDocument_get_body(IHTMLDocument2
*iface
, IHTMLElement
**p
)
154 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
155 nsIDOMHTMLElement
*nsbody
= NULL
;
159 TRACE("(%p)->(%p)\n", This
, p
);
161 if(This
->doc_node
->nsdoc
) {
164 nsres
= nsIDOMHTMLDocument_GetBody(This
->doc_node
->nsdoc
, &nsbody
);
165 if(NS_FAILED(nsres
)) {
166 TRACE("Could not get body: %08x\n", nsres
);
176 hres
= get_node(This
->doc_node
, (nsIDOMNode
*)nsbody
, TRUE
, &node
);
177 nsIDOMHTMLElement_Release(nsbody
);
181 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)p
);
186 static HRESULT WINAPI
HTMLDocument_get_activeElement(IHTMLDocument2
*iface
, IHTMLElement
**p
)
188 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
189 nsIDOMElement
*nselem
;
194 TRACE("(%p)->(%p)\n", This
, p
);
196 if(!This
->doc_node
->nsdoc
) {
202 * NOTE: Gecko may return an active element even if the document is not visible.
203 * IE returns NULL in this case.
205 nsres
= nsIDOMHTMLDocument_GetActiveElement(This
->doc_node
->nsdoc
, &nselem
);
206 if(NS_FAILED(nsres
)) {
207 ERR("GetActiveElement failed: %08x\n", nsres
);
211 hres
= get_elem(This
->doc_node
, nselem
, &elem
);
212 nsIDOMElement_Release(nselem
);
216 *p
= &elem
->IHTMLElement_iface
;
220 static HRESULT WINAPI
HTMLDocument_get_images(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
222 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
223 nsIDOMHTMLCollection
*nscoll
= NULL
;
226 TRACE("(%p)->(%p)\n", This
, p
);
233 if(!This
->doc_node
->nsdoc
) {
234 WARN("NULL nsdoc\n");
238 nsres
= nsIDOMHTMLDocument_GetImages(This
->doc_node
->nsdoc
, &nscoll
);
239 if(NS_FAILED(nsres
)) {
240 ERR("GetImages failed: %08x\n", nsres
);
245 *p
= create_collection_from_htmlcol(This
->doc_node
, nscoll
);
246 nsIDOMHTMLCollection_Release(nscoll
);
252 static HRESULT WINAPI
HTMLDocument_get_applets(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
254 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
255 nsIDOMHTMLCollection
*nscoll
= NULL
;
258 TRACE("(%p)->(%p)\n", This
, p
);
265 if(!This
->doc_node
->nsdoc
) {
266 WARN("NULL nsdoc\n");
270 nsres
= nsIDOMHTMLDocument_GetApplets(This
->doc_node
->nsdoc
, &nscoll
);
271 if(NS_FAILED(nsres
)) {
272 ERR("GetApplets failed: %08x\n", nsres
);
277 *p
= create_collection_from_htmlcol(This
->doc_node
, nscoll
);
278 nsIDOMHTMLCollection_Release(nscoll
);
284 static HRESULT WINAPI
HTMLDocument_get_links(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
286 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
287 nsIDOMHTMLCollection
*nscoll
= NULL
;
290 TRACE("(%p)->(%p)\n", This
, p
);
297 if(!This
->doc_node
->nsdoc
) {
298 WARN("NULL nsdoc\n");
302 nsres
= nsIDOMHTMLDocument_GetLinks(This
->doc_node
->nsdoc
, &nscoll
);
303 if(NS_FAILED(nsres
)) {
304 ERR("GetLinks failed: %08x\n", nsres
);
309 *p
= create_collection_from_htmlcol(This
->doc_node
, nscoll
);
310 nsIDOMHTMLCollection_Release(nscoll
);
316 static HRESULT WINAPI
HTMLDocument_get_forms(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
318 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
319 nsIDOMHTMLCollection
*nscoll
= NULL
;
322 TRACE("(%p)->(%p)\n", This
, p
);
329 if(!This
->doc_node
->nsdoc
) {
330 WARN("NULL nsdoc\n");
334 nsres
= nsIDOMHTMLDocument_GetForms(This
->doc_node
->nsdoc
, &nscoll
);
335 if(NS_FAILED(nsres
)) {
336 ERR("GetForms failed: %08x\n", nsres
);
341 *p
= create_collection_from_htmlcol(This
->doc_node
, nscoll
);
342 nsIDOMHTMLCollection_Release(nscoll
);
348 static HRESULT WINAPI
HTMLDocument_get_anchors(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
350 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
351 nsIDOMHTMLCollection
*nscoll
= NULL
;
354 TRACE("(%p)->(%p)\n", This
, p
);
361 if(!This
->doc_node
->nsdoc
) {
362 WARN("NULL nsdoc\n");
366 nsres
= nsIDOMHTMLDocument_GetAnchors(This
->doc_node
->nsdoc
, &nscoll
);
367 if(NS_FAILED(nsres
)) {
368 ERR("GetAnchors failed: %08x\n", nsres
);
373 *p
= create_collection_from_htmlcol(This
->doc_node
, nscoll
);
374 nsIDOMHTMLCollection_Release(nscoll
);
380 static HRESULT WINAPI
HTMLDocument_put_title(IHTMLDocument2
*iface
, BSTR v
)
382 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
386 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
388 if(!This
->doc_node
->nsdoc
) {
389 WARN("NULL nsdoc\n");
393 nsAString_InitDepend(&nsstr
, v
);
394 nsres
= nsIDOMHTMLDocument_SetTitle(This
->doc_node
->nsdoc
, &nsstr
);
395 nsAString_Finish(&nsstr
);
397 ERR("SetTitle failed: %08x\n", nsres
);
402 static HRESULT WINAPI
HTMLDocument_get_title(IHTMLDocument2
*iface
, BSTR
*p
)
404 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
405 const PRUnichar
*ret
;
409 TRACE("(%p)->(%p)\n", This
, p
);
411 if(!This
->doc_node
->nsdoc
) {
412 WARN("NULL nsdoc\n");
417 nsAString_Init(&nsstr
, NULL
);
418 nsres
= nsIDOMHTMLDocument_GetTitle(This
->doc_node
->nsdoc
, &nsstr
);
419 if (NS_SUCCEEDED(nsres
)) {
420 nsAString_GetData(&nsstr
, &ret
);
421 *p
= SysAllocString(ret
);
423 nsAString_Finish(&nsstr
);
425 if(NS_FAILED(nsres
)) {
426 ERR("GetTitle failed: %08x\n", nsres
);
433 static HRESULT WINAPI
HTMLDocument_get_scripts(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
435 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
436 nsIDOMHTMLCollection
*nscoll
= NULL
;
439 TRACE("(%p)->(%p)\n", This
, p
);
446 if(!This
->doc_node
->nsdoc
) {
447 WARN("NULL nsdoc\n");
451 nsres
= nsIDOMHTMLDocument_GetScripts(This
->doc_node
->nsdoc
, &nscoll
);
452 if(NS_FAILED(nsres
)) {
453 ERR("GetImages failed: %08x\n", nsres
);
458 *p
= create_collection_from_htmlcol(This
->doc_node
, nscoll
);
459 nsIDOMHTMLCollection_Release(nscoll
);
465 static HRESULT WINAPI
HTMLDocument_put_designMode(IHTMLDocument2
*iface
, BSTR v
)
467 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
470 static const WCHAR onW
[] = {'o','n',0};
472 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
474 if(strcmpiW(v
, onW
)) {
475 FIXME("Unsupported arg %s\n", debugstr_w(v
));
479 hres
= setup_edit_mode(This
->doc_obj
);
483 call_property_onchanged(&This
->cp_container
, DISPID_IHTMLDOCUMENT2_DESIGNMODE
);
487 static HRESULT WINAPI
HTMLDocument_get_designMode(IHTMLDocument2
*iface
, BSTR
*p
)
489 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
490 static const WCHAR szOff
[] = {'O','f','f',0};
491 FIXME("(%p)->(%p) always returning Off\n", This
, p
);
496 *p
= SysAllocString(szOff
);
501 static HRESULT WINAPI
HTMLDocument_get_selection(IHTMLDocument2
*iface
, IHTMLSelectionObject
**p
)
503 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
504 nsISelection
*nsselection
;
507 TRACE("(%p)->(%p)\n", This
, p
);
509 nsres
= nsIDOMWindow_GetSelection(This
->window
->nswindow
, &nsselection
);
510 if(NS_FAILED(nsres
)) {
511 ERR("GetSelection failed: %08x\n", nsres
);
515 return HTMLSelectionObject_Create(This
->doc_node
, nsselection
, p
);
518 static HRESULT WINAPI
HTMLDocument_get_readyState(IHTMLDocument2
*iface
, BSTR
*p
)
520 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
522 static const WCHAR wszUninitialized
[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
523 static const WCHAR wszLoading
[] = {'l','o','a','d','i','n','g',0};
524 static const WCHAR wszLoaded
[] = {'l','o','a','d','e','d',0};
525 static const WCHAR wszInteractive
[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
526 static const WCHAR wszComplete
[] = {'c','o','m','p','l','e','t','e',0};
528 static const LPCWSTR readystate_str
[] = {
536 TRACE("(%p)->(%p)\n", iface
, p
);
541 *p
= SysAllocString(readystate_str
[This
->window
->readystate
]);
545 static HRESULT WINAPI
HTMLDocument_get_frames(IHTMLDocument2
*iface
, IHTMLFramesCollection2
**p
)
547 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
549 TRACE("(%p)->(%p)\n", This
, p
);
551 return IHTMLWindow2_get_frames(&This
->window
->base
.IHTMLWindow2_iface
, p
);
554 static HRESULT WINAPI
HTMLDocument_get_embeds(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
556 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
557 FIXME("(%p)->(%p)\n", This
, p
);
561 static HRESULT WINAPI
HTMLDocument_get_plugins(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
563 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
564 FIXME("(%p)->(%p)\n", This
, p
);
568 static HRESULT WINAPI
HTMLDocument_put_alinkColor(IHTMLDocument2
*iface
, VARIANT v
)
570 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
571 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
575 static HRESULT WINAPI
HTMLDocument_get_alinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
577 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
578 FIXME("(%p)->(%p)\n", This
, p
);
582 static HRESULT WINAPI
HTMLDocument_put_bgColor(IHTMLDocument2
*iface
, VARIANT v
)
584 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
585 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
589 static HRESULT WINAPI
HTMLDocument_get_bgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
591 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
592 FIXME("(%p)->(%p)\n", This
, p
);
596 static HRESULT WINAPI
HTMLDocument_put_fgColor(IHTMLDocument2
*iface
, VARIANT v
)
598 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
599 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
603 static HRESULT WINAPI
HTMLDocument_get_fgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
605 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
606 FIXME("(%p)->(%p)\n", This
, p
);
610 static HRESULT WINAPI
HTMLDocument_put_linkColor(IHTMLDocument2
*iface
, VARIANT v
)
612 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
613 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
617 static HRESULT WINAPI
HTMLDocument_get_linkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
619 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
620 FIXME("(%p)->(%p)\n", This
, p
);
624 static HRESULT WINAPI
HTMLDocument_put_vlinkColor(IHTMLDocument2
*iface
, VARIANT v
)
626 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
627 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
631 static HRESULT WINAPI
HTMLDocument_get_vlinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
633 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
634 FIXME("(%p)->(%p)\n", This
, p
);
638 static HRESULT WINAPI
HTMLDocument_get_referrer(IHTMLDocument2
*iface
, BSTR
*p
)
640 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
642 FIXME("(%p)->(%p)\n", This
, p
);
648 static HRESULT WINAPI
HTMLDocument_get_location(IHTMLDocument2
*iface
, IHTMLLocation
**p
)
650 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
652 TRACE("(%p)->(%p)\n", This
, p
);
654 if(!This
->doc_node
->nsdoc
) {
655 WARN("NULL nsdoc\n");
659 return IHTMLWindow2_get_location(&This
->window
->base
.IHTMLWindow2_iface
, p
);
662 static HRESULT WINAPI
HTMLDocument_get_lastModified(IHTMLDocument2
*iface
, BSTR
*p
)
664 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
665 FIXME("(%p)->(%p)\n", This
, p
);
669 static HRESULT WINAPI
HTMLDocument_put_URL(IHTMLDocument2
*iface
, BSTR v
)
671 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
673 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
676 FIXME("No window available\n");
680 return navigate_url(This
->window
, v
, This
->window
->uri
, BINDING_NAVIGATED
);
683 static HRESULT WINAPI
HTMLDocument_get_URL(IHTMLDocument2
*iface
, BSTR
*p
)
685 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
687 static const WCHAR about_blank_url
[] =
688 {'a','b','o','u','t',':','b','l','a','n','k',0};
690 TRACE("(%p)->(%p)\n", iface
, p
);
692 *p
= SysAllocString(This
->window
->url
? This
->window
->url
: about_blank_url
);
693 return *p
? S_OK
: E_OUTOFMEMORY
;
696 static HRESULT WINAPI
HTMLDocument_put_domain(IHTMLDocument2
*iface
, BSTR v
)
698 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
699 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
703 static HRESULT WINAPI
HTMLDocument_get_domain(IHTMLDocument2
*iface
, BSTR
*p
)
705 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
708 TRACE("(%p)->(%p)\n", This
, p
);
710 if(!This
->window
|| !This
->window
->uri
) {
711 FIXME("No current URI\n");
715 hres
= IUri_GetHost(This
->window
->uri
, p
);
716 return FAILED(hres
) ? hres
: S_OK
;
719 static HRESULT WINAPI
HTMLDocument_put_cookie(IHTMLDocument2
*iface
, BSTR v
)
721 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
724 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
726 bret
= InternetSetCookieExW(This
->window
->url
, NULL
, v
, 0, 0);
728 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
729 return HRESULT_FROM_WIN32(GetLastError());
735 static HRESULT WINAPI
HTMLDocument_get_cookie(IHTMLDocument2
*iface
, BSTR
*p
)
737 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
741 TRACE("(%p)->(%p)\n", This
, p
);
744 bret
= InternetGetCookieExW(This
->window
->url
, NULL
, NULL
, &size
, 0, NULL
);
746 switch(GetLastError()) {
747 case ERROR_INSUFFICIENT_BUFFER
:
749 case ERROR_NO_MORE_ITEMS
:
753 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
754 return HRESULT_FROM_WIN32(GetLastError());
763 *p
= SysAllocStringLen(NULL
, size
/sizeof(WCHAR
)-1);
765 return E_OUTOFMEMORY
;
767 bret
= InternetGetCookieExW(This
->window
->url
, NULL
, *p
, &size
, 0, NULL
);
769 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
776 static HRESULT WINAPI
HTMLDocument_put_expando(IHTMLDocument2
*iface
, VARIANT_BOOL v
)
778 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
779 FIXME("(%p)->(%x)\n", This
, v
);
783 static HRESULT WINAPI
HTMLDocument_get_expando(IHTMLDocument2
*iface
, VARIANT_BOOL
*p
)
785 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
786 FIXME("(%p)->(%p)\n", This
, p
);
790 static HRESULT WINAPI
HTMLDocument_put_charset(IHTMLDocument2
*iface
, BSTR v
)
792 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
793 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
797 static HRESULT WINAPI
HTMLDocument_get_charset(IHTMLDocument2
*iface
, BSTR
*p
)
799 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
800 nsAString charset_str
;
803 TRACE("(%p)->(%p)\n", This
, p
);
805 if(!This
->doc_node
->nsdoc
) {
806 FIXME("NULL nsdoc\n");
810 nsAString_Init(&charset_str
, NULL
);
811 nsres
= nsIDOMHTMLDocument_GetCharacterSet(This
->doc_node
->nsdoc
, &charset_str
);
812 return return_nsstr(nsres
, &charset_str
, p
);
815 static HRESULT WINAPI
HTMLDocument_put_defaultCharset(IHTMLDocument2
*iface
, BSTR v
)
817 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
818 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
822 static HRESULT WINAPI
HTMLDocument_get_defaultCharset(IHTMLDocument2
*iface
, BSTR
*p
)
824 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
825 FIXME("(%p)->(%p)\n", This
, p
);
829 static HRESULT WINAPI
HTMLDocument_get_mimeType(IHTMLDocument2
*iface
, BSTR
*p
)
831 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
832 FIXME("(%p)->(%p)\n", This
, p
);
836 static HRESULT WINAPI
HTMLDocument_get_fileSize(IHTMLDocument2
*iface
, BSTR
*p
)
838 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
839 FIXME("(%p)->(%p)\n", This
, p
);
843 static HRESULT WINAPI
HTMLDocument_get_fileCreatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
845 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
846 FIXME("(%p)->(%p)\n", This
, p
);
850 static HRESULT WINAPI
HTMLDocument_get_fileModifiedDate(IHTMLDocument2
*iface
, BSTR
*p
)
852 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
853 FIXME("(%p)->(%p)\n", This
, p
);
857 static HRESULT WINAPI
HTMLDocument_get_fileUpdatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
859 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
860 FIXME("(%p)->(%p)\n", This
, p
);
864 static HRESULT WINAPI
HTMLDocument_get_security(IHTMLDocument2
*iface
, BSTR
*p
)
866 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
867 FIXME("(%p)->(%p)\n", This
, p
);
871 static HRESULT WINAPI
HTMLDocument_get_protocol(IHTMLDocument2
*iface
, BSTR
*p
)
873 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
874 FIXME("(%p)->(%p)\n", This
, p
);
878 static HRESULT WINAPI
HTMLDocument_get_nameProp(IHTMLDocument2
*iface
, BSTR
*p
)
880 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
881 FIXME("(%p)->(%p)\n", This
, p
);
885 static HRESULT
document_write(HTMLDocument
*This
, SAFEARRAY
*psarray
, BOOL ln
)
894 if(!This
->doc_node
->nsdoc
) {
895 WARN("NULL nsdoc\n");
902 if(psarray
->cDims
!= 1) {
903 FIXME("cDims=%d\n", psarray
->cDims
);
907 hres
= SafeArrayAccessData(psarray
, (void**)&var
);
909 WARN("SafeArrayAccessData failed: %08x\n", hres
);
913 V_VT(&tmp
) = VT_EMPTY
;
915 jsctx
= get_context_from_document(This
->doc_node
->nsdoc
);
916 argc
= psarray
->rgsabound
[0].cElements
;
917 for(i
=0; i
< argc
; i
++) {
918 if(V_VT(var
+i
) == VT_BSTR
) {
919 nsAString_InitDepend(&nsstr
, V_BSTR(var
+i
));
921 hres
= VariantChangeTypeEx(&tmp
, var
+i
, MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
), 0, VT_BSTR
);
923 WARN("Could not convert %s to string\n", debugstr_variant(var
+i
));
926 nsAString_InitDepend(&nsstr
, V_BSTR(&tmp
));
929 if(!ln
|| i
!= argc
-1)
930 nsres
= nsIDOMHTMLDocument_Write(This
->doc_node
->nsdoc
, &nsstr
, jsctx
);
932 nsres
= nsIDOMHTMLDocument_Writeln(This
->doc_node
->nsdoc
, &nsstr
, jsctx
);
933 nsAString_Finish(&nsstr
);
934 if(V_VT(var
+i
) != VT_BSTR
)
936 if(NS_FAILED(nsres
)) {
937 ERR("Write failed: %08x\n", nsres
);
943 SafeArrayUnaccessData(psarray
);
948 static HRESULT WINAPI
HTMLDocument_write(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
950 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
952 TRACE("(%p)->(%p)\n", iface
, psarray
);
954 return document_write(This
, psarray
, FALSE
);
957 static HRESULT WINAPI
HTMLDocument_writeln(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
959 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
961 TRACE("(%p)->(%p)\n", This
, psarray
);
963 return document_write(This
, psarray
, TRUE
);
966 static HRESULT WINAPI
HTMLDocument_open(IHTMLDocument2
*iface
, BSTR url
, VARIANT name
,
967 VARIANT features
, VARIANT replace
, IDispatch
**pomWindowResult
)
969 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
973 static const WCHAR text_htmlW
[] = {'t','e','x','t','/','h','t','m','l',0};
975 TRACE("(%p)->(%s %s %s %s %p)\n", This
, debugstr_w(url
), debugstr_variant(&name
),
976 debugstr_variant(&features
), debugstr_variant(&replace
), pomWindowResult
);
978 if(!This
->doc_node
->nsdoc
) {
983 if(!url
|| strcmpW(url
, text_htmlW
) || V_VT(&name
) != VT_ERROR
984 || V_VT(&features
) != VT_ERROR
|| V_VT(&replace
) != VT_ERROR
)
985 FIXME("unsupported args\n");
987 nsres
= nsIDOMHTMLDocument_Open(This
->doc_node
->nsdoc
, NULL
, NULL
, NULL
,
988 get_context_from_document(This
->doc_node
->nsdoc
), 0, &tmp
);
989 if(NS_FAILED(nsres
)) {
990 ERR("Open failed: %08x\n", nsres
);
995 nsISupports_Release(tmp
);
997 *pomWindowResult
= (IDispatch
*)&This
->window
->base
.IHTMLWindow2_iface
;
998 IHTMLWindow2_AddRef(&This
->window
->base
.IHTMLWindow2_iface
);
1002 static HRESULT WINAPI
HTMLDocument_close(IHTMLDocument2
*iface
)
1004 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1007 TRACE("(%p)\n", This
);
1009 if(!This
->doc_node
->nsdoc
) {
1014 nsres
= nsIDOMHTMLDocument_Close(This
->doc_node
->nsdoc
);
1015 if(NS_FAILED(nsres
)) {
1016 ERR("Close failed: %08x\n", nsres
);
1023 static HRESULT WINAPI
HTMLDocument_clear(IHTMLDocument2
*iface
)
1025 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1028 TRACE("(%p)\n", This
);
1030 nsres
= nsIDOMHTMLDocument_Clear(This
->doc_node
->nsdoc
);
1031 if(NS_FAILED(nsres
)) {
1032 ERR("Clear failed: %08x\n", nsres
);
1039 static HRESULT WINAPI
HTMLDocument_queryCommandSupported(IHTMLDocument2
*iface
, BSTR cmdID
,
1040 VARIANT_BOOL
*pfRet
)
1042 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1043 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1047 static HRESULT WINAPI
HTMLDocument_queryCommandEnabled(IHTMLDocument2
*iface
, BSTR cmdID
,
1048 VARIANT_BOOL
*pfRet
)
1050 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1051 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1055 static HRESULT WINAPI
HTMLDocument_queryCommandState(IHTMLDocument2
*iface
, BSTR cmdID
,
1056 VARIANT_BOOL
*pfRet
)
1058 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1059 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1063 static HRESULT WINAPI
HTMLDocument_queryCommandIndeterm(IHTMLDocument2
*iface
, BSTR cmdID
,
1064 VARIANT_BOOL
*pfRet
)
1066 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1067 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1071 static HRESULT WINAPI
HTMLDocument_queryCommandText(IHTMLDocument2
*iface
, BSTR cmdID
,
1074 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1075 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1079 static HRESULT WINAPI
HTMLDocument_queryCommandValue(IHTMLDocument2
*iface
, BSTR cmdID
,
1082 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1083 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1087 static HRESULT WINAPI
HTMLDocument_execCommand(IHTMLDocument2
*iface
, BSTR cmdID
,
1088 VARIANT_BOOL showUI
, VARIANT value
, VARIANT_BOOL
*pfRet
)
1090 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1091 FIXME("(%p)->(%s %x %s %p)\n", This
, debugstr_w(cmdID
), showUI
, debugstr_variant(&value
), pfRet
);
1095 static HRESULT WINAPI
HTMLDocument_execCommandShowHelp(IHTMLDocument2
*iface
, BSTR cmdID
,
1096 VARIANT_BOOL
*pfRet
)
1098 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1099 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1103 static HRESULT WINAPI
HTMLDocument_createElement(IHTMLDocument2
*iface
, BSTR eTag
,
1104 IHTMLElement
**newElem
)
1106 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1110 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(eTag
), newElem
);
1112 hres
= create_element(This
->doc_node
, eTag
, &elem
);
1116 *newElem
= &elem
->IHTMLElement_iface
;
1120 static HRESULT WINAPI
HTMLDocument_put_onhelp(IHTMLDocument2
*iface
, VARIANT v
)
1122 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1123 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1127 static HRESULT WINAPI
HTMLDocument_get_onhelp(IHTMLDocument2
*iface
, VARIANT
*p
)
1129 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1130 FIXME("(%p)->(%p)\n", This
, p
);
1134 static HRESULT WINAPI
HTMLDocument_put_onclick(IHTMLDocument2
*iface
, VARIANT v
)
1136 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1138 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1140 return set_doc_event(This
, EVENTID_CLICK
, &v
);
1143 static HRESULT WINAPI
HTMLDocument_get_onclick(IHTMLDocument2
*iface
, VARIANT
*p
)
1145 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1147 TRACE("(%p)->(%p)\n", This
, p
);
1149 return get_doc_event(This
, EVENTID_CLICK
, p
);
1152 static HRESULT WINAPI
HTMLDocument_put_ondblclick(IHTMLDocument2
*iface
, VARIANT v
)
1154 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1155 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1159 static HRESULT WINAPI
HTMLDocument_get_ondblclick(IHTMLDocument2
*iface
, VARIANT
*p
)
1161 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1162 FIXME("(%p)->(%p)\n", This
, p
);
1166 static HRESULT WINAPI
HTMLDocument_put_onkeyup(IHTMLDocument2
*iface
, VARIANT v
)
1168 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1170 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1172 return set_doc_event(This
, EVENTID_KEYUP
, &v
);
1175 static HRESULT WINAPI
HTMLDocument_get_onkeyup(IHTMLDocument2
*iface
, VARIANT
*p
)
1177 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1179 TRACE("(%p)->(%p)\n", This
, p
);
1181 return get_doc_event(This
, EVENTID_KEYUP
, p
);
1184 static HRESULT WINAPI
HTMLDocument_put_onkeydown(IHTMLDocument2
*iface
, VARIANT v
)
1186 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1188 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1190 return set_doc_event(This
, EVENTID_KEYDOWN
, &v
);
1193 static HRESULT WINAPI
HTMLDocument_get_onkeydown(IHTMLDocument2
*iface
, VARIANT
*p
)
1195 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1197 TRACE("(%p)->(%p)\n", This
, p
);
1199 return get_doc_event(This
, EVENTID_KEYDOWN
, p
);
1202 static HRESULT WINAPI
HTMLDocument_put_onkeypress(IHTMLDocument2
*iface
, VARIANT v
)
1204 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1206 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1208 return set_doc_event(This
, EVENTID_KEYPRESS
, &v
);
1211 static HRESULT WINAPI
HTMLDocument_get_onkeypress(IHTMLDocument2
*iface
, VARIANT
*p
)
1213 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1215 TRACE("(%p)->(%p)\n", This
, p
);
1217 return get_doc_event(This
, EVENTID_KEYPRESS
, p
);
1220 static HRESULT WINAPI
HTMLDocument_put_onmouseup(IHTMLDocument2
*iface
, VARIANT v
)
1222 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1224 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1226 return set_doc_event(This
, EVENTID_MOUSEUP
, &v
);
1229 static HRESULT WINAPI
HTMLDocument_get_onmouseup(IHTMLDocument2
*iface
, VARIANT
*p
)
1231 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1233 TRACE("(%p)->(%p)\n", This
, p
);
1235 return get_doc_event(This
, EVENTID_MOUSEUP
, p
);
1238 static HRESULT WINAPI
HTMLDocument_put_onmousedown(IHTMLDocument2
*iface
, VARIANT v
)
1240 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1242 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1244 return set_doc_event(This
, EVENTID_MOUSEDOWN
, &v
);
1247 static HRESULT WINAPI
HTMLDocument_get_onmousedown(IHTMLDocument2
*iface
, VARIANT
*p
)
1249 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1251 TRACE("(%p)->(%p)\n", This
, p
);
1253 return get_doc_event(This
, EVENTID_MOUSEDOWN
, p
);
1256 static HRESULT WINAPI
HTMLDocument_put_onmousemove(IHTMLDocument2
*iface
, VARIANT v
)
1258 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1260 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1262 return set_doc_event(This
, EVENTID_MOUSEMOVE
, &v
);
1265 static HRESULT WINAPI
HTMLDocument_get_onmousemove(IHTMLDocument2
*iface
, VARIANT
*p
)
1267 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1269 TRACE("(%p)->(%p)\n", This
, p
);
1271 return get_doc_event(This
, EVENTID_MOUSEMOVE
, p
);
1274 static HRESULT WINAPI
HTMLDocument_put_onmouseout(IHTMLDocument2
*iface
, VARIANT v
)
1276 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1278 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1280 return set_doc_event(This
, EVENTID_MOUSEOUT
, &v
);
1283 static HRESULT WINAPI
HTMLDocument_get_onmouseout(IHTMLDocument2
*iface
, VARIANT
*p
)
1285 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1287 TRACE("(%p)->(%p)\n", This
, p
);
1289 return get_doc_event(This
, EVENTID_MOUSEOUT
, p
);
1292 static HRESULT WINAPI
HTMLDocument_put_onmouseover(IHTMLDocument2
*iface
, VARIANT v
)
1294 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1296 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1298 return set_doc_event(This
, EVENTID_MOUSEOVER
, &v
);
1301 static HRESULT WINAPI
HTMLDocument_get_onmouseover(IHTMLDocument2
*iface
, VARIANT
*p
)
1303 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1305 TRACE("(%p)->(%p)\n", This
, p
);
1307 return get_doc_event(This
, EVENTID_MOUSEOVER
, p
);
1310 static HRESULT WINAPI
HTMLDocument_put_onreadystatechange(IHTMLDocument2
*iface
, VARIANT v
)
1312 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1314 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1316 return set_doc_event(This
, EVENTID_READYSTATECHANGE
, &v
);
1319 static HRESULT WINAPI
HTMLDocument_get_onreadystatechange(IHTMLDocument2
*iface
, VARIANT
*p
)
1321 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1323 TRACE("(%p)->(%p)\n", This
, p
);
1325 return get_doc_event(This
, EVENTID_READYSTATECHANGE
, p
);
1328 static HRESULT WINAPI
HTMLDocument_put_onafterupdate(IHTMLDocument2
*iface
, VARIANT v
)
1330 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1331 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1335 static HRESULT WINAPI
HTMLDocument_get_onafterupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1337 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1338 FIXME("(%p)->(%p)\n", This
, p
);
1342 static HRESULT WINAPI
HTMLDocument_put_onrowexit(IHTMLDocument2
*iface
, VARIANT v
)
1344 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1345 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1349 static HRESULT WINAPI
HTMLDocument_get_onrowexit(IHTMLDocument2
*iface
, VARIANT
*p
)
1351 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1352 FIXME("(%p)->(%p)\n", This
, p
);
1356 static HRESULT WINAPI
HTMLDocument_put_onrowenter(IHTMLDocument2
*iface
, VARIANT v
)
1358 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1359 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1363 static HRESULT WINAPI
HTMLDocument_get_onrowenter(IHTMLDocument2
*iface
, VARIANT
*p
)
1365 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1366 FIXME("(%p)->(%p)\n", This
, p
);
1370 static HRESULT WINAPI
HTMLDocument_put_ondragstart(IHTMLDocument2
*iface
, VARIANT v
)
1372 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1374 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1376 return set_doc_event(This
, EVENTID_DRAGSTART
, &v
);
1379 static HRESULT WINAPI
HTMLDocument_get_ondragstart(IHTMLDocument2
*iface
, VARIANT
*p
)
1381 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1383 TRACE("(%p)->(%p)\n", This
, p
);
1385 return get_doc_event(This
, EVENTID_DRAGSTART
, p
);
1388 static HRESULT WINAPI
HTMLDocument_put_onselectstart(IHTMLDocument2
*iface
, VARIANT v
)
1390 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1392 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1394 return set_doc_event(This
, EVENTID_SELECTSTART
, &v
);
1397 static HRESULT WINAPI
HTMLDocument_get_onselectstart(IHTMLDocument2
*iface
, VARIANT
*p
)
1399 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1401 TRACE("(%p)->(%p)\n", This
, p
);
1403 return get_doc_event(This
, EVENTID_SELECTSTART
, p
);
1406 static HRESULT WINAPI
HTMLDocument_elementFromPoint(IHTMLDocument2
*iface
, LONG x
, LONG y
,
1407 IHTMLElement
**elementHit
)
1409 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1410 nsIDOMElement
*nselem
;
1415 TRACE("(%p)->(%d %d %p)\n", This
, x
, y
, elementHit
);
1417 nsres
= nsIDOMHTMLDocument_ElementFromPoint(This
->doc_node
->nsdoc
, x
, y
, &nselem
);
1418 if(NS_FAILED(nsres
)) {
1419 ERR("ElementFromPoint failed: %08x\n", nsres
);
1428 hres
= get_node(This
->doc_node
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
1429 nsIDOMElement_Release(nselem
);
1433 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)elementHit
);
1438 static HRESULT WINAPI
HTMLDocument_get_parentWindow(IHTMLDocument2
*iface
, IHTMLWindow2
**p
)
1440 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1442 TRACE("(%p)->(%p)\n", This
, p
);
1444 *p
= &This
->window
->base
.IHTMLWindow2_iface
;
1445 IHTMLWindow2_AddRef(*p
);
1449 static HRESULT WINAPI
HTMLDocument_get_styleSheets(IHTMLDocument2
*iface
,
1450 IHTMLStyleSheetsCollection
**p
)
1452 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1453 nsIDOMStyleSheetList
*nsstylelist
;
1456 TRACE("(%p)->(%p)\n", This
, p
);
1460 if(!This
->doc_node
->nsdoc
) {
1461 WARN("NULL nsdoc\n");
1462 return E_UNEXPECTED
;
1465 nsres
= nsIDOMHTMLDocument_GetStyleSheets(This
->doc_node
->nsdoc
, &nsstylelist
);
1466 if(NS_FAILED(nsres
)) {
1467 ERR("GetStyleSheets failed: %08x\n", nsres
);
1471 *p
= HTMLStyleSheetsCollection_Create(nsstylelist
);
1472 nsIDOMStyleSheetList_Release(nsstylelist
);
1477 static HRESULT WINAPI
HTMLDocument_put_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT v
)
1479 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1480 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1484 static HRESULT WINAPI
HTMLDocument_get_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1486 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1487 FIXME("(%p)->(%p)\n", This
, p
);
1491 static HRESULT WINAPI
HTMLDocument_put_onerrorupdate(IHTMLDocument2
*iface
, VARIANT v
)
1493 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1494 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1498 static HRESULT WINAPI
HTMLDocument_get_onerrorupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1500 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1501 FIXME("(%p)->(%p)\n", This
, p
);
1505 static HRESULT WINAPI
HTMLDocument_toString(IHTMLDocument2
*iface
, BSTR
*String
)
1507 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1508 FIXME("(%p)->(%p)\n", This
, String
);
1512 static HRESULT WINAPI
HTMLDocument_createStyleSheet(IHTMLDocument2
*iface
, BSTR bstrHref
,
1513 LONG lIndex
, IHTMLStyleSheet
**ppnewStyleSheet
)
1515 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1516 nsIDOMHTMLHeadElement
*head_elem
;
1517 IHTMLStyleElement
*style_elem
;
1522 static const WCHAR styleW
[] = {'s','t','y','l','e',0};
1524 TRACE("(%p)->(%s %d %p)\n", This
, debugstr_w(bstrHref
), lIndex
, ppnewStyleSheet
);
1526 if(!This
->doc_node
->nsdoc
) {
1527 FIXME("not a real doc object\n");
1532 FIXME("Unsupported lIndex %d\n", lIndex
);
1535 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref
));
1536 *ppnewStyleSheet
= HTMLStyleSheet_Create(NULL
);
1540 hres
= create_element(This
->doc_node
, styleW
, &elem
);
1544 nsres
= nsIDOMHTMLDocument_GetHead(This
->doc_node
->nsdoc
, &head_elem
);
1545 if(NS_SUCCEEDED(nsres
)) {
1546 nsIDOMNode
*tmp_node
;
1548 nsres
= nsIDOMHTMLHeadElement_AppendChild(head_elem
, (nsIDOMNode
*)elem
->nselem
, &tmp_node
);
1549 nsIDOMHTMLHeadElement_Release(head_elem
);
1550 if(NS_SUCCEEDED(nsres
) && tmp_node
)
1551 nsIDOMNode_Release(tmp_node
);
1553 if(NS_FAILED(nsres
)) {
1554 IHTMLElement_Release(&elem
->IHTMLElement_iface
);
1558 hres
= IHTMLElement_QueryInterface(&elem
->IHTMLElement_iface
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
1559 assert(hres
== S_OK
);
1560 IHTMLElement_Release(&elem
->IHTMLElement_iface
);
1562 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, ppnewStyleSheet
);
1563 IHTMLStyleElement_Release(style_elem
);
1567 static const IHTMLDocument2Vtbl HTMLDocumentVtbl
= {
1568 HTMLDocument_QueryInterface
,
1569 HTMLDocument_AddRef
,
1570 HTMLDocument_Release
,
1571 HTMLDocument_GetTypeInfoCount
,
1572 HTMLDocument_GetTypeInfo
,
1573 HTMLDocument_GetIDsOfNames
,
1574 HTMLDocument_Invoke
,
1575 HTMLDocument_get_Script
,
1576 HTMLDocument_get_all
,
1577 HTMLDocument_get_body
,
1578 HTMLDocument_get_activeElement
,
1579 HTMLDocument_get_images
,
1580 HTMLDocument_get_applets
,
1581 HTMLDocument_get_links
,
1582 HTMLDocument_get_forms
,
1583 HTMLDocument_get_anchors
,
1584 HTMLDocument_put_title
,
1585 HTMLDocument_get_title
,
1586 HTMLDocument_get_scripts
,
1587 HTMLDocument_put_designMode
,
1588 HTMLDocument_get_designMode
,
1589 HTMLDocument_get_selection
,
1590 HTMLDocument_get_readyState
,
1591 HTMLDocument_get_frames
,
1592 HTMLDocument_get_embeds
,
1593 HTMLDocument_get_plugins
,
1594 HTMLDocument_put_alinkColor
,
1595 HTMLDocument_get_alinkColor
,
1596 HTMLDocument_put_bgColor
,
1597 HTMLDocument_get_bgColor
,
1598 HTMLDocument_put_fgColor
,
1599 HTMLDocument_get_fgColor
,
1600 HTMLDocument_put_linkColor
,
1601 HTMLDocument_get_linkColor
,
1602 HTMLDocument_put_vlinkColor
,
1603 HTMLDocument_get_vlinkColor
,
1604 HTMLDocument_get_referrer
,
1605 HTMLDocument_get_location
,
1606 HTMLDocument_get_lastModified
,
1607 HTMLDocument_put_URL
,
1608 HTMLDocument_get_URL
,
1609 HTMLDocument_put_domain
,
1610 HTMLDocument_get_domain
,
1611 HTMLDocument_put_cookie
,
1612 HTMLDocument_get_cookie
,
1613 HTMLDocument_put_expando
,
1614 HTMLDocument_get_expando
,
1615 HTMLDocument_put_charset
,
1616 HTMLDocument_get_charset
,
1617 HTMLDocument_put_defaultCharset
,
1618 HTMLDocument_get_defaultCharset
,
1619 HTMLDocument_get_mimeType
,
1620 HTMLDocument_get_fileSize
,
1621 HTMLDocument_get_fileCreatedDate
,
1622 HTMLDocument_get_fileModifiedDate
,
1623 HTMLDocument_get_fileUpdatedDate
,
1624 HTMLDocument_get_security
,
1625 HTMLDocument_get_protocol
,
1626 HTMLDocument_get_nameProp
,
1628 HTMLDocument_writeln
,
1632 HTMLDocument_queryCommandSupported
,
1633 HTMLDocument_queryCommandEnabled
,
1634 HTMLDocument_queryCommandState
,
1635 HTMLDocument_queryCommandIndeterm
,
1636 HTMLDocument_queryCommandText
,
1637 HTMLDocument_queryCommandValue
,
1638 HTMLDocument_execCommand
,
1639 HTMLDocument_execCommandShowHelp
,
1640 HTMLDocument_createElement
,
1641 HTMLDocument_put_onhelp
,
1642 HTMLDocument_get_onhelp
,
1643 HTMLDocument_put_onclick
,
1644 HTMLDocument_get_onclick
,
1645 HTMLDocument_put_ondblclick
,
1646 HTMLDocument_get_ondblclick
,
1647 HTMLDocument_put_onkeyup
,
1648 HTMLDocument_get_onkeyup
,
1649 HTMLDocument_put_onkeydown
,
1650 HTMLDocument_get_onkeydown
,
1651 HTMLDocument_put_onkeypress
,
1652 HTMLDocument_get_onkeypress
,
1653 HTMLDocument_put_onmouseup
,
1654 HTMLDocument_get_onmouseup
,
1655 HTMLDocument_put_onmousedown
,
1656 HTMLDocument_get_onmousedown
,
1657 HTMLDocument_put_onmousemove
,
1658 HTMLDocument_get_onmousemove
,
1659 HTMLDocument_put_onmouseout
,
1660 HTMLDocument_get_onmouseout
,
1661 HTMLDocument_put_onmouseover
,
1662 HTMLDocument_get_onmouseover
,
1663 HTMLDocument_put_onreadystatechange
,
1664 HTMLDocument_get_onreadystatechange
,
1665 HTMLDocument_put_onafterupdate
,
1666 HTMLDocument_get_onafterupdate
,
1667 HTMLDocument_put_onrowexit
,
1668 HTMLDocument_get_onrowexit
,
1669 HTMLDocument_put_onrowenter
,
1670 HTMLDocument_get_onrowenter
,
1671 HTMLDocument_put_ondragstart
,
1672 HTMLDocument_get_ondragstart
,
1673 HTMLDocument_put_onselectstart
,
1674 HTMLDocument_get_onselectstart
,
1675 HTMLDocument_elementFromPoint
,
1676 HTMLDocument_get_parentWindow
,
1677 HTMLDocument_get_styleSheets
,
1678 HTMLDocument_put_onbeforeupdate
,
1679 HTMLDocument_get_onbeforeupdate
,
1680 HTMLDocument_put_onerrorupdate
,
1681 HTMLDocument_get_onerrorupdate
,
1682 HTMLDocument_toString
,
1683 HTMLDocument_createStyleSheet
1686 static void HTMLDocument_on_advise(IUnknown
*iface
, cp_static_data_t
*cp
)
1688 HTMLDocument
*This
= impl_from_IHTMLDocument2((IHTMLDocument2
*)iface
);
1691 update_cp_events(This
->window
->base
.inner_window
, &This
->doc_node
->node
.event_target
, cp
, This
->doc_node
->node
.nsnode
);
1694 static inline HTMLDocument
*impl_from_ISupportErrorInfo(ISupportErrorInfo
*iface
)
1696 return CONTAINING_RECORD(iface
, HTMLDocument
, ISupportErrorInfo_iface
);
1699 static HRESULT WINAPI
SupportErrorInfo_QueryInterface(ISupportErrorInfo
*iface
, REFIID riid
, void **ppv
)
1701 HTMLDocument
*This
= impl_from_ISupportErrorInfo(iface
);
1702 return htmldoc_query_interface(This
, riid
, ppv
);
1705 static ULONG WINAPI
SupportErrorInfo_AddRef(ISupportErrorInfo
*iface
)
1707 HTMLDocument
*This
= impl_from_ISupportErrorInfo(iface
);
1708 return htmldoc_addref(This
);
1711 static ULONG WINAPI
SupportErrorInfo_Release(ISupportErrorInfo
*iface
)
1713 HTMLDocument
*This
= impl_from_ISupportErrorInfo(iface
);
1714 return htmldoc_release(This
);
1717 static HRESULT WINAPI
SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo
*iface
, REFIID riid
)
1719 FIXME("(%p)->(%s)\n", iface
, debugstr_guid(riid
));
1723 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl
= {
1724 SupportErrorInfo_QueryInterface
,
1725 SupportErrorInfo_AddRef
,
1726 SupportErrorInfo_Release
,
1727 SupportErrorInfo_InterfaceSupportsErrorInfo
1730 static inline HTMLDocument
*impl_from_IDispatchEx(IDispatchEx
*iface
)
1732 return CONTAINING_RECORD(iface
, HTMLDocument
, IDispatchEx_iface
);
1735 static HRESULT
dispid_from_elem_name(HTMLDocumentNode
*This
, BSTR name
, DISPID
*dispid
)
1737 nsIDOMNodeList
*node_list
;
1744 return DISP_E_UNKNOWNNAME
;
1746 nsAString_InitDepend(&name_str
, name
);
1747 nsres
= nsIDOMHTMLDocument_GetElementsByName(This
->nsdoc
, &name_str
, &node_list
);
1748 nsAString_Finish(&name_str
);
1749 if(NS_FAILED(nsres
))
1752 nsres
= nsIDOMNodeList_GetLength(node_list
, &len
);
1753 nsIDOMNodeList_Release(node_list
);
1754 if(NS_FAILED(nsres
))
1758 return DISP_E_UNKNOWNNAME
;
1760 for(i
=0; i
< This
->elem_vars_cnt
; i
++) {
1761 if(!strcmpW(name
, This
->elem_vars
[i
])) {
1762 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
1767 if(This
->elem_vars_cnt
== This
->elem_vars_size
) {
1770 if(This
->elem_vars_size
) {
1771 new_vars
= heap_realloc(This
->elem_vars
, This
->elem_vars_size
*2*sizeof(WCHAR
*));
1773 return E_OUTOFMEMORY
;
1774 This
->elem_vars_size
*= 2;
1776 new_vars
= heap_alloc(16*sizeof(WCHAR
*));
1778 return E_OUTOFMEMORY
;
1779 This
->elem_vars_size
= 16;
1782 This
->elem_vars
= new_vars
;
1785 This
->elem_vars
[This
->elem_vars_cnt
] = heap_strdupW(name
);
1786 if(!This
->elem_vars
[This
->elem_vars_cnt
])
1787 return E_OUTOFMEMORY
;
1789 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+This
->elem_vars_cnt
++;
1793 static HRESULT WINAPI
DocDispatchEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
1795 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1797 return htmldoc_query_interface(This
, riid
, ppv
);
1800 static ULONG WINAPI
DocDispatchEx_AddRef(IDispatchEx
*iface
)
1802 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1804 return htmldoc_addref(This
);
1807 static ULONG WINAPI
DocDispatchEx_Release(IDispatchEx
*iface
)
1809 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1811 return htmldoc_release(This
);
1814 static HRESULT WINAPI
DocDispatchEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
1816 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1818 return IDispatchEx_GetTypeInfoCount(This
->dispex
, pctinfo
);
1821 static HRESULT WINAPI
DocDispatchEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
1822 LCID lcid
, ITypeInfo
**ppTInfo
)
1824 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1826 return IDispatchEx_GetTypeInfo(This
->dispex
, iTInfo
, lcid
, ppTInfo
);
1829 static HRESULT WINAPI
DocDispatchEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
1830 LPOLESTR
*rgszNames
, UINT cNames
,
1831 LCID lcid
, DISPID
*rgDispId
)
1833 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1835 return IDispatchEx_GetIDsOfNames(This
->dispex
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1838 static HRESULT WINAPI
DocDispatchEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
1839 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1840 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1842 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1844 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1845 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1847 switch(dispIdMember
) {
1848 case DISPID_READYSTATE
:
1849 TRACE("DISPID_READYSTATE\n");
1851 if(!(wFlags
& DISPATCH_PROPERTYGET
))
1852 return E_INVALIDARG
;
1854 V_VT(pVarResult
) = VT_I4
;
1855 V_I4(pVarResult
) = This
->window
->readystate
;
1859 return IDispatchEx_Invoke(This
->dispex
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1860 pVarResult
, pExcepInfo
, puArgErr
);
1863 static HRESULT WINAPI
DocDispatchEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1865 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1868 hres
= IDispatchEx_GetDispID(This
->dispex
, bstrName
, grfdex
, pid
);
1869 if(hres
!= DISP_E_UNKNOWNNAME
)
1872 return dispid_from_elem_name(This
->doc_node
, bstrName
, pid
);
1875 static HRESULT WINAPI
DocDispatchEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1876 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1878 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1880 if(This
->window
&& id
== DISPID_IHTMLDOCUMENT2_LOCATION
&& (wFlags
& DISPATCH_PROPERTYPUT
))
1881 return IDispatchEx_InvokeEx(&This
->window
->base
.IDispatchEx_iface
, DISPID_IHTMLWINDOW2_LOCATION
,
1882 lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1885 return IDispatchEx_InvokeEx(This
->dispex
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1888 static HRESULT WINAPI
DocDispatchEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
1890 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1892 return IDispatchEx_DeleteMemberByName(This
->dispex
, bstrName
, grfdex
);
1895 static HRESULT WINAPI
DocDispatchEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
1897 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1899 return IDispatchEx_DeleteMemberByDispID(This
->dispex
, id
);
1902 static HRESULT WINAPI
DocDispatchEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
1904 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1906 return IDispatchEx_GetMemberProperties(This
->dispex
, id
, grfdexFetch
, pgrfdex
);
1909 static HRESULT WINAPI
DocDispatchEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
1911 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1913 return IDispatchEx_GetMemberName(This
->dispex
, id
, pbstrName
);
1916 static HRESULT WINAPI
DocDispatchEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
1918 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1920 return IDispatchEx_GetNextDispID(This
->dispex
, grfdex
, id
, pid
);
1923 static HRESULT WINAPI
DocDispatchEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
1925 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1927 return IDispatchEx_GetNameSpaceParent(This
->dispex
, ppunk
);
1930 static const IDispatchExVtbl DocDispatchExVtbl
= {
1931 DocDispatchEx_QueryInterface
,
1932 DocDispatchEx_AddRef
,
1933 DocDispatchEx_Release
,
1934 DocDispatchEx_GetTypeInfoCount
,
1935 DocDispatchEx_GetTypeInfo
,
1936 DocDispatchEx_GetIDsOfNames
,
1937 DocDispatchEx_Invoke
,
1938 DocDispatchEx_GetDispID
,
1939 DocDispatchEx_InvokeEx
,
1940 DocDispatchEx_DeleteMemberByName
,
1941 DocDispatchEx_DeleteMemberByDispID
,
1942 DocDispatchEx_GetMemberProperties
,
1943 DocDispatchEx_GetMemberName
,
1944 DocDispatchEx_GetNextDispID
,
1945 DocDispatchEx_GetNameSpaceParent
1948 static inline HTMLDocument
*impl_from_IProvideClassInfo(IProvideClassInfo
*iface
)
1950 return CONTAINING_RECORD(iface
, HTMLDocument
, IProvideClassInfo_iface
);
1953 static HRESULT WINAPI
ProvideClassInfo_QueryInterface(IProvideClassInfo
*iface
,
1954 REFIID riid
, void **ppv
)
1956 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1957 return htmldoc_query_interface(This
, riid
, ppv
);
1960 static ULONG WINAPI
ProvideClassInfo_AddRef(IProvideClassInfo
*iface
)
1962 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1963 return htmldoc_addref(This
);
1966 static ULONG WINAPI
ProvideClassInfo_Release(IProvideClassInfo
*iface
)
1968 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1969 return htmldoc_release(This
);
1972 static HRESULT WINAPI
ProvideClassInfo_GetClassInfo(IProvideClassInfo
* iface
,
1975 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1976 TRACE("(%p)->(%p)\n", This
, ppTI
);
1977 return get_htmldoc_classinfo(ppTI
);
1980 static const IProvideClassInfoVtbl ProvideClassInfoVtbl
= {
1981 ProvideClassInfo_QueryInterface
,
1982 ProvideClassInfo_AddRef
,
1983 ProvideClassInfo_Release
,
1984 ProvideClassInfo_GetClassInfo
1987 static BOOL
htmldoc_qi(HTMLDocument
*This
, REFIID riid
, void **ppv
)
1991 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1992 TRACE("(%p)->(IID_IUnknown, %p)\n", This
, ppv
);
1993 *ppv
= &This
->IHTMLDocument2_iface
;
1994 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1995 TRACE("(%p)->(IID_IDispatch, %p)\n", This
, ppv
);
1996 *ppv
= &This
->IDispatchEx_iface
;
1997 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
1998 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This
, ppv
);
1999 *ppv
= &This
->IDispatchEx_iface
;
2000 }else if(IsEqualGUID(&IID_IHTMLDocument
, riid
)) {
2001 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This
, ppv
);
2002 *ppv
= &This
->IHTMLDocument2_iface
;
2003 }else if(IsEqualGUID(&IID_IHTMLDocument2
, riid
)) {
2004 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This
, ppv
);
2005 *ppv
= &This
->IHTMLDocument2_iface
;
2006 }else if(IsEqualGUID(&IID_IHTMLDocument3
, riid
)) {
2007 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This
, ppv
);
2008 *ppv
= &This
->IHTMLDocument3_iface
;
2009 }else if(IsEqualGUID(&IID_IHTMLDocument4
, riid
)) {
2010 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This
, ppv
);
2011 *ppv
= &This
->IHTMLDocument4_iface
;
2012 }else if(IsEqualGUID(&IID_IHTMLDocument5
, riid
)) {
2013 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This
, ppv
);
2014 *ppv
= &This
->IHTMLDocument5_iface
;
2015 }else if(IsEqualGUID(&IID_IHTMLDocument6
, riid
)) {
2016 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This
, ppv
);
2017 *ppv
= &This
->IHTMLDocument6_iface
;
2018 }else if(IsEqualGUID(&IID_IPersist
, riid
)) {
2019 TRACE("(%p)->(IID_IPersist, %p)\n", This
, ppv
);
2020 *ppv
= &This
->IPersistFile_iface
;
2021 }else if(IsEqualGUID(&IID_IPersistMoniker
, riid
)) {
2022 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This
, ppv
);
2023 *ppv
= &This
->IPersistMoniker_iface
;
2024 }else if(IsEqualGUID(&IID_IPersistFile
, riid
)) {
2025 TRACE("(%p)->(IID_IPersistFile, %p)\n", This
, ppv
);
2026 *ppv
= &This
->IPersistFile_iface
;
2027 }else if(IsEqualGUID(&IID_IMonikerProp
, riid
)) {
2028 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This
, ppv
);
2029 *ppv
= &This
->IMonikerProp_iface
;
2030 }else if(IsEqualGUID(&IID_IOleObject
, riid
)) {
2031 TRACE("(%p)->(IID_IOleObject, %p)\n", This
, ppv
);
2032 *ppv
= &This
->IOleObject_iface
;
2033 }else if(IsEqualGUID(&IID_IOleDocument
, riid
)) {
2034 TRACE("(%p)->(IID_IOleDocument, %p)\n", This
, ppv
);
2035 *ppv
= &This
->IOleDocument_iface
;
2036 }else if(IsEqualGUID(&IID_IOleDocumentView
, riid
)) {
2037 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This
, ppv
);
2038 *ppv
= &This
->IOleDocumentView_iface
;
2039 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject
, riid
)) {
2040 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This
, ppv
);
2041 *ppv
= &This
->IOleInPlaceActiveObject_iface
;
2042 }else if(IsEqualGUID(&IID_IViewObject
, riid
)) {
2043 TRACE("(%p)->(IID_IViewObject, %p)\n", This
, ppv
);
2044 *ppv
= &This
->IViewObjectEx_iface
;
2045 }else if(IsEqualGUID(&IID_IViewObject2
, riid
)) {
2046 TRACE("(%p)->(IID_IViewObject2, %p)\n", This
, ppv
);
2047 *ppv
= &This
->IViewObjectEx_iface
;
2048 }else if(IsEqualGUID(&IID_IViewObjectEx
, riid
)) {
2049 TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This
, ppv
);
2050 *ppv
= &This
->IViewObjectEx_iface
;
2051 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
2052 TRACE("(%p)->(IID_IOleWindow, %p)\n", This
, ppv
);
2053 *ppv
= &This
->IOleInPlaceActiveObject_iface
;
2054 }else if(IsEqualGUID(&IID_IOleInPlaceObject
, riid
)) {
2055 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This
, ppv
);
2056 *ppv
= &This
->IOleInPlaceObjectWindowless_iface
;
2057 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless
, riid
)) {
2058 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This
, ppv
);
2059 *ppv
= &This
->IOleInPlaceObjectWindowless_iface
;
2060 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
2061 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This
, ppv
);
2062 *ppv
= &This
->IServiceProvider_iface
;
2063 }else if(IsEqualGUID(&IID_IOleCommandTarget
, riid
)) {
2064 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This
, ppv
);
2065 *ppv
= &This
->IOleCommandTarget_iface
;
2066 }else if(IsEqualGUID(&IID_IOleControl
, riid
)) {
2067 TRACE("(%p)->(IID_IOleControl, %p)\n", This
, ppv
);
2068 *ppv
= &This
->IOleControl_iface
;
2069 }else if(IsEqualGUID(&IID_IHlinkTarget
, riid
)) {
2070 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This
, ppv
);
2071 *ppv
= &This
->IHlinkTarget_iface
;
2072 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
2073 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
2074 *ppv
= &This
->cp_container
.IConnectionPointContainer_iface
;
2075 }else if(IsEqualGUID(&IID_IPersistStreamInit
, riid
)) {
2076 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This
, ppv
);
2077 *ppv
= &This
->IPersistStreamInit_iface
;
2078 }else if(IsEqualGUID(&DIID_DispHTMLDocument
, riid
)) {
2079 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This
, ppv
);
2080 *ppv
= &This
->IHTMLDocument2_iface
;
2081 }else if(IsEqualGUID(&IID_ISupportErrorInfo
, riid
)) {
2082 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This
, ppv
);
2083 *ppv
= &This
->ISupportErrorInfo_iface
;
2084 }else if(IsEqualGUID(&IID_IPersistHistory
, riid
)) {
2085 TRACE("(%p)->(IID_IPersistHistory %p)\n", This
, ppv
);
2086 *ppv
= &This
->IPersistHistory_iface
;
2087 }else if(IsEqualGUID(&CLSID_CMarkup
, riid
)) {
2088 FIXME("(%p)->(CLSID_CMarkup %p)\n", This
, ppv
);
2090 }else if(IsEqualGUID(&IID_IRunnableObject
, riid
)) {
2091 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This
, ppv
);
2093 }else if(IsEqualGUID(&IID_IPersistPropertyBag
, riid
)) {
2094 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This
, ppv
);
2096 }else if(IsEqualGUID(&IID_IMarshal
, riid
)) {
2097 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This
, ppv
);
2099 }else if(IsEqualGUID(&IID_IExternalConnection
, riid
)) {
2100 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This
, ppv
);
2102 }else if(IsEqualGUID(&IID_IStdMarshalInfo
, riid
)) {
2103 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This
, ppv
);
2105 }else if(IsEqualGUID(&IID_IObjectWithSite
, riid
)) {
2106 TRACE("(%p)->(IID_IObjectWithSite %p)\n", This
, ppv
);
2107 *ppv
= &This
->IObjectWithSite_iface
;
2108 }else if(IsEqualGUID(&IID_IOleContainer
, riid
)) {
2109 TRACE("(%p)->(IID_IOleContainer %p)\n", This
, ppv
);
2110 *ppv
= &This
->IOleContainer_iface
;
2111 }else if(IsEqualGUID(&IID_IObjectSafety
, riid
)) {
2112 TRACE("(%p)->(IID_IObjectSafety %p)\n", This
, ppv
);
2113 *ppv
= &This
->IObjectSafety_iface
;
2114 }else if(IsEqualGUID(&IID_IProvideClassInfo
, riid
)) {
2115 TRACE("(%p)->(IID_IProvideClassInfo, %p)\n", This
, ppv
);
2116 *ppv
= &This
->IProvideClassInfo_iface
;
2122 IUnknown_AddRef((IUnknown
*)*ppv
);
2126 static cp_static_data_t HTMLDocumentEvents_data
= { HTMLDocumentEvents_tid
, HTMLDocument_on_advise
};
2128 static const cpc_entry_t HTMLDocument_cpc
[] = {
2129 {&IID_IDispatch
, &HTMLDocumentEvents_data
},
2130 {&IID_IPropertyNotifySink
},
2131 {&DIID_HTMLDocumentEvents
, &HTMLDocumentEvents_data
},
2132 {&DIID_HTMLDocumentEvents2
},
2136 static void init_doc(HTMLDocument
*doc
, IUnknown
*unk_impl
, IDispatchEx
*dispex
)
2138 doc
->IHTMLDocument2_iface
.lpVtbl
= &HTMLDocumentVtbl
;
2139 doc
->IDispatchEx_iface
.lpVtbl
= &DocDispatchExVtbl
;
2140 doc
->ISupportErrorInfo_iface
.lpVtbl
= &SupportErrorInfoVtbl
;
2141 doc
->IProvideClassInfo_iface
.lpVtbl
= &ProvideClassInfoVtbl
;
2143 doc
->unk_impl
= unk_impl
;
2144 doc
->dispex
= dispex
;
2145 doc
->task_magic
= get_task_target_magic();
2147 HTMLDocument_HTMLDocument3_Init(doc
);
2148 HTMLDocument_HTMLDocument5_Init(doc
);
2149 HTMLDocument_Persist_Init(doc
);
2150 HTMLDocument_OleCmd_Init(doc
);
2151 HTMLDocument_OleObj_Init(doc
);
2152 HTMLDocument_View_Init(doc
);
2153 HTMLDocument_Window_Init(doc
);
2154 HTMLDocument_Service_Init(doc
);
2155 HTMLDocument_Hlink_Init(doc
);
2157 ConnectionPointContainer_Init(&doc
->cp_container
, (IUnknown
*)&doc
->IHTMLDocument2_iface
, HTMLDocument_cpc
);
2160 static void destroy_htmldoc(HTMLDocument
*This
)
2162 remove_target_tasks(This
->task_magic
);
2164 ConnectionPointContainer_Destroy(&This
->cp_container
);
2167 static inline HTMLDocumentNode
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
2169 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, node
);
2172 static HRESULT
HTMLDocumentNode_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
2174 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2176 if(htmldoc_qi(&This
->basedoc
, riid
, ppv
))
2177 return *ppv
? S_OK
: E_NOINTERFACE
;
2179 if(IsEqualGUID(&IID_IInternetHostSecurityManager
, riid
)) {
2180 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This
, ppv
);
2181 *ppv
= &This
->IInternetHostSecurityManager_iface
;
2183 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
2186 IUnknown_AddRef((IUnknown
*)*ppv
);
2190 static void HTMLDocumentNode_destructor(HTMLDOMNode
*iface
)
2192 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2195 for(i
=0; i
< This
->elem_vars_cnt
; i
++)
2196 heap_free(This
->elem_vars
[i
]);
2197 heap_free(This
->elem_vars
);
2199 detach_events(This
);
2200 if(This
->body_event_target
)
2201 release_event_target(This
->body_event_target
);
2203 ICatInformation_Release(This
->catmgr
);
2205 detach_selection(This
);
2206 detach_ranges(This
);
2208 while(!list_empty(&This
->plugin_hosts
))
2209 detach_plugin_host(LIST_ENTRY(list_head(&This
->plugin_hosts
), PluginHost
, entry
));
2211 if(This
->nsnode_selector
) {
2212 nsIDOMNodeSelector_Release(This
->nsnode_selector
);
2213 This
->nsnode_selector
= NULL
;
2217 assert(!This
->window
);
2218 release_document_mutation(This
);
2219 nsIDOMHTMLDocument_Release(This
->nsdoc
);
2220 }else if(This
->window
) {
2221 /* document fragments own reference to inner window */
2222 IHTMLWindow2_Release(&This
->window
->base
.IHTMLWindow2_iface
);
2223 This
->window
= NULL
;
2226 heap_free(This
->event_vector
);
2227 destroy_htmldoc(&This
->basedoc
);
2230 static HRESULT
HTMLDocumentNode_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
2232 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2233 FIXME("%p\n", This
);
2237 static void HTMLDocumentNode_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
2239 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2241 if(This
->nsnode_selector
)
2242 note_cc_edge((nsISupports
*)This
->nsnode_selector
, "This->nsnode_selector", cb
);
2244 note_cc_edge((nsISupports
*)This
->nsdoc
, "This->nsdoc", cb
);
2247 static void HTMLDocumentNode_unlink(HTMLDOMNode
*iface
)
2249 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2251 if(This
->nsnode_selector
) {
2252 nsIDOMNodeSelector_Release(This
->nsnode_selector
);
2253 This
->nsnode_selector
= NULL
;
2257 nsIDOMHTMLDocument
*nsdoc
= This
->nsdoc
;
2259 release_document_mutation(This
);
2261 nsIDOMHTMLDocument_Release(nsdoc
);
2262 This
->window
= NULL
;
2266 static const NodeImplVtbl HTMLDocumentNodeImplVtbl
= {
2267 HTMLDocumentNode_QI
,
2268 HTMLDocumentNode_destructor
,
2270 HTMLDocumentNode_clone
,
2282 HTMLDocumentNode_traverse
,
2283 HTMLDocumentNode_unlink
2286 static HRESULT
HTMLDocumentFragment_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
2288 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2289 HTMLDocumentNode
*new_node
;
2292 hres
= create_document_fragment(nsnode
, This
->node
.doc
, &new_node
);
2296 *ret
= &new_node
->node
;
2300 static inline HTMLDocumentNode
*impl_from_DispatchEx(DispatchEx
*iface
)
2302 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, node
.dispex
);
2305 static HRESULT
HTMLDocumentNode_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2306 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2308 HTMLDocumentNode
*This
= impl_from_DispatchEx(dispex
);
2309 nsIDOMNodeList
*node_list
;
2317 if(flags
!= DISPATCH_PROPERTYGET
&& flags
!= (DISPATCH_METHOD
|DISPATCH_PROPERTYGET
)) {
2318 FIXME("unsupported flags %x\n", flags
);
2322 i
= id
- MSHTML_DISPID_CUSTOM_MIN
;
2324 if(!This
->nsdoc
|| i
>= This
->elem_vars_cnt
)
2325 return DISP_E_UNKNOWNNAME
;
2327 nsAString_InitDepend(&name_str
, This
->elem_vars
[i
]);
2328 nsres
= nsIDOMHTMLDocument_GetElementsByName(This
->nsdoc
, &name_str
, &node_list
);
2329 nsAString_Finish(&name_str
);
2330 if(NS_FAILED(nsres
))
2333 nsres
= nsIDOMNodeList_Item(node_list
, 0, &nsnode
);
2334 nsIDOMNodeList_Release(node_list
);
2335 if(NS_FAILED(nsres
) || !nsnode
)
2336 return DISP_E_UNKNOWNNAME
;
2338 hres
= get_node(This
, nsnode
, TRUE
, &node
);
2342 V_VT(res
) = VT_DISPATCH
;
2343 V_DISPATCH(res
) = (IDispatch
*)&node
->IHTMLDOMNode_iface
;
2348 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl
= {
2351 HTMLDocumentNode_invoke
,
2355 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl
= {
2356 HTMLDocumentNode_QI
,
2357 HTMLDocumentNode_destructor
,
2359 HTMLDocumentFragment_clone
2362 static const tid_t HTMLDocumentNode_iface_tids
[] = {
2372 static dispex_static_data_t HTMLDocumentNode_dispex
= {
2373 &HTMLDocumentNode_dispex_vtbl
,
2374 DispHTMLDocument_tid
,
2376 HTMLDocumentNode_iface_tids
2379 static HTMLDocumentNode
*alloc_doc_node(HTMLDocumentObj
*doc_obj
, HTMLInnerWindow
*window
)
2381 HTMLDocumentNode
*doc
;
2383 doc
= heap_alloc_zero(sizeof(HTMLDocumentNode
));
2388 doc
->basedoc
.doc_node
= doc
;
2389 doc
->basedoc
.doc_obj
= doc_obj
;
2390 doc
->basedoc
.window
= window
->base
.outer_window
;
2391 doc
->window
= window
;
2393 init_dispex(&doc
->node
.dispex
, (IUnknown
*)&doc
->node
.IHTMLDOMNode_iface
,
2394 &HTMLDocumentNode_dispex
);
2395 init_doc(&doc
->basedoc
, (IUnknown
*)&doc
->node
.IHTMLDOMNode_iface
,
2396 &doc
->node
.dispex
.IDispatchEx_iface
);
2397 HTMLDocumentNode_SecMgr_Init(doc
);
2399 list_init(&doc
->selection_list
);
2400 list_init(&doc
->range_list
);
2401 list_init(&doc
->plugin_hosts
);
2406 HRESULT
create_doc_from_nsdoc(nsIDOMHTMLDocument
*nsdoc
, HTMLDocumentObj
*doc_obj
, HTMLInnerWindow
*window
, HTMLDocumentNode
**ret
)
2408 HTMLDocumentNode
*doc
;
2411 doc
= alloc_doc_node(doc_obj
, window
);
2413 return E_OUTOFMEMORY
;
2415 if(!doc_obj
->basedoc
.window
|| window
->base
.outer_window
== doc_obj
->basedoc
.window
)
2416 doc
->basedoc
.cp_container
.forward_container
= &doc_obj
->basedoc
.cp_container
;
2418 HTMLDOMNode_Init(doc
, &doc
->node
, (nsIDOMNode
*)nsdoc
);
2420 nsIDOMHTMLDocument_AddRef(nsdoc
);
2423 nsres
= nsIDOMHTMLDocument_QueryInterface(nsdoc
, &IID_nsIDOMNodeSelector
, (void**)&doc
->nsnode_selector
);
2424 assert(nsres
== NS_OK
);
2426 init_document_mutation(doc
);
2427 doc_init_events(doc
);
2429 doc
->node
.vtbl
= &HTMLDocumentNodeImplVtbl
;
2430 doc
->node
.cp_container
= &doc
->basedoc
.cp_container
;
2436 HRESULT
create_document_fragment(nsIDOMNode
*nsnode
, HTMLDocumentNode
*doc_node
, HTMLDocumentNode
**ret
)
2438 HTMLDocumentNode
*doc_frag
;
2440 doc_frag
= alloc_doc_node(doc_node
->basedoc
.doc_obj
, doc_node
->window
);
2442 return E_OUTOFMEMORY
;
2444 IHTMLWindow2_AddRef(&doc_frag
->window
->base
.IHTMLWindow2_iface
);
2446 HTMLDOMNode_Init(doc_node
, &doc_frag
->node
, nsnode
);
2447 doc_frag
->node
.vtbl
= &HTMLDocumentFragmentImplVtbl
;
2448 doc_frag
->node
.cp_container
= &doc_frag
->basedoc
.cp_container
;
2454 /**********************************************************
2455 * ICustomDoc implementation
2458 static inline HTMLDocumentObj
*impl_from_ICustomDoc(ICustomDoc
*iface
)
2460 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, ICustomDoc_iface
);
2463 static HRESULT WINAPI
CustomDoc_QueryInterface(ICustomDoc
*iface
, REFIID riid
, void **ppv
)
2465 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2467 if(htmldoc_qi(&This
->basedoc
, riid
, ppv
))
2468 return *ppv
? S_OK
: E_NOINTERFACE
;
2470 if(IsEqualGUID(&IID_ICustomDoc
, riid
)) {
2471 TRACE("(%p)->(IID_ICustomDoc %p)\n", This
, ppv
);
2472 *ppv
= &This
->ICustomDoc_iface
;
2473 }else if(IsEqualGUID(&IID_ITargetContainer
, riid
)) {
2474 TRACE("(%p)->(IID_ITargetContainer %p)\n", This
, ppv
);
2475 *ppv
= &This
->ITargetContainer_iface
;
2476 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
2477 return *ppv
? S_OK
: E_NOINTERFACE
;
2479 FIXME("Unimplemented interface %s\n", debugstr_guid(riid
));
2481 return E_NOINTERFACE
;
2484 IUnknown_AddRef((IUnknown
*)*ppv
);
2488 static ULONG WINAPI
CustomDoc_AddRef(ICustomDoc
*iface
)
2490 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2491 ULONG ref
= InterlockedIncrement(&This
->ref
);
2493 TRACE("(%p) ref = %u\n", This
, ref
);
2498 static ULONG WINAPI
CustomDoc_Release(ICustomDoc
*iface
)
2500 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2501 ULONG ref
= InterlockedDecrement(&This
->ref
);
2503 TRACE("(%p) ref = %u\n", This
, ref
);
2506 nsIDOMWindowUtils
*window_utils
= NULL
;
2508 if(This
->basedoc
.window
&& This
->basedoc
.window
->nswindow
)
2509 get_nsinterface((nsISupports
*)This
->basedoc
.window
->nswindow
, &IID_nsIDOMWindowUtils
, (void**)&window_utils
);
2511 if(This
->basedoc
.doc_node
) {
2512 This
->basedoc
.doc_node
->basedoc
.doc_obj
= NULL
;
2513 htmldoc_release(&This
->basedoc
.doc_node
->basedoc
);
2515 if(This
->basedoc
.window
) {
2516 This
->basedoc
.window
->doc_obj
= NULL
;
2517 IHTMLWindow2_Release(&This
->basedoc
.window
->base
.IHTMLWindow2_iface
);
2519 if(This
->basedoc
.advise_holder
)
2520 IOleAdviseHolder_Release(This
->basedoc
.advise_holder
);
2523 IAdviseSink_Release(This
->view_sink
);
2525 IOleObject_SetClientSite(&This
->basedoc
.IOleObject_iface
, NULL
);
2527 ICustomDoc_SetUIHandler(&This
->ICustomDoc_iface
, NULL
);
2528 if(This
->in_place_active
)
2529 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This
->basedoc
.IOleInPlaceObjectWindowless_iface
);
2531 IOleDocumentView_SetInPlaceSite(&This
->basedoc
.IOleDocumentView_iface
, NULL
);
2533 IOleUndoManager_Release(This
->undomgr
);
2534 if(This
->tooltips_hwnd
)
2535 DestroyWindow(This
->tooltips_hwnd
);
2538 DestroyWindow(This
->hwnd
);
2539 heap_free(This
->mime
);
2541 destroy_htmldoc(&This
->basedoc
);
2542 release_dispex(&This
->dispex
);
2544 if(This
->nscontainer
)
2545 NSContainer_Release(This
->nscontainer
);
2548 /* Force cycle collection */
2550 nsIDOMWindowUtils_CycleCollect(window_utils
, NULL
, 0);
2551 nsIDOMWindowUtils_Release(window_utils
);
2558 static HRESULT WINAPI
CustomDoc_SetUIHandler(ICustomDoc
*iface
, IDocHostUIHandler
*pUIHandler
)
2560 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2561 IOleCommandTarget
*cmdtrg
;
2564 TRACE("(%p)->(%p)\n", This
, pUIHandler
);
2566 if(This
->custom_hostui
&& This
->hostui
== pUIHandler
)
2569 This
->custom_hostui
= TRUE
;
2572 IDocHostUIHandler_Release(This
->hostui
);
2574 IDocHostUIHandler_AddRef(pUIHandler
);
2575 This
->hostui
= pUIHandler
;
2579 hres
= IDocHostUIHandler_QueryInterface(pUIHandler
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
2580 if(SUCCEEDED(hres
)) {
2581 FIXME("custom UI handler supports IOleCommandTarget\n");
2582 IOleCommandTarget_Release(cmdtrg
);
2588 static const ICustomDocVtbl CustomDocVtbl
= {
2589 CustomDoc_QueryInterface
,
2592 CustomDoc_SetUIHandler
2595 static const tid_t HTMLDocumentObj_iface_tids
[] = {
2602 static dispex_static_data_t HTMLDocumentObj_dispex
= {
2604 DispHTMLDocument_tid
,
2606 HTMLDocumentObj_iface_tids
2609 HRESULT
HTMLDocument_Create(IUnknown
*pUnkOuter
, REFIID riid
, void** ppvObject
)
2611 HTMLDocumentObj
*doc
;
2612 nsIDOMWindow
*nswindow
= NULL
;
2616 TRACE("(%p %s %p)\n", pUnkOuter
, debugstr_guid(riid
), ppvObject
);
2618 doc
= heap_alloc_zero(sizeof(HTMLDocumentObj
));
2620 return E_OUTOFMEMORY
;
2622 init_dispex(&doc
->dispex
, (IUnknown
*)&doc
->ICustomDoc_iface
, &HTMLDocumentObj_dispex
);
2623 init_doc(&doc
->basedoc
, (IUnknown
*)&doc
->ICustomDoc_iface
, &doc
->dispex
.IDispatchEx_iface
);
2624 TargetContainer_Init(doc
);
2626 doc
->ICustomDoc_iface
.lpVtbl
= &CustomDocVtbl
;
2628 doc
->basedoc
.doc_obj
= doc
;
2630 doc
->usermode
= UNKNOWN_USERMODE
;
2632 init_binding_ui(doc
);
2634 hres
= create_nscontainer(doc
, &doc
->nscontainer
);
2636 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2637 htmldoc_release(&doc
->basedoc
);
2641 hres
= htmldoc_query_interface(&doc
->basedoc
, riid
, ppvObject
);
2642 htmldoc_release(&doc
->basedoc
);
2646 nsres
= nsIWebBrowser_GetContentDOMWindow(doc
->nscontainer
->webbrowser
, &nswindow
);
2647 if(NS_FAILED(nsres
))
2648 ERR("GetContentDOMWindow failed: %08x\n", nsres
);
2650 hres
= HTMLOuterWindow_Create(doc
, nswindow
, NULL
/* FIXME */, &doc
->basedoc
.window
);
2652 nsIDOMWindow_Release(nswindow
);
2654 htmldoc_release(&doc
->basedoc
);
2658 if(!doc
->basedoc
.doc_node
&& doc
->basedoc
.window
->base
.inner_window
->doc
) {
2659 doc
->basedoc
.doc_node
= doc
->basedoc
.window
->base
.inner_window
->doc
;
2660 htmldoc_addref(&doc
->basedoc
.doc_node
->basedoc
);