gdi32: Fix leak in GdiDeleteSpoolFileHandle.
[wine.git] / dlls / mshtml / htmldoc.c
blobd347ecb93c70d22d1659fcd48bf1c16172b383c9
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 <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "wininet.h"
28 #include "ole2.h"
29 #include "perhist.h"
30 #include "mshtmdid.h"
31 #include "mshtmcid.h"
33 #include "wine/debug.h"
35 #include "mshtml_private.h"
36 #include "htmlevent.h"
37 #include "pluginhost.h"
38 #include "binding.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
42 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret);
44 HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement **ret)
46 nsIDOMNodeList *nsnode_list;
47 nsIDOMNode *nsnode = NULL;
48 nsIDOMElement *nselem;
49 nsAString id_str;
50 nsresult nsres;
51 HRESULT hres;
53 if(!doc->dom_document) {
54 WARN("NULL dom_document\n");
55 return E_UNEXPECTED;
58 nsAString_InitDepend(&id_str, id);
59 /* get element by id attribute */
60 nsres = nsIDOMDocument_GetElementById(doc->dom_document, &id_str, &nselem);
61 if(FAILED(nsres)) {
62 ERR("GetElementById failed: %08lx\n", nsres);
63 nsAString_Finish(&id_str);
64 return E_FAIL;
67 /* get first element by name attribute */
68 if(doc->html_document) {
69 nsres = nsIDOMHTMLDocument_GetElementsByName(doc->html_document, &id_str, &nsnode_list);
70 nsAString_Finish(&id_str);
71 if(FAILED(nsres)) {
72 ERR("getElementsByName failed: %08lx\n", nsres);
73 if(nselem)
74 nsIDOMElement_Release(nselem);
75 return E_FAIL;
78 nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode);
79 nsIDOMNodeList_Release(nsnode_list);
80 assert(nsres == NS_OK);
83 if(nsnode && nselem) {
84 UINT16 pos;
86 nsres = nsIDOMNode_CompareDocumentPosition(nsnode, (nsIDOMNode*)nselem, &pos);
87 if(NS_FAILED(nsres)) {
88 FIXME("CompareDocumentPosition failed: 0x%08lx\n", nsres);
89 nsIDOMNode_Release(nsnode);
90 nsIDOMElement_Release(nselem);
91 return E_FAIL;
94 TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
95 if(!(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS))) {
96 nsIDOMElement_Release(nselem);
97 nselem = NULL;
101 if(nsnode) {
102 if(!nselem) {
103 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
104 assert(nsres == NS_OK);
106 nsIDOMNode_Release(nsnode);
109 if(!nselem) {
110 *ret = NULL;
111 return S_OK;
114 hres = get_element(nselem, ret);
115 nsIDOMElement_Release(nselem);
116 return hres;
119 UINT get_document_charset(HTMLDocumentNode *doc)
121 nsAString charset_str;
122 UINT ret = 0;
123 nsresult nsres;
125 if(doc->charset)
126 return doc->charset;
128 nsAString_Init(&charset_str, NULL);
129 nsres = nsIDOMDocument_GetCharacterSet(doc->dom_document, &charset_str);
130 if(NS_SUCCEEDED(nsres)) {
131 const PRUnichar *charset;
133 nsAString_GetData(&charset_str, &charset);
135 if(*charset) {
136 BSTR str = SysAllocString(charset);
137 ret = cp_from_charset_string(str);
138 SysFreeString(str);
140 }else {
141 ERR("GetCharset failed: %08lx\n", nsres);
143 nsAString_Finish(&charset_str);
145 if(!ret)
146 return CP_UTF8;
148 return doc->charset = ret;
151 typedef struct {
152 HTMLDOMNode node;
153 IDOMDocumentType IDOMDocumentType_iface;
154 } DocumentType;
156 static inline DocumentType *impl_from_IDOMDocumentType(IDOMDocumentType *iface)
158 return CONTAINING_RECORD(iface, DocumentType, IDOMDocumentType_iface);
161 static HRESULT WINAPI DocumentType_QueryInterface(IDOMDocumentType *iface, REFIID riid, void **ppv)
163 DocumentType *This = impl_from_IDOMDocumentType(iface);
165 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
168 static ULONG WINAPI DocumentType_AddRef(IDOMDocumentType *iface)
170 DocumentType *This = impl_from_IDOMDocumentType(iface);
172 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
175 static ULONG WINAPI DocumentType_Release(IDOMDocumentType *iface)
177 DocumentType *This = impl_from_IDOMDocumentType(iface);
179 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
182 static HRESULT WINAPI DocumentType_GetTypeInfoCount(IDOMDocumentType *iface, UINT *pctinfo)
184 DocumentType *This = impl_from_IDOMDocumentType(iface);
186 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
189 static HRESULT WINAPI DocumentType_GetTypeInfo(IDOMDocumentType *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
191 DocumentType *This = impl_from_IDOMDocumentType(iface);
193 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
196 static HRESULT WINAPI DocumentType_GetIDsOfNames(IDOMDocumentType *iface, REFIID riid, LPOLESTR *rgszNames,
197 UINT cNames, LCID lcid, DISPID *rgDispId)
199 DocumentType *This = impl_from_IDOMDocumentType(iface);
201 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
202 cNames, lcid, rgDispId);
205 static HRESULT WINAPI DocumentType_Invoke(IDOMDocumentType *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
206 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
208 DocumentType *This = impl_from_IDOMDocumentType(iface);
210 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
211 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
214 static HRESULT WINAPI DocumentType_get_name(IDOMDocumentType *iface, BSTR *p)
216 DocumentType *This = impl_from_IDOMDocumentType(iface);
217 nsAString nsstr;
218 nsresult nsres;
220 TRACE("(%p)->(%p)\n", This, p);
222 nsAString_Init(&nsstr, NULL);
223 nsres = nsIDOMDocumentType_GetName((nsIDOMDocumentType*)This->node.nsnode, &nsstr);
224 return return_nsstr(nsres, &nsstr, p);
227 static HRESULT WINAPI DocumentType_get_entities(IDOMDocumentType *iface, IDispatch **p)
229 DocumentType *This = impl_from_IDOMDocumentType(iface);
231 FIXME("(%p)->(%p)\n", This, p);
233 return E_NOTIMPL;
236 static HRESULT WINAPI DocumentType_get_notations(IDOMDocumentType *iface, IDispatch **p)
238 DocumentType *This = impl_from_IDOMDocumentType(iface);
240 FIXME("(%p)->(%p)\n", This, p);
242 return E_NOTIMPL;
245 static HRESULT WINAPI DocumentType_get_publicId(IDOMDocumentType *iface, VARIANT *p)
247 DocumentType *This = impl_from_IDOMDocumentType(iface);
249 FIXME("(%p)->(%p)\n", This, p);
251 return E_NOTIMPL;
254 static HRESULT WINAPI DocumentType_get_systemId(IDOMDocumentType *iface, VARIANT *p)
256 DocumentType *This = impl_from_IDOMDocumentType(iface);
258 FIXME("(%p)->(%p)\n", This, p);
260 return E_NOTIMPL;
263 static HRESULT WINAPI DocumentType_get_internalSubset(IDOMDocumentType *iface, VARIANT *p)
265 DocumentType *This = impl_from_IDOMDocumentType(iface);
267 FIXME("(%p)->(%p)\n", This, p);
269 return E_NOTIMPL;
272 static const IDOMDocumentTypeVtbl DocumentTypeVtbl = {
273 DocumentType_QueryInterface,
274 DocumentType_AddRef,
275 DocumentType_Release,
276 DocumentType_GetTypeInfoCount,
277 DocumentType_GetTypeInfo,
278 DocumentType_GetIDsOfNames,
279 DocumentType_Invoke,
280 DocumentType_get_name,
281 DocumentType_get_entities,
282 DocumentType_get_notations,
283 DocumentType_get_publicId,
284 DocumentType_get_systemId,
285 DocumentType_get_internalSubset
288 static inline DocumentType *DocumentType_from_HTMLDOMNode(HTMLDOMNode *iface)
290 return CONTAINING_RECORD(iface, DocumentType, node);
293 static inline DocumentType *DocumentType_from_DispatchEx(DispatchEx *iface)
295 return CONTAINING_RECORD(iface, DocumentType, node.event_target.dispex);
298 static HRESULT DocumentType_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
300 DocumentType *This = DocumentType_from_HTMLDOMNode(iface);
302 return create_doctype_node(This->node.doc, nsnode, ret);
305 static const cpc_entry_t DocumentType_cpc[] = {{NULL}};
307 static const NodeImplVtbl DocumentTypeImplVtbl = {
308 .cpc_entries = DocumentType_cpc,
309 .clone = DocumentType_clone
312 static void *DocumentType_query_interface(DispatchEx *dispex, REFIID riid)
314 DocumentType *This = DocumentType_from_DispatchEx(dispex);
316 if(IsEqualGUID(&IID_IDOMDocumentType, riid))
317 return &This->IDOMDocumentType_iface;
319 return HTMLDOMNode_query_interface(&This->node.event_target.dispex, riid);
322 static nsISupports *DocumentType_get_gecko_target(DispatchEx *dispex)
324 DocumentType *This = DocumentType_from_DispatchEx(dispex);
325 return (nsISupports*)This->node.nsnode;
328 static EventTarget *DocumentType_get_parent_event_target(DispatchEx *dispex)
330 DocumentType *This = DocumentType_from_DispatchEx(dispex);
331 nsIDOMNode *nsnode;
332 HTMLDOMNode *node;
333 nsresult nsres;
334 HRESULT hres;
336 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
337 assert(nsres == NS_OK);
338 if(!nsnode)
339 return NULL;
341 hres = get_node(nsnode, TRUE, &node);
342 nsIDOMNode_Release(nsnode);
343 if(FAILED(hres))
344 return NULL;
346 return &node->event_target;
349 static IHTMLEventObj *DocumentType_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
351 DocumentType *This = DocumentType_from_DispatchEx(dispex);
352 return default_set_current_event(This->node.doc->window, event);
355 static const event_target_vtbl_t DocumentType_event_target_vtbl = {
357 .query_interface = DocumentType_query_interface,
358 .destructor = HTMLDOMNode_destructor,
359 .traverse = HTMLDOMNode_traverse,
360 .unlink = HTMLDOMNode_unlink
362 .get_gecko_target = DocumentType_get_gecko_target,
363 .get_parent_event_target = DocumentType_get_parent_event_target,
364 .set_current_event = DocumentType_set_current_event
367 static const tid_t DocumentType_iface_tids[] = {
368 IDOMDocumentType_tid,
369 IHTMLDOMNode_tid,
370 IHTMLDOMNode2_tid,
371 IHTMLDOMNode3_tid,
375 static dispex_static_data_t DocumentType_dispex = {
376 "DocumentType",
377 &DocumentType_event_target_vtbl.dispex_vtbl,
378 DispDOMDocumentType_tid,
379 DocumentType_iface_tids
382 HRESULT create_doctype_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **ret)
384 nsIDOMDocumentType *nsdoctype;
385 DocumentType *doctype;
386 nsresult nsres;
388 if(!(doctype = calloc(1, sizeof(*doctype))))
389 return E_OUTOFMEMORY;
391 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMDocumentType, (void**)&nsdoctype);
392 assert(nsres == NS_OK);
394 doctype->node.vtbl = &DocumentTypeImplVtbl;
395 doctype->IDOMDocumentType_iface.lpVtbl = &DocumentTypeVtbl;
396 HTMLDOMNode_Init(doc, &doctype->node, (nsIDOMNode*)nsdoctype, &DocumentType_dispex);
397 nsIDOMDocumentType_Release(nsdoctype);
399 *ret = &doctype->node;
400 return S_OK;
403 static inline HTMLDocumentNode *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
405 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument2_iface);
408 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
410 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
412 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
415 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
417 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
419 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
422 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
424 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
426 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
429 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
431 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
433 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
436 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo, LCID lcid,
437 ITypeInfo **ppTInfo)
439 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
441 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
444 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid, LPOLESTR *rgszNames,
445 UINT cNames, LCID lcid, DISPID *rgDispId)
447 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
449 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
450 rgDispId);
453 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
454 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
456 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
458 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
459 pDispParams, pVarResult, pExcepInfo, puArgErr);
462 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
464 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
465 HRESULT hres;
467 TRACE("(%p)->(%p)\n", This, p);
469 hres = IHTMLDocument7_get_parentWindow(&This->IHTMLDocument7_iface, (IHTMLWindow2**)p);
470 return hres == S_OK && !*p ? E_PENDING : hres;
473 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
475 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
477 TRACE("(%p)->(%p)\n", This, p);
478 *p = create_all_collection(&This->node, FALSE);
480 return S_OK;
483 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
485 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
486 nsIDOMElement *nsbody = NULL;
487 HTMLElement *element;
488 nsresult nsres;
489 HRESULT hres;
491 TRACE("(%p)->(%p)\n", This, p);
493 if(This->html_document) {
494 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, (nsIDOMHTMLElement **)&nsbody);
495 if(NS_FAILED(nsres)) {
496 TRACE("Could not get body: %08lx\n", nsres);
497 return E_UNEXPECTED;
499 }else {
500 nsAString nsnode_name;
501 nsIDOMDocumentFragment *frag;
503 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&frag);
504 if(!NS_FAILED(nsres)) {
505 nsAString_InitDepend(&nsnode_name, L"BODY");
506 nsIDOMDocumentFragment_QuerySelector(frag, &nsnode_name, &nsbody);
507 nsAString_Finish(&nsnode_name);
508 nsIDOMDocumentFragment_Release(frag);
512 if(!nsbody) {
513 *p = NULL;
514 return S_OK;
517 hres = get_element(nsbody, &element);
518 nsIDOMElement_Release(nsbody);
519 if(FAILED(hres))
520 return hres;
522 *p = &element->IHTMLElement_iface;
523 return S_OK;
526 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
528 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
529 nsIDOMElement *nselem;
530 HTMLElement *elem;
531 nsresult nsres;
532 HRESULT hres;
534 TRACE("(%p)->(%p)\n", This, p);
536 if(!This->dom_document) {
537 *p = NULL;
538 return S_OK;
542 * NOTE: Gecko may return an active element even if the document is not visible.
543 * IE returns NULL in this case.
545 nsres = nsIDOMDocument_GetActiveElement(This->dom_document, &nselem);
546 if(NS_FAILED(nsres)) {
547 ERR("GetActiveElement failed: %08lx\n", nsres);
548 return E_FAIL;
551 if(!nselem) {
552 *p = NULL;
553 return S_OK;
556 hres = get_element(nselem, &elem);
557 nsIDOMElement_Release(nselem);
558 if(FAILED(hres))
559 return hres;
561 *p = &elem->IHTMLElement_iface;
562 return S_OK;
565 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
567 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
568 nsIDOMHTMLCollection *nscoll = NULL;
569 nsresult nsres;
571 TRACE("(%p)->(%p)\n", This, p);
573 if(!p)
574 return E_INVALIDARG;
576 *p = NULL;
578 if(!This->dom_document) {
579 WARN("NULL dom_document\n");
580 return E_UNEXPECTED;
583 if(!This->html_document) {
584 FIXME("Not implemented for XML document\n");
585 return E_NOTIMPL;
588 nsres = nsIDOMHTMLDocument_GetImages(This->html_document, &nscoll);
589 if(NS_FAILED(nsres)) {
590 ERR("GetImages failed: %08lx\n", nsres);
591 return E_FAIL;
594 if(nscoll) {
595 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
596 nsIDOMHTMLCollection_Release(nscoll);
599 return S_OK;
602 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
604 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
605 nsIDOMHTMLCollection *nscoll = NULL;
606 nsresult nsres;
608 TRACE("(%p)->(%p)\n", This, p);
610 if(!p)
611 return E_INVALIDARG;
613 *p = NULL;
615 if(!This->dom_document) {
616 WARN("NULL dom_document\n");
617 return E_UNEXPECTED;
620 if(!This->html_document) {
621 FIXME("Not implemented for XML document\n");
622 return E_NOTIMPL;
625 nsres = nsIDOMHTMLDocument_GetApplets(This->html_document, &nscoll);
626 if(NS_FAILED(nsres)) {
627 ERR("GetApplets failed: %08lx\n", nsres);
628 return E_FAIL;
631 if(nscoll) {
632 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
633 nsIDOMHTMLCollection_Release(nscoll);
636 return S_OK;
639 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
641 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
642 nsIDOMHTMLCollection *nscoll = NULL;
643 nsresult nsres;
645 TRACE("(%p)->(%p)\n", This, p);
647 if(!p)
648 return E_INVALIDARG;
650 *p = NULL;
652 if(!This->dom_document) {
653 WARN("NULL dom_document\n");
654 return E_UNEXPECTED;
657 if(!This->html_document) {
658 FIXME("Not implemented for XML document\n");
659 return E_NOTIMPL;
662 nsres = nsIDOMHTMLDocument_GetLinks(This->html_document, &nscoll);
663 if(NS_FAILED(nsres)) {
664 ERR("GetLinks failed: %08lx\n", nsres);
665 return E_FAIL;
668 if(nscoll) {
669 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
670 nsIDOMHTMLCollection_Release(nscoll);
673 return S_OK;
676 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
678 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
679 nsIDOMHTMLCollection *nscoll = NULL;
680 nsresult nsres;
682 TRACE("(%p)->(%p)\n", This, p);
684 if(!p)
685 return E_INVALIDARG;
687 *p = NULL;
689 if(!This->dom_document) {
690 WARN("NULL dom_document\n");
691 return E_UNEXPECTED;
694 if(!This->html_document) {
695 FIXME("Not implemented for XML document\n");
696 return E_NOTIMPL;
699 nsres = nsIDOMHTMLDocument_GetForms(This->html_document, &nscoll);
700 if(NS_FAILED(nsres)) {
701 ERR("GetForms failed: %08lx\n", nsres);
702 return E_FAIL;
705 if(nscoll) {
706 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
707 nsIDOMHTMLCollection_Release(nscoll);
710 return S_OK;
713 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
715 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
716 nsIDOMHTMLCollection *nscoll = NULL;
717 nsresult nsres;
719 TRACE("(%p)->(%p)\n", This, p);
721 if(!p)
722 return E_INVALIDARG;
724 *p = NULL;
726 if(!This->dom_document) {
727 WARN("NULL dom_document\n");
728 return E_UNEXPECTED;
731 if(!This->html_document) {
732 FIXME("Not implemented for XML document\n");
733 return E_NOTIMPL;
736 nsres = nsIDOMHTMLDocument_GetAnchors(This->html_document, &nscoll);
737 if(NS_FAILED(nsres)) {
738 ERR("GetAnchors failed: %08lx\n", nsres);
739 return E_FAIL;
742 if(nscoll) {
743 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
744 nsIDOMHTMLCollection_Release(nscoll);
747 return S_OK;
750 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
752 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
753 nsAString nsstr;
754 nsresult nsres;
756 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
758 if(!This->dom_document) {
759 WARN("NULL dom_document\n");
760 return E_UNEXPECTED;
763 nsAString_InitDepend(&nsstr, v);
764 nsres = nsIDOMDocument_SetTitle(This->dom_document, &nsstr);
765 nsAString_Finish(&nsstr);
766 if(NS_FAILED(nsres))
767 ERR("SetTitle failed: %08lx\n", nsres);
769 return S_OK;
772 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
774 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
775 const PRUnichar *ret;
776 nsAString nsstr;
777 nsresult nsres;
779 TRACE("(%p)->(%p)\n", This, p);
781 if(!This->dom_document) {
782 WARN("NULL dom_document\n");
783 return E_UNEXPECTED;
787 nsAString_Init(&nsstr, NULL);
788 nsres = nsIDOMDocument_GetTitle(This->dom_document, &nsstr);
789 if (NS_SUCCEEDED(nsres)) {
790 nsAString_GetData(&nsstr, &ret);
791 *p = SysAllocString(ret);
793 nsAString_Finish(&nsstr);
795 if(NS_FAILED(nsres)) {
796 ERR("GetTitle failed: %08lx\n", nsres);
797 return E_FAIL;
800 return S_OK;
803 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
805 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
806 nsIDOMHTMLCollection *nscoll = NULL;
807 nsresult nsres;
809 TRACE("(%p)->(%p)\n", This, p);
811 if(!p)
812 return E_INVALIDARG;
814 *p = NULL;
816 if(!This->dom_document) {
817 WARN("NULL dom_document\n");
818 return E_UNEXPECTED;
821 if(!This->html_document) {
822 FIXME("Not implemented for XML document\n");
823 return E_NOTIMPL;
826 nsres = nsIDOMHTMLDocument_GetScripts(This->html_document, &nscoll);
827 if(NS_FAILED(nsres)) {
828 ERR("GetImages failed: %08lx\n", nsres);
829 return E_FAIL;
832 if(nscoll) {
833 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
834 nsIDOMHTMLCollection_Release(nscoll);
837 return S_OK;
840 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
842 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
843 HTMLDocumentObj *doc_obj;
844 HRESULT hres;
846 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
848 if(wcsicmp(v, L"on")) {
849 FIXME("Unsupported arg %s\n", debugstr_w(v));
850 return E_NOTIMPL;
853 doc_obj = This->doc_obj;
854 IUnknown_AddRef(doc_obj->outer_unk);
855 hres = setup_edit_mode(doc_obj);
856 IUnknown_Release(doc_obj->outer_unk);
857 if(FAILED(hres))
858 return hres;
860 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
861 return S_OK;
864 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
866 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
867 FIXME("(%p)->(%p) always returning Off\n", This, p);
869 if(!p)
870 return E_INVALIDARG;
872 *p = SysAllocString(L"Off");
874 return S_OK;
877 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
879 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
880 nsISelection *nsselection;
881 nsresult nsres;
883 TRACE("(%p)->(%p)\n", This, p);
885 if(!This->html_document) {
886 FIXME("Not implemented for XML document\n");
887 return E_NOTIMPL;
890 nsres = nsIDOMHTMLDocument_GetSelection(This->html_document, &nsselection);
891 if(NS_FAILED(nsres)) {
892 ERR("GetSelection failed: %08lx\n", nsres);
893 return E_FAIL;
896 return HTMLSelectionObject_Create(This, nsselection, p);
899 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
901 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
903 TRACE("(%p)->(%p)\n", iface, p);
905 if(!p)
906 return E_POINTER;
908 return get_readystate_string(This->outer_window ? This->outer_window->readystate : 0, p);
911 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
913 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
915 TRACE("(%p)->(%p)\n", This, p);
917 if(!This->outer_window) {
918 /* Not implemented by IE */
919 return E_NOTIMPL;
921 return IHTMLWindow2_get_frames(&This->outer_window->base.IHTMLWindow2_iface, p);
924 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
926 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
927 FIXME("(%p)->(%p)\n", This, p);
928 return E_NOTIMPL;
931 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
933 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
934 FIXME("(%p)->(%p)\n", This, p);
935 return E_NOTIMPL;
938 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
940 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
941 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
942 return E_NOTIMPL;
945 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
947 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
948 FIXME("(%p)->(%p)\n", This, p);
949 return E_NOTIMPL;
952 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
954 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
955 IHTMLElement *element = NULL;
956 IHTMLBodyElement *body;
957 HRESULT hr;
959 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
961 hr = IHTMLDocument2_get_body(iface, &element);
962 if (FAILED(hr))
964 ERR("Failed to get body (0x%08lx)\n", hr);
965 return hr;
968 if(!element)
970 FIXME("Empty body element.\n");
971 return hr;
974 hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body);
975 if (SUCCEEDED(hr))
977 hr = IHTMLBodyElement_put_bgColor(body, v);
978 IHTMLBodyElement_Release(body);
980 IHTMLElement_Release(element);
982 return hr;
985 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
987 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
988 nsAString nsstr;
989 nsresult nsres;
990 HRESULT hres;
992 TRACE("(%p)->(%p)\n", This, p);
994 if(!This->dom_document) {
995 WARN("NULL dom_document\n");
996 return E_UNEXPECTED;
999 if(!This->html_document) {
1000 FIXME("Not implemented for XML document\n");
1001 return E_NOTIMPL;
1004 nsAString_Init(&nsstr, NULL);
1005 nsres = nsIDOMHTMLDocument_GetBgColor(This->html_document, &nsstr);
1006 hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p);
1007 if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) {
1008 TRACE("default #ffffff\n");
1009 if(!(V_BSTR(p) = SysAllocString(L"#ffffff")))
1010 hres = E_OUTOFMEMORY;
1012 return hres;
1015 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
1017 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1018 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1019 return E_NOTIMPL;
1022 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
1024 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1025 FIXME("(%p)->(%p)\n", This, p);
1026 return E_NOTIMPL;
1029 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
1031 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1032 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1033 return E_NOTIMPL;
1036 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
1038 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1039 FIXME("(%p)->(%p)\n", This, p);
1040 return E_NOTIMPL;
1043 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
1045 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1046 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1047 return E_NOTIMPL;
1050 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
1052 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1053 FIXME("(%p)->(%p)\n", This, p);
1054 return E_NOTIMPL;
1057 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
1059 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1060 nsAString nsstr;
1061 nsresult nsres;
1063 TRACE("(%p)->(%p)\n", This, p);
1065 nsAString_InitDepend(&nsstr, NULL);
1066 nsres = nsIDOMDocument_GetReferrer(This->dom_document, &nsstr);
1067 return return_nsstr(nsres, &nsstr, p);
1070 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
1072 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1074 TRACE("(%p)->(%p)\n", This, p);
1076 if(!This->dom_document || !This->window) {
1077 WARN("NULL window\n");
1078 return E_UNEXPECTED;
1081 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
1084 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
1086 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1087 FIXME("(%p)->(%p)\n", This, p);
1088 return E_NOTIMPL;
1091 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
1093 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1095 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1097 if(!This->outer_window) {
1098 FIXME("No window available\n");
1099 return E_FAIL;
1102 return navigate_url(This->outer_window, v, This->outer_window->uri, BINDING_NAVIGATED);
1105 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
1107 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1109 TRACE("(%p)->(%p)\n", iface, p);
1111 *p = SysAllocString(This->outer_window && This->outer_window->url ? This->outer_window->url : L"about:blank");
1112 return *p ? S_OK : E_OUTOFMEMORY;
1115 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
1117 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1118 nsAString nsstr;
1119 nsresult nsres;
1121 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1123 if(!This->html_document) {
1124 FIXME("Not implemented for XML document\n");
1125 return E_NOTIMPL;
1128 nsAString_InitDepend(&nsstr, v);
1129 nsres = nsIDOMHTMLDocument_SetDomain(This->html_document, &nsstr);
1130 nsAString_Finish(&nsstr);
1131 if(NS_FAILED(nsres)) {
1132 ERR("SetDomain failed: %08lx\n", nsres);
1133 return E_INVALIDARG;
1136 return S_OK;
1139 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
1141 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1142 nsAString nsstr;
1143 nsresult nsres;
1145 TRACE("(%p)->(%p)\n", This, p);
1147 if(!This->html_document) {
1148 FIXME("Not implemented for XML document\n");
1149 return E_NOTIMPL;
1152 if(This->outer_window && !This->outer_window->uri)
1153 return E_FAIL;
1155 nsAString_Init(&nsstr, NULL);
1156 nsres = nsIDOMHTMLDocument_GetDomain(This->html_document, &nsstr);
1157 if(NS_SUCCEEDED(nsres) && This->outer_window && This->outer_window->uri) {
1158 const PRUnichar *str;
1159 HRESULT hres;
1161 nsAString_GetData(&nsstr, &str);
1162 if(!*str) {
1163 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
1164 nsAString_Finish(&nsstr);
1165 hres = IUri_GetHost(This->outer_window->uri, p);
1166 return FAILED(hres) ? hres : S_OK;
1170 return return_nsstr(nsres, &nsstr, p);
1173 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
1175 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1176 BOOL bret;
1178 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1180 if(!This->outer_window)
1181 return S_OK;
1183 bret = InternetSetCookieExW(This->outer_window->url, NULL, v, 0, 0);
1184 if(!bret) {
1185 FIXME("InternetSetCookieExW failed: %lu\n", GetLastError());
1186 return HRESULT_FROM_WIN32(GetLastError());
1189 return S_OK;
1192 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
1194 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1195 DWORD size;
1196 BOOL bret;
1198 TRACE("(%p)->(%p)\n", This, p);
1200 if(!This->outer_window) {
1201 *p = NULL;
1202 return S_OK;
1205 size = 0;
1206 bret = InternetGetCookieExW(This->outer_window->url, NULL, NULL, &size, 0, NULL);
1207 if(!bret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
1208 WARN("InternetGetCookieExW failed: %lu\n", GetLastError());
1209 *p = NULL;
1210 return S_OK;
1213 if(!size) {
1214 *p = NULL;
1215 return S_OK;
1218 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
1219 if(!*p)
1220 return E_OUTOFMEMORY;
1222 bret = InternetGetCookieExW(This->outer_window->url, NULL, *p, &size, 0, NULL);
1223 if(!bret) {
1224 ERR("InternetGetCookieExW failed: %lu\n", GetLastError());
1225 return E_FAIL;
1228 return S_OK;
1231 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
1233 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1234 FIXME("(%p)->(%x)\n", This, v);
1235 return E_NOTIMPL;
1238 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
1240 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1241 FIXME("(%p)->(%p)\n", This, p);
1242 return E_NOTIMPL;
1245 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
1247 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1248 FIXME("(%p)->(%s) returning S_OK\n", This, debugstr_w(v));
1249 return S_OK;
1252 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
1254 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1256 TRACE("(%p)->(%p)\n", This, p);
1258 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
1261 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
1263 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1264 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1265 return E_NOTIMPL;
1268 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
1270 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1272 TRACE("(%p)->(%p)\n", This, p);
1274 *p = charset_string_from_cp(GetACP());
1275 return *p ? S_OK : E_OUTOFMEMORY;
1278 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
1280 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1281 const PRUnichar *content_type;
1282 nsAString nsstr;
1283 nsresult nsres;
1284 HRESULT hres;
1286 TRACE("(%p)->(%p)\n", This, p);
1288 *p = NULL;
1290 if(This->window && This->window->base.outer_window->readystate == READYSTATE_UNINITIALIZED)
1291 return (*p = SysAllocString(L"")) ? S_OK : E_FAIL;
1293 nsAString_InitDepend(&nsstr, NULL);
1294 nsres = nsIDOMDocument_GetContentType(This->dom_document, &nsstr);
1295 if(NS_FAILED(nsres))
1296 return map_nsresult(nsres);
1298 nsAString_GetData(&nsstr, &content_type);
1299 hres = get_mime_type_display_name(content_type, p);
1300 nsAString_Finish(&nsstr);
1301 return hres;
1304 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
1306 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1307 FIXME("(%p)->(%p)\n", This, p);
1308 return E_NOTIMPL;
1311 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
1313 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1314 FIXME("(%p)->(%p)\n", This, p);
1315 return E_NOTIMPL;
1318 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
1320 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1321 FIXME("(%p)->(%p)\n", This, p);
1322 return E_NOTIMPL;
1325 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
1327 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1328 FIXME("(%p)->(%p)\n", This, p);
1329 return E_NOTIMPL;
1332 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
1334 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1335 FIXME("(%p)->(%p)\n", This, p);
1336 return E_NOTIMPL;
1339 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
1341 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1342 FIXME("(%p)->(%p)\n", This, p);
1343 return E_NOTIMPL;
1346 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1348 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1349 FIXME("(%p)->(%p)\n", This, p);
1350 return E_NOTIMPL;
1353 static HRESULT document_write(HTMLDocumentNode *This, SAFEARRAY *psarray, BOOL ln)
1355 VARIANT *var, tmp;
1356 JSContext *jsctx;
1357 nsAString nsstr;
1358 ULONG i, argc;
1359 nsresult nsres;
1360 HRESULT hres;
1362 if(!This->dom_document) {
1363 WARN("NULL dom_document\n");
1364 return E_UNEXPECTED;
1367 if(!This->html_document) {
1368 FIXME("Not implemented for XML document\n");
1369 return E_NOTIMPL;
1372 if (!psarray)
1373 return S_OK;
1375 if(psarray->cDims != 1) {
1376 FIXME("cDims=%d\n", psarray->cDims);
1377 return E_INVALIDARG;
1380 hres = SafeArrayAccessData(psarray, (void**)&var);
1381 if(FAILED(hres)) {
1382 WARN("SafeArrayAccessData failed: %08lx\n", hres);
1383 return hres;
1386 V_VT(&tmp) = VT_EMPTY;
1388 jsctx = get_context_from_document(This->dom_document);
1389 argc = psarray->rgsabound[0].cElements;
1390 for(i=0; i < argc; i++) {
1391 if(V_VT(var+i) == VT_BSTR) {
1392 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1393 }else {
1394 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1395 if(FAILED(hres)) {
1396 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1397 break;
1399 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1402 if(!ln || i != argc-1)
1403 nsres = nsIDOMHTMLDocument_Write(This->html_document, &nsstr, jsctx);
1404 else
1405 nsres = nsIDOMHTMLDocument_Writeln(This->html_document, &nsstr, jsctx);
1406 nsAString_Finish(&nsstr);
1407 if(V_VT(var+i) != VT_BSTR)
1408 VariantClear(&tmp);
1409 if(NS_FAILED(nsres)) {
1410 ERR("Write failed: %08lx\n", nsres);
1411 hres = E_FAIL;
1412 break;
1416 SafeArrayUnaccessData(psarray);
1418 return hres;
1421 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1423 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1425 TRACE("(%p)->(%p)\n", iface, psarray);
1427 return document_write(This, psarray, FALSE);
1430 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1432 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1434 TRACE("(%p)->(%p)\n", This, psarray);
1436 return document_write(This, psarray, TRUE);
1439 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1440 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1442 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1443 nsISupports *tmp;
1444 nsresult nsres;
1446 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1447 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1449 *pomWindowResult = NULL;
1451 if(!This->outer_window)
1452 return E_FAIL;
1454 if(!This->dom_document) {
1455 ERR("!dom_document\n");
1456 return E_NOTIMPL;
1459 if(!This->html_document) {
1460 FIXME("Not implemented for XML document\n");
1461 return E_NOTIMPL;
1464 if(!url || wcscmp(url, L"text/html") || V_VT(&name) != VT_ERROR
1465 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1466 FIXME("unsupported args\n");
1468 nsres = nsIDOMHTMLDocument_Open(This->html_document, NULL, NULL, NULL,
1469 get_context_from_document(This->dom_document), 0, &tmp);
1470 if(NS_FAILED(nsres)) {
1471 ERR("Open failed: %08lx\n", nsres);
1472 return E_FAIL;
1475 if(tmp)
1476 nsISupports_Release(tmp);
1478 *pomWindowResult = (IDispatch*)&This->outer_window->base.IHTMLWindow2_iface;
1479 IHTMLWindow2_AddRef(&This->outer_window->base.IHTMLWindow2_iface);
1480 return S_OK;
1483 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1485 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1486 nsresult nsres;
1488 TRACE("(%p)\n", This);
1490 if(!This->dom_document) {
1491 ERR("!dom_document\n");
1492 return E_NOTIMPL;
1495 if(!This->html_document) {
1496 FIXME("Not implemented for XML document\n");
1497 return E_NOTIMPL;
1500 nsres = nsIDOMHTMLDocument_Close(This->html_document);
1501 if(NS_FAILED(nsres)) {
1502 ERR("Close failed: %08lx\n", nsres);
1503 return E_FAIL;
1506 return S_OK;
1509 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1511 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1512 nsresult nsres;
1514 TRACE("(%p)\n", This);
1516 if(!This->html_document) {
1517 FIXME("Not implemented for XML document\n");
1518 return E_NOTIMPL;
1521 nsres = nsIDOMHTMLDocument_Clear(This->html_document);
1522 if(NS_FAILED(nsres)) {
1523 ERR("Clear failed: %08lx\n", nsres);
1524 return E_FAIL;
1527 return S_OK;
1530 static const struct {
1531 const WCHAR *name;
1532 OLECMDID id;
1533 }command_names[] = {
1534 {L"copy", IDM_COPY},
1535 {L"cut", IDM_CUT},
1536 {L"fontname", IDM_FONTNAME},
1537 {L"fontsize", IDM_FONTSIZE},
1538 {L"indent", IDM_INDENT},
1539 {L"insertorderedlist", IDM_ORDERLIST},
1540 {L"insertunorderedlist", IDM_UNORDERLIST},
1541 {L"outdent", IDM_OUTDENT},
1542 {L"paste", IDM_PASTE},
1543 {L"respectvisibilityindesign", IDM_RESPECTVISIBILITY_INDESIGN}
1546 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1548 int i;
1550 for(i = 0; i < ARRAY_SIZE(command_names); i++) {
1551 if(!wcsicmp(command_names[i].name, str)) {
1552 *cmdid = command_names[i].id;
1553 return TRUE;
1557 FIXME("Unknown command %s\n", debugstr_w(str));
1558 return FALSE;
1561 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1562 VARIANT_BOOL *pfRet)
1564 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1565 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1566 return E_NOTIMPL;
1569 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1570 VARIANT_BOOL *pfRet)
1572 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1573 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1574 return E_NOTIMPL;
1577 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1578 VARIANT_BOOL *pfRet)
1580 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1581 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1582 return E_NOTIMPL;
1585 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1586 VARIANT_BOOL *pfRet)
1588 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1589 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1590 return E_NOTIMPL;
1593 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1594 BSTR *pfRet)
1596 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1597 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1598 return E_NOTIMPL;
1601 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1602 VARIANT *pfRet)
1604 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1605 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1606 return E_NOTIMPL;
1609 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1610 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1612 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1613 OLECMDID cmdid;
1614 VARIANT ret;
1615 HRESULT hres;
1617 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1619 if(!cmdid_from_string(cmdID, &cmdid))
1620 return OLECMDERR_E_NOTSUPPORTED;
1622 V_VT(&ret) = VT_EMPTY;
1623 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1624 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1625 if(FAILED(hres))
1626 return hres;
1628 if(V_VT(&ret) != VT_EMPTY) {
1629 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1630 VariantClear(&ret);
1633 *pfRet = VARIANT_TRUE;
1634 return S_OK;
1637 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1638 VARIANT_BOOL *pfRet)
1640 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1641 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1642 return E_NOTIMPL;
1645 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1646 IHTMLElement **newElem)
1648 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1649 HTMLElement *elem;
1650 HRESULT hres;
1652 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1654 hres = create_element(This, eTag, &elem);
1655 if(FAILED(hres))
1656 return hres;
1658 *newElem = &elem->IHTMLElement_iface;
1659 return S_OK;
1662 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1664 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1665 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1666 return E_NOTIMPL;
1669 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1671 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1672 FIXME("(%p)->(%p)\n", This, p);
1673 return E_NOTIMPL;
1676 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1678 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1680 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1682 return set_doc_event(This, EVENTID_CLICK, &v);
1685 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1687 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1689 TRACE("(%p)->(%p)\n", This, p);
1691 return get_doc_event(This, EVENTID_CLICK, p);
1694 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1696 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1698 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1700 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1703 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1705 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1707 TRACE("(%p)->(%p)\n", This, p);
1709 return get_doc_event(This, EVENTID_DBLCLICK, p);
1712 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1714 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1716 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1718 return set_doc_event(This, EVENTID_KEYUP, &v);
1721 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1723 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1725 TRACE("(%p)->(%p)\n", This, p);
1727 return get_doc_event(This, EVENTID_KEYUP, p);
1730 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1732 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1734 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1736 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1739 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1741 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1743 TRACE("(%p)->(%p)\n", This, p);
1745 return get_doc_event(This, EVENTID_KEYDOWN, p);
1748 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1750 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1752 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1754 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1757 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1759 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1761 TRACE("(%p)->(%p)\n", This, p);
1763 return get_doc_event(This, EVENTID_KEYPRESS, p);
1766 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1768 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1770 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1772 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1775 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1777 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1779 TRACE("(%p)->(%p)\n", This, p);
1781 return get_doc_event(This, EVENTID_MOUSEUP, p);
1784 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1786 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1788 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1790 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1793 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1795 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1797 TRACE("(%p)->(%p)\n", This, p);
1799 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1802 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1804 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1806 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1808 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1811 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1813 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1815 TRACE("(%p)->(%p)\n", This, p);
1817 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1820 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1822 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1824 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1826 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1829 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1831 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1833 TRACE("(%p)->(%p)\n", This, p);
1835 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1838 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1840 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1842 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1844 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1847 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1849 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1851 TRACE("(%p)->(%p)\n", This, p);
1853 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1856 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1858 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1860 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1862 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1865 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1867 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1869 TRACE("(%p)->(%p)\n", This, p);
1871 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1874 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1876 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1877 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1878 return E_NOTIMPL;
1881 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1883 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1884 FIXME("(%p)->(%p)\n", This, p);
1885 return E_NOTIMPL;
1888 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1890 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1891 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1892 return E_NOTIMPL;
1895 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1897 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1898 FIXME("(%p)->(%p)\n", This, p);
1899 return E_NOTIMPL;
1902 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1904 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1905 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1906 return E_NOTIMPL;
1909 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1911 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1912 FIXME("(%p)->(%p)\n", This, p);
1913 return E_NOTIMPL;
1916 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1918 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1920 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1922 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1925 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1927 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1929 TRACE("(%p)->(%p)\n", This, p);
1931 return get_doc_event(This, EVENTID_DRAGSTART, p);
1934 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1936 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1938 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1940 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1943 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1945 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1947 TRACE("(%p)->(%p)\n", This, p);
1949 return get_doc_event(This, EVENTID_SELECTSTART, p);
1952 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1953 IHTMLElement **elementHit)
1955 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1956 nsIDOMElement *nselem;
1957 HTMLElement *element;
1958 nsresult nsres;
1959 HRESULT hres;
1961 TRACE("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1963 nsres = nsIDOMDocument_ElementFromPoint(This->dom_document, x, y, &nselem);
1964 if(NS_FAILED(nsres)) {
1965 ERR("ElementFromPoint failed: %08lx\n", nsres);
1966 return E_FAIL;
1969 if(!nselem) {
1970 *elementHit = NULL;
1971 return S_OK;
1974 hres = get_element(nselem, &element);
1975 nsIDOMElement_Release(nselem);
1976 if(FAILED(hres))
1977 return hres;
1979 *elementHit = &element->IHTMLElement_iface;
1980 return S_OK;
1983 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1985 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1986 HRESULT hres;
1988 TRACE("(%p)->(%p)\n", This, p);
1990 hres = IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
1991 return hres == S_OK && !*p ? E_FAIL : hres;
1994 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1995 IHTMLStyleSheetsCollection **p)
1997 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1998 nsIDOMStyleSheetList *nsstylelist;
1999 nsresult nsres;
2000 HRESULT hres;
2002 TRACE("(%p)->(%p)\n", This, p);
2004 *p = NULL;
2006 if(!This->dom_document) {
2007 WARN("NULL dom_document\n");
2008 return E_UNEXPECTED;
2011 nsres = nsIDOMDocument_GetStyleSheets(This->dom_document, &nsstylelist);
2012 if(NS_FAILED(nsres)) {
2013 ERR("GetStyleSheets failed: %08lx\n", nsres);
2014 return map_nsresult(nsres);
2017 hres = create_style_sheet_collection(nsstylelist,
2018 dispex_compat_mode(&This->node.event_target.dispex), p);
2019 nsIDOMStyleSheetList_Release(nsstylelist);
2020 return hres;
2023 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
2025 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2026 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2027 return E_NOTIMPL;
2030 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
2032 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2033 FIXME("(%p)->(%p)\n", This, p);
2034 return E_NOTIMPL;
2037 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
2039 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2040 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2041 return E_NOTIMPL;
2044 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
2046 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2047 FIXME("(%p)->(%p)\n", This, p);
2048 return E_NOTIMPL;
2051 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
2053 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2055 TRACE("(%p)->(%p)\n", This, String);
2057 return dispex_to_string(&This->node.event_target.dispex, String);
2060 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
2061 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
2063 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2064 nsIDOMHTMLHeadElement *head_elem;
2065 IHTMLStyleElement *style_elem;
2066 HTMLElement *elem;
2067 nsresult nsres;
2068 HRESULT hres;
2070 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
2072 if(!This->dom_document) {
2073 FIXME("not a real doc object\n");
2074 return E_NOTIMPL;
2077 if(!This->html_document) {
2078 FIXME("Not implemented for XML document\n");
2079 return E_NOTIMPL;
2082 if(lIndex != -1)
2083 FIXME("Unsupported lIndex %ld\n", lIndex);
2085 if(bstrHref && *bstrHref) {
2086 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
2087 return create_style_sheet(NULL, dispex_compat_mode(&This->node.event_target.dispex),
2088 ppnewStyleSheet);
2091 hres = create_element(This, L"style", &elem);
2092 if(FAILED(hres))
2093 return hres;
2095 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &head_elem);
2096 if(NS_SUCCEEDED(nsres)) {
2097 nsIDOMNode *head_node, *tmp_node;
2099 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
2100 nsIDOMHTMLHeadElement_Release(head_elem);
2101 assert(nsres == NS_OK);
2103 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
2104 nsIDOMNode_Release(head_node);
2105 if(NS_SUCCEEDED(nsres) && tmp_node)
2106 nsIDOMNode_Release(tmp_node);
2108 if(NS_FAILED(nsres)) {
2109 IHTMLElement_Release(&elem->IHTMLElement_iface);
2110 return E_FAIL;
2113 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
2114 assert(hres == S_OK);
2115 IHTMLElement_Release(&elem->IHTMLElement_iface);
2117 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
2118 IHTMLStyleElement_Release(style_elem);
2119 return hres;
2122 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
2123 HTMLDocument_QueryInterface,
2124 HTMLDocument_AddRef,
2125 HTMLDocument_Release,
2126 HTMLDocument_GetTypeInfoCount,
2127 HTMLDocument_GetTypeInfo,
2128 HTMLDocument_GetIDsOfNames,
2129 HTMLDocument_Invoke,
2130 HTMLDocument_get_Script,
2131 HTMLDocument_get_all,
2132 HTMLDocument_get_body,
2133 HTMLDocument_get_activeElement,
2134 HTMLDocument_get_images,
2135 HTMLDocument_get_applets,
2136 HTMLDocument_get_links,
2137 HTMLDocument_get_forms,
2138 HTMLDocument_get_anchors,
2139 HTMLDocument_put_title,
2140 HTMLDocument_get_title,
2141 HTMLDocument_get_scripts,
2142 HTMLDocument_put_designMode,
2143 HTMLDocument_get_designMode,
2144 HTMLDocument_get_selection,
2145 HTMLDocument_get_readyState,
2146 HTMLDocument_get_frames,
2147 HTMLDocument_get_embeds,
2148 HTMLDocument_get_plugins,
2149 HTMLDocument_put_alinkColor,
2150 HTMLDocument_get_alinkColor,
2151 HTMLDocument_put_bgColor,
2152 HTMLDocument_get_bgColor,
2153 HTMLDocument_put_fgColor,
2154 HTMLDocument_get_fgColor,
2155 HTMLDocument_put_linkColor,
2156 HTMLDocument_get_linkColor,
2157 HTMLDocument_put_vlinkColor,
2158 HTMLDocument_get_vlinkColor,
2159 HTMLDocument_get_referrer,
2160 HTMLDocument_get_location,
2161 HTMLDocument_get_lastModified,
2162 HTMLDocument_put_URL,
2163 HTMLDocument_get_URL,
2164 HTMLDocument_put_domain,
2165 HTMLDocument_get_domain,
2166 HTMLDocument_put_cookie,
2167 HTMLDocument_get_cookie,
2168 HTMLDocument_put_expando,
2169 HTMLDocument_get_expando,
2170 HTMLDocument_put_charset,
2171 HTMLDocument_get_charset,
2172 HTMLDocument_put_defaultCharset,
2173 HTMLDocument_get_defaultCharset,
2174 HTMLDocument_get_mimeType,
2175 HTMLDocument_get_fileSize,
2176 HTMLDocument_get_fileCreatedDate,
2177 HTMLDocument_get_fileModifiedDate,
2178 HTMLDocument_get_fileUpdatedDate,
2179 HTMLDocument_get_security,
2180 HTMLDocument_get_protocol,
2181 HTMLDocument_get_nameProp,
2182 HTMLDocument_write,
2183 HTMLDocument_writeln,
2184 HTMLDocument_open,
2185 HTMLDocument_close,
2186 HTMLDocument_clear,
2187 HTMLDocument_queryCommandSupported,
2188 HTMLDocument_queryCommandEnabled,
2189 HTMLDocument_queryCommandState,
2190 HTMLDocument_queryCommandIndeterm,
2191 HTMLDocument_queryCommandText,
2192 HTMLDocument_queryCommandValue,
2193 HTMLDocument_execCommand,
2194 HTMLDocument_execCommandShowHelp,
2195 HTMLDocument_createElement,
2196 HTMLDocument_put_onhelp,
2197 HTMLDocument_get_onhelp,
2198 HTMLDocument_put_onclick,
2199 HTMLDocument_get_onclick,
2200 HTMLDocument_put_ondblclick,
2201 HTMLDocument_get_ondblclick,
2202 HTMLDocument_put_onkeyup,
2203 HTMLDocument_get_onkeyup,
2204 HTMLDocument_put_onkeydown,
2205 HTMLDocument_get_onkeydown,
2206 HTMLDocument_put_onkeypress,
2207 HTMLDocument_get_onkeypress,
2208 HTMLDocument_put_onmouseup,
2209 HTMLDocument_get_onmouseup,
2210 HTMLDocument_put_onmousedown,
2211 HTMLDocument_get_onmousedown,
2212 HTMLDocument_put_onmousemove,
2213 HTMLDocument_get_onmousemove,
2214 HTMLDocument_put_onmouseout,
2215 HTMLDocument_get_onmouseout,
2216 HTMLDocument_put_onmouseover,
2217 HTMLDocument_get_onmouseover,
2218 HTMLDocument_put_onreadystatechange,
2219 HTMLDocument_get_onreadystatechange,
2220 HTMLDocument_put_onafterupdate,
2221 HTMLDocument_get_onafterupdate,
2222 HTMLDocument_put_onrowexit,
2223 HTMLDocument_get_onrowexit,
2224 HTMLDocument_put_onrowenter,
2225 HTMLDocument_get_onrowenter,
2226 HTMLDocument_put_ondragstart,
2227 HTMLDocument_get_ondragstart,
2228 HTMLDocument_put_onselectstart,
2229 HTMLDocument_get_onselectstart,
2230 HTMLDocument_elementFromPoint,
2231 HTMLDocument_get_parentWindow,
2232 HTMLDocument_get_styleSheets,
2233 HTMLDocument_put_onbeforeupdate,
2234 HTMLDocument_get_onbeforeupdate,
2235 HTMLDocument_put_onerrorupdate,
2236 HTMLDocument_get_onerrorupdate,
2237 HTMLDocument_toString,
2238 HTMLDocument_createStyleSheet
2241 static inline HTMLDocumentNode *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
2243 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument3_iface);
2246 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface, REFIID riid, void **ppv)
2248 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2249 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2252 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
2254 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2255 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2258 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
2260 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2261 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2264 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
2266 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2267 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2270 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo, LCID lcid,
2271 ITypeInfo **ppTInfo)
2273 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2274 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2277 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid, LPOLESTR *rgszNames,
2278 UINT cNames, LCID lcid, DISPID *rgDispId)
2280 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2281 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2284 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2285 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2287 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2288 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2289 pDispParams, pVarResult, pExcepInfo, puArgErr);
2292 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
2294 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2295 FIXME("(%p)\n", This);
2296 return E_NOTIMPL;
2299 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
2301 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2303 WARN("(%p)->(%x)\n", This, fForce);
2305 /* Doing nothing here should be fine for us. */
2306 return S_OK;
2309 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text, IHTMLDOMNode **newTextNode)
2311 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2312 nsIDOMText *nstext;
2313 HTMLDOMNode *node;
2314 nsAString text_str;
2315 nsresult nsres;
2316 HRESULT hres;
2318 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
2320 if(!This->dom_document) {
2321 WARN("NULL dom_document\n");
2322 return E_UNEXPECTED;
2325 nsAString_InitDepend(&text_str, text);
2326 nsres = nsIDOMDocument_CreateTextNode(This->dom_document, &text_str, &nstext);
2327 nsAString_Finish(&text_str);
2328 if(NS_FAILED(nsres)) {
2329 ERR("CreateTextNode failed: %08lx\n", nsres);
2330 return E_FAIL;
2333 hres = HTMLDOMTextNode_Create(This, (nsIDOMNode*)nstext, &node);
2334 nsIDOMText_Release(nstext);
2335 if(FAILED(hres))
2336 return hres;
2338 *newTextNode = &node->IHTMLDOMNode_iface;
2339 return S_OK;
2342 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
2344 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2345 nsIDOMElement *nselem = NULL;
2346 HTMLElement *element;
2347 nsresult nsres;
2348 HRESULT hres;
2350 TRACE("(%p)->(%p)\n", This, p);
2352 if(This->outer_window && This->outer_window->readystate == READYSTATE_UNINITIALIZED) {
2353 *p = NULL;
2354 return S_OK;
2357 if(!This->dom_document) {
2358 WARN("NULL dom_document\n");
2359 return E_UNEXPECTED;
2362 nsres = nsIDOMDocument_GetDocumentElement(This->dom_document, &nselem);
2363 if(NS_FAILED(nsres)) {
2364 ERR("GetDocumentElement failed: %08lx\n", nsres);
2365 return E_FAIL;
2368 if(!nselem) {
2369 *p = NULL;
2370 return S_OK;
2373 hres = get_element(nselem, &element);
2374 nsIDOMElement_Release(nselem);
2375 if(FAILED(hres))
2376 return hres;
2378 *p = &element->IHTMLElement_iface;
2379 return hres;
2382 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2384 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2386 TRACE("(%p)->(%p)\n", This, p);
2388 return elem_unique_id(++This->unique_id, p);
2391 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch* pDisp,
2392 VARIANT_BOOL *pfResult)
2394 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2396 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2398 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2401 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch *pDisp)
2403 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2405 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2407 return detach_event(&This->node.event_target, event, pDisp);
2410 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2412 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2413 FIXME("(%p)->()\n", This);
2414 return E_NOTIMPL;
2417 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2419 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2420 FIXME("(%p)->(%p)\n", This, p);
2421 return E_NOTIMPL;
2424 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2426 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2427 FIXME("(%p)->()\n", This);
2428 return E_NOTIMPL;
2431 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2433 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2434 FIXME("(%p)->(%p)\n", This, p);
2435 return E_NOTIMPL;
2438 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2440 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2441 FIXME("(%p)->()\n", This);
2442 return E_NOTIMPL;
2445 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2447 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2448 FIXME("(%p)->(%p)\n", This, p);
2449 return E_NOTIMPL;
2452 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2454 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2455 FIXME("(%p)->()\n", This);
2456 return E_NOTIMPL;
2459 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2461 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2462 FIXME("(%p)->(%p)\n", This, p);
2463 return E_NOTIMPL;
2466 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2468 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2469 FIXME("(%p)->()\n", This);
2470 return E_NOTIMPL;
2473 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2475 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2476 FIXME("(%p)->(%p)\n", This, p);
2477 return E_NOTIMPL;
2480 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2482 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2483 FIXME("(%p)->()\n", This);
2484 return E_NOTIMPL;
2487 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2489 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2490 FIXME("(%p)->(%p)\n", This, p);
2491 return E_NOTIMPL;
2494 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2496 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2497 FIXME("(%p)->()\n", This);
2498 return E_NOTIMPL;
2501 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2503 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2504 FIXME("(%p)->(%p)\n", This, p);
2505 return E_NOTIMPL;
2508 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2510 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2511 nsAString dir_str;
2512 nsresult nsres;
2514 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2516 if(!This->dom_document) {
2517 FIXME("NULL dom_document\n");
2518 return E_UNEXPECTED;
2521 nsAString_InitDepend(&dir_str, v);
2522 nsres = nsIDOMDocument_SetDir(This->dom_document, &dir_str);
2523 nsAString_Finish(&dir_str);
2524 if(NS_FAILED(nsres)) {
2525 ERR("SetDir failed: %08lx\n", nsres);
2526 return E_FAIL;
2529 return S_OK;
2532 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2534 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2535 nsAString dir_str;
2536 nsresult nsres;
2538 TRACE("(%p)->(%p)\n", This, p);
2540 if(!This->dom_document) {
2541 FIXME("NULL dom_document\n");
2542 return E_UNEXPECTED;
2545 nsAString_Init(&dir_str, NULL);
2546 nsres = nsIDOMDocument_GetDir(This->dom_document, &dir_str);
2547 return return_nsstr(nsres, &dir_str, p);
2550 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2552 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2554 TRACE("(%p)->()\n", This);
2556 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2559 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2561 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2563 TRACE("(%p)->(%p)\n", This, p);
2565 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2568 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2570 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2571 FIXME("(%p)->()\n", This);
2572 return E_NOTIMPL;
2575 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2577 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2578 FIXME("(%p)->(%p)\n", This, p);
2579 return E_NOTIMPL;
2582 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface, IHTMLDocument2 **ppNewDoc)
2584 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2585 nsIDOMDocumentFragment *doc_frag;
2586 HTMLDocumentNode *docnode;
2587 nsresult nsres;
2588 HRESULT hres;
2590 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2592 if(!This->dom_document) {
2593 FIXME("NULL dom_document\n");
2594 return E_NOTIMPL;
2597 nsres = nsIDOMDocument_CreateDocumentFragment(This->dom_document, &doc_frag);
2598 if(NS_FAILED(nsres)) {
2599 ERR("CreateDocumentFragment failed: %08lx\n", nsres);
2600 return E_FAIL;
2603 hres = create_document_fragment((nsIDOMNode*)doc_frag, This, &docnode);
2604 nsIDOMDocumentFragment_Release(doc_frag);
2605 if(FAILED(hres))
2606 return hres;
2608 *ppNewDoc = &docnode->IHTMLDocument2_iface;
2609 return S_OK;
2612 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface, IHTMLDocument2 **p)
2614 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2615 FIXME("(%p)->(%p)\n", This, p);
2616 return E_NOTIMPL;
2619 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL v)
2621 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2622 FIXME("(%p)->(%x)\n", This, v);
2623 return E_NOTIMPL;
2626 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2628 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2629 FIXME("(%p)->(%p)\n", This, p);
2630 return E_NOTIMPL;
2633 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2635 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2636 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2637 return E_NOTIMPL;
2640 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2642 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2643 FIXME("(%p)->(%p)\n", This, p);
2644 return E_NOTIMPL;
2647 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2649 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2651 TRACE("(%p)->(%p)\n", This, p);
2653 return IHTMLDOMNode_get_childNodes(&This->node.IHTMLDOMNode_iface, p);
2656 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL v)
2658 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2659 FIXME("(%p)->()\n", This);
2660 return E_NOTIMPL;
2663 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2665 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2666 FIXME("(%p)->(%p)\n", This, p);
2667 return E_NOTIMPL;
2670 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2672 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2673 FIXME("(%p)->()\n", This);
2674 return E_NOTIMPL;
2677 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2679 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2680 FIXME("(%p)->(%p)\n", This, p);
2681 return E_NOTIMPL;
2684 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2685 IHTMLElementCollection **ppelColl)
2687 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2688 nsIDOMNodeList *node_list;
2689 nsAString selector_str;
2690 WCHAR *selector;
2691 nsresult nsres;
2692 static const WCHAR formatW[] = L"*[id=%s],*[name=%s]";
2694 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2696 if(!This->dom_document) {
2697 /* We should probably return an empty collection. */
2698 FIXME("No dom_document\n");
2699 return E_NOTIMPL;
2702 selector = malloc(2 * SysStringLen(v) * sizeof(WCHAR) + sizeof(formatW));
2703 if(!selector)
2704 return E_OUTOFMEMORY;
2705 swprintf(selector, 2*SysStringLen(v) + ARRAY_SIZE(formatW), formatW, v, v);
2708 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2709 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2710 * types and search should be case insensitive. Those are currently not supported properly.
2712 nsAString_InitDepend(&selector_str, selector);
2713 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &selector_str, &node_list);
2714 nsAString_Finish(&selector_str);
2715 free(selector);
2716 if(NS_FAILED(nsres)) {
2717 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2718 return E_FAIL;
2721 *ppelColl = create_collection_from_nodelist(node_list, This->document_mode);
2722 nsIDOMNodeList_Release(node_list);
2723 return S_OK;
2727 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v, IHTMLElement **pel)
2729 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2730 HTMLElement *elem;
2731 HRESULT hres;
2733 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2735 hres = get_doc_elem_by_id(This, v, &elem);
2736 if(FAILED(hres) || !elem) {
2737 *pel = NULL;
2738 return hres;
2741 *pel = &elem->IHTMLElement_iface;
2742 return S_OK;
2746 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2747 IHTMLElementCollection **pelColl)
2749 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2750 nsIDOMNodeList *nslist;
2751 nsAString id_str;
2752 nsresult nsres;
2754 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2756 if(This->dom_document) {
2757 nsAString_InitDepend(&id_str, v);
2758 nsres = nsIDOMDocument_GetElementsByTagName(This->dom_document, &id_str, &nslist);
2759 nsAString_Finish(&id_str);
2760 if(FAILED(nsres)) {
2761 ERR("GetElementByName failed: %08lx\n", nsres);
2762 return E_FAIL;
2764 }else {
2765 nsIDOMDocumentFragment *docfrag;
2766 nsAString nsstr;
2768 if(v) {
2769 const WCHAR *ptr;
2770 for(ptr=v; *ptr; ptr++) {
2771 if(!iswalnum(*ptr)) {
2772 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2773 return E_NOTIMPL;
2778 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2779 if(NS_FAILED(nsres)) {
2780 ERR("Could not get nsIDOMDocumentFragment iface: %08lx\n", nsres);
2781 return E_UNEXPECTED;
2784 nsAString_InitDepend(&nsstr, v);
2785 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2786 nsAString_Finish(&nsstr);
2787 nsIDOMDocumentFragment_Release(docfrag);
2788 if(NS_FAILED(nsres)) {
2789 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2790 return E_FAIL;
2795 *pelColl = create_collection_from_nodelist(nslist, This->document_mode);
2796 nsIDOMNodeList_Release(nslist);
2798 return S_OK;
2801 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2802 HTMLDocument3_QueryInterface,
2803 HTMLDocument3_AddRef,
2804 HTMLDocument3_Release,
2805 HTMLDocument3_GetTypeInfoCount,
2806 HTMLDocument3_GetTypeInfo,
2807 HTMLDocument3_GetIDsOfNames,
2808 HTMLDocument3_Invoke,
2809 HTMLDocument3_releaseCapture,
2810 HTMLDocument3_recalc,
2811 HTMLDocument3_createTextNode,
2812 HTMLDocument3_get_documentElement,
2813 HTMLDocument3_get_uniqueID,
2814 HTMLDocument3_attachEvent,
2815 HTMLDocument3_detachEvent,
2816 HTMLDocument3_put_onrowsdelete,
2817 HTMLDocument3_get_onrowsdelete,
2818 HTMLDocument3_put_onrowsinserted,
2819 HTMLDocument3_get_onrowsinserted,
2820 HTMLDocument3_put_oncellchange,
2821 HTMLDocument3_get_oncellchange,
2822 HTMLDocument3_put_ondatasetchanged,
2823 HTMLDocument3_get_ondatasetchanged,
2824 HTMLDocument3_put_ondataavailable,
2825 HTMLDocument3_get_ondataavailable,
2826 HTMLDocument3_put_ondatasetcomplete,
2827 HTMLDocument3_get_ondatasetcomplete,
2828 HTMLDocument3_put_onpropertychange,
2829 HTMLDocument3_get_onpropertychange,
2830 HTMLDocument3_put_dir,
2831 HTMLDocument3_get_dir,
2832 HTMLDocument3_put_oncontextmenu,
2833 HTMLDocument3_get_oncontextmenu,
2834 HTMLDocument3_put_onstop,
2835 HTMLDocument3_get_onstop,
2836 HTMLDocument3_createDocumentFragment,
2837 HTMLDocument3_get_parentDocument,
2838 HTMLDocument3_put_enableDownload,
2839 HTMLDocument3_get_enableDownload,
2840 HTMLDocument3_put_baseUrl,
2841 HTMLDocument3_get_baseUrl,
2842 HTMLDocument3_get_childNodes,
2843 HTMLDocument3_put_inheritStyleSheets,
2844 HTMLDocument3_get_inheritStyleSheets,
2845 HTMLDocument3_put_onbeforeeditfocus,
2846 HTMLDocument3_get_onbeforeeditfocus,
2847 HTMLDocument3_getElementsByName,
2848 HTMLDocument3_getElementById,
2849 HTMLDocument3_getElementsByTagName
2852 static inline HTMLDocumentNode *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2854 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument4_iface);
2857 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface, REFIID riid, void **ppv)
2859 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2860 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2863 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2865 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2866 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2869 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2871 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2872 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2875 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2877 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2878 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2881 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo, LCID lcid,
2882 ITypeInfo **ppTInfo)
2884 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2885 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2888 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid, LPOLESTR *rgszNames,
2889 UINT cNames, LCID lcid, DISPID *rgDispId)
2891 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2892 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2895 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2896 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2898 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2899 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2900 pDispParams, pVarResult, pExcepInfo, puArgErr);
2903 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2905 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2906 nsIDOMHTMLElement *nsbody;
2907 nsresult nsres;
2909 TRACE("(%p)->()\n", This);
2911 if(!This->html_document) {
2912 FIXME("Not implemented for XML document\n");
2913 return E_NOTIMPL;
2916 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, &nsbody);
2917 if(NS_FAILED(nsres) || !nsbody) {
2918 ERR("GetBody failed: %08lx\n", nsres);
2919 return E_FAIL;
2922 nsres = nsIDOMHTMLElement_Focus(nsbody);
2923 nsIDOMHTMLElement_Release(nsbody);
2924 if(NS_FAILED(nsres)) {
2925 ERR("Focus failed: %08lx\n", nsres);
2926 return E_FAIL;
2929 return S_OK;
2932 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2934 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2935 cpp_bool has_focus;
2936 nsresult nsres;
2938 TRACE("(%p)->(%p)\n", This, pfFocus);
2940 if(!This->dom_document) {
2941 FIXME("Unimplemented for fragments.\n");
2942 return E_NOTIMPL;
2945 nsres = nsIDOMDocument_HasFocus(This->dom_document, &has_focus);
2946 assert(nsres == NS_OK);
2948 *pfFocus = variant_bool(has_focus);
2949 return S_OK;
2952 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2954 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2956 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2958 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2961 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2963 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2965 TRACE("(%p)->(%p)\n", This, p);
2967 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2970 static HRESULT WINAPI HTMLDocument4_get_namespaces(IHTMLDocument4 *iface, IDispatch **p)
2972 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2974 TRACE("(%p)->(%p)\n", This, p);
2976 if(!This->namespaces) {
2977 HRESULT hres;
2979 hres = create_namespace_collection(dispex_compat_mode(&This->node.event_target.dispex),
2980 &This->namespaces);
2981 if(FAILED(hres))
2982 return hres;
2985 IHTMLNamespaceCollection_AddRef(This->namespaces);
2986 *p = (IDispatch*)This->namespaces;
2987 return S_OK;
2990 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2991 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2993 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2994 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2995 return E_NOTIMPL;
2998 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
3000 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3001 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3002 return E_NOTIMPL;
3005 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
3007 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3008 FIXME("(%p)->(%p)\n", This, p);
3009 return E_NOTIMPL;
3012 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
3013 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
3015 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3017 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
3019 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
3020 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
3021 return E_NOTIMPL;
3024 return create_event_obj(dispex_compat_mode(&This->node.event_target.dispex), ppEventObj);
3027 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
3028 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
3030 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3032 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
3034 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCanceled);
3037 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
3038 IHTMLRenderStyle **ppIHTMLRenderStyle)
3040 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3041 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
3042 return E_NOTIMPL;
3045 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
3047 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3048 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3049 return E_NOTIMPL;
3052 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
3054 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3055 FIXME("(%p)->(%p)\n", This, p);
3056 return E_NOTIMPL;
3059 static HRESULT WINAPI HTMLDocument4_get_URLUnencoded(IHTMLDocument4 *iface, BSTR *p)
3061 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3062 FIXME("(%p)->(%p)\n", This, p);
3063 return E_NOTIMPL;
3066 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
3067 HTMLDocument4_QueryInterface,
3068 HTMLDocument4_AddRef,
3069 HTMLDocument4_Release,
3070 HTMLDocument4_GetTypeInfoCount,
3071 HTMLDocument4_GetTypeInfo,
3072 HTMLDocument4_GetIDsOfNames,
3073 HTMLDocument4_Invoke,
3074 HTMLDocument4_focus,
3075 HTMLDocument4_hasFocus,
3076 HTMLDocument4_put_onselectionchange,
3077 HTMLDocument4_get_onselectionchange,
3078 HTMLDocument4_get_namespaces,
3079 HTMLDocument4_createDocumentFromUrl,
3080 HTMLDocument4_put_media,
3081 HTMLDocument4_get_media,
3082 HTMLDocument4_createEventObject,
3083 HTMLDocument4_fireEvent,
3084 HTMLDocument4_createRenderStyle,
3085 HTMLDocument4_put_oncontrolselect,
3086 HTMLDocument4_get_oncontrolselect,
3087 HTMLDocument4_get_URLUnencoded
3090 static inline HTMLDocumentNode *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
3092 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument5_iface);
3095 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface, REFIID riid, void **ppv)
3097 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3098 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3101 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
3103 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3104 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3107 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
3109 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3110 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3113 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
3115 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3116 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3119 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo, LCID lcid,
3120 ITypeInfo **ppTInfo)
3122 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3123 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3126 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid, LPOLESTR *rgszNames,
3127 UINT cNames, LCID lcid, DISPID *rgDispId)
3129 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3130 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3133 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3134 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3136 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3137 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3138 pDispParams, pVarResult, pExcepInfo, puArgErr);
3141 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
3143 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3145 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3147 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
3150 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
3152 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3154 TRACE("(%p)->(%p)\n", This, p);
3156 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
3159 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
3161 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3162 nsIDOMDocumentType *nsdoctype;
3163 HTMLDOMNode *doctype_node;
3164 nsresult nsres;
3165 HRESULT hres;
3167 TRACE("(%p)->(%p)\n", This, p);
3169 if(dispex_compat_mode(&This->node.event_target.dispex) < COMPAT_MODE_IE9) {
3170 *p = NULL;
3171 return S_OK;
3174 nsres = nsIDOMDocument_GetDoctype(This->dom_document, &nsdoctype);
3175 if(NS_FAILED(nsres))
3176 return map_nsresult(nsres);
3177 if(!nsdoctype) {
3178 *p = NULL;
3179 return S_OK;
3182 hres = get_node((nsIDOMNode*)nsdoctype, TRUE, &doctype_node);
3183 nsIDOMDocumentType_Release(nsdoctype);
3185 if(SUCCEEDED(hres))
3186 *p = &doctype_node->IHTMLDOMNode_iface;
3187 return hres;
3190 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
3192 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3194 TRACE("(%p)->(%p)\n", This, p);
3196 if(!This->dom_implementation) {
3197 HRESULT hres;
3199 hres = create_dom_implementation(This, &This->dom_implementation);
3200 if(FAILED(hres))
3201 return hres;
3204 IHTMLDOMImplementation_AddRef(This->dom_implementation);
3205 *p = This->dom_implementation;
3206 return S_OK;
3209 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
3210 IHTMLDOMAttribute **ppattribute)
3212 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3213 HTMLDOMAttribute *attr;
3214 HRESULT hres;
3216 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
3218 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, dispex_compat_mode(&This->node.event_target.dispex), &attr);
3219 if(FAILED(hres))
3220 return hres;
3222 *ppattribute = &attr->IHTMLDOMAttribute_iface;
3223 return S_OK;
3226 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
3227 IHTMLDOMNode **ppRetNode)
3229 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3230 nsIDOMComment *nscomment;
3231 HTMLElement *elem;
3232 nsAString str;
3233 nsresult nsres;
3234 HRESULT hres;
3236 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
3238 if(!This->dom_document) {
3239 WARN("NULL dom_document\n");
3240 return E_UNEXPECTED;
3243 nsAString_InitDepend(&str, bstrdata);
3244 nsres = nsIDOMDocument_CreateComment(This->dom_document, &str, &nscomment);
3245 nsAString_Finish(&str);
3246 if(NS_FAILED(nsres)) {
3247 ERR("CreateTextNode failed: %08lx\n", nsres);
3248 return E_FAIL;
3251 hres = HTMLCommentElement_Create(This, (nsIDOMNode*)nscomment, &elem);
3252 nsIDOMComment_Release(nscomment);
3253 if(FAILED(hres))
3254 return hres;
3256 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
3257 return S_OK;
3260 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
3262 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3264 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3266 return set_doc_event(This, EVENTID_FOCUSIN, &v);
3269 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
3271 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3273 TRACE("(%p)->(%p)\n", This, p);
3275 return get_doc_event(This, EVENTID_FOCUSIN, p);
3278 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
3280 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3282 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3284 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
3287 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
3289 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3291 TRACE("(%p)->(%p)\n", This, p);
3293 return get_doc_event(This, EVENTID_FOCUSOUT, p);
3296 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
3298 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3299 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3300 return E_NOTIMPL;
3303 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
3305 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3306 FIXME("(%p)->(%p)\n", This, p);
3307 return E_NOTIMPL;
3310 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
3312 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3313 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3314 return E_NOTIMPL;
3317 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
3319 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3320 FIXME("(%p)->(%p)\n", This, p);
3321 return E_NOTIMPL;
3324 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
3326 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3327 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3328 return E_NOTIMPL;
3331 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
3333 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3334 FIXME("(%p)->(%p)\n", This, p);
3335 return E_NOTIMPL;
3338 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
3340 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3341 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3342 return E_NOTIMPL;
3345 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
3347 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3348 FIXME("(%p)->(%p)\n", This, p);
3349 return E_NOTIMPL;
3352 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
3354 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3356 TRACE("(%p)->(%p)\n", This, p);
3358 *p = SysAllocString(This->document_mode <= COMPAT_MODE_IE5 ? L"BackCompat" : L"CSS1Compat");
3359 return *p ? S_OK : E_OUTOFMEMORY;
3362 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
3363 HTMLDocument5_QueryInterface,
3364 HTMLDocument5_AddRef,
3365 HTMLDocument5_Release,
3366 HTMLDocument5_GetTypeInfoCount,
3367 HTMLDocument5_GetTypeInfo,
3368 HTMLDocument5_GetIDsOfNames,
3369 HTMLDocument5_Invoke,
3370 HTMLDocument5_put_onmousewheel,
3371 HTMLDocument5_get_onmousewheel,
3372 HTMLDocument5_get_doctype,
3373 HTMLDocument5_get_implementation,
3374 HTMLDocument5_createAttribute,
3375 HTMLDocument5_createComment,
3376 HTMLDocument5_put_onfocusin,
3377 HTMLDocument5_get_onfocusin,
3378 HTMLDocument5_put_onfocusout,
3379 HTMLDocument5_get_onfocusout,
3380 HTMLDocument5_put_onactivate,
3381 HTMLDocument5_get_onactivate,
3382 HTMLDocument5_put_ondeactivate,
3383 HTMLDocument5_get_ondeactivate,
3384 HTMLDocument5_put_onbeforeactivate,
3385 HTMLDocument5_get_onbeforeactivate,
3386 HTMLDocument5_put_onbeforedeactivate,
3387 HTMLDocument5_get_onbeforedeactivate,
3388 HTMLDocument5_get_compatMode
3391 static inline HTMLDocumentNode *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3393 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument6_iface);
3396 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface, REFIID riid, void **ppv)
3398 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3399 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3402 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3404 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3405 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3408 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3410 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3411 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3414 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3416 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3417 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3420 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo, LCID lcid,
3421 ITypeInfo **ppTInfo)
3423 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3424 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3427 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid, LPOLESTR *rgszNames,
3428 UINT cNames, LCID lcid, DISPID *rgDispId)
3430 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3431 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3434 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3435 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3437 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3438 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3439 pDispParams, pVarResult, pExcepInfo, puArgErr);
3442 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3443 IHTMLDocumentCompatibleInfoCollection **p)
3445 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3446 FIXME("(%p)->(%p)\n", This, p);
3447 return E_NOTIMPL;
3450 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3452 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3454 TRACE("(%p)->(%p)\n", This, p);
3456 V_VT(p) = VT_R4;
3457 V_R4(p) = compat_mode_info[This->document_mode].document_mode;
3458 return S_OK;
3461 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3462 VARIANT *p)
3464 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3466 TRACE("(%p)->(%p)\n", This, p);
3468 return get_doc_event(This, EVENTID_STORAGE, p);
3471 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3473 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3475 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3477 return set_doc_event(This, EVENTID_STORAGE, &v);
3480 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3481 VARIANT *p)
3483 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3485 TRACE("(%p)->(%p)\n", This, p);
3487 return get_doc_event(This, EVENTID_STORAGECOMMIT, p);
3490 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3492 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3494 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3496 return set_doc_event(This, EVENTID_STORAGECOMMIT, &v);
3499 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3500 BSTR bstrId, IHTMLElement2 **p)
3502 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3503 nsIDOMElement *nselem;
3504 HTMLElement *elem;
3505 nsAString nsstr;
3506 nsresult nsres;
3507 HRESULT hres;
3509 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3512 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3513 * not search for name attributes, so we may simply let Gecko do the right thing.
3516 if(!This->dom_document) {
3517 FIXME("Not a document\n");
3518 return E_FAIL;
3521 nsAString_InitDepend(&nsstr, bstrId);
3522 nsres = nsIDOMDocument_GetElementById(This->dom_document, &nsstr, &nselem);
3523 nsAString_Finish(&nsstr);
3524 if(NS_FAILED(nsres)) {
3525 ERR("GetElementById failed: %08lx\n", nsres);
3526 return E_FAIL;
3529 if(!nselem) {
3530 *p = NULL;
3531 return S_OK;
3534 hres = get_element(nselem, &elem);
3535 nsIDOMElement_Release(nselem);
3536 if(FAILED(hres))
3537 return hres;
3539 *p = &elem->IHTMLElement2_iface;
3540 return S_OK;
3543 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3545 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3546 FIXME("(%p)->()\n", This);
3547 return E_NOTIMPL;
3550 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3551 HTMLDocument6_QueryInterface,
3552 HTMLDocument6_AddRef,
3553 HTMLDocument6_Release,
3554 HTMLDocument6_GetTypeInfoCount,
3555 HTMLDocument6_GetTypeInfo,
3556 HTMLDocument6_GetIDsOfNames,
3557 HTMLDocument6_Invoke,
3558 HTMLDocument6_get_compatible,
3559 HTMLDocument6_get_documentMode,
3560 HTMLDocument6_put_onstorage,
3561 HTMLDocument6_get_onstorage,
3562 HTMLDocument6_put_onstoragecommit,
3563 HTMLDocument6_get_onstoragecommit,
3564 HTMLDocument6_getElementById,
3565 HTMLDocument6_updateSettings
3568 static inline HTMLDocumentNode *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3570 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument7_iface);
3573 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3575 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3576 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3579 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3581 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3582 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3585 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3587 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3588 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3591 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3593 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3594 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3597 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo, LCID lcid,
3598 ITypeInfo **ppTInfo)
3600 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3601 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3604 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid, LPOLESTR *rgszNames,
3605 UINT cNames, LCID lcid, DISPID *rgDispId)
3607 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3608 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3611 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3612 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3614 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3615 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3616 pDispParams, pVarResult, pExcepInfo, puArgErr);
3619 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3621 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3623 TRACE("(%p)->(%p)\n", This, p);
3625 if(This->window && This->window->base.outer_window) {
3626 *p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
3627 IHTMLWindow2_AddRef(*p);
3628 }else {
3629 *p = NULL;
3631 return S_OK;
3634 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3636 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3637 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3638 return E_NOTIMPL;
3641 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3643 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3644 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3645 return E_NOTIMPL;
3648 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3649 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3651 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3652 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3653 return E_NOTIMPL;
3656 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3658 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3659 nsIDOMElement *dom_element;
3660 HTMLElement *element;
3661 nsAString ns, tag;
3662 nsresult nsres;
3663 HRESULT hres;
3665 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3667 if(!This->dom_document) {
3668 FIXME("NULL dom_document\n");
3669 return E_FAIL;
3672 if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
3673 FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
3675 nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
3676 nsAString_InitDepend(&tag, bstrTag);
3677 nsres = nsIDOMDocument_CreateElementNS(This->dom_document, &ns, &tag, &dom_element);
3678 nsAString_Finish(&ns);
3679 nsAString_Finish(&tag);
3680 if(NS_FAILED(nsres)) {
3681 WARN("CreateElementNS failed: %08lx\n", nsres);
3682 return map_nsresult(nsres);
3685 hres = HTMLElement_Create(This, (nsIDOMNode*)dom_element, FALSE, &element);
3686 nsIDOMElement_Release(dom_element);
3687 if(FAILED(hres))
3688 return hres;
3690 *newElem = &element->IHTMLElement_iface;
3691 return S_OK;
3694 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3695 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3697 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3698 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3699 return E_NOTIMPL;
3702 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3704 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3705 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3706 return E_NOTIMPL;
3709 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3711 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3713 TRACE("(%p)->(%p)\n", This, p);
3715 return get_doc_event(This, EVENTID_MSTHUMBNAILCLICK, p);
3718 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3720 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3721 nsAString charset_str;
3722 nsresult nsres;
3724 TRACE("(%p)->(%p)\n", This, p);
3726 if(!This->dom_document) {
3727 FIXME("NULL dom_document\n");
3728 return E_FAIL;
3731 nsAString_Init(&charset_str, NULL);
3732 nsres = nsIDOMDocument_GetCharacterSet(This->dom_document, &charset_str);
3733 return return_nsstr(nsres, &charset_str, p);
3736 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3738 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3740 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3742 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3745 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3747 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3749 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3751 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3754 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3756 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3757 nsIDOMNodeList *nslist;
3758 nsAString nsstr;
3759 nsresult nsres;
3761 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3763 if(!This->dom_document) {
3764 FIXME("NULL dom_document not supported\n");
3765 return E_NOTIMPL;
3768 nsAString_InitDepend(&nsstr, v);
3769 nsres = nsIDOMDocument_GetElementsByClassName(This->dom_document, &nsstr, &nslist);
3770 nsAString_Finish(&nsstr);
3771 if(FAILED(nsres)) {
3772 ERR("GetElementByClassName failed: %08lx\n", nsres);
3773 return E_FAIL;
3777 *pel = create_collection_from_nodelist(nslist, This->document_mode);
3778 nsIDOMNodeList_Release(nslist);
3779 return S_OK;
3782 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3783 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3785 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3786 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3787 return E_NOTIMPL;
3790 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3792 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3793 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3794 return E_NOTIMPL;
3797 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3799 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3800 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3801 return E_NOTIMPL;
3804 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3806 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3807 FIXME("(%p)->(%p)\n", This, p);
3808 return E_NOTIMPL;
3811 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3813 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3815 TRACE("(%p)->(%p)\n", This, p);
3817 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3820 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3822 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3823 FIXME("(%p)->(%p)\n", This, p);
3824 return E_NOTIMPL;
3827 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3829 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3830 FIXME("(%p)->(%p)\n", This, p);
3831 return E_NOTIMPL;
3834 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3836 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3837 FIXME("(%p)->(%x)\n", This, v);
3838 return E_NOTIMPL;
3841 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3843 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3844 FIXME("(%p)->(%p)\n", This, p);
3845 return E_NOTIMPL;
3848 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3850 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3851 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3852 return E_NOTIMPL;
3855 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3857 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3858 FIXME("(%p)->(%p)\n", This, p);
3859 return E_NOTIMPL;
3862 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3864 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3865 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3866 return E_NOTIMPL;
3869 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3871 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3873 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3875 return set_doc_event(This, EVENTID_ABORT, &v);
3878 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3880 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3882 TRACE("(%p)->(%p)\n", This, p);
3884 return get_doc_event(This, EVENTID_ABORT, p);
3887 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3889 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3891 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3893 return set_doc_event(This, EVENTID_BLUR, &v);
3896 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3898 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3900 TRACE("(%p)->(%p)\n", This, p);
3902 return get_doc_event(This, EVENTID_BLUR, p);
3905 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3907 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3908 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3909 return E_NOTIMPL;
3912 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3914 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3915 FIXME("(%p)->(%p)\n", This, p);
3916 return E_NOTIMPL;
3919 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3921 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3922 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3923 return E_NOTIMPL;
3926 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3928 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3929 FIXME("(%p)->(%p)\n", This, p);
3930 return E_NOTIMPL;
3933 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3935 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3937 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3939 return set_doc_event(This, EVENTID_CHANGE, &v);
3942 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3944 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3946 TRACE("(%p)->(%p)\n", This, p);
3948 return get_doc_event(This, EVENTID_CHANGE, p);
3951 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3953 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3955 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3957 return set_doc_event(This, EVENTID_DRAG, &v);
3960 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3962 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3964 TRACE("(%p)->(%p)\n", This, p);
3966 return get_doc_event(This, EVENTID_DRAG, p);
3969 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3971 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3972 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3973 return E_NOTIMPL;
3976 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3978 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3979 FIXME("(%p)->(%p)\n", This, p);
3980 return E_NOTIMPL;
3983 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3985 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3986 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3987 return E_NOTIMPL;
3990 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3992 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3993 FIXME("(%p)->(%p)\n", This, p);
3994 return E_NOTIMPL;
3997 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3999 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4000 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4001 return E_NOTIMPL;
4004 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
4006 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4007 FIXME("(%p)->(%p)\n", This, p);
4008 return E_NOTIMPL;
4011 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
4013 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4014 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4015 return E_NOTIMPL;
4018 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
4020 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4021 FIXME("(%p)->(%p)\n", This, p);
4022 return E_NOTIMPL;
4025 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
4027 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4028 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4029 return E_NOTIMPL;
4032 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
4034 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4035 FIXME("(%p)->(%p)\n", This, p);
4036 return E_NOTIMPL;
4039 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
4041 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4042 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4043 return E_NOTIMPL;
4046 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
4048 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4049 FIXME("(%p)->(%p)\n", This, p);
4050 return E_NOTIMPL;
4053 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
4055 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4056 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4057 return E_NOTIMPL;
4060 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
4062 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4063 FIXME("(%p)->(%p)\n", This, p);
4064 return E_NOTIMPL;
4067 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
4069 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4070 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4071 return E_NOTIMPL;
4074 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
4076 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4077 FIXME("(%p)->(%p)\n", This, p);
4078 return E_NOTIMPL;
4081 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
4083 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4085 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4087 return set_doc_event(This, EVENTID_ERROR, &v);
4090 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
4092 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4094 TRACE("(%p)->(%p)\n", This, p);
4096 return get_doc_event(This, EVENTID_ERROR, p);
4099 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
4101 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4103 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4105 return set_doc_event(This, EVENTID_FOCUS, &v);
4108 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
4110 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4112 TRACE("(%p)->(%p)\n", This, p);
4114 return get_doc_event(This, EVENTID_FOCUS, p);
4117 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
4119 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4121 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4123 return set_doc_event(This, EVENTID_INPUT, &v);
4126 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
4128 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4130 TRACE("(%p)->(%p)\n", This, p);
4132 return get_doc_event(This, EVENTID_INPUT, p);
4135 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
4137 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4139 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4141 return set_doc_event(This, EVENTID_LOAD, &v);
4144 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
4146 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4148 TRACE("(%p)->(%p)\n", This, p);
4150 return get_doc_event(This, EVENTID_LOAD, p);
4153 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
4155 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4156 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4157 return E_NOTIMPL;
4160 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
4162 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4163 FIXME("(%p)->(%p)\n", This, p);
4164 return E_NOTIMPL;
4167 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
4169 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4170 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4171 return E_NOTIMPL;
4174 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
4176 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4177 FIXME("(%p)->(%p)\n", This, p);
4178 return E_NOTIMPL;
4181 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
4183 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4184 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4185 return E_NOTIMPL;
4188 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
4190 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4191 FIXME("(%p)->(%p)\n", This, p);
4192 return E_NOTIMPL;
4195 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
4197 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4198 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4199 return E_NOTIMPL;
4202 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
4204 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4205 FIXME("(%p)->(%p)\n", This, p);
4206 return E_NOTIMPL;
4209 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
4211 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4212 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4213 return E_NOTIMPL;
4216 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
4218 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4219 FIXME("(%p)->(%p)\n", This, p);
4220 return E_NOTIMPL;
4223 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
4225 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4226 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4227 return E_NOTIMPL;
4230 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
4232 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4233 FIXME("(%p)->(%p)\n", This, p);
4234 return E_NOTIMPL;
4237 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
4239 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4240 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4241 return E_NOTIMPL;
4244 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
4246 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4247 FIXME("(%p)->(%p)\n", This, p);
4248 return E_NOTIMPL;
4251 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
4253 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4254 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4255 return E_NOTIMPL;
4258 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
4260 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4261 FIXME("(%p)->(%p)\n", This, p);
4262 return E_NOTIMPL;
4265 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
4267 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4268 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4269 return E_NOTIMPL;
4272 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
4274 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4275 FIXME("(%p)->(%p)\n", This, p);
4276 return E_NOTIMPL;
4279 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
4281 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4283 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4285 return set_doc_event(This, EVENTID_SCROLL, &v);
4288 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
4290 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4292 TRACE("(%p)->(%p)\n", This, p);
4294 return get_doc_event(This, EVENTID_SCROLL, p);
4297 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
4299 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4300 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4301 return E_NOTIMPL;
4304 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
4306 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4307 FIXME("(%p)->(%p)\n", This, p);
4308 return E_NOTIMPL;
4311 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
4313 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4314 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4315 return E_NOTIMPL;
4318 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
4320 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4321 FIXME("(%p)->(%p)\n", This, p);
4322 return E_NOTIMPL;
4325 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
4327 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4328 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4329 return E_NOTIMPL;
4332 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
4334 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4335 FIXME("(%p)->(%p)\n", This, p);
4336 return E_NOTIMPL;
4339 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
4341 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4342 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4343 return E_NOTIMPL;
4346 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
4348 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4349 FIXME("(%p)->(%p)\n", This, p);
4350 return E_NOTIMPL;
4353 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
4355 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4357 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4359 return set_doc_event(This, EVENTID_SUBMIT, &v);
4362 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
4364 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4366 TRACE("(%p)->(%p)\n", This, p);
4368 return get_doc_event(This, EVENTID_SUBMIT, p);
4371 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
4373 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4374 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4375 return E_NOTIMPL;
4378 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
4380 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4381 FIXME("(%p)->(%p)\n", This, p);
4382 return E_NOTIMPL;
4385 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
4387 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4388 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4389 return E_NOTIMPL;
4392 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
4394 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4395 FIXME("(%p)->(%p)\n", This, p);
4396 return E_NOTIMPL;
4399 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
4401 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4402 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4403 return E_NOTIMPL;
4406 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4408 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4409 FIXME("(%p)->(%p)\n", This, p);
4410 return E_NOTIMPL;
4413 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4415 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4416 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4417 return E_NOTIMPL;
4420 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4422 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4423 FIXME("(%p)->(%p)\n", This, p);
4424 return E_NOTIMPL;
4427 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4429 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4430 FIXME("(%p)\n", This);
4431 return E_NOTIMPL;
4434 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4435 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4437 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4438 nsIDOMNode *nsnode = NULL;
4439 HTMLDOMNode *node;
4440 nsresult nsres;
4441 HRESULT hres;
4443 TRACE("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4445 if(!This->dom_document) {
4446 WARN("NULL dom_document\n");
4447 return E_UNEXPECTED;
4450 if(!(node = unsafe_impl_from_IHTMLDOMNode(pNodeSource))) {
4451 ERR("not our node\n");
4452 return E_FAIL;
4455 nsres = nsIDOMDocument_ImportNode(This->dom_document, node->nsnode, !!fDeep, 1, &nsnode);
4456 if(NS_FAILED(nsres)) {
4457 ERR("ImportNode failed: %08lx\n", nsres);
4458 return map_nsresult(nsres);
4461 if(!nsnode) {
4462 *ppNodeDest = NULL;
4463 return S_OK;
4466 hres = get_node(nsnode, TRUE, &node);
4467 nsIDOMNode_Release(nsnode);
4468 if(FAILED(hres))
4469 return hres;
4471 *ppNodeDest = &node->IHTMLDOMNode3_iface;
4472 return hres;
4475 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4477 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4479 TRACE("(%p)->(%p)\n", This, p);
4481 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4484 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4486 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4487 FIXME("(%p)->(%p)\n", This, v);
4488 return E_NOTIMPL;
4491 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4493 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4495 TRACE("(%p)->(%p)\n", This, p);
4497 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4500 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4502 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4503 nsIDOMHTMLHeadElement *nshead;
4504 nsIDOMElement *nselem;
4505 HTMLElement *elem;
4506 nsresult nsres;
4507 HRESULT hres;
4509 TRACE("(%p)->(%p)\n", This, p);
4511 if(!This->dom_document) {
4512 FIXME("No document\n");
4513 return E_FAIL;
4516 if(!This->html_document) {
4517 FIXME("Not implemented for XML document\n");
4518 return E_NOTIMPL;
4521 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &nshead);
4522 assert(nsres == NS_OK);
4524 if(!nshead) {
4525 *p = NULL;
4526 return S_OK;
4529 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4530 nsIDOMHTMLHeadElement_Release(nshead);
4531 assert(nsres == NS_OK);
4533 hres = get_element(nselem, &elem);
4534 nsIDOMElement_Release(nselem);
4535 if(FAILED(hres))
4536 return hres;
4538 *p = &elem->IHTMLElement_iface;
4539 return S_OK;
4542 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4543 HTMLDocument7_QueryInterface,
4544 HTMLDocument7_AddRef,
4545 HTMLDocument7_Release,
4546 HTMLDocument7_GetTypeInfoCount,
4547 HTMLDocument7_GetTypeInfo,
4548 HTMLDocument7_GetIDsOfNames,
4549 HTMLDocument7_Invoke,
4550 HTMLDocument7_get_defaultView,
4551 HTMLDocument7_createCDATASection,
4552 HTMLDocument7_getSelection,
4553 HTMLDocument7_getElementsByTagNameNS,
4554 HTMLDocument7_createElementNS,
4555 HTMLDocument7_createAttributeNS,
4556 HTMLDocument7_put_onmsthumbnailclick,
4557 HTMLDocument7_get_onmsthumbnailclick,
4558 HTMLDocument7_get_characterSet,
4559 HTMLDocument7_createElement,
4560 HTMLDocument7_createAttribute,
4561 HTMLDocument7_getElementsByClassName,
4562 HTMLDocument7_createProcessingInstruction,
4563 HTMLDocument7_adoptNode,
4564 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4565 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4566 HTMLDocument7_get_all,
4567 HTMLDocument7_get_inputEncoding,
4568 HTMLDocument7_get_xmlEncoding,
4569 HTMLDocument7_put_xmlStandalone,
4570 HTMLDocument7_get_xmlStandalone,
4571 HTMLDocument7_put_xmlVersion,
4572 HTMLDocument7_get_xmlVersion,
4573 HTMLDocument7_hasAttributes,
4574 HTMLDocument7_put_onabort,
4575 HTMLDocument7_get_onabort,
4576 HTMLDocument7_put_onblur,
4577 HTMLDocument7_get_onblur,
4578 HTMLDocument7_put_oncanplay,
4579 HTMLDocument7_get_oncanplay,
4580 HTMLDocument7_put_oncanplaythrough,
4581 HTMLDocument7_get_oncanplaythrough,
4582 HTMLDocument7_put_onchange,
4583 HTMLDocument7_get_onchange,
4584 HTMLDocument7_put_ondrag,
4585 HTMLDocument7_get_ondrag,
4586 HTMLDocument7_put_ondragend,
4587 HTMLDocument7_get_ondragend,
4588 HTMLDocument7_put_ondragenter,
4589 HTMLDocument7_get_ondragenter,
4590 HTMLDocument7_put_ondragleave,
4591 HTMLDocument7_get_ondragleave,
4592 HTMLDocument7_put_ondragover,
4593 HTMLDocument7_get_ondragover,
4594 HTMLDocument7_put_ondrop,
4595 HTMLDocument7_get_ondrop,
4596 HTMLDocument7_put_ondurationchange,
4597 HTMLDocument7_get_ondurationchange,
4598 HTMLDocument7_put_onemptied,
4599 HTMLDocument7_get_onemptied,
4600 HTMLDocument7_put_onended,
4601 HTMLDocument7_get_onended,
4602 HTMLDocument7_put_onerror,
4603 HTMLDocument7_get_onerror,
4604 HTMLDocument7_put_onfocus,
4605 HTMLDocument7_get_onfocus,
4606 HTMLDocument7_put_oninput,
4607 HTMLDocument7_get_oninput,
4608 HTMLDocument7_put_onload,
4609 HTMLDocument7_get_onload,
4610 HTMLDocument7_put_onloadeddata,
4611 HTMLDocument7_get_onloadeddata,
4612 HTMLDocument7_put_onloadedmetadata,
4613 HTMLDocument7_get_onloadedmetadata,
4614 HTMLDocument7_put_onloadstart,
4615 HTMLDocument7_get_onloadstart,
4616 HTMLDocument7_put_onpause,
4617 HTMLDocument7_get_onpause,
4618 HTMLDocument7_put_onplay,
4619 HTMLDocument7_get_onplay,
4620 HTMLDocument7_put_onplaying,
4621 HTMLDocument7_get_onplaying,
4622 HTMLDocument7_put_onprogress,
4623 HTMLDocument7_get_onprogress,
4624 HTMLDocument7_put_onratechange,
4625 HTMLDocument7_get_onratechange,
4626 HTMLDocument7_put_onreset,
4627 HTMLDocument7_get_onreset,
4628 HTMLDocument7_put_onscroll,
4629 HTMLDocument7_get_onscroll,
4630 HTMLDocument7_put_onseekend,
4631 HTMLDocument7_get_onseekend,
4632 HTMLDocument7_put_onseeking,
4633 HTMLDocument7_get_onseeking,
4634 HTMLDocument7_put_onselect,
4635 HTMLDocument7_get_onselect,
4636 HTMLDocument7_put_onstalled,
4637 HTMLDocument7_get_onstalled,
4638 HTMLDocument7_put_onsubmit,
4639 HTMLDocument7_get_onsubmit,
4640 HTMLDocument7_put_onsuspend,
4641 HTMLDocument7_get_onsuspend,
4642 HTMLDocument7_put_ontimeupdate,
4643 HTMLDocument7_get_ontimeupdate,
4644 HTMLDocument7_put_onvolumechange,
4645 HTMLDocument7_get_onvolumechange,
4646 HTMLDocument7_put_onwaiting,
4647 HTMLDocument7_get_onwaiting,
4648 HTMLDocument7_normalize,
4649 HTMLDocument7_importNode,
4650 HTMLDocument7_get_parentWindow,
4651 HTMLDocument7_put_body,
4652 HTMLDocument7_get_body,
4653 HTMLDocument7_get_head
4656 static inline HTMLDocumentNode *impl_from_IDocumentSelector(IDocumentSelector *iface)
4658 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentSelector_iface);
4661 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4663 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4664 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4667 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4669 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4670 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4673 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4675 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4676 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4679 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4681 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4682 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4685 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4686 LCID lcid, ITypeInfo **ppTInfo)
4688 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4689 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4692 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4693 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4695 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4696 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4697 rgDispId);
4700 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4701 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4703 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4704 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4705 pDispParams, pVarResult, pExcepInfo, puArgErr);
4708 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4710 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4711 nsIDOMElement *nselem;
4712 HTMLElement *elem;
4713 nsAString nsstr;
4714 nsresult nsres;
4715 HRESULT hres;
4717 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4719 nsAString_InitDepend(&nsstr, v);
4720 if(This->dom_document)
4721 nsres = nsIDOMDocument_QuerySelector(This->dom_document, &nsstr, &nselem);
4722 else {
4723 nsIDOMDocumentFragment *frag;
4724 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&frag);
4725 if(NS_SUCCEEDED(nsres)) {
4726 nsres = nsIDOMDocumentFragment_QuerySelector(frag, &nsstr, &nselem);
4727 nsIDOMDocumentFragment_Release(frag);
4730 nsAString_Finish(&nsstr);
4732 if(NS_FAILED(nsres)) {
4733 WARN("QuerySelector failed: %08lx\n", nsres);
4734 return map_nsresult(nsres);
4737 if(!nselem) {
4738 *pel = NULL;
4739 return S_OK;
4742 hres = get_element(nselem, &elem);
4743 nsIDOMElement_Release(nselem);
4744 if(FAILED(hres))
4745 return hres;
4747 *pel = &elem->IHTMLElement_iface;
4748 return S_OK;
4751 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4753 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4754 nsIDOMNodeList *node_list;
4755 nsAString nsstr;
4756 nsresult nsres;
4757 HRESULT hres;
4759 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4761 nsAString_InitDepend(&nsstr, v);
4762 if(This->dom_document)
4763 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &nsstr, &node_list);
4764 else {
4765 nsIDOMDocumentFragment *frag;
4766 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&frag);
4767 if(NS_SUCCEEDED(nsres)) {
4768 nsres = nsIDOMDocumentFragment_QuerySelectorAll(frag, &nsstr, &node_list);
4769 nsIDOMDocumentFragment_Release(frag);
4772 nsAString_Finish(&nsstr);
4774 if(NS_FAILED(nsres)) {
4775 WARN("QuerySelectorAll failed: %08lx\n", nsres);
4776 return map_nsresult(nsres);
4779 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
4780 nsIDOMNodeList_Release(node_list);
4781 return hres;
4784 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4785 DocumentSelector_QueryInterface,
4786 DocumentSelector_AddRef,
4787 DocumentSelector_Release,
4788 DocumentSelector_GetTypeInfoCount,
4789 DocumentSelector_GetTypeInfo,
4790 DocumentSelector_GetIDsOfNames,
4791 DocumentSelector_Invoke,
4792 DocumentSelector_querySelector,
4793 DocumentSelector_querySelectorAll
4796 static inline HTMLDocumentNode *impl_from_IDocumentEvent(IDocumentEvent *iface)
4798 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentEvent_iface);
4801 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4803 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4804 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4807 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4809 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4810 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4813 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4815 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4816 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4819 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4821 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4822 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4825 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4826 LCID lcid, ITypeInfo **ppTInfo)
4828 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4829 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4832 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4833 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4835 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4836 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4837 rgDispId);
4840 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4841 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4843 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4844 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4845 pDispParams, pVarResult, pExcepInfo, puArgErr);
4848 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4850 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4852 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4854 return create_document_event_str(This, eventType, p);
4857 static const IDocumentEventVtbl DocumentEventVtbl = {
4858 DocumentEvent_QueryInterface,
4859 DocumentEvent_AddRef,
4860 DocumentEvent_Release,
4861 DocumentEvent_GetTypeInfoCount,
4862 DocumentEvent_GetTypeInfo,
4863 DocumentEvent_GetIDsOfNames,
4864 DocumentEvent_Invoke,
4865 DocumentEvent_createEvent
4868 static void HTMLDocumentNode_on_advise(IUnknown *iface, cp_static_data_t *cp)
4870 HTMLDocumentNode *This = CONTAINING_RECORD((IHTMLDocument2*)iface, HTMLDocumentNode, IHTMLDocument2_iface);
4872 if(This->outer_window)
4873 update_doc_cp_events(This, cp);
4876 static inline HTMLDocumentNode *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4878 return CONTAINING_RECORD(iface, HTMLDocumentNode, ISupportErrorInfo_iface);
4881 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4883 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4884 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4887 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4889 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4890 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4893 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4895 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4896 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4899 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4901 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4902 return S_FALSE;
4905 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4906 SupportErrorInfo_QueryInterface,
4907 SupportErrorInfo_AddRef,
4908 SupportErrorInfo_Release,
4909 SupportErrorInfo_InterfaceSupportsErrorInfo
4912 static inline HTMLDocumentNode *impl_from_IDispatchEx(IDispatchEx *iface)
4914 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDispatchEx_iface);
4917 static HRESULT has_elem_name(nsIDOMHTMLDocument *html_document, const WCHAR *name)
4919 static const WCHAR fmt[] = L":-moz-any(applet,embed,form,iframe,img,object)[name=\"%s\"]";
4920 WCHAR buf[128], *selector = buf;
4921 nsAString selector_str;
4922 nsIDOMElement *nselem;
4923 nsresult nsres;
4924 size_t len;
4926 len = wcslen(name) + ARRAY_SIZE(fmt) - 2 /* %s */;
4927 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4928 return E_OUTOFMEMORY;
4929 swprintf(selector, len, fmt, name);
4931 nsAString_InitDepend(&selector_str, selector);
4932 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4933 nsAString_Finish(&selector_str);
4934 if(selector != buf)
4935 free(selector);
4936 if(NS_FAILED(nsres))
4937 return map_nsresult(nsres);
4939 if(!nselem)
4940 return DISP_E_UNKNOWNNAME;
4941 nsIDOMElement_Release(nselem);
4942 return S_OK;
4945 static HRESULT get_elem_by_name_or_id(nsIDOMHTMLDocument *html_document, const WCHAR *name, nsIDOMElement **ret)
4947 static const WCHAR fmt[] = L":-moz-any(embed,form,iframe,img):-moz-any([name=\"%s\"],[id=\"%s\"][name]),"
4948 L":-moz-any(applet,object):-moz-any([name=\"%s\"],[id=\"%s\"])";
4949 WCHAR buf[384], *selector = buf;
4950 nsAString selector_str;
4951 nsIDOMElement *nselem;
4952 nsresult nsres;
4953 size_t len;
4955 len = wcslen(name) * 4 + ARRAY_SIZE(fmt) - 8 /* %s */;
4956 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4957 return E_OUTOFMEMORY;
4958 swprintf(selector, len, fmt, name, name, name, name);
4960 nsAString_InitDepend(&selector_str, selector);
4961 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4962 nsAString_Finish(&selector_str);
4963 if(selector != buf)
4964 free(selector);
4965 if(NS_FAILED(nsres))
4966 return map_nsresult(nsres);
4968 if(ret) {
4969 *ret = nselem;
4970 return S_OK;
4973 if(nselem) {
4974 nsIDOMElement_Release(nselem);
4975 return S_OK;
4977 return DISP_E_UNKNOWNNAME;
4980 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, const WCHAR *name, DISPID *dispid)
4982 unsigned i;
4984 for(i=0; i < This->elem_vars_cnt; i++) {
4985 if(!wcscmp(name, This->elem_vars[i])) {
4986 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4987 return S_OK;
4991 if(This->elem_vars_cnt == This->elem_vars_size) {
4992 WCHAR **new_vars;
4994 if(This->elem_vars_size) {
4995 new_vars = realloc(This->elem_vars, This->elem_vars_size * 2 * sizeof(WCHAR*));
4996 if(!new_vars)
4997 return E_OUTOFMEMORY;
4998 This->elem_vars_size *= 2;
4999 }else {
5000 new_vars = malloc(16 * sizeof(WCHAR*));
5001 if(!new_vars)
5002 return E_OUTOFMEMORY;
5003 This->elem_vars_size = 16;
5006 This->elem_vars = new_vars;
5009 This->elem_vars[This->elem_vars_cnt] = wcsdup(name);
5010 if(!This->elem_vars[This->elem_vars_cnt])
5011 return E_OUTOFMEMORY;
5013 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
5014 return S_OK;
5017 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
5019 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5021 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5024 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
5026 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5028 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5031 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
5033 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5035 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5038 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
5040 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5042 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5045 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
5046 LCID lcid, ITypeInfo **ppTInfo)
5048 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5050 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5053 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
5054 LPOLESTR *rgszNames, UINT cNames,
5055 LCID lcid, DISPID *rgDispId)
5057 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5059 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
5062 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
5063 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5064 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5066 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5068 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
5069 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5071 return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags, pDispParams,
5072 pVarResult, pExcepInfo, NULL);
5075 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
5077 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5078 HRESULT hres;
5080 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex & ~fdexNameEnsure, pid);
5081 if(hres != DISP_E_UNKNOWNNAME)
5082 return hres;
5084 if(This->html_document) {
5085 hres = get_elem_by_name_or_id(This->html_document, bstrName, NULL);
5086 if(SUCCEEDED(hres))
5087 hres = dispid_from_elem_name(This, bstrName, pid);
5090 if(hres == DISP_E_UNKNOWNNAME && (grfdex & fdexNameEnsure))
5091 hres = dispex_get_dynid(&This->node.event_target.dispex, bstrName, FALSE, pid);
5092 return hres;
5095 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
5096 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
5098 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5100 if(This->window) {
5101 switch(id) {
5102 case DISPID_READYSTATE:
5103 TRACE("DISPID_READYSTATE\n");
5105 if(!(wFlags & DISPATCH_PROPERTYGET))
5106 return E_INVALIDARG;
5108 V_VT(pvarRes) = VT_I4;
5109 V_I4(pvarRes) = This->window->base.outer_window->readystate;
5110 return S_OK;
5111 default:
5112 break;
5116 return IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
5119 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
5121 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5123 return IDispatchEx_DeleteMemberByName(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex);
5126 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
5128 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5130 return IDispatchEx_DeleteMemberByDispID(&This->node.event_target.dispex.IDispatchEx_iface, id);
5133 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
5135 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5137 return IDispatchEx_GetMemberProperties(&This->node.event_target.dispex.IDispatchEx_iface, id, grfdexFetch, pgrfdex);
5140 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
5142 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5144 return IDispatchEx_GetMemberName(&This->node.event_target.dispex.IDispatchEx_iface, id, pbstrName);
5147 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
5149 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5151 return IDispatchEx_GetNextDispID(&This->node.event_target.dispex.IDispatchEx_iface, grfdex, id, pid);
5154 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
5156 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5158 return IDispatchEx_GetNameSpaceParent(&This->node.event_target.dispex.IDispatchEx_iface, ppunk);
5161 static const IDispatchExVtbl DocDispatchExVtbl = {
5162 DocDispatchEx_QueryInterface,
5163 DocDispatchEx_AddRef,
5164 DocDispatchEx_Release,
5165 DocDispatchEx_GetTypeInfoCount,
5166 DocDispatchEx_GetTypeInfo,
5167 DocDispatchEx_GetIDsOfNames,
5168 DocDispatchEx_Invoke,
5169 DocDispatchEx_GetDispID,
5170 DocDispatchEx_InvokeEx,
5171 DocDispatchEx_DeleteMemberByName,
5172 DocDispatchEx_DeleteMemberByDispID,
5173 DocDispatchEx_GetMemberProperties,
5174 DocDispatchEx_GetMemberName,
5175 DocDispatchEx_GetNextDispID,
5176 DocDispatchEx_GetNameSpaceParent
5179 static inline HTMLDocumentNode *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
5181 return CONTAINING_RECORD(iface, HTMLDocumentNode, IProvideMultipleClassInfo_iface);
5184 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
5185 REFIID riid, void **ppv)
5187 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5188 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5191 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
5193 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5194 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5197 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
5199 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5200 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5203 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
5205 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5206 TRACE("(%p)->(%p)\n", This, ppTI);
5207 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
5210 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
5212 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5213 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
5214 return E_NOTIMPL;
5217 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
5219 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5220 FIXME("(%p)->(%p)\n", This, pcti);
5221 *pcti = 1;
5222 return S_OK;
5225 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
5226 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
5228 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5229 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
5230 return E_NOTIMPL;
5233 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
5234 ProvideClassInfo_QueryInterface,
5235 ProvideClassInfo_AddRef,
5236 ProvideClassInfo_Release,
5237 ProvideClassInfo_GetClassInfo,
5238 ProvideClassInfo2_GetGUID,
5239 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
5240 ProvideMultipleClassInfo_GetInfoOfIndex
5243 /**********************************************************
5244 * IMarkupServices implementation
5246 static inline HTMLDocumentNode *impl_from_IMarkupServices(IMarkupServices *iface)
5248 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupServices_iface);
5251 static HRESULT WINAPI MarkupServices_QueryInterface(IMarkupServices *iface, REFIID riid, void **ppvObject)
5253 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5254 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5257 static ULONG WINAPI MarkupServices_AddRef(IMarkupServices *iface)
5259 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5260 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5263 static ULONG WINAPI MarkupServices_Release(IMarkupServices *iface)
5265 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5266 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5269 static HRESULT WINAPI MarkupServices_CreateMarkupPointer(IMarkupServices *iface, IMarkupPointer **ppPointer)
5271 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5273 TRACE("(%p)->(%p)\n", This, ppPointer);
5275 return create_markup_pointer(ppPointer);
5278 static HRESULT WINAPI MarkupServices_CreateMarkupContainer(IMarkupServices *iface, IMarkupContainer **ppMarkupContainer)
5280 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5281 FIXME("(%p)->(%p)\n", This, ppMarkupContainer);
5282 return E_NOTIMPL;
5285 static HRESULT WINAPI MarkupServices_CreateElement(IMarkupServices *iface,
5286 ELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement)
5288 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5289 FIXME("(%p)->(%d,%s,%p)\n", This, tagID, debugstr_w(pchAttributes), ppElement);
5290 return E_NOTIMPL;
5293 static HRESULT WINAPI MarkupServices_CloneElement(IMarkupServices *iface,
5294 IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone)
5296 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5297 FIXME("(%p)->(%p,%p)\n", This, pElemCloneThis, ppElementTheClone);
5298 return E_NOTIMPL;
5301 static HRESULT WINAPI MarkupServices_InsertElement(IMarkupServices *iface,
5302 IHTMLElement *pElementInsert, IMarkupPointer *pPointerStart,
5303 IMarkupPointer *pPointerFinish)
5305 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5306 FIXME("(%p)->(%p,%p,%p)\n", This, pElementInsert, pPointerStart, pPointerFinish);
5307 return E_NOTIMPL;
5310 static HRESULT WINAPI MarkupServices_RemoveElement(IMarkupServices *iface, IHTMLElement *pElementRemove)
5312 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5313 FIXME("(%p)->(%p)\n", This, pElementRemove);
5314 return E_NOTIMPL;
5317 static HRESULT WINAPI MarkupServices_Remove(IMarkupServices *iface,
5318 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5320 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5321 FIXME("(%p)->(%p,%p)\n", This, pPointerStart, pPointerFinish);
5322 return E_NOTIMPL;
5325 static HRESULT WINAPI MarkupServices_Copy(IMarkupServices *iface,
5326 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5327 IMarkupPointer *pPointerTarget)
5329 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5330 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5331 return E_NOTIMPL;
5334 static HRESULT WINAPI MarkupServices_Move(IMarkupServices *iface,
5335 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5336 IMarkupPointer *pPointerTarget)
5338 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5339 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5340 return E_NOTIMPL;
5343 static HRESULT WINAPI MarkupServices_InsertText(IMarkupServices *iface,
5344 OLECHAR *pchText, LONG cch, IMarkupPointer *pPointerTarget)
5346 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5347 FIXME("(%p)->(%s,%lx,%p)\n", This, debugstr_w(pchText), cch, pPointerTarget);
5348 return E_NOTIMPL;
5351 static HRESULT WINAPI MarkupServices_ParseString(IMarkupServices *iface,
5352 OLECHAR *pchHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5353 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5355 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5356 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(pchHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5357 return E_NOTIMPL;
5360 static HRESULT WINAPI MarkupServices_ParseGlobal(IMarkupServices *iface,
5361 HGLOBAL hglobalHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5362 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5364 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5365 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(hglobalHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5366 return E_NOTIMPL;
5369 static HRESULT WINAPI MarkupServices_IsScopedElement(IMarkupServices *iface,
5370 IHTMLElement *pElement, BOOL *pfScoped)
5372 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5373 FIXME("(%p)->(%p,%p)\n", This, pElement, pfScoped);
5374 return E_NOTIMPL;
5377 static HRESULT WINAPI MarkupServices_GetElementTagId(IMarkupServices *iface,
5378 IHTMLElement *pElement, ELEMENT_TAG_ID *ptagId)
5380 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5381 FIXME("(%p)->(%p,%p)\n", This, pElement, ptagId);
5382 return E_NOTIMPL;
5385 static HRESULT WINAPI MarkupServices_GetTagIDForName(IMarkupServices *iface,
5386 BSTR bstrName, ELEMENT_TAG_ID *ptagId)
5388 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5389 FIXME("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), ptagId);
5390 return E_NOTIMPL;
5393 static HRESULT WINAPI MarkupServices_GetNameForTagID(IMarkupServices *iface,
5394 ELEMENT_TAG_ID tagId, BSTR *pbstrName)
5396 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5397 FIXME("(%p)->(%d,%p)\n", This, tagId, pbstrName);
5398 return E_NOTIMPL;
5401 static HRESULT WINAPI MarkupServices_MovePointersToRange(IMarkupServices *iface,
5402 IHTMLTxtRange *pIRange, IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5404 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5405 FIXME("(%p)->(%p,%p,%p)\n", This, pIRange, pPointerStart, pPointerFinish);
5406 return E_NOTIMPL;
5409 static HRESULT WINAPI MarkupServices_MoveRangeToPointers(IMarkupServices *iface,
5410 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish, IHTMLTxtRange *pIRange)
5412 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5413 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerStart, pPointerFinish, pIRange);
5414 return E_NOTIMPL;
5417 static HRESULT WINAPI MarkupServices_BeginUndoUnit(IMarkupServices *iface, OLECHAR *pchTitle)
5419 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5420 FIXME("(%p)->(%s)\n", This, debugstr_w(pchTitle));
5421 return E_NOTIMPL;
5424 static HRESULT WINAPI MarkupServices_EndUndoUnit(IMarkupServices *iface)
5426 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5427 FIXME("(%p)\n", This);
5428 return E_NOTIMPL;
5431 static const IMarkupServicesVtbl MarkupServicesVtbl = {
5432 MarkupServices_QueryInterface,
5433 MarkupServices_AddRef,
5434 MarkupServices_Release,
5435 MarkupServices_CreateMarkupPointer,
5436 MarkupServices_CreateMarkupContainer,
5437 MarkupServices_CreateElement,
5438 MarkupServices_CloneElement,
5439 MarkupServices_InsertElement,
5440 MarkupServices_RemoveElement,
5441 MarkupServices_Remove,
5442 MarkupServices_Copy,
5443 MarkupServices_Move,
5444 MarkupServices_InsertText,
5445 MarkupServices_ParseString,
5446 MarkupServices_ParseGlobal,
5447 MarkupServices_IsScopedElement,
5448 MarkupServices_GetElementTagId,
5449 MarkupServices_GetTagIDForName,
5450 MarkupServices_GetNameForTagID,
5451 MarkupServices_MovePointersToRange,
5452 MarkupServices_MoveRangeToPointers,
5453 MarkupServices_BeginUndoUnit,
5454 MarkupServices_EndUndoUnit
5457 /**********************************************************
5458 * IMarkupContainer implementation
5460 static inline HTMLDocumentNode *impl_from_IMarkupContainer(IMarkupContainer *iface)
5462 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupContainer_iface);
5465 static HRESULT WINAPI MarkupContainer_QueryInterface(IMarkupContainer *iface, REFIID riid, void **ppvObject)
5467 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5468 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5471 static ULONG WINAPI MarkupContainer_AddRef(IMarkupContainer *iface)
5473 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5474 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5477 static ULONG WINAPI MarkupContainer_Release(IMarkupContainer *iface)
5479 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5480 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5483 static HRESULT WINAPI MarkupContainer_OwningDoc(IMarkupContainer *iface, IHTMLDocument2 **ppDoc)
5485 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5486 FIXME("(%p)->(%p)\n", This, ppDoc);
5487 return E_NOTIMPL;
5490 static const IMarkupContainerVtbl MarkupContainerVtbl = {
5491 MarkupContainer_QueryInterface,
5492 MarkupContainer_AddRef,
5493 MarkupContainer_Release,
5494 MarkupContainer_OwningDoc
5497 /**********************************************************
5498 * IDisplayServices implementation
5500 static inline HTMLDocumentNode *impl_from_IDisplayServices(IDisplayServices *iface)
5502 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDisplayServices_iface);
5505 static HRESULT WINAPI DisplayServices_QueryInterface(IDisplayServices *iface, REFIID riid, void **ppvObject)
5507 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5508 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5511 static ULONG WINAPI DisplayServices_AddRef(IDisplayServices *iface)
5513 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5514 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5517 static ULONG WINAPI DisplayServices_Release(IDisplayServices *iface)
5519 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5520 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5523 static HRESULT WINAPI DisplayServices_CreateDisplayPointer(IDisplayServices *iface, IDisplayPointer **ppDispPointer)
5525 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5526 FIXME("(%p)->(%p)\n", This, ppDispPointer);
5527 return E_NOTIMPL;
5530 static HRESULT WINAPI DisplayServices_TransformRect(IDisplayServices *iface,
5531 RECT *pRect, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5533 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5534 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_rect(pRect), eSource, eDestination, pIElement);
5535 return E_NOTIMPL;
5538 static HRESULT WINAPI DisplayServices_TransformPoint(IDisplayServices *iface,
5539 POINT *pPoint, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5541 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5542 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_point(pPoint), eSource, eDestination, pIElement);
5543 return E_NOTIMPL;
5546 static HRESULT WINAPI DisplayServices_GetCaret(IDisplayServices *iface, IHTMLCaret **ppCaret)
5548 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5549 FIXME("(%p)->(%p)\n", This, ppCaret);
5550 return E_NOTIMPL;
5553 static HRESULT WINAPI DisplayServices_GetComputedStyle(IDisplayServices *iface,
5554 IMarkupPointer *pPointer, IHTMLComputedStyle **ppComputedStyle)
5556 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5557 FIXME("(%p)->(%p,%p)\n", This, pPointer, ppComputedStyle);
5558 return E_NOTIMPL;
5561 static HRESULT WINAPI DisplayServices_ScrollRectIntoView(IDisplayServices *iface,
5562 IHTMLElement *pIElement, RECT rect)
5564 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5565 FIXME("(%p)->(%p,%s)\n", This, pIElement, wine_dbgstr_rect(&rect));
5566 return E_NOTIMPL;
5569 static HRESULT WINAPI DisplayServices_HasFlowLayout(IDisplayServices *iface,
5570 IHTMLElement *pIElement, BOOL *pfHasFlowLayout)
5572 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5573 FIXME("(%p)->(%p,%p)\n", This, pIElement, pfHasFlowLayout);
5574 return E_NOTIMPL;
5577 static const IDisplayServicesVtbl DisplayServicesVtbl = {
5578 DisplayServices_QueryInterface,
5579 DisplayServices_AddRef,
5580 DisplayServices_Release,
5581 DisplayServices_CreateDisplayPointer,
5582 DisplayServices_TransformRect,
5583 DisplayServices_TransformPoint,
5584 DisplayServices_GetCaret,
5585 DisplayServices_GetComputedStyle,
5586 DisplayServices_ScrollRectIntoView,
5587 DisplayServices_HasFlowLayout
5590 /**********************************************************
5591 * IDocumentRange implementation
5593 static inline HTMLDocumentNode *impl_from_IDocumentRange(IDocumentRange *iface)
5595 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentRange_iface);
5598 static HRESULT WINAPI DocumentRange_QueryInterface(IDocumentRange *iface, REFIID riid, void **ppv)
5600 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5602 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5605 static ULONG WINAPI DocumentRange_AddRef(IDocumentRange *iface)
5607 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5609 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5612 static ULONG WINAPI DocumentRange_Release(IDocumentRange *iface)
5614 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5616 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5619 static HRESULT WINAPI DocumentRange_GetTypeInfoCount(IDocumentRange *iface, UINT *pctinfo)
5621 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5623 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
5626 static HRESULT WINAPI DocumentRange_GetTypeInfo(IDocumentRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5628 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5630 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5633 static HRESULT WINAPI DocumentRange_GetIDsOfNames(IDocumentRange *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5634 LCID lcid, DISPID *rgDispId)
5636 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5638 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
5639 rgDispId);
5642 static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
5643 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5645 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5647 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5648 pDispParams, pVarResult, pExcepInfo, puArgErr);
5651 static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
5653 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5654 nsIDOMRange *nsrange;
5655 HRESULT hres;
5657 TRACE("(%p)->(%p)\n", This, p);
5659 if(!This->dom_document) {
5660 WARN("NULL dom_document\n");
5661 return E_UNEXPECTED;
5664 if(NS_FAILED(nsIDOMDocument_CreateRange(This->dom_document, &nsrange)))
5665 return E_FAIL;
5667 hres = create_dom_range(nsrange, dispex_compat_mode(&This->node.event_target.dispex), p);
5668 nsIDOMRange_Release(nsrange);
5669 return hres;
5672 static const IDocumentRangeVtbl DocumentRangeVtbl = {
5673 DocumentRange_QueryInterface,
5674 DocumentRange_AddRef,
5675 DocumentRange_Release,
5676 DocumentRange_GetTypeInfoCount,
5677 DocumentRange_GetTypeInfo,
5678 DocumentRange_GetIDsOfNames,
5679 DocumentRange_Invoke,
5680 DocumentRange_createRange
5683 static cp_static_data_t HTMLDocumentNodeEvents_data = { HTMLDocumentEvents_tid, HTMLDocumentNode_on_advise };
5684 static cp_static_data_t HTMLDocumentNodeEvents2_data = { HTMLDocumentEvents2_tid, HTMLDocumentNode_on_advise, TRUE };
5686 static const cpc_entry_t HTMLDocumentNode_cpc[] = {
5687 {&IID_IDispatch, &HTMLDocumentNodeEvents_data},
5688 {&IID_IPropertyNotifySink},
5689 {&DIID_HTMLDocumentEvents, &HTMLDocumentNodeEvents_data},
5690 {&DIID_HTMLDocumentEvents2, &HTMLDocumentNodeEvents2_data},
5691 {NULL}
5694 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5696 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
5699 void detach_document_node(HTMLDocumentNode *doc)
5701 unsigned i;
5703 while(!list_empty(&doc->plugin_hosts))
5704 detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
5706 if(doc->dom_implementation)
5707 detach_dom_implementation(doc->dom_implementation);
5709 unlink_ref(&doc->dom_implementation);
5710 unlink_ref(&doc->namespaces);
5711 detach_events(doc);
5712 detach_selection(doc);
5713 detach_ranges(doc);
5715 for(i=0; i < doc->elem_vars_cnt; i++)
5716 free(doc->elem_vars[i]);
5717 free(doc->elem_vars);
5718 doc->elem_vars_cnt = doc->elem_vars_size = 0;
5719 doc->elem_vars = NULL;
5721 unlink_ref(&doc->catmgr);
5722 if(doc->browser) {
5723 list_remove(&doc->browser_entry);
5724 doc->browser = NULL;
5728 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5730 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5731 FIXME("%p\n", This);
5732 return E_NOTIMPL;
5735 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
5736 .clsid = &CLSID_HTMLDocument,
5737 .cpc_entries = HTMLDocumentNode_cpc,
5738 .clone = HTMLDocumentNode_clone,
5741 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5743 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5744 HTMLDocumentNode *new_node;
5745 HRESULT hres;
5747 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
5748 if(FAILED(hres))
5749 return hres;
5751 *ret = &new_node->node;
5752 return S_OK;
5755 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
5757 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
5760 static void *HTMLDocumentNode_query_interface(DispatchEx *dispex, REFIID riid)
5762 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5764 if(IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDispatchEx, riid))
5765 return &This->IDispatchEx_iface;
5766 if(IsEqualGUID(&IID_IHTMLDocument, riid) || IsEqualGUID(&IID_IHTMLDocument2, riid))
5767 return &This->IHTMLDocument2_iface;
5768 if(IsEqualGUID(&IID_IHTMLDocument3, riid))
5769 return &This->IHTMLDocument3_iface;
5770 if(IsEqualGUID(&IID_IHTMLDocument4, riid))
5771 return &This->IHTMLDocument4_iface;
5772 if(IsEqualGUID(&IID_IHTMLDocument5, riid))
5773 return &This->IHTMLDocument5_iface;
5774 if(IsEqualGUID(&IID_IHTMLDocument6, riid))
5775 return &This->IHTMLDocument6_iface;
5776 if(IsEqualGUID(&IID_IHTMLDocument7, riid))
5777 return &This->IHTMLDocument7_iface;
5778 if(IsEqualGUID(&IID_IDocumentSelector, riid))
5779 return &This->IDocumentSelector_iface;
5780 if(IsEqualGUID(&IID_IDocumentEvent, riid))
5781 return &This->IDocumentEvent_iface;
5782 if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
5783 return &This->IHTMLDocument2_iface;
5784 if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
5785 return &This->ISupportErrorInfo_iface;
5786 if(IsEqualGUID(&IID_IProvideClassInfo, riid))
5787 return &This->IProvideMultipleClassInfo_iface;
5788 if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
5789 return &This->IProvideMultipleClassInfo_iface;
5790 if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
5791 return &This->IProvideMultipleClassInfo_iface;
5792 if(IsEqualGUID(&IID_IMarkupServices, riid))
5793 return &This->IMarkupServices_iface;
5794 if(IsEqualGUID(&IID_IMarkupContainer, riid))
5795 return &This->IMarkupContainer_iface;
5796 if(IsEqualGUID(&IID_IDisplayServices, riid))
5797 return &This->IDisplayServices_iface;
5798 if(IsEqualGUID(&IID_IDocumentRange, riid))
5799 return &This->IDocumentRange_iface;
5800 if(IsEqualGUID(&IID_IPersist, riid))
5801 return &This->IPersistFile_iface;
5802 if(IsEqualGUID(&IID_IPersistMoniker, riid))
5803 return &This->IPersistMoniker_iface;
5804 if(IsEqualGUID(&IID_IPersistFile, riid))
5805 return &This->IPersistFile_iface;
5806 if(IsEqualGUID(&IID_IMonikerProp, riid))
5807 return &This->IMonikerProp_iface;
5808 if(IsEqualGUID(&IID_IPersistStreamInit, riid))
5809 return &This->IPersistStreamInit_iface;
5810 if(IsEqualGUID(&IID_IPersistHistory, riid))
5811 return &This->IPersistHistory_iface;
5812 if(IsEqualGUID(&IID_IHlinkTarget, riid))
5813 return &This->IHlinkTarget_iface;
5814 if(IsEqualGUID(&IID_IOleCommandTarget, riid))
5815 return &This->IOleCommandTarget_iface;
5816 if(IsEqualGUID(&IID_IOleObject, riid))
5817 return &This->IOleObject_iface;
5818 if(IsEqualGUID(&IID_IOleDocument, riid))
5819 return &This->IOleDocument_iface;
5820 if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
5821 return &This->IOleInPlaceActiveObject_iface;
5822 if(IsEqualGUID(&IID_IOleWindow, riid))
5823 return &This->IOleInPlaceActiveObject_iface;
5824 if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
5825 return &This->IOleInPlaceObjectWindowless_iface;
5826 if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
5827 return &This->IOleInPlaceObjectWindowless_iface;
5828 if(IsEqualGUID(&IID_IOleControl, riid))
5829 return &This->IOleControl_iface;
5830 if(IsEqualGUID(&IID_IObjectWithSite, riid))
5831 return &This->IObjectWithSite_iface;
5832 if(IsEqualGUID(&IID_IOleContainer, riid))
5833 return &This->IOleContainer_iface;
5834 if(IsEqualGUID(&IID_IObjectSafety, riid))
5835 return &This->IObjectSafety_iface;
5836 if(IsEqualGUID(&IID_IServiceProvider, riid))
5837 return &This->IServiceProvider_iface;
5838 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
5839 return &This->IInternetHostSecurityManager_iface;
5840 if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
5841 return &This->cp_container.IConnectionPointContainer_iface;
5842 if(IsEqualGUID(&CLSID_CMarkup, riid)) {
5843 FIXME("(%p)->(CLSID_CMarkup)\n", This);
5844 return NULL;
5845 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
5846 return NULL;
5847 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
5848 return NULL;
5849 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
5850 return NULL;
5851 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
5852 return NULL;
5855 return HTMLDOMNode_query_interface(&This->node.event_target.dispex, riid);
5858 static void HTMLDocumentNode_unlink(DispatchEx *dispex)
5860 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5861 HTMLDOMNode_unlink(dispex);
5863 if(This->dom_document) {
5864 release_document_mutation(This);
5865 detach_document_node(This);
5866 This->dom_document = NULL;
5867 This->html_document = NULL;
5868 This->window = NULL;
5869 }else if(This->window) {
5870 detach_document_node(This);
5872 /* document fragments own reference to inner window */
5873 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
5874 This->window = NULL;
5878 static void HTMLDocumentNode_destructor(DispatchEx *dispex)
5880 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5882 free(This->event_vector);
5883 ConnectionPointContainer_Destroy(&This->cp_container);
5884 HTMLDOMNode_destructor(&This->node.event_target.dispex);
5887 static HRESULT HTMLDocumentNode_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
5889 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5890 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
5892 if(!This->dom_document || idx >= This->elem_vars_cnt)
5893 return DISP_E_MEMBERNOTFOUND;
5895 return (*name = SysAllocString(This->elem_vars[idx])) ? S_OK : E_OUTOFMEMORY;
5898 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5899 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5901 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5902 nsIDOMElement *nselem;
5903 HTMLDOMNode *node;
5904 unsigned i;
5905 HRESULT hres;
5907 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET))
5908 return MSHTML_E_INVALID_PROPERTY;
5910 i = id - MSHTML_DISPID_CUSTOM_MIN;
5912 if(!This->html_document || i >= This->elem_vars_cnt)
5913 return DISP_E_MEMBERNOTFOUND;
5915 hres = get_elem_by_name_or_id(This->html_document, This->elem_vars[i], &nselem);
5916 if(FAILED(hres))
5917 return hres;
5918 if(!nselem)
5919 return DISP_E_MEMBERNOTFOUND;
5921 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
5922 nsIDOMElement_Release(nselem);
5923 if(FAILED(hres))
5924 return hres;
5926 V_VT(res) = VT_DISPATCH;
5927 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5928 return S_OK;
5931 static HRESULT HTMLDocumentNode_next_dispid(DispatchEx *dispex, DISPID id, DISPID *pid)
5933 DWORD idx = (id == DISPID_STARTENUM) ? 0 : id - MSHTML_DISPID_CUSTOM_MIN + 1;
5934 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5935 nsIDOMNodeList *node_list;
5936 const PRUnichar *name;
5937 nsIDOMElement *nselem;
5938 nsIDOMNode *nsnode;
5939 nsAString nsstr;
5940 nsresult nsres;
5941 HRESULT hres;
5942 UINT32 i;
5944 if(!This->html_document)
5945 return S_FALSE;
5947 while(idx < This->elem_vars_cnt) {
5948 hres = has_elem_name(This->html_document, This->elem_vars[idx]);
5949 if(SUCCEEDED(hres)) {
5950 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
5951 return S_OK;
5953 if(hres != DISP_E_UNKNOWNNAME)
5954 return hres;
5955 idx++;
5958 /* Populate possibly missing DISPIDs */
5959 nsAString_InitDepend(&nsstr, L":-moz-any(applet,embed,form,iframe,img,object)[name]");
5960 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->html_document, &nsstr, &node_list);
5961 nsAString_Finish(&nsstr);
5962 if(NS_FAILED(nsres))
5963 return map_nsresult(nsres);
5965 for(i = 0, hres = S_OK; SUCCEEDED(hres); i++) {
5966 nsres = nsIDOMNodeList_Item(node_list, i, &nsnode);
5967 if(NS_FAILED(nsres)) {
5968 hres = map_nsresult(nsres);
5969 break;
5971 if(!nsnode)
5972 break;
5974 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
5975 nsIDOMNode_Release(nsnode);
5976 if(nsres != S_OK)
5977 continue;
5979 nsres = get_elem_attr_value(nselem, L"name", &nsstr, &name);
5980 nsIDOMElement_Release(nselem);
5981 if(NS_FAILED(nsres))
5982 hres = map_nsresult(nsres);
5983 else {
5984 hres = dispid_from_elem_name(This, name, &id);
5985 nsAString_Finish(&nsstr);
5988 nsIDOMNodeList_Release(node_list);
5989 if(FAILED(hres))
5990 return hres;
5992 if(idx >= This->elem_vars_cnt)
5993 return S_FALSE;
5995 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
5996 return S_OK;
5999 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
6001 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6003 TRACE("(%p) returning %u\n", This, This->document_mode);
6005 return lock_document_mode(This);
6008 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
6010 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6011 return (nsISupports*)This->node.nsnode;
6014 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
6016 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6017 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
6020 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
6022 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6023 if(!This->window)
6024 return NULL;
6025 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
6026 return &This->window->event_target;
6029 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
6031 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6032 ConnectionPointContainer *container = This->doc_obj
6033 ? &This->doc_obj->cp_container : &This->cp_container;
6034 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
6035 return container;
6038 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6040 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6041 return default_set_current_event(This->window, event);
6044 static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp, VARIANT *res,
6045 EXCEPINFO *ei, IServiceProvider *caller)
6047 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6049 if(!(flags & DISPATCH_PROPERTYPUT) || !This->outer_window)
6050 return S_FALSE;
6052 return IDispatchEx_InvokeEx(&This->outer_window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
6053 0, flags, dp, res, ei, caller);
6056 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
6058 .query_interface = HTMLDocumentNode_query_interface,
6059 .destructor = HTMLDocumentNode_destructor,
6060 .traverse = HTMLDOMNode_traverse,
6061 .unlink = HTMLDocumentNode_unlink,
6062 .get_name = HTMLDocumentNode_get_name,
6063 .invoke = HTMLDocumentNode_invoke,
6064 .next_dispid = HTMLDocumentNode_next_dispid,
6065 .get_compat_mode = HTMLDocumentNode_get_compat_mode,
6067 .get_gecko_target = HTMLDocumentNode_get_gecko_target,
6068 .bind_event = HTMLDocumentNode_bind_event,
6069 .get_parent_event_target = HTMLDocumentNode_get_parent_event_target,
6070 .get_cp_container = HTMLDocumentNode_get_cp_container,
6071 .set_current_event = HTMLDocumentNode_set_current_event
6074 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
6075 .clsid = &CLSID_HTMLDocument,
6076 .cpc_entries = HTMLDocumentNode_cpc,
6077 .clone = HTMLDocumentFragment_clone,
6080 static const tid_t HTMLDocumentNode_iface_tids[] = {
6081 IHTMLDOMNode_tid,
6082 IHTMLDOMNode2_tid,
6083 IHTMLDocument4_tid,
6084 IHTMLDocument5_tid,
6085 IDocumentSelector_tid,
6089 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6091 static const dispex_hook_t document2_hooks[] = {
6092 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6093 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6094 {DISPID_UNKNOWN}
6096 static const dispex_hook_t document2_ie11_hooks[] = {
6097 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6098 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6099 {DISPID_IHTMLDOCUMENT2_CREATESTYLESHEET, NULL},
6100 {DISPID_IHTMLDOCUMENT2_FILESIZE, NULL},
6101 {DISPID_IHTMLDOCUMENT2_SELECTION, NULL},
6102 {DISPID_UNKNOWN}
6104 static const dispex_hook_t document3_ie11_hooks[] = {
6105 {DISPID_IHTMLDOCUMENT3_ATTACHEVENT, NULL},
6106 {DISPID_IHTMLDOCUMENT3_DETACHEVENT, NULL},
6107 {DISPID_UNKNOWN}
6109 static const dispex_hook_t document6_ie9_hooks[] = {
6110 {DISPID_IHTMLDOCUMENT6_ONSTORAGE},
6111 {DISPID_UNKNOWN}
6114 HTMLDOMNode_init_dispex_info(info, mode);
6116 if(mode >= COMPAT_MODE_IE9) {
6117 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
6118 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
6121 /* Depending on compatibility version, we add interfaces in different order
6122 * so that the right getElementById implementation is used. */
6123 if(mode < COMPAT_MODE_IE8) {
6124 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
6125 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
6126 }else {
6127 dispex_info_add_interface(info, IHTMLDocument6_tid, mode >= COMPAT_MODE_IE9 ? document6_ie9_hooks : NULL);
6128 dispex_info_add_interface(info, IHTMLDocument3_tid, mode >= COMPAT_MODE_IE11 ? document3_ie11_hooks : NULL);
6130 dispex_info_add_interface(info, IHTMLDocument2_tid, mode >= COMPAT_MODE_IE11 ? document2_ie11_hooks : document2_hooks);
6133 static dispex_static_data_t HTMLDocumentNode_dispex = {
6134 "HTMLDocument",
6135 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
6136 DispHTMLDocument_tid,
6137 HTMLDocumentNode_iface_tids,
6138 HTMLDocumentNode_init_dispex_info
6141 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
6143 HTMLDocumentNode *doc;
6145 doc = calloc(1, sizeof(HTMLDocumentNode));
6146 if(!doc)
6147 return NULL;
6149 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
6150 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
6151 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
6152 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
6153 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
6154 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
6155 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
6156 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
6157 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
6158 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
6159 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
6160 doc->IMarkupServices_iface.lpVtbl = &MarkupServicesVtbl;
6161 doc->IMarkupContainer_iface.lpVtbl = &MarkupContainerVtbl;
6162 doc->IDisplayServices_iface.lpVtbl = &DisplayServicesVtbl;
6163 doc->IDocumentRange_iface.lpVtbl = &DocumentRangeVtbl;
6165 doc->doc_obj = doc_obj;
6166 doc->outer_window = window ? window->base.outer_window : NULL;
6167 doc->window = window;
6169 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocumentNode_cpc);
6170 HTMLDocumentNode_Persist_Init(doc);
6171 HTMLDocumentNode_Service_Init(doc);
6172 HTMLDocumentNode_OleCmd_Init(doc);
6173 HTMLDocumentNode_OleObj_Init(doc);
6174 HTMLDocumentNode_SecMgr_Init(doc);
6176 list_init(&doc->selection_list);
6177 list_init(&doc->range_list);
6178 list_init(&doc->plugin_hosts);
6180 return doc;
6183 HRESULT create_document_node(nsIDOMDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
6184 compat_mode_t parent_mode, HTMLDocumentNode **ret)
6186 HTMLDocumentObj *doc_obj = browser->doc;
6187 HTMLDocumentNode *doc;
6189 doc = alloc_doc_node(doc_obj, window);
6190 if(!doc)
6191 return E_OUTOFMEMORY;
6193 if(parent_mode >= COMPAT_MODE_IE9) {
6194 TRACE("using parent mode %u\n", parent_mode);
6195 doc->document_mode = parent_mode;
6196 lock_document_mode(doc);
6199 if(!doc_obj->window || (window && is_main_content_window(window->base.outer_window)))
6200 doc->cp_container.forward_container = &doc_obj->cp_container;
6202 /* Share reference with HTMLDOMNode */
6203 if(NS_SUCCEEDED(nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&doc->html_document))) {
6204 doc->dom_document = (nsIDOMDocument*)doc->html_document;
6205 nsIDOMHTMLDocument_Release(doc->html_document);
6206 }else {
6207 doc->dom_document = nsdoc;
6208 doc->html_document = NULL;
6211 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)doc->dom_document, &HTMLDocumentNode_dispex);
6213 init_document_mutation(doc);
6214 doc_init_events(doc);
6216 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
6218 list_add_head(&browser->document_nodes, &doc->browser_entry);
6219 doc->browser = browser;
6221 if(browser->usermode == EDITMODE && doc->html_document) {
6222 nsAString mode_str;
6223 nsresult nsres;
6225 nsAString_InitDepend(&mode_str, L"on");
6226 nsres = nsIDOMHTMLDocument_SetDesignMode(doc->html_document, &mode_str);
6227 nsAString_Finish(&mode_str);
6228 if(NS_FAILED(nsres))
6229 ERR("SetDesignMode failed: %08lx\n", nsres);
6232 *ret = doc;
6233 return S_OK;
6236 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
6238 HTMLDocumentNode *doc_frag;
6240 doc_frag = alloc_doc_node(doc_node->doc_obj, doc_node->window);
6241 if(!doc_frag)
6242 return E_OUTOFMEMORY;
6244 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
6246 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
6247 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
6248 doc_frag->document_mode = lock_document_mode(doc_node);
6250 *ret = doc_frag;
6251 return S_OK;
6254 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
6256 HTMLDOMNode *node;
6257 HRESULT hres;
6259 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
6260 if(FAILED(hres))
6261 return hres;
6263 if(!node) {
6264 ERR("document not initialized\n");
6265 return E_FAIL;
6268 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
6269 *ret = impl_from_HTMLDOMNode(node);
6270 return S_OK;