mshtml: Return DISP_E_MEMBERNOTFOUND when not finding member by DISPID.
[wine.git] / dlls / mshtml / htmldoc.c
blobe7074952983eca7b2b16aa2385b8fec03ff39af1
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);
3426 FIXME("(%p)->(%p)\n", This, p);
3427 return E_NOTIMPL;
3430 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3432 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3433 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3434 return E_NOTIMPL;
3437 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3438 VARIANT *p)
3440 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3441 FIXME("(%p)->(%p)\n", This, p);
3442 return E_NOTIMPL;
3445 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3447 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3448 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3449 return E_NOTIMPL;
3452 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3453 BSTR bstrId, IHTMLElement2 **p)
3455 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3456 nsIDOMElement *nselem;
3457 HTMLElement *elem;
3458 nsAString nsstr;
3459 nsresult nsres;
3460 HRESULT hres;
3462 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3465 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3466 * not search for name attributes, so we may simply let Gecko do the right thing.
3469 if(!This->doc_node->nsdoc) {
3470 FIXME("Not a document\n");
3471 return E_FAIL;
3474 nsAString_InitDepend(&nsstr, bstrId);
3475 nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &nsstr, &nselem);
3476 nsAString_Finish(&nsstr);
3477 if(NS_FAILED(nsres)) {
3478 ERR("GetElementById failed: %08lx\n", nsres);
3479 return E_FAIL;
3482 if(!nselem) {
3483 *p = NULL;
3484 return S_OK;
3487 hres = get_element(nselem, &elem);
3488 nsIDOMElement_Release(nselem);
3489 if(FAILED(hres))
3490 return hres;
3492 *p = &elem->IHTMLElement2_iface;
3493 return S_OK;
3496 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3498 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3499 FIXME("(%p)->()\n", This);
3500 return E_NOTIMPL;
3503 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3504 HTMLDocument6_QueryInterface,
3505 HTMLDocument6_AddRef,
3506 HTMLDocument6_Release,
3507 HTMLDocument6_GetTypeInfoCount,
3508 HTMLDocument6_GetTypeInfo,
3509 HTMLDocument6_GetIDsOfNames,
3510 HTMLDocument6_Invoke,
3511 HTMLDocument6_get_compatible,
3512 HTMLDocument6_get_documentMode,
3513 HTMLDocument6_put_onstorage,
3514 HTMLDocument6_get_onstorage,
3515 HTMLDocument6_put_onstoragecommit,
3516 HTMLDocument6_get_onstoragecommit,
3517 HTMLDocument6_getElementById,
3518 HTMLDocument6_updateSettings
3521 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3523 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3526 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3528 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3529 return htmldoc_query_interface(This, riid, ppv);
3532 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3534 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3535 return htmldoc_addref(This);
3538 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3540 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3541 return htmldoc_release(This);
3544 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3546 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3547 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3550 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3551 LCID lcid, ITypeInfo **ppTInfo)
3553 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3554 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3557 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3558 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3560 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3561 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3562 rgDispId);
3565 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3566 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3567 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3569 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3570 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3571 pDispParams, pVarResult, pExcepInfo, puArgErr);
3574 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3576 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface)->doc_node;
3578 TRACE("(%p)->(%p)\n", This, p);
3580 if(This->window && This->window->base.outer_window) {
3581 *p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
3582 IHTMLWindow2_AddRef(*p);
3583 }else {
3584 *p = NULL;
3586 return S_OK;
3589 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3591 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3592 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3593 return E_NOTIMPL;
3596 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3598 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3599 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3600 return E_NOTIMPL;
3603 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3604 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3606 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3607 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3608 return E_NOTIMPL;
3611 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3613 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3614 nsIDOMElement *dom_element;
3615 HTMLElement *element;
3616 nsAString ns, tag;
3617 nsresult nsres;
3618 HRESULT hres;
3620 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3622 if(!This->doc_node->nsdoc) {
3623 FIXME("NULL nsdoc\n");
3624 return E_FAIL;
3627 if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
3628 FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
3630 nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
3631 nsAString_InitDepend(&tag, bstrTag);
3632 nsres = nsIDOMHTMLDocument_CreateElementNS(This->doc_node->nsdoc, &ns, &tag, &dom_element);
3633 nsAString_Finish(&ns);
3634 nsAString_Finish(&tag);
3635 if(NS_FAILED(nsres)) {
3636 WARN("CreateElementNS failed: %08lx\n", nsres);
3637 return map_nsresult(nsres);
3640 hres = HTMLElement_Create(This->doc_node, (nsIDOMNode*)dom_element, FALSE, &element);
3641 nsIDOMElement_Release(dom_element);
3642 if(FAILED(hres))
3643 return hres;
3645 *newElem = &element->IHTMLElement_iface;
3646 return S_OK;
3649 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3650 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3652 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3653 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3654 return E_NOTIMPL;
3657 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3659 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3660 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3661 return E_NOTIMPL;
3664 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3666 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3668 TRACE("(%p)->(%p)\n", This, p);
3670 return get_doc_event(This, EVENTID_MSTHUMBNAILCLICK, p);
3673 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3675 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3676 nsAString charset_str;
3677 nsresult nsres;
3679 TRACE("(%p)->(%p)\n", This, p);
3681 if(!This->doc_node->nsdoc) {
3682 FIXME("NULL nsdoc\n");
3683 return E_FAIL;
3686 nsAString_Init(&charset_str, NULL);
3687 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
3688 return return_nsstr(nsres, &charset_str, p);
3691 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3693 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3695 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3697 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3700 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3702 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3704 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3706 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3709 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3711 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3712 nsIDOMNodeList *nslist;
3713 nsAString nsstr;
3714 nsresult nsres;
3716 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3718 if(!This->doc_node->nsdoc) {
3719 FIXME("NULL nsdoc not supported\n");
3720 return E_NOTIMPL;
3723 nsAString_InitDepend(&nsstr, v);
3724 nsres = nsIDOMHTMLDocument_GetElementsByClassName(This->doc_node->nsdoc, &nsstr, &nslist);
3725 nsAString_Finish(&nsstr);
3726 if(FAILED(nsres)) {
3727 ERR("GetElementByClassName failed: %08lx\n", nsres);
3728 return E_FAIL;
3732 *pel = create_collection_from_nodelist(nslist, This->doc_node->document_mode);
3733 nsIDOMNodeList_Release(nslist);
3734 return S_OK;
3737 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3738 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3740 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3741 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3742 return E_NOTIMPL;
3745 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3747 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3748 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3749 return E_NOTIMPL;
3752 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3754 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3755 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3756 return E_NOTIMPL;
3759 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3761 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3762 FIXME("(%p)->(%p)\n", This, p);
3763 return E_NOTIMPL;
3766 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3768 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3770 TRACE("(%p)->(%p)\n", This, p);
3772 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3775 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3777 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3778 FIXME("(%p)->(%p)\n", This, p);
3779 return E_NOTIMPL;
3782 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3784 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3785 FIXME("(%p)->(%p)\n", This, p);
3786 return E_NOTIMPL;
3789 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3791 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3792 FIXME("(%p)->(%x)\n", This, v);
3793 return E_NOTIMPL;
3796 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3798 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3799 FIXME("(%p)->(%p)\n", This, p);
3800 return E_NOTIMPL;
3803 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3805 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3806 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3807 return E_NOTIMPL;
3810 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3812 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3813 FIXME("(%p)->(%p)\n", This, p);
3814 return E_NOTIMPL;
3817 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3819 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3820 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3821 return E_NOTIMPL;
3824 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3826 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3828 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3830 return set_doc_event(This, EVENTID_ABORT, &v);
3833 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3835 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3837 TRACE("(%p)->(%p)\n", This, p);
3839 return get_doc_event(This, EVENTID_ABORT, p);
3842 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3844 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3846 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3848 return set_doc_event(This, EVENTID_BLUR, &v);
3851 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3853 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3855 TRACE("(%p)->(%p)\n", This, p);
3857 return get_doc_event(This, EVENTID_BLUR, p);
3860 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3862 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3863 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3864 return E_NOTIMPL;
3867 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3869 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3870 FIXME("(%p)->(%p)\n", This, p);
3871 return E_NOTIMPL;
3874 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3876 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3877 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3878 return E_NOTIMPL;
3881 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3883 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3884 FIXME("(%p)->(%p)\n", This, p);
3885 return E_NOTIMPL;
3888 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3890 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3892 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3894 return set_doc_event(This, EVENTID_CHANGE, &v);
3897 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3899 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3901 TRACE("(%p)->(%p)\n", This, p);
3903 return get_doc_event(This, EVENTID_CHANGE, p);
3906 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3908 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3910 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3912 return set_doc_event(This, EVENTID_DRAG, &v);
3915 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3917 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3919 TRACE("(%p)->(%p)\n", This, p);
3921 return get_doc_event(This, EVENTID_DRAG, p);
3924 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3926 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3927 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3928 return E_NOTIMPL;
3931 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3933 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3934 FIXME("(%p)->(%p)\n", This, p);
3935 return E_NOTIMPL;
3938 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3940 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3941 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3942 return E_NOTIMPL;
3945 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3947 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3948 FIXME("(%p)->(%p)\n", This, p);
3949 return E_NOTIMPL;
3952 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3954 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3955 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3956 return E_NOTIMPL;
3959 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3961 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3962 FIXME("(%p)->(%p)\n", This, p);
3963 return E_NOTIMPL;
3966 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3968 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3969 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3970 return E_NOTIMPL;
3973 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3975 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3976 FIXME("(%p)->(%p)\n", This, p);
3977 return E_NOTIMPL;
3980 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3982 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3983 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3984 return E_NOTIMPL;
3987 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3989 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3990 FIXME("(%p)->(%p)\n", This, p);
3991 return E_NOTIMPL;
3994 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3996 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3997 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3998 return E_NOTIMPL;
4001 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
4003 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4004 FIXME("(%p)->(%p)\n", This, p);
4005 return E_NOTIMPL;
4008 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
4010 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4011 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4012 return E_NOTIMPL;
4015 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
4017 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4018 FIXME("(%p)->(%p)\n", This, p);
4019 return E_NOTIMPL;
4022 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
4024 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4025 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4026 return E_NOTIMPL;
4029 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
4031 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4032 FIXME("(%p)->(%p)\n", This, p);
4033 return E_NOTIMPL;
4036 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
4038 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4040 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4042 return set_doc_event(This, EVENTID_ERROR, &v);
4045 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
4047 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4049 TRACE("(%p)->(%p)\n", This, p);
4051 return get_doc_event(This, EVENTID_ERROR, p);
4054 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
4056 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4058 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4060 return set_doc_event(This, EVENTID_FOCUS, &v);
4063 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
4065 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4067 TRACE("(%p)->(%p)\n", This, p);
4069 return get_doc_event(This, EVENTID_FOCUS, p);
4072 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
4074 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4076 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4078 return set_doc_event(This, EVENTID_INPUT, &v);
4081 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
4083 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4085 TRACE("(%p)->(%p)\n", This, p);
4087 return get_doc_event(This, EVENTID_INPUT, p);
4090 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
4092 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4094 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4096 return set_doc_event(This, EVENTID_LOAD, &v);
4099 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
4101 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4103 TRACE("(%p)->(%p)\n", This, p);
4105 return get_doc_event(This, EVENTID_LOAD, p);
4108 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
4110 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4111 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4112 return E_NOTIMPL;
4115 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
4117 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4118 FIXME("(%p)->(%p)\n", This, p);
4119 return E_NOTIMPL;
4122 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
4124 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4125 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4126 return E_NOTIMPL;
4129 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
4131 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4132 FIXME("(%p)->(%p)\n", This, p);
4133 return E_NOTIMPL;
4136 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
4138 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4139 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4140 return E_NOTIMPL;
4143 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
4145 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4146 FIXME("(%p)->(%p)\n", This, p);
4147 return E_NOTIMPL;
4150 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
4152 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4153 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4154 return E_NOTIMPL;
4157 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
4159 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4160 FIXME("(%p)->(%p)\n", This, p);
4161 return E_NOTIMPL;
4164 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
4166 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4167 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4168 return E_NOTIMPL;
4171 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
4173 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4174 FIXME("(%p)->(%p)\n", This, p);
4175 return E_NOTIMPL;
4178 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
4180 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4181 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4182 return E_NOTIMPL;
4185 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
4187 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4188 FIXME("(%p)->(%p)\n", This, p);
4189 return E_NOTIMPL;
4192 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
4194 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4195 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4196 return E_NOTIMPL;
4199 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
4201 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4202 FIXME("(%p)->(%p)\n", This, p);
4203 return E_NOTIMPL;
4206 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
4208 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4209 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4210 return E_NOTIMPL;
4213 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
4215 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4216 FIXME("(%p)->(%p)\n", This, p);
4217 return E_NOTIMPL;
4220 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
4222 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4223 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4224 return E_NOTIMPL;
4227 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
4229 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4230 FIXME("(%p)->(%p)\n", This, p);
4231 return E_NOTIMPL;
4234 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
4236 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4238 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4240 return set_doc_event(This, EVENTID_SCROLL, &v);
4243 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
4245 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4247 TRACE("(%p)->(%p)\n", This, p);
4249 return get_doc_event(This, EVENTID_SCROLL, p);
4252 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
4254 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4255 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4256 return E_NOTIMPL;
4259 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
4261 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4262 FIXME("(%p)->(%p)\n", This, p);
4263 return E_NOTIMPL;
4266 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
4268 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4269 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4270 return E_NOTIMPL;
4273 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
4275 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4276 FIXME("(%p)->(%p)\n", This, p);
4277 return E_NOTIMPL;
4280 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
4282 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4283 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4284 return E_NOTIMPL;
4287 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
4289 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4290 FIXME("(%p)->(%p)\n", This, p);
4291 return E_NOTIMPL;
4294 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
4296 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4297 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4298 return E_NOTIMPL;
4301 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
4303 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4304 FIXME("(%p)->(%p)\n", This, p);
4305 return E_NOTIMPL;
4308 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
4310 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4312 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4314 return set_doc_event(This, EVENTID_SUBMIT, &v);
4317 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
4319 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4321 TRACE("(%p)->(%p)\n", This, p);
4323 return get_doc_event(This, EVENTID_SUBMIT, p);
4326 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
4328 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4329 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4330 return E_NOTIMPL;
4333 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
4335 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4336 FIXME("(%p)->(%p)\n", This, p);
4337 return E_NOTIMPL;
4340 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
4342 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4343 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4344 return E_NOTIMPL;
4347 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
4349 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4350 FIXME("(%p)->(%p)\n", This, p);
4351 return E_NOTIMPL;
4354 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
4356 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4357 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4358 return E_NOTIMPL;
4361 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4363 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4364 FIXME("(%p)->(%p)\n", This, p);
4365 return E_NOTIMPL;
4368 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4370 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4371 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4372 return E_NOTIMPL;
4375 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4377 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4378 FIXME("(%p)->(%p)\n", This, p);
4379 return E_NOTIMPL;
4382 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4384 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4385 FIXME("(%p)\n", This);
4386 return E_NOTIMPL;
4389 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4390 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4392 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4393 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4394 return E_NOTIMPL;
4397 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4399 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4401 TRACE("(%p)->(%p)\n", This, p);
4403 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4406 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4408 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4409 FIXME("(%p)->(%p)\n", This, v);
4410 return E_NOTIMPL;
4413 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4415 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4417 TRACE("(%p)->(%p)\n", This, p);
4419 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4422 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4424 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4425 nsIDOMHTMLHeadElement *nshead;
4426 nsIDOMElement *nselem;
4427 HTMLElement *elem;
4428 nsresult nsres;
4429 HRESULT hres;
4431 TRACE("(%p)->(%p)\n", This, p);
4433 if(!This->doc_node->nsdoc) {
4434 FIXME("No document\n");
4435 return E_FAIL;
4438 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &nshead);
4439 assert(nsres == NS_OK);
4441 if(!nshead) {
4442 *p = NULL;
4443 return S_OK;
4446 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4447 nsIDOMHTMLHeadElement_Release(nshead);
4448 assert(nsres == NS_OK);
4450 hres = get_element(nselem, &elem);
4451 nsIDOMElement_Release(nselem);
4452 if(FAILED(hres))
4453 return hres;
4455 *p = &elem->IHTMLElement_iface;
4456 return S_OK;
4459 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4460 HTMLDocument7_QueryInterface,
4461 HTMLDocument7_AddRef,
4462 HTMLDocument7_Release,
4463 HTMLDocument7_GetTypeInfoCount,
4464 HTMLDocument7_GetTypeInfo,
4465 HTMLDocument7_GetIDsOfNames,
4466 HTMLDocument7_Invoke,
4467 HTMLDocument7_get_defaultView,
4468 HTMLDocument7_createCDATASection,
4469 HTMLDocument7_getSelection,
4470 HTMLDocument7_getElementsByTagNameNS,
4471 HTMLDocument7_createElementNS,
4472 HTMLDocument7_createAttributeNS,
4473 HTMLDocument7_put_onmsthumbnailclick,
4474 HTMLDocument7_get_onmsthumbnailclick,
4475 HTMLDocument7_get_characterSet,
4476 HTMLDocument7_createElement,
4477 HTMLDocument7_createAttribute,
4478 HTMLDocument7_getElementsByClassName,
4479 HTMLDocument7_createProcessingInstruction,
4480 HTMLDocument7_adoptNode,
4481 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4482 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4483 HTMLDocument7_get_all,
4484 HTMLDocument7_get_inputEncoding,
4485 HTMLDocument7_get_xmlEncoding,
4486 HTMLDocument7_put_xmlStandalone,
4487 HTMLDocument7_get_xmlStandalone,
4488 HTMLDocument7_put_xmlVersion,
4489 HTMLDocument7_get_xmlVersion,
4490 HTMLDocument7_hasAttributes,
4491 HTMLDocument7_put_onabort,
4492 HTMLDocument7_get_onabort,
4493 HTMLDocument7_put_onblur,
4494 HTMLDocument7_get_onblur,
4495 HTMLDocument7_put_oncanplay,
4496 HTMLDocument7_get_oncanplay,
4497 HTMLDocument7_put_oncanplaythrough,
4498 HTMLDocument7_get_oncanplaythrough,
4499 HTMLDocument7_put_onchange,
4500 HTMLDocument7_get_onchange,
4501 HTMLDocument7_put_ondrag,
4502 HTMLDocument7_get_ondrag,
4503 HTMLDocument7_put_ondragend,
4504 HTMLDocument7_get_ondragend,
4505 HTMLDocument7_put_ondragenter,
4506 HTMLDocument7_get_ondragenter,
4507 HTMLDocument7_put_ondragleave,
4508 HTMLDocument7_get_ondragleave,
4509 HTMLDocument7_put_ondragover,
4510 HTMLDocument7_get_ondragover,
4511 HTMLDocument7_put_ondrop,
4512 HTMLDocument7_get_ondrop,
4513 HTMLDocument7_put_ondurationchange,
4514 HTMLDocument7_get_ondurationchange,
4515 HTMLDocument7_put_onemptied,
4516 HTMLDocument7_get_onemptied,
4517 HTMLDocument7_put_onended,
4518 HTMLDocument7_get_onended,
4519 HTMLDocument7_put_onerror,
4520 HTMLDocument7_get_onerror,
4521 HTMLDocument7_put_onfocus,
4522 HTMLDocument7_get_onfocus,
4523 HTMLDocument7_put_oninput,
4524 HTMLDocument7_get_oninput,
4525 HTMLDocument7_put_onload,
4526 HTMLDocument7_get_onload,
4527 HTMLDocument7_put_onloadeddata,
4528 HTMLDocument7_get_onloadeddata,
4529 HTMLDocument7_put_onloadedmetadata,
4530 HTMLDocument7_get_onloadedmetadata,
4531 HTMLDocument7_put_onloadstart,
4532 HTMLDocument7_get_onloadstart,
4533 HTMLDocument7_put_onpause,
4534 HTMLDocument7_get_onpause,
4535 HTMLDocument7_put_onplay,
4536 HTMLDocument7_get_onplay,
4537 HTMLDocument7_put_onplaying,
4538 HTMLDocument7_get_onplaying,
4539 HTMLDocument7_put_onprogress,
4540 HTMLDocument7_get_onprogress,
4541 HTMLDocument7_put_onratechange,
4542 HTMLDocument7_get_onratechange,
4543 HTMLDocument7_put_onreset,
4544 HTMLDocument7_get_onreset,
4545 HTMLDocument7_put_onscroll,
4546 HTMLDocument7_get_onscroll,
4547 HTMLDocument7_put_onseekend,
4548 HTMLDocument7_get_onseekend,
4549 HTMLDocument7_put_onseeking,
4550 HTMLDocument7_get_onseeking,
4551 HTMLDocument7_put_onselect,
4552 HTMLDocument7_get_onselect,
4553 HTMLDocument7_put_onstalled,
4554 HTMLDocument7_get_onstalled,
4555 HTMLDocument7_put_onsubmit,
4556 HTMLDocument7_get_onsubmit,
4557 HTMLDocument7_put_onsuspend,
4558 HTMLDocument7_get_onsuspend,
4559 HTMLDocument7_put_ontimeupdate,
4560 HTMLDocument7_get_ontimeupdate,
4561 HTMLDocument7_put_onvolumechange,
4562 HTMLDocument7_get_onvolumechange,
4563 HTMLDocument7_put_onwaiting,
4564 HTMLDocument7_get_onwaiting,
4565 HTMLDocument7_normalize,
4566 HTMLDocument7_importNode,
4567 HTMLDocument7_get_parentWindow,
4568 HTMLDocument7_put_body,
4569 HTMLDocument7_get_body,
4570 HTMLDocument7_get_head
4573 static inline HTMLDocument *impl_from_IDocumentSelector(IDocumentSelector *iface)
4575 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentSelector_iface);
4578 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4580 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4581 return htmldoc_query_interface(This, riid, ppv);
4584 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4586 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4587 return htmldoc_addref(This);
4590 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4592 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4593 return htmldoc_release(This);
4596 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4598 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4599 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4602 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4603 LCID lcid, ITypeInfo **ppTInfo)
4605 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4606 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4609 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4610 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4612 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4613 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4614 rgDispId);
4617 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4618 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4620 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4621 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4622 pDispParams, pVarResult, pExcepInfo, puArgErr);
4625 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4627 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4628 nsIDOMElement *nselem;
4629 HTMLElement *elem;
4630 nsAString nsstr;
4631 nsresult nsres;
4632 HRESULT hres;
4634 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4636 nsAString_InitDepend(&nsstr, v);
4637 nsres = nsIDOMHTMLDocument_QuerySelector(This->doc_node->nsdoc, &nsstr, &nselem);
4638 nsAString_Finish(&nsstr);
4639 if(NS_FAILED(nsres)) {
4640 ERR("QuerySelector failed: %08lx\n", nsres);
4641 return E_FAIL;
4644 if(!nselem) {
4645 *pel = NULL;
4646 return S_OK;
4649 hres = get_element(nselem, &elem);
4650 nsIDOMElement_Release(nselem);
4651 if(FAILED(hres))
4652 return hres;
4654 *pel = &elem->IHTMLElement_iface;
4655 return S_OK;
4658 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4660 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4661 nsIDOMNodeList *node_list;
4662 nsAString nsstr;
4663 HRESULT hres;
4665 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4667 nsAString_InitDepend(&nsstr, v);
4668 hres = map_nsresult(nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &nsstr, &node_list));
4669 nsAString_Finish(&nsstr);
4670 if(FAILED(hres)) {
4671 ERR("QuerySelectorAll failed: %08lx\n", hres);
4672 return hres;
4675 hres = create_child_collection(node_list, dispex_compat_mode(&This->doc_node->node.event_target.dispex), pel);
4676 nsIDOMNodeList_Release(node_list);
4677 return hres;
4680 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4681 DocumentSelector_QueryInterface,
4682 DocumentSelector_AddRef,
4683 DocumentSelector_Release,
4684 DocumentSelector_GetTypeInfoCount,
4685 DocumentSelector_GetTypeInfo,
4686 DocumentSelector_GetIDsOfNames,
4687 DocumentSelector_Invoke,
4688 DocumentSelector_querySelector,
4689 DocumentSelector_querySelectorAll
4692 static inline HTMLDocument *impl_from_IDocumentEvent(IDocumentEvent *iface)
4694 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentEvent_iface);
4697 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4699 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4700 return htmldoc_query_interface(This, riid, ppv);
4703 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4705 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4706 return htmldoc_addref(This);
4709 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4711 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4712 return htmldoc_release(This);
4715 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4717 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4718 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4721 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4722 LCID lcid, ITypeInfo **ppTInfo)
4724 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4725 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4728 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4729 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4731 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4732 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4733 rgDispId);
4736 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4737 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4739 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4740 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4741 pDispParams, pVarResult, pExcepInfo, puArgErr);
4744 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4746 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4748 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4750 return create_document_event_str(This->doc_node, eventType, p);
4753 static const IDocumentEventVtbl DocumentEventVtbl = {
4754 DocumentEvent_QueryInterface,
4755 DocumentEvent_AddRef,
4756 DocumentEvent_Release,
4757 DocumentEvent_GetTypeInfoCount,
4758 DocumentEvent_GetTypeInfo,
4759 DocumentEvent_GetIDsOfNames,
4760 DocumentEvent_Invoke,
4761 DocumentEvent_createEvent
4764 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4766 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4768 if(This->window)
4769 update_doc_cp_events(This->doc_node, cp);
4772 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4774 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4777 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4779 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4780 return htmldoc_query_interface(This, riid, ppv);
4783 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4785 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4786 return htmldoc_addref(This);
4789 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4791 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4792 return htmldoc_release(This);
4795 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4797 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4798 return S_FALSE;
4801 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4802 SupportErrorInfo_QueryInterface,
4803 SupportErrorInfo_AddRef,
4804 SupportErrorInfo_Release,
4805 SupportErrorInfo_InterfaceSupportsErrorInfo
4808 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4810 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4813 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4815 nsIDOMNodeList *node_list;
4816 nsAString name_str;
4817 UINT32 len;
4818 unsigned i;
4819 nsresult nsres;
4821 if(!This->nsdoc)
4822 return DISP_E_UNKNOWNNAME;
4824 nsAString_InitDepend(&name_str, name);
4825 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4826 nsAString_Finish(&name_str);
4827 if(NS_FAILED(nsres))
4828 return E_FAIL;
4830 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4831 nsIDOMNodeList_Release(node_list);
4832 if(NS_FAILED(nsres))
4833 return E_FAIL;
4835 if(!len)
4836 return DISP_E_UNKNOWNNAME;
4838 for(i=0; i < This->elem_vars_cnt; i++) {
4839 if(!wcscmp(name, This->elem_vars[i])) {
4840 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4841 return S_OK;
4845 if(This->elem_vars_cnt == This->elem_vars_size) {
4846 WCHAR **new_vars;
4848 if(This->elem_vars_size) {
4849 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4850 if(!new_vars)
4851 return E_OUTOFMEMORY;
4852 This->elem_vars_size *= 2;
4853 }else {
4854 new_vars = heap_alloc(16*sizeof(WCHAR*));
4855 if(!new_vars)
4856 return E_OUTOFMEMORY;
4857 This->elem_vars_size = 16;
4860 This->elem_vars = new_vars;
4863 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4864 if(!This->elem_vars[This->elem_vars_cnt])
4865 return E_OUTOFMEMORY;
4867 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4868 return S_OK;
4871 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4873 HTMLDocument *This = impl_from_IDispatchEx(iface);
4875 return htmldoc_query_interface(This, riid, ppv);
4878 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4880 HTMLDocument *This = impl_from_IDispatchEx(iface);
4882 return htmldoc_addref(This);
4885 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4887 HTMLDocument *This = impl_from_IDispatchEx(iface);
4889 return htmldoc_release(This);
4892 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4894 HTMLDocument *This = impl_from_IDispatchEx(iface);
4896 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4899 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4900 LCID lcid, ITypeInfo **ppTInfo)
4902 HTMLDocument *This = impl_from_IDispatchEx(iface);
4904 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4907 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4908 LPOLESTR *rgszNames, UINT cNames,
4909 LCID lcid, DISPID *rgDispId)
4911 HTMLDocument *This = impl_from_IDispatchEx(iface);
4913 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4916 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4917 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4918 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4920 HTMLDocument *This = impl_from_IDispatchEx(iface);
4922 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4923 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4925 return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags, pDispParams,
4926 pVarResult, pExcepInfo, NULL);
4929 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4931 HTMLDocument *This = impl_from_IDispatchEx(iface);
4932 HRESULT hres;
4934 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4935 if(hres != DISP_E_UNKNOWNNAME)
4936 return hres;
4938 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4941 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4942 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4944 HTMLDocument *This = impl_from_IDispatchEx(iface);
4946 if(This->window) {
4947 switch(id) {
4948 case DISPID_READYSTATE:
4949 TRACE("DISPID_READYSTATE\n");
4951 if(!(wFlags & DISPATCH_PROPERTYGET))
4952 return E_INVALIDARG;
4954 V_VT(pvarRes) = VT_I4;
4955 V_I4(pvarRes) = This->window->readystate;
4956 return S_OK;
4957 default:
4958 break;
4962 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4965 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4967 HTMLDocument *This = impl_from_IDispatchEx(iface);
4969 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4972 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4974 HTMLDocument *This = impl_from_IDispatchEx(iface);
4976 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4979 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4981 HTMLDocument *This = impl_from_IDispatchEx(iface);
4983 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4986 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4988 HTMLDocument *This = impl_from_IDispatchEx(iface);
4990 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4993 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4995 HTMLDocument *This = impl_from_IDispatchEx(iface);
4997 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
5000 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
5002 HTMLDocument *This = impl_from_IDispatchEx(iface);
5004 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
5007 static const IDispatchExVtbl DocDispatchExVtbl = {
5008 DocDispatchEx_QueryInterface,
5009 DocDispatchEx_AddRef,
5010 DocDispatchEx_Release,
5011 DocDispatchEx_GetTypeInfoCount,
5012 DocDispatchEx_GetTypeInfo,
5013 DocDispatchEx_GetIDsOfNames,
5014 DocDispatchEx_Invoke,
5015 DocDispatchEx_GetDispID,
5016 DocDispatchEx_InvokeEx,
5017 DocDispatchEx_DeleteMemberByName,
5018 DocDispatchEx_DeleteMemberByDispID,
5019 DocDispatchEx_GetMemberProperties,
5020 DocDispatchEx_GetMemberName,
5021 DocDispatchEx_GetNextDispID,
5022 DocDispatchEx_GetNameSpaceParent
5025 static inline HTMLDocument *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
5027 return CONTAINING_RECORD(iface, HTMLDocument, IProvideMultipleClassInfo_iface);
5030 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
5031 REFIID riid, void **ppv)
5033 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5034 return htmldoc_query_interface(This, riid, ppv);
5037 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
5039 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5040 return htmldoc_addref(This);
5043 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
5045 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5046 return htmldoc_release(This);
5049 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
5051 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5052 TRACE("(%p)->(%p)\n", This, ppTI);
5053 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
5056 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
5058 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5059 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
5060 return E_NOTIMPL;
5063 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
5065 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5066 FIXME("(%p)->(%p)\n", This, pcti);
5067 *pcti = 1;
5068 return S_OK;
5071 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
5072 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
5074 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
5075 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
5076 return E_NOTIMPL;
5079 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
5080 ProvideClassInfo_QueryInterface,
5081 ProvideClassInfo_AddRef,
5082 ProvideClassInfo_Release,
5083 ProvideClassInfo_GetClassInfo,
5084 ProvideClassInfo2_GetGUID,
5085 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
5086 ProvideMultipleClassInfo_GetInfoOfIndex
5089 /**********************************************************
5090 * IMarkupServices implementation
5092 static inline HTMLDocument *impl_from_IMarkupServices(IMarkupServices *iface)
5094 return CONTAINING_RECORD(iface, HTMLDocument, IMarkupServices_iface);
5097 static HRESULT WINAPI MarkupServices_QueryInterface(IMarkupServices *iface, REFIID riid, void **ppvObject)
5099 HTMLDocument *This = impl_from_IMarkupServices(iface);
5100 return htmldoc_query_interface(This, riid, ppvObject);
5103 static ULONG WINAPI MarkupServices_AddRef(IMarkupServices *iface)
5105 HTMLDocument *This = impl_from_IMarkupServices(iface);
5106 return htmldoc_addref(This);
5109 static ULONG WINAPI MarkupServices_Release(IMarkupServices *iface)
5111 HTMLDocument *This = impl_from_IMarkupServices(iface);
5112 return htmldoc_release(This);
5115 static HRESULT WINAPI MarkupServices_CreateMarkupPointer(IMarkupServices *iface, IMarkupPointer **ppPointer)
5117 HTMLDocument *This = impl_from_IMarkupServices(iface);
5119 TRACE("(%p)->(%p)\n", This, ppPointer);
5121 return create_markup_pointer(ppPointer);
5124 static HRESULT WINAPI MarkupServices_CreateMarkupContainer(IMarkupServices *iface, IMarkupContainer **ppMarkupContainer)
5126 HTMLDocument *This = impl_from_IMarkupServices(iface);
5127 FIXME("(%p)->(%p)\n", This, ppMarkupContainer);
5128 return E_NOTIMPL;
5131 static HRESULT WINAPI MarkupServices_CreateElement(IMarkupServices *iface,
5132 ELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement)
5134 HTMLDocument *This = impl_from_IMarkupServices(iface);
5135 FIXME("(%p)->(%d,%s,%p)\n", This, tagID, debugstr_w(pchAttributes), ppElement);
5136 return E_NOTIMPL;
5139 static HRESULT WINAPI MarkupServices_CloneElement(IMarkupServices *iface,
5140 IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone)
5142 HTMLDocument *This = impl_from_IMarkupServices(iface);
5143 FIXME("(%p)->(%p,%p)\n", This, pElemCloneThis, ppElementTheClone);
5144 return E_NOTIMPL;
5147 static HRESULT WINAPI MarkupServices_InsertElement(IMarkupServices *iface,
5148 IHTMLElement *pElementInsert, IMarkupPointer *pPointerStart,
5149 IMarkupPointer *pPointerFinish)
5151 HTMLDocument *This = impl_from_IMarkupServices(iface);
5152 FIXME("(%p)->(%p,%p,%p)\n", This, pElementInsert, pPointerStart, pPointerFinish);
5153 return E_NOTIMPL;
5156 static HRESULT WINAPI MarkupServices_RemoveElement(IMarkupServices *iface, IHTMLElement *pElementRemove)
5158 HTMLDocument *This = impl_from_IMarkupServices(iface);
5159 FIXME("(%p)->(%p)\n", This, pElementRemove);
5160 return E_NOTIMPL;
5163 static HRESULT WINAPI MarkupServices_Remove(IMarkupServices *iface,
5164 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5166 HTMLDocument *This = impl_from_IMarkupServices(iface);
5167 FIXME("(%p)->(%p,%p)\n", This, pPointerStart, pPointerFinish);
5168 return E_NOTIMPL;
5171 static HRESULT WINAPI MarkupServices_Copy(IMarkupServices *iface,
5172 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5173 IMarkupPointer *pPointerTarget)
5175 HTMLDocument *This = impl_from_IMarkupServices(iface);
5176 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5177 return E_NOTIMPL;
5180 static HRESULT WINAPI MarkupServices_Move(IMarkupServices *iface,
5181 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5182 IMarkupPointer *pPointerTarget)
5184 HTMLDocument *This = impl_from_IMarkupServices(iface);
5185 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5186 return E_NOTIMPL;
5189 static HRESULT WINAPI MarkupServices_InsertText(IMarkupServices *iface,
5190 OLECHAR *pchText, LONG cch, IMarkupPointer *pPointerTarget)
5192 HTMLDocument *This = impl_from_IMarkupServices(iface);
5193 FIXME("(%p)->(%s,%lx,%p)\n", This, debugstr_w(pchText), cch, pPointerTarget);
5194 return E_NOTIMPL;
5197 static HRESULT WINAPI MarkupServices_ParseString(IMarkupServices *iface,
5198 OLECHAR *pchHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5199 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5201 HTMLDocument *This = impl_from_IMarkupServices(iface);
5202 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(pchHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5203 return E_NOTIMPL;
5206 static HRESULT WINAPI MarkupServices_ParseGlobal(IMarkupServices *iface,
5207 HGLOBAL hglobalHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5208 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5210 HTMLDocument *This = impl_from_IMarkupServices(iface);
5211 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(hglobalHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5212 return E_NOTIMPL;
5215 static HRESULT WINAPI MarkupServices_IsScopedElement(IMarkupServices *iface,
5216 IHTMLElement *pElement, BOOL *pfScoped)
5218 HTMLDocument *This = impl_from_IMarkupServices(iface);
5219 FIXME("(%p)->(%p,%p)\n", This, pElement, pfScoped);
5220 return E_NOTIMPL;
5223 static HRESULT WINAPI MarkupServices_GetElementTagId(IMarkupServices *iface,
5224 IHTMLElement *pElement, ELEMENT_TAG_ID *ptagId)
5226 HTMLDocument *This = impl_from_IMarkupServices(iface);
5227 FIXME("(%p)->(%p,%p)\n", This, pElement, ptagId);
5228 return E_NOTIMPL;
5231 static HRESULT WINAPI MarkupServices_GetTagIDForName(IMarkupServices *iface,
5232 BSTR bstrName, ELEMENT_TAG_ID *ptagId)
5234 HTMLDocument *This = impl_from_IMarkupServices(iface);
5235 FIXME("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), ptagId);
5236 return E_NOTIMPL;
5239 static HRESULT WINAPI MarkupServices_GetNameForTagID(IMarkupServices *iface,
5240 ELEMENT_TAG_ID tagId, BSTR *pbstrName)
5242 HTMLDocument *This = impl_from_IMarkupServices(iface);
5243 FIXME("(%p)->(%d,%p)\n", This, tagId, pbstrName);
5244 return E_NOTIMPL;
5247 static HRESULT WINAPI MarkupServices_MovePointersToRange(IMarkupServices *iface,
5248 IHTMLTxtRange *pIRange, IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5250 HTMLDocument *This = impl_from_IMarkupServices(iface);
5251 FIXME("(%p)->(%p,%p,%p)\n", This, pIRange, pPointerStart, pPointerFinish);
5252 return E_NOTIMPL;
5255 static HRESULT WINAPI MarkupServices_MoveRangeToPointers(IMarkupServices *iface,
5256 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish, IHTMLTxtRange *pIRange)
5258 HTMLDocument *This = impl_from_IMarkupServices(iface);
5259 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerStart, pPointerFinish, pIRange);
5260 return E_NOTIMPL;
5263 static HRESULT WINAPI MarkupServices_BeginUndoUnit(IMarkupServices *iface, OLECHAR *pchTitle)
5265 HTMLDocument *This = impl_from_IMarkupServices(iface);
5266 FIXME("(%p)->(%s)\n", This, debugstr_w(pchTitle));
5267 return E_NOTIMPL;
5270 static HRESULT WINAPI MarkupServices_EndUndoUnit(IMarkupServices *iface)
5272 HTMLDocument *This = impl_from_IMarkupServices(iface);
5273 FIXME("(%p)\n", This);
5274 return E_NOTIMPL;
5277 static const IMarkupServicesVtbl MarkupServicesVtbl = {
5278 MarkupServices_QueryInterface,
5279 MarkupServices_AddRef,
5280 MarkupServices_Release,
5281 MarkupServices_CreateMarkupPointer,
5282 MarkupServices_CreateMarkupContainer,
5283 MarkupServices_CreateElement,
5284 MarkupServices_CloneElement,
5285 MarkupServices_InsertElement,
5286 MarkupServices_RemoveElement,
5287 MarkupServices_Remove,
5288 MarkupServices_Copy,
5289 MarkupServices_Move,
5290 MarkupServices_InsertText,
5291 MarkupServices_ParseString,
5292 MarkupServices_ParseGlobal,
5293 MarkupServices_IsScopedElement,
5294 MarkupServices_GetElementTagId,
5295 MarkupServices_GetTagIDForName,
5296 MarkupServices_GetNameForTagID,
5297 MarkupServices_MovePointersToRange,
5298 MarkupServices_MoveRangeToPointers,
5299 MarkupServices_BeginUndoUnit,
5300 MarkupServices_EndUndoUnit
5303 /**********************************************************
5304 * IMarkupContainer implementation
5306 static inline HTMLDocument *impl_from_IMarkupContainer(IMarkupContainer *iface)
5308 return CONTAINING_RECORD(iface, HTMLDocument, IMarkupContainer_iface);
5311 static HRESULT WINAPI MarkupContainer_QueryInterface(IMarkupContainer *iface, REFIID riid, void **ppvObject)
5313 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5314 return htmldoc_query_interface(This, riid, ppvObject);
5317 static ULONG WINAPI MarkupContainer_AddRef(IMarkupContainer *iface)
5319 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5320 return htmldoc_addref(This);
5323 static ULONG WINAPI MarkupContainer_Release(IMarkupContainer *iface)
5325 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5326 return htmldoc_release(This);
5329 static HRESULT WINAPI MarkupContainer_OwningDoc(IMarkupContainer *iface, IHTMLDocument2 **ppDoc)
5331 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5332 FIXME("(%p)->(%p)\n", This, ppDoc);
5333 return E_NOTIMPL;
5336 static const IMarkupContainerVtbl MarkupContainerVtbl = {
5337 MarkupContainer_QueryInterface,
5338 MarkupContainer_AddRef,
5339 MarkupContainer_Release,
5340 MarkupContainer_OwningDoc
5343 /**********************************************************
5344 * IDisplayServices implementation
5346 static inline HTMLDocument *impl_from_IDisplayServices(IDisplayServices *iface)
5348 return CONTAINING_RECORD(iface, HTMLDocument, IDisplayServices_iface);
5351 static HRESULT WINAPI DisplayServices_QueryInterface(IDisplayServices *iface, REFIID riid, void **ppvObject)
5353 HTMLDocument *This = impl_from_IDisplayServices(iface);
5354 return htmldoc_query_interface(This, riid, ppvObject);
5357 static ULONG WINAPI DisplayServices_AddRef(IDisplayServices *iface)
5359 HTMLDocument *This = impl_from_IDisplayServices(iface);
5360 return htmldoc_addref(This);
5363 static ULONG WINAPI DisplayServices_Release(IDisplayServices *iface)
5365 HTMLDocument *This = impl_from_IDisplayServices(iface);
5366 return htmldoc_release(This);
5369 static HRESULT WINAPI DisplayServices_CreateDisplayPointer(IDisplayServices *iface, IDisplayPointer **ppDispPointer)
5371 HTMLDocument *This = impl_from_IDisplayServices(iface);
5372 FIXME("(%p)->(%p)\n", This, ppDispPointer);
5373 return E_NOTIMPL;
5376 static HRESULT WINAPI DisplayServices_TransformRect(IDisplayServices *iface,
5377 RECT *pRect, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5379 HTMLDocument *This = impl_from_IDisplayServices(iface);
5380 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_rect(pRect), eSource, eDestination, pIElement);
5381 return E_NOTIMPL;
5384 static HRESULT WINAPI DisplayServices_TransformPoint(IDisplayServices *iface,
5385 POINT *pPoint, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5387 HTMLDocument *This = impl_from_IDisplayServices(iface);
5388 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_point(pPoint), eSource, eDestination, pIElement);
5389 return E_NOTIMPL;
5392 static HRESULT WINAPI DisplayServices_GetCaret(IDisplayServices *iface, IHTMLCaret **ppCaret)
5394 HTMLDocument *This = impl_from_IDisplayServices(iface);
5395 FIXME("(%p)->(%p)\n", This, ppCaret);
5396 return E_NOTIMPL;
5399 static HRESULT WINAPI DisplayServices_GetComputedStyle(IDisplayServices *iface,
5400 IMarkupPointer *pPointer, IHTMLComputedStyle **ppComputedStyle)
5402 HTMLDocument *This = impl_from_IDisplayServices(iface);
5403 FIXME("(%p)->(%p,%p)\n", This, pPointer, ppComputedStyle);
5404 return E_NOTIMPL;
5407 static HRESULT WINAPI DisplayServices_ScrollRectIntoView(IDisplayServices *iface,
5408 IHTMLElement *pIElement, RECT rect)
5410 HTMLDocument *This = impl_from_IDisplayServices(iface);
5411 FIXME("(%p)->(%p,%s)\n", This, pIElement, wine_dbgstr_rect(&rect));
5412 return E_NOTIMPL;
5415 static HRESULT WINAPI DisplayServices_HasFlowLayout(IDisplayServices *iface,
5416 IHTMLElement *pIElement, BOOL *pfHasFlowLayout)
5418 HTMLDocument *This = impl_from_IDisplayServices(iface);
5419 FIXME("(%p)->(%p,%p)\n", This, pIElement, pfHasFlowLayout);
5420 return E_NOTIMPL;
5423 static const IDisplayServicesVtbl DisplayServicesVtbl = {
5424 DisplayServices_QueryInterface,
5425 DisplayServices_AddRef,
5426 DisplayServices_Release,
5427 DisplayServices_CreateDisplayPointer,
5428 DisplayServices_TransformRect,
5429 DisplayServices_TransformPoint,
5430 DisplayServices_GetCaret,
5431 DisplayServices_GetComputedStyle,
5432 DisplayServices_ScrollRectIntoView,
5433 DisplayServices_HasFlowLayout
5436 /**********************************************************
5437 * IDocumentRange implementation
5439 static inline HTMLDocument *impl_from_IDocumentRange(IDocumentRange *iface)
5441 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentRange_iface);
5444 static HRESULT WINAPI DocumentRange_QueryInterface(IDocumentRange *iface, REFIID riid, void **ppv)
5446 HTMLDocument *This = impl_from_IDocumentRange(iface);
5448 return htmldoc_query_interface(This, riid, ppv);
5451 static ULONG WINAPI DocumentRange_AddRef(IDocumentRange *iface)
5453 HTMLDocument *This = impl_from_IDocumentRange(iface);
5455 return htmldoc_addref(This);
5458 static ULONG WINAPI DocumentRange_Release(IDocumentRange *iface)
5460 HTMLDocument *This = impl_from_IDocumentRange(iface);
5462 return htmldoc_release(This);
5465 static HRESULT WINAPI DocumentRange_GetTypeInfoCount(IDocumentRange *iface, UINT *pctinfo)
5467 HTMLDocument *This = impl_from_IDocumentRange(iface);
5469 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
5472 static HRESULT WINAPI DocumentRange_GetTypeInfo(IDocumentRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5474 HTMLDocument *This = impl_from_IDocumentRange(iface);
5476 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5479 static HRESULT WINAPI DocumentRange_GetIDsOfNames(IDocumentRange *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5480 LCID lcid, DISPID *rgDispId)
5482 HTMLDocument *This = impl_from_IDocumentRange(iface);
5484 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
5485 rgDispId);
5488 static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
5489 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5491 HTMLDocument *This = impl_from_IDocumentRange(iface);
5493 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5494 pDispParams, pVarResult, pExcepInfo, puArgErr);
5497 static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
5499 HTMLDocument *This = impl_from_IDocumentRange(iface);
5500 nsIDOMRange *nsrange;
5501 HRESULT hres;
5503 TRACE("(%p)->(%p)\n", This, p);
5505 if(!This->doc_node->nsdoc) {
5506 WARN("NULL nsdoc\n");
5507 return E_UNEXPECTED;
5510 if(NS_FAILED(nsIDOMHTMLDocument_CreateRange(This->doc_node->nsdoc, &nsrange)))
5511 return E_FAIL;
5513 hres = create_dom_range(nsrange, dispex_compat_mode(&This->doc_node->node.event_target.dispex), p);
5514 nsIDOMRange_Release(nsrange);
5515 return hres;
5518 static const IDocumentRangeVtbl DocumentRangeVtbl = {
5519 DocumentRange_QueryInterface,
5520 DocumentRange_AddRef,
5521 DocumentRange_Release,
5522 DocumentRange_GetTypeInfoCount,
5523 DocumentRange_GetTypeInfo,
5524 DocumentRange_GetIDsOfNames,
5525 DocumentRange_Invoke,
5526 DocumentRange_createRange,
5529 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
5531 *ppv = NULL;
5533 if(IsEqualGUID(&IID_IUnknown, riid))
5534 *ppv = &This->IHTMLDocument2_iface;
5535 else if(IsEqualGUID(&IID_IDispatch, riid))
5536 *ppv = &This->IDispatchEx_iface;
5537 else if(IsEqualGUID(&IID_IDispatchEx, riid))
5538 *ppv = &This->IDispatchEx_iface;
5539 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
5540 *ppv = &This->IHTMLDocument2_iface;
5541 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
5542 *ppv = &This->IHTMLDocument2_iface;
5543 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
5544 *ppv = &This->IHTMLDocument3_iface;
5545 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
5546 *ppv = &This->IHTMLDocument4_iface;
5547 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
5548 *ppv = &This->IHTMLDocument5_iface;
5549 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
5550 *ppv = &This->IHTMLDocument6_iface;
5551 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
5552 *ppv = &This->IHTMLDocument7_iface;
5553 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
5554 *ppv = &This->IDocumentSelector_iface;
5555 else if(IsEqualGUID(&IID_IDocumentEvent, riid))
5556 *ppv = &This->IDocumentEvent_iface;
5557 else if(IsEqualGUID(&IID_IPersist, riid))
5558 *ppv = &This->IPersistFile_iface;
5559 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
5560 *ppv = &This->IPersistMoniker_iface;
5561 else if(IsEqualGUID(&IID_IPersistFile, riid))
5562 *ppv = &This->IPersistFile_iface;
5563 else if(IsEqualGUID(&IID_IMonikerProp, riid))
5564 *ppv = &This->IMonikerProp_iface;
5565 else if(IsEqualGUID(&IID_IOleObject, riid))
5566 *ppv = &This->IOleObject_iface;
5567 else if(IsEqualGUID(&IID_IOleDocument, riid))
5568 *ppv = &This->IOleDocument_iface;
5569 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
5570 *ppv = &This->IOleInPlaceActiveObject_iface;
5571 else if(IsEqualGUID(&IID_IOleWindow, riid))
5572 *ppv = &This->IOleInPlaceActiveObject_iface;
5573 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
5574 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5575 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
5576 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5577 else if(IsEqualGUID(&IID_IServiceProvider, riid))
5578 *ppv = &This->IServiceProvider_iface;
5579 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
5580 *ppv = &This->IOleCommandTarget_iface;
5581 else if(IsEqualGUID(&IID_IOleControl, riid))
5582 *ppv = &This->IOleControl_iface;
5583 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
5584 *ppv = &This->IHlinkTarget_iface;
5585 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
5586 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5587 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
5588 *ppv = &This->IPersistStreamInit_iface;
5589 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
5590 *ppv = &This->IHTMLDocument2_iface;
5591 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
5592 *ppv = &This->ISupportErrorInfo_iface;
5593 else if(IsEqualGUID(&IID_IPersistHistory, riid))
5594 *ppv = &This->IPersistHistory_iface;
5595 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
5596 *ppv = &This->IObjectWithSite_iface;
5597 else if(IsEqualGUID(&IID_IOleContainer, riid))
5598 *ppv = &This->IOleContainer_iface;
5599 else if(IsEqualGUID(&IID_IObjectSafety, riid))
5600 *ppv = &This->IObjectSafety_iface;
5601 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
5602 *ppv = &This->IProvideMultipleClassInfo_iface;
5603 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
5604 *ppv = &This->IProvideMultipleClassInfo_iface;
5605 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
5606 *ppv = &This->IProvideMultipleClassInfo_iface;
5607 else if(IsEqualGUID(&IID_IMarkupServices, riid))
5608 *ppv = &This->IMarkupServices_iface;
5609 else if(IsEqualGUID(&IID_IMarkupContainer, riid))
5610 *ppv = &This->IMarkupContainer_iface;
5611 else if(IsEqualGUID(&IID_IDisplayServices, riid))
5612 *ppv = &This->IDisplayServices_iface;
5613 else if(IsEqualGUID(&IID_IDocumentRange, riid))
5614 *ppv = &This->IDocumentRange_iface;
5615 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
5616 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
5617 *ppv = NULL;
5618 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
5619 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
5620 *ppv = NULL;
5621 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
5622 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
5623 *ppv = NULL;
5624 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
5625 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
5626 *ppv = NULL;
5627 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
5628 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
5629 *ppv = NULL;
5630 }else {
5631 return FALSE;
5634 if(*ppv)
5635 IUnknown_AddRef((IUnknown*)*ppv);
5636 return TRUE;
5639 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
5640 static cp_static_data_t HTMLDocumentEvents2_data = { HTMLDocumentEvents2_tid, HTMLDocument_on_advise, TRUE };
5642 static const cpc_entry_t HTMLDocument_cpc[] = {
5643 {&IID_IDispatch, &HTMLDocumentEvents_data},
5644 {&IID_IPropertyNotifySink},
5645 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
5646 {&DIID_HTMLDocumentEvents2, &HTMLDocumentEvents2_data},
5647 {NULL}
5650 static void init_doc(HTMLDocument *doc, IUnknown *outer, IDispatchEx *dispex)
5652 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
5653 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
5654 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
5655 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
5656 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
5657 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
5658 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
5659 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
5660 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
5661 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
5662 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
5663 doc->IMarkupServices_iface.lpVtbl = &MarkupServicesVtbl;
5664 doc->IMarkupContainer_iface.lpVtbl = &MarkupContainerVtbl;
5665 doc->IDisplayServices_iface.lpVtbl = &DisplayServicesVtbl;
5666 doc->IDocumentRange_iface.lpVtbl = &DocumentRangeVtbl;
5668 doc->outer_unk = outer;
5669 doc->dispex = dispex;
5671 HTMLDocument_Persist_Init(doc);
5672 HTMLDocument_OleCmd_Init(doc);
5673 HTMLDocument_OleObj_Init(doc);
5674 HTMLDocument_Service_Init(doc);
5676 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
5679 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5681 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
5684 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5686 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5688 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5690 if(htmldoc_qi(&This->basedoc, riid, ppv))
5691 return *ppv ? S_OK : E_NOINTERFACE;
5693 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
5694 *ppv = &This->IInternetHostSecurityManager_iface;
5695 else
5696 return HTMLDOMNode_QI(&This->node, riid, ppv);
5698 IUnknown_AddRef((IUnknown*)*ppv);
5699 return S_OK;
5702 void detach_document_node(HTMLDocumentNode *doc)
5704 unsigned i;
5706 while(!list_empty(&doc->plugin_hosts))
5707 detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
5709 if(doc->dom_implementation) {
5710 detach_dom_implementation(doc->dom_implementation);
5711 IHTMLDOMImplementation_Release(doc->dom_implementation);
5712 doc->dom_implementation = NULL;
5715 if(doc->namespaces) {
5716 IHTMLNamespaceCollection_Release(doc->namespaces);
5717 doc->namespaces = NULL;
5720 detach_events(doc);
5721 detach_selection(doc);
5722 detach_ranges(doc);
5724 for(i=0; i < doc->elem_vars_cnt; i++)
5725 heap_free(doc->elem_vars[i]);
5726 heap_free(doc->elem_vars);
5727 doc->elem_vars_cnt = doc->elem_vars_size = 0;
5728 doc->elem_vars = NULL;
5730 if(doc->catmgr) {
5731 ICatInformation_Release(doc->catmgr);
5732 doc->catmgr = NULL;
5735 if(!doc->nsdoc && doc->window) {
5736 /* document fragments own reference to inner window */
5737 IHTMLWindow2_Release(&doc->window->base.IHTMLWindow2_iface);
5738 doc->window = NULL;
5741 if(doc->browser) {
5742 list_remove(&doc->browser_entry);
5743 doc->browser = NULL;
5747 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
5749 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5751 TRACE("(%p)\n", This);
5753 heap_free(This->event_vector);
5754 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
5757 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5759 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5760 FIXME("%p\n", This);
5761 return E_NOTIMPL;
5764 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
5766 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5768 if(This->nsdoc)
5769 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
5772 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
5774 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5776 if(This->nsdoc) {
5777 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
5779 release_document_mutation(This);
5780 detach_document_node(This);
5781 This->nsdoc = NULL;
5782 nsIDOMHTMLDocument_Release(nsdoc);
5783 This->window = NULL;
5787 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
5788 &CLSID_HTMLDocument,
5789 HTMLDocumentNode_QI,
5790 HTMLDocumentNode_destructor,
5791 HTMLDocument_cpc,
5792 HTMLDocumentNode_clone,
5793 NULL,
5794 NULL,
5795 NULL,
5796 NULL,
5797 NULL,
5798 NULL,
5799 NULL,
5800 NULL,
5801 NULL,
5802 NULL,
5803 HTMLDocumentNode_traverse,
5804 HTMLDocumentNode_unlink
5807 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5809 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5810 HTMLDocumentNode *new_node;
5811 HRESULT hres;
5813 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
5814 if(FAILED(hres))
5815 return hres;
5817 *ret = &new_node->node;
5818 return S_OK;
5821 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
5823 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
5826 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5827 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5829 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5830 nsIDOMNodeList *node_list;
5831 nsAString name_str;
5832 nsIDOMNode *nsnode;
5833 HTMLDOMNode *node;
5834 unsigned i;
5835 nsresult nsres;
5836 HRESULT hres;
5838 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
5839 FIXME("unsupported flags %x\n", flags);
5840 return E_NOTIMPL;
5843 i = id - MSHTML_DISPID_CUSTOM_MIN;
5845 if(!This->nsdoc || i >= This->elem_vars_cnt)
5846 return DISP_E_MEMBERNOTFOUND;
5848 nsAString_InitDepend(&name_str, This->elem_vars[i]);
5849 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
5850 nsAString_Finish(&name_str);
5851 if(NS_FAILED(nsres))
5852 return E_FAIL;
5854 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
5855 nsIDOMNodeList_Release(node_list);
5856 if(NS_FAILED(nsres) || !nsnode)
5857 return DISP_E_MEMBERNOTFOUND;
5859 hres = get_node(nsnode, TRUE, &node);
5860 if(FAILED(hres))
5861 return hres;
5863 V_VT(res) = VT_DISPATCH;
5864 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5865 return S_OK;
5868 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
5870 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5872 TRACE("(%p) returning %u\n", This, This->document_mode);
5874 return lock_document_mode(This);
5877 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
5879 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5880 return (nsISupports*)This->node.nsnode;
5883 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
5885 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5886 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
5889 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
5891 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5892 if(!This->window)
5893 return NULL;
5894 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
5895 return &This->window->event_target;
5898 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
5900 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5901 ConnectionPointContainer *container = This->basedoc.doc_obj
5902 ? &This->basedoc.doc_obj->basedoc.cp_container : &This->basedoc.cp_container;
5903 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
5904 return container;
5907 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
5909 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5910 return default_set_current_event(This->window, event);
5913 static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp, VARIANT *res,
5914 EXCEPINFO *ei, IServiceProvider *caller)
5916 return IHTMLDocument2_location_hook(&impl_from_DispatchEx(dispex)->basedoc, flags, dp, res, ei, caller);
5919 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
5921 NULL,
5922 NULL,
5923 HTMLDocumentNode_invoke,
5924 HTMLDocumentNode_get_compat_mode,
5925 NULL
5927 HTMLDocumentNode_get_gecko_target,
5928 HTMLDocumentNode_bind_event,
5929 HTMLDocumentNode_get_parent_event_target,
5930 NULL,
5931 HTMLDocumentNode_get_cp_container,
5932 HTMLDocumentNode_set_current_event
5935 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
5936 &CLSID_HTMLDocument,
5937 HTMLDocumentNode_QI,
5938 HTMLDocumentNode_destructor,
5939 HTMLDocument_cpc,
5940 HTMLDocumentFragment_clone
5943 static const tid_t HTMLDocumentNode_iface_tids[] = {
5944 IHTMLDOMNode_tid,
5945 IHTMLDOMNode2_tid,
5946 IHTMLDocument4_tid,
5947 IHTMLDocument5_tid,
5948 IDocumentSelector_tid,
5952 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
5954 static const dispex_hook_t document2_hooks[] = {
5955 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
5956 {DISPID_UNKNOWN}
5959 HTMLDOMNode_init_dispex_info(info, mode);
5961 if(mode >= COMPAT_MODE_IE9) {
5962 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
5963 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
5966 /* Depending on compatibility version, we add interfaces in different order
5967 * so that the right getElementById implementation is used. */
5968 if(mode < COMPAT_MODE_IE8) {
5969 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5970 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5971 }else {
5972 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5973 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5975 dispex_info_add_interface(info, IHTMLDocument2_tid, document2_hooks);
5978 static dispex_static_data_t HTMLDocumentNode_dispex = {
5979 L"HTMLDocument",
5980 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
5981 DispHTMLDocument_tid,
5982 HTMLDocumentNode_iface_tids,
5983 HTMLDocumentNode_init_dispex_info
5986 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
5988 HTMLDocumentNode *doc;
5990 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
5991 if(!doc)
5992 return NULL;
5994 doc->ref = 1;
5995 doc->basedoc.doc_node = doc;
5996 doc->basedoc.doc_obj = doc_obj;
5997 doc->basedoc.window = window ? window->base.outer_window : NULL;
5998 doc->window = window;
6000 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
6001 &doc->node.event_target.dispex.IDispatchEx_iface);
6002 HTMLDocumentNode_SecMgr_Init(doc);
6004 list_init(&doc->selection_list);
6005 list_init(&doc->range_list);
6006 list_init(&doc->plugin_hosts);
6008 return doc;
6011 HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
6012 compat_mode_t parent_mode, HTMLDocumentNode **ret)
6014 HTMLDocumentObj *doc_obj = browser->doc;
6015 HTMLDocumentNode *doc;
6017 doc = alloc_doc_node(doc_obj, window);
6018 if(!doc)
6019 return E_OUTOFMEMORY;
6021 if(parent_mode >= COMPAT_MODE_IE9) {
6022 TRACE("using parent mode %u\n", parent_mode);
6023 doc->document_mode = parent_mode;
6024 lock_document_mode(doc);
6027 if(!doc_obj->basedoc.window || (window && is_main_content_window(window->base.outer_window)))
6028 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
6030 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc, &HTMLDocumentNode_dispex);
6032 nsIDOMHTMLDocument_AddRef(nsdoc);
6033 doc->nsdoc = nsdoc;
6035 init_document_mutation(doc);
6036 doc_init_events(doc);
6038 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
6040 list_add_head(&browser->document_nodes, &doc->browser_entry);
6041 doc->browser = browser;
6043 if(browser->usermode == EDITMODE) {
6044 nsAString mode_str;
6045 nsresult nsres;
6047 nsAString_InitDepend(&mode_str, L"on");
6048 nsres = nsIDOMHTMLDocument_SetDesignMode(doc->nsdoc, &mode_str);
6049 nsAString_Finish(&mode_str);
6050 if(NS_FAILED(nsres))
6051 ERR("SetDesignMode failed: %08lx\n", nsres);
6054 *ret = doc;
6055 return S_OK;
6058 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
6060 HTMLDocumentNode *doc_frag;
6062 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
6063 if(!doc_frag)
6064 return E_OUTOFMEMORY;
6066 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
6068 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
6069 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
6070 doc_frag->document_mode = lock_document_mode(doc_node);
6072 *ret = doc_frag;
6073 return S_OK;
6076 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
6078 HTMLDOMNode *node;
6079 HRESULT hres;
6081 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
6082 if(FAILED(hres))
6083 return hres;
6085 if(!node) {
6086 ERR("document not initialized\n");
6087 return E_FAIL;
6090 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
6091 *ret = impl_from_HTMLDOMNode(node);
6092 return S_OK;
6095 static inline HTMLDocumentObj *impl_from_IUnknown(IUnknown *iface)
6097 return CONTAINING_RECORD(iface, HTMLDocumentObj, IUnknown_inner);
6100 static HRESULT WINAPI HTMLDocumentObj_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
6102 HTMLDocumentObj *This = impl_from_IUnknown(iface);
6104 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
6106 if(IsEqualGUID(&IID_IUnknown, riid)) {
6107 *ppv = &This->IUnknown_inner;
6108 }else if(htmldoc_qi(&This->basedoc, riid, ppv)) {
6109 return *ppv ? S_OK : E_NOINTERFACE;
6110 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
6111 *ppv = &This->ICustomDoc_iface;
6112 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
6113 *ppv = &This->IOleDocumentView_iface;
6114 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
6115 *ppv = &This->IViewObjectEx_iface;
6116 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
6117 *ppv = &This->IViewObjectEx_iface;
6118 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
6119 *ppv = &This->IViewObjectEx_iface;
6120 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
6121 *ppv = &This->ITargetContainer_iface;
6122 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
6123 return *ppv ? S_OK : E_NOINTERFACE;
6124 }else {
6125 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
6126 *ppv = NULL;
6127 return E_NOINTERFACE;
6130 IUnknown_AddRef((IUnknown*)*ppv);
6131 return S_OK;
6134 static ULONG WINAPI HTMLDocumentObj_AddRef(IUnknown *iface)
6136 HTMLDocumentObj *This = impl_from_IUnknown(iface);
6137 ULONG ref = InterlockedIncrement(&This->ref);
6139 TRACE("(%p) ref = %lu\n", This, ref);
6141 return ref;
6144 static ULONG WINAPI HTMLDocumentObj_Release(IUnknown *iface)
6146 HTMLDocumentObj *This = impl_from_IUnknown(iface);
6147 ULONG ref = InterlockedDecrement(&This->ref);
6149 TRACE("(%p) ref = %lu\n", This, ref);
6151 if(!ref) {
6152 if(This->basedoc.doc_node) {
6153 This->basedoc.doc_node->basedoc.doc_obj = NULL;
6154 htmldoc_release(&This->basedoc.doc_node->basedoc);
6156 if(This->basedoc.window)
6157 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
6158 if(This->advise_holder)
6159 IOleAdviseHolder_Release(This->advise_holder);
6161 if(This->view_sink)
6162 IAdviseSink_Release(This->view_sink);
6163 if(This->client)
6164 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
6165 if(This->hostui)
6166 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
6167 if(This->in_place_active)
6168 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
6169 if(This->ipsite)
6170 IOleDocumentView_SetInPlaceSite(&This->IOleDocumentView_iface, NULL);
6171 if(This->undomgr)
6172 IOleUndoManager_Release(This->undomgr);
6173 if(This->editsvcs)
6174 IHTMLEditServices_Release(This->editsvcs);
6175 if(This->tooltips_hwnd)
6176 DestroyWindow(This->tooltips_hwnd);
6178 if(This->hwnd)
6179 DestroyWindow(This->hwnd);
6180 heap_free(This->mime);
6182 remove_target_tasks(This->task_magic);
6183 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
6184 release_dispex(&This->dispex);
6186 if(This->nscontainer)
6187 detach_gecko_browser(This->nscontainer);
6188 heap_free(This);
6191 return ref;
6194 static const IUnknownVtbl HTMLDocumentObjVtbl = {
6195 HTMLDocumentObj_QueryInterface,
6196 HTMLDocumentObj_AddRef,
6197 HTMLDocumentObj_Release
6200 /**********************************************************
6201 * ICustomDoc implementation
6204 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
6206 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
6209 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
6211 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
6213 return htmldoc_query_interface(&This->basedoc, riid, ppv);
6216 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
6218 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
6220 return htmldoc_addref(&This->basedoc);
6223 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
6225 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
6227 return htmldoc_release(&This->basedoc);
6230 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
6232 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
6233 IOleCommandTarget *cmdtrg;
6234 HRESULT hres;
6236 TRACE("(%p)->(%p)\n", This, pUIHandler);
6238 if(This->custom_hostui && This->hostui == pUIHandler)
6239 return S_OK;
6241 This->custom_hostui = TRUE;
6243 if(This->hostui)
6244 IDocHostUIHandler_Release(This->hostui);
6245 if(pUIHandler)
6246 IDocHostUIHandler_AddRef(pUIHandler);
6247 This->hostui = pUIHandler;
6248 if(!pUIHandler)
6249 return S_OK;
6251 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
6252 if(SUCCEEDED(hres)) {
6253 FIXME("custom UI handler supports IOleCommandTarget\n");
6254 IOleCommandTarget_Release(cmdtrg);
6257 return S_OK;
6260 static const ICustomDocVtbl CustomDocVtbl = {
6261 CustomDoc_QueryInterface,
6262 CustomDoc_AddRef,
6263 CustomDoc_Release,
6264 CustomDoc_SetUIHandler
6267 static HRESULT HTMLDocumentObj_location_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp, VARIANT *res,
6268 EXCEPINFO *ei, IServiceProvider *caller)
6270 return IHTMLDocument2_location_hook(&CONTAINING_RECORD(dispex, HTMLDocumentObj, dispex)->basedoc, flags, dp, res, ei, caller);
6273 static const tid_t HTMLDocumentObj_iface_tids[] = {
6274 IHTMLDocument3_tid,
6275 IHTMLDocument4_tid,
6276 IHTMLDocument5_tid,
6280 static void HTMLDocumentObj_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6282 static const dispex_hook_t document2_hooks[] = {
6283 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentObj_location_hook},
6284 {DISPID_UNKNOWN}
6286 dispex_info_add_interface(info, IHTMLDocument2_tid, document2_hooks);
6289 static dispex_static_data_t HTMLDocumentObj_dispex = {
6290 L"HTMLDocumentObj",
6291 NULL,
6292 DispHTMLDocument_tid,
6293 HTMLDocumentObj_iface_tids,
6294 HTMLDocumentObj_init_dispex_info
6297 static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID riid, void **ppv)
6299 HTMLDocumentObj *doc;
6300 HRESULT hres;
6302 if(outer && !IsEqualGUID(&IID_IUnknown, riid)) {
6303 *ppv = NULL;
6304 return E_INVALIDARG;
6307 /* ensure that security manager is initialized */
6308 if(!get_security_manager())
6309 return E_OUTOFMEMORY;
6311 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
6312 if(!doc)
6313 return E_OUTOFMEMORY;
6315 doc->ref = 1;
6316 doc->IUnknown_inner.lpVtbl = &HTMLDocumentObjVtbl;
6317 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
6319 doc->basedoc.doc_obj = doc;
6321 init_dispatch(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex, COMPAT_MODE_QUIRKS);
6322 init_doc(&doc->basedoc, outer ? outer : &doc->IUnknown_inner, &doc->dispex.IDispatchEx_iface);
6323 TargetContainer_Init(doc);
6324 doc->is_mhtml = is_mhtml;
6326 doc->task_magic = get_task_target_magic();
6328 HTMLDocument_View_Init(doc);
6330 hres = create_gecko_browser(doc, &doc->nscontainer);
6331 if(FAILED(hres)) {
6332 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
6333 htmldoc_release(&doc->basedoc);
6334 return hres;
6337 if(IsEqualGUID(&IID_IUnknown, riid)) {
6338 *ppv = &doc->IUnknown_inner;
6339 }else {
6340 hres = htmldoc_query_interface(&doc->basedoc, riid, ppv);
6341 htmldoc_release(&doc->basedoc);
6342 if(FAILED(hres))
6343 return hres;
6346 doc->basedoc.window = doc->nscontainer->content_window;
6347 IHTMLWindow2_AddRef(&doc->basedoc.window->base.IHTMLWindow2_iface);
6349 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
6350 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
6351 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
6354 get_thread_hwnd();
6356 return S_OK;
6359 HRESULT HTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
6361 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
6362 return create_document_object(FALSE, outer, riid, ppv);
6365 HRESULT MHTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
6367 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
6368 return create_document_object(TRUE, outer, riid, ppv);