qcap: Implement a stubbed SmartTee filter.
[wine/multimedia.git] / dlls / mshtml / htmldoc.c
blob2b660df7be8248b6eb4b50b96bef557dad21c087
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <assert.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "wininet.h"
31 #include "ole2.h"
32 #include "perhist.h"
33 #include "mshtmdid.h"
34 #include "mshtmcid.h"
36 #include "wine/debug.h"
38 #include "mshtml_private.h"
39 #include "htmlevent.h"
40 #include "pluginhost.h"
41 #include "binding.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
45 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret);
47 HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement **ret)
49 nsIDOMNodeList *nsnode_list;
50 nsIDOMElement *nselem;
51 nsIDOMNode *nsnode;
52 nsAString id_str;
53 nsresult nsres;
54 HRESULT hres;
56 if(!doc->nsdoc) {
57 WARN("NULL nsdoc\n");
58 return E_UNEXPECTED;
61 nsAString_InitDepend(&id_str, id);
62 /* get element by id attribute */
63 nsres = nsIDOMHTMLDocument_GetElementById(doc->nsdoc, &id_str, &nselem);
64 if(FAILED(nsres)) {
65 ERR("GetElementById failed: %08x\n", nsres);
66 nsAString_Finish(&id_str);
67 return E_FAIL;
70 /* get first element by name attribute */
71 nsres = nsIDOMHTMLDocument_GetElementsByName(doc->nsdoc, &id_str, &nsnode_list);
72 nsAString_Finish(&id_str);
73 if(FAILED(nsres)) {
74 ERR("getElementsByName failed: %08x\n", nsres);
75 if(nselem)
76 nsIDOMElement_Release(nselem);
77 return E_FAIL;
80 nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode);
81 nsIDOMNodeList_Release(nsnode_list);
82 assert(nsres == NS_OK);
84 if(nsnode && nselem) {
85 UINT16 pos;
87 nsres = nsIDOMNode_CompareDocumentPosition(nsnode, (nsIDOMNode*)nselem, &pos);
88 if(NS_FAILED(nsres)) {
89 FIXME("CompareDocumentPosition failed: 0x%08x\n", nsres);
90 nsIDOMNode_Release(nsnode);
91 nsIDOMElement_Release(nselem);
92 return E_FAIL;
95 TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
96 if(!(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS))) {
97 nsIDOMElement_Release(nselem);
98 nselem = NULL;
102 if(nsnode) {
103 if(!nselem) {
104 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
105 assert(nsres == NS_OK);
107 nsIDOMNode_Release(nsnode);
110 if(!nselem) {
111 *ret = NULL;
112 return S_OK;
115 hres = get_elem(doc, nselem, ret);
116 nsIDOMElement_Release(nselem);
117 return hres;
120 UINT get_document_charset(HTMLDocumentNode *doc)
122 nsAString charset_str;
123 UINT ret = 0;
124 nsresult nsres;
126 if(doc->charset)
127 return doc->charset;
129 nsAString_Init(&charset_str, NULL);
130 nsres = nsIDOMHTMLDocument_GetCharacterSet(doc->nsdoc, &charset_str);
131 if(NS_SUCCEEDED(nsres)) {
132 const PRUnichar *charset;
134 nsAString_GetData(&charset_str, &charset);
136 if(*charset) {
137 BSTR str = SysAllocString(charset);
138 ret = cp_from_charset_string(str);
139 SysFreeString(str);
141 }else {
142 ERR("GetCharset failed: %08x\n", nsres);
144 nsAString_Finish(&charset_str);
146 if(!ret)
147 return CP_UTF8;
149 return doc->charset = ret;
152 static inline HTMLDocument *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
154 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument2_iface);
157 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
159 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
161 return htmldoc_query_interface(This, riid, ppv);
164 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
166 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
168 return htmldoc_addref(This);
171 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
173 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
175 return htmldoc_release(This);
178 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
180 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
182 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
185 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
186 LCID lcid, ITypeInfo **ppTInfo)
188 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
190 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
193 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
194 LPOLESTR *rgszNames, UINT cNames,
195 LCID lcid, DISPID *rgDispId)
197 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
199 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
200 rgDispId);
203 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
204 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
205 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
207 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
209 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
210 pDispParams, pVarResult, pExcepInfo, puArgErr);
213 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
215 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
217 TRACE("(%p)->(%p)\n", This, p);
219 *p = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
220 IDispatch_AddRef(*p);
221 return S_OK;
224 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
226 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
227 nsIDOMElement *nselem = NULL;
228 HTMLDOMNode *node;
229 nsresult nsres;
230 HRESULT hres;
232 TRACE("(%p)->(%p)\n", This, p);
234 if(!This->doc_node->nsdoc) {
235 WARN("NULL nsdoc\n");
236 return E_UNEXPECTED;
239 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
240 if(NS_FAILED(nsres)) {
241 ERR("GetDocumentElement failed: %08x\n", nsres);
242 return E_FAIL;
245 if(!nselem) {
246 *p = NULL;
247 return S_OK;
250 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
251 nsIDOMElement_Release(nselem);
252 if(FAILED(hres))
253 return hres;
255 *p = create_all_collection(node, TRUE);
256 node_release(node);
257 return hres;
260 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
262 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
263 nsIDOMHTMLElement *nsbody = NULL;
264 HTMLDOMNode *node;
265 HRESULT hres;
267 TRACE("(%p)->(%p)\n", This, p);
269 if(This->doc_node->nsdoc) {
270 nsresult nsres;
272 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
273 if(NS_FAILED(nsres)) {
274 TRACE("Could not get body: %08x\n", nsres);
275 return E_UNEXPECTED;
279 if(!nsbody) {
280 *p = NULL;
281 return S_OK;
284 hres = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE, &node);
285 nsIDOMHTMLElement_Release(nsbody);
286 if(FAILED(hres))
287 return hres;
289 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
290 node_release(node);
291 return hres;
294 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
296 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
297 nsIDOMElement *nselem;
298 HTMLElement *elem;
299 nsresult nsres;
300 HRESULT hres;
302 TRACE("(%p)->(%p)\n", This, p);
304 if(!This->doc_node->nsdoc) {
305 *p = NULL;
306 return S_OK;
310 * NOTE: Gecko may return an active element even if the document is not visible.
311 * IE returns NULL in this case.
313 nsres = nsIDOMHTMLDocument_GetActiveElement(This->doc_node->nsdoc, &nselem);
314 if(NS_FAILED(nsres)) {
315 ERR("GetActiveElement failed: %08x\n", nsres);
316 return E_FAIL;
319 if(!nselem) {
320 *p = NULL;
321 return S_OK;
324 hres = get_elem(This->doc_node, nselem, &elem);
325 nsIDOMElement_Release(nselem);
326 if(FAILED(hres))
327 return hres;
329 *p = &elem->IHTMLElement_iface;
330 return S_OK;
333 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
335 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
336 nsIDOMHTMLCollection *nscoll = NULL;
337 nsresult nsres;
339 TRACE("(%p)->(%p)\n", This, p);
341 if(!p)
342 return E_INVALIDARG;
344 *p = NULL;
346 if(!This->doc_node->nsdoc) {
347 WARN("NULL nsdoc\n");
348 return E_UNEXPECTED;
351 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
352 if(NS_FAILED(nsres)) {
353 ERR("GetImages failed: %08x\n", nsres);
354 return E_FAIL;
357 if(nscoll) {
358 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
359 nsIDOMHTMLCollection_Release(nscoll);
362 return S_OK;
365 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
367 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
368 nsIDOMHTMLCollection *nscoll = NULL;
369 nsresult nsres;
371 TRACE("(%p)->(%p)\n", This, p);
373 if(!p)
374 return E_INVALIDARG;
376 *p = NULL;
378 if(!This->doc_node->nsdoc) {
379 WARN("NULL nsdoc\n");
380 return E_UNEXPECTED;
383 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
384 if(NS_FAILED(nsres)) {
385 ERR("GetApplets failed: %08x\n", nsres);
386 return E_FAIL;
389 if(nscoll) {
390 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
391 nsIDOMHTMLCollection_Release(nscoll);
394 return S_OK;
397 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
399 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
400 nsIDOMHTMLCollection *nscoll = NULL;
401 nsresult nsres;
403 TRACE("(%p)->(%p)\n", This, p);
405 if(!p)
406 return E_INVALIDARG;
408 *p = NULL;
410 if(!This->doc_node->nsdoc) {
411 WARN("NULL nsdoc\n");
412 return E_UNEXPECTED;
415 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
416 if(NS_FAILED(nsres)) {
417 ERR("GetLinks failed: %08x\n", nsres);
418 return E_FAIL;
421 if(nscoll) {
422 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
423 nsIDOMHTMLCollection_Release(nscoll);
426 return S_OK;
429 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
431 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
432 nsIDOMHTMLCollection *nscoll = NULL;
433 nsresult nsres;
435 TRACE("(%p)->(%p)\n", This, p);
437 if(!p)
438 return E_INVALIDARG;
440 *p = NULL;
442 if(!This->doc_node->nsdoc) {
443 WARN("NULL nsdoc\n");
444 return E_UNEXPECTED;
447 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
448 if(NS_FAILED(nsres)) {
449 ERR("GetForms failed: %08x\n", nsres);
450 return E_FAIL;
453 if(nscoll) {
454 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
455 nsIDOMHTMLCollection_Release(nscoll);
458 return S_OK;
461 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
463 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
464 nsIDOMHTMLCollection *nscoll = NULL;
465 nsresult nsres;
467 TRACE("(%p)->(%p)\n", This, p);
469 if(!p)
470 return E_INVALIDARG;
472 *p = NULL;
474 if(!This->doc_node->nsdoc) {
475 WARN("NULL nsdoc\n");
476 return E_UNEXPECTED;
479 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
480 if(NS_FAILED(nsres)) {
481 ERR("GetAnchors failed: %08x\n", nsres);
482 return E_FAIL;
485 if(nscoll) {
486 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
487 nsIDOMHTMLCollection_Release(nscoll);
490 return S_OK;
493 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
495 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
496 nsAString nsstr;
497 nsresult nsres;
499 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
501 if(!This->doc_node->nsdoc) {
502 WARN("NULL nsdoc\n");
503 return E_UNEXPECTED;
506 nsAString_InitDepend(&nsstr, v);
507 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
508 nsAString_Finish(&nsstr);
509 if(NS_FAILED(nsres))
510 ERR("SetTitle failed: %08x\n", nsres);
512 return S_OK;
515 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
517 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
518 const PRUnichar *ret;
519 nsAString nsstr;
520 nsresult nsres;
522 TRACE("(%p)->(%p)\n", This, p);
524 if(!This->doc_node->nsdoc) {
525 WARN("NULL nsdoc\n");
526 return E_UNEXPECTED;
530 nsAString_Init(&nsstr, NULL);
531 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
532 if (NS_SUCCEEDED(nsres)) {
533 nsAString_GetData(&nsstr, &ret);
534 *p = SysAllocString(ret);
536 nsAString_Finish(&nsstr);
538 if(NS_FAILED(nsres)) {
539 ERR("GetTitle failed: %08x\n", nsres);
540 return E_FAIL;
543 return S_OK;
546 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
548 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
549 nsIDOMHTMLCollection *nscoll = NULL;
550 nsresult nsres;
552 TRACE("(%p)->(%p)\n", This, p);
554 if(!p)
555 return E_INVALIDARG;
557 *p = NULL;
559 if(!This->doc_node->nsdoc) {
560 WARN("NULL nsdoc\n");
561 return E_UNEXPECTED;
564 nsres = nsIDOMHTMLDocument_GetScripts(This->doc_node->nsdoc, &nscoll);
565 if(NS_FAILED(nsres)) {
566 ERR("GetImages failed: %08x\n", nsres);
567 return E_FAIL;
570 if(nscoll) {
571 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
572 nsIDOMHTMLCollection_Release(nscoll);
575 return S_OK;
578 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
580 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
581 HRESULT hres;
583 static const WCHAR onW[] = {'o','n',0};
585 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
587 if(strcmpiW(v, onW)) {
588 FIXME("Unsupported arg %s\n", debugstr_w(v));
589 return E_NOTIMPL;
592 hres = setup_edit_mode(This->doc_obj);
593 if(FAILED(hres))
594 return hres;
596 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
597 return S_OK;
600 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
602 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
603 static const WCHAR szOff[] = {'O','f','f',0};
604 FIXME("(%p)->(%p) always returning Off\n", This, p);
606 if(!p)
607 return E_INVALIDARG;
609 *p = SysAllocString(szOff);
611 return S_OK;
614 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
616 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
617 nsISelection *nsselection;
618 nsresult nsres;
620 TRACE("(%p)->(%p)\n", This, p);
622 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
623 if(NS_FAILED(nsres)) {
624 ERR("GetSelection failed: %08x\n", nsres);
625 return E_FAIL;
628 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
631 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
633 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
636 TRACE("(%p)->(%p)\n", iface, p);
638 if(!p)
639 return E_POINTER;
641 return get_readystate_string(This->window->readystate, p);
644 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
646 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
648 TRACE("(%p)->(%p)\n", This, p);
650 return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p);
653 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
655 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
656 FIXME("(%p)->(%p)\n", This, p);
657 return E_NOTIMPL;
660 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
662 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
663 FIXME("(%p)->(%p)\n", This, p);
664 return E_NOTIMPL;
667 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
669 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
670 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
671 return E_NOTIMPL;
674 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
676 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
677 FIXME("(%p)->(%p)\n", This, p);
678 return E_NOTIMPL;
681 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
683 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
684 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
685 return E_NOTIMPL;
688 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
690 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
691 FIXME("(%p)->(%p)\n", This, p);
692 return E_NOTIMPL;
695 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
697 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
698 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
699 return E_NOTIMPL;
702 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
704 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
705 FIXME("(%p)->(%p)\n", This, p);
706 return E_NOTIMPL;
709 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
711 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
712 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
713 return E_NOTIMPL;
716 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
718 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
719 FIXME("(%p)->(%p)\n", This, p);
720 return E_NOTIMPL;
723 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
725 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
726 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
727 return E_NOTIMPL;
730 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
732 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
733 FIXME("(%p)->(%p)\n", This, p);
734 return E_NOTIMPL;
737 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
739 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
741 FIXME("(%p)->(%p)\n", This, p);
743 *p = NULL;
744 return S_OK;
747 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
749 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
751 TRACE("(%p)->(%p)\n", This, p);
753 if(!This->doc_node->nsdoc) {
754 WARN("NULL nsdoc\n");
755 return E_UNEXPECTED;
758 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
761 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
763 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
764 FIXME("(%p)->(%p)\n", This, p);
765 return E_NOTIMPL;
768 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
770 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
772 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
774 if(!This->window) {
775 FIXME("No window available\n");
776 return E_FAIL;
779 return navigate_url(This->window, v, This->window->uri, BINDING_NAVIGATED);
782 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
784 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
786 static const WCHAR about_blank_url[] =
787 {'a','b','o','u','t',':','b','l','a','n','k',0};
789 TRACE("(%p)->(%p)\n", iface, p);
791 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
792 return *p ? S_OK : E_OUTOFMEMORY;
795 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
797 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
798 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
799 return E_NOTIMPL;
802 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
804 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
805 HRESULT hres;
807 TRACE("(%p)->(%p)\n", This, p);
809 if(!This->window || !This->window->uri) {
810 FIXME("No current URI\n");
811 return E_FAIL;
814 hres = IUri_GetHost(This->window->uri, p);
815 return FAILED(hres) ? hres : S_OK;
818 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
820 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
821 BOOL bret;
823 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
825 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
826 if(!bret) {
827 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
828 return HRESULT_FROM_WIN32(GetLastError());
831 return S_OK;
834 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
836 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
837 DWORD size;
838 BOOL bret;
840 TRACE("(%p)->(%p)\n", This, p);
842 size = 0;
843 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
844 if(!bret) {
845 switch(GetLastError()) {
846 case ERROR_INSUFFICIENT_BUFFER:
847 break;
848 case ERROR_NO_MORE_ITEMS:
849 *p = NULL;
850 return S_OK;
851 default:
852 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
853 return HRESULT_FROM_WIN32(GetLastError());
857 if(!size) {
858 *p = NULL;
859 return S_OK;
862 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
863 if(!*p)
864 return E_OUTOFMEMORY;
866 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
867 if(!bret) {
868 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
869 return E_FAIL;
872 return S_OK;
875 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
877 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
878 FIXME("(%p)->(%x)\n", This, v);
879 return E_NOTIMPL;
882 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
884 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
885 FIXME("(%p)->(%p)\n", This, p);
886 return E_NOTIMPL;
889 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
891 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
892 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
893 return E_NOTIMPL;
896 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
898 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
899 nsAString charset_str;
900 nsresult nsres;
902 TRACE("(%p)->(%p)\n", This, p);
904 if(!This->doc_node->nsdoc) {
905 FIXME("NULL nsdoc\n");
906 return E_FAIL;
909 nsAString_Init(&charset_str, NULL);
910 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
911 return return_nsstr(nsres, &charset_str, p);
914 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
916 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
917 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
918 return E_NOTIMPL;
921 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
923 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
924 FIXME("(%p)->(%p)\n", This, p);
925 return E_NOTIMPL;
928 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
930 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
931 FIXME("(%p)->(%p)\n", This, p);
932 return E_NOTIMPL;
935 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
937 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
938 FIXME("(%p)->(%p)\n", This, p);
939 return E_NOTIMPL;
942 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
944 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
945 FIXME("(%p)->(%p)\n", This, p);
946 return E_NOTIMPL;
949 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
951 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
952 FIXME("(%p)->(%p)\n", This, p);
953 return E_NOTIMPL;
956 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
958 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
959 FIXME("(%p)->(%p)\n", This, p);
960 return E_NOTIMPL;
963 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
965 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
966 FIXME("(%p)->(%p)\n", This, p);
967 return E_NOTIMPL;
970 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
972 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
973 FIXME("(%p)->(%p)\n", This, p);
974 return E_NOTIMPL;
977 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
979 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
980 FIXME("(%p)->(%p)\n", This, p);
981 return E_NOTIMPL;
984 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
986 VARIANT *var, tmp;
987 JSContext *jsctx;
988 nsAString nsstr;
989 ULONG i, argc;
990 nsresult nsres;
991 HRESULT hres;
993 if(!This->doc_node->nsdoc) {
994 WARN("NULL nsdoc\n");
995 return E_UNEXPECTED;
998 if (!psarray)
999 return S_OK;
1001 if(psarray->cDims != 1) {
1002 FIXME("cDims=%d\n", psarray->cDims);
1003 return E_INVALIDARG;
1006 hres = SafeArrayAccessData(psarray, (void**)&var);
1007 if(FAILED(hres)) {
1008 WARN("SafeArrayAccessData failed: %08x\n", hres);
1009 return hres;
1012 V_VT(&tmp) = VT_EMPTY;
1014 jsctx = get_context_from_document(This->doc_node->nsdoc);
1015 argc = psarray->rgsabound[0].cElements;
1016 for(i=0; i < argc; i++) {
1017 if(V_VT(var+i) == VT_BSTR) {
1018 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1019 }else {
1020 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1021 if(FAILED(hres)) {
1022 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1023 break;
1025 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1028 if(!ln || i != argc-1)
1029 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1030 else
1031 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1032 nsAString_Finish(&nsstr);
1033 if(V_VT(var+i) != VT_BSTR)
1034 VariantClear(&tmp);
1035 if(NS_FAILED(nsres)) {
1036 ERR("Write failed: %08x\n", nsres);
1037 hres = E_FAIL;
1038 break;
1042 SafeArrayUnaccessData(psarray);
1044 return hres;
1047 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1049 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1051 TRACE("(%p)->(%p)\n", iface, psarray);
1053 return document_write(This, psarray, FALSE);
1056 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1058 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1060 TRACE("(%p)->(%p)\n", This, psarray);
1062 return document_write(This, psarray, TRUE);
1065 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1066 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1068 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1069 nsISupports *tmp;
1070 nsresult nsres;
1072 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
1074 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1075 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1077 if(!This->doc_node->nsdoc) {
1078 ERR("!nsdoc\n");
1079 return E_NOTIMPL;
1082 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
1083 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1084 FIXME("unsupported args\n");
1086 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1087 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1088 if(NS_FAILED(nsres)) {
1089 ERR("Open failed: %08x\n", nsres);
1090 return E_FAIL;
1093 if(tmp)
1094 nsISupports_Release(tmp);
1096 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1097 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1098 return S_OK;
1101 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1103 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1104 nsresult nsres;
1106 TRACE("(%p)\n", This);
1108 if(!This->doc_node->nsdoc) {
1109 ERR("!nsdoc\n");
1110 return E_NOTIMPL;
1113 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1114 if(NS_FAILED(nsres)) {
1115 ERR("Close failed: %08x\n", nsres);
1116 return E_FAIL;
1119 return S_OK;
1122 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1124 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1125 nsresult nsres;
1127 TRACE("(%p)\n", This);
1129 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1130 if(NS_FAILED(nsres)) {
1131 ERR("Clear failed: %08x\n", nsres);
1132 return E_FAIL;
1135 return S_OK;
1138 static const WCHAR copyW[] =
1139 {'c','o','p','y',0};
1140 static const WCHAR cutW[] =
1141 {'c','u','t',0};
1142 static const WCHAR fontnameW[] =
1143 {'f','o','n','t','n','a','m','e',0};
1144 static const WCHAR fontsizeW[] =
1145 {'f','o','n','t','s','i','z','e',0};
1146 static const WCHAR indentW[] =
1147 {'i','n','d','e','n','t',0};
1148 static const WCHAR insertorderedlistW[] =
1149 {'i','n','s','e','r','t','o','r','d','e','r','e','d','l','i','s','t',0};
1150 static const WCHAR insertunorderedlistW[] =
1151 {'i','n','s','e','r','t','u','n','o','r','d','e','r','e','d','l','i','s','t',0};
1152 static const WCHAR outdentW[] =
1153 {'o','u','t','d','e','n','t',0};
1154 static const WCHAR pasteW[] =
1155 {'p','a','s','t','e',0};
1156 static const WCHAR respectvisibilityindesignW[] =
1157 {'r','e','s','p','e','c','t','v','i','s','i','b','i','l','i','t','y','i','n','d','e','s','i','g','n',0};
1159 static const struct {
1160 const WCHAR *name;
1161 OLECMDID id;
1162 }command_names[] = {
1163 {copyW, IDM_COPY},
1164 {cutW, IDM_CUT},
1165 {fontnameW, IDM_FONTNAME},
1166 {fontsizeW, IDM_FONTSIZE},
1167 {indentW, IDM_INDENT},
1168 {insertorderedlistW, IDM_ORDERLIST},
1169 {insertunorderedlistW, IDM_UNORDERLIST},
1170 {outdentW, IDM_OUTDENT},
1171 {pasteW, IDM_PASTE},
1172 {respectvisibilityindesignW, IDM_RESPECTVISIBILITY_INDESIGN}
1175 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1177 int i;
1179 for(i = 0; i < sizeof(command_names)/sizeof(*command_names); i++) {
1180 if(!strcmpiW(command_names[i].name, str)) {
1181 *cmdid = command_names[i].id;
1182 return TRUE;
1186 FIXME("Unknown command %s\n", debugstr_w(str));
1187 return FALSE;
1190 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1191 VARIANT_BOOL *pfRet)
1193 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1194 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1195 return E_NOTIMPL;
1198 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1199 VARIANT_BOOL *pfRet)
1201 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1202 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1203 return E_NOTIMPL;
1206 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1207 VARIANT_BOOL *pfRet)
1209 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1210 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1211 return E_NOTIMPL;
1214 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1215 VARIANT_BOOL *pfRet)
1217 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1218 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1219 return E_NOTIMPL;
1222 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1223 BSTR *pfRet)
1225 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1226 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1227 return E_NOTIMPL;
1230 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1231 VARIANT *pfRet)
1233 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1234 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1235 return E_NOTIMPL;
1238 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1239 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1241 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1242 OLECMDID cmdid;
1243 VARIANT ret;
1244 HRESULT hres;
1246 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1248 if(!cmdid_from_string(cmdID, &cmdid))
1249 return OLECMDERR_E_NOTSUPPORTED;
1251 V_VT(&ret) = VT_EMPTY;
1252 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1253 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1254 if(FAILED(hres))
1255 return hres;
1257 if(V_VT(&ret) != VT_EMPTY) {
1258 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1259 VariantClear(&ret);
1262 *pfRet = VARIANT_TRUE;
1263 return S_OK;
1266 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1267 VARIANT_BOOL *pfRet)
1269 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1270 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1271 return E_NOTIMPL;
1274 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1275 IHTMLElement **newElem)
1277 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1278 HTMLElement *elem;
1279 HRESULT hres;
1281 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1283 hres = create_element(This->doc_node, eTag, &elem);
1284 if(FAILED(hres))
1285 return hres;
1287 *newElem = &elem->IHTMLElement_iface;
1288 return S_OK;
1291 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1293 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1294 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1295 return E_NOTIMPL;
1298 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1300 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1301 FIXME("(%p)->(%p)\n", This, p);
1302 return E_NOTIMPL;
1305 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1307 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1309 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1311 return set_doc_event(This, EVENTID_CLICK, &v);
1314 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1316 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1318 TRACE("(%p)->(%p)\n", This, p);
1320 return get_doc_event(This, EVENTID_CLICK, p);
1323 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1325 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1327 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1329 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1332 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1334 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1336 TRACE("(%p)->(%p)\n", This, p);
1338 return get_doc_event(This, EVENTID_DBLCLICK, p);
1341 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1343 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1345 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1347 return set_doc_event(This, EVENTID_KEYUP, &v);
1350 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1352 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1354 TRACE("(%p)->(%p)\n", This, p);
1356 return get_doc_event(This, EVENTID_KEYUP, p);
1359 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1361 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1363 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1365 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1368 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1370 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1372 TRACE("(%p)->(%p)\n", This, p);
1374 return get_doc_event(This, EVENTID_KEYDOWN, p);
1377 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1379 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1381 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1383 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1386 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1388 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1390 TRACE("(%p)->(%p)\n", This, p);
1392 return get_doc_event(This, EVENTID_KEYPRESS, p);
1395 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1397 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1399 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1401 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1404 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1406 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1408 TRACE("(%p)->(%p)\n", This, p);
1410 return get_doc_event(This, EVENTID_MOUSEUP, p);
1413 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1415 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1417 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1419 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1422 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1424 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1426 TRACE("(%p)->(%p)\n", This, p);
1428 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1431 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1433 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1435 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1437 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1440 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1442 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1444 TRACE("(%p)->(%p)\n", This, p);
1446 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1449 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1451 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1453 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1455 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1458 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1460 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1462 TRACE("(%p)->(%p)\n", This, p);
1464 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1467 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1469 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1471 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1473 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1476 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1478 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1480 TRACE("(%p)->(%p)\n", This, p);
1482 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1485 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1487 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1489 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1491 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1494 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1496 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1498 TRACE("(%p)->(%p)\n", This, p);
1500 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1503 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1505 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1506 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1507 return E_NOTIMPL;
1510 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1512 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1513 FIXME("(%p)->(%p)\n", This, p);
1514 return E_NOTIMPL;
1517 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1519 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1520 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1521 return E_NOTIMPL;
1524 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1526 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1527 FIXME("(%p)->(%p)\n", This, p);
1528 return E_NOTIMPL;
1531 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1533 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1534 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1535 return E_NOTIMPL;
1538 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1540 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1541 FIXME("(%p)->(%p)\n", This, p);
1542 return E_NOTIMPL;
1545 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1547 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1549 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1551 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1554 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1556 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1558 TRACE("(%p)->(%p)\n", This, p);
1560 return get_doc_event(This, EVENTID_DRAGSTART, p);
1563 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1565 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1567 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1569 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1572 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1574 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1576 TRACE("(%p)->(%p)\n", This, p);
1578 return get_doc_event(This, EVENTID_SELECTSTART, p);
1581 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1582 IHTMLElement **elementHit)
1584 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1585 nsIDOMElement *nselem;
1586 HTMLDOMNode *node;
1587 nsresult nsres;
1588 HRESULT hres;
1590 TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1592 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1593 if(NS_FAILED(nsres)) {
1594 ERR("ElementFromPoint failed: %08x\n", nsres);
1595 return E_FAIL;
1598 if(!nselem) {
1599 *elementHit = NULL;
1600 return S_OK;
1603 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
1604 nsIDOMElement_Release(nselem);
1605 if(FAILED(hres))
1606 return hres;
1608 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)elementHit);
1609 node_release(node);
1610 return hres;
1613 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1615 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1617 TRACE("(%p)->(%p)\n", This, p);
1619 *p = &This->window->base.IHTMLWindow2_iface;
1620 IHTMLWindow2_AddRef(*p);
1621 return S_OK;
1624 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1625 IHTMLStyleSheetsCollection **p)
1627 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1628 nsIDOMStyleSheetList *nsstylelist;
1629 nsresult nsres;
1631 TRACE("(%p)->(%p)\n", This, p);
1633 *p = NULL;
1635 if(!This->doc_node->nsdoc) {
1636 WARN("NULL nsdoc\n");
1637 return E_UNEXPECTED;
1640 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1641 if(NS_FAILED(nsres)) {
1642 ERR("GetStyleSheets failed: %08x\n", nsres);
1643 return E_FAIL;
1646 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1647 nsIDOMStyleSheetList_Release(nsstylelist);
1649 return S_OK;
1652 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1654 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1655 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1656 return E_NOTIMPL;
1659 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1661 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1662 FIXME("(%p)->(%p)\n", This, p);
1663 return E_NOTIMPL;
1666 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1668 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1669 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1670 return E_NOTIMPL;
1673 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1675 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1676 FIXME("(%p)->(%p)\n", This, p);
1677 return E_NOTIMPL;
1680 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1682 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1684 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1686 TRACE("(%p)->(%p)\n", This, String);
1688 if(!String)
1689 return E_INVALIDARG;
1691 *String = SysAllocString(objectW);
1692 return *String ? S_OK : E_OUTOFMEMORY;
1696 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1697 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1699 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1700 nsIDOMHTMLHeadElement *head_elem;
1701 IHTMLStyleElement *style_elem;
1702 HTMLElement *elem;
1703 nsresult nsres;
1704 HRESULT hres;
1706 static const WCHAR styleW[] = {'s','t','y','l','e',0};
1708 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1710 if(!This->doc_node->nsdoc) {
1711 FIXME("not a real doc object\n");
1712 return E_NOTIMPL;
1715 if(lIndex != -1)
1716 FIXME("Unsupported lIndex %d\n", lIndex);
1718 if(bstrHref && *bstrHref) {
1719 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
1720 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1721 return S_OK;
1724 hres = create_element(This->doc_node, styleW, &elem);
1725 if(FAILED(hres))
1726 return hres;
1728 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
1729 if(NS_SUCCEEDED(nsres)) {
1730 nsIDOMNode *head_node, *tmp_node;
1732 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
1733 nsIDOMHTMLHeadElement_Release(head_elem);
1734 assert(nsres == NS_OK);
1736 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
1737 nsIDOMNode_Release(head_node);
1738 if(NS_SUCCEEDED(nsres) && tmp_node)
1739 nsIDOMNode_Release(tmp_node);
1741 if(NS_FAILED(nsres)) {
1742 IHTMLElement_Release(&elem->IHTMLElement_iface);
1743 return E_FAIL;
1746 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
1747 assert(hres == S_OK);
1748 IHTMLElement_Release(&elem->IHTMLElement_iface);
1750 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
1751 IHTMLStyleElement_Release(style_elem);
1752 return hres;
1755 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1756 HTMLDocument_QueryInterface,
1757 HTMLDocument_AddRef,
1758 HTMLDocument_Release,
1759 HTMLDocument_GetTypeInfoCount,
1760 HTMLDocument_GetTypeInfo,
1761 HTMLDocument_GetIDsOfNames,
1762 HTMLDocument_Invoke,
1763 HTMLDocument_get_Script,
1764 HTMLDocument_get_all,
1765 HTMLDocument_get_body,
1766 HTMLDocument_get_activeElement,
1767 HTMLDocument_get_images,
1768 HTMLDocument_get_applets,
1769 HTMLDocument_get_links,
1770 HTMLDocument_get_forms,
1771 HTMLDocument_get_anchors,
1772 HTMLDocument_put_title,
1773 HTMLDocument_get_title,
1774 HTMLDocument_get_scripts,
1775 HTMLDocument_put_designMode,
1776 HTMLDocument_get_designMode,
1777 HTMLDocument_get_selection,
1778 HTMLDocument_get_readyState,
1779 HTMLDocument_get_frames,
1780 HTMLDocument_get_embeds,
1781 HTMLDocument_get_plugins,
1782 HTMLDocument_put_alinkColor,
1783 HTMLDocument_get_alinkColor,
1784 HTMLDocument_put_bgColor,
1785 HTMLDocument_get_bgColor,
1786 HTMLDocument_put_fgColor,
1787 HTMLDocument_get_fgColor,
1788 HTMLDocument_put_linkColor,
1789 HTMLDocument_get_linkColor,
1790 HTMLDocument_put_vlinkColor,
1791 HTMLDocument_get_vlinkColor,
1792 HTMLDocument_get_referrer,
1793 HTMLDocument_get_location,
1794 HTMLDocument_get_lastModified,
1795 HTMLDocument_put_URL,
1796 HTMLDocument_get_URL,
1797 HTMLDocument_put_domain,
1798 HTMLDocument_get_domain,
1799 HTMLDocument_put_cookie,
1800 HTMLDocument_get_cookie,
1801 HTMLDocument_put_expando,
1802 HTMLDocument_get_expando,
1803 HTMLDocument_put_charset,
1804 HTMLDocument_get_charset,
1805 HTMLDocument_put_defaultCharset,
1806 HTMLDocument_get_defaultCharset,
1807 HTMLDocument_get_mimeType,
1808 HTMLDocument_get_fileSize,
1809 HTMLDocument_get_fileCreatedDate,
1810 HTMLDocument_get_fileModifiedDate,
1811 HTMLDocument_get_fileUpdatedDate,
1812 HTMLDocument_get_security,
1813 HTMLDocument_get_protocol,
1814 HTMLDocument_get_nameProp,
1815 HTMLDocument_write,
1816 HTMLDocument_writeln,
1817 HTMLDocument_open,
1818 HTMLDocument_close,
1819 HTMLDocument_clear,
1820 HTMLDocument_queryCommandSupported,
1821 HTMLDocument_queryCommandEnabled,
1822 HTMLDocument_queryCommandState,
1823 HTMLDocument_queryCommandIndeterm,
1824 HTMLDocument_queryCommandText,
1825 HTMLDocument_queryCommandValue,
1826 HTMLDocument_execCommand,
1827 HTMLDocument_execCommandShowHelp,
1828 HTMLDocument_createElement,
1829 HTMLDocument_put_onhelp,
1830 HTMLDocument_get_onhelp,
1831 HTMLDocument_put_onclick,
1832 HTMLDocument_get_onclick,
1833 HTMLDocument_put_ondblclick,
1834 HTMLDocument_get_ondblclick,
1835 HTMLDocument_put_onkeyup,
1836 HTMLDocument_get_onkeyup,
1837 HTMLDocument_put_onkeydown,
1838 HTMLDocument_get_onkeydown,
1839 HTMLDocument_put_onkeypress,
1840 HTMLDocument_get_onkeypress,
1841 HTMLDocument_put_onmouseup,
1842 HTMLDocument_get_onmouseup,
1843 HTMLDocument_put_onmousedown,
1844 HTMLDocument_get_onmousedown,
1845 HTMLDocument_put_onmousemove,
1846 HTMLDocument_get_onmousemove,
1847 HTMLDocument_put_onmouseout,
1848 HTMLDocument_get_onmouseout,
1849 HTMLDocument_put_onmouseover,
1850 HTMLDocument_get_onmouseover,
1851 HTMLDocument_put_onreadystatechange,
1852 HTMLDocument_get_onreadystatechange,
1853 HTMLDocument_put_onafterupdate,
1854 HTMLDocument_get_onafterupdate,
1855 HTMLDocument_put_onrowexit,
1856 HTMLDocument_get_onrowexit,
1857 HTMLDocument_put_onrowenter,
1858 HTMLDocument_get_onrowenter,
1859 HTMLDocument_put_ondragstart,
1860 HTMLDocument_get_ondragstart,
1861 HTMLDocument_put_onselectstart,
1862 HTMLDocument_get_onselectstart,
1863 HTMLDocument_elementFromPoint,
1864 HTMLDocument_get_parentWindow,
1865 HTMLDocument_get_styleSheets,
1866 HTMLDocument_put_onbeforeupdate,
1867 HTMLDocument_get_onbeforeupdate,
1868 HTMLDocument_put_onerrorupdate,
1869 HTMLDocument_get_onerrorupdate,
1870 HTMLDocument_toString,
1871 HTMLDocument_createStyleSheet
1874 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
1876 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
1879 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
1880 REFIID riid, void **ppv)
1882 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1883 return htmldoc_query_interface(This, riid, ppv);
1886 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
1888 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1889 return htmldoc_addref(This);
1892 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
1894 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1895 return htmldoc_release(This);
1898 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
1900 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1901 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1904 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
1905 LCID lcid, ITypeInfo **ppTInfo)
1907 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1908 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1911 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
1912 LPOLESTR *rgszNames, UINT cNames,
1913 LCID lcid, DISPID *rgDispId)
1915 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1916 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1917 rgDispId);
1920 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
1921 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1922 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1924 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1925 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1926 pDispParams, pVarResult, pExcepInfo, puArgErr);
1929 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
1931 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1932 FIXME("(%p)\n", This);
1933 return E_NOTIMPL;
1936 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
1938 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1940 WARN("(%p)->(%x)\n", This, fForce);
1942 /* Doing nothing here should be fine for us. */
1943 return S_OK;
1946 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
1947 IHTMLDOMNode **newTextNode)
1949 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1950 nsIDOMText *nstext;
1951 HTMLDOMNode *node;
1952 nsAString text_str;
1953 nsresult nsres;
1954 HRESULT hres;
1956 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
1958 if(!This->doc_node->nsdoc) {
1959 WARN("NULL nsdoc\n");
1960 return E_UNEXPECTED;
1963 nsAString_InitDepend(&text_str, text);
1964 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
1965 nsAString_Finish(&text_str);
1966 if(NS_FAILED(nsres)) {
1967 ERR("CreateTextNode failed: %08x\n", nsres);
1968 return E_FAIL;
1971 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
1972 nsIDOMText_Release(nstext);
1973 if(FAILED(hres))
1974 return hres;
1976 *newTextNode = &node->IHTMLDOMNode_iface;
1977 return S_OK;
1980 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
1982 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1983 nsIDOMElement *nselem = NULL;
1984 HTMLDOMNode *node;
1985 nsresult nsres;
1986 HRESULT hres;
1988 TRACE("(%p)->(%p)\n", This, p);
1990 if(This->window->readystate == READYSTATE_UNINITIALIZED) {
1991 *p = NULL;
1992 return S_OK;
1995 if(!This->doc_node->nsdoc) {
1996 WARN("NULL nsdoc\n");
1997 return E_UNEXPECTED;
2000 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
2001 if(NS_FAILED(nsres)) {
2002 ERR("GetDocumentElement failed: %08x\n", nsres);
2003 return E_FAIL;
2006 if(!nselem) {
2007 *p = NULL;
2008 return S_OK;
2011 hres = get_node(This->doc_node, (nsIDOMNode *)nselem, TRUE, &node);
2012 nsIDOMElement_Release(nselem);
2013 if(FAILED(hres))
2014 return hres;
2016 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
2017 node_release(node);
2018 return hres;
2021 static HRESULT WINAPI HTMLDocument3_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2023 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2024 FIXME("(%p)->(%p)\n", This, p);
2025 return E_NOTIMPL;
2028 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2029 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2031 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2033 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2035 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2038 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2039 IDispatch *pDisp)
2041 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2043 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2045 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2048 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2050 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2051 FIXME("(%p)->()\n", This);
2052 return E_NOTIMPL;
2055 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2057 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2058 FIXME("(%p)->(%p)\n", This, p);
2059 return E_NOTIMPL;
2062 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2064 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2065 FIXME("(%p)->()\n", This);
2066 return E_NOTIMPL;
2069 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2071 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2072 FIXME("(%p)->(%p)\n", This, p);
2073 return E_NOTIMPL;
2076 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2078 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2079 FIXME("(%p)->()\n", This);
2080 return E_NOTIMPL;
2083 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2085 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2086 FIXME("(%p)->(%p)\n", This, p);
2087 return E_NOTIMPL;
2090 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2092 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2093 FIXME("(%p)->()\n", This);
2094 return E_NOTIMPL;
2097 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2099 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2100 FIXME("(%p)->(%p)\n", This, p);
2101 return E_NOTIMPL;
2104 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2106 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2107 FIXME("(%p)->()\n", This);
2108 return E_NOTIMPL;
2111 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2113 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2114 FIXME("(%p)->(%p)\n", This, p);
2115 return E_NOTIMPL;
2118 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2120 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2121 FIXME("(%p)->()\n", This);
2122 return E_NOTIMPL;
2125 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2127 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2128 FIXME("(%p)->(%p)\n", This, p);
2129 return E_NOTIMPL;
2132 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2134 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2135 FIXME("(%p)->()\n", This);
2136 return E_NOTIMPL;
2139 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2141 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2142 FIXME("(%p)->(%p)\n", This, p);
2143 return E_NOTIMPL;
2146 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2148 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2149 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2150 return E_NOTIMPL;
2153 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2155 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2156 FIXME("(%p)->(%p)\n", This, p);
2157 return E_NOTIMPL;
2160 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2162 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2164 TRACE("(%p)->()\n", This);
2166 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2169 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2171 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2173 TRACE("(%p)->(%p)\n", This, p);
2175 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2178 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2180 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2181 FIXME("(%p)->()\n", This);
2182 return E_NOTIMPL;
2185 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2187 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2188 FIXME("(%p)->(%p)\n", This, p);
2189 return E_NOTIMPL;
2192 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2193 IHTMLDocument2 **ppNewDoc)
2195 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2196 nsIDOMDocumentFragment *doc_frag;
2197 HTMLDocumentNode *docnode;
2198 nsresult nsres;
2199 HRESULT hres;
2201 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2203 if(!This->doc_node->nsdoc) {
2204 FIXME("NULL nsdoc\n");
2205 return E_NOTIMPL;
2208 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2209 if(NS_FAILED(nsres)) {
2210 ERR("CreateDocumentFragment failed: %08x\n", nsres);
2211 return E_FAIL;
2214 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2215 nsIDOMDocumentFragment_Release(doc_frag);
2216 if(FAILED(hres))
2217 return hres;
2219 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2220 return S_OK;
2223 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2224 IHTMLDocument2 **p)
2226 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2227 FIXME("(%p)->(%p)\n", This, p);
2228 return E_NOTIMPL;
2231 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2232 VARIANT_BOOL v)
2234 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2235 FIXME("(%p)->(%x)\n", This, v);
2236 return E_NOTIMPL;
2239 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2240 VARIANT_BOOL *p)
2242 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2243 FIXME("(%p)->(%p)\n", This, p);
2244 return E_NOTIMPL;
2247 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2249 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2250 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2251 return E_NOTIMPL;
2254 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2256 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2257 FIXME("(%p)->(%p)\n", This, p);
2258 return E_NOTIMPL;
2261 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2263 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2265 TRACE("(%p)->(%p)\n", This, p);
2267 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2270 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2271 VARIANT_BOOL v)
2273 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2274 FIXME("(%p)->()\n", This);
2275 return E_NOTIMPL;
2278 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2279 VARIANT_BOOL *p)
2281 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2282 FIXME("(%p)->(%p)\n", This, p);
2283 return E_NOTIMPL;
2286 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2288 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2289 FIXME("(%p)->()\n", This);
2290 return E_NOTIMPL;
2293 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2295 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2296 FIXME("(%p)->(%p)\n", This, p);
2297 return E_NOTIMPL;
2300 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2301 IHTMLElementCollection **ppelColl)
2303 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2304 nsIDOMNodeList *node_list;
2305 nsAString selector_str;
2306 WCHAR *selector;
2307 nsresult nsres;
2309 static const WCHAR formatW[] = {'*','[','i','d','=','%','s',']',',','*','[','n','a','m','e','=','%','s',']',0};
2311 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2313 if(!This->doc_node || !This->doc_node->nsdoc) {
2314 /* We should probably return an empty collection. */
2315 FIXME("No nsdoc\n");
2316 return E_NOTIMPL;
2319 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2320 if(!selector)
2321 return E_OUTOFMEMORY;
2322 sprintfW(selector, formatW, v, v);
2325 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2326 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2327 * types and search should be case insensitive. Those are currently not supported properly.
2329 nsAString_InitDepend(&selector_str, selector);
2330 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2331 nsAString_Finish(&selector_str);
2332 heap_free(selector);
2333 if(NS_FAILED(nsres)) {
2334 ERR("QuerySelectorAll failed: %08x\n", nsres);
2335 return E_FAIL;
2338 *ppelColl = create_collection_from_nodelist(This->doc_node, node_list);
2339 nsIDOMNodeList_Release(node_list);
2340 return S_OK;
2344 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2345 IHTMLElement **pel)
2347 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2348 HTMLElement *elem;
2349 HRESULT hres;
2351 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2353 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2354 if(FAILED(hres) || !elem) {
2355 *pel = NULL;
2356 return hres;
2359 *pel = &elem->IHTMLElement_iface;
2360 return S_OK;
2364 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2365 IHTMLElementCollection **pelColl)
2367 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2368 nsIDOMNodeList *nslist;
2369 nsAString id_str;
2370 nsresult nsres;
2372 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2374 if(!This->doc_node->nsdoc) {
2375 WARN("NULL nsdoc\n");
2376 return E_UNEXPECTED;
2379 nsAString_InitDepend(&id_str, v);
2380 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2381 nsAString_Finish(&id_str);
2382 if(FAILED(nsres)) {
2383 ERR("GetElementByName failed: %08x\n", nsres);
2384 return E_FAIL;
2387 *pelColl = create_collection_from_nodelist(This->doc_node, nslist);
2388 nsIDOMNodeList_Release(nslist);
2390 return S_OK;
2393 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2394 HTMLDocument3_QueryInterface,
2395 HTMLDocument3_AddRef,
2396 HTMLDocument3_Release,
2397 HTMLDocument3_GetTypeInfoCount,
2398 HTMLDocument3_GetTypeInfo,
2399 HTMLDocument3_GetIDsOfNames,
2400 HTMLDocument3_Invoke,
2401 HTMLDocument3_releaseCapture,
2402 HTMLDocument3_recalc,
2403 HTMLDocument3_createTextNode,
2404 HTMLDocument3_get_documentElement,
2405 HTMLDocument3_uniqueID,
2406 HTMLDocument3_attachEvent,
2407 HTMLDocument3_detachEvent,
2408 HTMLDocument3_put_onrowsdelete,
2409 HTMLDocument3_get_onrowsdelete,
2410 HTMLDocument3_put_onrowsinserted,
2411 HTMLDocument3_get_onrowsinserted,
2412 HTMLDocument3_put_oncellchange,
2413 HTMLDocument3_get_oncellchange,
2414 HTMLDocument3_put_ondatasetchanged,
2415 HTMLDocument3_get_ondatasetchanged,
2416 HTMLDocument3_put_ondataavailable,
2417 HTMLDocument3_get_ondataavailable,
2418 HTMLDocument3_put_ondatasetcomplete,
2419 HTMLDocument3_get_ondatasetcomplete,
2420 HTMLDocument3_put_onpropertychange,
2421 HTMLDocument3_get_onpropertychange,
2422 HTMLDocument3_put_dir,
2423 HTMLDocument3_get_dir,
2424 HTMLDocument3_put_oncontextmenu,
2425 HTMLDocument3_get_oncontextmenu,
2426 HTMLDocument3_put_onstop,
2427 HTMLDocument3_get_onstop,
2428 HTMLDocument3_createDocumentFragment,
2429 HTMLDocument3_get_parentDocument,
2430 HTMLDocument3_put_enableDownload,
2431 HTMLDocument3_get_enableDownload,
2432 HTMLDocument3_put_baseUrl,
2433 HTMLDocument3_get_baseUrl,
2434 HTMLDocument3_get_childNodes,
2435 HTMLDocument3_put_inheritStyleSheets,
2436 HTMLDocument3_get_inheritStyleSheets,
2437 HTMLDocument3_put_onbeforeeditfocus,
2438 HTMLDocument3_get_onbeforeeditfocus,
2439 HTMLDocument3_getElementsByName,
2440 HTMLDocument3_getElementById,
2441 HTMLDocument3_getElementsByTagName
2444 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2446 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2449 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2450 REFIID riid, void **ppv)
2452 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2453 return htmldoc_query_interface(This, riid, ppv);
2456 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2458 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2459 return htmldoc_addref(This);
2462 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2464 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2465 return htmldoc_release(This);
2468 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2470 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2471 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2474 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2475 LCID lcid, ITypeInfo **ppTInfo)
2477 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2478 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2481 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2482 LPOLESTR *rgszNames, UINT cNames,
2483 LCID lcid, DISPID *rgDispId)
2485 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2486 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2487 rgDispId);
2490 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2491 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2492 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2494 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2495 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2496 pDispParams, pVarResult, pExcepInfo, puArgErr);
2499 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2501 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2502 nsIDOMHTMLElement *nsbody;
2503 nsresult nsres;
2505 TRACE("(%p)->()\n", This);
2507 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2508 if(NS_FAILED(nsres) || !nsbody) {
2509 ERR("GetBody failed: %08x\n", nsres);
2510 return E_FAIL;
2513 nsres = nsIDOMHTMLElement_Focus(nsbody);
2514 nsIDOMHTMLElement_Release(nsbody);
2515 if(NS_FAILED(nsres)) {
2516 ERR("Focus failed: %08x\n", nsres);
2517 return E_FAIL;
2520 return S_OK;
2523 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2525 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2526 FIXME("(%p)->(%p)\n", This, pfFocus);
2527 return E_NOTIMPL;
2530 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2532 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2533 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2534 return E_NOTIMPL;
2537 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2539 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2540 FIXME("(%p)->(%p)\n", This, p);
2541 return E_NOTIMPL;
2544 static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
2546 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2547 FIXME("(%p)->(%p)\n", This, p);
2548 return E_NOTIMPL;
2551 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2552 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2554 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2555 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2556 return E_NOTIMPL;
2559 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2561 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2562 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2563 return E_NOTIMPL;
2566 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2568 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2569 FIXME("(%p)->(%p)\n", This, p);
2570 return E_NOTIMPL;
2573 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2574 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2576 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2578 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2580 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2581 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2582 return E_NOTIMPL;
2585 return create_event_obj(ppEventObj);
2588 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2589 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2591 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2593 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2595 return dispatch_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2598 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2599 IHTMLRenderStyle **ppIHTMLRenderStyle)
2601 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2602 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2603 return E_NOTIMPL;
2606 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2608 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2609 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2610 return E_NOTIMPL;
2613 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2615 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2616 FIXME("(%p)->(%p)\n", This, p);
2617 return E_NOTIMPL;
2620 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2622 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2623 FIXME("(%p)->(%p)\n", This, p);
2624 return E_NOTIMPL;
2627 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2628 HTMLDocument4_QueryInterface,
2629 HTMLDocument4_AddRef,
2630 HTMLDocument4_Release,
2631 HTMLDocument4_GetTypeInfoCount,
2632 HTMLDocument4_GetTypeInfo,
2633 HTMLDocument4_GetIDsOfNames,
2634 HTMLDocument4_Invoke,
2635 HTMLDocument4_focus,
2636 HTMLDocument4_hasFocus,
2637 HTMLDocument4_put_onselectionchange,
2638 HTMLDocument4_get_onselectionchange,
2639 HTMLDocument4_get_namespace,
2640 HTMLDocument4_createDocumentFromUrl,
2641 HTMLDocument4_put_media,
2642 HTMLDocument4_get_media,
2643 HTMLDocument4_createEventObject,
2644 HTMLDocument4_fireEvent,
2645 HTMLDocument4_createRenderStyle,
2646 HTMLDocument4_put_oncontrolselect,
2647 HTMLDocument4_get_oncontrolselect,
2648 HTMLDocument4_get_URLEncoded
2651 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2653 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2656 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2657 REFIID riid, void **ppv)
2659 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2660 return htmldoc_query_interface(This, riid, ppv);
2663 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2665 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2666 return htmldoc_addref(This);
2669 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2671 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2672 return htmldoc_release(This);
2675 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2677 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2678 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2681 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2682 LCID lcid, ITypeInfo **ppTInfo)
2684 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2685 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2688 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2689 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2691 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2692 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2693 rgDispId);
2696 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2697 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2698 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2700 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2701 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2702 pDispParams, pVarResult, pExcepInfo, puArgErr);
2705 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2707 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2708 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2709 return E_NOTIMPL;
2712 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2714 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2715 FIXME("(%p)->(%p)\n", This, p);
2716 return E_NOTIMPL;
2719 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2721 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2722 FIXME("(%p)->(%p)\n", This, p);
2723 return E_NOTIMPL;
2726 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2728 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2729 HTMLDocumentNode *doc_node = This->doc_node;
2731 TRACE("(%p)->(%p)\n", This, p);
2733 if(!doc_node->dom_implementation) {
2734 HRESULT hres;
2736 hres = create_dom_implementation(&doc_node->dom_implementation);
2737 if(FAILED(hres))
2738 return hres;
2741 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2742 *p = doc_node->dom_implementation;
2743 return S_OK;
2746 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2747 IHTMLDOMAttribute **ppattribute)
2749 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2750 HTMLDOMAttribute *attr;
2751 HRESULT hres;
2753 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2755 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
2756 if(FAILED(hres))
2757 return hres;
2759 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2760 return S_OK;
2763 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2764 IHTMLDOMNode **ppRetNode)
2766 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2767 nsIDOMComment *nscomment;
2768 HTMLElement *elem;
2769 nsAString str;
2770 nsresult nsres;
2771 HRESULT hres;
2773 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2775 if(!This->doc_node->nsdoc) {
2776 WARN("NULL nsdoc\n");
2777 return E_UNEXPECTED;
2780 nsAString_InitDepend(&str, bstrdata);
2781 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2782 nsAString_Finish(&str);
2783 if(NS_FAILED(nsres)) {
2784 ERR("CreateTextNode failed: %08x\n", nsres);
2785 return E_FAIL;
2788 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2789 nsIDOMComment_Release(nscomment);
2790 if(FAILED(hres))
2791 return hres;
2793 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2794 return S_OK;
2797 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2799 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2800 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2801 return E_NOTIMPL;
2804 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2806 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2807 FIXME("(%p)->(%p)\n", This, p);
2808 return E_NOTIMPL;
2811 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2813 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2814 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2815 return E_NOTIMPL;
2818 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2820 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2821 FIXME("(%p)->(%p)\n", This, p);
2822 return E_NOTIMPL;
2825 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2827 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2828 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2829 return E_NOTIMPL;
2832 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2834 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2835 FIXME("(%p)->(%p)\n", This, p);
2836 return E_NOTIMPL;
2839 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2841 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2842 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2843 return E_NOTIMPL;
2846 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2848 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2849 FIXME("(%p)->(%p)\n", This, p);
2850 return E_NOTIMPL;
2853 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2855 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2856 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2857 return E_NOTIMPL;
2860 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2862 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2863 FIXME("(%p)->(%p)\n", This, p);
2864 return E_NOTIMPL;
2867 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2869 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2870 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2871 return E_NOTIMPL;
2874 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2876 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2877 FIXME("(%p)->(%p)\n", This, p);
2878 return E_NOTIMPL;
2881 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2883 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2884 nsAString mode_str;
2885 nsresult nsres;
2887 TRACE("(%p)->(%p)\n", This, p);
2889 if(!This->doc_node->nsdoc) {
2890 WARN("NULL nsdoc\n");
2891 return E_UNEXPECTED;
2894 nsAString_Init(&mode_str, NULL);
2895 nsres = nsIDOMHTMLDocument_GetCompatMode(This->doc_node->nsdoc, &mode_str);
2896 return return_nsstr(nsres, &mode_str, p);
2899 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
2900 HTMLDocument5_QueryInterface,
2901 HTMLDocument5_AddRef,
2902 HTMLDocument5_Release,
2903 HTMLDocument5_GetTypeInfoCount,
2904 HTMLDocument5_GetTypeInfo,
2905 HTMLDocument5_GetIDsOfNames,
2906 HTMLDocument5_Invoke,
2907 HTMLDocument5_put_onmousewheel,
2908 HTMLDocument5_get_onmousewheel,
2909 HTMLDocument5_get_doctype,
2910 HTMLDocument5_get_implementation,
2911 HTMLDocument5_createAttribute,
2912 HTMLDocument5_createComment,
2913 HTMLDocument5_put_onfocusin,
2914 HTMLDocument5_get_onfocusin,
2915 HTMLDocument5_put_onfocusout,
2916 HTMLDocument5_get_onfocusout,
2917 HTMLDocument5_put_onactivate,
2918 HTMLDocument5_get_onactivate,
2919 HTMLDocument5_put_ondeactivate,
2920 HTMLDocument5_get_ondeactivate,
2921 HTMLDocument5_put_onbeforeactivate,
2922 HTMLDocument5_get_onbeforeactivate,
2923 HTMLDocument5_put_onbeforedeactivate,
2924 HTMLDocument5_get_onbeforedeactivate,
2925 HTMLDocument5_get_compatMode
2928 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
2930 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
2933 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
2934 REFIID riid, void **ppv)
2936 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2937 return htmldoc_query_interface(This, riid, ppv);
2940 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
2942 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2943 return htmldoc_addref(This);
2946 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
2948 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2949 return htmldoc_release(This);
2952 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
2954 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2955 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2958 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
2959 LCID lcid, ITypeInfo **ppTInfo)
2961 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2962 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2965 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
2966 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2968 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2969 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2970 rgDispId);
2973 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
2974 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2975 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2977 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2978 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2979 pDispParams, pVarResult, pExcepInfo, puArgErr);
2982 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
2983 IHTMLDocumentCompatibleInfoCollection **p)
2985 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2986 FIXME("(%p)->(%p)\n", This, p);
2987 return E_NOTIMPL;
2990 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface,
2991 VARIANT *p)
2993 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2994 FIXME("(%p)->(%p)\n", This, p);
2995 return E_NOTIMPL;
2998 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
2999 VARIANT *p)
3001 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3002 FIXME("(%p)->(%p)\n", This, p);
3003 return E_NOTIMPL;
3006 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3008 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3009 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3010 return E_NOTIMPL;
3013 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3014 VARIANT *p)
3016 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3017 FIXME("(%p)->(%p)\n", This, p);
3018 return E_NOTIMPL;
3021 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3023 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3024 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3025 return E_NOTIMPL;
3028 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3029 BSTR bstrId, IHTMLElement2 **p)
3031 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3032 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3033 return E_NOTIMPL;
3036 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3038 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3039 FIXME("(%p)->()\n", This);
3040 return E_NOTIMPL;
3043 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3044 HTMLDocument6_QueryInterface,
3045 HTMLDocument6_AddRef,
3046 HTMLDocument6_Release,
3047 HTMLDocument6_GetTypeInfoCount,
3048 HTMLDocument6_GetTypeInfo,
3049 HTMLDocument6_GetIDsOfNames,
3050 HTMLDocument6_Invoke,
3051 HTMLDocument6_get_compatible,
3052 HTMLDocument6_get_documentMode,
3053 HTMLDocument6_put_onstorage,
3054 HTMLDocument6_get_onstorage,
3055 HTMLDocument6_put_onstoragecommit,
3056 HTMLDocument6_get_onstoragecommit,
3057 HTMLDocument6_getElementById,
3058 HTMLDocument6_updateSettings
3061 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3063 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3066 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3068 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3069 return htmldoc_query_interface(This, riid, ppv);
3072 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3074 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3075 return htmldoc_addref(This);
3078 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3080 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3081 return htmldoc_release(This);
3084 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3086 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3087 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3090 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3091 LCID lcid, ITypeInfo **ppTInfo)
3093 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3094 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3097 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3098 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3100 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3101 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3102 rgDispId);
3105 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3106 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3107 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3109 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3110 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3111 pDispParams, pVarResult, pExcepInfo, puArgErr);
3114 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3116 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3117 FIXME("(%p)->(%p)\n", This, p);
3118 return E_NOTIMPL;
3121 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3123 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3124 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3125 return E_NOTIMPL;
3128 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3130 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3131 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3132 return E_NOTIMPL;
3135 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3136 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3138 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3139 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3140 return E_NOTIMPL;
3143 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3145 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3146 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3147 return E_NOTIMPL;
3150 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3151 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3153 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3154 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3155 return E_NOTIMPL;
3158 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3160 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3161 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3162 return E_NOTIMPL;
3165 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3167 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3168 FIXME("(%p)->(%p)\n", This, p);
3169 return E_NOTIMPL;
3172 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3174 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3175 FIXME("(%p)->(%p)\n", This, p);
3176 return E_NOTIMPL;
3179 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3181 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3182 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3183 return E_NOTIMPL;
3186 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3188 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3189 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3190 return E_NOTIMPL;
3193 static HRESULT WINAPI HTMLDocument7_getElementByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3195 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3196 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3197 return E_NOTIMPL;
3200 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3201 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3203 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3204 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3205 return E_NOTIMPL;
3208 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3210 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3211 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3212 return E_NOTIMPL;
3215 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3217 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3218 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3219 return E_NOTIMPL;
3222 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3224 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3225 FIXME("(%p)->(%p)\n", This, p);
3226 return E_NOTIMPL;
3229 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3231 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3232 FIXME("(%p)->(%p)\n", This, p);
3233 return E_NOTIMPL;
3236 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3238 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3239 FIXME("(%p)->(%p)\n", This, p);
3240 return E_NOTIMPL;
3243 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3245 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3246 FIXME("(%p)->(%p)\n", This, p);
3247 return E_NOTIMPL;
3250 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3252 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3253 FIXME("(%p)->(%x)\n", This, v);
3254 return E_NOTIMPL;
3257 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3259 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3260 FIXME("(%p)->(%p)\n", This, p);
3261 return E_NOTIMPL;
3264 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3266 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3267 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3268 return E_NOTIMPL;
3271 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3273 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3274 FIXME("(%p)->(%p)\n", This, p);
3275 return E_NOTIMPL;
3278 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3280 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3281 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3282 return E_NOTIMPL;
3285 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3287 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3288 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3289 return E_NOTIMPL;
3292 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3294 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3295 FIXME("(%p)->(%p)\n", This, p);
3296 return E_NOTIMPL;
3299 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3301 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3302 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3303 return E_NOTIMPL;
3306 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3308 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3309 FIXME("(%p)->(%p)\n", This, p);
3310 return E_NOTIMPL;
3313 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3315 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3316 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3317 return E_NOTIMPL;
3320 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3322 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3323 FIXME("(%p)->(%p)\n", This, p);
3324 return E_NOTIMPL;
3327 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3329 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3330 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3331 return E_NOTIMPL;
3334 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3336 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3337 FIXME("(%p)->(%p)\n", This, p);
3338 return E_NOTIMPL;
3341 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3343 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3344 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3345 return E_NOTIMPL;
3348 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3350 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3351 FIXME("(%p)->(%p)\n", This, p);
3352 return E_NOTIMPL;
3355 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3357 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3358 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3359 return E_NOTIMPL;
3362 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3364 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3365 FIXME("(%p)->(%p)\n", This, p);
3366 return E_NOTIMPL;
3369 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3371 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3372 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3373 return E_NOTIMPL;
3376 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3378 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3379 FIXME("(%p)->(%p)\n", This, p);
3380 return E_NOTIMPL;
3383 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3385 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3386 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3387 return E_NOTIMPL;
3390 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3392 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3393 FIXME("(%p)->(%p)\n", This, p);
3394 return E_NOTIMPL;
3397 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3399 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3400 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3401 return E_NOTIMPL;
3404 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3406 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3407 FIXME("(%p)->(%p)\n", This, p);
3408 return E_NOTIMPL;
3411 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3413 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3414 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3415 return E_NOTIMPL;
3418 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3420 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3421 FIXME("(%p)->(%p)\n", This, p);
3422 return E_NOTIMPL;
3425 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3427 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3428 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3429 return E_NOTIMPL;
3432 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3434 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3435 FIXME("(%p)->(%p)\n", This, p);
3436 return E_NOTIMPL;
3439 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3441 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3442 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3443 return E_NOTIMPL;
3446 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
3448 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3449 FIXME("(%p)->(%p)\n", This, p);
3450 return E_NOTIMPL;
3453 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
3455 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3456 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3457 return E_NOTIMPL;
3460 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
3462 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3463 FIXME("(%p)->(%p)\n", This, p);
3464 return E_NOTIMPL;
3467 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
3469 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3470 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3471 return E_NOTIMPL;
3474 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
3476 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3477 FIXME("(%p)->(%p)\n", This, p);
3478 return E_NOTIMPL;
3481 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
3483 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3484 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3485 return E_NOTIMPL;
3488 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
3490 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3491 FIXME("(%p)->(%p)\n", This, p);
3492 return E_NOTIMPL;
3495 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
3497 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3498 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3499 return E_NOTIMPL;
3502 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
3504 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3505 FIXME("(%p)->(%p)\n", This, p);
3506 return E_NOTIMPL;
3509 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
3511 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3512 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3513 return E_NOTIMPL;
3516 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
3518 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3519 FIXME("(%p)->(%p)\n", This, p);
3520 return E_NOTIMPL;
3523 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
3525 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3526 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3527 return E_NOTIMPL;
3530 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
3532 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3533 FIXME("(%p)->(%p)\n", This, p);
3534 return E_NOTIMPL;
3537 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
3539 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3540 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3541 return E_NOTIMPL;
3544 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
3546 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3547 FIXME("(%p)->(%p)\n", This, p);
3548 return E_NOTIMPL;
3551 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
3553 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3554 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3555 return E_NOTIMPL;
3558 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
3560 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3561 FIXME("(%p)->(%p)\n", This, p);
3562 return E_NOTIMPL;
3565 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
3567 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3568 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3569 return E_NOTIMPL;
3572 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
3574 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3575 FIXME("(%p)->(%p)\n", This, p);
3576 return E_NOTIMPL;
3579 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
3581 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3582 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3583 return E_NOTIMPL;
3586 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
3588 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3589 FIXME("(%p)->(%p)\n", This, p);
3590 return E_NOTIMPL;
3593 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
3595 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3596 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3597 return E_NOTIMPL;
3600 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
3602 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3603 FIXME("(%p)->(%p)\n", This, p);
3604 return E_NOTIMPL;
3607 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
3609 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3610 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3611 return E_NOTIMPL;
3614 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
3616 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3617 FIXME("(%p)->(%p)\n", This, p);
3618 return E_NOTIMPL;
3621 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
3623 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3624 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3625 return E_NOTIMPL;
3628 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
3630 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3631 FIXME("(%p)->(%p)\n", This, p);
3632 return E_NOTIMPL;
3635 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
3637 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3638 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3639 return E_NOTIMPL;
3642 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
3644 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3645 FIXME("(%p)->(%p)\n", This, p);
3646 return E_NOTIMPL;
3649 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
3651 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3652 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3653 return E_NOTIMPL;
3656 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
3658 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3659 FIXME("(%p)->(%p)\n", This, p);
3660 return E_NOTIMPL;
3663 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
3665 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3666 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3667 return E_NOTIMPL;
3670 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
3672 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3673 FIXME("(%p)->(%p)\n", This, p);
3674 return E_NOTIMPL;
3677 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
3679 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3680 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3681 return E_NOTIMPL;
3684 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
3686 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3687 FIXME("(%p)->(%p)\n", This, p);
3688 return E_NOTIMPL;
3691 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
3693 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3694 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3695 return E_NOTIMPL;
3698 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
3700 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3701 FIXME("(%p)->(%p)\n", This, p);
3702 return E_NOTIMPL;
3705 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
3707 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3708 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3709 return E_NOTIMPL;
3712 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
3714 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3715 FIXME("(%p)->(%p)\n", This, p);
3716 return E_NOTIMPL;
3719 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
3721 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3722 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3723 return E_NOTIMPL;
3726 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
3728 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3729 FIXME("(%p)->(%p)\n", This, p);
3730 return E_NOTIMPL;
3733 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
3735 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3736 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3737 return E_NOTIMPL;
3740 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
3742 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3743 FIXME("(%p)->(%p)\n", This, p);
3744 return E_NOTIMPL;
3747 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
3749 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3750 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3751 return E_NOTIMPL;
3754 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
3756 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3757 FIXME("(%p)->(%p)\n", This, p);
3758 return E_NOTIMPL;
3761 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
3763 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3764 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3765 return E_NOTIMPL;
3768 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
3770 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3771 FIXME("(%p)->(%p)\n", This, p);
3772 return E_NOTIMPL;
3775 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
3777 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3778 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3779 return E_NOTIMPL;
3782 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
3784 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3785 FIXME("(%p)->(%p)\n", This, p);
3786 return E_NOTIMPL;
3789 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
3791 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3792 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3793 return E_NOTIMPL;
3796 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
3798 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3799 FIXME("(%p)->(%p)\n", This, p);
3800 return E_NOTIMPL;
3803 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
3805 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3806 FIXME("(%p)\n", This);
3807 return E_NOTIMPL;
3810 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
3811 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
3813 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3814 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
3815 return E_NOTIMPL;
3818 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3820 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3821 FIXME("(%p)->(%p)\n", This, p);
3822 return E_NOTIMPL;
3825 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
3827 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3828 FIXME("(%p)->(%p)\n", This, v);
3829 return E_NOTIMPL;
3832 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
3834 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3835 FIXME("(%p)->(%p)\n", This, p);
3836 return E_NOTIMPL;
3839 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
3841 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3842 FIXME("(%p)->(%p)\n", This, p);
3843 return E_NOTIMPL;
3846 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
3847 HTMLDocument7_QueryInterface,
3848 HTMLDocument7_AddRef,
3849 HTMLDocument7_Release,
3850 HTMLDocument7_GetTypeInfoCount,
3851 HTMLDocument7_GetTypeInfo,
3852 HTMLDocument7_GetIDsOfNames,
3853 HTMLDocument7_Invoke,
3854 HTMLDocument7_get_defaultView,
3855 HTMLDocument7_createCDATASection,
3856 HTMLDocument7_getSelection,
3857 HTMLDocument7_getElementsByTagNameNS,
3858 HTMLDocument7_createElementNS,
3859 HTMLDocument7_createAttributeNS,
3860 HTMLDocument7_put_onmsthumbnailclick,
3861 HTMLDocument7_get_onmsthumbnailclick,
3862 HTMLDocument7_get_characterSet,
3863 HTMLDocument7_createElement,
3864 HTMLDocument7_createAttribute,
3865 HTMLDocument7_getElementByClassName,
3866 HTMLDocument7_createProcessingInstruction,
3867 HTMLDocument7_adoptNode,
3868 HTMLDocument7_put_onmssitemodejumplistitemremoved,
3869 HTMLDocument7_get_onmssitemodejumplistitemremoved,
3870 HTMLDocument7_get_all,
3871 HTMLDocument7_get_inputEncoding,
3872 HTMLDocument7_get_xmlEncoding,
3873 HTMLDocument7_put_xmlStandalone,
3874 HTMLDocument7_get_xmlStandalone,
3875 HTMLDocument7_put_xmlVersion,
3876 HTMLDocument7_get_xmlVersion,
3877 HTMLDocument7_hasAttributes,
3878 HTMLDocument7_put_onabort,
3879 HTMLDocument7_get_onabort,
3880 HTMLDocument7_put_onblur,
3881 HTMLDocument7_get_onblur,
3882 HTMLDocument7_put_oncanplay,
3883 HTMLDocument7_get_oncanplay,
3884 HTMLDocument7_put_oncanplaythrough,
3885 HTMLDocument7_get_oncanplaythrough,
3886 HTMLDocument7_put_onchange,
3887 HTMLDocument7_get_onchange,
3888 HTMLDocument7_put_ondrag,
3889 HTMLDocument7_get_ondrag,
3890 HTMLDocument7_put_ondragend,
3891 HTMLDocument7_get_ondragend,
3892 HTMLDocument7_put_ondragenter,
3893 HTMLDocument7_get_ondragenter,
3894 HTMLDocument7_put_ondragleave,
3895 HTMLDocument7_get_ondragleave,
3896 HTMLDocument7_put_ondragover,
3897 HTMLDocument7_get_ondragover,
3898 HTMLDocument7_put_ondrop,
3899 HTMLDocument7_get_ondrop,
3900 HTMLDocument7_put_ondurationchange,
3901 HTMLDocument7_get_ondurationchange,
3902 HTMLDocument7_put_onemptied,
3903 HTMLDocument7_get_onemptied,
3904 HTMLDocument7_put_onended,
3905 HTMLDocument7_get_onended,
3906 HTMLDocument7_put_onerror,
3907 HTMLDocument7_get_onerror,
3908 HTMLDocument7_put_onfocus,
3909 HTMLDocument7_get_onfocus,
3910 HTMLDocument7_put_oninput,
3911 HTMLDocument7_get_oninput,
3912 HTMLDocument7_put_onload,
3913 HTMLDocument7_get_onload,
3914 HTMLDocument7_put_onloadeddata,
3915 HTMLDocument7_get_onloadeddata,
3916 HTMLDocument7_put_onloadedmetadata,
3917 HTMLDocument7_get_onloadedmetadata,
3918 HTMLDocument7_put_onloadstart,
3919 HTMLDocument7_get_onloadstart,
3920 HTMLDocument7_put_onpause,
3921 HTMLDocument7_get_onpause,
3922 HTMLDocument7_put_onplay,
3923 HTMLDocument7_get_onplay,
3924 HTMLDocument7_put_onplaying,
3925 HTMLDocument7_get_onplaying,
3926 HTMLDocument7_put_onprogress,
3927 HTMLDocument7_get_onprogress,
3928 HTMLDocument7_put_onratechange,
3929 HTMLDocument7_get_onratechange,
3930 HTMLDocument7_put_onreset,
3931 HTMLDocument7_get_onreset,
3932 HTMLDocument7_put_onscroll,
3933 HTMLDocument7_get_onscroll,
3934 HTMLDocument7_put_onseekend,
3935 HTMLDocument7_get_onseekend,
3936 HTMLDocument7_put_onseeking,
3937 HTMLDocument7_get_onseeking,
3938 HTMLDocument7_put_onselect,
3939 HTMLDocument7_get_onselect,
3940 HTMLDocument7_put_onstalled,
3941 HTMLDocument7_get_onstalled,
3942 HTMLDocument7_put_onsubmit,
3943 HTMLDocument7_get_onsubmit,
3944 HTMLDocument7_put_onsuspend,
3945 HTMLDocument7_get_onsuspend,
3946 HTMLDocument7_put_ontimeupdate,
3947 HTMLDocument7_get_ontimeupdate,
3948 HTMLDocument7_put_onvolumechange,
3949 HTMLDocument7_get_onvolumechange,
3950 HTMLDocument7_put_onwaiting,
3951 HTMLDocument7_get_onwaiting,
3952 HTMLDocument7_normalize,
3953 HTMLDocument7_importNode,
3954 HTMLDocument7_get_parentWindow,
3955 HTMLDocument7_put_body,
3956 HTMLDocument7_get_body,
3957 HTMLDocument7_get_head
3960 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
3962 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
3964 if(This->window)
3965 update_doc_cp_events(This->doc_node, cp);
3968 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
3970 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
3973 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
3975 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
3976 return htmldoc_query_interface(This, riid, ppv);
3979 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
3981 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
3982 return htmldoc_addref(This);
3985 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
3987 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
3988 return htmldoc_release(This);
3991 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
3993 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
3994 return S_FALSE;
3997 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
3998 SupportErrorInfo_QueryInterface,
3999 SupportErrorInfo_AddRef,
4000 SupportErrorInfo_Release,
4001 SupportErrorInfo_InterfaceSupportsErrorInfo
4004 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4006 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4009 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4011 nsIDOMNodeList *node_list;
4012 nsAString name_str;
4013 UINT32 len;
4014 unsigned i;
4015 nsresult nsres;
4017 if(!This->nsdoc)
4018 return DISP_E_UNKNOWNNAME;
4020 nsAString_InitDepend(&name_str, name);
4021 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4022 nsAString_Finish(&name_str);
4023 if(NS_FAILED(nsres))
4024 return E_FAIL;
4026 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4027 nsIDOMNodeList_Release(node_list);
4028 if(NS_FAILED(nsres))
4029 return E_FAIL;
4031 if(!len)
4032 return DISP_E_UNKNOWNNAME;
4034 for(i=0; i < This->elem_vars_cnt; i++) {
4035 if(!strcmpW(name, This->elem_vars[i])) {
4036 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4037 return S_OK;
4041 if(This->elem_vars_cnt == This->elem_vars_size) {
4042 WCHAR **new_vars;
4044 if(This->elem_vars_size) {
4045 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4046 if(!new_vars)
4047 return E_OUTOFMEMORY;
4048 This->elem_vars_size *= 2;
4049 }else {
4050 new_vars = heap_alloc(16*sizeof(WCHAR*));
4051 if(!new_vars)
4052 return E_OUTOFMEMORY;
4053 This->elem_vars_size = 16;
4056 This->elem_vars = new_vars;
4059 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4060 if(!This->elem_vars[This->elem_vars_cnt])
4061 return E_OUTOFMEMORY;
4063 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4064 return S_OK;
4067 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4069 HTMLDocument *This = impl_from_IDispatchEx(iface);
4071 return htmldoc_query_interface(This, riid, ppv);
4074 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4076 HTMLDocument *This = impl_from_IDispatchEx(iface);
4078 return htmldoc_addref(This);
4081 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4083 HTMLDocument *This = impl_from_IDispatchEx(iface);
4085 return htmldoc_release(This);
4088 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4090 HTMLDocument *This = impl_from_IDispatchEx(iface);
4092 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4095 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4096 LCID lcid, ITypeInfo **ppTInfo)
4098 HTMLDocument *This = impl_from_IDispatchEx(iface);
4100 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4103 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4104 LPOLESTR *rgszNames, UINT cNames,
4105 LCID lcid, DISPID *rgDispId)
4107 HTMLDocument *This = impl_from_IDispatchEx(iface);
4109 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4112 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4113 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4114 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4116 HTMLDocument *This = impl_from_IDispatchEx(iface);
4118 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4119 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4121 switch(dispIdMember) {
4122 case DISPID_READYSTATE:
4123 TRACE("DISPID_READYSTATE\n");
4125 if(!(wFlags & DISPATCH_PROPERTYGET))
4126 return E_INVALIDARG;
4128 V_VT(pVarResult) = VT_I4;
4129 V_I4(pVarResult) = This->window->readystate;
4130 return S_OK;
4133 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
4134 pVarResult, pExcepInfo, puArgErr);
4137 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4139 HTMLDocument *This = impl_from_IDispatchEx(iface);
4140 HRESULT hres;
4142 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4143 if(hres != DISP_E_UNKNOWNNAME)
4144 return hres;
4146 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4149 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4150 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4152 HTMLDocument *This = impl_from_IDispatchEx(iface);
4154 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
4155 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
4156 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4159 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4162 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4164 HTMLDocument *This = impl_from_IDispatchEx(iface);
4166 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4169 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4171 HTMLDocument *This = impl_from_IDispatchEx(iface);
4173 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4176 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4178 HTMLDocument *This = impl_from_IDispatchEx(iface);
4180 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4183 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4185 HTMLDocument *This = impl_from_IDispatchEx(iface);
4187 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4190 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4192 HTMLDocument *This = impl_from_IDispatchEx(iface);
4194 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
4197 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
4199 HTMLDocument *This = impl_from_IDispatchEx(iface);
4201 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
4204 static const IDispatchExVtbl DocDispatchExVtbl = {
4205 DocDispatchEx_QueryInterface,
4206 DocDispatchEx_AddRef,
4207 DocDispatchEx_Release,
4208 DocDispatchEx_GetTypeInfoCount,
4209 DocDispatchEx_GetTypeInfo,
4210 DocDispatchEx_GetIDsOfNames,
4211 DocDispatchEx_Invoke,
4212 DocDispatchEx_GetDispID,
4213 DocDispatchEx_InvokeEx,
4214 DocDispatchEx_DeleteMemberByName,
4215 DocDispatchEx_DeleteMemberByDispID,
4216 DocDispatchEx_GetMemberProperties,
4217 DocDispatchEx_GetMemberName,
4218 DocDispatchEx_GetNextDispID,
4219 DocDispatchEx_GetNameSpaceParent
4222 static inline HTMLDocument *impl_from_IProvideClassInfo(IProvideClassInfo *iface)
4224 return CONTAINING_RECORD(iface, HTMLDocument, IProvideClassInfo_iface);
4227 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideClassInfo *iface,
4228 REFIID riid, void **ppv)
4230 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4231 return htmldoc_query_interface(This, riid, ppv);
4234 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideClassInfo *iface)
4236 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4237 return htmldoc_addref(This);
4240 static ULONG WINAPI ProvideClassInfo_Release(IProvideClassInfo *iface)
4242 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4243 return htmldoc_release(This);
4246 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideClassInfo* iface,
4247 ITypeInfo **ppTI)
4249 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4250 TRACE("(%p)->(%p)\n", This, ppTI);
4251 return get_htmldoc_classinfo(ppTI);
4254 static const IProvideClassInfoVtbl ProvideClassInfoVtbl = {
4255 ProvideClassInfo_QueryInterface,
4256 ProvideClassInfo_AddRef,
4257 ProvideClassInfo_Release,
4258 ProvideClassInfo_GetClassInfo
4261 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
4263 *ppv = NULL;
4265 if(IsEqualGUID(&IID_IUnknown, riid))
4266 *ppv = &This->IHTMLDocument2_iface;
4267 else if(IsEqualGUID(&IID_IDispatch, riid))
4268 *ppv = &This->IDispatchEx_iface;
4269 else if(IsEqualGUID(&IID_IDispatchEx, riid))
4270 *ppv = &This->IDispatchEx_iface;
4271 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
4272 *ppv = &This->IHTMLDocument2_iface;
4273 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
4274 *ppv = &This->IHTMLDocument2_iface;
4275 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
4276 *ppv = &This->IHTMLDocument3_iface;
4277 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
4278 *ppv = &This->IHTMLDocument4_iface;
4279 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
4280 *ppv = &This->IHTMLDocument5_iface;
4281 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
4282 *ppv = &This->IHTMLDocument6_iface;
4283 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
4284 *ppv = &This->IHTMLDocument7_iface;
4285 else if(IsEqualGUID(&IID_IPersist, riid))
4286 *ppv = &This->IPersistFile_iface;
4287 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
4288 *ppv = &This->IPersistMoniker_iface;
4289 else if(IsEqualGUID(&IID_IPersistFile, riid))
4290 *ppv = &This->IPersistFile_iface;
4291 else if(IsEqualGUID(&IID_IMonikerProp, riid))
4292 *ppv = &This->IMonikerProp_iface;
4293 else if(IsEqualGUID(&IID_IOleObject, riid))
4294 *ppv = &This->IOleObject_iface;
4295 else if(IsEqualGUID(&IID_IOleDocument, riid))
4296 *ppv = &This->IOleDocument_iface;
4297 else if(IsEqualGUID(&IID_IOleDocumentView, riid))
4298 *ppv = &This->IOleDocumentView_iface;
4299 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
4300 *ppv = &This->IOleInPlaceActiveObject_iface;
4301 else if(IsEqualGUID(&IID_IViewObject, riid))
4302 *ppv = &This->IViewObjectEx_iface;
4303 else if(IsEqualGUID(&IID_IViewObject2, riid))
4304 *ppv = &This->IViewObjectEx_iface;
4305 else if(IsEqualGUID(&IID_IViewObjectEx, riid))
4306 *ppv = &This->IViewObjectEx_iface;
4307 else if(IsEqualGUID(&IID_IOleWindow, riid))
4308 *ppv = &This->IOleInPlaceActiveObject_iface;
4309 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
4310 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4311 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
4312 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4313 else if(IsEqualGUID(&IID_IServiceProvider, riid))
4314 *ppv = &This->IServiceProvider_iface;
4315 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
4316 *ppv = &This->IOleCommandTarget_iface;
4317 else if(IsEqualGUID(&IID_IOleControl, riid))
4318 *ppv = &This->IOleControl_iface;
4319 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
4320 *ppv = &This->IHlinkTarget_iface;
4321 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
4322 *ppv = &This->cp_container.IConnectionPointContainer_iface;
4323 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
4324 *ppv = &This->IPersistStreamInit_iface;
4325 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
4326 *ppv = &This->IHTMLDocument2_iface;
4327 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
4328 *ppv = &This->ISupportErrorInfo_iface;
4329 else if(IsEqualGUID(&IID_IPersistHistory, riid))
4330 *ppv = &This->IPersistHistory_iface;
4331 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
4332 *ppv = &This->IObjectWithSite_iface;
4333 else if(IsEqualGUID(&IID_IOleContainer, riid))
4334 *ppv = &This->IOleContainer_iface;
4335 else if(IsEqualGUID(&IID_IObjectSafety, riid))
4336 *ppv = &This->IObjectSafety_iface;
4337 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
4338 *ppv = &This->IProvideClassInfo_iface;
4339 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
4340 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
4341 *ppv = NULL;
4342 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
4343 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
4344 *ppv = NULL;
4345 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
4346 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
4347 *ppv = NULL;
4348 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
4349 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
4350 *ppv = NULL;
4351 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
4352 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
4353 *ppv = NULL;
4354 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
4355 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
4356 *ppv = NULL;
4357 }else {
4358 return FALSE;
4361 if(*ppv)
4362 IUnknown_AddRef((IUnknown*)*ppv);
4363 return TRUE;
4366 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
4368 static const cpc_entry_t HTMLDocument_cpc[] = {
4369 {&IID_IDispatch, &HTMLDocumentEvents_data},
4370 {&IID_IPropertyNotifySink},
4371 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
4372 {&DIID_HTMLDocumentEvents2},
4373 {NULL}
4376 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
4378 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
4379 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
4380 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
4381 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
4382 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
4383 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
4384 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
4385 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
4386 doc->IProvideClassInfo_iface.lpVtbl = &ProvideClassInfoVtbl;
4388 doc->unk_impl = unk_impl;
4389 doc->dispex = dispex;
4390 doc->task_magic = get_task_target_magic();
4392 HTMLDocument_Persist_Init(doc);
4393 HTMLDocument_OleCmd_Init(doc);
4394 HTMLDocument_OleObj_Init(doc);
4395 HTMLDocument_View_Init(doc);
4396 HTMLDocument_Window_Init(doc);
4397 HTMLDocument_Service_Init(doc);
4398 HTMLDocument_Hlink_Init(doc);
4400 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
4403 static void destroy_htmldoc(HTMLDocument *This)
4405 remove_target_tasks(This->task_magic);
4407 ConnectionPointContainer_Destroy(&This->cp_container);
4410 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
4412 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
4415 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
4417 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4419 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4421 if(htmldoc_qi(&This->basedoc, riid, ppv))
4422 return *ppv ? S_OK : E_NOINTERFACE;
4424 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
4425 *ppv = &This->IInternetHostSecurityManager_iface;
4426 else
4427 return HTMLDOMNode_QI(&This->node, riid, ppv);
4429 IUnknown_AddRef((IUnknown*)*ppv);
4430 return S_OK;
4433 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
4435 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4436 unsigned i;
4438 for(i=0; i < This->elem_vars_cnt; i++)
4439 heap_free(This->elem_vars[i]);
4440 heap_free(This->elem_vars);
4442 detach_events(This);
4443 if(This->body_event_target)
4444 release_event_target(This->body_event_target);
4445 if(This->catmgr)
4446 ICatInformation_Release(This->catmgr);
4448 detach_selection(This);
4449 detach_ranges(This);
4451 while(!list_empty(&This->plugin_hosts))
4452 detach_plugin_host(LIST_ENTRY(list_head(&This->plugin_hosts), PluginHost, entry));
4454 if(!This->nsdoc && This->window) {
4455 /* document fragments own reference to inner window */
4456 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
4457 This->window = NULL;
4460 heap_free(This->event_vector);
4461 destroy_htmldoc(&This->basedoc);
4464 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4466 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4467 FIXME("%p\n", This);
4468 return E_NOTIMPL;
4471 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
4473 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4475 if(This->nsdoc)
4476 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
4479 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
4481 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4483 if(This->nsdoc) {
4484 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
4486 release_document_mutation(This);
4487 This->nsdoc = NULL;
4488 nsIDOMHTMLDocument_Release(nsdoc);
4489 This->window = NULL;
4493 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
4494 HTMLDocumentNode_QI,
4495 HTMLDocumentNode_destructor,
4496 HTMLDocument_cpc,
4497 HTMLDocumentNode_clone,
4498 NULL,
4499 NULL,
4500 NULL,
4501 NULL,
4502 NULL,
4503 NULL,
4504 NULL,
4505 NULL,
4506 NULL,
4507 NULL,
4508 NULL,
4509 HTMLDocumentNode_traverse,
4510 HTMLDocumentNode_unlink
4513 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4515 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4516 HTMLDocumentNode *new_node;
4517 HRESULT hres;
4519 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
4520 if(FAILED(hres))
4521 return hres;
4523 *ret = &new_node->node;
4524 return S_OK;
4527 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
4529 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
4532 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4533 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4535 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4536 nsIDOMNodeList *node_list;
4537 nsAString name_str;
4538 nsIDOMNode *nsnode;
4539 HTMLDOMNode *node;
4540 unsigned i;
4541 nsresult nsres;
4542 HRESULT hres;
4544 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
4545 FIXME("unsupported flags %x\n", flags);
4546 return E_NOTIMPL;
4549 i = id - MSHTML_DISPID_CUSTOM_MIN;
4551 if(!This->nsdoc || i >= This->elem_vars_cnt)
4552 return DISP_E_UNKNOWNNAME;
4554 nsAString_InitDepend(&name_str, This->elem_vars[i]);
4555 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4556 nsAString_Finish(&name_str);
4557 if(NS_FAILED(nsres))
4558 return E_FAIL;
4560 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
4561 nsIDOMNodeList_Release(node_list);
4562 if(NS_FAILED(nsres) || !nsnode)
4563 return DISP_E_UNKNOWNNAME;
4565 hres = get_node(This, nsnode, TRUE, &node);
4566 if(FAILED(hres))
4567 return hres;
4569 V_VT(res) = VT_DISPATCH;
4570 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
4571 return S_OK;
4574 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, int eid)
4576 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4577 ensure_doc_nsevent_handler(This, eid);
4580 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl = {
4581 NULL,
4582 NULL,
4583 HTMLDocumentNode_invoke,
4584 NULL,
4585 NULL,
4586 HTMLDocumentNode_bind_event
4589 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
4590 HTMLDocumentNode_QI,
4591 HTMLDocumentNode_destructor,
4592 HTMLDocument_cpc,
4593 HTMLDocumentFragment_clone
4596 static const tid_t HTMLDocumentNode_iface_tids[] = {
4597 IHTMLDOMNode_tid,
4598 IHTMLDOMNode2_tid,
4599 IHTMLDocument2_tid,
4600 IHTMLDocument3_tid,
4601 IHTMLDocument4_tid,
4602 IHTMLDocument5_tid,
4606 static dispex_static_data_t HTMLDocumentNode_dispex = {
4607 &HTMLDocumentNode_dispex_vtbl,
4608 DispHTMLDocument_tid,
4609 NULL,
4610 HTMLDocumentNode_iface_tids
4613 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
4615 HTMLDocumentNode *doc;
4617 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
4618 if(!doc)
4619 return NULL;
4621 doc->ref = 1;
4622 doc->basedoc.doc_node = doc;
4623 doc->basedoc.doc_obj = doc_obj;
4624 doc->basedoc.window = window->base.outer_window;
4625 doc->window = window;
4627 init_dispex(&doc->node.event_target.dispex, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4628 &HTMLDocumentNode_dispex);
4629 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4630 &doc->node.event_target.dispex.IDispatchEx_iface);
4631 HTMLDocumentNode_SecMgr_Init(doc);
4633 list_init(&doc->selection_list);
4634 list_init(&doc->range_list);
4635 list_init(&doc->plugin_hosts);
4637 return doc;
4640 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLInnerWindow *window, HTMLDocumentNode **ret)
4642 HTMLDocumentNode *doc;
4644 doc = alloc_doc_node(doc_obj, window);
4645 if(!doc)
4646 return E_OUTOFMEMORY;
4648 if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
4649 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
4651 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
4653 nsIDOMHTMLDocument_AddRef(nsdoc);
4654 doc->nsdoc = nsdoc;
4656 init_document_mutation(doc);
4657 doc_init_events(doc);
4659 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
4660 doc->node.cp_container = &doc->basedoc.cp_container;
4662 *ret = doc;
4663 return S_OK;
4666 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
4668 HTMLDocumentNode *doc_frag;
4670 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
4671 if(!doc_frag)
4672 return E_OUTOFMEMORY;
4674 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
4676 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
4677 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
4678 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
4680 *ret = doc_frag;
4681 return S_OK;
4684 /**********************************************************
4685 * ICustomDoc implementation
4688 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
4690 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
4693 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
4695 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4697 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4699 if(htmldoc_qi(&This->basedoc, riid, ppv))
4700 return *ppv ? S_OK : E_NOINTERFACE;
4702 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
4703 *ppv = &This->ICustomDoc_iface;
4704 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
4705 *ppv = &This->ITargetContainer_iface;
4706 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4707 return *ppv ? S_OK : E_NOINTERFACE;
4708 }else {
4709 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
4710 *ppv = NULL;
4711 return E_NOINTERFACE;
4714 IUnknown_AddRef((IUnknown*)*ppv);
4715 return S_OK;
4718 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
4720 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4721 ULONG ref = InterlockedIncrement(&This->ref);
4723 TRACE("(%p) ref = %u\n", This, ref);
4725 return ref;
4728 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
4730 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4731 ULONG ref = InterlockedDecrement(&This->ref);
4733 TRACE("(%p) ref = %u\n", This, ref);
4735 if(!ref) {
4736 nsIDOMWindowUtils *window_utils = NULL;
4738 if(This->basedoc.window && This->basedoc.window->nswindow)
4739 get_nsinterface((nsISupports*)This->basedoc.window->nswindow, &IID_nsIDOMWindowUtils, (void**)&window_utils);
4741 if(This->basedoc.doc_node) {
4742 This->basedoc.doc_node->basedoc.doc_obj = NULL;
4743 htmldoc_release(&This->basedoc.doc_node->basedoc);
4745 if(This->basedoc.window) {
4746 This->basedoc.window->doc_obj = NULL;
4747 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
4749 if(This->basedoc.advise_holder)
4750 IOleAdviseHolder_Release(This->basedoc.advise_holder);
4752 if(This->view_sink)
4753 IAdviseSink_Release(This->view_sink);
4754 if(This->client)
4755 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
4756 if(This->hostui)
4757 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
4758 if(This->in_place_active)
4759 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
4760 if(This->ipsite)
4761 IOleDocumentView_SetInPlaceSite(&This->basedoc.IOleDocumentView_iface, NULL);
4762 if(This->undomgr)
4763 IOleUndoManager_Release(This->undomgr);
4764 if(This->tooltips_hwnd)
4765 DestroyWindow(This->tooltips_hwnd);
4767 if(This->hwnd)
4768 DestroyWindow(This->hwnd);
4769 heap_free(This->mime);
4771 destroy_htmldoc(&This->basedoc);
4772 release_dispex(&This->dispex);
4774 if(This->nscontainer)
4775 NSContainer_Release(This->nscontainer);
4776 heap_free(This);
4778 /* Force cycle collection */
4779 if(window_utils) {
4780 nsIDOMWindowUtils_CycleCollect(window_utils, NULL, 0);
4781 nsIDOMWindowUtils_Release(window_utils);
4785 return ref;
4788 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
4790 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4791 IOleCommandTarget *cmdtrg;
4792 HRESULT hres;
4794 TRACE("(%p)->(%p)\n", This, pUIHandler);
4796 if(This->custom_hostui && This->hostui == pUIHandler)
4797 return S_OK;
4799 This->custom_hostui = TRUE;
4801 if(This->hostui)
4802 IDocHostUIHandler_Release(This->hostui);
4803 if(pUIHandler)
4804 IDocHostUIHandler_AddRef(pUIHandler);
4805 This->hostui = pUIHandler;
4806 if(!pUIHandler)
4807 return S_OK;
4809 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
4810 if(SUCCEEDED(hres)) {
4811 FIXME("custom UI handler supports IOleCommandTarget\n");
4812 IOleCommandTarget_Release(cmdtrg);
4815 return S_OK;
4818 static const ICustomDocVtbl CustomDocVtbl = {
4819 CustomDoc_QueryInterface,
4820 CustomDoc_AddRef,
4821 CustomDoc_Release,
4822 CustomDoc_SetUIHandler
4825 static const tid_t HTMLDocumentObj_iface_tids[] = {
4826 IHTMLDocument2_tid,
4827 IHTMLDocument3_tid,
4828 IHTMLDocument4_tid,
4829 IHTMLDocument5_tid,
4832 static dispex_static_data_t HTMLDocumentObj_dispex = {
4833 NULL,
4834 DispHTMLDocument_tid,
4835 NULL,
4836 HTMLDocumentObj_iface_tids
4839 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
4841 HTMLDocumentObj *doc;
4842 nsIDOMWindow *nswindow = NULL;
4843 nsresult nsres;
4844 HRESULT hres;
4846 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_mshtml_guid(riid), ppvObject);
4848 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
4849 if(!doc)
4850 return E_OUTOFMEMORY;
4852 init_dispex(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex);
4853 init_doc(&doc->basedoc, (IUnknown*)&doc->ICustomDoc_iface, &doc->dispex.IDispatchEx_iface);
4854 TargetContainer_Init(doc);
4856 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
4857 doc->ref = 1;
4858 doc->basedoc.doc_obj = doc;
4860 doc->usermode = UNKNOWN_USERMODE;
4862 init_binding_ui(doc);
4864 hres = create_nscontainer(doc, &doc->nscontainer);
4865 if(FAILED(hres)) {
4866 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
4867 htmldoc_release(&doc->basedoc);
4868 return hres;
4871 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
4872 htmldoc_release(&doc->basedoc);
4873 if(FAILED(hres))
4874 return hres;
4876 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
4877 if(NS_FAILED(nsres))
4878 ERR("GetContentDOMWindow failed: %08x\n", nsres);
4880 hres = HTMLOuterWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
4881 if(nswindow)
4882 nsIDOMWindow_Release(nswindow);
4883 if(FAILED(hres)) {
4884 htmldoc_release(&doc->basedoc);
4885 return hres;
4888 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
4889 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
4890 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
4893 get_thread_hwnd();
4895 return S_OK;