mshtml: Send load event synchronously for img elements that loaded instantly in legac...
[wine.git] / dlls / mshtml / htmldoc.c
blob49640cff9da8027c0739712a3cc22eac74fa795f
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);
490 nsIDOMElement *nselem = NULL;
491 HTMLDOMNode *node;
492 nsresult nsres;
493 HRESULT hres;
495 TRACE("(%p)->(%p)\n", This, p);
497 if(!This->dom_document) {
498 WARN("NULL dom_document\n");
499 return E_UNEXPECTED;
502 nsres = nsIDOMDocument_GetDocumentElement(This->dom_document, &nselem);
503 if(NS_FAILED(nsres)) {
504 ERR("GetDocumentElement failed: %08lx\n", nsres);
505 return E_FAIL;
508 if(!nselem) {
509 *p = NULL;
510 return S_OK;
513 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
514 nsIDOMElement_Release(nselem);
515 if(FAILED(hres))
516 return hres;
518 *p = create_all_collection(node, TRUE);
519 node_release(node);
520 return hres;
523 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
525 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
526 nsIDOMHTMLElement *nsbody = NULL;
527 HTMLElement *element;
528 HRESULT hres;
530 TRACE("(%p)->(%p)\n", This, p);
532 if(This->html_document) {
533 nsresult nsres;
535 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, &nsbody);
536 if(NS_FAILED(nsres)) {
537 TRACE("Could not get body: %08lx\n", nsres);
538 return E_UNEXPECTED;
542 if(!nsbody) {
543 *p = NULL;
544 return S_OK;
547 hres = get_element((nsIDOMElement*)nsbody, &element);
548 nsIDOMHTMLElement_Release(nsbody);
549 if(FAILED(hres))
550 return hres;
552 *p = &element->IHTMLElement_iface;
553 return S_OK;
556 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
558 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
559 nsIDOMElement *nselem;
560 HTMLElement *elem;
561 nsresult nsres;
562 HRESULT hres;
564 TRACE("(%p)->(%p)\n", This, p);
566 if(!This->dom_document) {
567 *p = NULL;
568 return S_OK;
572 * NOTE: Gecko may return an active element even if the document is not visible.
573 * IE returns NULL in this case.
575 nsres = nsIDOMDocument_GetActiveElement(This->dom_document, &nselem);
576 if(NS_FAILED(nsres)) {
577 ERR("GetActiveElement failed: %08lx\n", nsres);
578 return E_FAIL;
581 if(!nselem) {
582 *p = NULL;
583 return S_OK;
586 hres = get_element(nselem, &elem);
587 nsIDOMElement_Release(nselem);
588 if(FAILED(hres))
589 return hres;
591 *p = &elem->IHTMLElement_iface;
592 return S_OK;
595 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
597 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
598 nsIDOMHTMLCollection *nscoll = NULL;
599 nsresult nsres;
601 TRACE("(%p)->(%p)\n", This, p);
603 if(!p)
604 return E_INVALIDARG;
606 *p = NULL;
608 if(!This->dom_document) {
609 WARN("NULL dom_document\n");
610 return E_UNEXPECTED;
613 if(!This->html_document) {
614 FIXME("Not implemented for XML document\n");
615 return E_NOTIMPL;
618 nsres = nsIDOMHTMLDocument_GetImages(This->html_document, &nscoll);
619 if(NS_FAILED(nsres)) {
620 ERR("GetImages failed: %08lx\n", nsres);
621 return E_FAIL;
624 if(nscoll) {
625 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
626 nsIDOMHTMLCollection_Release(nscoll);
629 return S_OK;
632 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
634 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
635 nsIDOMHTMLCollection *nscoll = NULL;
636 nsresult nsres;
638 TRACE("(%p)->(%p)\n", This, p);
640 if(!p)
641 return E_INVALIDARG;
643 *p = NULL;
645 if(!This->dom_document) {
646 WARN("NULL dom_document\n");
647 return E_UNEXPECTED;
650 if(!This->html_document) {
651 FIXME("Not implemented for XML document\n");
652 return E_NOTIMPL;
655 nsres = nsIDOMHTMLDocument_GetApplets(This->html_document, &nscoll);
656 if(NS_FAILED(nsres)) {
657 ERR("GetApplets failed: %08lx\n", nsres);
658 return E_FAIL;
661 if(nscoll) {
662 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
663 nsIDOMHTMLCollection_Release(nscoll);
666 return S_OK;
669 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
671 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
672 nsIDOMHTMLCollection *nscoll = NULL;
673 nsresult nsres;
675 TRACE("(%p)->(%p)\n", This, p);
677 if(!p)
678 return E_INVALIDARG;
680 *p = NULL;
682 if(!This->dom_document) {
683 WARN("NULL dom_document\n");
684 return E_UNEXPECTED;
687 if(!This->html_document) {
688 FIXME("Not implemented for XML document\n");
689 return E_NOTIMPL;
692 nsres = nsIDOMHTMLDocument_GetLinks(This->html_document, &nscoll);
693 if(NS_FAILED(nsres)) {
694 ERR("GetLinks failed: %08lx\n", nsres);
695 return E_FAIL;
698 if(nscoll) {
699 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
700 nsIDOMHTMLCollection_Release(nscoll);
703 return S_OK;
706 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
708 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
709 nsIDOMHTMLCollection *nscoll = NULL;
710 nsresult nsres;
712 TRACE("(%p)->(%p)\n", This, p);
714 if(!p)
715 return E_INVALIDARG;
717 *p = NULL;
719 if(!This->dom_document) {
720 WARN("NULL dom_document\n");
721 return E_UNEXPECTED;
724 if(!This->html_document) {
725 FIXME("Not implemented for XML document\n");
726 return E_NOTIMPL;
729 nsres = nsIDOMHTMLDocument_GetForms(This->html_document, &nscoll);
730 if(NS_FAILED(nsres)) {
731 ERR("GetForms failed: %08lx\n", nsres);
732 return E_FAIL;
735 if(nscoll) {
736 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
737 nsIDOMHTMLCollection_Release(nscoll);
740 return S_OK;
743 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
745 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
746 nsIDOMHTMLCollection *nscoll = NULL;
747 nsresult nsres;
749 TRACE("(%p)->(%p)\n", This, p);
751 if(!p)
752 return E_INVALIDARG;
754 *p = NULL;
756 if(!This->dom_document) {
757 WARN("NULL dom_document\n");
758 return E_UNEXPECTED;
761 if(!This->html_document) {
762 FIXME("Not implemented for XML document\n");
763 return E_NOTIMPL;
766 nsres = nsIDOMHTMLDocument_GetAnchors(This->html_document, &nscoll);
767 if(NS_FAILED(nsres)) {
768 ERR("GetAnchors failed: %08lx\n", nsres);
769 return E_FAIL;
772 if(nscoll) {
773 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
774 nsIDOMHTMLCollection_Release(nscoll);
777 return S_OK;
780 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
782 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
783 nsAString nsstr;
784 nsresult nsres;
786 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
788 if(!This->dom_document) {
789 WARN("NULL dom_document\n");
790 return E_UNEXPECTED;
793 nsAString_InitDepend(&nsstr, v);
794 nsres = nsIDOMDocument_SetTitle(This->dom_document, &nsstr);
795 nsAString_Finish(&nsstr);
796 if(NS_FAILED(nsres))
797 ERR("SetTitle failed: %08lx\n", nsres);
799 return S_OK;
802 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
804 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
805 const PRUnichar *ret;
806 nsAString nsstr;
807 nsresult nsres;
809 TRACE("(%p)->(%p)\n", This, p);
811 if(!This->dom_document) {
812 WARN("NULL dom_document\n");
813 return E_UNEXPECTED;
817 nsAString_Init(&nsstr, NULL);
818 nsres = nsIDOMDocument_GetTitle(This->dom_document, &nsstr);
819 if (NS_SUCCEEDED(nsres)) {
820 nsAString_GetData(&nsstr, &ret);
821 *p = SysAllocString(ret);
823 nsAString_Finish(&nsstr);
825 if(NS_FAILED(nsres)) {
826 ERR("GetTitle failed: %08lx\n", nsres);
827 return E_FAIL;
830 return S_OK;
833 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
835 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
836 nsIDOMHTMLCollection *nscoll = NULL;
837 nsresult nsres;
839 TRACE("(%p)->(%p)\n", This, p);
841 if(!p)
842 return E_INVALIDARG;
844 *p = NULL;
846 if(!This->dom_document) {
847 WARN("NULL dom_document\n");
848 return E_UNEXPECTED;
851 if(!This->html_document) {
852 FIXME("Not implemented for XML document\n");
853 return E_NOTIMPL;
856 nsres = nsIDOMHTMLDocument_GetScripts(This->html_document, &nscoll);
857 if(NS_FAILED(nsres)) {
858 ERR("GetImages failed: %08lx\n", nsres);
859 return E_FAIL;
862 if(nscoll) {
863 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
864 nsIDOMHTMLCollection_Release(nscoll);
867 return S_OK;
870 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
872 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
873 HRESULT hres;
875 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
877 if(wcsicmp(v, L"on")) {
878 FIXME("Unsupported arg %s\n", debugstr_w(v));
879 return E_NOTIMPL;
882 hres = setup_edit_mode(This->doc_obj);
883 if(FAILED(hres))
884 return hres;
886 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
887 return S_OK;
890 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
892 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
893 FIXME("(%p)->(%p) always returning Off\n", This, p);
895 if(!p)
896 return E_INVALIDARG;
898 *p = SysAllocString(L"Off");
900 return S_OK;
903 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
905 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
906 nsISelection *nsselection;
907 nsresult nsres;
909 TRACE("(%p)->(%p)\n", This, p);
911 if(!This->html_document) {
912 FIXME("Not implemented for XML document\n");
913 return E_NOTIMPL;
916 nsres = nsIDOMHTMLDocument_GetSelection(This->html_document, &nsselection);
917 if(NS_FAILED(nsres)) {
918 ERR("GetSelection failed: %08lx\n", nsres);
919 return E_FAIL;
922 return HTMLSelectionObject_Create(This, nsselection, p);
925 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
927 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
929 TRACE("(%p)->(%p)\n", iface, p);
931 if(!p)
932 return E_POINTER;
934 return get_readystate_string(This->outer_window ? This->outer_window->readystate : 0, p);
937 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
939 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
941 TRACE("(%p)->(%p)\n", This, p);
943 if(!This->outer_window) {
944 /* Not implemented by IE */
945 return E_NOTIMPL;
947 return IHTMLWindow2_get_frames(&This->outer_window->base.IHTMLWindow2_iface, p);
950 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
952 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
953 FIXME("(%p)->(%p)\n", This, p);
954 return E_NOTIMPL;
957 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
959 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
960 FIXME("(%p)->(%p)\n", This, p);
961 return E_NOTIMPL;
964 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
966 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
967 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
968 return E_NOTIMPL;
971 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
973 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
974 FIXME("(%p)->(%p)\n", This, p);
975 return E_NOTIMPL;
978 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
980 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
981 IHTMLElement *element = NULL;
982 IHTMLBodyElement *body;
983 HRESULT hr;
985 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
987 hr = IHTMLDocument2_get_body(iface, &element);
988 if (FAILED(hr))
990 ERR("Failed to get body (0x%08lx)\n", hr);
991 return hr;
994 if(!element)
996 FIXME("Empty body element.\n");
997 return hr;
1000 hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body);
1001 if (SUCCEEDED(hr))
1003 hr = IHTMLBodyElement_put_bgColor(body, v);
1004 IHTMLBodyElement_Release(body);
1006 IHTMLElement_Release(element);
1008 return hr;
1011 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
1013 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1014 nsAString nsstr;
1015 nsresult nsres;
1016 HRESULT hres;
1018 TRACE("(%p)->(%p)\n", This, p);
1020 if(!This->dom_document) {
1021 WARN("NULL dom_document\n");
1022 return E_UNEXPECTED;
1025 if(!This->html_document) {
1026 FIXME("Not implemented for XML document\n");
1027 return E_NOTIMPL;
1030 nsAString_Init(&nsstr, NULL);
1031 nsres = nsIDOMHTMLDocument_GetBgColor(This->html_document, &nsstr);
1032 hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p);
1033 if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) {
1034 TRACE("default #ffffff\n");
1035 if(!(V_BSTR(p) = SysAllocString(L"#ffffff")))
1036 hres = E_OUTOFMEMORY;
1038 return hres;
1041 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
1043 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1044 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1045 return E_NOTIMPL;
1048 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
1050 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1051 FIXME("(%p)->(%p)\n", This, p);
1052 return E_NOTIMPL;
1055 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
1057 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1058 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1059 return E_NOTIMPL;
1062 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
1064 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1065 FIXME("(%p)->(%p)\n", This, p);
1066 return E_NOTIMPL;
1069 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
1071 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1072 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1073 return E_NOTIMPL;
1076 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
1078 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1079 FIXME("(%p)->(%p)\n", This, p);
1080 return E_NOTIMPL;
1083 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
1085 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1086 nsAString nsstr;
1087 nsresult nsres;
1089 TRACE("(%p)->(%p)\n", This, p);
1091 nsAString_InitDepend(&nsstr, NULL);
1092 nsres = nsIDOMDocument_GetReferrer(This->dom_document, &nsstr);
1093 return return_nsstr(nsres, &nsstr, p);
1096 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
1098 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1100 TRACE("(%p)->(%p)\n", This, p);
1102 if(!This->dom_document || !This->window) {
1103 WARN("NULL window\n");
1104 return E_UNEXPECTED;
1107 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
1110 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
1112 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1113 FIXME("(%p)->(%p)\n", This, p);
1114 return E_NOTIMPL;
1117 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
1119 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1121 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1123 if(!This->outer_window) {
1124 FIXME("No window available\n");
1125 return E_FAIL;
1128 return navigate_url(This->outer_window, v, This->outer_window->uri, BINDING_NAVIGATED);
1131 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
1133 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1135 TRACE("(%p)->(%p)\n", iface, p);
1137 *p = SysAllocString(This->outer_window && This->outer_window->url ? This->outer_window->url : L"about:blank");
1138 return *p ? S_OK : E_OUTOFMEMORY;
1141 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
1143 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1144 nsAString nsstr;
1145 nsresult nsres;
1147 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1149 if(!This->html_document) {
1150 FIXME("Not implemented for XML document\n");
1151 return E_NOTIMPL;
1154 nsAString_InitDepend(&nsstr, v);
1155 nsres = nsIDOMHTMLDocument_SetDomain(This->html_document, &nsstr);
1156 nsAString_Finish(&nsstr);
1157 if(NS_FAILED(nsres)) {
1158 ERR("SetDomain failed: %08lx\n", nsres);
1159 return E_INVALIDARG;
1162 return S_OK;
1165 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
1167 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1168 nsAString nsstr;
1169 nsresult nsres;
1171 TRACE("(%p)->(%p)\n", This, p);
1173 if(!This->html_document) {
1174 FIXME("Not implemented for XML document\n");
1175 return E_NOTIMPL;
1178 nsAString_Init(&nsstr, NULL);
1179 nsres = nsIDOMHTMLDocument_GetDomain(This->html_document, &nsstr);
1180 if(NS_SUCCEEDED(nsres) && This->outer_window && This->outer_window->uri) {
1181 const PRUnichar *str;
1182 HRESULT hres;
1184 nsAString_GetData(&nsstr, &str);
1185 if(!*str) {
1186 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
1187 nsAString_Finish(&nsstr);
1188 hres = IUri_GetHost(This->outer_window->uri, p);
1189 return FAILED(hres) ? hres : S_OK;
1193 return return_nsstr(nsres, &nsstr, p);
1196 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
1198 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1199 BOOL bret;
1201 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1203 if(!This->outer_window)
1204 return S_OK;
1206 bret = InternetSetCookieExW(This->outer_window->url, NULL, v, 0, 0);
1207 if(!bret) {
1208 FIXME("InternetSetCookieExW failed: %lu\n", GetLastError());
1209 return HRESULT_FROM_WIN32(GetLastError());
1212 return S_OK;
1215 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
1217 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1218 DWORD size;
1219 BOOL bret;
1221 TRACE("(%p)->(%p)\n", This, p);
1223 if(!This->outer_window) {
1224 *p = NULL;
1225 return S_OK;
1228 size = 0;
1229 bret = InternetGetCookieExW(This->outer_window->url, NULL, NULL, &size, 0, NULL);
1230 if(!bret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
1231 WARN("InternetGetCookieExW failed: %lu\n", GetLastError());
1232 *p = NULL;
1233 return S_OK;
1236 if(!size) {
1237 *p = NULL;
1238 return S_OK;
1241 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
1242 if(!*p)
1243 return E_OUTOFMEMORY;
1245 bret = InternetGetCookieExW(This->outer_window->url, NULL, *p, &size, 0, NULL);
1246 if(!bret) {
1247 ERR("InternetGetCookieExW failed: %lu\n", GetLastError());
1248 return E_FAIL;
1251 return S_OK;
1254 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
1256 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1257 FIXME("(%p)->(%x)\n", This, v);
1258 return E_NOTIMPL;
1261 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
1263 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1264 FIXME("(%p)->(%p)\n", This, p);
1265 return E_NOTIMPL;
1268 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
1270 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1271 FIXME("(%p)->(%s) returning S_OK\n", This, debugstr_w(v));
1272 return S_OK;
1275 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
1277 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1279 TRACE("(%p)->(%p)\n", This, p);
1281 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
1284 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
1286 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1287 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1288 return E_NOTIMPL;
1291 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
1293 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1295 TRACE("(%p)->(%p)\n", This, p);
1297 *p = charset_string_from_cp(GetACP());
1298 return *p ? S_OK : E_OUTOFMEMORY;
1301 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
1303 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1304 const PRUnichar *content_type;
1305 nsAString nsstr;
1306 nsresult nsres;
1307 HRESULT hres;
1309 TRACE("(%p)->(%p)\n", This, p);
1311 *p = NULL;
1313 if(This->window && This->window->base.outer_window->readystate == READYSTATE_UNINITIALIZED)
1314 return (*p = SysAllocString(L"")) ? S_OK : E_FAIL;
1316 nsAString_InitDepend(&nsstr, NULL);
1317 nsres = nsIDOMDocument_GetContentType(This->dom_document, &nsstr);
1318 if(NS_FAILED(nsres))
1319 return map_nsresult(nsres);
1321 nsAString_GetData(&nsstr, &content_type);
1322 hres = get_mime_type_display_name(content_type, p);
1323 nsAString_Finish(&nsstr);
1324 return hres;
1327 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
1329 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1330 FIXME("(%p)->(%p)\n", This, p);
1331 return E_NOTIMPL;
1334 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
1336 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1337 FIXME("(%p)->(%p)\n", This, p);
1338 return E_NOTIMPL;
1341 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
1343 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1344 FIXME("(%p)->(%p)\n", This, p);
1345 return E_NOTIMPL;
1348 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
1350 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1351 FIXME("(%p)->(%p)\n", This, p);
1352 return E_NOTIMPL;
1355 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
1357 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1358 FIXME("(%p)->(%p)\n", This, p);
1359 return E_NOTIMPL;
1362 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
1364 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1365 FIXME("(%p)->(%p)\n", This, p);
1366 return E_NOTIMPL;
1369 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1371 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1372 FIXME("(%p)->(%p)\n", This, p);
1373 return E_NOTIMPL;
1376 static HRESULT document_write(HTMLDocumentNode *This, SAFEARRAY *psarray, BOOL ln)
1378 VARIANT *var, tmp;
1379 JSContext *jsctx;
1380 nsAString nsstr;
1381 ULONG i, argc;
1382 nsresult nsres;
1383 HRESULT hres;
1385 if(!This->dom_document) {
1386 WARN("NULL dom_document\n");
1387 return E_UNEXPECTED;
1390 if(!This->html_document) {
1391 FIXME("Not implemented for XML document\n");
1392 return E_NOTIMPL;
1395 if (!psarray)
1396 return S_OK;
1398 if(psarray->cDims != 1) {
1399 FIXME("cDims=%d\n", psarray->cDims);
1400 return E_INVALIDARG;
1403 hres = SafeArrayAccessData(psarray, (void**)&var);
1404 if(FAILED(hres)) {
1405 WARN("SafeArrayAccessData failed: %08lx\n", hres);
1406 return hres;
1409 V_VT(&tmp) = VT_EMPTY;
1411 jsctx = get_context_from_document(This->dom_document);
1412 argc = psarray->rgsabound[0].cElements;
1413 for(i=0; i < argc; i++) {
1414 if(V_VT(var+i) == VT_BSTR) {
1415 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1416 }else {
1417 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1418 if(FAILED(hres)) {
1419 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1420 break;
1422 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1425 if(!ln || i != argc-1)
1426 nsres = nsIDOMHTMLDocument_Write(This->html_document, &nsstr, jsctx);
1427 else
1428 nsres = nsIDOMHTMLDocument_Writeln(This->html_document, &nsstr, jsctx);
1429 nsAString_Finish(&nsstr);
1430 if(V_VT(var+i) != VT_BSTR)
1431 VariantClear(&tmp);
1432 if(NS_FAILED(nsres)) {
1433 ERR("Write failed: %08lx\n", nsres);
1434 hres = E_FAIL;
1435 break;
1439 SafeArrayUnaccessData(psarray);
1441 return hres;
1444 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1446 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1448 TRACE("(%p)->(%p)\n", iface, psarray);
1450 return document_write(This, psarray, FALSE);
1453 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1455 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1457 TRACE("(%p)->(%p)\n", This, psarray);
1459 return document_write(This, psarray, TRUE);
1462 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1463 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1465 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1466 nsISupports *tmp;
1467 nsresult nsres;
1469 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1470 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1472 *pomWindowResult = NULL;
1474 if(!This->outer_window)
1475 return E_FAIL;
1477 if(!This->dom_document) {
1478 ERR("!dom_document\n");
1479 return E_NOTIMPL;
1482 if(!This->html_document) {
1483 FIXME("Not implemented for XML document\n");
1484 return E_NOTIMPL;
1487 if(!url || wcscmp(url, L"text/html") || V_VT(&name) != VT_ERROR
1488 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1489 FIXME("unsupported args\n");
1491 nsres = nsIDOMHTMLDocument_Open(This->html_document, NULL, NULL, NULL,
1492 get_context_from_document(This->dom_document), 0, &tmp);
1493 if(NS_FAILED(nsres)) {
1494 ERR("Open failed: %08lx\n", nsres);
1495 return E_FAIL;
1498 if(tmp)
1499 nsISupports_Release(tmp);
1501 *pomWindowResult = (IDispatch*)&This->outer_window->base.IHTMLWindow2_iface;
1502 IHTMLWindow2_AddRef(&This->outer_window->base.IHTMLWindow2_iface);
1503 return S_OK;
1506 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1508 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1509 nsresult nsres;
1511 TRACE("(%p)\n", This);
1513 if(!This->dom_document) {
1514 ERR("!dom_document\n");
1515 return E_NOTIMPL;
1518 if(!This->html_document) {
1519 FIXME("Not implemented for XML document\n");
1520 return E_NOTIMPL;
1523 nsres = nsIDOMHTMLDocument_Close(This->html_document);
1524 if(NS_FAILED(nsres)) {
1525 ERR("Close failed: %08lx\n", nsres);
1526 return E_FAIL;
1529 return S_OK;
1532 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1534 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1535 nsresult nsres;
1537 TRACE("(%p)\n", This);
1539 if(!This->html_document) {
1540 FIXME("Not implemented for XML document\n");
1541 return E_NOTIMPL;
1544 nsres = nsIDOMHTMLDocument_Clear(This->html_document);
1545 if(NS_FAILED(nsres)) {
1546 ERR("Clear failed: %08lx\n", nsres);
1547 return E_FAIL;
1550 return S_OK;
1553 static const struct {
1554 const WCHAR *name;
1555 OLECMDID id;
1556 }command_names[] = {
1557 {L"copy", IDM_COPY},
1558 {L"cut", IDM_CUT},
1559 {L"fontname", IDM_FONTNAME},
1560 {L"fontsize", IDM_FONTSIZE},
1561 {L"indent", IDM_INDENT},
1562 {L"insertorderedlist", IDM_ORDERLIST},
1563 {L"insertunorderedlist", IDM_UNORDERLIST},
1564 {L"outdent", IDM_OUTDENT},
1565 {L"paste", IDM_PASTE},
1566 {L"respectvisibilityindesign", IDM_RESPECTVISIBILITY_INDESIGN}
1569 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1571 int i;
1573 for(i = 0; i < ARRAY_SIZE(command_names); i++) {
1574 if(!wcsicmp(command_names[i].name, str)) {
1575 *cmdid = command_names[i].id;
1576 return TRUE;
1580 FIXME("Unknown command %s\n", debugstr_w(str));
1581 return FALSE;
1584 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1585 VARIANT_BOOL *pfRet)
1587 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1588 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1589 return E_NOTIMPL;
1592 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1593 VARIANT_BOOL *pfRet)
1595 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1596 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1597 return E_NOTIMPL;
1600 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1601 VARIANT_BOOL *pfRet)
1603 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1604 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1605 return E_NOTIMPL;
1608 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1609 VARIANT_BOOL *pfRet)
1611 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1612 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1613 return E_NOTIMPL;
1616 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1617 BSTR *pfRet)
1619 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1620 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1621 return E_NOTIMPL;
1624 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1625 VARIANT *pfRet)
1627 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1628 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1629 return E_NOTIMPL;
1632 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1633 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1635 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1636 OLECMDID cmdid;
1637 VARIANT ret;
1638 HRESULT hres;
1640 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1642 if(!cmdid_from_string(cmdID, &cmdid))
1643 return OLECMDERR_E_NOTSUPPORTED;
1645 V_VT(&ret) = VT_EMPTY;
1646 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1647 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1648 if(FAILED(hres))
1649 return hres;
1651 if(V_VT(&ret) != VT_EMPTY) {
1652 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1653 VariantClear(&ret);
1656 *pfRet = VARIANT_TRUE;
1657 return S_OK;
1660 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1661 VARIANT_BOOL *pfRet)
1663 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1664 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1665 return E_NOTIMPL;
1668 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1669 IHTMLElement **newElem)
1671 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1672 HTMLElement *elem;
1673 HRESULT hres;
1675 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1677 hres = create_element(This, eTag, &elem);
1678 if(FAILED(hres))
1679 return hres;
1681 *newElem = &elem->IHTMLElement_iface;
1682 return S_OK;
1685 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1687 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1688 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1689 return E_NOTIMPL;
1692 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1694 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1695 FIXME("(%p)->(%p)\n", This, p);
1696 return E_NOTIMPL;
1699 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1701 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1703 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1705 return set_doc_event(This, EVENTID_CLICK, &v);
1708 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1710 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1712 TRACE("(%p)->(%p)\n", This, p);
1714 return get_doc_event(This, EVENTID_CLICK, p);
1717 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1719 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1721 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1723 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1726 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1728 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1730 TRACE("(%p)->(%p)\n", This, p);
1732 return get_doc_event(This, EVENTID_DBLCLICK, p);
1735 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1737 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1739 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1741 return set_doc_event(This, EVENTID_KEYUP, &v);
1744 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1746 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1748 TRACE("(%p)->(%p)\n", This, p);
1750 return get_doc_event(This, EVENTID_KEYUP, p);
1753 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1755 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1757 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1759 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1762 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1764 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1766 TRACE("(%p)->(%p)\n", This, p);
1768 return get_doc_event(This, EVENTID_KEYDOWN, p);
1771 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1773 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1775 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1777 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1780 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1782 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1784 TRACE("(%p)->(%p)\n", This, p);
1786 return get_doc_event(This, EVENTID_KEYPRESS, p);
1789 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1791 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1793 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1795 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1798 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1800 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1802 TRACE("(%p)->(%p)\n", This, p);
1804 return get_doc_event(This, EVENTID_MOUSEUP, p);
1807 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1809 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1811 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1813 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1816 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1818 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1820 TRACE("(%p)->(%p)\n", This, p);
1822 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1825 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1827 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1829 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1831 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1834 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1836 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1838 TRACE("(%p)->(%p)\n", This, p);
1840 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1843 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1845 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1847 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1849 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1852 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1854 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1856 TRACE("(%p)->(%p)\n", This, p);
1858 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1861 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1863 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1865 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1867 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1870 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1872 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1874 TRACE("(%p)->(%p)\n", This, p);
1876 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1879 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1881 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1883 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1885 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1888 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1890 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1892 TRACE("(%p)->(%p)\n", This, p);
1894 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1897 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1899 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1900 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1901 return E_NOTIMPL;
1904 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1906 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1907 FIXME("(%p)->(%p)\n", This, p);
1908 return E_NOTIMPL;
1911 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1913 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1914 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1915 return E_NOTIMPL;
1918 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1920 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1921 FIXME("(%p)->(%p)\n", This, p);
1922 return E_NOTIMPL;
1925 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1927 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1928 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1929 return E_NOTIMPL;
1932 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1934 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1935 FIXME("(%p)->(%p)\n", This, p);
1936 return E_NOTIMPL;
1939 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1941 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1943 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1945 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1948 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1950 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1952 TRACE("(%p)->(%p)\n", This, p);
1954 return get_doc_event(This, EVENTID_DRAGSTART, p);
1957 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1959 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1961 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1963 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1966 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1968 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1970 TRACE("(%p)->(%p)\n", This, p);
1972 return get_doc_event(This, EVENTID_SELECTSTART, p);
1975 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1976 IHTMLElement **elementHit)
1978 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1979 nsIDOMElement *nselem;
1980 HTMLElement *element;
1981 nsresult nsres;
1982 HRESULT hres;
1984 TRACE("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1986 nsres = nsIDOMDocument_ElementFromPoint(This->dom_document, x, y, &nselem);
1987 if(NS_FAILED(nsres)) {
1988 ERR("ElementFromPoint failed: %08lx\n", nsres);
1989 return E_FAIL;
1992 if(!nselem) {
1993 *elementHit = NULL;
1994 return S_OK;
1997 hres = get_element(nselem, &element);
1998 nsIDOMElement_Release(nselem);
1999 if(FAILED(hres))
2000 return hres;
2002 *elementHit = &element->IHTMLElement_iface;
2003 return S_OK;
2006 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
2008 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2009 HRESULT hres;
2011 TRACE("(%p)->(%p)\n", This, p);
2013 hres = IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
2014 return hres == S_OK && !*p ? E_FAIL : hres;
2017 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
2018 IHTMLStyleSheetsCollection **p)
2020 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2021 nsIDOMStyleSheetList *nsstylelist;
2022 nsresult nsres;
2023 HRESULT hres;
2025 TRACE("(%p)->(%p)\n", This, p);
2027 *p = NULL;
2029 if(!This->dom_document) {
2030 WARN("NULL dom_document\n");
2031 return E_UNEXPECTED;
2034 nsres = nsIDOMDocument_GetStyleSheets(This->dom_document, &nsstylelist);
2035 if(NS_FAILED(nsres)) {
2036 ERR("GetStyleSheets failed: %08lx\n", nsres);
2037 return map_nsresult(nsres);
2040 hres = create_style_sheet_collection(nsstylelist,
2041 dispex_compat_mode(&This->node.event_target.dispex), p);
2042 nsIDOMStyleSheetList_Release(nsstylelist);
2043 return hres;
2046 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
2048 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2049 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2050 return E_NOTIMPL;
2053 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
2055 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2056 FIXME("(%p)->(%p)\n", This, p);
2057 return E_NOTIMPL;
2060 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
2062 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2063 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2064 return E_NOTIMPL;
2067 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
2069 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2070 FIXME("(%p)->(%p)\n", This, p);
2071 return E_NOTIMPL;
2074 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
2076 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2078 TRACE("(%p)->(%p)\n", This, String);
2080 return dispex_to_string(&This->node.event_target.dispex, String);
2083 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
2084 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
2086 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2087 nsIDOMHTMLHeadElement *head_elem;
2088 IHTMLStyleElement *style_elem;
2089 HTMLElement *elem;
2090 nsresult nsres;
2091 HRESULT hres;
2093 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
2095 if(!This->dom_document) {
2096 FIXME("not a real doc object\n");
2097 return E_NOTIMPL;
2100 if(!This->html_document) {
2101 FIXME("Not implemented for XML document\n");
2102 return E_NOTIMPL;
2105 if(lIndex != -1)
2106 FIXME("Unsupported lIndex %ld\n", lIndex);
2108 if(bstrHref && *bstrHref) {
2109 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
2110 return create_style_sheet(NULL, dispex_compat_mode(&This->node.event_target.dispex),
2111 ppnewStyleSheet);
2114 hres = create_element(This, L"style", &elem);
2115 if(FAILED(hres))
2116 return hres;
2118 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &head_elem);
2119 if(NS_SUCCEEDED(nsres)) {
2120 nsIDOMNode *head_node, *tmp_node;
2122 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
2123 nsIDOMHTMLHeadElement_Release(head_elem);
2124 assert(nsres == NS_OK);
2126 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
2127 nsIDOMNode_Release(head_node);
2128 if(NS_SUCCEEDED(nsres) && tmp_node)
2129 nsIDOMNode_Release(tmp_node);
2131 if(NS_FAILED(nsres)) {
2132 IHTMLElement_Release(&elem->IHTMLElement_iface);
2133 return E_FAIL;
2136 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
2137 assert(hres == S_OK);
2138 IHTMLElement_Release(&elem->IHTMLElement_iface);
2140 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
2141 IHTMLStyleElement_Release(style_elem);
2142 return hres;
2145 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
2146 HTMLDocument_QueryInterface,
2147 HTMLDocument_AddRef,
2148 HTMLDocument_Release,
2149 HTMLDocument_GetTypeInfoCount,
2150 HTMLDocument_GetTypeInfo,
2151 HTMLDocument_GetIDsOfNames,
2152 HTMLDocument_Invoke,
2153 HTMLDocument_get_Script,
2154 HTMLDocument_get_all,
2155 HTMLDocument_get_body,
2156 HTMLDocument_get_activeElement,
2157 HTMLDocument_get_images,
2158 HTMLDocument_get_applets,
2159 HTMLDocument_get_links,
2160 HTMLDocument_get_forms,
2161 HTMLDocument_get_anchors,
2162 HTMLDocument_put_title,
2163 HTMLDocument_get_title,
2164 HTMLDocument_get_scripts,
2165 HTMLDocument_put_designMode,
2166 HTMLDocument_get_designMode,
2167 HTMLDocument_get_selection,
2168 HTMLDocument_get_readyState,
2169 HTMLDocument_get_frames,
2170 HTMLDocument_get_embeds,
2171 HTMLDocument_get_plugins,
2172 HTMLDocument_put_alinkColor,
2173 HTMLDocument_get_alinkColor,
2174 HTMLDocument_put_bgColor,
2175 HTMLDocument_get_bgColor,
2176 HTMLDocument_put_fgColor,
2177 HTMLDocument_get_fgColor,
2178 HTMLDocument_put_linkColor,
2179 HTMLDocument_get_linkColor,
2180 HTMLDocument_put_vlinkColor,
2181 HTMLDocument_get_vlinkColor,
2182 HTMLDocument_get_referrer,
2183 HTMLDocument_get_location,
2184 HTMLDocument_get_lastModified,
2185 HTMLDocument_put_URL,
2186 HTMLDocument_get_URL,
2187 HTMLDocument_put_domain,
2188 HTMLDocument_get_domain,
2189 HTMLDocument_put_cookie,
2190 HTMLDocument_get_cookie,
2191 HTMLDocument_put_expando,
2192 HTMLDocument_get_expando,
2193 HTMLDocument_put_charset,
2194 HTMLDocument_get_charset,
2195 HTMLDocument_put_defaultCharset,
2196 HTMLDocument_get_defaultCharset,
2197 HTMLDocument_get_mimeType,
2198 HTMLDocument_get_fileSize,
2199 HTMLDocument_get_fileCreatedDate,
2200 HTMLDocument_get_fileModifiedDate,
2201 HTMLDocument_get_fileUpdatedDate,
2202 HTMLDocument_get_security,
2203 HTMLDocument_get_protocol,
2204 HTMLDocument_get_nameProp,
2205 HTMLDocument_write,
2206 HTMLDocument_writeln,
2207 HTMLDocument_open,
2208 HTMLDocument_close,
2209 HTMLDocument_clear,
2210 HTMLDocument_queryCommandSupported,
2211 HTMLDocument_queryCommandEnabled,
2212 HTMLDocument_queryCommandState,
2213 HTMLDocument_queryCommandIndeterm,
2214 HTMLDocument_queryCommandText,
2215 HTMLDocument_queryCommandValue,
2216 HTMLDocument_execCommand,
2217 HTMLDocument_execCommandShowHelp,
2218 HTMLDocument_createElement,
2219 HTMLDocument_put_onhelp,
2220 HTMLDocument_get_onhelp,
2221 HTMLDocument_put_onclick,
2222 HTMLDocument_get_onclick,
2223 HTMLDocument_put_ondblclick,
2224 HTMLDocument_get_ondblclick,
2225 HTMLDocument_put_onkeyup,
2226 HTMLDocument_get_onkeyup,
2227 HTMLDocument_put_onkeydown,
2228 HTMLDocument_get_onkeydown,
2229 HTMLDocument_put_onkeypress,
2230 HTMLDocument_get_onkeypress,
2231 HTMLDocument_put_onmouseup,
2232 HTMLDocument_get_onmouseup,
2233 HTMLDocument_put_onmousedown,
2234 HTMLDocument_get_onmousedown,
2235 HTMLDocument_put_onmousemove,
2236 HTMLDocument_get_onmousemove,
2237 HTMLDocument_put_onmouseout,
2238 HTMLDocument_get_onmouseout,
2239 HTMLDocument_put_onmouseover,
2240 HTMLDocument_get_onmouseover,
2241 HTMLDocument_put_onreadystatechange,
2242 HTMLDocument_get_onreadystatechange,
2243 HTMLDocument_put_onafterupdate,
2244 HTMLDocument_get_onafterupdate,
2245 HTMLDocument_put_onrowexit,
2246 HTMLDocument_get_onrowexit,
2247 HTMLDocument_put_onrowenter,
2248 HTMLDocument_get_onrowenter,
2249 HTMLDocument_put_ondragstart,
2250 HTMLDocument_get_ondragstart,
2251 HTMLDocument_put_onselectstart,
2252 HTMLDocument_get_onselectstart,
2253 HTMLDocument_elementFromPoint,
2254 HTMLDocument_get_parentWindow,
2255 HTMLDocument_get_styleSheets,
2256 HTMLDocument_put_onbeforeupdate,
2257 HTMLDocument_get_onbeforeupdate,
2258 HTMLDocument_put_onerrorupdate,
2259 HTMLDocument_get_onerrorupdate,
2260 HTMLDocument_toString,
2261 HTMLDocument_createStyleSheet
2264 static inline HTMLDocumentNode *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
2266 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument3_iface);
2269 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface, REFIID riid, void **ppv)
2271 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2272 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2275 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
2277 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2278 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2281 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
2283 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2284 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2287 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
2289 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2290 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2293 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo, LCID lcid,
2294 ITypeInfo **ppTInfo)
2296 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2297 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2300 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid, LPOLESTR *rgszNames,
2301 UINT cNames, LCID lcid, DISPID *rgDispId)
2303 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2304 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2307 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2308 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2310 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2311 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2312 pDispParams, pVarResult, pExcepInfo, puArgErr);
2315 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
2317 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2318 FIXME("(%p)\n", This);
2319 return E_NOTIMPL;
2322 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
2324 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2326 WARN("(%p)->(%x)\n", This, fForce);
2328 /* Doing nothing here should be fine for us. */
2329 return S_OK;
2332 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text, IHTMLDOMNode **newTextNode)
2334 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2335 nsIDOMText *nstext;
2336 HTMLDOMNode *node;
2337 nsAString text_str;
2338 nsresult nsres;
2339 HRESULT hres;
2341 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
2343 if(!This->dom_document) {
2344 WARN("NULL dom_document\n");
2345 return E_UNEXPECTED;
2348 nsAString_InitDepend(&text_str, text);
2349 nsres = nsIDOMDocument_CreateTextNode(This->dom_document, &text_str, &nstext);
2350 nsAString_Finish(&text_str);
2351 if(NS_FAILED(nsres)) {
2352 ERR("CreateTextNode failed: %08lx\n", nsres);
2353 return E_FAIL;
2356 hres = HTMLDOMTextNode_Create(This, (nsIDOMNode*)nstext, &node);
2357 nsIDOMText_Release(nstext);
2358 if(FAILED(hres))
2359 return hres;
2361 *newTextNode = &node->IHTMLDOMNode_iface;
2362 return S_OK;
2365 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
2367 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2368 nsIDOMElement *nselem = NULL;
2369 HTMLElement *element;
2370 nsresult nsres;
2371 HRESULT hres;
2373 TRACE("(%p)->(%p)\n", This, p);
2375 if(This->outer_window && This->outer_window->readystate == READYSTATE_UNINITIALIZED) {
2376 *p = NULL;
2377 return S_OK;
2380 if(!This->dom_document) {
2381 WARN("NULL dom_document\n");
2382 return E_UNEXPECTED;
2385 nsres = nsIDOMDocument_GetDocumentElement(This->dom_document, &nselem);
2386 if(NS_FAILED(nsres)) {
2387 ERR("GetDocumentElement failed: %08lx\n", nsres);
2388 return E_FAIL;
2391 if(!nselem) {
2392 *p = NULL;
2393 return S_OK;
2396 hres = get_element(nselem, &element);
2397 nsIDOMElement_Release(nselem);
2398 if(FAILED(hres))
2399 return hres;
2401 *p = &element->IHTMLElement_iface;
2402 return hres;
2405 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2407 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2409 TRACE("(%p)->(%p)\n", This, p);
2411 return elem_unique_id(++This->unique_id, p);
2414 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch* pDisp,
2415 VARIANT_BOOL *pfResult)
2417 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2419 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2421 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2424 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch *pDisp)
2426 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2428 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2430 return detach_event(&This->node.event_target, event, pDisp);
2433 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2435 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2436 FIXME("(%p)->()\n", This);
2437 return E_NOTIMPL;
2440 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2442 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2443 FIXME("(%p)->(%p)\n", This, p);
2444 return E_NOTIMPL;
2447 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2449 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2450 FIXME("(%p)->()\n", This);
2451 return E_NOTIMPL;
2454 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2456 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2457 FIXME("(%p)->(%p)\n", This, p);
2458 return E_NOTIMPL;
2461 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2463 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2464 FIXME("(%p)->()\n", This);
2465 return E_NOTIMPL;
2468 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2470 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2471 FIXME("(%p)->(%p)\n", This, p);
2472 return E_NOTIMPL;
2475 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2477 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2478 FIXME("(%p)->()\n", This);
2479 return E_NOTIMPL;
2482 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2484 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2485 FIXME("(%p)->(%p)\n", This, p);
2486 return E_NOTIMPL;
2489 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2491 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2492 FIXME("(%p)->()\n", This);
2493 return E_NOTIMPL;
2496 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2498 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2499 FIXME("(%p)->(%p)\n", This, p);
2500 return E_NOTIMPL;
2503 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2505 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2506 FIXME("(%p)->()\n", This);
2507 return E_NOTIMPL;
2510 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2512 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2513 FIXME("(%p)->(%p)\n", This, p);
2514 return E_NOTIMPL;
2517 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2519 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2520 FIXME("(%p)->()\n", This);
2521 return E_NOTIMPL;
2524 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2526 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2527 FIXME("(%p)->(%p)\n", This, p);
2528 return E_NOTIMPL;
2531 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2533 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2534 nsAString dir_str;
2535 nsresult nsres;
2537 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2539 if(!This->dom_document) {
2540 FIXME("NULL dom_document\n");
2541 return E_UNEXPECTED;
2544 nsAString_InitDepend(&dir_str, v);
2545 nsres = nsIDOMDocument_SetDir(This->dom_document, &dir_str);
2546 nsAString_Finish(&dir_str);
2547 if(NS_FAILED(nsres)) {
2548 ERR("SetDir failed: %08lx\n", nsres);
2549 return E_FAIL;
2552 return S_OK;
2555 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2557 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2558 nsAString dir_str;
2559 nsresult nsres;
2561 TRACE("(%p)->(%p)\n", This, p);
2563 if(!This->dom_document) {
2564 FIXME("NULL dom_document\n");
2565 return E_UNEXPECTED;
2568 nsAString_Init(&dir_str, NULL);
2569 nsres = nsIDOMDocument_GetDir(This->dom_document, &dir_str);
2570 return return_nsstr(nsres, &dir_str, p);
2573 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2575 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2577 TRACE("(%p)->()\n", This);
2579 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2582 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2584 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2586 TRACE("(%p)->(%p)\n", This, p);
2588 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2591 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2593 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2594 FIXME("(%p)->()\n", This);
2595 return E_NOTIMPL;
2598 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2600 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2601 FIXME("(%p)->(%p)\n", This, p);
2602 return E_NOTIMPL;
2605 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface, IHTMLDocument2 **ppNewDoc)
2607 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2608 nsIDOMDocumentFragment *doc_frag;
2609 HTMLDocumentNode *docnode;
2610 nsresult nsres;
2611 HRESULT hres;
2613 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2615 if(!This->dom_document) {
2616 FIXME("NULL dom_document\n");
2617 return E_NOTIMPL;
2620 nsres = nsIDOMDocument_CreateDocumentFragment(This->dom_document, &doc_frag);
2621 if(NS_FAILED(nsres)) {
2622 ERR("CreateDocumentFragment failed: %08lx\n", nsres);
2623 return E_FAIL;
2626 hres = create_document_fragment((nsIDOMNode*)doc_frag, This, &docnode);
2627 nsIDOMDocumentFragment_Release(doc_frag);
2628 if(FAILED(hres))
2629 return hres;
2631 *ppNewDoc = &docnode->IHTMLDocument2_iface;
2632 return S_OK;
2635 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface, IHTMLDocument2 **p)
2637 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2638 FIXME("(%p)->(%p)\n", This, p);
2639 return E_NOTIMPL;
2642 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL v)
2644 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2645 FIXME("(%p)->(%x)\n", This, v);
2646 return E_NOTIMPL;
2649 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2651 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2652 FIXME("(%p)->(%p)\n", This, p);
2653 return E_NOTIMPL;
2656 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2658 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2659 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2660 return E_NOTIMPL;
2663 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2665 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2666 FIXME("(%p)->(%p)\n", This, p);
2667 return E_NOTIMPL;
2670 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2672 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2674 TRACE("(%p)->(%p)\n", This, p);
2676 return IHTMLDOMNode_get_childNodes(&This->node.IHTMLDOMNode_iface, p);
2679 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL v)
2681 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2682 FIXME("(%p)->()\n", This);
2683 return E_NOTIMPL;
2686 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2688 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2689 FIXME("(%p)->(%p)\n", This, p);
2690 return E_NOTIMPL;
2693 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2695 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2696 FIXME("(%p)->()\n", This);
2697 return E_NOTIMPL;
2700 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2702 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2703 FIXME("(%p)->(%p)\n", This, p);
2704 return E_NOTIMPL;
2707 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2708 IHTMLElementCollection **ppelColl)
2710 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2711 nsIDOMNodeList *node_list;
2712 nsAString selector_str;
2713 WCHAR *selector;
2714 nsresult nsres;
2715 static const WCHAR formatW[] = L"*[id=%s],*[name=%s]";
2717 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2719 if(!This->dom_document) {
2720 /* We should probably return an empty collection. */
2721 FIXME("No dom_document\n");
2722 return E_NOTIMPL;
2725 selector = malloc(2 * SysStringLen(v) * sizeof(WCHAR) + sizeof(formatW));
2726 if(!selector)
2727 return E_OUTOFMEMORY;
2728 swprintf(selector, 2*SysStringLen(v) + ARRAY_SIZE(formatW), formatW, v, v);
2731 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2732 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2733 * types and search should be case insensitive. Those are currently not supported properly.
2735 nsAString_InitDepend(&selector_str, selector);
2736 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &selector_str, &node_list);
2737 nsAString_Finish(&selector_str);
2738 free(selector);
2739 if(NS_FAILED(nsres)) {
2740 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2741 return E_FAIL;
2744 *ppelColl = create_collection_from_nodelist(node_list, This->document_mode);
2745 nsIDOMNodeList_Release(node_list);
2746 return S_OK;
2750 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v, IHTMLElement **pel)
2752 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2753 HTMLElement *elem;
2754 HRESULT hres;
2756 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2758 hres = get_doc_elem_by_id(This, v, &elem);
2759 if(FAILED(hres) || !elem) {
2760 *pel = NULL;
2761 return hres;
2764 *pel = &elem->IHTMLElement_iface;
2765 return S_OK;
2769 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2770 IHTMLElementCollection **pelColl)
2772 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2773 nsIDOMNodeList *nslist;
2774 nsAString id_str;
2775 nsresult nsres;
2777 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2779 if(This->dom_document) {
2780 nsAString_InitDepend(&id_str, v);
2781 nsres = nsIDOMDocument_GetElementsByTagName(This->dom_document, &id_str, &nslist);
2782 nsAString_Finish(&id_str);
2783 if(FAILED(nsres)) {
2784 ERR("GetElementByName failed: %08lx\n", nsres);
2785 return E_FAIL;
2787 }else {
2788 nsIDOMDocumentFragment *docfrag;
2789 nsAString nsstr;
2791 if(v) {
2792 const WCHAR *ptr;
2793 for(ptr=v; *ptr; ptr++) {
2794 if(!iswalnum(*ptr)) {
2795 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2796 return E_NOTIMPL;
2801 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2802 if(NS_FAILED(nsres)) {
2803 ERR("Could not get nsIDOMDocumentFragment iface: %08lx\n", nsres);
2804 return E_UNEXPECTED;
2807 nsAString_InitDepend(&nsstr, v);
2808 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2809 nsAString_Finish(&nsstr);
2810 nsIDOMDocumentFragment_Release(docfrag);
2811 if(NS_FAILED(nsres)) {
2812 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2813 return E_FAIL;
2818 *pelColl = create_collection_from_nodelist(nslist, This->document_mode);
2819 nsIDOMNodeList_Release(nslist);
2821 return S_OK;
2824 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2825 HTMLDocument3_QueryInterface,
2826 HTMLDocument3_AddRef,
2827 HTMLDocument3_Release,
2828 HTMLDocument3_GetTypeInfoCount,
2829 HTMLDocument3_GetTypeInfo,
2830 HTMLDocument3_GetIDsOfNames,
2831 HTMLDocument3_Invoke,
2832 HTMLDocument3_releaseCapture,
2833 HTMLDocument3_recalc,
2834 HTMLDocument3_createTextNode,
2835 HTMLDocument3_get_documentElement,
2836 HTMLDocument3_get_uniqueID,
2837 HTMLDocument3_attachEvent,
2838 HTMLDocument3_detachEvent,
2839 HTMLDocument3_put_onrowsdelete,
2840 HTMLDocument3_get_onrowsdelete,
2841 HTMLDocument3_put_onrowsinserted,
2842 HTMLDocument3_get_onrowsinserted,
2843 HTMLDocument3_put_oncellchange,
2844 HTMLDocument3_get_oncellchange,
2845 HTMLDocument3_put_ondatasetchanged,
2846 HTMLDocument3_get_ondatasetchanged,
2847 HTMLDocument3_put_ondataavailable,
2848 HTMLDocument3_get_ondataavailable,
2849 HTMLDocument3_put_ondatasetcomplete,
2850 HTMLDocument3_get_ondatasetcomplete,
2851 HTMLDocument3_put_onpropertychange,
2852 HTMLDocument3_get_onpropertychange,
2853 HTMLDocument3_put_dir,
2854 HTMLDocument3_get_dir,
2855 HTMLDocument3_put_oncontextmenu,
2856 HTMLDocument3_get_oncontextmenu,
2857 HTMLDocument3_put_onstop,
2858 HTMLDocument3_get_onstop,
2859 HTMLDocument3_createDocumentFragment,
2860 HTMLDocument3_get_parentDocument,
2861 HTMLDocument3_put_enableDownload,
2862 HTMLDocument3_get_enableDownload,
2863 HTMLDocument3_put_baseUrl,
2864 HTMLDocument3_get_baseUrl,
2865 HTMLDocument3_get_childNodes,
2866 HTMLDocument3_put_inheritStyleSheets,
2867 HTMLDocument3_get_inheritStyleSheets,
2868 HTMLDocument3_put_onbeforeeditfocus,
2869 HTMLDocument3_get_onbeforeeditfocus,
2870 HTMLDocument3_getElementsByName,
2871 HTMLDocument3_getElementById,
2872 HTMLDocument3_getElementsByTagName
2875 static inline HTMLDocumentNode *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2877 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument4_iface);
2880 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface, REFIID riid, void **ppv)
2882 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2883 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2886 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2888 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2889 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2892 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2894 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2895 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2898 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2900 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2901 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2904 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo, LCID lcid,
2905 ITypeInfo **ppTInfo)
2907 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2908 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2911 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid, LPOLESTR *rgszNames,
2912 UINT cNames, LCID lcid, DISPID *rgDispId)
2914 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2915 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2918 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2919 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2921 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2922 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2923 pDispParams, pVarResult, pExcepInfo, puArgErr);
2926 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2928 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2929 nsIDOMHTMLElement *nsbody;
2930 nsresult nsres;
2932 TRACE("(%p)->()\n", This);
2934 if(!This->html_document) {
2935 FIXME("Not implemented for XML document\n");
2936 return E_NOTIMPL;
2939 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, &nsbody);
2940 if(NS_FAILED(nsres) || !nsbody) {
2941 ERR("GetBody failed: %08lx\n", nsres);
2942 return E_FAIL;
2945 nsres = nsIDOMHTMLElement_Focus(nsbody);
2946 nsIDOMHTMLElement_Release(nsbody);
2947 if(NS_FAILED(nsres)) {
2948 ERR("Focus failed: %08lx\n", nsres);
2949 return E_FAIL;
2952 return S_OK;
2955 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2957 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2958 cpp_bool has_focus;
2959 nsresult nsres;
2961 TRACE("(%p)->(%p)\n", This, pfFocus);
2963 if(!This->dom_document) {
2964 FIXME("Unimplemented for fragments.\n");
2965 return E_NOTIMPL;
2968 nsres = nsIDOMDocument_HasFocus(This->dom_document, &has_focus);
2969 assert(nsres == NS_OK);
2971 *pfFocus = variant_bool(has_focus);
2972 return S_OK;
2975 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2977 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2979 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2981 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2984 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2986 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2988 TRACE("(%p)->(%p)\n", This, p);
2990 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2993 static HRESULT WINAPI HTMLDocument4_get_namespaces(IHTMLDocument4 *iface, IDispatch **p)
2995 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2997 TRACE("(%p)->(%p)\n", This, p);
2999 if(!This->namespaces) {
3000 HRESULT hres;
3002 hres = create_namespace_collection(dispex_compat_mode(&This->node.event_target.dispex),
3003 &This->namespaces);
3004 if(FAILED(hres))
3005 return hres;
3008 IHTMLNamespaceCollection_AddRef(This->namespaces);
3009 *p = (IDispatch*)This->namespaces;
3010 return S_OK;
3013 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
3014 BSTR bstrOptions, IHTMLDocument2 **newDoc)
3016 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3017 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
3018 return E_NOTIMPL;
3021 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
3023 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3024 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3025 return E_NOTIMPL;
3028 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
3030 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3031 FIXME("(%p)->(%p)\n", This, p);
3032 return E_NOTIMPL;
3035 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
3036 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
3038 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3040 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
3042 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
3043 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
3044 return E_NOTIMPL;
3047 return create_event_obj(dispex_compat_mode(&This->node.event_target.dispex), ppEventObj);
3050 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
3051 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
3053 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3055 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
3057 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCanceled);
3060 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
3061 IHTMLRenderStyle **ppIHTMLRenderStyle)
3063 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3064 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
3065 return E_NOTIMPL;
3068 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
3070 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3071 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3072 return E_NOTIMPL;
3075 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
3077 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3078 FIXME("(%p)->(%p)\n", This, p);
3079 return E_NOTIMPL;
3082 static HRESULT WINAPI HTMLDocument4_get_URLUnencoded(IHTMLDocument4 *iface, BSTR *p)
3084 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3085 FIXME("(%p)->(%p)\n", This, p);
3086 return E_NOTIMPL;
3089 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
3090 HTMLDocument4_QueryInterface,
3091 HTMLDocument4_AddRef,
3092 HTMLDocument4_Release,
3093 HTMLDocument4_GetTypeInfoCount,
3094 HTMLDocument4_GetTypeInfo,
3095 HTMLDocument4_GetIDsOfNames,
3096 HTMLDocument4_Invoke,
3097 HTMLDocument4_focus,
3098 HTMLDocument4_hasFocus,
3099 HTMLDocument4_put_onselectionchange,
3100 HTMLDocument4_get_onselectionchange,
3101 HTMLDocument4_get_namespaces,
3102 HTMLDocument4_createDocumentFromUrl,
3103 HTMLDocument4_put_media,
3104 HTMLDocument4_get_media,
3105 HTMLDocument4_createEventObject,
3106 HTMLDocument4_fireEvent,
3107 HTMLDocument4_createRenderStyle,
3108 HTMLDocument4_put_oncontrolselect,
3109 HTMLDocument4_get_oncontrolselect,
3110 HTMLDocument4_get_URLUnencoded
3113 static inline HTMLDocumentNode *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
3115 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument5_iface);
3118 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface, REFIID riid, void **ppv)
3120 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3121 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3124 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
3126 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3127 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3130 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
3132 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3133 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3136 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
3138 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3139 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3142 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo, LCID lcid,
3143 ITypeInfo **ppTInfo)
3145 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3146 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3149 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid, LPOLESTR *rgszNames,
3150 UINT cNames, LCID lcid, DISPID *rgDispId)
3152 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3153 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3156 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3157 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3159 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3160 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3161 pDispParams, pVarResult, pExcepInfo, puArgErr);
3164 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
3166 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3168 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3170 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
3173 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
3175 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3177 TRACE("(%p)->(%p)\n", This, p);
3179 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
3182 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
3184 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3185 nsIDOMDocumentType *nsdoctype;
3186 HTMLDOMNode *doctype_node;
3187 nsresult nsres;
3188 HRESULT hres;
3190 TRACE("(%p)->(%p)\n", This, p);
3192 if(dispex_compat_mode(&This->node.event_target.dispex) < COMPAT_MODE_IE9) {
3193 *p = NULL;
3194 return S_OK;
3197 nsres = nsIDOMDocument_GetDoctype(This->dom_document, &nsdoctype);
3198 if(NS_FAILED(nsres))
3199 return map_nsresult(nsres);
3200 if(!nsdoctype) {
3201 *p = NULL;
3202 return S_OK;
3205 hres = get_node((nsIDOMNode*)nsdoctype, TRUE, &doctype_node);
3206 nsIDOMDocumentType_Release(nsdoctype);
3208 if(SUCCEEDED(hres))
3209 *p = &doctype_node->IHTMLDOMNode_iface;
3210 return hres;
3213 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
3215 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3217 TRACE("(%p)->(%p)\n", This, p);
3219 if(!This->dom_implementation) {
3220 HRESULT hres;
3222 hres = create_dom_implementation(This, &This->dom_implementation);
3223 if(FAILED(hres))
3224 return hres;
3227 IHTMLDOMImplementation_AddRef(This->dom_implementation);
3228 *p = This->dom_implementation;
3229 return S_OK;
3232 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
3233 IHTMLDOMAttribute **ppattribute)
3235 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3236 HTMLDOMAttribute *attr;
3237 HRESULT hres;
3239 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
3241 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, dispex_compat_mode(&This->node.event_target.dispex), &attr);
3242 if(FAILED(hres))
3243 return hres;
3245 *ppattribute = &attr->IHTMLDOMAttribute_iface;
3246 return S_OK;
3249 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
3250 IHTMLDOMNode **ppRetNode)
3252 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3253 nsIDOMComment *nscomment;
3254 HTMLElement *elem;
3255 nsAString str;
3256 nsresult nsres;
3257 HRESULT hres;
3259 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
3261 if(!This->dom_document) {
3262 WARN("NULL dom_document\n");
3263 return E_UNEXPECTED;
3266 nsAString_InitDepend(&str, bstrdata);
3267 nsres = nsIDOMDocument_CreateComment(This->dom_document, &str, &nscomment);
3268 nsAString_Finish(&str);
3269 if(NS_FAILED(nsres)) {
3270 ERR("CreateTextNode failed: %08lx\n", nsres);
3271 return E_FAIL;
3274 hres = HTMLCommentElement_Create(This, (nsIDOMNode*)nscomment, &elem);
3275 nsIDOMComment_Release(nscomment);
3276 if(FAILED(hres))
3277 return hres;
3279 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
3280 return S_OK;
3283 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
3285 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3287 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3289 return set_doc_event(This, EVENTID_FOCUSIN, &v);
3292 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
3294 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3296 TRACE("(%p)->(%p)\n", This, p);
3298 return get_doc_event(This, EVENTID_FOCUSIN, p);
3301 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
3303 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3305 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3307 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
3310 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
3312 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3314 TRACE("(%p)->(%p)\n", This, p);
3316 return get_doc_event(This, EVENTID_FOCUSOUT, p);
3319 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
3321 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3322 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3323 return E_NOTIMPL;
3326 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
3328 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3329 FIXME("(%p)->(%p)\n", This, p);
3330 return E_NOTIMPL;
3333 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
3335 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3336 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3337 return E_NOTIMPL;
3340 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
3342 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3343 FIXME("(%p)->(%p)\n", This, p);
3344 return E_NOTIMPL;
3347 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
3349 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3350 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3351 return E_NOTIMPL;
3354 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
3356 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3357 FIXME("(%p)->(%p)\n", This, p);
3358 return E_NOTIMPL;
3361 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
3363 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3364 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3365 return E_NOTIMPL;
3368 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
3370 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3371 FIXME("(%p)->(%p)\n", This, p);
3372 return E_NOTIMPL;
3375 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
3377 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3379 TRACE("(%p)->(%p)\n", This, p);
3381 *p = SysAllocString(This->document_mode <= COMPAT_MODE_IE5 ? L"BackCompat" : L"CSS1Compat");
3382 return *p ? S_OK : E_OUTOFMEMORY;
3385 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
3386 HTMLDocument5_QueryInterface,
3387 HTMLDocument5_AddRef,
3388 HTMLDocument5_Release,
3389 HTMLDocument5_GetTypeInfoCount,
3390 HTMLDocument5_GetTypeInfo,
3391 HTMLDocument5_GetIDsOfNames,
3392 HTMLDocument5_Invoke,
3393 HTMLDocument5_put_onmousewheel,
3394 HTMLDocument5_get_onmousewheel,
3395 HTMLDocument5_get_doctype,
3396 HTMLDocument5_get_implementation,
3397 HTMLDocument5_createAttribute,
3398 HTMLDocument5_createComment,
3399 HTMLDocument5_put_onfocusin,
3400 HTMLDocument5_get_onfocusin,
3401 HTMLDocument5_put_onfocusout,
3402 HTMLDocument5_get_onfocusout,
3403 HTMLDocument5_put_onactivate,
3404 HTMLDocument5_get_onactivate,
3405 HTMLDocument5_put_ondeactivate,
3406 HTMLDocument5_get_ondeactivate,
3407 HTMLDocument5_put_onbeforeactivate,
3408 HTMLDocument5_get_onbeforeactivate,
3409 HTMLDocument5_put_onbeforedeactivate,
3410 HTMLDocument5_get_onbeforedeactivate,
3411 HTMLDocument5_get_compatMode
3414 static inline HTMLDocumentNode *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3416 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument6_iface);
3419 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface, REFIID riid, void **ppv)
3421 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3422 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3425 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3427 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3428 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3431 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3433 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3434 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3437 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3439 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3440 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3443 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo, LCID lcid,
3444 ITypeInfo **ppTInfo)
3446 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3447 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3450 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid, LPOLESTR *rgszNames,
3451 UINT cNames, LCID lcid, DISPID *rgDispId)
3453 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3454 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3457 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3458 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3460 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3461 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3462 pDispParams, pVarResult, pExcepInfo, puArgErr);
3465 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3466 IHTMLDocumentCompatibleInfoCollection **p)
3468 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3469 FIXME("(%p)->(%p)\n", This, p);
3470 return E_NOTIMPL;
3473 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3475 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3477 TRACE("(%p)->(%p)\n", This, p);
3479 V_VT(p) = VT_R4;
3480 V_R4(p) = compat_mode_info[This->document_mode].document_mode;
3481 return S_OK;
3484 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3485 VARIANT *p)
3487 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3489 TRACE("(%p)->(%p)\n", This, p);
3491 return get_doc_event(This, EVENTID_STORAGE, p);
3494 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3496 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3498 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3500 return set_doc_event(This, EVENTID_STORAGE, &v);
3503 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3504 VARIANT *p)
3506 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3508 TRACE("(%p)->(%p)\n", This, p);
3510 return get_doc_event(This, EVENTID_STORAGECOMMIT, p);
3513 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3515 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3517 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3519 return set_doc_event(This, EVENTID_STORAGECOMMIT, &v);
3522 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3523 BSTR bstrId, IHTMLElement2 **p)
3525 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3526 nsIDOMElement *nselem;
3527 HTMLElement *elem;
3528 nsAString nsstr;
3529 nsresult nsres;
3530 HRESULT hres;
3532 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3535 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3536 * not search for name attributes, so we may simply let Gecko do the right thing.
3539 if(!This->dom_document) {
3540 FIXME("Not a document\n");
3541 return E_FAIL;
3544 nsAString_InitDepend(&nsstr, bstrId);
3545 nsres = nsIDOMDocument_GetElementById(This->dom_document, &nsstr, &nselem);
3546 nsAString_Finish(&nsstr);
3547 if(NS_FAILED(nsres)) {
3548 ERR("GetElementById failed: %08lx\n", nsres);
3549 return E_FAIL;
3552 if(!nselem) {
3553 *p = NULL;
3554 return S_OK;
3557 hres = get_element(nselem, &elem);
3558 nsIDOMElement_Release(nselem);
3559 if(FAILED(hres))
3560 return hres;
3562 *p = &elem->IHTMLElement2_iface;
3563 return S_OK;
3566 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3568 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3569 FIXME("(%p)->()\n", This);
3570 return E_NOTIMPL;
3573 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3574 HTMLDocument6_QueryInterface,
3575 HTMLDocument6_AddRef,
3576 HTMLDocument6_Release,
3577 HTMLDocument6_GetTypeInfoCount,
3578 HTMLDocument6_GetTypeInfo,
3579 HTMLDocument6_GetIDsOfNames,
3580 HTMLDocument6_Invoke,
3581 HTMLDocument6_get_compatible,
3582 HTMLDocument6_get_documentMode,
3583 HTMLDocument6_put_onstorage,
3584 HTMLDocument6_get_onstorage,
3585 HTMLDocument6_put_onstoragecommit,
3586 HTMLDocument6_get_onstoragecommit,
3587 HTMLDocument6_getElementById,
3588 HTMLDocument6_updateSettings
3591 static inline HTMLDocumentNode *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3593 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument7_iface);
3596 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3598 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3599 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3602 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3604 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3605 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3608 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3610 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3611 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3614 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3616 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3617 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3620 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo, LCID lcid,
3621 ITypeInfo **ppTInfo)
3623 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3624 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3627 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid, LPOLESTR *rgszNames,
3628 UINT cNames, LCID lcid, DISPID *rgDispId)
3630 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3631 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3634 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3635 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3637 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3638 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3639 pDispParams, pVarResult, pExcepInfo, puArgErr);
3642 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3644 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3646 TRACE("(%p)->(%p)\n", This, p);
3648 if(This->window && This->window->base.outer_window) {
3649 *p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
3650 IHTMLWindow2_AddRef(*p);
3651 }else {
3652 *p = NULL;
3654 return S_OK;
3657 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3659 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3660 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3661 return E_NOTIMPL;
3664 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3666 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3667 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3668 return E_NOTIMPL;
3671 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3672 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3674 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3675 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3676 return E_NOTIMPL;
3679 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3681 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3682 nsIDOMElement *dom_element;
3683 HTMLElement *element;
3684 nsAString ns, tag;
3685 nsresult nsres;
3686 HRESULT hres;
3688 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3690 if(!This->dom_document) {
3691 FIXME("NULL dom_document\n");
3692 return E_FAIL;
3695 if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
3696 FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
3698 nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
3699 nsAString_InitDepend(&tag, bstrTag);
3700 nsres = nsIDOMDocument_CreateElementNS(This->dom_document, &ns, &tag, &dom_element);
3701 nsAString_Finish(&ns);
3702 nsAString_Finish(&tag);
3703 if(NS_FAILED(nsres)) {
3704 WARN("CreateElementNS failed: %08lx\n", nsres);
3705 return map_nsresult(nsres);
3708 hres = HTMLElement_Create(This, (nsIDOMNode*)dom_element, FALSE, &element);
3709 nsIDOMElement_Release(dom_element);
3710 if(FAILED(hres))
3711 return hres;
3713 *newElem = &element->IHTMLElement_iface;
3714 return S_OK;
3717 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3718 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3720 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3721 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3722 return E_NOTIMPL;
3725 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3727 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3728 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3729 return E_NOTIMPL;
3732 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3734 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3736 TRACE("(%p)->(%p)\n", This, p);
3738 return get_doc_event(This, EVENTID_MSTHUMBNAILCLICK, p);
3741 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3743 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3744 nsAString charset_str;
3745 nsresult nsres;
3747 TRACE("(%p)->(%p)\n", This, p);
3749 if(!This->dom_document) {
3750 FIXME("NULL dom_document\n");
3751 return E_FAIL;
3754 nsAString_Init(&charset_str, NULL);
3755 nsres = nsIDOMDocument_GetCharacterSet(This->dom_document, &charset_str);
3756 return return_nsstr(nsres, &charset_str, p);
3759 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3761 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3763 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3765 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3768 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3770 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3772 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3774 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3777 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3779 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3780 nsIDOMNodeList *nslist;
3781 nsAString nsstr;
3782 nsresult nsres;
3784 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3786 if(!This->dom_document) {
3787 FIXME("NULL dom_document not supported\n");
3788 return E_NOTIMPL;
3791 nsAString_InitDepend(&nsstr, v);
3792 nsres = nsIDOMDocument_GetElementsByClassName(This->dom_document, &nsstr, &nslist);
3793 nsAString_Finish(&nsstr);
3794 if(FAILED(nsres)) {
3795 ERR("GetElementByClassName failed: %08lx\n", nsres);
3796 return E_FAIL;
3800 *pel = create_collection_from_nodelist(nslist, This->document_mode);
3801 nsIDOMNodeList_Release(nslist);
3802 return S_OK;
3805 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3806 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3808 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3809 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3810 return E_NOTIMPL;
3813 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3815 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3816 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3817 return E_NOTIMPL;
3820 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3822 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3823 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3824 return E_NOTIMPL;
3827 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3829 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3830 FIXME("(%p)->(%p)\n", This, p);
3831 return E_NOTIMPL;
3834 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3836 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3838 TRACE("(%p)->(%p)\n", This, p);
3840 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3843 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3845 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3846 FIXME("(%p)->(%p)\n", This, p);
3847 return E_NOTIMPL;
3850 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3852 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3853 FIXME("(%p)->(%p)\n", This, p);
3854 return E_NOTIMPL;
3857 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3859 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3860 FIXME("(%p)->(%x)\n", This, v);
3861 return E_NOTIMPL;
3864 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3866 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3867 FIXME("(%p)->(%p)\n", This, p);
3868 return E_NOTIMPL;
3871 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3873 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3874 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3875 return E_NOTIMPL;
3878 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3880 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3881 FIXME("(%p)->(%p)\n", This, p);
3882 return E_NOTIMPL;
3885 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3887 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3888 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3889 return E_NOTIMPL;
3892 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3894 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3896 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3898 return set_doc_event(This, EVENTID_ABORT, &v);
3901 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3903 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3905 TRACE("(%p)->(%p)\n", This, p);
3907 return get_doc_event(This, EVENTID_ABORT, p);
3910 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3912 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3914 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3916 return set_doc_event(This, EVENTID_BLUR, &v);
3919 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3921 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3923 TRACE("(%p)->(%p)\n", This, p);
3925 return get_doc_event(This, EVENTID_BLUR, p);
3928 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3930 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3931 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3932 return E_NOTIMPL;
3935 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3937 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3938 FIXME("(%p)->(%p)\n", This, p);
3939 return E_NOTIMPL;
3942 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3944 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3945 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3946 return E_NOTIMPL;
3949 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3951 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3952 FIXME("(%p)->(%p)\n", This, p);
3953 return E_NOTIMPL;
3956 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3958 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3960 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3962 return set_doc_event(This, EVENTID_CHANGE, &v);
3965 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3967 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3969 TRACE("(%p)->(%p)\n", This, p);
3971 return get_doc_event(This, EVENTID_CHANGE, p);
3974 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3976 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3978 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3980 return set_doc_event(This, EVENTID_DRAG, &v);
3983 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3985 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3987 TRACE("(%p)->(%p)\n", This, p);
3989 return get_doc_event(This, EVENTID_DRAG, p);
3992 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3994 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3995 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3996 return E_NOTIMPL;
3999 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
4001 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4002 FIXME("(%p)->(%p)\n", This, p);
4003 return E_NOTIMPL;
4006 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
4008 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4009 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4010 return E_NOTIMPL;
4013 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
4015 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4016 FIXME("(%p)->(%p)\n", This, p);
4017 return E_NOTIMPL;
4020 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
4022 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4023 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4024 return E_NOTIMPL;
4027 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
4029 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4030 FIXME("(%p)->(%p)\n", This, p);
4031 return E_NOTIMPL;
4034 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
4036 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4037 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4038 return E_NOTIMPL;
4041 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
4043 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4044 FIXME("(%p)->(%p)\n", This, p);
4045 return E_NOTIMPL;
4048 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
4050 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4051 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4052 return E_NOTIMPL;
4055 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
4057 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4058 FIXME("(%p)->(%p)\n", This, p);
4059 return E_NOTIMPL;
4062 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
4064 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4065 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4066 return E_NOTIMPL;
4069 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
4071 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4072 FIXME("(%p)->(%p)\n", This, p);
4073 return E_NOTIMPL;
4076 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
4078 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4079 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4080 return E_NOTIMPL;
4083 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
4085 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4086 FIXME("(%p)->(%p)\n", This, p);
4087 return E_NOTIMPL;
4090 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
4092 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4093 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4094 return E_NOTIMPL;
4097 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
4099 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4100 FIXME("(%p)->(%p)\n", This, p);
4101 return E_NOTIMPL;
4104 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
4106 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4108 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4110 return set_doc_event(This, EVENTID_ERROR, &v);
4113 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
4115 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4117 TRACE("(%p)->(%p)\n", This, p);
4119 return get_doc_event(This, EVENTID_ERROR, p);
4122 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
4124 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4126 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4128 return set_doc_event(This, EVENTID_FOCUS, &v);
4131 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
4133 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4135 TRACE("(%p)->(%p)\n", This, p);
4137 return get_doc_event(This, EVENTID_FOCUS, p);
4140 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
4142 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4144 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4146 return set_doc_event(This, EVENTID_INPUT, &v);
4149 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
4151 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4153 TRACE("(%p)->(%p)\n", This, p);
4155 return get_doc_event(This, EVENTID_INPUT, p);
4158 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
4160 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4162 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4164 return set_doc_event(This, EVENTID_LOAD, &v);
4167 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
4169 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4171 TRACE("(%p)->(%p)\n", This, p);
4173 return get_doc_event(This, EVENTID_LOAD, p);
4176 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
4178 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4179 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4180 return E_NOTIMPL;
4183 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
4185 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4186 FIXME("(%p)->(%p)\n", This, p);
4187 return E_NOTIMPL;
4190 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
4192 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4193 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4194 return E_NOTIMPL;
4197 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
4199 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4200 FIXME("(%p)->(%p)\n", This, p);
4201 return E_NOTIMPL;
4204 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
4206 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4207 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4208 return E_NOTIMPL;
4211 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
4213 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4214 FIXME("(%p)->(%p)\n", This, p);
4215 return E_NOTIMPL;
4218 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
4220 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4221 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4222 return E_NOTIMPL;
4225 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
4227 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4228 FIXME("(%p)->(%p)\n", This, p);
4229 return E_NOTIMPL;
4232 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
4234 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4235 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4236 return E_NOTIMPL;
4239 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
4241 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4242 FIXME("(%p)->(%p)\n", This, p);
4243 return E_NOTIMPL;
4246 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
4248 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4249 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4250 return E_NOTIMPL;
4253 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
4255 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4256 FIXME("(%p)->(%p)\n", This, p);
4257 return E_NOTIMPL;
4260 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
4262 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4263 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4264 return E_NOTIMPL;
4267 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
4269 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4270 FIXME("(%p)->(%p)\n", This, p);
4271 return E_NOTIMPL;
4274 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
4276 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4277 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4278 return E_NOTIMPL;
4281 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
4283 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4284 FIXME("(%p)->(%p)\n", This, p);
4285 return E_NOTIMPL;
4288 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
4290 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4291 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4292 return E_NOTIMPL;
4295 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
4297 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4298 FIXME("(%p)->(%p)\n", This, p);
4299 return E_NOTIMPL;
4302 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
4304 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4306 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4308 return set_doc_event(This, EVENTID_SCROLL, &v);
4311 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
4313 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4315 TRACE("(%p)->(%p)\n", This, p);
4317 return get_doc_event(This, EVENTID_SCROLL, p);
4320 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
4322 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4323 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4324 return E_NOTIMPL;
4327 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
4329 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4330 FIXME("(%p)->(%p)\n", This, p);
4331 return E_NOTIMPL;
4334 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
4336 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4337 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4338 return E_NOTIMPL;
4341 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
4343 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4344 FIXME("(%p)->(%p)\n", This, p);
4345 return E_NOTIMPL;
4348 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
4350 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4351 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4352 return E_NOTIMPL;
4355 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
4357 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4358 FIXME("(%p)->(%p)\n", This, p);
4359 return E_NOTIMPL;
4362 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
4364 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4365 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4366 return E_NOTIMPL;
4369 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
4371 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4372 FIXME("(%p)->(%p)\n", This, p);
4373 return E_NOTIMPL;
4376 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
4378 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4380 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4382 return set_doc_event(This, EVENTID_SUBMIT, &v);
4385 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
4387 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4389 TRACE("(%p)->(%p)\n", This, p);
4391 return get_doc_event(This, EVENTID_SUBMIT, p);
4394 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
4396 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4397 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4398 return E_NOTIMPL;
4401 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
4403 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4404 FIXME("(%p)->(%p)\n", This, p);
4405 return E_NOTIMPL;
4408 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
4410 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4411 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4412 return E_NOTIMPL;
4415 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
4417 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4418 FIXME("(%p)->(%p)\n", This, p);
4419 return E_NOTIMPL;
4422 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
4424 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4425 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4426 return E_NOTIMPL;
4429 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4431 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4432 FIXME("(%p)->(%p)\n", This, p);
4433 return E_NOTIMPL;
4436 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4438 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4439 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4440 return E_NOTIMPL;
4443 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4445 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4446 FIXME("(%p)->(%p)\n", This, p);
4447 return E_NOTIMPL;
4450 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4452 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4453 FIXME("(%p)\n", This);
4454 return E_NOTIMPL;
4457 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4458 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4460 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4461 nsIDOMNode *nsnode = NULL;
4462 HTMLDOMNode *node;
4463 nsresult nsres;
4464 HRESULT hres;
4466 TRACE("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4468 if(!This->dom_document) {
4469 WARN("NULL dom_document\n");
4470 return E_UNEXPECTED;
4473 if(!(node = unsafe_impl_from_IHTMLDOMNode(pNodeSource))) {
4474 ERR("not our node\n");
4475 return E_FAIL;
4478 nsres = nsIDOMDocument_ImportNode(This->dom_document, node->nsnode, !!fDeep, 1, &nsnode);
4479 if(NS_FAILED(nsres)) {
4480 ERR("ImportNode failed: %08lx\n", nsres);
4481 return map_nsresult(nsres);
4484 if(!nsnode) {
4485 *ppNodeDest = NULL;
4486 return S_OK;
4489 hres = get_node(nsnode, TRUE, &node);
4490 nsIDOMNode_Release(nsnode);
4491 if(FAILED(hres))
4492 return hres;
4494 *ppNodeDest = &node->IHTMLDOMNode3_iface;
4495 return hres;
4498 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4500 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4502 TRACE("(%p)->(%p)\n", This, p);
4504 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4507 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4509 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4510 FIXME("(%p)->(%p)\n", This, v);
4511 return E_NOTIMPL;
4514 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4516 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4518 TRACE("(%p)->(%p)\n", This, p);
4520 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4523 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4525 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4526 nsIDOMHTMLHeadElement *nshead;
4527 nsIDOMElement *nselem;
4528 HTMLElement *elem;
4529 nsresult nsres;
4530 HRESULT hres;
4532 TRACE("(%p)->(%p)\n", This, p);
4534 if(!This->dom_document) {
4535 FIXME("No document\n");
4536 return E_FAIL;
4539 if(!This->html_document) {
4540 FIXME("Not implemented for XML document\n");
4541 return E_NOTIMPL;
4544 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &nshead);
4545 assert(nsres == NS_OK);
4547 if(!nshead) {
4548 *p = NULL;
4549 return S_OK;
4552 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4553 nsIDOMHTMLHeadElement_Release(nshead);
4554 assert(nsres == NS_OK);
4556 hres = get_element(nselem, &elem);
4557 nsIDOMElement_Release(nselem);
4558 if(FAILED(hres))
4559 return hres;
4561 *p = &elem->IHTMLElement_iface;
4562 return S_OK;
4565 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4566 HTMLDocument7_QueryInterface,
4567 HTMLDocument7_AddRef,
4568 HTMLDocument7_Release,
4569 HTMLDocument7_GetTypeInfoCount,
4570 HTMLDocument7_GetTypeInfo,
4571 HTMLDocument7_GetIDsOfNames,
4572 HTMLDocument7_Invoke,
4573 HTMLDocument7_get_defaultView,
4574 HTMLDocument7_createCDATASection,
4575 HTMLDocument7_getSelection,
4576 HTMLDocument7_getElementsByTagNameNS,
4577 HTMLDocument7_createElementNS,
4578 HTMLDocument7_createAttributeNS,
4579 HTMLDocument7_put_onmsthumbnailclick,
4580 HTMLDocument7_get_onmsthumbnailclick,
4581 HTMLDocument7_get_characterSet,
4582 HTMLDocument7_createElement,
4583 HTMLDocument7_createAttribute,
4584 HTMLDocument7_getElementsByClassName,
4585 HTMLDocument7_createProcessingInstruction,
4586 HTMLDocument7_adoptNode,
4587 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4588 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4589 HTMLDocument7_get_all,
4590 HTMLDocument7_get_inputEncoding,
4591 HTMLDocument7_get_xmlEncoding,
4592 HTMLDocument7_put_xmlStandalone,
4593 HTMLDocument7_get_xmlStandalone,
4594 HTMLDocument7_put_xmlVersion,
4595 HTMLDocument7_get_xmlVersion,
4596 HTMLDocument7_hasAttributes,
4597 HTMLDocument7_put_onabort,
4598 HTMLDocument7_get_onabort,
4599 HTMLDocument7_put_onblur,
4600 HTMLDocument7_get_onblur,
4601 HTMLDocument7_put_oncanplay,
4602 HTMLDocument7_get_oncanplay,
4603 HTMLDocument7_put_oncanplaythrough,
4604 HTMLDocument7_get_oncanplaythrough,
4605 HTMLDocument7_put_onchange,
4606 HTMLDocument7_get_onchange,
4607 HTMLDocument7_put_ondrag,
4608 HTMLDocument7_get_ondrag,
4609 HTMLDocument7_put_ondragend,
4610 HTMLDocument7_get_ondragend,
4611 HTMLDocument7_put_ondragenter,
4612 HTMLDocument7_get_ondragenter,
4613 HTMLDocument7_put_ondragleave,
4614 HTMLDocument7_get_ondragleave,
4615 HTMLDocument7_put_ondragover,
4616 HTMLDocument7_get_ondragover,
4617 HTMLDocument7_put_ondrop,
4618 HTMLDocument7_get_ondrop,
4619 HTMLDocument7_put_ondurationchange,
4620 HTMLDocument7_get_ondurationchange,
4621 HTMLDocument7_put_onemptied,
4622 HTMLDocument7_get_onemptied,
4623 HTMLDocument7_put_onended,
4624 HTMLDocument7_get_onended,
4625 HTMLDocument7_put_onerror,
4626 HTMLDocument7_get_onerror,
4627 HTMLDocument7_put_onfocus,
4628 HTMLDocument7_get_onfocus,
4629 HTMLDocument7_put_oninput,
4630 HTMLDocument7_get_oninput,
4631 HTMLDocument7_put_onload,
4632 HTMLDocument7_get_onload,
4633 HTMLDocument7_put_onloadeddata,
4634 HTMLDocument7_get_onloadeddata,
4635 HTMLDocument7_put_onloadedmetadata,
4636 HTMLDocument7_get_onloadedmetadata,
4637 HTMLDocument7_put_onloadstart,
4638 HTMLDocument7_get_onloadstart,
4639 HTMLDocument7_put_onpause,
4640 HTMLDocument7_get_onpause,
4641 HTMLDocument7_put_onplay,
4642 HTMLDocument7_get_onplay,
4643 HTMLDocument7_put_onplaying,
4644 HTMLDocument7_get_onplaying,
4645 HTMLDocument7_put_onprogress,
4646 HTMLDocument7_get_onprogress,
4647 HTMLDocument7_put_onratechange,
4648 HTMLDocument7_get_onratechange,
4649 HTMLDocument7_put_onreset,
4650 HTMLDocument7_get_onreset,
4651 HTMLDocument7_put_onscroll,
4652 HTMLDocument7_get_onscroll,
4653 HTMLDocument7_put_onseekend,
4654 HTMLDocument7_get_onseekend,
4655 HTMLDocument7_put_onseeking,
4656 HTMLDocument7_get_onseeking,
4657 HTMLDocument7_put_onselect,
4658 HTMLDocument7_get_onselect,
4659 HTMLDocument7_put_onstalled,
4660 HTMLDocument7_get_onstalled,
4661 HTMLDocument7_put_onsubmit,
4662 HTMLDocument7_get_onsubmit,
4663 HTMLDocument7_put_onsuspend,
4664 HTMLDocument7_get_onsuspend,
4665 HTMLDocument7_put_ontimeupdate,
4666 HTMLDocument7_get_ontimeupdate,
4667 HTMLDocument7_put_onvolumechange,
4668 HTMLDocument7_get_onvolumechange,
4669 HTMLDocument7_put_onwaiting,
4670 HTMLDocument7_get_onwaiting,
4671 HTMLDocument7_normalize,
4672 HTMLDocument7_importNode,
4673 HTMLDocument7_get_parentWindow,
4674 HTMLDocument7_put_body,
4675 HTMLDocument7_get_body,
4676 HTMLDocument7_get_head
4679 static inline HTMLDocumentNode *impl_from_IDocumentSelector(IDocumentSelector *iface)
4681 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentSelector_iface);
4684 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4686 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4687 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4690 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4692 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4693 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4696 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4698 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4699 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4702 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4704 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4705 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4708 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4709 LCID lcid, ITypeInfo **ppTInfo)
4711 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4712 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4715 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4716 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4718 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4719 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4720 rgDispId);
4723 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4724 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4726 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4727 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4728 pDispParams, pVarResult, pExcepInfo, puArgErr);
4731 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4733 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4734 nsIDOMElement *nselem;
4735 HTMLElement *elem;
4736 nsAString nsstr;
4737 nsresult nsres;
4738 HRESULT hres;
4740 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4742 nsAString_InitDepend(&nsstr, v);
4743 nsres = nsIDOMDocument_QuerySelector(This->dom_document, &nsstr, &nselem);
4744 nsAString_Finish(&nsstr);
4745 if(NS_FAILED(nsres)) {
4746 WARN("QuerySelector failed: %08lx\n", nsres);
4747 return map_nsresult(nsres);
4750 if(!nselem) {
4751 *pel = NULL;
4752 return S_OK;
4755 hres = get_element(nselem, &elem);
4756 nsIDOMElement_Release(nselem);
4757 if(FAILED(hres))
4758 return hres;
4760 *pel = &elem->IHTMLElement_iface;
4761 return S_OK;
4764 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4766 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4767 nsIDOMNodeList *node_list;
4768 nsAString nsstr;
4769 nsresult nsres;
4770 HRESULT hres;
4772 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4774 nsAString_InitDepend(&nsstr, v);
4775 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &nsstr, &node_list);
4776 nsAString_Finish(&nsstr);
4777 if(NS_FAILED(nsres)) {
4778 WARN("QuerySelectorAll failed: %08lx\n", nsres);
4779 return map_nsresult(nsres);
4782 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
4783 nsIDOMNodeList_Release(node_list);
4784 return hres;
4787 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4788 DocumentSelector_QueryInterface,
4789 DocumentSelector_AddRef,
4790 DocumentSelector_Release,
4791 DocumentSelector_GetTypeInfoCount,
4792 DocumentSelector_GetTypeInfo,
4793 DocumentSelector_GetIDsOfNames,
4794 DocumentSelector_Invoke,
4795 DocumentSelector_querySelector,
4796 DocumentSelector_querySelectorAll
4799 static inline HTMLDocumentNode *impl_from_IDocumentEvent(IDocumentEvent *iface)
4801 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentEvent_iface);
4804 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4806 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4807 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4810 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4812 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4813 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4816 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4818 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4819 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4822 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4824 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4825 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4828 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4829 LCID lcid, ITypeInfo **ppTInfo)
4831 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4832 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4835 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4836 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4838 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4839 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4840 rgDispId);
4843 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4844 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4846 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4847 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4848 pDispParams, pVarResult, pExcepInfo, puArgErr);
4851 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4853 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4855 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4857 return create_document_event_str(This, eventType, p);
4860 static const IDocumentEventVtbl DocumentEventVtbl = {
4861 DocumentEvent_QueryInterface,
4862 DocumentEvent_AddRef,
4863 DocumentEvent_Release,
4864 DocumentEvent_GetTypeInfoCount,
4865 DocumentEvent_GetTypeInfo,
4866 DocumentEvent_GetIDsOfNames,
4867 DocumentEvent_Invoke,
4868 DocumentEvent_createEvent
4871 static void HTMLDocumentNode_on_advise(IUnknown *iface, cp_static_data_t *cp)
4873 HTMLDocumentNode *This = CONTAINING_RECORD((IHTMLDocument2*)iface, HTMLDocumentNode, IHTMLDocument2_iface);
4875 if(This->outer_window)
4876 update_doc_cp_events(This, cp);
4879 static inline HTMLDocumentNode *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4881 return CONTAINING_RECORD(iface, HTMLDocumentNode, ISupportErrorInfo_iface);
4884 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4886 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4887 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4890 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4892 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4893 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4896 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4898 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4899 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4902 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4904 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4905 return S_FALSE;
4908 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4909 SupportErrorInfo_QueryInterface,
4910 SupportErrorInfo_AddRef,
4911 SupportErrorInfo_Release,
4912 SupportErrorInfo_InterfaceSupportsErrorInfo
4915 static inline HTMLDocumentNode *impl_from_IDispatchEx(IDispatchEx *iface)
4917 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDispatchEx_iface);
4920 static HRESULT has_elem_name(nsIDOMHTMLDocument *html_document, const WCHAR *name)
4922 static const WCHAR fmt[] = L":-moz-any(applet,embed,form,iframe,img,object)[name=\"%s\"]";
4923 WCHAR buf[128], *selector = buf;
4924 nsAString selector_str;
4925 nsIDOMElement *nselem;
4926 nsresult nsres;
4927 size_t len;
4929 len = wcslen(name) + ARRAY_SIZE(fmt) - 2 /* %s */;
4930 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4931 return E_OUTOFMEMORY;
4932 swprintf(selector, len, fmt, name);
4934 nsAString_InitDepend(&selector_str, selector);
4935 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4936 nsAString_Finish(&selector_str);
4937 if(selector != buf)
4938 free(selector);
4939 if(NS_FAILED(nsres))
4940 return map_nsresult(nsres);
4942 if(!nselem)
4943 return DISP_E_UNKNOWNNAME;
4944 nsIDOMElement_Release(nselem);
4945 return S_OK;
4948 static HRESULT get_elem_by_name_or_id(nsIDOMHTMLDocument *html_document, const WCHAR *name, nsIDOMElement **ret)
4950 static const WCHAR fmt[] = L":-moz-any(embed,form,iframe,img):-moz-any([name=\"%s\"],[id=\"%s\"][name]),"
4951 L":-moz-any(applet,object):-moz-any([name=\"%s\"],[id=\"%s\"])";
4952 WCHAR buf[384], *selector = buf;
4953 nsAString selector_str;
4954 nsIDOMElement *nselem;
4955 nsresult nsres;
4956 size_t len;
4958 len = wcslen(name) * 4 + ARRAY_SIZE(fmt) - 8 /* %s */;
4959 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4960 return E_OUTOFMEMORY;
4961 swprintf(selector, len, fmt, name, name, name, name);
4963 nsAString_InitDepend(&selector_str, selector);
4964 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4965 nsAString_Finish(&selector_str);
4966 if(selector != buf)
4967 free(selector);
4968 if(NS_FAILED(nsres))
4969 return map_nsresult(nsres);
4971 if(ret) {
4972 *ret = nselem;
4973 return S_OK;
4976 if(nselem) {
4977 nsIDOMElement_Release(nselem);
4978 return S_OK;
4980 return DISP_E_UNKNOWNNAME;
4983 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, const WCHAR *name, DISPID *dispid)
4985 unsigned i;
4987 for(i=0; i < This->elem_vars_cnt; i++) {
4988 if(!wcscmp(name, This->elem_vars[i])) {
4989 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4990 return S_OK;
4994 if(This->elem_vars_cnt == This->elem_vars_size) {
4995 WCHAR **new_vars;
4997 if(This->elem_vars_size) {
4998 new_vars = realloc(This->elem_vars, This->elem_vars_size * 2 * sizeof(WCHAR*));
4999 if(!new_vars)
5000 return E_OUTOFMEMORY;
5001 This->elem_vars_size *= 2;
5002 }else {
5003 new_vars = malloc(16 * sizeof(WCHAR*));
5004 if(!new_vars)
5005 return E_OUTOFMEMORY;
5006 This->elem_vars_size = 16;
5009 This->elem_vars = new_vars;
5012 This->elem_vars[This->elem_vars_cnt] = wcsdup(name);
5013 if(!This->elem_vars[This->elem_vars_cnt])
5014 return E_OUTOFMEMORY;
5016 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
5017 return S_OK;
5020 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
5022 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5024 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5027 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
5029 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5031 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5034 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
5036 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5038 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5041 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
5043 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5045 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5048 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
5049 LCID lcid, ITypeInfo **ppTInfo)
5051 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5053 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5056 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
5057 LPOLESTR *rgszNames, UINT cNames,
5058 LCID lcid, DISPID *rgDispId)
5060 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5062 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
5065 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
5066 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5067 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5069 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5071 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
5072 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5074 return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags, pDispParams,
5075 pVarResult, pExcepInfo, NULL);
5078 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
5080 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5081 HRESULT hres;
5083 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex & ~fdexNameEnsure, pid);
5084 if(hres != DISP_E_UNKNOWNNAME)
5085 return hres;
5087 if(This->html_document) {
5088 hres = get_elem_by_name_or_id(This->html_document, bstrName, NULL);
5089 if(SUCCEEDED(hres))
5090 hres = dispid_from_elem_name(This, bstrName, pid);
5093 if(hres == DISP_E_UNKNOWNNAME && (grfdex & fdexNameEnsure))
5094 hres = dispex_get_dynid(&This->node.event_target.dispex, bstrName, FALSE, pid);
5095 return hres;
5098 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
5099 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
5101 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5103 if(This->window) {
5104 switch(id) {
5105 case DISPID_READYSTATE:
5106 TRACE("DISPID_READYSTATE\n");
5108 if(!(wFlags & DISPATCH_PROPERTYGET))
5109 return E_INVALIDARG;
5111 V_VT(pvarRes) = VT_I4;
5112 V_I4(pvarRes) = This->window->base.outer_window->readystate;
5113 return S_OK;
5114 default:
5115 break;
5119 return IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
5122 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
5124 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5126 return IDispatchEx_DeleteMemberByName(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex);
5129 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
5131 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5133 return IDispatchEx_DeleteMemberByDispID(&This->node.event_target.dispex.IDispatchEx_iface, id);
5136 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
5138 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5140 return IDispatchEx_GetMemberProperties(&This->node.event_target.dispex.IDispatchEx_iface, id, grfdexFetch, pgrfdex);
5143 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
5145 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5147 return IDispatchEx_GetMemberName(&This->node.event_target.dispex.IDispatchEx_iface, id, pbstrName);
5150 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
5152 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5154 return IDispatchEx_GetNextDispID(&This->node.event_target.dispex.IDispatchEx_iface, grfdex, id, pid);
5157 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
5159 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5161 return IDispatchEx_GetNameSpaceParent(&This->node.event_target.dispex.IDispatchEx_iface, ppunk);
5164 static const IDispatchExVtbl DocDispatchExVtbl = {
5165 DocDispatchEx_QueryInterface,
5166 DocDispatchEx_AddRef,
5167 DocDispatchEx_Release,
5168 DocDispatchEx_GetTypeInfoCount,
5169 DocDispatchEx_GetTypeInfo,
5170 DocDispatchEx_GetIDsOfNames,
5171 DocDispatchEx_Invoke,
5172 DocDispatchEx_GetDispID,
5173 DocDispatchEx_InvokeEx,
5174 DocDispatchEx_DeleteMemberByName,
5175 DocDispatchEx_DeleteMemberByDispID,
5176 DocDispatchEx_GetMemberProperties,
5177 DocDispatchEx_GetMemberName,
5178 DocDispatchEx_GetNextDispID,
5179 DocDispatchEx_GetNameSpaceParent
5182 static inline HTMLDocumentNode *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
5184 return CONTAINING_RECORD(iface, HTMLDocumentNode, IProvideMultipleClassInfo_iface);
5187 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
5188 REFIID riid, void **ppv)
5190 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5191 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5194 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
5196 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5197 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5200 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
5202 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5203 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5206 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
5208 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5209 TRACE("(%p)->(%p)\n", This, ppTI);
5210 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
5213 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
5215 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5216 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
5217 return E_NOTIMPL;
5220 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
5222 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5223 FIXME("(%p)->(%p)\n", This, pcti);
5224 *pcti = 1;
5225 return S_OK;
5228 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
5229 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
5231 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5232 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
5233 return E_NOTIMPL;
5236 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
5237 ProvideClassInfo_QueryInterface,
5238 ProvideClassInfo_AddRef,
5239 ProvideClassInfo_Release,
5240 ProvideClassInfo_GetClassInfo,
5241 ProvideClassInfo2_GetGUID,
5242 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
5243 ProvideMultipleClassInfo_GetInfoOfIndex
5246 /**********************************************************
5247 * IMarkupServices implementation
5249 static inline HTMLDocumentNode *impl_from_IMarkupServices(IMarkupServices *iface)
5251 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupServices_iface);
5254 static HRESULT WINAPI MarkupServices_QueryInterface(IMarkupServices *iface, REFIID riid, void **ppvObject)
5256 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5257 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5260 static ULONG WINAPI MarkupServices_AddRef(IMarkupServices *iface)
5262 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5263 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5266 static ULONG WINAPI MarkupServices_Release(IMarkupServices *iface)
5268 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5269 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5272 static HRESULT WINAPI MarkupServices_CreateMarkupPointer(IMarkupServices *iface, IMarkupPointer **ppPointer)
5274 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5276 TRACE("(%p)->(%p)\n", This, ppPointer);
5278 return create_markup_pointer(ppPointer);
5281 static HRESULT WINAPI MarkupServices_CreateMarkupContainer(IMarkupServices *iface, IMarkupContainer **ppMarkupContainer)
5283 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5284 FIXME("(%p)->(%p)\n", This, ppMarkupContainer);
5285 return E_NOTIMPL;
5288 static HRESULT WINAPI MarkupServices_CreateElement(IMarkupServices *iface,
5289 ELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement)
5291 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5292 FIXME("(%p)->(%d,%s,%p)\n", This, tagID, debugstr_w(pchAttributes), ppElement);
5293 return E_NOTIMPL;
5296 static HRESULT WINAPI MarkupServices_CloneElement(IMarkupServices *iface,
5297 IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone)
5299 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5300 FIXME("(%p)->(%p,%p)\n", This, pElemCloneThis, ppElementTheClone);
5301 return E_NOTIMPL;
5304 static HRESULT WINAPI MarkupServices_InsertElement(IMarkupServices *iface,
5305 IHTMLElement *pElementInsert, IMarkupPointer *pPointerStart,
5306 IMarkupPointer *pPointerFinish)
5308 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5309 FIXME("(%p)->(%p,%p,%p)\n", This, pElementInsert, pPointerStart, pPointerFinish);
5310 return E_NOTIMPL;
5313 static HRESULT WINAPI MarkupServices_RemoveElement(IMarkupServices *iface, IHTMLElement *pElementRemove)
5315 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5316 FIXME("(%p)->(%p)\n", This, pElementRemove);
5317 return E_NOTIMPL;
5320 static HRESULT WINAPI MarkupServices_Remove(IMarkupServices *iface,
5321 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5323 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5324 FIXME("(%p)->(%p,%p)\n", This, pPointerStart, pPointerFinish);
5325 return E_NOTIMPL;
5328 static HRESULT WINAPI MarkupServices_Copy(IMarkupServices *iface,
5329 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5330 IMarkupPointer *pPointerTarget)
5332 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5333 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5334 return E_NOTIMPL;
5337 static HRESULT WINAPI MarkupServices_Move(IMarkupServices *iface,
5338 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5339 IMarkupPointer *pPointerTarget)
5341 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5342 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5343 return E_NOTIMPL;
5346 static HRESULT WINAPI MarkupServices_InsertText(IMarkupServices *iface,
5347 OLECHAR *pchText, LONG cch, IMarkupPointer *pPointerTarget)
5349 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5350 FIXME("(%p)->(%s,%lx,%p)\n", This, debugstr_w(pchText), cch, pPointerTarget);
5351 return E_NOTIMPL;
5354 static HRESULT WINAPI MarkupServices_ParseString(IMarkupServices *iface,
5355 OLECHAR *pchHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5356 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5358 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5359 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(pchHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5360 return E_NOTIMPL;
5363 static HRESULT WINAPI MarkupServices_ParseGlobal(IMarkupServices *iface,
5364 HGLOBAL hglobalHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5365 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5367 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5368 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(hglobalHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5369 return E_NOTIMPL;
5372 static HRESULT WINAPI MarkupServices_IsScopedElement(IMarkupServices *iface,
5373 IHTMLElement *pElement, BOOL *pfScoped)
5375 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5376 FIXME("(%p)->(%p,%p)\n", This, pElement, pfScoped);
5377 return E_NOTIMPL;
5380 static HRESULT WINAPI MarkupServices_GetElementTagId(IMarkupServices *iface,
5381 IHTMLElement *pElement, ELEMENT_TAG_ID *ptagId)
5383 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5384 FIXME("(%p)->(%p,%p)\n", This, pElement, ptagId);
5385 return E_NOTIMPL;
5388 static HRESULT WINAPI MarkupServices_GetTagIDForName(IMarkupServices *iface,
5389 BSTR bstrName, ELEMENT_TAG_ID *ptagId)
5391 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5392 FIXME("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), ptagId);
5393 return E_NOTIMPL;
5396 static HRESULT WINAPI MarkupServices_GetNameForTagID(IMarkupServices *iface,
5397 ELEMENT_TAG_ID tagId, BSTR *pbstrName)
5399 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5400 FIXME("(%p)->(%d,%p)\n", This, tagId, pbstrName);
5401 return E_NOTIMPL;
5404 static HRESULT WINAPI MarkupServices_MovePointersToRange(IMarkupServices *iface,
5405 IHTMLTxtRange *pIRange, IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5407 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5408 FIXME("(%p)->(%p,%p,%p)\n", This, pIRange, pPointerStart, pPointerFinish);
5409 return E_NOTIMPL;
5412 static HRESULT WINAPI MarkupServices_MoveRangeToPointers(IMarkupServices *iface,
5413 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish, IHTMLTxtRange *pIRange)
5415 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5416 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerStart, pPointerFinish, pIRange);
5417 return E_NOTIMPL;
5420 static HRESULT WINAPI MarkupServices_BeginUndoUnit(IMarkupServices *iface, OLECHAR *pchTitle)
5422 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5423 FIXME("(%p)->(%s)\n", This, debugstr_w(pchTitle));
5424 return E_NOTIMPL;
5427 static HRESULT WINAPI MarkupServices_EndUndoUnit(IMarkupServices *iface)
5429 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5430 FIXME("(%p)\n", This);
5431 return E_NOTIMPL;
5434 static const IMarkupServicesVtbl MarkupServicesVtbl = {
5435 MarkupServices_QueryInterface,
5436 MarkupServices_AddRef,
5437 MarkupServices_Release,
5438 MarkupServices_CreateMarkupPointer,
5439 MarkupServices_CreateMarkupContainer,
5440 MarkupServices_CreateElement,
5441 MarkupServices_CloneElement,
5442 MarkupServices_InsertElement,
5443 MarkupServices_RemoveElement,
5444 MarkupServices_Remove,
5445 MarkupServices_Copy,
5446 MarkupServices_Move,
5447 MarkupServices_InsertText,
5448 MarkupServices_ParseString,
5449 MarkupServices_ParseGlobal,
5450 MarkupServices_IsScopedElement,
5451 MarkupServices_GetElementTagId,
5452 MarkupServices_GetTagIDForName,
5453 MarkupServices_GetNameForTagID,
5454 MarkupServices_MovePointersToRange,
5455 MarkupServices_MoveRangeToPointers,
5456 MarkupServices_BeginUndoUnit,
5457 MarkupServices_EndUndoUnit
5460 /**********************************************************
5461 * IMarkupContainer implementation
5463 static inline HTMLDocumentNode *impl_from_IMarkupContainer(IMarkupContainer *iface)
5465 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupContainer_iface);
5468 static HRESULT WINAPI MarkupContainer_QueryInterface(IMarkupContainer *iface, REFIID riid, void **ppvObject)
5470 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5471 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5474 static ULONG WINAPI MarkupContainer_AddRef(IMarkupContainer *iface)
5476 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5477 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5480 static ULONG WINAPI MarkupContainer_Release(IMarkupContainer *iface)
5482 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5483 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5486 static HRESULT WINAPI MarkupContainer_OwningDoc(IMarkupContainer *iface, IHTMLDocument2 **ppDoc)
5488 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5489 FIXME("(%p)->(%p)\n", This, ppDoc);
5490 return E_NOTIMPL;
5493 static const IMarkupContainerVtbl MarkupContainerVtbl = {
5494 MarkupContainer_QueryInterface,
5495 MarkupContainer_AddRef,
5496 MarkupContainer_Release,
5497 MarkupContainer_OwningDoc
5500 /**********************************************************
5501 * IDisplayServices implementation
5503 static inline HTMLDocumentNode *impl_from_IDisplayServices(IDisplayServices *iface)
5505 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDisplayServices_iface);
5508 static HRESULT WINAPI DisplayServices_QueryInterface(IDisplayServices *iface, REFIID riid, void **ppvObject)
5510 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5511 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5514 static ULONG WINAPI DisplayServices_AddRef(IDisplayServices *iface)
5516 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5517 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5520 static ULONG WINAPI DisplayServices_Release(IDisplayServices *iface)
5522 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5523 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5526 static HRESULT WINAPI DisplayServices_CreateDisplayPointer(IDisplayServices *iface, IDisplayPointer **ppDispPointer)
5528 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5529 FIXME("(%p)->(%p)\n", This, ppDispPointer);
5530 return E_NOTIMPL;
5533 static HRESULT WINAPI DisplayServices_TransformRect(IDisplayServices *iface,
5534 RECT *pRect, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5536 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5537 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_rect(pRect), eSource, eDestination, pIElement);
5538 return E_NOTIMPL;
5541 static HRESULT WINAPI DisplayServices_TransformPoint(IDisplayServices *iface,
5542 POINT *pPoint, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5544 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5545 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_point(pPoint), eSource, eDestination, pIElement);
5546 return E_NOTIMPL;
5549 static HRESULT WINAPI DisplayServices_GetCaret(IDisplayServices *iface, IHTMLCaret **ppCaret)
5551 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5552 FIXME("(%p)->(%p)\n", This, ppCaret);
5553 return E_NOTIMPL;
5556 static HRESULT WINAPI DisplayServices_GetComputedStyle(IDisplayServices *iface,
5557 IMarkupPointer *pPointer, IHTMLComputedStyle **ppComputedStyle)
5559 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5560 FIXME("(%p)->(%p,%p)\n", This, pPointer, ppComputedStyle);
5561 return E_NOTIMPL;
5564 static HRESULT WINAPI DisplayServices_ScrollRectIntoView(IDisplayServices *iface,
5565 IHTMLElement *pIElement, RECT rect)
5567 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5568 FIXME("(%p)->(%p,%s)\n", This, pIElement, wine_dbgstr_rect(&rect));
5569 return E_NOTIMPL;
5572 static HRESULT WINAPI DisplayServices_HasFlowLayout(IDisplayServices *iface,
5573 IHTMLElement *pIElement, BOOL *pfHasFlowLayout)
5575 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5576 FIXME("(%p)->(%p,%p)\n", This, pIElement, pfHasFlowLayout);
5577 return E_NOTIMPL;
5580 static const IDisplayServicesVtbl DisplayServicesVtbl = {
5581 DisplayServices_QueryInterface,
5582 DisplayServices_AddRef,
5583 DisplayServices_Release,
5584 DisplayServices_CreateDisplayPointer,
5585 DisplayServices_TransformRect,
5586 DisplayServices_TransformPoint,
5587 DisplayServices_GetCaret,
5588 DisplayServices_GetComputedStyle,
5589 DisplayServices_ScrollRectIntoView,
5590 DisplayServices_HasFlowLayout
5593 /**********************************************************
5594 * IDocumentRange implementation
5596 static inline HTMLDocumentNode *impl_from_IDocumentRange(IDocumentRange *iface)
5598 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentRange_iface);
5601 static HRESULT WINAPI DocumentRange_QueryInterface(IDocumentRange *iface, REFIID riid, void **ppv)
5603 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5605 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5608 static ULONG WINAPI DocumentRange_AddRef(IDocumentRange *iface)
5610 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5612 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5615 static ULONG WINAPI DocumentRange_Release(IDocumentRange *iface)
5617 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5619 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5622 static HRESULT WINAPI DocumentRange_GetTypeInfoCount(IDocumentRange *iface, UINT *pctinfo)
5624 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5626 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
5629 static HRESULT WINAPI DocumentRange_GetTypeInfo(IDocumentRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5631 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5633 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5636 static HRESULT WINAPI DocumentRange_GetIDsOfNames(IDocumentRange *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5637 LCID lcid, DISPID *rgDispId)
5639 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5641 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
5642 rgDispId);
5645 static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
5646 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5648 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5650 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5651 pDispParams, pVarResult, pExcepInfo, puArgErr);
5654 static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
5656 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5657 nsIDOMRange *nsrange;
5658 HRESULT hres;
5660 TRACE("(%p)->(%p)\n", This, p);
5662 if(!This->dom_document) {
5663 WARN("NULL dom_document\n");
5664 return E_UNEXPECTED;
5667 if(NS_FAILED(nsIDOMDocument_CreateRange(This->dom_document, &nsrange)))
5668 return E_FAIL;
5670 hres = create_dom_range(nsrange, dispex_compat_mode(&This->node.event_target.dispex), p);
5671 nsIDOMRange_Release(nsrange);
5672 return hres;
5675 static const IDocumentRangeVtbl DocumentRangeVtbl = {
5676 DocumentRange_QueryInterface,
5677 DocumentRange_AddRef,
5678 DocumentRange_Release,
5679 DocumentRange_GetTypeInfoCount,
5680 DocumentRange_GetTypeInfo,
5681 DocumentRange_GetIDsOfNames,
5682 DocumentRange_Invoke,
5683 DocumentRange_createRange
5686 static cp_static_data_t HTMLDocumentNodeEvents_data = { HTMLDocumentEvents_tid, HTMLDocumentNode_on_advise };
5687 static cp_static_data_t HTMLDocumentNodeEvents2_data = { HTMLDocumentEvents2_tid, HTMLDocumentNode_on_advise, TRUE };
5689 static const cpc_entry_t HTMLDocumentNode_cpc[] = {
5690 {&IID_IDispatch, &HTMLDocumentNodeEvents_data},
5691 {&IID_IPropertyNotifySink},
5692 {&DIID_HTMLDocumentEvents, &HTMLDocumentNodeEvents_data},
5693 {&DIID_HTMLDocumentEvents2, &HTMLDocumentNodeEvents2_data},
5694 {NULL}
5697 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5699 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
5702 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5704 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5706 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5708 if(IsEqualGUID(&IID_IUnknown, riid))
5709 *ppv = &This->IHTMLDocument2_iface;
5710 else if(IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDispatchEx, riid))
5711 *ppv = &This->IDispatchEx_iface;
5712 else if(IsEqualGUID(&IID_IHTMLDocument, riid) || IsEqualGUID(&IID_IHTMLDocument2, riid))
5713 *ppv = &This->IHTMLDocument2_iface;
5714 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
5715 *ppv = &This->IHTMLDocument3_iface;
5716 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
5717 *ppv = &This->IHTMLDocument4_iface;
5718 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
5719 *ppv = &This->IHTMLDocument5_iface;
5720 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
5721 *ppv = &This->IHTMLDocument6_iface;
5722 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
5723 *ppv = &This->IHTMLDocument7_iface;
5724 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
5725 *ppv = &This->IDocumentSelector_iface;
5726 else if(IsEqualGUID(&IID_IDocumentEvent, riid))
5727 *ppv = &This->IDocumentEvent_iface;
5728 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
5729 *ppv = &This->IHTMLDocument2_iface;
5730 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
5731 *ppv = &This->ISupportErrorInfo_iface;
5732 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
5733 *ppv = &This->IProvideMultipleClassInfo_iface;
5734 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
5735 *ppv = &This->IProvideMultipleClassInfo_iface;
5736 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
5737 *ppv = &This->IProvideMultipleClassInfo_iface;
5738 else if(IsEqualGUID(&IID_IMarkupServices, riid))
5739 *ppv = &This->IMarkupServices_iface;
5740 else if(IsEqualGUID(&IID_IMarkupContainer, riid))
5741 *ppv = &This->IMarkupContainer_iface;
5742 else if(IsEqualGUID(&IID_IDisplayServices, riid))
5743 *ppv = &This->IDisplayServices_iface;
5744 else if(IsEqualGUID(&IID_IDocumentRange, riid))
5745 *ppv = &This->IDocumentRange_iface;
5746 else if(IsEqualGUID(&IID_IPersist, riid))
5747 *ppv = &This->IPersistFile_iface;
5748 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
5749 *ppv = &This->IPersistMoniker_iface;
5750 else if(IsEqualGUID(&IID_IPersistFile, riid))
5751 *ppv = &This->IPersistFile_iface;
5752 else if(IsEqualGUID(&IID_IMonikerProp, riid))
5753 *ppv = &This->IMonikerProp_iface;
5754 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
5755 *ppv = &This->IPersistStreamInit_iface;
5756 else if(IsEqualGUID(&IID_IPersistHistory, riid))
5757 *ppv = &This->IPersistHistory_iface;
5758 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
5759 *ppv = &This->IHlinkTarget_iface;
5760 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
5761 *ppv = &This->IOleCommandTarget_iface;
5762 else if(IsEqualGUID(&IID_IOleObject, riid))
5763 *ppv = &This->IOleObject_iface;
5764 else if(IsEqualGUID(&IID_IOleDocument, riid))
5765 *ppv = &This->IOleDocument_iface;
5766 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
5767 *ppv = &This->IOleInPlaceActiveObject_iface;
5768 else if(IsEqualGUID(&IID_IOleWindow, riid))
5769 *ppv = &This->IOleInPlaceActiveObject_iface;
5770 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
5771 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5772 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
5773 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5774 else if(IsEqualGUID(&IID_IOleControl, riid))
5775 *ppv = &This->IOleControl_iface;
5776 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
5777 *ppv = &This->IObjectWithSite_iface;
5778 else if(IsEqualGUID(&IID_IOleContainer, riid))
5779 *ppv = &This->IOleContainer_iface;
5780 else if(IsEqualGUID(&IID_IObjectSafety, riid))
5781 *ppv = &This->IObjectSafety_iface;
5782 else if(IsEqualGUID(&IID_IServiceProvider, riid))
5783 *ppv = &This->IServiceProvider_iface;
5784 else if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
5785 *ppv = &This->IInternetHostSecurityManager_iface;
5786 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
5787 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5788 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
5789 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
5790 *ppv = NULL;
5791 return E_NOINTERFACE;
5792 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
5793 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
5794 *ppv = NULL;
5795 return E_NOINTERFACE;
5796 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
5797 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
5798 *ppv = NULL;
5799 return E_NOINTERFACE;
5800 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
5801 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
5802 *ppv = NULL;
5803 return E_NOINTERFACE;
5804 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
5805 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
5806 *ppv = NULL;
5807 return E_NOINTERFACE;
5808 }else {
5809 return HTMLDOMNode_QI(&This->node, riid, ppv);
5812 IUnknown_AddRef((IUnknown*)*ppv);
5813 return S_OK;
5816 void detach_document_node(HTMLDocumentNode *doc)
5818 unsigned i;
5820 while(!list_empty(&doc->plugin_hosts))
5821 detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
5823 if(doc->dom_implementation) {
5824 detach_dom_implementation(doc->dom_implementation);
5825 IHTMLDOMImplementation_Release(doc->dom_implementation);
5826 doc->dom_implementation = NULL;
5829 if(doc->namespaces) {
5830 IHTMLNamespaceCollection_Release(doc->namespaces);
5831 doc->namespaces = NULL;
5834 detach_events(doc);
5835 detach_selection(doc);
5836 detach_ranges(doc);
5838 for(i=0; i < doc->elem_vars_cnt; i++)
5839 free(doc->elem_vars[i]);
5840 free(doc->elem_vars);
5841 doc->elem_vars_cnt = doc->elem_vars_size = 0;
5842 doc->elem_vars = NULL;
5844 if(doc->catmgr) {
5845 ICatInformation_Release(doc->catmgr);
5846 doc->catmgr = NULL;
5849 if(!doc->dom_document && doc->window) {
5850 /* document fragments own reference to inner window */
5851 IHTMLWindow2_Release(&doc->window->base.IHTMLWindow2_iface);
5852 doc->window = NULL;
5855 if(doc->browser) {
5856 list_remove(&doc->browser_entry);
5857 doc->browser = NULL;
5861 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
5863 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5865 TRACE("(%p)\n", This);
5867 free(This->event_vector);
5868 ConnectionPointContainer_Destroy(&This->cp_container);
5871 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5873 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5874 FIXME("%p\n", This);
5875 return E_NOTIMPL;
5878 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
5880 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5882 if(This->dom_document)
5883 note_cc_edge((nsISupports*)This->dom_document, "This->dom_document", cb);
5886 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
5888 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5890 if(This->dom_document) {
5891 nsIDOMDocument *dom_document = This->dom_document;
5893 release_document_mutation(This);
5894 detach_document_node(This);
5895 This->dom_document = NULL;
5896 This->html_document = NULL;
5897 nsIDOMDocument_Release(dom_document);
5898 This->window = NULL;
5902 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
5903 &CLSID_HTMLDocument,
5904 HTMLDocumentNode_QI,
5905 HTMLDocumentNode_destructor,
5906 HTMLDocumentNode_cpc,
5907 HTMLDocumentNode_clone,
5908 NULL,
5909 NULL,
5910 NULL,
5911 NULL,
5912 NULL,
5913 NULL,
5914 NULL,
5915 NULL,
5916 NULL,
5917 NULL,
5918 NULL,
5919 NULL,
5920 HTMLDocumentNode_traverse,
5921 HTMLDocumentNode_unlink
5924 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5926 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5927 HTMLDocumentNode *new_node;
5928 HRESULT hres;
5930 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
5931 if(FAILED(hres))
5932 return hres;
5934 *ret = &new_node->node;
5935 return S_OK;
5938 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
5940 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
5943 static HRESULT HTMLDocumentNode_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
5945 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5946 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
5948 if(!This->dom_document || idx >= This->elem_vars_cnt)
5949 return DISP_E_MEMBERNOTFOUND;
5951 return (*name = SysAllocString(This->elem_vars[idx])) ? S_OK : E_OUTOFMEMORY;
5954 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5955 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5957 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5958 nsIDOMElement *nselem;
5959 HTMLDOMNode *node;
5960 unsigned i;
5961 HRESULT hres;
5963 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET))
5964 return MSHTML_E_INVALID_PROPERTY;
5966 i = id - MSHTML_DISPID_CUSTOM_MIN;
5968 if(!This->html_document || i >= This->elem_vars_cnt)
5969 return DISP_E_MEMBERNOTFOUND;
5971 hres = get_elem_by_name_or_id(This->html_document, This->elem_vars[i], &nselem);
5972 if(FAILED(hres))
5973 return hres;
5974 if(!nselem)
5975 return DISP_E_MEMBERNOTFOUND;
5977 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
5978 nsIDOMElement_Release(nselem);
5979 if(FAILED(hres))
5980 return hres;
5982 V_VT(res) = VT_DISPATCH;
5983 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5984 return S_OK;
5987 static HRESULT HTMLDocumentNode_next_dispid(DispatchEx *dispex, DISPID id, DISPID *pid)
5989 DWORD idx = (id == DISPID_STARTENUM) ? 0 : id - MSHTML_DISPID_CUSTOM_MIN + 1;
5990 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5991 nsIDOMNodeList *node_list;
5992 const PRUnichar *name;
5993 nsIDOMElement *nselem;
5994 nsIDOMNode *nsnode;
5995 nsAString nsstr;
5996 nsresult nsres;
5997 HRESULT hres;
5998 UINT32 i;
6000 if(!This->html_document)
6001 return S_FALSE;
6003 while(idx < This->elem_vars_cnt) {
6004 hres = has_elem_name(This->html_document, This->elem_vars[idx]);
6005 if(SUCCEEDED(hres)) {
6006 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
6007 return S_OK;
6009 if(hres != DISP_E_UNKNOWNNAME)
6010 return hres;
6011 idx++;
6014 /* Populate possibly missing DISPIDs */
6015 nsAString_InitDepend(&nsstr, L":-moz-any(applet,embed,form,iframe,img,object)[name]");
6016 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->html_document, &nsstr, &node_list);
6017 nsAString_Finish(&nsstr);
6018 if(NS_FAILED(nsres))
6019 return map_nsresult(nsres);
6021 for(i = 0, hres = S_OK; SUCCEEDED(hres); i++) {
6022 nsres = nsIDOMNodeList_Item(node_list, i, &nsnode);
6023 if(NS_FAILED(nsres)) {
6024 hres = map_nsresult(nsres);
6025 break;
6027 if(!nsnode)
6028 break;
6030 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
6031 nsIDOMNode_Release(nsnode);
6032 if(nsres != S_OK)
6033 continue;
6035 nsres = get_elem_attr_value(nselem, L"name", &nsstr, &name);
6036 nsIDOMElement_Release(nselem);
6037 if(NS_FAILED(nsres))
6038 hres = map_nsresult(nsres);
6039 else {
6040 hres = dispid_from_elem_name(This, name, &id);
6041 nsAString_Finish(&nsstr);
6044 nsIDOMNodeList_Release(node_list);
6045 if(FAILED(hres))
6046 return hres;
6048 if(idx >= This->elem_vars_cnt)
6049 return S_FALSE;
6051 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
6052 return S_OK;
6055 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
6057 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6059 TRACE("(%p) returning %u\n", This, This->document_mode);
6061 return lock_document_mode(This);
6064 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
6066 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6067 return (nsISupports*)This->node.nsnode;
6070 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
6072 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6073 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
6076 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
6078 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6079 if(!This->window)
6080 return NULL;
6081 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
6082 return &This->window->event_target;
6085 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
6087 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6088 ConnectionPointContainer *container = This->doc_obj
6089 ? &This->doc_obj->cp_container : &This->cp_container;
6090 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
6091 return container;
6094 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6096 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6097 return default_set_current_event(This->window, event);
6100 static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp, VARIANT *res,
6101 EXCEPINFO *ei, IServiceProvider *caller)
6103 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6105 if(!(flags & DISPATCH_PROPERTYPUT) || !This->outer_window)
6106 return S_FALSE;
6108 return IDispatchEx_InvokeEx(&This->outer_window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
6109 0, flags, dp, res, ei, caller);
6112 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
6114 NULL,
6115 NULL,
6116 HTMLDocumentNode_get_name,
6117 HTMLDocumentNode_invoke,
6118 NULL,
6119 HTMLDocumentNode_next_dispid,
6120 HTMLDocumentNode_get_compat_mode,
6121 NULL
6123 HTMLDocumentNode_get_gecko_target,
6124 HTMLDocumentNode_bind_event,
6125 NULL,
6126 HTMLDocumentNode_get_parent_event_target,
6127 NULL,
6128 HTMLDocumentNode_get_cp_container,
6129 HTMLDocumentNode_set_current_event
6132 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
6133 &CLSID_HTMLDocument,
6134 HTMLDocumentNode_QI,
6135 HTMLDocumentNode_destructor,
6136 HTMLDocumentNode_cpc,
6137 HTMLDocumentFragment_clone
6140 static const tid_t HTMLDocumentNode_iface_tids[] = {
6141 IHTMLDOMNode_tid,
6142 IHTMLDOMNode2_tid,
6143 IHTMLDocument4_tid,
6144 IHTMLDocument5_tid,
6145 IDocumentSelector_tid,
6149 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6151 static const dispex_hook_t document2_hooks[] = {
6152 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6153 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6154 {DISPID_UNKNOWN}
6156 static const dispex_hook_t document2_ie11_hooks[] = {
6157 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6158 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6159 {DISPID_IHTMLDOCUMENT2_CREATESTYLESHEET, NULL},
6160 {DISPID_IHTMLDOCUMENT2_FILESIZE, NULL},
6161 {DISPID_IHTMLDOCUMENT2_SELECTION, NULL},
6162 {DISPID_UNKNOWN}
6164 static const dispex_hook_t document3_ie11_hooks[] = {
6165 {DISPID_IHTMLDOCUMENT3_ATTACHEVENT, NULL},
6166 {DISPID_IHTMLDOCUMENT3_DETACHEVENT, NULL},
6167 {DISPID_UNKNOWN}
6169 static const dispex_hook_t document6_ie9_hooks[] = {
6170 {DISPID_IHTMLDOCUMENT6_ONSTORAGE},
6171 {DISPID_UNKNOWN}
6174 HTMLDOMNode_init_dispex_info(info, mode);
6176 if(mode >= COMPAT_MODE_IE9) {
6177 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
6178 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
6181 /* Depending on compatibility version, we add interfaces in different order
6182 * so that the right getElementById implementation is used. */
6183 if(mode < COMPAT_MODE_IE8) {
6184 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
6185 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
6186 }else {
6187 dispex_info_add_interface(info, IHTMLDocument6_tid, mode >= COMPAT_MODE_IE9 ? document6_ie9_hooks : NULL);
6188 dispex_info_add_interface(info, IHTMLDocument3_tid, mode >= COMPAT_MODE_IE11 ? document3_ie11_hooks : NULL);
6190 dispex_info_add_interface(info, IHTMLDocument2_tid, mode >= COMPAT_MODE_IE11 ? document2_ie11_hooks : document2_hooks);
6193 static dispex_static_data_t HTMLDocumentNode_dispex = {
6194 L"HTMLDocument",
6195 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
6196 DispHTMLDocument_tid,
6197 HTMLDocumentNode_iface_tids,
6198 HTMLDocumentNode_init_dispex_info
6201 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
6203 HTMLDocumentNode *doc;
6205 doc = calloc(1, sizeof(HTMLDocumentNode));
6206 if(!doc)
6207 return NULL;
6209 doc->ref = 1;
6210 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
6211 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
6212 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
6213 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
6214 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
6215 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
6216 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
6217 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
6218 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
6219 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
6220 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
6221 doc->IMarkupServices_iface.lpVtbl = &MarkupServicesVtbl;
6222 doc->IMarkupContainer_iface.lpVtbl = &MarkupContainerVtbl;
6223 doc->IDisplayServices_iface.lpVtbl = &DisplayServicesVtbl;
6224 doc->IDocumentRange_iface.lpVtbl = &DocumentRangeVtbl;
6226 doc->doc_obj = doc_obj;
6227 doc->outer_window = window ? window->base.outer_window : NULL;
6228 doc->window = window;
6230 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocumentNode_cpc);
6231 HTMLDocumentNode_Persist_Init(doc);
6232 HTMLDocumentNode_Service_Init(doc);
6233 HTMLDocumentNode_OleCmd_Init(doc);
6234 HTMLDocumentNode_OleObj_Init(doc);
6235 HTMLDocumentNode_SecMgr_Init(doc);
6237 list_init(&doc->selection_list);
6238 list_init(&doc->range_list);
6239 list_init(&doc->plugin_hosts);
6241 return doc;
6244 HRESULT create_document_node(nsIDOMDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
6245 compat_mode_t parent_mode, HTMLDocumentNode **ret)
6247 HTMLDocumentObj *doc_obj = browser->doc;
6248 HTMLDocumentNode *doc;
6250 doc = alloc_doc_node(doc_obj, window);
6251 if(!doc)
6252 return E_OUTOFMEMORY;
6254 if(parent_mode >= COMPAT_MODE_IE9) {
6255 TRACE("using parent mode %u\n", parent_mode);
6256 doc->document_mode = parent_mode;
6257 lock_document_mode(doc);
6260 if(!doc_obj->window || (window && is_main_content_window(window->base.outer_window)))
6261 doc->cp_container.forward_container = &doc_obj->cp_container;
6263 if(NS_SUCCEEDED(nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&doc->html_document)))
6264 doc->dom_document = (nsIDOMDocument*)doc->html_document;
6265 else {
6266 nsIDOMDocument_AddRef(nsdoc);
6267 doc->dom_document = nsdoc;
6268 doc->html_document = NULL;
6271 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)doc->dom_document, &HTMLDocumentNode_dispex);
6273 init_document_mutation(doc);
6274 doc_init_events(doc);
6276 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
6278 list_add_head(&browser->document_nodes, &doc->browser_entry);
6279 doc->browser = browser;
6281 if(browser->usermode == EDITMODE && doc->html_document) {
6282 nsAString mode_str;
6283 nsresult nsres;
6285 nsAString_InitDepend(&mode_str, L"on");
6286 nsres = nsIDOMHTMLDocument_SetDesignMode(doc->html_document, &mode_str);
6287 nsAString_Finish(&mode_str);
6288 if(NS_FAILED(nsres))
6289 ERR("SetDesignMode failed: %08lx\n", nsres);
6292 *ret = doc;
6293 return S_OK;
6296 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
6298 HTMLDocumentNode *doc_frag;
6300 doc_frag = alloc_doc_node(doc_node->doc_obj, doc_node->window);
6301 if(!doc_frag)
6302 return E_OUTOFMEMORY;
6304 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
6306 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
6307 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
6308 doc_frag->document_mode = lock_document_mode(doc_node);
6310 *ret = doc_frag;
6311 return S_OK;
6314 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
6316 HTMLDOMNode *node;
6317 HRESULT hres;
6319 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
6320 if(FAILED(hres))
6321 return hres;
6323 if(!node) {
6324 ERR("document not initialized\n");
6325 return E_FAIL;
6328 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
6329 *ret = impl_from_HTMLDOMNode(node);
6330 return S_OK;