include: Be consistent in naming regarding MSF's block.
[wine.git] / dlls / mshtml / htmldoc.c
blob2b885d479ab25cdb310411177c5779f2a1db736e
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_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
300 DocumentType *This = DocumentType_from_HTMLDOMNode(iface);
302 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDOMDocumentType, riid))
303 *ppv = &This->IDOMDocumentType_iface;
304 else
305 return HTMLDOMNode_QI(&This->node, riid, ppv);
307 IUnknown_AddRef((IUnknown*)*ppv);
308 return S_OK;
311 static void DocumentType_destructor(HTMLDOMNode *iface)
313 DocumentType *This = DocumentType_from_HTMLDOMNode(iface);
315 HTMLDOMNode_destructor(&This->node);
318 static HRESULT DocumentType_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
320 DocumentType *This = DocumentType_from_HTMLDOMNode(iface);
322 return create_doctype_node(This->node.doc, nsnode, ret);
325 static const cpc_entry_t DocumentType_cpc[] = {{NULL}};
327 static const NodeImplVtbl DocumentTypeImplVtbl = {
328 NULL,
329 DocumentType_QI,
330 DocumentType_destructor,
331 DocumentType_cpc,
332 DocumentType_clone
335 static nsISupports *DocumentType_get_gecko_target(DispatchEx *dispex)
337 DocumentType *This = DocumentType_from_DispatchEx(dispex);
338 return (nsISupports*)This->node.nsnode;
341 static EventTarget *DocumentType_get_parent_event_target(DispatchEx *dispex)
343 DocumentType *This = DocumentType_from_DispatchEx(dispex);
344 nsIDOMNode *nsnode;
345 HTMLDOMNode *node;
346 nsresult nsres;
347 HRESULT hres;
349 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
350 assert(nsres == NS_OK);
351 if(!nsnode)
352 return NULL;
354 hres = get_node(nsnode, TRUE, &node);
355 nsIDOMNode_Release(nsnode);
356 if(FAILED(hres))
357 return NULL;
359 return &node->event_target;
362 static IHTMLEventObj *DocumentType_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
364 DocumentType *This = DocumentType_from_DispatchEx(dispex);
365 return default_set_current_event(This->node.doc->window, event);
368 static event_target_vtbl_t DocumentType_event_target_vtbl = {
370 NULL,
372 DocumentType_get_gecko_target,
373 NULL,
374 NULL,
375 DocumentType_get_parent_event_target,
376 NULL,
377 NULL,
378 DocumentType_set_current_event
381 static const tid_t DocumentType_iface_tids[] = {
382 IDOMDocumentType_tid,
383 IHTMLDOMNode_tid,
384 IHTMLDOMNode2_tid,
385 IHTMLDOMNode3_tid,
389 static dispex_static_data_t DocumentType_dispex = {
390 L"DocumentType",
391 &DocumentType_event_target_vtbl.dispex_vtbl,
392 DispDOMDocumentType_tid,
393 DocumentType_iface_tids
396 HRESULT create_doctype_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **ret)
398 nsIDOMDocumentType *nsdoctype;
399 DocumentType *doctype;
400 nsresult nsres;
402 if(!(doctype = calloc(1, sizeof(*doctype))))
403 return E_OUTOFMEMORY;
405 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMDocumentType, (void**)&nsdoctype);
406 assert(nsres == NS_OK);
408 doctype->node.vtbl = &DocumentTypeImplVtbl;
409 doctype->IDOMDocumentType_iface.lpVtbl = &DocumentTypeVtbl;
410 HTMLDOMNode_Init(doc, &doctype->node, (nsIDOMNode*)nsdoctype, &DocumentType_dispex);
411 nsIDOMDocumentType_Release(nsdoctype);
413 *ret = &doctype->node;
414 return S_OK;
417 static inline HTMLDocumentNode *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
419 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument2_iface);
422 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
424 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
426 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
429 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
431 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
433 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
436 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
438 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
440 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
443 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
445 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
447 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
450 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo, LCID lcid,
451 ITypeInfo **ppTInfo)
453 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
455 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
458 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid, LPOLESTR *rgszNames,
459 UINT cNames, LCID lcid, DISPID *rgDispId)
461 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
463 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
464 rgDispId);
467 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
468 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
470 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
472 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
473 pDispParams, pVarResult, pExcepInfo, puArgErr);
476 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
478 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
479 HRESULT hres;
481 TRACE("(%p)->(%p)\n", This, p);
483 hres = IHTMLDocument7_get_parentWindow(&This->IHTMLDocument7_iface, (IHTMLWindow2**)p);
484 return hres == S_OK && !*p ? E_PENDING : hres;
487 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
489 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
491 TRACE("(%p)->(%p)\n", This, p);
492 *p = create_all_collection(&This->node, FALSE);
494 return S_OK;
497 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
499 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
500 nsIDOMElement *nsbody = NULL;
501 HTMLElement *element;
502 nsresult nsres;
503 HRESULT hres;
505 TRACE("(%p)->(%p)\n", This, p);
507 if(This->html_document) {
508 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, (nsIDOMHTMLElement **)&nsbody);
509 if(NS_FAILED(nsres)) {
510 TRACE("Could not get body: %08lx\n", nsres);
511 return E_UNEXPECTED;
513 }else {
514 nsAString nsnode_name;
515 nsIDOMDocumentFragment *frag;
517 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&frag);
518 if(!NS_FAILED(nsres)) {
519 nsAString_InitDepend(&nsnode_name, L"BODY");
520 nsIDOMDocumentFragment_QuerySelector(frag, &nsnode_name, &nsbody);
521 nsAString_Finish(&nsnode_name);
522 nsIDOMDocumentFragment_Release(frag);
526 if(!nsbody) {
527 *p = NULL;
528 return S_OK;
531 hres = get_element(nsbody, &element);
532 nsIDOMElement_Release(nsbody);
533 if(FAILED(hres))
534 return hres;
536 *p = &element->IHTMLElement_iface;
537 return S_OK;
540 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
542 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
543 nsIDOMElement *nselem;
544 HTMLElement *elem;
545 nsresult nsres;
546 HRESULT hres;
548 TRACE("(%p)->(%p)\n", This, p);
550 if(!This->dom_document) {
551 *p = NULL;
552 return S_OK;
556 * NOTE: Gecko may return an active element even if the document is not visible.
557 * IE returns NULL in this case.
559 nsres = nsIDOMDocument_GetActiveElement(This->dom_document, &nselem);
560 if(NS_FAILED(nsres)) {
561 ERR("GetActiveElement failed: %08lx\n", nsres);
562 return E_FAIL;
565 if(!nselem) {
566 *p = NULL;
567 return S_OK;
570 hres = get_element(nselem, &elem);
571 nsIDOMElement_Release(nselem);
572 if(FAILED(hres))
573 return hres;
575 *p = &elem->IHTMLElement_iface;
576 return S_OK;
579 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
581 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
582 nsIDOMHTMLCollection *nscoll = NULL;
583 nsresult nsres;
585 TRACE("(%p)->(%p)\n", This, p);
587 if(!p)
588 return E_INVALIDARG;
590 *p = NULL;
592 if(!This->dom_document) {
593 WARN("NULL dom_document\n");
594 return E_UNEXPECTED;
597 if(!This->html_document) {
598 FIXME("Not implemented for XML document\n");
599 return E_NOTIMPL;
602 nsres = nsIDOMHTMLDocument_GetImages(This->html_document, &nscoll);
603 if(NS_FAILED(nsres)) {
604 ERR("GetImages failed: %08lx\n", nsres);
605 return E_FAIL;
608 if(nscoll) {
609 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
610 nsIDOMHTMLCollection_Release(nscoll);
613 return S_OK;
616 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
618 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
619 nsIDOMHTMLCollection *nscoll = NULL;
620 nsresult nsres;
622 TRACE("(%p)->(%p)\n", This, p);
624 if(!p)
625 return E_INVALIDARG;
627 *p = NULL;
629 if(!This->dom_document) {
630 WARN("NULL dom_document\n");
631 return E_UNEXPECTED;
634 if(!This->html_document) {
635 FIXME("Not implemented for XML document\n");
636 return E_NOTIMPL;
639 nsres = nsIDOMHTMLDocument_GetApplets(This->html_document, &nscoll);
640 if(NS_FAILED(nsres)) {
641 ERR("GetApplets failed: %08lx\n", nsres);
642 return E_FAIL;
645 if(nscoll) {
646 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
647 nsIDOMHTMLCollection_Release(nscoll);
650 return S_OK;
653 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
655 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
656 nsIDOMHTMLCollection *nscoll = NULL;
657 nsresult nsres;
659 TRACE("(%p)->(%p)\n", This, p);
661 if(!p)
662 return E_INVALIDARG;
664 *p = NULL;
666 if(!This->dom_document) {
667 WARN("NULL dom_document\n");
668 return E_UNEXPECTED;
671 if(!This->html_document) {
672 FIXME("Not implemented for XML document\n");
673 return E_NOTIMPL;
676 nsres = nsIDOMHTMLDocument_GetLinks(This->html_document, &nscoll);
677 if(NS_FAILED(nsres)) {
678 ERR("GetLinks failed: %08lx\n", nsres);
679 return E_FAIL;
682 if(nscoll) {
683 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
684 nsIDOMHTMLCollection_Release(nscoll);
687 return S_OK;
690 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
692 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
693 nsIDOMHTMLCollection *nscoll = NULL;
694 nsresult nsres;
696 TRACE("(%p)->(%p)\n", This, p);
698 if(!p)
699 return E_INVALIDARG;
701 *p = NULL;
703 if(!This->dom_document) {
704 WARN("NULL dom_document\n");
705 return E_UNEXPECTED;
708 if(!This->html_document) {
709 FIXME("Not implemented for XML document\n");
710 return E_NOTIMPL;
713 nsres = nsIDOMHTMLDocument_GetForms(This->html_document, &nscoll);
714 if(NS_FAILED(nsres)) {
715 ERR("GetForms failed: %08lx\n", nsres);
716 return E_FAIL;
719 if(nscoll) {
720 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
721 nsIDOMHTMLCollection_Release(nscoll);
724 return S_OK;
727 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
729 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
730 nsIDOMHTMLCollection *nscoll = NULL;
731 nsresult nsres;
733 TRACE("(%p)->(%p)\n", This, p);
735 if(!p)
736 return E_INVALIDARG;
738 *p = NULL;
740 if(!This->dom_document) {
741 WARN("NULL dom_document\n");
742 return E_UNEXPECTED;
745 if(!This->html_document) {
746 FIXME("Not implemented for XML document\n");
747 return E_NOTIMPL;
750 nsres = nsIDOMHTMLDocument_GetAnchors(This->html_document, &nscoll);
751 if(NS_FAILED(nsres)) {
752 ERR("GetAnchors failed: %08lx\n", nsres);
753 return E_FAIL;
756 if(nscoll) {
757 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
758 nsIDOMHTMLCollection_Release(nscoll);
761 return S_OK;
764 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
766 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
767 nsAString nsstr;
768 nsresult nsres;
770 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
772 if(!This->dom_document) {
773 WARN("NULL dom_document\n");
774 return E_UNEXPECTED;
777 nsAString_InitDepend(&nsstr, v);
778 nsres = nsIDOMDocument_SetTitle(This->dom_document, &nsstr);
779 nsAString_Finish(&nsstr);
780 if(NS_FAILED(nsres))
781 ERR("SetTitle failed: %08lx\n", nsres);
783 return S_OK;
786 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
788 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
789 const PRUnichar *ret;
790 nsAString nsstr;
791 nsresult nsres;
793 TRACE("(%p)->(%p)\n", This, p);
795 if(!This->dom_document) {
796 WARN("NULL dom_document\n");
797 return E_UNEXPECTED;
801 nsAString_Init(&nsstr, NULL);
802 nsres = nsIDOMDocument_GetTitle(This->dom_document, &nsstr);
803 if (NS_SUCCEEDED(nsres)) {
804 nsAString_GetData(&nsstr, &ret);
805 *p = SysAllocString(ret);
807 nsAString_Finish(&nsstr);
809 if(NS_FAILED(nsres)) {
810 ERR("GetTitle failed: %08lx\n", nsres);
811 return E_FAIL;
814 return S_OK;
817 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
819 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
820 nsIDOMHTMLCollection *nscoll = NULL;
821 nsresult nsres;
823 TRACE("(%p)->(%p)\n", This, p);
825 if(!p)
826 return E_INVALIDARG;
828 *p = NULL;
830 if(!This->dom_document) {
831 WARN("NULL dom_document\n");
832 return E_UNEXPECTED;
835 if(!This->html_document) {
836 FIXME("Not implemented for XML document\n");
837 return E_NOTIMPL;
840 nsres = nsIDOMHTMLDocument_GetScripts(This->html_document, &nscoll);
841 if(NS_FAILED(nsres)) {
842 ERR("GetImages failed: %08lx\n", nsres);
843 return E_FAIL;
846 if(nscoll) {
847 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
848 nsIDOMHTMLCollection_Release(nscoll);
851 return S_OK;
854 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
856 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
857 HRESULT hres;
859 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
861 if(wcsicmp(v, L"on")) {
862 FIXME("Unsupported arg %s\n", debugstr_w(v));
863 return E_NOTIMPL;
866 hres = setup_edit_mode(This->doc_obj);
867 if(FAILED(hres))
868 return hres;
870 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
871 return S_OK;
874 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
876 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
877 FIXME("(%p)->(%p) always returning Off\n", This, p);
879 if(!p)
880 return E_INVALIDARG;
882 *p = SysAllocString(L"Off");
884 return S_OK;
887 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
889 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
890 nsISelection *nsselection;
891 nsresult nsres;
893 TRACE("(%p)->(%p)\n", This, p);
895 if(!This->html_document) {
896 FIXME("Not implemented for XML document\n");
897 return E_NOTIMPL;
900 nsres = nsIDOMHTMLDocument_GetSelection(This->html_document, &nsselection);
901 if(NS_FAILED(nsres)) {
902 ERR("GetSelection failed: %08lx\n", nsres);
903 return E_FAIL;
906 return HTMLSelectionObject_Create(This, nsselection, p);
909 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
911 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
913 TRACE("(%p)->(%p)\n", iface, p);
915 if(!p)
916 return E_POINTER;
918 return get_readystate_string(This->outer_window ? This->outer_window->readystate : 0, p);
921 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
923 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
925 TRACE("(%p)->(%p)\n", This, p);
927 if(!This->outer_window) {
928 /* Not implemented by IE */
929 return E_NOTIMPL;
931 return IHTMLWindow2_get_frames(&This->outer_window->base.IHTMLWindow2_iface, p);
934 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
936 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
937 FIXME("(%p)->(%p)\n", This, p);
938 return E_NOTIMPL;
941 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
943 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
944 FIXME("(%p)->(%p)\n", This, p);
945 return E_NOTIMPL;
948 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
950 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
951 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
952 return E_NOTIMPL;
955 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
957 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
958 FIXME("(%p)->(%p)\n", This, p);
959 return E_NOTIMPL;
962 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
964 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
965 IHTMLElement *element = NULL;
966 IHTMLBodyElement *body;
967 HRESULT hr;
969 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
971 hr = IHTMLDocument2_get_body(iface, &element);
972 if (FAILED(hr))
974 ERR("Failed to get body (0x%08lx)\n", hr);
975 return hr;
978 if(!element)
980 FIXME("Empty body element.\n");
981 return hr;
984 hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body);
985 if (SUCCEEDED(hr))
987 hr = IHTMLBodyElement_put_bgColor(body, v);
988 IHTMLBodyElement_Release(body);
990 IHTMLElement_Release(element);
992 return hr;
995 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
997 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
998 nsAString nsstr;
999 nsresult nsres;
1000 HRESULT hres;
1002 TRACE("(%p)->(%p)\n", This, p);
1004 if(!This->dom_document) {
1005 WARN("NULL dom_document\n");
1006 return E_UNEXPECTED;
1009 if(!This->html_document) {
1010 FIXME("Not implemented for XML document\n");
1011 return E_NOTIMPL;
1014 nsAString_Init(&nsstr, NULL);
1015 nsres = nsIDOMHTMLDocument_GetBgColor(This->html_document, &nsstr);
1016 hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p);
1017 if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) {
1018 TRACE("default #ffffff\n");
1019 if(!(V_BSTR(p) = SysAllocString(L"#ffffff")))
1020 hres = E_OUTOFMEMORY;
1022 return hres;
1025 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
1027 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1028 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1029 return E_NOTIMPL;
1032 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
1034 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1035 FIXME("(%p)->(%p)\n", This, p);
1036 return E_NOTIMPL;
1039 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
1041 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1042 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1043 return E_NOTIMPL;
1046 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
1048 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1049 FIXME("(%p)->(%p)\n", This, p);
1050 return E_NOTIMPL;
1053 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
1055 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1056 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1057 return E_NOTIMPL;
1060 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
1062 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1063 FIXME("(%p)->(%p)\n", This, p);
1064 return E_NOTIMPL;
1067 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
1069 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1070 nsAString nsstr;
1071 nsresult nsres;
1073 TRACE("(%p)->(%p)\n", This, p);
1075 nsAString_InitDepend(&nsstr, NULL);
1076 nsres = nsIDOMDocument_GetReferrer(This->dom_document, &nsstr);
1077 return return_nsstr(nsres, &nsstr, p);
1080 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
1082 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1084 TRACE("(%p)->(%p)\n", This, p);
1086 if(!This->dom_document || !This->window) {
1087 WARN("NULL window\n");
1088 return E_UNEXPECTED;
1091 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
1094 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
1096 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1097 FIXME("(%p)->(%p)\n", This, p);
1098 return E_NOTIMPL;
1101 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
1103 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1105 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1107 if(!This->outer_window) {
1108 FIXME("No window available\n");
1109 return E_FAIL;
1112 return navigate_url(This->outer_window, v, This->outer_window->uri, BINDING_NAVIGATED);
1115 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
1117 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1119 TRACE("(%p)->(%p)\n", iface, p);
1121 *p = SysAllocString(This->outer_window && This->outer_window->url ? This->outer_window->url : L"about:blank");
1122 return *p ? S_OK : E_OUTOFMEMORY;
1125 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
1127 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1128 nsAString nsstr;
1129 nsresult nsres;
1131 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1133 if(!This->html_document) {
1134 FIXME("Not implemented for XML document\n");
1135 return E_NOTIMPL;
1138 nsAString_InitDepend(&nsstr, v);
1139 nsres = nsIDOMHTMLDocument_SetDomain(This->html_document, &nsstr);
1140 nsAString_Finish(&nsstr);
1141 if(NS_FAILED(nsres)) {
1142 ERR("SetDomain failed: %08lx\n", nsres);
1143 return E_INVALIDARG;
1146 return S_OK;
1149 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
1151 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1152 nsAString nsstr;
1153 nsresult nsres;
1155 TRACE("(%p)->(%p)\n", This, p);
1157 if(!This->html_document) {
1158 FIXME("Not implemented for XML document\n");
1159 return E_NOTIMPL;
1162 if(This->outer_window && !This->outer_window->uri)
1163 return E_FAIL;
1165 nsAString_Init(&nsstr, NULL);
1166 nsres = nsIDOMHTMLDocument_GetDomain(This->html_document, &nsstr);
1167 if(NS_SUCCEEDED(nsres) && This->outer_window && This->outer_window->uri) {
1168 const PRUnichar *str;
1169 HRESULT hres;
1171 nsAString_GetData(&nsstr, &str);
1172 if(!*str) {
1173 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
1174 nsAString_Finish(&nsstr);
1175 hres = IUri_GetHost(This->outer_window->uri, p);
1176 return FAILED(hres) ? hres : S_OK;
1180 return return_nsstr(nsres, &nsstr, p);
1183 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
1185 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1186 BOOL bret;
1188 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1190 if(!This->outer_window)
1191 return S_OK;
1193 bret = InternetSetCookieExW(This->outer_window->url, NULL, v, 0, 0);
1194 if(!bret) {
1195 FIXME("InternetSetCookieExW failed: %lu\n", GetLastError());
1196 return HRESULT_FROM_WIN32(GetLastError());
1199 return S_OK;
1202 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
1204 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1205 DWORD size;
1206 BOOL bret;
1208 TRACE("(%p)->(%p)\n", This, p);
1210 if(!This->outer_window) {
1211 *p = NULL;
1212 return S_OK;
1215 size = 0;
1216 bret = InternetGetCookieExW(This->outer_window->url, NULL, NULL, &size, 0, NULL);
1217 if(!bret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
1218 WARN("InternetGetCookieExW failed: %lu\n", GetLastError());
1219 *p = NULL;
1220 return S_OK;
1223 if(!size) {
1224 *p = NULL;
1225 return S_OK;
1228 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
1229 if(!*p)
1230 return E_OUTOFMEMORY;
1232 bret = InternetGetCookieExW(This->outer_window->url, NULL, *p, &size, 0, NULL);
1233 if(!bret) {
1234 ERR("InternetGetCookieExW failed: %lu\n", GetLastError());
1235 return E_FAIL;
1238 return S_OK;
1241 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
1243 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1244 FIXME("(%p)->(%x)\n", This, v);
1245 return E_NOTIMPL;
1248 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
1250 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1251 FIXME("(%p)->(%p)\n", This, p);
1252 return E_NOTIMPL;
1255 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
1257 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1258 FIXME("(%p)->(%s) returning S_OK\n", This, debugstr_w(v));
1259 return S_OK;
1262 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
1264 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1266 TRACE("(%p)->(%p)\n", This, p);
1268 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
1271 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
1273 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1274 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1275 return E_NOTIMPL;
1278 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
1280 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1282 TRACE("(%p)->(%p)\n", This, p);
1284 *p = charset_string_from_cp(GetACP());
1285 return *p ? S_OK : E_OUTOFMEMORY;
1288 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
1290 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1291 const PRUnichar *content_type;
1292 nsAString nsstr;
1293 nsresult nsres;
1294 HRESULT hres;
1296 TRACE("(%p)->(%p)\n", This, p);
1298 *p = NULL;
1300 if(This->window && This->window->base.outer_window->readystate == READYSTATE_UNINITIALIZED)
1301 return (*p = SysAllocString(L"")) ? S_OK : E_FAIL;
1303 nsAString_InitDepend(&nsstr, NULL);
1304 nsres = nsIDOMDocument_GetContentType(This->dom_document, &nsstr);
1305 if(NS_FAILED(nsres))
1306 return map_nsresult(nsres);
1308 nsAString_GetData(&nsstr, &content_type);
1309 hres = get_mime_type_display_name(content_type, p);
1310 nsAString_Finish(&nsstr);
1311 return hres;
1314 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
1316 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1317 FIXME("(%p)->(%p)\n", This, p);
1318 return E_NOTIMPL;
1321 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
1323 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1324 FIXME("(%p)->(%p)\n", This, p);
1325 return E_NOTIMPL;
1328 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
1330 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1331 FIXME("(%p)->(%p)\n", This, p);
1332 return E_NOTIMPL;
1335 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
1337 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1338 FIXME("(%p)->(%p)\n", This, p);
1339 return E_NOTIMPL;
1342 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
1344 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1345 FIXME("(%p)->(%p)\n", This, p);
1346 return E_NOTIMPL;
1349 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
1351 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1352 FIXME("(%p)->(%p)\n", This, p);
1353 return E_NOTIMPL;
1356 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1358 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1359 FIXME("(%p)->(%p)\n", This, p);
1360 return E_NOTIMPL;
1363 static HRESULT document_write(HTMLDocumentNode *This, SAFEARRAY *psarray, BOOL ln)
1365 VARIANT *var, tmp;
1366 JSContext *jsctx;
1367 nsAString nsstr;
1368 ULONG i, argc;
1369 nsresult nsres;
1370 HRESULT hres;
1372 if(!This->dom_document) {
1373 WARN("NULL dom_document\n");
1374 return E_UNEXPECTED;
1377 if(!This->html_document) {
1378 FIXME("Not implemented for XML document\n");
1379 return E_NOTIMPL;
1382 if (!psarray)
1383 return S_OK;
1385 if(psarray->cDims != 1) {
1386 FIXME("cDims=%d\n", psarray->cDims);
1387 return E_INVALIDARG;
1390 hres = SafeArrayAccessData(psarray, (void**)&var);
1391 if(FAILED(hres)) {
1392 WARN("SafeArrayAccessData failed: %08lx\n", hres);
1393 return hres;
1396 V_VT(&tmp) = VT_EMPTY;
1398 jsctx = get_context_from_document(This->dom_document);
1399 argc = psarray->rgsabound[0].cElements;
1400 for(i=0; i < argc; i++) {
1401 if(V_VT(var+i) == VT_BSTR) {
1402 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1403 }else {
1404 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1405 if(FAILED(hres)) {
1406 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1407 break;
1409 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1412 if(!ln || i != argc-1)
1413 nsres = nsIDOMHTMLDocument_Write(This->html_document, &nsstr, jsctx);
1414 else
1415 nsres = nsIDOMHTMLDocument_Writeln(This->html_document, &nsstr, jsctx);
1416 nsAString_Finish(&nsstr);
1417 if(V_VT(var+i) != VT_BSTR)
1418 VariantClear(&tmp);
1419 if(NS_FAILED(nsres)) {
1420 ERR("Write failed: %08lx\n", nsres);
1421 hres = E_FAIL;
1422 break;
1426 SafeArrayUnaccessData(psarray);
1428 return hres;
1431 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1433 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1435 TRACE("(%p)->(%p)\n", iface, psarray);
1437 return document_write(This, psarray, FALSE);
1440 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1442 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1444 TRACE("(%p)->(%p)\n", This, psarray);
1446 return document_write(This, psarray, TRUE);
1449 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1450 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1452 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1453 nsISupports *tmp;
1454 nsresult nsres;
1456 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1457 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1459 *pomWindowResult = NULL;
1461 if(!This->outer_window)
1462 return E_FAIL;
1464 if(!This->dom_document) {
1465 ERR("!dom_document\n");
1466 return E_NOTIMPL;
1469 if(!This->html_document) {
1470 FIXME("Not implemented for XML document\n");
1471 return E_NOTIMPL;
1474 if(!url || wcscmp(url, L"text/html") || V_VT(&name) != VT_ERROR
1475 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1476 FIXME("unsupported args\n");
1478 nsres = nsIDOMHTMLDocument_Open(This->html_document, NULL, NULL, NULL,
1479 get_context_from_document(This->dom_document), 0, &tmp);
1480 if(NS_FAILED(nsres)) {
1481 ERR("Open failed: %08lx\n", nsres);
1482 return E_FAIL;
1485 if(tmp)
1486 nsISupports_Release(tmp);
1488 *pomWindowResult = (IDispatch*)&This->outer_window->base.IHTMLWindow2_iface;
1489 IHTMLWindow2_AddRef(&This->outer_window->base.IHTMLWindow2_iface);
1490 return S_OK;
1493 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1495 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1496 nsresult nsres;
1498 TRACE("(%p)\n", This);
1500 if(!This->dom_document) {
1501 ERR("!dom_document\n");
1502 return E_NOTIMPL;
1505 if(!This->html_document) {
1506 FIXME("Not implemented for XML document\n");
1507 return E_NOTIMPL;
1510 nsres = nsIDOMHTMLDocument_Close(This->html_document);
1511 if(NS_FAILED(nsres)) {
1512 ERR("Close failed: %08lx\n", nsres);
1513 return E_FAIL;
1516 return S_OK;
1519 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1521 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1522 nsresult nsres;
1524 TRACE("(%p)\n", This);
1526 if(!This->html_document) {
1527 FIXME("Not implemented for XML document\n");
1528 return E_NOTIMPL;
1531 nsres = nsIDOMHTMLDocument_Clear(This->html_document);
1532 if(NS_FAILED(nsres)) {
1533 ERR("Clear failed: %08lx\n", nsres);
1534 return E_FAIL;
1537 return S_OK;
1540 static const struct {
1541 const WCHAR *name;
1542 OLECMDID id;
1543 }command_names[] = {
1544 {L"copy", IDM_COPY},
1545 {L"cut", IDM_CUT},
1546 {L"fontname", IDM_FONTNAME},
1547 {L"fontsize", IDM_FONTSIZE},
1548 {L"indent", IDM_INDENT},
1549 {L"insertorderedlist", IDM_ORDERLIST},
1550 {L"insertunorderedlist", IDM_UNORDERLIST},
1551 {L"outdent", IDM_OUTDENT},
1552 {L"paste", IDM_PASTE},
1553 {L"respectvisibilityindesign", IDM_RESPECTVISIBILITY_INDESIGN}
1556 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1558 int i;
1560 for(i = 0; i < ARRAY_SIZE(command_names); i++) {
1561 if(!wcsicmp(command_names[i].name, str)) {
1562 *cmdid = command_names[i].id;
1563 return TRUE;
1567 FIXME("Unknown command %s\n", debugstr_w(str));
1568 return FALSE;
1571 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1572 VARIANT_BOOL *pfRet)
1574 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1575 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1576 return E_NOTIMPL;
1579 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1580 VARIANT_BOOL *pfRet)
1582 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1583 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1584 return E_NOTIMPL;
1587 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1588 VARIANT_BOOL *pfRet)
1590 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1591 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1592 return E_NOTIMPL;
1595 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1596 VARIANT_BOOL *pfRet)
1598 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1599 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1600 return E_NOTIMPL;
1603 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1604 BSTR *pfRet)
1606 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1607 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1608 return E_NOTIMPL;
1611 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1612 VARIANT *pfRet)
1614 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1615 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1616 return E_NOTIMPL;
1619 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1620 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1622 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1623 OLECMDID cmdid;
1624 VARIANT ret;
1625 HRESULT hres;
1627 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1629 if(!cmdid_from_string(cmdID, &cmdid))
1630 return OLECMDERR_E_NOTSUPPORTED;
1632 V_VT(&ret) = VT_EMPTY;
1633 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1634 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1635 if(FAILED(hres))
1636 return hres;
1638 if(V_VT(&ret) != VT_EMPTY) {
1639 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1640 VariantClear(&ret);
1643 *pfRet = VARIANT_TRUE;
1644 return S_OK;
1647 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1648 VARIANT_BOOL *pfRet)
1650 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1651 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1652 return E_NOTIMPL;
1655 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1656 IHTMLElement **newElem)
1658 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1659 HTMLElement *elem;
1660 HRESULT hres;
1662 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1664 hres = create_element(This, eTag, &elem);
1665 if(FAILED(hres))
1666 return hres;
1668 *newElem = &elem->IHTMLElement_iface;
1669 return S_OK;
1672 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1674 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1675 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1676 return E_NOTIMPL;
1679 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1681 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1682 FIXME("(%p)->(%p)\n", This, p);
1683 return E_NOTIMPL;
1686 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1688 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1690 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1692 return set_doc_event(This, EVENTID_CLICK, &v);
1695 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1697 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1699 TRACE("(%p)->(%p)\n", This, p);
1701 return get_doc_event(This, EVENTID_CLICK, p);
1704 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1706 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1708 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1710 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1713 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1715 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1717 TRACE("(%p)->(%p)\n", This, p);
1719 return get_doc_event(This, EVENTID_DBLCLICK, p);
1722 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1724 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1726 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1728 return set_doc_event(This, EVENTID_KEYUP, &v);
1731 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1733 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1735 TRACE("(%p)->(%p)\n", This, p);
1737 return get_doc_event(This, EVENTID_KEYUP, p);
1740 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1742 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1744 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1746 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1749 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1751 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1753 TRACE("(%p)->(%p)\n", This, p);
1755 return get_doc_event(This, EVENTID_KEYDOWN, p);
1758 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1760 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1762 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1764 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1767 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1769 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1771 TRACE("(%p)->(%p)\n", This, p);
1773 return get_doc_event(This, EVENTID_KEYPRESS, p);
1776 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1778 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1780 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1782 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1785 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1787 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1789 TRACE("(%p)->(%p)\n", This, p);
1791 return get_doc_event(This, EVENTID_MOUSEUP, p);
1794 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1796 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1798 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1800 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1803 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1805 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1807 TRACE("(%p)->(%p)\n", This, p);
1809 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1812 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1814 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1816 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1818 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1821 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1823 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1825 TRACE("(%p)->(%p)\n", This, p);
1827 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1830 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1832 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1834 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1836 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1839 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1841 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1843 TRACE("(%p)->(%p)\n", This, p);
1845 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1848 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1850 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1852 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1854 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1857 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1859 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1861 TRACE("(%p)->(%p)\n", This, p);
1863 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1866 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1868 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1870 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1872 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1875 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1877 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1879 TRACE("(%p)->(%p)\n", This, p);
1881 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1884 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1886 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1887 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1888 return E_NOTIMPL;
1891 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1893 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1894 FIXME("(%p)->(%p)\n", This, p);
1895 return E_NOTIMPL;
1898 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1900 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1901 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1902 return E_NOTIMPL;
1905 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1907 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1908 FIXME("(%p)->(%p)\n", This, p);
1909 return E_NOTIMPL;
1912 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1914 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1915 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1916 return E_NOTIMPL;
1919 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1921 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1922 FIXME("(%p)->(%p)\n", This, p);
1923 return E_NOTIMPL;
1926 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1928 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1930 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1932 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1935 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1937 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1939 TRACE("(%p)->(%p)\n", This, p);
1941 return get_doc_event(This, EVENTID_DRAGSTART, p);
1944 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1946 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1948 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1950 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1953 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1955 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1957 TRACE("(%p)->(%p)\n", This, p);
1959 return get_doc_event(This, EVENTID_SELECTSTART, p);
1962 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1963 IHTMLElement **elementHit)
1965 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1966 nsIDOMElement *nselem;
1967 HTMLElement *element;
1968 nsresult nsres;
1969 HRESULT hres;
1971 TRACE("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1973 nsres = nsIDOMDocument_ElementFromPoint(This->dom_document, x, y, &nselem);
1974 if(NS_FAILED(nsres)) {
1975 ERR("ElementFromPoint failed: %08lx\n", nsres);
1976 return E_FAIL;
1979 if(!nselem) {
1980 *elementHit = NULL;
1981 return S_OK;
1984 hres = get_element(nselem, &element);
1985 nsIDOMElement_Release(nselem);
1986 if(FAILED(hres))
1987 return hres;
1989 *elementHit = &element->IHTMLElement_iface;
1990 return S_OK;
1993 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1995 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1996 HRESULT hres;
1998 TRACE("(%p)->(%p)\n", This, p);
2000 hres = IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
2001 return hres == S_OK && !*p ? E_FAIL : hres;
2004 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
2005 IHTMLStyleSheetsCollection **p)
2007 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2008 nsIDOMStyleSheetList *nsstylelist;
2009 nsresult nsres;
2010 HRESULT hres;
2012 TRACE("(%p)->(%p)\n", This, p);
2014 *p = NULL;
2016 if(!This->dom_document) {
2017 WARN("NULL dom_document\n");
2018 return E_UNEXPECTED;
2021 nsres = nsIDOMDocument_GetStyleSheets(This->dom_document, &nsstylelist);
2022 if(NS_FAILED(nsres)) {
2023 ERR("GetStyleSheets failed: %08lx\n", nsres);
2024 return map_nsresult(nsres);
2027 hres = create_style_sheet_collection(nsstylelist,
2028 dispex_compat_mode(&This->node.event_target.dispex), p);
2029 nsIDOMStyleSheetList_Release(nsstylelist);
2030 return hres;
2033 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
2035 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2036 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2037 return E_NOTIMPL;
2040 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
2042 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2043 FIXME("(%p)->(%p)\n", This, p);
2044 return E_NOTIMPL;
2047 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
2049 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2050 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2051 return E_NOTIMPL;
2054 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
2056 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2057 FIXME("(%p)->(%p)\n", This, p);
2058 return E_NOTIMPL;
2061 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
2063 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2065 TRACE("(%p)->(%p)\n", This, String);
2067 return dispex_to_string(&This->node.event_target.dispex, String);
2070 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
2071 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
2073 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2074 nsIDOMHTMLHeadElement *head_elem;
2075 IHTMLStyleElement *style_elem;
2076 HTMLElement *elem;
2077 nsresult nsres;
2078 HRESULT hres;
2080 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
2082 if(!This->dom_document) {
2083 FIXME("not a real doc object\n");
2084 return E_NOTIMPL;
2087 if(!This->html_document) {
2088 FIXME("Not implemented for XML document\n");
2089 return E_NOTIMPL;
2092 if(lIndex != -1)
2093 FIXME("Unsupported lIndex %ld\n", lIndex);
2095 if(bstrHref && *bstrHref) {
2096 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
2097 return create_style_sheet(NULL, dispex_compat_mode(&This->node.event_target.dispex),
2098 ppnewStyleSheet);
2101 hres = create_element(This, L"style", &elem);
2102 if(FAILED(hres))
2103 return hres;
2105 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &head_elem);
2106 if(NS_SUCCEEDED(nsres)) {
2107 nsIDOMNode *head_node, *tmp_node;
2109 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
2110 nsIDOMHTMLHeadElement_Release(head_elem);
2111 assert(nsres == NS_OK);
2113 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
2114 nsIDOMNode_Release(head_node);
2115 if(NS_SUCCEEDED(nsres) && tmp_node)
2116 nsIDOMNode_Release(tmp_node);
2118 if(NS_FAILED(nsres)) {
2119 IHTMLElement_Release(&elem->IHTMLElement_iface);
2120 return E_FAIL;
2123 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
2124 assert(hres == S_OK);
2125 IHTMLElement_Release(&elem->IHTMLElement_iface);
2127 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
2128 IHTMLStyleElement_Release(style_elem);
2129 return hres;
2132 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
2133 HTMLDocument_QueryInterface,
2134 HTMLDocument_AddRef,
2135 HTMLDocument_Release,
2136 HTMLDocument_GetTypeInfoCount,
2137 HTMLDocument_GetTypeInfo,
2138 HTMLDocument_GetIDsOfNames,
2139 HTMLDocument_Invoke,
2140 HTMLDocument_get_Script,
2141 HTMLDocument_get_all,
2142 HTMLDocument_get_body,
2143 HTMLDocument_get_activeElement,
2144 HTMLDocument_get_images,
2145 HTMLDocument_get_applets,
2146 HTMLDocument_get_links,
2147 HTMLDocument_get_forms,
2148 HTMLDocument_get_anchors,
2149 HTMLDocument_put_title,
2150 HTMLDocument_get_title,
2151 HTMLDocument_get_scripts,
2152 HTMLDocument_put_designMode,
2153 HTMLDocument_get_designMode,
2154 HTMLDocument_get_selection,
2155 HTMLDocument_get_readyState,
2156 HTMLDocument_get_frames,
2157 HTMLDocument_get_embeds,
2158 HTMLDocument_get_plugins,
2159 HTMLDocument_put_alinkColor,
2160 HTMLDocument_get_alinkColor,
2161 HTMLDocument_put_bgColor,
2162 HTMLDocument_get_bgColor,
2163 HTMLDocument_put_fgColor,
2164 HTMLDocument_get_fgColor,
2165 HTMLDocument_put_linkColor,
2166 HTMLDocument_get_linkColor,
2167 HTMLDocument_put_vlinkColor,
2168 HTMLDocument_get_vlinkColor,
2169 HTMLDocument_get_referrer,
2170 HTMLDocument_get_location,
2171 HTMLDocument_get_lastModified,
2172 HTMLDocument_put_URL,
2173 HTMLDocument_get_URL,
2174 HTMLDocument_put_domain,
2175 HTMLDocument_get_domain,
2176 HTMLDocument_put_cookie,
2177 HTMLDocument_get_cookie,
2178 HTMLDocument_put_expando,
2179 HTMLDocument_get_expando,
2180 HTMLDocument_put_charset,
2181 HTMLDocument_get_charset,
2182 HTMLDocument_put_defaultCharset,
2183 HTMLDocument_get_defaultCharset,
2184 HTMLDocument_get_mimeType,
2185 HTMLDocument_get_fileSize,
2186 HTMLDocument_get_fileCreatedDate,
2187 HTMLDocument_get_fileModifiedDate,
2188 HTMLDocument_get_fileUpdatedDate,
2189 HTMLDocument_get_security,
2190 HTMLDocument_get_protocol,
2191 HTMLDocument_get_nameProp,
2192 HTMLDocument_write,
2193 HTMLDocument_writeln,
2194 HTMLDocument_open,
2195 HTMLDocument_close,
2196 HTMLDocument_clear,
2197 HTMLDocument_queryCommandSupported,
2198 HTMLDocument_queryCommandEnabled,
2199 HTMLDocument_queryCommandState,
2200 HTMLDocument_queryCommandIndeterm,
2201 HTMLDocument_queryCommandText,
2202 HTMLDocument_queryCommandValue,
2203 HTMLDocument_execCommand,
2204 HTMLDocument_execCommandShowHelp,
2205 HTMLDocument_createElement,
2206 HTMLDocument_put_onhelp,
2207 HTMLDocument_get_onhelp,
2208 HTMLDocument_put_onclick,
2209 HTMLDocument_get_onclick,
2210 HTMLDocument_put_ondblclick,
2211 HTMLDocument_get_ondblclick,
2212 HTMLDocument_put_onkeyup,
2213 HTMLDocument_get_onkeyup,
2214 HTMLDocument_put_onkeydown,
2215 HTMLDocument_get_onkeydown,
2216 HTMLDocument_put_onkeypress,
2217 HTMLDocument_get_onkeypress,
2218 HTMLDocument_put_onmouseup,
2219 HTMLDocument_get_onmouseup,
2220 HTMLDocument_put_onmousedown,
2221 HTMLDocument_get_onmousedown,
2222 HTMLDocument_put_onmousemove,
2223 HTMLDocument_get_onmousemove,
2224 HTMLDocument_put_onmouseout,
2225 HTMLDocument_get_onmouseout,
2226 HTMLDocument_put_onmouseover,
2227 HTMLDocument_get_onmouseover,
2228 HTMLDocument_put_onreadystatechange,
2229 HTMLDocument_get_onreadystatechange,
2230 HTMLDocument_put_onafterupdate,
2231 HTMLDocument_get_onafterupdate,
2232 HTMLDocument_put_onrowexit,
2233 HTMLDocument_get_onrowexit,
2234 HTMLDocument_put_onrowenter,
2235 HTMLDocument_get_onrowenter,
2236 HTMLDocument_put_ondragstart,
2237 HTMLDocument_get_ondragstart,
2238 HTMLDocument_put_onselectstart,
2239 HTMLDocument_get_onselectstart,
2240 HTMLDocument_elementFromPoint,
2241 HTMLDocument_get_parentWindow,
2242 HTMLDocument_get_styleSheets,
2243 HTMLDocument_put_onbeforeupdate,
2244 HTMLDocument_get_onbeforeupdate,
2245 HTMLDocument_put_onerrorupdate,
2246 HTMLDocument_get_onerrorupdate,
2247 HTMLDocument_toString,
2248 HTMLDocument_createStyleSheet
2251 static inline HTMLDocumentNode *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
2253 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument3_iface);
2256 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface, REFIID riid, void **ppv)
2258 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2259 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2262 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
2264 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2265 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2268 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
2270 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2271 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2274 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
2276 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2277 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2280 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo, LCID lcid,
2281 ITypeInfo **ppTInfo)
2283 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2284 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2287 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid, LPOLESTR *rgszNames,
2288 UINT cNames, LCID lcid, DISPID *rgDispId)
2290 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2291 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2294 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2295 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2297 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2298 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2299 pDispParams, pVarResult, pExcepInfo, puArgErr);
2302 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
2304 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2305 FIXME("(%p)\n", This);
2306 return E_NOTIMPL;
2309 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
2311 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2313 WARN("(%p)->(%x)\n", This, fForce);
2315 /* Doing nothing here should be fine for us. */
2316 return S_OK;
2319 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text, IHTMLDOMNode **newTextNode)
2321 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2322 nsIDOMText *nstext;
2323 HTMLDOMNode *node;
2324 nsAString text_str;
2325 nsresult nsres;
2326 HRESULT hres;
2328 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
2330 if(!This->dom_document) {
2331 WARN("NULL dom_document\n");
2332 return E_UNEXPECTED;
2335 nsAString_InitDepend(&text_str, text);
2336 nsres = nsIDOMDocument_CreateTextNode(This->dom_document, &text_str, &nstext);
2337 nsAString_Finish(&text_str);
2338 if(NS_FAILED(nsres)) {
2339 ERR("CreateTextNode failed: %08lx\n", nsres);
2340 return E_FAIL;
2343 hres = HTMLDOMTextNode_Create(This, (nsIDOMNode*)nstext, &node);
2344 nsIDOMText_Release(nstext);
2345 if(FAILED(hres))
2346 return hres;
2348 *newTextNode = &node->IHTMLDOMNode_iface;
2349 return S_OK;
2352 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
2354 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2355 nsIDOMElement *nselem = NULL;
2356 HTMLElement *element;
2357 nsresult nsres;
2358 HRESULT hres;
2360 TRACE("(%p)->(%p)\n", This, p);
2362 if(This->outer_window && This->outer_window->readystate == READYSTATE_UNINITIALIZED) {
2363 *p = NULL;
2364 return S_OK;
2367 if(!This->dom_document) {
2368 WARN("NULL dom_document\n");
2369 return E_UNEXPECTED;
2372 nsres = nsIDOMDocument_GetDocumentElement(This->dom_document, &nselem);
2373 if(NS_FAILED(nsres)) {
2374 ERR("GetDocumentElement failed: %08lx\n", nsres);
2375 return E_FAIL;
2378 if(!nselem) {
2379 *p = NULL;
2380 return S_OK;
2383 hres = get_element(nselem, &element);
2384 nsIDOMElement_Release(nselem);
2385 if(FAILED(hres))
2386 return hres;
2388 *p = &element->IHTMLElement_iface;
2389 return hres;
2392 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2394 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2396 TRACE("(%p)->(%p)\n", This, p);
2398 return elem_unique_id(++This->unique_id, p);
2401 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch* pDisp,
2402 VARIANT_BOOL *pfResult)
2404 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2406 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2408 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2411 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch *pDisp)
2413 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2415 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2417 return detach_event(&This->node.event_target, event, pDisp);
2420 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2422 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2423 FIXME("(%p)->()\n", This);
2424 return E_NOTIMPL;
2427 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2429 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2430 FIXME("(%p)->(%p)\n", This, p);
2431 return E_NOTIMPL;
2434 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2436 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2437 FIXME("(%p)->()\n", This);
2438 return E_NOTIMPL;
2441 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2443 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2444 FIXME("(%p)->(%p)\n", This, p);
2445 return E_NOTIMPL;
2448 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2450 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2451 FIXME("(%p)->()\n", This);
2452 return E_NOTIMPL;
2455 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2457 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2458 FIXME("(%p)->(%p)\n", This, p);
2459 return E_NOTIMPL;
2462 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2464 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2465 FIXME("(%p)->()\n", This);
2466 return E_NOTIMPL;
2469 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2471 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2472 FIXME("(%p)->(%p)\n", This, p);
2473 return E_NOTIMPL;
2476 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2478 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2479 FIXME("(%p)->()\n", This);
2480 return E_NOTIMPL;
2483 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2485 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2486 FIXME("(%p)->(%p)\n", This, p);
2487 return E_NOTIMPL;
2490 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2492 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2493 FIXME("(%p)->()\n", This);
2494 return E_NOTIMPL;
2497 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2499 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2500 FIXME("(%p)->(%p)\n", This, p);
2501 return E_NOTIMPL;
2504 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2506 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2507 FIXME("(%p)->()\n", This);
2508 return E_NOTIMPL;
2511 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2513 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2514 FIXME("(%p)->(%p)\n", This, p);
2515 return E_NOTIMPL;
2518 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2520 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2521 nsAString dir_str;
2522 nsresult nsres;
2524 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2526 if(!This->dom_document) {
2527 FIXME("NULL dom_document\n");
2528 return E_UNEXPECTED;
2531 nsAString_InitDepend(&dir_str, v);
2532 nsres = nsIDOMDocument_SetDir(This->dom_document, &dir_str);
2533 nsAString_Finish(&dir_str);
2534 if(NS_FAILED(nsres)) {
2535 ERR("SetDir failed: %08lx\n", nsres);
2536 return E_FAIL;
2539 return S_OK;
2542 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2544 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2545 nsAString dir_str;
2546 nsresult nsres;
2548 TRACE("(%p)->(%p)\n", This, p);
2550 if(!This->dom_document) {
2551 FIXME("NULL dom_document\n");
2552 return E_UNEXPECTED;
2555 nsAString_Init(&dir_str, NULL);
2556 nsres = nsIDOMDocument_GetDir(This->dom_document, &dir_str);
2557 return return_nsstr(nsres, &dir_str, p);
2560 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2562 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2564 TRACE("(%p)->()\n", This);
2566 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2569 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2571 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2573 TRACE("(%p)->(%p)\n", This, p);
2575 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2578 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2580 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2581 FIXME("(%p)->()\n", This);
2582 return E_NOTIMPL;
2585 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2587 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2588 FIXME("(%p)->(%p)\n", This, p);
2589 return E_NOTIMPL;
2592 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface, IHTMLDocument2 **ppNewDoc)
2594 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2595 nsIDOMDocumentFragment *doc_frag;
2596 HTMLDocumentNode *docnode;
2597 nsresult nsres;
2598 HRESULT hres;
2600 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2602 if(!This->dom_document) {
2603 FIXME("NULL dom_document\n");
2604 return E_NOTIMPL;
2607 nsres = nsIDOMDocument_CreateDocumentFragment(This->dom_document, &doc_frag);
2608 if(NS_FAILED(nsres)) {
2609 ERR("CreateDocumentFragment failed: %08lx\n", nsres);
2610 return E_FAIL;
2613 hres = create_document_fragment((nsIDOMNode*)doc_frag, This, &docnode);
2614 nsIDOMDocumentFragment_Release(doc_frag);
2615 if(FAILED(hres))
2616 return hres;
2618 *ppNewDoc = &docnode->IHTMLDocument2_iface;
2619 return S_OK;
2622 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface, IHTMLDocument2 **p)
2624 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2625 FIXME("(%p)->(%p)\n", This, p);
2626 return E_NOTIMPL;
2629 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL v)
2631 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2632 FIXME("(%p)->(%x)\n", This, v);
2633 return E_NOTIMPL;
2636 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2638 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2639 FIXME("(%p)->(%p)\n", This, p);
2640 return E_NOTIMPL;
2643 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2645 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2646 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2647 return E_NOTIMPL;
2650 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2652 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2653 FIXME("(%p)->(%p)\n", This, p);
2654 return E_NOTIMPL;
2657 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2659 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2661 TRACE("(%p)->(%p)\n", This, p);
2663 return IHTMLDOMNode_get_childNodes(&This->node.IHTMLDOMNode_iface, p);
2666 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL v)
2668 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2669 FIXME("(%p)->()\n", This);
2670 return E_NOTIMPL;
2673 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2675 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2676 FIXME("(%p)->(%p)\n", This, p);
2677 return E_NOTIMPL;
2680 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2682 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2683 FIXME("(%p)->()\n", This);
2684 return E_NOTIMPL;
2687 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2689 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2690 FIXME("(%p)->(%p)\n", This, p);
2691 return E_NOTIMPL;
2694 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2695 IHTMLElementCollection **ppelColl)
2697 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2698 nsIDOMNodeList *node_list;
2699 nsAString selector_str;
2700 WCHAR *selector;
2701 nsresult nsres;
2702 static const WCHAR formatW[] = L"*[id=%s],*[name=%s]";
2704 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2706 if(!This->dom_document) {
2707 /* We should probably return an empty collection. */
2708 FIXME("No dom_document\n");
2709 return E_NOTIMPL;
2712 selector = malloc(2 * SysStringLen(v) * sizeof(WCHAR) + sizeof(formatW));
2713 if(!selector)
2714 return E_OUTOFMEMORY;
2715 swprintf(selector, 2*SysStringLen(v) + ARRAY_SIZE(formatW), formatW, v, v);
2718 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2719 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2720 * types and search should be case insensitive. Those are currently not supported properly.
2722 nsAString_InitDepend(&selector_str, selector);
2723 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &selector_str, &node_list);
2724 nsAString_Finish(&selector_str);
2725 free(selector);
2726 if(NS_FAILED(nsres)) {
2727 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2728 return E_FAIL;
2731 *ppelColl = create_collection_from_nodelist(node_list, This->document_mode);
2732 nsIDOMNodeList_Release(node_list);
2733 return S_OK;
2737 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v, IHTMLElement **pel)
2739 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2740 HTMLElement *elem;
2741 HRESULT hres;
2743 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2745 hres = get_doc_elem_by_id(This, v, &elem);
2746 if(FAILED(hres) || !elem) {
2747 *pel = NULL;
2748 return hres;
2751 *pel = &elem->IHTMLElement_iface;
2752 return S_OK;
2756 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2757 IHTMLElementCollection **pelColl)
2759 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2760 nsIDOMNodeList *nslist;
2761 nsAString id_str;
2762 nsresult nsres;
2764 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2766 if(This->dom_document) {
2767 nsAString_InitDepend(&id_str, v);
2768 nsres = nsIDOMDocument_GetElementsByTagName(This->dom_document, &id_str, &nslist);
2769 nsAString_Finish(&id_str);
2770 if(FAILED(nsres)) {
2771 ERR("GetElementByName failed: %08lx\n", nsres);
2772 return E_FAIL;
2774 }else {
2775 nsIDOMDocumentFragment *docfrag;
2776 nsAString nsstr;
2778 if(v) {
2779 const WCHAR *ptr;
2780 for(ptr=v; *ptr; ptr++) {
2781 if(!iswalnum(*ptr)) {
2782 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2783 return E_NOTIMPL;
2788 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2789 if(NS_FAILED(nsres)) {
2790 ERR("Could not get nsIDOMDocumentFragment iface: %08lx\n", nsres);
2791 return E_UNEXPECTED;
2794 nsAString_InitDepend(&nsstr, v);
2795 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2796 nsAString_Finish(&nsstr);
2797 nsIDOMDocumentFragment_Release(docfrag);
2798 if(NS_FAILED(nsres)) {
2799 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2800 return E_FAIL;
2805 *pelColl = create_collection_from_nodelist(nslist, This->document_mode);
2806 nsIDOMNodeList_Release(nslist);
2808 return S_OK;
2811 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2812 HTMLDocument3_QueryInterface,
2813 HTMLDocument3_AddRef,
2814 HTMLDocument3_Release,
2815 HTMLDocument3_GetTypeInfoCount,
2816 HTMLDocument3_GetTypeInfo,
2817 HTMLDocument3_GetIDsOfNames,
2818 HTMLDocument3_Invoke,
2819 HTMLDocument3_releaseCapture,
2820 HTMLDocument3_recalc,
2821 HTMLDocument3_createTextNode,
2822 HTMLDocument3_get_documentElement,
2823 HTMLDocument3_get_uniqueID,
2824 HTMLDocument3_attachEvent,
2825 HTMLDocument3_detachEvent,
2826 HTMLDocument3_put_onrowsdelete,
2827 HTMLDocument3_get_onrowsdelete,
2828 HTMLDocument3_put_onrowsinserted,
2829 HTMLDocument3_get_onrowsinserted,
2830 HTMLDocument3_put_oncellchange,
2831 HTMLDocument3_get_oncellchange,
2832 HTMLDocument3_put_ondatasetchanged,
2833 HTMLDocument3_get_ondatasetchanged,
2834 HTMLDocument3_put_ondataavailable,
2835 HTMLDocument3_get_ondataavailable,
2836 HTMLDocument3_put_ondatasetcomplete,
2837 HTMLDocument3_get_ondatasetcomplete,
2838 HTMLDocument3_put_onpropertychange,
2839 HTMLDocument3_get_onpropertychange,
2840 HTMLDocument3_put_dir,
2841 HTMLDocument3_get_dir,
2842 HTMLDocument3_put_oncontextmenu,
2843 HTMLDocument3_get_oncontextmenu,
2844 HTMLDocument3_put_onstop,
2845 HTMLDocument3_get_onstop,
2846 HTMLDocument3_createDocumentFragment,
2847 HTMLDocument3_get_parentDocument,
2848 HTMLDocument3_put_enableDownload,
2849 HTMLDocument3_get_enableDownload,
2850 HTMLDocument3_put_baseUrl,
2851 HTMLDocument3_get_baseUrl,
2852 HTMLDocument3_get_childNodes,
2853 HTMLDocument3_put_inheritStyleSheets,
2854 HTMLDocument3_get_inheritStyleSheets,
2855 HTMLDocument3_put_onbeforeeditfocus,
2856 HTMLDocument3_get_onbeforeeditfocus,
2857 HTMLDocument3_getElementsByName,
2858 HTMLDocument3_getElementById,
2859 HTMLDocument3_getElementsByTagName
2862 static inline HTMLDocumentNode *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2864 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument4_iface);
2867 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface, REFIID riid, void **ppv)
2869 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2870 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2873 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2875 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2876 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2879 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2881 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2882 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2885 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2887 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2888 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2891 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo, LCID lcid,
2892 ITypeInfo **ppTInfo)
2894 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2895 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2898 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid, LPOLESTR *rgszNames,
2899 UINT cNames, LCID lcid, DISPID *rgDispId)
2901 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2902 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2905 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2906 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2908 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2909 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2910 pDispParams, pVarResult, pExcepInfo, puArgErr);
2913 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2915 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2916 nsIDOMHTMLElement *nsbody;
2917 nsresult nsres;
2919 TRACE("(%p)->()\n", This);
2921 if(!This->html_document) {
2922 FIXME("Not implemented for XML document\n");
2923 return E_NOTIMPL;
2926 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, &nsbody);
2927 if(NS_FAILED(nsres) || !nsbody) {
2928 ERR("GetBody failed: %08lx\n", nsres);
2929 return E_FAIL;
2932 nsres = nsIDOMHTMLElement_Focus(nsbody);
2933 nsIDOMHTMLElement_Release(nsbody);
2934 if(NS_FAILED(nsres)) {
2935 ERR("Focus failed: %08lx\n", nsres);
2936 return E_FAIL;
2939 return S_OK;
2942 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2944 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2945 cpp_bool has_focus;
2946 nsresult nsres;
2948 TRACE("(%p)->(%p)\n", This, pfFocus);
2950 if(!This->dom_document) {
2951 FIXME("Unimplemented for fragments.\n");
2952 return E_NOTIMPL;
2955 nsres = nsIDOMDocument_HasFocus(This->dom_document, &has_focus);
2956 assert(nsres == NS_OK);
2958 *pfFocus = variant_bool(has_focus);
2959 return S_OK;
2962 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2964 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2966 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2968 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2971 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2973 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2975 TRACE("(%p)->(%p)\n", This, p);
2977 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2980 static HRESULT WINAPI HTMLDocument4_get_namespaces(IHTMLDocument4 *iface, IDispatch **p)
2982 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2984 TRACE("(%p)->(%p)\n", This, p);
2986 if(!This->namespaces) {
2987 HRESULT hres;
2989 hres = create_namespace_collection(dispex_compat_mode(&This->node.event_target.dispex),
2990 &This->namespaces);
2991 if(FAILED(hres))
2992 return hres;
2995 IHTMLNamespaceCollection_AddRef(This->namespaces);
2996 *p = (IDispatch*)This->namespaces;
2997 return S_OK;
3000 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
3001 BSTR bstrOptions, IHTMLDocument2 **newDoc)
3003 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3004 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
3005 return E_NOTIMPL;
3008 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
3010 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3011 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3012 return E_NOTIMPL;
3015 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
3017 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3018 FIXME("(%p)->(%p)\n", This, p);
3019 return E_NOTIMPL;
3022 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
3023 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
3025 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3027 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
3029 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
3030 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
3031 return E_NOTIMPL;
3034 return create_event_obj(dispex_compat_mode(&This->node.event_target.dispex), ppEventObj);
3037 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
3038 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
3040 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3042 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
3044 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCanceled);
3047 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
3048 IHTMLRenderStyle **ppIHTMLRenderStyle)
3050 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3051 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
3052 return E_NOTIMPL;
3055 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
3057 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3058 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3059 return E_NOTIMPL;
3062 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
3064 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3065 FIXME("(%p)->(%p)\n", This, p);
3066 return E_NOTIMPL;
3069 static HRESULT WINAPI HTMLDocument4_get_URLUnencoded(IHTMLDocument4 *iface, BSTR *p)
3071 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3072 FIXME("(%p)->(%p)\n", This, p);
3073 return E_NOTIMPL;
3076 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
3077 HTMLDocument4_QueryInterface,
3078 HTMLDocument4_AddRef,
3079 HTMLDocument4_Release,
3080 HTMLDocument4_GetTypeInfoCount,
3081 HTMLDocument4_GetTypeInfo,
3082 HTMLDocument4_GetIDsOfNames,
3083 HTMLDocument4_Invoke,
3084 HTMLDocument4_focus,
3085 HTMLDocument4_hasFocus,
3086 HTMLDocument4_put_onselectionchange,
3087 HTMLDocument4_get_onselectionchange,
3088 HTMLDocument4_get_namespaces,
3089 HTMLDocument4_createDocumentFromUrl,
3090 HTMLDocument4_put_media,
3091 HTMLDocument4_get_media,
3092 HTMLDocument4_createEventObject,
3093 HTMLDocument4_fireEvent,
3094 HTMLDocument4_createRenderStyle,
3095 HTMLDocument4_put_oncontrolselect,
3096 HTMLDocument4_get_oncontrolselect,
3097 HTMLDocument4_get_URLUnencoded
3100 static inline HTMLDocumentNode *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
3102 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument5_iface);
3105 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface, REFIID riid, void **ppv)
3107 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3108 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3111 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
3113 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3114 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3117 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
3119 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3120 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3123 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
3125 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3126 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3129 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo, LCID lcid,
3130 ITypeInfo **ppTInfo)
3132 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3133 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3136 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid, LPOLESTR *rgszNames,
3137 UINT cNames, LCID lcid, DISPID *rgDispId)
3139 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3140 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3143 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3144 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3146 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3147 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3148 pDispParams, pVarResult, pExcepInfo, puArgErr);
3151 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
3153 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3155 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3157 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
3160 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
3162 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3164 TRACE("(%p)->(%p)\n", This, p);
3166 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
3169 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
3171 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3172 nsIDOMDocumentType *nsdoctype;
3173 HTMLDOMNode *doctype_node;
3174 nsresult nsres;
3175 HRESULT hres;
3177 TRACE("(%p)->(%p)\n", This, p);
3179 if(dispex_compat_mode(&This->node.event_target.dispex) < COMPAT_MODE_IE9) {
3180 *p = NULL;
3181 return S_OK;
3184 nsres = nsIDOMDocument_GetDoctype(This->dom_document, &nsdoctype);
3185 if(NS_FAILED(nsres))
3186 return map_nsresult(nsres);
3187 if(!nsdoctype) {
3188 *p = NULL;
3189 return S_OK;
3192 hres = get_node((nsIDOMNode*)nsdoctype, TRUE, &doctype_node);
3193 nsIDOMDocumentType_Release(nsdoctype);
3195 if(SUCCEEDED(hres))
3196 *p = &doctype_node->IHTMLDOMNode_iface;
3197 return hres;
3200 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
3202 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3204 TRACE("(%p)->(%p)\n", This, p);
3206 if(!This->dom_implementation) {
3207 HRESULT hres;
3209 hres = create_dom_implementation(This, &This->dom_implementation);
3210 if(FAILED(hres))
3211 return hres;
3214 IHTMLDOMImplementation_AddRef(This->dom_implementation);
3215 *p = This->dom_implementation;
3216 return S_OK;
3219 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
3220 IHTMLDOMAttribute **ppattribute)
3222 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3223 HTMLDOMAttribute *attr;
3224 HRESULT hres;
3226 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
3228 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, dispex_compat_mode(&This->node.event_target.dispex), &attr);
3229 if(FAILED(hres))
3230 return hres;
3232 *ppattribute = &attr->IHTMLDOMAttribute_iface;
3233 return S_OK;
3236 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
3237 IHTMLDOMNode **ppRetNode)
3239 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3240 nsIDOMComment *nscomment;
3241 HTMLElement *elem;
3242 nsAString str;
3243 nsresult nsres;
3244 HRESULT hres;
3246 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
3248 if(!This->dom_document) {
3249 WARN("NULL dom_document\n");
3250 return E_UNEXPECTED;
3253 nsAString_InitDepend(&str, bstrdata);
3254 nsres = nsIDOMDocument_CreateComment(This->dom_document, &str, &nscomment);
3255 nsAString_Finish(&str);
3256 if(NS_FAILED(nsres)) {
3257 ERR("CreateTextNode failed: %08lx\n", nsres);
3258 return E_FAIL;
3261 hres = HTMLCommentElement_Create(This, (nsIDOMNode*)nscomment, &elem);
3262 nsIDOMComment_Release(nscomment);
3263 if(FAILED(hres))
3264 return hres;
3266 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
3267 return S_OK;
3270 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
3272 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3274 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3276 return set_doc_event(This, EVENTID_FOCUSIN, &v);
3279 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
3281 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3283 TRACE("(%p)->(%p)\n", This, p);
3285 return get_doc_event(This, EVENTID_FOCUSIN, p);
3288 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
3290 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3292 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3294 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
3297 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
3299 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3301 TRACE("(%p)->(%p)\n", This, p);
3303 return get_doc_event(This, EVENTID_FOCUSOUT, p);
3306 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
3308 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3309 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3310 return E_NOTIMPL;
3313 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
3315 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3316 FIXME("(%p)->(%p)\n", This, p);
3317 return E_NOTIMPL;
3320 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
3322 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3323 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3324 return E_NOTIMPL;
3327 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
3329 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3330 FIXME("(%p)->(%p)\n", This, p);
3331 return E_NOTIMPL;
3334 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
3336 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3337 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3338 return E_NOTIMPL;
3341 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
3343 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3344 FIXME("(%p)->(%p)\n", This, p);
3345 return E_NOTIMPL;
3348 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
3350 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3351 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3352 return E_NOTIMPL;
3355 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
3357 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3358 FIXME("(%p)->(%p)\n", This, p);
3359 return E_NOTIMPL;
3362 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
3364 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3366 TRACE("(%p)->(%p)\n", This, p);
3368 *p = SysAllocString(This->document_mode <= COMPAT_MODE_IE5 ? L"BackCompat" : L"CSS1Compat");
3369 return *p ? S_OK : E_OUTOFMEMORY;
3372 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
3373 HTMLDocument5_QueryInterface,
3374 HTMLDocument5_AddRef,
3375 HTMLDocument5_Release,
3376 HTMLDocument5_GetTypeInfoCount,
3377 HTMLDocument5_GetTypeInfo,
3378 HTMLDocument5_GetIDsOfNames,
3379 HTMLDocument5_Invoke,
3380 HTMLDocument5_put_onmousewheel,
3381 HTMLDocument5_get_onmousewheel,
3382 HTMLDocument5_get_doctype,
3383 HTMLDocument5_get_implementation,
3384 HTMLDocument5_createAttribute,
3385 HTMLDocument5_createComment,
3386 HTMLDocument5_put_onfocusin,
3387 HTMLDocument5_get_onfocusin,
3388 HTMLDocument5_put_onfocusout,
3389 HTMLDocument5_get_onfocusout,
3390 HTMLDocument5_put_onactivate,
3391 HTMLDocument5_get_onactivate,
3392 HTMLDocument5_put_ondeactivate,
3393 HTMLDocument5_get_ondeactivate,
3394 HTMLDocument5_put_onbeforeactivate,
3395 HTMLDocument5_get_onbeforeactivate,
3396 HTMLDocument5_put_onbeforedeactivate,
3397 HTMLDocument5_get_onbeforedeactivate,
3398 HTMLDocument5_get_compatMode
3401 static inline HTMLDocumentNode *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3403 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument6_iface);
3406 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface, REFIID riid, void **ppv)
3408 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3409 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3412 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3414 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3415 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3418 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3420 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3421 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3424 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3426 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3427 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3430 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo, LCID lcid,
3431 ITypeInfo **ppTInfo)
3433 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3434 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3437 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid, LPOLESTR *rgszNames,
3438 UINT cNames, LCID lcid, DISPID *rgDispId)
3440 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3441 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3444 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3445 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3447 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3448 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3449 pDispParams, pVarResult, pExcepInfo, puArgErr);
3452 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3453 IHTMLDocumentCompatibleInfoCollection **p)
3455 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3456 FIXME("(%p)->(%p)\n", This, p);
3457 return E_NOTIMPL;
3460 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3462 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3464 TRACE("(%p)->(%p)\n", This, p);
3466 V_VT(p) = VT_R4;
3467 V_R4(p) = compat_mode_info[This->document_mode].document_mode;
3468 return S_OK;
3471 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3472 VARIANT *p)
3474 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3476 TRACE("(%p)->(%p)\n", This, p);
3478 return get_doc_event(This, EVENTID_STORAGE, p);
3481 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3483 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3485 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3487 return set_doc_event(This, EVENTID_STORAGE, &v);
3490 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3491 VARIANT *p)
3493 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3495 TRACE("(%p)->(%p)\n", This, p);
3497 return get_doc_event(This, EVENTID_STORAGECOMMIT, p);
3500 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3502 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3504 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3506 return set_doc_event(This, EVENTID_STORAGECOMMIT, &v);
3509 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3510 BSTR bstrId, IHTMLElement2 **p)
3512 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3513 nsIDOMElement *nselem;
3514 HTMLElement *elem;
3515 nsAString nsstr;
3516 nsresult nsres;
3517 HRESULT hres;
3519 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3522 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3523 * not search for name attributes, so we may simply let Gecko do the right thing.
3526 if(!This->dom_document) {
3527 FIXME("Not a document\n");
3528 return E_FAIL;
3531 nsAString_InitDepend(&nsstr, bstrId);
3532 nsres = nsIDOMDocument_GetElementById(This->dom_document, &nsstr, &nselem);
3533 nsAString_Finish(&nsstr);
3534 if(NS_FAILED(nsres)) {
3535 ERR("GetElementById failed: %08lx\n", nsres);
3536 return E_FAIL;
3539 if(!nselem) {
3540 *p = NULL;
3541 return S_OK;
3544 hres = get_element(nselem, &elem);
3545 nsIDOMElement_Release(nselem);
3546 if(FAILED(hres))
3547 return hres;
3549 *p = &elem->IHTMLElement2_iface;
3550 return S_OK;
3553 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3555 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3556 FIXME("(%p)->()\n", This);
3557 return E_NOTIMPL;
3560 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3561 HTMLDocument6_QueryInterface,
3562 HTMLDocument6_AddRef,
3563 HTMLDocument6_Release,
3564 HTMLDocument6_GetTypeInfoCount,
3565 HTMLDocument6_GetTypeInfo,
3566 HTMLDocument6_GetIDsOfNames,
3567 HTMLDocument6_Invoke,
3568 HTMLDocument6_get_compatible,
3569 HTMLDocument6_get_documentMode,
3570 HTMLDocument6_put_onstorage,
3571 HTMLDocument6_get_onstorage,
3572 HTMLDocument6_put_onstoragecommit,
3573 HTMLDocument6_get_onstoragecommit,
3574 HTMLDocument6_getElementById,
3575 HTMLDocument6_updateSettings
3578 static inline HTMLDocumentNode *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3580 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument7_iface);
3583 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3585 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3586 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3589 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3591 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3592 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3595 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3597 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3598 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3601 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3603 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3604 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3607 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo, LCID lcid,
3608 ITypeInfo **ppTInfo)
3610 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3611 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3614 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid, LPOLESTR *rgszNames,
3615 UINT cNames, LCID lcid, DISPID *rgDispId)
3617 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3618 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3621 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3622 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3624 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3625 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3626 pDispParams, pVarResult, pExcepInfo, puArgErr);
3629 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3631 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3633 TRACE("(%p)->(%p)\n", This, p);
3635 if(This->window && This->window->base.outer_window) {
3636 *p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
3637 IHTMLWindow2_AddRef(*p);
3638 }else {
3639 *p = NULL;
3641 return S_OK;
3644 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3646 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3647 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3648 return E_NOTIMPL;
3651 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3653 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3654 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3655 return E_NOTIMPL;
3658 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3659 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3661 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3662 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3663 return E_NOTIMPL;
3666 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3668 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3669 nsIDOMElement *dom_element;
3670 HTMLElement *element;
3671 nsAString ns, tag;
3672 nsresult nsres;
3673 HRESULT hres;
3675 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3677 if(!This->dom_document) {
3678 FIXME("NULL dom_document\n");
3679 return E_FAIL;
3682 if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
3683 FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
3685 nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
3686 nsAString_InitDepend(&tag, bstrTag);
3687 nsres = nsIDOMDocument_CreateElementNS(This->dom_document, &ns, &tag, &dom_element);
3688 nsAString_Finish(&ns);
3689 nsAString_Finish(&tag);
3690 if(NS_FAILED(nsres)) {
3691 WARN("CreateElementNS failed: %08lx\n", nsres);
3692 return map_nsresult(nsres);
3695 hres = HTMLElement_Create(This, (nsIDOMNode*)dom_element, FALSE, &element);
3696 nsIDOMElement_Release(dom_element);
3697 if(FAILED(hres))
3698 return hres;
3700 *newElem = &element->IHTMLElement_iface;
3701 return S_OK;
3704 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3705 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3707 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3708 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3709 return E_NOTIMPL;
3712 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3714 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3715 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3716 return E_NOTIMPL;
3719 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3721 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3723 TRACE("(%p)->(%p)\n", This, p);
3725 return get_doc_event(This, EVENTID_MSTHUMBNAILCLICK, p);
3728 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3730 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3731 nsAString charset_str;
3732 nsresult nsres;
3734 TRACE("(%p)->(%p)\n", This, p);
3736 if(!This->dom_document) {
3737 FIXME("NULL dom_document\n");
3738 return E_FAIL;
3741 nsAString_Init(&charset_str, NULL);
3742 nsres = nsIDOMDocument_GetCharacterSet(This->dom_document, &charset_str);
3743 return return_nsstr(nsres, &charset_str, p);
3746 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3748 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3750 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3752 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3755 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3757 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3759 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3761 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3764 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3766 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3767 nsIDOMNodeList *nslist;
3768 nsAString nsstr;
3769 nsresult nsres;
3771 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3773 if(!This->dom_document) {
3774 FIXME("NULL dom_document not supported\n");
3775 return E_NOTIMPL;
3778 nsAString_InitDepend(&nsstr, v);
3779 nsres = nsIDOMDocument_GetElementsByClassName(This->dom_document, &nsstr, &nslist);
3780 nsAString_Finish(&nsstr);
3781 if(FAILED(nsres)) {
3782 ERR("GetElementByClassName failed: %08lx\n", nsres);
3783 return E_FAIL;
3787 *pel = create_collection_from_nodelist(nslist, This->document_mode);
3788 nsIDOMNodeList_Release(nslist);
3789 return S_OK;
3792 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3793 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3795 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3796 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3797 return E_NOTIMPL;
3800 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3802 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3803 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3804 return E_NOTIMPL;
3807 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3809 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3810 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3811 return E_NOTIMPL;
3814 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3816 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3817 FIXME("(%p)->(%p)\n", This, p);
3818 return E_NOTIMPL;
3821 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3823 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3825 TRACE("(%p)->(%p)\n", This, p);
3827 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3830 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3832 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3833 FIXME("(%p)->(%p)\n", This, p);
3834 return E_NOTIMPL;
3837 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3839 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3840 FIXME("(%p)->(%p)\n", This, p);
3841 return E_NOTIMPL;
3844 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3846 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3847 FIXME("(%p)->(%x)\n", This, v);
3848 return E_NOTIMPL;
3851 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3853 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3854 FIXME("(%p)->(%p)\n", This, p);
3855 return E_NOTIMPL;
3858 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3860 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3861 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3862 return E_NOTIMPL;
3865 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3867 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3868 FIXME("(%p)->(%p)\n", This, p);
3869 return E_NOTIMPL;
3872 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3874 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3875 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3876 return E_NOTIMPL;
3879 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3881 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3883 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3885 return set_doc_event(This, EVENTID_ABORT, &v);
3888 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3890 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3892 TRACE("(%p)->(%p)\n", This, p);
3894 return get_doc_event(This, EVENTID_ABORT, p);
3897 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3899 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3901 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3903 return set_doc_event(This, EVENTID_BLUR, &v);
3906 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3908 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3910 TRACE("(%p)->(%p)\n", This, p);
3912 return get_doc_event(This, EVENTID_BLUR, p);
3915 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3917 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3918 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3919 return E_NOTIMPL;
3922 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3924 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3925 FIXME("(%p)->(%p)\n", This, p);
3926 return E_NOTIMPL;
3929 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3931 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3932 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3933 return E_NOTIMPL;
3936 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3938 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3939 FIXME("(%p)->(%p)\n", This, p);
3940 return E_NOTIMPL;
3943 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3945 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3947 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3949 return set_doc_event(This, EVENTID_CHANGE, &v);
3952 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3954 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3956 TRACE("(%p)->(%p)\n", This, p);
3958 return get_doc_event(This, EVENTID_CHANGE, p);
3961 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3963 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3965 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3967 return set_doc_event(This, EVENTID_DRAG, &v);
3970 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3972 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3974 TRACE("(%p)->(%p)\n", This, p);
3976 return get_doc_event(This, EVENTID_DRAG, p);
3979 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3981 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3982 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3983 return E_NOTIMPL;
3986 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3988 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3989 FIXME("(%p)->(%p)\n", This, p);
3990 return E_NOTIMPL;
3993 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3995 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3996 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3997 return E_NOTIMPL;
4000 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
4002 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4003 FIXME("(%p)->(%p)\n", This, p);
4004 return E_NOTIMPL;
4007 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
4009 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4010 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4011 return E_NOTIMPL;
4014 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
4016 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4017 FIXME("(%p)->(%p)\n", This, p);
4018 return E_NOTIMPL;
4021 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
4023 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4024 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4025 return E_NOTIMPL;
4028 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
4030 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4031 FIXME("(%p)->(%p)\n", This, p);
4032 return E_NOTIMPL;
4035 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
4037 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4038 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4039 return E_NOTIMPL;
4042 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
4044 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4045 FIXME("(%p)->(%p)\n", This, p);
4046 return E_NOTIMPL;
4049 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
4051 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4052 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4053 return E_NOTIMPL;
4056 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
4058 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4059 FIXME("(%p)->(%p)\n", This, p);
4060 return E_NOTIMPL;
4063 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
4065 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4066 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4067 return E_NOTIMPL;
4070 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
4072 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4073 FIXME("(%p)->(%p)\n", This, p);
4074 return E_NOTIMPL;
4077 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
4079 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4080 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4081 return E_NOTIMPL;
4084 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
4086 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4087 FIXME("(%p)->(%p)\n", This, p);
4088 return E_NOTIMPL;
4091 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
4093 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4095 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4097 return set_doc_event(This, EVENTID_ERROR, &v);
4100 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
4102 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4104 TRACE("(%p)->(%p)\n", This, p);
4106 return get_doc_event(This, EVENTID_ERROR, p);
4109 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
4111 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4113 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4115 return set_doc_event(This, EVENTID_FOCUS, &v);
4118 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
4120 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4122 TRACE("(%p)->(%p)\n", This, p);
4124 return get_doc_event(This, EVENTID_FOCUS, p);
4127 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
4129 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4131 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4133 return set_doc_event(This, EVENTID_INPUT, &v);
4136 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
4138 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4140 TRACE("(%p)->(%p)\n", This, p);
4142 return get_doc_event(This, EVENTID_INPUT, p);
4145 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
4147 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4149 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4151 return set_doc_event(This, EVENTID_LOAD, &v);
4154 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
4156 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4158 TRACE("(%p)->(%p)\n", This, p);
4160 return get_doc_event(This, EVENTID_LOAD, p);
4163 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
4165 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4166 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4167 return E_NOTIMPL;
4170 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
4172 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4173 FIXME("(%p)->(%p)\n", This, p);
4174 return E_NOTIMPL;
4177 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
4179 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4180 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4181 return E_NOTIMPL;
4184 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
4186 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4187 FIXME("(%p)->(%p)\n", This, p);
4188 return E_NOTIMPL;
4191 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
4193 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4194 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4195 return E_NOTIMPL;
4198 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
4200 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4201 FIXME("(%p)->(%p)\n", This, p);
4202 return E_NOTIMPL;
4205 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
4207 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4208 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4209 return E_NOTIMPL;
4212 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
4214 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4215 FIXME("(%p)->(%p)\n", This, p);
4216 return E_NOTIMPL;
4219 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
4221 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4222 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4223 return E_NOTIMPL;
4226 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
4228 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4229 FIXME("(%p)->(%p)\n", This, p);
4230 return E_NOTIMPL;
4233 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
4235 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4236 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4237 return E_NOTIMPL;
4240 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
4242 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4243 FIXME("(%p)->(%p)\n", This, p);
4244 return E_NOTIMPL;
4247 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
4249 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4250 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4251 return E_NOTIMPL;
4254 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
4256 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4257 FIXME("(%p)->(%p)\n", This, p);
4258 return E_NOTIMPL;
4261 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
4263 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4264 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4265 return E_NOTIMPL;
4268 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
4270 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4271 FIXME("(%p)->(%p)\n", This, p);
4272 return E_NOTIMPL;
4275 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
4277 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4278 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4279 return E_NOTIMPL;
4282 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
4284 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4285 FIXME("(%p)->(%p)\n", This, p);
4286 return E_NOTIMPL;
4289 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
4291 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4293 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4295 return set_doc_event(This, EVENTID_SCROLL, &v);
4298 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
4300 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4302 TRACE("(%p)->(%p)\n", This, p);
4304 return get_doc_event(This, EVENTID_SCROLL, p);
4307 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
4309 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4310 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4311 return E_NOTIMPL;
4314 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
4316 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4317 FIXME("(%p)->(%p)\n", This, p);
4318 return E_NOTIMPL;
4321 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
4323 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4324 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4325 return E_NOTIMPL;
4328 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
4330 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4331 FIXME("(%p)->(%p)\n", This, p);
4332 return E_NOTIMPL;
4335 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
4337 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4338 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4339 return E_NOTIMPL;
4342 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
4344 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4345 FIXME("(%p)->(%p)\n", This, p);
4346 return E_NOTIMPL;
4349 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
4351 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4352 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4353 return E_NOTIMPL;
4356 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
4358 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4359 FIXME("(%p)->(%p)\n", This, p);
4360 return E_NOTIMPL;
4363 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
4365 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4367 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4369 return set_doc_event(This, EVENTID_SUBMIT, &v);
4372 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
4374 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4376 TRACE("(%p)->(%p)\n", This, p);
4378 return get_doc_event(This, EVENTID_SUBMIT, p);
4381 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
4383 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4384 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4385 return E_NOTIMPL;
4388 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
4390 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4391 FIXME("(%p)->(%p)\n", This, p);
4392 return E_NOTIMPL;
4395 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
4397 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4398 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4399 return E_NOTIMPL;
4402 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
4404 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4405 FIXME("(%p)->(%p)\n", This, p);
4406 return E_NOTIMPL;
4409 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
4411 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4412 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4413 return E_NOTIMPL;
4416 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4418 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4419 FIXME("(%p)->(%p)\n", This, p);
4420 return E_NOTIMPL;
4423 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4425 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4426 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4427 return E_NOTIMPL;
4430 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4432 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4433 FIXME("(%p)->(%p)\n", This, p);
4434 return E_NOTIMPL;
4437 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4439 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4440 FIXME("(%p)\n", This);
4441 return E_NOTIMPL;
4444 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4445 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4447 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4448 nsIDOMNode *nsnode = NULL;
4449 HTMLDOMNode *node;
4450 nsresult nsres;
4451 HRESULT hres;
4453 TRACE("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4455 if(!This->dom_document) {
4456 WARN("NULL dom_document\n");
4457 return E_UNEXPECTED;
4460 if(!(node = unsafe_impl_from_IHTMLDOMNode(pNodeSource))) {
4461 ERR("not our node\n");
4462 return E_FAIL;
4465 nsres = nsIDOMDocument_ImportNode(This->dom_document, node->nsnode, !!fDeep, 1, &nsnode);
4466 if(NS_FAILED(nsres)) {
4467 ERR("ImportNode failed: %08lx\n", nsres);
4468 return map_nsresult(nsres);
4471 if(!nsnode) {
4472 *ppNodeDest = NULL;
4473 return S_OK;
4476 hres = get_node(nsnode, TRUE, &node);
4477 nsIDOMNode_Release(nsnode);
4478 if(FAILED(hres))
4479 return hres;
4481 *ppNodeDest = &node->IHTMLDOMNode3_iface;
4482 return hres;
4485 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4487 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4489 TRACE("(%p)->(%p)\n", This, p);
4491 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4494 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4496 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4497 FIXME("(%p)->(%p)\n", This, v);
4498 return E_NOTIMPL;
4501 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4503 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4505 TRACE("(%p)->(%p)\n", This, p);
4507 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4510 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4512 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4513 nsIDOMHTMLHeadElement *nshead;
4514 nsIDOMElement *nselem;
4515 HTMLElement *elem;
4516 nsresult nsres;
4517 HRESULT hres;
4519 TRACE("(%p)->(%p)\n", This, p);
4521 if(!This->dom_document) {
4522 FIXME("No document\n");
4523 return E_FAIL;
4526 if(!This->html_document) {
4527 FIXME("Not implemented for XML document\n");
4528 return E_NOTIMPL;
4531 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &nshead);
4532 assert(nsres == NS_OK);
4534 if(!nshead) {
4535 *p = NULL;
4536 return S_OK;
4539 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4540 nsIDOMHTMLHeadElement_Release(nshead);
4541 assert(nsres == NS_OK);
4543 hres = get_element(nselem, &elem);
4544 nsIDOMElement_Release(nselem);
4545 if(FAILED(hres))
4546 return hres;
4548 *p = &elem->IHTMLElement_iface;
4549 return S_OK;
4552 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4553 HTMLDocument7_QueryInterface,
4554 HTMLDocument7_AddRef,
4555 HTMLDocument7_Release,
4556 HTMLDocument7_GetTypeInfoCount,
4557 HTMLDocument7_GetTypeInfo,
4558 HTMLDocument7_GetIDsOfNames,
4559 HTMLDocument7_Invoke,
4560 HTMLDocument7_get_defaultView,
4561 HTMLDocument7_createCDATASection,
4562 HTMLDocument7_getSelection,
4563 HTMLDocument7_getElementsByTagNameNS,
4564 HTMLDocument7_createElementNS,
4565 HTMLDocument7_createAttributeNS,
4566 HTMLDocument7_put_onmsthumbnailclick,
4567 HTMLDocument7_get_onmsthumbnailclick,
4568 HTMLDocument7_get_characterSet,
4569 HTMLDocument7_createElement,
4570 HTMLDocument7_createAttribute,
4571 HTMLDocument7_getElementsByClassName,
4572 HTMLDocument7_createProcessingInstruction,
4573 HTMLDocument7_adoptNode,
4574 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4575 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4576 HTMLDocument7_get_all,
4577 HTMLDocument7_get_inputEncoding,
4578 HTMLDocument7_get_xmlEncoding,
4579 HTMLDocument7_put_xmlStandalone,
4580 HTMLDocument7_get_xmlStandalone,
4581 HTMLDocument7_put_xmlVersion,
4582 HTMLDocument7_get_xmlVersion,
4583 HTMLDocument7_hasAttributes,
4584 HTMLDocument7_put_onabort,
4585 HTMLDocument7_get_onabort,
4586 HTMLDocument7_put_onblur,
4587 HTMLDocument7_get_onblur,
4588 HTMLDocument7_put_oncanplay,
4589 HTMLDocument7_get_oncanplay,
4590 HTMLDocument7_put_oncanplaythrough,
4591 HTMLDocument7_get_oncanplaythrough,
4592 HTMLDocument7_put_onchange,
4593 HTMLDocument7_get_onchange,
4594 HTMLDocument7_put_ondrag,
4595 HTMLDocument7_get_ondrag,
4596 HTMLDocument7_put_ondragend,
4597 HTMLDocument7_get_ondragend,
4598 HTMLDocument7_put_ondragenter,
4599 HTMLDocument7_get_ondragenter,
4600 HTMLDocument7_put_ondragleave,
4601 HTMLDocument7_get_ondragleave,
4602 HTMLDocument7_put_ondragover,
4603 HTMLDocument7_get_ondragover,
4604 HTMLDocument7_put_ondrop,
4605 HTMLDocument7_get_ondrop,
4606 HTMLDocument7_put_ondurationchange,
4607 HTMLDocument7_get_ondurationchange,
4608 HTMLDocument7_put_onemptied,
4609 HTMLDocument7_get_onemptied,
4610 HTMLDocument7_put_onended,
4611 HTMLDocument7_get_onended,
4612 HTMLDocument7_put_onerror,
4613 HTMLDocument7_get_onerror,
4614 HTMLDocument7_put_onfocus,
4615 HTMLDocument7_get_onfocus,
4616 HTMLDocument7_put_oninput,
4617 HTMLDocument7_get_oninput,
4618 HTMLDocument7_put_onload,
4619 HTMLDocument7_get_onload,
4620 HTMLDocument7_put_onloadeddata,
4621 HTMLDocument7_get_onloadeddata,
4622 HTMLDocument7_put_onloadedmetadata,
4623 HTMLDocument7_get_onloadedmetadata,
4624 HTMLDocument7_put_onloadstart,
4625 HTMLDocument7_get_onloadstart,
4626 HTMLDocument7_put_onpause,
4627 HTMLDocument7_get_onpause,
4628 HTMLDocument7_put_onplay,
4629 HTMLDocument7_get_onplay,
4630 HTMLDocument7_put_onplaying,
4631 HTMLDocument7_get_onplaying,
4632 HTMLDocument7_put_onprogress,
4633 HTMLDocument7_get_onprogress,
4634 HTMLDocument7_put_onratechange,
4635 HTMLDocument7_get_onratechange,
4636 HTMLDocument7_put_onreset,
4637 HTMLDocument7_get_onreset,
4638 HTMLDocument7_put_onscroll,
4639 HTMLDocument7_get_onscroll,
4640 HTMLDocument7_put_onseekend,
4641 HTMLDocument7_get_onseekend,
4642 HTMLDocument7_put_onseeking,
4643 HTMLDocument7_get_onseeking,
4644 HTMLDocument7_put_onselect,
4645 HTMLDocument7_get_onselect,
4646 HTMLDocument7_put_onstalled,
4647 HTMLDocument7_get_onstalled,
4648 HTMLDocument7_put_onsubmit,
4649 HTMLDocument7_get_onsubmit,
4650 HTMLDocument7_put_onsuspend,
4651 HTMLDocument7_get_onsuspend,
4652 HTMLDocument7_put_ontimeupdate,
4653 HTMLDocument7_get_ontimeupdate,
4654 HTMLDocument7_put_onvolumechange,
4655 HTMLDocument7_get_onvolumechange,
4656 HTMLDocument7_put_onwaiting,
4657 HTMLDocument7_get_onwaiting,
4658 HTMLDocument7_normalize,
4659 HTMLDocument7_importNode,
4660 HTMLDocument7_get_parentWindow,
4661 HTMLDocument7_put_body,
4662 HTMLDocument7_get_body,
4663 HTMLDocument7_get_head
4666 static inline HTMLDocumentNode *impl_from_IDocumentSelector(IDocumentSelector *iface)
4668 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentSelector_iface);
4671 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4673 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4674 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4677 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4679 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4680 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4683 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4685 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4686 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4689 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4691 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4692 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4695 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4696 LCID lcid, ITypeInfo **ppTInfo)
4698 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4699 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4702 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4703 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4705 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4706 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4707 rgDispId);
4710 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4711 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4713 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4714 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4715 pDispParams, pVarResult, pExcepInfo, puArgErr);
4718 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4720 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4721 nsIDOMElement *nselem;
4722 HTMLElement *elem;
4723 nsAString nsstr;
4724 nsresult nsres;
4725 HRESULT hres;
4727 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4729 nsAString_InitDepend(&nsstr, v);
4730 nsres = nsIDOMDocument_QuerySelector(This->dom_document, &nsstr, &nselem);
4731 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 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &nsstr, &node_list);
4763 nsAString_Finish(&nsstr);
4764 if(NS_FAILED(nsres)) {
4765 WARN("QuerySelectorAll failed: %08lx\n", nsres);
4766 return map_nsresult(nsres);
4769 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
4770 nsIDOMNodeList_Release(node_list);
4771 return hres;
4774 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4775 DocumentSelector_QueryInterface,
4776 DocumentSelector_AddRef,
4777 DocumentSelector_Release,
4778 DocumentSelector_GetTypeInfoCount,
4779 DocumentSelector_GetTypeInfo,
4780 DocumentSelector_GetIDsOfNames,
4781 DocumentSelector_Invoke,
4782 DocumentSelector_querySelector,
4783 DocumentSelector_querySelectorAll
4786 static inline HTMLDocumentNode *impl_from_IDocumentEvent(IDocumentEvent *iface)
4788 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentEvent_iface);
4791 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4793 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4794 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4797 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4799 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4800 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4803 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4805 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4806 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4809 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4811 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4812 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4815 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4816 LCID lcid, ITypeInfo **ppTInfo)
4818 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4819 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4822 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4823 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4825 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4826 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4827 rgDispId);
4830 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4831 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4833 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4834 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4835 pDispParams, pVarResult, pExcepInfo, puArgErr);
4838 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4840 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4842 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4844 return create_document_event_str(This, eventType, p);
4847 static const IDocumentEventVtbl DocumentEventVtbl = {
4848 DocumentEvent_QueryInterface,
4849 DocumentEvent_AddRef,
4850 DocumentEvent_Release,
4851 DocumentEvent_GetTypeInfoCount,
4852 DocumentEvent_GetTypeInfo,
4853 DocumentEvent_GetIDsOfNames,
4854 DocumentEvent_Invoke,
4855 DocumentEvent_createEvent
4858 static void HTMLDocumentNode_on_advise(IUnknown *iface, cp_static_data_t *cp)
4860 HTMLDocumentNode *This = CONTAINING_RECORD((IHTMLDocument2*)iface, HTMLDocumentNode, IHTMLDocument2_iface);
4862 if(This->outer_window)
4863 update_doc_cp_events(This, cp);
4866 static inline HTMLDocumentNode *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4868 return CONTAINING_RECORD(iface, HTMLDocumentNode, ISupportErrorInfo_iface);
4871 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4873 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4874 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4877 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4879 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4880 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4883 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4885 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4886 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4889 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4891 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4892 return S_FALSE;
4895 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4896 SupportErrorInfo_QueryInterface,
4897 SupportErrorInfo_AddRef,
4898 SupportErrorInfo_Release,
4899 SupportErrorInfo_InterfaceSupportsErrorInfo
4902 static inline HTMLDocumentNode *impl_from_IDispatchEx(IDispatchEx *iface)
4904 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDispatchEx_iface);
4907 static HRESULT has_elem_name(nsIDOMHTMLDocument *html_document, const WCHAR *name)
4909 static const WCHAR fmt[] = L":-moz-any(applet,embed,form,iframe,img,object)[name=\"%s\"]";
4910 WCHAR buf[128], *selector = buf;
4911 nsAString selector_str;
4912 nsIDOMElement *nselem;
4913 nsresult nsres;
4914 size_t len;
4916 len = wcslen(name) + ARRAY_SIZE(fmt) - 2 /* %s */;
4917 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4918 return E_OUTOFMEMORY;
4919 swprintf(selector, len, fmt, name);
4921 nsAString_InitDepend(&selector_str, selector);
4922 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4923 nsAString_Finish(&selector_str);
4924 if(selector != buf)
4925 free(selector);
4926 if(NS_FAILED(nsres))
4927 return map_nsresult(nsres);
4929 if(!nselem)
4930 return DISP_E_UNKNOWNNAME;
4931 nsIDOMElement_Release(nselem);
4932 return S_OK;
4935 static HRESULT get_elem_by_name_or_id(nsIDOMHTMLDocument *html_document, const WCHAR *name, nsIDOMElement **ret)
4937 static const WCHAR fmt[] = L":-moz-any(embed,form,iframe,img):-moz-any([name=\"%s\"],[id=\"%s\"][name]),"
4938 L":-moz-any(applet,object):-moz-any([name=\"%s\"],[id=\"%s\"])";
4939 WCHAR buf[384], *selector = buf;
4940 nsAString selector_str;
4941 nsIDOMElement *nselem;
4942 nsresult nsres;
4943 size_t len;
4945 len = wcslen(name) * 4 + ARRAY_SIZE(fmt) - 8 /* %s */;
4946 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4947 return E_OUTOFMEMORY;
4948 swprintf(selector, len, fmt, name, name, name, name);
4950 nsAString_InitDepend(&selector_str, selector);
4951 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4952 nsAString_Finish(&selector_str);
4953 if(selector != buf)
4954 free(selector);
4955 if(NS_FAILED(nsres))
4956 return map_nsresult(nsres);
4958 if(ret) {
4959 *ret = nselem;
4960 return S_OK;
4963 if(nselem) {
4964 nsIDOMElement_Release(nselem);
4965 return S_OK;
4967 return DISP_E_UNKNOWNNAME;
4970 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, const WCHAR *name, DISPID *dispid)
4972 unsigned i;
4974 for(i=0; i < This->elem_vars_cnt; i++) {
4975 if(!wcscmp(name, This->elem_vars[i])) {
4976 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4977 return S_OK;
4981 if(This->elem_vars_cnt == This->elem_vars_size) {
4982 WCHAR **new_vars;
4984 if(This->elem_vars_size) {
4985 new_vars = realloc(This->elem_vars, This->elem_vars_size * 2 * sizeof(WCHAR*));
4986 if(!new_vars)
4987 return E_OUTOFMEMORY;
4988 This->elem_vars_size *= 2;
4989 }else {
4990 new_vars = malloc(16 * sizeof(WCHAR*));
4991 if(!new_vars)
4992 return E_OUTOFMEMORY;
4993 This->elem_vars_size = 16;
4996 This->elem_vars = new_vars;
4999 This->elem_vars[This->elem_vars_cnt] = wcsdup(name);
5000 if(!This->elem_vars[This->elem_vars_cnt])
5001 return E_OUTOFMEMORY;
5003 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
5004 return S_OK;
5007 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
5009 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5011 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5014 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
5016 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5018 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5021 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
5023 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5025 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5028 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
5030 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5032 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5035 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
5036 LCID lcid, ITypeInfo **ppTInfo)
5038 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5040 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5043 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
5044 LPOLESTR *rgszNames, UINT cNames,
5045 LCID lcid, DISPID *rgDispId)
5047 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5049 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
5052 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
5053 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5054 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5056 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5058 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
5059 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5061 return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags, pDispParams,
5062 pVarResult, pExcepInfo, NULL);
5065 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
5067 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5068 HRESULT hres;
5070 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex & ~fdexNameEnsure, pid);
5071 if(hres != DISP_E_UNKNOWNNAME)
5072 return hres;
5074 if(This->html_document) {
5075 hres = get_elem_by_name_or_id(This->html_document, bstrName, NULL);
5076 if(SUCCEEDED(hres))
5077 hres = dispid_from_elem_name(This, bstrName, pid);
5080 if(hres == DISP_E_UNKNOWNNAME && (grfdex & fdexNameEnsure))
5081 hres = dispex_get_dynid(&This->node.event_target.dispex, bstrName, FALSE, pid);
5082 return hres;
5085 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
5086 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
5088 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5090 if(This->window) {
5091 switch(id) {
5092 case DISPID_READYSTATE:
5093 TRACE("DISPID_READYSTATE\n");
5095 if(!(wFlags & DISPATCH_PROPERTYGET))
5096 return E_INVALIDARG;
5098 V_VT(pvarRes) = VT_I4;
5099 V_I4(pvarRes) = This->window->base.outer_window->readystate;
5100 return S_OK;
5101 default:
5102 break;
5106 return IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
5109 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
5111 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5113 return IDispatchEx_DeleteMemberByName(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex);
5116 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
5118 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5120 return IDispatchEx_DeleteMemberByDispID(&This->node.event_target.dispex.IDispatchEx_iface, id);
5123 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
5125 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5127 return IDispatchEx_GetMemberProperties(&This->node.event_target.dispex.IDispatchEx_iface, id, grfdexFetch, pgrfdex);
5130 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
5132 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5134 return IDispatchEx_GetMemberName(&This->node.event_target.dispex.IDispatchEx_iface, id, pbstrName);
5137 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
5139 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5141 return IDispatchEx_GetNextDispID(&This->node.event_target.dispex.IDispatchEx_iface, grfdex, id, pid);
5144 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
5146 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5148 return IDispatchEx_GetNameSpaceParent(&This->node.event_target.dispex.IDispatchEx_iface, ppunk);
5151 static const IDispatchExVtbl DocDispatchExVtbl = {
5152 DocDispatchEx_QueryInterface,
5153 DocDispatchEx_AddRef,
5154 DocDispatchEx_Release,
5155 DocDispatchEx_GetTypeInfoCount,
5156 DocDispatchEx_GetTypeInfo,
5157 DocDispatchEx_GetIDsOfNames,
5158 DocDispatchEx_Invoke,
5159 DocDispatchEx_GetDispID,
5160 DocDispatchEx_InvokeEx,
5161 DocDispatchEx_DeleteMemberByName,
5162 DocDispatchEx_DeleteMemberByDispID,
5163 DocDispatchEx_GetMemberProperties,
5164 DocDispatchEx_GetMemberName,
5165 DocDispatchEx_GetNextDispID,
5166 DocDispatchEx_GetNameSpaceParent
5169 static inline HTMLDocumentNode *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
5171 return CONTAINING_RECORD(iface, HTMLDocumentNode, IProvideMultipleClassInfo_iface);
5174 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
5175 REFIID riid, void **ppv)
5177 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5178 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5181 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
5183 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5184 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5187 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
5189 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5190 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5193 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
5195 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5196 TRACE("(%p)->(%p)\n", This, ppTI);
5197 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
5200 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
5202 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5203 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
5204 return E_NOTIMPL;
5207 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
5209 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5210 FIXME("(%p)->(%p)\n", This, pcti);
5211 *pcti = 1;
5212 return S_OK;
5215 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
5216 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
5218 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5219 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
5220 return E_NOTIMPL;
5223 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
5224 ProvideClassInfo_QueryInterface,
5225 ProvideClassInfo_AddRef,
5226 ProvideClassInfo_Release,
5227 ProvideClassInfo_GetClassInfo,
5228 ProvideClassInfo2_GetGUID,
5229 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
5230 ProvideMultipleClassInfo_GetInfoOfIndex
5233 /**********************************************************
5234 * IMarkupServices implementation
5236 static inline HTMLDocumentNode *impl_from_IMarkupServices(IMarkupServices *iface)
5238 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupServices_iface);
5241 static HRESULT WINAPI MarkupServices_QueryInterface(IMarkupServices *iface, REFIID riid, void **ppvObject)
5243 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5244 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5247 static ULONG WINAPI MarkupServices_AddRef(IMarkupServices *iface)
5249 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5250 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5253 static ULONG WINAPI MarkupServices_Release(IMarkupServices *iface)
5255 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5256 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5259 static HRESULT WINAPI MarkupServices_CreateMarkupPointer(IMarkupServices *iface, IMarkupPointer **ppPointer)
5261 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5263 TRACE("(%p)->(%p)\n", This, ppPointer);
5265 return create_markup_pointer(ppPointer);
5268 static HRESULT WINAPI MarkupServices_CreateMarkupContainer(IMarkupServices *iface, IMarkupContainer **ppMarkupContainer)
5270 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5271 FIXME("(%p)->(%p)\n", This, ppMarkupContainer);
5272 return E_NOTIMPL;
5275 static HRESULT WINAPI MarkupServices_CreateElement(IMarkupServices *iface,
5276 ELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement)
5278 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5279 FIXME("(%p)->(%d,%s,%p)\n", This, tagID, debugstr_w(pchAttributes), ppElement);
5280 return E_NOTIMPL;
5283 static HRESULT WINAPI MarkupServices_CloneElement(IMarkupServices *iface,
5284 IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone)
5286 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5287 FIXME("(%p)->(%p,%p)\n", This, pElemCloneThis, ppElementTheClone);
5288 return E_NOTIMPL;
5291 static HRESULT WINAPI MarkupServices_InsertElement(IMarkupServices *iface,
5292 IHTMLElement *pElementInsert, IMarkupPointer *pPointerStart,
5293 IMarkupPointer *pPointerFinish)
5295 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5296 FIXME("(%p)->(%p,%p,%p)\n", This, pElementInsert, pPointerStart, pPointerFinish);
5297 return E_NOTIMPL;
5300 static HRESULT WINAPI MarkupServices_RemoveElement(IMarkupServices *iface, IHTMLElement *pElementRemove)
5302 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5303 FIXME("(%p)->(%p)\n", This, pElementRemove);
5304 return E_NOTIMPL;
5307 static HRESULT WINAPI MarkupServices_Remove(IMarkupServices *iface,
5308 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5310 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5311 FIXME("(%p)->(%p,%p)\n", This, pPointerStart, pPointerFinish);
5312 return E_NOTIMPL;
5315 static HRESULT WINAPI MarkupServices_Copy(IMarkupServices *iface,
5316 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5317 IMarkupPointer *pPointerTarget)
5319 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5320 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5321 return E_NOTIMPL;
5324 static HRESULT WINAPI MarkupServices_Move(IMarkupServices *iface,
5325 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5326 IMarkupPointer *pPointerTarget)
5328 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5329 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5330 return E_NOTIMPL;
5333 static HRESULT WINAPI MarkupServices_InsertText(IMarkupServices *iface,
5334 OLECHAR *pchText, LONG cch, IMarkupPointer *pPointerTarget)
5336 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5337 FIXME("(%p)->(%s,%lx,%p)\n", This, debugstr_w(pchText), cch, pPointerTarget);
5338 return E_NOTIMPL;
5341 static HRESULT WINAPI MarkupServices_ParseString(IMarkupServices *iface,
5342 OLECHAR *pchHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5343 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5345 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5346 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(pchHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5347 return E_NOTIMPL;
5350 static HRESULT WINAPI MarkupServices_ParseGlobal(IMarkupServices *iface,
5351 HGLOBAL hglobalHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5352 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5354 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5355 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(hglobalHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5356 return E_NOTIMPL;
5359 static HRESULT WINAPI MarkupServices_IsScopedElement(IMarkupServices *iface,
5360 IHTMLElement *pElement, BOOL *pfScoped)
5362 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5363 FIXME("(%p)->(%p,%p)\n", This, pElement, pfScoped);
5364 return E_NOTIMPL;
5367 static HRESULT WINAPI MarkupServices_GetElementTagId(IMarkupServices *iface,
5368 IHTMLElement *pElement, ELEMENT_TAG_ID *ptagId)
5370 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5371 FIXME("(%p)->(%p,%p)\n", This, pElement, ptagId);
5372 return E_NOTIMPL;
5375 static HRESULT WINAPI MarkupServices_GetTagIDForName(IMarkupServices *iface,
5376 BSTR bstrName, ELEMENT_TAG_ID *ptagId)
5378 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5379 FIXME("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), ptagId);
5380 return E_NOTIMPL;
5383 static HRESULT WINAPI MarkupServices_GetNameForTagID(IMarkupServices *iface,
5384 ELEMENT_TAG_ID tagId, BSTR *pbstrName)
5386 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5387 FIXME("(%p)->(%d,%p)\n", This, tagId, pbstrName);
5388 return E_NOTIMPL;
5391 static HRESULT WINAPI MarkupServices_MovePointersToRange(IMarkupServices *iface,
5392 IHTMLTxtRange *pIRange, IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5394 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5395 FIXME("(%p)->(%p,%p,%p)\n", This, pIRange, pPointerStart, pPointerFinish);
5396 return E_NOTIMPL;
5399 static HRESULT WINAPI MarkupServices_MoveRangeToPointers(IMarkupServices *iface,
5400 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish, IHTMLTxtRange *pIRange)
5402 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5403 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerStart, pPointerFinish, pIRange);
5404 return E_NOTIMPL;
5407 static HRESULT WINAPI MarkupServices_BeginUndoUnit(IMarkupServices *iface, OLECHAR *pchTitle)
5409 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5410 FIXME("(%p)->(%s)\n", This, debugstr_w(pchTitle));
5411 return E_NOTIMPL;
5414 static HRESULT WINAPI MarkupServices_EndUndoUnit(IMarkupServices *iface)
5416 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5417 FIXME("(%p)\n", This);
5418 return E_NOTIMPL;
5421 static const IMarkupServicesVtbl MarkupServicesVtbl = {
5422 MarkupServices_QueryInterface,
5423 MarkupServices_AddRef,
5424 MarkupServices_Release,
5425 MarkupServices_CreateMarkupPointer,
5426 MarkupServices_CreateMarkupContainer,
5427 MarkupServices_CreateElement,
5428 MarkupServices_CloneElement,
5429 MarkupServices_InsertElement,
5430 MarkupServices_RemoveElement,
5431 MarkupServices_Remove,
5432 MarkupServices_Copy,
5433 MarkupServices_Move,
5434 MarkupServices_InsertText,
5435 MarkupServices_ParseString,
5436 MarkupServices_ParseGlobal,
5437 MarkupServices_IsScopedElement,
5438 MarkupServices_GetElementTagId,
5439 MarkupServices_GetTagIDForName,
5440 MarkupServices_GetNameForTagID,
5441 MarkupServices_MovePointersToRange,
5442 MarkupServices_MoveRangeToPointers,
5443 MarkupServices_BeginUndoUnit,
5444 MarkupServices_EndUndoUnit
5447 /**********************************************************
5448 * IMarkupContainer implementation
5450 static inline HTMLDocumentNode *impl_from_IMarkupContainer(IMarkupContainer *iface)
5452 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupContainer_iface);
5455 static HRESULT WINAPI MarkupContainer_QueryInterface(IMarkupContainer *iface, REFIID riid, void **ppvObject)
5457 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5458 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5461 static ULONG WINAPI MarkupContainer_AddRef(IMarkupContainer *iface)
5463 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5464 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5467 static ULONG WINAPI MarkupContainer_Release(IMarkupContainer *iface)
5469 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5470 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5473 static HRESULT WINAPI MarkupContainer_OwningDoc(IMarkupContainer *iface, IHTMLDocument2 **ppDoc)
5475 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5476 FIXME("(%p)->(%p)\n", This, ppDoc);
5477 return E_NOTIMPL;
5480 static const IMarkupContainerVtbl MarkupContainerVtbl = {
5481 MarkupContainer_QueryInterface,
5482 MarkupContainer_AddRef,
5483 MarkupContainer_Release,
5484 MarkupContainer_OwningDoc
5487 /**********************************************************
5488 * IDisplayServices implementation
5490 static inline HTMLDocumentNode *impl_from_IDisplayServices(IDisplayServices *iface)
5492 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDisplayServices_iface);
5495 static HRESULT WINAPI DisplayServices_QueryInterface(IDisplayServices *iface, REFIID riid, void **ppvObject)
5497 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5498 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5501 static ULONG WINAPI DisplayServices_AddRef(IDisplayServices *iface)
5503 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5504 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5507 static ULONG WINAPI DisplayServices_Release(IDisplayServices *iface)
5509 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5510 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5513 static HRESULT WINAPI DisplayServices_CreateDisplayPointer(IDisplayServices *iface, IDisplayPointer **ppDispPointer)
5515 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5516 FIXME("(%p)->(%p)\n", This, ppDispPointer);
5517 return E_NOTIMPL;
5520 static HRESULT WINAPI DisplayServices_TransformRect(IDisplayServices *iface,
5521 RECT *pRect, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5523 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5524 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_rect(pRect), eSource, eDestination, pIElement);
5525 return E_NOTIMPL;
5528 static HRESULT WINAPI DisplayServices_TransformPoint(IDisplayServices *iface,
5529 POINT *pPoint, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5531 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5532 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_point(pPoint), eSource, eDestination, pIElement);
5533 return E_NOTIMPL;
5536 static HRESULT WINAPI DisplayServices_GetCaret(IDisplayServices *iface, IHTMLCaret **ppCaret)
5538 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5539 FIXME("(%p)->(%p)\n", This, ppCaret);
5540 return E_NOTIMPL;
5543 static HRESULT WINAPI DisplayServices_GetComputedStyle(IDisplayServices *iface,
5544 IMarkupPointer *pPointer, IHTMLComputedStyle **ppComputedStyle)
5546 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5547 FIXME("(%p)->(%p,%p)\n", This, pPointer, ppComputedStyle);
5548 return E_NOTIMPL;
5551 static HRESULT WINAPI DisplayServices_ScrollRectIntoView(IDisplayServices *iface,
5552 IHTMLElement *pIElement, RECT rect)
5554 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5555 FIXME("(%p)->(%p,%s)\n", This, pIElement, wine_dbgstr_rect(&rect));
5556 return E_NOTIMPL;
5559 static HRESULT WINAPI DisplayServices_HasFlowLayout(IDisplayServices *iface,
5560 IHTMLElement *pIElement, BOOL *pfHasFlowLayout)
5562 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5563 FIXME("(%p)->(%p,%p)\n", This, pIElement, pfHasFlowLayout);
5564 return E_NOTIMPL;
5567 static const IDisplayServicesVtbl DisplayServicesVtbl = {
5568 DisplayServices_QueryInterface,
5569 DisplayServices_AddRef,
5570 DisplayServices_Release,
5571 DisplayServices_CreateDisplayPointer,
5572 DisplayServices_TransformRect,
5573 DisplayServices_TransformPoint,
5574 DisplayServices_GetCaret,
5575 DisplayServices_GetComputedStyle,
5576 DisplayServices_ScrollRectIntoView,
5577 DisplayServices_HasFlowLayout
5580 /**********************************************************
5581 * IDocumentRange implementation
5583 static inline HTMLDocumentNode *impl_from_IDocumentRange(IDocumentRange *iface)
5585 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentRange_iface);
5588 static HRESULT WINAPI DocumentRange_QueryInterface(IDocumentRange *iface, REFIID riid, void **ppv)
5590 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5592 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5595 static ULONG WINAPI DocumentRange_AddRef(IDocumentRange *iface)
5597 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5599 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5602 static ULONG WINAPI DocumentRange_Release(IDocumentRange *iface)
5604 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5606 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5609 static HRESULT WINAPI DocumentRange_GetTypeInfoCount(IDocumentRange *iface, UINT *pctinfo)
5611 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5613 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
5616 static HRESULT WINAPI DocumentRange_GetTypeInfo(IDocumentRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5618 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5620 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5623 static HRESULT WINAPI DocumentRange_GetIDsOfNames(IDocumentRange *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5624 LCID lcid, DISPID *rgDispId)
5626 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5628 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
5629 rgDispId);
5632 static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
5633 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5635 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5637 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5638 pDispParams, pVarResult, pExcepInfo, puArgErr);
5641 static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
5643 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5644 nsIDOMRange *nsrange;
5645 HRESULT hres;
5647 TRACE("(%p)->(%p)\n", This, p);
5649 if(!This->dom_document) {
5650 WARN("NULL dom_document\n");
5651 return E_UNEXPECTED;
5654 if(NS_FAILED(nsIDOMDocument_CreateRange(This->dom_document, &nsrange)))
5655 return E_FAIL;
5657 hres = create_dom_range(nsrange, dispex_compat_mode(&This->node.event_target.dispex), p);
5658 nsIDOMRange_Release(nsrange);
5659 return hres;
5662 static const IDocumentRangeVtbl DocumentRangeVtbl = {
5663 DocumentRange_QueryInterface,
5664 DocumentRange_AddRef,
5665 DocumentRange_Release,
5666 DocumentRange_GetTypeInfoCount,
5667 DocumentRange_GetTypeInfo,
5668 DocumentRange_GetIDsOfNames,
5669 DocumentRange_Invoke,
5670 DocumentRange_createRange
5673 static cp_static_data_t HTMLDocumentNodeEvents_data = { HTMLDocumentEvents_tid, HTMLDocumentNode_on_advise };
5674 static cp_static_data_t HTMLDocumentNodeEvents2_data = { HTMLDocumentEvents2_tid, HTMLDocumentNode_on_advise, TRUE };
5676 static const cpc_entry_t HTMLDocumentNode_cpc[] = {
5677 {&IID_IDispatch, &HTMLDocumentNodeEvents_data},
5678 {&IID_IPropertyNotifySink},
5679 {&DIID_HTMLDocumentEvents, &HTMLDocumentNodeEvents_data},
5680 {&DIID_HTMLDocumentEvents2, &HTMLDocumentNodeEvents2_data},
5681 {NULL}
5684 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5686 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
5689 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5691 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5693 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5695 if(IsEqualGUID(&IID_IUnknown, riid))
5696 *ppv = &This->IHTMLDocument2_iface;
5697 else if(IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDispatchEx, riid))
5698 *ppv = &This->IDispatchEx_iface;
5699 else if(IsEqualGUID(&IID_IHTMLDocument, riid) || IsEqualGUID(&IID_IHTMLDocument2, riid))
5700 *ppv = &This->IHTMLDocument2_iface;
5701 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
5702 *ppv = &This->IHTMLDocument3_iface;
5703 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
5704 *ppv = &This->IHTMLDocument4_iface;
5705 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
5706 *ppv = &This->IHTMLDocument5_iface;
5707 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
5708 *ppv = &This->IHTMLDocument6_iface;
5709 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
5710 *ppv = &This->IHTMLDocument7_iface;
5711 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
5712 *ppv = &This->IDocumentSelector_iface;
5713 else if(IsEqualGUID(&IID_IDocumentEvent, riid))
5714 *ppv = &This->IDocumentEvent_iface;
5715 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
5716 *ppv = &This->IHTMLDocument2_iface;
5717 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
5718 *ppv = &This->ISupportErrorInfo_iface;
5719 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
5720 *ppv = &This->IProvideMultipleClassInfo_iface;
5721 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
5722 *ppv = &This->IProvideMultipleClassInfo_iface;
5723 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
5724 *ppv = &This->IProvideMultipleClassInfo_iface;
5725 else if(IsEqualGUID(&IID_IMarkupServices, riid))
5726 *ppv = &This->IMarkupServices_iface;
5727 else if(IsEqualGUID(&IID_IMarkupContainer, riid))
5728 *ppv = &This->IMarkupContainer_iface;
5729 else if(IsEqualGUID(&IID_IDisplayServices, riid))
5730 *ppv = &This->IDisplayServices_iface;
5731 else if(IsEqualGUID(&IID_IDocumentRange, riid))
5732 *ppv = &This->IDocumentRange_iface;
5733 else if(IsEqualGUID(&IID_IPersist, riid))
5734 *ppv = &This->IPersistFile_iface;
5735 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
5736 *ppv = &This->IPersistMoniker_iface;
5737 else if(IsEqualGUID(&IID_IPersistFile, riid))
5738 *ppv = &This->IPersistFile_iface;
5739 else if(IsEqualGUID(&IID_IMonikerProp, riid))
5740 *ppv = &This->IMonikerProp_iface;
5741 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
5742 *ppv = &This->IPersistStreamInit_iface;
5743 else if(IsEqualGUID(&IID_IPersistHistory, riid))
5744 *ppv = &This->IPersistHistory_iface;
5745 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
5746 *ppv = &This->IHlinkTarget_iface;
5747 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
5748 *ppv = &This->IOleCommandTarget_iface;
5749 else if(IsEqualGUID(&IID_IOleObject, riid))
5750 *ppv = &This->IOleObject_iface;
5751 else if(IsEqualGUID(&IID_IOleDocument, riid))
5752 *ppv = &This->IOleDocument_iface;
5753 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
5754 *ppv = &This->IOleInPlaceActiveObject_iface;
5755 else if(IsEqualGUID(&IID_IOleWindow, riid))
5756 *ppv = &This->IOleInPlaceActiveObject_iface;
5757 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
5758 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5759 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
5760 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5761 else if(IsEqualGUID(&IID_IOleControl, riid))
5762 *ppv = &This->IOleControl_iface;
5763 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
5764 *ppv = &This->IObjectWithSite_iface;
5765 else if(IsEqualGUID(&IID_IOleContainer, riid))
5766 *ppv = &This->IOleContainer_iface;
5767 else if(IsEqualGUID(&IID_IObjectSafety, riid))
5768 *ppv = &This->IObjectSafety_iface;
5769 else if(IsEqualGUID(&IID_IServiceProvider, riid))
5770 *ppv = &This->IServiceProvider_iface;
5771 else if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
5772 *ppv = &This->IInternetHostSecurityManager_iface;
5773 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
5774 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5775 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
5776 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
5777 *ppv = NULL;
5778 return E_NOINTERFACE;
5779 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
5780 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
5781 *ppv = NULL;
5782 return E_NOINTERFACE;
5783 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
5784 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
5785 *ppv = NULL;
5786 return E_NOINTERFACE;
5787 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
5788 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
5789 *ppv = NULL;
5790 return E_NOINTERFACE;
5791 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
5792 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
5793 *ppv = NULL;
5794 return E_NOINTERFACE;
5795 }else {
5796 return HTMLDOMNode_QI(&This->node, riid, ppv);
5799 IUnknown_AddRef((IUnknown*)*ppv);
5800 return S_OK;
5803 void detach_document_node(HTMLDocumentNode *doc)
5805 unsigned i;
5807 while(!list_empty(&doc->plugin_hosts))
5808 detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
5810 if(doc->dom_implementation) {
5811 detach_dom_implementation(doc->dom_implementation);
5812 IHTMLDOMImplementation_Release(doc->dom_implementation);
5813 doc->dom_implementation = NULL;
5816 if(doc->namespaces) {
5817 IHTMLNamespaceCollection_Release(doc->namespaces);
5818 doc->namespaces = NULL;
5821 detach_events(doc);
5822 detach_selection(doc);
5823 detach_ranges(doc);
5825 for(i=0; i < doc->elem_vars_cnt; i++)
5826 free(doc->elem_vars[i]);
5827 free(doc->elem_vars);
5828 doc->elem_vars_cnt = doc->elem_vars_size = 0;
5829 doc->elem_vars = NULL;
5831 if(doc->catmgr) {
5832 ICatInformation_Release(doc->catmgr);
5833 doc->catmgr = NULL;
5836 if(doc->browser) {
5837 list_remove(&doc->browser_entry);
5838 doc->browser = NULL;
5842 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
5844 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5846 TRACE("(%p)\n", This);
5848 free(This->event_vector);
5849 ConnectionPointContainer_Destroy(&This->cp_container);
5852 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5854 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5855 FIXME("%p\n", This);
5856 return E_NOTIMPL;
5859 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
5861 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5863 if(This->dom_document)
5864 note_cc_edge((nsISupports*)This->dom_document, "This->dom_document", cb);
5867 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
5869 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5871 if(This->dom_document) {
5872 nsIDOMDocument *dom_document = This->dom_document;
5874 release_document_mutation(This);
5875 detach_document_node(This);
5876 This->dom_document = NULL;
5877 This->html_document = NULL;
5878 nsIDOMDocument_Release(dom_document);
5879 This->window = NULL;
5883 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
5884 &CLSID_HTMLDocument,
5885 HTMLDocumentNode_QI,
5886 HTMLDocumentNode_destructor,
5887 HTMLDocumentNode_cpc,
5888 HTMLDocumentNode_clone,
5889 NULL,
5890 NULL,
5891 NULL,
5892 NULL,
5893 NULL,
5894 NULL,
5895 NULL,
5896 NULL,
5897 NULL,
5898 NULL,
5899 NULL,
5900 NULL,
5901 HTMLDocumentNode_traverse,
5902 HTMLDocumentNode_unlink
5905 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5907 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5908 HTMLDocumentNode *new_node;
5909 HRESULT hres;
5911 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
5912 if(FAILED(hres))
5913 return hres;
5915 *ret = &new_node->node;
5916 return S_OK;
5919 static void HTMLDocumentFragment_unlink(HTMLDOMNode *iface)
5921 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5923 if(This->window) {
5924 detach_document_node(This);
5926 /* document fragments own reference to inner window */
5927 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
5928 This->window = NULL;
5932 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
5934 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
5937 static HRESULT HTMLDocumentNode_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
5939 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5940 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
5942 if(!This->dom_document || idx >= This->elem_vars_cnt)
5943 return DISP_E_MEMBERNOTFOUND;
5945 return (*name = SysAllocString(This->elem_vars[idx])) ? S_OK : E_OUTOFMEMORY;
5948 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5949 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5951 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5952 nsIDOMElement *nselem;
5953 HTMLDOMNode *node;
5954 unsigned i;
5955 HRESULT hres;
5957 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET))
5958 return MSHTML_E_INVALID_PROPERTY;
5960 i = id - MSHTML_DISPID_CUSTOM_MIN;
5962 if(!This->html_document || i >= This->elem_vars_cnt)
5963 return DISP_E_MEMBERNOTFOUND;
5965 hres = get_elem_by_name_or_id(This->html_document, This->elem_vars[i], &nselem);
5966 if(FAILED(hres))
5967 return hres;
5968 if(!nselem)
5969 return DISP_E_MEMBERNOTFOUND;
5971 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
5972 nsIDOMElement_Release(nselem);
5973 if(FAILED(hres))
5974 return hres;
5976 V_VT(res) = VT_DISPATCH;
5977 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5978 return S_OK;
5981 static HRESULT HTMLDocumentNode_next_dispid(DispatchEx *dispex, DISPID id, DISPID *pid)
5983 DWORD idx = (id == DISPID_STARTENUM) ? 0 : id - MSHTML_DISPID_CUSTOM_MIN + 1;
5984 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5985 nsIDOMNodeList *node_list;
5986 const PRUnichar *name;
5987 nsIDOMElement *nselem;
5988 nsIDOMNode *nsnode;
5989 nsAString nsstr;
5990 nsresult nsres;
5991 HRESULT hres;
5992 UINT32 i;
5994 if(!This->html_document)
5995 return S_FALSE;
5997 while(idx < This->elem_vars_cnt) {
5998 hres = has_elem_name(This->html_document, This->elem_vars[idx]);
5999 if(SUCCEEDED(hres)) {
6000 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
6001 return S_OK;
6003 if(hres != DISP_E_UNKNOWNNAME)
6004 return hres;
6005 idx++;
6008 /* Populate possibly missing DISPIDs */
6009 nsAString_InitDepend(&nsstr, L":-moz-any(applet,embed,form,iframe,img,object)[name]");
6010 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->html_document, &nsstr, &node_list);
6011 nsAString_Finish(&nsstr);
6012 if(NS_FAILED(nsres))
6013 return map_nsresult(nsres);
6015 for(i = 0, hres = S_OK; SUCCEEDED(hres); i++) {
6016 nsres = nsIDOMNodeList_Item(node_list, i, &nsnode);
6017 if(NS_FAILED(nsres)) {
6018 hres = map_nsresult(nsres);
6019 break;
6021 if(!nsnode)
6022 break;
6024 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
6025 nsIDOMNode_Release(nsnode);
6026 if(nsres != S_OK)
6027 continue;
6029 nsres = get_elem_attr_value(nselem, L"name", &nsstr, &name);
6030 nsIDOMElement_Release(nselem);
6031 if(NS_FAILED(nsres))
6032 hres = map_nsresult(nsres);
6033 else {
6034 hres = dispid_from_elem_name(This, name, &id);
6035 nsAString_Finish(&nsstr);
6038 nsIDOMNodeList_Release(node_list);
6039 if(FAILED(hres))
6040 return hres;
6042 if(idx >= This->elem_vars_cnt)
6043 return S_FALSE;
6045 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
6046 return S_OK;
6049 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
6051 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6053 TRACE("(%p) returning %u\n", This, This->document_mode);
6055 return lock_document_mode(This);
6058 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
6060 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6061 return (nsISupports*)This->node.nsnode;
6064 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
6066 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6067 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
6070 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
6072 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6073 if(!This->window)
6074 return NULL;
6075 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
6076 return &This->window->event_target;
6079 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
6081 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6082 ConnectionPointContainer *container = This->doc_obj
6083 ? &This->doc_obj->cp_container : &This->cp_container;
6084 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
6085 return container;
6088 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6090 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6091 return default_set_current_event(This->window, event);
6094 static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp, VARIANT *res,
6095 EXCEPINFO *ei, IServiceProvider *caller)
6097 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6099 if(!(flags & DISPATCH_PROPERTYPUT) || !This->outer_window)
6100 return S_FALSE;
6102 return IDispatchEx_InvokeEx(&This->outer_window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
6103 0, flags, dp, res, ei, caller);
6106 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
6108 NULL,
6109 NULL,
6110 HTMLDocumentNode_get_name,
6111 HTMLDocumentNode_invoke,
6112 NULL,
6113 HTMLDocumentNode_next_dispid,
6114 HTMLDocumentNode_get_compat_mode,
6115 NULL
6117 HTMLDocumentNode_get_gecko_target,
6118 HTMLDocumentNode_bind_event,
6119 NULL,
6120 HTMLDocumentNode_get_parent_event_target,
6121 NULL,
6122 HTMLDocumentNode_get_cp_container,
6123 HTMLDocumentNode_set_current_event
6126 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
6127 &CLSID_HTMLDocument,
6128 HTMLDocumentNode_QI,
6129 HTMLDocumentNode_destructor,
6130 HTMLDocumentNode_cpc,
6131 HTMLDocumentFragment_clone,
6132 NULL,
6133 NULL,
6134 NULL,
6135 NULL,
6136 NULL,
6137 NULL,
6138 NULL,
6139 NULL,
6140 NULL,
6141 NULL,
6142 NULL,
6143 NULL,
6144 NULL,
6145 HTMLDocumentFragment_unlink
6148 static const tid_t HTMLDocumentNode_iface_tids[] = {
6149 IHTMLDOMNode_tid,
6150 IHTMLDOMNode2_tid,
6151 IHTMLDocument4_tid,
6152 IHTMLDocument5_tid,
6153 IDocumentSelector_tid,
6157 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6159 static const dispex_hook_t document2_hooks[] = {
6160 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6161 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6162 {DISPID_UNKNOWN}
6164 static const dispex_hook_t document2_ie11_hooks[] = {
6165 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6166 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6167 {DISPID_IHTMLDOCUMENT2_CREATESTYLESHEET, NULL},
6168 {DISPID_IHTMLDOCUMENT2_FILESIZE, NULL},
6169 {DISPID_IHTMLDOCUMENT2_SELECTION, NULL},
6170 {DISPID_UNKNOWN}
6172 static const dispex_hook_t document3_ie11_hooks[] = {
6173 {DISPID_IHTMLDOCUMENT3_ATTACHEVENT, NULL},
6174 {DISPID_IHTMLDOCUMENT3_DETACHEVENT, NULL},
6175 {DISPID_UNKNOWN}
6177 static const dispex_hook_t document6_ie9_hooks[] = {
6178 {DISPID_IHTMLDOCUMENT6_ONSTORAGE},
6179 {DISPID_UNKNOWN}
6182 HTMLDOMNode_init_dispex_info(info, mode);
6184 if(mode >= COMPAT_MODE_IE9) {
6185 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
6186 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
6189 /* Depending on compatibility version, we add interfaces in different order
6190 * so that the right getElementById implementation is used. */
6191 if(mode < COMPAT_MODE_IE8) {
6192 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
6193 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
6194 }else {
6195 dispex_info_add_interface(info, IHTMLDocument6_tid, mode >= COMPAT_MODE_IE9 ? document6_ie9_hooks : NULL);
6196 dispex_info_add_interface(info, IHTMLDocument3_tid, mode >= COMPAT_MODE_IE11 ? document3_ie11_hooks : NULL);
6198 dispex_info_add_interface(info, IHTMLDocument2_tid, mode >= COMPAT_MODE_IE11 ? document2_ie11_hooks : document2_hooks);
6201 static dispex_static_data_t HTMLDocumentNode_dispex = {
6202 L"HTMLDocument",
6203 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
6204 DispHTMLDocument_tid,
6205 HTMLDocumentNode_iface_tids,
6206 HTMLDocumentNode_init_dispex_info
6209 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
6211 HTMLDocumentNode *doc;
6213 doc = calloc(1, sizeof(HTMLDocumentNode));
6214 if(!doc)
6215 return NULL;
6217 doc->ref = 1;
6218 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
6219 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
6220 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
6221 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
6222 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
6223 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
6224 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
6225 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
6226 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
6227 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
6228 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
6229 doc->IMarkupServices_iface.lpVtbl = &MarkupServicesVtbl;
6230 doc->IMarkupContainer_iface.lpVtbl = &MarkupContainerVtbl;
6231 doc->IDisplayServices_iface.lpVtbl = &DisplayServicesVtbl;
6232 doc->IDocumentRange_iface.lpVtbl = &DocumentRangeVtbl;
6234 doc->doc_obj = doc_obj;
6235 doc->outer_window = window ? window->base.outer_window : NULL;
6236 doc->window = window;
6238 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocumentNode_cpc);
6239 HTMLDocumentNode_Persist_Init(doc);
6240 HTMLDocumentNode_Service_Init(doc);
6241 HTMLDocumentNode_OleCmd_Init(doc);
6242 HTMLDocumentNode_OleObj_Init(doc);
6243 HTMLDocumentNode_SecMgr_Init(doc);
6245 list_init(&doc->selection_list);
6246 list_init(&doc->range_list);
6247 list_init(&doc->plugin_hosts);
6249 return doc;
6252 HRESULT create_document_node(nsIDOMDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
6253 compat_mode_t parent_mode, HTMLDocumentNode **ret)
6255 HTMLDocumentObj *doc_obj = browser->doc;
6256 HTMLDocumentNode *doc;
6258 doc = alloc_doc_node(doc_obj, window);
6259 if(!doc)
6260 return E_OUTOFMEMORY;
6262 if(parent_mode >= COMPAT_MODE_IE9) {
6263 TRACE("using parent mode %u\n", parent_mode);
6264 doc->document_mode = parent_mode;
6265 lock_document_mode(doc);
6268 if(!doc_obj->window || (window && is_main_content_window(window->base.outer_window)))
6269 doc->cp_container.forward_container = &doc_obj->cp_container;
6271 if(NS_SUCCEEDED(nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&doc->html_document)))
6272 doc->dom_document = (nsIDOMDocument*)doc->html_document;
6273 else {
6274 nsIDOMDocument_AddRef(nsdoc);
6275 doc->dom_document = nsdoc;
6276 doc->html_document = NULL;
6279 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)doc->dom_document, &HTMLDocumentNode_dispex);
6281 init_document_mutation(doc);
6282 doc_init_events(doc);
6284 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
6286 list_add_head(&browser->document_nodes, &doc->browser_entry);
6287 doc->browser = browser;
6289 if(browser->usermode == EDITMODE && doc->html_document) {
6290 nsAString mode_str;
6291 nsresult nsres;
6293 nsAString_InitDepend(&mode_str, L"on");
6294 nsres = nsIDOMHTMLDocument_SetDesignMode(doc->html_document, &mode_str);
6295 nsAString_Finish(&mode_str);
6296 if(NS_FAILED(nsres))
6297 ERR("SetDesignMode failed: %08lx\n", nsres);
6300 *ret = doc;
6301 return S_OK;
6304 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
6306 HTMLDocumentNode *doc_frag;
6308 doc_frag = alloc_doc_node(doc_node->doc_obj, doc_node->window);
6309 if(!doc_frag)
6310 return E_OUTOFMEMORY;
6312 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
6314 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
6315 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
6316 doc_frag->document_mode = lock_document_mode(doc_node);
6318 *ret = doc_frag;
6319 return S_OK;
6322 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
6324 HTMLDOMNode *node;
6325 HRESULT hres;
6327 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
6328 if(FAILED(hres))
6329 return hres;
6331 if(!node) {
6332 ERR("document not initialized\n");
6333 return E_FAIL;
6336 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
6337 *ret = impl_from_HTMLDOMNode(node);
6338 return S_OK;