mshtml: Fix classList toggle() when return value pointer is NULL.
[wine.git] / dlls / mshtml / htmldoc.c
blob049b5c3559e04ffcf447b949121336a862da9b6c
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 DocumentType_get_parent_event_target,
375 NULL,
376 NULL,
377 DocumentType_set_current_event
380 static const tid_t DocumentType_iface_tids[] = {
381 IDOMDocumentType_tid,
382 IHTMLDOMNode_tid,
383 IHTMLDOMNode2_tid,
384 IHTMLDOMNode3_tid,
388 static dispex_static_data_t DocumentType_dispex = {
389 L"DocumentType",
390 &DocumentType_event_target_vtbl.dispex_vtbl,
391 DispDOMDocumentType_tid,
392 DocumentType_iface_tids
395 HRESULT create_doctype_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **ret)
397 nsIDOMDocumentType *nsdoctype;
398 DocumentType *doctype;
399 nsresult nsres;
401 if(!(doctype = calloc(1, sizeof(*doctype))))
402 return E_OUTOFMEMORY;
404 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMDocumentType, (void**)&nsdoctype);
405 assert(nsres == NS_OK);
407 doctype->node.vtbl = &DocumentTypeImplVtbl;
408 doctype->IDOMDocumentType_iface.lpVtbl = &DocumentTypeVtbl;
409 HTMLDOMNode_Init(doc, &doctype->node, (nsIDOMNode*)nsdoctype, &DocumentType_dispex);
410 nsIDOMDocumentType_Release(nsdoctype);
412 *ret = &doctype->node;
413 return S_OK;
416 static inline HTMLDocumentNode *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
418 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument2_iface);
421 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
423 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
425 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
428 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
430 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
432 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
435 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
437 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
439 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
442 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
444 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
446 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
449 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo, LCID lcid,
450 ITypeInfo **ppTInfo)
452 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
454 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
457 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid, LPOLESTR *rgszNames,
458 UINT cNames, LCID lcid, DISPID *rgDispId)
460 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
462 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
463 rgDispId);
466 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
467 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
469 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
471 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
472 pDispParams, pVarResult, pExcepInfo, puArgErr);
475 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
477 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
478 HRESULT hres;
480 TRACE("(%p)->(%p)\n", This, p);
482 hres = IHTMLDocument7_get_parentWindow(&This->IHTMLDocument7_iface, (IHTMLWindow2**)p);
483 return hres == S_OK && !*p ? E_PENDING : hres;
486 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
488 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
490 TRACE("(%p)->(%p)\n", This, p);
491 *p = create_all_collection(&This->node, FALSE);
493 return S_OK;
496 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
498 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
499 nsIDOMElement *nsbody = NULL;
500 HTMLElement *element;
501 nsresult nsres;
502 HRESULT hres;
504 TRACE("(%p)->(%p)\n", This, p);
506 if(This->html_document) {
507 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, (nsIDOMHTMLElement **)&nsbody);
508 if(NS_FAILED(nsres)) {
509 TRACE("Could not get body: %08lx\n", nsres);
510 return E_UNEXPECTED;
512 }else {
513 nsAString nsnode_name;
514 nsIDOMDocumentFragment *frag;
516 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&frag);
517 if(!NS_FAILED(nsres)) {
518 nsAString_InitDepend(&nsnode_name, L"BODY");
519 nsIDOMDocumentFragment_QuerySelector(frag, &nsnode_name, &nsbody);
520 nsAString_Finish(&nsnode_name);
521 nsIDOMDocumentFragment_Release(frag);
525 if(!nsbody) {
526 *p = NULL;
527 return S_OK;
530 hres = get_element(nsbody, &element);
531 nsIDOMElement_Release(nsbody);
532 if(FAILED(hres))
533 return hres;
535 *p = &element->IHTMLElement_iface;
536 return S_OK;
539 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
541 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
542 nsIDOMElement *nselem;
543 HTMLElement *elem;
544 nsresult nsres;
545 HRESULT hres;
547 TRACE("(%p)->(%p)\n", This, p);
549 if(!This->dom_document) {
550 *p = NULL;
551 return S_OK;
555 * NOTE: Gecko may return an active element even if the document is not visible.
556 * IE returns NULL in this case.
558 nsres = nsIDOMDocument_GetActiveElement(This->dom_document, &nselem);
559 if(NS_FAILED(nsres)) {
560 ERR("GetActiveElement failed: %08lx\n", nsres);
561 return E_FAIL;
564 if(!nselem) {
565 *p = NULL;
566 return S_OK;
569 hres = get_element(nselem, &elem);
570 nsIDOMElement_Release(nselem);
571 if(FAILED(hres))
572 return hres;
574 *p = &elem->IHTMLElement_iface;
575 return S_OK;
578 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
580 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
581 nsIDOMHTMLCollection *nscoll = NULL;
582 nsresult nsres;
584 TRACE("(%p)->(%p)\n", This, p);
586 if(!p)
587 return E_INVALIDARG;
589 *p = NULL;
591 if(!This->dom_document) {
592 WARN("NULL dom_document\n");
593 return E_UNEXPECTED;
596 if(!This->html_document) {
597 FIXME("Not implemented for XML document\n");
598 return E_NOTIMPL;
601 nsres = nsIDOMHTMLDocument_GetImages(This->html_document, &nscoll);
602 if(NS_FAILED(nsres)) {
603 ERR("GetImages failed: %08lx\n", nsres);
604 return E_FAIL;
607 if(nscoll) {
608 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
609 nsIDOMHTMLCollection_Release(nscoll);
612 return S_OK;
615 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
617 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
618 nsIDOMHTMLCollection *nscoll = NULL;
619 nsresult nsres;
621 TRACE("(%p)->(%p)\n", This, p);
623 if(!p)
624 return E_INVALIDARG;
626 *p = NULL;
628 if(!This->dom_document) {
629 WARN("NULL dom_document\n");
630 return E_UNEXPECTED;
633 if(!This->html_document) {
634 FIXME("Not implemented for XML document\n");
635 return E_NOTIMPL;
638 nsres = nsIDOMHTMLDocument_GetApplets(This->html_document, &nscoll);
639 if(NS_FAILED(nsres)) {
640 ERR("GetApplets failed: %08lx\n", nsres);
641 return E_FAIL;
644 if(nscoll) {
645 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
646 nsIDOMHTMLCollection_Release(nscoll);
649 return S_OK;
652 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
654 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
655 nsIDOMHTMLCollection *nscoll = NULL;
656 nsresult nsres;
658 TRACE("(%p)->(%p)\n", This, p);
660 if(!p)
661 return E_INVALIDARG;
663 *p = NULL;
665 if(!This->dom_document) {
666 WARN("NULL dom_document\n");
667 return E_UNEXPECTED;
670 if(!This->html_document) {
671 FIXME("Not implemented for XML document\n");
672 return E_NOTIMPL;
675 nsres = nsIDOMHTMLDocument_GetLinks(This->html_document, &nscoll);
676 if(NS_FAILED(nsres)) {
677 ERR("GetLinks failed: %08lx\n", nsres);
678 return E_FAIL;
681 if(nscoll) {
682 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
683 nsIDOMHTMLCollection_Release(nscoll);
686 return S_OK;
689 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
691 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
692 nsIDOMHTMLCollection *nscoll = NULL;
693 nsresult nsres;
695 TRACE("(%p)->(%p)\n", This, p);
697 if(!p)
698 return E_INVALIDARG;
700 *p = NULL;
702 if(!This->dom_document) {
703 WARN("NULL dom_document\n");
704 return E_UNEXPECTED;
707 if(!This->html_document) {
708 FIXME("Not implemented for XML document\n");
709 return E_NOTIMPL;
712 nsres = nsIDOMHTMLDocument_GetForms(This->html_document, &nscoll);
713 if(NS_FAILED(nsres)) {
714 ERR("GetForms failed: %08lx\n", nsres);
715 return E_FAIL;
718 if(nscoll) {
719 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
720 nsIDOMHTMLCollection_Release(nscoll);
723 return S_OK;
726 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
728 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
729 nsIDOMHTMLCollection *nscoll = NULL;
730 nsresult nsres;
732 TRACE("(%p)->(%p)\n", This, p);
734 if(!p)
735 return E_INVALIDARG;
737 *p = NULL;
739 if(!This->dom_document) {
740 WARN("NULL dom_document\n");
741 return E_UNEXPECTED;
744 if(!This->html_document) {
745 FIXME("Not implemented for XML document\n");
746 return E_NOTIMPL;
749 nsres = nsIDOMHTMLDocument_GetAnchors(This->html_document, &nscoll);
750 if(NS_FAILED(nsres)) {
751 ERR("GetAnchors failed: %08lx\n", nsres);
752 return E_FAIL;
755 if(nscoll) {
756 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
757 nsIDOMHTMLCollection_Release(nscoll);
760 return S_OK;
763 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
765 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
766 nsAString nsstr;
767 nsresult nsres;
769 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
771 if(!This->dom_document) {
772 WARN("NULL dom_document\n");
773 return E_UNEXPECTED;
776 nsAString_InitDepend(&nsstr, v);
777 nsres = nsIDOMDocument_SetTitle(This->dom_document, &nsstr);
778 nsAString_Finish(&nsstr);
779 if(NS_FAILED(nsres))
780 ERR("SetTitle failed: %08lx\n", nsres);
782 return S_OK;
785 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
787 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
788 const PRUnichar *ret;
789 nsAString nsstr;
790 nsresult nsres;
792 TRACE("(%p)->(%p)\n", This, p);
794 if(!This->dom_document) {
795 WARN("NULL dom_document\n");
796 return E_UNEXPECTED;
800 nsAString_Init(&nsstr, NULL);
801 nsres = nsIDOMDocument_GetTitle(This->dom_document, &nsstr);
802 if (NS_SUCCEEDED(nsres)) {
803 nsAString_GetData(&nsstr, &ret);
804 *p = SysAllocString(ret);
806 nsAString_Finish(&nsstr);
808 if(NS_FAILED(nsres)) {
809 ERR("GetTitle failed: %08lx\n", nsres);
810 return E_FAIL;
813 return S_OK;
816 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
818 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
819 nsIDOMHTMLCollection *nscoll = NULL;
820 nsresult nsres;
822 TRACE("(%p)->(%p)\n", This, p);
824 if(!p)
825 return E_INVALIDARG;
827 *p = NULL;
829 if(!This->dom_document) {
830 WARN("NULL dom_document\n");
831 return E_UNEXPECTED;
834 if(!This->html_document) {
835 FIXME("Not implemented for XML document\n");
836 return E_NOTIMPL;
839 nsres = nsIDOMHTMLDocument_GetScripts(This->html_document, &nscoll);
840 if(NS_FAILED(nsres)) {
841 ERR("GetImages failed: %08lx\n", nsres);
842 return E_FAIL;
845 if(nscoll) {
846 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
847 nsIDOMHTMLCollection_Release(nscoll);
850 return S_OK;
853 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
855 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
856 HTMLDocumentObj *doc_obj;
857 HRESULT hres;
859 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
861 if(wcsicmp(v, L"on")) {
862 FIXME("Unsupported arg %s\n", debugstr_w(v));
863 return E_NOTIMPL;
866 doc_obj = This->doc_obj;
867 IUnknown_AddRef(doc_obj->outer_unk);
868 hres = setup_edit_mode(doc_obj);
869 IUnknown_Release(doc_obj->outer_unk);
870 if(FAILED(hres))
871 return hres;
873 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
874 return S_OK;
877 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
879 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
880 FIXME("(%p)->(%p) always returning Off\n", This, p);
882 if(!p)
883 return E_INVALIDARG;
885 *p = SysAllocString(L"Off");
887 return S_OK;
890 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
892 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
893 nsISelection *nsselection;
894 nsresult nsres;
896 TRACE("(%p)->(%p)\n", This, p);
898 if(!This->html_document) {
899 FIXME("Not implemented for XML document\n");
900 return E_NOTIMPL;
903 nsres = nsIDOMHTMLDocument_GetSelection(This->html_document, &nsselection);
904 if(NS_FAILED(nsres)) {
905 ERR("GetSelection failed: %08lx\n", nsres);
906 return E_FAIL;
909 return HTMLSelectionObject_Create(This, nsselection, p);
912 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
914 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
916 TRACE("(%p)->(%p)\n", iface, p);
918 if(!p)
919 return E_POINTER;
921 return get_readystate_string(This->outer_window ? This->outer_window->readystate : 0, p);
924 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
926 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
928 TRACE("(%p)->(%p)\n", This, p);
930 if(!This->outer_window) {
931 /* Not implemented by IE */
932 return E_NOTIMPL;
934 return IHTMLWindow2_get_frames(&This->outer_window->base.IHTMLWindow2_iface, p);
937 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
939 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
940 FIXME("(%p)->(%p)\n", This, p);
941 return E_NOTIMPL;
944 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
946 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
947 FIXME("(%p)->(%p)\n", This, p);
948 return E_NOTIMPL;
951 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
953 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
954 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
955 return E_NOTIMPL;
958 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
960 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
961 FIXME("(%p)->(%p)\n", This, p);
962 return E_NOTIMPL;
965 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
967 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
968 IHTMLElement *element = NULL;
969 IHTMLBodyElement *body;
970 HRESULT hr;
972 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
974 hr = IHTMLDocument2_get_body(iface, &element);
975 if (FAILED(hr))
977 ERR("Failed to get body (0x%08lx)\n", hr);
978 return hr;
981 if(!element)
983 FIXME("Empty body element.\n");
984 return hr;
987 hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body);
988 if (SUCCEEDED(hr))
990 hr = IHTMLBodyElement_put_bgColor(body, v);
991 IHTMLBodyElement_Release(body);
993 IHTMLElement_Release(element);
995 return hr;
998 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
1000 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1001 nsAString nsstr;
1002 nsresult nsres;
1003 HRESULT hres;
1005 TRACE("(%p)->(%p)\n", This, p);
1007 if(!This->dom_document) {
1008 WARN("NULL dom_document\n");
1009 return E_UNEXPECTED;
1012 if(!This->html_document) {
1013 FIXME("Not implemented for XML document\n");
1014 return E_NOTIMPL;
1017 nsAString_Init(&nsstr, NULL);
1018 nsres = nsIDOMHTMLDocument_GetBgColor(This->html_document, &nsstr);
1019 hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p);
1020 if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) {
1021 TRACE("default #ffffff\n");
1022 if(!(V_BSTR(p) = SysAllocString(L"#ffffff")))
1023 hres = E_OUTOFMEMORY;
1025 return hres;
1028 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
1030 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1031 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1032 return E_NOTIMPL;
1035 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
1037 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1038 FIXME("(%p)->(%p)\n", This, p);
1039 return E_NOTIMPL;
1042 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
1044 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1045 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1046 return E_NOTIMPL;
1049 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
1051 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1052 FIXME("(%p)->(%p)\n", This, p);
1053 return E_NOTIMPL;
1056 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
1058 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1059 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1060 return E_NOTIMPL;
1063 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
1065 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1066 FIXME("(%p)->(%p)\n", This, p);
1067 return E_NOTIMPL;
1070 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
1072 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1073 nsAString nsstr;
1074 nsresult nsres;
1076 TRACE("(%p)->(%p)\n", This, p);
1078 nsAString_InitDepend(&nsstr, NULL);
1079 nsres = nsIDOMDocument_GetReferrer(This->dom_document, &nsstr);
1080 return return_nsstr(nsres, &nsstr, p);
1083 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
1085 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1087 TRACE("(%p)->(%p)\n", This, p);
1089 if(!This->dom_document || !This->window) {
1090 WARN("NULL window\n");
1091 return E_UNEXPECTED;
1094 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
1097 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
1099 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1100 FIXME("(%p)->(%p)\n", This, p);
1101 return E_NOTIMPL;
1104 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
1106 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1108 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1110 if(!This->outer_window) {
1111 FIXME("No window available\n");
1112 return E_FAIL;
1115 return navigate_url(This->outer_window, v, This->outer_window->uri, BINDING_NAVIGATED);
1118 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
1120 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1122 TRACE("(%p)->(%p)\n", iface, p);
1124 *p = SysAllocString(This->outer_window && This->outer_window->url ? This->outer_window->url : L"about:blank");
1125 return *p ? S_OK : E_OUTOFMEMORY;
1128 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
1130 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1131 nsAString nsstr;
1132 nsresult nsres;
1134 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1136 if(!This->html_document) {
1137 FIXME("Not implemented for XML document\n");
1138 return E_NOTIMPL;
1141 nsAString_InitDepend(&nsstr, v);
1142 nsres = nsIDOMHTMLDocument_SetDomain(This->html_document, &nsstr);
1143 nsAString_Finish(&nsstr);
1144 if(NS_FAILED(nsres)) {
1145 ERR("SetDomain failed: %08lx\n", nsres);
1146 return E_INVALIDARG;
1149 return S_OK;
1152 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
1154 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1155 nsAString nsstr;
1156 nsresult nsres;
1158 TRACE("(%p)->(%p)\n", This, p);
1160 if(!This->html_document) {
1161 FIXME("Not implemented for XML document\n");
1162 return E_NOTIMPL;
1165 if(This->outer_window && !This->outer_window->uri)
1166 return E_FAIL;
1168 nsAString_Init(&nsstr, NULL);
1169 nsres = nsIDOMHTMLDocument_GetDomain(This->html_document, &nsstr);
1170 if(NS_SUCCEEDED(nsres) && This->outer_window && This->outer_window->uri) {
1171 const PRUnichar *str;
1172 HRESULT hres;
1174 nsAString_GetData(&nsstr, &str);
1175 if(!*str) {
1176 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
1177 nsAString_Finish(&nsstr);
1178 hres = IUri_GetHost(This->outer_window->uri, p);
1179 return FAILED(hres) ? hres : S_OK;
1183 return return_nsstr(nsres, &nsstr, p);
1186 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
1188 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1189 BOOL bret;
1191 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1193 if(!This->outer_window)
1194 return S_OK;
1196 bret = InternetSetCookieExW(This->outer_window->url, NULL, v, 0, 0);
1197 if(!bret) {
1198 FIXME("InternetSetCookieExW failed: %lu\n", GetLastError());
1199 return HRESULT_FROM_WIN32(GetLastError());
1202 return S_OK;
1205 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
1207 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1208 DWORD size;
1209 BOOL bret;
1211 TRACE("(%p)->(%p)\n", This, p);
1213 if(!This->outer_window) {
1214 *p = NULL;
1215 return S_OK;
1218 size = 0;
1219 bret = InternetGetCookieExW(This->outer_window->url, NULL, NULL, &size, 0, NULL);
1220 if(!bret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
1221 WARN("InternetGetCookieExW failed: %lu\n", GetLastError());
1222 *p = NULL;
1223 return S_OK;
1226 if(!size) {
1227 *p = NULL;
1228 return S_OK;
1231 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
1232 if(!*p)
1233 return E_OUTOFMEMORY;
1235 bret = InternetGetCookieExW(This->outer_window->url, NULL, *p, &size, 0, NULL);
1236 if(!bret) {
1237 ERR("InternetGetCookieExW failed: %lu\n", GetLastError());
1238 return E_FAIL;
1241 return S_OK;
1244 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
1246 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1247 FIXME("(%p)->(%x)\n", This, v);
1248 return E_NOTIMPL;
1251 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
1253 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1254 FIXME("(%p)->(%p)\n", This, p);
1255 return E_NOTIMPL;
1258 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
1260 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1261 FIXME("(%p)->(%s) returning S_OK\n", This, debugstr_w(v));
1262 return S_OK;
1265 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
1267 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1269 TRACE("(%p)->(%p)\n", This, p);
1271 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
1274 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
1276 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1277 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1278 return E_NOTIMPL;
1281 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
1283 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1285 TRACE("(%p)->(%p)\n", This, p);
1287 *p = charset_string_from_cp(GetACP());
1288 return *p ? S_OK : E_OUTOFMEMORY;
1291 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
1293 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1294 const PRUnichar *content_type;
1295 nsAString nsstr;
1296 nsresult nsres;
1297 HRESULT hres;
1299 TRACE("(%p)->(%p)\n", This, p);
1301 *p = NULL;
1303 if(This->window && This->window->base.outer_window->readystate == READYSTATE_UNINITIALIZED)
1304 return (*p = SysAllocString(L"")) ? S_OK : E_FAIL;
1306 nsAString_InitDepend(&nsstr, NULL);
1307 nsres = nsIDOMDocument_GetContentType(This->dom_document, &nsstr);
1308 if(NS_FAILED(nsres))
1309 return map_nsresult(nsres);
1311 nsAString_GetData(&nsstr, &content_type);
1312 hres = get_mime_type_display_name(content_type, p);
1313 nsAString_Finish(&nsstr);
1314 return hres;
1317 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
1319 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1320 FIXME("(%p)->(%p)\n", This, p);
1321 return E_NOTIMPL;
1324 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
1326 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1327 FIXME("(%p)->(%p)\n", This, p);
1328 return E_NOTIMPL;
1331 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
1333 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1334 FIXME("(%p)->(%p)\n", This, p);
1335 return E_NOTIMPL;
1338 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
1340 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1341 FIXME("(%p)->(%p)\n", This, p);
1342 return E_NOTIMPL;
1345 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
1347 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1348 FIXME("(%p)->(%p)\n", This, p);
1349 return E_NOTIMPL;
1352 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
1354 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1355 FIXME("(%p)->(%p)\n", This, p);
1356 return E_NOTIMPL;
1359 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1361 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1362 FIXME("(%p)->(%p)\n", This, p);
1363 return E_NOTIMPL;
1366 static HRESULT document_write(HTMLDocumentNode *This, SAFEARRAY *psarray, BOOL ln)
1368 VARIANT *var, tmp;
1369 JSContext *jsctx;
1370 nsAString nsstr;
1371 ULONG i, argc;
1372 nsresult nsres;
1373 HRESULT hres;
1375 if(!This->dom_document) {
1376 WARN("NULL dom_document\n");
1377 return E_UNEXPECTED;
1380 if(!This->html_document) {
1381 FIXME("Not implemented for XML document\n");
1382 return E_NOTIMPL;
1385 if (!psarray)
1386 return S_OK;
1388 if(psarray->cDims != 1) {
1389 FIXME("cDims=%d\n", psarray->cDims);
1390 return E_INVALIDARG;
1393 hres = SafeArrayAccessData(psarray, (void**)&var);
1394 if(FAILED(hres)) {
1395 WARN("SafeArrayAccessData failed: %08lx\n", hres);
1396 return hres;
1399 V_VT(&tmp) = VT_EMPTY;
1401 jsctx = get_context_from_document(This->dom_document);
1402 argc = psarray->rgsabound[0].cElements;
1403 for(i=0; i < argc; i++) {
1404 if(V_VT(var+i) == VT_BSTR) {
1405 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1406 }else {
1407 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1408 if(FAILED(hres)) {
1409 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1410 break;
1412 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1415 if(!ln || i != argc-1)
1416 nsres = nsIDOMHTMLDocument_Write(This->html_document, &nsstr, jsctx);
1417 else
1418 nsres = nsIDOMHTMLDocument_Writeln(This->html_document, &nsstr, jsctx);
1419 nsAString_Finish(&nsstr);
1420 if(V_VT(var+i) != VT_BSTR)
1421 VariantClear(&tmp);
1422 if(NS_FAILED(nsres)) {
1423 ERR("Write failed: %08lx\n", nsres);
1424 hres = E_FAIL;
1425 break;
1429 SafeArrayUnaccessData(psarray);
1431 return hres;
1434 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1436 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1438 TRACE("(%p)->(%p)\n", iface, psarray);
1440 return document_write(This, psarray, FALSE);
1443 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1445 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1447 TRACE("(%p)->(%p)\n", This, psarray);
1449 return document_write(This, psarray, TRUE);
1452 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1453 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1455 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1456 nsISupports *tmp;
1457 nsresult nsres;
1459 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1460 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1462 *pomWindowResult = NULL;
1464 if(!This->outer_window)
1465 return E_FAIL;
1467 if(!This->dom_document) {
1468 ERR("!dom_document\n");
1469 return E_NOTIMPL;
1472 if(!This->html_document) {
1473 FIXME("Not implemented for XML document\n");
1474 return E_NOTIMPL;
1477 if(!url || wcscmp(url, L"text/html") || V_VT(&name) != VT_ERROR
1478 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1479 FIXME("unsupported args\n");
1481 nsres = nsIDOMHTMLDocument_Open(This->html_document, NULL, NULL, NULL,
1482 get_context_from_document(This->dom_document), 0, &tmp);
1483 if(NS_FAILED(nsres)) {
1484 ERR("Open failed: %08lx\n", nsres);
1485 return E_FAIL;
1488 if(tmp)
1489 nsISupports_Release(tmp);
1491 *pomWindowResult = (IDispatch*)&This->outer_window->base.IHTMLWindow2_iface;
1492 IHTMLWindow2_AddRef(&This->outer_window->base.IHTMLWindow2_iface);
1493 return S_OK;
1496 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1498 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1499 nsresult nsres;
1501 TRACE("(%p)\n", This);
1503 if(!This->dom_document) {
1504 ERR("!dom_document\n");
1505 return E_NOTIMPL;
1508 if(!This->html_document) {
1509 FIXME("Not implemented for XML document\n");
1510 return E_NOTIMPL;
1513 nsres = nsIDOMHTMLDocument_Close(This->html_document);
1514 if(NS_FAILED(nsres)) {
1515 ERR("Close failed: %08lx\n", nsres);
1516 return E_FAIL;
1519 return S_OK;
1522 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1524 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1525 nsresult nsres;
1527 TRACE("(%p)\n", This);
1529 if(!This->html_document) {
1530 FIXME("Not implemented for XML document\n");
1531 return E_NOTIMPL;
1534 nsres = nsIDOMHTMLDocument_Clear(This->html_document);
1535 if(NS_FAILED(nsres)) {
1536 ERR("Clear failed: %08lx\n", nsres);
1537 return E_FAIL;
1540 return S_OK;
1543 static const struct {
1544 const WCHAR *name;
1545 OLECMDID id;
1546 }command_names[] = {
1547 {L"copy", IDM_COPY},
1548 {L"cut", IDM_CUT},
1549 {L"fontname", IDM_FONTNAME},
1550 {L"fontsize", IDM_FONTSIZE},
1551 {L"indent", IDM_INDENT},
1552 {L"insertorderedlist", IDM_ORDERLIST},
1553 {L"insertunorderedlist", IDM_UNORDERLIST},
1554 {L"outdent", IDM_OUTDENT},
1555 {L"paste", IDM_PASTE},
1556 {L"respectvisibilityindesign", IDM_RESPECTVISIBILITY_INDESIGN}
1559 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1561 int i;
1563 for(i = 0; i < ARRAY_SIZE(command_names); i++) {
1564 if(!wcsicmp(command_names[i].name, str)) {
1565 *cmdid = command_names[i].id;
1566 return TRUE;
1570 FIXME("Unknown command %s\n", debugstr_w(str));
1571 return FALSE;
1574 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1575 VARIANT_BOOL *pfRet)
1577 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1578 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1579 return E_NOTIMPL;
1582 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1583 VARIANT_BOOL *pfRet)
1585 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1586 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1587 return E_NOTIMPL;
1590 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1591 VARIANT_BOOL *pfRet)
1593 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1594 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1595 return E_NOTIMPL;
1598 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1599 VARIANT_BOOL *pfRet)
1601 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1602 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1603 return E_NOTIMPL;
1606 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1607 BSTR *pfRet)
1609 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1610 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1611 return E_NOTIMPL;
1614 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1615 VARIANT *pfRet)
1617 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1618 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1619 return E_NOTIMPL;
1622 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1623 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1625 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1626 OLECMDID cmdid;
1627 VARIANT ret;
1628 HRESULT hres;
1630 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1632 if(!cmdid_from_string(cmdID, &cmdid))
1633 return OLECMDERR_E_NOTSUPPORTED;
1635 V_VT(&ret) = VT_EMPTY;
1636 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1637 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1638 if(FAILED(hres))
1639 return hres;
1641 if(V_VT(&ret) != VT_EMPTY) {
1642 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1643 VariantClear(&ret);
1646 *pfRet = VARIANT_TRUE;
1647 return S_OK;
1650 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1651 VARIANT_BOOL *pfRet)
1653 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1654 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1655 return E_NOTIMPL;
1658 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1659 IHTMLElement **newElem)
1661 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1662 HTMLElement *elem;
1663 HRESULT hres;
1665 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1667 hres = create_element(This, eTag, &elem);
1668 if(FAILED(hres))
1669 return hres;
1671 *newElem = &elem->IHTMLElement_iface;
1672 return S_OK;
1675 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1677 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1678 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1679 return E_NOTIMPL;
1682 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1684 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1685 FIXME("(%p)->(%p)\n", This, p);
1686 return E_NOTIMPL;
1689 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1691 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1693 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1695 return set_doc_event(This, EVENTID_CLICK, &v);
1698 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1700 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1702 TRACE("(%p)->(%p)\n", This, p);
1704 return get_doc_event(This, EVENTID_CLICK, p);
1707 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1709 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1711 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1713 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1716 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1718 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1720 TRACE("(%p)->(%p)\n", This, p);
1722 return get_doc_event(This, EVENTID_DBLCLICK, p);
1725 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1727 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1729 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1731 return set_doc_event(This, EVENTID_KEYUP, &v);
1734 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1736 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1738 TRACE("(%p)->(%p)\n", This, p);
1740 return get_doc_event(This, EVENTID_KEYUP, p);
1743 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1745 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1747 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1749 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1752 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1754 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1756 TRACE("(%p)->(%p)\n", This, p);
1758 return get_doc_event(This, EVENTID_KEYDOWN, p);
1761 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1763 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1765 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1767 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1770 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1772 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1774 TRACE("(%p)->(%p)\n", This, p);
1776 return get_doc_event(This, EVENTID_KEYPRESS, p);
1779 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1781 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1783 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1785 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1788 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1790 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1792 TRACE("(%p)->(%p)\n", This, p);
1794 return get_doc_event(This, EVENTID_MOUSEUP, p);
1797 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1799 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1801 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1803 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1806 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1808 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1810 TRACE("(%p)->(%p)\n", This, p);
1812 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1815 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1817 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1819 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1821 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1824 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1826 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1828 TRACE("(%p)->(%p)\n", This, p);
1830 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1833 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1835 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1837 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1839 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1842 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1844 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1846 TRACE("(%p)->(%p)\n", This, p);
1848 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1851 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1853 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1855 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1857 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1860 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1862 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1864 TRACE("(%p)->(%p)\n", This, p);
1866 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1869 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1871 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1873 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1875 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1878 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1880 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1882 TRACE("(%p)->(%p)\n", This, p);
1884 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1887 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1889 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1890 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1891 return E_NOTIMPL;
1894 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1896 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1897 FIXME("(%p)->(%p)\n", This, p);
1898 return E_NOTIMPL;
1901 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1903 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1904 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1905 return E_NOTIMPL;
1908 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1910 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1911 FIXME("(%p)->(%p)\n", This, p);
1912 return E_NOTIMPL;
1915 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1917 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1918 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1919 return E_NOTIMPL;
1922 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1924 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1925 FIXME("(%p)->(%p)\n", This, p);
1926 return E_NOTIMPL;
1929 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1931 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1933 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1935 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1938 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1940 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1942 TRACE("(%p)->(%p)\n", This, p);
1944 return get_doc_event(This, EVENTID_DRAGSTART, p);
1947 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1949 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1951 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1953 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1956 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1958 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1960 TRACE("(%p)->(%p)\n", This, p);
1962 return get_doc_event(This, EVENTID_SELECTSTART, p);
1965 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1966 IHTMLElement **elementHit)
1968 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1969 nsIDOMElement *nselem;
1970 HTMLElement *element;
1971 nsresult nsres;
1972 HRESULT hres;
1974 TRACE("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1976 nsres = nsIDOMDocument_ElementFromPoint(This->dom_document, x, y, &nselem);
1977 if(NS_FAILED(nsres)) {
1978 ERR("ElementFromPoint failed: %08lx\n", nsres);
1979 return E_FAIL;
1982 if(!nselem) {
1983 *elementHit = NULL;
1984 return S_OK;
1987 hres = get_element(nselem, &element);
1988 nsIDOMElement_Release(nselem);
1989 if(FAILED(hres))
1990 return hres;
1992 *elementHit = &element->IHTMLElement_iface;
1993 return S_OK;
1996 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1998 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1999 HRESULT hres;
2001 TRACE("(%p)->(%p)\n", This, p);
2003 hres = IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
2004 return hres == S_OK && !*p ? E_FAIL : hres;
2007 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
2008 IHTMLStyleSheetsCollection **p)
2010 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2011 nsIDOMStyleSheetList *nsstylelist;
2012 nsresult nsres;
2013 HRESULT hres;
2015 TRACE("(%p)->(%p)\n", This, p);
2017 *p = NULL;
2019 if(!This->dom_document) {
2020 WARN("NULL dom_document\n");
2021 return E_UNEXPECTED;
2024 nsres = nsIDOMDocument_GetStyleSheets(This->dom_document, &nsstylelist);
2025 if(NS_FAILED(nsres)) {
2026 ERR("GetStyleSheets failed: %08lx\n", nsres);
2027 return map_nsresult(nsres);
2030 hres = create_style_sheet_collection(nsstylelist,
2031 dispex_compat_mode(&This->node.event_target.dispex), p);
2032 nsIDOMStyleSheetList_Release(nsstylelist);
2033 return hres;
2036 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
2038 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2039 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2040 return E_NOTIMPL;
2043 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
2045 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2046 FIXME("(%p)->(%p)\n", This, p);
2047 return E_NOTIMPL;
2050 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
2052 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2053 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2054 return E_NOTIMPL;
2057 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
2059 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2060 FIXME("(%p)->(%p)\n", This, p);
2061 return E_NOTIMPL;
2064 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
2066 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2068 TRACE("(%p)->(%p)\n", This, String);
2070 return dispex_to_string(&This->node.event_target.dispex, String);
2073 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
2074 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
2076 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2077 nsIDOMHTMLHeadElement *head_elem;
2078 IHTMLStyleElement *style_elem;
2079 HTMLElement *elem;
2080 nsresult nsres;
2081 HRESULT hres;
2083 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
2085 if(!This->dom_document) {
2086 FIXME("not a real doc object\n");
2087 return E_NOTIMPL;
2090 if(!This->html_document) {
2091 FIXME("Not implemented for XML document\n");
2092 return E_NOTIMPL;
2095 if(lIndex != -1)
2096 FIXME("Unsupported lIndex %ld\n", lIndex);
2098 if(bstrHref && *bstrHref) {
2099 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
2100 return create_style_sheet(NULL, dispex_compat_mode(&This->node.event_target.dispex),
2101 ppnewStyleSheet);
2104 hres = create_element(This, L"style", &elem);
2105 if(FAILED(hres))
2106 return hres;
2108 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &head_elem);
2109 if(NS_SUCCEEDED(nsres)) {
2110 nsIDOMNode *head_node, *tmp_node;
2112 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
2113 nsIDOMHTMLHeadElement_Release(head_elem);
2114 assert(nsres == NS_OK);
2116 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
2117 nsIDOMNode_Release(head_node);
2118 if(NS_SUCCEEDED(nsres) && tmp_node)
2119 nsIDOMNode_Release(tmp_node);
2121 if(NS_FAILED(nsres)) {
2122 IHTMLElement_Release(&elem->IHTMLElement_iface);
2123 return E_FAIL;
2126 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
2127 assert(hres == S_OK);
2128 IHTMLElement_Release(&elem->IHTMLElement_iface);
2130 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
2131 IHTMLStyleElement_Release(style_elem);
2132 return hres;
2135 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
2136 HTMLDocument_QueryInterface,
2137 HTMLDocument_AddRef,
2138 HTMLDocument_Release,
2139 HTMLDocument_GetTypeInfoCount,
2140 HTMLDocument_GetTypeInfo,
2141 HTMLDocument_GetIDsOfNames,
2142 HTMLDocument_Invoke,
2143 HTMLDocument_get_Script,
2144 HTMLDocument_get_all,
2145 HTMLDocument_get_body,
2146 HTMLDocument_get_activeElement,
2147 HTMLDocument_get_images,
2148 HTMLDocument_get_applets,
2149 HTMLDocument_get_links,
2150 HTMLDocument_get_forms,
2151 HTMLDocument_get_anchors,
2152 HTMLDocument_put_title,
2153 HTMLDocument_get_title,
2154 HTMLDocument_get_scripts,
2155 HTMLDocument_put_designMode,
2156 HTMLDocument_get_designMode,
2157 HTMLDocument_get_selection,
2158 HTMLDocument_get_readyState,
2159 HTMLDocument_get_frames,
2160 HTMLDocument_get_embeds,
2161 HTMLDocument_get_plugins,
2162 HTMLDocument_put_alinkColor,
2163 HTMLDocument_get_alinkColor,
2164 HTMLDocument_put_bgColor,
2165 HTMLDocument_get_bgColor,
2166 HTMLDocument_put_fgColor,
2167 HTMLDocument_get_fgColor,
2168 HTMLDocument_put_linkColor,
2169 HTMLDocument_get_linkColor,
2170 HTMLDocument_put_vlinkColor,
2171 HTMLDocument_get_vlinkColor,
2172 HTMLDocument_get_referrer,
2173 HTMLDocument_get_location,
2174 HTMLDocument_get_lastModified,
2175 HTMLDocument_put_URL,
2176 HTMLDocument_get_URL,
2177 HTMLDocument_put_domain,
2178 HTMLDocument_get_domain,
2179 HTMLDocument_put_cookie,
2180 HTMLDocument_get_cookie,
2181 HTMLDocument_put_expando,
2182 HTMLDocument_get_expando,
2183 HTMLDocument_put_charset,
2184 HTMLDocument_get_charset,
2185 HTMLDocument_put_defaultCharset,
2186 HTMLDocument_get_defaultCharset,
2187 HTMLDocument_get_mimeType,
2188 HTMLDocument_get_fileSize,
2189 HTMLDocument_get_fileCreatedDate,
2190 HTMLDocument_get_fileModifiedDate,
2191 HTMLDocument_get_fileUpdatedDate,
2192 HTMLDocument_get_security,
2193 HTMLDocument_get_protocol,
2194 HTMLDocument_get_nameProp,
2195 HTMLDocument_write,
2196 HTMLDocument_writeln,
2197 HTMLDocument_open,
2198 HTMLDocument_close,
2199 HTMLDocument_clear,
2200 HTMLDocument_queryCommandSupported,
2201 HTMLDocument_queryCommandEnabled,
2202 HTMLDocument_queryCommandState,
2203 HTMLDocument_queryCommandIndeterm,
2204 HTMLDocument_queryCommandText,
2205 HTMLDocument_queryCommandValue,
2206 HTMLDocument_execCommand,
2207 HTMLDocument_execCommandShowHelp,
2208 HTMLDocument_createElement,
2209 HTMLDocument_put_onhelp,
2210 HTMLDocument_get_onhelp,
2211 HTMLDocument_put_onclick,
2212 HTMLDocument_get_onclick,
2213 HTMLDocument_put_ondblclick,
2214 HTMLDocument_get_ondblclick,
2215 HTMLDocument_put_onkeyup,
2216 HTMLDocument_get_onkeyup,
2217 HTMLDocument_put_onkeydown,
2218 HTMLDocument_get_onkeydown,
2219 HTMLDocument_put_onkeypress,
2220 HTMLDocument_get_onkeypress,
2221 HTMLDocument_put_onmouseup,
2222 HTMLDocument_get_onmouseup,
2223 HTMLDocument_put_onmousedown,
2224 HTMLDocument_get_onmousedown,
2225 HTMLDocument_put_onmousemove,
2226 HTMLDocument_get_onmousemove,
2227 HTMLDocument_put_onmouseout,
2228 HTMLDocument_get_onmouseout,
2229 HTMLDocument_put_onmouseover,
2230 HTMLDocument_get_onmouseover,
2231 HTMLDocument_put_onreadystatechange,
2232 HTMLDocument_get_onreadystatechange,
2233 HTMLDocument_put_onafterupdate,
2234 HTMLDocument_get_onafterupdate,
2235 HTMLDocument_put_onrowexit,
2236 HTMLDocument_get_onrowexit,
2237 HTMLDocument_put_onrowenter,
2238 HTMLDocument_get_onrowenter,
2239 HTMLDocument_put_ondragstart,
2240 HTMLDocument_get_ondragstart,
2241 HTMLDocument_put_onselectstart,
2242 HTMLDocument_get_onselectstart,
2243 HTMLDocument_elementFromPoint,
2244 HTMLDocument_get_parentWindow,
2245 HTMLDocument_get_styleSheets,
2246 HTMLDocument_put_onbeforeupdate,
2247 HTMLDocument_get_onbeforeupdate,
2248 HTMLDocument_put_onerrorupdate,
2249 HTMLDocument_get_onerrorupdate,
2250 HTMLDocument_toString,
2251 HTMLDocument_createStyleSheet
2254 static inline HTMLDocumentNode *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
2256 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument3_iface);
2259 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface, REFIID riid, void **ppv)
2261 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2262 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2265 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
2267 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2268 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2271 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
2273 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2274 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2277 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
2279 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2280 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2283 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo, LCID lcid,
2284 ITypeInfo **ppTInfo)
2286 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2287 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2290 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid, LPOLESTR *rgszNames,
2291 UINT cNames, LCID lcid, DISPID *rgDispId)
2293 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2294 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2297 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2298 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2300 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2301 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2302 pDispParams, pVarResult, pExcepInfo, puArgErr);
2305 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
2307 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2308 FIXME("(%p)\n", This);
2309 return E_NOTIMPL;
2312 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
2314 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2316 WARN("(%p)->(%x)\n", This, fForce);
2318 /* Doing nothing here should be fine for us. */
2319 return S_OK;
2322 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text, IHTMLDOMNode **newTextNode)
2324 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2325 nsIDOMText *nstext;
2326 HTMLDOMNode *node;
2327 nsAString text_str;
2328 nsresult nsres;
2329 HRESULT hres;
2331 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
2333 if(!This->dom_document) {
2334 WARN("NULL dom_document\n");
2335 return E_UNEXPECTED;
2338 nsAString_InitDepend(&text_str, text);
2339 nsres = nsIDOMDocument_CreateTextNode(This->dom_document, &text_str, &nstext);
2340 nsAString_Finish(&text_str);
2341 if(NS_FAILED(nsres)) {
2342 ERR("CreateTextNode failed: %08lx\n", nsres);
2343 return E_FAIL;
2346 hres = HTMLDOMTextNode_Create(This, (nsIDOMNode*)nstext, &node);
2347 nsIDOMText_Release(nstext);
2348 if(FAILED(hres))
2349 return hres;
2351 *newTextNode = &node->IHTMLDOMNode_iface;
2352 return S_OK;
2355 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
2357 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2358 nsIDOMElement *nselem = NULL;
2359 HTMLElement *element;
2360 nsresult nsres;
2361 HRESULT hres;
2363 TRACE("(%p)->(%p)\n", This, p);
2365 if(This->outer_window && This->outer_window->readystate == READYSTATE_UNINITIALIZED) {
2366 *p = NULL;
2367 return S_OK;
2370 if(!This->dom_document) {
2371 WARN("NULL dom_document\n");
2372 return E_UNEXPECTED;
2375 nsres = nsIDOMDocument_GetDocumentElement(This->dom_document, &nselem);
2376 if(NS_FAILED(nsres)) {
2377 ERR("GetDocumentElement failed: %08lx\n", nsres);
2378 return E_FAIL;
2381 if(!nselem) {
2382 *p = NULL;
2383 return S_OK;
2386 hres = get_element(nselem, &element);
2387 nsIDOMElement_Release(nselem);
2388 if(FAILED(hres))
2389 return hres;
2391 *p = &element->IHTMLElement_iface;
2392 return hres;
2395 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2397 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2399 TRACE("(%p)->(%p)\n", This, p);
2401 return elem_unique_id(++This->unique_id, p);
2404 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch* pDisp,
2405 VARIANT_BOOL *pfResult)
2407 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2409 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2411 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2414 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch *pDisp)
2416 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2418 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2420 return detach_event(&This->node.event_target, event, pDisp);
2423 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2425 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2426 FIXME("(%p)->()\n", This);
2427 return E_NOTIMPL;
2430 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2432 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2433 FIXME("(%p)->(%p)\n", This, p);
2434 return E_NOTIMPL;
2437 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2439 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2440 FIXME("(%p)->()\n", This);
2441 return E_NOTIMPL;
2444 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2446 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2447 FIXME("(%p)->(%p)\n", This, p);
2448 return E_NOTIMPL;
2451 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2453 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2454 FIXME("(%p)->()\n", This);
2455 return E_NOTIMPL;
2458 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2460 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2461 FIXME("(%p)->(%p)\n", This, p);
2462 return E_NOTIMPL;
2465 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2467 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2468 FIXME("(%p)->()\n", This);
2469 return E_NOTIMPL;
2472 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2474 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2475 FIXME("(%p)->(%p)\n", This, p);
2476 return E_NOTIMPL;
2479 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2481 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2482 FIXME("(%p)->()\n", This);
2483 return E_NOTIMPL;
2486 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2488 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2489 FIXME("(%p)->(%p)\n", This, p);
2490 return E_NOTIMPL;
2493 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2495 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2496 FIXME("(%p)->()\n", This);
2497 return E_NOTIMPL;
2500 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2502 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2503 FIXME("(%p)->(%p)\n", This, p);
2504 return E_NOTIMPL;
2507 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2509 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2510 FIXME("(%p)->()\n", This);
2511 return E_NOTIMPL;
2514 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2516 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2517 FIXME("(%p)->(%p)\n", This, p);
2518 return E_NOTIMPL;
2521 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2523 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2524 nsAString dir_str;
2525 nsresult nsres;
2527 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2529 if(!This->dom_document) {
2530 FIXME("NULL dom_document\n");
2531 return E_UNEXPECTED;
2534 nsAString_InitDepend(&dir_str, v);
2535 nsres = nsIDOMDocument_SetDir(This->dom_document, &dir_str);
2536 nsAString_Finish(&dir_str);
2537 if(NS_FAILED(nsres)) {
2538 ERR("SetDir failed: %08lx\n", nsres);
2539 return E_FAIL;
2542 return S_OK;
2545 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2547 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2548 nsAString dir_str;
2549 nsresult nsres;
2551 TRACE("(%p)->(%p)\n", This, p);
2553 if(!This->dom_document) {
2554 FIXME("NULL dom_document\n");
2555 return E_UNEXPECTED;
2558 nsAString_Init(&dir_str, NULL);
2559 nsres = nsIDOMDocument_GetDir(This->dom_document, &dir_str);
2560 return return_nsstr(nsres, &dir_str, p);
2563 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2565 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2567 TRACE("(%p)->()\n", This);
2569 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2572 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2574 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2576 TRACE("(%p)->(%p)\n", This, p);
2578 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2581 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2583 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2584 FIXME("(%p)->()\n", This);
2585 return E_NOTIMPL;
2588 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2590 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2591 FIXME("(%p)->(%p)\n", This, p);
2592 return E_NOTIMPL;
2595 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface, IHTMLDocument2 **ppNewDoc)
2597 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2598 nsIDOMDocumentFragment *doc_frag;
2599 HTMLDocumentNode *docnode;
2600 nsresult nsres;
2601 HRESULT hres;
2603 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2605 if(!This->dom_document) {
2606 FIXME("NULL dom_document\n");
2607 return E_NOTIMPL;
2610 nsres = nsIDOMDocument_CreateDocumentFragment(This->dom_document, &doc_frag);
2611 if(NS_FAILED(nsres)) {
2612 ERR("CreateDocumentFragment failed: %08lx\n", nsres);
2613 return E_FAIL;
2616 hres = create_document_fragment((nsIDOMNode*)doc_frag, This, &docnode);
2617 nsIDOMDocumentFragment_Release(doc_frag);
2618 if(FAILED(hres))
2619 return hres;
2621 *ppNewDoc = &docnode->IHTMLDocument2_iface;
2622 return S_OK;
2625 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface, IHTMLDocument2 **p)
2627 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2628 FIXME("(%p)->(%p)\n", This, p);
2629 return E_NOTIMPL;
2632 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL v)
2634 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2635 FIXME("(%p)->(%x)\n", This, v);
2636 return E_NOTIMPL;
2639 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2641 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2642 FIXME("(%p)->(%p)\n", This, p);
2643 return E_NOTIMPL;
2646 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2648 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2649 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2650 return E_NOTIMPL;
2653 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2655 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2656 FIXME("(%p)->(%p)\n", This, p);
2657 return E_NOTIMPL;
2660 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2662 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2664 TRACE("(%p)->(%p)\n", This, p);
2666 return IHTMLDOMNode_get_childNodes(&This->node.IHTMLDOMNode_iface, p);
2669 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL v)
2671 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2672 FIXME("(%p)->()\n", This);
2673 return E_NOTIMPL;
2676 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2678 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2679 FIXME("(%p)->(%p)\n", This, p);
2680 return E_NOTIMPL;
2683 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2685 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2686 FIXME("(%p)->()\n", This);
2687 return E_NOTIMPL;
2690 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2692 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2693 FIXME("(%p)->(%p)\n", This, p);
2694 return E_NOTIMPL;
2697 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2698 IHTMLElementCollection **ppelColl)
2700 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2701 nsIDOMNodeList *node_list;
2702 nsAString selector_str;
2703 WCHAR *selector;
2704 nsresult nsres;
2705 static const WCHAR formatW[] = L"*[id=%s],*[name=%s]";
2707 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2709 if(!This->dom_document) {
2710 /* We should probably return an empty collection. */
2711 FIXME("No dom_document\n");
2712 return E_NOTIMPL;
2715 selector = malloc(2 * SysStringLen(v) * sizeof(WCHAR) + sizeof(formatW));
2716 if(!selector)
2717 return E_OUTOFMEMORY;
2718 swprintf(selector, 2*SysStringLen(v) + ARRAY_SIZE(formatW), formatW, v, v);
2721 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2722 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2723 * types and search should be case insensitive. Those are currently not supported properly.
2725 nsAString_InitDepend(&selector_str, selector);
2726 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &selector_str, &node_list);
2727 nsAString_Finish(&selector_str);
2728 free(selector);
2729 if(NS_FAILED(nsres)) {
2730 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2731 return E_FAIL;
2734 *ppelColl = create_collection_from_nodelist(node_list, This->document_mode);
2735 nsIDOMNodeList_Release(node_list);
2736 return S_OK;
2740 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v, IHTMLElement **pel)
2742 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2743 HTMLElement *elem;
2744 HRESULT hres;
2746 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2748 hres = get_doc_elem_by_id(This, v, &elem);
2749 if(FAILED(hres) || !elem) {
2750 *pel = NULL;
2751 return hres;
2754 *pel = &elem->IHTMLElement_iface;
2755 return S_OK;
2759 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2760 IHTMLElementCollection **pelColl)
2762 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2763 nsIDOMNodeList *nslist;
2764 nsAString id_str;
2765 nsresult nsres;
2767 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2769 if(This->dom_document) {
2770 nsAString_InitDepend(&id_str, v);
2771 nsres = nsIDOMDocument_GetElementsByTagName(This->dom_document, &id_str, &nslist);
2772 nsAString_Finish(&id_str);
2773 if(FAILED(nsres)) {
2774 ERR("GetElementByName failed: %08lx\n", nsres);
2775 return E_FAIL;
2777 }else {
2778 nsIDOMDocumentFragment *docfrag;
2779 nsAString nsstr;
2781 if(v) {
2782 const WCHAR *ptr;
2783 for(ptr=v; *ptr; ptr++) {
2784 if(!iswalnum(*ptr)) {
2785 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2786 return E_NOTIMPL;
2791 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2792 if(NS_FAILED(nsres)) {
2793 ERR("Could not get nsIDOMDocumentFragment iface: %08lx\n", nsres);
2794 return E_UNEXPECTED;
2797 nsAString_InitDepend(&nsstr, v);
2798 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2799 nsAString_Finish(&nsstr);
2800 nsIDOMDocumentFragment_Release(docfrag);
2801 if(NS_FAILED(nsres)) {
2802 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2803 return E_FAIL;
2808 *pelColl = create_collection_from_nodelist(nslist, This->document_mode);
2809 nsIDOMNodeList_Release(nslist);
2811 return S_OK;
2814 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2815 HTMLDocument3_QueryInterface,
2816 HTMLDocument3_AddRef,
2817 HTMLDocument3_Release,
2818 HTMLDocument3_GetTypeInfoCount,
2819 HTMLDocument3_GetTypeInfo,
2820 HTMLDocument3_GetIDsOfNames,
2821 HTMLDocument3_Invoke,
2822 HTMLDocument3_releaseCapture,
2823 HTMLDocument3_recalc,
2824 HTMLDocument3_createTextNode,
2825 HTMLDocument3_get_documentElement,
2826 HTMLDocument3_get_uniqueID,
2827 HTMLDocument3_attachEvent,
2828 HTMLDocument3_detachEvent,
2829 HTMLDocument3_put_onrowsdelete,
2830 HTMLDocument3_get_onrowsdelete,
2831 HTMLDocument3_put_onrowsinserted,
2832 HTMLDocument3_get_onrowsinserted,
2833 HTMLDocument3_put_oncellchange,
2834 HTMLDocument3_get_oncellchange,
2835 HTMLDocument3_put_ondatasetchanged,
2836 HTMLDocument3_get_ondatasetchanged,
2837 HTMLDocument3_put_ondataavailable,
2838 HTMLDocument3_get_ondataavailable,
2839 HTMLDocument3_put_ondatasetcomplete,
2840 HTMLDocument3_get_ondatasetcomplete,
2841 HTMLDocument3_put_onpropertychange,
2842 HTMLDocument3_get_onpropertychange,
2843 HTMLDocument3_put_dir,
2844 HTMLDocument3_get_dir,
2845 HTMLDocument3_put_oncontextmenu,
2846 HTMLDocument3_get_oncontextmenu,
2847 HTMLDocument3_put_onstop,
2848 HTMLDocument3_get_onstop,
2849 HTMLDocument3_createDocumentFragment,
2850 HTMLDocument3_get_parentDocument,
2851 HTMLDocument3_put_enableDownload,
2852 HTMLDocument3_get_enableDownload,
2853 HTMLDocument3_put_baseUrl,
2854 HTMLDocument3_get_baseUrl,
2855 HTMLDocument3_get_childNodes,
2856 HTMLDocument3_put_inheritStyleSheets,
2857 HTMLDocument3_get_inheritStyleSheets,
2858 HTMLDocument3_put_onbeforeeditfocus,
2859 HTMLDocument3_get_onbeforeeditfocus,
2860 HTMLDocument3_getElementsByName,
2861 HTMLDocument3_getElementById,
2862 HTMLDocument3_getElementsByTagName
2865 static inline HTMLDocumentNode *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2867 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument4_iface);
2870 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface, REFIID riid, void **ppv)
2872 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2873 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2876 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2878 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2879 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2882 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2884 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2885 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2888 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2890 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2891 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2894 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo, LCID lcid,
2895 ITypeInfo **ppTInfo)
2897 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2898 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2901 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid, LPOLESTR *rgszNames,
2902 UINT cNames, LCID lcid, DISPID *rgDispId)
2904 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2905 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2908 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2909 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2911 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2912 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2913 pDispParams, pVarResult, pExcepInfo, puArgErr);
2916 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2918 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2919 nsIDOMHTMLElement *nsbody;
2920 nsresult nsres;
2922 TRACE("(%p)->()\n", This);
2924 if(!This->html_document) {
2925 FIXME("Not implemented for XML document\n");
2926 return E_NOTIMPL;
2929 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, &nsbody);
2930 if(NS_FAILED(nsres) || !nsbody) {
2931 ERR("GetBody failed: %08lx\n", nsres);
2932 return E_FAIL;
2935 nsres = nsIDOMHTMLElement_Focus(nsbody);
2936 nsIDOMHTMLElement_Release(nsbody);
2937 if(NS_FAILED(nsres)) {
2938 ERR("Focus failed: %08lx\n", nsres);
2939 return E_FAIL;
2942 return S_OK;
2945 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2947 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2948 cpp_bool has_focus;
2949 nsresult nsres;
2951 TRACE("(%p)->(%p)\n", This, pfFocus);
2953 if(!This->dom_document) {
2954 FIXME("Unimplemented for fragments.\n");
2955 return E_NOTIMPL;
2958 nsres = nsIDOMDocument_HasFocus(This->dom_document, &has_focus);
2959 assert(nsres == NS_OK);
2961 *pfFocus = variant_bool(has_focus);
2962 return S_OK;
2965 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2967 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2969 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2971 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2974 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2976 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2978 TRACE("(%p)->(%p)\n", This, p);
2980 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2983 static HRESULT WINAPI HTMLDocument4_get_namespaces(IHTMLDocument4 *iface, IDispatch **p)
2985 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2987 TRACE("(%p)->(%p)\n", This, p);
2989 if(!This->namespaces) {
2990 HRESULT hres;
2992 hres = create_namespace_collection(dispex_compat_mode(&This->node.event_target.dispex),
2993 &This->namespaces);
2994 if(FAILED(hres))
2995 return hres;
2998 IHTMLNamespaceCollection_AddRef(This->namespaces);
2999 *p = (IDispatch*)This->namespaces;
3000 return S_OK;
3003 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
3004 BSTR bstrOptions, IHTMLDocument2 **newDoc)
3006 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3007 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
3008 return E_NOTIMPL;
3011 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
3013 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3014 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3015 return E_NOTIMPL;
3018 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
3020 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3021 FIXME("(%p)->(%p)\n", This, p);
3022 return E_NOTIMPL;
3025 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
3026 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
3028 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3030 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
3032 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
3033 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
3034 return E_NOTIMPL;
3037 return create_event_obj(dispex_compat_mode(&This->node.event_target.dispex), ppEventObj);
3040 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
3041 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
3043 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3045 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
3047 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCanceled);
3050 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
3051 IHTMLRenderStyle **ppIHTMLRenderStyle)
3053 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3054 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
3055 return E_NOTIMPL;
3058 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
3060 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3061 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3062 return E_NOTIMPL;
3065 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
3067 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3068 FIXME("(%p)->(%p)\n", This, p);
3069 return E_NOTIMPL;
3072 static HRESULT WINAPI HTMLDocument4_get_URLUnencoded(IHTMLDocument4 *iface, BSTR *p)
3074 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3075 FIXME("(%p)->(%p)\n", This, p);
3076 return E_NOTIMPL;
3079 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
3080 HTMLDocument4_QueryInterface,
3081 HTMLDocument4_AddRef,
3082 HTMLDocument4_Release,
3083 HTMLDocument4_GetTypeInfoCount,
3084 HTMLDocument4_GetTypeInfo,
3085 HTMLDocument4_GetIDsOfNames,
3086 HTMLDocument4_Invoke,
3087 HTMLDocument4_focus,
3088 HTMLDocument4_hasFocus,
3089 HTMLDocument4_put_onselectionchange,
3090 HTMLDocument4_get_onselectionchange,
3091 HTMLDocument4_get_namespaces,
3092 HTMLDocument4_createDocumentFromUrl,
3093 HTMLDocument4_put_media,
3094 HTMLDocument4_get_media,
3095 HTMLDocument4_createEventObject,
3096 HTMLDocument4_fireEvent,
3097 HTMLDocument4_createRenderStyle,
3098 HTMLDocument4_put_oncontrolselect,
3099 HTMLDocument4_get_oncontrolselect,
3100 HTMLDocument4_get_URLUnencoded
3103 static inline HTMLDocumentNode *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
3105 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument5_iface);
3108 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface, REFIID riid, void **ppv)
3110 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3111 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3114 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
3116 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3117 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3120 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
3122 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3123 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3126 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
3128 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3129 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3132 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo, LCID lcid,
3133 ITypeInfo **ppTInfo)
3135 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3136 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3139 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid, LPOLESTR *rgszNames,
3140 UINT cNames, LCID lcid, DISPID *rgDispId)
3142 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3143 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3146 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3147 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3149 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3150 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3151 pDispParams, pVarResult, pExcepInfo, puArgErr);
3154 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
3156 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3158 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3160 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
3163 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
3165 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3167 TRACE("(%p)->(%p)\n", This, p);
3169 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
3172 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
3174 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3175 nsIDOMDocumentType *nsdoctype;
3176 HTMLDOMNode *doctype_node;
3177 nsresult nsres;
3178 HRESULT hres;
3180 TRACE("(%p)->(%p)\n", This, p);
3182 if(dispex_compat_mode(&This->node.event_target.dispex) < COMPAT_MODE_IE9) {
3183 *p = NULL;
3184 return S_OK;
3187 nsres = nsIDOMDocument_GetDoctype(This->dom_document, &nsdoctype);
3188 if(NS_FAILED(nsres))
3189 return map_nsresult(nsres);
3190 if(!nsdoctype) {
3191 *p = NULL;
3192 return S_OK;
3195 hres = get_node((nsIDOMNode*)nsdoctype, TRUE, &doctype_node);
3196 nsIDOMDocumentType_Release(nsdoctype);
3198 if(SUCCEEDED(hres))
3199 *p = &doctype_node->IHTMLDOMNode_iface;
3200 return hres;
3203 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
3205 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3207 TRACE("(%p)->(%p)\n", This, p);
3209 if(!This->dom_implementation) {
3210 HRESULT hres;
3212 hres = create_dom_implementation(This, &This->dom_implementation);
3213 if(FAILED(hres))
3214 return hres;
3217 IHTMLDOMImplementation_AddRef(This->dom_implementation);
3218 *p = This->dom_implementation;
3219 return S_OK;
3222 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
3223 IHTMLDOMAttribute **ppattribute)
3225 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3226 HTMLDOMAttribute *attr;
3227 HRESULT hres;
3229 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
3231 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, dispex_compat_mode(&This->node.event_target.dispex), &attr);
3232 if(FAILED(hres))
3233 return hres;
3235 *ppattribute = &attr->IHTMLDOMAttribute_iface;
3236 return S_OK;
3239 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
3240 IHTMLDOMNode **ppRetNode)
3242 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3243 nsIDOMComment *nscomment;
3244 HTMLElement *elem;
3245 nsAString str;
3246 nsresult nsres;
3247 HRESULT hres;
3249 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
3251 if(!This->dom_document) {
3252 WARN("NULL dom_document\n");
3253 return E_UNEXPECTED;
3256 nsAString_InitDepend(&str, bstrdata);
3257 nsres = nsIDOMDocument_CreateComment(This->dom_document, &str, &nscomment);
3258 nsAString_Finish(&str);
3259 if(NS_FAILED(nsres)) {
3260 ERR("CreateTextNode failed: %08lx\n", nsres);
3261 return E_FAIL;
3264 hres = HTMLCommentElement_Create(This, (nsIDOMNode*)nscomment, &elem);
3265 nsIDOMComment_Release(nscomment);
3266 if(FAILED(hres))
3267 return hres;
3269 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
3270 return S_OK;
3273 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
3275 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3277 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3279 return set_doc_event(This, EVENTID_FOCUSIN, &v);
3282 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
3284 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3286 TRACE("(%p)->(%p)\n", This, p);
3288 return get_doc_event(This, EVENTID_FOCUSIN, p);
3291 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
3293 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3295 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3297 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
3300 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
3302 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3304 TRACE("(%p)->(%p)\n", This, p);
3306 return get_doc_event(This, EVENTID_FOCUSOUT, p);
3309 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
3311 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3312 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3313 return E_NOTIMPL;
3316 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
3318 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3319 FIXME("(%p)->(%p)\n", This, p);
3320 return E_NOTIMPL;
3323 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
3325 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3326 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3327 return E_NOTIMPL;
3330 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
3332 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3333 FIXME("(%p)->(%p)\n", This, p);
3334 return E_NOTIMPL;
3337 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
3339 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3340 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3341 return E_NOTIMPL;
3344 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
3346 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3347 FIXME("(%p)->(%p)\n", This, p);
3348 return E_NOTIMPL;
3351 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
3353 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3354 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3355 return E_NOTIMPL;
3358 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
3360 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3361 FIXME("(%p)->(%p)\n", This, p);
3362 return E_NOTIMPL;
3365 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
3367 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3369 TRACE("(%p)->(%p)\n", This, p);
3371 *p = SysAllocString(This->document_mode <= COMPAT_MODE_IE5 ? L"BackCompat" : L"CSS1Compat");
3372 return *p ? S_OK : E_OUTOFMEMORY;
3375 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
3376 HTMLDocument5_QueryInterface,
3377 HTMLDocument5_AddRef,
3378 HTMLDocument5_Release,
3379 HTMLDocument5_GetTypeInfoCount,
3380 HTMLDocument5_GetTypeInfo,
3381 HTMLDocument5_GetIDsOfNames,
3382 HTMLDocument5_Invoke,
3383 HTMLDocument5_put_onmousewheel,
3384 HTMLDocument5_get_onmousewheel,
3385 HTMLDocument5_get_doctype,
3386 HTMLDocument5_get_implementation,
3387 HTMLDocument5_createAttribute,
3388 HTMLDocument5_createComment,
3389 HTMLDocument5_put_onfocusin,
3390 HTMLDocument5_get_onfocusin,
3391 HTMLDocument5_put_onfocusout,
3392 HTMLDocument5_get_onfocusout,
3393 HTMLDocument5_put_onactivate,
3394 HTMLDocument5_get_onactivate,
3395 HTMLDocument5_put_ondeactivate,
3396 HTMLDocument5_get_ondeactivate,
3397 HTMLDocument5_put_onbeforeactivate,
3398 HTMLDocument5_get_onbeforeactivate,
3399 HTMLDocument5_put_onbeforedeactivate,
3400 HTMLDocument5_get_onbeforedeactivate,
3401 HTMLDocument5_get_compatMode
3404 static inline HTMLDocumentNode *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3406 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument6_iface);
3409 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface, REFIID riid, void **ppv)
3411 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3412 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3415 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3417 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3418 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3421 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3423 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3424 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3427 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3429 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3430 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3433 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo, LCID lcid,
3434 ITypeInfo **ppTInfo)
3436 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3437 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3440 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid, LPOLESTR *rgszNames,
3441 UINT cNames, LCID lcid, DISPID *rgDispId)
3443 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3444 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3447 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3448 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3450 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3451 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3452 pDispParams, pVarResult, pExcepInfo, puArgErr);
3455 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3456 IHTMLDocumentCompatibleInfoCollection **p)
3458 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3459 FIXME("(%p)->(%p)\n", This, p);
3460 return E_NOTIMPL;
3463 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3465 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3467 TRACE("(%p)->(%p)\n", This, p);
3469 V_VT(p) = VT_R4;
3470 V_R4(p) = compat_mode_info[This->document_mode].document_mode;
3471 return S_OK;
3474 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3475 VARIANT *p)
3477 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3479 TRACE("(%p)->(%p)\n", This, p);
3481 return get_doc_event(This, EVENTID_STORAGE, p);
3484 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3486 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3488 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3490 return set_doc_event(This, EVENTID_STORAGE, &v);
3493 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3494 VARIANT *p)
3496 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3498 TRACE("(%p)->(%p)\n", This, p);
3500 return get_doc_event(This, EVENTID_STORAGECOMMIT, p);
3503 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3505 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3507 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3509 return set_doc_event(This, EVENTID_STORAGECOMMIT, &v);
3512 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3513 BSTR bstrId, IHTMLElement2 **p)
3515 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3516 nsIDOMElement *nselem;
3517 HTMLElement *elem;
3518 nsAString nsstr;
3519 nsresult nsres;
3520 HRESULT hres;
3522 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3525 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3526 * not search for name attributes, so we may simply let Gecko do the right thing.
3529 if(!This->dom_document) {
3530 FIXME("Not a document\n");
3531 return E_FAIL;
3534 nsAString_InitDepend(&nsstr, bstrId);
3535 nsres = nsIDOMDocument_GetElementById(This->dom_document, &nsstr, &nselem);
3536 nsAString_Finish(&nsstr);
3537 if(NS_FAILED(nsres)) {
3538 ERR("GetElementById failed: %08lx\n", nsres);
3539 return E_FAIL;
3542 if(!nselem) {
3543 *p = NULL;
3544 return S_OK;
3547 hres = get_element(nselem, &elem);
3548 nsIDOMElement_Release(nselem);
3549 if(FAILED(hres))
3550 return hres;
3552 *p = &elem->IHTMLElement2_iface;
3553 return S_OK;
3556 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3558 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3559 FIXME("(%p)->()\n", This);
3560 return E_NOTIMPL;
3563 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3564 HTMLDocument6_QueryInterface,
3565 HTMLDocument6_AddRef,
3566 HTMLDocument6_Release,
3567 HTMLDocument6_GetTypeInfoCount,
3568 HTMLDocument6_GetTypeInfo,
3569 HTMLDocument6_GetIDsOfNames,
3570 HTMLDocument6_Invoke,
3571 HTMLDocument6_get_compatible,
3572 HTMLDocument6_get_documentMode,
3573 HTMLDocument6_put_onstorage,
3574 HTMLDocument6_get_onstorage,
3575 HTMLDocument6_put_onstoragecommit,
3576 HTMLDocument6_get_onstoragecommit,
3577 HTMLDocument6_getElementById,
3578 HTMLDocument6_updateSettings
3581 static inline HTMLDocumentNode *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3583 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument7_iface);
3586 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3588 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3589 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3592 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3594 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3595 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3598 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3600 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3601 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3604 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3606 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3607 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3610 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo, LCID lcid,
3611 ITypeInfo **ppTInfo)
3613 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3614 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3617 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid, LPOLESTR *rgszNames,
3618 UINT cNames, LCID lcid, DISPID *rgDispId)
3620 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3621 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3624 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3625 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3627 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3628 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3629 pDispParams, pVarResult, pExcepInfo, puArgErr);
3632 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3634 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3636 TRACE("(%p)->(%p)\n", This, p);
3638 if(This->window && This->window->base.outer_window) {
3639 *p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
3640 IHTMLWindow2_AddRef(*p);
3641 }else {
3642 *p = NULL;
3644 return S_OK;
3647 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3649 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3650 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3651 return E_NOTIMPL;
3654 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3656 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3657 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3658 return E_NOTIMPL;
3661 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3662 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3664 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3665 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3666 return E_NOTIMPL;
3669 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3671 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3672 nsIDOMElement *dom_element;
3673 HTMLElement *element;
3674 nsAString ns, tag;
3675 nsresult nsres;
3676 HRESULT hres;
3678 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3680 if(!This->dom_document) {
3681 FIXME("NULL dom_document\n");
3682 return E_FAIL;
3685 if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
3686 FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
3688 nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
3689 nsAString_InitDepend(&tag, bstrTag);
3690 nsres = nsIDOMDocument_CreateElementNS(This->dom_document, &ns, &tag, &dom_element);
3691 nsAString_Finish(&ns);
3692 nsAString_Finish(&tag);
3693 if(NS_FAILED(nsres)) {
3694 WARN("CreateElementNS failed: %08lx\n", nsres);
3695 return map_nsresult(nsres);
3698 hres = HTMLElement_Create(This, (nsIDOMNode*)dom_element, FALSE, &element);
3699 nsIDOMElement_Release(dom_element);
3700 if(FAILED(hres))
3701 return hres;
3703 *newElem = &element->IHTMLElement_iface;
3704 return S_OK;
3707 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3708 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3710 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3711 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3712 return E_NOTIMPL;
3715 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3717 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3718 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3719 return E_NOTIMPL;
3722 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3724 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3726 TRACE("(%p)->(%p)\n", This, p);
3728 return get_doc_event(This, EVENTID_MSTHUMBNAILCLICK, p);
3731 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3733 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3734 nsAString charset_str;
3735 nsresult nsres;
3737 TRACE("(%p)->(%p)\n", This, p);
3739 if(!This->dom_document) {
3740 FIXME("NULL dom_document\n");
3741 return E_FAIL;
3744 nsAString_Init(&charset_str, NULL);
3745 nsres = nsIDOMDocument_GetCharacterSet(This->dom_document, &charset_str);
3746 return return_nsstr(nsres, &charset_str, p);
3749 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3751 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3753 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3755 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3758 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3760 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3762 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3764 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3767 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3769 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3770 nsIDOMNodeList *nslist;
3771 nsAString nsstr;
3772 nsresult nsres;
3774 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3776 if(!This->dom_document) {
3777 FIXME("NULL dom_document not supported\n");
3778 return E_NOTIMPL;
3781 nsAString_InitDepend(&nsstr, v);
3782 nsres = nsIDOMDocument_GetElementsByClassName(This->dom_document, &nsstr, &nslist);
3783 nsAString_Finish(&nsstr);
3784 if(FAILED(nsres)) {
3785 ERR("GetElementByClassName failed: %08lx\n", nsres);
3786 return E_FAIL;
3790 *pel = create_collection_from_nodelist(nslist, This->document_mode);
3791 nsIDOMNodeList_Release(nslist);
3792 return S_OK;
3795 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3796 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3798 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3799 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3800 return E_NOTIMPL;
3803 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3805 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3806 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3807 return E_NOTIMPL;
3810 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3812 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3813 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3814 return E_NOTIMPL;
3817 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3819 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3820 FIXME("(%p)->(%p)\n", This, p);
3821 return E_NOTIMPL;
3824 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3826 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3828 TRACE("(%p)->(%p)\n", This, p);
3830 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3833 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3835 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3836 FIXME("(%p)->(%p)\n", This, p);
3837 return E_NOTIMPL;
3840 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3842 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3843 FIXME("(%p)->(%p)\n", This, p);
3844 return E_NOTIMPL;
3847 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3849 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3850 FIXME("(%p)->(%x)\n", This, v);
3851 return E_NOTIMPL;
3854 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3856 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3857 FIXME("(%p)->(%p)\n", This, p);
3858 return E_NOTIMPL;
3861 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3863 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3864 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3865 return E_NOTIMPL;
3868 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3870 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3871 FIXME("(%p)->(%p)\n", This, p);
3872 return E_NOTIMPL;
3875 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3877 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3878 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3879 return E_NOTIMPL;
3882 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3884 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3886 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3888 return set_doc_event(This, EVENTID_ABORT, &v);
3891 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3893 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3895 TRACE("(%p)->(%p)\n", This, p);
3897 return get_doc_event(This, EVENTID_ABORT, p);
3900 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3902 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3904 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3906 return set_doc_event(This, EVENTID_BLUR, &v);
3909 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3911 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3913 TRACE("(%p)->(%p)\n", This, p);
3915 return get_doc_event(This, EVENTID_BLUR, p);
3918 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3920 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3921 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3922 return E_NOTIMPL;
3925 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3927 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3928 FIXME("(%p)->(%p)\n", This, p);
3929 return E_NOTIMPL;
3932 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3934 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3935 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3936 return E_NOTIMPL;
3939 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3941 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3942 FIXME("(%p)->(%p)\n", This, p);
3943 return E_NOTIMPL;
3946 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3948 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3950 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3952 return set_doc_event(This, EVENTID_CHANGE, &v);
3955 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3957 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3959 TRACE("(%p)->(%p)\n", This, p);
3961 return get_doc_event(This, EVENTID_CHANGE, p);
3964 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3966 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3968 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3970 return set_doc_event(This, EVENTID_DRAG, &v);
3973 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3975 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3977 TRACE("(%p)->(%p)\n", This, p);
3979 return get_doc_event(This, EVENTID_DRAG, p);
3982 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3984 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3985 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3986 return E_NOTIMPL;
3989 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3991 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3992 FIXME("(%p)->(%p)\n", This, p);
3993 return E_NOTIMPL;
3996 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3998 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3999 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4000 return E_NOTIMPL;
4003 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
4005 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4006 FIXME("(%p)->(%p)\n", This, p);
4007 return E_NOTIMPL;
4010 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
4012 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4013 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4014 return E_NOTIMPL;
4017 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
4019 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4020 FIXME("(%p)->(%p)\n", This, p);
4021 return E_NOTIMPL;
4024 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
4026 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4027 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4028 return E_NOTIMPL;
4031 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
4033 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4034 FIXME("(%p)->(%p)\n", This, p);
4035 return E_NOTIMPL;
4038 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
4040 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4041 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4042 return E_NOTIMPL;
4045 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
4047 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4048 FIXME("(%p)->(%p)\n", This, p);
4049 return E_NOTIMPL;
4052 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
4054 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4055 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4056 return E_NOTIMPL;
4059 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
4061 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4062 FIXME("(%p)->(%p)\n", This, p);
4063 return E_NOTIMPL;
4066 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
4068 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4069 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4070 return E_NOTIMPL;
4073 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
4075 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4076 FIXME("(%p)->(%p)\n", This, p);
4077 return E_NOTIMPL;
4080 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
4082 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4083 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4084 return E_NOTIMPL;
4087 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
4089 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4090 FIXME("(%p)->(%p)\n", This, p);
4091 return E_NOTIMPL;
4094 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
4096 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4098 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4100 return set_doc_event(This, EVENTID_ERROR, &v);
4103 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
4105 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4107 TRACE("(%p)->(%p)\n", This, p);
4109 return get_doc_event(This, EVENTID_ERROR, p);
4112 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
4114 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4116 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4118 return set_doc_event(This, EVENTID_FOCUS, &v);
4121 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
4123 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4125 TRACE("(%p)->(%p)\n", This, p);
4127 return get_doc_event(This, EVENTID_FOCUS, p);
4130 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
4132 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4134 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4136 return set_doc_event(This, EVENTID_INPUT, &v);
4139 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
4141 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4143 TRACE("(%p)->(%p)\n", This, p);
4145 return get_doc_event(This, EVENTID_INPUT, p);
4148 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
4150 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4152 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4154 return set_doc_event(This, EVENTID_LOAD, &v);
4157 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
4159 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4161 TRACE("(%p)->(%p)\n", This, p);
4163 return get_doc_event(This, EVENTID_LOAD, p);
4166 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
4168 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4169 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4170 return E_NOTIMPL;
4173 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
4175 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4176 FIXME("(%p)->(%p)\n", This, p);
4177 return E_NOTIMPL;
4180 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
4182 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4183 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4184 return E_NOTIMPL;
4187 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
4189 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4190 FIXME("(%p)->(%p)\n", This, p);
4191 return E_NOTIMPL;
4194 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
4196 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4197 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4198 return E_NOTIMPL;
4201 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
4203 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4204 FIXME("(%p)->(%p)\n", This, p);
4205 return E_NOTIMPL;
4208 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
4210 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4211 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4212 return E_NOTIMPL;
4215 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
4217 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4218 FIXME("(%p)->(%p)\n", This, p);
4219 return E_NOTIMPL;
4222 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
4224 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4225 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4226 return E_NOTIMPL;
4229 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
4231 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4232 FIXME("(%p)->(%p)\n", This, p);
4233 return E_NOTIMPL;
4236 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
4238 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4239 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4240 return E_NOTIMPL;
4243 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
4245 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4246 FIXME("(%p)->(%p)\n", This, p);
4247 return E_NOTIMPL;
4250 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
4252 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4253 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4254 return E_NOTIMPL;
4257 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
4259 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4260 FIXME("(%p)->(%p)\n", This, p);
4261 return E_NOTIMPL;
4264 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
4266 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4267 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4268 return E_NOTIMPL;
4271 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
4273 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4274 FIXME("(%p)->(%p)\n", This, p);
4275 return E_NOTIMPL;
4278 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
4280 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4281 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4282 return E_NOTIMPL;
4285 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
4287 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4288 FIXME("(%p)->(%p)\n", This, p);
4289 return E_NOTIMPL;
4292 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
4294 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4296 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4298 return set_doc_event(This, EVENTID_SCROLL, &v);
4301 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
4303 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4305 TRACE("(%p)->(%p)\n", This, p);
4307 return get_doc_event(This, EVENTID_SCROLL, p);
4310 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
4312 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4313 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4314 return E_NOTIMPL;
4317 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
4319 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4320 FIXME("(%p)->(%p)\n", This, p);
4321 return E_NOTIMPL;
4324 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
4326 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4327 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4328 return E_NOTIMPL;
4331 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
4333 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4334 FIXME("(%p)->(%p)\n", This, p);
4335 return E_NOTIMPL;
4338 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
4340 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4341 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4342 return E_NOTIMPL;
4345 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
4347 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4348 FIXME("(%p)->(%p)\n", This, p);
4349 return E_NOTIMPL;
4352 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
4354 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4355 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4356 return E_NOTIMPL;
4359 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
4361 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4362 FIXME("(%p)->(%p)\n", This, p);
4363 return E_NOTIMPL;
4366 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
4368 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4370 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4372 return set_doc_event(This, EVENTID_SUBMIT, &v);
4375 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
4377 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4379 TRACE("(%p)->(%p)\n", This, p);
4381 return get_doc_event(This, EVENTID_SUBMIT, p);
4384 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
4386 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4387 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4388 return E_NOTIMPL;
4391 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
4393 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4394 FIXME("(%p)->(%p)\n", This, p);
4395 return E_NOTIMPL;
4398 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
4400 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4401 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4402 return E_NOTIMPL;
4405 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
4407 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4408 FIXME("(%p)->(%p)\n", This, p);
4409 return E_NOTIMPL;
4412 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
4414 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4415 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4416 return E_NOTIMPL;
4419 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4421 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4422 FIXME("(%p)->(%p)\n", This, p);
4423 return E_NOTIMPL;
4426 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4428 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4429 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4430 return E_NOTIMPL;
4433 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4435 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4436 FIXME("(%p)->(%p)\n", This, p);
4437 return E_NOTIMPL;
4440 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4442 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4443 FIXME("(%p)\n", This);
4444 return E_NOTIMPL;
4447 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4448 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4450 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4451 nsIDOMNode *nsnode = NULL;
4452 HTMLDOMNode *node;
4453 nsresult nsres;
4454 HRESULT hres;
4456 TRACE("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4458 if(!This->dom_document) {
4459 WARN("NULL dom_document\n");
4460 return E_UNEXPECTED;
4463 if(!(node = unsafe_impl_from_IHTMLDOMNode(pNodeSource))) {
4464 ERR("not our node\n");
4465 return E_FAIL;
4468 nsres = nsIDOMDocument_ImportNode(This->dom_document, node->nsnode, !!fDeep, 1, &nsnode);
4469 if(NS_FAILED(nsres)) {
4470 ERR("ImportNode failed: %08lx\n", nsres);
4471 return map_nsresult(nsres);
4474 if(!nsnode) {
4475 *ppNodeDest = NULL;
4476 return S_OK;
4479 hres = get_node(nsnode, TRUE, &node);
4480 nsIDOMNode_Release(nsnode);
4481 if(FAILED(hres))
4482 return hres;
4484 *ppNodeDest = &node->IHTMLDOMNode3_iface;
4485 return hres;
4488 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4490 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4492 TRACE("(%p)->(%p)\n", This, p);
4494 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4497 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4499 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4500 FIXME("(%p)->(%p)\n", This, v);
4501 return E_NOTIMPL;
4504 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4506 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4508 TRACE("(%p)->(%p)\n", This, p);
4510 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4513 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4515 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4516 nsIDOMHTMLHeadElement *nshead;
4517 nsIDOMElement *nselem;
4518 HTMLElement *elem;
4519 nsresult nsres;
4520 HRESULT hres;
4522 TRACE("(%p)->(%p)\n", This, p);
4524 if(!This->dom_document) {
4525 FIXME("No document\n");
4526 return E_FAIL;
4529 if(!This->html_document) {
4530 FIXME("Not implemented for XML document\n");
4531 return E_NOTIMPL;
4534 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &nshead);
4535 assert(nsres == NS_OK);
4537 if(!nshead) {
4538 *p = NULL;
4539 return S_OK;
4542 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4543 nsIDOMHTMLHeadElement_Release(nshead);
4544 assert(nsres == NS_OK);
4546 hres = get_element(nselem, &elem);
4547 nsIDOMElement_Release(nselem);
4548 if(FAILED(hres))
4549 return hres;
4551 *p = &elem->IHTMLElement_iface;
4552 return S_OK;
4555 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4556 HTMLDocument7_QueryInterface,
4557 HTMLDocument7_AddRef,
4558 HTMLDocument7_Release,
4559 HTMLDocument7_GetTypeInfoCount,
4560 HTMLDocument7_GetTypeInfo,
4561 HTMLDocument7_GetIDsOfNames,
4562 HTMLDocument7_Invoke,
4563 HTMLDocument7_get_defaultView,
4564 HTMLDocument7_createCDATASection,
4565 HTMLDocument7_getSelection,
4566 HTMLDocument7_getElementsByTagNameNS,
4567 HTMLDocument7_createElementNS,
4568 HTMLDocument7_createAttributeNS,
4569 HTMLDocument7_put_onmsthumbnailclick,
4570 HTMLDocument7_get_onmsthumbnailclick,
4571 HTMLDocument7_get_characterSet,
4572 HTMLDocument7_createElement,
4573 HTMLDocument7_createAttribute,
4574 HTMLDocument7_getElementsByClassName,
4575 HTMLDocument7_createProcessingInstruction,
4576 HTMLDocument7_adoptNode,
4577 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4578 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4579 HTMLDocument7_get_all,
4580 HTMLDocument7_get_inputEncoding,
4581 HTMLDocument7_get_xmlEncoding,
4582 HTMLDocument7_put_xmlStandalone,
4583 HTMLDocument7_get_xmlStandalone,
4584 HTMLDocument7_put_xmlVersion,
4585 HTMLDocument7_get_xmlVersion,
4586 HTMLDocument7_hasAttributes,
4587 HTMLDocument7_put_onabort,
4588 HTMLDocument7_get_onabort,
4589 HTMLDocument7_put_onblur,
4590 HTMLDocument7_get_onblur,
4591 HTMLDocument7_put_oncanplay,
4592 HTMLDocument7_get_oncanplay,
4593 HTMLDocument7_put_oncanplaythrough,
4594 HTMLDocument7_get_oncanplaythrough,
4595 HTMLDocument7_put_onchange,
4596 HTMLDocument7_get_onchange,
4597 HTMLDocument7_put_ondrag,
4598 HTMLDocument7_get_ondrag,
4599 HTMLDocument7_put_ondragend,
4600 HTMLDocument7_get_ondragend,
4601 HTMLDocument7_put_ondragenter,
4602 HTMLDocument7_get_ondragenter,
4603 HTMLDocument7_put_ondragleave,
4604 HTMLDocument7_get_ondragleave,
4605 HTMLDocument7_put_ondragover,
4606 HTMLDocument7_get_ondragover,
4607 HTMLDocument7_put_ondrop,
4608 HTMLDocument7_get_ondrop,
4609 HTMLDocument7_put_ondurationchange,
4610 HTMLDocument7_get_ondurationchange,
4611 HTMLDocument7_put_onemptied,
4612 HTMLDocument7_get_onemptied,
4613 HTMLDocument7_put_onended,
4614 HTMLDocument7_get_onended,
4615 HTMLDocument7_put_onerror,
4616 HTMLDocument7_get_onerror,
4617 HTMLDocument7_put_onfocus,
4618 HTMLDocument7_get_onfocus,
4619 HTMLDocument7_put_oninput,
4620 HTMLDocument7_get_oninput,
4621 HTMLDocument7_put_onload,
4622 HTMLDocument7_get_onload,
4623 HTMLDocument7_put_onloadeddata,
4624 HTMLDocument7_get_onloadeddata,
4625 HTMLDocument7_put_onloadedmetadata,
4626 HTMLDocument7_get_onloadedmetadata,
4627 HTMLDocument7_put_onloadstart,
4628 HTMLDocument7_get_onloadstart,
4629 HTMLDocument7_put_onpause,
4630 HTMLDocument7_get_onpause,
4631 HTMLDocument7_put_onplay,
4632 HTMLDocument7_get_onplay,
4633 HTMLDocument7_put_onplaying,
4634 HTMLDocument7_get_onplaying,
4635 HTMLDocument7_put_onprogress,
4636 HTMLDocument7_get_onprogress,
4637 HTMLDocument7_put_onratechange,
4638 HTMLDocument7_get_onratechange,
4639 HTMLDocument7_put_onreset,
4640 HTMLDocument7_get_onreset,
4641 HTMLDocument7_put_onscroll,
4642 HTMLDocument7_get_onscroll,
4643 HTMLDocument7_put_onseekend,
4644 HTMLDocument7_get_onseekend,
4645 HTMLDocument7_put_onseeking,
4646 HTMLDocument7_get_onseeking,
4647 HTMLDocument7_put_onselect,
4648 HTMLDocument7_get_onselect,
4649 HTMLDocument7_put_onstalled,
4650 HTMLDocument7_get_onstalled,
4651 HTMLDocument7_put_onsubmit,
4652 HTMLDocument7_get_onsubmit,
4653 HTMLDocument7_put_onsuspend,
4654 HTMLDocument7_get_onsuspend,
4655 HTMLDocument7_put_ontimeupdate,
4656 HTMLDocument7_get_ontimeupdate,
4657 HTMLDocument7_put_onvolumechange,
4658 HTMLDocument7_get_onvolumechange,
4659 HTMLDocument7_put_onwaiting,
4660 HTMLDocument7_get_onwaiting,
4661 HTMLDocument7_normalize,
4662 HTMLDocument7_importNode,
4663 HTMLDocument7_get_parentWindow,
4664 HTMLDocument7_put_body,
4665 HTMLDocument7_get_body,
4666 HTMLDocument7_get_head
4669 static inline HTMLDocumentNode *impl_from_IDocumentSelector(IDocumentSelector *iface)
4671 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentSelector_iface);
4674 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4676 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4677 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4680 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4682 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4683 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4686 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4688 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4689 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4692 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4694 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4695 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4698 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4699 LCID lcid, ITypeInfo **ppTInfo)
4701 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4702 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4705 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4706 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4708 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4709 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4710 rgDispId);
4713 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4714 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4716 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4717 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4718 pDispParams, pVarResult, pExcepInfo, puArgErr);
4721 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4723 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4724 nsIDOMElement *nselem;
4725 HTMLElement *elem;
4726 nsAString nsstr;
4727 nsresult nsres;
4728 HRESULT hres;
4730 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4732 nsAString_InitDepend(&nsstr, v);
4733 nsres = nsIDOMDocument_QuerySelector(This->dom_document, &nsstr, &nselem);
4734 nsAString_Finish(&nsstr);
4735 if(NS_FAILED(nsres)) {
4736 WARN("QuerySelector failed: %08lx\n", nsres);
4737 return map_nsresult(nsres);
4740 if(!nselem) {
4741 *pel = NULL;
4742 return S_OK;
4745 hres = get_element(nselem, &elem);
4746 nsIDOMElement_Release(nselem);
4747 if(FAILED(hres))
4748 return hres;
4750 *pel = &elem->IHTMLElement_iface;
4751 return S_OK;
4754 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4756 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4757 nsIDOMNodeList *node_list;
4758 nsAString nsstr;
4759 nsresult nsres;
4760 HRESULT hres;
4762 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4764 nsAString_InitDepend(&nsstr, v);
4765 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &nsstr, &node_list);
4766 nsAString_Finish(&nsstr);
4767 if(NS_FAILED(nsres)) {
4768 WARN("QuerySelectorAll failed: %08lx\n", nsres);
4769 return map_nsresult(nsres);
4772 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
4773 nsIDOMNodeList_Release(node_list);
4774 return hres;
4777 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4778 DocumentSelector_QueryInterface,
4779 DocumentSelector_AddRef,
4780 DocumentSelector_Release,
4781 DocumentSelector_GetTypeInfoCount,
4782 DocumentSelector_GetTypeInfo,
4783 DocumentSelector_GetIDsOfNames,
4784 DocumentSelector_Invoke,
4785 DocumentSelector_querySelector,
4786 DocumentSelector_querySelectorAll
4789 static inline HTMLDocumentNode *impl_from_IDocumentEvent(IDocumentEvent *iface)
4791 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentEvent_iface);
4794 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4796 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4797 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4800 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4802 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4803 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4806 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4808 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4809 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4812 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4814 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4815 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4818 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4819 LCID lcid, ITypeInfo **ppTInfo)
4821 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4822 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4825 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4826 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4828 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4829 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4830 rgDispId);
4833 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4834 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4836 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4837 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4838 pDispParams, pVarResult, pExcepInfo, puArgErr);
4841 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4843 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4845 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4847 return create_document_event_str(This, eventType, p);
4850 static const IDocumentEventVtbl DocumentEventVtbl = {
4851 DocumentEvent_QueryInterface,
4852 DocumentEvent_AddRef,
4853 DocumentEvent_Release,
4854 DocumentEvent_GetTypeInfoCount,
4855 DocumentEvent_GetTypeInfo,
4856 DocumentEvent_GetIDsOfNames,
4857 DocumentEvent_Invoke,
4858 DocumentEvent_createEvent
4861 static void HTMLDocumentNode_on_advise(IUnknown *iface, cp_static_data_t *cp)
4863 HTMLDocumentNode *This = CONTAINING_RECORD((IHTMLDocument2*)iface, HTMLDocumentNode, IHTMLDocument2_iface);
4865 if(This->outer_window)
4866 update_doc_cp_events(This, cp);
4869 static inline HTMLDocumentNode *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4871 return CONTAINING_RECORD(iface, HTMLDocumentNode, ISupportErrorInfo_iface);
4874 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4876 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4877 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4880 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4882 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4883 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4886 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4888 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4889 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4892 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4894 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4895 return S_FALSE;
4898 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4899 SupportErrorInfo_QueryInterface,
4900 SupportErrorInfo_AddRef,
4901 SupportErrorInfo_Release,
4902 SupportErrorInfo_InterfaceSupportsErrorInfo
4905 static inline HTMLDocumentNode *impl_from_IDispatchEx(IDispatchEx *iface)
4907 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDispatchEx_iface);
4910 static HRESULT has_elem_name(nsIDOMHTMLDocument *html_document, const WCHAR *name)
4912 static const WCHAR fmt[] = L":-moz-any(applet,embed,form,iframe,img,object)[name=\"%s\"]";
4913 WCHAR buf[128], *selector = buf;
4914 nsAString selector_str;
4915 nsIDOMElement *nselem;
4916 nsresult nsres;
4917 size_t len;
4919 len = wcslen(name) + ARRAY_SIZE(fmt) - 2 /* %s */;
4920 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4921 return E_OUTOFMEMORY;
4922 swprintf(selector, len, fmt, name);
4924 nsAString_InitDepend(&selector_str, selector);
4925 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4926 nsAString_Finish(&selector_str);
4927 if(selector != buf)
4928 free(selector);
4929 if(NS_FAILED(nsres))
4930 return map_nsresult(nsres);
4932 if(!nselem)
4933 return DISP_E_UNKNOWNNAME;
4934 nsIDOMElement_Release(nselem);
4935 return S_OK;
4938 static HRESULT get_elem_by_name_or_id(nsIDOMHTMLDocument *html_document, const WCHAR *name, nsIDOMElement **ret)
4940 static const WCHAR fmt[] = L":-moz-any(embed,form,iframe,img):-moz-any([name=\"%s\"],[id=\"%s\"][name]),"
4941 L":-moz-any(applet,object):-moz-any([name=\"%s\"],[id=\"%s\"])";
4942 WCHAR buf[384], *selector = buf;
4943 nsAString selector_str;
4944 nsIDOMElement *nselem;
4945 nsresult nsres;
4946 size_t len;
4948 len = wcslen(name) * 4 + ARRAY_SIZE(fmt) - 8 /* %s */;
4949 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4950 return E_OUTOFMEMORY;
4951 swprintf(selector, len, fmt, name, name, name, name);
4953 nsAString_InitDepend(&selector_str, selector);
4954 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4955 nsAString_Finish(&selector_str);
4956 if(selector != buf)
4957 free(selector);
4958 if(NS_FAILED(nsres))
4959 return map_nsresult(nsres);
4961 if(ret) {
4962 *ret = nselem;
4963 return S_OK;
4966 if(nselem) {
4967 nsIDOMElement_Release(nselem);
4968 return S_OK;
4970 return DISP_E_UNKNOWNNAME;
4973 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, const WCHAR *name, DISPID *dispid)
4975 unsigned i;
4977 for(i=0; i < This->elem_vars_cnt; i++) {
4978 if(!wcscmp(name, This->elem_vars[i])) {
4979 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4980 return S_OK;
4984 if(This->elem_vars_cnt == This->elem_vars_size) {
4985 WCHAR **new_vars;
4987 if(This->elem_vars_size) {
4988 new_vars = realloc(This->elem_vars, This->elem_vars_size * 2 * sizeof(WCHAR*));
4989 if(!new_vars)
4990 return E_OUTOFMEMORY;
4991 This->elem_vars_size *= 2;
4992 }else {
4993 new_vars = malloc(16 * sizeof(WCHAR*));
4994 if(!new_vars)
4995 return E_OUTOFMEMORY;
4996 This->elem_vars_size = 16;
4999 This->elem_vars = new_vars;
5002 This->elem_vars[This->elem_vars_cnt] = wcsdup(name);
5003 if(!This->elem_vars[This->elem_vars_cnt])
5004 return E_OUTOFMEMORY;
5006 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
5007 return S_OK;
5010 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
5012 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5014 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5017 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
5019 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5021 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5024 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
5026 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5028 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5031 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
5033 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5035 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5038 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
5039 LCID lcid, ITypeInfo **ppTInfo)
5041 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5043 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5046 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
5047 LPOLESTR *rgszNames, UINT cNames,
5048 LCID lcid, DISPID *rgDispId)
5050 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5052 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
5055 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
5056 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5057 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5059 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5061 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
5062 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5064 return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags, pDispParams,
5065 pVarResult, pExcepInfo, NULL);
5068 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
5070 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5071 HRESULT hres;
5073 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex & ~fdexNameEnsure, pid);
5074 if(hres != DISP_E_UNKNOWNNAME)
5075 return hres;
5077 if(This->html_document) {
5078 hres = get_elem_by_name_or_id(This->html_document, bstrName, NULL);
5079 if(SUCCEEDED(hres))
5080 hres = dispid_from_elem_name(This, bstrName, pid);
5083 if(hres == DISP_E_UNKNOWNNAME && (grfdex & fdexNameEnsure))
5084 hres = dispex_get_dynid(&This->node.event_target.dispex, bstrName, FALSE, pid);
5085 return hres;
5088 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
5089 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
5091 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5093 if(This->window) {
5094 switch(id) {
5095 case DISPID_READYSTATE:
5096 TRACE("DISPID_READYSTATE\n");
5098 if(!(wFlags & DISPATCH_PROPERTYGET))
5099 return E_INVALIDARG;
5101 V_VT(pvarRes) = VT_I4;
5102 V_I4(pvarRes) = This->window->base.outer_window->readystate;
5103 return S_OK;
5104 default:
5105 break;
5109 return IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
5112 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
5114 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5116 return IDispatchEx_DeleteMemberByName(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex);
5119 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
5121 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5123 return IDispatchEx_DeleteMemberByDispID(&This->node.event_target.dispex.IDispatchEx_iface, id);
5126 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
5128 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5130 return IDispatchEx_GetMemberProperties(&This->node.event_target.dispex.IDispatchEx_iface, id, grfdexFetch, pgrfdex);
5133 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
5135 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5137 return IDispatchEx_GetMemberName(&This->node.event_target.dispex.IDispatchEx_iface, id, pbstrName);
5140 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
5142 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5144 return IDispatchEx_GetNextDispID(&This->node.event_target.dispex.IDispatchEx_iface, grfdex, id, pid);
5147 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
5149 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5151 return IDispatchEx_GetNameSpaceParent(&This->node.event_target.dispex.IDispatchEx_iface, ppunk);
5154 static const IDispatchExVtbl DocDispatchExVtbl = {
5155 DocDispatchEx_QueryInterface,
5156 DocDispatchEx_AddRef,
5157 DocDispatchEx_Release,
5158 DocDispatchEx_GetTypeInfoCount,
5159 DocDispatchEx_GetTypeInfo,
5160 DocDispatchEx_GetIDsOfNames,
5161 DocDispatchEx_Invoke,
5162 DocDispatchEx_GetDispID,
5163 DocDispatchEx_InvokeEx,
5164 DocDispatchEx_DeleteMemberByName,
5165 DocDispatchEx_DeleteMemberByDispID,
5166 DocDispatchEx_GetMemberProperties,
5167 DocDispatchEx_GetMemberName,
5168 DocDispatchEx_GetNextDispID,
5169 DocDispatchEx_GetNameSpaceParent
5172 static inline HTMLDocumentNode *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
5174 return CONTAINING_RECORD(iface, HTMLDocumentNode, IProvideMultipleClassInfo_iface);
5177 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
5178 REFIID riid, void **ppv)
5180 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5181 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5184 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
5186 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5187 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5190 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
5192 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5193 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5196 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
5198 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5199 TRACE("(%p)->(%p)\n", This, ppTI);
5200 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
5203 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
5205 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5206 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
5207 return E_NOTIMPL;
5210 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
5212 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5213 FIXME("(%p)->(%p)\n", This, pcti);
5214 *pcti = 1;
5215 return S_OK;
5218 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
5219 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
5221 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5222 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
5223 return E_NOTIMPL;
5226 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
5227 ProvideClassInfo_QueryInterface,
5228 ProvideClassInfo_AddRef,
5229 ProvideClassInfo_Release,
5230 ProvideClassInfo_GetClassInfo,
5231 ProvideClassInfo2_GetGUID,
5232 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
5233 ProvideMultipleClassInfo_GetInfoOfIndex
5236 /**********************************************************
5237 * IMarkupServices implementation
5239 static inline HTMLDocumentNode *impl_from_IMarkupServices(IMarkupServices *iface)
5241 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupServices_iface);
5244 static HRESULT WINAPI MarkupServices_QueryInterface(IMarkupServices *iface, REFIID riid, void **ppvObject)
5246 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5247 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5250 static ULONG WINAPI MarkupServices_AddRef(IMarkupServices *iface)
5252 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5253 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5256 static ULONG WINAPI MarkupServices_Release(IMarkupServices *iface)
5258 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5259 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5262 static HRESULT WINAPI MarkupServices_CreateMarkupPointer(IMarkupServices *iface, IMarkupPointer **ppPointer)
5264 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5266 TRACE("(%p)->(%p)\n", This, ppPointer);
5268 return create_markup_pointer(ppPointer);
5271 static HRESULT WINAPI MarkupServices_CreateMarkupContainer(IMarkupServices *iface, IMarkupContainer **ppMarkupContainer)
5273 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5274 FIXME("(%p)->(%p)\n", This, ppMarkupContainer);
5275 return E_NOTIMPL;
5278 static HRESULT WINAPI MarkupServices_CreateElement(IMarkupServices *iface,
5279 ELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement)
5281 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5282 FIXME("(%p)->(%d,%s,%p)\n", This, tagID, debugstr_w(pchAttributes), ppElement);
5283 return E_NOTIMPL;
5286 static HRESULT WINAPI MarkupServices_CloneElement(IMarkupServices *iface,
5287 IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone)
5289 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5290 FIXME("(%p)->(%p,%p)\n", This, pElemCloneThis, ppElementTheClone);
5291 return E_NOTIMPL;
5294 static HRESULT WINAPI MarkupServices_InsertElement(IMarkupServices *iface,
5295 IHTMLElement *pElementInsert, IMarkupPointer *pPointerStart,
5296 IMarkupPointer *pPointerFinish)
5298 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5299 FIXME("(%p)->(%p,%p,%p)\n", This, pElementInsert, pPointerStart, pPointerFinish);
5300 return E_NOTIMPL;
5303 static HRESULT WINAPI MarkupServices_RemoveElement(IMarkupServices *iface, IHTMLElement *pElementRemove)
5305 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5306 FIXME("(%p)->(%p)\n", This, pElementRemove);
5307 return E_NOTIMPL;
5310 static HRESULT WINAPI MarkupServices_Remove(IMarkupServices *iface,
5311 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5313 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5314 FIXME("(%p)->(%p,%p)\n", This, pPointerStart, pPointerFinish);
5315 return E_NOTIMPL;
5318 static HRESULT WINAPI MarkupServices_Copy(IMarkupServices *iface,
5319 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5320 IMarkupPointer *pPointerTarget)
5322 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5323 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5324 return E_NOTIMPL;
5327 static HRESULT WINAPI MarkupServices_Move(IMarkupServices *iface,
5328 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5329 IMarkupPointer *pPointerTarget)
5331 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5332 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5333 return E_NOTIMPL;
5336 static HRESULT WINAPI MarkupServices_InsertText(IMarkupServices *iface,
5337 OLECHAR *pchText, LONG cch, IMarkupPointer *pPointerTarget)
5339 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5340 FIXME("(%p)->(%s,%lx,%p)\n", This, debugstr_w(pchText), cch, pPointerTarget);
5341 return E_NOTIMPL;
5344 static HRESULT WINAPI MarkupServices_ParseString(IMarkupServices *iface,
5345 OLECHAR *pchHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5346 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5348 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5349 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(pchHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5350 return E_NOTIMPL;
5353 static HRESULT WINAPI MarkupServices_ParseGlobal(IMarkupServices *iface,
5354 HGLOBAL hglobalHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5355 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5357 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5358 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(hglobalHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5359 return E_NOTIMPL;
5362 static HRESULT WINAPI MarkupServices_IsScopedElement(IMarkupServices *iface,
5363 IHTMLElement *pElement, BOOL *pfScoped)
5365 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5366 FIXME("(%p)->(%p,%p)\n", This, pElement, pfScoped);
5367 return E_NOTIMPL;
5370 static HRESULT WINAPI MarkupServices_GetElementTagId(IMarkupServices *iface,
5371 IHTMLElement *pElement, ELEMENT_TAG_ID *ptagId)
5373 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5374 FIXME("(%p)->(%p,%p)\n", This, pElement, ptagId);
5375 return E_NOTIMPL;
5378 static HRESULT WINAPI MarkupServices_GetTagIDForName(IMarkupServices *iface,
5379 BSTR bstrName, ELEMENT_TAG_ID *ptagId)
5381 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5382 FIXME("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), ptagId);
5383 return E_NOTIMPL;
5386 static HRESULT WINAPI MarkupServices_GetNameForTagID(IMarkupServices *iface,
5387 ELEMENT_TAG_ID tagId, BSTR *pbstrName)
5389 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5390 FIXME("(%p)->(%d,%p)\n", This, tagId, pbstrName);
5391 return E_NOTIMPL;
5394 static HRESULT WINAPI MarkupServices_MovePointersToRange(IMarkupServices *iface,
5395 IHTMLTxtRange *pIRange, IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5397 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5398 FIXME("(%p)->(%p,%p,%p)\n", This, pIRange, pPointerStart, pPointerFinish);
5399 return E_NOTIMPL;
5402 static HRESULT WINAPI MarkupServices_MoveRangeToPointers(IMarkupServices *iface,
5403 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish, IHTMLTxtRange *pIRange)
5405 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5406 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerStart, pPointerFinish, pIRange);
5407 return E_NOTIMPL;
5410 static HRESULT WINAPI MarkupServices_BeginUndoUnit(IMarkupServices *iface, OLECHAR *pchTitle)
5412 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5413 FIXME("(%p)->(%s)\n", This, debugstr_w(pchTitle));
5414 return E_NOTIMPL;
5417 static HRESULT WINAPI MarkupServices_EndUndoUnit(IMarkupServices *iface)
5419 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5420 FIXME("(%p)\n", This);
5421 return E_NOTIMPL;
5424 static const IMarkupServicesVtbl MarkupServicesVtbl = {
5425 MarkupServices_QueryInterface,
5426 MarkupServices_AddRef,
5427 MarkupServices_Release,
5428 MarkupServices_CreateMarkupPointer,
5429 MarkupServices_CreateMarkupContainer,
5430 MarkupServices_CreateElement,
5431 MarkupServices_CloneElement,
5432 MarkupServices_InsertElement,
5433 MarkupServices_RemoveElement,
5434 MarkupServices_Remove,
5435 MarkupServices_Copy,
5436 MarkupServices_Move,
5437 MarkupServices_InsertText,
5438 MarkupServices_ParseString,
5439 MarkupServices_ParseGlobal,
5440 MarkupServices_IsScopedElement,
5441 MarkupServices_GetElementTagId,
5442 MarkupServices_GetTagIDForName,
5443 MarkupServices_GetNameForTagID,
5444 MarkupServices_MovePointersToRange,
5445 MarkupServices_MoveRangeToPointers,
5446 MarkupServices_BeginUndoUnit,
5447 MarkupServices_EndUndoUnit
5450 /**********************************************************
5451 * IMarkupContainer implementation
5453 static inline HTMLDocumentNode *impl_from_IMarkupContainer(IMarkupContainer *iface)
5455 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupContainer_iface);
5458 static HRESULT WINAPI MarkupContainer_QueryInterface(IMarkupContainer *iface, REFIID riid, void **ppvObject)
5460 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5461 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5464 static ULONG WINAPI MarkupContainer_AddRef(IMarkupContainer *iface)
5466 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5467 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5470 static ULONG WINAPI MarkupContainer_Release(IMarkupContainer *iface)
5472 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5473 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5476 static HRESULT WINAPI MarkupContainer_OwningDoc(IMarkupContainer *iface, IHTMLDocument2 **ppDoc)
5478 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5479 FIXME("(%p)->(%p)\n", This, ppDoc);
5480 return E_NOTIMPL;
5483 static const IMarkupContainerVtbl MarkupContainerVtbl = {
5484 MarkupContainer_QueryInterface,
5485 MarkupContainer_AddRef,
5486 MarkupContainer_Release,
5487 MarkupContainer_OwningDoc
5490 /**********************************************************
5491 * IDisplayServices implementation
5493 static inline HTMLDocumentNode *impl_from_IDisplayServices(IDisplayServices *iface)
5495 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDisplayServices_iface);
5498 static HRESULT WINAPI DisplayServices_QueryInterface(IDisplayServices *iface, REFIID riid, void **ppvObject)
5500 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5501 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5504 static ULONG WINAPI DisplayServices_AddRef(IDisplayServices *iface)
5506 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5507 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5510 static ULONG WINAPI DisplayServices_Release(IDisplayServices *iface)
5512 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5513 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5516 static HRESULT WINAPI DisplayServices_CreateDisplayPointer(IDisplayServices *iface, IDisplayPointer **ppDispPointer)
5518 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5519 FIXME("(%p)->(%p)\n", This, ppDispPointer);
5520 return E_NOTIMPL;
5523 static HRESULT WINAPI DisplayServices_TransformRect(IDisplayServices *iface,
5524 RECT *pRect, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5526 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5527 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_rect(pRect), eSource, eDestination, pIElement);
5528 return E_NOTIMPL;
5531 static HRESULT WINAPI DisplayServices_TransformPoint(IDisplayServices *iface,
5532 POINT *pPoint, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5534 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5535 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_point(pPoint), eSource, eDestination, pIElement);
5536 return E_NOTIMPL;
5539 static HRESULT WINAPI DisplayServices_GetCaret(IDisplayServices *iface, IHTMLCaret **ppCaret)
5541 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5542 FIXME("(%p)->(%p)\n", This, ppCaret);
5543 return E_NOTIMPL;
5546 static HRESULT WINAPI DisplayServices_GetComputedStyle(IDisplayServices *iface,
5547 IMarkupPointer *pPointer, IHTMLComputedStyle **ppComputedStyle)
5549 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5550 FIXME("(%p)->(%p,%p)\n", This, pPointer, ppComputedStyle);
5551 return E_NOTIMPL;
5554 static HRESULT WINAPI DisplayServices_ScrollRectIntoView(IDisplayServices *iface,
5555 IHTMLElement *pIElement, RECT rect)
5557 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5558 FIXME("(%p)->(%p,%s)\n", This, pIElement, wine_dbgstr_rect(&rect));
5559 return E_NOTIMPL;
5562 static HRESULT WINAPI DisplayServices_HasFlowLayout(IDisplayServices *iface,
5563 IHTMLElement *pIElement, BOOL *pfHasFlowLayout)
5565 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5566 FIXME("(%p)->(%p,%p)\n", This, pIElement, pfHasFlowLayout);
5567 return E_NOTIMPL;
5570 static const IDisplayServicesVtbl DisplayServicesVtbl = {
5571 DisplayServices_QueryInterface,
5572 DisplayServices_AddRef,
5573 DisplayServices_Release,
5574 DisplayServices_CreateDisplayPointer,
5575 DisplayServices_TransformRect,
5576 DisplayServices_TransformPoint,
5577 DisplayServices_GetCaret,
5578 DisplayServices_GetComputedStyle,
5579 DisplayServices_ScrollRectIntoView,
5580 DisplayServices_HasFlowLayout
5583 /**********************************************************
5584 * IDocumentRange implementation
5586 static inline HTMLDocumentNode *impl_from_IDocumentRange(IDocumentRange *iface)
5588 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentRange_iface);
5591 static HRESULT WINAPI DocumentRange_QueryInterface(IDocumentRange *iface, REFIID riid, void **ppv)
5593 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5595 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5598 static ULONG WINAPI DocumentRange_AddRef(IDocumentRange *iface)
5600 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5602 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5605 static ULONG WINAPI DocumentRange_Release(IDocumentRange *iface)
5607 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5609 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5612 static HRESULT WINAPI DocumentRange_GetTypeInfoCount(IDocumentRange *iface, UINT *pctinfo)
5614 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5616 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
5619 static HRESULT WINAPI DocumentRange_GetTypeInfo(IDocumentRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5621 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5623 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5626 static HRESULT WINAPI DocumentRange_GetIDsOfNames(IDocumentRange *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5627 LCID lcid, DISPID *rgDispId)
5629 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5631 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
5632 rgDispId);
5635 static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
5636 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5638 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5640 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5641 pDispParams, pVarResult, pExcepInfo, puArgErr);
5644 static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
5646 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5647 nsIDOMRange *nsrange;
5648 HRESULT hres;
5650 TRACE("(%p)->(%p)\n", This, p);
5652 if(!This->dom_document) {
5653 WARN("NULL dom_document\n");
5654 return E_UNEXPECTED;
5657 if(NS_FAILED(nsIDOMDocument_CreateRange(This->dom_document, &nsrange)))
5658 return E_FAIL;
5660 hres = create_dom_range(nsrange, dispex_compat_mode(&This->node.event_target.dispex), p);
5661 nsIDOMRange_Release(nsrange);
5662 return hres;
5665 static const IDocumentRangeVtbl DocumentRangeVtbl = {
5666 DocumentRange_QueryInterface,
5667 DocumentRange_AddRef,
5668 DocumentRange_Release,
5669 DocumentRange_GetTypeInfoCount,
5670 DocumentRange_GetTypeInfo,
5671 DocumentRange_GetIDsOfNames,
5672 DocumentRange_Invoke,
5673 DocumentRange_createRange
5676 static cp_static_data_t HTMLDocumentNodeEvents_data = { HTMLDocumentEvents_tid, HTMLDocumentNode_on_advise };
5677 static cp_static_data_t HTMLDocumentNodeEvents2_data = { HTMLDocumentEvents2_tid, HTMLDocumentNode_on_advise, TRUE };
5679 static const cpc_entry_t HTMLDocumentNode_cpc[] = {
5680 {&IID_IDispatch, &HTMLDocumentNodeEvents_data},
5681 {&IID_IPropertyNotifySink},
5682 {&DIID_HTMLDocumentEvents, &HTMLDocumentNodeEvents_data},
5683 {&DIID_HTMLDocumentEvents2, &HTMLDocumentNodeEvents2_data},
5684 {NULL}
5687 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5689 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
5692 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5694 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5696 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5698 if(IsEqualGUID(&IID_IUnknown, riid))
5699 *ppv = &This->IHTMLDocument2_iface;
5700 else if(IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDispatchEx, riid))
5701 *ppv = &This->IDispatchEx_iface;
5702 else if(IsEqualGUID(&IID_IHTMLDocument, riid) || IsEqualGUID(&IID_IHTMLDocument2, riid))
5703 *ppv = &This->IHTMLDocument2_iface;
5704 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
5705 *ppv = &This->IHTMLDocument3_iface;
5706 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
5707 *ppv = &This->IHTMLDocument4_iface;
5708 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
5709 *ppv = &This->IHTMLDocument5_iface;
5710 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
5711 *ppv = &This->IHTMLDocument6_iface;
5712 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
5713 *ppv = &This->IHTMLDocument7_iface;
5714 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
5715 *ppv = &This->IDocumentSelector_iface;
5716 else if(IsEqualGUID(&IID_IDocumentEvent, riid))
5717 *ppv = &This->IDocumentEvent_iface;
5718 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
5719 *ppv = &This->IHTMLDocument2_iface;
5720 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
5721 *ppv = &This->ISupportErrorInfo_iface;
5722 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
5723 *ppv = &This->IProvideMultipleClassInfo_iface;
5724 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
5725 *ppv = &This->IProvideMultipleClassInfo_iface;
5726 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
5727 *ppv = &This->IProvideMultipleClassInfo_iface;
5728 else if(IsEqualGUID(&IID_IMarkupServices, riid))
5729 *ppv = &This->IMarkupServices_iface;
5730 else if(IsEqualGUID(&IID_IMarkupContainer, riid))
5731 *ppv = &This->IMarkupContainer_iface;
5732 else if(IsEqualGUID(&IID_IDisplayServices, riid))
5733 *ppv = &This->IDisplayServices_iface;
5734 else if(IsEqualGUID(&IID_IDocumentRange, riid))
5735 *ppv = &This->IDocumentRange_iface;
5736 else if(IsEqualGUID(&IID_IPersist, riid))
5737 *ppv = &This->IPersistFile_iface;
5738 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
5739 *ppv = &This->IPersistMoniker_iface;
5740 else if(IsEqualGUID(&IID_IPersistFile, riid))
5741 *ppv = &This->IPersistFile_iface;
5742 else if(IsEqualGUID(&IID_IMonikerProp, riid))
5743 *ppv = &This->IMonikerProp_iface;
5744 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
5745 *ppv = &This->IPersistStreamInit_iface;
5746 else if(IsEqualGUID(&IID_IPersistHistory, riid))
5747 *ppv = &This->IPersistHistory_iface;
5748 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
5749 *ppv = &This->IHlinkTarget_iface;
5750 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
5751 *ppv = &This->IOleCommandTarget_iface;
5752 else if(IsEqualGUID(&IID_IOleObject, riid))
5753 *ppv = &This->IOleObject_iface;
5754 else if(IsEqualGUID(&IID_IOleDocument, riid))
5755 *ppv = &This->IOleDocument_iface;
5756 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
5757 *ppv = &This->IOleInPlaceActiveObject_iface;
5758 else if(IsEqualGUID(&IID_IOleWindow, riid))
5759 *ppv = &This->IOleInPlaceActiveObject_iface;
5760 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
5761 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5762 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
5763 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5764 else if(IsEqualGUID(&IID_IOleControl, riid))
5765 *ppv = &This->IOleControl_iface;
5766 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
5767 *ppv = &This->IObjectWithSite_iface;
5768 else if(IsEqualGUID(&IID_IOleContainer, riid))
5769 *ppv = &This->IOleContainer_iface;
5770 else if(IsEqualGUID(&IID_IObjectSafety, riid))
5771 *ppv = &This->IObjectSafety_iface;
5772 else if(IsEqualGUID(&IID_IServiceProvider, riid))
5773 *ppv = &This->IServiceProvider_iface;
5774 else if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
5775 *ppv = &This->IInternetHostSecurityManager_iface;
5776 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
5777 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5778 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
5779 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
5780 *ppv = NULL;
5781 return E_NOINTERFACE;
5782 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
5783 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
5784 *ppv = NULL;
5785 return E_NOINTERFACE;
5786 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
5787 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
5788 *ppv = NULL;
5789 return E_NOINTERFACE;
5790 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
5791 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
5792 *ppv = NULL;
5793 return E_NOINTERFACE;
5794 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
5795 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
5796 *ppv = NULL;
5797 return E_NOINTERFACE;
5798 }else {
5799 return HTMLDOMNode_QI(&This->node, riid, ppv);
5802 IUnknown_AddRef((IUnknown*)*ppv);
5803 return S_OK;
5806 void detach_document_node(HTMLDocumentNode *doc)
5808 unsigned i;
5810 while(!list_empty(&doc->plugin_hosts))
5811 detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
5813 if(doc->dom_implementation) {
5814 detach_dom_implementation(doc->dom_implementation);
5815 IHTMLDOMImplementation_Release(doc->dom_implementation);
5816 doc->dom_implementation = NULL;
5819 if(doc->namespaces) {
5820 IHTMLNamespaceCollection_Release(doc->namespaces);
5821 doc->namespaces = NULL;
5824 detach_events(doc);
5825 detach_selection(doc);
5826 detach_ranges(doc);
5828 for(i=0; i < doc->elem_vars_cnt; i++)
5829 free(doc->elem_vars[i]);
5830 free(doc->elem_vars);
5831 doc->elem_vars_cnt = doc->elem_vars_size = 0;
5832 doc->elem_vars = NULL;
5834 if(doc->catmgr) {
5835 ICatInformation_Release(doc->catmgr);
5836 doc->catmgr = NULL;
5839 if(doc->browser) {
5840 list_remove(&doc->browser_entry);
5841 doc->browser = NULL;
5845 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
5847 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5849 TRACE("(%p)\n", This);
5851 free(This->event_vector);
5852 ConnectionPointContainer_Destroy(&This->cp_container);
5855 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5857 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5858 FIXME("%p\n", This);
5859 return E_NOTIMPL;
5862 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
5864 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5866 if(This->dom_document) {
5867 release_document_mutation(This);
5868 detach_document_node(This);
5869 This->dom_document = NULL;
5870 This->html_document = NULL;
5871 This->window = NULL;
5875 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
5876 &CLSID_HTMLDocument,
5877 HTMLDocumentNode_QI,
5878 HTMLDocumentNode_destructor,
5879 HTMLDocumentNode_cpc,
5880 HTMLDocumentNode_clone,
5881 NULL,
5882 NULL,
5883 NULL,
5884 NULL,
5885 NULL,
5886 NULL,
5887 NULL,
5888 NULL,
5889 NULL,
5890 NULL,
5891 NULL,
5892 NULL,
5893 HTMLDocumentNode_unlink
5896 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5898 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5899 HTMLDocumentNode *new_node;
5900 HRESULT hres;
5902 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
5903 if(FAILED(hres))
5904 return hres;
5906 *ret = &new_node->node;
5907 return S_OK;
5910 static void HTMLDocumentFragment_unlink(HTMLDOMNode *iface)
5912 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5914 if(This->window) {
5915 detach_document_node(This);
5917 /* document fragments own reference to inner window */
5918 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
5919 This->window = NULL;
5923 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
5925 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
5928 static HRESULT HTMLDocumentNode_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
5930 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5931 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
5933 if(!This->dom_document || idx >= This->elem_vars_cnt)
5934 return DISP_E_MEMBERNOTFOUND;
5936 return (*name = SysAllocString(This->elem_vars[idx])) ? S_OK : E_OUTOFMEMORY;
5939 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5940 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5942 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5943 nsIDOMElement *nselem;
5944 HTMLDOMNode *node;
5945 unsigned i;
5946 HRESULT hres;
5948 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET))
5949 return MSHTML_E_INVALID_PROPERTY;
5951 i = id - MSHTML_DISPID_CUSTOM_MIN;
5953 if(!This->html_document || i >= This->elem_vars_cnt)
5954 return DISP_E_MEMBERNOTFOUND;
5956 hres = get_elem_by_name_or_id(This->html_document, This->elem_vars[i], &nselem);
5957 if(FAILED(hres))
5958 return hres;
5959 if(!nselem)
5960 return DISP_E_MEMBERNOTFOUND;
5962 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
5963 nsIDOMElement_Release(nselem);
5964 if(FAILED(hres))
5965 return hres;
5967 V_VT(res) = VT_DISPATCH;
5968 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5969 return S_OK;
5972 static HRESULT HTMLDocumentNode_next_dispid(DispatchEx *dispex, DISPID id, DISPID *pid)
5974 DWORD idx = (id == DISPID_STARTENUM) ? 0 : id - MSHTML_DISPID_CUSTOM_MIN + 1;
5975 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5976 nsIDOMNodeList *node_list;
5977 const PRUnichar *name;
5978 nsIDOMElement *nselem;
5979 nsIDOMNode *nsnode;
5980 nsAString nsstr;
5981 nsresult nsres;
5982 HRESULT hres;
5983 UINT32 i;
5985 if(!This->html_document)
5986 return S_FALSE;
5988 while(idx < This->elem_vars_cnt) {
5989 hres = has_elem_name(This->html_document, This->elem_vars[idx]);
5990 if(SUCCEEDED(hres)) {
5991 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
5992 return S_OK;
5994 if(hres != DISP_E_UNKNOWNNAME)
5995 return hres;
5996 idx++;
5999 /* Populate possibly missing DISPIDs */
6000 nsAString_InitDepend(&nsstr, L":-moz-any(applet,embed,form,iframe,img,object)[name]");
6001 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->html_document, &nsstr, &node_list);
6002 nsAString_Finish(&nsstr);
6003 if(NS_FAILED(nsres))
6004 return map_nsresult(nsres);
6006 for(i = 0, hres = S_OK; SUCCEEDED(hres); i++) {
6007 nsres = nsIDOMNodeList_Item(node_list, i, &nsnode);
6008 if(NS_FAILED(nsres)) {
6009 hres = map_nsresult(nsres);
6010 break;
6012 if(!nsnode)
6013 break;
6015 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
6016 nsIDOMNode_Release(nsnode);
6017 if(nsres != S_OK)
6018 continue;
6020 nsres = get_elem_attr_value(nselem, L"name", &nsstr, &name);
6021 nsIDOMElement_Release(nselem);
6022 if(NS_FAILED(nsres))
6023 hres = map_nsresult(nsres);
6024 else {
6025 hres = dispid_from_elem_name(This, name, &id);
6026 nsAString_Finish(&nsstr);
6029 nsIDOMNodeList_Release(node_list);
6030 if(FAILED(hres))
6031 return hres;
6033 if(idx >= This->elem_vars_cnt)
6034 return S_FALSE;
6036 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
6037 return S_OK;
6040 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
6042 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6044 TRACE("(%p) returning %u\n", This, This->document_mode);
6046 return lock_document_mode(This);
6049 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
6051 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6052 return (nsISupports*)This->node.nsnode;
6055 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
6057 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6058 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
6061 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
6063 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6064 if(!This->window)
6065 return NULL;
6066 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
6067 return &This->window->event_target;
6070 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
6072 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6073 ConnectionPointContainer *container = This->doc_obj
6074 ? &This->doc_obj->cp_container : &This->cp_container;
6075 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
6076 return container;
6079 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6081 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6082 return default_set_current_event(This->window, event);
6085 static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp, VARIANT *res,
6086 EXCEPINFO *ei, IServiceProvider *caller)
6088 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6090 if(!(flags & DISPATCH_PROPERTYPUT) || !This->outer_window)
6091 return S_FALSE;
6093 return IDispatchEx_InvokeEx(&This->outer_window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
6094 0, flags, dp, res, ei, caller);
6097 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
6099 NULL,
6100 NULL,
6101 HTMLDocumentNode_get_name,
6102 HTMLDocumentNode_invoke,
6103 NULL,
6104 HTMLDocumentNode_next_dispid,
6105 HTMLDocumentNode_get_compat_mode,
6106 NULL
6108 HTMLDocumentNode_get_gecko_target,
6109 HTMLDocumentNode_bind_event,
6110 HTMLDocumentNode_get_parent_event_target,
6111 NULL,
6112 HTMLDocumentNode_get_cp_container,
6113 HTMLDocumentNode_set_current_event
6116 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
6117 &CLSID_HTMLDocument,
6118 HTMLDocumentNode_QI,
6119 HTMLDocumentNode_destructor,
6120 HTMLDocumentNode_cpc,
6121 HTMLDocumentFragment_clone,
6122 NULL,
6123 NULL,
6124 NULL,
6125 NULL,
6126 NULL,
6127 NULL,
6128 NULL,
6129 NULL,
6130 NULL,
6131 NULL,
6132 NULL,
6133 NULL,
6134 HTMLDocumentFragment_unlink
6137 static const tid_t HTMLDocumentNode_iface_tids[] = {
6138 IHTMLDOMNode_tid,
6139 IHTMLDOMNode2_tid,
6140 IHTMLDocument4_tid,
6141 IHTMLDocument5_tid,
6142 IDocumentSelector_tid,
6146 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6148 static const dispex_hook_t document2_hooks[] = {
6149 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6150 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6151 {DISPID_UNKNOWN}
6153 static const dispex_hook_t document2_ie11_hooks[] = {
6154 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6155 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6156 {DISPID_IHTMLDOCUMENT2_CREATESTYLESHEET, NULL},
6157 {DISPID_IHTMLDOCUMENT2_FILESIZE, NULL},
6158 {DISPID_IHTMLDOCUMENT2_SELECTION, NULL},
6159 {DISPID_UNKNOWN}
6161 static const dispex_hook_t document3_ie11_hooks[] = {
6162 {DISPID_IHTMLDOCUMENT3_ATTACHEVENT, NULL},
6163 {DISPID_IHTMLDOCUMENT3_DETACHEVENT, NULL},
6164 {DISPID_UNKNOWN}
6166 static const dispex_hook_t document6_ie9_hooks[] = {
6167 {DISPID_IHTMLDOCUMENT6_ONSTORAGE},
6168 {DISPID_UNKNOWN}
6171 HTMLDOMNode_init_dispex_info(info, mode);
6173 if(mode >= COMPAT_MODE_IE9) {
6174 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
6175 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
6178 /* Depending on compatibility version, we add interfaces in different order
6179 * so that the right getElementById implementation is used. */
6180 if(mode < COMPAT_MODE_IE8) {
6181 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
6182 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
6183 }else {
6184 dispex_info_add_interface(info, IHTMLDocument6_tid, mode >= COMPAT_MODE_IE9 ? document6_ie9_hooks : NULL);
6185 dispex_info_add_interface(info, IHTMLDocument3_tid, mode >= COMPAT_MODE_IE11 ? document3_ie11_hooks : NULL);
6187 dispex_info_add_interface(info, IHTMLDocument2_tid, mode >= COMPAT_MODE_IE11 ? document2_ie11_hooks : document2_hooks);
6190 static dispex_static_data_t HTMLDocumentNode_dispex = {
6191 L"HTMLDocument",
6192 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
6193 DispHTMLDocument_tid,
6194 HTMLDocumentNode_iface_tids,
6195 HTMLDocumentNode_init_dispex_info
6198 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
6200 HTMLDocumentNode *doc;
6202 doc = calloc(1, sizeof(HTMLDocumentNode));
6203 if(!doc)
6204 return NULL;
6206 doc->ref = 1;
6207 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
6208 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
6209 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
6210 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
6211 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
6212 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
6213 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
6214 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
6215 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
6216 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
6217 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
6218 doc->IMarkupServices_iface.lpVtbl = &MarkupServicesVtbl;
6219 doc->IMarkupContainer_iface.lpVtbl = &MarkupContainerVtbl;
6220 doc->IDisplayServices_iface.lpVtbl = &DisplayServicesVtbl;
6221 doc->IDocumentRange_iface.lpVtbl = &DocumentRangeVtbl;
6223 doc->doc_obj = doc_obj;
6224 doc->outer_window = window ? window->base.outer_window : NULL;
6225 doc->window = window;
6227 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocumentNode_cpc);
6228 HTMLDocumentNode_Persist_Init(doc);
6229 HTMLDocumentNode_Service_Init(doc);
6230 HTMLDocumentNode_OleCmd_Init(doc);
6231 HTMLDocumentNode_OleObj_Init(doc);
6232 HTMLDocumentNode_SecMgr_Init(doc);
6234 list_init(&doc->selection_list);
6235 list_init(&doc->range_list);
6236 list_init(&doc->plugin_hosts);
6238 return doc;
6241 HRESULT create_document_node(nsIDOMDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
6242 compat_mode_t parent_mode, HTMLDocumentNode **ret)
6244 HTMLDocumentObj *doc_obj = browser->doc;
6245 HTMLDocumentNode *doc;
6247 doc = alloc_doc_node(doc_obj, window);
6248 if(!doc)
6249 return E_OUTOFMEMORY;
6251 if(parent_mode >= COMPAT_MODE_IE9) {
6252 TRACE("using parent mode %u\n", parent_mode);
6253 doc->document_mode = parent_mode;
6254 lock_document_mode(doc);
6257 if(!doc_obj->window || (window && is_main_content_window(window->base.outer_window)))
6258 doc->cp_container.forward_container = &doc_obj->cp_container;
6260 /* Share reference with HTMLDOMNode */
6261 if(NS_SUCCEEDED(nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&doc->html_document))) {
6262 doc->dom_document = (nsIDOMDocument*)doc->html_document;
6263 nsIDOMHTMLDocument_Release(doc->html_document);
6264 }else {
6265 doc->dom_document = nsdoc;
6266 doc->html_document = NULL;
6269 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)doc->dom_document, &HTMLDocumentNode_dispex);
6271 init_document_mutation(doc);
6272 doc_init_events(doc);
6274 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
6276 list_add_head(&browser->document_nodes, &doc->browser_entry);
6277 doc->browser = browser;
6279 if(browser->usermode == EDITMODE && doc->html_document) {
6280 nsAString mode_str;
6281 nsresult nsres;
6283 nsAString_InitDepend(&mode_str, L"on");
6284 nsres = nsIDOMHTMLDocument_SetDesignMode(doc->html_document, &mode_str);
6285 nsAString_Finish(&mode_str);
6286 if(NS_FAILED(nsres))
6287 ERR("SetDesignMode failed: %08lx\n", nsres);
6290 *ret = doc;
6291 return S_OK;
6294 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
6296 HTMLDocumentNode *doc_frag;
6298 doc_frag = alloc_doc_node(doc_node->doc_obj, doc_node->window);
6299 if(!doc_frag)
6300 return E_OUTOFMEMORY;
6302 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
6304 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
6305 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
6306 doc_frag->document_mode = lock_document_mode(doc_node);
6308 *ret = doc_frag;
6309 return S_OK;
6312 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
6314 HTMLDOMNode *node;
6315 HRESULT hres;
6317 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
6318 if(FAILED(hres))
6319 return hres;
6321 if(!node) {
6322 ERR("document not initialized\n");
6323 return E_FAIL;
6326 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
6327 *ret = impl_from_HTMLDOMNode(node);
6328 return S_OK;