mshtml: Inherit document mode from parent document.
[wine.git] / dlls / mshtml / htmldoc.c
blobe32385e9141fbbb68e9e14d8acd4d35b595966c0
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <assert.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "wininet.h"
31 #include "ole2.h"
32 #include "perhist.h"
33 #include "mshtmdid.h"
34 #include "mshtmcid.h"
36 #include "wine/debug.h"
38 #include "mshtml_private.h"
39 #include "htmlevent.h"
40 #include "pluginhost.h"
41 #include "binding.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
45 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret);
47 HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement **ret)
49 nsIDOMNodeList *nsnode_list;
50 nsIDOMElement *nselem;
51 nsIDOMNode *nsnode;
52 nsAString id_str;
53 nsresult nsres;
54 HRESULT hres;
56 if(!doc->nsdoc) {
57 WARN("NULL nsdoc\n");
58 return E_UNEXPECTED;
61 nsAString_InitDepend(&id_str, id);
62 /* get element by id attribute */
63 nsres = nsIDOMHTMLDocument_GetElementById(doc->nsdoc, &id_str, &nselem);
64 if(FAILED(nsres)) {
65 ERR("GetElementById failed: %08x\n", nsres);
66 nsAString_Finish(&id_str);
67 return E_FAIL;
70 /* get first element by name attribute */
71 nsres = nsIDOMHTMLDocument_GetElementsByName(doc->nsdoc, &id_str, &nsnode_list);
72 nsAString_Finish(&id_str);
73 if(FAILED(nsres)) {
74 ERR("getElementsByName failed: %08x\n", nsres);
75 if(nselem)
76 nsIDOMElement_Release(nselem);
77 return E_FAIL;
80 nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode);
81 nsIDOMNodeList_Release(nsnode_list);
82 assert(nsres == NS_OK);
84 if(nsnode && nselem) {
85 UINT16 pos;
87 nsres = nsIDOMNode_CompareDocumentPosition(nsnode, (nsIDOMNode*)nselem, &pos);
88 if(NS_FAILED(nsres)) {
89 FIXME("CompareDocumentPosition failed: 0x%08x\n", nsres);
90 nsIDOMNode_Release(nsnode);
91 nsIDOMElement_Release(nselem);
92 return E_FAIL;
95 TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
96 if(!(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS))) {
97 nsIDOMElement_Release(nselem);
98 nselem = NULL;
102 if(nsnode) {
103 if(!nselem) {
104 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
105 assert(nsres == NS_OK);
107 nsIDOMNode_Release(nsnode);
110 if(!nselem) {
111 *ret = NULL;
112 return S_OK;
115 hres = get_elem(doc, nselem, ret);
116 nsIDOMElement_Release(nselem);
117 return hres;
120 UINT get_document_charset(HTMLDocumentNode *doc)
122 nsAString charset_str;
123 UINT ret = 0;
124 nsresult nsres;
126 if(doc->charset)
127 return doc->charset;
129 nsAString_Init(&charset_str, NULL);
130 nsres = nsIDOMHTMLDocument_GetCharacterSet(doc->nsdoc, &charset_str);
131 if(NS_SUCCEEDED(nsres)) {
132 const PRUnichar *charset;
134 nsAString_GetData(&charset_str, &charset);
136 if(*charset) {
137 BSTR str = SysAllocString(charset);
138 ret = cp_from_charset_string(str);
139 SysFreeString(str);
141 }else {
142 ERR("GetCharset failed: %08x\n", nsres);
144 nsAString_Finish(&charset_str);
146 if(!ret)
147 return CP_UTF8;
149 return doc->charset = ret;
152 static inline HTMLDocument *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
154 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument2_iface);
157 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
159 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
161 return htmldoc_query_interface(This, riid, ppv);
164 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
166 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
168 return htmldoc_addref(This);
171 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
173 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
175 return htmldoc_release(This);
178 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
180 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
182 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
185 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
186 LCID lcid, ITypeInfo **ppTInfo)
188 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
190 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
193 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
194 LPOLESTR *rgszNames, UINT cNames,
195 LCID lcid, DISPID *rgDispId)
197 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
199 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
200 rgDispId);
203 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
204 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
205 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
207 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
209 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
210 pDispParams, pVarResult, pExcepInfo, puArgErr);
213 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
215 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
217 TRACE("(%p)->(%p)\n", This, p);
219 *p = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
220 IDispatch_AddRef(*p);
221 return S_OK;
224 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
226 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
227 nsIDOMElement *nselem = NULL;
228 HTMLDOMNode *node;
229 nsresult nsres;
230 HRESULT hres;
232 TRACE("(%p)->(%p)\n", This, p);
234 if(!This->doc_node->nsdoc) {
235 WARN("NULL nsdoc\n");
236 return E_UNEXPECTED;
239 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
240 if(NS_FAILED(nsres)) {
241 ERR("GetDocumentElement failed: %08x\n", nsres);
242 return E_FAIL;
245 if(!nselem) {
246 *p = NULL;
247 return S_OK;
250 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
251 nsIDOMElement_Release(nselem);
252 if(FAILED(hres))
253 return hres;
255 *p = create_all_collection(node, TRUE);
256 node_release(node);
257 return hres;
260 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
262 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
263 nsIDOMHTMLElement *nsbody = NULL;
264 HTMLDOMNode *node;
265 HRESULT hres;
267 TRACE("(%p)->(%p)\n", This, p);
269 if(This->doc_node->nsdoc) {
270 nsresult nsres;
272 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
273 if(NS_FAILED(nsres)) {
274 TRACE("Could not get body: %08x\n", nsres);
275 return E_UNEXPECTED;
279 if(!nsbody) {
280 *p = NULL;
281 return S_OK;
284 hres = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE, &node);
285 nsIDOMHTMLElement_Release(nsbody);
286 if(FAILED(hres))
287 return hres;
289 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
290 node_release(node);
291 return hres;
294 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
296 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
297 nsIDOMElement *nselem;
298 HTMLElement *elem;
299 nsresult nsres;
300 HRESULT hres;
302 TRACE("(%p)->(%p)\n", This, p);
304 if(!This->doc_node->nsdoc) {
305 *p = NULL;
306 return S_OK;
310 * NOTE: Gecko may return an active element even if the document is not visible.
311 * IE returns NULL in this case.
313 nsres = nsIDOMHTMLDocument_GetActiveElement(This->doc_node->nsdoc, &nselem);
314 if(NS_FAILED(nsres)) {
315 ERR("GetActiveElement failed: %08x\n", nsres);
316 return E_FAIL;
319 if(!nselem) {
320 *p = NULL;
321 return S_OK;
324 hres = get_elem(This->doc_node, nselem, &elem);
325 nsIDOMElement_Release(nselem);
326 if(FAILED(hres))
327 return hres;
329 *p = &elem->IHTMLElement_iface;
330 return S_OK;
333 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
335 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
336 nsIDOMHTMLCollection *nscoll = NULL;
337 nsresult nsres;
339 TRACE("(%p)->(%p)\n", This, p);
341 if(!p)
342 return E_INVALIDARG;
344 *p = NULL;
346 if(!This->doc_node->nsdoc) {
347 WARN("NULL nsdoc\n");
348 return E_UNEXPECTED;
351 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
352 if(NS_FAILED(nsres)) {
353 ERR("GetImages failed: %08x\n", nsres);
354 return E_FAIL;
357 if(nscoll) {
358 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
359 nsIDOMHTMLCollection_Release(nscoll);
362 return S_OK;
365 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
367 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
368 nsIDOMHTMLCollection *nscoll = NULL;
369 nsresult nsres;
371 TRACE("(%p)->(%p)\n", This, p);
373 if(!p)
374 return E_INVALIDARG;
376 *p = NULL;
378 if(!This->doc_node->nsdoc) {
379 WARN("NULL nsdoc\n");
380 return E_UNEXPECTED;
383 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
384 if(NS_FAILED(nsres)) {
385 ERR("GetApplets failed: %08x\n", nsres);
386 return E_FAIL;
389 if(nscoll) {
390 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
391 nsIDOMHTMLCollection_Release(nscoll);
394 return S_OK;
397 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
399 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
400 nsIDOMHTMLCollection *nscoll = NULL;
401 nsresult nsres;
403 TRACE("(%p)->(%p)\n", This, p);
405 if(!p)
406 return E_INVALIDARG;
408 *p = NULL;
410 if(!This->doc_node->nsdoc) {
411 WARN("NULL nsdoc\n");
412 return E_UNEXPECTED;
415 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
416 if(NS_FAILED(nsres)) {
417 ERR("GetLinks failed: %08x\n", nsres);
418 return E_FAIL;
421 if(nscoll) {
422 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
423 nsIDOMHTMLCollection_Release(nscoll);
426 return S_OK;
429 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
431 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
432 nsIDOMHTMLCollection *nscoll = NULL;
433 nsresult nsres;
435 TRACE("(%p)->(%p)\n", This, p);
437 if(!p)
438 return E_INVALIDARG;
440 *p = NULL;
442 if(!This->doc_node->nsdoc) {
443 WARN("NULL nsdoc\n");
444 return E_UNEXPECTED;
447 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
448 if(NS_FAILED(nsres)) {
449 ERR("GetForms failed: %08x\n", nsres);
450 return E_FAIL;
453 if(nscoll) {
454 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
455 nsIDOMHTMLCollection_Release(nscoll);
458 return S_OK;
461 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
463 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
464 nsIDOMHTMLCollection *nscoll = NULL;
465 nsresult nsres;
467 TRACE("(%p)->(%p)\n", This, p);
469 if(!p)
470 return E_INVALIDARG;
472 *p = NULL;
474 if(!This->doc_node->nsdoc) {
475 WARN("NULL nsdoc\n");
476 return E_UNEXPECTED;
479 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
480 if(NS_FAILED(nsres)) {
481 ERR("GetAnchors failed: %08x\n", nsres);
482 return E_FAIL;
485 if(nscoll) {
486 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
487 nsIDOMHTMLCollection_Release(nscoll);
490 return S_OK;
493 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
495 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
496 nsAString nsstr;
497 nsresult nsres;
499 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
501 if(!This->doc_node->nsdoc) {
502 WARN("NULL nsdoc\n");
503 return E_UNEXPECTED;
506 nsAString_InitDepend(&nsstr, v);
507 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
508 nsAString_Finish(&nsstr);
509 if(NS_FAILED(nsres))
510 ERR("SetTitle failed: %08x\n", nsres);
512 return S_OK;
515 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
517 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
518 const PRUnichar *ret;
519 nsAString nsstr;
520 nsresult nsres;
522 TRACE("(%p)->(%p)\n", This, p);
524 if(!This->doc_node->nsdoc) {
525 WARN("NULL nsdoc\n");
526 return E_UNEXPECTED;
530 nsAString_Init(&nsstr, NULL);
531 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
532 if (NS_SUCCEEDED(nsres)) {
533 nsAString_GetData(&nsstr, &ret);
534 *p = SysAllocString(ret);
536 nsAString_Finish(&nsstr);
538 if(NS_FAILED(nsres)) {
539 ERR("GetTitle failed: %08x\n", nsres);
540 return E_FAIL;
543 return S_OK;
546 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
548 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
549 nsIDOMHTMLCollection *nscoll = NULL;
550 nsresult nsres;
552 TRACE("(%p)->(%p)\n", This, p);
554 if(!p)
555 return E_INVALIDARG;
557 *p = NULL;
559 if(!This->doc_node->nsdoc) {
560 WARN("NULL nsdoc\n");
561 return E_UNEXPECTED;
564 nsres = nsIDOMHTMLDocument_GetScripts(This->doc_node->nsdoc, &nscoll);
565 if(NS_FAILED(nsres)) {
566 ERR("GetImages failed: %08x\n", nsres);
567 return E_FAIL;
570 if(nscoll) {
571 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
572 nsIDOMHTMLCollection_Release(nscoll);
575 return S_OK;
578 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
580 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
581 HRESULT hres;
583 static const WCHAR onW[] = {'o','n',0};
585 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
587 if(strcmpiW(v, onW)) {
588 FIXME("Unsupported arg %s\n", debugstr_w(v));
589 return E_NOTIMPL;
592 hres = setup_edit_mode(This->doc_obj);
593 if(FAILED(hres))
594 return hres;
596 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
597 return S_OK;
600 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
602 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
603 static const WCHAR szOff[] = {'O','f','f',0};
604 FIXME("(%p)->(%p) always returning Off\n", This, p);
606 if(!p)
607 return E_INVALIDARG;
609 *p = SysAllocString(szOff);
611 return S_OK;
614 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
616 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
617 nsISelection *nsselection;
618 nsresult nsres;
620 TRACE("(%p)->(%p)\n", This, p);
622 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
623 if(NS_FAILED(nsres)) {
624 ERR("GetSelection failed: %08x\n", nsres);
625 return E_FAIL;
628 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
631 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
633 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
636 TRACE("(%p)->(%p)\n", iface, p);
638 if(!p)
639 return E_POINTER;
641 return get_readystate_string(This->window->readystate, p);
644 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
646 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
648 TRACE("(%p)->(%p)\n", This, p);
650 return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p);
653 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
655 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
656 FIXME("(%p)->(%p)\n", This, p);
657 return E_NOTIMPL;
660 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
662 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
663 FIXME("(%p)->(%p)\n", This, p);
664 return E_NOTIMPL;
667 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
669 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
670 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
671 return E_NOTIMPL;
674 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
676 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
677 FIXME("(%p)->(%p)\n", This, p);
678 return E_NOTIMPL;
681 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
683 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
684 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
685 return E_NOTIMPL;
688 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
690 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
691 FIXME("(%p)->(%p)\n", This, p);
692 return E_NOTIMPL;
695 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
697 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
698 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
699 return E_NOTIMPL;
702 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
704 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
705 FIXME("(%p)->(%p)\n", This, p);
706 return E_NOTIMPL;
709 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
711 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
712 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
713 return E_NOTIMPL;
716 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
718 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
719 FIXME("(%p)->(%p)\n", This, p);
720 return E_NOTIMPL;
723 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
725 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
726 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
727 return E_NOTIMPL;
730 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
732 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
733 FIXME("(%p)->(%p)\n", This, p);
734 return E_NOTIMPL;
737 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
739 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
741 FIXME("(%p)->(%p)\n", This, p);
743 *p = NULL;
744 return S_OK;
747 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
749 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
751 TRACE("(%p)->(%p)\n", This, p);
753 if(!This->doc_node->nsdoc) {
754 WARN("NULL nsdoc\n");
755 return E_UNEXPECTED;
758 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
761 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
763 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
764 FIXME("(%p)->(%p)\n", This, p);
765 return E_NOTIMPL;
768 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
770 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
772 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
774 if(!This->window) {
775 FIXME("No window available\n");
776 return E_FAIL;
779 return navigate_url(This->window, v, This->window->uri, BINDING_NAVIGATED);
782 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
784 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
786 static const WCHAR about_blank_url[] =
787 {'a','b','o','u','t',':','b','l','a','n','k',0};
789 TRACE("(%p)->(%p)\n", iface, p);
791 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
792 return *p ? S_OK : E_OUTOFMEMORY;
795 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
797 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
798 nsAString nsstr;
799 nsresult nsres;
801 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
803 nsAString_InitDepend(&nsstr, v);
804 nsres = nsIDOMHTMLDocument_SetDomain(This->doc_node->nsdoc, &nsstr);
805 nsAString_Finish(&nsstr);
806 if(NS_FAILED(nsres)) {
807 ERR("SetDomain failed: %08x\n", nsres);
808 return E_INVALIDARG;
811 return S_OK;
814 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
816 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
817 nsAString nsstr;
818 nsresult nsres;
820 TRACE("(%p)->(%p)\n", This, p);
822 nsAString_Init(&nsstr, NULL);
823 nsres = nsIDOMHTMLDocument_GetDomain(This->doc_node->nsdoc, &nsstr);
824 if(NS_SUCCEEDED(nsres) && This->window && This->window->uri) {
825 const PRUnichar *str;
826 HRESULT hres;
828 nsAString_GetData(&nsstr, &str);
829 if(!*str) {
830 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
831 nsAString_Finish(&nsstr);
832 hres = IUri_GetHost(This->window->uri, p);
833 return FAILED(hres) ? hres : S_OK;
837 return return_nsstr(nsres, &nsstr, p);
840 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
842 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
843 BOOL bret;
845 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
847 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
848 if(!bret) {
849 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
850 return HRESULT_FROM_WIN32(GetLastError());
853 return S_OK;
856 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
858 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
859 DWORD size;
860 BOOL bret;
862 TRACE("(%p)->(%p)\n", This, p);
864 size = 0;
865 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
866 if(!bret) {
867 switch(GetLastError()) {
868 case ERROR_INSUFFICIENT_BUFFER:
869 break;
870 case ERROR_NO_MORE_ITEMS:
871 *p = NULL;
872 return S_OK;
873 default:
874 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
875 return HRESULT_FROM_WIN32(GetLastError());
879 if(!size) {
880 *p = NULL;
881 return S_OK;
884 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
885 if(!*p)
886 return E_OUTOFMEMORY;
888 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
889 if(!bret) {
890 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
891 return E_FAIL;
894 return S_OK;
897 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
899 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
900 FIXME("(%p)->(%x)\n", This, v);
901 return E_NOTIMPL;
904 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
906 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
907 FIXME("(%p)->(%p)\n", This, p);
908 return E_NOTIMPL;
911 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
913 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
914 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
915 return E_NOTIMPL;
918 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
920 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
922 TRACE("(%p)->(%p)\n", This, p);
924 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
927 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
929 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
930 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
931 return E_NOTIMPL;
934 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
936 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
938 TRACE("(%p)->(%p)\n", This, p);
940 *p = charset_string_from_cp(GetACP());
941 return *p ? S_OK : E_OUTOFMEMORY;
944 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
946 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
947 FIXME("(%p)->(%p)\n", This, p);
948 return E_NOTIMPL;
951 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
953 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
954 FIXME("(%p)->(%p)\n", This, p);
955 return E_NOTIMPL;
958 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
960 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
961 FIXME("(%p)->(%p)\n", This, p);
962 return E_NOTIMPL;
965 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
967 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
968 FIXME("(%p)->(%p)\n", This, p);
969 return E_NOTIMPL;
972 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
974 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
975 FIXME("(%p)->(%p)\n", This, p);
976 return E_NOTIMPL;
979 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
981 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
982 FIXME("(%p)->(%p)\n", This, p);
983 return E_NOTIMPL;
986 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
988 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
989 FIXME("(%p)->(%p)\n", This, p);
990 return E_NOTIMPL;
993 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
995 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
996 FIXME("(%p)->(%p)\n", This, p);
997 return E_NOTIMPL;
1000 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
1002 VARIANT *var, tmp;
1003 JSContext *jsctx;
1004 nsAString nsstr;
1005 ULONG i, argc;
1006 nsresult nsres;
1007 HRESULT hres;
1009 if(!This->doc_node->nsdoc) {
1010 WARN("NULL nsdoc\n");
1011 return E_UNEXPECTED;
1014 if (!psarray)
1015 return S_OK;
1017 if(psarray->cDims != 1) {
1018 FIXME("cDims=%d\n", psarray->cDims);
1019 return E_INVALIDARG;
1022 hres = SafeArrayAccessData(psarray, (void**)&var);
1023 if(FAILED(hres)) {
1024 WARN("SafeArrayAccessData failed: %08x\n", hres);
1025 return hres;
1028 V_VT(&tmp) = VT_EMPTY;
1030 jsctx = get_context_from_document(This->doc_node->nsdoc);
1031 argc = psarray->rgsabound[0].cElements;
1032 for(i=0; i < argc; i++) {
1033 if(V_VT(var+i) == VT_BSTR) {
1034 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1035 }else {
1036 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1037 if(FAILED(hres)) {
1038 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1039 break;
1041 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1044 if(!ln || i != argc-1)
1045 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1046 else
1047 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1048 nsAString_Finish(&nsstr);
1049 if(V_VT(var+i) != VT_BSTR)
1050 VariantClear(&tmp);
1051 if(NS_FAILED(nsres)) {
1052 ERR("Write failed: %08x\n", nsres);
1053 hres = E_FAIL;
1054 break;
1058 SafeArrayUnaccessData(psarray);
1060 return hres;
1063 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1065 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1067 TRACE("(%p)->(%p)\n", iface, psarray);
1069 return document_write(This, psarray, FALSE);
1072 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1074 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1076 TRACE("(%p)->(%p)\n", This, psarray);
1078 return document_write(This, psarray, TRUE);
1081 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1082 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1084 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1085 nsISupports *tmp;
1086 nsresult nsres;
1088 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
1090 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1091 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1093 if(!This->doc_node->nsdoc) {
1094 ERR("!nsdoc\n");
1095 return E_NOTIMPL;
1098 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
1099 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1100 FIXME("unsupported args\n");
1102 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1103 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1104 if(NS_FAILED(nsres)) {
1105 ERR("Open failed: %08x\n", nsres);
1106 return E_FAIL;
1109 if(tmp)
1110 nsISupports_Release(tmp);
1112 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1113 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1114 return S_OK;
1117 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1119 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1120 nsresult nsres;
1122 TRACE("(%p)\n", This);
1124 if(!This->doc_node->nsdoc) {
1125 ERR("!nsdoc\n");
1126 return E_NOTIMPL;
1129 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1130 if(NS_FAILED(nsres)) {
1131 ERR("Close failed: %08x\n", nsres);
1132 return E_FAIL;
1135 return S_OK;
1138 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1140 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1141 nsresult nsres;
1143 TRACE("(%p)\n", This);
1145 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1146 if(NS_FAILED(nsres)) {
1147 ERR("Clear failed: %08x\n", nsres);
1148 return E_FAIL;
1151 return S_OK;
1154 static const WCHAR copyW[] =
1155 {'c','o','p','y',0};
1156 static const WCHAR cutW[] =
1157 {'c','u','t',0};
1158 static const WCHAR fontnameW[] =
1159 {'f','o','n','t','n','a','m','e',0};
1160 static const WCHAR fontsizeW[] =
1161 {'f','o','n','t','s','i','z','e',0};
1162 static const WCHAR indentW[] =
1163 {'i','n','d','e','n','t',0};
1164 static const WCHAR insertorderedlistW[] =
1165 {'i','n','s','e','r','t','o','r','d','e','r','e','d','l','i','s','t',0};
1166 static const WCHAR insertunorderedlistW[] =
1167 {'i','n','s','e','r','t','u','n','o','r','d','e','r','e','d','l','i','s','t',0};
1168 static const WCHAR outdentW[] =
1169 {'o','u','t','d','e','n','t',0};
1170 static const WCHAR pasteW[] =
1171 {'p','a','s','t','e',0};
1172 static const WCHAR respectvisibilityindesignW[] =
1173 {'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};
1175 static const struct {
1176 const WCHAR *name;
1177 OLECMDID id;
1178 }command_names[] = {
1179 {copyW, IDM_COPY},
1180 {cutW, IDM_CUT},
1181 {fontnameW, IDM_FONTNAME},
1182 {fontsizeW, IDM_FONTSIZE},
1183 {indentW, IDM_INDENT},
1184 {insertorderedlistW, IDM_ORDERLIST},
1185 {insertunorderedlistW, IDM_UNORDERLIST},
1186 {outdentW, IDM_OUTDENT},
1187 {pasteW, IDM_PASTE},
1188 {respectvisibilityindesignW, IDM_RESPECTVISIBILITY_INDESIGN}
1191 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1193 int i;
1195 for(i = 0; i < sizeof(command_names)/sizeof(*command_names); i++) {
1196 if(!strcmpiW(command_names[i].name, str)) {
1197 *cmdid = command_names[i].id;
1198 return TRUE;
1202 FIXME("Unknown command %s\n", debugstr_w(str));
1203 return FALSE;
1206 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1207 VARIANT_BOOL *pfRet)
1209 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1210 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1211 return E_NOTIMPL;
1214 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1215 VARIANT_BOOL *pfRet)
1217 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1218 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1219 return E_NOTIMPL;
1222 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1223 VARIANT_BOOL *pfRet)
1225 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1226 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1227 return E_NOTIMPL;
1230 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1231 VARIANT_BOOL *pfRet)
1233 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1234 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1235 return E_NOTIMPL;
1238 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1239 BSTR *pfRet)
1241 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1242 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1243 return E_NOTIMPL;
1246 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1247 VARIANT *pfRet)
1249 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1250 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1251 return E_NOTIMPL;
1254 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1255 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1257 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1258 OLECMDID cmdid;
1259 VARIANT ret;
1260 HRESULT hres;
1262 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1264 if(!cmdid_from_string(cmdID, &cmdid))
1265 return OLECMDERR_E_NOTSUPPORTED;
1267 V_VT(&ret) = VT_EMPTY;
1268 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1269 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1270 if(FAILED(hres))
1271 return hres;
1273 if(V_VT(&ret) != VT_EMPTY) {
1274 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1275 VariantClear(&ret);
1278 *pfRet = VARIANT_TRUE;
1279 return S_OK;
1282 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1283 VARIANT_BOOL *pfRet)
1285 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1286 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1287 return E_NOTIMPL;
1290 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1291 IHTMLElement **newElem)
1293 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1294 HTMLElement *elem;
1295 HRESULT hres;
1297 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1299 hres = create_element(This->doc_node, eTag, &elem);
1300 if(FAILED(hres))
1301 return hres;
1303 *newElem = &elem->IHTMLElement_iface;
1304 return S_OK;
1307 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1309 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1310 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1311 return E_NOTIMPL;
1314 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1316 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1317 FIXME("(%p)->(%p)\n", This, p);
1318 return E_NOTIMPL;
1321 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1323 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1325 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1327 return set_doc_event(This, EVENTID_CLICK, &v);
1330 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1332 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1334 TRACE("(%p)->(%p)\n", This, p);
1336 return get_doc_event(This, EVENTID_CLICK, p);
1339 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1341 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1343 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1345 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1348 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1350 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1352 TRACE("(%p)->(%p)\n", This, p);
1354 return get_doc_event(This, EVENTID_DBLCLICK, p);
1357 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1359 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1361 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1363 return set_doc_event(This, EVENTID_KEYUP, &v);
1366 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1368 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1370 TRACE("(%p)->(%p)\n", This, p);
1372 return get_doc_event(This, EVENTID_KEYUP, p);
1375 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1377 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1379 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1381 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1384 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1386 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1388 TRACE("(%p)->(%p)\n", This, p);
1390 return get_doc_event(This, EVENTID_KEYDOWN, p);
1393 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1395 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1397 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1399 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1402 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1404 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1406 TRACE("(%p)->(%p)\n", This, p);
1408 return get_doc_event(This, EVENTID_KEYPRESS, p);
1411 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1413 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1415 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1417 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1420 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1422 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1424 TRACE("(%p)->(%p)\n", This, p);
1426 return get_doc_event(This, EVENTID_MOUSEUP, p);
1429 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1431 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1433 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1435 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1438 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1440 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1442 TRACE("(%p)->(%p)\n", This, p);
1444 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1447 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1449 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1451 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1453 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1456 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1458 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1460 TRACE("(%p)->(%p)\n", This, p);
1462 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1465 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1467 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1469 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1471 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1474 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1476 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1478 TRACE("(%p)->(%p)\n", This, p);
1480 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1483 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1485 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1487 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1489 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1492 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1494 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1496 TRACE("(%p)->(%p)\n", This, p);
1498 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1501 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1503 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1505 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1507 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1510 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1512 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1514 TRACE("(%p)->(%p)\n", This, p);
1516 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1519 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1521 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1522 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1523 return E_NOTIMPL;
1526 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1528 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1529 FIXME("(%p)->(%p)\n", This, p);
1530 return E_NOTIMPL;
1533 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1535 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1536 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1537 return E_NOTIMPL;
1540 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1542 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1543 FIXME("(%p)->(%p)\n", This, p);
1544 return E_NOTIMPL;
1547 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1549 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1550 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1551 return E_NOTIMPL;
1554 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1556 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1557 FIXME("(%p)->(%p)\n", This, p);
1558 return E_NOTIMPL;
1561 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1563 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1565 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1567 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1570 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1572 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1574 TRACE("(%p)->(%p)\n", This, p);
1576 return get_doc_event(This, EVENTID_DRAGSTART, p);
1579 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1581 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1583 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1585 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1588 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1590 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1592 TRACE("(%p)->(%p)\n", This, p);
1594 return get_doc_event(This, EVENTID_SELECTSTART, p);
1597 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1598 IHTMLElement **elementHit)
1600 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1601 nsIDOMElement *nselem;
1602 HTMLDOMNode *node;
1603 nsresult nsres;
1604 HRESULT hres;
1606 TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1608 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1609 if(NS_FAILED(nsres)) {
1610 ERR("ElementFromPoint failed: %08x\n", nsres);
1611 return E_FAIL;
1614 if(!nselem) {
1615 *elementHit = NULL;
1616 return S_OK;
1619 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
1620 nsIDOMElement_Release(nselem);
1621 if(FAILED(hres))
1622 return hres;
1624 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)elementHit);
1625 node_release(node);
1626 return hres;
1629 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1631 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1633 TRACE("(%p)->(%p)\n", This, p);
1635 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
1638 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1639 IHTMLStyleSheetsCollection **p)
1641 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1642 nsIDOMStyleSheetList *nsstylelist;
1643 nsresult nsres;
1645 TRACE("(%p)->(%p)\n", This, p);
1647 *p = NULL;
1649 if(!This->doc_node->nsdoc) {
1650 WARN("NULL nsdoc\n");
1651 return E_UNEXPECTED;
1654 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1655 if(NS_FAILED(nsres)) {
1656 ERR("GetStyleSheets failed: %08x\n", nsres);
1657 return E_FAIL;
1660 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1661 nsIDOMStyleSheetList_Release(nsstylelist);
1663 return S_OK;
1666 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1668 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1669 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1670 return E_NOTIMPL;
1673 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1675 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1676 FIXME("(%p)->(%p)\n", This, p);
1677 return E_NOTIMPL;
1680 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1682 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1683 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1684 return E_NOTIMPL;
1687 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1689 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1690 FIXME("(%p)->(%p)\n", This, p);
1691 return E_NOTIMPL;
1694 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1696 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1698 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1700 TRACE("(%p)->(%p)\n", This, String);
1702 if(!String)
1703 return E_INVALIDARG;
1705 *String = SysAllocString(objectW);
1706 return *String ? S_OK : E_OUTOFMEMORY;
1710 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1711 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1713 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1714 nsIDOMHTMLHeadElement *head_elem;
1715 IHTMLStyleElement *style_elem;
1716 HTMLElement *elem;
1717 nsresult nsres;
1718 HRESULT hres;
1720 static const WCHAR styleW[] = {'s','t','y','l','e',0};
1722 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1724 if(!This->doc_node->nsdoc) {
1725 FIXME("not a real doc object\n");
1726 return E_NOTIMPL;
1729 if(lIndex != -1)
1730 FIXME("Unsupported lIndex %d\n", lIndex);
1732 if(bstrHref && *bstrHref) {
1733 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
1734 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1735 return S_OK;
1738 hres = create_element(This->doc_node, styleW, &elem);
1739 if(FAILED(hres))
1740 return hres;
1742 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
1743 if(NS_SUCCEEDED(nsres)) {
1744 nsIDOMNode *head_node, *tmp_node;
1746 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
1747 nsIDOMHTMLHeadElement_Release(head_elem);
1748 assert(nsres == NS_OK);
1750 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
1751 nsIDOMNode_Release(head_node);
1752 if(NS_SUCCEEDED(nsres) && tmp_node)
1753 nsIDOMNode_Release(tmp_node);
1755 if(NS_FAILED(nsres)) {
1756 IHTMLElement_Release(&elem->IHTMLElement_iface);
1757 return E_FAIL;
1760 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
1761 assert(hres == S_OK);
1762 IHTMLElement_Release(&elem->IHTMLElement_iface);
1764 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
1765 IHTMLStyleElement_Release(style_elem);
1766 return hres;
1769 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1770 HTMLDocument_QueryInterface,
1771 HTMLDocument_AddRef,
1772 HTMLDocument_Release,
1773 HTMLDocument_GetTypeInfoCount,
1774 HTMLDocument_GetTypeInfo,
1775 HTMLDocument_GetIDsOfNames,
1776 HTMLDocument_Invoke,
1777 HTMLDocument_get_Script,
1778 HTMLDocument_get_all,
1779 HTMLDocument_get_body,
1780 HTMLDocument_get_activeElement,
1781 HTMLDocument_get_images,
1782 HTMLDocument_get_applets,
1783 HTMLDocument_get_links,
1784 HTMLDocument_get_forms,
1785 HTMLDocument_get_anchors,
1786 HTMLDocument_put_title,
1787 HTMLDocument_get_title,
1788 HTMLDocument_get_scripts,
1789 HTMLDocument_put_designMode,
1790 HTMLDocument_get_designMode,
1791 HTMLDocument_get_selection,
1792 HTMLDocument_get_readyState,
1793 HTMLDocument_get_frames,
1794 HTMLDocument_get_embeds,
1795 HTMLDocument_get_plugins,
1796 HTMLDocument_put_alinkColor,
1797 HTMLDocument_get_alinkColor,
1798 HTMLDocument_put_bgColor,
1799 HTMLDocument_get_bgColor,
1800 HTMLDocument_put_fgColor,
1801 HTMLDocument_get_fgColor,
1802 HTMLDocument_put_linkColor,
1803 HTMLDocument_get_linkColor,
1804 HTMLDocument_put_vlinkColor,
1805 HTMLDocument_get_vlinkColor,
1806 HTMLDocument_get_referrer,
1807 HTMLDocument_get_location,
1808 HTMLDocument_get_lastModified,
1809 HTMLDocument_put_URL,
1810 HTMLDocument_get_URL,
1811 HTMLDocument_put_domain,
1812 HTMLDocument_get_domain,
1813 HTMLDocument_put_cookie,
1814 HTMLDocument_get_cookie,
1815 HTMLDocument_put_expando,
1816 HTMLDocument_get_expando,
1817 HTMLDocument_put_charset,
1818 HTMLDocument_get_charset,
1819 HTMLDocument_put_defaultCharset,
1820 HTMLDocument_get_defaultCharset,
1821 HTMLDocument_get_mimeType,
1822 HTMLDocument_get_fileSize,
1823 HTMLDocument_get_fileCreatedDate,
1824 HTMLDocument_get_fileModifiedDate,
1825 HTMLDocument_get_fileUpdatedDate,
1826 HTMLDocument_get_security,
1827 HTMLDocument_get_protocol,
1828 HTMLDocument_get_nameProp,
1829 HTMLDocument_write,
1830 HTMLDocument_writeln,
1831 HTMLDocument_open,
1832 HTMLDocument_close,
1833 HTMLDocument_clear,
1834 HTMLDocument_queryCommandSupported,
1835 HTMLDocument_queryCommandEnabled,
1836 HTMLDocument_queryCommandState,
1837 HTMLDocument_queryCommandIndeterm,
1838 HTMLDocument_queryCommandText,
1839 HTMLDocument_queryCommandValue,
1840 HTMLDocument_execCommand,
1841 HTMLDocument_execCommandShowHelp,
1842 HTMLDocument_createElement,
1843 HTMLDocument_put_onhelp,
1844 HTMLDocument_get_onhelp,
1845 HTMLDocument_put_onclick,
1846 HTMLDocument_get_onclick,
1847 HTMLDocument_put_ondblclick,
1848 HTMLDocument_get_ondblclick,
1849 HTMLDocument_put_onkeyup,
1850 HTMLDocument_get_onkeyup,
1851 HTMLDocument_put_onkeydown,
1852 HTMLDocument_get_onkeydown,
1853 HTMLDocument_put_onkeypress,
1854 HTMLDocument_get_onkeypress,
1855 HTMLDocument_put_onmouseup,
1856 HTMLDocument_get_onmouseup,
1857 HTMLDocument_put_onmousedown,
1858 HTMLDocument_get_onmousedown,
1859 HTMLDocument_put_onmousemove,
1860 HTMLDocument_get_onmousemove,
1861 HTMLDocument_put_onmouseout,
1862 HTMLDocument_get_onmouseout,
1863 HTMLDocument_put_onmouseover,
1864 HTMLDocument_get_onmouseover,
1865 HTMLDocument_put_onreadystatechange,
1866 HTMLDocument_get_onreadystatechange,
1867 HTMLDocument_put_onafterupdate,
1868 HTMLDocument_get_onafterupdate,
1869 HTMLDocument_put_onrowexit,
1870 HTMLDocument_get_onrowexit,
1871 HTMLDocument_put_onrowenter,
1872 HTMLDocument_get_onrowenter,
1873 HTMLDocument_put_ondragstart,
1874 HTMLDocument_get_ondragstart,
1875 HTMLDocument_put_onselectstart,
1876 HTMLDocument_get_onselectstart,
1877 HTMLDocument_elementFromPoint,
1878 HTMLDocument_get_parentWindow,
1879 HTMLDocument_get_styleSheets,
1880 HTMLDocument_put_onbeforeupdate,
1881 HTMLDocument_get_onbeforeupdate,
1882 HTMLDocument_put_onerrorupdate,
1883 HTMLDocument_get_onerrorupdate,
1884 HTMLDocument_toString,
1885 HTMLDocument_createStyleSheet
1888 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
1890 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
1893 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
1894 REFIID riid, void **ppv)
1896 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1897 return htmldoc_query_interface(This, riid, ppv);
1900 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
1902 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1903 return htmldoc_addref(This);
1906 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
1908 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1909 return htmldoc_release(This);
1912 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
1914 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1915 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1918 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
1919 LCID lcid, ITypeInfo **ppTInfo)
1921 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1922 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1925 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
1926 LPOLESTR *rgszNames, UINT cNames,
1927 LCID lcid, DISPID *rgDispId)
1929 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1930 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1931 rgDispId);
1934 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
1935 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1936 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1938 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1939 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1940 pDispParams, pVarResult, pExcepInfo, puArgErr);
1943 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
1945 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1946 FIXME("(%p)\n", This);
1947 return E_NOTIMPL;
1950 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
1952 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1954 WARN("(%p)->(%x)\n", This, fForce);
1956 /* Doing nothing here should be fine for us. */
1957 return S_OK;
1960 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
1961 IHTMLDOMNode **newTextNode)
1963 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1964 nsIDOMText *nstext;
1965 HTMLDOMNode *node;
1966 nsAString text_str;
1967 nsresult nsres;
1968 HRESULT hres;
1970 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
1972 if(!This->doc_node->nsdoc) {
1973 WARN("NULL nsdoc\n");
1974 return E_UNEXPECTED;
1977 nsAString_InitDepend(&text_str, text);
1978 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
1979 nsAString_Finish(&text_str);
1980 if(NS_FAILED(nsres)) {
1981 ERR("CreateTextNode failed: %08x\n", nsres);
1982 return E_FAIL;
1985 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
1986 nsIDOMText_Release(nstext);
1987 if(FAILED(hres))
1988 return hres;
1990 *newTextNode = &node->IHTMLDOMNode_iface;
1991 return S_OK;
1994 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
1996 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1997 nsIDOMElement *nselem = NULL;
1998 HTMLDOMNode *node;
1999 nsresult nsres;
2000 HRESULT hres;
2002 TRACE("(%p)->(%p)\n", This, p);
2004 if(This->window->readystate == READYSTATE_UNINITIALIZED) {
2005 *p = NULL;
2006 return S_OK;
2009 if(!This->doc_node->nsdoc) {
2010 WARN("NULL nsdoc\n");
2011 return E_UNEXPECTED;
2014 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
2015 if(NS_FAILED(nsres)) {
2016 ERR("GetDocumentElement failed: %08x\n", nsres);
2017 return E_FAIL;
2020 if(!nselem) {
2021 *p = NULL;
2022 return S_OK;
2025 hres = get_node(This->doc_node, (nsIDOMNode *)nselem, TRUE, &node);
2026 nsIDOMElement_Release(nselem);
2027 if(FAILED(hres))
2028 return hres;
2030 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
2031 node_release(node);
2032 return hres;
2035 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2037 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2039 TRACE("(%p)->(%p)\n", This, p);
2041 return elem_unique_id(++This->doc_node->unique_id, p);
2044 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2045 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2047 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2049 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2051 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2054 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2055 IDispatch *pDisp)
2057 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2059 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2061 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2064 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2066 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2067 FIXME("(%p)->()\n", This);
2068 return E_NOTIMPL;
2071 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2073 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2074 FIXME("(%p)->(%p)\n", This, p);
2075 return E_NOTIMPL;
2078 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2080 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2081 FIXME("(%p)->()\n", This);
2082 return E_NOTIMPL;
2085 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2087 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2088 FIXME("(%p)->(%p)\n", This, p);
2089 return E_NOTIMPL;
2092 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2094 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2095 FIXME("(%p)->()\n", This);
2096 return E_NOTIMPL;
2099 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2101 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2102 FIXME("(%p)->(%p)\n", This, p);
2103 return E_NOTIMPL;
2106 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2108 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2109 FIXME("(%p)->()\n", This);
2110 return E_NOTIMPL;
2113 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2115 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2116 FIXME("(%p)->(%p)\n", This, p);
2117 return E_NOTIMPL;
2120 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2122 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2123 FIXME("(%p)->()\n", This);
2124 return E_NOTIMPL;
2127 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2129 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2130 FIXME("(%p)->(%p)\n", This, p);
2131 return E_NOTIMPL;
2134 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2136 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2137 FIXME("(%p)->()\n", This);
2138 return E_NOTIMPL;
2141 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2143 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2144 FIXME("(%p)->(%p)\n", This, p);
2145 return E_NOTIMPL;
2148 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2150 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2151 FIXME("(%p)->()\n", This);
2152 return E_NOTIMPL;
2155 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2157 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2158 FIXME("(%p)->(%p)\n", This, p);
2159 return E_NOTIMPL;
2162 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2164 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2165 nsAString dir_str;
2166 nsresult nsres;
2168 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2170 if(!This->doc_node->nsdoc) {
2171 FIXME("NULL nsdoc\n");
2172 return E_UNEXPECTED;
2175 nsAString_InitDepend(&dir_str, v);
2176 nsres = nsIDOMHTMLDocument_SetDir(This->doc_node->nsdoc, &dir_str);
2177 nsAString_Finish(&dir_str);
2178 if(NS_FAILED(nsres)) {
2179 ERR("SetDir failed: %08x\n", nsres);
2180 return E_FAIL;
2183 return S_OK;
2186 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2188 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2189 nsAString dir_str;
2190 nsresult nsres;
2192 TRACE("(%p)->(%p)\n", This, p);
2194 if(!This->doc_node->nsdoc) {
2195 FIXME("NULL nsdoc\n");
2196 return E_UNEXPECTED;
2199 nsAString_Init(&dir_str, NULL);
2200 nsres = nsIDOMHTMLDocument_GetDir(This->doc_node->nsdoc, &dir_str);
2201 return return_nsstr(nsres, &dir_str, p);
2204 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2206 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2208 TRACE("(%p)->()\n", This);
2210 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2213 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2215 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2217 TRACE("(%p)->(%p)\n", This, p);
2219 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2222 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2224 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2225 FIXME("(%p)->()\n", This);
2226 return E_NOTIMPL;
2229 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2231 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2232 FIXME("(%p)->(%p)\n", This, p);
2233 return E_NOTIMPL;
2236 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2237 IHTMLDocument2 **ppNewDoc)
2239 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2240 nsIDOMDocumentFragment *doc_frag;
2241 HTMLDocumentNode *docnode;
2242 nsresult nsres;
2243 HRESULT hres;
2245 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2247 if(!This->doc_node->nsdoc) {
2248 FIXME("NULL nsdoc\n");
2249 return E_NOTIMPL;
2252 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2253 if(NS_FAILED(nsres)) {
2254 ERR("CreateDocumentFragment failed: %08x\n", nsres);
2255 return E_FAIL;
2258 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2259 nsIDOMDocumentFragment_Release(doc_frag);
2260 if(FAILED(hres))
2261 return hres;
2263 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2264 return S_OK;
2267 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2268 IHTMLDocument2 **p)
2270 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2271 FIXME("(%p)->(%p)\n", This, p);
2272 return E_NOTIMPL;
2275 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2276 VARIANT_BOOL v)
2278 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2279 FIXME("(%p)->(%x)\n", This, v);
2280 return E_NOTIMPL;
2283 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2284 VARIANT_BOOL *p)
2286 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2287 FIXME("(%p)->(%p)\n", This, p);
2288 return E_NOTIMPL;
2291 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2293 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2294 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2295 return E_NOTIMPL;
2298 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2300 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2301 FIXME("(%p)->(%p)\n", This, p);
2302 return E_NOTIMPL;
2305 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2307 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2309 TRACE("(%p)->(%p)\n", This, p);
2311 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2314 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2315 VARIANT_BOOL v)
2317 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2318 FIXME("(%p)->()\n", This);
2319 return E_NOTIMPL;
2322 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2323 VARIANT_BOOL *p)
2325 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2326 FIXME("(%p)->(%p)\n", This, p);
2327 return E_NOTIMPL;
2330 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2332 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2333 FIXME("(%p)->()\n", This);
2334 return E_NOTIMPL;
2337 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2339 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2340 FIXME("(%p)->(%p)\n", This, p);
2341 return E_NOTIMPL;
2344 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2345 IHTMLElementCollection **ppelColl)
2347 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2348 nsIDOMNodeList *node_list;
2349 nsAString selector_str;
2350 WCHAR *selector;
2351 nsresult nsres;
2353 static const WCHAR formatW[] = {'*','[','i','d','=','%','s',']',',','*','[','n','a','m','e','=','%','s',']',0};
2355 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2357 if(!This->doc_node || !This->doc_node->nsdoc) {
2358 /* We should probably return an empty collection. */
2359 FIXME("No nsdoc\n");
2360 return E_NOTIMPL;
2363 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2364 if(!selector)
2365 return E_OUTOFMEMORY;
2366 sprintfW(selector, formatW, v, v);
2369 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2370 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2371 * types and search should be case insensitive. Those are currently not supported properly.
2373 nsAString_InitDepend(&selector_str, selector);
2374 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2375 nsAString_Finish(&selector_str);
2376 heap_free(selector);
2377 if(NS_FAILED(nsres)) {
2378 ERR("QuerySelectorAll failed: %08x\n", nsres);
2379 return E_FAIL;
2382 *ppelColl = create_collection_from_nodelist(This->doc_node, node_list);
2383 nsIDOMNodeList_Release(node_list);
2384 return S_OK;
2388 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2389 IHTMLElement **pel)
2391 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2392 HTMLElement *elem;
2393 HRESULT hres;
2395 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2397 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2398 if(FAILED(hres) || !elem) {
2399 *pel = NULL;
2400 return hres;
2403 *pel = &elem->IHTMLElement_iface;
2404 return S_OK;
2408 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2409 IHTMLElementCollection **pelColl)
2411 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2412 nsIDOMNodeList *nslist;
2413 nsAString id_str;
2414 nsresult nsres;
2416 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2418 if(This->doc_node->nsdoc) {
2419 nsAString_InitDepend(&id_str, v);
2420 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2421 nsAString_Finish(&id_str);
2422 if(FAILED(nsres)) {
2423 ERR("GetElementByName failed: %08x\n", nsres);
2424 return E_FAIL;
2426 }else {
2427 nsIDOMDocumentFragment *docfrag;
2428 nsAString nsstr;
2430 if(v) {
2431 const WCHAR *ptr;
2432 for(ptr=v; *ptr; ptr++) {
2433 if(!isalnumW(*ptr)) {
2434 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2435 return E_NOTIMPL;
2440 nsres = nsIDOMNode_QueryInterface(This->doc_node->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2441 if(NS_FAILED(nsres)) {
2442 ERR("Could not get nsIDOMDocumentFragment iface: %08x\n", nsres);
2443 return E_UNEXPECTED;
2446 nsAString_InitDepend(&nsstr, v);
2447 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2448 nsAString_Finish(&nsstr);
2449 nsIDOMDocumentFragment_Release(docfrag);
2450 if(NS_FAILED(nsres)) {
2451 ERR("QuerySelectorAll failed: %08x\n", nsres);
2452 return E_FAIL;
2457 *pelColl = create_collection_from_nodelist(This->doc_node, nslist);
2458 nsIDOMNodeList_Release(nslist);
2460 return S_OK;
2463 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2464 HTMLDocument3_QueryInterface,
2465 HTMLDocument3_AddRef,
2466 HTMLDocument3_Release,
2467 HTMLDocument3_GetTypeInfoCount,
2468 HTMLDocument3_GetTypeInfo,
2469 HTMLDocument3_GetIDsOfNames,
2470 HTMLDocument3_Invoke,
2471 HTMLDocument3_releaseCapture,
2472 HTMLDocument3_recalc,
2473 HTMLDocument3_createTextNode,
2474 HTMLDocument3_get_documentElement,
2475 HTMLDocument3_get_uniqueID,
2476 HTMLDocument3_attachEvent,
2477 HTMLDocument3_detachEvent,
2478 HTMLDocument3_put_onrowsdelete,
2479 HTMLDocument3_get_onrowsdelete,
2480 HTMLDocument3_put_onrowsinserted,
2481 HTMLDocument3_get_onrowsinserted,
2482 HTMLDocument3_put_oncellchange,
2483 HTMLDocument3_get_oncellchange,
2484 HTMLDocument3_put_ondatasetchanged,
2485 HTMLDocument3_get_ondatasetchanged,
2486 HTMLDocument3_put_ondataavailable,
2487 HTMLDocument3_get_ondataavailable,
2488 HTMLDocument3_put_ondatasetcomplete,
2489 HTMLDocument3_get_ondatasetcomplete,
2490 HTMLDocument3_put_onpropertychange,
2491 HTMLDocument3_get_onpropertychange,
2492 HTMLDocument3_put_dir,
2493 HTMLDocument3_get_dir,
2494 HTMLDocument3_put_oncontextmenu,
2495 HTMLDocument3_get_oncontextmenu,
2496 HTMLDocument3_put_onstop,
2497 HTMLDocument3_get_onstop,
2498 HTMLDocument3_createDocumentFragment,
2499 HTMLDocument3_get_parentDocument,
2500 HTMLDocument3_put_enableDownload,
2501 HTMLDocument3_get_enableDownload,
2502 HTMLDocument3_put_baseUrl,
2503 HTMLDocument3_get_baseUrl,
2504 HTMLDocument3_get_childNodes,
2505 HTMLDocument3_put_inheritStyleSheets,
2506 HTMLDocument3_get_inheritStyleSheets,
2507 HTMLDocument3_put_onbeforeeditfocus,
2508 HTMLDocument3_get_onbeforeeditfocus,
2509 HTMLDocument3_getElementsByName,
2510 HTMLDocument3_getElementById,
2511 HTMLDocument3_getElementsByTagName
2514 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2516 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2519 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2520 REFIID riid, void **ppv)
2522 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2523 return htmldoc_query_interface(This, riid, ppv);
2526 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2528 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2529 return htmldoc_addref(This);
2532 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2534 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2535 return htmldoc_release(This);
2538 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2540 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2541 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2544 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2545 LCID lcid, ITypeInfo **ppTInfo)
2547 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2548 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2551 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2552 LPOLESTR *rgszNames, UINT cNames,
2553 LCID lcid, DISPID *rgDispId)
2555 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2556 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2557 rgDispId);
2560 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2561 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2562 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2564 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2565 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2566 pDispParams, pVarResult, pExcepInfo, puArgErr);
2569 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2571 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2572 nsIDOMHTMLElement *nsbody;
2573 nsresult nsres;
2575 TRACE("(%p)->()\n", This);
2577 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2578 if(NS_FAILED(nsres) || !nsbody) {
2579 ERR("GetBody failed: %08x\n", nsres);
2580 return E_FAIL;
2583 nsres = nsIDOMHTMLElement_Focus(nsbody);
2584 nsIDOMHTMLElement_Release(nsbody);
2585 if(NS_FAILED(nsres)) {
2586 ERR("Focus failed: %08x\n", nsres);
2587 return E_FAIL;
2590 return S_OK;
2593 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2595 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2596 cpp_bool has_focus;
2597 nsresult nsres;
2599 TRACE("(%p)->(%p)\n", This, pfFocus);
2601 if(!This->doc_node->nsdoc) {
2602 FIXME("Unimplemented for fragments.\n");
2603 return E_NOTIMPL;
2606 nsres = nsIDOMHTMLDocument_HasFocus(This->doc_node->nsdoc, &has_focus);
2607 assert(nsres == NS_OK);
2609 *pfFocus = has_focus ? VARIANT_TRUE : VARIANT_FALSE;
2610 return S_OK;
2613 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2615 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2617 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2619 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2622 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2624 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2626 TRACE("(%p)->(%p)\n", This, p);
2628 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2631 static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
2633 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2634 FIXME("(%p)->(%p)\n", This, p);
2635 return E_NOTIMPL;
2638 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2639 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2641 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2642 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2643 return E_NOTIMPL;
2646 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2648 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2649 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2650 return E_NOTIMPL;
2653 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2655 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2656 FIXME("(%p)->(%p)\n", This, p);
2657 return E_NOTIMPL;
2660 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2661 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2663 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2665 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2667 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2668 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2669 return E_NOTIMPL;
2672 return create_event_obj(ppEventObj);
2675 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2676 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2678 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2680 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2682 return dispatch_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2685 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2686 IHTMLRenderStyle **ppIHTMLRenderStyle)
2688 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2689 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2690 return E_NOTIMPL;
2693 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2695 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2696 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2697 return E_NOTIMPL;
2700 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2702 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2703 FIXME("(%p)->(%p)\n", This, p);
2704 return E_NOTIMPL;
2707 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2709 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2710 FIXME("(%p)->(%p)\n", This, p);
2711 return E_NOTIMPL;
2714 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2715 HTMLDocument4_QueryInterface,
2716 HTMLDocument4_AddRef,
2717 HTMLDocument4_Release,
2718 HTMLDocument4_GetTypeInfoCount,
2719 HTMLDocument4_GetTypeInfo,
2720 HTMLDocument4_GetIDsOfNames,
2721 HTMLDocument4_Invoke,
2722 HTMLDocument4_focus,
2723 HTMLDocument4_hasFocus,
2724 HTMLDocument4_put_onselectionchange,
2725 HTMLDocument4_get_onselectionchange,
2726 HTMLDocument4_get_namespace,
2727 HTMLDocument4_createDocumentFromUrl,
2728 HTMLDocument4_put_media,
2729 HTMLDocument4_get_media,
2730 HTMLDocument4_createEventObject,
2731 HTMLDocument4_fireEvent,
2732 HTMLDocument4_createRenderStyle,
2733 HTMLDocument4_put_oncontrolselect,
2734 HTMLDocument4_get_oncontrolselect,
2735 HTMLDocument4_get_URLEncoded
2738 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2740 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2743 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2744 REFIID riid, void **ppv)
2746 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2747 return htmldoc_query_interface(This, riid, ppv);
2750 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2752 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2753 return htmldoc_addref(This);
2756 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2758 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2759 return htmldoc_release(This);
2762 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2764 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2765 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2768 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2769 LCID lcid, ITypeInfo **ppTInfo)
2771 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2772 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2775 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2776 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2778 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2779 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2780 rgDispId);
2783 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2784 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2785 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2787 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2788 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2789 pDispParams, pVarResult, pExcepInfo, puArgErr);
2792 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2794 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2796 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2798 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
2801 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2803 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2805 TRACE("(%p)->(%p)\n", This, p);
2807 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
2810 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2812 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2813 FIXME("(%p)->(%p)\n", This, p);
2814 return E_NOTIMPL;
2817 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2819 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2820 HTMLDocumentNode *doc_node = This->doc_node;
2822 TRACE("(%p)->(%p)\n", This, p);
2824 if(!doc_node->dom_implementation) {
2825 HRESULT hres;
2827 hres = create_dom_implementation(&doc_node->dom_implementation);
2828 if(FAILED(hres))
2829 return hres;
2832 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2833 *p = doc_node->dom_implementation;
2834 return S_OK;
2837 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2838 IHTMLDOMAttribute **ppattribute)
2840 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2841 HTMLDOMAttribute *attr;
2842 HRESULT hres;
2844 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2846 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
2847 if(FAILED(hres))
2848 return hres;
2850 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2851 return S_OK;
2854 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2855 IHTMLDOMNode **ppRetNode)
2857 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2858 nsIDOMComment *nscomment;
2859 HTMLElement *elem;
2860 nsAString str;
2861 nsresult nsres;
2862 HRESULT hres;
2864 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2866 if(!This->doc_node->nsdoc) {
2867 WARN("NULL nsdoc\n");
2868 return E_UNEXPECTED;
2871 nsAString_InitDepend(&str, bstrdata);
2872 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2873 nsAString_Finish(&str);
2874 if(NS_FAILED(nsres)) {
2875 ERR("CreateTextNode failed: %08x\n", nsres);
2876 return E_FAIL;
2879 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2880 nsIDOMComment_Release(nscomment);
2881 if(FAILED(hres))
2882 return hres;
2884 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2885 return S_OK;
2888 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2890 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2892 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2894 return set_doc_event(This, EVENTID_FOCUSIN, &v);
2897 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2899 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2901 TRACE("(%p)->(%p)\n", This, p);
2903 return get_doc_event(This, EVENTID_FOCUSIN, p);
2906 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2908 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2910 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2912 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
2915 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2917 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2919 TRACE("(%p)->(%p)\n", This, p);
2921 return get_doc_event(This, EVENTID_FOCUSOUT, p);
2924 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2926 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2927 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2928 return E_NOTIMPL;
2931 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2933 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2934 FIXME("(%p)->(%p)\n", This, p);
2935 return E_NOTIMPL;
2938 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2940 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2941 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2942 return E_NOTIMPL;
2945 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2947 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2948 FIXME("(%p)->(%p)\n", This, p);
2949 return E_NOTIMPL;
2952 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2954 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2955 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2956 return E_NOTIMPL;
2959 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2961 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2962 FIXME("(%p)->(%p)\n", This, p);
2963 return E_NOTIMPL;
2966 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2968 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2969 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2970 return E_NOTIMPL;
2973 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2975 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2976 FIXME("(%p)->(%p)\n", This, p);
2977 return E_NOTIMPL;
2980 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2982 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2984 static const WCHAR BackCompatW[] = {'B','a','c','k','C','o','m','p','a','t',0};
2985 static const WCHAR CSS1CompatW[] = {'C','S','S','1','C','o','m','p','a','t',0};
2987 TRACE("(%p)->(%p)\n", This, p);
2989 *p = SysAllocString(This->doc_node->document_mode <= COMPAT_MODE_IE5 ? BackCompatW : CSS1CompatW);
2990 return *p ? S_OK : E_OUTOFMEMORY;
2993 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
2994 HTMLDocument5_QueryInterface,
2995 HTMLDocument5_AddRef,
2996 HTMLDocument5_Release,
2997 HTMLDocument5_GetTypeInfoCount,
2998 HTMLDocument5_GetTypeInfo,
2999 HTMLDocument5_GetIDsOfNames,
3000 HTMLDocument5_Invoke,
3001 HTMLDocument5_put_onmousewheel,
3002 HTMLDocument5_get_onmousewheel,
3003 HTMLDocument5_get_doctype,
3004 HTMLDocument5_get_implementation,
3005 HTMLDocument5_createAttribute,
3006 HTMLDocument5_createComment,
3007 HTMLDocument5_put_onfocusin,
3008 HTMLDocument5_get_onfocusin,
3009 HTMLDocument5_put_onfocusout,
3010 HTMLDocument5_get_onfocusout,
3011 HTMLDocument5_put_onactivate,
3012 HTMLDocument5_get_onactivate,
3013 HTMLDocument5_put_ondeactivate,
3014 HTMLDocument5_get_ondeactivate,
3015 HTMLDocument5_put_onbeforeactivate,
3016 HTMLDocument5_get_onbeforeactivate,
3017 HTMLDocument5_put_onbeforedeactivate,
3018 HTMLDocument5_get_onbeforedeactivate,
3019 HTMLDocument5_get_compatMode
3022 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3024 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
3027 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
3028 REFIID riid, void **ppv)
3030 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3031 return htmldoc_query_interface(This, riid, ppv);
3034 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3036 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3037 return htmldoc_addref(This);
3040 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3042 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3043 return htmldoc_release(This);
3046 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3048 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3049 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3052 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
3053 LCID lcid, ITypeInfo **ppTInfo)
3055 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3056 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3059 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
3060 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3062 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3063 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3064 rgDispId);
3067 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
3068 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3069 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3071 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3072 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3073 pDispParams, pVarResult, pExcepInfo, puArgErr);
3076 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3077 IHTMLDocumentCompatibleInfoCollection **p)
3079 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3080 FIXME("(%p)->(%p)\n", This, p);
3081 return E_NOTIMPL;
3084 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3086 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3088 TRACE("(%p)->(%p)\n", This, p);
3090 if(!This->doc_node) {
3091 FIXME("NULL doc_node\n");
3092 return E_UNEXPECTED;
3095 V_VT(p) = VT_R4;
3096 V_R4(p) = compat_mode_info[This->doc_node->document_mode].document_mode;
3097 return S_OK;
3100 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3101 VARIANT *p)
3103 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3104 FIXME("(%p)->(%p)\n", This, p);
3105 return E_NOTIMPL;
3108 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3110 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3111 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3112 return E_NOTIMPL;
3115 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3116 VARIANT *p)
3118 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3119 FIXME("(%p)->(%p)\n", This, p);
3120 return E_NOTIMPL;
3123 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3125 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3126 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3127 return E_NOTIMPL;
3130 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3131 BSTR bstrId, IHTMLElement2 **p)
3133 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3134 nsIDOMElement *nselem;
3135 HTMLElement *elem;
3136 nsAString nsstr;
3137 nsresult nsres;
3138 HRESULT hres;
3140 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3143 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3144 * not search for name attributes, so we may simply let Gecko do the right thing.
3147 if(!This->doc_node->nsdoc) {
3148 FIXME("Not a document\n");
3149 return E_FAIL;
3152 nsAString_InitDepend(&nsstr, bstrId);
3153 nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &nsstr, &nselem);
3154 nsAString_Finish(&nsstr);
3155 if(NS_FAILED(nsres)) {
3156 ERR("GetElementById failed: %08x\n", nsres);
3157 return E_FAIL;
3160 if(!nselem) {
3161 *p = NULL;
3162 return S_OK;
3165 hres = get_elem(This->doc_node, nselem, &elem);
3166 nsIDOMElement_Release(nselem);
3167 if(FAILED(hres))
3168 return hres;
3170 *p = &elem->IHTMLElement2_iface;
3171 return S_OK;
3174 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3176 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3177 FIXME("(%p)->()\n", This);
3178 return E_NOTIMPL;
3181 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3182 HTMLDocument6_QueryInterface,
3183 HTMLDocument6_AddRef,
3184 HTMLDocument6_Release,
3185 HTMLDocument6_GetTypeInfoCount,
3186 HTMLDocument6_GetTypeInfo,
3187 HTMLDocument6_GetIDsOfNames,
3188 HTMLDocument6_Invoke,
3189 HTMLDocument6_get_compatible,
3190 HTMLDocument6_get_documentMode,
3191 HTMLDocument6_put_onstorage,
3192 HTMLDocument6_get_onstorage,
3193 HTMLDocument6_put_onstoragecommit,
3194 HTMLDocument6_get_onstoragecommit,
3195 HTMLDocument6_getElementById,
3196 HTMLDocument6_updateSettings
3199 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3201 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3204 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3206 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3207 return htmldoc_query_interface(This, riid, ppv);
3210 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3212 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3213 return htmldoc_addref(This);
3216 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3218 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3219 return htmldoc_release(This);
3222 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3224 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3225 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3228 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3229 LCID lcid, ITypeInfo **ppTInfo)
3231 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3232 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3235 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3236 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3238 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3239 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3240 rgDispId);
3243 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3244 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3245 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3247 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3248 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3249 pDispParams, pVarResult, pExcepInfo, puArgErr);
3252 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3254 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3256 TRACE("(%p)->(%p)\n", This, p);
3258 *p = &This->window->base.IHTMLWindow2_iface;
3259 IHTMLWindow2_AddRef(*p);
3260 return S_OK;
3263 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3265 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3266 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3267 return E_NOTIMPL;
3270 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3272 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3273 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3274 return E_NOTIMPL;
3277 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3278 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3280 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3281 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3282 return E_NOTIMPL;
3285 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3287 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3288 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3289 return E_NOTIMPL;
3292 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3293 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3295 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3296 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3297 return E_NOTIMPL;
3300 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3302 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3303 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3304 return E_NOTIMPL;
3307 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3309 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3310 FIXME("(%p)->(%p)\n", This, p);
3311 return E_NOTIMPL;
3314 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3316 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3317 nsAString charset_str;
3318 nsresult nsres;
3320 TRACE("(%p)->(%p)\n", This, p);
3322 if(!This->doc_node->nsdoc) {
3323 FIXME("NULL nsdoc\n");
3324 return E_FAIL;
3327 nsAString_Init(&charset_str, NULL);
3328 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
3329 return return_nsstr(nsres, &charset_str, p);
3332 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3334 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3336 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3338 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3341 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3343 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3345 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3347 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3350 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3352 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3353 nsIDOMNodeList *nslist;
3354 nsAString nsstr;
3355 nsresult nsres;
3357 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3359 if(!This->doc_node->nsdoc) {
3360 FIXME("NULL nsdoc not supported\n");
3361 return E_NOTIMPL;
3364 nsAString_InitDepend(&nsstr, v);
3365 nsres = nsIDOMHTMLDocument_GetElementsByClassName(This->doc_node->nsdoc, &nsstr, &nslist);
3366 nsAString_Finish(&nsstr);
3367 if(FAILED(nsres)) {
3368 ERR("GetElementByClassName failed: %08x\n", nsres);
3369 return E_FAIL;
3373 *pel = create_collection_from_nodelist(This->doc_node, nslist);
3374 nsIDOMNodeList_Release(nslist);
3375 return S_OK;
3378 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3379 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3381 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3382 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3383 return E_NOTIMPL;
3386 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3388 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3389 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3390 return E_NOTIMPL;
3393 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3395 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3396 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3397 return E_NOTIMPL;
3400 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3402 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3403 FIXME("(%p)->(%p)\n", This, p);
3404 return E_NOTIMPL;
3407 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3409 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3411 TRACE("(%p)->(%p)\n", This, p);
3413 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3416 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3418 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3419 FIXME("(%p)->(%p)\n", This, p);
3420 return E_NOTIMPL;
3423 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3425 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3426 FIXME("(%p)->(%p)\n", This, p);
3427 return E_NOTIMPL;
3430 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3432 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3433 FIXME("(%p)->(%x)\n", This, v);
3434 return E_NOTIMPL;
3437 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3439 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3440 FIXME("(%p)->(%p)\n", This, p);
3441 return E_NOTIMPL;
3444 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3446 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3447 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3448 return E_NOTIMPL;
3451 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3453 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3454 FIXME("(%p)->(%p)\n", This, p);
3455 return E_NOTIMPL;
3458 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3460 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3461 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3462 return E_NOTIMPL;
3465 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3467 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3469 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3471 return set_doc_event(This, EVENTID_ABORT, &v);
3474 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3476 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3478 TRACE("(%p)->(%p)\n", This, p);
3480 return get_doc_event(This, EVENTID_ABORT, p);
3483 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3485 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3487 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3489 return set_doc_event(This, EVENTID_BLUR, &v);
3492 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3494 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3496 TRACE("(%p)->(%p)\n", This, p);
3498 return get_doc_event(This, EVENTID_BLUR, p);
3501 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3503 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3504 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3505 return E_NOTIMPL;
3508 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3510 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3511 FIXME("(%p)->(%p)\n", This, p);
3512 return E_NOTIMPL;
3515 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3517 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3518 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3519 return E_NOTIMPL;
3522 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3524 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3525 FIXME("(%p)->(%p)\n", This, p);
3526 return E_NOTIMPL;
3529 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3531 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3533 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3535 return set_doc_event(This, EVENTID_CHANGE, &v);
3538 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3540 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3542 TRACE("(%p)->(%p)\n", This, p);
3544 return get_doc_event(This, EVENTID_CHANGE, p);
3547 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3549 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3551 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3553 return set_doc_event(This, EVENTID_DRAG, &v);
3556 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3558 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3560 TRACE("(%p)->(%p)\n", This, p);
3562 return get_doc_event(This, EVENTID_DRAG, p);
3565 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3567 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3568 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3569 return E_NOTIMPL;
3572 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3574 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3575 FIXME("(%p)->(%p)\n", This, p);
3576 return E_NOTIMPL;
3579 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3581 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3582 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3583 return E_NOTIMPL;
3586 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3588 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3589 FIXME("(%p)->(%p)\n", This, p);
3590 return E_NOTIMPL;
3593 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3595 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3596 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3597 return E_NOTIMPL;
3600 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3602 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3603 FIXME("(%p)->(%p)\n", This, p);
3604 return E_NOTIMPL;
3607 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3609 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3610 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3611 return E_NOTIMPL;
3614 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3616 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3617 FIXME("(%p)->(%p)\n", This, p);
3618 return E_NOTIMPL;
3621 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3623 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3624 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3625 return E_NOTIMPL;
3628 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3630 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3631 FIXME("(%p)->(%p)\n", This, p);
3632 return E_NOTIMPL;
3635 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3637 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3638 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3639 return E_NOTIMPL;
3642 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
3644 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3645 FIXME("(%p)->(%p)\n", This, p);
3646 return E_NOTIMPL;
3649 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
3651 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3652 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3653 return E_NOTIMPL;
3656 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
3658 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3659 FIXME("(%p)->(%p)\n", This, p);
3660 return E_NOTIMPL;
3663 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
3665 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3666 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3667 return E_NOTIMPL;
3670 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
3672 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3673 FIXME("(%p)->(%p)\n", This, p);
3674 return E_NOTIMPL;
3677 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
3679 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3681 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3683 return set_doc_event(This, EVENTID_ERROR, &v);
3686 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
3688 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3690 TRACE("(%p)->(%p)\n", This, p);
3692 return get_doc_event(This, EVENTID_ERROR, p);
3695 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
3697 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3699 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3701 return set_doc_event(This, EVENTID_FOCUS, &v);
3704 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
3706 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3708 TRACE("(%p)->(%p)\n", This, p);
3710 return get_doc_event(This, EVENTID_FOCUS, p);
3713 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
3715 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3716 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3717 return E_NOTIMPL;
3720 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
3722 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3723 FIXME("(%p)->(%p)\n", This, p);
3724 return E_NOTIMPL;
3727 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
3729 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3731 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3733 return set_doc_event(This, EVENTID_LOAD, &v);
3736 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
3738 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3740 TRACE("(%p)->(%p)\n", This, p);
3742 return get_doc_event(This, EVENTID_LOAD, p);
3745 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
3747 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3748 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3749 return E_NOTIMPL;
3752 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
3754 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3755 FIXME("(%p)->(%p)\n", This, p);
3756 return E_NOTIMPL;
3759 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
3761 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3762 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3763 return E_NOTIMPL;
3766 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
3768 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3769 FIXME("(%p)->(%p)\n", This, p);
3770 return E_NOTIMPL;
3773 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
3775 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3776 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3777 return E_NOTIMPL;
3780 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
3782 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3783 FIXME("(%p)->(%p)\n", This, p);
3784 return E_NOTIMPL;
3787 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
3789 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3790 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3791 return E_NOTIMPL;
3794 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
3796 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3797 FIXME("(%p)->(%p)\n", This, p);
3798 return E_NOTIMPL;
3801 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
3803 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3804 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3805 return E_NOTIMPL;
3808 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
3810 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3811 FIXME("(%p)->(%p)\n", This, p);
3812 return E_NOTIMPL;
3815 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
3817 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3818 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3819 return E_NOTIMPL;
3822 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
3824 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3825 FIXME("(%p)->(%p)\n", This, p);
3826 return E_NOTIMPL;
3829 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
3831 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3832 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3833 return E_NOTIMPL;
3836 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
3838 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3839 FIXME("(%p)->(%p)\n", This, p);
3840 return E_NOTIMPL;
3843 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
3845 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3846 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3847 return E_NOTIMPL;
3850 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
3852 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3853 FIXME("(%p)->(%p)\n", This, p);
3854 return E_NOTIMPL;
3857 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
3859 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3860 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3861 return E_NOTIMPL;
3864 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
3866 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3867 FIXME("(%p)->(%p)\n", This, p);
3868 return E_NOTIMPL;
3871 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
3873 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3875 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3877 return set_doc_event(This, EVENTID_SCROLL, &v);
3880 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
3882 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3884 TRACE("(%p)->(%p)\n", This, p);
3886 return get_doc_event(This, EVENTID_SCROLL, p);
3889 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
3891 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3892 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3893 return E_NOTIMPL;
3896 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
3898 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3899 FIXME("(%p)->(%p)\n", This, p);
3900 return E_NOTIMPL;
3903 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
3905 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3906 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3907 return E_NOTIMPL;
3910 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
3912 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3913 FIXME("(%p)->(%p)\n", This, p);
3914 return E_NOTIMPL;
3917 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
3919 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3920 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3921 return E_NOTIMPL;
3924 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
3926 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3927 FIXME("(%p)->(%p)\n", This, p);
3928 return E_NOTIMPL;
3931 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
3933 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3934 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3935 return E_NOTIMPL;
3938 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
3940 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3941 FIXME("(%p)->(%p)\n", This, p);
3942 return E_NOTIMPL;
3945 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
3947 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3949 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3951 return set_doc_event(This, EVENTID_SUBMIT, &v);
3954 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
3956 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3958 TRACE("(%p)->(%p)\n", This, p);
3960 return get_doc_event(This, EVENTID_SUBMIT, p);
3963 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
3965 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3966 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3967 return E_NOTIMPL;
3970 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
3972 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3973 FIXME("(%p)->(%p)\n", This, p);
3974 return E_NOTIMPL;
3977 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
3979 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3980 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3981 return E_NOTIMPL;
3984 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
3986 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3987 FIXME("(%p)->(%p)\n", This, p);
3988 return E_NOTIMPL;
3991 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
3993 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3994 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3995 return E_NOTIMPL;
3998 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4000 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4001 FIXME("(%p)->(%p)\n", This, p);
4002 return E_NOTIMPL;
4005 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4007 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4008 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4009 return E_NOTIMPL;
4012 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4014 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4015 FIXME("(%p)->(%p)\n", This, p);
4016 return E_NOTIMPL;
4019 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4021 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4022 FIXME("(%p)\n", This);
4023 return E_NOTIMPL;
4026 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4027 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4029 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4030 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4031 return E_NOTIMPL;
4034 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4036 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4038 TRACE("(%p)->(%p)\n", This, p);
4040 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4043 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4045 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4046 FIXME("(%p)->(%p)\n", This, v);
4047 return E_NOTIMPL;
4050 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4052 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4054 TRACE("(%p)->(%p)\n", This, p);
4056 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4059 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4061 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4062 nsIDOMHTMLHeadElement *nshead;
4063 nsIDOMElement *nselem;
4064 HTMLElement *elem;
4065 nsresult nsres;
4066 HRESULT hres;
4068 TRACE("(%p)->(%p)\n", This, p);
4070 if(!This->doc_node->nsdoc) {
4071 FIXME("No document\n");
4072 return E_FAIL;
4075 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &nshead);
4076 assert(nsres == NS_OK);
4078 if(!nshead) {
4079 *p = NULL;
4080 return S_OK;
4083 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4084 nsIDOMHTMLHeadElement_Release(nshead);
4085 assert(nsres == NS_OK);
4087 hres = get_elem(This->doc_node, nselem, &elem);
4088 nsIDOMElement_Release(nselem);
4089 if(FAILED(hres))
4090 return hres;
4092 *p = &elem->IHTMLElement_iface;
4093 return S_OK;
4096 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4097 HTMLDocument7_QueryInterface,
4098 HTMLDocument7_AddRef,
4099 HTMLDocument7_Release,
4100 HTMLDocument7_GetTypeInfoCount,
4101 HTMLDocument7_GetTypeInfo,
4102 HTMLDocument7_GetIDsOfNames,
4103 HTMLDocument7_Invoke,
4104 HTMLDocument7_get_defaultView,
4105 HTMLDocument7_createCDATASection,
4106 HTMLDocument7_getSelection,
4107 HTMLDocument7_getElementsByTagNameNS,
4108 HTMLDocument7_createElementNS,
4109 HTMLDocument7_createAttributeNS,
4110 HTMLDocument7_put_onmsthumbnailclick,
4111 HTMLDocument7_get_onmsthumbnailclick,
4112 HTMLDocument7_get_characterSet,
4113 HTMLDocument7_createElement,
4114 HTMLDocument7_createAttribute,
4115 HTMLDocument7_getElementsByClassName,
4116 HTMLDocument7_createProcessingInstruction,
4117 HTMLDocument7_adoptNode,
4118 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4119 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4120 HTMLDocument7_get_all,
4121 HTMLDocument7_get_inputEncoding,
4122 HTMLDocument7_get_xmlEncoding,
4123 HTMLDocument7_put_xmlStandalone,
4124 HTMLDocument7_get_xmlStandalone,
4125 HTMLDocument7_put_xmlVersion,
4126 HTMLDocument7_get_xmlVersion,
4127 HTMLDocument7_hasAttributes,
4128 HTMLDocument7_put_onabort,
4129 HTMLDocument7_get_onabort,
4130 HTMLDocument7_put_onblur,
4131 HTMLDocument7_get_onblur,
4132 HTMLDocument7_put_oncanplay,
4133 HTMLDocument7_get_oncanplay,
4134 HTMLDocument7_put_oncanplaythrough,
4135 HTMLDocument7_get_oncanplaythrough,
4136 HTMLDocument7_put_onchange,
4137 HTMLDocument7_get_onchange,
4138 HTMLDocument7_put_ondrag,
4139 HTMLDocument7_get_ondrag,
4140 HTMLDocument7_put_ondragend,
4141 HTMLDocument7_get_ondragend,
4142 HTMLDocument7_put_ondragenter,
4143 HTMLDocument7_get_ondragenter,
4144 HTMLDocument7_put_ondragleave,
4145 HTMLDocument7_get_ondragleave,
4146 HTMLDocument7_put_ondragover,
4147 HTMLDocument7_get_ondragover,
4148 HTMLDocument7_put_ondrop,
4149 HTMLDocument7_get_ondrop,
4150 HTMLDocument7_put_ondurationchange,
4151 HTMLDocument7_get_ondurationchange,
4152 HTMLDocument7_put_onemptied,
4153 HTMLDocument7_get_onemptied,
4154 HTMLDocument7_put_onended,
4155 HTMLDocument7_get_onended,
4156 HTMLDocument7_put_onerror,
4157 HTMLDocument7_get_onerror,
4158 HTMLDocument7_put_onfocus,
4159 HTMLDocument7_get_onfocus,
4160 HTMLDocument7_put_oninput,
4161 HTMLDocument7_get_oninput,
4162 HTMLDocument7_put_onload,
4163 HTMLDocument7_get_onload,
4164 HTMLDocument7_put_onloadeddata,
4165 HTMLDocument7_get_onloadeddata,
4166 HTMLDocument7_put_onloadedmetadata,
4167 HTMLDocument7_get_onloadedmetadata,
4168 HTMLDocument7_put_onloadstart,
4169 HTMLDocument7_get_onloadstart,
4170 HTMLDocument7_put_onpause,
4171 HTMLDocument7_get_onpause,
4172 HTMLDocument7_put_onplay,
4173 HTMLDocument7_get_onplay,
4174 HTMLDocument7_put_onplaying,
4175 HTMLDocument7_get_onplaying,
4176 HTMLDocument7_put_onprogress,
4177 HTMLDocument7_get_onprogress,
4178 HTMLDocument7_put_onratechange,
4179 HTMLDocument7_get_onratechange,
4180 HTMLDocument7_put_onreset,
4181 HTMLDocument7_get_onreset,
4182 HTMLDocument7_put_onscroll,
4183 HTMLDocument7_get_onscroll,
4184 HTMLDocument7_put_onseekend,
4185 HTMLDocument7_get_onseekend,
4186 HTMLDocument7_put_onseeking,
4187 HTMLDocument7_get_onseeking,
4188 HTMLDocument7_put_onselect,
4189 HTMLDocument7_get_onselect,
4190 HTMLDocument7_put_onstalled,
4191 HTMLDocument7_get_onstalled,
4192 HTMLDocument7_put_onsubmit,
4193 HTMLDocument7_get_onsubmit,
4194 HTMLDocument7_put_onsuspend,
4195 HTMLDocument7_get_onsuspend,
4196 HTMLDocument7_put_ontimeupdate,
4197 HTMLDocument7_get_ontimeupdate,
4198 HTMLDocument7_put_onvolumechange,
4199 HTMLDocument7_get_onvolumechange,
4200 HTMLDocument7_put_onwaiting,
4201 HTMLDocument7_get_onwaiting,
4202 HTMLDocument7_normalize,
4203 HTMLDocument7_importNode,
4204 HTMLDocument7_get_parentWindow,
4205 HTMLDocument7_put_body,
4206 HTMLDocument7_get_body,
4207 HTMLDocument7_get_head
4210 static inline HTMLDocument *impl_from_IDocumentSelector(IDocumentSelector *iface)
4212 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentSelector_iface);
4215 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4217 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4218 return htmldoc_query_interface(This, riid, ppv);
4221 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4223 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4224 return htmldoc_addref(This);
4227 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4229 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4230 return htmldoc_release(This);
4233 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4235 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4236 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4239 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4240 LCID lcid, ITypeInfo **ppTInfo)
4242 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4243 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4246 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4247 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4249 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4250 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4251 rgDispId);
4254 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4255 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4257 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4258 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4259 pDispParams, pVarResult, pExcepInfo, puArgErr);
4262 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4264 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4265 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4266 return E_NOTIMPL;
4269 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4271 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4272 nsIDOMNodeList *node_list;
4273 nsAString nsstr;
4274 nsresult nsres;
4276 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4278 nsAString_InitDepend(&nsstr, v);
4279 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &nsstr, &node_list);
4280 nsAString_Finish(&nsstr);
4281 if(NS_FAILED(nsres)) {
4282 ERR("QuerySelectorAll failed: %08x\n", nsres);
4283 return E_FAIL;
4286 *pel = create_child_collection(This->doc_node, node_list);
4287 nsIDOMNodeList_Release(node_list);
4288 return *pel ? S_OK : E_OUTOFMEMORY;
4291 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4292 DocumentSelector_QueryInterface,
4293 DocumentSelector_AddRef,
4294 DocumentSelector_Release,
4295 DocumentSelector_GetTypeInfoCount,
4296 DocumentSelector_GetTypeInfo,
4297 DocumentSelector_GetIDsOfNames,
4298 DocumentSelector_Invoke,
4299 DocumentSelector_querySelector,
4300 DocumentSelector_querySelectorAll
4303 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4305 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4307 if(This->window)
4308 update_doc_cp_events(This->doc_node, cp);
4311 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4313 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4316 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4318 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4319 return htmldoc_query_interface(This, riid, ppv);
4322 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4324 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4325 return htmldoc_addref(This);
4328 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4330 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4331 return htmldoc_release(This);
4334 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4336 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4337 return S_FALSE;
4340 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4341 SupportErrorInfo_QueryInterface,
4342 SupportErrorInfo_AddRef,
4343 SupportErrorInfo_Release,
4344 SupportErrorInfo_InterfaceSupportsErrorInfo
4347 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4349 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4352 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4354 nsIDOMNodeList *node_list;
4355 nsAString name_str;
4356 UINT32 len;
4357 unsigned i;
4358 nsresult nsres;
4360 if(!This->nsdoc)
4361 return DISP_E_UNKNOWNNAME;
4363 nsAString_InitDepend(&name_str, name);
4364 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4365 nsAString_Finish(&name_str);
4366 if(NS_FAILED(nsres))
4367 return E_FAIL;
4369 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4370 nsIDOMNodeList_Release(node_list);
4371 if(NS_FAILED(nsres))
4372 return E_FAIL;
4374 if(!len)
4375 return DISP_E_UNKNOWNNAME;
4377 for(i=0; i < This->elem_vars_cnt; i++) {
4378 if(!strcmpW(name, This->elem_vars[i])) {
4379 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4380 return S_OK;
4384 if(This->elem_vars_cnt == This->elem_vars_size) {
4385 WCHAR **new_vars;
4387 if(This->elem_vars_size) {
4388 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4389 if(!new_vars)
4390 return E_OUTOFMEMORY;
4391 This->elem_vars_size *= 2;
4392 }else {
4393 new_vars = heap_alloc(16*sizeof(WCHAR*));
4394 if(!new_vars)
4395 return E_OUTOFMEMORY;
4396 This->elem_vars_size = 16;
4399 This->elem_vars = new_vars;
4402 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4403 if(!This->elem_vars[This->elem_vars_cnt])
4404 return E_OUTOFMEMORY;
4406 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4407 return S_OK;
4410 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4412 HTMLDocument *This = impl_from_IDispatchEx(iface);
4414 return htmldoc_query_interface(This, riid, ppv);
4417 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4419 HTMLDocument *This = impl_from_IDispatchEx(iface);
4421 return htmldoc_addref(This);
4424 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4426 HTMLDocument *This = impl_from_IDispatchEx(iface);
4428 return htmldoc_release(This);
4431 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4433 HTMLDocument *This = impl_from_IDispatchEx(iface);
4435 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4438 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4439 LCID lcid, ITypeInfo **ppTInfo)
4441 HTMLDocument *This = impl_from_IDispatchEx(iface);
4443 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4446 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4447 LPOLESTR *rgszNames, UINT cNames,
4448 LCID lcid, DISPID *rgDispId)
4450 HTMLDocument *This = impl_from_IDispatchEx(iface);
4452 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4455 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4456 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4457 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4459 HTMLDocument *This = impl_from_IDispatchEx(iface);
4461 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4462 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4464 switch(dispIdMember) {
4465 case DISPID_READYSTATE:
4466 TRACE("DISPID_READYSTATE\n");
4468 if(!(wFlags & DISPATCH_PROPERTYGET))
4469 return E_INVALIDARG;
4471 V_VT(pVarResult) = VT_I4;
4472 V_I4(pVarResult) = This->window->readystate;
4473 return S_OK;
4476 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
4477 pVarResult, pExcepInfo, puArgErr);
4480 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4482 HTMLDocument *This = impl_from_IDispatchEx(iface);
4483 HRESULT hres;
4485 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4486 if(hres != DISP_E_UNKNOWNNAME)
4487 return hres;
4489 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4492 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4493 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4495 HTMLDocument *This = impl_from_IDispatchEx(iface);
4497 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
4498 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
4499 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4502 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4505 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4507 HTMLDocument *This = impl_from_IDispatchEx(iface);
4509 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4512 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4514 HTMLDocument *This = impl_from_IDispatchEx(iface);
4516 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4519 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4521 HTMLDocument *This = impl_from_IDispatchEx(iface);
4523 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4526 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4528 HTMLDocument *This = impl_from_IDispatchEx(iface);
4530 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4533 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4535 HTMLDocument *This = impl_from_IDispatchEx(iface);
4537 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
4540 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
4542 HTMLDocument *This = impl_from_IDispatchEx(iface);
4544 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
4547 static const IDispatchExVtbl DocDispatchExVtbl = {
4548 DocDispatchEx_QueryInterface,
4549 DocDispatchEx_AddRef,
4550 DocDispatchEx_Release,
4551 DocDispatchEx_GetTypeInfoCount,
4552 DocDispatchEx_GetTypeInfo,
4553 DocDispatchEx_GetIDsOfNames,
4554 DocDispatchEx_Invoke,
4555 DocDispatchEx_GetDispID,
4556 DocDispatchEx_InvokeEx,
4557 DocDispatchEx_DeleteMemberByName,
4558 DocDispatchEx_DeleteMemberByDispID,
4559 DocDispatchEx_GetMemberProperties,
4560 DocDispatchEx_GetMemberName,
4561 DocDispatchEx_GetNextDispID,
4562 DocDispatchEx_GetNameSpaceParent
4565 static inline HTMLDocument *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
4567 return CONTAINING_RECORD(iface, HTMLDocument, IProvideMultipleClassInfo_iface);
4570 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
4571 REFIID riid, void **ppv)
4573 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4574 return htmldoc_query_interface(This, riid, ppv);
4577 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
4579 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4580 return htmldoc_addref(This);
4583 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
4585 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4586 return htmldoc_release(This);
4589 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
4591 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4592 TRACE("(%p)->(%p)\n", This, ppTI);
4593 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
4596 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
4598 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4599 FIXME("(%p)->(%u %p)\n", This, dwGuidKind, pGUID);
4600 return E_NOTIMPL;
4603 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
4605 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4606 FIXME("(%p)->(%p)\n", This, pcti);
4607 *pcti = 1;
4608 return S_OK;
4611 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
4612 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
4614 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4615 FIXME("(%p)->(%u %x %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
4616 return E_NOTIMPL;
4619 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
4620 ProvideClassInfo_QueryInterface,
4621 ProvideClassInfo_AddRef,
4622 ProvideClassInfo_Release,
4623 ProvideClassInfo_GetClassInfo,
4624 ProvideClassInfo2_GetGUID,
4625 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
4626 ProvideMultipleClassInfo_GetInfoOfIndex
4629 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
4631 *ppv = NULL;
4633 if(IsEqualGUID(&IID_IUnknown, riid))
4634 *ppv = &This->IHTMLDocument2_iface;
4635 else if(IsEqualGUID(&IID_IDispatch, riid))
4636 *ppv = &This->IDispatchEx_iface;
4637 else if(IsEqualGUID(&IID_IDispatchEx, riid))
4638 *ppv = &This->IDispatchEx_iface;
4639 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
4640 *ppv = &This->IHTMLDocument2_iface;
4641 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
4642 *ppv = &This->IHTMLDocument2_iface;
4643 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
4644 *ppv = &This->IHTMLDocument3_iface;
4645 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
4646 *ppv = &This->IHTMLDocument4_iface;
4647 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
4648 *ppv = &This->IHTMLDocument5_iface;
4649 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
4650 *ppv = &This->IHTMLDocument6_iface;
4651 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
4652 *ppv = &This->IHTMLDocument7_iface;
4653 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
4654 *ppv = &This->IDocumentSelector_iface;
4655 else if(IsEqualGUID(&IID_IPersist, riid))
4656 *ppv = &This->IPersistFile_iface;
4657 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
4658 *ppv = &This->IPersistMoniker_iface;
4659 else if(IsEqualGUID(&IID_IPersistFile, riid))
4660 *ppv = &This->IPersistFile_iface;
4661 else if(IsEqualGUID(&IID_IMonikerProp, riid))
4662 *ppv = &This->IMonikerProp_iface;
4663 else if(IsEqualGUID(&IID_IOleObject, riid))
4664 *ppv = &This->IOleObject_iface;
4665 else if(IsEqualGUID(&IID_IOleDocument, riid))
4666 *ppv = &This->IOleDocument_iface;
4667 else if(IsEqualGUID(&IID_IOleDocumentView, riid))
4668 *ppv = &This->IOleDocumentView_iface;
4669 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
4670 *ppv = &This->IOleInPlaceActiveObject_iface;
4671 else if(IsEqualGUID(&IID_IViewObject, riid))
4672 *ppv = &This->IViewObjectEx_iface;
4673 else if(IsEqualGUID(&IID_IViewObject2, riid))
4674 *ppv = &This->IViewObjectEx_iface;
4675 else if(IsEqualGUID(&IID_IViewObjectEx, riid))
4676 *ppv = &This->IViewObjectEx_iface;
4677 else if(IsEqualGUID(&IID_IOleWindow, riid))
4678 *ppv = &This->IOleInPlaceActiveObject_iface;
4679 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
4680 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4681 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
4682 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4683 else if(IsEqualGUID(&IID_IServiceProvider, riid))
4684 *ppv = &This->IServiceProvider_iface;
4685 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
4686 *ppv = &This->IOleCommandTarget_iface;
4687 else if(IsEqualGUID(&IID_IOleControl, riid))
4688 *ppv = &This->IOleControl_iface;
4689 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
4690 *ppv = &This->IHlinkTarget_iface;
4691 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
4692 *ppv = &This->cp_container.IConnectionPointContainer_iface;
4693 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
4694 *ppv = &This->IPersistStreamInit_iface;
4695 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
4696 *ppv = &This->IHTMLDocument2_iface;
4697 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
4698 *ppv = &This->ISupportErrorInfo_iface;
4699 else if(IsEqualGUID(&IID_IPersistHistory, riid))
4700 *ppv = &This->IPersistHistory_iface;
4701 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
4702 *ppv = &This->IObjectWithSite_iface;
4703 else if(IsEqualGUID(&IID_IOleContainer, riid))
4704 *ppv = &This->IOleContainer_iface;
4705 else if(IsEqualGUID(&IID_IObjectSafety, riid))
4706 *ppv = &This->IObjectSafety_iface;
4707 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
4708 *ppv = &This->IProvideMultipleClassInfo_iface;
4709 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
4710 *ppv = &This->IProvideMultipleClassInfo_iface;
4711 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
4712 *ppv = &This->IProvideMultipleClassInfo_iface;
4713 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
4714 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
4715 *ppv = NULL;
4716 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
4717 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
4718 *ppv = NULL;
4719 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
4720 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
4721 *ppv = NULL;
4722 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
4723 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
4724 *ppv = NULL;
4725 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
4726 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
4727 *ppv = NULL;
4728 }else {
4729 return FALSE;
4732 if(*ppv)
4733 IUnknown_AddRef((IUnknown*)*ppv);
4734 return TRUE;
4737 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
4739 static const cpc_entry_t HTMLDocument_cpc[] = {
4740 {&IID_IDispatch, &HTMLDocumentEvents_data},
4741 {&IID_IPropertyNotifySink},
4742 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
4743 {&DIID_HTMLDocumentEvents2},
4744 {NULL}
4747 static void init_doc(HTMLDocument *doc, IUnknown *outer, IDispatchEx *dispex)
4749 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
4750 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
4751 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
4752 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
4753 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
4754 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
4755 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
4756 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
4757 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
4758 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
4760 doc->outer_unk = outer;
4761 doc->dispex = dispex;
4762 doc->task_magic = get_task_target_magic();
4764 HTMLDocument_Persist_Init(doc);
4765 HTMLDocument_OleCmd_Init(doc);
4766 HTMLDocument_OleObj_Init(doc);
4767 HTMLDocument_View_Init(doc);
4768 HTMLDocument_Window_Init(doc);
4769 HTMLDocument_Service_Init(doc);
4770 HTMLDocument_Hlink_Init(doc);
4772 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
4775 static void destroy_htmldoc(HTMLDocument *This)
4777 remove_target_tasks(This->task_magic);
4779 ConnectionPointContainer_Destroy(&This->cp_container);
4782 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
4784 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
4787 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
4789 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4791 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4793 if(htmldoc_qi(&This->basedoc, riid, ppv))
4794 return *ppv ? S_OK : E_NOINTERFACE;
4796 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
4797 *ppv = &This->IInternetHostSecurityManager_iface;
4798 else
4799 return HTMLDOMNode_QI(&This->node, riid, ppv);
4801 IUnknown_AddRef((IUnknown*)*ppv);
4802 return S_OK;
4805 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
4807 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4808 unsigned i;
4810 for(i=0; i < This->elem_vars_cnt; i++)
4811 heap_free(This->elem_vars[i]);
4812 heap_free(This->elem_vars);
4814 detach_events(This);
4815 if(This->catmgr)
4816 ICatInformation_Release(This->catmgr);
4818 detach_selection(This);
4819 detach_ranges(This);
4821 while(!list_empty(&This->plugin_hosts))
4822 detach_plugin_host(LIST_ENTRY(list_head(&This->plugin_hosts), PluginHost, entry));
4824 if(!This->nsdoc && This->window) {
4825 /* document fragments own reference to inner window */
4826 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
4827 This->window = NULL;
4830 heap_free(This->event_vector);
4831 destroy_htmldoc(&This->basedoc);
4834 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4836 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4837 FIXME("%p\n", This);
4838 return E_NOTIMPL;
4841 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
4843 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4845 if(This->nsdoc)
4846 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
4849 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
4851 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4853 if(This->nsdoc) {
4854 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
4856 release_document_mutation(This);
4857 This->nsdoc = NULL;
4858 nsIDOMHTMLDocument_Release(nsdoc);
4859 This->window = NULL;
4863 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
4864 &CLSID_HTMLDocument,
4865 HTMLDocumentNode_QI,
4866 HTMLDocumentNode_destructor,
4867 HTMLDocument_cpc,
4868 HTMLDocumentNode_clone,
4869 NULL,
4870 NULL,
4871 NULL,
4872 NULL,
4873 NULL,
4874 NULL,
4875 NULL,
4876 NULL,
4877 NULL,
4878 NULL,
4879 NULL,
4880 HTMLDocumentNode_traverse,
4881 HTMLDocumentNode_unlink
4884 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4886 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4887 HTMLDocumentNode *new_node;
4888 HRESULT hres;
4890 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
4891 if(FAILED(hres))
4892 return hres;
4894 *ret = &new_node->node;
4895 return S_OK;
4898 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
4900 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
4903 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4904 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4906 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4907 nsIDOMNodeList *node_list;
4908 nsAString name_str;
4909 nsIDOMNode *nsnode;
4910 HTMLDOMNode *node;
4911 unsigned i;
4912 nsresult nsres;
4913 HRESULT hres;
4915 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
4916 FIXME("unsupported flags %x\n", flags);
4917 return E_NOTIMPL;
4920 i = id - MSHTML_DISPID_CUSTOM_MIN;
4922 if(!This->nsdoc || i >= This->elem_vars_cnt)
4923 return DISP_E_UNKNOWNNAME;
4925 nsAString_InitDepend(&name_str, This->elem_vars[i]);
4926 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4927 nsAString_Finish(&name_str);
4928 if(NS_FAILED(nsres))
4929 return E_FAIL;
4931 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
4932 nsIDOMNodeList_Release(node_list);
4933 if(NS_FAILED(nsres) || !nsnode)
4934 return DISP_E_UNKNOWNNAME;
4936 hres = get_node(This, nsnode, TRUE, &node);
4937 if(FAILED(hres))
4938 return hres;
4940 V_VT(res) = VT_DISPATCH;
4941 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
4942 return S_OK;
4945 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
4947 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4949 TRACE("(%p) returning %u\n", This, This->document_mode);
4951 This->document_mode_locked = TRUE;
4952 return This->document_mode;
4955 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, int eid)
4957 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4958 ensure_doc_nsevent_handler(This, eid);
4961 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl = {
4962 NULL,
4963 NULL,
4964 HTMLDocumentNode_invoke,
4965 HTMLDocumentNode_get_compat_mode,
4966 NULL,
4967 NULL,
4968 HTMLDocumentNode_bind_event
4971 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
4972 &CLSID_HTMLDocument,
4973 HTMLDocumentNode_QI,
4974 HTMLDocumentNode_destructor,
4975 HTMLDocument_cpc,
4976 HTMLDocumentFragment_clone
4979 static const tid_t HTMLDocumentNode_iface_tids[] = {
4980 IHTMLDOMNode_tid,
4981 IHTMLDOMNode2_tid,
4982 IHTMLDocument2_tid,
4983 IHTMLDocument4_tid,
4984 IHTMLDocument5_tid,
4985 IDocumentSelector_tid,
4989 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
4991 HTMLDOMNode_init_dispex_info(info, mode);
4993 if(mode >= COMPAT_MODE_IE9)
4994 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
4996 /* Depending on compatibility version, we add interfaces in different order
4997 * so that the right getElementById implementation is used. */
4998 if(mode < COMPAT_MODE_IE8) {
4999 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5000 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5001 }else {
5002 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5003 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5007 static dispex_static_data_t HTMLDocumentNode_dispex = {
5008 &HTMLDocumentNode_dispex_vtbl,
5009 DispHTMLDocument_tid,
5010 HTMLDocumentNode_iface_tids,
5011 HTMLDocumentNode_init_dispex_info
5014 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
5016 HTMLDocumentNode *doc;
5018 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
5019 if(!doc)
5020 return NULL;
5022 doc->ref = 1;
5023 doc->basedoc.doc_node = doc;
5024 doc->basedoc.doc_obj = doc_obj;
5025 doc->basedoc.window = window->base.outer_window;
5026 doc->window = window;
5028 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
5029 &doc->node.event_target.dispex.IDispatchEx_iface);
5030 HTMLDocumentNode_SecMgr_Init(doc);
5032 list_init(&doc->selection_list);
5033 list_init(&doc->range_list);
5034 list_init(&doc->plugin_hosts);
5036 return doc;
5039 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLInnerWindow *window, HTMLDocumentNode **ret)
5041 HTMLDocumentNode *doc;
5043 doc = alloc_doc_node(doc_obj, window);
5044 if(!doc)
5045 return E_OUTOFMEMORY;
5047 if(window->base.outer_window->parent) {
5048 compat_mode_t parent_mode = window->base.outer_window->parent->base.inner_window->doc->document_mode;
5049 TRACE("parent mode %u\n", parent_mode);
5050 if(parent_mode >= COMPAT_MODE_IE9) {
5051 doc->document_mode_locked = TRUE;
5052 doc->document_mode = parent_mode;
5056 if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
5057 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
5059 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc, &HTMLDocumentNode_dispex);
5061 nsIDOMHTMLDocument_AddRef(nsdoc);
5062 doc->nsdoc = nsdoc;
5064 init_document_mutation(doc);
5065 doc_init_events(doc);
5067 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
5068 doc->node.cp_container = &doc->basedoc.cp_container;
5070 *ret = doc;
5071 return S_OK;
5074 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
5076 HTMLDocumentNode *doc_frag;
5078 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
5079 if(!doc_frag)
5080 return E_OUTOFMEMORY;
5082 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
5084 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
5085 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
5086 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
5088 *ret = doc_frag;
5089 return S_OK;
5092 static inline HTMLDocumentObj *impl_from_IUnknown(IUnknown *iface)
5094 return CONTAINING_RECORD(iface, HTMLDocumentObj, IUnknown_outer);
5097 static HRESULT WINAPI HTMLDocumentObj_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
5099 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5101 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5103 if(IsEqualGUID(&IID_IUnknown, riid)) {
5104 *ppv = &This->IUnknown_outer;
5105 }else if(htmldoc_qi(&This->basedoc, riid, ppv)) {
5106 return *ppv ? S_OK : E_NOINTERFACE;
5107 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
5108 *ppv = &This->ICustomDoc_iface;
5109 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
5110 *ppv = &This->ITargetContainer_iface;
5111 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5112 return *ppv ? S_OK : E_NOINTERFACE;
5113 }else {
5114 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
5115 *ppv = NULL;
5116 return E_NOINTERFACE;
5119 IUnknown_AddRef((IUnknown*)*ppv);
5120 return S_OK;
5123 static ULONG WINAPI HTMLDocumentObj_AddRef(IUnknown *iface)
5125 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5126 ULONG ref = InterlockedIncrement(&This->ref);
5128 TRACE("(%p) ref = %u\n", This, ref);
5130 return ref;
5133 static ULONG WINAPI HTMLDocumentObj_Release(IUnknown *iface)
5135 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5136 ULONG ref = InterlockedDecrement(&This->ref);
5138 TRACE("(%p) ref = %u\n", This, ref);
5140 if(!ref) {
5141 nsIDOMWindowUtils *window_utils = NULL;
5143 if(This->basedoc.window && This->basedoc.window->nswindow)
5144 get_nsinterface((nsISupports*)This->basedoc.window->nswindow, &IID_nsIDOMWindowUtils, (void**)&window_utils);
5146 if(This->basedoc.doc_node) {
5147 This->basedoc.doc_node->basedoc.doc_obj = NULL;
5148 htmldoc_release(&This->basedoc.doc_node->basedoc);
5150 if(This->basedoc.window) {
5151 This->basedoc.window->doc_obj = NULL;
5152 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
5154 if(This->basedoc.advise_holder)
5155 IOleAdviseHolder_Release(This->basedoc.advise_holder);
5157 if(This->view_sink)
5158 IAdviseSink_Release(This->view_sink);
5159 if(This->client)
5160 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
5161 if(This->hostui)
5162 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
5163 if(This->in_place_active)
5164 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
5165 if(This->ipsite)
5166 IOleDocumentView_SetInPlaceSite(&This->basedoc.IOleDocumentView_iface, NULL);
5167 if(This->undomgr)
5168 IOleUndoManager_Release(This->undomgr);
5169 if(This->editsvcs)
5170 IHTMLEditServices_Release(This->editsvcs);
5171 if(This->tooltips_hwnd)
5172 DestroyWindow(This->tooltips_hwnd);
5174 if(This->hwnd)
5175 DestroyWindow(This->hwnd);
5176 heap_free(This->mime);
5178 destroy_htmldoc(&This->basedoc);
5179 release_dispex(&This->dispex);
5181 if(This->nscontainer)
5182 NSContainer_Release(This->nscontainer);
5183 heap_free(This);
5185 /* Force cycle collection */
5186 if(window_utils) {
5187 nsIDOMWindowUtils_CycleCollect(window_utils, NULL, 0);
5188 nsIDOMWindowUtils_Release(window_utils);
5192 return ref;
5195 static const IUnknownVtbl HTMLDocumentObjVtbl = {
5196 HTMLDocumentObj_QueryInterface,
5197 HTMLDocumentObj_AddRef,
5198 HTMLDocumentObj_Release
5201 /**********************************************************
5202 * ICustomDoc implementation
5205 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
5207 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
5210 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
5212 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5214 return htmldoc_query_interface(&This->basedoc, riid, ppv);
5217 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
5219 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5221 return htmldoc_addref(&This->basedoc);
5224 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
5226 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5228 return htmldoc_release(&This->basedoc);
5231 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
5233 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5234 IOleCommandTarget *cmdtrg;
5235 HRESULT hres;
5237 TRACE("(%p)->(%p)\n", This, pUIHandler);
5239 if(This->custom_hostui && This->hostui == pUIHandler)
5240 return S_OK;
5242 This->custom_hostui = TRUE;
5244 if(This->hostui)
5245 IDocHostUIHandler_Release(This->hostui);
5246 if(pUIHandler)
5247 IDocHostUIHandler_AddRef(pUIHandler);
5248 This->hostui = pUIHandler;
5249 if(!pUIHandler)
5250 return S_OK;
5252 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
5253 if(SUCCEEDED(hres)) {
5254 FIXME("custom UI handler supports IOleCommandTarget\n");
5255 IOleCommandTarget_Release(cmdtrg);
5258 return S_OK;
5261 static const ICustomDocVtbl CustomDocVtbl = {
5262 CustomDoc_QueryInterface,
5263 CustomDoc_AddRef,
5264 CustomDoc_Release,
5265 CustomDoc_SetUIHandler
5268 static const tid_t HTMLDocumentObj_iface_tids[] = {
5269 IHTMLDocument2_tid,
5270 IHTMLDocument3_tid,
5271 IHTMLDocument4_tid,
5272 IHTMLDocument5_tid,
5275 static dispex_static_data_t HTMLDocumentObj_dispex = {
5276 NULL,
5277 DispHTMLDocument_tid,
5278 HTMLDocumentObj_iface_tids
5281 static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID riid, void **ppv)
5283 mozIDOMWindowProxy *mozwindow;
5284 HTMLDocumentObj *doc;
5285 nsIDOMWindow *nswindow = NULL;
5286 nsresult nsres;
5287 HRESULT hres;
5289 if(outer && !IsEqualGUID(&IID_IUnknown, riid)) {
5290 *ppv = NULL;
5291 return E_INVALIDARG;
5294 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
5295 if(!doc)
5296 return E_OUTOFMEMORY;
5298 doc->ref = 1;
5299 doc->IUnknown_outer.lpVtbl = &HTMLDocumentObjVtbl;
5300 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
5302 init_dispex(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex);
5303 init_doc(&doc->basedoc, outer ? outer : &doc->IUnknown_outer, &doc->dispex.IDispatchEx_iface);
5304 TargetContainer_Init(doc);
5305 doc->basedoc.doc_obj = doc;
5306 doc->is_mhtml = is_mhtml;
5308 doc->usermode = UNKNOWN_USERMODE;
5310 init_binding_ui(doc);
5312 hres = create_nscontainer(doc, &doc->nscontainer);
5313 if(FAILED(hres)) {
5314 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
5315 htmldoc_release(&doc->basedoc);
5316 return hres;
5319 if(IsEqualGUID(&IID_IUnknown, riid)) {
5320 *ppv = &doc->IUnknown_outer;
5321 }else {
5322 hres = htmldoc_query_interface(&doc->basedoc, riid, ppv);
5323 htmldoc_release(&doc->basedoc);
5324 if(FAILED(hres))
5325 return hres;
5328 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &mozwindow);
5329 if(NS_FAILED(nsres))
5330 ERR("GetContentDOMWindow failed: %08x\n", nsres);
5332 nsres = mozIDOMWindowProxy_QueryInterface(mozwindow, &IID_nsIDOMWindow, (void**)&nswindow);
5333 mozIDOMWindowProxy_Release(mozwindow);
5334 assert(nsres == NS_OK);
5336 hres = HTMLOuterWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
5337 if(nswindow)
5338 nsIDOMWindow_Release(nswindow);
5339 if(FAILED(hres)) {
5340 htmldoc_release(&doc->basedoc);
5341 return hres;
5344 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
5345 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
5346 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
5349 get_thread_hwnd();
5351 return S_OK;
5354 HRESULT HTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
5356 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
5357 return create_document_object(FALSE, outer, riid, ppv);
5360 HRESULT MHTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
5362 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
5363 return create_document_object(TRUE, outer, riid, ppv);