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
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
37 #include "htmlevent.h"
38 #include "pluginhost.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
42 static inline HTMLDocument
*impl_from_IHTMLDocument2(IHTMLDocument2
*iface
)
44 return CONTAINING_RECORD(iface
, HTMLDocument
, IHTMLDocument2_iface
);
47 static HRESULT WINAPI
HTMLDocument_QueryInterface(IHTMLDocument2
*iface
, REFIID riid
, void **ppv
)
49 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
51 return htmldoc_query_interface(This
, riid
, ppv
);
54 static ULONG WINAPI
HTMLDocument_AddRef(IHTMLDocument2
*iface
)
56 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
58 return htmldoc_addref(This
);
61 static ULONG WINAPI
HTMLDocument_Release(IHTMLDocument2
*iface
)
63 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
65 return htmldoc_release(This
);
68 static HRESULT WINAPI
HTMLDocument_GetTypeInfoCount(IHTMLDocument2
*iface
, UINT
*pctinfo
)
70 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
72 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
75 static HRESULT WINAPI
HTMLDocument_GetTypeInfo(IHTMLDocument2
*iface
, UINT iTInfo
,
76 LCID lcid
, ITypeInfo
**ppTInfo
)
78 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
80 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
83 static HRESULT WINAPI
HTMLDocument_GetIDsOfNames(IHTMLDocument2
*iface
, REFIID riid
,
84 LPOLESTR
*rgszNames
, UINT cNames
,
85 LCID lcid
, DISPID
*rgDispId
)
87 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
89 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
93 static HRESULT WINAPI
HTMLDocument_Invoke(IHTMLDocument2
*iface
, DISPID dispIdMember
,
94 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
95 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
97 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
99 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
100 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
103 static HRESULT WINAPI
HTMLDocument_get_Script(IHTMLDocument2
*iface
, IDispatch
**p
)
105 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
107 TRACE("(%p)->(%p)\n", This
, p
);
109 *p
= (IDispatch
*)&This
->window
->IHTMLWindow2_iface
;
110 IDispatch_AddRef(*p
);
114 static HRESULT WINAPI
HTMLDocument_get_all(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
116 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
117 nsIDOMElement
*nselem
= NULL
;
122 TRACE("(%p)->(%p)\n", This
, p
);
124 if(!This
->doc_node
->nsdoc
) {
125 WARN("NULL nsdoc\n");
129 nsres
= nsIDOMHTMLDocument_GetDocumentElement(This
->doc_node
->nsdoc
, &nselem
);
130 if(NS_FAILED(nsres
)) {
131 ERR("GetDocumentElement failed: %08x\n", nsres
);
140 hres
= get_node(This
->doc_node
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
142 *p
= create_all_collection(node
, TRUE
);
143 nsIDOMElement_Release(nselem
);
147 static HRESULT WINAPI
HTMLDocument_get_body(IHTMLDocument2
*iface
, IHTMLElement
**p
)
149 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
150 nsIDOMHTMLElement
*nsbody
= NULL
;
154 TRACE("(%p)->(%p)\n", This
, p
);
156 if(This
->doc_node
->nsdoc
) {
159 nsres
= nsIDOMHTMLDocument_GetBody(This
->doc_node
->nsdoc
, &nsbody
);
160 if(NS_FAILED(nsres
)) {
161 TRACE("Could not get body: %08x\n", nsres
);
171 hres
= get_node(This
->doc_node
, (nsIDOMNode
*)nsbody
, TRUE
, &node
);
172 nsIDOMHTMLElement_Release(nsbody
);
176 return IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)p
);
179 static HRESULT WINAPI
HTMLDocument_get_activeElement(IHTMLDocument2
*iface
, IHTMLElement
**p
)
181 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
182 FIXME("(%p)->(%p)\n", This
, p
);
186 static HRESULT WINAPI
HTMLDocument_get_images(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
188 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
189 nsIDOMHTMLCollection
*nscoll
= NULL
;
192 TRACE("(%p)->(%p)\n", This
, p
);
199 if(!This
->doc_node
->nsdoc
) {
200 WARN("NULL nsdoc\n");
204 nsres
= nsIDOMHTMLDocument_GetImages(This
->doc_node
->nsdoc
, &nscoll
);
205 if(NS_FAILED(nsres
)) {
206 ERR("GetImages failed: %08x\n", nsres
);
211 *p
= create_collection_from_htmlcol(This
->doc_node
, (IUnknown
*)&This
->IHTMLDocument2_iface
, nscoll
);
212 nsIDOMElement_Release(nscoll
);
218 static HRESULT WINAPI
HTMLDocument_get_applets(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
220 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
221 nsIDOMHTMLCollection
*nscoll
= NULL
;
224 TRACE("(%p)->(%p)\n", This
, p
);
231 if(!This
->doc_node
->nsdoc
) {
232 WARN("NULL nsdoc\n");
236 nsres
= nsIDOMHTMLDocument_GetApplets(This
->doc_node
->nsdoc
, &nscoll
);
237 if(NS_FAILED(nsres
)) {
238 ERR("GetApplets failed: %08x\n", nsres
);
243 *p
= create_collection_from_htmlcol(This
->doc_node
, (IUnknown
*)&This
->IHTMLDocument2_iface
, nscoll
);
244 nsIDOMElement_Release(nscoll
);
250 static HRESULT WINAPI
HTMLDocument_get_links(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
252 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
253 nsIDOMHTMLCollection
*nscoll
= NULL
;
256 TRACE("(%p)->(%p)\n", This
, p
);
263 if(!This
->doc_node
->nsdoc
) {
264 WARN("NULL nsdoc\n");
268 nsres
= nsIDOMHTMLDocument_GetLinks(This
->doc_node
->nsdoc
, &nscoll
);
269 if(NS_FAILED(nsres
)) {
270 ERR("GetLinks failed: %08x\n", nsres
);
275 *p
= create_collection_from_htmlcol(This
->doc_node
, (IUnknown
*)&This
->IHTMLDocument2_iface
, nscoll
);
276 nsIDOMElement_Release(nscoll
);
282 static HRESULT WINAPI
HTMLDocument_get_forms(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
284 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
285 nsIDOMHTMLCollection
*nscoll
= NULL
;
288 TRACE("(%p)->(%p)\n", This
, p
);
295 if(!This
->doc_node
->nsdoc
) {
296 WARN("NULL nsdoc\n");
300 nsres
= nsIDOMHTMLDocument_GetForms(This
->doc_node
->nsdoc
, &nscoll
);
301 if(NS_FAILED(nsres
)) {
302 ERR("GetForms failed: %08x\n", nsres
);
307 *p
= create_collection_from_htmlcol(This
->doc_node
, (IUnknown
*)&This
->IHTMLDocument2_iface
, nscoll
);
308 nsIDOMElement_Release(nscoll
);
314 static HRESULT WINAPI
HTMLDocument_get_anchors(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
316 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
317 nsIDOMHTMLCollection
*nscoll
= NULL
;
320 TRACE("(%p)->(%p)\n", This
, p
);
327 if(!This
->doc_node
->nsdoc
) {
328 WARN("NULL nsdoc\n");
332 nsres
= nsIDOMHTMLDocument_GetAnchors(This
->doc_node
->nsdoc
, &nscoll
);
333 if(NS_FAILED(nsres
)) {
334 ERR("GetAnchors failed: %08x\n", nsres
);
339 *p
= create_collection_from_htmlcol(This
->doc_node
, (IUnknown
*)&This
->IHTMLDocument2_iface
, nscoll
);
340 nsIDOMElement_Release(nscoll
);
346 static HRESULT WINAPI
HTMLDocument_put_title(IHTMLDocument2
*iface
, BSTR v
)
348 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
352 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
354 if(!This
->doc_node
->nsdoc
) {
355 WARN("NULL nsdoc\n");
359 nsAString_InitDepend(&nsstr
, v
);
360 nsres
= nsIDOMHTMLDocument_SetTitle(This
->doc_node
->nsdoc
, &nsstr
);
361 nsAString_Finish(&nsstr
);
363 ERR("SetTitle failed: %08x\n", nsres
);
368 static HRESULT WINAPI
HTMLDocument_get_title(IHTMLDocument2
*iface
, BSTR
*p
)
370 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
371 const PRUnichar
*ret
;
375 TRACE("(%p)->(%p)\n", This
, p
);
377 if(!This
->doc_node
->nsdoc
) {
378 WARN("NULL nsdoc\n");
383 nsAString_Init(&nsstr
, NULL
);
384 nsres
= nsIDOMHTMLDocument_GetTitle(This
->doc_node
->nsdoc
, &nsstr
);
385 if (NS_SUCCEEDED(nsres
)) {
386 nsAString_GetData(&nsstr
, &ret
);
387 *p
= SysAllocString(ret
);
389 nsAString_Finish(&nsstr
);
391 if(NS_FAILED(nsres
)) {
392 ERR("GetTitle failed: %08x\n", nsres
);
399 static HRESULT WINAPI
HTMLDocument_get_scripts(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
401 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
402 FIXME("(%p)->(%p)\n", This
, p
);
406 static HRESULT WINAPI
HTMLDocument_put_designMode(IHTMLDocument2
*iface
, BSTR v
)
408 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
409 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
413 static HRESULT WINAPI
HTMLDocument_get_designMode(IHTMLDocument2
*iface
, BSTR
*p
)
415 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
416 static WCHAR szOff
[] = {'O','f','f',0};
417 FIXME("(%p)->(%p) always returning Off\n", This
, p
);
422 *p
= SysAllocString(szOff
);
427 static HRESULT WINAPI
HTMLDocument_get_selection(IHTMLDocument2
*iface
, IHTMLSelectionObject
**p
)
429 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
430 nsISelection
*nsselection
;
433 TRACE("(%p)->(%p)\n", This
, p
);
435 nsres
= nsIDOMWindow_GetSelection(This
->window
->nswindow
, &nsselection
);
436 if(NS_FAILED(nsres
)) {
437 ERR("GetSelection failed: %08x\n", nsres
);
441 return HTMLSelectionObject_Create(This
->doc_node
, nsselection
, p
);
444 static HRESULT WINAPI
HTMLDocument_get_readyState(IHTMLDocument2
*iface
, BSTR
*p
)
446 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
448 static const WCHAR wszUninitialized
[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
449 static const WCHAR wszLoading
[] = {'l','o','a','d','i','n','g',0};
450 static const WCHAR wszLoaded
[] = {'l','o','a','d','e','d',0};
451 static const WCHAR wszInteractive
[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
452 static const WCHAR wszComplete
[] = {'c','o','m','p','l','e','t','e',0};
454 static const LPCWSTR readystate_str
[] = {
462 TRACE("(%p)->(%p)\n", iface
, p
);
467 *p
= SysAllocString(readystate_str
[This
->window
->readystate
]);
471 static HRESULT WINAPI
HTMLDocument_get_frames(IHTMLDocument2
*iface
, IHTMLFramesCollection2
**p
)
473 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
475 TRACE("(%p)->(%p)\n", This
, p
);
477 return IHTMLWindow2_get_frames(&This
->window
->IHTMLWindow2_iface
, p
);
480 static HRESULT WINAPI
HTMLDocument_get_embeds(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
482 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
483 FIXME("(%p)->(%p)\n", This
, p
);
487 static HRESULT WINAPI
HTMLDocument_get_plugins(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
489 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
490 FIXME("(%p)->(%p)\n", This
, p
);
494 static HRESULT WINAPI
HTMLDocument_put_alinkColor(IHTMLDocument2
*iface
, VARIANT v
)
496 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
497 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
501 static HRESULT WINAPI
HTMLDocument_get_alinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
503 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
504 FIXME("(%p)->(%p)\n", This
, p
);
508 static HRESULT WINAPI
HTMLDocument_put_bgColor(IHTMLDocument2
*iface
, VARIANT v
)
510 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
511 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
515 static HRESULT WINAPI
HTMLDocument_get_bgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
517 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
518 FIXME("(%p)->(%p)\n", This
, p
);
522 static HRESULT WINAPI
HTMLDocument_put_fgColor(IHTMLDocument2
*iface
, VARIANT v
)
524 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
525 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
529 static HRESULT WINAPI
HTMLDocument_get_fgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
531 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
532 FIXME("(%p)->(%p)\n", This
, p
);
536 static HRESULT WINAPI
HTMLDocument_put_linkColor(IHTMLDocument2
*iface
, VARIANT v
)
538 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
539 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
543 static HRESULT WINAPI
HTMLDocument_get_linkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
545 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
546 FIXME("(%p)->(%p)\n", This
, p
);
550 static HRESULT WINAPI
HTMLDocument_put_vlinkColor(IHTMLDocument2
*iface
, VARIANT v
)
552 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
553 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
557 static HRESULT WINAPI
HTMLDocument_get_vlinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
559 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
560 FIXME("(%p)->(%p)\n", This
, p
);
564 static HRESULT WINAPI
HTMLDocument_get_referrer(IHTMLDocument2
*iface
, BSTR
*p
)
566 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
568 FIXME("(%p)->(%p)\n", This
, p
);
574 static HRESULT WINAPI
HTMLDocument_get_location(IHTMLDocument2
*iface
, IHTMLLocation
**p
)
576 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
578 TRACE("(%p)->(%p)\n", This
, p
);
580 if(!This
->doc_node
->nsdoc
) {
581 WARN("NULL nsdoc\n");
585 return IHTMLWindow2_get_location(&This
->window
->IHTMLWindow2_iface
, p
);
588 static HRESULT WINAPI
HTMLDocument_get_lastModified(IHTMLDocument2
*iface
, BSTR
*p
)
590 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
591 FIXME("(%p)->(%p)\n", This
, p
);
595 static HRESULT WINAPI
HTMLDocument_put_URL(IHTMLDocument2
*iface
, BSTR v
)
597 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
598 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
602 static HRESULT WINAPI
HTMLDocument_get_URL(IHTMLDocument2
*iface
, BSTR
*p
)
604 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
606 static const WCHAR about_blank_url
[] =
607 {'a','b','o','u','t',':','b','l','a','n','k',0};
609 TRACE("(%p)->(%p)\n", iface
, p
);
611 *p
= SysAllocString(This
->window
->url
? This
->window
->url
: about_blank_url
);
612 return *p
? S_OK
: E_OUTOFMEMORY
;
615 static HRESULT WINAPI
HTMLDocument_put_domain(IHTMLDocument2
*iface
, BSTR v
)
617 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
618 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
622 static HRESULT WINAPI
HTMLDocument_get_domain(IHTMLDocument2
*iface
, BSTR
*p
)
624 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
627 TRACE("(%p)->(%p)\n", This
, p
);
629 if(!This
->window
|| !This
->window
->uri
) {
630 FIXME("No current URI\n");
634 hres
= IUri_GetHost(This
->window
->uri
, p
);
635 return FAILED(hres
) ? hres
: S_OK
;
638 static HRESULT WINAPI
HTMLDocument_put_cookie(IHTMLDocument2
*iface
, BSTR v
)
640 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
643 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
645 bret
= InternetSetCookieExW(This
->window
->url
, NULL
, v
, 0, 0);
647 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
648 return HRESULT_FROM_WIN32(GetLastError());
654 static HRESULT WINAPI
HTMLDocument_get_cookie(IHTMLDocument2
*iface
, BSTR
*p
)
656 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
660 TRACE("(%p)->(%p)\n", This
, p
);
663 bret
= InternetGetCookieExW(This
->window
->url
, NULL
, NULL
, &size
, 0, NULL
);
665 switch(GetLastError()) {
666 case ERROR_INSUFFICIENT_BUFFER
:
668 case ERROR_NO_MORE_ITEMS
:
672 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
673 return HRESULT_FROM_WIN32(GetLastError());
682 *p
= SysAllocStringLen(NULL
, size
-1);
684 return E_OUTOFMEMORY
;
686 bret
= InternetGetCookieExW(This
->window
->url
, NULL
, *p
, &size
, 0, NULL
);
688 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
695 static HRESULT WINAPI
HTMLDocument_put_expando(IHTMLDocument2
*iface
, VARIANT_BOOL v
)
697 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
698 FIXME("(%p)->(%x)\n", This
, v
);
702 static HRESULT WINAPI
HTMLDocument_get_expando(IHTMLDocument2
*iface
, VARIANT_BOOL
*p
)
704 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
705 FIXME("(%p)->(%p)\n", This
, p
);
709 static HRESULT WINAPI
HTMLDocument_put_charset(IHTMLDocument2
*iface
, BSTR v
)
711 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
712 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
716 static HRESULT WINAPI
HTMLDocument_get_charset(IHTMLDocument2
*iface
, BSTR
*p
)
718 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
719 FIXME("(%p)->(%p)\n", This
, p
);
723 static HRESULT WINAPI
HTMLDocument_put_defaultCharset(IHTMLDocument2
*iface
, BSTR v
)
725 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
726 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
730 static HRESULT WINAPI
HTMLDocument_get_defaultCharset(IHTMLDocument2
*iface
, BSTR
*p
)
732 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
733 FIXME("(%p)->(%p)\n", This
, p
);
737 static HRESULT WINAPI
HTMLDocument_get_mimeType(IHTMLDocument2
*iface
, BSTR
*p
)
739 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
740 FIXME("(%p)->(%p)\n", This
, p
);
744 static HRESULT WINAPI
HTMLDocument_get_fileSize(IHTMLDocument2
*iface
, BSTR
*p
)
746 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
747 FIXME("(%p)->(%p)\n", This
, p
);
751 static HRESULT WINAPI
HTMLDocument_get_fileCreatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
753 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
754 FIXME("(%p)->(%p)\n", This
, p
);
758 static HRESULT WINAPI
HTMLDocument_get_fileModifiedDate(IHTMLDocument2
*iface
, BSTR
*p
)
760 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
761 FIXME("(%p)->(%p)\n", This
, p
);
765 static HRESULT WINAPI
HTMLDocument_get_fileUpdatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
767 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
768 FIXME("(%p)->(%p)\n", This
, p
);
772 static HRESULT WINAPI
HTMLDocument_get_security(IHTMLDocument2
*iface
, BSTR
*p
)
774 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
775 FIXME("(%p)->(%p)\n", This
, p
);
779 static HRESULT WINAPI
HTMLDocument_get_protocol(IHTMLDocument2
*iface
, BSTR
*p
)
781 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
782 FIXME("(%p)->(%p)\n", This
, p
);
786 static HRESULT WINAPI
HTMLDocument_get_nameProp(IHTMLDocument2
*iface
, BSTR
*p
)
788 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
789 FIXME("(%p)->(%p)\n", This
, p
);
793 static HRESULT
document_write(HTMLDocument
*This
, SAFEARRAY
*psarray
, BOOL ln
)
801 if(!This
->doc_node
->nsdoc
) {
802 WARN("NULL nsdoc\n");
809 if(psarray
->cDims
!= 1) {
810 FIXME("cDims=%d\n", psarray
->cDims
);
814 hres
= SafeArrayAccessData(psarray
, (void**)&var
);
816 WARN("SafeArrayAccessData failed: %08x\n", hres
);
820 nsAString_Init(&nsstr
, NULL
);
822 argc
= psarray
->rgsabound
[0].cElements
;
823 for(i
=0; i
< argc
; i
++) {
824 if(V_VT(var
+i
) == VT_BSTR
) {
825 nsAString_SetData(&nsstr
, V_BSTR(var
+i
));
826 if(!ln
|| i
!= argc
-1)
827 nsres
= nsIDOMHTMLDocument_Write(This
->doc_node
->nsdoc
, &nsstr
, NULL
/* FIXME! */);
829 nsres
= nsIDOMHTMLDocument_Writeln(This
->doc_node
->nsdoc
, &nsstr
, NULL
/* FIXME! */);
831 ERR("Write failed: %08x\n", nsres
);
833 FIXME("unsupported arg[%d] = %s\n", i
, debugstr_variant(var
+i
));
837 nsAString_Finish(&nsstr
);
838 SafeArrayUnaccessData(psarray
);
843 static HRESULT WINAPI
HTMLDocument_write(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
845 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
847 TRACE("(%p)->(%p)\n", iface
, psarray
);
849 return document_write(This
, psarray
, FALSE
);
852 static HRESULT WINAPI
HTMLDocument_writeln(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
854 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
856 TRACE("(%p)->(%p)\n", This
, psarray
);
858 return document_write(This
, psarray
, TRUE
);
861 static HRESULT WINAPI
HTMLDocument_open(IHTMLDocument2
*iface
, BSTR url
, VARIANT name
,
862 VARIANT features
, VARIANT replace
, IDispatch
**pomWindowResult
)
864 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
868 static const WCHAR text_htmlW
[] = {'t','e','x','t','/','h','t','m','l',0};
870 TRACE("(%p)->(%s %s %s %s %p)\n", This
, debugstr_w(url
), debugstr_variant(&name
),
871 debugstr_variant(&features
), debugstr_variant(&replace
), pomWindowResult
);
873 if(!This
->doc_node
->nsdoc
) {
878 if(!url
|| strcmpW(url
, text_htmlW
) || V_VT(&name
) != VT_ERROR
879 || V_VT(&features
) != VT_ERROR
|| V_VT(&replace
) != VT_ERROR
)
880 FIXME("unsupported args\n");
882 nsres
= nsIDOMHTMLDocument_Open(This
->doc_node
->nsdoc
, NULL
, NULL
, NULL
, NULL
, 0, &tmp
);
883 if(NS_FAILED(nsres
)) {
884 ERR("Open failed: %08x\n", nsres
);
889 nsISupports_Release(tmp
);
891 *pomWindowResult
= (IDispatch
*)&This
->window
->IHTMLWindow2_iface
;
892 IHTMLWindow2_AddRef(&This
->window
->IHTMLWindow2_iface
);
896 static HRESULT WINAPI
HTMLDocument_close(IHTMLDocument2
*iface
)
898 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
901 TRACE("(%p)\n", This
);
903 if(!This
->doc_node
->nsdoc
) {
908 nsres
= nsIDOMHTMLDocument_Close(This
->doc_node
->nsdoc
);
909 if(NS_FAILED(nsres
)) {
910 ERR("Close failed: %08x\n", nsres
);
917 static HRESULT WINAPI
HTMLDocument_clear(IHTMLDocument2
*iface
)
919 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
922 TRACE("(%p)\n", This
);
924 nsres
= nsIDOMHTMLDocument_Clear(This
->doc_node
->nsdoc
);
925 if(NS_FAILED(nsres
)) {
926 ERR("Clear failed: %08x\n", nsres
);
933 static HRESULT WINAPI
HTMLDocument_queryCommandSupported(IHTMLDocument2
*iface
, BSTR cmdID
,
936 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
937 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
941 static HRESULT WINAPI
HTMLDocument_queryCommandEnabled(IHTMLDocument2
*iface
, BSTR cmdID
,
944 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
945 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
949 static HRESULT WINAPI
HTMLDocument_queryCommandState(IHTMLDocument2
*iface
, BSTR cmdID
,
952 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
953 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
957 static HRESULT WINAPI
HTMLDocument_queryCommandIndeterm(IHTMLDocument2
*iface
, BSTR cmdID
,
960 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
961 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
965 static HRESULT WINAPI
HTMLDocument_queryCommandText(IHTMLDocument2
*iface
, BSTR cmdID
,
968 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
969 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
973 static HRESULT WINAPI
HTMLDocument_queryCommandValue(IHTMLDocument2
*iface
, BSTR cmdID
,
976 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
977 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
981 static HRESULT WINAPI
HTMLDocument_execCommand(IHTMLDocument2
*iface
, BSTR cmdID
,
982 VARIANT_BOOL showUI
, VARIANT value
, VARIANT_BOOL
*pfRet
)
984 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
985 FIXME("(%p)->(%s %x %s %p)\n", This
, debugstr_w(cmdID
), showUI
, debugstr_variant(&value
), pfRet
);
989 static HRESULT WINAPI
HTMLDocument_execCommandShowHelp(IHTMLDocument2
*iface
, BSTR cmdID
,
992 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
993 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
997 static HRESULT WINAPI
HTMLDocument_createElement(IHTMLDocument2
*iface
, BSTR eTag
,
998 IHTMLElement
**newElem
)
1000 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1001 nsIDOMHTMLElement
*nselem
;
1005 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(eTag
), newElem
);
1007 hres
= create_nselem(This
->doc_node
, eTag
, &nselem
);
1011 hres
= HTMLElement_Create(This
->doc_node
, (nsIDOMNode
*)nselem
, TRUE
, &elem
);
1012 nsIDOMHTMLElement_Release(nselem
);
1016 *newElem
= &elem
->IHTMLElement_iface
;
1017 IHTMLElement_AddRef(&elem
->IHTMLElement_iface
);
1021 static HRESULT WINAPI
HTMLDocument_put_onhelp(IHTMLDocument2
*iface
, VARIANT v
)
1023 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1024 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1028 static HRESULT WINAPI
HTMLDocument_get_onhelp(IHTMLDocument2
*iface
, VARIANT
*p
)
1030 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1031 FIXME("(%p)->(%p)\n", This
, p
);
1035 static HRESULT WINAPI
HTMLDocument_put_onclick(IHTMLDocument2
*iface
, VARIANT v
)
1037 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1039 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1041 return set_doc_event(This
, EVENTID_CLICK
, &v
);
1044 static HRESULT WINAPI
HTMLDocument_get_onclick(IHTMLDocument2
*iface
, VARIANT
*p
)
1046 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1048 TRACE("(%p)->(%p)\n", This
, p
);
1050 return get_doc_event(This
, EVENTID_CLICK
, p
);
1053 static HRESULT WINAPI
HTMLDocument_put_ondblclick(IHTMLDocument2
*iface
, VARIANT v
)
1055 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1056 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1060 static HRESULT WINAPI
HTMLDocument_get_ondblclick(IHTMLDocument2
*iface
, VARIANT
*p
)
1062 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1063 FIXME("(%p)->(%p)\n", This
, p
);
1067 static HRESULT WINAPI
HTMLDocument_put_onkeyup(IHTMLDocument2
*iface
, VARIANT v
)
1069 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1071 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1073 return set_doc_event(This
, EVENTID_KEYUP
, &v
);
1076 static HRESULT WINAPI
HTMLDocument_get_onkeyup(IHTMLDocument2
*iface
, VARIANT
*p
)
1078 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1080 TRACE("(%p)->(%p)\n", This
, p
);
1082 return get_doc_event(This
, EVENTID_KEYUP
, p
);
1085 static HRESULT WINAPI
HTMLDocument_put_onkeydown(IHTMLDocument2
*iface
, VARIANT v
)
1087 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1089 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1091 return set_doc_event(This
, EVENTID_KEYDOWN
, &v
);
1094 static HRESULT WINAPI
HTMLDocument_get_onkeydown(IHTMLDocument2
*iface
, VARIANT
*p
)
1096 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1098 TRACE("(%p)->(%p)\n", This
, p
);
1100 return get_doc_event(This
, EVENTID_KEYDOWN
, p
);
1103 static HRESULT WINAPI
HTMLDocument_put_onkeypress(IHTMLDocument2
*iface
, VARIANT v
)
1105 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1106 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1110 static HRESULT WINAPI
HTMLDocument_get_onkeypress(IHTMLDocument2
*iface
, VARIANT
*p
)
1112 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1113 FIXME("(%p)->(%p)\n", This
, p
);
1117 static HRESULT WINAPI
HTMLDocument_put_onmouseup(IHTMLDocument2
*iface
, VARIANT v
)
1119 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1121 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1123 return set_doc_event(This
, EVENTID_MOUSEUP
, &v
);
1126 static HRESULT WINAPI
HTMLDocument_get_onmouseup(IHTMLDocument2
*iface
, VARIANT
*p
)
1128 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1130 TRACE("(%p)->(%p)\n", This
, p
);
1132 return get_doc_event(This
, EVENTID_MOUSEUP
, p
);
1135 static HRESULT WINAPI
HTMLDocument_put_onmousedown(IHTMLDocument2
*iface
, VARIANT v
)
1137 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1139 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1141 return set_doc_event(This
, EVENTID_MOUSEDOWN
, &v
);
1144 static HRESULT WINAPI
HTMLDocument_get_onmousedown(IHTMLDocument2
*iface
, VARIANT
*p
)
1146 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1148 TRACE("(%p)->(%p)\n", This
, p
);
1150 return get_doc_event(This
, EVENTID_MOUSEDOWN
, p
);
1153 static HRESULT WINAPI
HTMLDocument_put_onmousemove(IHTMLDocument2
*iface
, VARIANT v
)
1155 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1157 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1159 return set_doc_event(This
, EVENTID_MOUSEMOVE
, &v
);
1162 static HRESULT WINAPI
HTMLDocument_get_onmousemove(IHTMLDocument2
*iface
, VARIANT
*p
)
1164 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1166 TRACE("(%p)->(%p)\n", This
, p
);
1168 return get_doc_event(This
, EVENTID_MOUSEMOVE
, p
);
1171 static HRESULT WINAPI
HTMLDocument_put_onmouseout(IHTMLDocument2
*iface
, VARIANT v
)
1173 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1175 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1177 return set_doc_event(This
, EVENTID_MOUSEOUT
, &v
);
1180 static HRESULT WINAPI
HTMLDocument_get_onmouseout(IHTMLDocument2
*iface
, VARIANT
*p
)
1182 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1184 TRACE("(%p)->(%p)\n", This
, p
);
1186 return get_doc_event(This
, EVENTID_MOUSEOUT
, p
);
1189 static HRESULT WINAPI
HTMLDocument_put_onmouseover(IHTMLDocument2
*iface
, VARIANT v
)
1191 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1193 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1195 return set_doc_event(This
, EVENTID_MOUSEOVER
, &v
);
1198 static HRESULT WINAPI
HTMLDocument_get_onmouseover(IHTMLDocument2
*iface
, VARIANT
*p
)
1200 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1202 TRACE("(%p)->(%p)\n", This
, p
);
1204 return get_doc_event(This
, EVENTID_MOUSEOVER
, p
);
1207 static HRESULT WINAPI
HTMLDocument_put_onreadystatechange(IHTMLDocument2
*iface
, VARIANT v
)
1209 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1211 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1213 return set_doc_event(This
, EVENTID_READYSTATECHANGE
, &v
);
1216 static HRESULT WINAPI
HTMLDocument_get_onreadystatechange(IHTMLDocument2
*iface
, VARIANT
*p
)
1218 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1220 TRACE("(%p)->(%p)\n", This
, p
);
1222 return get_doc_event(This
, EVENTID_READYSTATECHANGE
, p
);
1225 static HRESULT WINAPI
HTMLDocument_put_onafterupdate(IHTMLDocument2
*iface
, VARIANT v
)
1227 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1228 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1232 static HRESULT WINAPI
HTMLDocument_get_onafterupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1234 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1235 FIXME("(%p)->(%p)\n", This
, p
);
1239 static HRESULT WINAPI
HTMLDocument_put_onrowexit(IHTMLDocument2
*iface
, VARIANT v
)
1241 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1242 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1246 static HRESULT WINAPI
HTMLDocument_get_onrowexit(IHTMLDocument2
*iface
, VARIANT
*p
)
1248 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1249 FIXME("(%p)->(%p)\n", This
, p
);
1253 static HRESULT WINAPI
HTMLDocument_put_onrowenter(IHTMLDocument2
*iface
, VARIANT v
)
1255 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1256 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1260 static HRESULT WINAPI
HTMLDocument_get_onrowenter(IHTMLDocument2
*iface
, VARIANT
*p
)
1262 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1263 FIXME("(%p)->(%p)\n", This
, p
);
1267 static HRESULT WINAPI
HTMLDocument_put_ondragstart(IHTMLDocument2
*iface
, VARIANT v
)
1269 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1271 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1273 return set_doc_event(This
, EVENTID_DRAGSTART
, &v
);
1276 static HRESULT WINAPI
HTMLDocument_get_ondragstart(IHTMLDocument2
*iface
, VARIANT
*p
)
1278 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1280 TRACE("(%p)->(%p)\n", This
, p
);
1282 return get_doc_event(This
, EVENTID_DRAGSTART
, p
);
1285 static HRESULT WINAPI
HTMLDocument_put_onselectstart(IHTMLDocument2
*iface
, VARIANT v
)
1287 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1289 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1291 return set_doc_event(This
, EVENTID_SELECTSTART
, &v
);
1294 static HRESULT WINAPI
HTMLDocument_get_onselectstart(IHTMLDocument2
*iface
, VARIANT
*p
)
1296 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1298 TRACE("(%p)->(%p)\n", This
, p
);
1300 return get_doc_event(This
, EVENTID_SELECTSTART
, p
);
1303 static HRESULT WINAPI
HTMLDocument_elementFromPoint(IHTMLDocument2
*iface
, LONG x
, LONG y
,
1304 IHTMLElement
**elementHit
)
1306 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1307 nsIDOMElement
*nselem
;
1312 TRACE("(%p)->(%d %d %p)\n", This
, x
, y
, elementHit
);
1314 nsres
= nsIDOMHTMLDocument_ElementFromPoint(This
->doc_node
->nsdoc
, x
, y
, &nselem
);
1315 if(NS_FAILED(nsres
)) {
1316 ERR("ElementFromPoint failed: %08x\n", nsres
);
1325 hres
= get_node(This
->doc_node
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
1326 nsIDOMElement_Release(nselem
);
1330 return IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)elementHit
);
1333 static HRESULT WINAPI
HTMLDocument_get_parentWindow(IHTMLDocument2
*iface
, IHTMLWindow2
**p
)
1335 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1337 TRACE("(%p)->(%p)\n", This
, p
);
1339 *p
= &This
->window
->IHTMLWindow2_iface
;
1340 IHTMLWindow2_AddRef(*p
);
1344 static HRESULT WINAPI
HTMLDocument_get_styleSheets(IHTMLDocument2
*iface
,
1345 IHTMLStyleSheetsCollection
**p
)
1347 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1348 nsIDOMStyleSheetList
*nsstylelist
;
1351 TRACE("(%p)->(%p)\n", This
, p
);
1355 if(!This
->doc_node
->nsdoc
) {
1356 WARN("NULL nsdoc\n");
1357 return E_UNEXPECTED
;
1360 nsres
= nsIDOMHTMLDocument_GetStyleSheets(This
->doc_node
->nsdoc
, &nsstylelist
);
1361 if(NS_FAILED(nsres
)) {
1362 ERR("GetStyleSheets failed: %08x\n", nsres
);
1366 *p
= HTMLStyleSheetsCollection_Create(nsstylelist
);
1367 nsIDOMStyleSheetList_Release(nsstylelist
);
1372 static HRESULT WINAPI
HTMLDocument_put_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT v
)
1374 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1375 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1379 static HRESULT WINAPI
HTMLDocument_get_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1381 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1382 FIXME("(%p)->(%p)\n", This
, p
);
1386 static HRESULT WINAPI
HTMLDocument_put_onerrorupdate(IHTMLDocument2
*iface
, VARIANT v
)
1388 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1389 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1393 static HRESULT WINAPI
HTMLDocument_get_onerrorupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1395 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1396 FIXME("(%p)->(%p)\n", This
, p
);
1400 static HRESULT WINAPI
HTMLDocument_toString(IHTMLDocument2
*iface
, BSTR
*String
)
1402 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1403 FIXME("(%p)->(%p)\n", This
, String
);
1407 static HRESULT WINAPI
HTMLDocument_createStyleSheet(IHTMLDocument2
*iface
, BSTR bstrHref
,
1408 LONG lIndex
, IHTMLStyleSheet
**ppnewStyleSheet
)
1410 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1412 FIXME("(%p)->(%s %d %p) semi-stub\n", This
, debugstr_w(bstrHref
), lIndex
, ppnewStyleSheet
);
1414 *ppnewStyleSheet
= HTMLStyleSheet_Create(NULL
);
1418 static const IHTMLDocument2Vtbl HTMLDocumentVtbl
= {
1419 HTMLDocument_QueryInterface
,
1420 HTMLDocument_AddRef
,
1421 HTMLDocument_Release
,
1422 HTMLDocument_GetTypeInfoCount
,
1423 HTMLDocument_GetTypeInfo
,
1424 HTMLDocument_GetIDsOfNames
,
1425 HTMLDocument_Invoke
,
1426 HTMLDocument_get_Script
,
1427 HTMLDocument_get_all
,
1428 HTMLDocument_get_body
,
1429 HTMLDocument_get_activeElement
,
1430 HTMLDocument_get_images
,
1431 HTMLDocument_get_applets
,
1432 HTMLDocument_get_links
,
1433 HTMLDocument_get_forms
,
1434 HTMLDocument_get_anchors
,
1435 HTMLDocument_put_title
,
1436 HTMLDocument_get_title
,
1437 HTMLDocument_get_scripts
,
1438 HTMLDocument_put_designMode
,
1439 HTMLDocument_get_designMode
,
1440 HTMLDocument_get_selection
,
1441 HTMLDocument_get_readyState
,
1442 HTMLDocument_get_frames
,
1443 HTMLDocument_get_embeds
,
1444 HTMLDocument_get_plugins
,
1445 HTMLDocument_put_alinkColor
,
1446 HTMLDocument_get_alinkColor
,
1447 HTMLDocument_put_bgColor
,
1448 HTMLDocument_get_bgColor
,
1449 HTMLDocument_put_fgColor
,
1450 HTMLDocument_get_fgColor
,
1451 HTMLDocument_put_linkColor
,
1452 HTMLDocument_get_linkColor
,
1453 HTMLDocument_put_vlinkColor
,
1454 HTMLDocument_get_vlinkColor
,
1455 HTMLDocument_get_referrer
,
1456 HTMLDocument_get_location
,
1457 HTMLDocument_get_lastModified
,
1458 HTMLDocument_put_URL
,
1459 HTMLDocument_get_URL
,
1460 HTMLDocument_put_domain
,
1461 HTMLDocument_get_domain
,
1462 HTMLDocument_put_cookie
,
1463 HTMLDocument_get_cookie
,
1464 HTMLDocument_put_expando
,
1465 HTMLDocument_get_expando
,
1466 HTMLDocument_put_charset
,
1467 HTMLDocument_get_charset
,
1468 HTMLDocument_put_defaultCharset
,
1469 HTMLDocument_get_defaultCharset
,
1470 HTMLDocument_get_mimeType
,
1471 HTMLDocument_get_fileSize
,
1472 HTMLDocument_get_fileCreatedDate
,
1473 HTMLDocument_get_fileModifiedDate
,
1474 HTMLDocument_get_fileUpdatedDate
,
1475 HTMLDocument_get_security
,
1476 HTMLDocument_get_protocol
,
1477 HTMLDocument_get_nameProp
,
1479 HTMLDocument_writeln
,
1483 HTMLDocument_queryCommandSupported
,
1484 HTMLDocument_queryCommandEnabled
,
1485 HTMLDocument_queryCommandState
,
1486 HTMLDocument_queryCommandIndeterm
,
1487 HTMLDocument_queryCommandText
,
1488 HTMLDocument_queryCommandValue
,
1489 HTMLDocument_execCommand
,
1490 HTMLDocument_execCommandShowHelp
,
1491 HTMLDocument_createElement
,
1492 HTMLDocument_put_onhelp
,
1493 HTMLDocument_get_onhelp
,
1494 HTMLDocument_put_onclick
,
1495 HTMLDocument_get_onclick
,
1496 HTMLDocument_put_ondblclick
,
1497 HTMLDocument_get_ondblclick
,
1498 HTMLDocument_put_onkeyup
,
1499 HTMLDocument_get_onkeyup
,
1500 HTMLDocument_put_onkeydown
,
1501 HTMLDocument_get_onkeydown
,
1502 HTMLDocument_put_onkeypress
,
1503 HTMLDocument_get_onkeypress
,
1504 HTMLDocument_put_onmouseup
,
1505 HTMLDocument_get_onmouseup
,
1506 HTMLDocument_put_onmousedown
,
1507 HTMLDocument_get_onmousedown
,
1508 HTMLDocument_put_onmousemove
,
1509 HTMLDocument_get_onmousemove
,
1510 HTMLDocument_put_onmouseout
,
1511 HTMLDocument_get_onmouseout
,
1512 HTMLDocument_put_onmouseover
,
1513 HTMLDocument_get_onmouseover
,
1514 HTMLDocument_put_onreadystatechange
,
1515 HTMLDocument_get_onreadystatechange
,
1516 HTMLDocument_put_onafterupdate
,
1517 HTMLDocument_get_onafterupdate
,
1518 HTMLDocument_put_onrowexit
,
1519 HTMLDocument_get_onrowexit
,
1520 HTMLDocument_put_onrowenter
,
1521 HTMLDocument_get_onrowenter
,
1522 HTMLDocument_put_ondragstart
,
1523 HTMLDocument_get_ondragstart
,
1524 HTMLDocument_put_onselectstart
,
1525 HTMLDocument_get_onselectstart
,
1526 HTMLDocument_elementFromPoint
,
1527 HTMLDocument_get_parentWindow
,
1528 HTMLDocument_get_styleSheets
,
1529 HTMLDocument_put_onbeforeupdate
,
1530 HTMLDocument_get_onbeforeupdate
,
1531 HTMLDocument_put_onerrorupdate
,
1532 HTMLDocument_get_onerrorupdate
,
1533 HTMLDocument_toString
,
1534 HTMLDocument_createStyleSheet
1537 static void HTMLDocument_on_advise(IUnknown
*iface
, cp_static_data_t
*cp
)
1539 HTMLDocument
*This
= impl_from_IHTMLDocument2((IHTMLDocument2
*)iface
);
1542 update_cp_events(This
->window
, &This
->doc_node
->node
.event_target
, cp
, This
->doc_node
->node
.nsnode
);
1545 static inline HTMLDocument
*impl_from_ISupportErrorInfo(ISupportErrorInfo
*iface
)
1547 return CONTAINING_RECORD(iface
, HTMLDocument
, ISupportErrorInfo_iface
);
1550 static HRESULT WINAPI
SupportErrorInfo_QueryInterface(ISupportErrorInfo
*iface
, REFIID riid
, void **ppv
)
1552 HTMLDocument
*This
= impl_from_ISupportErrorInfo(iface
);
1553 return htmldoc_query_interface(This
, riid
, ppv
);
1556 static ULONG WINAPI
SupportErrorInfo_AddRef(ISupportErrorInfo
*iface
)
1558 HTMLDocument
*This
= impl_from_ISupportErrorInfo(iface
);
1559 return htmldoc_addref(This
);
1562 static ULONG WINAPI
SupportErrorInfo_Release(ISupportErrorInfo
*iface
)
1564 HTMLDocument
*This
= impl_from_ISupportErrorInfo(iface
);
1565 return htmldoc_release(This
);
1568 static HRESULT WINAPI
SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo
*iface
, REFIID riid
)
1570 FIXME("(%p)->(%s)\n", iface
, debugstr_guid(riid
));
1574 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl
= {
1575 SupportErrorInfo_QueryInterface
,
1576 SupportErrorInfo_AddRef
,
1577 SupportErrorInfo_Release
,
1578 SupportErrorInfo_InterfaceSupportsErrorInfo
1581 static inline HTMLDocument
*impl_from_IDispatchEx(IDispatchEx
*iface
)
1583 return CONTAINING_RECORD(iface
, HTMLDocument
, IDispatchEx_iface
);
1586 static HRESULT
dispid_from_elem_name(HTMLDocumentNode
*This
, BSTR name
, DISPID
*dispid
)
1588 nsIDOMNodeList
*node_list
;
1595 return DISP_E_UNKNOWNNAME
;
1597 nsAString_InitDepend(&name_str
, name
);
1598 nsres
= nsIDOMHTMLDocument_GetElementsByName(This
->nsdoc
, &name_str
, &node_list
);
1599 nsAString_Finish(&name_str
);
1600 if(NS_FAILED(nsres
))
1603 nsres
= nsIDOMNodeList_GetLength(node_list
, &len
);
1604 nsIDOMNodeList_Release(node_list
);
1605 if(NS_FAILED(nsres
))
1609 return DISP_E_UNKNOWNNAME
;
1611 for(i
=0; i
< This
->elem_vars_cnt
; i
++) {
1612 if(!strcmpW(name
, This
->elem_vars
[i
])) {
1613 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
1618 if(This
->elem_vars_cnt
== This
->elem_vars_size
) {
1621 if(This
->elem_vars_size
) {
1622 new_vars
= heap_realloc(This
->elem_vars
, This
->elem_vars_size
*2*sizeof(WCHAR
*));
1624 return E_OUTOFMEMORY
;
1625 This
->elem_vars_size
*= 2;
1627 new_vars
= heap_alloc(16*sizeof(WCHAR
*));
1629 return E_OUTOFMEMORY
;
1630 This
->elem_vars_size
= 16;
1633 This
->elem_vars
= new_vars
;
1636 This
->elem_vars
[This
->elem_vars_cnt
] = heap_strdupW(name
);
1637 if(!This
->elem_vars
[This
->elem_vars_cnt
])
1638 return E_OUTOFMEMORY
;
1640 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+This
->elem_vars_cnt
++;
1644 static HRESULT WINAPI
DocDispatchEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
1646 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1648 return htmldoc_query_interface(This
, riid
, ppv
);
1651 static ULONG WINAPI
DocDispatchEx_AddRef(IDispatchEx
*iface
)
1653 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1655 return htmldoc_addref(This
);
1658 static ULONG WINAPI
DocDispatchEx_Release(IDispatchEx
*iface
)
1660 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1662 return htmldoc_release(This
);
1665 static HRESULT WINAPI
DocDispatchEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
1667 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1669 return IDispatchEx_GetTypeInfoCount(This
->dispex
, pctinfo
);
1672 static HRESULT WINAPI
DocDispatchEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
1673 LCID lcid
, ITypeInfo
**ppTInfo
)
1675 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1677 return IDispatchEx_GetTypeInfo(This
->dispex
, iTInfo
, lcid
, ppTInfo
);
1680 static HRESULT WINAPI
DocDispatchEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
1681 LPOLESTR
*rgszNames
, UINT cNames
,
1682 LCID lcid
, DISPID
*rgDispId
)
1684 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1686 return IDispatchEx_GetIDsOfNames(This
->dispex
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1689 static HRESULT WINAPI
DocDispatchEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
1690 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1691 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1693 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1695 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1696 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1698 switch(dispIdMember
) {
1699 case DISPID_READYSTATE
:
1700 TRACE("DISPID_READYSTATE\n");
1702 if(!(wFlags
& DISPATCH_PROPERTYGET
))
1703 return E_INVALIDARG
;
1705 V_VT(pVarResult
) = VT_I4
;
1706 V_I4(pVarResult
) = This
->window
->readystate
;
1710 return IDispatchEx_Invoke(This
->dispex
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1711 pVarResult
, pExcepInfo
, puArgErr
);
1714 static HRESULT WINAPI
DocDispatchEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1716 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1719 hres
= IDispatchEx_GetDispID(This
->dispex
, bstrName
, grfdex
, pid
);
1720 if(hres
!= DISP_E_UNKNOWNNAME
)
1723 return dispid_from_elem_name(This
->doc_node
, bstrName
, pid
);
1726 static HRESULT WINAPI
DocDispatchEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1727 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1729 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1731 if(This
->window
&& id
== DISPID_IHTMLDOCUMENT2_LOCATION
&& (wFlags
& DISPATCH_PROPERTYPUT
))
1732 return IDispatchEx_InvokeEx(&This
->window
->IDispatchEx_iface
, DISPID_IHTMLWINDOW2_LOCATION
,
1733 lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1736 return IDispatchEx_InvokeEx(This
->dispex
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1739 static HRESULT WINAPI
DocDispatchEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
1741 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1743 return IDispatchEx_DeleteMemberByName(This
->dispex
, bstrName
, grfdex
);
1746 static HRESULT WINAPI
DocDispatchEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
1748 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1750 return IDispatchEx_DeleteMemberByDispID(This
->dispex
, id
);
1753 static HRESULT WINAPI
DocDispatchEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
1755 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1757 return IDispatchEx_GetMemberProperties(This
->dispex
, id
, grfdexFetch
, pgrfdex
);
1760 static HRESULT WINAPI
DocDispatchEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
1762 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1764 return IDispatchEx_GetMemberName(This
->dispex
, id
, pbstrName
);
1767 static HRESULT WINAPI
DocDispatchEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
1769 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1771 return IDispatchEx_GetNextDispID(This
->dispex
, grfdex
, id
, pid
);
1774 static HRESULT WINAPI
DocDispatchEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
1776 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1778 return IDispatchEx_GetNameSpaceParent(This
->dispex
, ppunk
);
1781 static const IDispatchExVtbl DocDispatchExVtbl
= {
1782 DocDispatchEx_QueryInterface
,
1783 DocDispatchEx_AddRef
,
1784 DocDispatchEx_Release
,
1785 DocDispatchEx_GetTypeInfoCount
,
1786 DocDispatchEx_GetTypeInfo
,
1787 DocDispatchEx_GetIDsOfNames
,
1788 DocDispatchEx_Invoke
,
1789 DocDispatchEx_GetDispID
,
1790 DocDispatchEx_InvokeEx
,
1791 DocDispatchEx_DeleteMemberByName
,
1792 DocDispatchEx_DeleteMemberByDispID
,
1793 DocDispatchEx_GetMemberProperties
,
1794 DocDispatchEx_GetMemberName
,
1795 DocDispatchEx_GetNextDispID
,
1796 DocDispatchEx_GetNameSpaceParent
1799 static inline HTMLDocument
*impl_from_IProvideClassInfo(IProvideClassInfo
*iface
)
1801 return CONTAINING_RECORD(iface
, HTMLDocument
, IProvideClassInfo_iface
);
1804 static HRESULT WINAPI
ProvideClassInfo_QueryInterface(IProvideClassInfo
*iface
,
1805 REFIID riid
, void **ppv
)
1807 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1808 return htmldoc_query_interface(This
, riid
, ppv
);
1811 static ULONG WINAPI
ProvideClassInfo_AddRef(IProvideClassInfo
*iface
)
1813 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1814 return htmldoc_addref(This
);
1817 static ULONG WINAPI
ProvideClassInfo_Release(IProvideClassInfo
*iface
)
1819 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1820 return htmldoc_release(This
);
1823 static HRESULT WINAPI
ProvideClassInfo_GetClassInfo(IProvideClassInfo
* iface
,
1826 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1827 TRACE("(%p)->(%p)\n", This
, ppTI
);
1828 return get_htmldoc_classinfo(ppTI
);
1831 static const IProvideClassInfoVtbl ProvideClassInfoVtbl
= {
1832 ProvideClassInfo_QueryInterface
,
1833 ProvideClassInfo_AddRef
,
1834 ProvideClassInfo_Release
,
1835 ProvideClassInfo_GetClassInfo
1838 static BOOL
htmldoc_qi(HTMLDocument
*This
, REFIID riid
, void **ppv
)
1842 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1843 TRACE("(%p)->(IID_IUnknown, %p)\n", This
, ppv
);
1844 *ppv
= &This
->IHTMLDocument2_iface
;
1845 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1846 TRACE("(%p)->(IID_IDispatch, %p)\n", This
, ppv
);
1847 *ppv
= &This
->IDispatchEx_iface
;
1848 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
1849 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This
, ppv
);
1850 *ppv
= &This
->IDispatchEx_iface
;
1851 }else if(IsEqualGUID(&IID_IHTMLDocument
, riid
)) {
1852 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This
, ppv
);
1853 *ppv
= &This
->IHTMLDocument2_iface
;
1854 }else if(IsEqualGUID(&IID_IHTMLDocument2
, riid
)) {
1855 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This
, ppv
);
1856 *ppv
= &This
->IHTMLDocument2_iface
;
1857 }else if(IsEqualGUID(&IID_IHTMLDocument3
, riid
)) {
1858 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This
, ppv
);
1859 *ppv
= &This
->IHTMLDocument3_iface
;
1860 }else if(IsEqualGUID(&IID_IHTMLDocument4
, riid
)) {
1861 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This
, ppv
);
1862 *ppv
= &This
->IHTMLDocument4_iface
;
1863 }else if(IsEqualGUID(&IID_IHTMLDocument5
, riid
)) {
1864 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This
, ppv
);
1865 *ppv
= &This
->IHTMLDocument5_iface
;
1866 }else if(IsEqualGUID(&IID_IHTMLDocument6
, riid
)) {
1867 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This
, ppv
);
1868 *ppv
= &This
->IHTMLDocument6_iface
;
1869 }else if(IsEqualGUID(&IID_IPersist
, riid
)) {
1870 TRACE("(%p)->(IID_IPersist, %p)\n", This
, ppv
);
1871 *ppv
= &This
->IPersistFile_iface
;
1872 }else if(IsEqualGUID(&IID_IPersistMoniker
, riid
)) {
1873 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This
, ppv
);
1874 *ppv
= &This
->IPersistMoniker_iface
;
1875 }else if(IsEqualGUID(&IID_IPersistFile
, riid
)) {
1876 TRACE("(%p)->(IID_IPersistFile, %p)\n", This
, ppv
);
1877 *ppv
= &This
->IPersistFile_iface
;
1878 }else if(IsEqualGUID(&IID_IMonikerProp
, riid
)) {
1879 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This
, ppv
);
1880 *ppv
= &This
->IMonikerProp_iface
;
1881 }else if(IsEqualGUID(&IID_IOleObject
, riid
)) {
1882 TRACE("(%p)->(IID_IOleObject, %p)\n", This
, ppv
);
1883 *ppv
= &This
->IOleObject_iface
;
1884 }else if(IsEqualGUID(&IID_IOleDocument
, riid
)) {
1885 TRACE("(%p)->(IID_IOleDocument, %p)\n", This
, ppv
);
1886 *ppv
= &This
->IOleDocument_iface
;
1887 }else if(IsEqualGUID(&IID_IOleDocumentView
, riid
)) {
1888 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This
, ppv
);
1889 *ppv
= &This
->IOleDocumentView_iface
;
1890 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject
, riid
)) {
1891 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This
, ppv
);
1892 *ppv
= &This
->IOleInPlaceActiveObject_iface
;
1893 }else if(IsEqualGUID(&IID_IViewObject
, riid
)) {
1894 TRACE("(%p)->(IID_IViewObject, %p)\n", This
, ppv
);
1895 *ppv
= &This
->IViewObjectEx_iface
;
1896 }else if(IsEqualGUID(&IID_IViewObject2
, riid
)) {
1897 TRACE("(%p)->(IID_IViewObject2, %p)\n", This
, ppv
);
1898 *ppv
= &This
->IViewObjectEx_iface
;
1899 }else if(IsEqualGUID(&IID_IViewObjectEx
, riid
)) {
1900 TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This
, ppv
);
1901 *ppv
= &This
->IViewObjectEx_iface
;
1902 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
1903 TRACE("(%p)->(IID_IOleWindow, %p)\n", This
, ppv
);
1904 *ppv
= &This
->IOleInPlaceActiveObject_iface
;
1905 }else if(IsEqualGUID(&IID_IOleInPlaceObject
, riid
)) {
1906 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This
, ppv
);
1907 *ppv
= &This
->IOleInPlaceObjectWindowless_iface
;
1908 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless
, riid
)) {
1909 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This
, ppv
);
1910 *ppv
= &This
->IOleInPlaceObjectWindowless_iface
;
1911 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
1912 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This
, ppv
);
1913 *ppv
= &This
->IServiceProvider_iface
;
1914 }else if(IsEqualGUID(&IID_IOleCommandTarget
, riid
)) {
1915 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This
, ppv
);
1916 *ppv
= &This
->IOleCommandTarget_iface
;
1917 }else if(IsEqualGUID(&IID_IOleControl
, riid
)) {
1918 TRACE("(%p)->(IID_IOleControl, %p)\n", This
, ppv
);
1919 *ppv
= &This
->IOleControl_iface
;
1920 }else if(IsEqualGUID(&IID_IHlinkTarget
, riid
)) {
1921 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This
, ppv
);
1922 *ppv
= &This
->IHlinkTarget_iface
;
1923 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1924 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1925 *ppv
= &This
->cp_container
.IConnectionPointContainer_iface
;
1926 }else if(IsEqualGUID(&IID_IPersistStreamInit
, riid
)) {
1927 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This
, ppv
);
1928 *ppv
= &This
->IPersistStreamInit_iface
;
1929 }else if(IsEqualGUID(&DIID_DispHTMLDocument
, riid
)) {
1930 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This
, ppv
);
1931 *ppv
= &This
->IHTMLDocument2_iface
;
1932 }else if(IsEqualGUID(&IID_ISupportErrorInfo
, riid
)) {
1933 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This
, ppv
);
1934 *ppv
= &This
->ISupportErrorInfo_iface
;
1935 }else if(IsEqualGUID(&IID_IPersistHistory
, riid
)) {
1936 TRACE("(%p)->(IID_IPersistHistory %p)\n", This
, ppv
);
1937 *ppv
= &This
->IPersistHistory_iface
;
1938 }else if(IsEqualGUID(&CLSID_CMarkup
, riid
)) {
1939 FIXME("(%p)->(CLSID_CMarkup %p)\n", This
, ppv
);
1941 }else if(IsEqualGUID(&IID_IRunnableObject
, riid
)) {
1942 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This
, ppv
);
1944 }else if(IsEqualGUID(&IID_IPersistPropertyBag
, riid
)) {
1945 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This
, ppv
);
1947 }else if(IsEqualGUID(&IID_IMarshal
, riid
)) {
1948 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This
, ppv
);
1950 }else if(IsEqualGUID(&IID_IExternalConnection
, riid
)) {
1951 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This
, ppv
);
1953 }else if(IsEqualGUID(&IID_IStdMarshalInfo
, riid
)) {
1954 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This
, ppv
);
1956 }else if(IsEqualGUID(&IID_IObjectWithSite
, riid
)) {
1957 TRACE("(%p)->(IID_IObjectWithSite %p)\n", This
, ppv
);
1958 *ppv
= &This
->IObjectWithSite_iface
;
1959 }else if(IsEqualGUID(&IID_IOleContainer
, riid
)) {
1960 TRACE("(%p)->(IID_IOleContainer %p)\n", This
, ppv
);
1961 *ppv
= &This
->IOleContainer_iface
;
1962 }else if(IsEqualGUID(&IID_IObjectSafety
, riid
)) {
1963 TRACE("(%p)->(IID_IObjectSafety %p)\n", This
, ppv
);
1964 *ppv
= &This
->IObjectSafety_iface
;
1965 }else if(IsEqualGUID(&IID_IProvideClassInfo
, riid
)) {
1966 TRACE("(%p)->(IID_IProvideClassInfo, %p)\n", This
, ppv
);
1967 *ppv
= &This
->IProvideClassInfo_iface
;
1973 IUnknown_AddRef((IUnknown
*)*ppv
);
1977 static cp_static_data_t HTMLDocumentEvents_data
= { HTMLDocumentEvents_tid
, HTMLDocument_on_advise
};
1979 static void init_doc(HTMLDocument
*doc
, IUnknown
*unk_impl
, IDispatchEx
*dispex
)
1981 doc
->IHTMLDocument2_iface
.lpVtbl
= &HTMLDocumentVtbl
;
1982 doc
->IDispatchEx_iface
.lpVtbl
= &DocDispatchExVtbl
;
1983 doc
->ISupportErrorInfo_iface
.lpVtbl
= &SupportErrorInfoVtbl
;
1984 doc
->IProvideClassInfo_iface
.lpVtbl
= &ProvideClassInfoVtbl
;
1986 doc
->unk_impl
= unk_impl
;
1987 doc
->dispex
= dispex
;
1988 doc
->task_magic
= get_task_target_magic();
1990 HTMLDocument_HTMLDocument3_Init(doc
);
1991 HTMLDocument_HTMLDocument5_Init(doc
);
1992 HTMLDocument_Persist_Init(doc
);
1993 HTMLDocument_OleCmd_Init(doc
);
1994 HTMLDocument_OleObj_Init(doc
);
1995 HTMLDocument_View_Init(doc
);
1996 HTMLDocument_Window_Init(doc
);
1997 HTMLDocument_Service_Init(doc
);
1998 HTMLDocument_Hlink_Init(doc
);
2000 ConnectionPointContainer_Init(&doc
->cp_container
, (IUnknown
*)&doc
->IHTMLDocument2_iface
);
2001 ConnectionPoint_Init(&doc
->cp_dispatch
, &doc
->cp_container
, &IID_IDispatch
, &HTMLDocumentEvents_data
);
2002 ConnectionPoint_Init(&doc
->cp_propnotif
, &doc
->cp_container
, &IID_IPropertyNotifySink
, NULL
);
2003 ConnectionPoint_Init(&doc
->cp_htmldocevents
, &doc
->cp_container
, &DIID_HTMLDocumentEvents
, &HTMLDocumentEvents_data
);
2004 ConnectionPoint_Init(&doc
->cp_htmldocevents2
, &doc
->cp_container
, &DIID_HTMLDocumentEvents2
, NULL
);
2007 static void destroy_htmldoc(HTMLDocument
*This
)
2009 remove_target_tasks(This
->task_magic
);
2011 ConnectionPointContainer_Destroy(&This
->cp_container
);
2014 static inline HTMLDocumentNode
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
2016 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, node
);
2019 static HRESULT
HTMLDocumentNode_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
2021 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2023 if(htmldoc_qi(&This
->basedoc
, riid
, ppv
))
2024 return *ppv
? S_OK
: E_NOINTERFACE
;
2026 if(IsEqualGUID(&IID_IInternetHostSecurityManager
, riid
)) {
2027 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This
, ppv
);
2028 *ppv
= &This
->IInternetHostSecurityManager_iface
;
2030 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
2033 IUnknown_AddRef((IUnknown
*)*ppv
);
2037 static void HTMLDocumentNode_destructor(HTMLDOMNode
*iface
)
2039 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2042 for(i
=0; i
< This
->elem_vars_cnt
; i
++)
2043 heap_free(This
->elem_vars
[i
]);
2044 heap_free(This
->elem_vars
);
2046 detach_events(This
);
2047 if(This
->body_event_target
)
2048 release_event_target(This
->body_event_target
);
2049 if(This
->nsevent_listener
)
2050 release_nsevents(This
);
2052 ICatInformation_Release(This
->catmgr
);
2054 detach_selection(This
);
2055 detach_ranges(This
);
2056 release_nodes(This
);
2058 while(!list_empty(&This
->plugin_hosts
))
2059 detach_plugin_host(LIST_ENTRY(list_head(&This
->plugin_hosts
), PluginHost
, entry
));
2062 release_document_mutation(This
);
2063 nsIDOMHTMLDocument_Release(This
->nsdoc
);
2066 heap_free(This
->event_vector
);
2067 destroy_htmldoc(&This
->basedoc
);
2070 static HRESULT
HTMLDocumentNode_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
2072 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2073 FIXME("%p\n", This
);
2077 static const NodeImplVtbl HTMLDocumentNodeImplVtbl
= {
2078 HTMLDocumentNode_QI
,
2079 HTMLDocumentNode_destructor
,
2080 HTMLDocumentNode_clone
2083 static HRESULT
HTMLDocumentFragment_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
2085 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2086 HTMLDocumentNode
*new_node
;
2089 hres
= create_document_fragment(nsnode
, This
->node
.doc
, &new_node
);
2093 *ret
= &new_node
->node
;
2097 static inline HTMLDocumentNode
*impl_from_DispatchEx(DispatchEx
*iface
)
2099 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, node
.dispex
);
2102 static HRESULT
HTMLDocumentNode_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2103 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2105 HTMLDocumentNode
*This
= impl_from_DispatchEx(dispex
);
2106 nsIDOMNodeList
*node_list
;
2114 if(flags
!= DISPATCH_PROPERTYGET
) {
2115 FIXME("unsupported flags %x\n", flags
);
2119 i
= id
- MSHTML_DISPID_CUSTOM_MIN
;
2121 if(!This
->nsdoc
|| i
>= This
->elem_vars_cnt
)
2122 return DISP_E_UNKNOWNNAME
;
2124 nsAString_InitDepend(&name_str
, This
->elem_vars
[i
]);
2125 nsres
= nsIDOMHTMLDocument_GetElementsByName(This
->nsdoc
, &name_str
, &node_list
);
2126 nsAString_Finish(&name_str
);
2127 if(NS_FAILED(nsres
))
2130 nsres
= nsIDOMNodeList_Item(node_list
, 0, &nsnode
);
2131 nsIDOMNodeList_Release(node_list
);
2132 if(NS_FAILED(nsres
) || !nsnode
)
2133 return DISP_E_UNKNOWNNAME
;
2135 hres
= get_node(This
, nsnode
, TRUE
, &node
);
2139 IHTMLDOMNode_AddRef(&node
->IHTMLDOMNode_iface
);
2140 V_VT(res
) = VT_DISPATCH
;
2141 V_DISPATCH(res
) = (IDispatch
*)&node
->IHTMLDOMNode_iface
;
2146 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl
= {
2149 HTMLDocumentNode_invoke
,
2153 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl
= {
2154 HTMLDocumentNode_QI
,
2155 HTMLDocumentNode_destructor
,
2156 HTMLDocumentFragment_clone
2159 static const tid_t HTMLDocumentNode_iface_tids
[] = {
2169 static dispex_static_data_t HTMLDocumentNode_dispex
= {
2170 &HTMLDocumentNode_dispex_vtbl
,
2171 DispHTMLDocument_tid
,
2173 HTMLDocumentNode_iface_tids
2176 static HTMLDocumentNode
*alloc_doc_node(HTMLDocumentObj
*doc_obj
, HTMLWindow
*window
)
2178 HTMLDocumentNode
*doc
;
2180 doc
= heap_alloc_zero(sizeof(HTMLDocumentNode
));
2185 doc
->basedoc
.doc_node
= doc
;
2186 doc
->basedoc
.doc_obj
= doc_obj
;
2187 doc
->basedoc
.window
= window
;
2189 init_dispex(&doc
->node
.dispex
, (IUnknown
*)&doc
->node
.IHTMLDOMNode_iface
,
2190 &HTMLDocumentNode_dispex
);
2191 init_doc(&doc
->basedoc
, (IUnknown
*)&doc
->node
.IHTMLDOMNode_iface
,
2192 &doc
->node
.dispex
.IDispatchEx_iface
);
2193 HTMLDocumentNode_SecMgr_Init(doc
);
2195 list_init(&doc
->bindings
);
2196 list_init(&doc
->selection_list
);
2197 list_init(&doc
->range_list
);
2198 list_init(&doc
->plugin_hosts
);
2203 HRESULT
create_doc_from_nsdoc(nsIDOMHTMLDocument
*nsdoc
, HTMLDocumentObj
*doc_obj
, HTMLWindow
*window
, HTMLDocumentNode
**ret
)
2205 HTMLDocumentNode
*doc
;
2207 doc
= alloc_doc_node(doc_obj
, window
);
2209 return E_OUTOFMEMORY
;
2211 if(!doc_obj
->basedoc
.window
|| window
== doc_obj
->basedoc
.window
)
2212 doc
->basedoc
.cp_container
.forward_container
= &doc_obj
->basedoc
.cp_container
;
2214 nsIDOMHTMLDocument_AddRef(nsdoc
);
2216 init_document_mutation(doc
);
2217 doc_init_events(doc
);
2219 HTMLDOMNode_Init(doc
, &doc
->node
, (nsIDOMNode
*)nsdoc
);
2220 doc
->node
.vtbl
= &HTMLDocumentNodeImplVtbl
;
2221 doc
->node
.cp_container
= &doc
->basedoc
.cp_container
;
2227 HRESULT
create_document_fragment(nsIDOMNode
*nsnode
, HTMLDocumentNode
*doc_node
, HTMLDocumentNode
**ret
)
2229 HTMLDocumentNode
*doc_frag
;
2231 doc_frag
= alloc_doc_node(doc_node
->basedoc
.doc_obj
, doc_node
->basedoc
.window
);
2233 return E_OUTOFMEMORY
;
2235 HTMLDOMNode_Init(doc_node
, &doc_frag
->node
, nsnode
);
2236 doc_frag
->node
.vtbl
= &HTMLDocumentFragmentImplVtbl
;
2237 doc_frag
->node
.cp_container
= &doc_frag
->basedoc
.cp_container
;
2239 htmldoc_addref(&doc_frag
->basedoc
);
2244 /**********************************************************
2245 * ICustomDoc implementation
2248 static inline HTMLDocumentObj
*impl_from_ICustomDoc(ICustomDoc
*iface
)
2250 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, ICustomDoc_iface
);
2253 static HRESULT WINAPI
CustomDoc_QueryInterface(ICustomDoc
*iface
, REFIID riid
, void **ppv
)
2255 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2257 if(htmldoc_qi(&This
->basedoc
, riid
, ppv
))
2258 return *ppv
? S_OK
: E_NOINTERFACE
;
2260 if(IsEqualGUID(&IID_ICustomDoc
, riid
)) {
2261 TRACE("(%p)->(IID_ICustomDoc %p)\n", This
, ppv
);
2262 *ppv
= &This
->ICustomDoc_iface
;
2263 }else if(IsEqualGUID(&IID_ITargetContainer
, riid
)) {
2264 TRACE("(%p)->(IID_ITargetContainer %p)\n", This
, ppv
);
2265 *ppv
= &This
->ITargetContainer_iface
;
2266 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
2267 return *ppv
? S_OK
: E_NOINTERFACE
;
2269 FIXME("Unimplemented interface %s\n", debugstr_guid(riid
));
2271 return E_NOINTERFACE
;
2274 IUnknown_AddRef((IUnknown
*)*ppv
);
2278 static ULONG WINAPI
CustomDoc_AddRef(ICustomDoc
*iface
)
2280 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2281 ULONG ref
= InterlockedIncrement(&This
->ref
);
2283 TRACE("(%p) ref = %u\n", This
, ref
);
2288 static ULONG WINAPI
CustomDoc_Release(ICustomDoc
*iface
)
2290 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2291 ULONG ref
= InterlockedDecrement(&This
->ref
);
2293 TRACE("(%p) ref = %u\n", This
, ref
);
2296 if(This
->basedoc
.doc_node
) {
2297 This
->basedoc
.doc_node
->basedoc
.doc_obj
= NULL
;
2298 htmldoc_release(&This
->basedoc
.doc_node
->basedoc
);
2300 if(This
->basedoc
.window
) {
2301 This
->basedoc
.window
->doc_obj
= NULL
;
2302 IHTMLWindow2_Release(&This
->basedoc
.window
->IHTMLWindow2_iface
);
2304 if(This
->basedoc
.advise_holder
)
2305 IOleAdviseHolder_Release(This
->basedoc
.advise_holder
);
2308 IAdviseSink_Release(This
->view_sink
);
2310 IOleObject_SetClientSite(&This
->basedoc
.IOleObject_iface
, NULL
);
2312 ICustomDoc_SetUIHandler(&This
->ICustomDoc_iface
, NULL
);
2313 if(This
->in_place_active
)
2314 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This
->basedoc
.IOleInPlaceObjectWindowless_iface
);
2316 IOleDocumentView_SetInPlaceSite(&This
->basedoc
.IOleDocumentView_iface
, NULL
);
2318 IOleUndoManager_Release(This
->undomgr
);
2319 if(This
->tooltips_hwnd
)
2320 DestroyWindow(This
->tooltips_hwnd
);
2323 DestroyWindow(This
->hwnd
);
2324 heap_free(This
->mime
);
2326 destroy_htmldoc(&This
->basedoc
);
2327 release_dispex(&This
->dispex
);
2329 if(This
->nscontainer
)
2330 NSContainer_Release(This
->nscontainer
);
2337 static HRESULT WINAPI
CustomDoc_SetUIHandler(ICustomDoc
*iface
, IDocHostUIHandler
*pUIHandler
)
2339 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2340 IOleCommandTarget
*cmdtrg
;
2343 TRACE("(%p)->(%p)\n", This
, pUIHandler
);
2345 if(This
->custom_hostui
&& This
->hostui
== pUIHandler
)
2348 This
->custom_hostui
= TRUE
;
2351 IDocHostUIHandler_Release(This
->hostui
);
2353 IDocHostUIHandler_AddRef(pUIHandler
);
2354 This
->hostui
= pUIHandler
;
2358 hres
= IDocHostUIHandler_QueryInterface(pUIHandler
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
2359 if(SUCCEEDED(hres
)) {
2360 FIXME("custom UI handler supports IOleCommandTarget\n");
2361 IOleCommandTarget_Release(cmdtrg
);
2367 static const ICustomDocVtbl CustomDocVtbl
= {
2368 CustomDoc_QueryInterface
,
2371 CustomDoc_SetUIHandler
2374 static const tid_t HTMLDocumentObj_iface_tids
[] = {
2381 static dispex_static_data_t HTMLDocumentObj_dispex
= {
2383 DispHTMLDocument_tid
,
2385 HTMLDocumentObj_iface_tids
2388 HRESULT
HTMLDocument_Create(IUnknown
*pUnkOuter
, REFIID riid
, void** ppvObject
)
2390 HTMLDocumentObj
*doc
;
2391 nsIDOMWindow
*nswindow
= NULL
;
2395 TRACE("(%p %s %p)\n", pUnkOuter
, debugstr_guid(riid
), ppvObject
);
2397 doc
= heap_alloc_zero(sizeof(HTMLDocumentObj
));
2399 return E_OUTOFMEMORY
;
2401 init_dispex(&doc
->dispex
, (IUnknown
*)&doc
->ICustomDoc_iface
, &HTMLDocumentObj_dispex
);
2402 init_doc(&doc
->basedoc
, (IUnknown
*)&doc
->ICustomDoc_iface
, &doc
->dispex
.IDispatchEx_iface
);
2403 TargetContainer_Init(doc
);
2405 doc
->ICustomDoc_iface
.lpVtbl
= &CustomDocVtbl
;
2407 doc
->basedoc
.doc_obj
= doc
;
2409 doc
->usermode
= UNKNOWN_USERMODE
;
2411 hres
= create_nscontainer(doc
, NULL
, &doc
->nscontainer
);
2413 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2414 htmldoc_release(&doc
->basedoc
);
2418 hres
= htmldoc_query_interface(&doc
->basedoc
, riid
, ppvObject
);
2419 htmldoc_release(&doc
->basedoc
);
2424 nsres
= nsIWebBrowser_GetContentDOMWindow(doc
->nscontainer
->webbrowser
, &nswindow
);
2425 if(NS_FAILED(nsres
))
2426 ERR("GetContentDOMWindow failed: %08x\n", nsres
);
2428 hres
= HTMLWindow_Create(doc
, nswindow
, NULL
/* FIXME */, &doc
->basedoc
.window
);
2430 nsIDOMWindow_Release(nswindow
);
2432 htmldoc_release(&doc
->basedoc
);
2436 if(!doc
->basedoc
.doc_node
&& doc
->basedoc
.window
->doc
) {
2437 doc
->basedoc
.doc_node
= doc
->basedoc
.window
->doc
;
2438 htmldoc_addref(&doc
->basedoc
.doc_node
->basedoc
);