mshtml: Replace get_htmldoc_classinfo with more generic helper.
[wine.git] / dlls / mshtml / htmldoc.c
blob57679fc3278443aebd477c42c59aaa66704163e7
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);
921 nsAString charset_str;
922 nsresult nsres;
924 TRACE("(%p)->(%p)\n", This, p);
926 if(!This->doc_node->nsdoc) {
927 FIXME("NULL nsdoc\n");
928 return E_FAIL;
931 nsAString_Init(&charset_str, NULL);
932 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
933 return return_nsstr(nsres, &charset_str, p);
936 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
938 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
939 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
940 return E_NOTIMPL;
943 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
945 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
947 TRACE("(%p)->(%p)\n", This, p);
949 *p = charset_string_from_cp(GetACP());
950 return *p ? S_OK : E_OUTOFMEMORY;
953 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
955 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
956 FIXME("(%p)->(%p)\n", This, p);
957 return E_NOTIMPL;
960 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
962 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
963 FIXME("(%p)->(%p)\n", This, p);
964 return E_NOTIMPL;
967 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
969 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
970 FIXME("(%p)->(%p)\n", This, p);
971 return E_NOTIMPL;
974 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
976 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
977 FIXME("(%p)->(%p)\n", This, p);
978 return E_NOTIMPL;
981 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
983 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
984 FIXME("(%p)->(%p)\n", This, p);
985 return E_NOTIMPL;
988 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
990 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
991 FIXME("(%p)->(%p)\n", This, p);
992 return E_NOTIMPL;
995 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
997 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
998 FIXME("(%p)->(%p)\n", This, p);
999 return E_NOTIMPL;
1002 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1004 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1005 FIXME("(%p)->(%p)\n", This, p);
1006 return E_NOTIMPL;
1009 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
1011 VARIANT *var, tmp;
1012 JSContext *jsctx;
1013 nsAString nsstr;
1014 ULONG i, argc;
1015 nsresult nsres;
1016 HRESULT hres;
1018 if(!This->doc_node->nsdoc) {
1019 WARN("NULL nsdoc\n");
1020 return E_UNEXPECTED;
1023 if (!psarray)
1024 return S_OK;
1026 if(psarray->cDims != 1) {
1027 FIXME("cDims=%d\n", psarray->cDims);
1028 return E_INVALIDARG;
1031 hres = SafeArrayAccessData(psarray, (void**)&var);
1032 if(FAILED(hres)) {
1033 WARN("SafeArrayAccessData failed: %08x\n", hres);
1034 return hres;
1037 V_VT(&tmp) = VT_EMPTY;
1039 jsctx = get_context_from_document(This->doc_node->nsdoc);
1040 argc = psarray->rgsabound[0].cElements;
1041 for(i=0; i < argc; i++) {
1042 if(V_VT(var+i) == VT_BSTR) {
1043 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1044 }else {
1045 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1046 if(FAILED(hres)) {
1047 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1048 break;
1050 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1053 if(!ln || i != argc-1)
1054 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1055 else
1056 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1057 nsAString_Finish(&nsstr);
1058 if(V_VT(var+i) != VT_BSTR)
1059 VariantClear(&tmp);
1060 if(NS_FAILED(nsres)) {
1061 ERR("Write failed: %08x\n", nsres);
1062 hres = E_FAIL;
1063 break;
1067 SafeArrayUnaccessData(psarray);
1069 return hres;
1072 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1074 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1076 TRACE("(%p)->(%p)\n", iface, psarray);
1078 return document_write(This, psarray, FALSE);
1081 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1083 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1085 TRACE("(%p)->(%p)\n", This, psarray);
1087 return document_write(This, psarray, TRUE);
1090 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1091 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1093 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1094 nsISupports *tmp;
1095 nsresult nsres;
1097 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
1099 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1100 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1102 if(!This->doc_node->nsdoc) {
1103 ERR("!nsdoc\n");
1104 return E_NOTIMPL;
1107 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
1108 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1109 FIXME("unsupported args\n");
1111 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1112 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1113 if(NS_FAILED(nsres)) {
1114 ERR("Open failed: %08x\n", nsres);
1115 return E_FAIL;
1118 if(tmp)
1119 nsISupports_Release(tmp);
1121 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1122 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1123 return S_OK;
1126 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1128 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1129 nsresult nsres;
1131 TRACE("(%p)\n", This);
1133 if(!This->doc_node->nsdoc) {
1134 ERR("!nsdoc\n");
1135 return E_NOTIMPL;
1138 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1139 if(NS_FAILED(nsres)) {
1140 ERR("Close failed: %08x\n", nsres);
1141 return E_FAIL;
1144 return S_OK;
1147 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1149 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1150 nsresult nsres;
1152 TRACE("(%p)\n", This);
1154 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1155 if(NS_FAILED(nsres)) {
1156 ERR("Clear failed: %08x\n", nsres);
1157 return E_FAIL;
1160 return S_OK;
1163 static const WCHAR copyW[] =
1164 {'c','o','p','y',0};
1165 static const WCHAR cutW[] =
1166 {'c','u','t',0};
1167 static const WCHAR fontnameW[] =
1168 {'f','o','n','t','n','a','m','e',0};
1169 static const WCHAR fontsizeW[] =
1170 {'f','o','n','t','s','i','z','e',0};
1171 static const WCHAR indentW[] =
1172 {'i','n','d','e','n','t',0};
1173 static const WCHAR insertorderedlistW[] =
1174 {'i','n','s','e','r','t','o','r','d','e','r','e','d','l','i','s','t',0};
1175 static const WCHAR insertunorderedlistW[] =
1176 {'i','n','s','e','r','t','u','n','o','r','d','e','r','e','d','l','i','s','t',0};
1177 static const WCHAR outdentW[] =
1178 {'o','u','t','d','e','n','t',0};
1179 static const WCHAR pasteW[] =
1180 {'p','a','s','t','e',0};
1181 static const WCHAR respectvisibilityindesignW[] =
1182 {'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};
1184 static const struct {
1185 const WCHAR *name;
1186 OLECMDID id;
1187 }command_names[] = {
1188 {copyW, IDM_COPY},
1189 {cutW, IDM_CUT},
1190 {fontnameW, IDM_FONTNAME},
1191 {fontsizeW, IDM_FONTSIZE},
1192 {indentW, IDM_INDENT},
1193 {insertorderedlistW, IDM_ORDERLIST},
1194 {insertunorderedlistW, IDM_UNORDERLIST},
1195 {outdentW, IDM_OUTDENT},
1196 {pasteW, IDM_PASTE},
1197 {respectvisibilityindesignW, IDM_RESPECTVISIBILITY_INDESIGN}
1200 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1202 int i;
1204 for(i = 0; i < sizeof(command_names)/sizeof(*command_names); i++) {
1205 if(!strcmpiW(command_names[i].name, str)) {
1206 *cmdid = command_names[i].id;
1207 return TRUE;
1211 FIXME("Unknown command %s\n", debugstr_w(str));
1212 return FALSE;
1215 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1216 VARIANT_BOOL *pfRet)
1218 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1219 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1220 return E_NOTIMPL;
1223 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1224 VARIANT_BOOL *pfRet)
1226 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1227 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1228 return E_NOTIMPL;
1231 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1232 VARIANT_BOOL *pfRet)
1234 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1235 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1236 return E_NOTIMPL;
1239 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1240 VARIANT_BOOL *pfRet)
1242 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1243 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1244 return E_NOTIMPL;
1247 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1248 BSTR *pfRet)
1250 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1251 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1252 return E_NOTIMPL;
1255 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1256 VARIANT *pfRet)
1258 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1259 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1260 return E_NOTIMPL;
1263 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1264 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1266 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1267 OLECMDID cmdid;
1268 VARIANT ret;
1269 HRESULT hres;
1271 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1273 if(!cmdid_from_string(cmdID, &cmdid))
1274 return OLECMDERR_E_NOTSUPPORTED;
1276 V_VT(&ret) = VT_EMPTY;
1277 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1278 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1279 if(FAILED(hres))
1280 return hres;
1282 if(V_VT(&ret) != VT_EMPTY) {
1283 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1284 VariantClear(&ret);
1287 *pfRet = VARIANT_TRUE;
1288 return S_OK;
1291 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1292 VARIANT_BOOL *pfRet)
1294 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1295 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1296 return E_NOTIMPL;
1299 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1300 IHTMLElement **newElem)
1302 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1303 HTMLElement *elem;
1304 HRESULT hres;
1306 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1308 hres = create_element(This->doc_node, eTag, &elem);
1309 if(FAILED(hres))
1310 return hres;
1312 *newElem = &elem->IHTMLElement_iface;
1313 return S_OK;
1316 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1318 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1319 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1320 return E_NOTIMPL;
1323 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1325 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1326 FIXME("(%p)->(%p)\n", This, p);
1327 return E_NOTIMPL;
1330 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1332 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1334 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1336 return set_doc_event(This, EVENTID_CLICK, &v);
1339 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1341 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1343 TRACE("(%p)->(%p)\n", This, p);
1345 return get_doc_event(This, EVENTID_CLICK, p);
1348 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1350 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1352 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1354 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1357 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1359 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1361 TRACE("(%p)->(%p)\n", This, p);
1363 return get_doc_event(This, EVENTID_DBLCLICK, p);
1366 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1368 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1370 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1372 return set_doc_event(This, EVENTID_KEYUP, &v);
1375 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1377 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1379 TRACE("(%p)->(%p)\n", This, p);
1381 return get_doc_event(This, EVENTID_KEYUP, p);
1384 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1386 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1388 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1390 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1393 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1395 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1397 TRACE("(%p)->(%p)\n", This, p);
1399 return get_doc_event(This, EVENTID_KEYDOWN, p);
1402 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1404 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1406 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1408 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1411 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1413 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1415 TRACE("(%p)->(%p)\n", This, p);
1417 return get_doc_event(This, EVENTID_KEYPRESS, p);
1420 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1422 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1424 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1426 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1429 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1431 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1433 TRACE("(%p)->(%p)\n", This, p);
1435 return get_doc_event(This, EVENTID_MOUSEUP, p);
1438 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1440 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1442 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1444 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1447 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1449 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1451 TRACE("(%p)->(%p)\n", This, p);
1453 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1456 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1458 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1460 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1462 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1465 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1467 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1469 TRACE("(%p)->(%p)\n", This, p);
1471 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1474 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1476 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1478 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1480 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1483 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1485 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1487 TRACE("(%p)->(%p)\n", This, p);
1489 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1492 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1494 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1496 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1498 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1501 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1503 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1505 TRACE("(%p)->(%p)\n", This, p);
1507 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1510 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1512 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1514 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1516 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1519 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1521 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1523 TRACE("(%p)->(%p)\n", This, p);
1525 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1528 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1530 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1531 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1532 return E_NOTIMPL;
1535 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1537 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1538 FIXME("(%p)->(%p)\n", This, p);
1539 return E_NOTIMPL;
1542 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1544 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1545 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1546 return E_NOTIMPL;
1549 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1551 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1552 FIXME("(%p)->(%p)\n", This, p);
1553 return E_NOTIMPL;
1556 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1558 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1559 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1560 return E_NOTIMPL;
1563 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1565 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1566 FIXME("(%p)->(%p)\n", This, p);
1567 return E_NOTIMPL;
1570 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1572 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1574 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1576 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1579 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1581 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1583 TRACE("(%p)->(%p)\n", This, p);
1585 return get_doc_event(This, EVENTID_DRAGSTART, p);
1588 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1590 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1592 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1594 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1597 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1599 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1601 TRACE("(%p)->(%p)\n", This, p);
1603 return get_doc_event(This, EVENTID_SELECTSTART, p);
1606 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1607 IHTMLElement **elementHit)
1609 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1610 nsIDOMElement *nselem;
1611 HTMLDOMNode *node;
1612 nsresult nsres;
1613 HRESULT hres;
1615 TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1617 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1618 if(NS_FAILED(nsres)) {
1619 ERR("ElementFromPoint failed: %08x\n", nsres);
1620 return E_FAIL;
1623 if(!nselem) {
1624 *elementHit = NULL;
1625 return S_OK;
1628 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
1629 nsIDOMElement_Release(nselem);
1630 if(FAILED(hres))
1631 return hres;
1633 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)elementHit);
1634 node_release(node);
1635 return hres;
1638 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1640 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1642 TRACE("(%p)->(%p)\n", This, p);
1644 *p = &This->window->base.IHTMLWindow2_iface;
1645 IHTMLWindow2_AddRef(*p);
1646 return S_OK;
1649 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1650 IHTMLStyleSheetsCollection **p)
1652 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1653 nsIDOMStyleSheetList *nsstylelist;
1654 nsresult nsres;
1656 TRACE("(%p)->(%p)\n", This, p);
1658 *p = NULL;
1660 if(!This->doc_node->nsdoc) {
1661 WARN("NULL nsdoc\n");
1662 return E_UNEXPECTED;
1665 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1666 if(NS_FAILED(nsres)) {
1667 ERR("GetStyleSheets failed: %08x\n", nsres);
1668 return E_FAIL;
1671 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1672 nsIDOMStyleSheetList_Release(nsstylelist);
1674 return S_OK;
1677 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1679 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1680 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1681 return E_NOTIMPL;
1684 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1686 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1687 FIXME("(%p)->(%p)\n", This, p);
1688 return E_NOTIMPL;
1691 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1693 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1694 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1695 return E_NOTIMPL;
1698 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1700 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1701 FIXME("(%p)->(%p)\n", This, p);
1702 return E_NOTIMPL;
1705 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1707 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1709 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1711 TRACE("(%p)->(%p)\n", This, String);
1713 if(!String)
1714 return E_INVALIDARG;
1716 *String = SysAllocString(objectW);
1717 return *String ? S_OK : E_OUTOFMEMORY;
1721 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1722 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1724 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1725 nsIDOMHTMLHeadElement *head_elem;
1726 IHTMLStyleElement *style_elem;
1727 HTMLElement *elem;
1728 nsresult nsres;
1729 HRESULT hres;
1731 static const WCHAR styleW[] = {'s','t','y','l','e',0};
1733 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1735 if(!This->doc_node->nsdoc) {
1736 FIXME("not a real doc object\n");
1737 return E_NOTIMPL;
1740 if(lIndex != -1)
1741 FIXME("Unsupported lIndex %d\n", lIndex);
1743 if(bstrHref && *bstrHref) {
1744 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
1745 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1746 return S_OK;
1749 hres = create_element(This->doc_node, styleW, &elem);
1750 if(FAILED(hres))
1751 return hres;
1753 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
1754 if(NS_SUCCEEDED(nsres)) {
1755 nsIDOMNode *head_node, *tmp_node;
1757 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
1758 nsIDOMHTMLHeadElement_Release(head_elem);
1759 assert(nsres == NS_OK);
1761 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
1762 nsIDOMNode_Release(head_node);
1763 if(NS_SUCCEEDED(nsres) && tmp_node)
1764 nsIDOMNode_Release(tmp_node);
1766 if(NS_FAILED(nsres)) {
1767 IHTMLElement_Release(&elem->IHTMLElement_iface);
1768 return E_FAIL;
1771 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
1772 assert(hres == S_OK);
1773 IHTMLElement_Release(&elem->IHTMLElement_iface);
1775 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
1776 IHTMLStyleElement_Release(style_elem);
1777 return hres;
1780 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1781 HTMLDocument_QueryInterface,
1782 HTMLDocument_AddRef,
1783 HTMLDocument_Release,
1784 HTMLDocument_GetTypeInfoCount,
1785 HTMLDocument_GetTypeInfo,
1786 HTMLDocument_GetIDsOfNames,
1787 HTMLDocument_Invoke,
1788 HTMLDocument_get_Script,
1789 HTMLDocument_get_all,
1790 HTMLDocument_get_body,
1791 HTMLDocument_get_activeElement,
1792 HTMLDocument_get_images,
1793 HTMLDocument_get_applets,
1794 HTMLDocument_get_links,
1795 HTMLDocument_get_forms,
1796 HTMLDocument_get_anchors,
1797 HTMLDocument_put_title,
1798 HTMLDocument_get_title,
1799 HTMLDocument_get_scripts,
1800 HTMLDocument_put_designMode,
1801 HTMLDocument_get_designMode,
1802 HTMLDocument_get_selection,
1803 HTMLDocument_get_readyState,
1804 HTMLDocument_get_frames,
1805 HTMLDocument_get_embeds,
1806 HTMLDocument_get_plugins,
1807 HTMLDocument_put_alinkColor,
1808 HTMLDocument_get_alinkColor,
1809 HTMLDocument_put_bgColor,
1810 HTMLDocument_get_bgColor,
1811 HTMLDocument_put_fgColor,
1812 HTMLDocument_get_fgColor,
1813 HTMLDocument_put_linkColor,
1814 HTMLDocument_get_linkColor,
1815 HTMLDocument_put_vlinkColor,
1816 HTMLDocument_get_vlinkColor,
1817 HTMLDocument_get_referrer,
1818 HTMLDocument_get_location,
1819 HTMLDocument_get_lastModified,
1820 HTMLDocument_put_URL,
1821 HTMLDocument_get_URL,
1822 HTMLDocument_put_domain,
1823 HTMLDocument_get_domain,
1824 HTMLDocument_put_cookie,
1825 HTMLDocument_get_cookie,
1826 HTMLDocument_put_expando,
1827 HTMLDocument_get_expando,
1828 HTMLDocument_put_charset,
1829 HTMLDocument_get_charset,
1830 HTMLDocument_put_defaultCharset,
1831 HTMLDocument_get_defaultCharset,
1832 HTMLDocument_get_mimeType,
1833 HTMLDocument_get_fileSize,
1834 HTMLDocument_get_fileCreatedDate,
1835 HTMLDocument_get_fileModifiedDate,
1836 HTMLDocument_get_fileUpdatedDate,
1837 HTMLDocument_get_security,
1838 HTMLDocument_get_protocol,
1839 HTMLDocument_get_nameProp,
1840 HTMLDocument_write,
1841 HTMLDocument_writeln,
1842 HTMLDocument_open,
1843 HTMLDocument_close,
1844 HTMLDocument_clear,
1845 HTMLDocument_queryCommandSupported,
1846 HTMLDocument_queryCommandEnabled,
1847 HTMLDocument_queryCommandState,
1848 HTMLDocument_queryCommandIndeterm,
1849 HTMLDocument_queryCommandText,
1850 HTMLDocument_queryCommandValue,
1851 HTMLDocument_execCommand,
1852 HTMLDocument_execCommandShowHelp,
1853 HTMLDocument_createElement,
1854 HTMLDocument_put_onhelp,
1855 HTMLDocument_get_onhelp,
1856 HTMLDocument_put_onclick,
1857 HTMLDocument_get_onclick,
1858 HTMLDocument_put_ondblclick,
1859 HTMLDocument_get_ondblclick,
1860 HTMLDocument_put_onkeyup,
1861 HTMLDocument_get_onkeyup,
1862 HTMLDocument_put_onkeydown,
1863 HTMLDocument_get_onkeydown,
1864 HTMLDocument_put_onkeypress,
1865 HTMLDocument_get_onkeypress,
1866 HTMLDocument_put_onmouseup,
1867 HTMLDocument_get_onmouseup,
1868 HTMLDocument_put_onmousedown,
1869 HTMLDocument_get_onmousedown,
1870 HTMLDocument_put_onmousemove,
1871 HTMLDocument_get_onmousemove,
1872 HTMLDocument_put_onmouseout,
1873 HTMLDocument_get_onmouseout,
1874 HTMLDocument_put_onmouseover,
1875 HTMLDocument_get_onmouseover,
1876 HTMLDocument_put_onreadystatechange,
1877 HTMLDocument_get_onreadystatechange,
1878 HTMLDocument_put_onafterupdate,
1879 HTMLDocument_get_onafterupdate,
1880 HTMLDocument_put_onrowexit,
1881 HTMLDocument_get_onrowexit,
1882 HTMLDocument_put_onrowenter,
1883 HTMLDocument_get_onrowenter,
1884 HTMLDocument_put_ondragstart,
1885 HTMLDocument_get_ondragstart,
1886 HTMLDocument_put_onselectstart,
1887 HTMLDocument_get_onselectstart,
1888 HTMLDocument_elementFromPoint,
1889 HTMLDocument_get_parentWindow,
1890 HTMLDocument_get_styleSheets,
1891 HTMLDocument_put_onbeforeupdate,
1892 HTMLDocument_get_onbeforeupdate,
1893 HTMLDocument_put_onerrorupdate,
1894 HTMLDocument_get_onerrorupdate,
1895 HTMLDocument_toString,
1896 HTMLDocument_createStyleSheet
1899 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
1901 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
1904 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
1905 REFIID riid, void **ppv)
1907 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1908 return htmldoc_query_interface(This, riid, ppv);
1911 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
1913 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1914 return htmldoc_addref(This);
1917 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
1919 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1920 return htmldoc_release(This);
1923 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
1925 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1926 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1929 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
1930 LCID lcid, ITypeInfo **ppTInfo)
1932 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1933 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1936 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
1937 LPOLESTR *rgszNames, UINT cNames,
1938 LCID lcid, DISPID *rgDispId)
1940 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1941 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1942 rgDispId);
1945 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
1946 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1947 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1949 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1950 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1951 pDispParams, pVarResult, pExcepInfo, puArgErr);
1954 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
1956 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1957 FIXME("(%p)\n", This);
1958 return E_NOTIMPL;
1961 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
1963 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1965 WARN("(%p)->(%x)\n", This, fForce);
1967 /* Doing nothing here should be fine for us. */
1968 return S_OK;
1971 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
1972 IHTMLDOMNode **newTextNode)
1974 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1975 nsIDOMText *nstext;
1976 HTMLDOMNode *node;
1977 nsAString text_str;
1978 nsresult nsres;
1979 HRESULT hres;
1981 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
1983 if(!This->doc_node->nsdoc) {
1984 WARN("NULL nsdoc\n");
1985 return E_UNEXPECTED;
1988 nsAString_InitDepend(&text_str, text);
1989 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
1990 nsAString_Finish(&text_str);
1991 if(NS_FAILED(nsres)) {
1992 ERR("CreateTextNode failed: %08x\n", nsres);
1993 return E_FAIL;
1996 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
1997 nsIDOMText_Release(nstext);
1998 if(FAILED(hres))
1999 return hres;
2001 *newTextNode = &node->IHTMLDOMNode_iface;
2002 return S_OK;
2005 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
2007 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2008 nsIDOMElement *nselem = NULL;
2009 HTMLDOMNode *node;
2010 nsresult nsres;
2011 HRESULT hres;
2013 TRACE("(%p)->(%p)\n", This, p);
2015 if(This->window->readystate == READYSTATE_UNINITIALIZED) {
2016 *p = NULL;
2017 return S_OK;
2020 if(!This->doc_node->nsdoc) {
2021 WARN("NULL nsdoc\n");
2022 return E_UNEXPECTED;
2025 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
2026 if(NS_FAILED(nsres)) {
2027 ERR("GetDocumentElement failed: %08x\n", nsres);
2028 return E_FAIL;
2031 if(!nselem) {
2032 *p = NULL;
2033 return S_OK;
2036 hres = get_node(This->doc_node, (nsIDOMNode *)nselem, TRUE, &node);
2037 nsIDOMElement_Release(nselem);
2038 if(FAILED(hres))
2039 return hres;
2041 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
2042 node_release(node);
2043 return hres;
2046 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2048 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2050 TRACE("(%p)->(%p)\n", This, p);
2052 return elem_unique_id(++This->doc_node->unique_id, p);
2055 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2056 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2058 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2060 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2062 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2065 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2066 IDispatch *pDisp)
2068 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2070 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2072 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2075 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2077 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2078 FIXME("(%p)->()\n", This);
2079 return E_NOTIMPL;
2082 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2084 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2085 FIXME("(%p)->(%p)\n", This, p);
2086 return E_NOTIMPL;
2089 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2091 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2092 FIXME("(%p)->()\n", This);
2093 return E_NOTIMPL;
2096 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2098 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2099 FIXME("(%p)->(%p)\n", This, p);
2100 return E_NOTIMPL;
2103 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2105 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2106 FIXME("(%p)->()\n", This);
2107 return E_NOTIMPL;
2110 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2112 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2113 FIXME("(%p)->(%p)\n", This, p);
2114 return E_NOTIMPL;
2117 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2119 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2120 FIXME("(%p)->()\n", This);
2121 return E_NOTIMPL;
2124 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2126 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2127 FIXME("(%p)->(%p)\n", This, p);
2128 return E_NOTIMPL;
2131 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2133 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2134 FIXME("(%p)->()\n", This);
2135 return E_NOTIMPL;
2138 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2140 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2141 FIXME("(%p)->(%p)\n", This, p);
2142 return E_NOTIMPL;
2145 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2147 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2148 FIXME("(%p)->()\n", This);
2149 return E_NOTIMPL;
2152 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2154 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2155 FIXME("(%p)->(%p)\n", This, p);
2156 return E_NOTIMPL;
2159 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2161 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2162 FIXME("(%p)->()\n", This);
2163 return E_NOTIMPL;
2166 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2168 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2169 FIXME("(%p)->(%p)\n", This, p);
2170 return E_NOTIMPL;
2173 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2175 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2176 nsAString dir_str;
2177 nsresult nsres;
2179 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2181 if(!This->doc_node->nsdoc) {
2182 FIXME("NULL nsdoc\n");
2183 return E_UNEXPECTED;
2186 nsAString_InitDepend(&dir_str, v);
2187 nsres = nsIDOMHTMLDocument_SetDir(This->doc_node->nsdoc, &dir_str);
2188 nsAString_Finish(&dir_str);
2189 if(NS_FAILED(nsres)) {
2190 ERR("SetDir failed: %08x\n", nsres);
2191 return E_FAIL;
2194 return S_OK;
2197 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2199 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2200 nsAString dir_str;
2201 nsresult nsres;
2203 TRACE("(%p)->(%p)\n", This, p);
2205 if(!This->doc_node->nsdoc) {
2206 FIXME("NULL nsdoc\n");
2207 return E_UNEXPECTED;
2210 nsAString_Init(&dir_str, NULL);
2211 nsres = nsIDOMHTMLDocument_GetDir(This->doc_node->nsdoc, &dir_str);
2212 return return_nsstr(nsres, &dir_str, p);
2215 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2217 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2219 TRACE("(%p)->()\n", This);
2221 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2224 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2226 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2228 TRACE("(%p)->(%p)\n", This, p);
2230 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2233 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2235 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2236 FIXME("(%p)->()\n", This);
2237 return E_NOTIMPL;
2240 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2242 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2243 FIXME("(%p)->(%p)\n", This, p);
2244 return E_NOTIMPL;
2247 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2248 IHTMLDocument2 **ppNewDoc)
2250 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2251 nsIDOMDocumentFragment *doc_frag;
2252 HTMLDocumentNode *docnode;
2253 nsresult nsres;
2254 HRESULT hres;
2256 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2258 if(!This->doc_node->nsdoc) {
2259 FIXME("NULL nsdoc\n");
2260 return E_NOTIMPL;
2263 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2264 if(NS_FAILED(nsres)) {
2265 ERR("CreateDocumentFragment failed: %08x\n", nsres);
2266 return E_FAIL;
2269 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2270 nsIDOMDocumentFragment_Release(doc_frag);
2271 if(FAILED(hres))
2272 return hres;
2274 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2275 return S_OK;
2278 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2279 IHTMLDocument2 **p)
2281 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2282 FIXME("(%p)->(%p)\n", This, p);
2283 return E_NOTIMPL;
2286 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2287 VARIANT_BOOL v)
2289 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2290 FIXME("(%p)->(%x)\n", This, v);
2291 return E_NOTIMPL;
2294 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2295 VARIANT_BOOL *p)
2297 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2298 FIXME("(%p)->(%p)\n", This, p);
2299 return E_NOTIMPL;
2302 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2304 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2305 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2306 return E_NOTIMPL;
2309 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2311 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2312 FIXME("(%p)->(%p)\n", This, p);
2313 return E_NOTIMPL;
2316 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2318 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2320 TRACE("(%p)->(%p)\n", This, p);
2322 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2325 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2326 VARIANT_BOOL v)
2328 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2329 FIXME("(%p)->()\n", This);
2330 return E_NOTIMPL;
2333 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2334 VARIANT_BOOL *p)
2336 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2337 FIXME("(%p)->(%p)\n", This, p);
2338 return E_NOTIMPL;
2341 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2343 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2344 FIXME("(%p)->()\n", This);
2345 return E_NOTIMPL;
2348 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2350 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2351 FIXME("(%p)->(%p)\n", This, p);
2352 return E_NOTIMPL;
2355 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2356 IHTMLElementCollection **ppelColl)
2358 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2359 nsIDOMNodeList *node_list;
2360 nsAString selector_str;
2361 WCHAR *selector;
2362 nsresult nsres;
2364 static const WCHAR formatW[] = {'*','[','i','d','=','%','s',']',',','*','[','n','a','m','e','=','%','s',']',0};
2366 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2368 if(!This->doc_node || !This->doc_node->nsdoc) {
2369 /* We should probably return an empty collection. */
2370 FIXME("No nsdoc\n");
2371 return E_NOTIMPL;
2374 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2375 if(!selector)
2376 return E_OUTOFMEMORY;
2377 sprintfW(selector, formatW, v, v);
2380 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2381 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2382 * types and search should be case insensitive. Those are currently not supported properly.
2384 nsAString_InitDepend(&selector_str, selector);
2385 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2386 nsAString_Finish(&selector_str);
2387 heap_free(selector);
2388 if(NS_FAILED(nsres)) {
2389 ERR("QuerySelectorAll failed: %08x\n", nsres);
2390 return E_FAIL;
2393 *ppelColl = create_collection_from_nodelist(This->doc_node, node_list);
2394 nsIDOMNodeList_Release(node_list);
2395 return S_OK;
2399 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2400 IHTMLElement **pel)
2402 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2403 HTMLElement *elem;
2404 HRESULT hres;
2406 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2408 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2409 if(FAILED(hres) || !elem) {
2410 *pel = NULL;
2411 return hres;
2414 *pel = &elem->IHTMLElement_iface;
2415 return S_OK;
2419 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2420 IHTMLElementCollection **pelColl)
2422 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2423 nsIDOMNodeList *nslist;
2424 nsAString id_str;
2425 nsresult nsres;
2427 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2429 if(This->doc_node->nsdoc) {
2430 nsAString_InitDepend(&id_str, v);
2431 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2432 nsAString_Finish(&id_str);
2433 if(FAILED(nsres)) {
2434 ERR("GetElementByName failed: %08x\n", nsres);
2435 return E_FAIL;
2437 }else {
2438 nsIDOMDocumentFragment *docfrag;
2439 nsAString nsstr;
2441 if(v) {
2442 const WCHAR *ptr;
2443 for(ptr=v; *ptr; ptr++) {
2444 if(!isalnumW(*ptr)) {
2445 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2446 return E_NOTIMPL;
2451 nsres = nsIDOMNode_QueryInterface(This->doc_node->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2452 if(NS_FAILED(nsres)) {
2453 ERR("Could not get nsIDOMDocumentFragment iface: %08x\n", nsres);
2454 return E_UNEXPECTED;
2457 nsAString_InitDepend(&nsstr, v);
2458 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2459 nsAString_Finish(&nsstr);
2460 nsIDOMDocumentFragment_Release(docfrag);
2461 if(NS_FAILED(nsres)) {
2462 ERR("QuerySelectorAll failed: %08x\n", nsres);
2463 return E_FAIL;
2468 *pelColl = create_collection_from_nodelist(This->doc_node, nslist);
2469 nsIDOMNodeList_Release(nslist);
2471 return S_OK;
2474 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2475 HTMLDocument3_QueryInterface,
2476 HTMLDocument3_AddRef,
2477 HTMLDocument3_Release,
2478 HTMLDocument3_GetTypeInfoCount,
2479 HTMLDocument3_GetTypeInfo,
2480 HTMLDocument3_GetIDsOfNames,
2481 HTMLDocument3_Invoke,
2482 HTMLDocument3_releaseCapture,
2483 HTMLDocument3_recalc,
2484 HTMLDocument3_createTextNode,
2485 HTMLDocument3_get_documentElement,
2486 HTMLDocument3_get_uniqueID,
2487 HTMLDocument3_attachEvent,
2488 HTMLDocument3_detachEvent,
2489 HTMLDocument3_put_onrowsdelete,
2490 HTMLDocument3_get_onrowsdelete,
2491 HTMLDocument3_put_onrowsinserted,
2492 HTMLDocument3_get_onrowsinserted,
2493 HTMLDocument3_put_oncellchange,
2494 HTMLDocument3_get_oncellchange,
2495 HTMLDocument3_put_ondatasetchanged,
2496 HTMLDocument3_get_ondatasetchanged,
2497 HTMLDocument3_put_ondataavailable,
2498 HTMLDocument3_get_ondataavailable,
2499 HTMLDocument3_put_ondatasetcomplete,
2500 HTMLDocument3_get_ondatasetcomplete,
2501 HTMLDocument3_put_onpropertychange,
2502 HTMLDocument3_get_onpropertychange,
2503 HTMLDocument3_put_dir,
2504 HTMLDocument3_get_dir,
2505 HTMLDocument3_put_oncontextmenu,
2506 HTMLDocument3_get_oncontextmenu,
2507 HTMLDocument3_put_onstop,
2508 HTMLDocument3_get_onstop,
2509 HTMLDocument3_createDocumentFragment,
2510 HTMLDocument3_get_parentDocument,
2511 HTMLDocument3_put_enableDownload,
2512 HTMLDocument3_get_enableDownload,
2513 HTMLDocument3_put_baseUrl,
2514 HTMLDocument3_get_baseUrl,
2515 HTMLDocument3_get_childNodes,
2516 HTMLDocument3_put_inheritStyleSheets,
2517 HTMLDocument3_get_inheritStyleSheets,
2518 HTMLDocument3_put_onbeforeeditfocus,
2519 HTMLDocument3_get_onbeforeeditfocus,
2520 HTMLDocument3_getElementsByName,
2521 HTMLDocument3_getElementById,
2522 HTMLDocument3_getElementsByTagName
2525 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2527 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2530 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2531 REFIID riid, void **ppv)
2533 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2534 return htmldoc_query_interface(This, riid, ppv);
2537 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2539 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2540 return htmldoc_addref(This);
2543 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2545 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2546 return htmldoc_release(This);
2549 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2551 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2552 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2555 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2556 LCID lcid, ITypeInfo **ppTInfo)
2558 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2559 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2562 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2563 LPOLESTR *rgszNames, UINT cNames,
2564 LCID lcid, DISPID *rgDispId)
2566 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2567 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2568 rgDispId);
2571 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2572 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2573 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2575 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2576 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2577 pDispParams, pVarResult, pExcepInfo, puArgErr);
2580 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2582 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2583 nsIDOMHTMLElement *nsbody;
2584 nsresult nsres;
2586 TRACE("(%p)->()\n", This);
2588 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2589 if(NS_FAILED(nsres) || !nsbody) {
2590 ERR("GetBody failed: %08x\n", nsres);
2591 return E_FAIL;
2594 nsres = nsIDOMHTMLElement_Focus(nsbody);
2595 nsIDOMHTMLElement_Release(nsbody);
2596 if(NS_FAILED(nsres)) {
2597 ERR("Focus failed: %08x\n", nsres);
2598 return E_FAIL;
2601 return S_OK;
2604 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2606 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2607 cpp_bool has_focus;
2608 nsresult nsres;
2610 TRACE("(%p)->(%p)\n", This, pfFocus);
2612 if(!This->doc_node->nsdoc) {
2613 FIXME("Unimplemented for fragments.\n");
2614 return E_NOTIMPL;
2617 nsres = nsIDOMHTMLDocument_HasFocus(This->doc_node->nsdoc, &has_focus);
2618 assert(nsres == NS_OK);
2620 *pfFocus = has_focus ? VARIANT_TRUE : VARIANT_FALSE;
2621 return S_OK;
2624 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2626 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2628 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2630 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2633 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2635 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2637 TRACE("(%p)->(%p)\n", This, p);
2639 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2642 static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
2644 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2645 FIXME("(%p)->(%p)\n", This, p);
2646 return E_NOTIMPL;
2649 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2650 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2652 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2653 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2654 return E_NOTIMPL;
2657 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2659 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2660 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2661 return E_NOTIMPL;
2664 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2666 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2667 FIXME("(%p)->(%p)\n", This, p);
2668 return E_NOTIMPL;
2671 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2672 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2674 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2676 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2678 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2679 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2680 return E_NOTIMPL;
2683 return create_event_obj(ppEventObj);
2686 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2687 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2689 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2691 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2693 return dispatch_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2696 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2697 IHTMLRenderStyle **ppIHTMLRenderStyle)
2699 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2700 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2701 return E_NOTIMPL;
2704 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2706 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2707 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2708 return E_NOTIMPL;
2711 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2713 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2714 FIXME("(%p)->(%p)\n", This, p);
2715 return E_NOTIMPL;
2718 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2720 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2721 FIXME("(%p)->(%p)\n", This, p);
2722 return E_NOTIMPL;
2725 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2726 HTMLDocument4_QueryInterface,
2727 HTMLDocument4_AddRef,
2728 HTMLDocument4_Release,
2729 HTMLDocument4_GetTypeInfoCount,
2730 HTMLDocument4_GetTypeInfo,
2731 HTMLDocument4_GetIDsOfNames,
2732 HTMLDocument4_Invoke,
2733 HTMLDocument4_focus,
2734 HTMLDocument4_hasFocus,
2735 HTMLDocument4_put_onselectionchange,
2736 HTMLDocument4_get_onselectionchange,
2737 HTMLDocument4_get_namespace,
2738 HTMLDocument4_createDocumentFromUrl,
2739 HTMLDocument4_put_media,
2740 HTMLDocument4_get_media,
2741 HTMLDocument4_createEventObject,
2742 HTMLDocument4_fireEvent,
2743 HTMLDocument4_createRenderStyle,
2744 HTMLDocument4_put_oncontrolselect,
2745 HTMLDocument4_get_oncontrolselect,
2746 HTMLDocument4_get_URLEncoded
2749 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2751 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2754 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2755 REFIID riid, void **ppv)
2757 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2758 return htmldoc_query_interface(This, riid, ppv);
2761 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2763 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2764 return htmldoc_addref(This);
2767 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2769 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2770 return htmldoc_release(This);
2773 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2775 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2776 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2779 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2780 LCID lcid, ITypeInfo **ppTInfo)
2782 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2783 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2786 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2787 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2789 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2790 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2791 rgDispId);
2794 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2795 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2796 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2798 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2799 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2800 pDispParams, pVarResult, pExcepInfo, puArgErr);
2803 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2805 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2807 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2809 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
2812 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2814 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2816 TRACE("(%p)->(%p)\n", This, p);
2818 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
2821 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2823 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2824 FIXME("(%p)->(%p)\n", This, p);
2825 return E_NOTIMPL;
2828 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2830 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2831 HTMLDocumentNode *doc_node = This->doc_node;
2833 TRACE("(%p)->(%p)\n", This, p);
2835 if(!doc_node->dom_implementation) {
2836 HRESULT hres;
2838 hres = create_dom_implementation(&doc_node->dom_implementation);
2839 if(FAILED(hres))
2840 return hres;
2843 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2844 *p = doc_node->dom_implementation;
2845 return S_OK;
2848 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2849 IHTMLDOMAttribute **ppattribute)
2851 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2852 HTMLDOMAttribute *attr;
2853 HRESULT hres;
2855 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2857 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
2858 if(FAILED(hres))
2859 return hres;
2861 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2862 return S_OK;
2865 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2866 IHTMLDOMNode **ppRetNode)
2868 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2869 nsIDOMComment *nscomment;
2870 HTMLElement *elem;
2871 nsAString str;
2872 nsresult nsres;
2873 HRESULT hres;
2875 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2877 if(!This->doc_node->nsdoc) {
2878 WARN("NULL nsdoc\n");
2879 return E_UNEXPECTED;
2882 nsAString_InitDepend(&str, bstrdata);
2883 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2884 nsAString_Finish(&str);
2885 if(NS_FAILED(nsres)) {
2886 ERR("CreateTextNode failed: %08x\n", nsres);
2887 return E_FAIL;
2890 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2891 nsIDOMComment_Release(nscomment);
2892 if(FAILED(hres))
2893 return hres;
2895 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2896 return S_OK;
2899 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2901 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2903 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2905 return set_doc_event(This, EVENTID_FOCUSIN, &v);
2908 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2910 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2912 TRACE("(%p)->(%p)\n", This, p);
2914 return get_doc_event(This, EVENTID_FOCUSIN, p);
2917 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2919 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2921 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2923 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
2926 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2928 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2930 TRACE("(%p)->(%p)\n", This, p);
2932 return get_doc_event(This, EVENTID_FOCUSOUT, p);
2935 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2937 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2938 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2939 return E_NOTIMPL;
2942 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2944 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2945 FIXME("(%p)->(%p)\n", This, p);
2946 return E_NOTIMPL;
2949 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2951 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2952 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2953 return E_NOTIMPL;
2956 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2958 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2959 FIXME("(%p)->(%p)\n", This, p);
2960 return E_NOTIMPL;
2963 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2965 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2966 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2967 return E_NOTIMPL;
2970 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2972 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2973 FIXME("(%p)->(%p)\n", This, p);
2974 return E_NOTIMPL;
2977 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2979 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2980 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2981 return E_NOTIMPL;
2984 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2986 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2987 FIXME("(%p)->(%p)\n", This, p);
2988 return E_NOTIMPL;
2991 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2993 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2995 static const WCHAR BackCompatW[] = {'B','a','c','k','C','o','m','p','a','t',0};
2996 static const WCHAR CSS1CompatW[] = {'C','S','S','1','C','o','m','p','a','t',0};
2998 TRACE("(%p)->(%p)\n", This, p);
3000 *p = SysAllocString(This->doc_node->document_mode == COMPAT_MODE_QUIRKS ? BackCompatW : CSS1CompatW);
3001 return *p ? S_OK : E_OUTOFMEMORY;
3004 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
3005 HTMLDocument5_QueryInterface,
3006 HTMLDocument5_AddRef,
3007 HTMLDocument5_Release,
3008 HTMLDocument5_GetTypeInfoCount,
3009 HTMLDocument5_GetTypeInfo,
3010 HTMLDocument5_GetIDsOfNames,
3011 HTMLDocument5_Invoke,
3012 HTMLDocument5_put_onmousewheel,
3013 HTMLDocument5_get_onmousewheel,
3014 HTMLDocument5_get_doctype,
3015 HTMLDocument5_get_implementation,
3016 HTMLDocument5_createAttribute,
3017 HTMLDocument5_createComment,
3018 HTMLDocument5_put_onfocusin,
3019 HTMLDocument5_get_onfocusin,
3020 HTMLDocument5_put_onfocusout,
3021 HTMLDocument5_get_onfocusout,
3022 HTMLDocument5_put_onactivate,
3023 HTMLDocument5_get_onactivate,
3024 HTMLDocument5_put_ondeactivate,
3025 HTMLDocument5_get_ondeactivate,
3026 HTMLDocument5_put_onbeforeactivate,
3027 HTMLDocument5_get_onbeforeactivate,
3028 HTMLDocument5_put_onbeforedeactivate,
3029 HTMLDocument5_get_onbeforedeactivate,
3030 HTMLDocument5_get_compatMode
3033 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3035 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
3038 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
3039 REFIID riid, void **ppv)
3041 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3042 return htmldoc_query_interface(This, riid, ppv);
3045 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3047 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3048 return htmldoc_addref(This);
3051 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3053 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3054 return htmldoc_release(This);
3057 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3059 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3060 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3063 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
3064 LCID lcid, ITypeInfo **ppTInfo)
3066 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3067 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3070 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
3071 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3073 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3074 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3075 rgDispId);
3078 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
3079 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3080 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3082 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3083 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3084 pDispParams, pVarResult, pExcepInfo, puArgErr);
3087 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3088 IHTMLDocumentCompatibleInfoCollection **p)
3090 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3091 FIXME("(%p)->(%p)\n", This, p);
3092 return E_NOTIMPL;
3095 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3097 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3099 static const int docmode_values[] = {
3100 5, /* DOCMODE_QUIRKS */
3101 7, /* DOCMODE_IE7 */
3102 8, /* DOCMODE_IE8 */
3103 9, /* DOCMODE_IE8 */
3104 10, /* DOCMODE_IE10 */
3105 11 /* DOCMODE_IE11 */
3108 TRACE("(%p)->(%p)\n", This, p);
3110 if(!This->doc_node) {
3111 FIXME("NULL doc_node\n");
3112 return E_UNEXPECTED;
3115 assert(This->doc_node->document_mode < sizeof(docmode_values)/sizeof(*docmode_values));
3117 V_VT(p) = VT_I4;
3118 V_I4(p) = docmode_values[This->doc_node->document_mode];
3119 return S_OK;
3122 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3123 VARIANT *p)
3125 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3126 FIXME("(%p)->(%p)\n", This, p);
3127 return E_NOTIMPL;
3130 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3132 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3133 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3134 return E_NOTIMPL;
3137 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3138 VARIANT *p)
3140 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3141 FIXME("(%p)->(%p)\n", This, p);
3142 return E_NOTIMPL;
3145 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3147 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3148 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3149 return E_NOTIMPL;
3152 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3153 BSTR bstrId, IHTMLElement2 **p)
3155 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3156 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3157 return E_NOTIMPL;
3160 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3162 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3163 FIXME("(%p)->()\n", This);
3164 return E_NOTIMPL;
3167 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3168 HTMLDocument6_QueryInterface,
3169 HTMLDocument6_AddRef,
3170 HTMLDocument6_Release,
3171 HTMLDocument6_GetTypeInfoCount,
3172 HTMLDocument6_GetTypeInfo,
3173 HTMLDocument6_GetIDsOfNames,
3174 HTMLDocument6_Invoke,
3175 HTMLDocument6_get_compatible,
3176 HTMLDocument6_get_documentMode,
3177 HTMLDocument6_put_onstorage,
3178 HTMLDocument6_get_onstorage,
3179 HTMLDocument6_put_onstoragecommit,
3180 HTMLDocument6_get_onstoragecommit,
3181 HTMLDocument6_getElementById,
3182 HTMLDocument6_updateSettings
3185 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3187 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3190 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3192 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3193 return htmldoc_query_interface(This, riid, ppv);
3196 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3198 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3199 return htmldoc_addref(This);
3202 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3204 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3205 return htmldoc_release(This);
3208 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3210 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3211 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3214 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3215 LCID lcid, ITypeInfo **ppTInfo)
3217 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3218 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3221 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3222 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3224 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3225 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3226 rgDispId);
3229 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3230 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3231 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3233 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3234 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3235 pDispParams, pVarResult, pExcepInfo, puArgErr);
3238 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3240 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3241 FIXME("(%p)->(%p)\n", This, p);
3242 return E_NOTIMPL;
3245 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3247 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3248 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3249 return E_NOTIMPL;
3252 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3254 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3255 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3256 return E_NOTIMPL;
3259 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3260 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3262 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3263 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3264 return E_NOTIMPL;
3267 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3269 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3270 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3271 return E_NOTIMPL;
3274 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3275 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3277 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3278 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3279 return E_NOTIMPL;
3282 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3284 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3285 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3286 return E_NOTIMPL;
3289 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3291 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3292 FIXME("(%p)->(%p)\n", This, p);
3293 return E_NOTIMPL;
3296 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3298 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3299 FIXME("(%p)->(%p)\n", This, p);
3300 return E_NOTIMPL;
3303 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3305 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3306 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3307 return E_NOTIMPL;
3310 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3312 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3313 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3314 return E_NOTIMPL;
3317 static HRESULT WINAPI HTMLDocument7_getElementByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3319 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3320 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3321 return E_NOTIMPL;
3324 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3325 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3327 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3328 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3329 return E_NOTIMPL;
3332 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3334 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3335 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3336 return E_NOTIMPL;
3339 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3341 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3342 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3343 return E_NOTIMPL;
3346 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3348 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3349 FIXME("(%p)->(%p)\n", This, p);
3350 return E_NOTIMPL;
3353 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3355 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3356 FIXME("(%p)->(%p)\n", This, p);
3357 return E_NOTIMPL;
3360 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3362 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3363 FIXME("(%p)->(%p)\n", This, p);
3364 return E_NOTIMPL;
3367 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3369 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3370 FIXME("(%p)->(%p)\n", This, p);
3371 return E_NOTIMPL;
3374 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3376 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3377 FIXME("(%p)->(%x)\n", This, v);
3378 return E_NOTIMPL;
3381 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3383 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3384 FIXME("(%p)->(%p)\n", This, p);
3385 return E_NOTIMPL;
3388 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3390 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3391 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3392 return E_NOTIMPL;
3395 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3397 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3398 FIXME("(%p)->(%p)\n", This, p);
3399 return E_NOTIMPL;
3402 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3404 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3405 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3406 return E_NOTIMPL;
3409 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3411 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3412 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3413 return E_NOTIMPL;
3416 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3418 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3419 FIXME("(%p)->(%p)\n", This, p);
3420 return E_NOTIMPL;
3423 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3425 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3426 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3427 return E_NOTIMPL;
3430 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3432 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3433 FIXME("(%p)->(%p)\n", This, p);
3434 return E_NOTIMPL;
3437 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3439 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3440 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3441 return E_NOTIMPL;
3444 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3446 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3447 FIXME("(%p)->(%p)\n", This, p);
3448 return E_NOTIMPL;
3451 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3453 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3454 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3455 return E_NOTIMPL;
3458 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3460 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3461 FIXME("(%p)->(%p)\n", This, p);
3462 return E_NOTIMPL;
3465 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3467 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3468 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3469 return E_NOTIMPL;
3472 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3474 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3475 FIXME("(%p)->(%p)\n", This, p);
3476 return E_NOTIMPL;
3479 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3481 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3483 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3485 return set_doc_event(This, EVENTID_DRAG, &v);
3488 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3490 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3492 TRACE("(%p)->(%p)\n", This, p);
3494 return get_doc_event(This, EVENTID_DRAG, p);
3497 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3499 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3500 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3501 return E_NOTIMPL;
3504 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3506 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3507 FIXME("(%p)->(%p)\n", This, p);
3508 return E_NOTIMPL;
3511 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3513 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3514 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3515 return E_NOTIMPL;
3518 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3520 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3521 FIXME("(%p)->(%p)\n", This, p);
3522 return E_NOTIMPL;
3525 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3527 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3528 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3529 return E_NOTIMPL;
3532 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3534 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3535 FIXME("(%p)->(%p)\n", This, p);
3536 return E_NOTIMPL;
3539 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3541 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3542 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3543 return E_NOTIMPL;
3546 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3548 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3549 FIXME("(%p)->(%p)\n", This, p);
3550 return E_NOTIMPL;
3553 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3555 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3556 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3557 return E_NOTIMPL;
3560 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3562 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3563 FIXME("(%p)->(%p)\n", This, p);
3564 return E_NOTIMPL;
3567 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3569 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3570 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3571 return E_NOTIMPL;
3574 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
3576 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3577 FIXME("(%p)->(%p)\n", This, p);
3578 return E_NOTIMPL;
3581 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
3583 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3584 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3585 return E_NOTIMPL;
3588 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
3590 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3591 FIXME("(%p)->(%p)\n", This, p);
3592 return E_NOTIMPL;
3595 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
3597 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3598 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3599 return E_NOTIMPL;
3602 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
3604 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3605 FIXME("(%p)->(%p)\n", This, p);
3606 return E_NOTIMPL;
3609 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
3611 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3612 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3613 return E_NOTIMPL;
3616 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
3618 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3619 FIXME("(%p)->(%p)\n", This, p);
3620 return E_NOTIMPL;
3623 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
3625 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3626 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3627 return E_NOTIMPL;
3630 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
3632 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3633 FIXME("(%p)->(%p)\n", This, p);
3634 return E_NOTIMPL;
3637 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
3639 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3640 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3641 return E_NOTIMPL;
3644 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
3646 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3647 FIXME("(%p)->(%p)\n", This, p);
3648 return E_NOTIMPL;
3651 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
3653 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3654 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3655 return E_NOTIMPL;
3658 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
3660 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3661 FIXME("(%p)->(%p)\n", This, p);
3662 return E_NOTIMPL;
3665 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
3667 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3668 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3669 return E_NOTIMPL;
3672 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
3674 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3675 FIXME("(%p)->(%p)\n", This, p);
3676 return E_NOTIMPL;
3679 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
3681 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3682 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3683 return E_NOTIMPL;
3686 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
3688 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3689 FIXME("(%p)->(%p)\n", This, p);
3690 return E_NOTIMPL;
3693 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
3695 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3696 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3697 return E_NOTIMPL;
3700 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
3702 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3703 FIXME("(%p)->(%p)\n", This, p);
3704 return E_NOTIMPL;
3707 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
3709 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3710 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3711 return E_NOTIMPL;
3714 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
3716 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3717 FIXME("(%p)->(%p)\n", This, p);
3718 return E_NOTIMPL;
3721 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
3723 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3724 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3725 return E_NOTIMPL;
3728 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
3730 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3731 FIXME("(%p)->(%p)\n", This, p);
3732 return E_NOTIMPL;
3735 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
3737 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3738 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3739 return E_NOTIMPL;
3742 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
3744 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3745 FIXME("(%p)->(%p)\n", This, p);
3746 return E_NOTIMPL;
3749 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
3751 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3752 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3753 return E_NOTIMPL;
3756 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
3758 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3759 FIXME("(%p)->(%p)\n", This, p);
3760 return E_NOTIMPL;
3763 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
3765 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3766 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3767 return E_NOTIMPL;
3770 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
3772 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3773 FIXME("(%p)->(%p)\n", This, p);
3774 return E_NOTIMPL;
3777 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
3779 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3780 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3781 return E_NOTIMPL;
3784 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
3786 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3787 FIXME("(%p)->(%p)\n", This, p);
3788 return E_NOTIMPL;
3791 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
3793 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3795 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3797 return set_doc_event(This, EVENTID_SCROLL, &v);
3800 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
3802 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3804 TRACE("(%p)->(%p)\n", This, p);
3806 return get_doc_event(This, EVENTID_SCROLL, p);
3809 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
3811 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3812 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3813 return E_NOTIMPL;
3816 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
3818 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3819 FIXME("(%p)->(%p)\n", This, p);
3820 return E_NOTIMPL;
3823 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
3825 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3826 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3827 return E_NOTIMPL;
3830 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
3832 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3833 FIXME("(%p)->(%p)\n", This, p);
3834 return E_NOTIMPL;
3837 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
3839 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3840 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3841 return E_NOTIMPL;
3844 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
3846 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3847 FIXME("(%p)->(%p)\n", This, p);
3848 return E_NOTIMPL;
3851 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
3853 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3854 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3855 return E_NOTIMPL;
3858 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
3860 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3861 FIXME("(%p)->(%p)\n", This, p);
3862 return E_NOTIMPL;
3865 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
3867 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3868 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3869 return E_NOTIMPL;
3872 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
3874 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3875 FIXME("(%p)->(%p)\n", This, p);
3876 return E_NOTIMPL;
3879 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
3881 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3882 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3883 return E_NOTIMPL;
3886 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
3888 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3889 FIXME("(%p)->(%p)\n", This, p);
3890 return E_NOTIMPL;
3893 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
3895 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3896 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3897 return E_NOTIMPL;
3900 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
3902 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3903 FIXME("(%p)->(%p)\n", This, p);
3904 return E_NOTIMPL;
3907 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
3909 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3910 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3911 return E_NOTIMPL;
3914 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
3916 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3917 FIXME("(%p)->(%p)\n", This, p);
3918 return E_NOTIMPL;
3921 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
3923 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3924 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3925 return E_NOTIMPL;
3928 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
3930 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3931 FIXME("(%p)->(%p)\n", This, p);
3932 return E_NOTIMPL;
3935 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
3937 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3938 FIXME("(%p)\n", This);
3939 return E_NOTIMPL;
3942 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
3943 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
3945 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3946 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
3947 return E_NOTIMPL;
3950 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3952 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3953 FIXME("(%p)->(%p)\n", This, p);
3954 return E_NOTIMPL;
3957 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
3959 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3960 FIXME("(%p)->(%p)\n", This, v);
3961 return E_NOTIMPL;
3964 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
3966 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3967 FIXME("(%p)->(%p)\n", This, p);
3968 return E_NOTIMPL;
3971 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
3973 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3974 FIXME("(%p)->(%p)\n", This, p);
3975 return E_NOTIMPL;
3978 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
3979 HTMLDocument7_QueryInterface,
3980 HTMLDocument7_AddRef,
3981 HTMLDocument7_Release,
3982 HTMLDocument7_GetTypeInfoCount,
3983 HTMLDocument7_GetTypeInfo,
3984 HTMLDocument7_GetIDsOfNames,
3985 HTMLDocument7_Invoke,
3986 HTMLDocument7_get_defaultView,
3987 HTMLDocument7_createCDATASection,
3988 HTMLDocument7_getSelection,
3989 HTMLDocument7_getElementsByTagNameNS,
3990 HTMLDocument7_createElementNS,
3991 HTMLDocument7_createAttributeNS,
3992 HTMLDocument7_put_onmsthumbnailclick,
3993 HTMLDocument7_get_onmsthumbnailclick,
3994 HTMLDocument7_get_characterSet,
3995 HTMLDocument7_createElement,
3996 HTMLDocument7_createAttribute,
3997 HTMLDocument7_getElementByClassName,
3998 HTMLDocument7_createProcessingInstruction,
3999 HTMLDocument7_adoptNode,
4000 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4001 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4002 HTMLDocument7_get_all,
4003 HTMLDocument7_get_inputEncoding,
4004 HTMLDocument7_get_xmlEncoding,
4005 HTMLDocument7_put_xmlStandalone,
4006 HTMLDocument7_get_xmlStandalone,
4007 HTMLDocument7_put_xmlVersion,
4008 HTMLDocument7_get_xmlVersion,
4009 HTMLDocument7_hasAttributes,
4010 HTMLDocument7_put_onabort,
4011 HTMLDocument7_get_onabort,
4012 HTMLDocument7_put_onblur,
4013 HTMLDocument7_get_onblur,
4014 HTMLDocument7_put_oncanplay,
4015 HTMLDocument7_get_oncanplay,
4016 HTMLDocument7_put_oncanplaythrough,
4017 HTMLDocument7_get_oncanplaythrough,
4018 HTMLDocument7_put_onchange,
4019 HTMLDocument7_get_onchange,
4020 HTMLDocument7_put_ondrag,
4021 HTMLDocument7_get_ondrag,
4022 HTMLDocument7_put_ondragend,
4023 HTMLDocument7_get_ondragend,
4024 HTMLDocument7_put_ondragenter,
4025 HTMLDocument7_get_ondragenter,
4026 HTMLDocument7_put_ondragleave,
4027 HTMLDocument7_get_ondragleave,
4028 HTMLDocument7_put_ondragover,
4029 HTMLDocument7_get_ondragover,
4030 HTMLDocument7_put_ondrop,
4031 HTMLDocument7_get_ondrop,
4032 HTMLDocument7_put_ondurationchange,
4033 HTMLDocument7_get_ondurationchange,
4034 HTMLDocument7_put_onemptied,
4035 HTMLDocument7_get_onemptied,
4036 HTMLDocument7_put_onended,
4037 HTMLDocument7_get_onended,
4038 HTMLDocument7_put_onerror,
4039 HTMLDocument7_get_onerror,
4040 HTMLDocument7_put_onfocus,
4041 HTMLDocument7_get_onfocus,
4042 HTMLDocument7_put_oninput,
4043 HTMLDocument7_get_oninput,
4044 HTMLDocument7_put_onload,
4045 HTMLDocument7_get_onload,
4046 HTMLDocument7_put_onloadeddata,
4047 HTMLDocument7_get_onloadeddata,
4048 HTMLDocument7_put_onloadedmetadata,
4049 HTMLDocument7_get_onloadedmetadata,
4050 HTMLDocument7_put_onloadstart,
4051 HTMLDocument7_get_onloadstart,
4052 HTMLDocument7_put_onpause,
4053 HTMLDocument7_get_onpause,
4054 HTMLDocument7_put_onplay,
4055 HTMLDocument7_get_onplay,
4056 HTMLDocument7_put_onplaying,
4057 HTMLDocument7_get_onplaying,
4058 HTMLDocument7_put_onprogress,
4059 HTMLDocument7_get_onprogress,
4060 HTMLDocument7_put_onratechange,
4061 HTMLDocument7_get_onratechange,
4062 HTMLDocument7_put_onreset,
4063 HTMLDocument7_get_onreset,
4064 HTMLDocument7_put_onscroll,
4065 HTMLDocument7_get_onscroll,
4066 HTMLDocument7_put_onseekend,
4067 HTMLDocument7_get_onseekend,
4068 HTMLDocument7_put_onseeking,
4069 HTMLDocument7_get_onseeking,
4070 HTMLDocument7_put_onselect,
4071 HTMLDocument7_get_onselect,
4072 HTMLDocument7_put_onstalled,
4073 HTMLDocument7_get_onstalled,
4074 HTMLDocument7_put_onsubmit,
4075 HTMLDocument7_get_onsubmit,
4076 HTMLDocument7_put_onsuspend,
4077 HTMLDocument7_get_onsuspend,
4078 HTMLDocument7_put_ontimeupdate,
4079 HTMLDocument7_get_ontimeupdate,
4080 HTMLDocument7_put_onvolumechange,
4081 HTMLDocument7_get_onvolumechange,
4082 HTMLDocument7_put_onwaiting,
4083 HTMLDocument7_get_onwaiting,
4084 HTMLDocument7_normalize,
4085 HTMLDocument7_importNode,
4086 HTMLDocument7_get_parentWindow,
4087 HTMLDocument7_put_body,
4088 HTMLDocument7_get_body,
4089 HTMLDocument7_get_head
4092 static inline HTMLDocument *impl_from_IDocumentSelector(IDocumentSelector *iface)
4094 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentSelector_iface);
4097 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4099 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4100 return htmldoc_query_interface(This, riid, ppv);
4103 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4105 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4106 return htmldoc_addref(This);
4109 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4111 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4112 return htmldoc_release(This);
4115 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4117 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4118 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4121 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4122 LCID lcid, ITypeInfo **ppTInfo)
4124 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4125 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4128 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4129 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4131 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4132 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4133 rgDispId);
4136 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4137 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4139 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4140 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4141 pDispParams, pVarResult, pExcepInfo, puArgErr);
4144 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4146 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4147 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4148 return E_NOTIMPL;
4151 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4153 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4154 nsIDOMNodeList *node_list;
4155 nsAString nsstr;
4156 nsresult nsres;
4158 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4160 nsAString_InitDepend(&nsstr, v);
4161 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &nsstr, &node_list);
4162 nsAString_Finish(&nsstr);
4163 if(NS_FAILED(nsres)) {
4164 ERR("QuerySelectorAll failed: %08x\n", nsres);
4165 return E_FAIL;
4168 *pel = create_child_collection(This->doc_node, node_list);
4169 nsIDOMNodeList_Release(node_list);
4170 return *pel ? S_OK : E_OUTOFMEMORY;
4173 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4174 DocumentSelector_QueryInterface,
4175 DocumentSelector_AddRef,
4176 DocumentSelector_Release,
4177 DocumentSelector_GetTypeInfoCount,
4178 DocumentSelector_GetTypeInfo,
4179 DocumentSelector_GetIDsOfNames,
4180 DocumentSelector_Invoke,
4181 DocumentSelector_querySelector,
4182 DocumentSelector_querySelectorAll
4185 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4187 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4189 if(This->window)
4190 update_doc_cp_events(This->doc_node, cp);
4193 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4195 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4198 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4200 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4201 return htmldoc_query_interface(This, riid, ppv);
4204 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4206 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4207 return htmldoc_addref(This);
4210 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4212 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4213 return htmldoc_release(This);
4216 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4218 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4219 return S_FALSE;
4222 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4223 SupportErrorInfo_QueryInterface,
4224 SupportErrorInfo_AddRef,
4225 SupportErrorInfo_Release,
4226 SupportErrorInfo_InterfaceSupportsErrorInfo
4229 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4231 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4234 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4236 nsIDOMNodeList *node_list;
4237 nsAString name_str;
4238 UINT32 len;
4239 unsigned i;
4240 nsresult nsres;
4242 if(!This->nsdoc)
4243 return DISP_E_UNKNOWNNAME;
4245 nsAString_InitDepend(&name_str, name);
4246 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4247 nsAString_Finish(&name_str);
4248 if(NS_FAILED(nsres))
4249 return E_FAIL;
4251 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4252 nsIDOMNodeList_Release(node_list);
4253 if(NS_FAILED(nsres))
4254 return E_FAIL;
4256 if(!len)
4257 return DISP_E_UNKNOWNNAME;
4259 for(i=0; i < This->elem_vars_cnt; i++) {
4260 if(!strcmpW(name, This->elem_vars[i])) {
4261 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4262 return S_OK;
4266 if(This->elem_vars_cnt == This->elem_vars_size) {
4267 WCHAR **new_vars;
4269 if(This->elem_vars_size) {
4270 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4271 if(!new_vars)
4272 return E_OUTOFMEMORY;
4273 This->elem_vars_size *= 2;
4274 }else {
4275 new_vars = heap_alloc(16*sizeof(WCHAR*));
4276 if(!new_vars)
4277 return E_OUTOFMEMORY;
4278 This->elem_vars_size = 16;
4281 This->elem_vars = new_vars;
4284 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4285 if(!This->elem_vars[This->elem_vars_cnt])
4286 return E_OUTOFMEMORY;
4288 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4289 return S_OK;
4292 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4294 HTMLDocument *This = impl_from_IDispatchEx(iface);
4296 return htmldoc_query_interface(This, riid, ppv);
4299 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4301 HTMLDocument *This = impl_from_IDispatchEx(iface);
4303 return htmldoc_addref(This);
4306 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4308 HTMLDocument *This = impl_from_IDispatchEx(iface);
4310 return htmldoc_release(This);
4313 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4315 HTMLDocument *This = impl_from_IDispatchEx(iface);
4317 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4320 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4321 LCID lcid, ITypeInfo **ppTInfo)
4323 HTMLDocument *This = impl_from_IDispatchEx(iface);
4325 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4328 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4329 LPOLESTR *rgszNames, UINT cNames,
4330 LCID lcid, DISPID *rgDispId)
4332 HTMLDocument *This = impl_from_IDispatchEx(iface);
4334 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4337 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4338 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4339 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4341 HTMLDocument *This = impl_from_IDispatchEx(iface);
4343 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4344 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4346 switch(dispIdMember) {
4347 case DISPID_READYSTATE:
4348 TRACE("DISPID_READYSTATE\n");
4350 if(!(wFlags & DISPATCH_PROPERTYGET))
4351 return E_INVALIDARG;
4353 V_VT(pVarResult) = VT_I4;
4354 V_I4(pVarResult) = This->window->readystate;
4355 return S_OK;
4358 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
4359 pVarResult, pExcepInfo, puArgErr);
4362 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4364 HTMLDocument *This = impl_from_IDispatchEx(iface);
4365 HRESULT hres;
4367 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4368 if(hres != DISP_E_UNKNOWNNAME)
4369 return hres;
4371 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4374 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4375 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4377 HTMLDocument *This = impl_from_IDispatchEx(iface);
4379 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
4380 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
4381 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4384 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4387 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4389 HTMLDocument *This = impl_from_IDispatchEx(iface);
4391 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4394 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4396 HTMLDocument *This = impl_from_IDispatchEx(iface);
4398 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4401 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4403 HTMLDocument *This = impl_from_IDispatchEx(iface);
4405 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4408 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4410 HTMLDocument *This = impl_from_IDispatchEx(iface);
4412 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4415 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4417 HTMLDocument *This = impl_from_IDispatchEx(iface);
4419 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
4422 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
4424 HTMLDocument *This = impl_from_IDispatchEx(iface);
4426 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
4429 static const IDispatchExVtbl DocDispatchExVtbl = {
4430 DocDispatchEx_QueryInterface,
4431 DocDispatchEx_AddRef,
4432 DocDispatchEx_Release,
4433 DocDispatchEx_GetTypeInfoCount,
4434 DocDispatchEx_GetTypeInfo,
4435 DocDispatchEx_GetIDsOfNames,
4436 DocDispatchEx_Invoke,
4437 DocDispatchEx_GetDispID,
4438 DocDispatchEx_InvokeEx,
4439 DocDispatchEx_DeleteMemberByName,
4440 DocDispatchEx_DeleteMemberByDispID,
4441 DocDispatchEx_GetMemberProperties,
4442 DocDispatchEx_GetMemberName,
4443 DocDispatchEx_GetNextDispID,
4444 DocDispatchEx_GetNameSpaceParent
4447 static inline HTMLDocument *impl_from_IProvideClassInfo(IProvideClassInfo *iface)
4449 return CONTAINING_RECORD(iface, HTMLDocument, IProvideClassInfo_iface);
4452 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideClassInfo *iface,
4453 REFIID riid, void **ppv)
4455 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4456 return htmldoc_query_interface(This, riid, ppv);
4459 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideClassInfo *iface)
4461 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4462 return htmldoc_addref(This);
4465 static ULONG WINAPI ProvideClassInfo_Release(IProvideClassInfo *iface)
4467 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4468 return htmldoc_release(This);
4471 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideClassInfo* iface,
4472 ITypeInfo **ppTI)
4474 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4475 TRACE("(%p)->(%p)\n", This, ppTI);
4476 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
4479 static const IProvideClassInfoVtbl ProvideClassInfoVtbl = {
4480 ProvideClassInfo_QueryInterface,
4481 ProvideClassInfo_AddRef,
4482 ProvideClassInfo_Release,
4483 ProvideClassInfo_GetClassInfo
4486 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
4488 *ppv = NULL;
4490 if(IsEqualGUID(&IID_IUnknown, riid))
4491 *ppv = &This->IHTMLDocument2_iface;
4492 else if(IsEqualGUID(&IID_IDispatch, riid))
4493 *ppv = &This->IDispatchEx_iface;
4494 else if(IsEqualGUID(&IID_IDispatchEx, riid))
4495 *ppv = &This->IDispatchEx_iface;
4496 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
4497 *ppv = &This->IHTMLDocument2_iface;
4498 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
4499 *ppv = &This->IHTMLDocument2_iface;
4500 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
4501 *ppv = &This->IHTMLDocument3_iface;
4502 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
4503 *ppv = &This->IHTMLDocument4_iface;
4504 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
4505 *ppv = &This->IHTMLDocument5_iface;
4506 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
4507 *ppv = &This->IHTMLDocument6_iface;
4508 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
4509 *ppv = &This->IHTMLDocument7_iface;
4510 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
4511 *ppv = &This->IDocumentSelector_iface;
4512 else if(IsEqualGUID(&IID_IPersist, riid))
4513 *ppv = &This->IPersistFile_iface;
4514 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
4515 *ppv = &This->IPersistMoniker_iface;
4516 else if(IsEqualGUID(&IID_IPersistFile, riid))
4517 *ppv = &This->IPersistFile_iface;
4518 else if(IsEqualGUID(&IID_IMonikerProp, riid))
4519 *ppv = &This->IMonikerProp_iface;
4520 else if(IsEqualGUID(&IID_IOleObject, riid))
4521 *ppv = &This->IOleObject_iface;
4522 else if(IsEqualGUID(&IID_IOleDocument, riid))
4523 *ppv = &This->IOleDocument_iface;
4524 else if(IsEqualGUID(&IID_IOleDocumentView, riid))
4525 *ppv = &This->IOleDocumentView_iface;
4526 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
4527 *ppv = &This->IOleInPlaceActiveObject_iface;
4528 else if(IsEqualGUID(&IID_IViewObject, riid))
4529 *ppv = &This->IViewObjectEx_iface;
4530 else if(IsEqualGUID(&IID_IViewObject2, riid))
4531 *ppv = &This->IViewObjectEx_iface;
4532 else if(IsEqualGUID(&IID_IViewObjectEx, riid))
4533 *ppv = &This->IViewObjectEx_iface;
4534 else if(IsEqualGUID(&IID_IOleWindow, riid))
4535 *ppv = &This->IOleInPlaceActiveObject_iface;
4536 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
4537 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4538 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
4539 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4540 else if(IsEqualGUID(&IID_IServiceProvider, riid))
4541 *ppv = &This->IServiceProvider_iface;
4542 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
4543 *ppv = &This->IOleCommandTarget_iface;
4544 else if(IsEqualGUID(&IID_IOleControl, riid))
4545 *ppv = &This->IOleControl_iface;
4546 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
4547 *ppv = &This->IHlinkTarget_iface;
4548 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
4549 *ppv = &This->cp_container.IConnectionPointContainer_iface;
4550 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
4551 *ppv = &This->IPersistStreamInit_iface;
4552 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
4553 *ppv = &This->IHTMLDocument2_iface;
4554 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
4555 *ppv = &This->ISupportErrorInfo_iface;
4556 else if(IsEqualGUID(&IID_IPersistHistory, riid))
4557 *ppv = &This->IPersistHistory_iface;
4558 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
4559 *ppv = &This->IObjectWithSite_iface;
4560 else if(IsEqualGUID(&IID_IOleContainer, riid))
4561 *ppv = &This->IOleContainer_iface;
4562 else if(IsEqualGUID(&IID_IObjectSafety, riid))
4563 *ppv = &This->IObjectSafety_iface;
4564 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
4565 *ppv = &This->IProvideClassInfo_iface;
4566 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
4567 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
4568 *ppv = NULL;
4569 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
4570 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
4571 *ppv = NULL;
4572 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
4573 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
4574 *ppv = NULL;
4575 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
4576 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
4577 *ppv = NULL;
4578 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
4579 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
4580 *ppv = NULL;
4581 }else {
4582 return FALSE;
4585 if(*ppv)
4586 IUnknown_AddRef((IUnknown*)*ppv);
4587 return TRUE;
4590 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
4592 static const cpc_entry_t HTMLDocument_cpc[] = {
4593 {&IID_IDispatch, &HTMLDocumentEvents_data},
4594 {&IID_IPropertyNotifySink},
4595 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
4596 {&DIID_HTMLDocumentEvents2},
4597 {NULL}
4600 static void init_doc(HTMLDocument *doc, IUnknown *outer, IDispatchEx *dispex)
4602 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
4603 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
4604 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
4605 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
4606 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
4607 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
4608 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
4609 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
4610 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
4611 doc->IProvideClassInfo_iface.lpVtbl = &ProvideClassInfoVtbl;
4613 doc->outer_unk = outer;
4614 doc->dispex = dispex;
4615 doc->task_magic = get_task_target_magic();
4617 HTMLDocument_Persist_Init(doc);
4618 HTMLDocument_OleCmd_Init(doc);
4619 HTMLDocument_OleObj_Init(doc);
4620 HTMLDocument_View_Init(doc);
4621 HTMLDocument_Window_Init(doc);
4622 HTMLDocument_Service_Init(doc);
4623 HTMLDocument_Hlink_Init(doc);
4625 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
4628 static void destroy_htmldoc(HTMLDocument *This)
4630 remove_target_tasks(This->task_magic);
4632 ConnectionPointContainer_Destroy(&This->cp_container);
4635 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
4637 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
4640 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
4642 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4644 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4646 if(htmldoc_qi(&This->basedoc, riid, ppv))
4647 return *ppv ? S_OK : E_NOINTERFACE;
4649 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
4650 *ppv = &This->IInternetHostSecurityManager_iface;
4651 else
4652 return HTMLDOMNode_QI(&This->node, riid, ppv);
4654 IUnknown_AddRef((IUnknown*)*ppv);
4655 return S_OK;
4658 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
4660 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4661 unsigned i;
4663 for(i=0; i < This->elem_vars_cnt; i++)
4664 heap_free(This->elem_vars[i]);
4665 heap_free(This->elem_vars);
4667 detach_events(This);
4668 if(This->catmgr)
4669 ICatInformation_Release(This->catmgr);
4671 detach_selection(This);
4672 detach_ranges(This);
4674 while(!list_empty(&This->plugin_hosts))
4675 detach_plugin_host(LIST_ENTRY(list_head(&This->plugin_hosts), PluginHost, entry));
4677 if(!This->nsdoc && This->window) {
4678 /* document fragments own reference to inner window */
4679 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
4680 This->window = NULL;
4683 heap_free(This->event_vector);
4684 destroy_htmldoc(&This->basedoc);
4687 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4689 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4690 FIXME("%p\n", This);
4691 return E_NOTIMPL;
4694 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
4696 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4698 if(This->nsdoc)
4699 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
4702 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
4704 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4706 if(This->nsdoc) {
4707 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
4709 release_document_mutation(This);
4710 This->nsdoc = NULL;
4711 nsIDOMHTMLDocument_Release(nsdoc);
4712 This->window = NULL;
4716 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
4717 HTMLDocumentNode_QI,
4718 HTMLDocumentNode_destructor,
4719 HTMLDocument_cpc,
4720 HTMLDocumentNode_clone,
4721 NULL,
4722 NULL,
4723 NULL,
4724 NULL,
4725 NULL,
4726 NULL,
4727 NULL,
4728 NULL,
4729 NULL,
4730 NULL,
4731 NULL,
4732 HTMLDocumentNode_traverse,
4733 HTMLDocumentNode_unlink
4736 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4738 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4739 HTMLDocumentNode *new_node;
4740 HRESULT hres;
4742 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
4743 if(FAILED(hres))
4744 return hres;
4746 *ret = &new_node->node;
4747 return S_OK;
4750 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
4752 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
4755 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4756 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4758 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4759 nsIDOMNodeList *node_list;
4760 nsAString name_str;
4761 nsIDOMNode *nsnode;
4762 HTMLDOMNode *node;
4763 unsigned i;
4764 nsresult nsres;
4765 HRESULT hres;
4767 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
4768 FIXME("unsupported flags %x\n", flags);
4769 return E_NOTIMPL;
4772 i = id - MSHTML_DISPID_CUSTOM_MIN;
4774 if(!This->nsdoc || i >= This->elem_vars_cnt)
4775 return DISP_E_UNKNOWNNAME;
4777 nsAString_InitDepend(&name_str, This->elem_vars[i]);
4778 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4779 nsAString_Finish(&name_str);
4780 if(NS_FAILED(nsres))
4781 return E_FAIL;
4783 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
4784 nsIDOMNodeList_Release(node_list);
4785 if(NS_FAILED(nsres) || !nsnode)
4786 return DISP_E_UNKNOWNNAME;
4788 hres = get_node(This, nsnode, TRUE, &node);
4789 if(FAILED(hres))
4790 return hres;
4792 V_VT(res) = VT_DISPATCH;
4793 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
4794 return S_OK;
4797 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, int eid)
4799 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4800 ensure_doc_nsevent_handler(This, eid);
4803 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl = {
4804 NULL,
4805 NULL,
4806 HTMLDocumentNode_invoke,
4807 NULL,
4808 NULL,
4809 HTMLDocumentNode_bind_event
4812 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
4813 HTMLDocumentNode_QI,
4814 HTMLDocumentNode_destructor,
4815 HTMLDocument_cpc,
4816 HTMLDocumentFragment_clone
4819 static const tid_t HTMLDocumentNode_iface_tids[] = {
4820 IHTMLDOMNode_tid,
4821 IHTMLDOMNode2_tid,
4822 IHTMLDocument2_tid,
4823 IHTMLDocument3_tid,
4824 IHTMLDocument4_tid,
4825 IHTMLDocument5_tid,
4826 IHTMLDocument6_tid,
4827 IDocumentSelector_tid,
4831 static dispex_static_data_t HTMLDocumentNode_dispex = {
4832 &HTMLDocumentNode_dispex_vtbl,
4833 DispHTMLDocument_tid,
4834 HTMLDocumentNode_iface_tids
4837 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
4839 HTMLDocumentNode *doc;
4841 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
4842 if(!doc)
4843 return NULL;
4845 doc->ref = 1;
4846 doc->basedoc.doc_node = doc;
4847 doc->basedoc.doc_obj = doc_obj;
4848 doc->basedoc.window = window->base.outer_window;
4849 doc->window = window;
4851 init_dispex(&doc->node.event_target.dispex, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4852 &HTMLDocumentNode_dispex);
4853 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4854 &doc->node.event_target.dispex.IDispatchEx_iface);
4855 HTMLDocumentNode_SecMgr_Init(doc);
4857 list_init(&doc->selection_list);
4858 list_init(&doc->range_list);
4859 list_init(&doc->plugin_hosts);
4861 return doc;
4864 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLInnerWindow *window, HTMLDocumentNode **ret)
4866 HTMLDocumentNode *doc;
4868 doc = alloc_doc_node(doc_obj, window);
4869 if(!doc)
4870 return E_OUTOFMEMORY;
4872 if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
4873 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
4875 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
4877 nsIDOMHTMLDocument_AddRef(nsdoc);
4878 doc->nsdoc = nsdoc;
4880 init_document_mutation(doc);
4881 doc_init_events(doc);
4883 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
4884 doc->node.cp_container = &doc->basedoc.cp_container;
4886 *ret = doc;
4887 return S_OK;
4890 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
4892 HTMLDocumentNode *doc_frag;
4894 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
4895 if(!doc_frag)
4896 return E_OUTOFMEMORY;
4898 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
4900 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
4901 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
4902 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
4904 *ret = doc_frag;
4905 return S_OK;
4908 static inline HTMLDocumentObj *impl_from_IUnknown(IUnknown *iface)
4910 return CONTAINING_RECORD(iface, HTMLDocumentObj, IUnknown_outer);
4913 static HRESULT WINAPI HTMLDocumentObj_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
4915 HTMLDocumentObj *This = impl_from_IUnknown(iface);
4917 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4919 if(IsEqualGUID(&IID_IUnknown, riid)) {
4920 *ppv = &This->IUnknown_outer;
4921 }else if(htmldoc_qi(&This->basedoc, riid, ppv)) {
4922 return *ppv ? S_OK : E_NOINTERFACE;
4923 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
4924 *ppv = &This->ICustomDoc_iface;
4925 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
4926 *ppv = &This->ITargetContainer_iface;
4927 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4928 return *ppv ? S_OK : E_NOINTERFACE;
4929 }else {
4930 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
4931 *ppv = NULL;
4932 return E_NOINTERFACE;
4935 IUnknown_AddRef((IUnknown*)*ppv);
4936 return S_OK;
4939 static ULONG WINAPI HTMLDocumentObj_AddRef(IUnknown *iface)
4941 HTMLDocumentObj *This = impl_from_IUnknown(iface);
4942 ULONG ref = InterlockedIncrement(&This->ref);
4944 TRACE("(%p) ref = %u\n", This, ref);
4946 return ref;
4949 static ULONG WINAPI HTMLDocumentObj_Release(IUnknown *iface)
4951 HTMLDocumentObj *This = impl_from_IUnknown(iface);
4952 ULONG ref = InterlockedDecrement(&This->ref);
4954 TRACE("(%p) ref = %u\n", This, ref);
4956 if(!ref) {
4957 nsIDOMWindowUtils *window_utils = NULL;
4959 if(This->basedoc.window && This->basedoc.window->nswindow)
4960 get_nsinterface((nsISupports*)This->basedoc.window->nswindow, &IID_nsIDOMWindowUtils, (void**)&window_utils);
4962 if(This->basedoc.doc_node) {
4963 This->basedoc.doc_node->basedoc.doc_obj = NULL;
4964 htmldoc_release(&This->basedoc.doc_node->basedoc);
4966 if(This->basedoc.window) {
4967 This->basedoc.window->doc_obj = NULL;
4968 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
4970 if(This->basedoc.advise_holder)
4971 IOleAdviseHolder_Release(This->basedoc.advise_holder);
4973 if(This->view_sink)
4974 IAdviseSink_Release(This->view_sink);
4975 if(This->client)
4976 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
4977 if(This->hostui)
4978 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
4979 if(This->in_place_active)
4980 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
4981 if(This->ipsite)
4982 IOleDocumentView_SetInPlaceSite(&This->basedoc.IOleDocumentView_iface, NULL);
4983 if(This->undomgr)
4984 IOleUndoManager_Release(This->undomgr);
4985 if(This->editsvcs)
4986 IHTMLEditServices_Release(This->editsvcs);
4987 if(This->tooltips_hwnd)
4988 DestroyWindow(This->tooltips_hwnd);
4990 if(This->hwnd)
4991 DestroyWindow(This->hwnd);
4992 heap_free(This->mime);
4994 destroy_htmldoc(&This->basedoc);
4995 release_dispex(&This->dispex);
4997 if(This->nscontainer)
4998 NSContainer_Release(This->nscontainer);
4999 heap_free(This);
5001 /* Force cycle collection */
5002 if(window_utils) {
5003 nsIDOMWindowUtils_CycleCollect(window_utils, NULL, 0);
5004 nsIDOMWindowUtils_Release(window_utils);
5008 return ref;
5011 static const IUnknownVtbl HTMLDocumentObjVtbl = {
5012 HTMLDocumentObj_QueryInterface,
5013 HTMLDocumentObj_AddRef,
5014 HTMLDocumentObj_Release
5017 /**********************************************************
5018 * ICustomDoc implementation
5021 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
5023 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
5026 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
5028 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5030 return htmldoc_query_interface(&This->basedoc, riid, ppv);
5033 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
5035 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5037 return htmldoc_addref(&This->basedoc);
5040 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
5042 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5044 return htmldoc_release(&This->basedoc);
5047 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
5049 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5050 IOleCommandTarget *cmdtrg;
5051 HRESULT hres;
5053 TRACE("(%p)->(%p)\n", This, pUIHandler);
5055 if(This->custom_hostui && This->hostui == pUIHandler)
5056 return S_OK;
5058 This->custom_hostui = TRUE;
5060 if(This->hostui)
5061 IDocHostUIHandler_Release(This->hostui);
5062 if(pUIHandler)
5063 IDocHostUIHandler_AddRef(pUIHandler);
5064 This->hostui = pUIHandler;
5065 if(!pUIHandler)
5066 return S_OK;
5068 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
5069 if(SUCCEEDED(hres)) {
5070 FIXME("custom UI handler supports IOleCommandTarget\n");
5071 IOleCommandTarget_Release(cmdtrg);
5074 return S_OK;
5077 static const ICustomDocVtbl CustomDocVtbl = {
5078 CustomDoc_QueryInterface,
5079 CustomDoc_AddRef,
5080 CustomDoc_Release,
5081 CustomDoc_SetUIHandler
5084 static const tid_t HTMLDocumentObj_iface_tids[] = {
5085 IHTMLDocument2_tid,
5086 IHTMLDocument3_tid,
5087 IHTMLDocument4_tid,
5088 IHTMLDocument5_tid,
5091 static dispex_static_data_t HTMLDocumentObj_dispex = {
5092 NULL,
5093 DispHTMLDocument_tid,
5094 HTMLDocumentObj_iface_tids
5097 static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID riid, void **ppv)
5099 mozIDOMWindowProxy *mozwindow;
5100 HTMLDocumentObj *doc;
5101 nsIDOMWindow *nswindow = NULL;
5102 nsresult nsres;
5103 HRESULT hres;
5105 if(outer && !IsEqualGUID(&IID_IUnknown, riid)) {
5106 *ppv = NULL;
5107 return E_INVALIDARG;
5110 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
5111 if(!doc)
5112 return E_OUTOFMEMORY;
5114 doc->ref = 1;
5115 doc->IUnknown_outer.lpVtbl = &HTMLDocumentObjVtbl;
5116 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
5118 init_dispex(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex);
5119 init_doc(&doc->basedoc, outer ? outer : &doc->IUnknown_outer, &doc->dispex.IDispatchEx_iface);
5120 TargetContainer_Init(doc);
5121 doc->basedoc.doc_obj = doc;
5122 doc->is_mhtml = is_mhtml;
5124 doc->usermode = UNKNOWN_USERMODE;
5126 init_binding_ui(doc);
5128 hres = create_nscontainer(doc, &doc->nscontainer);
5129 if(FAILED(hres)) {
5130 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
5131 htmldoc_release(&doc->basedoc);
5132 return hres;
5135 if(IsEqualGUID(&IID_IUnknown, riid)) {
5136 *ppv = &doc->IUnknown_outer;
5137 }else {
5138 hres = htmldoc_query_interface(&doc->basedoc, riid, ppv);
5139 htmldoc_release(&doc->basedoc);
5140 if(FAILED(hres))
5141 return hres;
5144 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &mozwindow);
5145 if(NS_FAILED(nsres))
5146 ERR("GetContentDOMWindow failed: %08x\n", nsres);
5148 nsres = mozIDOMWindowProxy_QueryInterface(mozwindow, &IID_nsIDOMWindow, (void**)&nswindow);
5149 mozIDOMWindowProxy_Release(mozwindow);
5150 assert(nsres == NS_OK);
5152 hres = HTMLOuterWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
5153 if(nswindow)
5154 nsIDOMWindow_Release(nswindow);
5155 if(FAILED(hres)) {
5156 htmldoc_release(&doc->basedoc);
5157 return hres;
5160 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
5161 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
5162 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
5165 get_thread_hwnd();
5167 return S_OK;
5170 HRESULT HTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
5172 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
5173 return create_document_object(FALSE, outer, riid, ppv);
5176 HRESULT MHTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
5178 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
5179 return create_document_object(TRUE, outer, riid, ppv);