secur32/tests: Use importlib for functions available since Windows XP.
[wine.git] / dlls / mshtml / htmldoc.c
blob47e087de7b852e207b733a3bdc30370b9c8e3f8d
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 nsres = nsIDOMHTMLDocument_GetDir(This->doc_node->nsdoc, &dir_str);
2211 return return_nsstr(nsres, &dir_str, p);
2214 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2216 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2218 TRACE("(%p)->()\n", This);
2220 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2223 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2225 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2227 TRACE("(%p)->(%p)\n", This, p);
2229 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2232 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2234 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2235 FIXME("(%p)->()\n", This);
2236 return E_NOTIMPL;
2239 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2241 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2242 FIXME("(%p)->(%p)\n", This, p);
2243 return E_NOTIMPL;
2246 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2247 IHTMLDocument2 **ppNewDoc)
2249 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2250 nsIDOMDocumentFragment *doc_frag;
2251 HTMLDocumentNode *docnode;
2252 nsresult nsres;
2253 HRESULT hres;
2255 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2257 if(!This->doc_node->nsdoc) {
2258 FIXME("NULL nsdoc\n");
2259 return E_NOTIMPL;
2262 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2263 if(NS_FAILED(nsres)) {
2264 ERR("CreateDocumentFragment failed: %08x\n", nsres);
2265 return E_FAIL;
2268 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2269 nsIDOMDocumentFragment_Release(doc_frag);
2270 if(FAILED(hres))
2271 return hres;
2273 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2274 return S_OK;
2277 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2278 IHTMLDocument2 **p)
2280 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2281 FIXME("(%p)->(%p)\n", This, p);
2282 return E_NOTIMPL;
2285 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2286 VARIANT_BOOL v)
2288 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2289 FIXME("(%p)->(%x)\n", This, v);
2290 return E_NOTIMPL;
2293 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2294 VARIANT_BOOL *p)
2296 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2297 FIXME("(%p)->(%p)\n", This, p);
2298 return E_NOTIMPL;
2301 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2303 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2304 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2305 return E_NOTIMPL;
2308 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2310 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2311 FIXME("(%p)->(%p)\n", This, p);
2312 return E_NOTIMPL;
2315 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2317 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2319 TRACE("(%p)->(%p)\n", This, p);
2321 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2324 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2325 VARIANT_BOOL v)
2327 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2328 FIXME("(%p)->()\n", This);
2329 return E_NOTIMPL;
2332 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2333 VARIANT_BOOL *p)
2335 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2336 FIXME("(%p)->(%p)\n", This, p);
2337 return E_NOTIMPL;
2340 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2342 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2343 FIXME("(%p)->()\n", This);
2344 return E_NOTIMPL;
2347 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2349 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2350 FIXME("(%p)->(%p)\n", This, p);
2351 return E_NOTIMPL;
2354 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2355 IHTMLElementCollection **ppelColl)
2357 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2358 nsIDOMNodeList *node_list;
2359 nsAString selector_str;
2360 WCHAR *selector;
2361 nsresult nsres;
2363 static const WCHAR formatW[] = {'*','[','i','d','=','%','s',']',',','*','[','n','a','m','e','=','%','s',']',0};
2365 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2367 if(!This->doc_node || !This->doc_node->nsdoc) {
2368 /* We should probably return an empty collection. */
2369 FIXME("No nsdoc\n");
2370 return E_NOTIMPL;
2373 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2374 if(!selector)
2375 return E_OUTOFMEMORY;
2376 sprintfW(selector, formatW, v, v);
2379 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2380 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2381 * types and search should be case insensitive. Those are currently not supported properly.
2383 nsAString_InitDepend(&selector_str, selector);
2384 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2385 nsAString_Finish(&selector_str);
2386 heap_free(selector);
2387 if(NS_FAILED(nsres)) {
2388 ERR("QuerySelectorAll failed: %08x\n", nsres);
2389 return E_FAIL;
2392 *ppelColl = create_collection_from_nodelist(This->doc_node, node_list);
2393 nsIDOMNodeList_Release(node_list);
2394 return S_OK;
2398 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2399 IHTMLElement **pel)
2401 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2402 HTMLElement *elem;
2403 HRESULT hres;
2405 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2407 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2408 if(FAILED(hres) || !elem) {
2409 *pel = NULL;
2410 return hres;
2413 *pel = &elem->IHTMLElement_iface;
2414 return S_OK;
2418 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2419 IHTMLElementCollection **pelColl)
2421 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2422 nsIDOMNodeList *nslist;
2423 nsAString id_str;
2424 nsresult nsres;
2426 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2428 if(This->doc_node->nsdoc) {
2429 nsAString_InitDepend(&id_str, v);
2430 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2431 nsAString_Finish(&id_str);
2432 if(FAILED(nsres)) {
2433 ERR("GetElementByName failed: %08x\n", nsres);
2434 return E_FAIL;
2436 }else {
2437 nsIDOMDocumentFragment *docfrag;
2438 nsAString nsstr;
2440 if(v) {
2441 const WCHAR *ptr;
2442 for(ptr=v; *ptr; ptr++) {
2443 if(!isalnumW(*ptr)) {
2444 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2445 return E_NOTIMPL;
2450 nsres = nsIDOMNode_QueryInterface(This->doc_node->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2451 if(NS_FAILED(nsres)) {
2452 ERR("Could not get nsIDOMDocumentFragment iface: %08x\n", nsres);
2453 return E_UNEXPECTED;
2456 nsAString_InitDepend(&nsstr, v);
2457 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2458 nsAString_Finish(&nsstr);
2459 nsIDOMDocumentFragment_Release(docfrag);
2460 if(NS_FAILED(nsres)) {
2461 ERR("QuerySelectorAll failed: %08x\n", nsres);
2462 return E_FAIL;
2467 *pelColl = create_collection_from_nodelist(This->doc_node, nslist);
2468 nsIDOMNodeList_Release(nslist);
2470 return S_OK;
2473 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2474 HTMLDocument3_QueryInterface,
2475 HTMLDocument3_AddRef,
2476 HTMLDocument3_Release,
2477 HTMLDocument3_GetTypeInfoCount,
2478 HTMLDocument3_GetTypeInfo,
2479 HTMLDocument3_GetIDsOfNames,
2480 HTMLDocument3_Invoke,
2481 HTMLDocument3_releaseCapture,
2482 HTMLDocument3_recalc,
2483 HTMLDocument3_createTextNode,
2484 HTMLDocument3_get_documentElement,
2485 HTMLDocument3_get_uniqueID,
2486 HTMLDocument3_attachEvent,
2487 HTMLDocument3_detachEvent,
2488 HTMLDocument3_put_onrowsdelete,
2489 HTMLDocument3_get_onrowsdelete,
2490 HTMLDocument3_put_onrowsinserted,
2491 HTMLDocument3_get_onrowsinserted,
2492 HTMLDocument3_put_oncellchange,
2493 HTMLDocument3_get_oncellchange,
2494 HTMLDocument3_put_ondatasetchanged,
2495 HTMLDocument3_get_ondatasetchanged,
2496 HTMLDocument3_put_ondataavailable,
2497 HTMLDocument3_get_ondataavailable,
2498 HTMLDocument3_put_ondatasetcomplete,
2499 HTMLDocument3_get_ondatasetcomplete,
2500 HTMLDocument3_put_onpropertychange,
2501 HTMLDocument3_get_onpropertychange,
2502 HTMLDocument3_put_dir,
2503 HTMLDocument3_get_dir,
2504 HTMLDocument3_put_oncontextmenu,
2505 HTMLDocument3_get_oncontextmenu,
2506 HTMLDocument3_put_onstop,
2507 HTMLDocument3_get_onstop,
2508 HTMLDocument3_createDocumentFragment,
2509 HTMLDocument3_get_parentDocument,
2510 HTMLDocument3_put_enableDownload,
2511 HTMLDocument3_get_enableDownload,
2512 HTMLDocument3_put_baseUrl,
2513 HTMLDocument3_get_baseUrl,
2514 HTMLDocument3_get_childNodes,
2515 HTMLDocument3_put_inheritStyleSheets,
2516 HTMLDocument3_get_inheritStyleSheets,
2517 HTMLDocument3_put_onbeforeeditfocus,
2518 HTMLDocument3_get_onbeforeeditfocus,
2519 HTMLDocument3_getElementsByName,
2520 HTMLDocument3_getElementById,
2521 HTMLDocument3_getElementsByTagName
2524 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2526 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2529 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2530 REFIID riid, void **ppv)
2532 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2533 return htmldoc_query_interface(This, riid, ppv);
2536 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2538 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2539 return htmldoc_addref(This);
2542 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2544 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2545 return htmldoc_release(This);
2548 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2550 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2551 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2554 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2555 LCID lcid, ITypeInfo **ppTInfo)
2557 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2558 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2561 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2562 LPOLESTR *rgszNames, UINT cNames,
2563 LCID lcid, DISPID *rgDispId)
2565 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2566 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2567 rgDispId);
2570 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2571 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2572 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2574 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2575 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2576 pDispParams, pVarResult, pExcepInfo, puArgErr);
2579 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2581 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2582 nsIDOMHTMLElement *nsbody;
2583 nsresult nsres;
2585 TRACE("(%p)->()\n", This);
2587 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2588 if(NS_FAILED(nsres) || !nsbody) {
2589 ERR("GetBody failed: %08x\n", nsres);
2590 return E_FAIL;
2593 nsres = nsIDOMHTMLElement_Focus(nsbody);
2594 nsIDOMHTMLElement_Release(nsbody);
2595 if(NS_FAILED(nsres)) {
2596 ERR("Focus failed: %08x\n", nsres);
2597 return E_FAIL;
2600 return S_OK;
2603 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2605 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2606 cpp_bool has_focus;
2607 nsresult nsres;
2609 TRACE("(%p)->(%p)\n", This, pfFocus);
2611 if(!This->doc_node->nsdoc) {
2612 FIXME("Unimplemented for fragments.\n");
2613 return E_NOTIMPL;
2616 nsres = nsIDOMHTMLDocument_HasFocus(This->doc_node->nsdoc, &has_focus);
2617 assert(nsres == NS_OK);
2619 *pfFocus = has_focus ? VARIANT_TRUE : VARIANT_FALSE;
2620 return S_OK;
2623 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2625 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2626 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2627 return E_NOTIMPL;
2630 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2632 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2633 FIXME("(%p)->(%p)\n", This, p);
2634 return E_NOTIMPL;
2637 static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
2639 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2640 FIXME("(%p)->(%p)\n", This, p);
2641 return E_NOTIMPL;
2644 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2645 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2647 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2648 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2649 return E_NOTIMPL;
2652 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2654 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2655 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2656 return E_NOTIMPL;
2659 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2661 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2662 FIXME("(%p)->(%p)\n", This, p);
2663 return E_NOTIMPL;
2666 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2667 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2669 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2671 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2673 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2674 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2675 return E_NOTIMPL;
2678 return create_event_obj(ppEventObj);
2681 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2682 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2684 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2686 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2688 return dispatch_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2691 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2692 IHTMLRenderStyle **ppIHTMLRenderStyle)
2694 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2695 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2696 return E_NOTIMPL;
2699 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2701 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2702 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2703 return E_NOTIMPL;
2706 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2708 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2709 FIXME("(%p)->(%p)\n", This, p);
2710 return E_NOTIMPL;
2713 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2715 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2716 FIXME("(%p)->(%p)\n", This, p);
2717 return E_NOTIMPL;
2720 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2721 HTMLDocument4_QueryInterface,
2722 HTMLDocument4_AddRef,
2723 HTMLDocument4_Release,
2724 HTMLDocument4_GetTypeInfoCount,
2725 HTMLDocument4_GetTypeInfo,
2726 HTMLDocument4_GetIDsOfNames,
2727 HTMLDocument4_Invoke,
2728 HTMLDocument4_focus,
2729 HTMLDocument4_hasFocus,
2730 HTMLDocument4_put_onselectionchange,
2731 HTMLDocument4_get_onselectionchange,
2732 HTMLDocument4_get_namespace,
2733 HTMLDocument4_createDocumentFromUrl,
2734 HTMLDocument4_put_media,
2735 HTMLDocument4_get_media,
2736 HTMLDocument4_createEventObject,
2737 HTMLDocument4_fireEvent,
2738 HTMLDocument4_createRenderStyle,
2739 HTMLDocument4_put_oncontrolselect,
2740 HTMLDocument4_get_oncontrolselect,
2741 HTMLDocument4_get_URLEncoded
2744 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2746 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2749 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2750 REFIID riid, void **ppv)
2752 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2753 return htmldoc_query_interface(This, riid, ppv);
2756 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2758 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2759 return htmldoc_addref(This);
2762 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2764 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2765 return htmldoc_release(This);
2768 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2770 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2771 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2774 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2775 LCID lcid, ITypeInfo **ppTInfo)
2777 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2778 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2781 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2782 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2784 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2785 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2786 rgDispId);
2789 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2790 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2791 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2793 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2794 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2795 pDispParams, pVarResult, pExcepInfo, puArgErr);
2798 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2800 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2801 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2802 return E_NOTIMPL;
2805 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2807 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2808 FIXME("(%p)->(%p)\n", This, p);
2809 return E_NOTIMPL;
2812 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2814 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2815 FIXME("(%p)->(%p)\n", This, p);
2816 return E_NOTIMPL;
2819 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2821 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2822 HTMLDocumentNode *doc_node = This->doc_node;
2824 TRACE("(%p)->(%p)\n", This, p);
2826 if(!doc_node->dom_implementation) {
2827 HRESULT hres;
2829 hres = create_dom_implementation(&doc_node->dom_implementation);
2830 if(FAILED(hres))
2831 return hres;
2834 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2835 *p = doc_node->dom_implementation;
2836 return S_OK;
2839 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2840 IHTMLDOMAttribute **ppattribute)
2842 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2843 HTMLDOMAttribute *attr;
2844 HRESULT hres;
2846 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2848 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
2849 if(FAILED(hres))
2850 return hres;
2852 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2853 return S_OK;
2856 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2857 IHTMLDOMNode **ppRetNode)
2859 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2860 nsIDOMComment *nscomment;
2861 HTMLElement *elem;
2862 nsAString str;
2863 nsresult nsres;
2864 HRESULT hres;
2866 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2868 if(!This->doc_node->nsdoc) {
2869 WARN("NULL nsdoc\n");
2870 return E_UNEXPECTED;
2873 nsAString_InitDepend(&str, bstrdata);
2874 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2875 nsAString_Finish(&str);
2876 if(NS_FAILED(nsres)) {
2877 ERR("CreateTextNode failed: %08x\n", nsres);
2878 return E_FAIL;
2881 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2882 nsIDOMComment_Release(nscomment);
2883 if(FAILED(hres))
2884 return hres;
2886 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2887 return S_OK;
2890 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2892 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2893 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2894 return E_NOTIMPL;
2897 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2899 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2900 FIXME("(%p)->(%p)\n", This, p);
2901 return E_NOTIMPL;
2904 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2906 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2907 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2908 return E_NOTIMPL;
2911 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2913 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2914 FIXME("(%p)->(%p)\n", This, p);
2915 return E_NOTIMPL;
2918 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2920 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2921 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2922 return E_NOTIMPL;
2925 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2927 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2928 FIXME("(%p)->(%p)\n", This, p);
2929 return E_NOTIMPL;
2932 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2934 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2935 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2936 return E_NOTIMPL;
2939 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2941 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2942 FIXME("(%p)->(%p)\n", This, p);
2943 return E_NOTIMPL;
2946 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2948 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2949 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2950 return E_NOTIMPL;
2953 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2955 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2956 FIXME("(%p)->(%p)\n", This, p);
2957 return E_NOTIMPL;
2960 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2962 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2963 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2964 return E_NOTIMPL;
2967 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2969 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2970 FIXME("(%p)->(%p)\n", This, p);
2971 return E_NOTIMPL;
2974 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2976 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2978 static const WCHAR BackCompatW[] = {'B','a','c','k','C','o','m','p','a','t',0};
2979 static const WCHAR CSS1CompatW[] = {'C','S','S','1','C','o','m','p','a','t',0};
2981 TRACE("(%p)->(%p)\n", This, p);
2983 *p = SysAllocString(This->doc_node->document_mode == COMPAT_MODE_QUIRKS ? BackCompatW : CSS1CompatW);
2984 return *p ? S_OK : E_OUTOFMEMORY;
2987 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
2988 HTMLDocument5_QueryInterface,
2989 HTMLDocument5_AddRef,
2990 HTMLDocument5_Release,
2991 HTMLDocument5_GetTypeInfoCount,
2992 HTMLDocument5_GetTypeInfo,
2993 HTMLDocument5_GetIDsOfNames,
2994 HTMLDocument5_Invoke,
2995 HTMLDocument5_put_onmousewheel,
2996 HTMLDocument5_get_onmousewheel,
2997 HTMLDocument5_get_doctype,
2998 HTMLDocument5_get_implementation,
2999 HTMLDocument5_createAttribute,
3000 HTMLDocument5_createComment,
3001 HTMLDocument5_put_onfocusin,
3002 HTMLDocument5_get_onfocusin,
3003 HTMLDocument5_put_onfocusout,
3004 HTMLDocument5_get_onfocusout,
3005 HTMLDocument5_put_onactivate,
3006 HTMLDocument5_get_onactivate,
3007 HTMLDocument5_put_ondeactivate,
3008 HTMLDocument5_get_ondeactivate,
3009 HTMLDocument5_put_onbeforeactivate,
3010 HTMLDocument5_get_onbeforeactivate,
3011 HTMLDocument5_put_onbeforedeactivate,
3012 HTMLDocument5_get_onbeforedeactivate,
3013 HTMLDocument5_get_compatMode
3016 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3018 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
3021 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
3022 REFIID riid, void **ppv)
3024 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3025 return htmldoc_query_interface(This, riid, ppv);
3028 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3030 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3031 return htmldoc_addref(This);
3034 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3036 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3037 return htmldoc_release(This);
3040 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3042 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3043 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3046 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
3047 LCID lcid, ITypeInfo **ppTInfo)
3049 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3050 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3053 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
3054 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3056 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3057 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3058 rgDispId);
3061 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
3062 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3063 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3065 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3066 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3067 pDispParams, pVarResult, pExcepInfo, puArgErr);
3070 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3071 IHTMLDocumentCompatibleInfoCollection **p)
3073 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3074 FIXME("(%p)->(%p)\n", This, p);
3075 return E_NOTIMPL;
3078 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3080 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3082 static const int docmode_values[] = {
3083 5, /* DOCMODE_QUIRKS */
3084 7, /* DOCMODE_IE7 */
3085 8, /* DOCMODE_IE8 */
3086 9, /* DOCMODE_IE8 */
3087 10, /* DOCMODE_IE10 */
3088 11 /* DOCMODE_IE11 */
3091 TRACE("(%p)->(%p)\n", This, p);
3093 if(!This->doc_node) {
3094 FIXME("NULL doc_node\n");
3095 return E_UNEXPECTED;
3098 assert(This->doc_node->document_mode < sizeof(docmode_values)/sizeof(*docmode_values));
3100 V_VT(p) = VT_I4;
3101 V_I4(p) = docmode_values[This->doc_node->document_mode];
3102 return S_OK;
3105 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3106 VARIANT *p)
3108 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3109 FIXME("(%p)->(%p)\n", This, p);
3110 return E_NOTIMPL;
3113 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3115 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3116 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3117 return E_NOTIMPL;
3120 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3121 VARIANT *p)
3123 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3124 FIXME("(%p)->(%p)\n", This, p);
3125 return E_NOTIMPL;
3128 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3130 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3131 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3132 return E_NOTIMPL;
3135 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3136 BSTR bstrId, IHTMLElement2 **p)
3138 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3139 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3140 return E_NOTIMPL;
3143 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3145 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3146 FIXME("(%p)->()\n", This);
3147 return E_NOTIMPL;
3150 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3151 HTMLDocument6_QueryInterface,
3152 HTMLDocument6_AddRef,
3153 HTMLDocument6_Release,
3154 HTMLDocument6_GetTypeInfoCount,
3155 HTMLDocument6_GetTypeInfo,
3156 HTMLDocument6_GetIDsOfNames,
3157 HTMLDocument6_Invoke,
3158 HTMLDocument6_get_compatible,
3159 HTMLDocument6_get_documentMode,
3160 HTMLDocument6_put_onstorage,
3161 HTMLDocument6_get_onstorage,
3162 HTMLDocument6_put_onstoragecommit,
3163 HTMLDocument6_get_onstoragecommit,
3164 HTMLDocument6_getElementById,
3165 HTMLDocument6_updateSettings
3168 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3170 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3173 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3175 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3176 return htmldoc_query_interface(This, riid, ppv);
3179 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3181 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3182 return htmldoc_addref(This);
3185 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3187 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3188 return htmldoc_release(This);
3191 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3193 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3194 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3197 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3198 LCID lcid, ITypeInfo **ppTInfo)
3200 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3201 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3204 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3205 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3207 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3208 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3209 rgDispId);
3212 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3213 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3214 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3216 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3217 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3218 pDispParams, pVarResult, pExcepInfo, puArgErr);
3221 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3223 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3224 FIXME("(%p)->(%p)\n", This, p);
3225 return E_NOTIMPL;
3228 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3230 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3231 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3232 return E_NOTIMPL;
3235 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3237 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3238 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3239 return E_NOTIMPL;
3242 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3243 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3245 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3246 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3247 return E_NOTIMPL;
3250 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3252 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3253 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3254 return E_NOTIMPL;
3257 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3258 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3260 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3261 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3262 return E_NOTIMPL;
3265 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3267 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3268 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3269 return E_NOTIMPL;
3272 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3274 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3275 FIXME("(%p)->(%p)\n", This, p);
3276 return E_NOTIMPL;
3279 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3281 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3282 FIXME("(%p)->(%p)\n", This, p);
3283 return E_NOTIMPL;
3286 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3288 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3289 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3290 return E_NOTIMPL;
3293 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3295 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3296 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3297 return E_NOTIMPL;
3300 static HRESULT WINAPI HTMLDocument7_getElementByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3302 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3303 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3304 return E_NOTIMPL;
3307 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3308 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3310 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3311 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3312 return E_NOTIMPL;
3315 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3317 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3318 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3319 return E_NOTIMPL;
3322 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3324 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3325 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3326 return E_NOTIMPL;
3329 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3331 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3332 FIXME("(%p)->(%p)\n", This, p);
3333 return E_NOTIMPL;
3336 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3338 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3339 FIXME("(%p)->(%p)\n", This, p);
3340 return E_NOTIMPL;
3343 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3345 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3346 FIXME("(%p)->(%p)\n", This, p);
3347 return E_NOTIMPL;
3350 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3352 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3353 FIXME("(%p)->(%p)\n", This, p);
3354 return E_NOTIMPL;
3357 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3359 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3360 FIXME("(%p)->(%x)\n", This, v);
3361 return E_NOTIMPL;
3364 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3366 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3367 FIXME("(%p)->(%p)\n", This, p);
3368 return E_NOTIMPL;
3371 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3373 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3374 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3375 return E_NOTIMPL;
3378 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3380 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3381 FIXME("(%p)->(%p)\n", This, p);
3382 return E_NOTIMPL;
3385 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3387 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3388 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3389 return E_NOTIMPL;
3392 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3394 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3395 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3396 return E_NOTIMPL;
3399 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3401 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3402 FIXME("(%p)->(%p)\n", This, p);
3403 return E_NOTIMPL;
3406 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3408 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3409 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3410 return E_NOTIMPL;
3413 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3415 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3416 FIXME("(%p)->(%p)\n", This, p);
3417 return E_NOTIMPL;
3420 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3422 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3423 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3424 return E_NOTIMPL;
3427 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3429 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3430 FIXME("(%p)->(%p)\n", This, p);
3431 return E_NOTIMPL;
3434 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3436 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3437 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3438 return E_NOTIMPL;
3441 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3443 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3444 FIXME("(%p)->(%p)\n", This, p);
3445 return E_NOTIMPL;
3448 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3450 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3451 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3452 return E_NOTIMPL;
3455 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3457 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3458 FIXME("(%p)->(%p)\n", This, p);
3459 return E_NOTIMPL;
3462 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3464 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3465 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3466 return E_NOTIMPL;
3469 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3471 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3472 FIXME("(%p)->(%p)\n", This, p);
3473 return E_NOTIMPL;
3476 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3478 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3479 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3480 return E_NOTIMPL;
3483 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3485 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3486 FIXME("(%p)->(%p)\n", This, p);
3487 return E_NOTIMPL;
3490 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3492 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3493 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3494 return E_NOTIMPL;
3497 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3499 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3500 FIXME("(%p)->(%p)\n", This, p);
3501 return E_NOTIMPL;
3504 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3506 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3507 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3508 return E_NOTIMPL;
3511 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3513 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3514 FIXME("(%p)->(%p)\n", This, p);
3515 return E_NOTIMPL;
3518 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3520 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3521 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3522 return E_NOTIMPL;
3525 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3527 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3528 FIXME("(%p)->(%p)\n", This, p);
3529 return E_NOTIMPL;
3532 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3534 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3535 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3536 return E_NOTIMPL;
3539 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3541 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3542 FIXME("(%p)->(%p)\n", This, p);
3543 return E_NOTIMPL;
3546 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3548 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3549 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3550 return E_NOTIMPL;
3553 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
3555 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3556 FIXME("(%p)->(%p)\n", This, p);
3557 return E_NOTIMPL;
3560 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
3562 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3563 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3564 return E_NOTIMPL;
3567 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
3569 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3570 FIXME("(%p)->(%p)\n", This, p);
3571 return E_NOTIMPL;
3574 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
3576 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3577 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3578 return E_NOTIMPL;
3581 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
3583 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3584 FIXME("(%p)->(%p)\n", This, p);
3585 return E_NOTIMPL;
3588 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
3590 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3591 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3592 return E_NOTIMPL;
3595 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
3597 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3598 FIXME("(%p)->(%p)\n", This, p);
3599 return E_NOTIMPL;
3602 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
3604 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3605 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3606 return E_NOTIMPL;
3609 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
3611 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3612 FIXME("(%p)->(%p)\n", This, p);
3613 return E_NOTIMPL;
3616 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
3618 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3619 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3620 return E_NOTIMPL;
3623 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
3625 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3626 FIXME("(%p)->(%p)\n", This, p);
3627 return E_NOTIMPL;
3630 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
3632 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3633 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3634 return E_NOTIMPL;
3637 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
3639 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3640 FIXME("(%p)->(%p)\n", This, p);
3641 return E_NOTIMPL;
3644 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
3646 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3647 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3648 return E_NOTIMPL;
3651 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
3653 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3654 FIXME("(%p)->(%p)\n", This, p);
3655 return E_NOTIMPL;
3658 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
3660 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3661 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3662 return E_NOTIMPL;
3665 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
3667 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3668 FIXME("(%p)->(%p)\n", This, p);
3669 return E_NOTIMPL;
3672 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
3674 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3675 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3676 return E_NOTIMPL;
3679 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
3681 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3682 FIXME("(%p)->(%p)\n", This, p);
3683 return E_NOTIMPL;
3686 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
3688 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3689 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3690 return E_NOTIMPL;
3693 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
3695 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3696 FIXME("(%p)->(%p)\n", This, p);
3697 return E_NOTIMPL;
3700 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
3702 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3703 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3704 return E_NOTIMPL;
3707 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
3709 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3710 FIXME("(%p)->(%p)\n", This, p);
3711 return E_NOTIMPL;
3714 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
3716 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3717 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3718 return E_NOTIMPL;
3721 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
3723 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3724 FIXME("(%p)->(%p)\n", This, p);
3725 return E_NOTIMPL;
3728 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
3730 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3731 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3732 return E_NOTIMPL;
3735 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
3737 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3738 FIXME("(%p)->(%p)\n", This, p);
3739 return E_NOTIMPL;
3742 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
3744 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3745 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3746 return E_NOTIMPL;
3749 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
3751 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3752 FIXME("(%p)->(%p)\n", This, p);
3753 return E_NOTIMPL;
3756 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
3758 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3759 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3760 return E_NOTIMPL;
3763 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
3765 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3766 FIXME("(%p)->(%p)\n", This, p);
3767 return E_NOTIMPL;
3770 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
3772 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3773 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3774 return E_NOTIMPL;
3777 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
3779 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3780 FIXME("(%p)->(%p)\n", This, p);
3781 return E_NOTIMPL;
3784 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
3786 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3787 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3788 return E_NOTIMPL;
3791 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
3793 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3794 FIXME("(%p)->(%p)\n", This, p);
3795 return E_NOTIMPL;
3798 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
3800 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3801 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3802 return E_NOTIMPL;
3805 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
3807 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3808 FIXME("(%p)->(%p)\n", This, p);
3809 return E_NOTIMPL;
3812 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
3814 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3815 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3816 return E_NOTIMPL;
3819 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
3821 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3822 FIXME("(%p)->(%p)\n", This, p);
3823 return E_NOTIMPL;
3826 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
3828 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3829 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3830 return E_NOTIMPL;
3833 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
3835 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3836 FIXME("(%p)->(%p)\n", This, p);
3837 return E_NOTIMPL;
3840 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
3842 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3843 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3844 return E_NOTIMPL;
3847 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
3849 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3850 FIXME("(%p)->(%p)\n", This, p);
3851 return E_NOTIMPL;
3854 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
3856 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3857 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3858 return E_NOTIMPL;
3861 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
3863 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3864 FIXME("(%p)->(%p)\n", This, p);
3865 return E_NOTIMPL;
3868 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
3870 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3871 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3872 return E_NOTIMPL;
3875 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
3877 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3878 FIXME("(%p)->(%p)\n", This, p);
3879 return E_NOTIMPL;
3882 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
3884 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3885 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3886 return E_NOTIMPL;
3889 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
3891 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3892 FIXME("(%p)->(%p)\n", This, p);
3893 return E_NOTIMPL;
3896 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
3898 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3899 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3900 return E_NOTIMPL;
3903 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
3905 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3906 FIXME("(%p)->(%p)\n", This, p);
3907 return E_NOTIMPL;
3910 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
3912 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3913 FIXME("(%p)\n", This);
3914 return E_NOTIMPL;
3917 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
3918 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
3920 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3921 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
3922 return E_NOTIMPL;
3925 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3927 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3928 FIXME("(%p)->(%p)\n", This, p);
3929 return E_NOTIMPL;
3932 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
3934 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3935 FIXME("(%p)->(%p)\n", This, v);
3936 return E_NOTIMPL;
3939 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
3941 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3942 FIXME("(%p)->(%p)\n", This, p);
3943 return E_NOTIMPL;
3946 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
3948 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3949 FIXME("(%p)->(%p)\n", This, p);
3950 return E_NOTIMPL;
3953 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
3954 HTMLDocument7_QueryInterface,
3955 HTMLDocument7_AddRef,
3956 HTMLDocument7_Release,
3957 HTMLDocument7_GetTypeInfoCount,
3958 HTMLDocument7_GetTypeInfo,
3959 HTMLDocument7_GetIDsOfNames,
3960 HTMLDocument7_Invoke,
3961 HTMLDocument7_get_defaultView,
3962 HTMLDocument7_createCDATASection,
3963 HTMLDocument7_getSelection,
3964 HTMLDocument7_getElementsByTagNameNS,
3965 HTMLDocument7_createElementNS,
3966 HTMLDocument7_createAttributeNS,
3967 HTMLDocument7_put_onmsthumbnailclick,
3968 HTMLDocument7_get_onmsthumbnailclick,
3969 HTMLDocument7_get_characterSet,
3970 HTMLDocument7_createElement,
3971 HTMLDocument7_createAttribute,
3972 HTMLDocument7_getElementByClassName,
3973 HTMLDocument7_createProcessingInstruction,
3974 HTMLDocument7_adoptNode,
3975 HTMLDocument7_put_onmssitemodejumplistitemremoved,
3976 HTMLDocument7_get_onmssitemodejumplistitemremoved,
3977 HTMLDocument7_get_all,
3978 HTMLDocument7_get_inputEncoding,
3979 HTMLDocument7_get_xmlEncoding,
3980 HTMLDocument7_put_xmlStandalone,
3981 HTMLDocument7_get_xmlStandalone,
3982 HTMLDocument7_put_xmlVersion,
3983 HTMLDocument7_get_xmlVersion,
3984 HTMLDocument7_hasAttributes,
3985 HTMLDocument7_put_onabort,
3986 HTMLDocument7_get_onabort,
3987 HTMLDocument7_put_onblur,
3988 HTMLDocument7_get_onblur,
3989 HTMLDocument7_put_oncanplay,
3990 HTMLDocument7_get_oncanplay,
3991 HTMLDocument7_put_oncanplaythrough,
3992 HTMLDocument7_get_oncanplaythrough,
3993 HTMLDocument7_put_onchange,
3994 HTMLDocument7_get_onchange,
3995 HTMLDocument7_put_ondrag,
3996 HTMLDocument7_get_ondrag,
3997 HTMLDocument7_put_ondragend,
3998 HTMLDocument7_get_ondragend,
3999 HTMLDocument7_put_ondragenter,
4000 HTMLDocument7_get_ondragenter,
4001 HTMLDocument7_put_ondragleave,
4002 HTMLDocument7_get_ondragleave,
4003 HTMLDocument7_put_ondragover,
4004 HTMLDocument7_get_ondragover,
4005 HTMLDocument7_put_ondrop,
4006 HTMLDocument7_get_ondrop,
4007 HTMLDocument7_put_ondurationchange,
4008 HTMLDocument7_get_ondurationchange,
4009 HTMLDocument7_put_onemptied,
4010 HTMLDocument7_get_onemptied,
4011 HTMLDocument7_put_onended,
4012 HTMLDocument7_get_onended,
4013 HTMLDocument7_put_onerror,
4014 HTMLDocument7_get_onerror,
4015 HTMLDocument7_put_onfocus,
4016 HTMLDocument7_get_onfocus,
4017 HTMLDocument7_put_oninput,
4018 HTMLDocument7_get_oninput,
4019 HTMLDocument7_put_onload,
4020 HTMLDocument7_get_onload,
4021 HTMLDocument7_put_onloadeddata,
4022 HTMLDocument7_get_onloadeddata,
4023 HTMLDocument7_put_onloadedmetadata,
4024 HTMLDocument7_get_onloadedmetadata,
4025 HTMLDocument7_put_onloadstart,
4026 HTMLDocument7_get_onloadstart,
4027 HTMLDocument7_put_onpause,
4028 HTMLDocument7_get_onpause,
4029 HTMLDocument7_put_onplay,
4030 HTMLDocument7_get_onplay,
4031 HTMLDocument7_put_onplaying,
4032 HTMLDocument7_get_onplaying,
4033 HTMLDocument7_put_onprogress,
4034 HTMLDocument7_get_onprogress,
4035 HTMLDocument7_put_onratechange,
4036 HTMLDocument7_get_onratechange,
4037 HTMLDocument7_put_onreset,
4038 HTMLDocument7_get_onreset,
4039 HTMLDocument7_put_onscroll,
4040 HTMLDocument7_get_onscroll,
4041 HTMLDocument7_put_onseekend,
4042 HTMLDocument7_get_onseekend,
4043 HTMLDocument7_put_onseeking,
4044 HTMLDocument7_get_onseeking,
4045 HTMLDocument7_put_onselect,
4046 HTMLDocument7_get_onselect,
4047 HTMLDocument7_put_onstalled,
4048 HTMLDocument7_get_onstalled,
4049 HTMLDocument7_put_onsubmit,
4050 HTMLDocument7_get_onsubmit,
4051 HTMLDocument7_put_onsuspend,
4052 HTMLDocument7_get_onsuspend,
4053 HTMLDocument7_put_ontimeupdate,
4054 HTMLDocument7_get_ontimeupdate,
4055 HTMLDocument7_put_onvolumechange,
4056 HTMLDocument7_get_onvolumechange,
4057 HTMLDocument7_put_onwaiting,
4058 HTMLDocument7_get_onwaiting,
4059 HTMLDocument7_normalize,
4060 HTMLDocument7_importNode,
4061 HTMLDocument7_get_parentWindow,
4062 HTMLDocument7_put_body,
4063 HTMLDocument7_get_body,
4064 HTMLDocument7_get_head
4067 static inline HTMLDocument *impl_from_IDocumentSelector(IDocumentSelector *iface)
4069 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentSelector_iface);
4072 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4074 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4075 return htmldoc_query_interface(This, riid, ppv);
4078 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4080 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4081 return htmldoc_addref(This);
4084 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4086 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4087 return htmldoc_release(This);
4090 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4092 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4093 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4096 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4097 LCID lcid, ITypeInfo **ppTInfo)
4099 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4100 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4103 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4104 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4106 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4107 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4108 rgDispId);
4111 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4112 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4114 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4115 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4116 pDispParams, pVarResult, pExcepInfo, puArgErr);
4119 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4121 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4122 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4123 return E_NOTIMPL;
4126 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4128 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4129 nsIDOMNodeList *node_list;
4130 nsAString nsstr;
4131 nsresult nsres;
4133 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4135 nsAString_InitDepend(&nsstr, v);
4136 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &nsstr, &node_list);
4137 nsAString_Finish(&nsstr);
4138 if(NS_FAILED(nsres)) {
4139 ERR("QuerySelectorAll failed: %08x\n", nsres);
4140 return E_FAIL;
4143 *pel = create_child_collection(This->doc_node, node_list);
4144 nsIDOMNodeList_Release(node_list);
4145 return *pel ? S_OK : E_OUTOFMEMORY;
4148 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4149 DocumentSelector_QueryInterface,
4150 DocumentSelector_AddRef,
4151 DocumentSelector_Release,
4152 DocumentSelector_GetTypeInfoCount,
4153 DocumentSelector_GetTypeInfo,
4154 DocumentSelector_GetIDsOfNames,
4155 DocumentSelector_Invoke,
4156 DocumentSelector_querySelector,
4157 DocumentSelector_querySelectorAll
4160 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4162 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4164 if(This->window)
4165 update_doc_cp_events(This->doc_node, cp);
4168 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4170 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4173 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4175 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4176 return htmldoc_query_interface(This, riid, ppv);
4179 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4181 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4182 return htmldoc_addref(This);
4185 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4187 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4188 return htmldoc_release(This);
4191 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4193 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4194 return S_FALSE;
4197 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4198 SupportErrorInfo_QueryInterface,
4199 SupportErrorInfo_AddRef,
4200 SupportErrorInfo_Release,
4201 SupportErrorInfo_InterfaceSupportsErrorInfo
4204 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4206 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4209 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4211 nsIDOMNodeList *node_list;
4212 nsAString name_str;
4213 UINT32 len;
4214 unsigned i;
4215 nsresult nsres;
4217 if(!This->nsdoc)
4218 return DISP_E_UNKNOWNNAME;
4220 nsAString_InitDepend(&name_str, name);
4221 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4222 nsAString_Finish(&name_str);
4223 if(NS_FAILED(nsres))
4224 return E_FAIL;
4226 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4227 nsIDOMNodeList_Release(node_list);
4228 if(NS_FAILED(nsres))
4229 return E_FAIL;
4231 if(!len)
4232 return DISP_E_UNKNOWNNAME;
4234 for(i=0; i < This->elem_vars_cnt; i++) {
4235 if(!strcmpW(name, This->elem_vars[i])) {
4236 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4237 return S_OK;
4241 if(This->elem_vars_cnt == This->elem_vars_size) {
4242 WCHAR **new_vars;
4244 if(This->elem_vars_size) {
4245 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4246 if(!new_vars)
4247 return E_OUTOFMEMORY;
4248 This->elem_vars_size *= 2;
4249 }else {
4250 new_vars = heap_alloc(16*sizeof(WCHAR*));
4251 if(!new_vars)
4252 return E_OUTOFMEMORY;
4253 This->elem_vars_size = 16;
4256 This->elem_vars = new_vars;
4259 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4260 if(!This->elem_vars[This->elem_vars_cnt])
4261 return E_OUTOFMEMORY;
4263 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4264 return S_OK;
4267 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4269 HTMLDocument *This = impl_from_IDispatchEx(iface);
4271 return htmldoc_query_interface(This, riid, ppv);
4274 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4276 HTMLDocument *This = impl_from_IDispatchEx(iface);
4278 return htmldoc_addref(This);
4281 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4283 HTMLDocument *This = impl_from_IDispatchEx(iface);
4285 return htmldoc_release(This);
4288 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4290 HTMLDocument *This = impl_from_IDispatchEx(iface);
4292 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4295 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4296 LCID lcid, ITypeInfo **ppTInfo)
4298 HTMLDocument *This = impl_from_IDispatchEx(iface);
4300 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4303 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4304 LPOLESTR *rgszNames, UINT cNames,
4305 LCID lcid, DISPID *rgDispId)
4307 HTMLDocument *This = impl_from_IDispatchEx(iface);
4309 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4312 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4313 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4314 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4316 HTMLDocument *This = impl_from_IDispatchEx(iface);
4318 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4319 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4321 switch(dispIdMember) {
4322 case DISPID_READYSTATE:
4323 TRACE("DISPID_READYSTATE\n");
4325 if(!(wFlags & DISPATCH_PROPERTYGET))
4326 return E_INVALIDARG;
4328 V_VT(pVarResult) = VT_I4;
4329 V_I4(pVarResult) = This->window->readystate;
4330 return S_OK;
4333 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
4334 pVarResult, pExcepInfo, puArgErr);
4337 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4339 HTMLDocument *This = impl_from_IDispatchEx(iface);
4340 HRESULT hres;
4342 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4343 if(hres != DISP_E_UNKNOWNNAME)
4344 return hres;
4346 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4349 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4350 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4352 HTMLDocument *This = impl_from_IDispatchEx(iface);
4354 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
4355 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
4356 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4359 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4362 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4364 HTMLDocument *This = impl_from_IDispatchEx(iface);
4366 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4369 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4371 HTMLDocument *This = impl_from_IDispatchEx(iface);
4373 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4376 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4378 HTMLDocument *This = impl_from_IDispatchEx(iface);
4380 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4383 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4385 HTMLDocument *This = impl_from_IDispatchEx(iface);
4387 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4390 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4392 HTMLDocument *This = impl_from_IDispatchEx(iface);
4394 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
4397 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
4399 HTMLDocument *This = impl_from_IDispatchEx(iface);
4401 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
4404 static const IDispatchExVtbl DocDispatchExVtbl = {
4405 DocDispatchEx_QueryInterface,
4406 DocDispatchEx_AddRef,
4407 DocDispatchEx_Release,
4408 DocDispatchEx_GetTypeInfoCount,
4409 DocDispatchEx_GetTypeInfo,
4410 DocDispatchEx_GetIDsOfNames,
4411 DocDispatchEx_Invoke,
4412 DocDispatchEx_GetDispID,
4413 DocDispatchEx_InvokeEx,
4414 DocDispatchEx_DeleteMemberByName,
4415 DocDispatchEx_DeleteMemberByDispID,
4416 DocDispatchEx_GetMemberProperties,
4417 DocDispatchEx_GetMemberName,
4418 DocDispatchEx_GetNextDispID,
4419 DocDispatchEx_GetNameSpaceParent
4422 static inline HTMLDocument *impl_from_IProvideClassInfo(IProvideClassInfo *iface)
4424 return CONTAINING_RECORD(iface, HTMLDocument, IProvideClassInfo_iface);
4427 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideClassInfo *iface,
4428 REFIID riid, void **ppv)
4430 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4431 return htmldoc_query_interface(This, riid, ppv);
4434 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideClassInfo *iface)
4436 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4437 return htmldoc_addref(This);
4440 static ULONG WINAPI ProvideClassInfo_Release(IProvideClassInfo *iface)
4442 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4443 return htmldoc_release(This);
4446 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideClassInfo* iface,
4447 ITypeInfo **ppTI)
4449 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4450 TRACE("(%p)->(%p)\n", This, ppTI);
4451 return get_htmldoc_classinfo(ppTI);
4454 static const IProvideClassInfoVtbl ProvideClassInfoVtbl = {
4455 ProvideClassInfo_QueryInterface,
4456 ProvideClassInfo_AddRef,
4457 ProvideClassInfo_Release,
4458 ProvideClassInfo_GetClassInfo
4461 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
4463 *ppv = NULL;
4465 if(IsEqualGUID(&IID_IUnknown, riid))
4466 *ppv = &This->IHTMLDocument2_iface;
4467 else if(IsEqualGUID(&IID_IDispatch, riid))
4468 *ppv = &This->IDispatchEx_iface;
4469 else if(IsEqualGUID(&IID_IDispatchEx, riid))
4470 *ppv = &This->IDispatchEx_iface;
4471 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
4472 *ppv = &This->IHTMLDocument2_iface;
4473 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
4474 *ppv = &This->IHTMLDocument2_iface;
4475 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
4476 *ppv = &This->IHTMLDocument3_iface;
4477 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
4478 *ppv = &This->IHTMLDocument4_iface;
4479 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
4480 *ppv = &This->IHTMLDocument5_iface;
4481 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
4482 *ppv = &This->IHTMLDocument6_iface;
4483 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
4484 *ppv = &This->IHTMLDocument7_iface;
4485 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
4486 *ppv = &This->IDocumentSelector_iface;
4487 else if(IsEqualGUID(&IID_IPersist, riid))
4488 *ppv = &This->IPersistFile_iface;
4489 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
4490 *ppv = &This->IPersistMoniker_iface;
4491 else if(IsEqualGUID(&IID_IPersistFile, riid))
4492 *ppv = &This->IPersistFile_iface;
4493 else if(IsEqualGUID(&IID_IMonikerProp, riid))
4494 *ppv = &This->IMonikerProp_iface;
4495 else if(IsEqualGUID(&IID_IOleObject, riid))
4496 *ppv = &This->IOleObject_iface;
4497 else if(IsEqualGUID(&IID_IOleDocument, riid))
4498 *ppv = &This->IOleDocument_iface;
4499 else if(IsEqualGUID(&IID_IOleDocumentView, riid))
4500 *ppv = &This->IOleDocumentView_iface;
4501 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
4502 *ppv = &This->IOleInPlaceActiveObject_iface;
4503 else if(IsEqualGUID(&IID_IViewObject, riid))
4504 *ppv = &This->IViewObjectEx_iface;
4505 else if(IsEqualGUID(&IID_IViewObject2, riid))
4506 *ppv = &This->IViewObjectEx_iface;
4507 else if(IsEqualGUID(&IID_IViewObjectEx, riid))
4508 *ppv = &This->IViewObjectEx_iface;
4509 else if(IsEqualGUID(&IID_IOleWindow, riid))
4510 *ppv = &This->IOleInPlaceActiveObject_iface;
4511 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
4512 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4513 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
4514 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4515 else if(IsEqualGUID(&IID_IServiceProvider, riid))
4516 *ppv = &This->IServiceProvider_iface;
4517 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
4518 *ppv = &This->IOleCommandTarget_iface;
4519 else if(IsEqualGUID(&IID_IOleControl, riid))
4520 *ppv = &This->IOleControl_iface;
4521 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
4522 *ppv = &This->IHlinkTarget_iface;
4523 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
4524 *ppv = &This->cp_container.IConnectionPointContainer_iface;
4525 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
4526 *ppv = &This->IPersistStreamInit_iface;
4527 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
4528 *ppv = &This->IHTMLDocument2_iface;
4529 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
4530 *ppv = &This->ISupportErrorInfo_iface;
4531 else if(IsEqualGUID(&IID_IPersistHistory, riid))
4532 *ppv = &This->IPersistHistory_iface;
4533 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
4534 *ppv = &This->IObjectWithSite_iface;
4535 else if(IsEqualGUID(&IID_IOleContainer, riid))
4536 *ppv = &This->IOleContainer_iface;
4537 else if(IsEqualGUID(&IID_IObjectSafety, riid))
4538 *ppv = &This->IObjectSafety_iface;
4539 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
4540 *ppv = &This->IProvideClassInfo_iface;
4541 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
4542 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
4543 *ppv = NULL;
4544 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
4545 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
4546 *ppv = NULL;
4547 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
4548 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
4549 *ppv = NULL;
4550 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
4551 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
4552 *ppv = NULL;
4553 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
4554 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
4555 *ppv = NULL;
4556 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
4557 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
4558 *ppv = NULL;
4559 }else {
4560 return FALSE;
4563 if(*ppv)
4564 IUnknown_AddRef((IUnknown*)*ppv);
4565 return TRUE;
4568 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
4570 static const cpc_entry_t HTMLDocument_cpc[] = {
4571 {&IID_IDispatch, &HTMLDocumentEvents_data},
4572 {&IID_IPropertyNotifySink},
4573 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
4574 {&DIID_HTMLDocumentEvents2},
4575 {NULL}
4578 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
4580 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
4581 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
4582 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
4583 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
4584 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
4585 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
4586 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
4587 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
4588 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
4589 doc->IProvideClassInfo_iface.lpVtbl = &ProvideClassInfoVtbl;
4591 doc->unk_impl = unk_impl;
4592 doc->dispex = dispex;
4593 doc->task_magic = get_task_target_magic();
4595 HTMLDocument_Persist_Init(doc);
4596 HTMLDocument_OleCmd_Init(doc);
4597 HTMLDocument_OleObj_Init(doc);
4598 HTMLDocument_View_Init(doc);
4599 HTMLDocument_Window_Init(doc);
4600 HTMLDocument_Service_Init(doc);
4601 HTMLDocument_Hlink_Init(doc);
4603 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
4606 static void destroy_htmldoc(HTMLDocument *This)
4608 remove_target_tasks(This->task_magic);
4610 ConnectionPointContainer_Destroy(&This->cp_container);
4613 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
4615 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
4618 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
4620 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4622 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4624 if(htmldoc_qi(&This->basedoc, riid, ppv))
4625 return *ppv ? S_OK : E_NOINTERFACE;
4627 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
4628 *ppv = &This->IInternetHostSecurityManager_iface;
4629 else
4630 return HTMLDOMNode_QI(&This->node, riid, ppv);
4632 IUnknown_AddRef((IUnknown*)*ppv);
4633 return S_OK;
4636 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
4638 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4639 unsigned i;
4641 for(i=0; i < This->elem_vars_cnt; i++)
4642 heap_free(This->elem_vars[i]);
4643 heap_free(This->elem_vars);
4645 detach_events(This);
4646 if(This->body_event_target)
4647 release_event_target(This->body_event_target);
4648 if(This->catmgr)
4649 ICatInformation_Release(This->catmgr);
4651 detach_selection(This);
4652 detach_ranges(This);
4654 while(!list_empty(&This->plugin_hosts))
4655 detach_plugin_host(LIST_ENTRY(list_head(&This->plugin_hosts), PluginHost, entry));
4657 if(!This->nsdoc && This->window) {
4658 /* document fragments own reference to inner window */
4659 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
4660 This->window = NULL;
4663 heap_free(This->event_vector);
4664 destroy_htmldoc(&This->basedoc);
4667 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4669 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4670 FIXME("%p\n", This);
4671 return E_NOTIMPL;
4674 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
4676 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4678 if(This->nsdoc)
4679 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
4682 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
4684 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4686 if(This->nsdoc) {
4687 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
4689 release_document_mutation(This);
4690 This->nsdoc = NULL;
4691 nsIDOMHTMLDocument_Release(nsdoc);
4692 This->window = NULL;
4696 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
4697 HTMLDocumentNode_QI,
4698 HTMLDocumentNode_destructor,
4699 HTMLDocument_cpc,
4700 HTMLDocumentNode_clone,
4701 NULL,
4702 NULL,
4703 NULL,
4704 NULL,
4705 NULL,
4706 NULL,
4707 NULL,
4708 NULL,
4709 NULL,
4710 NULL,
4711 NULL,
4712 HTMLDocumentNode_traverse,
4713 HTMLDocumentNode_unlink
4716 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4718 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4719 HTMLDocumentNode *new_node;
4720 HRESULT hres;
4722 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
4723 if(FAILED(hres))
4724 return hres;
4726 *ret = &new_node->node;
4727 return S_OK;
4730 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
4732 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
4735 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4736 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4738 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4739 nsIDOMNodeList *node_list;
4740 nsAString name_str;
4741 nsIDOMNode *nsnode;
4742 HTMLDOMNode *node;
4743 unsigned i;
4744 nsresult nsres;
4745 HRESULT hres;
4747 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
4748 FIXME("unsupported flags %x\n", flags);
4749 return E_NOTIMPL;
4752 i = id - MSHTML_DISPID_CUSTOM_MIN;
4754 if(!This->nsdoc || i >= This->elem_vars_cnt)
4755 return DISP_E_UNKNOWNNAME;
4757 nsAString_InitDepend(&name_str, This->elem_vars[i]);
4758 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4759 nsAString_Finish(&name_str);
4760 if(NS_FAILED(nsres))
4761 return E_FAIL;
4763 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
4764 nsIDOMNodeList_Release(node_list);
4765 if(NS_FAILED(nsres) || !nsnode)
4766 return DISP_E_UNKNOWNNAME;
4768 hres = get_node(This, nsnode, TRUE, &node);
4769 if(FAILED(hres))
4770 return hres;
4772 V_VT(res) = VT_DISPATCH;
4773 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
4774 return S_OK;
4777 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, int eid)
4779 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4780 ensure_doc_nsevent_handler(This, eid);
4783 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl = {
4784 NULL,
4785 NULL,
4786 HTMLDocumentNode_invoke,
4787 NULL,
4788 NULL,
4789 HTMLDocumentNode_bind_event
4792 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
4793 HTMLDocumentNode_QI,
4794 HTMLDocumentNode_destructor,
4795 HTMLDocument_cpc,
4796 HTMLDocumentFragment_clone
4799 static const tid_t HTMLDocumentNode_iface_tids[] = {
4800 IHTMLDOMNode_tid,
4801 IHTMLDOMNode2_tid,
4802 IHTMLDocument2_tid,
4803 IHTMLDocument3_tid,
4804 IHTMLDocument4_tid,
4805 IHTMLDocument5_tid,
4806 IHTMLDocument6_tid,
4807 IDocumentSelector_tid,
4811 static dispex_static_data_t HTMLDocumentNode_dispex = {
4812 &HTMLDocumentNode_dispex_vtbl,
4813 DispHTMLDocument_tid,
4814 HTMLDocumentNode_iface_tids
4817 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
4819 HTMLDocumentNode *doc;
4821 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
4822 if(!doc)
4823 return NULL;
4825 doc->ref = 1;
4826 doc->basedoc.doc_node = doc;
4827 doc->basedoc.doc_obj = doc_obj;
4828 doc->basedoc.window = window->base.outer_window;
4829 doc->window = window;
4831 init_dispex(&doc->node.event_target.dispex, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4832 &HTMLDocumentNode_dispex);
4833 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4834 &doc->node.event_target.dispex.IDispatchEx_iface);
4835 HTMLDocumentNode_SecMgr_Init(doc);
4837 list_init(&doc->selection_list);
4838 list_init(&doc->range_list);
4839 list_init(&doc->plugin_hosts);
4841 return doc;
4844 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLInnerWindow *window, HTMLDocumentNode **ret)
4846 HTMLDocumentNode *doc;
4848 doc = alloc_doc_node(doc_obj, window);
4849 if(!doc)
4850 return E_OUTOFMEMORY;
4852 if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
4853 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
4855 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
4857 nsIDOMHTMLDocument_AddRef(nsdoc);
4858 doc->nsdoc = nsdoc;
4860 init_document_mutation(doc);
4861 doc_init_events(doc);
4863 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
4864 doc->node.cp_container = &doc->basedoc.cp_container;
4866 *ret = doc;
4867 return S_OK;
4870 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
4872 HTMLDocumentNode *doc_frag;
4874 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
4875 if(!doc_frag)
4876 return E_OUTOFMEMORY;
4878 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
4880 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
4881 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
4882 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
4884 *ret = doc_frag;
4885 return S_OK;
4888 /**********************************************************
4889 * ICustomDoc implementation
4892 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
4894 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
4897 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
4899 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4901 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4903 if(htmldoc_qi(&This->basedoc, riid, ppv))
4904 return *ppv ? S_OK : E_NOINTERFACE;
4906 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
4907 *ppv = &This->ICustomDoc_iface;
4908 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
4909 *ppv = &This->ITargetContainer_iface;
4910 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4911 return *ppv ? S_OK : E_NOINTERFACE;
4912 }else {
4913 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
4914 *ppv = NULL;
4915 return E_NOINTERFACE;
4918 IUnknown_AddRef((IUnknown*)*ppv);
4919 return S_OK;
4922 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
4924 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4925 ULONG ref = InterlockedIncrement(&This->ref);
4927 TRACE("(%p) ref = %u\n", This, ref);
4929 return ref;
4932 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
4934 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4935 ULONG ref = InterlockedDecrement(&This->ref);
4937 TRACE("(%p) ref = %u\n", This, ref);
4939 if(!ref) {
4940 nsIDOMWindowUtils *window_utils = NULL;
4942 if(This->basedoc.window && This->basedoc.window->nswindow)
4943 get_nsinterface((nsISupports*)This->basedoc.window->nswindow, &IID_nsIDOMWindowUtils, (void**)&window_utils);
4945 if(This->basedoc.doc_node) {
4946 This->basedoc.doc_node->basedoc.doc_obj = NULL;
4947 htmldoc_release(&This->basedoc.doc_node->basedoc);
4949 if(This->basedoc.window) {
4950 This->basedoc.window->doc_obj = NULL;
4951 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
4953 if(This->basedoc.advise_holder)
4954 IOleAdviseHolder_Release(This->basedoc.advise_holder);
4956 if(This->view_sink)
4957 IAdviseSink_Release(This->view_sink);
4958 if(This->client)
4959 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
4960 if(This->hostui)
4961 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
4962 if(This->in_place_active)
4963 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
4964 if(This->ipsite)
4965 IOleDocumentView_SetInPlaceSite(&This->basedoc.IOleDocumentView_iface, NULL);
4966 if(This->undomgr)
4967 IOleUndoManager_Release(This->undomgr);
4968 if(This->editsvcs)
4969 IHTMLEditServices_Release(This->editsvcs);
4970 if(This->tooltips_hwnd)
4971 DestroyWindow(This->tooltips_hwnd);
4973 if(This->hwnd)
4974 DestroyWindow(This->hwnd);
4975 heap_free(This->mime);
4977 destroy_htmldoc(&This->basedoc);
4978 release_dispex(&This->dispex);
4980 if(This->nscontainer)
4981 NSContainer_Release(This->nscontainer);
4982 heap_free(This);
4984 /* Force cycle collection */
4985 if(window_utils) {
4986 nsIDOMWindowUtils_CycleCollect(window_utils, NULL, 0);
4987 nsIDOMWindowUtils_Release(window_utils);
4991 return ref;
4994 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
4996 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4997 IOleCommandTarget *cmdtrg;
4998 HRESULT hres;
5000 TRACE("(%p)->(%p)\n", This, pUIHandler);
5002 if(This->custom_hostui && This->hostui == pUIHandler)
5003 return S_OK;
5005 This->custom_hostui = TRUE;
5007 if(This->hostui)
5008 IDocHostUIHandler_Release(This->hostui);
5009 if(pUIHandler)
5010 IDocHostUIHandler_AddRef(pUIHandler);
5011 This->hostui = pUIHandler;
5012 if(!pUIHandler)
5013 return S_OK;
5015 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
5016 if(SUCCEEDED(hres)) {
5017 FIXME("custom UI handler supports IOleCommandTarget\n");
5018 IOleCommandTarget_Release(cmdtrg);
5021 return S_OK;
5024 static const ICustomDocVtbl CustomDocVtbl = {
5025 CustomDoc_QueryInterface,
5026 CustomDoc_AddRef,
5027 CustomDoc_Release,
5028 CustomDoc_SetUIHandler
5031 static const tid_t HTMLDocumentObj_iface_tids[] = {
5032 IHTMLDocument2_tid,
5033 IHTMLDocument3_tid,
5034 IHTMLDocument4_tid,
5035 IHTMLDocument5_tid,
5038 static dispex_static_data_t HTMLDocumentObj_dispex = {
5039 NULL,
5040 DispHTMLDocument_tid,
5041 HTMLDocumentObj_iface_tids
5044 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
5046 mozIDOMWindowProxy *mozwindow;
5047 HTMLDocumentObj *doc;
5048 nsIDOMWindow *nswindow = NULL;
5049 nsresult nsres;
5050 HRESULT hres;
5052 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_mshtml_guid(riid), ppvObject);
5054 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
5055 if(!doc)
5056 return E_OUTOFMEMORY;
5058 init_dispex(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex);
5059 init_doc(&doc->basedoc, (IUnknown*)&doc->ICustomDoc_iface, &doc->dispex.IDispatchEx_iface);
5060 TargetContainer_Init(doc);
5062 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
5063 doc->ref = 1;
5064 doc->basedoc.doc_obj = doc;
5066 doc->usermode = UNKNOWN_USERMODE;
5068 init_binding_ui(doc);
5070 hres = create_nscontainer(doc, &doc->nscontainer);
5071 if(FAILED(hres)) {
5072 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
5073 htmldoc_release(&doc->basedoc);
5074 return hres;
5077 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
5078 htmldoc_release(&doc->basedoc);
5079 if(FAILED(hres))
5080 return hres;
5082 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &mozwindow);
5083 if(NS_FAILED(nsres))
5084 ERR("GetContentDOMWindow failed: %08x\n", nsres);
5086 nsres = mozIDOMWindowProxy_QueryInterface(mozwindow, &IID_nsIDOMWindow, (void**)&nswindow);
5087 mozIDOMWindowProxy_Release(mozwindow);
5088 assert(nsres == NS_OK);
5090 hres = HTMLOuterWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
5091 if(nswindow)
5092 nsIDOMWindow_Release(nswindow);
5093 if(FAILED(hres)) {
5094 htmldoc_release(&doc->basedoc);
5095 return hres;
5098 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
5099 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
5100 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
5103 get_thread_hwnd();
5105 return S_OK;