mshtml: Don't create dynamic prop before checking if elem prop even exists.
[wine.git] / dlls / mshtml / htmldoc.c
blob2a99316d1292c482a7f0664b19ee2f018a603220
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 nsIDOMElement *nselem;
48 nsIDOMNode *nsnode;
49 nsAString id_str;
50 nsresult nsres;
51 HRESULT hres;
53 if(!doc->nsdoc) {
54 WARN("NULL nsdoc\n");
55 return E_UNEXPECTED;
58 nsAString_InitDepend(&id_str, id);
59 /* get element by id attribute */
60 nsres = nsIDOMHTMLDocument_GetElementById(doc->nsdoc, &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 nsres = nsIDOMHTMLDocument_GetElementsByName(doc->nsdoc, &id_str, &nsnode_list);
69 nsAString_Finish(&id_str);
70 if(FAILED(nsres)) {
71 ERR("getElementsByName failed: %08lx\n", nsres);
72 if(nselem)
73 nsIDOMElement_Release(nselem);
74 return E_FAIL;
77 nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode);
78 nsIDOMNodeList_Release(nsnode_list);
79 assert(nsres == NS_OK);
81 if(nsnode && nselem) {
82 UINT16 pos;
84 nsres = nsIDOMNode_CompareDocumentPosition(nsnode, (nsIDOMNode*)nselem, &pos);
85 if(NS_FAILED(nsres)) {
86 FIXME("CompareDocumentPosition failed: 0x%08lx\n", nsres);
87 nsIDOMNode_Release(nsnode);
88 nsIDOMElement_Release(nselem);
89 return E_FAIL;
92 TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
93 if(!(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS))) {
94 nsIDOMElement_Release(nselem);
95 nselem = NULL;
99 if(nsnode) {
100 if(!nselem) {
101 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
102 assert(nsres == NS_OK);
104 nsIDOMNode_Release(nsnode);
107 if(!nselem) {
108 *ret = NULL;
109 return S_OK;
112 hres = get_element(nselem, ret);
113 nsIDOMElement_Release(nselem);
114 return hres;
117 UINT get_document_charset(HTMLDocumentNode *doc)
119 nsAString charset_str;
120 UINT ret = 0;
121 nsresult nsres;
123 if(doc->charset)
124 return doc->charset;
126 nsAString_Init(&charset_str, NULL);
127 nsres = nsIDOMHTMLDocument_GetCharacterSet(doc->nsdoc, &charset_str);
128 if(NS_SUCCEEDED(nsres)) {
129 const PRUnichar *charset;
131 nsAString_GetData(&charset_str, &charset);
133 if(*charset) {
134 BSTR str = SysAllocString(charset);
135 ret = cp_from_charset_string(str);
136 SysFreeString(str);
138 }else {
139 ERR("GetCharset failed: %08lx\n", nsres);
141 nsAString_Finish(&charset_str);
143 if(!ret)
144 return CP_UTF8;
146 return doc->charset = ret;
149 typedef struct {
150 HTMLDOMNode node;
151 IDOMDocumentType IDOMDocumentType_iface;
152 } DocumentType;
154 static inline DocumentType *impl_from_IDOMDocumentType(IDOMDocumentType *iface)
156 return CONTAINING_RECORD(iface, DocumentType, IDOMDocumentType_iface);
159 static HRESULT WINAPI DocumentType_QueryInterface(IDOMDocumentType *iface, REFIID riid, void **ppv)
161 DocumentType *This = impl_from_IDOMDocumentType(iface);
163 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
166 static ULONG WINAPI DocumentType_AddRef(IDOMDocumentType *iface)
168 DocumentType *This = impl_from_IDOMDocumentType(iface);
170 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
173 static ULONG WINAPI DocumentType_Release(IDOMDocumentType *iface)
175 DocumentType *This = impl_from_IDOMDocumentType(iface);
177 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
180 static HRESULT WINAPI DocumentType_GetTypeInfoCount(IDOMDocumentType *iface, UINT *pctinfo)
182 DocumentType *This = impl_from_IDOMDocumentType(iface);
184 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
187 static HRESULT WINAPI DocumentType_GetTypeInfo(IDOMDocumentType *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
189 DocumentType *This = impl_from_IDOMDocumentType(iface);
191 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
194 static HRESULT WINAPI DocumentType_GetIDsOfNames(IDOMDocumentType *iface, REFIID riid, LPOLESTR *rgszNames,
195 UINT cNames, LCID lcid, DISPID *rgDispId)
197 DocumentType *This = impl_from_IDOMDocumentType(iface);
199 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
200 cNames, lcid, rgDispId);
203 static HRESULT WINAPI DocumentType_Invoke(IDOMDocumentType *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
204 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
206 DocumentType *This = impl_from_IDOMDocumentType(iface);
208 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
209 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
212 static HRESULT WINAPI DocumentType_get_name(IDOMDocumentType *iface, BSTR *p)
214 DocumentType *This = impl_from_IDOMDocumentType(iface);
215 nsAString nsstr;
216 nsresult nsres;
218 TRACE("(%p)->(%p)\n", This, p);
220 nsAString_Init(&nsstr, NULL);
221 nsres = nsIDOMDocumentType_GetName((nsIDOMDocumentType*)This->node.nsnode, &nsstr);
222 return return_nsstr(nsres, &nsstr, p);
225 static HRESULT WINAPI DocumentType_get_entities(IDOMDocumentType *iface, IDispatch **p)
227 DocumentType *This = impl_from_IDOMDocumentType(iface);
229 FIXME("(%p)->(%p)\n", This, p);
231 return E_NOTIMPL;
234 static HRESULT WINAPI DocumentType_get_notations(IDOMDocumentType *iface, IDispatch **p)
236 DocumentType *This = impl_from_IDOMDocumentType(iface);
238 FIXME("(%p)->(%p)\n", This, p);
240 return E_NOTIMPL;
243 static HRESULT WINAPI DocumentType_get_publicId(IDOMDocumentType *iface, VARIANT *p)
245 DocumentType *This = impl_from_IDOMDocumentType(iface);
247 FIXME("(%p)->(%p)\n", This, p);
249 return E_NOTIMPL;
252 static HRESULT WINAPI DocumentType_get_systemId(IDOMDocumentType *iface, VARIANT *p)
254 DocumentType *This = impl_from_IDOMDocumentType(iface);
256 FIXME("(%p)->(%p)\n", This, p);
258 return E_NOTIMPL;
261 static HRESULT WINAPI DocumentType_get_internalSubset(IDOMDocumentType *iface, VARIANT *p)
263 DocumentType *This = impl_from_IDOMDocumentType(iface);
265 FIXME("(%p)->(%p)\n", This, p);
267 return E_NOTIMPL;
270 static const IDOMDocumentTypeVtbl DocumentTypeVtbl = {
271 DocumentType_QueryInterface,
272 DocumentType_AddRef,
273 DocumentType_Release,
274 DocumentType_GetTypeInfoCount,
275 DocumentType_GetTypeInfo,
276 DocumentType_GetIDsOfNames,
277 DocumentType_Invoke,
278 DocumentType_get_name,
279 DocumentType_get_entities,
280 DocumentType_get_notations,
281 DocumentType_get_publicId,
282 DocumentType_get_systemId,
283 DocumentType_get_internalSubset
286 static inline DocumentType *DocumentType_from_HTMLDOMNode(HTMLDOMNode *iface)
288 return CONTAINING_RECORD(iface, DocumentType, node);
291 static inline DocumentType *DocumentType_from_DispatchEx(DispatchEx *iface)
293 return CONTAINING_RECORD(iface, DocumentType, node.event_target.dispex);
296 static HRESULT DocumentType_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
298 DocumentType *This = DocumentType_from_HTMLDOMNode(iface);
300 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDOMDocumentType, riid))
301 *ppv = &This->IDOMDocumentType_iface;
302 else
303 return HTMLDOMNode_QI(&This->node, riid, ppv);
305 IUnknown_AddRef((IUnknown*)*ppv);
306 return S_OK;
309 static void DocumentType_destructor(HTMLDOMNode *iface)
311 DocumentType *This = DocumentType_from_HTMLDOMNode(iface);
313 HTMLDOMNode_destructor(&This->node);
316 static HRESULT DocumentType_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
318 DocumentType *This = DocumentType_from_HTMLDOMNode(iface);
320 return create_doctype_node(This->node.doc, nsnode, ret);
323 static const cpc_entry_t DocumentType_cpc[] = {{NULL}};
325 static const NodeImplVtbl DocumentTypeImplVtbl = {
326 NULL,
327 DocumentType_QI,
328 DocumentType_destructor,
329 DocumentType_cpc,
330 DocumentType_clone
333 static nsISupports *DocumentType_get_gecko_target(DispatchEx *dispex)
335 DocumentType *This = DocumentType_from_DispatchEx(dispex);
336 return (nsISupports*)This->node.nsnode;
339 static EventTarget *DocumentType_get_parent_event_target(DispatchEx *dispex)
341 DocumentType *This = DocumentType_from_DispatchEx(dispex);
342 nsIDOMNode *nsnode;
343 HTMLDOMNode *node;
344 nsresult nsres;
345 HRESULT hres;
347 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
348 assert(nsres == NS_OK);
349 if(!nsnode)
350 return NULL;
352 hres = get_node(nsnode, TRUE, &node);
353 nsIDOMNode_Release(nsnode);
354 if(FAILED(hres))
355 return NULL;
357 return &node->event_target;
360 static IHTMLEventObj *DocumentType_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
362 DocumentType *This = DocumentType_from_DispatchEx(dispex);
363 return default_set_current_event(This->node.doc->window, event);
366 static event_target_vtbl_t DocumentType_event_target_vtbl = {
368 NULL,
370 DocumentType_get_gecko_target,
371 NULL,
372 DocumentType_get_parent_event_target,
373 NULL,
374 NULL,
375 DocumentType_set_current_event
378 static const tid_t DocumentType_iface_tids[] = {
379 IDOMDocumentType_tid,
380 IHTMLDOMNode_tid,
381 IHTMLDOMNode2_tid,
382 IHTMLDOMNode3_tid,
386 static dispex_static_data_t DocumentType_dispex = {
387 L"DocumentType",
388 &DocumentType_event_target_vtbl.dispex_vtbl,
389 DispDOMDocumentType_tid,
390 DocumentType_iface_tids
393 HRESULT create_doctype_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **ret)
395 nsIDOMDocumentType *nsdoctype;
396 DocumentType *doctype;
397 nsresult nsres;
399 if(!(doctype = heap_alloc_zero(sizeof(*doctype))))
400 return E_OUTOFMEMORY;
402 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMDocumentType, (void**)&nsdoctype);
403 assert(nsres == NS_OK);
405 doctype->node.vtbl = &DocumentTypeImplVtbl;
406 doctype->IDOMDocumentType_iface.lpVtbl = &DocumentTypeVtbl;
407 HTMLDOMNode_Init(doc, &doctype->node, (nsIDOMNode*)nsdoctype, &DocumentType_dispex);
408 nsIDOMDocumentType_Release(nsdoctype);
410 *ret = &doctype->node;
411 return S_OK;
414 static inline HTMLDocument *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
416 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument2_iface);
419 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
421 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
423 return htmldoc_query_interface(This, riid, ppv);
426 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
428 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
430 return htmldoc_addref(This);
433 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
435 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
437 return htmldoc_release(This);
440 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
442 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
444 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
447 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
448 LCID lcid, ITypeInfo **ppTInfo)
450 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
452 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
455 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
456 LPOLESTR *rgszNames, UINT cNames,
457 LCID lcid, DISPID *rgDispId)
459 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
461 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
462 rgDispId);
465 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
466 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
467 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
469 HTMLDocument *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 HTMLDocument *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 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
489 nsIDOMElement *nselem = NULL;
490 HTMLDOMNode *node;
491 nsresult nsres;
492 HRESULT hres;
494 TRACE("(%p)->(%p)\n", This, p);
496 if(!This->doc_node->nsdoc) {
497 WARN("NULL nsdoc\n");
498 return E_UNEXPECTED;
501 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
502 if(NS_FAILED(nsres)) {
503 ERR("GetDocumentElement failed: %08lx\n", nsres);
504 return E_FAIL;
507 if(!nselem) {
508 *p = NULL;
509 return S_OK;
512 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
513 nsIDOMElement_Release(nselem);
514 if(FAILED(hres))
515 return hres;
517 *p = create_all_collection(node, TRUE);
518 node_release(node);
519 return hres;
522 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
524 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
525 nsIDOMHTMLElement *nsbody = NULL;
526 HTMLElement *element;
527 HRESULT hres;
529 TRACE("(%p)->(%p)\n", This, p);
531 if(This->doc_node->nsdoc) {
532 nsresult nsres;
534 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
535 if(NS_FAILED(nsres)) {
536 TRACE("Could not get body: %08lx\n", nsres);
537 return E_UNEXPECTED;
541 if(!nsbody) {
542 *p = NULL;
543 return S_OK;
546 hres = get_element((nsIDOMElement*)nsbody, &element);
547 nsIDOMHTMLElement_Release(nsbody);
548 if(FAILED(hres))
549 return hres;
551 *p = &element->IHTMLElement_iface;
552 return S_OK;
555 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
557 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
558 nsIDOMElement *nselem;
559 HTMLElement *elem;
560 nsresult nsres;
561 HRESULT hres;
563 TRACE("(%p)->(%p)\n", This, p);
565 if(!This->doc_node->nsdoc) {
566 *p = NULL;
567 return S_OK;
571 * NOTE: Gecko may return an active element even if the document is not visible.
572 * IE returns NULL in this case.
574 nsres = nsIDOMHTMLDocument_GetActiveElement(This->doc_node->nsdoc, &nselem);
575 if(NS_FAILED(nsres)) {
576 ERR("GetActiveElement failed: %08lx\n", nsres);
577 return E_FAIL;
580 if(!nselem) {
581 *p = NULL;
582 return S_OK;
585 hres = get_element(nselem, &elem);
586 nsIDOMElement_Release(nselem);
587 if(FAILED(hres))
588 return hres;
590 *p = &elem->IHTMLElement_iface;
591 return S_OK;
594 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
596 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
597 nsIDOMHTMLCollection *nscoll = NULL;
598 nsresult nsres;
600 TRACE("(%p)->(%p)\n", This, p);
602 if(!p)
603 return E_INVALIDARG;
605 *p = NULL;
607 if(!This->doc_node->nsdoc) {
608 WARN("NULL nsdoc\n");
609 return E_UNEXPECTED;
612 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
613 if(NS_FAILED(nsres)) {
614 ERR("GetImages failed: %08lx\n", nsres);
615 return E_FAIL;
618 if(nscoll) {
619 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
620 nsIDOMHTMLCollection_Release(nscoll);
623 return S_OK;
626 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
628 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
629 nsIDOMHTMLCollection *nscoll = NULL;
630 nsresult nsres;
632 TRACE("(%p)->(%p)\n", This, p);
634 if(!p)
635 return E_INVALIDARG;
637 *p = NULL;
639 if(!This->doc_node->nsdoc) {
640 WARN("NULL nsdoc\n");
641 return E_UNEXPECTED;
644 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
645 if(NS_FAILED(nsres)) {
646 ERR("GetApplets failed: %08lx\n", nsres);
647 return E_FAIL;
650 if(nscoll) {
651 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
652 nsIDOMHTMLCollection_Release(nscoll);
655 return S_OK;
658 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
660 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
661 nsIDOMHTMLCollection *nscoll = NULL;
662 nsresult nsres;
664 TRACE("(%p)->(%p)\n", This, p);
666 if(!p)
667 return E_INVALIDARG;
669 *p = NULL;
671 if(!This->doc_node->nsdoc) {
672 WARN("NULL nsdoc\n");
673 return E_UNEXPECTED;
676 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
677 if(NS_FAILED(nsres)) {
678 ERR("GetLinks failed: %08lx\n", nsres);
679 return E_FAIL;
682 if(nscoll) {
683 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
684 nsIDOMHTMLCollection_Release(nscoll);
687 return S_OK;
690 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
692 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
693 nsIDOMHTMLCollection *nscoll = NULL;
694 nsresult nsres;
696 TRACE("(%p)->(%p)\n", This, p);
698 if(!p)
699 return E_INVALIDARG;
701 *p = NULL;
703 if(!This->doc_node->nsdoc) {
704 WARN("NULL nsdoc\n");
705 return E_UNEXPECTED;
708 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
709 if(NS_FAILED(nsres)) {
710 ERR("GetForms failed: %08lx\n", nsres);
711 return E_FAIL;
714 if(nscoll) {
715 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
716 nsIDOMHTMLCollection_Release(nscoll);
719 return S_OK;
722 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
724 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
725 nsIDOMHTMLCollection *nscoll = NULL;
726 nsresult nsres;
728 TRACE("(%p)->(%p)\n", This, p);
730 if(!p)
731 return E_INVALIDARG;
733 *p = NULL;
735 if(!This->doc_node->nsdoc) {
736 WARN("NULL nsdoc\n");
737 return E_UNEXPECTED;
740 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
741 if(NS_FAILED(nsres)) {
742 ERR("GetAnchors failed: %08lx\n", nsres);
743 return E_FAIL;
746 if(nscoll) {
747 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
748 nsIDOMHTMLCollection_Release(nscoll);
751 return S_OK;
754 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
756 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
757 nsAString nsstr;
758 nsresult nsres;
760 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
762 if(!This->doc_node->nsdoc) {
763 WARN("NULL nsdoc\n");
764 return E_UNEXPECTED;
767 nsAString_InitDepend(&nsstr, v);
768 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
769 nsAString_Finish(&nsstr);
770 if(NS_FAILED(nsres))
771 ERR("SetTitle failed: %08lx\n", nsres);
773 return S_OK;
776 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
778 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
779 const PRUnichar *ret;
780 nsAString nsstr;
781 nsresult nsres;
783 TRACE("(%p)->(%p)\n", This, p);
785 if(!This->doc_node->nsdoc) {
786 WARN("NULL nsdoc\n");
787 return E_UNEXPECTED;
791 nsAString_Init(&nsstr, NULL);
792 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
793 if (NS_SUCCEEDED(nsres)) {
794 nsAString_GetData(&nsstr, &ret);
795 *p = SysAllocString(ret);
797 nsAString_Finish(&nsstr);
799 if(NS_FAILED(nsres)) {
800 ERR("GetTitle failed: %08lx\n", nsres);
801 return E_FAIL;
804 return S_OK;
807 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
809 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
810 nsIDOMHTMLCollection *nscoll = NULL;
811 nsresult nsres;
813 TRACE("(%p)->(%p)\n", This, p);
815 if(!p)
816 return E_INVALIDARG;
818 *p = NULL;
820 if(!This->doc_node->nsdoc) {
821 WARN("NULL nsdoc\n");
822 return E_UNEXPECTED;
825 nsres = nsIDOMHTMLDocument_GetScripts(This->doc_node->nsdoc, &nscoll);
826 if(NS_FAILED(nsres)) {
827 ERR("GetImages failed: %08lx\n", nsres);
828 return E_FAIL;
831 if(nscoll) {
832 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
833 nsIDOMHTMLCollection_Release(nscoll);
836 return S_OK;
839 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
841 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
842 HRESULT hres;
844 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
846 if(wcsicmp(v, L"on")) {
847 FIXME("Unsupported arg %s\n", debugstr_w(v));
848 return E_NOTIMPL;
851 hres = setup_edit_mode(This->doc_obj);
852 if(FAILED(hres))
853 return hres;
855 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
856 return S_OK;
859 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
861 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
862 FIXME("(%p)->(%p) always returning Off\n", This, p);
864 if(!p)
865 return E_INVALIDARG;
867 *p = SysAllocString(L"Off");
869 return S_OK;
872 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
874 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
875 nsISelection *nsselection;
876 nsresult nsres;
878 TRACE("(%p)->(%p)\n", This, p);
880 nsres = nsIDOMHTMLDocument_GetSelection(This->doc_node->nsdoc, &nsselection);
881 if(NS_FAILED(nsres)) {
882 ERR("GetSelection failed: %08lx\n", nsres);
883 return E_FAIL;
886 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
889 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
891 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
894 TRACE("(%p)->(%p)\n", iface, p);
896 if(!p)
897 return E_POINTER;
899 return get_readystate_string(This->window ? This->window->readystate : 0, p);
902 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
904 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
906 TRACE("(%p)->(%p)\n", This, p);
908 if(!This->window) {
909 /* Not implemented by IE */
910 return E_NOTIMPL;
912 return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p);
915 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
917 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
918 FIXME("(%p)->(%p)\n", This, p);
919 return E_NOTIMPL;
922 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
924 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
925 FIXME("(%p)->(%p)\n", This, p);
926 return E_NOTIMPL;
929 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
931 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
932 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
933 return E_NOTIMPL;
936 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
938 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
939 FIXME("(%p)->(%p)\n", This, p);
940 return E_NOTIMPL;
943 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
945 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
946 IHTMLElement *element = NULL;
947 IHTMLBodyElement *body;
948 HRESULT hr;
950 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
952 hr = IHTMLDocument2_get_body(iface, &element);
953 if (FAILED(hr))
955 ERR("Failed to get body (0x%08lx)\n", hr);
956 return hr;
959 if(!element)
961 FIXME("Empty body element.\n");
962 return hr;
965 hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body);
966 if (SUCCEEDED(hr))
968 hr = IHTMLBodyElement_put_bgColor(body, v);
969 IHTMLBodyElement_Release(body);
971 IHTMLElement_Release(element);
973 return hr;
976 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
978 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
979 nsAString nsstr;
980 nsresult nsres;
981 HRESULT hres;
983 TRACE("(%p)->(%p)\n", This, p);
985 if(!This->doc_node->nsdoc) {
986 WARN("NULL nsdoc\n");
987 return E_UNEXPECTED;
990 nsAString_Init(&nsstr, NULL);
991 nsres = nsIDOMHTMLDocument_GetBgColor(This->doc_node->nsdoc, &nsstr);
992 hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p);
993 if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) {
994 TRACE("default #ffffff\n");
995 if(!(V_BSTR(p) = SysAllocString(L"#ffffff")))
996 hres = E_OUTOFMEMORY;
998 return hres;
1001 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
1003 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1004 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1005 return E_NOTIMPL;
1008 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
1010 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1011 FIXME("(%p)->(%p)\n", This, p);
1012 return E_NOTIMPL;
1015 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
1017 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1018 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1019 return E_NOTIMPL;
1022 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
1024 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1025 FIXME("(%p)->(%p)\n", This, p);
1026 return E_NOTIMPL;
1029 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
1031 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1032 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1033 return E_NOTIMPL;
1036 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
1038 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1039 FIXME("(%p)->(%p)\n", This, p);
1040 return E_NOTIMPL;
1043 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
1045 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1047 FIXME("(%p)->(%p)\n", This, p);
1049 *p = NULL;
1050 return S_OK;
1053 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
1055 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface)->doc_node;
1057 TRACE("(%p)->(%p)\n", This, p);
1059 if(!This->nsdoc || !This->window) {
1060 WARN("NULL window\n");
1061 return E_UNEXPECTED;
1064 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
1067 static HRESULT IHTMLDocument2_location_hook(HTMLDocument *doc, WORD flags, DISPPARAMS *dp, VARIANT *res,
1068 EXCEPINFO *ei, IServiceProvider *caller)
1070 if(!(flags & DISPATCH_PROPERTYPUT) || !doc->window)
1071 return S_FALSE;
1073 return IDispatchEx_InvokeEx(&doc->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
1074 0, flags, dp, res, ei, caller);
1077 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
1079 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1080 FIXME("(%p)->(%p)\n", This, p);
1081 return E_NOTIMPL;
1084 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
1086 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1088 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1090 if(!This->window) {
1091 FIXME("No window available\n");
1092 return E_FAIL;
1095 return navigate_url(This->window, v, This->window->uri, BINDING_NAVIGATED);
1098 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
1100 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1102 TRACE("(%p)->(%p)\n", iface, p);
1104 *p = SysAllocString(This->window && This->window->url ? This->window->url : L"about:blank");
1105 return *p ? S_OK : E_OUTOFMEMORY;
1108 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
1110 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1111 nsAString nsstr;
1112 nsresult nsres;
1114 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1116 nsAString_InitDepend(&nsstr, v);
1117 nsres = nsIDOMHTMLDocument_SetDomain(This->doc_node->nsdoc, &nsstr);
1118 nsAString_Finish(&nsstr);
1119 if(NS_FAILED(nsres)) {
1120 ERR("SetDomain failed: %08lx\n", nsres);
1121 return E_INVALIDARG;
1124 return S_OK;
1127 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
1129 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1130 nsAString nsstr;
1131 nsresult nsres;
1133 TRACE("(%p)->(%p)\n", This, p);
1135 nsAString_Init(&nsstr, NULL);
1136 nsres = nsIDOMHTMLDocument_GetDomain(This->doc_node->nsdoc, &nsstr);
1137 if(NS_SUCCEEDED(nsres) && This->window && This->window->uri) {
1138 const PRUnichar *str;
1139 HRESULT hres;
1141 nsAString_GetData(&nsstr, &str);
1142 if(!*str) {
1143 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
1144 nsAString_Finish(&nsstr);
1145 hres = IUri_GetHost(This->window->uri, p);
1146 return FAILED(hres) ? hres : S_OK;
1150 return return_nsstr(nsres, &nsstr, p);
1153 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
1155 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1156 BOOL bret;
1158 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1160 if(!This->window)
1161 return S_OK;
1163 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
1164 if(!bret) {
1165 FIXME("InternetSetCookieExW failed: %lu\n", GetLastError());
1166 return HRESULT_FROM_WIN32(GetLastError());
1169 return S_OK;
1172 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
1174 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1175 DWORD size;
1176 BOOL bret;
1178 TRACE("(%p)->(%p)\n", This, p);
1180 if(!This->window) {
1181 *p = NULL;
1182 return S_OK;
1185 size = 0;
1186 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
1187 if(!bret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
1188 WARN("InternetGetCookieExW failed: %lu\n", GetLastError());
1189 *p = NULL;
1190 return S_OK;
1193 if(!size) {
1194 *p = NULL;
1195 return S_OK;
1198 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
1199 if(!*p)
1200 return E_OUTOFMEMORY;
1202 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
1203 if(!bret) {
1204 ERR("InternetGetCookieExW failed: %lu\n", GetLastError());
1205 return E_FAIL;
1208 return S_OK;
1211 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
1213 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1214 FIXME("(%p)->(%x)\n", This, v);
1215 return E_NOTIMPL;
1218 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
1220 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1221 FIXME("(%p)->(%p)\n", This, p);
1222 return E_NOTIMPL;
1225 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
1227 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1228 FIXME("(%p)->(%s) returning S_OK\n", This, debugstr_w(v));
1229 return S_OK;
1232 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
1234 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1236 TRACE("(%p)->(%p)\n", This, p);
1238 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
1241 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
1243 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1244 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1245 return E_NOTIMPL;
1248 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
1250 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1252 TRACE("(%p)->(%p)\n", This, p);
1254 *p = charset_string_from_cp(GetACP());
1255 return *p ? S_OK : E_OUTOFMEMORY;
1258 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
1260 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1261 FIXME("(%p)->(%p)\n", This, p);
1262 return E_NOTIMPL;
1265 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
1267 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1268 FIXME("(%p)->(%p)\n", This, p);
1269 return E_NOTIMPL;
1272 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
1274 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1275 FIXME("(%p)->(%p)\n", This, p);
1276 return E_NOTIMPL;
1279 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
1281 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1282 FIXME("(%p)->(%p)\n", This, p);
1283 return E_NOTIMPL;
1286 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
1288 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1289 FIXME("(%p)->(%p)\n", This, p);
1290 return E_NOTIMPL;
1293 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
1295 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1296 FIXME("(%p)->(%p)\n", This, p);
1297 return E_NOTIMPL;
1300 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
1302 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1303 FIXME("(%p)->(%p)\n", This, p);
1304 return E_NOTIMPL;
1307 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1309 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1310 FIXME("(%p)->(%p)\n", This, p);
1311 return E_NOTIMPL;
1314 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
1316 VARIANT *var, tmp;
1317 JSContext *jsctx;
1318 nsAString nsstr;
1319 ULONG i, argc;
1320 nsresult nsres;
1321 HRESULT hres;
1323 if(!This->doc_node->nsdoc) {
1324 WARN("NULL nsdoc\n");
1325 return E_UNEXPECTED;
1328 if (!psarray)
1329 return S_OK;
1331 if(psarray->cDims != 1) {
1332 FIXME("cDims=%d\n", psarray->cDims);
1333 return E_INVALIDARG;
1336 hres = SafeArrayAccessData(psarray, (void**)&var);
1337 if(FAILED(hres)) {
1338 WARN("SafeArrayAccessData failed: %08lx\n", hres);
1339 return hres;
1342 V_VT(&tmp) = VT_EMPTY;
1344 jsctx = get_context_from_document(This->doc_node->nsdoc);
1345 argc = psarray->rgsabound[0].cElements;
1346 for(i=0; i < argc; i++) {
1347 if(V_VT(var+i) == VT_BSTR) {
1348 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1349 }else {
1350 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1351 if(FAILED(hres)) {
1352 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1353 break;
1355 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1358 if(!ln || i != argc-1)
1359 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1360 else
1361 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1362 nsAString_Finish(&nsstr);
1363 if(V_VT(var+i) != VT_BSTR)
1364 VariantClear(&tmp);
1365 if(NS_FAILED(nsres)) {
1366 ERR("Write failed: %08lx\n", nsres);
1367 hres = E_FAIL;
1368 break;
1372 SafeArrayUnaccessData(psarray);
1374 return hres;
1377 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1379 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1381 TRACE("(%p)->(%p)\n", iface, psarray);
1383 return document_write(This, psarray, FALSE);
1386 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1388 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1390 TRACE("(%p)->(%p)\n", This, psarray);
1392 return document_write(This, psarray, TRUE);
1395 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1396 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1398 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1399 nsISupports *tmp;
1400 nsresult nsres;
1402 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1403 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1405 *pomWindowResult = NULL;
1407 if(!This->window)
1408 return E_FAIL;
1410 if(!This->doc_node->nsdoc) {
1411 ERR("!nsdoc\n");
1412 return E_NOTIMPL;
1415 if(!url || wcscmp(url, L"text/html") || V_VT(&name) != VT_ERROR
1416 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1417 FIXME("unsupported args\n");
1419 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1420 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1421 if(NS_FAILED(nsres)) {
1422 ERR("Open failed: %08lx\n", nsres);
1423 return E_FAIL;
1426 if(tmp)
1427 nsISupports_Release(tmp);
1429 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1430 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1431 return S_OK;
1434 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1436 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1437 nsresult nsres;
1439 TRACE("(%p)\n", This);
1441 if(!This->doc_node->nsdoc) {
1442 ERR("!nsdoc\n");
1443 return E_NOTIMPL;
1446 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1447 if(NS_FAILED(nsres)) {
1448 ERR("Close failed: %08lx\n", nsres);
1449 return E_FAIL;
1452 return S_OK;
1455 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1457 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1458 nsresult nsres;
1460 TRACE("(%p)\n", This);
1462 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1463 if(NS_FAILED(nsres)) {
1464 ERR("Clear failed: %08lx\n", nsres);
1465 return E_FAIL;
1468 return S_OK;
1471 static const struct {
1472 const WCHAR *name;
1473 OLECMDID id;
1474 }command_names[] = {
1475 {L"copy", IDM_COPY},
1476 {L"cut", IDM_CUT},
1477 {L"fontname", IDM_FONTNAME},
1478 {L"fontsize", IDM_FONTSIZE},
1479 {L"indent", IDM_INDENT},
1480 {L"insertorderedlist", IDM_ORDERLIST},
1481 {L"insertunorderedlist", IDM_UNORDERLIST},
1482 {L"outdent", IDM_OUTDENT},
1483 {L"paste", IDM_PASTE},
1484 {L"respectvisibilityindesign", IDM_RESPECTVISIBILITY_INDESIGN}
1487 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1489 int i;
1491 for(i = 0; i < ARRAY_SIZE(command_names); i++) {
1492 if(!wcsicmp(command_names[i].name, str)) {
1493 *cmdid = command_names[i].id;
1494 return TRUE;
1498 FIXME("Unknown command %s\n", debugstr_w(str));
1499 return FALSE;
1502 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1503 VARIANT_BOOL *pfRet)
1505 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1506 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1507 return E_NOTIMPL;
1510 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1511 VARIANT_BOOL *pfRet)
1513 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1514 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1515 return E_NOTIMPL;
1518 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1519 VARIANT_BOOL *pfRet)
1521 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1522 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1523 return E_NOTIMPL;
1526 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1527 VARIANT_BOOL *pfRet)
1529 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1530 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1531 return E_NOTIMPL;
1534 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1535 BSTR *pfRet)
1537 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1538 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1539 return E_NOTIMPL;
1542 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1543 VARIANT *pfRet)
1545 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1546 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1547 return E_NOTIMPL;
1550 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1551 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1553 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1554 OLECMDID cmdid;
1555 VARIANT ret;
1556 HRESULT hres;
1558 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1560 if(!cmdid_from_string(cmdID, &cmdid))
1561 return OLECMDERR_E_NOTSUPPORTED;
1563 V_VT(&ret) = VT_EMPTY;
1564 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1565 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1566 if(FAILED(hres))
1567 return hres;
1569 if(V_VT(&ret) != VT_EMPTY) {
1570 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1571 VariantClear(&ret);
1574 *pfRet = VARIANT_TRUE;
1575 return S_OK;
1578 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1579 VARIANT_BOOL *pfRet)
1581 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1582 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1583 return E_NOTIMPL;
1586 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1587 IHTMLElement **newElem)
1589 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1590 HTMLElement *elem;
1591 HRESULT hres;
1593 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1595 hres = create_element(This->doc_node, eTag, &elem);
1596 if(FAILED(hres))
1597 return hres;
1599 *newElem = &elem->IHTMLElement_iface;
1600 return S_OK;
1603 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1605 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1606 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1607 return E_NOTIMPL;
1610 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1612 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1613 FIXME("(%p)->(%p)\n", This, p);
1614 return E_NOTIMPL;
1617 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1619 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1621 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1623 return set_doc_event(This, EVENTID_CLICK, &v);
1626 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1628 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1630 TRACE("(%p)->(%p)\n", This, p);
1632 return get_doc_event(This, EVENTID_CLICK, p);
1635 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1637 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1639 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1641 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1644 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1646 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1648 TRACE("(%p)->(%p)\n", This, p);
1650 return get_doc_event(This, EVENTID_DBLCLICK, p);
1653 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1655 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1657 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1659 return set_doc_event(This, EVENTID_KEYUP, &v);
1662 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1664 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1666 TRACE("(%p)->(%p)\n", This, p);
1668 return get_doc_event(This, EVENTID_KEYUP, p);
1671 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1673 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1675 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1677 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1680 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1682 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1684 TRACE("(%p)->(%p)\n", This, p);
1686 return get_doc_event(This, EVENTID_KEYDOWN, p);
1689 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1691 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1693 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1695 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1698 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1700 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1702 TRACE("(%p)->(%p)\n", This, p);
1704 return get_doc_event(This, EVENTID_KEYPRESS, p);
1707 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1709 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1711 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1713 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1716 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1718 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1720 TRACE("(%p)->(%p)\n", This, p);
1722 return get_doc_event(This, EVENTID_MOUSEUP, p);
1725 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1727 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1729 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1731 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1734 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1736 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1738 TRACE("(%p)->(%p)\n", This, p);
1740 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1743 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1745 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1747 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1749 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1752 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1754 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1756 TRACE("(%p)->(%p)\n", This, p);
1758 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1761 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1763 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1765 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1767 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1770 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1772 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1774 TRACE("(%p)->(%p)\n", This, p);
1776 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1779 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1781 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1783 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1785 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1788 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1790 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1792 TRACE("(%p)->(%p)\n", This, p);
1794 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1797 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1799 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1801 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1803 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1806 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1808 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1810 TRACE("(%p)->(%p)\n", This, p);
1812 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1815 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1817 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1818 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1819 return E_NOTIMPL;
1822 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1824 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1825 FIXME("(%p)->(%p)\n", This, p);
1826 return E_NOTIMPL;
1829 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1831 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1832 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1833 return E_NOTIMPL;
1836 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1838 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1839 FIXME("(%p)->(%p)\n", This, p);
1840 return E_NOTIMPL;
1843 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1845 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1846 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1847 return E_NOTIMPL;
1850 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1852 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1853 FIXME("(%p)->(%p)\n", This, p);
1854 return E_NOTIMPL;
1857 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1859 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1861 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1863 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1866 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1868 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1870 TRACE("(%p)->(%p)\n", This, p);
1872 return get_doc_event(This, EVENTID_DRAGSTART, p);
1875 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1877 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1879 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1881 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1884 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1886 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1888 TRACE("(%p)->(%p)\n", This, p);
1890 return get_doc_event(This, EVENTID_SELECTSTART, p);
1893 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1894 IHTMLElement **elementHit)
1896 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1897 nsIDOMElement *nselem;
1898 HTMLElement *element;
1899 nsresult nsres;
1900 HRESULT hres;
1902 TRACE("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1904 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1905 if(NS_FAILED(nsres)) {
1906 ERR("ElementFromPoint failed: %08lx\n", nsres);
1907 return E_FAIL;
1910 if(!nselem) {
1911 *elementHit = NULL;
1912 return S_OK;
1915 hres = get_element(nselem, &element);
1916 nsIDOMElement_Release(nselem);
1917 if(FAILED(hres))
1918 return hres;
1920 *elementHit = &element->IHTMLElement_iface;
1921 return S_OK;
1924 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1926 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1927 HRESULT hres;
1929 TRACE("(%p)->(%p)\n", This, p);
1931 hres = IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
1932 return hres == S_OK && !*p ? E_FAIL : hres;
1935 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1936 IHTMLStyleSheetsCollection **p)
1938 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1939 nsIDOMStyleSheetList *nsstylelist;
1940 nsresult nsres;
1941 HRESULT hres;
1943 TRACE("(%p)->(%p)\n", This, p);
1945 *p = NULL;
1947 if(!This->doc_node->nsdoc) {
1948 WARN("NULL nsdoc\n");
1949 return E_UNEXPECTED;
1952 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1953 if(NS_FAILED(nsres)) {
1954 ERR("GetStyleSheets failed: %08lx\n", nsres);
1955 return map_nsresult(nsres);
1958 hres = create_style_sheet_collection(nsstylelist,
1959 dispex_compat_mode(&This->doc_node->node.event_target.dispex), p);
1960 nsIDOMStyleSheetList_Release(nsstylelist);
1961 return hres;
1964 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1966 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1967 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1968 return E_NOTIMPL;
1971 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1973 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1974 FIXME("(%p)->(%p)\n", This, p);
1975 return E_NOTIMPL;
1978 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1980 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1981 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1982 return E_NOTIMPL;
1985 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1987 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1988 FIXME("(%p)->(%p)\n", This, p);
1989 return E_NOTIMPL;
1992 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1994 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1996 TRACE("(%p)->(%p)\n", This, String);
1998 return dispex_to_string(&This->doc_node->node.event_target.dispex, String);
2001 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
2002 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
2004 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
2005 nsIDOMHTMLHeadElement *head_elem;
2006 IHTMLStyleElement *style_elem;
2007 HTMLElement *elem;
2008 nsresult nsres;
2009 HRESULT hres;
2011 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
2013 if(!This->doc_node->nsdoc) {
2014 FIXME("not a real doc object\n");
2015 return E_NOTIMPL;
2018 if(lIndex != -1)
2019 FIXME("Unsupported lIndex %ld\n", lIndex);
2021 if(bstrHref && *bstrHref) {
2022 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
2023 return create_style_sheet(NULL, dispex_compat_mode(&This->doc_node->node.event_target.dispex),
2024 ppnewStyleSheet);
2027 hres = create_element(This->doc_node, L"style", &elem);
2028 if(FAILED(hres))
2029 return hres;
2031 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
2032 if(NS_SUCCEEDED(nsres)) {
2033 nsIDOMNode *head_node, *tmp_node;
2035 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
2036 nsIDOMHTMLHeadElement_Release(head_elem);
2037 assert(nsres == NS_OK);
2039 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
2040 nsIDOMNode_Release(head_node);
2041 if(NS_SUCCEEDED(nsres) && tmp_node)
2042 nsIDOMNode_Release(tmp_node);
2044 if(NS_FAILED(nsres)) {
2045 IHTMLElement_Release(&elem->IHTMLElement_iface);
2046 return E_FAIL;
2049 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
2050 assert(hres == S_OK);
2051 IHTMLElement_Release(&elem->IHTMLElement_iface);
2053 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
2054 IHTMLStyleElement_Release(style_elem);
2055 return hres;
2058 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
2059 HTMLDocument_QueryInterface,
2060 HTMLDocument_AddRef,
2061 HTMLDocument_Release,
2062 HTMLDocument_GetTypeInfoCount,
2063 HTMLDocument_GetTypeInfo,
2064 HTMLDocument_GetIDsOfNames,
2065 HTMLDocument_Invoke,
2066 HTMLDocument_get_Script,
2067 HTMLDocument_get_all,
2068 HTMLDocument_get_body,
2069 HTMLDocument_get_activeElement,
2070 HTMLDocument_get_images,
2071 HTMLDocument_get_applets,
2072 HTMLDocument_get_links,
2073 HTMLDocument_get_forms,
2074 HTMLDocument_get_anchors,
2075 HTMLDocument_put_title,
2076 HTMLDocument_get_title,
2077 HTMLDocument_get_scripts,
2078 HTMLDocument_put_designMode,
2079 HTMLDocument_get_designMode,
2080 HTMLDocument_get_selection,
2081 HTMLDocument_get_readyState,
2082 HTMLDocument_get_frames,
2083 HTMLDocument_get_embeds,
2084 HTMLDocument_get_plugins,
2085 HTMLDocument_put_alinkColor,
2086 HTMLDocument_get_alinkColor,
2087 HTMLDocument_put_bgColor,
2088 HTMLDocument_get_bgColor,
2089 HTMLDocument_put_fgColor,
2090 HTMLDocument_get_fgColor,
2091 HTMLDocument_put_linkColor,
2092 HTMLDocument_get_linkColor,
2093 HTMLDocument_put_vlinkColor,
2094 HTMLDocument_get_vlinkColor,
2095 HTMLDocument_get_referrer,
2096 HTMLDocument_get_location,
2097 HTMLDocument_get_lastModified,
2098 HTMLDocument_put_URL,
2099 HTMLDocument_get_URL,
2100 HTMLDocument_put_domain,
2101 HTMLDocument_get_domain,
2102 HTMLDocument_put_cookie,
2103 HTMLDocument_get_cookie,
2104 HTMLDocument_put_expando,
2105 HTMLDocument_get_expando,
2106 HTMLDocument_put_charset,
2107 HTMLDocument_get_charset,
2108 HTMLDocument_put_defaultCharset,
2109 HTMLDocument_get_defaultCharset,
2110 HTMLDocument_get_mimeType,
2111 HTMLDocument_get_fileSize,
2112 HTMLDocument_get_fileCreatedDate,
2113 HTMLDocument_get_fileModifiedDate,
2114 HTMLDocument_get_fileUpdatedDate,
2115 HTMLDocument_get_security,
2116 HTMLDocument_get_protocol,
2117 HTMLDocument_get_nameProp,
2118 HTMLDocument_write,
2119 HTMLDocument_writeln,
2120 HTMLDocument_open,
2121 HTMLDocument_close,
2122 HTMLDocument_clear,
2123 HTMLDocument_queryCommandSupported,
2124 HTMLDocument_queryCommandEnabled,
2125 HTMLDocument_queryCommandState,
2126 HTMLDocument_queryCommandIndeterm,
2127 HTMLDocument_queryCommandText,
2128 HTMLDocument_queryCommandValue,
2129 HTMLDocument_execCommand,
2130 HTMLDocument_execCommandShowHelp,
2131 HTMLDocument_createElement,
2132 HTMLDocument_put_onhelp,
2133 HTMLDocument_get_onhelp,
2134 HTMLDocument_put_onclick,
2135 HTMLDocument_get_onclick,
2136 HTMLDocument_put_ondblclick,
2137 HTMLDocument_get_ondblclick,
2138 HTMLDocument_put_onkeyup,
2139 HTMLDocument_get_onkeyup,
2140 HTMLDocument_put_onkeydown,
2141 HTMLDocument_get_onkeydown,
2142 HTMLDocument_put_onkeypress,
2143 HTMLDocument_get_onkeypress,
2144 HTMLDocument_put_onmouseup,
2145 HTMLDocument_get_onmouseup,
2146 HTMLDocument_put_onmousedown,
2147 HTMLDocument_get_onmousedown,
2148 HTMLDocument_put_onmousemove,
2149 HTMLDocument_get_onmousemove,
2150 HTMLDocument_put_onmouseout,
2151 HTMLDocument_get_onmouseout,
2152 HTMLDocument_put_onmouseover,
2153 HTMLDocument_get_onmouseover,
2154 HTMLDocument_put_onreadystatechange,
2155 HTMLDocument_get_onreadystatechange,
2156 HTMLDocument_put_onafterupdate,
2157 HTMLDocument_get_onafterupdate,
2158 HTMLDocument_put_onrowexit,
2159 HTMLDocument_get_onrowexit,
2160 HTMLDocument_put_onrowenter,
2161 HTMLDocument_get_onrowenter,
2162 HTMLDocument_put_ondragstart,
2163 HTMLDocument_get_ondragstart,
2164 HTMLDocument_put_onselectstart,
2165 HTMLDocument_get_onselectstart,
2166 HTMLDocument_elementFromPoint,
2167 HTMLDocument_get_parentWindow,
2168 HTMLDocument_get_styleSheets,
2169 HTMLDocument_put_onbeforeupdate,
2170 HTMLDocument_get_onbeforeupdate,
2171 HTMLDocument_put_onerrorupdate,
2172 HTMLDocument_get_onerrorupdate,
2173 HTMLDocument_toString,
2174 HTMLDocument_createStyleSheet
2177 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
2179 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
2182 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
2183 REFIID riid, void **ppv)
2185 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2186 return htmldoc_query_interface(This, riid, ppv);
2189 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
2191 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2192 return htmldoc_addref(This);
2195 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
2197 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2198 return htmldoc_release(This);
2201 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
2203 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2204 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2207 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
2208 LCID lcid, ITypeInfo **ppTInfo)
2210 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2211 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2214 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
2215 LPOLESTR *rgszNames, UINT cNames,
2216 LCID lcid, DISPID *rgDispId)
2218 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2219 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2220 rgDispId);
2223 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
2224 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2225 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2227 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2228 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2229 pDispParams, pVarResult, pExcepInfo, puArgErr);
2232 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
2234 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2235 FIXME("(%p)\n", This);
2236 return E_NOTIMPL;
2239 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
2241 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2243 WARN("(%p)->(%x)\n", This, fForce);
2245 /* Doing nothing here should be fine for us. */
2246 return S_OK;
2249 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
2250 IHTMLDOMNode **newTextNode)
2252 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2253 nsIDOMText *nstext;
2254 HTMLDOMNode *node;
2255 nsAString text_str;
2256 nsresult nsres;
2257 HRESULT hres;
2259 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
2261 if(!This->doc_node->nsdoc) {
2262 WARN("NULL nsdoc\n");
2263 return E_UNEXPECTED;
2266 nsAString_InitDepend(&text_str, text);
2267 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
2268 nsAString_Finish(&text_str);
2269 if(NS_FAILED(nsres)) {
2270 ERR("CreateTextNode failed: %08lx\n", nsres);
2271 return E_FAIL;
2274 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
2275 nsIDOMText_Release(nstext);
2276 if(FAILED(hres))
2277 return hres;
2279 *newTextNode = &node->IHTMLDOMNode_iface;
2280 return S_OK;
2283 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
2285 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2286 nsIDOMElement *nselem = NULL;
2287 HTMLElement *element;
2288 nsresult nsres;
2289 HRESULT hres;
2291 TRACE("(%p)->(%p)\n", This, p);
2293 if(This->window && This->window->readystate == READYSTATE_UNINITIALIZED) {
2294 *p = NULL;
2295 return S_OK;
2298 if(!This->doc_node->nsdoc) {
2299 WARN("NULL nsdoc\n");
2300 return E_UNEXPECTED;
2303 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
2304 if(NS_FAILED(nsres)) {
2305 ERR("GetDocumentElement failed: %08lx\n", nsres);
2306 return E_FAIL;
2309 if(!nselem) {
2310 *p = NULL;
2311 return S_OK;
2314 hres = get_element(nselem, &element);
2315 nsIDOMElement_Release(nselem);
2316 if(FAILED(hres))
2317 return hres;
2319 *p = &element->IHTMLElement_iface;
2320 return hres;
2323 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2325 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2327 TRACE("(%p)->(%p)\n", This, p);
2329 return elem_unique_id(++This->doc_node->unique_id, p);
2332 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2333 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2335 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2337 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2339 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2342 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2343 IDispatch *pDisp)
2345 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2347 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2349 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2352 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2354 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2355 FIXME("(%p)->()\n", This);
2356 return E_NOTIMPL;
2359 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2361 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2362 FIXME("(%p)->(%p)\n", This, p);
2363 return E_NOTIMPL;
2366 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2368 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2369 FIXME("(%p)->()\n", This);
2370 return E_NOTIMPL;
2373 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2375 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2376 FIXME("(%p)->(%p)\n", This, p);
2377 return E_NOTIMPL;
2380 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2382 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2383 FIXME("(%p)->()\n", This);
2384 return E_NOTIMPL;
2387 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2389 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2390 FIXME("(%p)->(%p)\n", This, p);
2391 return E_NOTIMPL;
2394 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2396 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2397 FIXME("(%p)->()\n", This);
2398 return E_NOTIMPL;
2401 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2403 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2404 FIXME("(%p)->(%p)\n", This, p);
2405 return E_NOTIMPL;
2408 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2410 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2411 FIXME("(%p)->()\n", This);
2412 return E_NOTIMPL;
2415 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2417 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2418 FIXME("(%p)->(%p)\n", This, p);
2419 return E_NOTIMPL;
2422 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2424 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2425 FIXME("(%p)->()\n", This);
2426 return E_NOTIMPL;
2429 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2431 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2432 FIXME("(%p)->(%p)\n", This, p);
2433 return E_NOTIMPL;
2436 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2438 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2439 FIXME("(%p)->()\n", This);
2440 return E_NOTIMPL;
2443 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2445 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2446 FIXME("(%p)->(%p)\n", This, p);
2447 return E_NOTIMPL;
2450 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2452 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2453 nsAString dir_str;
2454 nsresult nsres;
2456 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2458 if(!This->doc_node->nsdoc) {
2459 FIXME("NULL nsdoc\n");
2460 return E_UNEXPECTED;
2463 nsAString_InitDepend(&dir_str, v);
2464 nsres = nsIDOMHTMLDocument_SetDir(This->doc_node->nsdoc, &dir_str);
2465 nsAString_Finish(&dir_str);
2466 if(NS_FAILED(nsres)) {
2467 ERR("SetDir failed: %08lx\n", nsres);
2468 return E_FAIL;
2471 return S_OK;
2474 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2476 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2477 nsAString dir_str;
2478 nsresult nsres;
2480 TRACE("(%p)->(%p)\n", This, p);
2482 if(!This->doc_node->nsdoc) {
2483 FIXME("NULL nsdoc\n");
2484 return E_UNEXPECTED;
2487 nsAString_Init(&dir_str, NULL);
2488 nsres = nsIDOMHTMLDocument_GetDir(This->doc_node->nsdoc, &dir_str);
2489 return return_nsstr(nsres, &dir_str, p);
2492 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2494 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2496 TRACE("(%p)->()\n", This);
2498 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2501 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2503 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2505 TRACE("(%p)->(%p)\n", This, p);
2507 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2510 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2512 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2513 FIXME("(%p)->()\n", This);
2514 return E_NOTIMPL;
2517 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2519 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2520 FIXME("(%p)->(%p)\n", This, p);
2521 return E_NOTIMPL;
2524 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2525 IHTMLDocument2 **ppNewDoc)
2527 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2528 nsIDOMDocumentFragment *doc_frag;
2529 HTMLDocumentNode *docnode;
2530 nsresult nsres;
2531 HRESULT hres;
2533 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2535 if(!This->doc_node->nsdoc) {
2536 FIXME("NULL nsdoc\n");
2537 return E_NOTIMPL;
2540 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2541 if(NS_FAILED(nsres)) {
2542 ERR("CreateDocumentFragment failed: %08lx\n", nsres);
2543 return E_FAIL;
2546 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2547 nsIDOMDocumentFragment_Release(doc_frag);
2548 if(FAILED(hres))
2549 return hres;
2551 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2552 return S_OK;
2555 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2556 IHTMLDocument2 **p)
2558 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2559 FIXME("(%p)->(%p)\n", This, p);
2560 return E_NOTIMPL;
2563 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2564 VARIANT_BOOL v)
2566 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2567 FIXME("(%p)->(%x)\n", This, v);
2568 return E_NOTIMPL;
2571 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2572 VARIANT_BOOL *p)
2574 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2575 FIXME("(%p)->(%p)\n", This, p);
2576 return E_NOTIMPL;
2579 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2581 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2582 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2583 return E_NOTIMPL;
2586 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2588 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2589 FIXME("(%p)->(%p)\n", This, p);
2590 return E_NOTIMPL;
2593 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2595 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2597 TRACE("(%p)->(%p)\n", This, p);
2599 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2602 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2603 VARIANT_BOOL v)
2605 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2606 FIXME("(%p)->()\n", This);
2607 return E_NOTIMPL;
2610 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2611 VARIANT_BOOL *p)
2613 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2614 FIXME("(%p)->(%p)\n", This, p);
2615 return E_NOTIMPL;
2618 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2620 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2621 FIXME("(%p)->()\n", This);
2622 return E_NOTIMPL;
2625 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2627 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2628 FIXME("(%p)->(%p)\n", This, p);
2629 return E_NOTIMPL;
2632 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2633 IHTMLElementCollection **ppelColl)
2635 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2636 nsIDOMNodeList *node_list;
2637 nsAString selector_str;
2638 WCHAR *selector;
2639 nsresult nsres;
2640 static const WCHAR formatW[] = L"*[id=%s],*[name=%s]";
2642 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2644 if(!This->doc_node || !This->doc_node->nsdoc) {
2645 /* We should probably return an empty collection. */
2646 FIXME("No nsdoc\n");
2647 return E_NOTIMPL;
2650 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2651 if(!selector)
2652 return E_OUTOFMEMORY;
2653 swprintf(selector, 2*SysStringLen(v) + ARRAY_SIZE(formatW), formatW, v, v);
2656 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2657 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2658 * types and search should be case insensitive. Those are currently not supported properly.
2660 nsAString_InitDepend(&selector_str, selector);
2661 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2662 nsAString_Finish(&selector_str);
2663 heap_free(selector);
2664 if(NS_FAILED(nsres)) {
2665 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2666 return E_FAIL;
2669 *ppelColl = create_collection_from_nodelist(node_list, This->doc_node->document_mode);
2670 nsIDOMNodeList_Release(node_list);
2671 return S_OK;
2675 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2676 IHTMLElement **pel)
2678 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2679 HTMLElement *elem;
2680 HRESULT hres;
2682 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2684 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2685 if(FAILED(hres) || !elem) {
2686 *pel = NULL;
2687 return hres;
2690 *pel = &elem->IHTMLElement_iface;
2691 return S_OK;
2695 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2696 IHTMLElementCollection **pelColl)
2698 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2699 nsIDOMNodeList *nslist;
2700 nsAString id_str;
2701 nsresult nsres;
2703 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2705 if(This->doc_node->nsdoc) {
2706 nsAString_InitDepend(&id_str, v);
2707 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2708 nsAString_Finish(&id_str);
2709 if(FAILED(nsres)) {
2710 ERR("GetElementByName failed: %08lx\n", nsres);
2711 return E_FAIL;
2713 }else {
2714 nsIDOMDocumentFragment *docfrag;
2715 nsAString nsstr;
2717 if(v) {
2718 const WCHAR *ptr;
2719 for(ptr=v; *ptr; ptr++) {
2720 if(!iswalnum(*ptr)) {
2721 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2722 return E_NOTIMPL;
2727 nsres = nsIDOMNode_QueryInterface(This->doc_node->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2728 if(NS_FAILED(nsres)) {
2729 ERR("Could not get nsIDOMDocumentFragment iface: %08lx\n", nsres);
2730 return E_UNEXPECTED;
2733 nsAString_InitDepend(&nsstr, v);
2734 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2735 nsAString_Finish(&nsstr);
2736 nsIDOMDocumentFragment_Release(docfrag);
2737 if(NS_FAILED(nsres)) {
2738 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2739 return E_FAIL;
2744 *pelColl = create_collection_from_nodelist(nslist, This->doc_node->document_mode);
2745 nsIDOMNodeList_Release(nslist);
2747 return S_OK;
2750 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2751 HTMLDocument3_QueryInterface,
2752 HTMLDocument3_AddRef,
2753 HTMLDocument3_Release,
2754 HTMLDocument3_GetTypeInfoCount,
2755 HTMLDocument3_GetTypeInfo,
2756 HTMLDocument3_GetIDsOfNames,
2757 HTMLDocument3_Invoke,
2758 HTMLDocument3_releaseCapture,
2759 HTMLDocument3_recalc,
2760 HTMLDocument3_createTextNode,
2761 HTMLDocument3_get_documentElement,
2762 HTMLDocument3_get_uniqueID,
2763 HTMLDocument3_attachEvent,
2764 HTMLDocument3_detachEvent,
2765 HTMLDocument3_put_onrowsdelete,
2766 HTMLDocument3_get_onrowsdelete,
2767 HTMLDocument3_put_onrowsinserted,
2768 HTMLDocument3_get_onrowsinserted,
2769 HTMLDocument3_put_oncellchange,
2770 HTMLDocument3_get_oncellchange,
2771 HTMLDocument3_put_ondatasetchanged,
2772 HTMLDocument3_get_ondatasetchanged,
2773 HTMLDocument3_put_ondataavailable,
2774 HTMLDocument3_get_ondataavailable,
2775 HTMLDocument3_put_ondatasetcomplete,
2776 HTMLDocument3_get_ondatasetcomplete,
2777 HTMLDocument3_put_onpropertychange,
2778 HTMLDocument3_get_onpropertychange,
2779 HTMLDocument3_put_dir,
2780 HTMLDocument3_get_dir,
2781 HTMLDocument3_put_oncontextmenu,
2782 HTMLDocument3_get_oncontextmenu,
2783 HTMLDocument3_put_onstop,
2784 HTMLDocument3_get_onstop,
2785 HTMLDocument3_createDocumentFragment,
2786 HTMLDocument3_get_parentDocument,
2787 HTMLDocument3_put_enableDownload,
2788 HTMLDocument3_get_enableDownload,
2789 HTMLDocument3_put_baseUrl,
2790 HTMLDocument3_get_baseUrl,
2791 HTMLDocument3_get_childNodes,
2792 HTMLDocument3_put_inheritStyleSheets,
2793 HTMLDocument3_get_inheritStyleSheets,
2794 HTMLDocument3_put_onbeforeeditfocus,
2795 HTMLDocument3_get_onbeforeeditfocus,
2796 HTMLDocument3_getElementsByName,
2797 HTMLDocument3_getElementById,
2798 HTMLDocument3_getElementsByTagName
2801 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2803 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2806 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2807 REFIID riid, void **ppv)
2809 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2810 return htmldoc_query_interface(This, riid, ppv);
2813 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2815 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2816 return htmldoc_addref(This);
2819 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2821 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2822 return htmldoc_release(This);
2825 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2827 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2828 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2831 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2832 LCID lcid, ITypeInfo **ppTInfo)
2834 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2835 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2838 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2839 LPOLESTR *rgszNames, UINT cNames,
2840 LCID lcid, DISPID *rgDispId)
2842 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2843 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2844 rgDispId);
2847 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2848 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2849 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2851 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2852 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2853 pDispParams, pVarResult, pExcepInfo, puArgErr);
2856 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2858 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2859 nsIDOMHTMLElement *nsbody;
2860 nsresult nsres;
2862 TRACE("(%p)->()\n", This);
2864 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2865 if(NS_FAILED(nsres) || !nsbody) {
2866 ERR("GetBody failed: %08lx\n", nsres);
2867 return E_FAIL;
2870 nsres = nsIDOMHTMLElement_Focus(nsbody);
2871 nsIDOMHTMLElement_Release(nsbody);
2872 if(NS_FAILED(nsres)) {
2873 ERR("Focus failed: %08lx\n", nsres);
2874 return E_FAIL;
2877 return S_OK;
2880 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2882 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2883 cpp_bool has_focus;
2884 nsresult nsres;
2886 TRACE("(%p)->(%p)\n", This, pfFocus);
2888 if(!This->doc_node->nsdoc) {
2889 FIXME("Unimplemented for fragments.\n");
2890 return E_NOTIMPL;
2893 nsres = nsIDOMHTMLDocument_HasFocus(This->doc_node->nsdoc, &has_focus);
2894 assert(nsres == NS_OK);
2896 *pfFocus = variant_bool(has_focus);
2897 return S_OK;
2900 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2902 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2904 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2906 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2909 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2911 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2913 TRACE("(%p)->(%p)\n", This, p);
2915 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2918 static HRESULT WINAPI HTMLDocument4_get_namespaces(IHTMLDocument4 *iface, IDispatch **p)
2920 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2922 TRACE("(%p)->(%p)\n", This, p);
2924 if(!This->doc_node->namespaces) {
2925 HRESULT hres;
2927 hres = create_namespace_collection(dispex_compat_mode(&This->doc_node->node.event_target.dispex),
2928 &This->doc_node->namespaces);
2929 if(FAILED(hres))
2930 return hres;
2933 IHTMLNamespaceCollection_AddRef(This->doc_node->namespaces);
2934 *p = (IDispatch*)This->doc_node->namespaces;
2935 return S_OK;
2938 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2939 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2941 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2942 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2943 return E_NOTIMPL;
2946 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2948 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2949 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2950 return E_NOTIMPL;
2953 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2955 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2956 FIXME("(%p)->(%p)\n", This, p);
2957 return E_NOTIMPL;
2960 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2961 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2963 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2965 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2967 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2968 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2969 return E_NOTIMPL;
2972 return create_event_obj(dispex_compat_mode(&This->doc_node->node.event_target.dispex), ppEventObj);
2975 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2976 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2978 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2980 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2982 return fire_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2985 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2986 IHTMLRenderStyle **ppIHTMLRenderStyle)
2988 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2989 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2990 return E_NOTIMPL;
2993 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2995 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2996 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2997 return E_NOTIMPL;
3000 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
3002 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
3003 FIXME("(%p)->(%p)\n", This, p);
3004 return E_NOTIMPL;
3007 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
3009 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
3010 FIXME("(%p)->(%p)\n", This, p);
3011 return E_NOTIMPL;
3014 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
3015 HTMLDocument4_QueryInterface,
3016 HTMLDocument4_AddRef,
3017 HTMLDocument4_Release,
3018 HTMLDocument4_GetTypeInfoCount,
3019 HTMLDocument4_GetTypeInfo,
3020 HTMLDocument4_GetIDsOfNames,
3021 HTMLDocument4_Invoke,
3022 HTMLDocument4_focus,
3023 HTMLDocument4_hasFocus,
3024 HTMLDocument4_put_onselectionchange,
3025 HTMLDocument4_get_onselectionchange,
3026 HTMLDocument4_get_namespaces,
3027 HTMLDocument4_createDocumentFromUrl,
3028 HTMLDocument4_put_media,
3029 HTMLDocument4_get_media,
3030 HTMLDocument4_createEventObject,
3031 HTMLDocument4_fireEvent,
3032 HTMLDocument4_createRenderStyle,
3033 HTMLDocument4_put_oncontrolselect,
3034 HTMLDocument4_get_oncontrolselect,
3035 HTMLDocument4_get_URLEncoded
3038 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
3040 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
3043 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
3044 REFIID riid, void **ppv)
3046 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3047 return htmldoc_query_interface(This, riid, ppv);
3050 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
3052 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3053 return htmldoc_addref(This);
3056 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
3058 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3059 return htmldoc_release(This);
3062 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
3064 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3065 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3068 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
3069 LCID lcid, ITypeInfo **ppTInfo)
3071 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3072 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3075 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
3076 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3078 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3079 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3080 rgDispId);
3083 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
3084 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3085 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3087 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3088 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3089 pDispParams, pVarResult, pExcepInfo, puArgErr);
3092 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
3094 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3096 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3098 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
3101 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
3103 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3105 TRACE("(%p)->(%p)\n", This, p);
3107 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
3110 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
3112 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3113 HTMLDocumentNode *doc_node = This->doc_node;
3114 nsIDOMDocumentType *nsdoctype;
3115 HTMLDOMNode *doctype_node;
3116 nsresult nsres;
3117 HRESULT hres;
3119 TRACE("(%p)->(%p)\n", This, p);
3121 if(dispex_compat_mode(&doc_node->node.event_target.dispex) < COMPAT_MODE_IE9) {
3122 *p = NULL;
3123 return S_OK;
3126 nsres = nsIDOMHTMLDocument_GetDoctype(doc_node->nsdoc, &nsdoctype);
3127 if(NS_FAILED(nsres))
3128 return map_nsresult(nsres);
3129 if(!nsdoctype) {
3130 *p = NULL;
3131 return S_OK;
3134 hres = get_node((nsIDOMNode*)nsdoctype, TRUE, &doctype_node);
3135 nsIDOMDocumentType_Release(nsdoctype);
3137 if(SUCCEEDED(hres))
3138 *p = &doctype_node->IHTMLDOMNode_iface;
3139 return hres;
3142 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
3144 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3145 HTMLDocumentNode *doc_node = This->doc_node;
3147 TRACE("(%p)->(%p)\n", This, p);
3149 if(!doc_node->dom_implementation) {
3150 HRESULT hres;
3152 hres = create_dom_implementation(doc_node, &doc_node->dom_implementation);
3153 if(FAILED(hres))
3154 return hres;
3157 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
3158 *p = doc_node->dom_implementation;
3159 return S_OK;
3162 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
3163 IHTMLDOMAttribute **ppattribute)
3165 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3166 HTMLDOMAttribute *attr;
3167 HRESULT hres;
3169 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
3171 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, dispex_compat_mode(&This->doc_node->node.event_target.dispex), &attr);
3172 if(FAILED(hres))
3173 return hres;
3175 *ppattribute = &attr->IHTMLDOMAttribute_iface;
3176 return S_OK;
3179 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
3180 IHTMLDOMNode **ppRetNode)
3182 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3183 nsIDOMComment *nscomment;
3184 HTMLElement *elem;
3185 nsAString str;
3186 nsresult nsres;
3187 HRESULT hres;
3189 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
3191 if(!This->doc_node->nsdoc) {
3192 WARN("NULL nsdoc\n");
3193 return E_UNEXPECTED;
3196 nsAString_InitDepend(&str, bstrdata);
3197 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
3198 nsAString_Finish(&str);
3199 if(NS_FAILED(nsres)) {
3200 ERR("CreateTextNode failed: %08lx\n", nsres);
3201 return E_FAIL;
3204 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
3205 nsIDOMComment_Release(nscomment);
3206 if(FAILED(hres))
3207 return hres;
3209 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
3210 return S_OK;
3213 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
3215 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3217 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3219 return set_doc_event(This, EVENTID_FOCUSIN, &v);
3222 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
3224 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3226 TRACE("(%p)->(%p)\n", This, p);
3228 return get_doc_event(This, EVENTID_FOCUSIN, p);
3231 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
3233 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3235 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3237 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
3240 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
3242 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3244 TRACE("(%p)->(%p)\n", This, p);
3246 return get_doc_event(This, EVENTID_FOCUSOUT, p);
3249 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
3251 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3252 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3253 return E_NOTIMPL;
3256 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
3258 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3259 FIXME("(%p)->(%p)\n", This, p);
3260 return E_NOTIMPL;
3263 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
3265 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3266 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3267 return E_NOTIMPL;
3270 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
3272 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3273 FIXME("(%p)->(%p)\n", This, p);
3274 return E_NOTIMPL;
3277 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
3279 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3280 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3281 return E_NOTIMPL;
3284 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
3286 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3287 FIXME("(%p)->(%p)\n", This, p);
3288 return E_NOTIMPL;
3291 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
3293 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3294 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3295 return E_NOTIMPL;
3298 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
3300 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3301 FIXME("(%p)->(%p)\n", This, p);
3302 return E_NOTIMPL;
3305 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
3307 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
3309 TRACE("(%p)->(%p)\n", This, p);
3311 *p = SysAllocString(This->doc_node->document_mode <= COMPAT_MODE_IE5 ? L"BackCompat" : L"CSS1Compat");
3312 return *p ? S_OK : E_OUTOFMEMORY;
3315 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
3316 HTMLDocument5_QueryInterface,
3317 HTMLDocument5_AddRef,
3318 HTMLDocument5_Release,
3319 HTMLDocument5_GetTypeInfoCount,
3320 HTMLDocument5_GetTypeInfo,
3321 HTMLDocument5_GetIDsOfNames,
3322 HTMLDocument5_Invoke,
3323 HTMLDocument5_put_onmousewheel,
3324 HTMLDocument5_get_onmousewheel,
3325 HTMLDocument5_get_doctype,
3326 HTMLDocument5_get_implementation,
3327 HTMLDocument5_createAttribute,
3328 HTMLDocument5_createComment,
3329 HTMLDocument5_put_onfocusin,
3330 HTMLDocument5_get_onfocusin,
3331 HTMLDocument5_put_onfocusout,
3332 HTMLDocument5_get_onfocusout,
3333 HTMLDocument5_put_onactivate,
3334 HTMLDocument5_get_onactivate,
3335 HTMLDocument5_put_ondeactivate,
3336 HTMLDocument5_get_ondeactivate,
3337 HTMLDocument5_put_onbeforeactivate,
3338 HTMLDocument5_get_onbeforeactivate,
3339 HTMLDocument5_put_onbeforedeactivate,
3340 HTMLDocument5_get_onbeforedeactivate,
3341 HTMLDocument5_get_compatMode
3344 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3346 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
3349 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
3350 REFIID riid, void **ppv)
3352 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3353 return htmldoc_query_interface(This, riid, ppv);
3356 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3358 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3359 return htmldoc_addref(This);
3362 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3364 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3365 return htmldoc_release(This);
3368 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3370 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3371 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3374 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
3375 LCID lcid, ITypeInfo **ppTInfo)
3377 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3378 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3381 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
3382 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3384 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3385 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3386 rgDispId);
3389 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
3390 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3391 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3393 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3394 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3395 pDispParams, pVarResult, pExcepInfo, puArgErr);
3398 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3399 IHTMLDocumentCompatibleInfoCollection **p)
3401 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3402 FIXME("(%p)->(%p)\n", This, p);
3403 return E_NOTIMPL;
3406 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3408 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3410 TRACE("(%p)->(%p)\n", This, p);
3412 if(!This->doc_node) {
3413 FIXME("NULL doc_node\n");
3414 return E_UNEXPECTED;
3417 V_VT(p) = VT_R4;
3418 V_R4(p) = compat_mode_info[This->doc_node->document_mode].document_mode;
3419 return S_OK;
3422 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3423 VARIANT *p)
3425 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3427 TRACE("(%p)->(%p)\n", This, p);
3429 return get_doc_event(This, EVENTID_STORAGE, p);
3432 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3434 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3436 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3438 return set_doc_event(This, EVENTID_STORAGE, &v);
3441 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3442 VARIANT *p)
3444 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3446 TRACE("(%p)->(%p)\n", This, p);
3448 return get_doc_event(This, EVENTID_STORAGECOMMIT, p);
3451 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3453 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3455 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3457 return set_doc_event(This, EVENTID_STORAGECOMMIT, &v);
3460 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3461 BSTR bstrId, IHTMLElement2 **p)
3463 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3464 nsIDOMElement *nselem;
3465 HTMLElement *elem;
3466 nsAString nsstr;
3467 nsresult nsres;
3468 HRESULT hres;
3470 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3473 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3474 * not search for name attributes, so we may simply let Gecko do the right thing.
3477 if(!This->doc_node->nsdoc) {
3478 FIXME("Not a document\n");
3479 return E_FAIL;
3482 nsAString_InitDepend(&nsstr, bstrId);
3483 nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &nsstr, &nselem);
3484 nsAString_Finish(&nsstr);
3485 if(NS_FAILED(nsres)) {
3486 ERR("GetElementById failed: %08lx\n", nsres);
3487 return E_FAIL;
3490 if(!nselem) {
3491 *p = NULL;
3492 return S_OK;
3495 hres = get_element(nselem, &elem);
3496 nsIDOMElement_Release(nselem);
3497 if(FAILED(hres))
3498 return hres;
3500 *p = &elem->IHTMLElement2_iface;
3501 return S_OK;
3504 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3506 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3507 FIXME("(%p)->()\n", This);
3508 return E_NOTIMPL;
3511 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3512 HTMLDocument6_QueryInterface,
3513 HTMLDocument6_AddRef,
3514 HTMLDocument6_Release,
3515 HTMLDocument6_GetTypeInfoCount,
3516 HTMLDocument6_GetTypeInfo,
3517 HTMLDocument6_GetIDsOfNames,
3518 HTMLDocument6_Invoke,
3519 HTMLDocument6_get_compatible,
3520 HTMLDocument6_get_documentMode,
3521 HTMLDocument6_put_onstorage,
3522 HTMLDocument6_get_onstorage,
3523 HTMLDocument6_put_onstoragecommit,
3524 HTMLDocument6_get_onstoragecommit,
3525 HTMLDocument6_getElementById,
3526 HTMLDocument6_updateSettings
3529 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3531 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3534 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3536 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3537 return htmldoc_query_interface(This, riid, ppv);
3540 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3542 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3543 return htmldoc_addref(This);
3546 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3548 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3549 return htmldoc_release(This);
3552 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3554 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3555 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3558 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3559 LCID lcid, ITypeInfo **ppTInfo)
3561 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3562 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3565 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3566 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3568 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3569 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3570 rgDispId);
3573 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3574 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3575 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3577 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3578 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3579 pDispParams, pVarResult, pExcepInfo, puArgErr);
3582 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3584 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface)->doc_node;
3586 TRACE("(%p)->(%p)\n", This, p);
3588 if(This->window && This->window->base.outer_window) {
3589 *p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
3590 IHTMLWindow2_AddRef(*p);
3591 }else {
3592 *p = NULL;
3594 return S_OK;
3597 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3599 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3600 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3601 return E_NOTIMPL;
3604 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3606 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3607 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3608 return E_NOTIMPL;
3611 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3612 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3614 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3615 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3616 return E_NOTIMPL;
3619 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3621 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3622 nsIDOMElement *dom_element;
3623 HTMLElement *element;
3624 nsAString ns, tag;
3625 nsresult nsres;
3626 HRESULT hres;
3628 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3630 if(!This->doc_node->nsdoc) {
3631 FIXME("NULL nsdoc\n");
3632 return E_FAIL;
3635 if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
3636 FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
3638 nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
3639 nsAString_InitDepend(&tag, bstrTag);
3640 nsres = nsIDOMHTMLDocument_CreateElementNS(This->doc_node->nsdoc, &ns, &tag, &dom_element);
3641 nsAString_Finish(&ns);
3642 nsAString_Finish(&tag);
3643 if(NS_FAILED(nsres)) {
3644 WARN("CreateElementNS failed: %08lx\n", nsres);
3645 return map_nsresult(nsres);
3648 hres = HTMLElement_Create(This->doc_node, (nsIDOMNode*)dom_element, FALSE, &element);
3649 nsIDOMElement_Release(dom_element);
3650 if(FAILED(hres))
3651 return hres;
3653 *newElem = &element->IHTMLElement_iface;
3654 return S_OK;
3657 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3658 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3660 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3661 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3662 return E_NOTIMPL;
3665 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3667 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3668 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3669 return E_NOTIMPL;
3672 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3674 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3676 TRACE("(%p)->(%p)\n", This, p);
3678 return get_doc_event(This, EVENTID_MSTHUMBNAILCLICK, p);
3681 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3683 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3684 nsAString charset_str;
3685 nsresult nsres;
3687 TRACE("(%p)->(%p)\n", This, p);
3689 if(!This->doc_node->nsdoc) {
3690 FIXME("NULL nsdoc\n");
3691 return E_FAIL;
3694 nsAString_Init(&charset_str, NULL);
3695 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
3696 return return_nsstr(nsres, &charset_str, p);
3699 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3701 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3703 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3705 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3708 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3710 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3712 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3714 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3717 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3719 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3720 nsIDOMNodeList *nslist;
3721 nsAString nsstr;
3722 nsresult nsres;
3724 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3726 if(!This->doc_node->nsdoc) {
3727 FIXME("NULL nsdoc not supported\n");
3728 return E_NOTIMPL;
3731 nsAString_InitDepend(&nsstr, v);
3732 nsres = nsIDOMHTMLDocument_GetElementsByClassName(This->doc_node->nsdoc, &nsstr, &nslist);
3733 nsAString_Finish(&nsstr);
3734 if(FAILED(nsres)) {
3735 ERR("GetElementByClassName failed: %08lx\n", nsres);
3736 return E_FAIL;
3740 *pel = create_collection_from_nodelist(nslist, This->doc_node->document_mode);
3741 nsIDOMNodeList_Release(nslist);
3742 return S_OK;
3745 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3746 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3748 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3749 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3750 return E_NOTIMPL;
3753 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3755 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3756 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3757 return E_NOTIMPL;
3760 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3762 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3763 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3764 return E_NOTIMPL;
3767 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3769 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3770 FIXME("(%p)->(%p)\n", This, p);
3771 return E_NOTIMPL;
3774 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3776 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3778 TRACE("(%p)->(%p)\n", This, p);
3780 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3783 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3785 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3786 FIXME("(%p)->(%p)\n", This, p);
3787 return E_NOTIMPL;
3790 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3792 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3793 FIXME("(%p)->(%p)\n", This, p);
3794 return E_NOTIMPL;
3797 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3799 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3800 FIXME("(%p)->(%x)\n", This, v);
3801 return E_NOTIMPL;
3804 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3806 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3807 FIXME("(%p)->(%p)\n", This, p);
3808 return E_NOTIMPL;
3811 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3813 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3814 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3815 return E_NOTIMPL;
3818 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3820 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3821 FIXME("(%p)->(%p)\n", This, p);
3822 return E_NOTIMPL;
3825 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3827 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3828 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3829 return E_NOTIMPL;
3832 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3834 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3836 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3838 return set_doc_event(This, EVENTID_ABORT, &v);
3841 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3843 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3845 TRACE("(%p)->(%p)\n", This, p);
3847 return get_doc_event(This, EVENTID_ABORT, p);
3850 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3852 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3854 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3856 return set_doc_event(This, EVENTID_BLUR, &v);
3859 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3861 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3863 TRACE("(%p)->(%p)\n", This, p);
3865 return get_doc_event(This, EVENTID_BLUR, p);
3868 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3870 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3871 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3872 return E_NOTIMPL;
3875 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3877 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3878 FIXME("(%p)->(%p)\n", This, p);
3879 return E_NOTIMPL;
3882 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3884 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3885 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3886 return E_NOTIMPL;
3889 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3891 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3892 FIXME("(%p)->(%p)\n", This, p);
3893 return E_NOTIMPL;
3896 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3898 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3900 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3902 return set_doc_event(This, EVENTID_CHANGE, &v);
3905 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3907 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3909 TRACE("(%p)->(%p)\n", This, p);
3911 return get_doc_event(This, EVENTID_CHANGE, p);
3914 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3916 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3918 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3920 return set_doc_event(This, EVENTID_DRAG, &v);
3923 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3925 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3927 TRACE("(%p)->(%p)\n", This, p);
3929 return get_doc_event(This, EVENTID_DRAG, p);
3932 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3934 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3935 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3936 return E_NOTIMPL;
3939 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3941 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3942 FIXME("(%p)->(%p)\n", This, p);
3943 return E_NOTIMPL;
3946 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3948 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3949 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3950 return E_NOTIMPL;
3953 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3955 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3956 FIXME("(%p)->(%p)\n", This, p);
3957 return E_NOTIMPL;
3960 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3962 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3963 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3964 return E_NOTIMPL;
3967 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3969 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3970 FIXME("(%p)->(%p)\n", This, p);
3971 return E_NOTIMPL;
3974 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3976 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3977 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3978 return E_NOTIMPL;
3981 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3983 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3984 FIXME("(%p)->(%p)\n", This, p);
3985 return E_NOTIMPL;
3988 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3990 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3991 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3992 return E_NOTIMPL;
3995 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3997 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3998 FIXME("(%p)->(%p)\n", This, p);
3999 return E_NOTIMPL;
4002 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
4004 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4005 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4006 return E_NOTIMPL;
4009 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
4011 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4012 FIXME("(%p)->(%p)\n", This, p);
4013 return E_NOTIMPL;
4016 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
4018 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4019 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4020 return E_NOTIMPL;
4023 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
4025 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4026 FIXME("(%p)->(%p)\n", This, p);
4027 return E_NOTIMPL;
4030 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
4032 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4033 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4034 return E_NOTIMPL;
4037 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
4039 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4040 FIXME("(%p)->(%p)\n", This, p);
4041 return E_NOTIMPL;
4044 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
4046 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4048 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4050 return set_doc_event(This, EVENTID_ERROR, &v);
4053 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
4055 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4057 TRACE("(%p)->(%p)\n", This, p);
4059 return get_doc_event(This, EVENTID_ERROR, p);
4062 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
4064 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4066 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4068 return set_doc_event(This, EVENTID_FOCUS, &v);
4071 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
4073 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4075 TRACE("(%p)->(%p)\n", This, p);
4077 return get_doc_event(This, EVENTID_FOCUS, p);
4080 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
4082 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4084 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4086 return set_doc_event(This, EVENTID_INPUT, &v);
4089 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
4091 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4093 TRACE("(%p)->(%p)\n", This, p);
4095 return get_doc_event(This, EVENTID_INPUT, p);
4098 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
4100 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4102 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4104 return set_doc_event(This, EVENTID_LOAD, &v);
4107 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
4109 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4111 TRACE("(%p)->(%p)\n", This, p);
4113 return get_doc_event(This, EVENTID_LOAD, p);
4116 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
4118 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4119 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4120 return E_NOTIMPL;
4123 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
4125 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4126 FIXME("(%p)->(%p)\n", This, p);
4127 return E_NOTIMPL;
4130 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
4132 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4133 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4134 return E_NOTIMPL;
4137 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
4139 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4140 FIXME("(%p)->(%p)\n", This, p);
4141 return E_NOTIMPL;
4144 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
4146 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4147 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4148 return E_NOTIMPL;
4151 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
4153 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4154 FIXME("(%p)->(%p)\n", This, p);
4155 return E_NOTIMPL;
4158 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
4160 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4161 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4162 return E_NOTIMPL;
4165 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
4167 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4168 FIXME("(%p)->(%p)\n", This, p);
4169 return E_NOTIMPL;
4172 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
4174 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4175 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4176 return E_NOTIMPL;
4179 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
4181 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4182 FIXME("(%p)->(%p)\n", This, p);
4183 return E_NOTIMPL;
4186 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
4188 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4189 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4190 return E_NOTIMPL;
4193 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
4195 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4196 FIXME("(%p)->(%p)\n", This, p);
4197 return E_NOTIMPL;
4200 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
4202 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4203 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4204 return E_NOTIMPL;
4207 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
4209 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4210 FIXME("(%p)->(%p)\n", This, p);
4211 return E_NOTIMPL;
4214 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
4216 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4217 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4218 return E_NOTIMPL;
4221 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
4223 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4224 FIXME("(%p)->(%p)\n", This, p);
4225 return E_NOTIMPL;
4228 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
4230 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4231 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4232 return E_NOTIMPL;
4235 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
4237 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4238 FIXME("(%p)->(%p)\n", This, p);
4239 return E_NOTIMPL;
4242 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
4244 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4246 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4248 return set_doc_event(This, EVENTID_SCROLL, &v);
4251 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
4253 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4255 TRACE("(%p)->(%p)\n", This, p);
4257 return get_doc_event(This, EVENTID_SCROLL, p);
4260 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
4262 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4263 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4264 return E_NOTIMPL;
4267 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
4269 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4270 FIXME("(%p)->(%p)\n", This, p);
4271 return E_NOTIMPL;
4274 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
4276 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4277 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4278 return E_NOTIMPL;
4281 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
4283 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4284 FIXME("(%p)->(%p)\n", This, p);
4285 return E_NOTIMPL;
4288 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
4290 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4291 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4292 return E_NOTIMPL;
4295 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
4297 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4298 FIXME("(%p)->(%p)\n", This, p);
4299 return E_NOTIMPL;
4302 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
4304 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4305 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4306 return E_NOTIMPL;
4309 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
4311 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4312 FIXME("(%p)->(%p)\n", This, p);
4313 return E_NOTIMPL;
4316 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
4318 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4320 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4322 return set_doc_event(This, EVENTID_SUBMIT, &v);
4325 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
4327 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4329 TRACE("(%p)->(%p)\n", This, p);
4331 return get_doc_event(This, EVENTID_SUBMIT, p);
4334 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
4336 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4337 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4338 return E_NOTIMPL;
4341 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
4343 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4344 FIXME("(%p)->(%p)\n", This, p);
4345 return E_NOTIMPL;
4348 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
4350 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4351 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4352 return E_NOTIMPL;
4355 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
4357 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4358 FIXME("(%p)->(%p)\n", This, p);
4359 return E_NOTIMPL;
4362 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
4364 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4365 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4366 return E_NOTIMPL;
4369 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4371 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4372 FIXME("(%p)->(%p)\n", This, p);
4373 return E_NOTIMPL;
4376 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4378 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4379 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4380 return E_NOTIMPL;
4383 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4385 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4386 FIXME("(%p)->(%p)\n", This, p);
4387 return E_NOTIMPL;
4390 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4392 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4393 FIXME("(%p)\n", This);
4394 return E_NOTIMPL;
4397 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4398 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4400 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4401 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4402 return E_NOTIMPL;
4405 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4407 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4409 TRACE("(%p)->(%p)\n", This, p);
4411 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4414 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4416 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4417 FIXME("(%p)->(%p)\n", This, v);
4418 return E_NOTIMPL;
4421 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4423 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4425 TRACE("(%p)->(%p)\n", This, p);
4427 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4430 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4432 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4433 nsIDOMHTMLHeadElement *nshead;
4434 nsIDOMElement *nselem;
4435 HTMLElement *elem;
4436 nsresult nsres;
4437 HRESULT hres;
4439 TRACE("(%p)->(%p)\n", This, p);
4441 if(!This->doc_node->nsdoc) {
4442 FIXME("No document\n");
4443 return E_FAIL;
4446 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &nshead);
4447 assert(nsres == NS_OK);
4449 if(!nshead) {
4450 *p = NULL;
4451 return S_OK;
4454 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4455 nsIDOMHTMLHeadElement_Release(nshead);
4456 assert(nsres == NS_OK);
4458 hres = get_element(nselem, &elem);
4459 nsIDOMElement_Release(nselem);
4460 if(FAILED(hres))
4461 return hres;
4463 *p = &elem->IHTMLElement_iface;
4464 return S_OK;
4467 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4468 HTMLDocument7_QueryInterface,
4469 HTMLDocument7_AddRef,
4470 HTMLDocument7_Release,
4471 HTMLDocument7_GetTypeInfoCount,
4472 HTMLDocument7_GetTypeInfo,
4473 HTMLDocument7_GetIDsOfNames,
4474 HTMLDocument7_Invoke,
4475 HTMLDocument7_get_defaultView,
4476 HTMLDocument7_createCDATASection,
4477 HTMLDocument7_getSelection,
4478 HTMLDocument7_getElementsByTagNameNS,
4479 HTMLDocument7_createElementNS,
4480 HTMLDocument7_createAttributeNS,
4481 HTMLDocument7_put_onmsthumbnailclick,
4482 HTMLDocument7_get_onmsthumbnailclick,
4483 HTMLDocument7_get_characterSet,
4484 HTMLDocument7_createElement,
4485 HTMLDocument7_createAttribute,
4486 HTMLDocument7_getElementsByClassName,
4487 HTMLDocument7_createProcessingInstruction,
4488 HTMLDocument7_adoptNode,
4489 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4490 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4491 HTMLDocument7_get_all,
4492 HTMLDocument7_get_inputEncoding,
4493 HTMLDocument7_get_xmlEncoding,
4494 HTMLDocument7_put_xmlStandalone,
4495 HTMLDocument7_get_xmlStandalone,
4496 HTMLDocument7_put_xmlVersion,
4497 HTMLDocument7_get_xmlVersion,
4498 HTMLDocument7_hasAttributes,
4499 HTMLDocument7_put_onabort,
4500 HTMLDocument7_get_onabort,
4501 HTMLDocument7_put_onblur,
4502 HTMLDocument7_get_onblur,
4503 HTMLDocument7_put_oncanplay,
4504 HTMLDocument7_get_oncanplay,
4505 HTMLDocument7_put_oncanplaythrough,
4506 HTMLDocument7_get_oncanplaythrough,
4507 HTMLDocument7_put_onchange,
4508 HTMLDocument7_get_onchange,
4509 HTMLDocument7_put_ondrag,
4510 HTMLDocument7_get_ondrag,
4511 HTMLDocument7_put_ondragend,
4512 HTMLDocument7_get_ondragend,
4513 HTMLDocument7_put_ondragenter,
4514 HTMLDocument7_get_ondragenter,
4515 HTMLDocument7_put_ondragleave,
4516 HTMLDocument7_get_ondragleave,
4517 HTMLDocument7_put_ondragover,
4518 HTMLDocument7_get_ondragover,
4519 HTMLDocument7_put_ondrop,
4520 HTMLDocument7_get_ondrop,
4521 HTMLDocument7_put_ondurationchange,
4522 HTMLDocument7_get_ondurationchange,
4523 HTMLDocument7_put_onemptied,
4524 HTMLDocument7_get_onemptied,
4525 HTMLDocument7_put_onended,
4526 HTMLDocument7_get_onended,
4527 HTMLDocument7_put_onerror,
4528 HTMLDocument7_get_onerror,
4529 HTMLDocument7_put_onfocus,
4530 HTMLDocument7_get_onfocus,
4531 HTMLDocument7_put_oninput,
4532 HTMLDocument7_get_oninput,
4533 HTMLDocument7_put_onload,
4534 HTMLDocument7_get_onload,
4535 HTMLDocument7_put_onloadeddata,
4536 HTMLDocument7_get_onloadeddata,
4537 HTMLDocument7_put_onloadedmetadata,
4538 HTMLDocument7_get_onloadedmetadata,
4539 HTMLDocument7_put_onloadstart,
4540 HTMLDocument7_get_onloadstart,
4541 HTMLDocument7_put_onpause,
4542 HTMLDocument7_get_onpause,
4543 HTMLDocument7_put_onplay,
4544 HTMLDocument7_get_onplay,
4545 HTMLDocument7_put_onplaying,
4546 HTMLDocument7_get_onplaying,
4547 HTMLDocument7_put_onprogress,
4548 HTMLDocument7_get_onprogress,
4549 HTMLDocument7_put_onratechange,
4550 HTMLDocument7_get_onratechange,
4551 HTMLDocument7_put_onreset,
4552 HTMLDocument7_get_onreset,
4553 HTMLDocument7_put_onscroll,
4554 HTMLDocument7_get_onscroll,
4555 HTMLDocument7_put_onseekend,
4556 HTMLDocument7_get_onseekend,
4557 HTMLDocument7_put_onseeking,
4558 HTMLDocument7_get_onseeking,
4559 HTMLDocument7_put_onselect,
4560 HTMLDocument7_get_onselect,
4561 HTMLDocument7_put_onstalled,
4562 HTMLDocument7_get_onstalled,
4563 HTMLDocument7_put_onsubmit,
4564 HTMLDocument7_get_onsubmit,
4565 HTMLDocument7_put_onsuspend,
4566 HTMLDocument7_get_onsuspend,
4567 HTMLDocument7_put_ontimeupdate,
4568 HTMLDocument7_get_ontimeupdate,
4569 HTMLDocument7_put_onvolumechange,
4570 HTMLDocument7_get_onvolumechange,
4571 HTMLDocument7_put_onwaiting,
4572 HTMLDocument7_get_onwaiting,
4573 HTMLDocument7_normalize,
4574 HTMLDocument7_importNode,
4575 HTMLDocument7_get_parentWindow,
4576 HTMLDocument7_put_body,
4577 HTMLDocument7_get_body,
4578 HTMLDocument7_get_head
4581 static inline HTMLDocument *impl_from_IDocumentSelector(IDocumentSelector *iface)
4583 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentSelector_iface);
4586 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4588 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4589 return htmldoc_query_interface(This, riid, ppv);
4592 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4594 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4595 return htmldoc_addref(This);
4598 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4600 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4601 return htmldoc_release(This);
4604 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4606 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4607 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4610 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4611 LCID lcid, ITypeInfo **ppTInfo)
4613 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4614 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4617 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4618 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4620 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4621 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4622 rgDispId);
4625 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4626 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4628 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4629 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4630 pDispParams, pVarResult, pExcepInfo, puArgErr);
4633 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4635 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4636 nsIDOMElement *nselem;
4637 HTMLElement *elem;
4638 nsAString nsstr;
4639 nsresult nsres;
4640 HRESULT hres;
4642 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4644 nsAString_InitDepend(&nsstr, v);
4645 nsres = nsIDOMHTMLDocument_QuerySelector(This->doc_node->nsdoc, &nsstr, &nselem);
4646 nsAString_Finish(&nsstr);
4647 if(NS_FAILED(nsres)) {
4648 ERR("QuerySelector failed: %08lx\n", nsres);
4649 return E_FAIL;
4652 if(!nselem) {
4653 *pel = NULL;
4654 return S_OK;
4657 hres = get_element(nselem, &elem);
4658 nsIDOMElement_Release(nselem);
4659 if(FAILED(hres))
4660 return hres;
4662 *pel = &elem->IHTMLElement_iface;
4663 return S_OK;
4666 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4668 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4669 nsIDOMNodeList *node_list;
4670 nsAString nsstr;
4671 HRESULT hres;
4673 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4675 nsAString_InitDepend(&nsstr, v);
4676 hres = map_nsresult(nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &nsstr, &node_list));
4677 nsAString_Finish(&nsstr);
4678 if(FAILED(hres)) {
4679 ERR("QuerySelectorAll failed: %08lx\n", hres);
4680 return hres;
4683 hres = create_child_collection(node_list, dispex_compat_mode(&This->doc_node->node.event_target.dispex), pel);
4684 nsIDOMNodeList_Release(node_list);
4685 return hres;
4688 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4689 DocumentSelector_QueryInterface,
4690 DocumentSelector_AddRef,
4691 DocumentSelector_Release,
4692 DocumentSelector_GetTypeInfoCount,
4693 DocumentSelector_GetTypeInfo,
4694 DocumentSelector_GetIDsOfNames,
4695 DocumentSelector_Invoke,
4696 DocumentSelector_querySelector,
4697 DocumentSelector_querySelectorAll
4700 static inline HTMLDocument *impl_from_IDocumentEvent(IDocumentEvent *iface)
4702 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentEvent_iface);
4705 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4707 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4708 return htmldoc_query_interface(This, riid, ppv);
4711 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4713 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4714 return htmldoc_addref(This);
4717 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4719 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4720 return htmldoc_release(This);
4723 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4725 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4726 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4729 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4730 LCID lcid, ITypeInfo **ppTInfo)
4732 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4733 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4736 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4737 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4739 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4740 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4741 rgDispId);
4744 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4745 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4747 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4748 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4749 pDispParams, pVarResult, pExcepInfo, puArgErr);
4752 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4754 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4756 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4758 return create_document_event_str(This->doc_node, eventType, p);
4761 static const IDocumentEventVtbl DocumentEventVtbl = {
4762 DocumentEvent_QueryInterface,
4763 DocumentEvent_AddRef,
4764 DocumentEvent_Release,
4765 DocumentEvent_GetTypeInfoCount,
4766 DocumentEvent_GetTypeInfo,
4767 DocumentEvent_GetIDsOfNames,
4768 DocumentEvent_Invoke,
4769 DocumentEvent_createEvent
4772 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4774 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4776 if(This->window)
4777 update_doc_cp_events(This->doc_node, cp);
4780 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4782 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4785 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4787 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4788 return htmldoc_query_interface(This, riid, ppv);
4791 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4793 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4794 return htmldoc_addref(This);
4797 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4799 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4800 return htmldoc_release(This);
4803 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4805 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4806 return S_FALSE;
4809 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4810 SupportErrorInfo_QueryInterface,
4811 SupportErrorInfo_AddRef,
4812 SupportErrorInfo_Release,
4813 SupportErrorInfo_InterfaceSupportsErrorInfo
4816 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4818 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4821 static HRESULT has_elem_name(nsIDOMHTMLDocument *nsdoc, const WCHAR *name)
4823 static const WCHAR fmt[] = L":-moz-any(applet,embed,form,iframe,img,object)[name=\"%s\"]";
4824 WCHAR buf[128], *selector = buf;
4825 nsAString selector_str;
4826 nsIDOMElement *nselem;
4827 nsresult nsres;
4828 size_t len;
4830 len = wcslen(name) + ARRAY_SIZE(fmt) - 2 /* %s */;
4831 if(len > ARRAY_SIZE(buf) && !(selector = heap_alloc(len * sizeof(WCHAR))))
4832 return E_OUTOFMEMORY;
4833 swprintf(selector, len, fmt, name);
4835 nsAString_InitDepend(&selector_str, selector);
4836 nsres = nsIDOMHTMLDocument_QuerySelector(nsdoc, &selector_str, &nselem);
4837 nsAString_Finish(&selector_str);
4838 if(selector != buf)
4839 heap_free(selector);
4840 if(NS_FAILED(nsres))
4841 return map_nsresult(nsres);
4843 if(!nselem)
4844 return DISP_E_UNKNOWNNAME;
4845 nsIDOMElement_Release(nselem);
4846 return S_OK;
4849 static HRESULT get_elem_by_name_or_id(nsIDOMHTMLDocument *nsdoc, const WCHAR *name, nsIDOMElement **ret)
4851 static const WCHAR fmt[] = L":-moz-any(embed,form,iframe,img):-moz-any([name=\"%s\"],[id=\"%s\"][name]),"
4852 L":-moz-any(applet,object):-moz-any([name=\"%s\"],[id=\"%s\"])";
4853 WCHAR buf[384], *selector = buf;
4854 nsAString selector_str;
4855 nsIDOMElement *nselem;
4856 nsresult nsres;
4857 size_t len;
4859 len = wcslen(name) * 4 + ARRAY_SIZE(fmt) - 8 /* %s */;
4860 if(len > ARRAY_SIZE(buf) && !(selector = heap_alloc(len * sizeof(WCHAR))))
4861 return E_OUTOFMEMORY;
4862 swprintf(selector, len, fmt, name, name, name, name);
4864 nsAString_InitDepend(&selector_str, selector);
4865 nsres = nsIDOMHTMLDocument_QuerySelector(nsdoc, &selector_str, &nselem);
4866 nsAString_Finish(&selector_str);
4867 if(selector != buf)
4868 heap_free(selector);
4869 if(NS_FAILED(nsres))
4870 return map_nsresult(nsres);
4872 if(ret) {
4873 *ret = nselem;
4874 return S_OK;
4877 if(nselem) {
4878 nsIDOMElement_Release(nselem);
4879 return S_OK;
4881 return DISP_E_UNKNOWNNAME;
4884 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, const WCHAR *name, DISPID *dispid)
4886 unsigned i;
4888 for(i=0; i < This->elem_vars_cnt; i++) {
4889 if(!wcscmp(name, This->elem_vars[i])) {
4890 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4891 return S_OK;
4895 if(This->elem_vars_cnt == This->elem_vars_size) {
4896 WCHAR **new_vars;
4898 if(This->elem_vars_size) {
4899 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4900 if(!new_vars)
4901 return E_OUTOFMEMORY;
4902 This->elem_vars_size *= 2;
4903 }else {
4904 new_vars = heap_alloc(16*sizeof(WCHAR*));
4905 if(!new_vars)
4906 return E_OUTOFMEMORY;
4907 This->elem_vars_size = 16;
4910 This->elem_vars = new_vars;
4913 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4914 if(!This->elem_vars[This->elem_vars_cnt])
4915 return E_OUTOFMEMORY;
4917 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4918 return S_OK;
4921 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4923 HTMLDocument *This = impl_from_IDispatchEx(iface);
4925 return htmldoc_query_interface(This, riid, ppv);
4928 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4930 HTMLDocument *This = impl_from_IDispatchEx(iface);
4932 return htmldoc_addref(This);
4935 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4937 HTMLDocument *This = impl_from_IDispatchEx(iface);
4939 return htmldoc_release(This);
4942 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4944 HTMLDocument *This = impl_from_IDispatchEx(iface);
4946 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4949 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4950 LCID lcid, ITypeInfo **ppTInfo)
4952 HTMLDocument *This = impl_from_IDispatchEx(iface);
4954 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4957 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4958 LPOLESTR *rgszNames, UINT cNames,
4959 LCID lcid, DISPID *rgDispId)
4961 HTMLDocument *This = impl_from_IDispatchEx(iface);
4963 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4966 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4967 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4968 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4970 HTMLDocument *This = impl_from_IDispatchEx(iface);
4972 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4973 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4975 return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags, pDispParams,
4976 pVarResult, pExcepInfo, NULL);
4979 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4981 HTMLDocument *This = impl_from_IDispatchEx(iface);
4982 HRESULT hres;
4984 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex & ~fdexNameEnsure, pid);
4985 if(hres != DISP_E_UNKNOWNNAME)
4986 return hres;
4988 if(This->doc_node->nsdoc) {
4989 hres = get_elem_by_name_or_id(This->doc_node->nsdoc, bstrName, NULL);
4990 if(SUCCEEDED(hres))
4991 hres = dispid_from_elem_name(This->doc_node, bstrName, pid);
4994 if(hres == DISP_E_UNKNOWNNAME && (grfdex & fdexNameEnsure))
4995 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4996 return hres;
4999 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
5000 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
5002 HTMLDocument *This = impl_from_IDispatchEx(iface);
5004 if(This->window) {
5005 switch(id) {
5006 case DISPID_READYSTATE:
5007 TRACE("DISPID_READYSTATE\n");
5009 if(!(wFlags & DISPATCH_PROPERTYGET))
5010 return E_INVALIDARG;
5012 V_VT(pvarRes) = VT_I4;
5013 V_I4(pvarRes) = This->window->readystate;
5014 return S_OK;
5015 default:
5016 break;
5020 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
5023 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
5025 HTMLDocument *This = impl_from_IDispatchEx(iface);
5027 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
5030 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
5032 HTMLDocument *This = impl_from_IDispatchEx(iface);
5034 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
5037 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
5039 HTMLDocument *This = impl_from_IDispatchEx(iface);
5041 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
5044 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
5046 HTMLDocument *This = impl_from_IDispatchEx(iface);
5048 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
5051 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
5053 HTMLDocument *This = impl_from_IDispatchEx(iface);
5055 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
5058 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
5060 HTMLDocument *This = impl_from_IDispatchEx(iface);
5062 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
5065 static const IDispatchExVtbl DocDispatchExVtbl = {
5066 DocDispatchEx_QueryInterface,
5067 DocDispatchEx_AddRef,
5068 DocDispatchEx_Release,
5069 DocDispatchEx_GetTypeInfoCount,
5070 DocDispatchEx_GetTypeInfo,
5071 DocDispatchEx_GetIDsOfNames,
5072 DocDispatchEx_Invoke,
5073 DocDispatchEx_GetDispID,
5074 DocDispatchEx_InvokeEx,
5075 DocDispatchEx_DeleteMemberByName,
5076 DocDispatchEx_DeleteMemberByDispID,
5077 DocDispatchEx_GetMemberProperties,
5078 DocDispatchEx_GetMemberName,
5079 DocDispatchEx_GetNextDispID,
5080 DocDispatchEx_GetNameSpaceParent
5083 static inline HTMLDocument *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
5085 return CONTAINING_RECORD(iface, HTMLDocument, IProvideMultipleClassInfo_iface);
5088 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
5089 REFIID riid, void **ppv)
5091 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5092 return htmldoc_query_interface(This, riid, ppv);
5095 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
5097 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5098 return htmldoc_addref(This);
5101 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
5103 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5104 return htmldoc_release(This);
5107 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
5109 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5110 TRACE("(%p)->(%p)\n", This, ppTI);
5111 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
5114 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
5116 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5117 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
5118 return E_NOTIMPL;
5121 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
5123 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5124 FIXME("(%p)->(%p)\n", This, pcti);
5125 *pcti = 1;
5126 return S_OK;
5129 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
5130 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
5132 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5133 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
5134 return E_NOTIMPL;
5137 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
5138 ProvideClassInfo_QueryInterface,
5139 ProvideClassInfo_AddRef,
5140 ProvideClassInfo_Release,
5141 ProvideClassInfo_GetClassInfo,
5142 ProvideClassInfo2_GetGUID,
5143 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
5144 ProvideMultipleClassInfo_GetInfoOfIndex
5147 /**********************************************************
5148 * IMarkupServices implementation
5150 static inline HTMLDocument *impl_from_IMarkupServices(IMarkupServices *iface)
5152 return CONTAINING_RECORD(iface, HTMLDocument, IMarkupServices_iface);
5155 static HRESULT WINAPI MarkupServices_QueryInterface(IMarkupServices *iface, REFIID riid, void **ppvObject)
5157 HTMLDocument *This = impl_from_IMarkupServices(iface);
5158 return htmldoc_query_interface(This, riid, ppvObject);
5161 static ULONG WINAPI MarkupServices_AddRef(IMarkupServices *iface)
5163 HTMLDocument *This = impl_from_IMarkupServices(iface);
5164 return htmldoc_addref(This);
5167 static ULONG WINAPI MarkupServices_Release(IMarkupServices *iface)
5169 HTMLDocument *This = impl_from_IMarkupServices(iface);
5170 return htmldoc_release(This);
5173 static HRESULT WINAPI MarkupServices_CreateMarkupPointer(IMarkupServices *iface, IMarkupPointer **ppPointer)
5175 HTMLDocument *This = impl_from_IMarkupServices(iface);
5177 TRACE("(%p)->(%p)\n", This, ppPointer);
5179 return create_markup_pointer(ppPointer);
5182 static HRESULT WINAPI MarkupServices_CreateMarkupContainer(IMarkupServices *iface, IMarkupContainer **ppMarkupContainer)
5184 HTMLDocument *This = impl_from_IMarkupServices(iface);
5185 FIXME("(%p)->(%p)\n", This, ppMarkupContainer);
5186 return E_NOTIMPL;
5189 static HRESULT WINAPI MarkupServices_CreateElement(IMarkupServices *iface,
5190 ELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement)
5192 HTMLDocument *This = impl_from_IMarkupServices(iface);
5193 FIXME("(%p)->(%d,%s,%p)\n", This, tagID, debugstr_w(pchAttributes), ppElement);
5194 return E_NOTIMPL;
5197 static HRESULT WINAPI MarkupServices_CloneElement(IMarkupServices *iface,
5198 IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone)
5200 HTMLDocument *This = impl_from_IMarkupServices(iface);
5201 FIXME("(%p)->(%p,%p)\n", This, pElemCloneThis, ppElementTheClone);
5202 return E_NOTIMPL;
5205 static HRESULT WINAPI MarkupServices_InsertElement(IMarkupServices *iface,
5206 IHTMLElement *pElementInsert, IMarkupPointer *pPointerStart,
5207 IMarkupPointer *pPointerFinish)
5209 HTMLDocument *This = impl_from_IMarkupServices(iface);
5210 FIXME("(%p)->(%p,%p,%p)\n", This, pElementInsert, pPointerStart, pPointerFinish);
5211 return E_NOTIMPL;
5214 static HRESULT WINAPI MarkupServices_RemoveElement(IMarkupServices *iface, IHTMLElement *pElementRemove)
5216 HTMLDocument *This = impl_from_IMarkupServices(iface);
5217 FIXME("(%p)->(%p)\n", This, pElementRemove);
5218 return E_NOTIMPL;
5221 static HRESULT WINAPI MarkupServices_Remove(IMarkupServices *iface,
5222 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5224 HTMLDocument *This = impl_from_IMarkupServices(iface);
5225 FIXME("(%p)->(%p,%p)\n", This, pPointerStart, pPointerFinish);
5226 return E_NOTIMPL;
5229 static HRESULT WINAPI MarkupServices_Copy(IMarkupServices *iface,
5230 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5231 IMarkupPointer *pPointerTarget)
5233 HTMLDocument *This = impl_from_IMarkupServices(iface);
5234 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5235 return E_NOTIMPL;
5238 static HRESULT WINAPI MarkupServices_Move(IMarkupServices *iface,
5239 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5240 IMarkupPointer *pPointerTarget)
5242 HTMLDocument *This = impl_from_IMarkupServices(iface);
5243 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5244 return E_NOTIMPL;
5247 static HRESULT WINAPI MarkupServices_InsertText(IMarkupServices *iface,
5248 OLECHAR *pchText, LONG cch, IMarkupPointer *pPointerTarget)
5250 HTMLDocument *This = impl_from_IMarkupServices(iface);
5251 FIXME("(%p)->(%s,%lx,%p)\n", This, debugstr_w(pchText), cch, pPointerTarget);
5252 return E_NOTIMPL;
5255 static HRESULT WINAPI MarkupServices_ParseString(IMarkupServices *iface,
5256 OLECHAR *pchHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5257 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5259 HTMLDocument *This = impl_from_IMarkupServices(iface);
5260 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(pchHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5261 return E_NOTIMPL;
5264 static HRESULT WINAPI MarkupServices_ParseGlobal(IMarkupServices *iface,
5265 HGLOBAL hglobalHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5266 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5268 HTMLDocument *This = impl_from_IMarkupServices(iface);
5269 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(hglobalHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5270 return E_NOTIMPL;
5273 static HRESULT WINAPI MarkupServices_IsScopedElement(IMarkupServices *iface,
5274 IHTMLElement *pElement, BOOL *pfScoped)
5276 HTMLDocument *This = impl_from_IMarkupServices(iface);
5277 FIXME("(%p)->(%p,%p)\n", This, pElement, pfScoped);
5278 return E_NOTIMPL;
5281 static HRESULT WINAPI MarkupServices_GetElementTagId(IMarkupServices *iface,
5282 IHTMLElement *pElement, ELEMENT_TAG_ID *ptagId)
5284 HTMLDocument *This = impl_from_IMarkupServices(iface);
5285 FIXME("(%p)->(%p,%p)\n", This, pElement, ptagId);
5286 return E_NOTIMPL;
5289 static HRESULT WINAPI MarkupServices_GetTagIDForName(IMarkupServices *iface,
5290 BSTR bstrName, ELEMENT_TAG_ID *ptagId)
5292 HTMLDocument *This = impl_from_IMarkupServices(iface);
5293 FIXME("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), ptagId);
5294 return E_NOTIMPL;
5297 static HRESULT WINAPI MarkupServices_GetNameForTagID(IMarkupServices *iface,
5298 ELEMENT_TAG_ID tagId, BSTR *pbstrName)
5300 HTMLDocument *This = impl_from_IMarkupServices(iface);
5301 FIXME("(%p)->(%d,%p)\n", This, tagId, pbstrName);
5302 return E_NOTIMPL;
5305 static HRESULT WINAPI MarkupServices_MovePointersToRange(IMarkupServices *iface,
5306 IHTMLTxtRange *pIRange, IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5308 HTMLDocument *This = impl_from_IMarkupServices(iface);
5309 FIXME("(%p)->(%p,%p,%p)\n", This, pIRange, pPointerStart, pPointerFinish);
5310 return E_NOTIMPL;
5313 static HRESULT WINAPI MarkupServices_MoveRangeToPointers(IMarkupServices *iface,
5314 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish, IHTMLTxtRange *pIRange)
5316 HTMLDocument *This = impl_from_IMarkupServices(iface);
5317 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerStart, pPointerFinish, pIRange);
5318 return E_NOTIMPL;
5321 static HRESULT WINAPI MarkupServices_BeginUndoUnit(IMarkupServices *iface, OLECHAR *pchTitle)
5323 HTMLDocument *This = impl_from_IMarkupServices(iface);
5324 FIXME("(%p)->(%s)\n", This, debugstr_w(pchTitle));
5325 return E_NOTIMPL;
5328 static HRESULT WINAPI MarkupServices_EndUndoUnit(IMarkupServices *iface)
5330 HTMLDocument *This = impl_from_IMarkupServices(iface);
5331 FIXME("(%p)\n", This);
5332 return E_NOTIMPL;
5335 static const IMarkupServicesVtbl MarkupServicesVtbl = {
5336 MarkupServices_QueryInterface,
5337 MarkupServices_AddRef,
5338 MarkupServices_Release,
5339 MarkupServices_CreateMarkupPointer,
5340 MarkupServices_CreateMarkupContainer,
5341 MarkupServices_CreateElement,
5342 MarkupServices_CloneElement,
5343 MarkupServices_InsertElement,
5344 MarkupServices_RemoveElement,
5345 MarkupServices_Remove,
5346 MarkupServices_Copy,
5347 MarkupServices_Move,
5348 MarkupServices_InsertText,
5349 MarkupServices_ParseString,
5350 MarkupServices_ParseGlobal,
5351 MarkupServices_IsScopedElement,
5352 MarkupServices_GetElementTagId,
5353 MarkupServices_GetTagIDForName,
5354 MarkupServices_GetNameForTagID,
5355 MarkupServices_MovePointersToRange,
5356 MarkupServices_MoveRangeToPointers,
5357 MarkupServices_BeginUndoUnit,
5358 MarkupServices_EndUndoUnit
5361 /**********************************************************
5362 * IMarkupContainer implementation
5364 static inline HTMLDocument *impl_from_IMarkupContainer(IMarkupContainer *iface)
5366 return CONTAINING_RECORD(iface, HTMLDocument, IMarkupContainer_iface);
5369 static HRESULT WINAPI MarkupContainer_QueryInterface(IMarkupContainer *iface, REFIID riid, void **ppvObject)
5371 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5372 return htmldoc_query_interface(This, riid, ppvObject);
5375 static ULONG WINAPI MarkupContainer_AddRef(IMarkupContainer *iface)
5377 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5378 return htmldoc_addref(This);
5381 static ULONG WINAPI MarkupContainer_Release(IMarkupContainer *iface)
5383 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5384 return htmldoc_release(This);
5387 static HRESULT WINAPI MarkupContainer_OwningDoc(IMarkupContainer *iface, IHTMLDocument2 **ppDoc)
5389 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5390 FIXME("(%p)->(%p)\n", This, ppDoc);
5391 return E_NOTIMPL;
5394 static const IMarkupContainerVtbl MarkupContainerVtbl = {
5395 MarkupContainer_QueryInterface,
5396 MarkupContainer_AddRef,
5397 MarkupContainer_Release,
5398 MarkupContainer_OwningDoc
5401 /**********************************************************
5402 * IDisplayServices implementation
5404 static inline HTMLDocument *impl_from_IDisplayServices(IDisplayServices *iface)
5406 return CONTAINING_RECORD(iface, HTMLDocument, IDisplayServices_iface);
5409 static HRESULT WINAPI DisplayServices_QueryInterface(IDisplayServices *iface, REFIID riid, void **ppvObject)
5411 HTMLDocument *This = impl_from_IDisplayServices(iface);
5412 return htmldoc_query_interface(This, riid, ppvObject);
5415 static ULONG WINAPI DisplayServices_AddRef(IDisplayServices *iface)
5417 HTMLDocument *This = impl_from_IDisplayServices(iface);
5418 return htmldoc_addref(This);
5421 static ULONG WINAPI DisplayServices_Release(IDisplayServices *iface)
5423 HTMLDocument *This = impl_from_IDisplayServices(iface);
5424 return htmldoc_release(This);
5427 static HRESULT WINAPI DisplayServices_CreateDisplayPointer(IDisplayServices *iface, IDisplayPointer **ppDispPointer)
5429 HTMLDocument *This = impl_from_IDisplayServices(iface);
5430 FIXME("(%p)->(%p)\n", This, ppDispPointer);
5431 return E_NOTIMPL;
5434 static HRESULT WINAPI DisplayServices_TransformRect(IDisplayServices *iface,
5435 RECT *pRect, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5437 HTMLDocument *This = impl_from_IDisplayServices(iface);
5438 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_rect(pRect), eSource, eDestination, pIElement);
5439 return E_NOTIMPL;
5442 static HRESULT WINAPI DisplayServices_TransformPoint(IDisplayServices *iface,
5443 POINT *pPoint, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5445 HTMLDocument *This = impl_from_IDisplayServices(iface);
5446 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_point(pPoint), eSource, eDestination, pIElement);
5447 return E_NOTIMPL;
5450 static HRESULT WINAPI DisplayServices_GetCaret(IDisplayServices *iface, IHTMLCaret **ppCaret)
5452 HTMLDocument *This = impl_from_IDisplayServices(iface);
5453 FIXME("(%p)->(%p)\n", This, ppCaret);
5454 return E_NOTIMPL;
5457 static HRESULT WINAPI DisplayServices_GetComputedStyle(IDisplayServices *iface,
5458 IMarkupPointer *pPointer, IHTMLComputedStyle **ppComputedStyle)
5460 HTMLDocument *This = impl_from_IDisplayServices(iface);
5461 FIXME("(%p)->(%p,%p)\n", This, pPointer, ppComputedStyle);
5462 return E_NOTIMPL;
5465 static HRESULT WINAPI DisplayServices_ScrollRectIntoView(IDisplayServices *iface,
5466 IHTMLElement *pIElement, RECT rect)
5468 HTMLDocument *This = impl_from_IDisplayServices(iface);
5469 FIXME("(%p)->(%p,%s)\n", This, pIElement, wine_dbgstr_rect(&rect));
5470 return E_NOTIMPL;
5473 static HRESULT WINAPI DisplayServices_HasFlowLayout(IDisplayServices *iface,
5474 IHTMLElement *pIElement, BOOL *pfHasFlowLayout)
5476 HTMLDocument *This = impl_from_IDisplayServices(iface);
5477 FIXME("(%p)->(%p,%p)\n", This, pIElement, pfHasFlowLayout);
5478 return E_NOTIMPL;
5481 static const IDisplayServicesVtbl DisplayServicesVtbl = {
5482 DisplayServices_QueryInterface,
5483 DisplayServices_AddRef,
5484 DisplayServices_Release,
5485 DisplayServices_CreateDisplayPointer,
5486 DisplayServices_TransformRect,
5487 DisplayServices_TransformPoint,
5488 DisplayServices_GetCaret,
5489 DisplayServices_GetComputedStyle,
5490 DisplayServices_ScrollRectIntoView,
5491 DisplayServices_HasFlowLayout
5494 /**********************************************************
5495 * IDocumentRange implementation
5497 static inline HTMLDocument *impl_from_IDocumentRange(IDocumentRange *iface)
5499 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentRange_iface);
5502 static HRESULT WINAPI DocumentRange_QueryInterface(IDocumentRange *iface, REFIID riid, void **ppv)
5504 HTMLDocument *This = impl_from_IDocumentRange(iface);
5506 return htmldoc_query_interface(This, riid, ppv);
5509 static ULONG WINAPI DocumentRange_AddRef(IDocumentRange *iface)
5511 HTMLDocument *This = impl_from_IDocumentRange(iface);
5513 return htmldoc_addref(This);
5516 static ULONG WINAPI DocumentRange_Release(IDocumentRange *iface)
5518 HTMLDocument *This = impl_from_IDocumentRange(iface);
5520 return htmldoc_release(This);
5523 static HRESULT WINAPI DocumentRange_GetTypeInfoCount(IDocumentRange *iface, UINT *pctinfo)
5525 HTMLDocument *This = impl_from_IDocumentRange(iface);
5527 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
5530 static HRESULT WINAPI DocumentRange_GetTypeInfo(IDocumentRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5532 HTMLDocument *This = impl_from_IDocumentRange(iface);
5534 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5537 static HRESULT WINAPI DocumentRange_GetIDsOfNames(IDocumentRange *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5538 LCID lcid, DISPID *rgDispId)
5540 HTMLDocument *This = impl_from_IDocumentRange(iface);
5542 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
5543 rgDispId);
5546 static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
5547 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5549 HTMLDocument *This = impl_from_IDocumentRange(iface);
5551 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5552 pDispParams, pVarResult, pExcepInfo, puArgErr);
5555 static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
5557 HTMLDocument *This = impl_from_IDocumentRange(iface);
5558 nsIDOMRange *nsrange;
5559 HRESULT hres;
5561 TRACE("(%p)->(%p)\n", This, p);
5563 if(!This->doc_node->nsdoc) {
5564 WARN("NULL nsdoc\n");
5565 return E_UNEXPECTED;
5568 if(NS_FAILED(nsIDOMHTMLDocument_CreateRange(This->doc_node->nsdoc, &nsrange)))
5569 return E_FAIL;
5571 hres = create_dom_range(nsrange, dispex_compat_mode(&This->doc_node->node.event_target.dispex), p);
5572 nsIDOMRange_Release(nsrange);
5573 return hres;
5576 static const IDocumentRangeVtbl DocumentRangeVtbl = {
5577 DocumentRange_QueryInterface,
5578 DocumentRange_AddRef,
5579 DocumentRange_Release,
5580 DocumentRange_GetTypeInfoCount,
5581 DocumentRange_GetTypeInfo,
5582 DocumentRange_GetIDsOfNames,
5583 DocumentRange_Invoke,
5584 DocumentRange_createRange,
5587 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
5589 *ppv = NULL;
5591 if(IsEqualGUID(&IID_IUnknown, riid))
5592 *ppv = &This->IHTMLDocument2_iface;
5593 else if(IsEqualGUID(&IID_IDispatch, riid))
5594 *ppv = &This->IDispatchEx_iface;
5595 else if(IsEqualGUID(&IID_IDispatchEx, riid))
5596 *ppv = &This->IDispatchEx_iface;
5597 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
5598 *ppv = &This->IHTMLDocument2_iface;
5599 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
5600 *ppv = &This->IHTMLDocument2_iface;
5601 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
5602 *ppv = &This->IHTMLDocument3_iface;
5603 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
5604 *ppv = &This->IHTMLDocument4_iface;
5605 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
5606 *ppv = &This->IHTMLDocument5_iface;
5607 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
5608 *ppv = &This->IHTMLDocument6_iface;
5609 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
5610 *ppv = &This->IHTMLDocument7_iface;
5611 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
5612 *ppv = &This->IDocumentSelector_iface;
5613 else if(IsEqualGUID(&IID_IDocumentEvent, riid))
5614 *ppv = &This->IDocumentEvent_iface;
5615 else if(IsEqualGUID(&IID_IPersist, riid))
5616 *ppv = &This->IPersistFile_iface;
5617 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
5618 *ppv = &This->IPersistMoniker_iface;
5619 else if(IsEqualGUID(&IID_IPersistFile, riid))
5620 *ppv = &This->IPersistFile_iface;
5621 else if(IsEqualGUID(&IID_IMonikerProp, riid))
5622 *ppv = &This->IMonikerProp_iface;
5623 else if(IsEqualGUID(&IID_IOleObject, riid))
5624 *ppv = &This->IOleObject_iface;
5625 else if(IsEqualGUID(&IID_IOleDocument, riid))
5626 *ppv = &This->IOleDocument_iface;
5627 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
5628 *ppv = &This->IOleInPlaceActiveObject_iface;
5629 else if(IsEqualGUID(&IID_IOleWindow, riid))
5630 *ppv = &This->IOleInPlaceActiveObject_iface;
5631 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
5632 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5633 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
5634 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5635 else if(IsEqualGUID(&IID_IServiceProvider, riid))
5636 *ppv = &This->IServiceProvider_iface;
5637 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
5638 *ppv = &This->IOleCommandTarget_iface;
5639 else if(IsEqualGUID(&IID_IOleControl, riid))
5640 *ppv = &This->IOleControl_iface;
5641 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
5642 *ppv = &This->IHlinkTarget_iface;
5643 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
5644 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5645 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
5646 *ppv = &This->IPersistStreamInit_iface;
5647 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
5648 *ppv = &This->IHTMLDocument2_iface;
5649 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
5650 *ppv = &This->ISupportErrorInfo_iface;
5651 else if(IsEqualGUID(&IID_IPersistHistory, riid))
5652 *ppv = &This->IPersistHistory_iface;
5653 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
5654 *ppv = &This->IObjectWithSite_iface;
5655 else if(IsEqualGUID(&IID_IOleContainer, riid))
5656 *ppv = &This->IOleContainer_iface;
5657 else if(IsEqualGUID(&IID_IObjectSafety, riid))
5658 *ppv = &This->IObjectSafety_iface;
5659 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
5660 *ppv = &This->IProvideMultipleClassInfo_iface;
5661 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
5662 *ppv = &This->IProvideMultipleClassInfo_iface;
5663 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
5664 *ppv = &This->IProvideMultipleClassInfo_iface;
5665 else if(IsEqualGUID(&IID_IMarkupServices, riid))
5666 *ppv = &This->IMarkupServices_iface;
5667 else if(IsEqualGUID(&IID_IMarkupContainer, riid))
5668 *ppv = &This->IMarkupContainer_iface;
5669 else if(IsEqualGUID(&IID_IDisplayServices, riid))
5670 *ppv = &This->IDisplayServices_iface;
5671 else if(IsEqualGUID(&IID_IDocumentRange, riid))
5672 *ppv = &This->IDocumentRange_iface;
5673 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
5674 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
5675 *ppv = NULL;
5676 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
5677 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
5678 *ppv = NULL;
5679 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
5680 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
5681 *ppv = NULL;
5682 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
5683 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
5684 *ppv = NULL;
5685 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
5686 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
5687 *ppv = NULL;
5688 }else {
5689 return FALSE;
5692 if(*ppv)
5693 IUnknown_AddRef((IUnknown*)*ppv);
5694 return TRUE;
5697 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
5698 static cp_static_data_t HTMLDocumentEvents2_data = { HTMLDocumentEvents2_tid, HTMLDocument_on_advise, TRUE };
5700 static const cpc_entry_t HTMLDocument_cpc[] = {
5701 {&IID_IDispatch, &HTMLDocumentEvents_data},
5702 {&IID_IPropertyNotifySink},
5703 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
5704 {&DIID_HTMLDocumentEvents2, &HTMLDocumentEvents2_data},
5705 {NULL}
5708 static void init_doc(HTMLDocument *doc, IUnknown *outer, IDispatchEx *dispex)
5710 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
5711 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
5712 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
5713 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
5714 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
5715 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
5716 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
5717 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
5718 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
5719 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
5720 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
5721 doc->IMarkupServices_iface.lpVtbl = &MarkupServicesVtbl;
5722 doc->IMarkupContainer_iface.lpVtbl = &MarkupContainerVtbl;
5723 doc->IDisplayServices_iface.lpVtbl = &DisplayServicesVtbl;
5724 doc->IDocumentRange_iface.lpVtbl = &DocumentRangeVtbl;
5726 doc->outer_unk = outer;
5727 doc->dispex = dispex;
5729 HTMLDocument_Persist_Init(doc);
5730 HTMLDocument_OleCmd_Init(doc);
5731 HTMLDocument_OleObj_Init(doc);
5732 HTMLDocument_Service_Init(doc);
5734 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
5737 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5739 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
5742 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5744 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5746 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5748 if(htmldoc_qi(&This->basedoc, riid, ppv))
5749 return *ppv ? S_OK : E_NOINTERFACE;
5751 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
5752 *ppv = &This->IInternetHostSecurityManager_iface;
5753 else
5754 return HTMLDOMNode_QI(&This->node, riid, ppv);
5756 IUnknown_AddRef((IUnknown*)*ppv);
5757 return S_OK;
5760 void detach_document_node(HTMLDocumentNode *doc)
5762 unsigned i;
5764 while(!list_empty(&doc->plugin_hosts))
5765 detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
5767 if(doc->dom_implementation) {
5768 detach_dom_implementation(doc->dom_implementation);
5769 IHTMLDOMImplementation_Release(doc->dom_implementation);
5770 doc->dom_implementation = NULL;
5773 if(doc->namespaces) {
5774 IHTMLNamespaceCollection_Release(doc->namespaces);
5775 doc->namespaces = NULL;
5778 detach_events(doc);
5779 detach_selection(doc);
5780 detach_ranges(doc);
5782 for(i=0; i < doc->elem_vars_cnt; i++)
5783 heap_free(doc->elem_vars[i]);
5784 heap_free(doc->elem_vars);
5785 doc->elem_vars_cnt = doc->elem_vars_size = 0;
5786 doc->elem_vars = NULL;
5788 if(doc->catmgr) {
5789 ICatInformation_Release(doc->catmgr);
5790 doc->catmgr = NULL;
5793 if(!doc->nsdoc && doc->window) {
5794 /* document fragments own reference to inner window */
5795 IHTMLWindow2_Release(&doc->window->base.IHTMLWindow2_iface);
5796 doc->window = NULL;
5799 if(doc->browser) {
5800 list_remove(&doc->browser_entry);
5801 doc->browser = NULL;
5805 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
5807 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5809 TRACE("(%p)\n", This);
5811 heap_free(This->event_vector);
5812 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
5815 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5817 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5818 FIXME("%p\n", This);
5819 return E_NOTIMPL;
5822 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
5824 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5826 if(This->nsdoc)
5827 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
5830 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
5832 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5834 if(This->nsdoc) {
5835 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
5837 release_document_mutation(This);
5838 detach_document_node(This);
5839 This->nsdoc = NULL;
5840 nsIDOMHTMLDocument_Release(nsdoc);
5841 This->window = NULL;
5845 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
5846 &CLSID_HTMLDocument,
5847 HTMLDocumentNode_QI,
5848 HTMLDocumentNode_destructor,
5849 HTMLDocument_cpc,
5850 HTMLDocumentNode_clone,
5851 NULL,
5852 NULL,
5853 NULL,
5854 NULL,
5855 NULL,
5856 NULL,
5857 NULL,
5858 NULL,
5859 NULL,
5860 NULL,
5861 NULL,
5862 HTMLDocumentNode_traverse,
5863 HTMLDocumentNode_unlink
5866 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5868 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5869 HTMLDocumentNode *new_node;
5870 HRESULT hres;
5872 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
5873 if(FAILED(hres))
5874 return hres;
5876 *ret = &new_node->node;
5877 return S_OK;
5880 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
5882 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
5885 static HRESULT HTMLDocumentNode_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
5887 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5888 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
5890 if(!This->nsdoc || idx >= This->elem_vars_cnt)
5891 return DISP_E_MEMBERNOTFOUND;
5893 return (*name = SysAllocString(This->elem_vars[idx])) ? S_OK : E_OUTOFMEMORY;
5896 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5897 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5899 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5900 nsIDOMElement *nselem;
5901 HTMLDOMNode *node;
5902 unsigned i;
5903 HRESULT hres;
5905 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET))
5906 return MSHTML_E_INVALID_PROPERTY;
5908 i = id - MSHTML_DISPID_CUSTOM_MIN;
5910 if(!This->nsdoc || i >= This->elem_vars_cnt)
5911 return DISP_E_MEMBERNOTFOUND;
5913 hres = get_elem_by_name_or_id(This->nsdoc, This->elem_vars[i], &nselem);
5914 if(FAILED(hres))
5915 return hres;
5916 if(!nselem)
5917 return DISP_E_MEMBERNOTFOUND;
5919 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
5920 nsIDOMElement_Release(nselem);
5921 if(FAILED(hres))
5922 return hres;
5924 V_VT(res) = VT_DISPATCH;
5925 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5926 return S_OK;
5929 static HRESULT HTMLDocumentNode_next_dispid(DispatchEx *dispex, DISPID id, DISPID *pid)
5931 DWORD idx = (id == DISPID_STARTENUM) ? 0 : id - MSHTML_DISPID_CUSTOM_MIN + 1;
5932 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5933 nsIDOMNodeList *node_list;
5934 const PRUnichar *name;
5935 nsIDOMElement *nselem;
5936 nsIDOMNode *nsnode;
5937 nsAString nsstr;
5938 nsresult nsres;
5939 HRESULT hres;
5940 UINT32 i;
5942 if(!This->nsdoc)
5943 return S_FALSE;
5945 while(idx < This->elem_vars_cnt) {
5946 hres = has_elem_name(This->nsdoc, This->elem_vars[idx]);
5947 if(SUCCEEDED(hres)) {
5948 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
5949 return S_OK;
5951 if(hres != DISP_E_UNKNOWNNAME)
5952 return hres;
5953 idx++;
5956 /* Populate possibly missing DISPIDs */
5957 nsAString_InitDepend(&nsstr, L":-moz-any(applet,embed,form,iframe,img,object)[name]");
5958 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->nsdoc, &nsstr, &node_list);
5959 nsAString_Finish(&nsstr);
5960 if(NS_FAILED(nsres))
5961 return map_nsresult(nsres);
5963 for(i = 0, hres = S_OK; SUCCEEDED(hres); i++) {
5964 nsres = nsIDOMNodeList_Item(node_list, i, &nsnode);
5965 if(NS_FAILED(nsres)) {
5966 hres = map_nsresult(nsres);
5967 break;
5969 if(!nsnode)
5970 break;
5972 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
5973 nsIDOMNode_Release(nsnode);
5974 if(nsres != S_OK)
5975 continue;
5977 nsres = get_elem_attr_value(nselem, L"name", &nsstr, &name);
5978 nsIDOMElement_Release(nselem);
5979 if(NS_FAILED(nsres))
5980 hres = map_nsresult(nsres);
5981 else {
5982 hres = dispid_from_elem_name(This, name, &id);
5983 nsAString_Finish(&nsstr);
5986 nsIDOMNodeList_Release(node_list);
5987 if(FAILED(hres))
5988 return hres;
5990 if(idx >= This->elem_vars_cnt)
5991 return S_FALSE;
5993 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
5994 return S_OK;
5997 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
5999 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6001 TRACE("(%p) returning %u\n", This, This->document_mode);
6003 return lock_document_mode(This);
6006 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
6008 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6009 return (nsISupports*)This->node.nsnode;
6012 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
6014 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6015 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
6018 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
6020 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6021 if(!This->window)
6022 return NULL;
6023 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
6024 return &This->window->event_target;
6027 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
6029 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6030 ConnectionPointContainer *container = This->basedoc.doc_obj
6031 ? &This->basedoc.doc_obj->basedoc.cp_container : &This->basedoc.cp_container;
6032 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
6033 return container;
6036 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6038 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6039 return default_set_current_event(This->window, event);
6042 static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp, VARIANT *res,
6043 EXCEPINFO *ei, IServiceProvider *caller)
6045 return IHTMLDocument2_location_hook(&impl_from_DispatchEx(dispex)->basedoc, flags, dp, res, ei, caller);
6048 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
6050 NULL,
6051 NULL,
6052 HTMLDocumentNode_get_name,
6053 HTMLDocumentNode_invoke,
6054 NULL,
6055 HTMLDocumentNode_next_dispid,
6056 HTMLDocumentNode_get_compat_mode,
6057 NULL
6059 HTMLDocumentNode_get_gecko_target,
6060 HTMLDocumentNode_bind_event,
6061 HTMLDocumentNode_get_parent_event_target,
6062 NULL,
6063 HTMLDocumentNode_get_cp_container,
6064 HTMLDocumentNode_set_current_event
6067 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
6068 &CLSID_HTMLDocument,
6069 HTMLDocumentNode_QI,
6070 HTMLDocumentNode_destructor,
6071 HTMLDocument_cpc,
6072 HTMLDocumentFragment_clone
6075 static const tid_t HTMLDocumentNode_iface_tids[] = {
6076 IHTMLDOMNode_tid,
6077 IHTMLDOMNode2_tid,
6078 IHTMLDocument4_tid,
6079 IHTMLDocument5_tid,
6080 IDocumentSelector_tid,
6084 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6086 static const dispex_hook_t document2_hooks[] = {
6087 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6088 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6089 {DISPID_UNKNOWN}
6091 static const dispex_hook_t document6_ie9_hooks[] = {
6092 {DISPID_IHTMLDOCUMENT6_ONSTORAGE},
6093 {DISPID_UNKNOWN}
6096 HTMLDOMNode_init_dispex_info(info, mode);
6098 if(mode >= COMPAT_MODE_IE9) {
6099 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
6100 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
6103 /* Depending on compatibility version, we add interfaces in different order
6104 * so that the right getElementById implementation is used. */
6105 if(mode < COMPAT_MODE_IE8) {
6106 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
6107 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
6108 }else {
6109 dispex_info_add_interface(info, IHTMLDocument6_tid, mode >= COMPAT_MODE_IE9 ? document6_ie9_hooks : NULL);
6110 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
6112 dispex_info_add_interface(info, IHTMLDocument2_tid, document2_hooks);
6115 static dispex_static_data_t HTMLDocumentNode_dispex = {
6116 L"HTMLDocument",
6117 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
6118 DispHTMLDocument_tid,
6119 HTMLDocumentNode_iface_tids,
6120 HTMLDocumentNode_init_dispex_info
6123 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
6125 HTMLDocumentNode *doc;
6127 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
6128 if(!doc)
6129 return NULL;
6131 doc->ref = 1;
6132 doc->basedoc.doc_node = doc;
6133 doc->basedoc.doc_obj = doc_obj;
6134 doc->basedoc.window = window ? window->base.outer_window : NULL;
6135 doc->window = window;
6137 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
6138 &doc->node.event_target.dispex.IDispatchEx_iface);
6139 HTMLDocumentNode_SecMgr_Init(doc);
6141 list_init(&doc->selection_list);
6142 list_init(&doc->range_list);
6143 list_init(&doc->plugin_hosts);
6145 return doc;
6148 HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
6149 compat_mode_t parent_mode, HTMLDocumentNode **ret)
6151 HTMLDocumentObj *doc_obj = browser->doc;
6152 HTMLDocumentNode *doc;
6154 doc = alloc_doc_node(doc_obj, window);
6155 if(!doc)
6156 return E_OUTOFMEMORY;
6158 if(parent_mode >= COMPAT_MODE_IE9) {
6159 TRACE("using parent mode %u\n", parent_mode);
6160 doc->document_mode = parent_mode;
6161 lock_document_mode(doc);
6164 if(!doc_obj->basedoc.window || (window && is_main_content_window(window->base.outer_window)))
6165 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
6167 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc, &HTMLDocumentNode_dispex);
6169 nsIDOMHTMLDocument_AddRef(nsdoc);
6170 doc->nsdoc = nsdoc;
6172 init_document_mutation(doc);
6173 doc_init_events(doc);
6175 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
6177 list_add_head(&browser->document_nodes, &doc->browser_entry);
6178 doc->browser = browser;
6180 if(browser->usermode == EDITMODE) {
6181 nsAString mode_str;
6182 nsresult nsres;
6184 nsAString_InitDepend(&mode_str, L"on");
6185 nsres = nsIDOMHTMLDocument_SetDesignMode(doc->nsdoc, &mode_str);
6186 nsAString_Finish(&mode_str);
6187 if(NS_FAILED(nsres))
6188 ERR("SetDesignMode failed: %08lx\n", nsres);
6191 *ret = doc;
6192 return S_OK;
6195 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
6197 HTMLDocumentNode *doc_frag;
6199 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
6200 if(!doc_frag)
6201 return E_OUTOFMEMORY;
6203 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
6205 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
6206 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
6207 doc_frag->document_mode = lock_document_mode(doc_node);
6209 *ret = doc_frag;
6210 return S_OK;
6213 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
6215 HTMLDOMNode *node;
6216 HRESULT hres;
6218 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
6219 if(FAILED(hres))
6220 return hres;
6222 if(!node) {
6223 ERR("document not initialized\n");
6224 return E_FAIL;
6227 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
6228 *ret = impl_from_HTMLDOMNode(node);
6229 return S_OK;
6232 static inline HTMLDocumentObj *impl_from_IUnknown(IUnknown *iface)
6234 return CONTAINING_RECORD(iface, HTMLDocumentObj, IUnknown_inner);
6237 static HRESULT WINAPI HTMLDocumentObj_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
6239 HTMLDocumentObj *This = impl_from_IUnknown(iface);
6241 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
6243 if(IsEqualGUID(&IID_IUnknown, riid)) {
6244 *ppv = &This->IUnknown_inner;
6245 }else if(htmldoc_qi(&This->basedoc, riid, ppv)) {
6246 return *ppv ? S_OK : E_NOINTERFACE;
6247 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
6248 *ppv = &This->ICustomDoc_iface;
6249 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
6250 *ppv = &This->IOleDocumentView_iface;
6251 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
6252 *ppv = &This->IViewObjectEx_iface;
6253 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
6254 *ppv = &This->IViewObjectEx_iface;
6255 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
6256 *ppv = &This->IViewObjectEx_iface;
6257 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
6258 *ppv = &This->ITargetContainer_iface;
6259 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
6260 return *ppv ? S_OK : E_NOINTERFACE;
6261 }else {
6262 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
6263 *ppv = NULL;
6264 return E_NOINTERFACE;
6267 IUnknown_AddRef((IUnknown*)*ppv);
6268 return S_OK;
6271 static ULONG WINAPI HTMLDocumentObj_AddRef(IUnknown *iface)
6273 HTMLDocumentObj *This = impl_from_IUnknown(iface);
6274 ULONG ref = InterlockedIncrement(&This->ref);
6276 TRACE("(%p) ref = %lu\n", This, ref);
6278 return ref;
6281 static ULONG WINAPI HTMLDocumentObj_Release(IUnknown *iface)
6283 HTMLDocumentObj *This = impl_from_IUnknown(iface);
6284 ULONG ref = InterlockedDecrement(&This->ref);
6286 TRACE("(%p) ref = %lu\n", This, ref);
6288 if(!ref) {
6289 if(This->basedoc.doc_node) {
6290 This->basedoc.doc_node->basedoc.doc_obj = NULL;
6291 htmldoc_release(&This->basedoc.doc_node->basedoc);
6293 if(This->basedoc.window)
6294 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
6295 if(This->advise_holder)
6296 IOleAdviseHolder_Release(This->advise_holder);
6298 if(This->view_sink)
6299 IAdviseSink_Release(This->view_sink);
6300 if(This->client)
6301 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
6302 if(This->hostui)
6303 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
6304 if(This->in_place_active)
6305 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
6306 if(This->ipsite)
6307 IOleDocumentView_SetInPlaceSite(&This->IOleDocumentView_iface, NULL);
6308 if(This->undomgr)
6309 IOleUndoManager_Release(This->undomgr);
6310 if(This->editsvcs)
6311 IHTMLEditServices_Release(This->editsvcs);
6312 if(This->tooltips_hwnd)
6313 DestroyWindow(This->tooltips_hwnd);
6315 if(This->hwnd)
6316 DestroyWindow(This->hwnd);
6317 heap_free(This->mime);
6319 remove_target_tasks(This->task_magic);
6320 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
6321 release_dispex(&This->dispex);
6323 if(This->nscontainer)
6324 detach_gecko_browser(This->nscontainer);
6325 heap_free(This);
6328 return ref;
6331 static const IUnknownVtbl HTMLDocumentObjVtbl = {
6332 HTMLDocumentObj_QueryInterface,
6333 HTMLDocumentObj_AddRef,
6334 HTMLDocumentObj_Release
6337 /**********************************************************
6338 * ICustomDoc implementation
6341 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
6343 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
6346 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
6348 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
6350 return htmldoc_query_interface(&This->basedoc, riid, ppv);
6353 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
6355 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
6357 return htmldoc_addref(&This->basedoc);
6360 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
6362 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
6364 return htmldoc_release(&This->basedoc);
6367 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
6369 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
6370 IOleCommandTarget *cmdtrg;
6371 HRESULT hres;
6373 TRACE("(%p)->(%p)\n", This, pUIHandler);
6375 if(This->custom_hostui && This->hostui == pUIHandler)
6376 return S_OK;
6378 This->custom_hostui = TRUE;
6380 if(This->hostui)
6381 IDocHostUIHandler_Release(This->hostui);
6382 if(pUIHandler)
6383 IDocHostUIHandler_AddRef(pUIHandler);
6384 This->hostui = pUIHandler;
6385 if(!pUIHandler)
6386 return S_OK;
6388 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
6389 if(SUCCEEDED(hres)) {
6390 FIXME("custom UI handler supports IOleCommandTarget\n");
6391 IOleCommandTarget_Release(cmdtrg);
6394 return S_OK;
6397 static const ICustomDocVtbl CustomDocVtbl = {
6398 CustomDoc_QueryInterface,
6399 CustomDoc_AddRef,
6400 CustomDoc_Release,
6401 CustomDoc_SetUIHandler
6404 static HRESULT HTMLDocumentObj_location_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp, VARIANT *res,
6405 EXCEPINFO *ei, IServiceProvider *caller)
6407 return IHTMLDocument2_location_hook(&CONTAINING_RECORD(dispex, HTMLDocumentObj, dispex)->basedoc, flags, dp, res, ei, caller);
6410 static const tid_t HTMLDocumentObj_iface_tids[] = {
6411 IHTMLDocument3_tid,
6412 IHTMLDocument4_tid,
6413 IHTMLDocument5_tid,
6417 static void HTMLDocumentObj_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6419 static const dispex_hook_t document2_hooks[] = {
6420 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6421 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentObj_location_hook},
6422 {DISPID_UNKNOWN}
6424 dispex_info_add_interface(info, IHTMLDocument2_tid, document2_hooks);
6427 static dispex_static_data_t HTMLDocumentObj_dispex = {
6428 L"HTMLDocumentObj",
6429 NULL,
6430 DispHTMLDocument_tid,
6431 HTMLDocumentObj_iface_tids,
6432 HTMLDocumentObj_init_dispex_info
6435 static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID riid, void **ppv)
6437 HTMLDocumentObj *doc;
6438 HRESULT hres;
6440 if(outer && !IsEqualGUID(&IID_IUnknown, riid)) {
6441 *ppv = NULL;
6442 return E_INVALIDARG;
6445 /* ensure that security manager is initialized */
6446 if(!get_security_manager())
6447 return E_OUTOFMEMORY;
6449 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
6450 if(!doc)
6451 return E_OUTOFMEMORY;
6453 doc->ref = 1;
6454 doc->IUnknown_inner.lpVtbl = &HTMLDocumentObjVtbl;
6455 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
6457 doc->basedoc.doc_obj = doc;
6459 init_dispatch(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex, COMPAT_MODE_QUIRKS);
6460 init_doc(&doc->basedoc, outer ? outer : &doc->IUnknown_inner, &doc->dispex.IDispatchEx_iface);
6461 TargetContainer_Init(doc);
6462 doc->is_mhtml = is_mhtml;
6464 doc->task_magic = get_task_target_magic();
6466 HTMLDocument_View_Init(doc);
6468 hres = create_gecko_browser(doc, &doc->nscontainer);
6469 if(FAILED(hres)) {
6470 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
6471 htmldoc_release(&doc->basedoc);
6472 return hres;
6475 if(IsEqualGUID(&IID_IUnknown, riid)) {
6476 *ppv = &doc->IUnknown_inner;
6477 }else {
6478 hres = htmldoc_query_interface(&doc->basedoc, riid, ppv);
6479 htmldoc_release(&doc->basedoc);
6480 if(FAILED(hres))
6481 return hres;
6484 doc->basedoc.window = doc->nscontainer->content_window;
6485 IHTMLWindow2_AddRef(&doc->basedoc.window->base.IHTMLWindow2_iface);
6487 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
6488 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
6489 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
6492 get_thread_hwnd();
6494 return S_OK;
6497 HRESULT HTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
6499 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
6500 return create_document_object(FALSE, outer, riid, ppv);
6503 HRESULT MHTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
6505 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
6506 return create_document_object(TRUE, outer, riid, ppv);