wined3d: Merge volumetexture_init() and texture_init().
[wine.git] / dlls / mshtml / htmldoc.c
blob8cee880b935993a7f0ef1d02aaa9948681f94c5d
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_element(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((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 HTMLElement *element;
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_element((nsIDOMElement*)nsbody, &element);
285 nsIDOMHTMLElement_Release(nsbody);
286 if(FAILED(hres))
287 return hres;
289 *p = &element->IHTMLElement_iface;
290 return S_OK;
293 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
295 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
296 nsIDOMElement *nselem;
297 HTMLElement *elem;
298 nsresult nsres;
299 HRESULT hres;
301 TRACE("(%p)->(%p)\n", This, p);
303 if(!This->doc_node->nsdoc) {
304 *p = NULL;
305 return S_OK;
309 * NOTE: Gecko may return an active element even if the document is not visible.
310 * IE returns NULL in this case.
312 nsres = nsIDOMHTMLDocument_GetActiveElement(This->doc_node->nsdoc, &nselem);
313 if(NS_FAILED(nsres)) {
314 ERR("GetActiveElement failed: %08x\n", nsres);
315 return E_FAIL;
318 if(!nselem) {
319 *p = NULL;
320 return S_OK;
323 hres = get_element(nselem, &elem);
324 nsIDOMElement_Release(nselem);
325 if(FAILED(hres))
326 return hres;
328 *p = &elem->IHTMLElement_iface;
329 return S_OK;
332 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
334 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
335 nsIDOMHTMLCollection *nscoll = NULL;
336 nsresult nsres;
338 TRACE("(%p)->(%p)\n", This, p);
340 if(!p)
341 return E_INVALIDARG;
343 *p = NULL;
345 if(!This->doc_node->nsdoc) {
346 WARN("NULL nsdoc\n");
347 return E_UNEXPECTED;
350 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
351 if(NS_FAILED(nsres)) {
352 ERR("GetImages failed: %08x\n", nsres);
353 return E_FAIL;
356 if(nscoll) {
357 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
358 nsIDOMHTMLCollection_Release(nscoll);
361 return S_OK;
364 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
366 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
367 nsIDOMHTMLCollection *nscoll = NULL;
368 nsresult nsres;
370 TRACE("(%p)->(%p)\n", This, p);
372 if(!p)
373 return E_INVALIDARG;
375 *p = NULL;
377 if(!This->doc_node->nsdoc) {
378 WARN("NULL nsdoc\n");
379 return E_UNEXPECTED;
382 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
383 if(NS_FAILED(nsres)) {
384 ERR("GetApplets failed: %08x\n", nsres);
385 return E_FAIL;
388 if(nscoll) {
389 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
390 nsIDOMHTMLCollection_Release(nscoll);
393 return S_OK;
396 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
398 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
399 nsIDOMHTMLCollection *nscoll = NULL;
400 nsresult nsres;
402 TRACE("(%p)->(%p)\n", This, p);
404 if(!p)
405 return E_INVALIDARG;
407 *p = NULL;
409 if(!This->doc_node->nsdoc) {
410 WARN("NULL nsdoc\n");
411 return E_UNEXPECTED;
414 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
415 if(NS_FAILED(nsres)) {
416 ERR("GetLinks failed: %08x\n", nsres);
417 return E_FAIL;
420 if(nscoll) {
421 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
422 nsIDOMHTMLCollection_Release(nscoll);
425 return S_OK;
428 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
430 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
431 nsIDOMHTMLCollection *nscoll = NULL;
432 nsresult nsres;
434 TRACE("(%p)->(%p)\n", This, p);
436 if(!p)
437 return E_INVALIDARG;
439 *p = NULL;
441 if(!This->doc_node->nsdoc) {
442 WARN("NULL nsdoc\n");
443 return E_UNEXPECTED;
446 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
447 if(NS_FAILED(nsres)) {
448 ERR("GetForms failed: %08x\n", nsres);
449 return E_FAIL;
452 if(nscoll) {
453 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
454 nsIDOMHTMLCollection_Release(nscoll);
457 return S_OK;
460 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
462 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
463 nsIDOMHTMLCollection *nscoll = NULL;
464 nsresult nsres;
466 TRACE("(%p)->(%p)\n", This, p);
468 if(!p)
469 return E_INVALIDARG;
471 *p = NULL;
473 if(!This->doc_node->nsdoc) {
474 WARN("NULL nsdoc\n");
475 return E_UNEXPECTED;
478 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
479 if(NS_FAILED(nsres)) {
480 ERR("GetAnchors failed: %08x\n", nsres);
481 return E_FAIL;
484 if(nscoll) {
485 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
486 nsIDOMHTMLCollection_Release(nscoll);
489 return S_OK;
492 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
494 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
495 nsAString nsstr;
496 nsresult nsres;
498 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
500 if(!This->doc_node->nsdoc) {
501 WARN("NULL nsdoc\n");
502 return E_UNEXPECTED;
505 nsAString_InitDepend(&nsstr, v);
506 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
507 nsAString_Finish(&nsstr);
508 if(NS_FAILED(nsres))
509 ERR("SetTitle failed: %08x\n", nsres);
511 return S_OK;
514 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
516 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
517 const PRUnichar *ret;
518 nsAString nsstr;
519 nsresult nsres;
521 TRACE("(%p)->(%p)\n", This, p);
523 if(!This->doc_node->nsdoc) {
524 WARN("NULL nsdoc\n");
525 return E_UNEXPECTED;
529 nsAString_Init(&nsstr, NULL);
530 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
531 if (NS_SUCCEEDED(nsres)) {
532 nsAString_GetData(&nsstr, &ret);
533 *p = SysAllocString(ret);
535 nsAString_Finish(&nsstr);
537 if(NS_FAILED(nsres)) {
538 ERR("GetTitle failed: %08x\n", nsres);
539 return E_FAIL;
542 return S_OK;
545 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
547 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
548 nsIDOMHTMLCollection *nscoll = NULL;
549 nsresult nsres;
551 TRACE("(%p)->(%p)\n", This, p);
553 if(!p)
554 return E_INVALIDARG;
556 *p = NULL;
558 if(!This->doc_node->nsdoc) {
559 WARN("NULL nsdoc\n");
560 return E_UNEXPECTED;
563 nsres = nsIDOMHTMLDocument_GetScripts(This->doc_node->nsdoc, &nscoll);
564 if(NS_FAILED(nsres)) {
565 ERR("GetImages failed: %08x\n", nsres);
566 return E_FAIL;
569 if(nscoll) {
570 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
571 nsIDOMHTMLCollection_Release(nscoll);
574 return S_OK;
577 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
579 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
580 HRESULT hres;
582 static const WCHAR onW[] = {'o','n',0};
584 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
586 if(strcmpiW(v, onW)) {
587 FIXME("Unsupported arg %s\n", debugstr_w(v));
588 return E_NOTIMPL;
591 hres = setup_edit_mode(This->doc_obj);
592 if(FAILED(hres))
593 return hres;
595 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
596 return S_OK;
599 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
601 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
602 static const WCHAR szOff[] = {'O','f','f',0};
603 FIXME("(%p)->(%p) always returning Off\n", This, p);
605 if(!p)
606 return E_INVALIDARG;
608 *p = SysAllocString(szOff);
610 return S_OK;
613 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
615 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
616 nsISelection *nsselection;
617 nsresult nsres;
619 TRACE("(%p)->(%p)\n", This, p);
621 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
622 if(NS_FAILED(nsres)) {
623 ERR("GetSelection failed: %08x\n", nsres);
624 return E_FAIL;
627 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
630 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
632 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
635 TRACE("(%p)->(%p)\n", iface, p);
637 if(!p)
638 return E_POINTER;
640 return get_readystate_string(This->window->readystate, p);
643 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
645 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
647 TRACE("(%p)->(%p)\n", This, p);
649 return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p);
652 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
654 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
655 FIXME("(%p)->(%p)\n", This, p);
656 return E_NOTIMPL;
659 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
661 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
662 FIXME("(%p)->(%p)\n", This, p);
663 return E_NOTIMPL;
666 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
668 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
669 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
670 return E_NOTIMPL;
673 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
675 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
676 FIXME("(%p)->(%p)\n", This, p);
677 return E_NOTIMPL;
680 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
682 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
683 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
684 return E_NOTIMPL;
687 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
689 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
690 FIXME("(%p)->(%p)\n", This, p);
691 return E_NOTIMPL;
694 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
696 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
697 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
698 return E_NOTIMPL;
701 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
703 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
704 FIXME("(%p)->(%p)\n", This, p);
705 return E_NOTIMPL;
708 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
710 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
711 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
712 return E_NOTIMPL;
715 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
717 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
718 FIXME("(%p)->(%p)\n", This, p);
719 return E_NOTIMPL;
722 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
724 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
725 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
726 return E_NOTIMPL;
729 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
731 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
732 FIXME("(%p)->(%p)\n", This, p);
733 return E_NOTIMPL;
736 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
738 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
740 FIXME("(%p)->(%p)\n", This, p);
742 *p = NULL;
743 return S_OK;
746 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
748 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
750 TRACE("(%p)->(%p)\n", This, p);
752 if(!This->doc_node->nsdoc) {
753 WARN("NULL nsdoc\n");
754 return E_UNEXPECTED;
757 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
760 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
762 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
763 FIXME("(%p)->(%p)\n", This, p);
764 return E_NOTIMPL;
767 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
769 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
771 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
773 if(!This->window) {
774 FIXME("No window available\n");
775 return E_FAIL;
778 return navigate_url(This->window, v, This->window->uri, BINDING_NAVIGATED);
781 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
783 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
785 static const WCHAR about_blank_url[] =
786 {'a','b','o','u','t',':','b','l','a','n','k',0};
788 TRACE("(%p)->(%p)\n", iface, p);
790 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
791 return *p ? S_OK : E_OUTOFMEMORY;
794 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
796 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
797 nsAString nsstr;
798 nsresult nsres;
800 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
802 nsAString_InitDepend(&nsstr, v);
803 nsres = nsIDOMHTMLDocument_SetDomain(This->doc_node->nsdoc, &nsstr);
804 nsAString_Finish(&nsstr);
805 if(NS_FAILED(nsres)) {
806 ERR("SetDomain failed: %08x\n", nsres);
807 return E_INVALIDARG;
810 return S_OK;
813 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
815 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
816 nsAString nsstr;
817 nsresult nsres;
819 TRACE("(%p)->(%p)\n", This, p);
821 nsAString_Init(&nsstr, NULL);
822 nsres = nsIDOMHTMLDocument_GetDomain(This->doc_node->nsdoc, &nsstr);
823 if(NS_SUCCEEDED(nsres) && This->window && This->window->uri) {
824 const PRUnichar *str;
825 HRESULT hres;
827 nsAString_GetData(&nsstr, &str);
828 if(!*str) {
829 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
830 nsAString_Finish(&nsstr);
831 hres = IUri_GetHost(This->window->uri, p);
832 return FAILED(hres) ? hres : S_OK;
836 return return_nsstr(nsres, &nsstr, p);
839 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
841 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
842 BOOL bret;
844 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
846 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
847 if(!bret) {
848 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
849 return HRESULT_FROM_WIN32(GetLastError());
852 return S_OK;
855 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
857 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
858 DWORD size;
859 BOOL bret;
861 TRACE("(%p)->(%p)\n", This, p);
863 size = 0;
864 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
865 if(!bret) {
866 switch(GetLastError()) {
867 case ERROR_INSUFFICIENT_BUFFER:
868 break;
869 case ERROR_NO_MORE_ITEMS:
870 *p = NULL;
871 return S_OK;
872 default:
873 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
874 return HRESULT_FROM_WIN32(GetLastError());
878 if(!size) {
879 *p = NULL;
880 return S_OK;
883 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
884 if(!*p)
885 return E_OUTOFMEMORY;
887 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
888 if(!bret) {
889 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
890 return E_FAIL;
893 return S_OK;
896 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
898 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
899 FIXME("(%p)->(%x)\n", This, v);
900 return E_NOTIMPL;
903 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
905 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
906 FIXME("(%p)->(%p)\n", This, p);
907 return E_NOTIMPL;
910 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
912 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
913 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
914 return E_NOTIMPL;
917 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
919 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
921 TRACE("(%p)->(%p)\n", This, p);
923 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
926 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
928 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
929 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
930 return E_NOTIMPL;
933 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
935 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
937 TRACE("(%p)->(%p)\n", This, p);
939 *p = charset_string_from_cp(GetACP());
940 return *p ? S_OK : E_OUTOFMEMORY;
943 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
945 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
946 FIXME("(%p)->(%p)\n", This, p);
947 return E_NOTIMPL;
950 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
952 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
953 FIXME("(%p)->(%p)\n", This, p);
954 return E_NOTIMPL;
957 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
959 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
960 FIXME("(%p)->(%p)\n", This, p);
961 return E_NOTIMPL;
964 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
966 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
967 FIXME("(%p)->(%p)\n", This, p);
968 return E_NOTIMPL;
971 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
973 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
974 FIXME("(%p)->(%p)\n", This, p);
975 return E_NOTIMPL;
978 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
980 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
981 FIXME("(%p)->(%p)\n", This, p);
982 return E_NOTIMPL;
985 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
987 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
988 FIXME("(%p)->(%p)\n", This, p);
989 return E_NOTIMPL;
992 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
994 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
995 FIXME("(%p)->(%p)\n", This, p);
996 return E_NOTIMPL;
999 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
1001 VARIANT *var, tmp;
1002 JSContext *jsctx;
1003 nsAString nsstr;
1004 ULONG i, argc;
1005 nsresult nsres;
1006 HRESULT hres;
1008 if(!This->doc_node->nsdoc) {
1009 WARN("NULL nsdoc\n");
1010 return E_UNEXPECTED;
1013 if (!psarray)
1014 return S_OK;
1016 if(psarray->cDims != 1) {
1017 FIXME("cDims=%d\n", psarray->cDims);
1018 return E_INVALIDARG;
1021 hres = SafeArrayAccessData(psarray, (void**)&var);
1022 if(FAILED(hres)) {
1023 WARN("SafeArrayAccessData failed: %08x\n", hres);
1024 return hres;
1027 V_VT(&tmp) = VT_EMPTY;
1029 jsctx = get_context_from_document(This->doc_node->nsdoc);
1030 argc = psarray->rgsabound[0].cElements;
1031 for(i=0; i < argc; i++) {
1032 if(V_VT(var+i) == VT_BSTR) {
1033 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1034 }else {
1035 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1036 if(FAILED(hres)) {
1037 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1038 break;
1040 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1043 if(!ln || i != argc-1)
1044 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1045 else
1046 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1047 nsAString_Finish(&nsstr);
1048 if(V_VT(var+i) != VT_BSTR)
1049 VariantClear(&tmp);
1050 if(NS_FAILED(nsres)) {
1051 ERR("Write failed: %08x\n", nsres);
1052 hres = E_FAIL;
1053 break;
1057 SafeArrayUnaccessData(psarray);
1059 return hres;
1062 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1064 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1066 TRACE("(%p)->(%p)\n", iface, psarray);
1068 return document_write(This, psarray, FALSE);
1071 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1073 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1075 TRACE("(%p)->(%p)\n", This, psarray);
1077 return document_write(This, psarray, TRUE);
1080 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1081 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1083 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1084 nsISupports *tmp;
1085 nsresult nsres;
1087 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
1089 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1090 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1092 if(!This->doc_node->nsdoc) {
1093 ERR("!nsdoc\n");
1094 return E_NOTIMPL;
1097 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
1098 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1099 FIXME("unsupported args\n");
1101 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1102 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1103 if(NS_FAILED(nsres)) {
1104 ERR("Open failed: %08x\n", nsres);
1105 return E_FAIL;
1108 if(tmp)
1109 nsISupports_Release(tmp);
1111 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1112 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1113 return S_OK;
1116 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1118 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1119 nsresult nsres;
1121 TRACE("(%p)\n", This);
1123 if(!This->doc_node->nsdoc) {
1124 ERR("!nsdoc\n");
1125 return E_NOTIMPL;
1128 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1129 if(NS_FAILED(nsres)) {
1130 ERR("Close failed: %08x\n", nsres);
1131 return E_FAIL;
1134 return S_OK;
1137 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1139 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1140 nsresult nsres;
1142 TRACE("(%p)\n", This);
1144 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1145 if(NS_FAILED(nsres)) {
1146 ERR("Clear failed: %08x\n", nsres);
1147 return E_FAIL;
1150 return S_OK;
1153 static const WCHAR copyW[] =
1154 {'c','o','p','y',0};
1155 static const WCHAR cutW[] =
1156 {'c','u','t',0};
1157 static const WCHAR fontnameW[] =
1158 {'f','o','n','t','n','a','m','e',0};
1159 static const WCHAR fontsizeW[] =
1160 {'f','o','n','t','s','i','z','e',0};
1161 static const WCHAR indentW[] =
1162 {'i','n','d','e','n','t',0};
1163 static const WCHAR insertorderedlistW[] =
1164 {'i','n','s','e','r','t','o','r','d','e','r','e','d','l','i','s','t',0};
1165 static const WCHAR insertunorderedlistW[] =
1166 {'i','n','s','e','r','t','u','n','o','r','d','e','r','e','d','l','i','s','t',0};
1167 static const WCHAR outdentW[] =
1168 {'o','u','t','d','e','n','t',0};
1169 static const WCHAR pasteW[] =
1170 {'p','a','s','t','e',0};
1171 static const WCHAR respectvisibilityindesignW[] =
1172 {'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};
1174 static const struct {
1175 const WCHAR *name;
1176 OLECMDID id;
1177 }command_names[] = {
1178 {copyW, IDM_COPY},
1179 {cutW, IDM_CUT},
1180 {fontnameW, IDM_FONTNAME},
1181 {fontsizeW, IDM_FONTSIZE},
1182 {indentW, IDM_INDENT},
1183 {insertorderedlistW, IDM_ORDERLIST},
1184 {insertunorderedlistW, IDM_UNORDERLIST},
1185 {outdentW, IDM_OUTDENT},
1186 {pasteW, IDM_PASTE},
1187 {respectvisibilityindesignW, IDM_RESPECTVISIBILITY_INDESIGN}
1190 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1192 int i;
1194 for(i = 0; i < sizeof(command_names)/sizeof(*command_names); i++) {
1195 if(!strcmpiW(command_names[i].name, str)) {
1196 *cmdid = command_names[i].id;
1197 return TRUE;
1201 FIXME("Unknown command %s\n", debugstr_w(str));
1202 return FALSE;
1205 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1206 VARIANT_BOOL *pfRet)
1208 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1209 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1210 return E_NOTIMPL;
1213 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1214 VARIANT_BOOL *pfRet)
1216 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1217 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1218 return E_NOTIMPL;
1221 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1222 VARIANT_BOOL *pfRet)
1224 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1225 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1226 return E_NOTIMPL;
1229 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1230 VARIANT_BOOL *pfRet)
1232 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1233 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1234 return E_NOTIMPL;
1237 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1238 BSTR *pfRet)
1240 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1241 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1242 return E_NOTIMPL;
1245 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1246 VARIANT *pfRet)
1248 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1249 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1250 return E_NOTIMPL;
1253 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1254 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1256 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1257 OLECMDID cmdid;
1258 VARIANT ret;
1259 HRESULT hres;
1261 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1263 if(!cmdid_from_string(cmdID, &cmdid))
1264 return OLECMDERR_E_NOTSUPPORTED;
1266 V_VT(&ret) = VT_EMPTY;
1267 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1268 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1269 if(FAILED(hres))
1270 return hres;
1272 if(V_VT(&ret) != VT_EMPTY) {
1273 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1274 VariantClear(&ret);
1277 *pfRet = VARIANT_TRUE;
1278 return S_OK;
1281 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1282 VARIANT_BOOL *pfRet)
1284 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1285 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1286 return E_NOTIMPL;
1289 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1290 IHTMLElement **newElem)
1292 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1293 HTMLElement *elem;
1294 HRESULT hres;
1296 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1298 hres = create_element(This->doc_node, eTag, &elem);
1299 if(FAILED(hres))
1300 return hres;
1302 *newElem = &elem->IHTMLElement_iface;
1303 return S_OK;
1306 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1308 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1309 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1310 return E_NOTIMPL;
1313 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1315 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1316 FIXME("(%p)->(%p)\n", This, p);
1317 return E_NOTIMPL;
1320 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1322 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1324 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1326 return set_doc_event(This, EVENTID_CLICK, &v);
1329 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1331 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1333 TRACE("(%p)->(%p)\n", This, p);
1335 return get_doc_event(This, EVENTID_CLICK, p);
1338 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1340 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1342 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1344 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1347 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1349 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1351 TRACE("(%p)->(%p)\n", This, p);
1353 return get_doc_event(This, EVENTID_DBLCLICK, p);
1356 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1358 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1360 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1362 return set_doc_event(This, EVENTID_KEYUP, &v);
1365 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1367 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1369 TRACE("(%p)->(%p)\n", This, p);
1371 return get_doc_event(This, EVENTID_KEYUP, p);
1374 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1376 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1378 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1380 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1383 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1385 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1387 TRACE("(%p)->(%p)\n", This, p);
1389 return get_doc_event(This, EVENTID_KEYDOWN, p);
1392 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1394 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1396 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1398 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1401 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1403 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1405 TRACE("(%p)->(%p)\n", This, p);
1407 return get_doc_event(This, EVENTID_KEYPRESS, p);
1410 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1412 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1414 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1416 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1419 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1421 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1423 TRACE("(%p)->(%p)\n", This, p);
1425 return get_doc_event(This, EVENTID_MOUSEUP, p);
1428 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1430 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1432 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1434 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1437 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1439 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1441 TRACE("(%p)->(%p)\n", This, p);
1443 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1446 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1448 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1450 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1452 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1455 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1457 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1459 TRACE("(%p)->(%p)\n", This, p);
1461 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1464 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1466 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1468 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1470 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1473 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1475 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1477 TRACE("(%p)->(%p)\n", This, p);
1479 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1482 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1484 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1486 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1488 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1491 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1493 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1495 TRACE("(%p)->(%p)\n", This, p);
1497 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1500 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1502 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1504 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1506 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1509 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1511 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1513 TRACE("(%p)->(%p)\n", This, p);
1515 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1518 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1520 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1521 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1522 return E_NOTIMPL;
1525 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1527 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1528 FIXME("(%p)->(%p)\n", This, p);
1529 return E_NOTIMPL;
1532 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1534 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1535 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1536 return E_NOTIMPL;
1539 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1541 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1542 FIXME("(%p)->(%p)\n", This, p);
1543 return E_NOTIMPL;
1546 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1548 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1549 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1550 return E_NOTIMPL;
1553 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1555 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1556 FIXME("(%p)->(%p)\n", This, p);
1557 return E_NOTIMPL;
1560 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1562 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1564 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1566 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1569 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1571 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1573 TRACE("(%p)->(%p)\n", This, p);
1575 return get_doc_event(This, EVENTID_DRAGSTART, p);
1578 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1580 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1582 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1584 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1587 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1589 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1591 TRACE("(%p)->(%p)\n", This, p);
1593 return get_doc_event(This, EVENTID_SELECTSTART, p);
1596 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1597 IHTMLElement **elementHit)
1599 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1600 nsIDOMElement *nselem;
1601 HTMLElement *element;
1602 nsresult nsres;
1603 HRESULT hres;
1605 TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1607 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1608 if(NS_FAILED(nsres)) {
1609 ERR("ElementFromPoint failed: %08x\n", nsres);
1610 return E_FAIL;
1613 if(!nselem) {
1614 *elementHit = NULL;
1615 return S_OK;
1618 hres = get_element(nselem, &element);
1619 nsIDOMElement_Release(nselem);
1620 if(FAILED(hres))
1621 return hres;
1623 *elementHit = &element->IHTMLElement_iface;
1624 return S_OK;
1627 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1629 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1631 TRACE("(%p)->(%p)\n", This, p);
1633 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
1636 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1637 IHTMLStyleSheetsCollection **p)
1639 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1640 nsIDOMStyleSheetList *nsstylelist;
1641 nsresult nsres;
1643 TRACE("(%p)->(%p)\n", This, p);
1645 *p = NULL;
1647 if(!This->doc_node->nsdoc) {
1648 WARN("NULL nsdoc\n");
1649 return E_UNEXPECTED;
1652 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1653 if(NS_FAILED(nsres)) {
1654 ERR("GetStyleSheets failed: %08x\n", nsres);
1655 return E_FAIL;
1658 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1659 nsIDOMStyleSheetList_Release(nsstylelist);
1661 return S_OK;
1664 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1666 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1667 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1668 return E_NOTIMPL;
1671 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1673 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1674 FIXME("(%p)->(%p)\n", This, p);
1675 return E_NOTIMPL;
1678 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1680 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1681 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1682 return E_NOTIMPL;
1685 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1687 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1688 FIXME("(%p)->(%p)\n", This, p);
1689 return E_NOTIMPL;
1692 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1694 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1696 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1698 TRACE("(%p)->(%p)\n", This, String);
1700 if(!String)
1701 return E_INVALIDARG;
1703 *String = SysAllocString(objectW);
1704 return *String ? S_OK : E_OUTOFMEMORY;
1708 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1709 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1711 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1712 nsIDOMHTMLHeadElement *head_elem;
1713 IHTMLStyleElement *style_elem;
1714 HTMLElement *elem;
1715 nsresult nsres;
1716 HRESULT hres;
1718 static const WCHAR styleW[] = {'s','t','y','l','e',0};
1720 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1722 if(!This->doc_node->nsdoc) {
1723 FIXME("not a real doc object\n");
1724 return E_NOTIMPL;
1727 if(lIndex != -1)
1728 FIXME("Unsupported lIndex %d\n", lIndex);
1730 if(bstrHref && *bstrHref) {
1731 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
1732 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1733 return S_OK;
1736 hres = create_element(This->doc_node, styleW, &elem);
1737 if(FAILED(hres))
1738 return hres;
1740 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
1741 if(NS_SUCCEEDED(nsres)) {
1742 nsIDOMNode *head_node, *tmp_node;
1744 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
1745 nsIDOMHTMLHeadElement_Release(head_elem);
1746 assert(nsres == NS_OK);
1748 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
1749 nsIDOMNode_Release(head_node);
1750 if(NS_SUCCEEDED(nsres) && tmp_node)
1751 nsIDOMNode_Release(tmp_node);
1753 if(NS_FAILED(nsres)) {
1754 IHTMLElement_Release(&elem->IHTMLElement_iface);
1755 return E_FAIL;
1758 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
1759 assert(hres == S_OK);
1760 IHTMLElement_Release(&elem->IHTMLElement_iface);
1762 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
1763 IHTMLStyleElement_Release(style_elem);
1764 return hres;
1767 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1768 HTMLDocument_QueryInterface,
1769 HTMLDocument_AddRef,
1770 HTMLDocument_Release,
1771 HTMLDocument_GetTypeInfoCount,
1772 HTMLDocument_GetTypeInfo,
1773 HTMLDocument_GetIDsOfNames,
1774 HTMLDocument_Invoke,
1775 HTMLDocument_get_Script,
1776 HTMLDocument_get_all,
1777 HTMLDocument_get_body,
1778 HTMLDocument_get_activeElement,
1779 HTMLDocument_get_images,
1780 HTMLDocument_get_applets,
1781 HTMLDocument_get_links,
1782 HTMLDocument_get_forms,
1783 HTMLDocument_get_anchors,
1784 HTMLDocument_put_title,
1785 HTMLDocument_get_title,
1786 HTMLDocument_get_scripts,
1787 HTMLDocument_put_designMode,
1788 HTMLDocument_get_designMode,
1789 HTMLDocument_get_selection,
1790 HTMLDocument_get_readyState,
1791 HTMLDocument_get_frames,
1792 HTMLDocument_get_embeds,
1793 HTMLDocument_get_plugins,
1794 HTMLDocument_put_alinkColor,
1795 HTMLDocument_get_alinkColor,
1796 HTMLDocument_put_bgColor,
1797 HTMLDocument_get_bgColor,
1798 HTMLDocument_put_fgColor,
1799 HTMLDocument_get_fgColor,
1800 HTMLDocument_put_linkColor,
1801 HTMLDocument_get_linkColor,
1802 HTMLDocument_put_vlinkColor,
1803 HTMLDocument_get_vlinkColor,
1804 HTMLDocument_get_referrer,
1805 HTMLDocument_get_location,
1806 HTMLDocument_get_lastModified,
1807 HTMLDocument_put_URL,
1808 HTMLDocument_get_URL,
1809 HTMLDocument_put_domain,
1810 HTMLDocument_get_domain,
1811 HTMLDocument_put_cookie,
1812 HTMLDocument_get_cookie,
1813 HTMLDocument_put_expando,
1814 HTMLDocument_get_expando,
1815 HTMLDocument_put_charset,
1816 HTMLDocument_get_charset,
1817 HTMLDocument_put_defaultCharset,
1818 HTMLDocument_get_defaultCharset,
1819 HTMLDocument_get_mimeType,
1820 HTMLDocument_get_fileSize,
1821 HTMLDocument_get_fileCreatedDate,
1822 HTMLDocument_get_fileModifiedDate,
1823 HTMLDocument_get_fileUpdatedDate,
1824 HTMLDocument_get_security,
1825 HTMLDocument_get_protocol,
1826 HTMLDocument_get_nameProp,
1827 HTMLDocument_write,
1828 HTMLDocument_writeln,
1829 HTMLDocument_open,
1830 HTMLDocument_close,
1831 HTMLDocument_clear,
1832 HTMLDocument_queryCommandSupported,
1833 HTMLDocument_queryCommandEnabled,
1834 HTMLDocument_queryCommandState,
1835 HTMLDocument_queryCommandIndeterm,
1836 HTMLDocument_queryCommandText,
1837 HTMLDocument_queryCommandValue,
1838 HTMLDocument_execCommand,
1839 HTMLDocument_execCommandShowHelp,
1840 HTMLDocument_createElement,
1841 HTMLDocument_put_onhelp,
1842 HTMLDocument_get_onhelp,
1843 HTMLDocument_put_onclick,
1844 HTMLDocument_get_onclick,
1845 HTMLDocument_put_ondblclick,
1846 HTMLDocument_get_ondblclick,
1847 HTMLDocument_put_onkeyup,
1848 HTMLDocument_get_onkeyup,
1849 HTMLDocument_put_onkeydown,
1850 HTMLDocument_get_onkeydown,
1851 HTMLDocument_put_onkeypress,
1852 HTMLDocument_get_onkeypress,
1853 HTMLDocument_put_onmouseup,
1854 HTMLDocument_get_onmouseup,
1855 HTMLDocument_put_onmousedown,
1856 HTMLDocument_get_onmousedown,
1857 HTMLDocument_put_onmousemove,
1858 HTMLDocument_get_onmousemove,
1859 HTMLDocument_put_onmouseout,
1860 HTMLDocument_get_onmouseout,
1861 HTMLDocument_put_onmouseover,
1862 HTMLDocument_get_onmouseover,
1863 HTMLDocument_put_onreadystatechange,
1864 HTMLDocument_get_onreadystatechange,
1865 HTMLDocument_put_onafterupdate,
1866 HTMLDocument_get_onafterupdate,
1867 HTMLDocument_put_onrowexit,
1868 HTMLDocument_get_onrowexit,
1869 HTMLDocument_put_onrowenter,
1870 HTMLDocument_get_onrowenter,
1871 HTMLDocument_put_ondragstart,
1872 HTMLDocument_get_ondragstart,
1873 HTMLDocument_put_onselectstart,
1874 HTMLDocument_get_onselectstart,
1875 HTMLDocument_elementFromPoint,
1876 HTMLDocument_get_parentWindow,
1877 HTMLDocument_get_styleSheets,
1878 HTMLDocument_put_onbeforeupdate,
1879 HTMLDocument_get_onbeforeupdate,
1880 HTMLDocument_put_onerrorupdate,
1881 HTMLDocument_get_onerrorupdate,
1882 HTMLDocument_toString,
1883 HTMLDocument_createStyleSheet
1886 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
1888 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
1891 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
1892 REFIID riid, void **ppv)
1894 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1895 return htmldoc_query_interface(This, riid, ppv);
1898 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
1900 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1901 return htmldoc_addref(This);
1904 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
1906 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1907 return htmldoc_release(This);
1910 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
1912 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1913 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1916 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
1917 LCID lcid, ITypeInfo **ppTInfo)
1919 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1920 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1923 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
1924 LPOLESTR *rgszNames, UINT cNames,
1925 LCID lcid, DISPID *rgDispId)
1927 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1928 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1929 rgDispId);
1932 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
1933 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1934 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1936 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1937 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1938 pDispParams, pVarResult, pExcepInfo, puArgErr);
1941 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
1943 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1944 FIXME("(%p)\n", This);
1945 return E_NOTIMPL;
1948 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
1950 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1952 WARN("(%p)->(%x)\n", This, fForce);
1954 /* Doing nothing here should be fine for us. */
1955 return S_OK;
1958 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
1959 IHTMLDOMNode **newTextNode)
1961 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1962 nsIDOMText *nstext;
1963 HTMLDOMNode *node;
1964 nsAString text_str;
1965 nsresult nsres;
1966 HRESULT hres;
1968 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
1970 if(!This->doc_node->nsdoc) {
1971 WARN("NULL nsdoc\n");
1972 return E_UNEXPECTED;
1975 nsAString_InitDepend(&text_str, text);
1976 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
1977 nsAString_Finish(&text_str);
1978 if(NS_FAILED(nsres)) {
1979 ERR("CreateTextNode failed: %08x\n", nsres);
1980 return E_FAIL;
1983 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
1984 nsIDOMText_Release(nstext);
1985 if(FAILED(hres))
1986 return hres;
1988 *newTextNode = &node->IHTMLDOMNode_iface;
1989 return S_OK;
1992 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
1994 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1995 nsIDOMElement *nselem = NULL;
1996 HTMLElement *element;
1997 nsresult nsres;
1998 HRESULT hres;
2000 TRACE("(%p)->(%p)\n", This, p);
2002 if(This->window->readystate == READYSTATE_UNINITIALIZED) {
2003 *p = NULL;
2004 return S_OK;
2007 if(!This->doc_node->nsdoc) {
2008 WARN("NULL nsdoc\n");
2009 return E_UNEXPECTED;
2012 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
2013 if(NS_FAILED(nsres)) {
2014 ERR("GetDocumentElement failed: %08x\n", nsres);
2015 return E_FAIL;
2018 if(!nselem) {
2019 *p = NULL;
2020 return S_OK;
2023 hres = get_element(nselem, &element);
2024 nsIDOMElement_Release(nselem);
2025 if(FAILED(hres))
2026 return hres;
2028 *p = &element->IHTMLElement_iface;
2029 return hres;
2032 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2034 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2036 TRACE("(%p)->(%p)\n", This, p);
2038 return elem_unique_id(++This->doc_node->unique_id, p);
2041 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2042 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2044 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2046 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2048 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2051 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2052 IDispatch *pDisp)
2054 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2056 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2058 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2061 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2063 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2064 FIXME("(%p)->()\n", This);
2065 return E_NOTIMPL;
2068 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2070 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2071 FIXME("(%p)->(%p)\n", This, p);
2072 return E_NOTIMPL;
2075 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2077 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2078 FIXME("(%p)->()\n", This);
2079 return E_NOTIMPL;
2082 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2084 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2085 FIXME("(%p)->(%p)\n", This, p);
2086 return E_NOTIMPL;
2089 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2091 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2092 FIXME("(%p)->()\n", This);
2093 return E_NOTIMPL;
2096 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2098 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2099 FIXME("(%p)->(%p)\n", This, p);
2100 return E_NOTIMPL;
2103 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2105 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2106 FIXME("(%p)->()\n", This);
2107 return E_NOTIMPL;
2110 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2112 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2113 FIXME("(%p)->(%p)\n", This, p);
2114 return E_NOTIMPL;
2117 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2119 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2120 FIXME("(%p)->()\n", This);
2121 return E_NOTIMPL;
2124 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2126 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2127 FIXME("(%p)->(%p)\n", This, p);
2128 return E_NOTIMPL;
2131 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2133 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2134 FIXME("(%p)->()\n", This);
2135 return E_NOTIMPL;
2138 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2140 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2141 FIXME("(%p)->(%p)\n", This, p);
2142 return E_NOTIMPL;
2145 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2147 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2148 FIXME("(%p)->()\n", This);
2149 return E_NOTIMPL;
2152 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2154 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2155 FIXME("(%p)->(%p)\n", This, p);
2156 return E_NOTIMPL;
2159 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2161 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2162 nsAString dir_str;
2163 nsresult nsres;
2165 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2167 if(!This->doc_node->nsdoc) {
2168 FIXME("NULL nsdoc\n");
2169 return E_UNEXPECTED;
2172 nsAString_InitDepend(&dir_str, v);
2173 nsres = nsIDOMHTMLDocument_SetDir(This->doc_node->nsdoc, &dir_str);
2174 nsAString_Finish(&dir_str);
2175 if(NS_FAILED(nsres)) {
2176 ERR("SetDir failed: %08x\n", nsres);
2177 return E_FAIL;
2180 return S_OK;
2183 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2185 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2186 nsAString dir_str;
2187 nsresult nsres;
2189 TRACE("(%p)->(%p)\n", This, p);
2191 if(!This->doc_node->nsdoc) {
2192 FIXME("NULL nsdoc\n");
2193 return E_UNEXPECTED;
2196 nsAString_Init(&dir_str, NULL);
2197 nsres = nsIDOMHTMLDocument_GetDir(This->doc_node->nsdoc, &dir_str);
2198 return return_nsstr(nsres, &dir_str, p);
2201 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2203 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2205 TRACE("(%p)->()\n", This);
2207 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2210 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2212 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2214 TRACE("(%p)->(%p)\n", This, p);
2216 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2219 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2221 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2222 FIXME("(%p)->()\n", This);
2223 return E_NOTIMPL;
2226 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2228 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2229 FIXME("(%p)->(%p)\n", This, p);
2230 return E_NOTIMPL;
2233 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2234 IHTMLDocument2 **ppNewDoc)
2236 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2237 nsIDOMDocumentFragment *doc_frag;
2238 HTMLDocumentNode *docnode;
2239 nsresult nsres;
2240 HRESULT hres;
2242 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2244 if(!This->doc_node->nsdoc) {
2245 FIXME("NULL nsdoc\n");
2246 return E_NOTIMPL;
2249 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2250 if(NS_FAILED(nsres)) {
2251 ERR("CreateDocumentFragment failed: %08x\n", nsres);
2252 return E_FAIL;
2255 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2256 nsIDOMDocumentFragment_Release(doc_frag);
2257 if(FAILED(hres))
2258 return hres;
2260 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2261 return S_OK;
2264 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2265 IHTMLDocument2 **p)
2267 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2268 FIXME("(%p)->(%p)\n", This, p);
2269 return E_NOTIMPL;
2272 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2273 VARIANT_BOOL v)
2275 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2276 FIXME("(%p)->(%x)\n", This, v);
2277 return E_NOTIMPL;
2280 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2281 VARIANT_BOOL *p)
2283 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2284 FIXME("(%p)->(%p)\n", This, p);
2285 return E_NOTIMPL;
2288 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2290 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2291 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2292 return E_NOTIMPL;
2295 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2297 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2298 FIXME("(%p)->(%p)\n", This, p);
2299 return E_NOTIMPL;
2302 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2304 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2306 TRACE("(%p)->(%p)\n", This, p);
2308 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2311 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2312 VARIANT_BOOL v)
2314 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2315 FIXME("(%p)->()\n", This);
2316 return E_NOTIMPL;
2319 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2320 VARIANT_BOOL *p)
2322 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2323 FIXME("(%p)->(%p)\n", This, p);
2324 return E_NOTIMPL;
2327 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2329 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2330 FIXME("(%p)->()\n", This);
2331 return E_NOTIMPL;
2334 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2336 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2337 FIXME("(%p)->(%p)\n", This, p);
2338 return E_NOTIMPL;
2341 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2342 IHTMLElementCollection **ppelColl)
2344 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2345 nsIDOMNodeList *node_list;
2346 nsAString selector_str;
2347 WCHAR *selector;
2348 nsresult nsres;
2350 static const WCHAR formatW[] = {'*','[','i','d','=','%','s',']',',','*','[','n','a','m','e','=','%','s',']',0};
2352 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2354 if(!This->doc_node || !This->doc_node->nsdoc) {
2355 /* We should probably return an empty collection. */
2356 FIXME("No nsdoc\n");
2357 return E_NOTIMPL;
2360 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2361 if(!selector)
2362 return E_OUTOFMEMORY;
2363 sprintfW(selector, formatW, v, v);
2366 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2367 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2368 * types and search should be case insensitive. Those are currently not supported properly.
2370 nsAString_InitDepend(&selector_str, selector);
2371 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2372 nsAString_Finish(&selector_str);
2373 heap_free(selector);
2374 if(NS_FAILED(nsres)) {
2375 ERR("QuerySelectorAll failed: %08x\n", nsres);
2376 return E_FAIL;
2379 *ppelColl = create_collection_from_nodelist(node_list, This->doc_node->document_mode);
2380 nsIDOMNodeList_Release(node_list);
2381 return S_OK;
2385 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2386 IHTMLElement **pel)
2388 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2389 HTMLElement *elem;
2390 HRESULT hres;
2392 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2394 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2395 if(FAILED(hres) || !elem) {
2396 *pel = NULL;
2397 return hres;
2400 *pel = &elem->IHTMLElement_iface;
2401 return S_OK;
2405 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2406 IHTMLElementCollection **pelColl)
2408 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2409 nsIDOMNodeList *nslist;
2410 nsAString id_str;
2411 nsresult nsres;
2413 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2415 if(This->doc_node->nsdoc) {
2416 nsAString_InitDepend(&id_str, v);
2417 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2418 nsAString_Finish(&id_str);
2419 if(FAILED(nsres)) {
2420 ERR("GetElementByName failed: %08x\n", nsres);
2421 return E_FAIL;
2423 }else {
2424 nsIDOMDocumentFragment *docfrag;
2425 nsAString nsstr;
2427 if(v) {
2428 const WCHAR *ptr;
2429 for(ptr=v; *ptr; ptr++) {
2430 if(!isalnumW(*ptr)) {
2431 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2432 return E_NOTIMPL;
2437 nsres = nsIDOMNode_QueryInterface(This->doc_node->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2438 if(NS_FAILED(nsres)) {
2439 ERR("Could not get nsIDOMDocumentFragment iface: %08x\n", nsres);
2440 return E_UNEXPECTED;
2443 nsAString_InitDepend(&nsstr, v);
2444 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2445 nsAString_Finish(&nsstr);
2446 nsIDOMDocumentFragment_Release(docfrag);
2447 if(NS_FAILED(nsres)) {
2448 ERR("QuerySelectorAll failed: %08x\n", nsres);
2449 return E_FAIL;
2454 *pelColl = create_collection_from_nodelist(nslist, This->doc_node->document_mode);
2455 nsIDOMNodeList_Release(nslist);
2457 return S_OK;
2460 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2461 HTMLDocument3_QueryInterface,
2462 HTMLDocument3_AddRef,
2463 HTMLDocument3_Release,
2464 HTMLDocument3_GetTypeInfoCount,
2465 HTMLDocument3_GetTypeInfo,
2466 HTMLDocument3_GetIDsOfNames,
2467 HTMLDocument3_Invoke,
2468 HTMLDocument3_releaseCapture,
2469 HTMLDocument3_recalc,
2470 HTMLDocument3_createTextNode,
2471 HTMLDocument3_get_documentElement,
2472 HTMLDocument3_get_uniqueID,
2473 HTMLDocument3_attachEvent,
2474 HTMLDocument3_detachEvent,
2475 HTMLDocument3_put_onrowsdelete,
2476 HTMLDocument3_get_onrowsdelete,
2477 HTMLDocument3_put_onrowsinserted,
2478 HTMLDocument3_get_onrowsinserted,
2479 HTMLDocument3_put_oncellchange,
2480 HTMLDocument3_get_oncellchange,
2481 HTMLDocument3_put_ondatasetchanged,
2482 HTMLDocument3_get_ondatasetchanged,
2483 HTMLDocument3_put_ondataavailable,
2484 HTMLDocument3_get_ondataavailable,
2485 HTMLDocument3_put_ondatasetcomplete,
2486 HTMLDocument3_get_ondatasetcomplete,
2487 HTMLDocument3_put_onpropertychange,
2488 HTMLDocument3_get_onpropertychange,
2489 HTMLDocument3_put_dir,
2490 HTMLDocument3_get_dir,
2491 HTMLDocument3_put_oncontextmenu,
2492 HTMLDocument3_get_oncontextmenu,
2493 HTMLDocument3_put_onstop,
2494 HTMLDocument3_get_onstop,
2495 HTMLDocument3_createDocumentFragment,
2496 HTMLDocument3_get_parentDocument,
2497 HTMLDocument3_put_enableDownload,
2498 HTMLDocument3_get_enableDownload,
2499 HTMLDocument3_put_baseUrl,
2500 HTMLDocument3_get_baseUrl,
2501 HTMLDocument3_get_childNodes,
2502 HTMLDocument3_put_inheritStyleSheets,
2503 HTMLDocument3_get_inheritStyleSheets,
2504 HTMLDocument3_put_onbeforeeditfocus,
2505 HTMLDocument3_get_onbeforeeditfocus,
2506 HTMLDocument3_getElementsByName,
2507 HTMLDocument3_getElementById,
2508 HTMLDocument3_getElementsByTagName
2511 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2513 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2516 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2517 REFIID riid, void **ppv)
2519 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2520 return htmldoc_query_interface(This, riid, ppv);
2523 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2525 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2526 return htmldoc_addref(This);
2529 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2531 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2532 return htmldoc_release(This);
2535 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2537 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2538 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2541 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2542 LCID lcid, ITypeInfo **ppTInfo)
2544 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2545 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2548 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2549 LPOLESTR *rgszNames, UINT cNames,
2550 LCID lcid, DISPID *rgDispId)
2552 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2553 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2554 rgDispId);
2557 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2558 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2559 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2561 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2562 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2563 pDispParams, pVarResult, pExcepInfo, puArgErr);
2566 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2568 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2569 nsIDOMHTMLElement *nsbody;
2570 nsresult nsres;
2572 TRACE("(%p)->()\n", This);
2574 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2575 if(NS_FAILED(nsres) || !nsbody) {
2576 ERR("GetBody failed: %08x\n", nsres);
2577 return E_FAIL;
2580 nsres = nsIDOMHTMLElement_Focus(nsbody);
2581 nsIDOMHTMLElement_Release(nsbody);
2582 if(NS_FAILED(nsres)) {
2583 ERR("Focus failed: %08x\n", nsres);
2584 return E_FAIL;
2587 return S_OK;
2590 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2592 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2593 cpp_bool has_focus;
2594 nsresult nsres;
2596 TRACE("(%p)->(%p)\n", This, pfFocus);
2598 if(!This->doc_node->nsdoc) {
2599 FIXME("Unimplemented for fragments.\n");
2600 return E_NOTIMPL;
2603 nsres = nsIDOMHTMLDocument_HasFocus(This->doc_node->nsdoc, &has_focus);
2604 assert(nsres == NS_OK);
2606 *pfFocus = variant_bool(has_focus);
2607 return S_OK;
2610 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2612 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2614 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2616 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2619 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2621 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2623 TRACE("(%p)->(%p)\n", This, p);
2625 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2628 static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
2630 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2631 FIXME("(%p)->(%p)\n", This, p);
2632 return E_NOTIMPL;
2635 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2636 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2638 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2639 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2640 return E_NOTIMPL;
2643 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2645 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2646 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2647 return E_NOTIMPL;
2650 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2652 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2653 FIXME("(%p)->(%p)\n", This, p);
2654 return E_NOTIMPL;
2657 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2658 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2660 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2662 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2664 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2665 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2666 return E_NOTIMPL;
2669 return create_event_obj(ppEventObj);
2672 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2673 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2675 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2677 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2679 return fire_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2682 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2683 IHTMLRenderStyle **ppIHTMLRenderStyle)
2685 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2686 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2687 return E_NOTIMPL;
2690 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2692 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2693 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2694 return E_NOTIMPL;
2697 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2699 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2700 FIXME("(%p)->(%p)\n", This, p);
2701 return E_NOTIMPL;
2704 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2706 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2707 FIXME("(%p)->(%p)\n", This, p);
2708 return E_NOTIMPL;
2711 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2712 HTMLDocument4_QueryInterface,
2713 HTMLDocument4_AddRef,
2714 HTMLDocument4_Release,
2715 HTMLDocument4_GetTypeInfoCount,
2716 HTMLDocument4_GetTypeInfo,
2717 HTMLDocument4_GetIDsOfNames,
2718 HTMLDocument4_Invoke,
2719 HTMLDocument4_focus,
2720 HTMLDocument4_hasFocus,
2721 HTMLDocument4_put_onselectionchange,
2722 HTMLDocument4_get_onselectionchange,
2723 HTMLDocument4_get_namespace,
2724 HTMLDocument4_createDocumentFromUrl,
2725 HTMLDocument4_put_media,
2726 HTMLDocument4_get_media,
2727 HTMLDocument4_createEventObject,
2728 HTMLDocument4_fireEvent,
2729 HTMLDocument4_createRenderStyle,
2730 HTMLDocument4_put_oncontrolselect,
2731 HTMLDocument4_get_oncontrolselect,
2732 HTMLDocument4_get_URLEncoded
2735 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2737 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2740 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2741 REFIID riid, void **ppv)
2743 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2744 return htmldoc_query_interface(This, riid, ppv);
2747 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2749 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2750 return htmldoc_addref(This);
2753 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2755 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2756 return htmldoc_release(This);
2759 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2761 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2762 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2765 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2766 LCID lcid, ITypeInfo **ppTInfo)
2768 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2769 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2772 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2773 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2775 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2776 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2777 rgDispId);
2780 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2781 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2782 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2784 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2785 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2786 pDispParams, pVarResult, pExcepInfo, puArgErr);
2789 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2791 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2793 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2795 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
2798 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2800 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2802 TRACE("(%p)->(%p)\n", This, p);
2804 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
2807 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2809 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2810 FIXME("(%p)->(%p)\n", This, p);
2811 return E_NOTIMPL;
2814 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2816 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2817 HTMLDocumentNode *doc_node = This->doc_node;
2819 TRACE("(%p)->(%p)\n", This, p);
2821 if(!doc_node->dom_implementation) {
2822 HRESULT hres;
2824 hres = create_dom_implementation(&doc_node->dom_implementation);
2825 if(FAILED(hres))
2826 return hres;
2829 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2830 *p = doc_node->dom_implementation;
2831 return S_OK;
2834 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2835 IHTMLDOMAttribute **ppattribute)
2837 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2838 HTMLDOMAttribute *attr;
2839 HRESULT hres;
2841 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2843 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
2844 if(FAILED(hres))
2845 return hres;
2847 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2848 return S_OK;
2851 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2852 IHTMLDOMNode **ppRetNode)
2854 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2855 nsIDOMComment *nscomment;
2856 HTMLElement *elem;
2857 nsAString str;
2858 nsresult nsres;
2859 HRESULT hres;
2861 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2863 if(!This->doc_node->nsdoc) {
2864 WARN("NULL nsdoc\n");
2865 return E_UNEXPECTED;
2868 nsAString_InitDepend(&str, bstrdata);
2869 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2870 nsAString_Finish(&str);
2871 if(NS_FAILED(nsres)) {
2872 ERR("CreateTextNode failed: %08x\n", nsres);
2873 return E_FAIL;
2876 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2877 nsIDOMComment_Release(nscomment);
2878 if(FAILED(hres))
2879 return hres;
2881 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2882 return S_OK;
2885 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2887 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2889 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2891 return set_doc_event(This, EVENTID_FOCUSIN, &v);
2894 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2896 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2898 TRACE("(%p)->(%p)\n", This, p);
2900 return get_doc_event(This, EVENTID_FOCUSIN, p);
2903 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2905 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2907 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2909 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
2912 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2914 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2916 TRACE("(%p)->(%p)\n", This, p);
2918 return get_doc_event(This, EVENTID_FOCUSOUT, p);
2921 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2923 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2924 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2925 return E_NOTIMPL;
2928 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2930 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2931 FIXME("(%p)->(%p)\n", This, p);
2932 return E_NOTIMPL;
2935 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2937 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2938 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2939 return E_NOTIMPL;
2942 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2944 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2945 FIXME("(%p)->(%p)\n", This, p);
2946 return E_NOTIMPL;
2949 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2951 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2952 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2953 return E_NOTIMPL;
2956 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2958 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2959 FIXME("(%p)->(%p)\n", This, p);
2960 return E_NOTIMPL;
2963 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2965 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2966 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2967 return E_NOTIMPL;
2970 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2972 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2973 FIXME("(%p)->(%p)\n", This, p);
2974 return E_NOTIMPL;
2977 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2979 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2981 static const WCHAR BackCompatW[] = {'B','a','c','k','C','o','m','p','a','t',0};
2982 static const WCHAR CSS1CompatW[] = {'C','S','S','1','C','o','m','p','a','t',0};
2984 TRACE("(%p)->(%p)\n", This, p);
2986 *p = SysAllocString(This->doc_node->document_mode <= COMPAT_MODE_IE5 ? BackCompatW : CSS1CompatW);
2987 return *p ? S_OK : E_OUTOFMEMORY;
2990 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
2991 HTMLDocument5_QueryInterface,
2992 HTMLDocument5_AddRef,
2993 HTMLDocument5_Release,
2994 HTMLDocument5_GetTypeInfoCount,
2995 HTMLDocument5_GetTypeInfo,
2996 HTMLDocument5_GetIDsOfNames,
2997 HTMLDocument5_Invoke,
2998 HTMLDocument5_put_onmousewheel,
2999 HTMLDocument5_get_onmousewheel,
3000 HTMLDocument5_get_doctype,
3001 HTMLDocument5_get_implementation,
3002 HTMLDocument5_createAttribute,
3003 HTMLDocument5_createComment,
3004 HTMLDocument5_put_onfocusin,
3005 HTMLDocument5_get_onfocusin,
3006 HTMLDocument5_put_onfocusout,
3007 HTMLDocument5_get_onfocusout,
3008 HTMLDocument5_put_onactivate,
3009 HTMLDocument5_get_onactivate,
3010 HTMLDocument5_put_ondeactivate,
3011 HTMLDocument5_get_ondeactivate,
3012 HTMLDocument5_put_onbeforeactivate,
3013 HTMLDocument5_get_onbeforeactivate,
3014 HTMLDocument5_put_onbeforedeactivate,
3015 HTMLDocument5_get_onbeforedeactivate,
3016 HTMLDocument5_get_compatMode
3019 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3021 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
3024 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
3025 REFIID riid, void **ppv)
3027 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3028 return htmldoc_query_interface(This, riid, ppv);
3031 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3033 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3034 return htmldoc_addref(This);
3037 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3039 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3040 return htmldoc_release(This);
3043 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3045 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3046 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3049 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
3050 LCID lcid, ITypeInfo **ppTInfo)
3052 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3053 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3056 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
3057 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3059 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3060 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3061 rgDispId);
3064 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
3065 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3066 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3068 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3069 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3070 pDispParams, pVarResult, pExcepInfo, puArgErr);
3073 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3074 IHTMLDocumentCompatibleInfoCollection **p)
3076 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3077 FIXME("(%p)->(%p)\n", This, p);
3078 return E_NOTIMPL;
3081 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3083 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3085 TRACE("(%p)->(%p)\n", This, p);
3087 if(!This->doc_node) {
3088 FIXME("NULL doc_node\n");
3089 return E_UNEXPECTED;
3092 V_VT(p) = VT_R4;
3093 V_R4(p) = compat_mode_info[This->doc_node->document_mode].document_mode;
3094 return S_OK;
3097 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3098 VARIANT *p)
3100 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3101 FIXME("(%p)->(%p)\n", This, p);
3102 return E_NOTIMPL;
3105 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3107 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3108 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3109 return E_NOTIMPL;
3112 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3113 VARIANT *p)
3115 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3116 FIXME("(%p)->(%p)\n", This, p);
3117 return E_NOTIMPL;
3120 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3122 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3123 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3124 return E_NOTIMPL;
3127 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3128 BSTR bstrId, IHTMLElement2 **p)
3130 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3131 nsIDOMElement *nselem;
3132 HTMLElement *elem;
3133 nsAString nsstr;
3134 nsresult nsres;
3135 HRESULT hres;
3137 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3140 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3141 * not search for name attributes, so we may simply let Gecko do the right thing.
3144 if(!This->doc_node->nsdoc) {
3145 FIXME("Not a document\n");
3146 return E_FAIL;
3149 nsAString_InitDepend(&nsstr, bstrId);
3150 nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &nsstr, &nselem);
3151 nsAString_Finish(&nsstr);
3152 if(NS_FAILED(nsres)) {
3153 ERR("GetElementById failed: %08x\n", nsres);
3154 return E_FAIL;
3157 if(!nselem) {
3158 *p = NULL;
3159 return S_OK;
3162 hres = get_element(nselem, &elem);
3163 nsIDOMElement_Release(nselem);
3164 if(FAILED(hres))
3165 return hres;
3167 *p = &elem->IHTMLElement2_iface;
3168 return S_OK;
3171 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3173 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3174 FIXME("(%p)->()\n", This);
3175 return E_NOTIMPL;
3178 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3179 HTMLDocument6_QueryInterface,
3180 HTMLDocument6_AddRef,
3181 HTMLDocument6_Release,
3182 HTMLDocument6_GetTypeInfoCount,
3183 HTMLDocument6_GetTypeInfo,
3184 HTMLDocument6_GetIDsOfNames,
3185 HTMLDocument6_Invoke,
3186 HTMLDocument6_get_compatible,
3187 HTMLDocument6_get_documentMode,
3188 HTMLDocument6_put_onstorage,
3189 HTMLDocument6_get_onstorage,
3190 HTMLDocument6_put_onstoragecommit,
3191 HTMLDocument6_get_onstoragecommit,
3192 HTMLDocument6_getElementById,
3193 HTMLDocument6_updateSettings
3196 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3198 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3201 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3203 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3204 return htmldoc_query_interface(This, riid, ppv);
3207 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3209 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3210 return htmldoc_addref(This);
3213 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3215 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3216 return htmldoc_release(This);
3219 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3221 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3222 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3225 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3226 LCID lcid, ITypeInfo **ppTInfo)
3228 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3229 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3232 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3233 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3235 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3236 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3237 rgDispId);
3240 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3241 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3242 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3244 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3245 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3246 pDispParams, pVarResult, pExcepInfo, puArgErr);
3249 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3251 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3253 TRACE("(%p)->(%p)\n", This, p);
3255 *p = &This->window->base.IHTMLWindow2_iface;
3256 IHTMLWindow2_AddRef(*p);
3257 return S_OK;
3260 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3262 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3263 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3264 return E_NOTIMPL;
3267 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3269 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3270 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3271 return E_NOTIMPL;
3274 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3275 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3277 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3278 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3279 return E_NOTIMPL;
3282 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3284 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3285 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3286 return E_NOTIMPL;
3289 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3290 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3292 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3293 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3294 return E_NOTIMPL;
3297 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3299 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3300 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3301 return E_NOTIMPL;
3304 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3306 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3307 FIXME("(%p)->(%p)\n", This, p);
3308 return E_NOTIMPL;
3311 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3313 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3314 nsAString charset_str;
3315 nsresult nsres;
3317 TRACE("(%p)->(%p)\n", This, p);
3319 if(!This->doc_node->nsdoc) {
3320 FIXME("NULL nsdoc\n");
3321 return E_FAIL;
3324 nsAString_Init(&charset_str, NULL);
3325 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
3326 return return_nsstr(nsres, &charset_str, p);
3329 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3331 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3333 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3335 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3338 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3340 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3342 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3344 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3347 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3349 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3350 nsIDOMNodeList *nslist;
3351 nsAString nsstr;
3352 nsresult nsres;
3354 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3356 if(!This->doc_node->nsdoc) {
3357 FIXME("NULL nsdoc not supported\n");
3358 return E_NOTIMPL;
3361 nsAString_InitDepend(&nsstr, v);
3362 nsres = nsIDOMHTMLDocument_GetElementsByClassName(This->doc_node->nsdoc, &nsstr, &nslist);
3363 nsAString_Finish(&nsstr);
3364 if(FAILED(nsres)) {
3365 ERR("GetElementByClassName failed: %08x\n", nsres);
3366 return E_FAIL;
3370 *pel = create_collection_from_nodelist(nslist, This->doc_node->document_mode);
3371 nsIDOMNodeList_Release(nslist);
3372 return S_OK;
3375 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3376 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3378 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3379 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3380 return E_NOTIMPL;
3383 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3385 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3386 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3387 return E_NOTIMPL;
3390 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3392 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3393 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3394 return E_NOTIMPL;
3397 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3399 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3400 FIXME("(%p)->(%p)\n", This, p);
3401 return E_NOTIMPL;
3404 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3406 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3408 TRACE("(%p)->(%p)\n", This, p);
3410 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3413 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3415 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3416 FIXME("(%p)->(%p)\n", This, p);
3417 return E_NOTIMPL;
3420 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3422 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3423 FIXME("(%p)->(%p)\n", This, p);
3424 return E_NOTIMPL;
3427 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3429 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3430 FIXME("(%p)->(%x)\n", This, v);
3431 return E_NOTIMPL;
3434 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3436 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3437 FIXME("(%p)->(%p)\n", This, p);
3438 return E_NOTIMPL;
3441 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3443 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3444 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3445 return E_NOTIMPL;
3448 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3450 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3451 FIXME("(%p)->(%p)\n", This, p);
3452 return E_NOTIMPL;
3455 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3457 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3458 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3459 return E_NOTIMPL;
3462 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3464 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3466 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3468 return set_doc_event(This, EVENTID_ABORT, &v);
3471 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3473 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3475 TRACE("(%p)->(%p)\n", This, p);
3477 return get_doc_event(This, EVENTID_ABORT, p);
3480 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3482 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3484 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3486 return set_doc_event(This, EVENTID_BLUR, &v);
3489 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3491 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3493 TRACE("(%p)->(%p)\n", This, p);
3495 return get_doc_event(This, EVENTID_BLUR, p);
3498 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3500 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3501 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3502 return E_NOTIMPL;
3505 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3507 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3508 FIXME("(%p)->(%p)\n", This, p);
3509 return E_NOTIMPL;
3512 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3514 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3515 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3516 return E_NOTIMPL;
3519 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3521 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3522 FIXME("(%p)->(%p)\n", This, p);
3523 return E_NOTIMPL;
3526 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3528 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3530 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3532 return set_doc_event(This, EVENTID_CHANGE, &v);
3535 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3537 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3539 TRACE("(%p)->(%p)\n", This, p);
3541 return get_doc_event(This, EVENTID_CHANGE, p);
3544 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3546 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3548 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3550 return set_doc_event(This, EVENTID_DRAG, &v);
3553 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3555 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3557 TRACE("(%p)->(%p)\n", This, p);
3559 return get_doc_event(This, EVENTID_DRAG, p);
3562 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3564 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3565 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3566 return E_NOTIMPL;
3569 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3571 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3572 FIXME("(%p)->(%p)\n", This, p);
3573 return E_NOTIMPL;
3576 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3578 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3579 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3580 return E_NOTIMPL;
3583 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3585 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3586 FIXME("(%p)->(%p)\n", This, p);
3587 return E_NOTIMPL;
3590 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3592 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3593 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3594 return E_NOTIMPL;
3597 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3599 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3600 FIXME("(%p)->(%p)\n", This, p);
3601 return E_NOTIMPL;
3604 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3606 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3607 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3608 return E_NOTIMPL;
3611 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3613 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3614 FIXME("(%p)->(%p)\n", This, p);
3615 return E_NOTIMPL;
3618 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3620 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3621 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3622 return E_NOTIMPL;
3625 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3627 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3628 FIXME("(%p)->(%p)\n", This, p);
3629 return E_NOTIMPL;
3632 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3634 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3635 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3636 return E_NOTIMPL;
3639 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
3641 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3642 FIXME("(%p)->(%p)\n", This, p);
3643 return E_NOTIMPL;
3646 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
3648 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3649 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3650 return E_NOTIMPL;
3653 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
3655 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3656 FIXME("(%p)->(%p)\n", This, p);
3657 return E_NOTIMPL;
3660 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
3662 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3663 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3664 return E_NOTIMPL;
3667 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
3669 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3670 FIXME("(%p)->(%p)\n", This, p);
3671 return E_NOTIMPL;
3674 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
3676 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3678 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3680 return set_doc_event(This, EVENTID_ERROR, &v);
3683 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
3685 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3687 TRACE("(%p)->(%p)\n", This, p);
3689 return get_doc_event(This, EVENTID_ERROR, p);
3692 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
3694 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3696 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3698 return set_doc_event(This, EVENTID_FOCUS, &v);
3701 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
3703 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3705 TRACE("(%p)->(%p)\n", This, p);
3707 return get_doc_event(This, EVENTID_FOCUS, p);
3710 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
3712 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3713 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3714 return E_NOTIMPL;
3717 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
3719 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3720 FIXME("(%p)->(%p)\n", This, p);
3721 return E_NOTIMPL;
3724 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
3726 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3728 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3730 return set_doc_event(This, EVENTID_LOAD, &v);
3733 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
3735 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3737 TRACE("(%p)->(%p)\n", This, p);
3739 return get_doc_event(This, EVENTID_LOAD, p);
3742 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
3744 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3745 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3746 return E_NOTIMPL;
3749 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
3751 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3752 FIXME("(%p)->(%p)\n", This, p);
3753 return E_NOTIMPL;
3756 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
3758 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3759 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3760 return E_NOTIMPL;
3763 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
3765 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3766 FIXME("(%p)->(%p)\n", This, p);
3767 return E_NOTIMPL;
3770 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
3772 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3773 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3774 return E_NOTIMPL;
3777 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
3779 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3780 FIXME("(%p)->(%p)\n", This, p);
3781 return E_NOTIMPL;
3784 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
3786 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3787 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3788 return E_NOTIMPL;
3791 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
3793 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3794 FIXME("(%p)->(%p)\n", This, p);
3795 return E_NOTIMPL;
3798 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
3800 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3801 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3802 return E_NOTIMPL;
3805 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
3807 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3808 FIXME("(%p)->(%p)\n", This, p);
3809 return E_NOTIMPL;
3812 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
3814 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3815 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3816 return E_NOTIMPL;
3819 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
3821 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3822 FIXME("(%p)->(%p)\n", This, p);
3823 return E_NOTIMPL;
3826 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
3828 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3829 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3830 return E_NOTIMPL;
3833 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
3835 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3836 FIXME("(%p)->(%p)\n", This, p);
3837 return E_NOTIMPL;
3840 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
3842 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3843 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3844 return E_NOTIMPL;
3847 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
3849 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3850 FIXME("(%p)->(%p)\n", This, p);
3851 return E_NOTIMPL;
3854 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
3856 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3857 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3858 return E_NOTIMPL;
3861 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
3863 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3864 FIXME("(%p)->(%p)\n", This, p);
3865 return E_NOTIMPL;
3868 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
3870 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3872 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3874 return set_doc_event(This, EVENTID_SCROLL, &v);
3877 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
3879 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3881 TRACE("(%p)->(%p)\n", This, p);
3883 return get_doc_event(This, EVENTID_SCROLL, p);
3886 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
3888 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3889 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3890 return E_NOTIMPL;
3893 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
3895 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3896 FIXME("(%p)->(%p)\n", This, p);
3897 return E_NOTIMPL;
3900 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
3902 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3903 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3904 return E_NOTIMPL;
3907 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
3909 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3910 FIXME("(%p)->(%p)\n", This, p);
3911 return E_NOTIMPL;
3914 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
3916 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3917 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3918 return E_NOTIMPL;
3921 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
3923 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3924 FIXME("(%p)->(%p)\n", This, p);
3925 return E_NOTIMPL;
3928 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
3930 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3931 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3932 return E_NOTIMPL;
3935 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
3937 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3938 FIXME("(%p)->(%p)\n", This, p);
3939 return E_NOTIMPL;
3942 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
3944 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3946 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3948 return set_doc_event(This, EVENTID_SUBMIT, &v);
3951 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
3953 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3955 TRACE("(%p)->(%p)\n", This, p);
3957 return get_doc_event(This, EVENTID_SUBMIT, p);
3960 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
3962 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3963 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3964 return E_NOTIMPL;
3967 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
3969 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3970 FIXME("(%p)->(%p)\n", This, p);
3971 return E_NOTIMPL;
3974 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
3976 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3977 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3978 return E_NOTIMPL;
3981 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
3983 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3984 FIXME("(%p)->(%p)\n", This, p);
3985 return E_NOTIMPL;
3988 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
3990 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3991 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3992 return E_NOTIMPL;
3995 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
3997 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3998 FIXME("(%p)->(%p)\n", This, p);
3999 return E_NOTIMPL;
4002 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4004 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4005 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4006 return E_NOTIMPL;
4009 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4011 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4012 FIXME("(%p)->(%p)\n", This, p);
4013 return E_NOTIMPL;
4016 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4018 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4019 FIXME("(%p)\n", This);
4020 return E_NOTIMPL;
4023 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4024 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4026 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4027 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4028 return E_NOTIMPL;
4031 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4033 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4035 TRACE("(%p)->(%p)\n", This, p);
4037 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4040 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4042 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4043 FIXME("(%p)->(%p)\n", This, v);
4044 return E_NOTIMPL;
4047 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4049 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4051 TRACE("(%p)->(%p)\n", This, p);
4053 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4056 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4058 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4059 nsIDOMHTMLHeadElement *nshead;
4060 nsIDOMElement *nselem;
4061 HTMLElement *elem;
4062 nsresult nsres;
4063 HRESULT hres;
4065 TRACE("(%p)->(%p)\n", This, p);
4067 if(!This->doc_node->nsdoc) {
4068 FIXME("No document\n");
4069 return E_FAIL;
4072 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &nshead);
4073 assert(nsres == NS_OK);
4075 if(!nshead) {
4076 *p = NULL;
4077 return S_OK;
4080 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4081 nsIDOMHTMLHeadElement_Release(nshead);
4082 assert(nsres == NS_OK);
4084 hres = get_element(nselem, &elem);
4085 nsIDOMElement_Release(nselem);
4086 if(FAILED(hres))
4087 return hres;
4089 *p = &elem->IHTMLElement_iface;
4090 return S_OK;
4093 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4094 HTMLDocument7_QueryInterface,
4095 HTMLDocument7_AddRef,
4096 HTMLDocument7_Release,
4097 HTMLDocument7_GetTypeInfoCount,
4098 HTMLDocument7_GetTypeInfo,
4099 HTMLDocument7_GetIDsOfNames,
4100 HTMLDocument7_Invoke,
4101 HTMLDocument7_get_defaultView,
4102 HTMLDocument7_createCDATASection,
4103 HTMLDocument7_getSelection,
4104 HTMLDocument7_getElementsByTagNameNS,
4105 HTMLDocument7_createElementNS,
4106 HTMLDocument7_createAttributeNS,
4107 HTMLDocument7_put_onmsthumbnailclick,
4108 HTMLDocument7_get_onmsthumbnailclick,
4109 HTMLDocument7_get_characterSet,
4110 HTMLDocument7_createElement,
4111 HTMLDocument7_createAttribute,
4112 HTMLDocument7_getElementsByClassName,
4113 HTMLDocument7_createProcessingInstruction,
4114 HTMLDocument7_adoptNode,
4115 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4116 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4117 HTMLDocument7_get_all,
4118 HTMLDocument7_get_inputEncoding,
4119 HTMLDocument7_get_xmlEncoding,
4120 HTMLDocument7_put_xmlStandalone,
4121 HTMLDocument7_get_xmlStandalone,
4122 HTMLDocument7_put_xmlVersion,
4123 HTMLDocument7_get_xmlVersion,
4124 HTMLDocument7_hasAttributes,
4125 HTMLDocument7_put_onabort,
4126 HTMLDocument7_get_onabort,
4127 HTMLDocument7_put_onblur,
4128 HTMLDocument7_get_onblur,
4129 HTMLDocument7_put_oncanplay,
4130 HTMLDocument7_get_oncanplay,
4131 HTMLDocument7_put_oncanplaythrough,
4132 HTMLDocument7_get_oncanplaythrough,
4133 HTMLDocument7_put_onchange,
4134 HTMLDocument7_get_onchange,
4135 HTMLDocument7_put_ondrag,
4136 HTMLDocument7_get_ondrag,
4137 HTMLDocument7_put_ondragend,
4138 HTMLDocument7_get_ondragend,
4139 HTMLDocument7_put_ondragenter,
4140 HTMLDocument7_get_ondragenter,
4141 HTMLDocument7_put_ondragleave,
4142 HTMLDocument7_get_ondragleave,
4143 HTMLDocument7_put_ondragover,
4144 HTMLDocument7_get_ondragover,
4145 HTMLDocument7_put_ondrop,
4146 HTMLDocument7_get_ondrop,
4147 HTMLDocument7_put_ondurationchange,
4148 HTMLDocument7_get_ondurationchange,
4149 HTMLDocument7_put_onemptied,
4150 HTMLDocument7_get_onemptied,
4151 HTMLDocument7_put_onended,
4152 HTMLDocument7_get_onended,
4153 HTMLDocument7_put_onerror,
4154 HTMLDocument7_get_onerror,
4155 HTMLDocument7_put_onfocus,
4156 HTMLDocument7_get_onfocus,
4157 HTMLDocument7_put_oninput,
4158 HTMLDocument7_get_oninput,
4159 HTMLDocument7_put_onload,
4160 HTMLDocument7_get_onload,
4161 HTMLDocument7_put_onloadeddata,
4162 HTMLDocument7_get_onloadeddata,
4163 HTMLDocument7_put_onloadedmetadata,
4164 HTMLDocument7_get_onloadedmetadata,
4165 HTMLDocument7_put_onloadstart,
4166 HTMLDocument7_get_onloadstart,
4167 HTMLDocument7_put_onpause,
4168 HTMLDocument7_get_onpause,
4169 HTMLDocument7_put_onplay,
4170 HTMLDocument7_get_onplay,
4171 HTMLDocument7_put_onplaying,
4172 HTMLDocument7_get_onplaying,
4173 HTMLDocument7_put_onprogress,
4174 HTMLDocument7_get_onprogress,
4175 HTMLDocument7_put_onratechange,
4176 HTMLDocument7_get_onratechange,
4177 HTMLDocument7_put_onreset,
4178 HTMLDocument7_get_onreset,
4179 HTMLDocument7_put_onscroll,
4180 HTMLDocument7_get_onscroll,
4181 HTMLDocument7_put_onseekend,
4182 HTMLDocument7_get_onseekend,
4183 HTMLDocument7_put_onseeking,
4184 HTMLDocument7_get_onseeking,
4185 HTMLDocument7_put_onselect,
4186 HTMLDocument7_get_onselect,
4187 HTMLDocument7_put_onstalled,
4188 HTMLDocument7_get_onstalled,
4189 HTMLDocument7_put_onsubmit,
4190 HTMLDocument7_get_onsubmit,
4191 HTMLDocument7_put_onsuspend,
4192 HTMLDocument7_get_onsuspend,
4193 HTMLDocument7_put_ontimeupdate,
4194 HTMLDocument7_get_ontimeupdate,
4195 HTMLDocument7_put_onvolumechange,
4196 HTMLDocument7_get_onvolumechange,
4197 HTMLDocument7_put_onwaiting,
4198 HTMLDocument7_get_onwaiting,
4199 HTMLDocument7_normalize,
4200 HTMLDocument7_importNode,
4201 HTMLDocument7_get_parentWindow,
4202 HTMLDocument7_put_body,
4203 HTMLDocument7_get_body,
4204 HTMLDocument7_get_head
4207 static inline HTMLDocument *impl_from_IDocumentSelector(IDocumentSelector *iface)
4209 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentSelector_iface);
4212 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4214 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4215 return htmldoc_query_interface(This, riid, ppv);
4218 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4220 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4221 return htmldoc_addref(This);
4224 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4226 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4227 return htmldoc_release(This);
4230 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4232 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4233 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4236 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4237 LCID lcid, ITypeInfo **ppTInfo)
4239 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4240 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4243 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4244 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4246 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4247 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4248 rgDispId);
4251 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4252 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4254 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4255 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4256 pDispParams, pVarResult, pExcepInfo, puArgErr);
4259 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4261 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4262 nsIDOMElement *nselem;
4263 HTMLElement *elem;
4264 nsAString nsstr;
4265 nsresult nsres;
4266 HRESULT hres;
4268 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4270 nsAString_InitDepend(&nsstr, v);
4271 nsres = nsIDOMHTMLDocument_QuerySelector(This->doc_node->nsdoc, &nsstr, &nselem);
4272 nsAString_Finish(&nsstr);
4273 if(NS_FAILED(nsres)) {
4274 ERR("QuerySelector failed: %08x\n", nsres);
4275 return E_FAIL;
4278 if(!nselem) {
4279 *pel = NULL;
4280 return S_OK;
4283 hres = get_element(nselem, &elem);
4284 nsIDOMElement_Release(nselem);
4285 if(FAILED(hres))
4286 return hres;
4288 *pel = &elem->IHTMLElement_iface;
4289 return S_OK;
4292 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4294 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4295 nsIDOMNodeList *node_list;
4296 nsAString nsstr;
4297 nsresult nsres;
4299 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4301 nsAString_InitDepend(&nsstr, v);
4302 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &nsstr, &node_list);
4303 nsAString_Finish(&nsstr);
4304 if(NS_FAILED(nsres)) {
4305 ERR("QuerySelectorAll failed: %08x\n", nsres);
4306 return E_FAIL;
4309 *pel = create_child_collection(node_list);
4310 nsIDOMNodeList_Release(node_list);
4311 return *pel ? S_OK : E_OUTOFMEMORY;
4314 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4315 DocumentSelector_QueryInterface,
4316 DocumentSelector_AddRef,
4317 DocumentSelector_Release,
4318 DocumentSelector_GetTypeInfoCount,
4319 DocumentSelector_GetTypeInfo,
4320 DocumentSelector_GetIDsOfNames,
4321 DocumentSelector_Invoke,
4322 DocumentSelector_querySelector,
4323 DocumentSelector_querySelectorAll
4326 static inline HTMLDocument *impl_from_IDocumentEvent(IDocumentEvent *iface)
4328 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentEvent_iface);
4331 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4333 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4334 return htmldoc_query_interface(This, riid, ppv);
4337 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4339 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4340 return htmldoc_addref(This);
4343 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4345 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4346 return htmldoc_release(This);
4349 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4351 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4352 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4355 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4356 LCID lcid, ITypeInfo **ppTInfo)
4358 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4359 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4362 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4363 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4365 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4366 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4367 rgDispId);
4370 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4371 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4373 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4374 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4375 pDispParams, pVarResult, pExcepInfo, puArgErr);
4378 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4380 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4382 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4384 return create_document_event_str(This->doc_node, eventType, p);
4387 static const IDocumentEventVtbl DocumentEventVtbl = {
4388 DocumentEvent_QueryInterface,
4389 DocumentEvent_AddRef,
4390 DocumentEvent_Release,
4391 DocumentEvent_GetTypeInfoCount,
4392 DocumentEvent_GetTypeInfo,
4393 DocumentEvent_GetIDsOfNames,
4394 DocumentEvent_Invoke,
4395 DocumentEvent_createEvent
4398 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4400 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4402 if(This->window)
4403 update_doc_cp_events(This->doc_node, cp);
4406 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4408 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4411 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4413 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4414 return htmldoc_query_interface(This, riid, ppv);
4417 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4419 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4420 return htmldoc_addref(This);
4423 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4425 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4426 return htmldoc_release(This);
4429 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4431 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4432 return S_FALSE;
4435 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4436 SupportErrorInfo_QueryInterface,
4437 SupportErrorInfo_AddRef,
4438 SupportErrorInfo_Release,
4439 SupportErrorInfo_InterfaceSupportsErrorInfo
4442 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4444 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4447 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4449 nsIDOMNodeList *node_list;
4450 nsAString name_str;
4451 UINT32 len;
4452 unsigned i;
4453 nsresult nsres;
4455 if(!This->nsdoc)
4456 return DISP_E_UNKNOWNNAME;
4458 nsAString_InitDepend(&name_str, name);
4459 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4460 nsAString_Finish(&name_str);
4461 if(NS_FAILED(nsres))
4462 return E_FAIL;
4464 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4465 nsIDOMNodeList_Release(node_list);
4466 if(NS_FAILED(nsres))
4467 return E_FAIL;
4469 if(!len)
4470 return DISP_E_UNKNOWNNAME;
4472 for(i=0; i < This->elem_vars_cnt; i++) {
4473 if(!strcmpW(name, This->elem_vars[i])) {
4474 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4475 return S_OK;
4479 if(This->elem_vars_cnt == This->elem_vars_size) {
4480 WCHAR **new_vars;
4482 if(This->elem_vars_size) {
4483 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4484 if(!new_vars)
4485 return E_OUTOFMEMORY;
4486 This->elem_vars_size *= 2;
4487 }else {
4488 new_vars = heap_alloc(16*sizeof(WCHAR*));
4489 if(!new_vars)
4490 return E_OUTOFMEMORY;
4491 This->elem_vars_size = 16;
4494 This->elem_vars = new_vars;
4497 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4498 if(!This->elem_vars[This->elem_vars_cnt])
4499 return E_OUTOFMEMORY;
4501 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4502 return S_OK;
4505 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4507 HTMLDocument *This = impl_from_IDispatchEx(iface);
4509 return htmldoc_query_interface(This, riid, ppv);
4512 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4514 HTMLDocument *This = impl_from_IDispatchEx(iface);
4516 return htmldoc_addref(This);
4519 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4521 HTMLDocument *This = impl_from_IDispatchEx(iface);
4523 return htmldoc_release(This);
4526 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4528 HTMLDocument *This = impl_from_IDispatchEx(iface);
4530 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4533 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4534 LCID lcid, ITypeInfo **ppTInfo)
4536 HTMLDocument *This = impl_from_IDispatchEx(iface);
4538 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4541 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4542 LPOLESTR *rgszNames, UINT cNames,
4543 LCID lcid, DISPID *rgDispId)
4545 HTMLDocument *This = impl_from_IDispatchEx(iface);
4547 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4550 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4551 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4552 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4554 HTMLDocument *This = impl_from_IDispatchEx(iface);
4556 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4557 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4559 switch(dispIdMember) {
4560 case DISPID_READYSTATE:
4561 TRACE("DISPID_READYSTATE\n");
4563 if(!(wFlags & DISPATCH_PROPERTYGET))
4564 return E_INVALIDARG;
4566 V_VT(pVarResult) = VT_I4;
4567 V_I4(pVarResult) = This->window->readystate;
4568 return S_OK;
4571 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
4572 pVarResult, pExcepInfo, puArgErr);
4575 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4577 HTMLDocument *This = impl_from_IDispatchEx(iface);
4578 HRESULT hres;
4580 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4581 if(hres != DISP_E_UNKNOWNNAME)
4582 return hres;
4584 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4587 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4588 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4590 HTMLDocument *This = impl_from_IDispatchEx(iface);
4592 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
4593 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
4594 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4597 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4600 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4602 HTMLDocument *This = impl_from_IDispatchEx(iface);
4604 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4607 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4609 HTMLDocument *This = impl_from_IDispatchEx(iface);
4611 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4614 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4616 HTMLDocument *This = impl_from_IDispatchEx(iface);
4618 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4621 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4623 HTMLDocument *This = impl_from_IDispatchEx(iface);
4625 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4628 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4630 HTMLDocument *This = impl_from_IDispatchEx(iface);
4632 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
4635 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
4637 HTMLDocument *This = impl_from_IDispatchEx(iface);
4639 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
4642 static const IDispatchExVtbl DocDispatchExVtbl = {
4643 DocDispatchEx_QueryInterface,
4644 DocDispatchEx_AddRef,
4645 DocDispatchEx_Release,
4646 DocDispatchEx_GetTypeInfoCount,
4647 DocDispatchEx_GetTypeInfo,
4648 DocDispatchEx_GetIDsOfNames,
4649 DocDispatchEx_Invoke,
4650 DocDispatchEx_GetDispID,
4651 DocDispatchEx_InvokeEx,
4652 DocDispatchEx_DeleteMemberByName,
4653 DocDispatchEx_DeleteMemberByDispID,
4654 DocDispatchEx_GetMemberProperties,
4655 DocDispatchEx_GetMemberName,
4656 DocDispatchEx_GetNextDispID,
4657 DocDispatchEx_GetNameSpaceParent
4660 static inline HTMLDocument *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
4662 return CONTAINING_RECORD(iface, HTMLDocument, IProvideMultipleClassInfo_iface);
4665 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
4666 REFIID riid, void **ppv)
4668 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4669 return htmldoc_query_interface(This, riid, ppv);
4672 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
4674 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4675 return htmldoc_addref(This);
4678 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
4680 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4681 return htmldoc_release(This);
4684 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
4686 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4687 TRACE("(%p)->(%p)\n", This, ppTI);
4688 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
4691 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
4693 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4694 FIXME("(%p)->(%u %p)\n", This, dwGuidKind, pGUID);
4695 return E_NOTIMPL;
4698 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
4700 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4701 FIXME("(%p)->(%p)\n", This, pcti);
4702 *pcti = 1;
4703 return S_OK;
4706 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
4707 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
4709 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4710 FIXME("(%p)->(%u %x %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
4711 return E_NOTIMPL;
4714 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
4715 ProvideClassInfo_QueryInterface,
4716 ProvideClassInfo_AddRef,
4717 ProvideClassInfo_Release,
4718 ProvideClassInfo_GetClassInfo,
4719 ProvideClassInfo2_GetGUID,
4720 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
4721 ProvideMultipleClassInfo_GetInfoOfIndex
4724 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
4726 *ppv = NULL;
4728 if(IsEqualGUID(&IID_IUnknown, riid))
4729 *ppv = &This->IHTMLDocument2_iface;
4730 else if(IsEqualGUID(&IID_IDispatch, riid))
4731 *ppv = &This->IDispatchEx_iface;
4732 else if(IsEqualGUID(&IID_IDispatchEx, riid))
4733 *ppv = &This->IDispatchEx_iface;
4734 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
4735 *ppv = &This->IHTMLDocument2_iface;
4736 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
4737 *ppv = &This->IHTMLDocument2_iface;
4738 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
4739 *ppv = &This->IHTMLDocument3_iface;
4740 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
4741 *ppv = &This->IHTMLDocument4_iface;
4742 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
4743 *ppv = &This->IHTMLDocument5_iface;
4744 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
4745 *ppv = &This->IHTMLDocument6_iface;
4746 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
4747 *ppv = &This->IHTMLDocument7_iface;
4748 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
4749 *ppv = &This->IDocumentSelector_iface;
4750 else if(IsEqualGUID(&IID_IDocumentEvent, riid))
4751 *ppv = &This->IDocumentEvent_iface;
4752 else if(IsEqualGUID(&IID_IPersist, riid))
4753 *ppv = &This->IPersistFile_iface;
4754 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
4755 *ppv = &This->IPersistMoniker_iface;
4756 else if(IsEqualGUID(&IID_IPersistFile, riid))
4757 *ppv = &This->IPersistFile_iface;
4758 else if(IsEqualGUID(&IID_IMonikerProp, riid))
4759 *ppv = &This->IMonikerProp_iface;
4760 else if(IsEqualGUID(&IID_IOleObject, riid))
4761 *ppv = &This->IOleObject_iface;
4762 else if(IsEqualGUID(&IID_IOleDocument, riid))
4763 *ppv = &This->IOleDocument_iface;
4764 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
4765 *ppv = &This->IOleInPlaceActiveObject_iface;
4766 else if(IsEqualGUID(&IID_IOleWindow, riid))
4767 *ppv = &This->IOleInPlaceActiveObject_iface;
4768 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
4769 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4770 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
4771 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4772 else if(IsEqualGUID(&IID_IServiceProvider, riid))
4773 *ppv = &This->IServiceProvider_iface;
4774 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
4775 *ppv = &This->IOleCommandTarget_iface;
4776 else if(IsEqualGUID(&IID_IOleControl, riid))
4777 *ppv = &This->IOleControl_iface;
4778 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
4779 *ppv = &This->IHlinkTarget_iface;
4780 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
4781 *ppv = &This->cp_container.IConnectionPointContainer_iface;
4782 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
4783 *ppv = &This->IPersistStreamInit_iface;
4784 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
4785 *ppv = &This->IHTMLDocument2_iface;
4786 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
4787 *ppv = &This->ISupportErrorInfo_iface;
4788 else if(IsEqualGUID(&IID_IPersistHistory, riid))
4789 *ppv = &This->IPersistHistory_iface;
4790 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
4791 *ppv = &This->IObjectWithSite_iface;
4792 else if(IsEqualGUID(&IID_IOleContainer, riid))
4793 *ppv = &This->IOleContainer_iface;
4794 else if(IsEqualGUID(&IID_IObjectSafety, riid))
4795 *ppv = &This->IObjectSafety_iface;
4796 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
4797 *ppv = &This->IProvideMultipleClassInfo_iface;
4798 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
4799 *ppv = &This->IProvideMultipleClassInfo_iface;
4800 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
4801 *ppv = &This->IProvideMultipleClassInfo_iface;
4802 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
4803 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
4804 *ppv = NULL;
4805 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
4806 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
4807 *ppv = NULL;
4808 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
4809 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
4810 *ppv = NULL;
4811 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
4812 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
4813 *ppv = NULL;
4814 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
4815 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
4816 *ppv = NULL;
4817 }else {
4818 return FALSE;
4821 if(*ppv)
4822 IUnknown_AddRef((IUnknown*)*ppv);
4823 return TRUE;
4826 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
4828 static const cpc_entry_t HTMLDocument_cpc[] = {
4829 {&IID_IDispatch, &HTMLDocumentEvents_data},
4830 {&IID_IPropertyNotifySink},
4831 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
4832 {&DIID_HTMLDocumentEvents2},
4833 {NULL}
4836 static void init_doc(HTMLDocument *doc, IUnknown *outer, IDispatchEx *dispex)
4838 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
4839 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
4840 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
4841 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
4842 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
4843 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
4844 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
4845 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
4846 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
4847 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
4848 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
4850 doc->outer_unk = outer;
4851 doc->dispex = dispex;
4853 HTMLDocument_Persist_Init(doc);
4854 HTMLDocument_OleCmd_Init(doc);
4855 HTMLDocument_OleObj_Init(doc);
4856 HTMLDocument_Service_Init(doc);
4858 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
4861 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
4863 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
4866 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
4868 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4870 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4872 if(htmldoc_qi(&This->basedoc, riid, ppv))
4873 return *ppv ? S_OK : E_NOINTERFACE;
4875 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
4876 *ppv = &This->IInternetHostSecurityManager_iface;
4877 else
4878 return HTMLDOMNode_QI(&This->node, riid, ppv);
4880 IUnknown_AddRef((IUnknown*)*ppv);
4881 return S_OK;
4884 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
4886 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4887 unsigned i;
4889 for(i=0; i < This->elem_vars_cnt; i++)
4890 heap_free(This->elem_vars[i]);
4891 heap_free(This->elem_vars);
4893 detach_events(This);
4894 if(This->catmgr)
4895 ICatInformation_Release(This->catmgr);
4897 detach_selection(This);
4898 detach_ranges(This);
4900 while(!list_empty(&This->plugin_hosts))
4901 detach_plugin_host(LIST_ENTRY(list_head(&This->plugin_hosts), PluginHost, entry));
4903 if(!This->nsdoc && This->window) {
4904 /* document fragments own reference to inner window */
4905 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
4906 This->window = NULL;
4909 heap_free(This->event_vector);
4910 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
4913 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4915 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4916 FIXME("%p\n", This);
4917 return E_NOTIMPL;
4920 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
4922 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4924 if(This->nsdoc)
4925 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
4928 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
4930 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4932 if(This->nsdoc) {
4933 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
4935 release_document_mutation(This);
4936 This->nsdoc = NULL;
4937 nsIDOMHTMLDocument_Release(nsdoc);
4938 This->window = NULL;
4942 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
4943 &CLSID_HTMLDocument,
4944 HTMLDocumentNode_QI,
4945 HTMLDocumentNode_destructor,
4946 HTMLDocument_cpc,
4947 HTMLDocumentNode_clone,
4948 NULL,
4949 NULL,
4950 NULL,
4951 NULL,
4952 NULL,
4953 NULL,
4954 NULL,
4955 NULL,
4956 NULL,
4957 NULL,
4958 HTMLDocumentNode_traverse,
4959 HTMLDocumentNode_unlink
4962 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4964 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4965 HTMLDocumentNode *new_node;
4966 HRESULT hres;
4968 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
4969 if(FAILED(hres))
4970 return hres;
4972 *ret = &new_node->node;
4973 return S_OK;
4976 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
4978 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
4981 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4982 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4984 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4985 nsIDOMNodeList *node_list;
4986 nsAString name_str;
4987 nsIDOMNode *nsnode;
4988 HTMLDOMNode *node;
4989 unsigned i;
4990 nsresult nsres;
4991 HRESULT hres;
4993 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
4994 FIXME("unsupported flags %x\n", flags);
4995 return E_NOTIMPL;
4998 i = id - MSHTML_DISPID_CUSTOM_MIN;
5000 if(!This->nsdoc || i >= This->elem_vars_cnt)
5001 return DISP_E_UNKNOWNNAME;
5003 nsAString_InitDepend(&name_str, This->elem_vars[i]);
5004 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
5005 nsAString_Finish(&name_str);
5006 if(NS_FAILED(nsres))
5007 return E_FAIL;
5009 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
5010 nsIDOMNodeList_Release(node_list);
5011 if(NS_FAILED(nsres) || !nsnode)
5012 return DISP_E_UNKNOWNNAME;
5014 hres = get_node(nsnode, TRUE, &node);
5015 if(FAILED(hres))
5016 return hres;
5018 V_VT(res) = VT_DISPATCH;
5019 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5020 return S_OK;
5023 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
5025 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5027 TRACE("(%p) returning %u\n", This, This->document_mode);
5029 return lock_document_mode(This);
5032 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
5034 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5035 return (nsISupports*)This->node.nsnode;
5038 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
5040 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5041 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
5044 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
5046 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5047 if(!This->window)
5048 return NULL;
5049 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
5050 return &This->window->event_target;
5053 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
5055 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5056 ConnectionPointContainer *container = This->basedoc.doc_obj
5057 ? &This->basedoc.doc_obj->basedoc.cp_container : &This->basedoc.cp_container;
5058 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
5059 return container;
5062 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
5064 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5065 return default_set_current_event(This->window, event);
5068 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
5070 NULL,
5071 NULL,
5072 HTMLDocumentNode_invoke,
5073 HTMLDocumentNode_get_compat_mode,
5074 NULL
5076 HTMLDocumentNode_get_gecko_target,
5077 HTMLDocumentNode_bind_event,
5078 HTMLDocumentNode_get_parent_event_target,
5079 NULL,
5080 HTMLDocumentNode_get_cp_container,
5081 HTMLDocumentNode_set_current_event
5084 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
5085 &CLSID_HTMLDocument,
5086 HTMLDocumentNode_QI,
5087 HTMLDocumentNode_destructor,
5088 HTMLDocument_cpc,
5089 HTMLDocumentFragment_clone
5092 static const tid_t HTMLDocumentNode_iface_tids[] = {
5093 IHTMLDOMNode_tid,
5094 IHTMLDOMNode2_tid,
5095 IHTMLDocument2_tid,
5096 IHTMLDocument4_tid,
5097 IHTMLDocument5_tid,
5098 IDocumentSelector_tid,
5102 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
5104 HTMLDOMNode_init_dispex_info(info, mode);
5106 if(mode >= COMPAT_MODE_IE9) {
5107 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
5108 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
5111 /* Depending on compatibility version, we add interfaces in different order
5112 * so that the right getElementById implementation is used. */
5113 if(mode < COMPAT_MODE_IE8) {
5114 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5115 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5116 }else {
5117 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5118 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5122 static dispex_static_data_t HTMLDocumentNode_dispex = {
5123 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
5124 DispHTMLDocument_tid,
5125 HTMLDocumentNode_iface_tids,
5126 HTMLDocumentNode_init_dispex_info
5129 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
5131 HTMLDocumentNode *doc;
5133 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
5134 if(!doc)
5135 return NULL;
5137 doc->ref = 1;
5138 doc->basedoc.doc_node = doc;
5139 doc->basedoc.doc_obj = doc_obj;
5140 doc->basedoc.window = window->base.outer_window;
5141 doc->window = window;
5143 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
5144 &doc->node.event_target.dispex.IDispatchEx_iface);
5145 HTMLDocumentNode_SecMgr_Init(doc);
5147 list_init(&doc->selection_list);
5148 list_init(&doc->range_list);
5149 list_init(&doc->plugin_hosts);
5151 return doc;
5154 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLInnerWindow *window, HTMLDocumentNode **ret)
5156 HTMLDocumentNode *doc;
5158 doc = alloc_doc_node(doc_obj, window);
5159 if(!doc)
5160 return E_OUTOFMEMORY;
5162 if(window->base.outer_window->parent) {
5163 compat_mode_t parent_mode = window->base.outer_window->parent->base.inner_window->doc->document_mode;
5164 TRACE("parent mode %u\n", parent_mode);
5165 if(parent_mode >= COMPAT_MODE_IE9) {
5166 doc->document_mode = parent_mode;
5167 lock_document_mode(doc);
5171 if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
5172 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
5174 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc, &HTMLDocumentNode_dispex);
5176 nsIDOMHTMLDocument_AddRef(nsdoc);
5177 doc->nsdoc = nsdoc;
5179 init_document_mutation(doc);
5180 doc_init_events(doc);
5182 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
5184 *ret = doc;
5185 return S_OK;
5188 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
5190 HTMLDocumentNode *doc_frag;
5192 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
5193 if(!doc_frag)
5194 return E_OUTOFMEMORY;
5196 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
5198 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
5199 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
5201 *ret = doc_frag;
5202 return S_OK;
5205 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
5207 HTMLDOMNode *node;
5208 HRESULT hres;
5210 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
5211 if(FAILED(hres))
5212 return hres;
5214 if(!node) {
5215 ERR("document not initialized\n");
5216 return E_FAIL;
5219 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
5220 *ret = impl_from_HTMLDOMNode(node);
5221 return S_OK;
5224 static inline HTMLDocumentObj *impl_from_IUnknown(IUnknown *iface)
5226 return CONTAINING_RECORD(iface, HTMLDocumentObj, IUnknown_outer);
5229 static HRESULT WINAPI HTMLDocumentObj_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
5231 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5233 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5235 if(IsEqualGUID(&IID_IUnknown, riid)) {
5236 *ppv = &This->IUnknown_outer;
5237 }else if(htmldoc_qi(&This->basedoc, riid, ppv)) {
5238 return *ppv ? S_OK : E_NOINTERFACE;
5239 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
5240 *ppv = &This->ICustomDoc_iface;
5241 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
5242 *ppv = &This->IOleDocumentView_iface;
5243 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
5244 *ppv = &This->IViewObjectEx_iface;
5245 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
5246 *ppv = &This->IViewObjectEx_iface;
5247 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
5248 *ppv = &This->IViewObjectEx_iface;
5249 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
5250 *ppv = &This->ITargetContainer_iface;
5251 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5252 return *ppv ? S_OK : E_NOINTERFACE;
5253 }else {
5254 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
5255 *ppv = NULL;
5256 return E_NOINTERFACE;
5259 IUnknown_AddRef((IUnknown*)*ppv);
5260 return S_OK;
5263 static ULONG WINAPI HTMLDocumentObj_AddRef(IUnknown *iface)
5265 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5266 ULONG ref = InterlockedIncrement(&This->ref);
5268 TRACE("(%p) ref = %u\n", This, ref);
5270 return ref;
5273 static ULONG WINAPI HTMLDocumentObj_Release(IUnknown *iface)
5275 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5276 ULONG ref = InterlockedDecrement(&This->ref);
5278 TRACE("(%p) ref = %u\n", This, ref);
5280 if(!ref) {
5281 nsIDOMWindowUtils *window_utils = NULL;
5283 if(This->basedoc.window && This->basedoc.window->nswindow)
5284 get_nsinterface((nsISupports*)This->basedoc.window->nswindow, &IID_nsIDOMWindowUtils, (void**)&window_utils);
5286 if(This->basedoc.doc_node) {
5287 This->basedoc.doc_node->basedoc.doc_obj = NULL;
5288 htmldoc_release(&This->basedoc.doc_node->basedoc);
5290 if(This->basedoc.window) {
5291 This->basedoc.window->doc_obj = NULL;
5292 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
5294 if(This->advise_holder)
5295 IOleAdviseHolder_Release(This->advise_holder);
5297 if(This->view_sink)
5298 IAdviseSink_Release(This->view_sink);
5299 if(This->client)
5300 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
5301 if(This->hostui)
5302 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
5303 if(This->in_place_active)
5304 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
5305 if(This->ipsite)
5306 IOleDocumentView_SetInPlaceSite(&This->IOleDocumentView_iface, NULL);
5307 if(This->undomgr)
5308 IOleUndoManager_Release(This->undomgr);
5309 if(This->editsvcs)
5310 IHTMLEditServices_Release(This->editsvcs);
5311 if(This->tooltips_hwnd)
5312 DestroyWindow(This->tooltips_hwnd);
5314 if(This->hwnd)
5315 DestroyWindow(This->hwnd);
5316 heap_free(This->mime);
5318 remove_target_tasks(This->task_magic);
5319 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
5320 release_dispex(&This->dispex);
5322 if(This->nscontainer)
5323 NSContainer_Release(This->nscontainer);
5324 heap_free(This);
5326 /* Force cycle collection */
5327 if(window_utils) {
5328 nsIDOMWindowUtils_CycleCollect(window_utils, NULL, 0);
5329 nsIDOMWindowUtils_Release(window_utils);
5333 return ref;
5336 static const IUnknownVtbl HTMLDocumentObjVtbl = {
5337 HTMLDocumentObj_QueryInterface,
5338 HTMLDocumentObj_AddRef,
5339 HTMLDocumentObj_Release
5342 /**********************************************************
5343 * ICustomDoc implementation
5346 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
5348 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
5351 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
5353 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5355 return htmldoc_query_interface(&This->basedoc, riid, ppv);
5358 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
5360 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5362 return htmldoc_addref(&This->basedoc);
5365 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
5367 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5369 return htmldoc_release(&This->basedoc);
5372 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
5374 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5375 IOleCommandTarget *cmdtrg;
5376 HRESULT hres;
5378 TRACE("(%p)->(%p)\n", This, pUIHandler);
5380 if(This->custom_hostui && This->hostui == pUIHandler)
5381 return S_OK;
5383 This->custom_hostui = TRUE;
5385 if(This->hostui)
5386 IDocHostUIHandler_Release(This->hostui);
5387 if(pUIHandler)
5388 IDocHostUIHandler_AddRef(pUIHandler);
5389 This->hostui = pUIHandler;
5390 if(!pUIHandler)
5391 return S_OK;
5393 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
5394 if(SUCCEEDED(hres)) {
5395 FIXME("custom UI handler supports IOleCommandTarget\n");
5396 IOleCommandTarget_Release(cmdtrg);
5399 return S_OK;
5402 static const ICustomDocVtbl CustomDocVtbl = {
5403 CustomDoc_QueryInterface,
5404 CustomDoc_AddRef,
5405 CustomDoc_Release,
5406 CustomDoc_SetUIHandler
5409 static const tid_t HTMLDocumentObj_iface_tids[] = {
5410 IHTMLDocument2_tid,
5411 IHTMLDocument3_tid,
5412 IHTMLDocument4_tid,
5413 IHTMLDocument5_tid,
5416 static dispex_static_data_t HTMLDocumentObj_dispex = {
5417 NULL,
5418 DispHTMLDocument_tid,
5419 HTMLDocumentObj_iface_tids
5422 static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID riid, void **ppv)
5424 mozIDOMWindowProxy *mozwindow;
5425 HTMLDocumentObj *doc;
5426 nsIDOMWindow *nswindow = NULL;
5427 nsresult nsres;
5428 HRESULT hres;
5430 if(outer && !IsEqualGUID(&IID_IUnknown, riid)) {
5431 *ppv = NULL;
5432 return E_INVALIDARG;
5435 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
5436 if(!doc)
5437 return E_OUTOFMEMORY;
5439 doc->ref = 1;
5440 doc->IUnknown_outer.lpVtbl = &HTMLDocumentObjVtbl;
5441 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
5443 init_dispex(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex);
5444 init_doc(&doc->basedoc, outer ? outer : &doc->IUnknown_outer, &doc->dispex.IDispatchEx_iface);
5445 TargetContainer_Init(doc);
5446 doc->basedoc.doc_obj = doc;
5447 doc->is_mhtml = is_mhtml;
5449 doc->usermode = UNKNOWN_USERMODE;
5450 doc->task_magic = get_task_target_magic();
5452 HTMLDocument_View_Init(doc);
5454 hres = create_nscontainer(doc, &doc->nscontainer);
5455 if(FAILED(hres)) {
5456 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
5457 htmldoc_release(&doc->basedoc);
5458 return hres;
5461 if(IsEqualGUID(&IID_IUnknown, riid)) {
5462 *ppv = &doc->IUnknown_outer;
5463 }else {
5464 hres = htmldoc_query_interface(&doc->basedoc, riid, ppv);
5465 htmldoc_release(&doc->basedoc);
5466 if(FAILED(hres))
5467 return hres;
5470 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &mozwindow);
5471 if(NS_FAILED(nsres))
5472 ERR("GetContentDOMWindow failed: %08x\n", nsres);
5474 nsres = mozIDOMWindowProxy_QueryInterface(mozwindow, &IID_nsIDOMWindow, (void**)&nswindow);
5475 mozIDOMWindowProxy_Release(mozwindow);
5476 assert(nsres == NS_OK);
5478 hres = HTMLOuterWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
5479 if(nswindow)
5480 nsIDOMWindow_Release(nswindow);
5481 if(FAILED(hres)) {
5482 htmldoc_release(&doc->basedoc);
5483 return hres;
5486 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
5487 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
5488 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
5491 get_thread_hwnd();
5493 return S_OK;
5496 HRESULT HTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
5498 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
5499 return create_document_object(FALSE, outer, riid, ppv);
5502 HRESULT MHTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
5504 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
5505 return create_document_object(TRUE, outer, riid, ppv);