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
);
625 FIXME("(%p)->(%p)\n", This
, p
);
629 static HRESULT WINAPI
HTMLDocument_put_cookie(IHTMLDocument2
*iface
, BSTR v
)
631 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
634 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
636 bret
= InternetSetCookieExW(This
->window
->url
, NULL
, v
, 0, 0);
638 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
639 return HRESULT_FROM_WIN32(GetLastError());
645 static HRESULT WINAPI
HTMLDocument_get_cookie(IHTMLDocument2
*iface
, BSTR
*p
)
647 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
651 TRACE("(%p)->(%p)\n", This
, p
);
654 bret
= InternetGetCookieExW(This
->window
->url
, NULL
, NULL
, &size
, 0, NULL
);
656 switch(GetLastError()) {
657 case ERROR_INSUFFICIENT_BUFFER
:
659 case ERROR_NO_MORE_ITEMS
:
663 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
664 return HRESULT_FROM_WIN32(GetLastError());
673 *p
= SysAllocStringLen(NULL
, size
-1);
675 return E_OUTOFMEMORY
;
677 bret
= InternetGetCookieExW(This
->window
->url
, NULL
, *p
, &size
, 0, NULL
);
679 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
686 static HRESULT WINAPI
HTMLDocument_put_expando(IHTMLDocument2
*iface
, VARIANT_BOOL v
)
688 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
689 FIXME("(%p)->(%x)\n", This
, v
);
693 static HRESULT WINAPI
HTMLDocument_get_expando(IHTMLDocument2
*iface
, VARIANT_BOOL
*p
)
695 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
696 FIXME("(%p)->(%p)\n", This
, p
);
700 static HRESULT WINAPI
HTMLDocument_put_charset(IHTMLDocument2
*iface
, BSTR v
)
702 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
703 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
707 static HRESULT WINAPI
HTMLDocument_get_charset(IHTMLDocument2
*iface
, BSTR
*p
)
709 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
710 FIXME("(%p)->(%p)\n", This
, p
);
714 static HRESULT WINAPI
HTMLDocument_put_defaultCharset(IHTMLDocument2
*iface
, BSTR v
)
716 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
717 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
721 static HRESULT WINAPI
HTMLDocument_get_defaultCharset(IHTMLDocument2
*iface
, BSTR
*p
)
723 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
724 FIXME("(%p)->(%p)\n", This
, p
);
728 static HRESULT WINAPI
HTMLDocument_get_mimeType(IHTMLDocument2
*iface
, BSTR
*p
)
730 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
731 FIXME("(%p)->(%p)\n", This
, p
);
735 static HRESULT WINAPI
HTMLDocument_get_fileSize(IHTMLDocument2
*iface
, BSTR
*p
)
737 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
738 FIXME("(%p)->(%p)\n", This
, p
);
742 static HRESULT WINAPI
HTMLDocument_get_fileCreatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
744 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
745 FIXME("(%p)->(%p)\n", This
, p
);
749 static HRESULT WINAPI
HTMLDocument_get_fileModifiedDate(IHTMLDocument2
*iface
, BSTR
*p
)
751 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
752 FIXME("(%p)->(%p)\n", This
, p
);
756 static HRESULT WINAPI
HTMLDocument_get_fileUpdatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
758 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
759 FIXME("(%p)->(%p)\n", This
, p
);
763 static HRESULT WINAPI
HTMLDocument_get_security(IHTMLDocument2
*iface
, BSTR
*p
)
765 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
766 FIXME("(%p)->(%p)\n", This
, p
);
770 static HRESULT WINAPI
HTMLDocument_get_protocol(IHTMLDocument2
*iface
, BSTR
*p
)
772 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
773 FIXME("(%p)->(%p)\n", This
, p
);
777 static HRESULT WINAPI
HTMLDocument_get_nameProp(IHTMLDocument2
*iface
, BSTR
*p
)
779 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
780 FIXME("(%p)->(%p)\n", This
, p
);
784 static HRESULT
document_write(HTMLDocument
*This
, SAFEARRAY
*psarray
, BOOL ln
)
792 if(!This
->doc_node
->nsdoc
) {
793 WARN("NULL nsdoc\n");
800 if(psarray
->cDims
!= 1) {
801 FIXME("cDims=%d\n", psarray
->cDims
);
805 hres
= SafeArrayAccessData(psarray
, (void**)&var
);
807 WARN("SafeArrayAccessData failed: %08x\n", hres
);
811 nsAString_Init(&nsstr
, NULL
);
813 argc
= psarray
->rgsabound
[0].cElements
;
814 for(i
=0; i
< argc
; i
++) {
815 if(V_VT(var
+i
) == VT_BSTR
) {
816 nsAString_SetData(&nsstr
, V_BSTR(var
+i
));
817 if(!ln
|| i
!= argc
-1)
818 nsres
= nsIDOMHTMLDocument_Write(This
->doc_node
->nsdoc
, &nsstr
, NULL
/* FIXME! */);
820 nsres
= nsIDOMHTMLDocument_Writeln(This
->doc_node
->nsdoc
, &nsstr
, NULL
/* FIXME! */);
822 ERR("Write failed: %08x\n", nsres
);
824 FIXME("unsupported arg[%d] = %s\n", i
, debugstr_variant(var
+i
));
828 nsAString_Finish(&nsstr
);
829 SafeArrayUnaccessData(psarray
);
834 static HRESULT WINAPI
HTMLDocument_write(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
836 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
838 TRACE("(%p)->(%p)\n", iface
, psarray
);
840 return document_write(This
, psarray
, FALSE
);
843 static HRESULT WINAPI
HTMLDocument_writeln(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
845 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
847 TRACE("(%p)->(%p)\n", This
, psarray
);
849 return document_write(This
, psarray
, TRUE
);
852 static HRESULT WINAPI
HTMLDocument_open(IHTMLDocument2
*iface
, BSTR url
, VARIANT name
,
853 VARIANT features
, VARIANT replace
, IDispatch
**pomWindowResult
)
855 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
859 static const WCHAR text_htmlW
[] = {'t','e','x','t','/','h','t','m','l',0};
861 TRACE("(%p)->(%s %s %s %s %p)\n", This
, debugstr_w(url
), debugstr_variant(&name
),
862 debugstr_variant(&features
), debugstr_variant(&replace
), pomWindowResult
);
864 if(!This
->doc_node
->nsdoc
) {
869 if(!url
|| strcmpW(url
, text_htmlW
) || V_VT(&name
) != VT_ERROR
870 || V_VT(&features
) != VT_ERROR
|| V_VT(&replace
) != VT_ERROR
)
871 FIXME("unsupported args\n");
873 nsres
= nsIDOMHTMLDocument_Open(This
->doc_node
->nsdoc
, NULL
, NULL
, NULL
, NULL
, 0, &tmp
);
874 if(NS_FAILED(nsres
)) {
875 ERR("Open failed: %08x\n", nsres
);
880 nsISupports_Release(tmp
);
882 *pomWindowResult
= (IDispatch
*)&This
->window
->IHTMLWindow2_iface
;
883 IHTMLWindow2_AddRef(&This
->window
->IHTMLWindow2_iface
);
887 static HRESULT WINAPI
HTMLDocument_close(IHTMLDocument2
*iface
)
889 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
892 TRACE("(%p)\n", This
);
894 if(!This
->doc_node
->nsdoc
) {
899 nsres
= nsIDOMHTMLDocument_Close(This
->doc_node
->nsdoc
);
900 if(NS_FAILED(nsres
)) {
901 ERR("Close failed: %08x\n", nsres
);
908 static HRESULT WINAPI
HTMLDocument_clear(IHTMLDocument2
*iface
)
910 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
913 TRACE("(%p)\n", This
);
915 nsres
= nsIDOMHTMLDocument_Clear(This
->doc_node
->nsdoc
);
916 if(NS_FAILED(nsres
)) {
917 ERR("Clear failed: %08x\n", nsres
);
924 static HRESULT WINAPI
HTMLDocument_queryCommandSupported(IHTMLDocument2
*iface
, BSTR cmdID
,
927 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
928 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
932 static HRESULT WINAPI
HTMLDocument_queryCommandEnabled(IHTMLDocument2
*iface
, BSTR cmdID
,
935 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
936 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
940 static HRESULT WINAPI
HTMLDocument_queryCommandState(IHTMLDocument2
*iface
, BSTR cmdID
,
943 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
944 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
948 static HRESULT WINAPI
HTMLDocument_queryCommandIndeterm(IHTMLDocument2
*iface
, BSTR cmdID
,
951 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
952 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
956 static HRESULT WINAPI
HTMLDocument_queryCommandText(IHTMLDocument2
*iface
, BSTR cmdID
,
959 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
960 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
964 static HRESULT WINAPI
HTMLDocument_queryCommandValue(IHTMLDocument2
*iface
, BSTR cmdID
,
967 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
968 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
972 static HRESULT WINAPI
HTMLDocument_execCommand(IHTMLDocument2
*iface
, BSTR cmdID
,
973 VARIANT_BOOL showUI
, VARIANT value
, VARIANT_BOOL
*pfRet
)
975 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
976 FIXME("(%p)->(%s %x %s %p)\n", This
, debugstr_w(cmdID
), showUI
, debugstr_variant(&value
), pfRet
);
980 static HRESULT WINAPI
HTMLDocument_execCommandShowHelp(IHTMLDocument2
*iface
, BSTR cmdID
,
983 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
984 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
988 static HRESULT WINAPI
HTMLDocument_createElement(IHTMLDocument2
*iface
, BSTR eTag
,
989 IHTMLElement
**newElem
)
991 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
992 nsIDOMHTMLElement
*nselem
;
996 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(eTag
), newElem
);
998 hres
= create_nselem(This
->doc_node
, eTag
, &nselem
);
1002 hres
= HTMLElement_Create(This
->doc_node
, (nsIDOMNode
*)nselem
, TRUE
, &elem
);
1003 nsIDOMHTMLElement_Release(nselem
);
1007 *newElem
= &elem
->IHTMLElement_iface
;
1008 IHTMLElement_AddRef(&elem
->IHTMLElement_iface
);
1012 static HRESULT WINAPI
HTMLDocument_put_onhelp(IHTMLDocument2
*iface
, VARIANT v
)
1014 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1015 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1019 static HRESULT WINAPI
HTMLDocument_get_onhelp(IHTMLDocument2
*iface
, VARIANT
*p
)
1021 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1022 FIXME("(%p)->(%p)\n", This
, p
);
1026 static HRESULT WINAPI
HTMLDocument_put_onclick(IHTMLDocument2
*iface
, VARIANT v
)
1028 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1030 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1032 return set_doc_event(This
, EVENTID_CLICK
, &v
);
1035 static HRESULT WINAPI
HTMLDocument_get_onclick(IHTMLDocument2
*iface
, VARIANT
*p
)
1037 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1039 TRACE("(%p)->(%p)\n", This
, p
);
1041 return get_doc_event(This
, EVENTID_CLICK
, p
);
1044 static HRESULT WINAPI
HTMLDocument_put_ondblclick(IHTMLDocument2
*iface
, VARIANT v
)
1046 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1047 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1051 static HRESULT WINAPI
HTMLDocument_get_ondblclick(IHTMLDocument2
*iface
, VARIANT
*p
)
1053 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1054 FIXME("(%p)->(%p)\n", This
, p
);
1058 static HRESULT WINAPI
HTMLDocument_put_onkeyup(IHTMLDocument2
*iface
, VARIANT v
)
1060 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1062 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1064 return set_doc_event(This
, EVENTID_KEYUP
, &v
);
1067 static HRESULT WINAPI
HTMLDocument_get_onkeyup(IHTMLDocument2
*iface
, VARIANT
*p
)
1069 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1071 TRACE("(%p)->(%p)\n", This
, p
);
1073 return get_doc_event(This
, EVENTID_KEYUP
, p
);
1076 static HRESULT WINAPI
HTMLDocument_put_onkeydown(IHTMLDocument2
*iface
, VARIANT v
)
1078 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1080 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1082 return set_doc_event(This
, EVENTID_KEYDOWN
, &v
);
1085 static HRESULT WINAPI
HTMLDocument_get_onkeydown(IHTMLDocument2
*iface
, VARIANT
*p
)
1087 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1089 TRACE("(%p)->(%p)\n", This
, p
);
1091 return get_doc_event(This
, EVENTID_KEYDOWN
, p
);
1094 static HRESULT WINAPI
HTMLDocument_put_onkeypress(IHTMLDocument2
*iface
, VARIANT v
)
1096 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1097 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1101 static HRESULT WINAPI
HTMLDocument_get_onkeypress(IHTMLDocument2
*iface
, VARIANT
*p
)
1103 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1104 FIXME("(%p)->(%p)\n", This
, p
);
1108 static HRESULT WINAPI
HTMLDocument_put_onmouseup(IHTMLDocument2
*iface
, VARIANT v
)
1110 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1112 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1114 return set_doc_event(This
, EVENTID_MOUSEUP
, &v
);
1117 static HRESULT WINAPI
HTMLDocument_get_onmouseup(IHTMLDocument2
*iface
, VARIANT
*p
)
1119 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1121 TRACE("(%p)->(%p)\n", This
, p
);
1123 return get_doc_event(This
, EVENTID_MOUSEUP
, p
);
1126 static HRESULT WINAPI
HTMLDocument_put_onmousedown(IHTMLDocument2
*iface
, VARIANT v
)
1128 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1130 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1132 return set_doc_event(This
, EVENTID_MOUSEDOWN
, &v
);
1135 static HRESULT WINAPI
HTMLDocument_get_onmousedown(IHTMLDocument2
*iface
, VARIANT
*p
)
1137 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1139 TRACE("(%p)->(%p)\n", This
, p
);
1141 return get_doc_event(This
, EVENTID_MOUSEDOWN
, p
);
1144 static HRESULT WINAPI
HTMLDocument_put_onmousemove(IHTMLDocument2
*iface
, VARIANT v
)
1146 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1148 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1150 return set_doc_event(This
, EVENTID_MOUSEMOVE
, &v
);
1153 static HRESULT WINAPI
HTMLDocument_get_onmousemove(IHTMLDocument2
*iface
, VARIANT
*p
)
1155 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1157 TRACE("(%p)->(%p)\n", This
, p
);
1159 return get_doc_event(This
, EVENTID_MOUSEMOVE
, p
);
1162 static HRESULT WINAPI
HTMLDocument_put_onmouseout(IHTMLDocument2
*iface
, VARIANT v
)
1164 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1166 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1168 return set_doc_event(This
, EVENTID_MOUSEOUT
, &v
);
1171 static HRESULT WINAPI
HTMLDocument_get_onmouseout(IHTMLDocument2
*iface
, VARIANT
*p
)
1173 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1175 TRACE("(%p)->(%p)\n", This
, p
);
1177 return get_doc_event(This
, EVENTID_MOUSEOUT
, p
);
1180 static HRESULT WINAPI
HTMLDocument_put_onmouseover(IHTMLDocument2
*iface
, VARIANT v
)
1182 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1184 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1186 return set_doc_event(This
, EVENTID_MOUSEOVER
, &v
);
1189 static HRESULT WINAPI
HTMLDocument_get_onmouseover(IHTMLDocument2
*iface
, VARIANT
*p
)
1191 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1193 TRACE("(%p)->(%p)\n", This
, p
);
1195 return get_doc_event(This
, EVENTID_MOUSEOVER
, p
);
1198 static HRESULT WINAPI
HTMLDocument_put_onreadystatechange(IHTMLDocument2
*iface
, VARIANT v
)
1200 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1202 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1204 return set_doc_event(This
, EVENTID_READYSTATECHANGE
, &v
);
1207 static HRESULT WINAPI
HTMLDocument_get_onreadystatechange(IHTMLDocument2
*iface
, VARIANT
*p
)
1209 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1211 TRACE("(%p)->(%p)\n", This
, p
);
1213 return get_doc_event(This
, EVENTID_READYSTATECHANGE
, p
);
1216 static HRESULT WINAPI
HTMLDocument_put_onafterupdate(IHTMLDocument2
*iface
, VARIANT v
)
1218 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1219 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1223 static HRESULT WINAPI
HTMLDocument_get_onafterupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1225 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1226 FIXME("(%p)->(%p)\n", This
, p
);
1230 static HRESULT WINAPI
HTMLDocument_put_onrowexit(IHTMLDocument2
*iface
, VARIANT v
)
1232 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1233 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1237 static HRESULT WINAPI
HTMLDocument_get_onrowexit(IHTMLDocument2
*iface
, VARIANT
*p
)
1239 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1240 FIXME("(%p)->(%p)\n", This
, p
);
1244 static HRESULT WINAPI
HTMLDocument_put_onrowenter(IHTMLDocument2
*iface
, VARIANT v
)
1246 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1247 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1251 static HRESULT WINAPI
HTMLDocument_get_onrowenter(IHTMLDocument2
*iface
, VARIANT
*p
)
1253 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1254 FIXME("(%p)->(%p)\n", This
, p
);
1258 static HRESULT WINAPI
HTMLDocument_put_ondragstart(IHTMLDocument2
*iface
, VARIANT v
)
1260 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1262 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1264 return set_doc_event(This
, EVENTID_DRAGSTART
, &v
);
1267 static HRESULT WINAPI
HTMLDocument_get_ondragstart(IHTMLDocument2
*iface
, VARIANT
*p
)
1269 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1271 TRACE("(%p)->(%p)\n", This
, p
);
1273 return get_doc_event(This
, EVENTID_DRAGSTART
, p
);
1276 static HRESULT WINAPI
HTMLDocument_put_onselectstart(IHTMLDocument2
*iface
, VARIANT v
)
1278 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1280 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1282 return set_doc_event(This
, EVENTID_SELECTSTART
, &v
);
1285 static HRESULT WINAPI
HTMLDocument_get_onselectstart(IHTMLDocument2
*iface
, VARIANT
*p
)
1287 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1289 TRACE("(%p)->(%p)\n", This
, p
);
1291 return get_doc_event(This
, EVENTID_SELECTSTART
, p
);
1294 static HRESULT WINAPI
HTMLDocument_elementFromPoint(IHTMLDocument2
*iface
, LONG x
, LONG y
,
1295 IHTMLElement
**elementHit
)
1297 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1298 nsIDOMElement
*nselem
;
1303 TRACE("(%p)->(%d %d %p)\n", This
, x
, y
, elementHit
);
1305 nsres
= nsIDOMHTMLDocument_ElementFromPoint(This
->doc_node
->nsdoc
, x
, y
, &nselem
);
1306 if(NS_FAILED(nsres
)) {
1307 ERR("ElementFromPoint failed: %08x\n", nsres
);
1316 hres
= get_node(This
->doc_node
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
1317 nsIDOMElement_Release(nselem
);
1321 return IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)elementHit
);
1324 static HRESULT WINAPI
HTMLDocument_get_parentWindow(IHTMLDocument2
*iface
, IHTMLWindow2
**p
)
1326 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1328 TRACE("(%p)->(%p)\n", This
, p
);
1330 *p
= &This
->window
->IHTMLWindow2_iface
;
1331 IHTMLWindow2_AddRef(*p
);
1335 static HRESULT WINAPI
HTMLDocument_get_styleSheets(IHTMLDocument2
*iface
,
1336 IHTMLStyleSheetsCollection
**p
)
1338 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1339 nsIDOMStyleSheetList
*nsstylelist
;
1342 TRACE("(%p)->(%p)\n", This
, p
);
1346 if(!This
->doc_node
->nsdoc
) {
1347 WARN("NULL nsdoc\n");
1348 return E_UNEXPECTED
;
1351 nsres
= nsIDOMHTMLDocument_GetStyleSheets(This
->doc_node
->nsdoc
, &nsstylelist
);
1352 if(NS_FAILED(nsres
)) {
1353 ERR("GetStyleSheets failed: %08x\n", nsres
);
1357 *p
= HTMLStyleSheetsCollection_Create(nsstylelist
);
1358 nsIDOMStyleSheetList_Release(nsstylelist
);
1363 static HRESULT WINAPI
HTMLDocument_put_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT v
)
1365 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1366 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1370 static HRESULT WINAPI
HTMLDocument_get_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1372 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1373 FIXME("(%p)->(%p)\n", This
, p
);
1377 static HRESULT WINAPI
HTMLDocument_put_onerrorupdate(IHTMLDocument2
*iface
, VARIANT v
)
1379 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1380 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1384 static HRESULT WINAPI
HTMLDocument_get_onerrorupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1386 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1387 FIXME("(%p)->(%p)\n", This
, p
);
1391 static HRESULT WINAPI
HTMLDocument_toString(IHTMLDocument2
*iface
, BSTR
*String
)
1393 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1394 FIXME("(%p)->(%p)\n", This
, String
);
1398 static HRESULT WINAPI
HTMLDocument_createStyleSheet(IHTMLDocument2
*iface
, BSTR bstrHref
,
1399 LONG lIndex
, IHTMLStyleSheet
**ppnewStyleSheet
)
1401 HTMLDocument
*This
= impl_from_IHTMLDocument2(iface
);
1403 FIXME("(%p)->(%s %d %p) semi-stub\n", This
, debugstr_w(bstrHref
), lIndex
, ppnewStyleSheet
);
1405 *ppnewStyleSheet
= HTMLStyleSheet_Create(NULL
);
1409 static const IHTMLDocument2Vtbl HTMLDocumentVtbl
= {
1410 HTMLDocument_QueryInterface
,
1411 HTMLDocument_AddRef
,
1412 HTMLDocument_Release
,
1413 HTMLDocument_GetTypeInfoCount
,
1414 HTMLDocument_GetTypeInfo
,
1415 HTMLDocument_GetIDsOfNames
,
1416 HTMLDocument_Invoke
,
1417 HTMLDocument_get_Script
,
1418 HTMLDocument_get_all
,
1419 HTMLDocument_get_body
,
1420 HTMLDocument_get_activeElement
,
1421 HTMLDocument_get_images
,
1422 HTMLDocument_get_applets
,
1423 HTMLDocument_get_links
,
1424 HTMLDocument_get_forms
,
1425 HTMLDocument_get_anchors
,
1426 HTMLDocument_put_title
,
1427 HTMLDocument_get_title
,
1428 HTMLDocument_get_scripts
,
1429 HTMLDocument_put_designMode
,
1430 HTMLDocument_get_designMode
,
1431 HTMLDocument_get_selection
,
1432 HTMLDocument_get_readyState
,
1433 HTMLDocument_get_frames
,
1434 HTMLDocument_get_embeds
,
1435 HTMLDocument_get_plugins
,
1436 HTMLDocument_put_alinkColor
,
1437 HTMLDocument_get_alinkColor
,
1438 HTMLDocument_put_bgColor
,
1439 HTMLDocument_get_bgColor
,
1440 HTMLDocument_put_fgColor
,
1441 HTMLDocument_get_fgColor
,
1442 HTMLDocument_put_linkColor
,
1443 HTMLDocument_get_linkColor
,
1444 HTMLDocument_put_vlinkColor
,
1445 HTMLDocument_get_vlinkColor
,
1446 HTMLDocument_get_referrer
,
1447 HTMLDocument_get_location
,
1448 HTMLDocument_get_lastModified
,
1449 HTMLDocument_put_URL
,
1450 HTMLDocument_get_URL
,
1451 HTMLDocument_put_domain
,
1452 HTMLDocument_get_domain
,
1453 HTMLDocument_put_cookie
,
1454 HTMLDocument_get_cookie
,
1455 HTMLDocument_put_expando
,
1456 HTMLDocument_get_expando
,
1457 HTMLDocument_put_charset
,
1458 HTMLDocument_get_charset
,
1459 HTMLDocument_put_defaultCharset
,
1460 HTMLDocument_get_defaultCharset
,
1461 HTMLDocument_get_mimeType
,
1462 HTMLDocument_get_fileSize
,
1463 HTMLDocument_get_fileCreatedDate
,
1464 HTMLDocument_get_fileModifiedDate
,
1465 HTMLDocument_get_fileUpdatedDate
,
1466 HTMLDocument_get_security
,
1467 HTMLDocument_get_protocol
,
1468 HTMLDocument_get_nameProp
,
1470 HTMLDocument_writeln
,
1474 HTMLDocument_queryCommandSupported
,
1475 HTMLDocument_queryCommandEnabled
,
1476 HTMLDocument_queryCommandState
,
1477 HTMLDocument_queryCommandIndeterm
,
1478 HTMLDocument_queryCommandText
,
1479 HTMLDocument_queryCommandValue
,
1480 HTMLDocument_execCommand
,
1481 HTMLDocument_execCommandShowHelp
,
1482 HTMLDocument_createElement
,
1483 HTMLDocument_put_onhelp
,
1484 HTMLDocument_get_onhelp
,
1485 HTMLDocument_put_onclick
,
1486 HTMLDocument_get_onclick
,
1487 HTMLDocument_put_ondblclick
,
1488 HTMLDocument_get_ondblclick
,
1489 HTMLDocument_put_onkeyup
,
1490 HTMLDocument_get_onkeyup
,
1491 HTMLDocument_put_onkeydown
,
1492 HTMLDocument_get_onkeydown
,
1493 HTMLDocument_put_onkeypress
,
1494 HTMLDocument_get_onkeypress
,
1495 HTMLDocument_put_onmouseup
,
1496 HTMLDocument_get_onmouseup
,
1497 HTMLDocument_put_onmousedown
,
1498 HTMLDocument_get_onmousedown
,
1499 HTMLDocument_put_onmousemove
,
1500 HTMLDocument_get_onmousemove
,
1501 HTMLDocument_put_onmouseout
,
1502 HTMLDocument_get_onmouseout
,
1503 HTMLDocument_put_onmouseover
,
1504 HTMLDocument_get_onmouseover
,
1505 HTMLDocument_put_onreadystatechange
,
1506 HTMLDocument_get_onreadystatechange
,
1507 HTMLDocument_put_onafterupdate
,
1508 HTMLDocument_get_onafterupdate
,
1509 HTMLDocument_put_onrowexit
,
1510 HTMLDocument_get_onrowexit
,
1511 HTMLDocument_put_onrowenter
,
1512 HTMLDocument_get_onrowenter
,
1513 HTMLDocument_put_ondragstart
,
1514 HTMLDocument_get_ondragstart
,
1515 HTMLDocument_put_onselectstart
,
1516 HTMLDocument_get_onselectstart
,
1517 HTMLDocument_elementFromPoint
,
1518 HTMLDocument_get_parentWindow
,
1519 HTMLDocument_get_styleSheets
,
1520 HTMLDocument_put_onbeforeupdate
,
1521 HTMLDocument_get_onbeforeupdate
,
1522 HTMLDocument_put_onerrorupdate
,
1523 HTMLDocument_get_onerrorupdate
,
1524 HTMLDocument_toString
,
1525 HTMLDocument_createStyleSheet
1528 static void HTMLDocument_on_advise(IUnknown
*iface
, cp_static_data_t
*cp
)
1530 HTMLDocument
*This
= impl_from_IHTMLDocument2((IHTMLDocument2
*)iface
);
1533 update_cp_events(This
->window
, &This
->doc_node
->node
.event_target
, cp
, This
->doc_node
->node
.nsnode
);
1536 static inline HTMLDocument
*impl_from_ISupportErrorInfo(ISupportErrorInfo
*iface
)
1538 return CONTAINING_RECORD(iface
, HTMLDocument
, ISupportErrorInfo_iface
);
1541 static HRESULT WINAPI
SupportErrorInfo_QueryInterface(ISupportErrorInfo
*iface
, REFIID riid
, void **ppv
)
1543 HTMLDocument
*This
= impl_from_ISupportErrorInfo(iface
);
1544 return htmldoc_query_interface(This
, riid
, ppv
);
1547 static ULONG WINAPI
SupportErrorInfo_AddRef(ISupportErrorInfo
*iface
)
1549 HTMLDocument
*This
= impl_from_ISupportErrorInfo(iface
);
1550 return htmldoc_addref(This
);
1553 static ULONG WINAPI
SupportErrorInfo_Release(ISupportErrorInfo
*iface
)
1555 HTMLDocument
*This
= impl_from_ISupportErrorInfo(iface
);
1556 return htmldoc_release(This
);
1559 static HRESULT WINAPI
SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo
*iface
, REFIID riid
)
1561 FIXME("(%p)->(%s)\n", iface
, debugstr_guid(riid
));
1565 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl
= {
1566 SupportErrorInfo_QueryInterface
,
1567 SupportErrorInfo_AddRef
,
1568 SupportErrorInfo_Release
,
1569 SupportErrorInfo_InterfaceSupportsErrorInfo
1572 static inline HTMLDocument
*impl_from_IDispatchEx(IDispatchEx
*iface
)
1574 return CONTAINING_RECORD(iface
, HTMLDocument
, IDispatchEx_iface
);
1577 static HRESULT
dispid_from_elem_name(HTMLDocumentNode
*This
, BSTR name
, DISPID
*dispid
)
1579 nsIDOMNodeList
*node_list
;
1586 return DISP_E_UNKNOWNNAME
;
1588 nsAString_InitDepend(&name_str
, name
);
1589 nsres
= nsIDOMHTMLDocument_GetElementsByName(This
->nsdoc
, &name_str
, &node_list
);
1590 nsAString_Finish(&name_str
);
1591 if(NS_FAILED(nsres
))
1594 nsres
= nsIDOMNodeList_GetLength(node_list
, &len
);
1595 nsIDOMNodeList_Release(node_list
);
1596 if(NS_FAILED(nsres
))
1600 return DISP_E_UNKNOWNNAME
;
1602 for(i
=0; i
< This
->elem_vars_cnt
; i
++) {
1603 if(!strcmpW(name
, This
->elem_vars
[i
])) {
1604 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
1609 if(This
->elem_vars_cnt
== This
->elem_vars_size
) {
1612 if(This
->elem_vars_size
) {
1613 new_vars
= heap_realloc(This
->elem_vars
, This
->elem_vars_size
*2*sizeof(WCHAR
*));
1615 return E_OUTOFMEMORY
;
1616 This
->elem_vars_size
*= 2;
1618 new_vars
= heap_alloc(16*sizeof(WCHAR
*));
1620 return E_OUTOFMEMORY
;
1621 This
->elem_vars_size
= 16;
1624 This
->elem_vars
= new_vars
;
1627 This
->elem_vars
[This
->elem_vars_cnt
] = heap_strdupW(name
);
1628 if(!This
->elem_vars
[This
->elem_vars_cnt
])
1629 return E_OUTOFMEMORY
;
1631 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+This
->elem_vars_cnt
++;
1635 static HRESULT WINAPI
DocDispatchEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
1637 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1639 return htmldoc_query_interface(This
, riid
, ppv
);
1642 static ULONG WINAPI
DocDispatchEx_AddRef(IDispatchEx
*iface
)
1644 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1646 return htmldoc_addref(This
);
1649 static ULONG WINAPI
DocDispatchEx_Release(IDispatchEx
*iface
)
1651 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1653 return htmldoc_release(This
);
1656 static HRESULT WINAPI
DocDispatchEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
1658 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1660 return IDispatchEx_GetTypeInfoCount(This
->dispex
, pctinfo
);
1663 static HRESULT WINAPI
DocDispatchEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
1664 LCID lcid
, ITypeInfo
**ppTInfo
)
1666 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1668 return IDispatchEx_GetTypeInfo(This
->dispex
, iTInfo
, lcid
, ppTInfo
);
1671 static HRESULT WINAPI
DocDispatchEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
1672 LPOLESTR
*rgszNames
, UINT cNames
,
1673 LCID lcid
, DISPID
*rgDispId
)
1675 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1677 return IDispatchEx_GetIDsOfNames(This
->dispex
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1680 static HRESULT WINAPI
DocDispatchEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
1681 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1682 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1684 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1686 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1687 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1689 switch(dispIdMember
) {
1690 case DISPID_READYSTATE
:
1691 TRACE("DISPID_READYSTATE\n");
1693 if(!(wFlags
& DISPATCH_PROPERTYGET
))
1694 return E_INVALIDARG
;
1696 V_VT(pVarResult
) = VT_I4
;
1697 V_I4(pVarResult
) = This
->window
->readystate
;
1701 return IDispatchEx_Invoke(This
->dispex
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1702 pVarResult
, pExcepInfo
, puArgErr
);
1705 static HRESULT WINAPI
DocDispatchEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1707 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1710 hres
= IDispatchEx_GetDispID(This
->dispex
, bstrName
, grfdex
, pid
);
1711 if(hres
!= DISP_E_UNKNOWNNAME
)
1714 return dispid_from_elem_name(This
->doc_node
, bstrName
, pid
);
1717 static HRESULT WINAPI
DocDispatchEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1718 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1720 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1722 if(This
->window
&& id
== DISPID_IHTMLDOCUMENT2_LOCATION
&& (wFlags
& DISPATCH_PROPERTYPUT
))
1723 return IDispatchEx_InvokeEx(&This
->window
->IDispatchEx_iface
, DISPID_IHTMLWINDOW2_LOCATION
,
1724 lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1727 return IDispatchEx_InvokeEx(This
->dispex
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1730 static HRESULT WINAPI
DocDispatchEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
1732 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1734 return IDispatchEx_DeleteMemberByName(This
->dispex
, bstrName
, grfdex
);
1737 static HRESULT WINAPI
DocDispatchEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
1739 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1741 return IDispatchEx_DeleteMemberByDispID(This
->dispex
, id
);
1744 static HRESULT WINAPI
DocDispatchEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
1746 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1748 return IDispatchEx_GetMemberProperties(This
->dispex
, id
, grfdexFetch
, pgrfdex
);
1751 static HRESULT WINAPI
DocDispatchEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
1753 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1755 return IDispatchEx_GetMemberName(This
->dispex
, id
, pbstrName
);
1758 static HRESULT WINAPI
DocDispatchEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
1760 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1762 return IDispatchEx_GetNextDispID(This
->dispex
, grfdex
, id
, pid
);
1765 static HRESULT WINAPI
DocDispatchEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
1767 HTMLDocument
*This
= impl_from_IDispatchEx(iface
);
1769 return IDispatchEx_GetNameSpaceParent(This
->dispex
, ppunk
);
1772 static const IDispatchExVtbl DocDispatchExVtbl
= {
1773 DocDispatchEx_QueryInterface
,
1774 DocDispatchEx_AddRef
,
1775 DocDispatchEx_Release
,
1776 DocDispatchEx_GetTypeInfoCount
,
1777 DocDispatchEx_GetTypeInfo
,
1778 DocDispatchEx_GetIDsOfNames
,
1779 DocDispatchEx_Invoke
,
1780 DocDispatchEx_GetDispID
,
1781 DocDispatchEx_InvokeEx
,
1782 DocDispatchEx_DeleteMemberByName
,
1783 DocDispatchEx_DeleteMemberByDispID
,
1784 DocDispatchEx_GetMemberProperties
,
1785 DocDispatchEx_GetMemberName
,
1786 DocDispatchEx_GetNextDispID
,
1787 DocDispatchEx_GetNameSpaceParent
1790 static inline HTMLDocument
*impl_from_IProvideClassInfo(IProvideClassInfo
*iface
)
1792 return CONTAINING_RECORD(iface
, HTMLDocument
, IProvideClassInfo_iface
);
1795 static HRESULT WINAPI
ProvideClassInfo_QueryInterface(IProvideClassInfo
*iface
,
1796 REFIID riid
, void **ppv
)
1798 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1799 return htmldoc_query_interface(This
, riid
, ppv
);
1802 static ULONG WINAPI
ProvideClassInfo_AddRef(IProvideClassInfo
*iface
)
1804 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1805 return htmldoc_addref(This
);
1808 static ULONG WINAPI
ProvideClassInfo_Release(IProvideClassInfo
*iface
)
1810 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1811 return htmldoc_release(This
);
1814 static HRESULT WINAPI
ProvideClassInfo_GetClassInfo(IProvideClassInfo
* iface
,
1817 HTMLDocument
*This
= impl_from_IProvideClassInfo(iface
);
1818 TRACE("(%p)->(%p)\n", This
, ppTI
);
1819 return get_htmldoc_classinfo(ppTI
);
1822 static const IProvideClassInfoVtbl ProvideClassInfoVtbl
= {
1823 ProvideClassInfo_QueryInterface
,
1824 ProvideClassInfo_AddRef
,
1825 ProvideClassInfo_Release
,
1826 ProvideClassInfo_GetClassInfo
1829 static BOOL
htmldoc_qi(HTMLDocument
*This
, REFIID riid
, void **ppv
)
1833 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1834 TRACE("(%p)->(IID_IUnknown, %p)\n", This
, ppv
);
1835 *ppv
= &This
->IHTMLDocument2_iface
;
1836 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1837 TRACE("(%p)->(IID_IDispatch, %p)\n", This
, ppv
);
1838 *ppv
= &This
->IDispatchEx_iface
;
1839 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
1840 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This
, ppv
);
1841 *ppv
= &This
->IDispatchEx_iface
;
1842 }else if(IsEqualGUID(&IID_IHTMLDocument
, riid
)) {
1843 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This
, ppv
);
1844 *ppv
= &This
->IHTMLDocument2_iface
;
1845 }else if(IsEqualGUID(&IID_IHTMLDocument2
, riid
)) {
1846 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This
, ppv
);
1847 *ppv
= &This
->IHTMLDocument2_iface
;
1848 }else if(IsEqualGUID(&IID_IHTMLDocument3
, riid
)) {
1849 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This
, ppv
);
1850 *ppv
= &This
->IHTMLDocument3_iface
;
1851 }else if(IsEqualGUID(&IID_IHTMLDocument4
, riid
)) {
1852 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This
, ppv
);
1853 *ppv
= &This
->IHTMLDocument4_iface
;
1854 }else if(IsEqualGUID(&IID_IHTMLDocument5
, riid
)) {
1855 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This
, ppv
);
1856 *ppv
= &This
->IHTMLDocument5_iface
;
1857 }else if(IsEqualGUID(&IID_IHTMLDocument6
, riid
)) {
1858 TRACE("(%p)->(IID_IHTMLDocument6, %p)\n", This
, ppv
);
1859 *ppv
= &This
->IHTMLDocument6_iface
;
1860 }else if(IsEqualGUID(&IID_IPersist
, riid
)) {
1861 TRACE("(%p)->(IID_IPersist, %p)\n", This
, ppv
);
1862 *ppv
= &This
->IPersistFile_iface
;
1863 }else if(IsEqualGUID(&IID_IPersistMoniker
, riid
)) {
1864 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This
, ppv
);
1865 *ppv
= &This
->IPersistMoniker_iface
;
1866 }else if(IsEqualGUID(&IID_IPersistFile
, riid
)) {
1867 TRACE("(%p)->(IID_IPersistFile, %p)\n", This
, ppv
);
1868 *ppv
= &This
->IPersistFile_iface
;
1869 }else if(IsEqualGUID(&IID_IMonikerProp
, riid
)) {
1870 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This
, ppv
);
1871 *ppv
= &This
->IMonikerProp_iface
;
1872 }else if(IsEqualGUID(&IID_IOleObject
, riid
)) {
1873 TRACE("(%p)->(IID_IOleObject, %p)\n", This
, ppv
);
1874 *ppv
= &This
->IOleObject_iface
;
1875 }else if(IsEqualGUID(&IID_IOleDocument
, riid
)) {
1876 TRACE("(%p)->(IID_IOleDocument, %p)\n", This
, ppv
);
1877 *ppv
= &This
->IOleDocument_iface
;
1878 }else if(IsEqualGUID(&IID_IOleDocumentView
, riid
)) {
1879 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This
, ppv
);
1880 *ppv
= &This
->IOleDocumentView_iface
;
1881 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject
, riid
)) {
1882 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This
, ppv
);
1883 *ppv
= &This
->IOleInPlaceActiveObject_iface
;
1884 }else if(IsEqualGUID(&IID_IViewObject
, riid
)) {
1885 TRACE("(%p)->(IID_IViewObject, %p)\n", This
, ppv
);
1886 *ppv
= &This
->IViewObjectEx_iface
;
1887 }else if(IsEqualGUID(&IID_IViewObject2
, riid
)) {
1888 TRACE("(%p)->(IID_IViewObject2, %p)\n", This
, ppv
);
1889 *ppv
= &This
->IViewObjectEx_iface
;
1890 }else if(IsEqualGUID(&IID_IViewObjectEx
, riid
)) {
1891 TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This
, ppv
);
1892 *ppv
= &This
->IViewObjectEx_iface
;
1893 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
1894 TRACE("(%p)->(IID_IOleWindow, %p)\n", This
, ppv
);
1895 *ppv
= &This
->IOleInPlaceActiveObject_iface
;
1896 }else if(IsEqualGUID(&IID_IOleInPlaceObject
, riid
)) {
1897 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This
, ppv
);
1898 *ppv
= &This
->IOleInPlaceObjectWindowless_iface
;
1899 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless
, riid
)) {
1900 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This
, ppv
);
1901 *ppv
= &This
->IOleInPlaceObjectWindowless_iface
;
1902 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
1903 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This
, ppv
);
1904 *ppv
= &This
->IServiceProvider_iface
;
1905 }else if(IsEqualGUID(&IID_IOleCommandTarget
, riid
)) {
1906 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This
, ppv
);
1907 *ppv
= &This
->IOleCommandTarget_iface
;
1908 }else if(IsEqualGUID(&IID_IOleControl
, riid
)) {
1909 TRACE("(%p)->(IID_IOleControl, %p)\n", This
, ppv
);
1910 *ppv
= &This
->IOleControl_iface
;
1911 }else if(IsEqualGUID(&IID_IHlinkTarget
, riid
)) {
1912 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This
, ppv
);
1913 *ppv
= &This
->IHlinkTarget_iface
;
1914 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1915 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1916 *ppv
= &This
->cp_container
.IConnectionPointContainer_iface
;
1917 }else if(IsEqualGUID(&IID_IPersistStreamInit
, riid
)) {
1918 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This
, ppv
);
1919 *ppv
= &This
->IPersistStreamInit_iface
;
1920 }else if(IsEqualGUID(&DIID_DispHTMLDocument
, riid
)) {
1921 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This
, ppv
);
1922 *ppv
= &This
->IHTMLDocument2_iface
;
1923 }else if(IsEqualGUID(&IID_ISupportErrorInfo
, riid
)) {
1924 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This
, ppv
);
1925 *ppv
= &This
->ISupportErrorInfo_iface
;
1926 }else if(IsEqualGUID(&IID_IPersistHistory
, riid
)) {
1927 TRACE("(%p)->(IID_IPersistHistory %p)\n", This
, ppv
);
1928 *ppv
= &This
->IPersistHistory_iface
;
1929 }else if(IsEqualGUID(&CLSID_CMarkup
, riid
)) {
1930 FIXME("(%p)->(CLSID_CMarkup %p)\n", This
, ppv
);
1932 }else if(IsEqualGUID(&IID_IRunnableObject
, riid
)) {
1933 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This
, ppv
);
1935 }else if(IsEqualGUID(&IID_IPersistPropertyBag
, riid
)) {
1936 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This
, ppv
);
1938 }else if(IsEqualGUID(&IID_IMarshal
, riid
)) {
1939 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This
, ppv
);
1941 }else if(IsEqualGUID(&IID_IExternalConnection
, riid
)) {
1942 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This
, ppv
);
1944 }else if(IsEqualGUID(&IID_IStdMarshalInfo
, riid
)) {
1945 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This
, ppv
);
1947 }else if(IsEqualGUID(&IID_IObjectWithSite
, riid
)) {
1948 TRACE("(%p)->(IID_IObjectWithSite %p)\n", This
, ppv
);
1949 *ppv
= &This
->IObjectWithSite_iface
;
1950 }else if(IsEqualGUID(&IID_IOleContainer
, riid
)) {
1951 TRACE("(%p)->(IID_IOleContainer %p)\n", This
, ppv
);
1952 *ppv
= &This
->IOleContainer_iface
;
1953 }else if(IsEqualGUID(&IID_IObjectSafety
, riid
)) {
1954 TRACE("(%p)->(IID_IObjectSafety %p)\n", This
, ppv
);
1955 *ppv
= &This
->IObjectSafety_iface
;
1956 }else if(IsEqualGUID(&IID_IProvideClassInfo
, riid
)) {
1957 TRACE("(%p)->(IID_IProvideClassInfo, %p)\n", This
, ppv
);
1958 *ppv
= &This
->IProvideClassInfo_iface
;
1964 IUnknown_AddRef((IUnknown
*)*ppv
);
1968 static cp_static_data_t HTMLDocumentEvents_data
= { HTMLDocumentEvents_tid
, HTMLDocument_on_advise
};
1970 static void init_doc(HTMLDocument
*doc
, IUnknown
*unk_impl
, IDispatchEx
*dispex
)
1972 doc
->IHTMLDocument2_iface
.lpVtbl
= &HTMLDocumentVtbl
;
1973 doc
->IDispatchEx_iface
.lpVtbl
= &DocDispatchExVtbl
;
1974 doc
->ISupportErrorInfo_iface
.lpVtbl
= &SupportErrorInfoVtbl
;
1975 doc
->IProvideClassInfo_iface
.lpVtbl
= &ProvideClassInfoVtbl
;
1977 doc
->unk_impl
= unk_impl
;
1978 doc
->dispex
= dispex
;
1979 doc
->task_magic
= get_task_target_magic();
1981 HTMLDocument_HTMLDocument3_Init(doc
);
1982 HTMLDocument_HTMLDocument5_Init(doc
);
1983 HTMLDocument_Persist_Init(doc
);
1984 HTMLDocument_OleCmd_Init(doc
);
1985 HTMLDocument_OleObj_Init(doc
);
1986 HTMLDocument_View_Init(doc
);
1987 HTMLDocument_Window_Init(doc
);
1988 HTMLDocument_Service_Init(doc
);
1989 HTMLDocument_Hlink_Init(doc
);
1991 ConnectionPointContainer_Init(&doc
->cp_container
, (IUnknown
*)&doc
->IHTMLDocument2_iface
);
1992 ConnectionPoint_Init(&doc
->cp_dispatch
, &doc
->cp_container
, &IID_IDispatch
, &HTMLDocumentEvents_data
);
1993 ConnectionPoint_Init(&doc
->cp_propnotif
, &doc
->cp_container
, &IID_IPropertyNotifySink
, NULL
);
1994 ConnectionPoint_Init(&doc
->cp_htmldocevents
, &doc
->cp_container
, &DIID_HTMLDocumentEvents
, &HTMLDocumentEvents_data
);
1995 ConnectionPoint_Init(&doc
->cp_htmldocevents2
, &doc
->cp_container
, &DIID_HTMLDocumentEvents2
, NULL
);
1998 static void destroy_htmldoc(HTMLDocument
*This
)
2000 remove_target_tasks(This
->task_magic
);
2002 ConnectionPointContainer_Destroy(&This
->cp_container
);
2005 static inline HTMLDocumentNode
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
2007 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, node
);
2010 static HRESULT
HTMLDocumentNode_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
2012 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2014 if(htmldoc_qi(&This
->basedoc
, riid
, ppv
))
2015 return *ppv
? S_OK
: E_NOINTERFACE
;
2017 if(IsEqualGUID(&IID_IInternetHostSecurityManager
, riid
)) {
2018 TRACE("(%p)->(IID_IInternetHostSecurityManager %p)\n", This
, ppv
);
2019 *ppv
= &This
->IInternetHostSecurityManager_iface
;
2021 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
2024 IUnknown_AddRef((IUnknown
*)*ppv
);
2028 static void HTMLDocumentNode_destructor(HTMLDOMNode
*iface
)
2030 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2033 for(i
=0; i
< This
->elem_vars_cnt
; i
++)
2034 heap_free(This
->elem_vars
[i
]);
2035 heap_free(This
->elem_vars
);
2037 detach_events(This
);
2038 if(This
->body_event_target
)
2039 release_event_target(This
->body_event_target
);
2040 if(This
->nsevent_listener
)
2041 release_nsevents(This
);
2043 ICatInformation_Release(This
->catmgr
);
2045 detach_selection(This
);
2046 detach_ranges(This
);
2047 release_nodes(This
);
2049 while(!list_empty(&This
->plugin_hosts
))
2050 detach_plugin_host(LIST_ENTRY(list_head(&This
->plugin_hosts
), PluginHost
, entry
));
2053 release_document_mutation(This
);
2054 nsIDOMHTMLDocument_Release(This
->nsdoc
);
2057 heap_free(This
->event_vector
);
2058 destroy_htmldoc(&This
->basedoc
);
2061 static HRESULT
HTMLDocumentNode_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
2063 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2064 FIXME("%p\n", This
);
2068 static const NodeImplVtbl HTMLDocumentNodeImplVtbl
= {
2069 HTMLDocumentNode_QI
,
2070 HTMLDocumentNode_destructor
,
2071 HTMLDocumentNode_clone
2074 static HRESULT
HTMLDocumentFragment_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
2076 HTMLDocumentNode
*This
= impl_from_HTMLDOMNode(iface
);
2077 HTMLDocumentNode
*new_node
;
2080 hres
= create_document_fragment(nsnode
, This
->node
.doc
, &new_node
);
2084 *ret
= &new_node
->node
;
2088 static inline HTMLDocumentNode
*impl_from_DispatchEx(DispatchEx
*iface
)
2090 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, node
.dispex
);
2093 static HRESULT
HTMLDocumentNode_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2094 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2096 HTMLDocumentNode
*This
= impl_from_DispatchEx(dispex
);
2097 nsIDOMNodeList
*node_list
;
2105 if(flags
!= DISPATCH_PROPERTYGET
) {
2106 FIXME("unsupported flags %x\n", flags
);
2110 i
= id
- MSHTML_DISPID_CUSTOM_MIN
;
2112 if(!This
->nsdoc
|| i
>= This
->elem_vars_cnt
)
2113 return DISP_E_UNKNOWNNAME
;
2115 nsAString_InitDepend(&name_str
, This
->elem_vars
[i
]);
2116 nsres
= nsIDOMHTMLDocument_GetElementsByName(This
->nsdoc
, &name_str
, &node_list
);
2117 nsAString_Finish(&name_str
);
2118 if(NS_FAILED(nsres
))
2121 nsres
= nsIDOMNodeList_Item(node_list
, 0, &nsnode
);
2122 nsIDOMNodeList_Release(node_list
);
2123 if(NS_FAILED(nsres
) || !nsnode
)
2124 return DISP_E_UNKNOWNNAME
;
2126 hres
= get_node(This
, nsnode
, TRUE
, &node
);
2130 IHTMLDOMNode_AddRef(&node
->IHTMLDOMNode_iface
);
2131 V_VT(res
) = VT_DISPATCH
;
2132 V_DISPATCH(res
) = (IDispatch
*)&node
->IHTMLDOMNode_iface
;
2137 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl
= {
2140 HTMLDocumentNode_invoke
,
2144 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl
= {
2145 HTMLDocumentNode_QI
,
2146 HTMLDocumentNode_destructor
,
2147 HTMLDocumentFragment_clone
2150 static const tid_t HTMLDocumentNode_iface_tids
[] = {
2160 static dispex_static_data_t HTMLDocumentNode_dispex
= {
2161 &HTMLDocumentNode_dispex_vtbl
,
2162 DispHTMLDocument_tid
,
2164 HTMLDocumentNode_iface_tids
2167 static HTMLDocumentNode
*alloc_doc_node(HTMLDocumentObj
*doc_obj
, HTMLWindow
*window
)
2169 HTMLDocumentNode
*doc
;
2171 doc
= heap_alloc_zero(sizeof(HTMLDocumentNode
));
2176 doc
->basedoc
.doc_node
= doc
;
2177 doc
->basedoc
.doc_obj
= doc_obj
;
2178 doc
->basedoc
.window
= window
;
2180 init_dispex(&doc
->node
.dispex
, (IUnknown
*)&doc
->node
.IHTMLDOMNode_iface
,
2181 &HTMLDocumentNode_dispex
);
2182 init_doc(&doc
->basedoc
, (IUnknown
*)&doc
->node
.IHTMLDOMNode_iface
,
2183 &doc
->node
.dispex
.IDispatchEx_iface
);
2184 HTMLDocumentNode_SecMgr_Init(doc
);
2186 list_init(&doc
->bindings
);
2187 list_init(&doc
->selection_list
);
2188 list_init(&doc
->range_list
);
2189 list_init(&doc
->plugin_hosts
);
2194 HRESULT
create_doc_from_nsdoc(nsIDOMHTMLDocument
*nsdoc
, HTMLDocumentObj
*doc_obj
, HTMLWindow
*window
, HTMLDocumentNode
**ret
)
2196 HTMLDocumentNode
*doc
;
2198 doc
= alloc_doc_node(doc_obj
, window
);
2200 return E_OUTOFMEMORY
;
2202 if(!doc_obj
->basedoc
.window
|| window
== doc_obj
->basedoc
.window
)
2203 doc
->basedoc
.cp_container
.forward_container
= &doc_obj
->basedoc
.cp_container
;
2205 nsIDOMHTMLDocument_AddRef(nsdoc
);
2207 init_document_mutation(doc
);
2208 doc_init_events(doc
);
2210 HTMLDOMNode_Init(doc
, &doc
->node
, (nsIDOMNode
*)nsdoc
);
2211 doc
->node
.vtbl
= &HTMLDocumentNodeImplVtbl
;
2212 doc
->node
.cp_container
= &doc
->basedoc
.cp_container
;
2218 HRESULT
create_document_fragment(nsIDOMNode
*nsnode
, HTMLDocumentNode
*doc_node
, HTMLDocumentNode
**ret
)
2220 HTMLDocumentNode
*doc_frag
;
2222 doc_frag
= alloc_doc_node(doc_node
->basedoc
.doc_obj
, doc_node
->basedoc
.window
);
2224 return E_OUTOFMEMORY
;
2226 HTMLDOMNode_Init(doc_node
, &doc_frag
->node
, nsnode
);
2227 doc_frag
->node
.vtbl
= &HTMLDocumentFragmentImplVtbl
;
2228 doc_frag
->node
.cp_container
= &doc_frag
->basedoc
.cp_container
;
2230 htmldoc_addref(&doc_frag
->basedoc
);
2235 /**********************************************************
2236 * ICustomDoc implementation
2239 static inline HTMLDocumentObj
*impl_from_ICustomDoc(ICustomDoc
*iface
)
2241 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, ICustomDoc_iface
);
2244 static HRESULT WINAPI
CustomDoc_QueryInterface(ICustomDoc
*iface
, REFIID riid
, void **ppv
)
2246 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2248 if(htmldoc_qi(&This
->basedoc
, riid
, ppv
))
2249 return *ppv
? S_OK
: E_NOINTERFACE
;
2251 if(IsEqualGUID(&IID_ICustomDoc
, riid
)) {
2252 TRACE("(%p)->(IID_ICustomDoc %p)\n", This
, ppv
);
2253 *ppv
= &This
->ICustomDoc_iface
;
2254 }else if(IsEqualGUID(&IID_ITargetContainer
, riid
)) {
2255 TRACE("(%p)->(IID_ITargetContainer %p)\n", This
, ppv
);
2256 *ppv
= &This
->ITargetContainer_iface
;
2257 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
2258 return *ppv
? S_OK
: E_NOINTERFACE
;
2260 FIXME("Unimplemented interface %s\n", debugstr_guid(riid
));
2262 return E_NOINTERFACE
;
2265 IUnknown_AddRef((IUnknown
*)*ppv
);
2269 static ULONG WINAPI
CustomDoc_AddRef(ICustomDoc
*iface
)
2271 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2272 ULONG ref
= InterlockedIncrement(&This
->ref
);
2274 TRACE("(%p) ref = %u\n", This
, ref
);
2279 static ULONG WINAPI
CustomDoc_Release(ICustomDoc
*iface
)
2281 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2282 ULONG ref
= InterlockedDecrement(&This
->ref
);
2284 TRACE("(%p) ref = %u\n", This
, ref
);
2287 if(This
->basedoc
.doc_node
) {
2288 This
->basedoc
.doc_node
->basedoc
.doc_obj
= NULL
;
2289 htmldoc_release(&This
->basedoc
.doc_node
->basedoc
);
2291 if(This
->basedoc
.window
) {
2292 This
->basedoc
.window
->doc_obj
= NULL
;
2293 IHTMLWindow2_Release(&This
->basedoc
.window
->IHTMLWindow2_iface
);
2295 if(This
->basedoc
.advise_holder
)
2296 IOleAdviseHolder_Release(This
->basedoc
.advise_holder
);
2299 IAdviseSink_Release(This
->view_sink
);
2301 IOleObject_SetClientSite(&This
->basedoc
.IOleObject_iface
, NULL
);
2303 ICustomDoc_SetUIHandler(&This
->ICustomDoc_iface
, NULL
);
2304 if(This
->in_place_active
)
2305 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This
->basedoc
.IOleInPlaceObjectWindowless_iface
);
2307 IOleDocumentView_SetInPlaceSite(&This
->basedoc
.IOleDocumentView_iface
, NULL
);
2309 IOleUndoManager_Release(This
->undomgr
);
2310 if(This
->tooltips_hwnd
)
2311 DestroyWindow(This
->tooltips_hwnd
);
2314 DestroyWindow(This
->hwnd
);
2315 heap_free(This
->mime
);
2317 destroy_htmldoc(&This
->basedoc
);
2318 release_dispex(&This
->dispex
);
2320 if(This
->nscontainer
)
2321 NSContainer_Release(This
->nscontainer
);
2328 static HRESULT WINAPI
CustomDoc_SetUIHandler(ICustomDoc
*iface
, IDocHostUIHandler
*pUIHandler
)
2330 HTMLDocumentObj
*This
= impl_from_ICustomDoc(iface
);
2331 IOleCommandTarget
*cmdtrg
;
2334 TRACE("(%p)->(%p)\n", This
, pUIHandler
);
2336 if(This
->custom_hostui
&& This
->hostui
== pUIHandler
)
2339 This
->custom_hostui
= TRUE
;
2342 IDocHostUIHandler_Release(This
->hostui
);
2344 IDocHostUIHandler_AddRef(pUIHandler
);
2345 This
->hostui
= pUIHandler
;
2349 hres
= IDocHostUIHandler_QueryInterface(pUIHandler
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
2350 if(SUCCEEDED(hres
)) {
2351 FIXME("custom UI handler supports IOleCommandTarget\n");
2352 IOleCommandTarget_Release(cmdtrg
);
2358 static const ICustomDocVtbl CustomDocVtbl
= {
2359 CustomDoc_QueryInterface
,
2362 CustomDoc_SetUIHandler
2365 static const tid_t HTMLDocumentObj_iface_tids
[] = {
2372 static dispex_static_data_t HTMLDocumentObj_dispex
= {
2374 DispHTMLDocument_tid
,
2376 HTMLDocumentObj_iface_tids
2379 HRESULT
HTMLDocument_Create(IUnknown
*pUnkOuter
, REFIID riid
, void** ppvObject
)
2381 HTMLDocumentObj
*doc
;
2382 nsIDOMWindow
*nswindow
= NULL
;
2386 TRACE("(%p %s %p)\n", pUnkOuter
, debugstr_guid(riid
), ppvObject
);
2388 doc
= heap_alloc_zero(sizeof(HTMLDocumentObj
));
2390 return E_OUTOFMEMORY
;
2392 init_dispex(&doc
->dispex
, (IUnknown
*)&doc
->ICustomDoc_iface
, &HTMLDocumentObj_dispex
);
2393 init_doc(&doc
->basedoc
, (IUnknown
*)&doc
->ICustomDoc_iface
, &doc
->dispex
.IDispatchEx_iface
);
2394 TargetContainer_Init(doc
);
2396 doc
->ICustomDoc_iface
.lpVtbl
= &CustomDocVtbl
;
2398 doc
->basedoc
.doc_obj
= doc
;
2400 doc
->usermode
= UNKNOWN_USERMODE
;
2402 hres
= create_nscontainer(doc
, NULL
, &doc
->nscontainer
);
2404 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
2405 htmldoc_release(&doc
->basedoc
);
2409 hres
= htmldoc_query_interface(&doc
->basedoc
, riid
, ppvObject
);
2410 htmldoc_release(&doc
->basedoc
);
2415 nsres
= nsIWebBrowser_GetContentDOMWindow(doc
->nscontainer
->webbrowser
, &nswindow
);
2416 if(NS_FAILED(nsres
))
2417 ERR("GetContentDOMWindow failed: %08x\n", nsres
);
2419 hres
= HTMLWindow_Create(doc
, nswindow
, NULL
/* FIXME */, &doc
->basedoc
.window
);
2421 nsIDOMWindow_Release(nswindow
);
2423 htmldoc_release(&doc
->basedoc
);
2427 if(!doc
->basedoc
.doc_node
&& doc
->basedoc
.window
->doc
) {
2428 doc
->basedoc
.doc_node
= doc
->basedoc
.window
->doc
;
2429 htmldoc_addref(&doc
->basedoc
.doc_node
->basedoc
);