shcore: Use CRT allocation functions.
[wine.git] / dlls / mshtml / htmldoc.c
blobdd8c4b24a4a65da8e7aea7cd98cd1473053ac985
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "wininet.h"
28 #include "ole2.h"
29 #include "perhist.h"
30 #include "mshtmdid.h"
31 #include "mshtmcid.h"
33 #include "wine/debug.h"
35 #include "mshtml_private.h"
36 #include "htmlevent.h"
37 #include "pluginhost.h"
38 #include "binding.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
42 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret);
44 HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement **ret)
46 nsIDOMNodeList *nsnode_list;
47 nsIDOMNode *nsnode = NULL;
48 nsIDOMElement *nselem;
49 nsAString id_str;
50 nsresult nsres;
51 HRESULT hres;
53 if(!doc->dom_document) {
54 WARN("NULL dom_document\n");
55 return E_UNEXPECTED;
58 nsAString_InitDepend(&id_str, id);
59 /* get element by id attribute */
60 nsres = nsIDOMDocument_GetElementById(doc->dom_document, &id_str, &nselem);
61 if(FAILED(nsres)) {
62 ERR("GetElementById failed: %08lx\n", nsres);
63 nsAString_Finish(&id_str);
64 return E_FAIL;
67 /* get first element by name attribute */
68 if(doc->html_document) {
69 nsres = nsIDOMHTMLDocument_GetElementsByName(doc->html_document, &id_str, &nsnode_list);
70 nsAString_Finish(&id_str);
71 if(FAILED(nsres)) {
72 ERR("getElementsByName failed: %08lx\n", nsres);
73 if(nselem)
74 nsIDOMElement_Release(nselem);
75 return E_FAIL;
78 nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode);
79 nsIDOMNodeList_Release(nsnode_list);
80 assert(nsres == NS_OK);
83 if(nsnode && nselem) {
84 UINT16 pos;
86 nsres = nsIDOMNode_CompareDocumentPosition(nsnode, (nsIDOMNode*)nselem, &pos);
87 if(NS_FAILED(nsres)) {
88 FIXME("CompareDocumentPosition failed: 0x%08lx\n", nsres);
89 nsIDOMNode_Release(nsnode);
90 nsIDOMElement_Release(nselem);
91 return E_FAIL;
94 TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
95 if(!(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS))) {
96 nsIDOMElement_Release(nselem);
97 nselem = NULL;
101 if(nsnode) {
102 if(!nselem) {
103 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
104 assert(nsres == NS_OK);
106 nsIDOMNode_Release(nsnode);
109 if(!nselem) {
110 *ret = NULL;
111 return S_OK;
114 hres = get_element(nselem, ret);
115 nsIDOMElement_Release(nselem);
116 return hres;
119 UINT get_document_charset(HTMLDocumentNode *doc)
121 nsAString charset_str;
122 UINT ret = 0;
123 nsresult nsres;
125 if(doc->charset)
126 return doc->charset;
128 nsAString_Init(&charset_str, NULL);
129 nsres = nsIDOMDocument_GetCharacterSet(doc->dom_document, &charset_str);
130 if(NS_SUCCEEDED(nsres)) {
131 const PRUnichar *charset;
133 nsAString_GetData(&charset_str, &charset);
135 if(*charset) {
136 BSTR str = SysAllocString(charset);
137 ret = cp_from_charset_string(str);
138 SysFreeString(str);
140 }else {
141 ERR("GetCharset failed: %08lx\n", nsres);
143 nsAString_Finish(&charset_str);
145 if(!ret)
146 return CP_UTF8;
148 return doc->charset = ret;
151 typedef struct {
152 HTMLDOMNode node;
153 IDOMDocumentType IDOMDocumentType_iface;
154 } DocumentType;
156 static inline DocumentType *impl_from_IDOMDocumentType(IDOMDocumentType *iface)
158 return CONTAINING_RECORD(iface, DocumentType, IDOMDocumentType_iface);
161 static HRESULT WINAPI DocumentType_QueryInterface(IDOMDocumentType *iface, REFIID riid, void **ppv)
163 DocumentType *This = impl_from_IDOMDocumentType(iface);
165 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
168 static ULONG WINAPI DocumentType_AddRef(IDOMDocumentType *iface)
170 DocumentType *This = impl_from_IDOMDocumentType(iface);
172 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
175 static ULONG WINAPI DocumentType_Release(IDOMDocumentType *iface)
177 DocumentType *This = impl_from_IDOMDocumentType(iface);
179 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
182 static HRESULT WINAPI DocumentType_GetTypeInfoCount(IDOMDocumentType *iface, UINT *pctinfo)
184 DocumentType *This = impl_from_IDOMDocumentType(iface);
186 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
189 static HRESULT WINAPI DocumentType_GetTypeInfo(IDOMDocumentType *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
191 DocumentType *This = impl_from_IDOMDocumentType(iface);
193 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
196 static HRESULT WINAPI DocumentType_GetIDsOfNames(IDOMDocumentType *iface, REFIID riid, LPOLESTR *rgszNames,
197 UINT cNames, LCID lcid, DISPID *rgDispId)
199 DocumentType *This = impl_from_IDOMDocumentType(iface);
201 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
202 cNames, lcid, rgDispId);
205 static HRESULT WINAPI DocumentType_Invoke(IDOMDocumentType *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
206 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
208 DocumentType *This = impl_from_IDOMDocumentType(iface);
210 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
211 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
214 static HRESULT WINAPI DocumentType_get_name(IDOMDocumentType *iface, BSTR *p)
216 DocumentType *This = impl_from_IDOMDocumentType(iface);
217 nsAString nsstr;
218 nsresult nsres;
220 TRACE("(%p)->(%p)\n", This, p);
222 nsAString_Init(&nsstr, NULL);
223 nsres = nsIDOMDocumentType_GetName((nsIDOMDocumentType*)This->node.nsnode, &nsstr);
224 return return_nsstr(nsres, &nsstr, p);
227 static HRESULT WINAPI DocumentType_get_entities(IDOMDocumentType *iface, IDispatch **p)
229 DocumentType *This = impl_from_IDOMDocumentType(iface);
231 FIXME("(%p)->(%p)\n", This, p);
233 return E_NOTIMPL;
236 static HRESULT WINAPI DocumentType_get_notations(IDOMDocumentType *iface, IDispatch **p)
238 DocumentType *This = impl_from_IDOMDocumentType(iface);
240 FIXME("(%p)->(%p)\n", This, p);
242 return E_NOTIMPL;
245 static HRESULT WINAPI DocumentType_get_publicId(IDOMDocumentType *iface, VARIANT *p)
247 DocumentType *This = impl_from_IDOMDocumentType(iface);
249 FIXME("(%p)->(%p)\n", This, p);
251 return E_NOTIMPL;
254 static HRESULT WINAPI DocumentType_get_systemId(IDOMDocumentType *iface, VARIANT *p)
256 DocumentType *This = impl_from_IDOMDocumentType(iface);
258 FIXME("(%p)->(%p)\n", This, p);
260 return E_NOTIMPL;
263 static HRESULT WINAPI DocumentType_get_internalSubset(IDOMDocumentType *iface, VARIANT *p)
265 DocumentType *This = impl_from_IDOMDocumentType(iface);
267 FIXME("(%p)->(%p)\n", This, p);
269 return E_NOTIMPL;
272 static const IDOMDocumentTypeVtbl DocumentTypeVtbl = {
273 DocumentType_QueryInterface,
274 DocumentType_AddRef,
275 DocumentType_Release,
276 DocumentType_GetTypeInfoCount,
277 DocumentType_GetTypeInfo,
278 DocumentType_GetIDsOfNames,
279 DocumentType_Invoke,
280 DocumentType_get_name,
281 DocumentType_get_entities,
282 DocumentType_get_notations,
283 DocumentType_get_publicId,
284 DocumentType_get_systemId,
285 DocumentType_get_internalSubset
288 static inline DocumentType *DocumentType_from_HTMLDOMNode(HTMLDOMNode *iface)
290 return CONTAINING_RECORD(iface, DocumentType, node);
293 static inline DocumentType *DocumentType_from_DispatchEx(DispatchEx *iface)
295 return CONTAINING_RECORD(iface, DocumentType, node.event_target.dispex);
298 static HRESULT DocumentType_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
300 DocumentType *This = DocumentType_from_HTMLDOMNode(iface);
302 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDOMDocumentType, riid))
303 *ppv = &This->IDOMDocumentType_iface;
304 else
305 return HTMLDOMNode_QI(&This->node, riid, ppv);
307 IUnknown_AddRef((IUnknown*)*ppv);
308 return S_OK;
311 static HRESULT DocumentType_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
313 DocumentType *This = DocumentType_from_HTMLDOMNode(iface);
315 return create_doctype_node(This->node.doc, nsnode, ret);
318 static const cpc_entry_t DocumentType_cpc[] = {{NULL}};
320 static const NodeImplVtbl DocumentTypeImplVtbl = {
321 .qi = DocumentType_QI,
322 .cpc_entries = DocumentType_cpc,
323 .clone = DocumentType_clone
326 static nsISupports *DocumentType_get_gecko_target(DispatchEx *dispex)
328 DocumentType *This = DocumentType_from_DispatchEx(dispex);
329 return (nsISupports*)This->node.nsnode;
332 static EventTarget *DocumentType_get_parent_event_target(DispatchEx *dispex)
334 DocumentType *This = DocumentType_from_DispatchEx(dispex);
335 nsIDOMNode *nsnode;
336 HTMLDOMNode *node;
337 nsresult nsres;
338 HRESULT hres;
340 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
341 assert(nsres == NS_OK);
342 if(!nsnode)
343 return NULL;
345 hres = get_node(nsnode, TRUE, &node);
346 nsIDOMNode_Release(nsnode);
347 if(FAILED(hres))
348 return NULL;
350 return &node->event_target;
353 static IHTMLEventObj *DocumentType_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
355 DocumentType *This = DocumentType_from_DispatchEx(dispex);
356 return default_set_current_event(This->node.doc->window, event);
359 static const event_target_vtbl_t DocumentType_event_target_vtbl = {
361 .destructor = HTMLDOMNode_destructor,
362 .traverse = HTMLDOMNode_traverse,
363 .unlink = HTMLDOMNode_unlink
365 .get_gecko_target = DocumentType_get_gecko_target,
366 .get_parent_event_target = DocumentType_get_parent_event_target,
367 .set_current_event = DocumentType_set_current_event
370 static const tid_t DocumentType_iface_tids[] = {
371 IDOMDocumentType_tid,
372 IHTMLDOMNode_tid,
373 IHTMLDOMNode2_tid,
374 IHTMLDOMNode3_tid,
378 static dispex_static_data_t DocumentType_dispex = {
379 "DocumentType",
380 &DocumentType_event_target_vtbl.dispex_vtbl,
381 DispDOMDocumentType_tid,
382 DocumentType_iface_tids
385 HRESULT create_doctype_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **ret)
387 nsIDOMDocumentType *nsdoctype;
388 DocumentType *doctype;
389 nsresult nsres;
391 if(!(doctype = calloc(1, sizeof(*doctype))))
392 return E_OUTOFMEMORY;
394 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMDocumentType, (void**)&nsdoctype);
395 assert(nsres == NS_OK);
397 doctype->node.vtbl = &DocumentTypeImplVtbl;
398 doctype->IDOMDocumentType_iface.lpVtbl = &DocumentTypeVtbl;
399 HTMLDOMNode_Init(doc, &doctype->node, (nsIDOMNode*)nsdoctype, &DocumentType_dispex);
400 nsIDOMDocumentType_Release(nsdoctype);
402 *ret = &doctype->node;
403 return S_OK;
406 static inline HTMLDocumentNode *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
408 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument2_iface);
411 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
413 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
415 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
418 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
420 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
422 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
425 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
427 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
429 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
432 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
434 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
436 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
439 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo, LCID lcid,
440 ITypeInfo **ppTInfo)
442 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
444 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
447 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid, LPOLESTR *rgszNames,
448 UINT cNames, LCID lcid, DISPID *rgDispId)
450 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
452 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
453 rgDispId);
456 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
457 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
459 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
461 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
462 pDispParams, pVarResult, pExcepInfo, puArgErr);
465 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
467 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
468 HRESULT hres;
470 TRACE("(%p)->(%p)\n", This, p);
472 hres = IHTMLDocument7_get_parentWindow(&This->IHTMLDocument7_iface, (IHTMLWindow2**)p);
473 return hres == S_OK && !*p ? E_PENDING : hres;
476 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
478 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
480 TRACE("(%p)->(%p)\n", This, p);
481 *p = create_all_collection(&This->node, FALSE);
483 return S_OK;
486 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
488 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
489 nsIDOMElement *nsbody = NULL;
490 HTMLElement *element;
491 nsresult nsres;
492 HRESULT hres;
494 TRACE("(%p)->(%p)\n", This, p);
496 if(This->html_document) {
497 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, (nsIDOMHTMLElement **)&nsbody);
498 if(NS_FAILED(nsres)) {
499 TRACE("Could not get body: %08lx\n", nsres);
500 return E_UNEXPECTED;
502 }else {
503 nsAString nsnode_name;
504 nsIDOMDocumentFragment *frag;
506 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&frag);
507 if(!NS_FAILED(nsres)) {
508 nsAString_InitDepend(&nsnode_name, L"BODY");
509 nsIDOMDocumentFragment_QuerySelector(frag, &nsnode_name, &nsbody);
510 nsAString_Finish(&nsnode_name);
511 nsIDOMDocumentFragment_Release(frag);
515 if(!nsbody) {
516 *p = NULL;
517 return S_OK;
520 hres = get_element(nsbody, &element);
521 nsIDOMElement_Release(nsbody);
522 if(FAILED(hres))
523 return hres;
525 *p = &element->IHTMLElement_iface;
526 return S_OK;
529 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
531 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
532 nsIDOMElement *nselem;
533 HTMLElement *elem;
534 nsresult nsres;
535 HRESULT hres;
537 TRACE("(%p)->(%p)\n", This, p);
539 if(!This->dom_document) {
540 *p = NULL;
541 return S_OK;
545 * NOTE: Gecko may return an active element even if the document is not visible.
546 * IE returns NULL in this case.
548 nsres = nsIDOMDocument_GetActiveElement(This->dom_document, &nselem);
549 if(NS_FAILED(nsres)) {
550 ERR("GetActiveElement failed: %08lx\n", nsres);
551 return E_FAIL;
554 if(!nselem) {
555 *p = NULL;
556 return S_OK;
559 hres = get_element(nselem, &elem);
560 nsIDOMElement_Release(nselem);
561 if(FAILED(hres))
562 return hres;
564 *p = &elem->IHTMLElement_iface;
565 return S_OK;
568 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
570 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
571 nsIDOMHTMLCollection *nscoll = NULL;
572 nsresult nsres;
574 TRACE("(%p)->(%p)\n", This, p);
576 if(!p)
577 return E_INVALIDARG;
579 *p = NULL;
581 if(!This->dom_document) {
582 WARN("NULL dom_document\n");
583 return E_UNEXPECTED;
586 if(!This->html_document) {
587 FIXME("Not implemented for XML document\n");
588 return E_NOTIMPL;
591 nsres = nsIDOMHTMLDocument_GetImages(This->html_document, &nscoll);
592 if(NS_FAILED(nsres)) {
593 ERR("GetImages failed: %08lx\n", nsres);
594 return E_FAIL;
597 if(nscoll) {
598 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
599 nsIDOMHTMLCollection_Release(nscoll);
602 return S_OK;
605 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
607 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
608 nsIDOMHTMLCollection *nscoll = NULL;
609 nsresult nsres;
611 TRACE("(%p)->(%p)\n", This, p);
613 if(!p)
614 return E_INVALIDARG;
616 *p = NULL;
618 if(!This->dom_document) {
619 WARN("NULL dom_document\n");
620 return E_UNEXPECTED;
623 if(!This->html_document) {
624 FIXME("Not implemented for XML document\n");
625 return E_NOTIMPL;
628 nsres = nsIDOMHTMLDocument_GetApplets(This->html_document, &nscoll);
629 if(NS_FAILED(nsres)) {
630 ERR("GetApplets failed: %08lx\n", nsres);
631 return E_FAIL;
634 if(nscoll) {
635 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
636 nsIDOMHTMLCollection_Release(nscoll);
639 return S_OK;
642 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
644 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
645 nsIDOMHTMLCollection *nscoll = NULL;
646 nsresult nsres;
648 TRACE("(%p)->(%p)\n", This, p);
650 if(!p)
651 return E_INVALIDARG;
653 *p = NULL;
655 if(!This->dom_document) {
656 WARN("NULL dom_document\n");
657 return E_UNEXPECTED;
660 if(!This->html_document) {
661 FIXME("Not implemented for XML document\n");
662 return E_NOTIMPL;
665 nsres = nsIDOMHTMLDocument_GetLinks(This->html_document, &nscoll);
666 if(NS_FAILED(nsres)) {
667 ERR("GetLinks failed: %08lx\n", nsres);
668 return E_FAIL;
671 if(nscoll) {
672 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
673 nsIDOMHTMLCollection_Release(nscoll);
676 return S_OK;
679 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
681 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
682 nsIDOMHTMLCollection *nscoll = NULL;
683 nsresult nsres;
685 TRACE("(%p)->(%p)\n", This, p);
687 if(!p)
688 return E_INVALIDARG;
690 *p = NULL;
692 if(!This->dom_document) {
693 WARN("NULL dom_document\n");
694 return E_UNEXPECTED;
697 if(!This->html_document) {
698 FIXME("Not implemented for XML document\n");
699 return E_NOTIMPL;
702 nsres = nsIDOMHTMLDocument_GetForms(This->html_document, &nscoll);
703 if(NS_FAILED(nsres)) {
704 ERR("GetForms failed: %08lx\n", nsres);
705 return E_FAIL;
708 if(nscoll) {
709 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
710 nsIDOMHTMLCollection_Release(nscoll);
713 return S_OK;
716 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
718 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
719 nsIDOMHTMLCollection *nscoll = NULL;
720 nsresult nsres;
722 TRACE("(%p)->(%p)\n", This, p);
724 if(!p)
725 return E_INVALIDARG;
727 *p = NULL;
729 if(!This->dom_document) {
730 WARN("NULL dom_document\n");
731 return E_UNEXPECTED;
734 if(!This->html_document) {
735 FIXME("Not implemented for XML document\n");
736 return E_NOTIMPL;
739 nsres = nsIDOMHTMLDocument_GetAnchors(This->html_document, &nscoll);
740 if(NS_FAILED(nsres)) {
741 ERR("GetAnchors failed: %08lx\n", nsres);
742 return E_FAIL;
745 if(nscoll) {
746 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
747 nsIDOMHTMLCollection_Release(nscoll);
750 return S_OK;
753 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
755 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
756 nsAString nsstr;
757 nsresult nsres;
759 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
761 if(!This->dom_document) {
762 WARN("NULL dom_document\n");
763 return E_UNEXPECTED;
766 nsAString_InitDepend(&nsstr, v);
767 nsres = nsIDOMDocument_SetTitle(This->dom_document, &nsstr);
768 nsAString_Finish(&nsstr);
769 if(NS_FAILED(nsres))
770 ERR("SetTitle failed: %08lx\n", nsres);
772 return S_OK;
775 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
777 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
778 const PRUnichar *ret;
779 nsAString nsstr;
780 nsresult nsres;
782 TRACE("(%p)->(%p)\n", This, p);
784 if(!This->dom_document) {
785 WARN("NULL dom_document\n");
786 return E_UNEXPECTED;
790 nsAString_Init(&nsstr, NULL);
791 nsres = nsIDOMDocument_GetTitle(This->dom_document, &nsstr);
792 if (NS_SUCCEEDED(nsres)) {
793 nsAString_GetData(&nsstr, &ret);
794 *p = SysAllocString(ret);
796 nsAString_Finish(&nsstr);
798 if(NS_FAILED(nsres)) {
799 ERR("GetTitle failed: %08lx\n", nsres);
800 return E_FAIL;
803 return S_OK;
806 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
808 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
809 nsIDOMHTMLCollection *nscoll = NULL;
810 nsresult nsres;
812 TRACE("(%p)->(%p)\n", This, p);
814 if(!p)
815 return E_INVALIDARG;
817 *p = NULL;
819 if(!This->dom_document) {
820 WARN("NULL dom_document\n");
821 return E_UNEXPECTED;
824 if(!This->html_document) {
825 FIXME("Not implemented for XML document\n");
826 return E_NOTIMPL;
829 nsres = nsIDOMHTMLDocument_GetScripts(This->html_document, &nscoll);
830 if(NS_FAILED(nsres)) {
831 ERR("GetImages failed: %08lx\n", nsres);
832 return E_FAIL;
835 if(nscoll) {
836 *p = create_collection_from_htmlcol(nscoll, This->document_mode);
837 nsIDOMHTMLCollection_Release(nscoll);
840 return S_OK;
843 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
845 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
846 HTMLDocumentObj *doc_obj;
847 HRESULT hres;
849 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
851 if(wcsicmp(v, L"on")) {
852 FIXME("Unsupported arg %s\n", debugstr_w(v));
853 return E_NOTIMPL;
856 doc_obj = This->doc_obj;
857 IUnknown_AddRef(doc_obj->outer_unk);
858 hres = setup_edit_mode(doc_obj);
859 IUnknown_Release(doc_obj->outer_unk);
860 if(FAILED(hres))
861 return hres;
863 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
864 return S_OK;
867 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
869 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
870 FIXME("(%p)->(%p) always returning Off\n", This, p);
872 if(!p)
873 return E_INVALIDARG;
875 *p = SysAllocString(L"Off");
877 return S_OK;
880 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
882 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
883 nsISelection *nsselection;
884 nsresult nsres;
886 TRACE("(%p)->(%p)\n", This, p);
888 if(!This->html_document) {
889 FIXME("Not implemented for XML document\n");
890 return E_NOTIMPL;
893 nsres = nsIDOMHTMLDocument_GetSelection(This->html_document, &nsselection);
894 if(NS_FAILED(nsres)) {
895 ERR("GetSelection failed: %08lx\n", nsres);
896 return E_FAIL;
899 return HTMLSelectionObject_Create(This, nsselection, p);
902 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
904 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
906 TRACE("(%p)->(%p)\n", iface, p);
908 if(!p)
909 return E_POINTER;
911 return get_readystate_string(This->outer_window ? This->outer_window->readystate : 0, p);
914 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
916 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
918 TRACE("(%p)->(%p)\n", This, p);
920 if(!This->outer_window) {
921 /* Not implemented by IE */
922 return E_NOTIMPL;
924 return IHTMLWindow2_get_frames(&This->outer_window->base.IHTMLWindow2_iface, p);
927 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
929 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
930 FIXME("(%p)->(%p)\n", This, p);
931 return E_NOTIMPL;
934 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
936 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
937 FIXME("(%p)->(%p)\n", This, p);
938 return E_NOTIMPL;
941 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
943 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
944 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
945 return E_NOTIMPL;
948 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
950 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
951 FIXME("(%p)->(%p)\n", This, p);
952 return E_NOTIMPL;
955 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
957 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
958 IHTMLElement *element = NULL;
959 IHTMLBodyElement *body;
960 HRESULT hr;
962 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
964 hr = IHTMLDocument2_get_body(iface, &element);
965 if (FAILED(hr))
967 ERR("Failed to get body (0x%08lx)\n", hr);
968 return hr;
971 if(!element)
973 FIXME("Empty body element.\n");
974 return hr;
977 hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body);
978 if (SUCCEEDED(hr))
980 hr = IHTMLBodyElement_put_bgColor(body, v);
981 IHTMLBodyElement_Release(body);
983 IHTMLElement_Release(element);
985 return hr;
988 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
990 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
991 nsAString nsstr;
992 nsresult nsres;
993 HRESULT hres;
995 TRACE("(%p)->(%p)\n", This, p);
997 if(!This->dom_document) {
998 WARN("NULL dom_document\n");
999 return E_UNEXPECTED;
1002 if(!This->html_document) {
1003 FIXME("Not implemented for XML document\n");
1004 return E_NOTIMPL;
1007 nsAString_Init(&nsstr, NULL);
1008 nsres = nsIDOMHTMLDocument_GetBgColor(This->html_document, &nsstr);
1009 hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p);
1010 if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) {
1011 TRACE("default #ffffff\n");
1012 if(!(V_BSTR(p) = SysAllocString(L"#ffffff")))
1013 hres = E_OUTOFMEMORY;
1015 return hres;
1018 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
1020 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1021 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1022 return E_NOTIMPL;
1025 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
1027 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1028 FIXME("(%p)->(%p)\n", This, p);
1029 return E_NOTIMPL;
1032 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
1034 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1035 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1036 return E_NOTIMPL;
1039 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
1041 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1042 FIXME("(%p)->(%p)\n", This, p);
1043 return E_NOTIMPL;
1046 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
1048 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1049 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1050 return E_NOTIMPL;
1053 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
1055 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1056 FIXME("(%p)->(%p)\n", This, p);
1057 return E_NOTIMPL;
1060 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
1062 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1063 nsAString nsstr;
1064 nsresult nsres;
1066 TRACE("(%p)->(%p)\n", This, p);
1068 nsAString_InitDepend(&nsstr, NULL);
1069 nsres = nsIDOMDocument_GetReferrer(This->dom_document, &nsstr);
1070 return return_nsstr(nsres, &nsstr, p);
1073 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
1075 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1077 TRACE("(%p)->(%p)\n", This, p);
1079 if(!This->dom_document || !This->window) {
1080 WARN("NULL window\n");
1081 return E_UNEXPECTED;
1084 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
1087 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
1089 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1090 FIXME("(%p)->(%p)\n", This, p);
1091 return E_NOTIMPL;
1094 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
1096 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1098 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1100 if(!This->outer_window) {
1101 FIXME("No window available\n");
1102 return E_FAIL;
1105 return navigate_url(This->outer_window, v, This->outer_window->uri, BINDING_NAVIGATED);
1108 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
1110 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1112 TRACE("(%p)->(%p)\n", iface, p);
1114 *p = SysAllocString(This->outer_window && This->outer_window->url ? This->outer_window->url : L"about:blank");
1115 return *p ? S_OK : E_OUTOFMEMORY;
1118 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
1120 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1121 nsAString nsstr;
1122 nsresult nsres;
1124 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1126 if(!This->html_document) {
1127 FIXME("Not implemented for XML document\n");
1128 return E_NOTIMPL;
1131 nsAString_InitDepend(&nsstr, v);
1132 nsres = nsIDOMHTMLDocument_SetDomain(This->html_document, &nsstr);
1133 nsAString_Finish(&nsstr);
1134 if(NS_FAILED(nsres)) {
1135 ERR("SetDomain failed: %08lx\n", nsres);
1136 return E_INVALIDARG;
1139 return S_OK;
1142 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
1144 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1145 nsAString nsstr;
1146 nsresult nsres;
1148 TRACE("(%p)->(%p)\n", This, p);
1150 if(!This->html_document) {
1151 FIXME("Not implemented for XML document\n");
1152 return E_NOTIMPL;
1155 if(This->outer_window && !This->outer_window->uri)
1156 return E_FAIL;
1158 nsAString_Init(&nsstr, NULL);
1159 nsres = nsIDOMHTMLDocument_GetDomain(This->html_document, &nsstr);
1160 if(NS_SUCCEEDED(nsres) && This->outer_window && This->outer_window->uri) {
1161 const PRUnichar *str;
1162 HRESULT hres;
1164 nsAString_GetData(&nsstr, &str);
1165 if(!*str) {
1166 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
1167 nsAString_Finish(&nsstr);
1168 hres = IUri_GetHost(This->outer_window->uri, p);
1169 return FAILED(hres) ? hres : S_OK;
1173 return return_nsstr(nsres, &nsstr, p);
1176 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
1178 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1179 BOOL bret;
1181 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1183 if(!This->outer_window)
1184 return S_OK;
1186 bret = InternetSetCookieExW(This->outer_window->url, NULL, v, 0, 0);
1187 if(!bret) {
1188 FIXME("InternetSetCookieExW failed: %lu\n", GetLastError());
1189 return HRESULT_FROM_WIN32(GetLastError());
1192 return S_OK;
1195 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
1197 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1198 DWORD size;
1199 BOOL bret;
1201 TRACE("(%p)->(%p)\n", This, p);
1203 if(!This->outer_window) {
1204 *p = NULL;
1205 return S_OK;
1208 size = 0;
1209 bret = InternetGetCookieExW(This->outer_window->url, NULL, NULL, &size, 0, NULL);
1210 if(!bret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
1211 WARN("InternetGetCookieExW failed: %lu\n", GetLastError());
1212 *p = NULL;
1213 return S_OK;
1216 if(!size) {
1217 *p = NULL;
1218 return S_OK;
1221 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
1222 if(!*p)
1223 return E_OUTOFMEMORY;
1225 bret = InternetGetCookieExW(This->outer_window->url, NULL, *p, &size, 0, NULL);
1226 if(!bret) {
1227 ERR("InternetGetCookieExW failed: %lu\n", GetLastError());
1228 return E_FAIL;
1231 return S_OK;
1234 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
1236 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1237 FIXME("(%p)->(%x)\n", This, v);
1238 return E_NOTIMPL;
1241 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
1243 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1244 FIXME("(%p)->(%p)\n", This, p);
1245 return E_NOTIMPL;
1248 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
1250 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1251 FIXME("(%p)->(%s) returning S_OK\n", This, debugstr_w(v));
1252 return S_OK;
1255 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
1257 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1259 TRACE("(%p)->(%p)\n", This, p);
1261 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
1264 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
1266 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1267 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1268 return E_NOTIMPL;
1271 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
1273 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1275 TRACE("(%p)->(%p)\n", This, p);
1277 *p = charset_string_from_cp(GetACP());
1278 return *p ? S_OK : E_OUTOFMEMORY;
1281 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
1283 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1284 const PRUnichar *content_type;
1285 nsAString nsstr;
1286 nsresult nsres;
1287 HRESULT hres;
1289 TRACE("(%p)->(%p)\n", This, p);
1291 *p = NULL;
1293 if(This->window && This->window->base.outer_window->readystate == READYSTATE_UNINITIALIZED)
1294 return (*p = SysAllocString(L"")) ? S_OK : E_FAIL;
1296 nsAString_InitDepend(&nsstr, NULL);
1297 nsres = nsIDOMDocument_GetContentType(This->dom_document, &nsstr);
1298 if(NS_FAILED(nsres))
1299 return map_nsresult(nsres);
1301 nsAString_GetData(&nsstr, &content_type);
1302 hres = get_mime_type_display_name(content_type, p);
1303 nsAString_Finish(&nsstr);
1304 return hres;
1307 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
1309 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1310 FIXME("(%p)->(%p)\n", This, p);
1311 return E_NOTIMPL;
1314 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
1316 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1317 FIXME("(%p)->(%p)\n", This, p);
1318 return E_NOTIMPL;
1321 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
1323 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1324 FIXME("(%p)->(%p)\n", This, p);
1325 return E_NOTIMPL;
1328 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
1330 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1331 FIXME("(%p)->(%p)\n", This, p);
1332 return E_NOTIMPL;
1335 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
1337 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1338 FIXME("(%p)->(%p)\n", This, p);
1339 return E_NOTIMPL;
1342 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
1344 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1345 FIXME("(%p)->(%p)\n", This, p);
1346 return E_NOTIMPL;
1349 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1351 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1352 FIXME("(%p)->(%p)\n", This, p);
1353 return E_NOTIMPL;
1356 static HRESULT document_write(HTMLDocumentNode *This, SAFEARRAY *psarray, BOOL ln)
1358 VARIANT *var, tmp;
1359 JSContext *jsctx;
1360 nsAString nsstr;
1361 ULONG i, argc;
1362 nsresult nsres;
1363 HRESULT hres;
1365 if(!This->dom_document) {
1366 WARN("NULL dom_document\n");
1367 return E_UNEXPECTED;
1370 if(!This->html_document) {
1371 FIXME("Not implemented for XML document\n");
1372 return E_NOTIMPL;
1375 if (!psarray)
1376 return S_OK;
1378 if(psarray->cDims != 1) {
1379 FIXME("cDims=%d\n", psarray->cDims);
1380 return E_INVALIDARG;
1383 hres = SafeArrayAccessData(psarray, (void**)&var);
1384 if(FAILED(hres)) {
1385 WARN("SafeArrayAccessData failed: %08lx\n", hres);
1386 return hres;
1389 V_VT(&tmp) = VT_EMPTY;
1391 jsctx = get_context_from_document(This->dom_document);
1392 argc = psarray->rgsabound[0].cElements;
1393 for(i=0; i < argc; i++) {
1394 if(V_VT(var+i) == VT_BSTR) {
1395 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1396 }else {
1397 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1398 if(FAILED(hres)) {
1399 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1400 break;
1402 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1405 if(!ln || i != argc-1)
1406 nsres = nsIDOMHTMLDocument_Write(This->html_document, &nsstr, jsctx);
1407 else
1408 nsres = nsIDOMHTMLDocument_Writeln(This->html_document, &nsstr, jsctx);
1409 nsAString_Finish(&nsstr);
1410 if(V_VT(var+i) != VT_BSTR)
1411 VariantClear(&tmp);
1412 if(NS_FAILED(nsres)) {
1413 ERR("Write failed: %08lx\n", nsres);
1414 hres = E_FAIL;
1415 break;
1419 SafeArrayUnaccessData(psarray);
1421 return hres;
1424 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1426 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1428 TRACE("(%p)->(%p)\n", iface, psarray);
1430 return document_write(This, psarray, FALSE);
1433 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1435 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1437 TRACE("(%p)->(%p)\n", This, psarray);
1439 return document_write(This, psarray, TRUE);
1442 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1443 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1445 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1446 nsISupports *tmp;
1447 nsresult nsres;
1449 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1450 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1452 *pomWindowResult = NULL;
1454 if(!This->outer_window)
1455 return E_FAIL;
1457 if(!This->dom_document) {
1458 ERR("!dom_document\n");
1459 return E_NOTIMPL;
1462 if(!This->html_document) {
1463 FIXME("Not implemented for XML document\n");
1464 return E_NOTIMPL;
1467 if(!url || wcscmp(url, L"text/html") || V_VT(&name) != VT_ERROR
1468 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1469 FIXME("unsupported args\n");
1471 nsres = nsIDOMHTMLDocument_Open(This->html_document, NULL, NULL, NULL,
1472 get_context_from_document(This->dom_document), 0, &tmp);
1473 if(NS_FAILED(nsres)) {
1474 ERR("Open failed: %08lx\n", nsres);
1475 return E_FAIL;
1478 if(tmp)
1479 nsISupports_Release(tmp);
1481 *pomWindowResult = (IDispatch*)&This->outer_window->base.IHTMLWindow2_iface;
1482 IHTMLWindow2_AddRef(&This->outer_window->base.IHTMLWindow2_iface);
1483 return S_OK;
1486 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1488 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1489 nsresult nsres;
1491 TRACE("(%p)\n", This);
1493 if(!This->dom_document) {
1494 ERR("!dom_document\n");
1495 return E_NOTIMPL;
1498 if(!This->html_document) {
1499 FIXME("Not implemented for XML document\n");
1500 return E_NOTIMPL;
1503 nsres = nsIDOMHTMLDocument_Close(This->html_document);
1504 if(NS_FAILED(nsres)) {
1505 ERR("Close failed: %08lx\n", nsres);
1506 return E_FAIL;
1509 return S_OK;
1512 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1514 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1515 nsresult nsres;
1517 TRACE("(%p)\n", This);
1519 if(!This->html_document) {
1520 FIXME("Not implemented for XML document\n");
1521 return E_NOTIMPL;
1524 nsres = nsIDOMHTMLDocument_Clear(This->html_document);
1525 if(NS_FAILED(nsres)) {
1526 ERR("Clear failed: %08lx\n", nsres);
1527 return E_FAIL;
1530 return S_OK;
1533 static const struct {
1534 const WCHAR *name;
1535 OLECMDID id;
1536 }command_names[] = {
1537 {L"copy", IDM_COPY},
1538 {L"cut", IDM_CUT},
1539 {L"fontname", IDM_FONTNAME},
1540 {L"fontsize", IDM_FONTSIZE},
1541 {L"indent", IDM_INDENT},
1542 {L"insertorderedlist", IDM_ORDERLIST},
1543 {L"insertunorderedlist", IDM_UNORDERLIST},
1544 {L"outdent", IDM_OUTDENT},
1545 {L"paste", IDM_PASTE},
1546 {L"respectvisibilityindesign", IDM_RESPECTVISIBILITY_INDESIGN}
1549 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1551 int i;
1553 for(i = 0; i < ARRAY_SIZE(command_names); i++) {
1554 if(!wcsicmp(command_names[i].name, str)) {
1555 *cmdid = command_names[i].id;
1556 return TRUE;
1560 FIXME("Unknown command %s\n", debugstr_w(str));
1561 return FALSE;
1564 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1565 VARIANT_BOOL *pfRet)
1567 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1568 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1569 return E_NOTIMPL;
1572 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1573 VARIANT_BOOL *pfRet)
1575 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1576 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1577 return E_NOTIMPL;
1580 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1581 VARIANT_BOOL *pfRet)
1583 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1584 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1585 return E_NOTIMPL;
1588 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1589 VARIANT_BOOL *pfRet)
1591 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1592 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1593 return E_NOTIMPL;
1596 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1597 BSTR *pfRet)
1599 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1600 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1601 return E_NOTIMPL;
1604 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1605 VARIANT *pfRet)
1607 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1608 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1609 return E_NOTIMPL;
1612 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1613 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1615 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1616 OLECMDID cmdid;
1617 VARIANT ret;
1618 HRESULT hres;
1620 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1622 if(!cmdid_from_string(cmdID, &cmdid))
1623 return OLECMDERR_E_NOTSUPPORTED;
1625 V_VT(&ret) = VT_EMPTY;
1626 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1627 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1628 if(FAILED(hres))
1629 return hres;
1631 if(V_VT(&ret) != VT_EMPTY) {
1632 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1633 VariantClear(&ret);
1636 *pfRet = VARIANT_TRUE;
1637 return S_OK;
1640 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1641 VARIANT_BOOL *pfRet)
1643 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1644 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1645 return E_NOTIMPL;
1648 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1649 IHTMLElement **newElem)
1651 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1652 HTMLElement *elem;
1653 HRESULT hres;
1655 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1657 hres = create_element(This, eTag, &elem);
1658 if(FAILED(hres))
1659 return hres;
1661 *newElem = &elem->IHTMLElement_iface;
1662 return S_OK;
1665 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1667 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1668 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1669 return E_NOTIMPL;
1672 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1674 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1675 FIXME("(%p)->(%p)\n", This, p);
1676 return E_NOTIMPL;
1679 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1681 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1683 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1685 return set_doc_event(This, EVENTID_CLICK, &v);
1688 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1690 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1692 TRACE("(%p)->(%p)\n", This, p);
1694 return get_doc_event(This, EVENTID_CLICK, p);
1697 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1699 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1701 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1703 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1706 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1708 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1710 TRACE("(%p)->(%p)\n", This, p);
1712 return get_doc_event(This, EVENTID_DBLCLICK, p);
1715 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1717 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1719 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1721 return set_doc_event(This, EVENTID_KEYUP, &v);
1724 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1726 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1728 TRACE("(%p)->(%p)\n", This, p);
1730 return get_doc_event(This, EVENTID_KEYUP, p);
1733 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1735 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1737 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1739 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1742 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1744 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1746 TRACE("(%p)->(%p)\n", This, p);
1748 return get_doc_event(This, EVENTID_KEYDOWN, p);
1751 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1753 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1755 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1757 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1760 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1762 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1764 TRACE("(%p)->(%p)\n", This, p);
1766 return get_doc_event(This, EVENTID_KEYPRESS, p);
1769 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1771 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1773 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1775 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1778 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1780 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1782 TRACE("(%p)->(%p)\n", This, p);
1784 return get_doc_event(This, EVENTID_MOUSEUP, p);
1787 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1789 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1791 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1793 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1796 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1798 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1800 TRACE("(%p)->(%p)\n", This, p);
1802 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1805 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1807 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1809 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1811 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1814 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1816 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1818 TRACE("(%p)->(%p)\n", This, p);
1820 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1823 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1825 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1827 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1829 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1832 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1834 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1836 TRACE("(%p)->(%p)\n", This, p);
1838 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1841 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1843 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1845 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1847 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1850 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1852 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1854 TRACE("(%p)->(%p)\n", This, p);
1856 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1859 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1861 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1863 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1865 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1868 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1870 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1872 TRACE("(%p)->(%p)\n", This, p);
1874 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1877 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1879 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1880 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1881 return E_NOTIMPL;
1884 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1886 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1887 FIXME("(%p)->(%p)\n", This, p);
1888 return E_NOTIMPL;
1891 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1893 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1894 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1895 return E_NOTIMPL;
1898 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1900 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1901 FIXME("(%p)->(%p)\n", This, p);
1902 return E_NOTIMPL;
1905 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1907 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1908 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1909 return E_NOTIMPL;
1912 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1914 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1915 FIXME("(%p)->(%p)\n", This, p);
1916 return E_NOTIMPL;
1919 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1921 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1923 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1925 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1928 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1930 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1932 TRACE("(%p)->(%p)\n", This, p);
1934 return get_doc_event(This, EVENTID_DRAGSTART, p);
1937 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1939 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1941 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1943 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1946 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1948 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1950 TRACE("(%p)->(%p)\n", This, p);
1952 return get_doc_event(This, EVENTID_SELECTSTART, p);
1955 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1956 IHTMLElement **elementHit)
1958 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1959 nsIDOMElement *nselem;
1960 HTMLElement *element;
1961 nsresult nsres;
1962 HRESULT hres;
1964 TRACE("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1966 nsres = nsIDOMDocument_ElementFromPoint(This->dom_document, x, y, &nselem);
1967 if(NS_FAILED(nsres)) {
1968 ERR("ElementFromPoint failed: %08lx\n", nsres);
1969 return E_FAIL;
1972 if(!nselem) {
1973 *elementHit = NULL;
1974 return S_OK;
1977 hres = get_element(nselem, &element);
1978 nsIDOMElement_Release(nselem);
1979 if(FAILED(hres))
1980 return hres;
1982 *elementHit = &element->IHTMLElement_iface;
1983 return S_OK;
1986 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1988 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
1989 HRESULT hres;
1991 TRACE("(%p)->(%p)\n", This, p);
1993 hres = IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
1994 return hres == S_OK && !*p ? E_FAIL : hres;
1997 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1998 IHTMLStyleSheetsCollection **p)
2000 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2001 nsIDOMStyleSheetList *nsstylelist;
2002 nsresult nsres;
2003 HRESULT hres;
2005 TRACE("(%p)->(%p)\n", This, p);
2007 *p = NULL;
2009 if(!This->dom_document) {
2010 WARN("NULL dom_document\n");
2011 return E_UNEXPECTED;
2014 nsres = nsIDOMDocument_GetStyleSheets(This->dom_document, &nsstylelist);
2015 if(NS_FAILED(nsres)) {
2016 ERR("GetStyleSheets failed: %08lx\n", nsres);
2017 return map_nsresult(nsres);
2020 hres = create_style_sheet_collection(nsstylelist,
2021 dispex_compat_mode(&This->node.event_target.dispex), p);
2022 nsIDOMStyleSheetList_Release(nsstylelist);
2023 return hres;
2026 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
2028 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2029 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2030 return E_NOTIMPL;
2033 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
2035 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2036 FIXME("(%p)->(%p)\n", This, p);
2037 return E_NOTIMPL;
2040 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
2042 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2043 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2044 return E_NOTIMPL;
2047 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
2049 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2050 FIXME("(%p)->(%p)\n", This, p);
2051 return E_NOTIMPL;
2054 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
2056 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2058 TRACE("(%p)->(%p)\n", This, String);
2060 return dispex_to_string(&This->node.event_target.dispex, String);
2063 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
2064 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
2066 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
2067 nsIDOMHTMLHeadElement *head_elem;
2068 IHTMLStyleElement *style_elem;
2069 HTMLElement *elem;
2070 nsresult nsres;
2071 HRESULT hres;
2073 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
2075 if(!This->dom_document) {
2076 FIXME("not a real doc object\n");
2077 return E_NOTIMPL;
2080 if(!This->html_document) {
2081 FIXME("Not implemented for XML document\n");
2082 return E_NOTIMPL;
2085 if(lIndex != -1)
2086 FIXME("Unsupported lIndex %ld\n", lIndex);
2088 if(bstrHref && *bstrHref) {
2089 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
2090 return create_style_sheet(NULL, dispex_compat_mode(&This->node.event_target.dispex),
2091 ppnewStyleSheet);
2094 hres = create_element(This, L"style", &elem);
2095 if(FAILED(hres))
2096 return hres;
2098 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &head_elem);
2099 if(NS_SUCCEEDED(nsres)) {
2100 nsIDOMNode *head_node, *tmp_node;
2102 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
2103 nsIDOMHTMLHeadElement_Release(head_elem);
2104 assert(nsres == NS_OK);
2106 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
2107 nsIDOMNode_Release(head_node);
2108 if(NS_SUCCEEDED(nsres) && tmp_node)
2109 nsIDOMNode_Release(tmp_node);
2111 if(NS_FAILED(nsres)) {
2112 IHTMLElement_Release(&elem->IHTMLElement_iface);
2113 return E_FAIL;
2116 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
2117 assert(hres == S_OK);
2118 IHTMLElement_Release(&elem->IHTMLElement_iface);
2120 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
2121 IHTMLStyleElement_Release(style_elem);
2122 return hres;
2125 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
2126 HTMLDocument_QueryInterface,
2127 HTMLDocument_AddRef,
2128 HTMLDocument_Release,
2129 HTMLDocument_GetTypeInfoCount,
2130 HTMLDocument_GetTypeInfo,
2131 HTMLDocument_GetIDsOfNames,
2132 HTMLDocument_Invoke,
2133 HTMLDocument_get_Script,
2134 HTMLDocument_get_all,
2135 HTMLDocument_get_body,
2136 HTMLDocument_get_activeElement,
2137 HTMLDocument_get_images,
2138 HTMLDocument_get_applets,
2139 HTMLDocument_get_links,
2140 HTMLDocument_get_forms,
2141 HTMLDocument_get_anchors,
2142 HTMLDocument_put_title,
2143 HTMLDocument_get_title,
2144 HTMLDocument_get_scripts,
2145 HTMLDocument_put_designMode,
2146 HTMLDocument_get_designMode,
2147 HTMLDocument_get_selection,
2148 HTMLDocument_get_readyState,
2149 HTMLDocument_get_frames,
2150 HTMLDocument_get_embeds,
2151 HTMLDocument_get_plugins,
2152 HTMLDocument_put_alinkColor,
2153 HTMLDocument_get_alinkColor,
2154 HTMLDocument_put_bgColor,
2155 HTMLDocument_get_bgColor,
2156 HTMLDocument_put_fgColor,
2157 HTMLDocument_get_fgColor,
2158 HTMLDocument_put_linkColor,
2159 HTMLDocument_get_linkColor,
2160 HTMLDocument_put_vlinkColor,
2161 HTMLDocument_get_vlinkColor,
2162 HTMLDocument_get_referrer,
2163 HTMLDocument_get_location,
2164 HTMLDocument_get_lastModified,
2165 HTMLDocument_put_URL,
2166 HTMLDocument_get_URL,
2167 HTMLDocument_put_domain,
2168 HTMLDocument_get_domain,
2169 HTMLDocument_put_cookie,
2170 HTMLDocument_get_cookie,
2171 HTMLDocument_put_expando,
2172 HTMLDocument_get_expando,
2173 HTMLDocument_put_charset,
2174 HTMLDocument_get_charset,
2175 HTMLDocument_put_defaultCharset,
2176 HTMLDocument_get_defaultCharset,
2177 HTMLDocument_get_mimeType,
2178 HTMLDocument_get_fileSize,
2179 HTMLDocument_get_fileCreatedDate,
2180 HTMLDocument_get_fileModifiedDate,
2181 HTMLDocument_get_fileUpdatedDate,
2182 HTMLDocument_get_security,
2183 HTMLDocument_get_protocol,
2184 HTMLDocument_get_nameProp,
2185 HTMLDocument_write,
2186 HTMLDocument_writeln,
2187 HTMLDocument_open,
2188 HTMLDocument_close,
2189 HTMLDocument_clear,
2190 HTMLDocument_queryCommandSupported,
2191 HTMLDocument_queryCommandEnabled,
2192 HTMLDocument_queryCommandState,
2193 HTMLDocument_queryCommandIndeterm,
2194 HTMLDocument_queryCommandText,
2195 HTMLDocument_queryCommandValue,
2196 HTMLDocument_execCommand,
2197 HTMLDocument_execCommandShowHelp,
2198 HTMLDocument_createElement,
2199 HTMLDocument_put_onhelp,
2200 HTMLDocument_get_onhelp,
2201 HTMLDocument_put_onclick,
2202 HTMLDocument_get_onclick,
2203 HTMLDocument_put_ondblclick,
2204 HTMLDocument_get_ondblclick,
2205 HTMLDocument_put_onkeyup,
2206 HTMLDocument_get_onkeyup,
2207 HTMLDocument_put_onkeydown,
2208 HTMLDocument_get_onkeydown,
2209 HTMLDocument_put_onkeypress,
2210 HTMLDocument_get_onkeypress,
2211 HTMLDocument_put_onmouseup,
2212 HTMLDocument_get_onmouseup,
2213 HTMLDocument_put_onmousedown,
2214 HTMLDocument_get_onmousedown,
2215 HTMLDocument_put_onmousemove,
2216 HTMLDocument_get_onmousemove,
2217 HTMLDocument_put_onmouseout,
2218 HTMLDocument_get_onmouseout,
2219 HTMLDocument_put_onmouseover,
2220 HTMLDocument_get_onmouseover,
2221 HTMLDocument_put_onreadystatechange,
2222 HTMLDocument_get_onreadystatechange,
2223 HTMLDocument_put_onafterupdate,
2224 HTMLDocument_get_onafterupdate,
2225 HTMLDocument_put_onrowexit,
2226 HTMLDocument_get_onrowexit,
2227 HTMLDocument_put_onrowenter,
2228 HTMLDocument_get_onrowenter,
2229 HTMLDocument_put_ondragstart,
2230 HTMLDocument_get_ondragstart,
2231 HTMLDocument_put_onselectstart,
2232 HTMLDocument_get_onselectstart,
2233 HTMLDocument_elementFromPoint,
2234 HTMLDocument_get_parentWindow,
2235 HTMLDocument_get_styleSheets,
2236 HTMLDocument_put_onbeforeupdate,
2237 HTMLDocument_get_onbeforeupdate,
2238 HTMLDocument_put_onerrorupdate,
2239 HTMLDocument_get_onerrorupdate,
2240 HTMLDocument_toString,
2241 HTMLDocument_createStyleSheet
2244 static inline HTMLDocumentNode *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
2246 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument3_iface);
2249 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface, REFIID riid, void **ppv)
2251 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2252 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2255 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
2257 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2258 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2261 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
2263 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2264 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2267 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
2269 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2270 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2273 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo, LCID lcid,
2274 ITypeInfo **ppTInfo)
2276 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2277 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2280 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid, LPOLESTR *rgszNames,
2281 UINT cNames, LCID lcid, DISPID *rgDispId)
2283 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2284 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2287 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2288 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2290 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2291 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2292 pDispParams, pVarResult, pExcepInfo, puArgErr);
2295 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
2297 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2298 FIXME("(%p)\n", This);
2299 return E_NOTIMPL;
2302 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
2304 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2306 WARN("(%p)->(%x)\n", This, fForce);
2308 /* Doing nothing here should be fine for us. */
2309 return S_OK;
2312 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text, IHTMLDOMNode **newTextNode)
2314 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2315 nsIDOMText *nstext;
2316 HTMLDOMNode *node;
2317 nsAString text_str;
2318 nsresult nsres;
2319 HRESULT hres;
2321 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
2323 if(!This->dom_document) {
2324 WARN("NULL dom_document\n");
2325 return E_UNEXPECTED;
2328 nsAString_InitDepend(&text_str, text);
2329 nsres = nsIDOMDocument_CreateTextNode(This->dom_document, &text_str, &nstext);
2330 nsAString_Finish(&text_str);
2331 if(NS_FAILED(nsres)) {
2332 ERR("CreateTextNode failed: %08lx\n", nsres);
2333 return E_FAIL;
2336 hres = HTMLDOMTextNode_Create(This, (nsIDOMNode*)nstext, &node);
2337 nsIDOMText_Release(nstext);
2338 if(FAILED(hres))
2339 return hres;
2341 *newTextNode = &node->IHTMLDOMNode_iface;
2342 return S_OK;
2345 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
2347 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2348 nsIDOMElement *nselem = NULL;
2349 HTMLElement *element;
2350 nsresult nsres;
2351 HRESULT hres;
2353 TRACE("(%p)->(%p)\n", This, p);
2355 if(This->outer_window && This->outer_window->readystate == READYSTATE_UNINITIALIZED) {
2356 *p = NULL;
2357 return S_OK;
2360 if(!This->dom_document) {
2361 WARN("NULL dom_document\n");
2362 return E_UNEXPECTED;
2365 nsres = nsIDOMDocument_GetDocumentElement(This->dom_document, &nselem);
2366 if(NS_FAILED(nsres)) {
2367 ERR("GetDocumentElement failed: %08lx\n", nsres);
2368 return E_FAIL;
2371 if(!nselem) {
2372 *p = NULL;
2373 return S_OK;
2376 hres = get_element(nselem, &element);
2377 nsIDOMElement_Release(nselem);
2378 if(FAILED(hres))
2379 return hres;
2381 *p = &element->IHTMLElement_iface;
2382 return hres;
2385 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2387 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2389 TRACE("(%p)->(%p)\n", This, p);
2391 return elem_unique_id(++This->unique_id, p);
2394 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch* pDisp,
2395 VARIANT_BOOL *pfResult)
2397 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2399 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2401 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2404 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch *pDisp)
2406 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2408 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2410 return detach_event(&This->node.event_target, event, pDisp);
2413 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2415 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2416 FIXME("(%p)->()\n", This);
2417 return E_NOTIMPL;
2420 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2422 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2423 FIXME("(%p)->(%p)\n", This, p);
2424 return E_NOTIMPL;
2427 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2429 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2430 FIXME("(%p)->()\n", This);
2431 return E_NOTIMPL;
2434 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2436 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2437 FIXME("(%p)->(%p)\n", This, p);
2438 return E_NOTIMPL;
2441 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2443 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2444 FIXME("(%p)->()\n", This);
2445 return E_NOTIMPL;
2448 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2450 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2451 FIXME("(%p)->(%p)\n", This, p);
2452 return E_NOTIMPL;
2455 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2457 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2458 FIXME("(%p)->()\n", This);
2459 return E_NOTIMPL;
2462 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2464 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2465 FIXME("(%p)->(%p)\n", This, p);
2466 return E_NOTIMPL;
2469 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2471 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2472 FIXME("(%p)->()\n", This);
2473 return E_NOTIMPL;
2476 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2478 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2479 FIXME("(%p)->(%p)\n", This, p);
2480 return E_NOTIMPL;
2483 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2485 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2486 FIXME("(%p)->()\n", This);
2487 return E_NOTIMPL;
2490 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2492 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2493 FIXME("(%p)->(%p)\n", This, p);
2494 return E_NOTIMPL;
2497 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2499 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2500 FIXME("(%p)->()\n", This);
2501 return E_NOTIMPL;
2504 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2506 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2507 FIXME("(%p)->(%p)\n", This, p);
2508 return E_NOTIMPL;
2511 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2513 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2514 nsAString dir_str;
2515 nsresult nsres;
2517 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2519 if(!This->dom_document) {
2520 FIXME("NULL dom_document\n");
2521 return E_UNEXPECTED;
2524 nsAString_InitDepend(&dir_str, v);
2525 nsres = nsIDOMDocument_SetDir(This->dom_document, &dir_str);
2526 nsAString_Finish(&dir_str);
2527 if(NS_FAILED(nsres)) {
2528 ERR("SetDir failed: %08lx\n", nsres);
2529 return E_FAIL;
2532 return S_OK;
2535 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2537 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2538 nsAString dir_str;
2539 nsresult nsres;
2541 TRACE("(%p)->(%p)\n", This, p);
2543 if(!This->dom_document) {
2544 FIXME("NULL dom_document\n");
2545 return E_UNEXPECTED;
2548 nsAString_Init(&dir_str, NULL);
2549 nsres = nsIDOMDocument_GetDir(This->dom_document, &dir_str);
2550 return return_nsstr(nsres, &dir_str, p);
2553 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2555 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2557 TRACE("(%p)->()\n", This);
2559 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2562 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2564 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2566 TRACE("(%p)->(%p)\n", This, p);
2568 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2571 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2573 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2574 FIXME("(%p)->()\n", This);
2575 return E_NOTIMPL;
2578 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2580 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2581 FIXME("(%p)->(%p)\n", This, p);
2582 return E_NOTIMPL;
2585 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface, IHTMLDocument2 **ppNewDoc)
2587 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2588 nsIDOMDocumentFragment *doc_frag;
2589 HTMLDocumentNode *docnode;
2590 nsresult nsres;
2591 HRESULT hres;
2593 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2595 if(!This->dom_document) {
2596 FIXME("NULL dom_document\n");
2597 return E_NOTIMPL;
2600 nsres = nsIDOMDocument_CreateDocumentFragment(This->dom_document, &doc_frag);
2601 if(NS_FAILED(nsres)) {
2602 ERR("CreateDocumentFragment failed: %08lx\n", nsres);
2603 return E_FAIL;
2606 hres = create_document_fragment((nsIDOMNode*)doc_frag, This, &docnode);
2607 nsIDOMDocumentFragment_Release(doc_frag);
2608 if(FAILED(hres))
2609 return hres;
2611 *ppNewDoc = &docnode->IHTMLDocument2_iface;
2612 return S_OK;
2615 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface, IHTMLDocument2 **p)
2617 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2618 FIXME("(%p)->(%p)\n", This, p);
2619 return E_NOTIMPL;
2622 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL v)
2624 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2625 FIXME("(%p)->(%x)\n", This, v);
2626 return E_NOTIMPL;
2629 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2631 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2632 FIXME("(%p)->(%p)\n", This, p);
2633 return E_NOTIMPL;
2636 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2638 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2639 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2640 return E_NOTIMPL;
2643 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2645 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2646 FIXME("(%p)->(%p)\n", This, p);
2647 return E_NOTIMPL;
2650 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2652 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2654 TRACE("(%p)->(%p)\n", This, p);
2656 return IHTMLDOMNode_get_childNodes(&This->node.IHTMLDOMNode_iface, p);
2659 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL v)
2661 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2662 FIXME("(%p)->()\n", This);
2663 return E_NOTIMPL;
2666 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL *p)
2668 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2669 FIXME("(%p)->(%p)\n", This, p);
2670 return E_NOTIMPL;
2673 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2675 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2676 FIXME("(%p)->()\n", This);
2677 return E_NOTIMPL;
2680 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2682 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2683 FIXME("(%p)->(%p)\n", This, p);
2684 return E_NOTIMPL;
2687 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2688 IHTMLElementCollection **ppelColl)
2690 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2691 nsIDOMNodeList *node_list;
2692 nsAString selector_str;
2693 WCHAR *selector;
2694 nsresult nsres;
2695 static const WCHAR formatW[] = L"*[id=%s],*[name=%s]";
2697 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2699 if(!This->dom_document) {
2700 /* We should probably return an empty collection. */
2701 FIXME("No dom_document\n");
2702 return E_NOTIMPL;
2705 selector = malloc(2 * SysStringLen(v) * sizeof(WCHAR) + sizeof(formatW));
2706 if(!selector)
2707 return E_OUTOFMEMORY;
2708 swprintf(selector, 2*SysStringLen(v) + ARRAY_SIZE(formatW), formatW, v, v);
2711 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2712 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2713 * types and search should be case insensitive. Those are currently not supported properly.
2715 nsAString_InitDepend(&selector_str, selector);
2716 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &selector_str, &node_list);
2717 nsAString_Finish(&selector_str);
2718 free(selector);
2719 if(NS_FAILED(nsres)) {
2720 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2721 return E_FAIL;
2724 *ppelColl = create_collection_from_nodelist(node_list, This->document_mode);
2725 nsIDOMNodeList_Release(node_list);
2726 return S_OK;
2730 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v, IHTMLElement **pel)
2732 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2733 HTMLElement *elem;
2734 HRESULT hres;
2736 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2738 hres = get_doc_elem_by_id(This, v, &elem);
2739 if(FAILED(hres) || !elem) {
2740 *pel = NULL;
2741 return hres;
2744 *pel = &elem->IHTMLElement_iface;
2745 return S_OK;
2749 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2750 IHTMLElementCollection **pelColl)
2752 HTMLDocumentNode *This = impl_from_IHTMLDocument3(iface);
2753 nsIDOMNodeList *nslist;
2754 nsAString id_str;
2755 nsresult nsres;
2757 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2759 if(This->dom_document) {
2760 nsAString_InitDepend(&id_str, v);
2761 nsres = nsIDOMDocument_GetElementsByTagName(This->dom_document, &id_str, &nslist);
2762 nsAString_Finish(&id_str);
2763 if(FAILED(nsres)) {
2764 ERR("GetElementByName failed: %08lx\n", nsres);
2765 return E_FAIL;
2767 }else {
2768 nsIDOMDocumentFragment *docfrag;
2769 nsAString nsstr;
2771 if(v) {
2772 const WCHAR *ptr;
2773 for(ptr=v; *ptr; ptr++) {
2774 if(!iswalnum(*ptr)) {
2775 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2776 return E_NOTIMPL;
2781 nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2782 if(NS_FAILED(nsres)) {
2783 ERR("Could not get nsIDOMDocumentFragment iface: %08lx\n", nsres);
2784 return E_UNEXPECTED;
2787 nsAString_InitDepend(&nsstr, v);
2788 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2789 nsAString_Finish(&nsstr);
2790 nsIDOMDocumentFragment_Release(docfrag);
2791 if(NS_FAILED(nsres)) {
2792 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2793 return E_FAIL;
2798 *pelColl = create_collection_from_nodelist(nslist, This->document_mode);
2799 nsIDOMNodeList_Release(nslist);
2801 return S_OK;
2804 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2805 HTMLDocument3_QueryInterface,
2806 HTMLDocument3_AddRef,
2807 HTMLDocument3_Release,
2808 HTMLDocument3_GetTypeInfoCount,
2809 HTMLDocument3_GetTypeInfo,
2810 HTMLDocument3_GetIDsOfNames,
2811 HTMLDocument3_Invoke,
2812 HTMLDocument3_releaseCapture,
2813 HTMLDocument3_recalc,
2814 HTMLDocument3_createTextNode,
2815 HTMLDocument3_get_documentElement,
2816 HTMLDocument3_get_uniqueID,
2817 HTMLDocument3_attachEvent,
2818 HTMLDocument3_detachEvent,
2819 HTMLDocument3_put_onrowsdelete,
2820 HTMLDocument3_get_onrowsdelete,
2821 HTMLDocument3_put_onrowsinserted,
2822 HTMLDocument3_get_onrowsinserted,
2823 HTMLDocument3_put_oncellchange,
2824 HTMLDocument3_get_oncellchange,
2825 HTMLDocument3_put_ondatasetchanged,
2826 HTMLDocument3_get_ondatasetchanged,
2827 HTMLDocument3_put_ondataavailable,
2828 HTMLDocument3_get_ondataavailable,
2829 HTMLDocument3_put_ondatasetcomplete,
2830 HTMLDocument3_get_ondatasetcomplete,
2831 HTMLDocument3_put_onpropertychange,
2832 HTMLDocument3_get_onpropertychange,
2833 HTMLDocument3_put_dir,
2834 HTMLDocument3_get_dir,
2835 HTMLDocument3_put_oncontextmenu,
2836 HTMLDocument3_get_oncontextmenu,
2837 HTMLDocument3_put_onstop,
2838 HTMLDocument3_get_onstop,
2839 HTMLDocument3_createDocumentFragment,
2840 HTMLDocument3_get_parentDocument,
2841 HTMLDocument3_put_enableDownload,
2842 HTMLDocument3_get_enableDownload,
2843 HTMLDocument3_put_baseUrl,
2844 HTMLDocument3_get_baseUrl,
2845 HTMLDocument3_get_childNodes,
2846 HTMLDocument3_put_inheritStyleSheets,
2847 HTMLDocument3_get_inheritStyleSheets,
2848 HTMLDocument3_put_onbeforeeditfocus,
2849 HTMLDocument3_get_onbeforeeditfocus,
2850 HTMLDocument3_getElementsByName,
2851 HTMLDocument3_getElementById,
2852 HTMLDocument3_getElementsByTagName
2855 static inline HTMLDocumentNode *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2857 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument4_iface);
2860 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface, REFIID riid, void **ppv)
2862 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2863 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
2866 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2868 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2869 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
2872 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2874 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2875 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
2878 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2880 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2881 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2884 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo, LCID lcid,
2885 ITypeInfo **ppTInfo)
2887 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2888 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2891 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid, LPOLESTR *rgszNames,
2892 UINT cNames, LCID lcid, DISPID *rgDispId)
2894 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2895 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
2898 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
2899 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2901 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2902 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2903 pDispParams, pVarResult, pExcepInfo, puArgErr);
2906 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2908 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2909 nsIDOMHTMLElement *nsbody;
2910 nsresult nsres;
2912 TRACE("(%p)->()\n", This);
2914 if(!This->html_document) {
2915 FIXME("Not implemented for XML document\n");
2916 return E_NOTIMPL;
2919 nsres = nsIDOMHTMLDocument_GetBody(This->html_document, &nsbody);
2920 if(NS_FAILED(nsres) || !nsbody) {
2921 ERR("GetBody failed: %08lx\n", nsres);
2922 return E_FAIL;
2925 nsres = nsIDOMHTMLElement_Focus(nsbody);
2926 nsIDOMHTMLElement_Release(nsbody);
2927 if(NS_FAILED(nsres)) {
2928 ERR("Focus failed: %08lx\n", nsres);
2929 return E_FAIL;
2932 return S_OK;
2935 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2937 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2938 cpp_bool has_focus;
2939 nsresult nsres;
2941 TRACE("(%p)->(%p)\n", This, pfFocus);
2943 if(!This->dom_document) {
2944 FIXME("Unimplemented for fragments.\n");
2945 return E_NOTIMPL;
2948 nsres = nsIDOMDocument_HasFocus(This->dom_document, &has_focus);
2949 assert(nsres == NS_OK);
2951 *pfFocus = variant_bool(has_focus);
2952 return S_OK;
2955 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2957 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2959 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2961 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2964 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2966 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2968 TRACE("(%p)->(%p)\n", This, p);
2970 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2973 static HRESULT WINAPI HTMLDocument4_get_namespaces(IHTMLDocument4 *iface, IDispatch **p)
2975 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2977 TRACE("(%p)->(%p)\n", This, p);
2979 if(!This->namespaces) {
2980 HRESULT hres;
2982 hres = create_namespace_collection(dispex_compat_mode(&This->node.event_target.dispex),
2983 &This->namespaces);
2984 if(FAILED(hres))
2985 return hres;
2988 IHTMLNamespaceCollection_AddRef(This->namespaces);
2989 *p = (IDispatch*)This->namespaces;
2990 return S_OK;
2993 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2994 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2996 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
2997 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2998 return E_NOTIMPL;
3001 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
3003 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3004 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3005 return E_NOTIMPL;
3008 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
3010 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3011 FIXME("(%p)->(%p)\n", This, p);
3012 return E_NOTIMPL;
3015 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
3016 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
3018 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3020 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
3022 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
3023 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
3024 return E_NOTIMPL;
3027 return create_event_obj(dispex_compat_mode(&This->node.event_target.dispex), ppEventObj);
3030 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
3031 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
3033 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3035 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
3037 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCanceled);
3040 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
3041 IHTMLRenderStyle **ppIHTMLRenderStyle)
3043 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3044 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
3045 return E_NOTIMPL;
3048 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
3050 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3051 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3052 return E_NOTIMPL;
3055 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
3057 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3058 FIXME("(%p)->(%p)\n", This, p);
3059 return E_NOTIMPL;
3062 static HRESULT WINAPI HTMLDocument4_get_URLUnencoded(IHTMLDocument4 *iface, BSTR *p)
3064 HTMLDocumentNode *This = impl_from_IHTMLDocument4(iface);
3065 FIXME("(%p)->(%p)\n", This, p);
3066 return E_NOTIMPL;
3069 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
3070 HTMLDocument4_QueryInterface,
3071 HTMLDocument4_AddRef,
3072 HTMLDocument4_Release,
3073 HTMLDocument4_GetTypeInfoCount,
3074 HTMLDocument4_GetTypeInfo,
3075 HTMLDocument4_GetIDsOfNames,
3076 HTMLDocument4_Invoke,
3077 HTMLDocument4_focus,
3078 HTMLDocument4_hasFocus,
3079 HTMLDocument4_put_onselectionchange,
3080 HTMLDocument4_get_onselectionchange,
3081 HTMLDocument4_get_namespaces,
3082 HTMLDocument4_createDocumentFromUrl,
3083 HTMLDocument4_put_media,
3084 HTMLDocument4_get_media,
3085 HTMLDocument4_createEventObject,
3086 HTMLDocument4_fireEvent,
3087 HTMLDocument4_createRenderStyle,
3088 HTMLDocument4_put_oncontrolselect,
3089 HTMLDocument4_get_oncontrolselect,
3090 HTMLDocument4_get_URLUnencoded
3093 static inline HTMLDocumentNode *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
3095 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument5_iface);
3098 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface, REFIID riid, void **ppv)
3100 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3101 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3104 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
3106 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3107 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3110 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
3112 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3113 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3116 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
3118 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3119 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3122 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo, LCID lcid,
3123 ITypeInfo **ppTInfo)
3125 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3126 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3129 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid, LPOLESTR *rgszNames,
3130 UINT cNames, LCID lcid, DISPID *rgDispId)
3132 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3133 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3136 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3137 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3139 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3140 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3141 pDispParams, pVarResult, pExcepInfo, puArgErr);
3144 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
3146 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3148 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3150 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
3153 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
3155 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3157 TRACE("(%p)->(%p)\n", This, p);
3159 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
3162 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
3164 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3165 nsIDOMDocumentType *nsdoctype;
3166 HTMLDOMNode *doctype_node;
3167 nsresult nsres;
3168 HRESULT hres;
3170 TRACE("(%p)->(%p)\n", This, p);
3172 if(dispex_compat_mode(&This->node.event_target.dispex) < COMPAT_MODE_IE9) {
3173 *p = NULL;
3174 return S_OK;
3177 nsres = nsIDOMDocument_GetDoctype(This->dom_document, &nsdoctype);
3178 if(NS_FAILED(nsres))
3179 return map_nsresult(nsres);
3180 if(!nsdoctype) {
3181 *p = NULL;
3182 return S_OK;
3185 hres = get_node((nsIDOMNode*)nsdoctype, TRUE, &doctype_node);
3186 nsIDOMDocumentType_Release(nsdoctype);
3188 if(SUCCEEDED(hres))
3189 *p = &doctype_node->IHTMLDOMNode_iface;
3190 return hres;
3193 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
3195 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3197 TRACE("(%p)->(%p)\n", This, p);
3199 if(!This->dom_implementation) {
3200 HRESULT hres;
3202 hres = create_dom_implementation(This, &This->dom_implementation);
3203 if(FAILED(hres))
3204 return hres;
3207 IHTMLDOMImplementation_AddRef(This->dom_implementation);
3208 *p = This->dom_implementation;
3209 return S_OK;
3212 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
3213 IHTMLDOMAttribute **ppattribute)
3215 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3216 HTMLDOMAttribute *attr;
3217 HRESULT hres;
3219 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
3221 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, dispex_compat_mode(&This->node.event_target.dispex), &attr);
3222 if(FAILED(hres))
3223 return hres;
3225 *ppattribute = &attr->IHTMLDOMAttribute_iface;
3226 return S_OK;
3229 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
3230 IHTMLDOMNode **ppRetNode)
3232 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3233 nsIDOMComment *nscomment;
3234 HTMLElement *elem;
3235 nsAString str;
3236 nsresult nsres;
3237 HRESULT hres;
3239 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
3241 if(!This->dom_document) {
3242 WARN("NULL dom_document\n");
3243 return E_UNEXPECTED;
3246 nsAString_InitDepend(&str, bstrdata);
3247 nsres = nsIDOMDocument_CreateComment(This->dom_document, &str, &nscomment);
3248 nsAString_Finish(&str);
3249 if(NS_FAILED(nsres)) {
3250 ERR("CreateTextNode failed: %08lx\n", nsres);
3251 return E_FAIL;
3254 hres = HTMLCommentElement_Create(This, (nsIDOMNode*)nscomment, &elem);
3255 nsIDOMComment_Release(nscomment);
3256 if(FAILED(hres))
3257 return hres;
3259 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
3260 return S_OK;
3263 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
3265 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3267 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3269 return set_doc_event(This, EVENTID_FOCUSIN, &v);
3272 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
3274 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3276 TRACE("(%p)->(%p)\n", This, p);
3278 return get_doc_event(This, EVENTID_FOCUSIN, p);
3281 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
3283 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3285 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3287 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
3290 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
3292 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3294 TRACE("(%p)->(%p)\n", This, p);
3296 return get_doc_event(This, EVENTID_FOCUSOUT, p);
3299 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
3301 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3302 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3303 return E_NOTIMPL;
3306 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
3308 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3309 FIXME("(%p)->(%p)\n", This, p);
3310 return E_NOTIMPL;
3313 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
3315 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3316 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3317 return E_NOTIMPL;
3320 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
3322 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3323 FIXME("(%p)->(%p)\n", This, p);
3324 return E_NOTIMPL;
3327 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
3329 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3330 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3331 return E_NOTIMPL;
3334 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
3336 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3337 FIXME("(%p)->(%p)\n", This, p);
3338 return E_NOTIMPL;
3341 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
3343 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3344 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3345 return E_NOTIMPL;
3348 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
3350 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3351 FIXME("(%p)->(%p)\n", This, p);
3352 return E_NOTIMPL;
3355 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
3357 HTMLDocumentNode *This = impl_from_IHTMLDocument5(iface);
3359 TRACE("(%p)->(%p)\n", This, p);
3361 *p = SysAllocString(This->document_mode <= COMPAT_MODE_IE5 ? L"BackCompat" : L"CSS1Compat");
3362 return *p ? S_OK : E_OUTOFMEMORY;
3365 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
3366 HTMLDocument5_QueryInterface,
3367 HTMLDocument5_AddRef,
3368 HTMLDocument5_Release,
3369 HTMLDocument5_GetTypeInfoCount,
3370 HTMLDocument5_GetTypeInfo,
3371 HTMLDocument5_GetIDsOfNames,
3372 HTMLDocument5_Invoke,
3373 HTMLDocument5_put_onmousewheel,
3374 HTMLDocument5_get_onmousewheel,
3375 HTMLDocument5_get_doctype,
3376 HTMLDocument5_get_implementation,
3377 HTMLDocument5_createAttribute,
3378 HTMLDocument5_createComment,
3379 HTMLDocument5_put_onfocusin,
3380 HTMLDocument5_get_onfocusin,
3381 HTMLDocument5_put_onfocusout,
3382 HTMLDocument5_get_onfocusout,
3383 HTMLDocument5_put_onactivate,
3384 HTMLDocument5_get_onactivate,
3385 HTMLDocument5_put_ondeactivate,
3386 HTMLDocument5_get_ondeactivate,
3387 HTMLDocument5_put_onbeforeactivate,
3388 HTMLDocument5_get_onbeforeactivate,
3389 HTMLDocument5_put_onbeforedeactivate,
3390 HTMLDocument5_get_onbeforedeactivate,
3391 HTMLDocument5_get_compatMode
3394 static inline HTMLDocumentNode *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3396 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument6_iface);
3399 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface, REFIID riid, void **ppv)
3401 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3402 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3405 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3407 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3408 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3411 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3413 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3414 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3417 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3419 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3420 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3423 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo, LCID lcid,
3424 ITypeInfo **ppTInfo)
3426 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3427 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3430 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid, LPOLESTR *rgszNames,
3431 UINT cNames, LCID lcid, DISPID *rgDispId)
3433 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3434 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3437 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3438 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3440 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3441 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3442 pDispParams, pVarResult, pExcepInfo, puArgErr);
3445 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3446 IHTMLDocumentCompatibleInfoCollection **p)
3448 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3449 FIXME("(%p)->(%p)\n", This, p);
3450 return E_NOTIMPL;
3453 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3455 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3457 TRACE("(%p)->(%p)\n", This, p);
3459 V_VT(p) = VT_R4;
3460 V_R4(p) = compat_mode_info[This->document_mode].document_mode;
3461 return S_OK;
3464 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3465 VARIANT *p)
3467 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3469 TRACE("(%p)->(%p)\n", This, p);
3471 return get_doc_event(This, EVENTID_STORAGE, p);
3474 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3476 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3478 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3480 return set_doc_event(This, EVENTID_STORAGE, &v);
3483 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3484 VARIANT *p)
3486 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3488 TRACE("(%p)->(%p)\n", This, p);
3490 return get_doc_event(This, EVENTID_STORAGECOMMIT, p);
3493 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3495 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3497 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3499 return set_doc_event(This, EVENTID_STORAGECOMMIT, &v);
3502 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3503 BSTR bstrId, IHTMLElement2 **p)
3505 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3506 nsIDOMElement *nselem;
3507 HTMLElement *elem;
3508 nsAString nsstr;
3509 nsresult nsres;
3510 HRESULT hres;
3512 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3515 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3516 * not search for name attributes, so we may simply let Gecko do the right thing.
3519 if(!This->dom_document) {
3520 FIXME("Not a document\n");
3521 return E_FAIL;
3524 nsAString_InitDepend(&nsstr, bstrId);
3525 nsres = nsIDOMDocument_GetElementById(This->dom_document, &nsstr, &nselem);
3526 nsAString_Finish(&nsstr);
3527 if(NS_FAILED(nsres)) {
3528 ERR("GetElementById failed: %08lx\n", nsres);
3529 return E_FAIL;
3532 if(!nselem) {
3533 *p = NULL;
3534 return S_OK;
3537 hres = get_element(nselem, &elem);
3538 nsIDOMElement_Release(nselem);
3539 if(FAILED(hres))
3540 return hres;
3542 *p = &elem->IHTMLElement2_iface;
3543 return S_OK;
3546 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3548 HTMLDocumentNode *This = impl_from_IHTMLDocument6(iface);
3549 FIXME("(%p)->()\n", This);
3550 return E_NOTIMPL;
3553 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3554 HTMLDocument6_QueryInterface,
3555 HTMLDocument6_AddRef,
3556 HTMLDocument6_Release,
3557 HTMLDocument6_GetTypeInfoCount,
3558 HTMLDocument6_GetTypeInfo,
3559 HTMLDocument6_GetIDsOfNames,
3560 HTMLDocument6_Invoke,
3561 HTMLDocument6_get_compatible,
3562 HTMLDocument6_get_documentMode,
3563 HTMLDocument6_put_onstorage,
3564 HTMLDocument6_get_onstorage,
3565 HTMLDocument6_put_onstoragecommit,
3566 HTMLDocument6_get_onstoragecommit,
3567 HTMLDocument6_getElementById,
3568 HTMLDocument6_updateSettings
3571 static inline HTMLDocumentNode *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3573 return CONTAINING_RECORD(iface, HTMLDocumentNode, IHTMLDocument7_iface);
3576 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3578 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3579 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
3582 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3584 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3585 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
3588 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3590 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3591 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
3594 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3596 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3597 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3600 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo, LCID lcid,
3601 ITypeInfo **ppTInfo)
3603 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3604 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3607 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid, LPOLESTR *rgszNames,
3608 UINT cNames, LCID lcid, DISPID *rgDispId)
3610 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3611 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
3614 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
3615 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3617 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3618 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3619 pDispParams, pVarResult, pExcepInfo, puArgErr);
3622 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3624 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3626 TRACE("(%p)->(%p)\n", This, p);
3628 if(This->window && This->window->base.outer_window) {
3629 *p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
3630 IHTMLWindow2_AddRef(*p);
3631 }else {
3632 *p = NULL;
3634 return S_OK;
3637 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3639 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3640 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3641 return E_NOTIMPL;
3644 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3646 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3647 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3648 return E_NOTIMPL;
3651 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3652 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3654 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3655 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3656 return E_NOTIMPL;
3659 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3661 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3662 nsIDOMElement *dom_element;
3663 HTMLElement *element;
3664 nsAString ns, tag;
3665 nsresult nsres;
3666 HRESULT hres;
3668 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3670 if(!This->dom_document) {
3671 FIXME("NULL dom_document\n");
3672 return E_FAIL;
3675 if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
3676 FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
3678 nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
3679 nsAString_InitDepend(&tag, bstrTag);
3680 nsres = nsIDOMDocument_CreateElementNS(This->dom_document, &ns, &tag, &dom_element);
3681 nsAString_Finish(&ns);
3682 nsAString_Finish(&tag);
3683 if(NS_FAILED(nsres)) {
3684 WARN("CreateElementNS failed: %08lx\n", nsres);
3685 return map_nsresult(nsres);
3688 hres = HTMLElement_Create(This, (nsIDOMNode*)dom_element, FALSE, &element);
3689 nsIDOMElement_Release(dom_element);
3690 if(FAILED(hres))
3691 return hres;
3693 *newElem = &element->IHTMLElement_iface;
3694 return S_OK;
3697 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3698 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3700 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3701 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3702 return E_NOTIMPL;
3705 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3707 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3708 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3709 return E_NOTIMPL;
3712 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3714 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3716 TRACE("(%p)->(%p)\n", This, p);
3718 return get_doc_event(This, EVENTID_MSTHUMBNAILCLICK, p);
3721 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3723 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3724 nsAString charset_str;
3725 nsresult nsres;
3727 TRACE("(%p)->(%p)\n", This, p);
3729 if(!This->dom_document) {
3730 FIXME("NULL dom_document\n");
3731 return E_FAIL;
3734 nsAString_Init(&charset_str, NULL);
3735 nsres = nsIDOMDocument_GetCharacterSet(This->dom_document, &charset_str);
3736 return return_nsstr(nsres, &charset_str, p);
3739 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3741 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3743 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3745 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3748 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3750 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3752 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3754 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3757 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3759 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3760 nsIDOMNodeList *nslist;
3761 nsAString nsstr;
3762 nsresult nsres;
3764 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3766 if(!This->dom_document) {
3767 FIXME("NULL dom_document not supported\n");
3768 return E_NOTIMPL;
3771 nsAString_InitDepend(&nsstr, v);
3772 nsres = nsIDOMDocument_GetElementsByClassName(This->dom_document, &nsstr, &nslist);
3773 nsAString_Finish(&nsstr);
3774 if(FAILED(nsres)) {
3775 ERR("GetElementByClassName failed: %08lx\n", nsres);
3776 return E_FAIL;
3780 *pel = create_collection_from_nodelist(nslist, This->document_mode);
3781 nsIDOMNodeList_Release(nslist);
3782 return S_OK;
3785 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3786 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3788 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3789 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3790 return E_NOTIMPL;
3793 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3795 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3796 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3797 return E_NOTIMPL;
3800 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3802 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3803 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3804 return E_NOTIMPL;
3807 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3809 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3810 FIXME("(%p)->(%p)\n", This, p);
3811 return E_NOTIMPL;
3814 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3816 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3818 TRACE("(%p)->(%p)\n", This, p);
3820 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3823 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3825 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3826 FIXME("(%p)->(%p)\n", This, p);
3827 return E_NOTIMPL;
3830 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3832 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3833 FIXME("(%p)->(%p)\n", This, p);
3834 return E_NOTIMPL;
3837 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3839 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3840 FIXME("(%p)->(%x)\n", This, v);
3841 return E_NOTIMPL;
3844 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3846 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3847 FIXME("(%p)->(%p)\n", This, p);
3848 return E_NOTIMPL;
3851 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3853 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3854 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3855 return E_NOTIMPL;
3858 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3860 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3861 FIXME("(%p)->(%p)\n", This, p);
3862 return E_NOTIMPL;
3865 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3867 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3868 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3869 return E_NOTIMPL;
3872 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3874 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3876 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3878 return set_doc_event(This, EVENTID_ABORT, &v);
3881 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3883 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3885 TRACE("(%p)->(%p)\n", This, p);
3887 return get_doc_event(This, EVENTID_ABORT, p);
3890 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3892 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3894 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3896 return set_doc_event(This, EVENTID_BLUR, &v);
3899 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3901 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3903 TRACE("(%p)->(%p)\n", This, p);
3905 return get_doc_event(This, EVENTID_BLUR, p);
3908 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3910 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3911 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3912 return E_NOTIMPL;
3915 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3917 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3918 FIXME("(%p)->(%p)\n", This, p);
3919 return E_NOTIMPL;
3922 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3924 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3925 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3926 return E_NOTIMPL;
3929 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3931 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3932 FIXME("(%p)->(%p)\n", This, p);
3933 return E_NOTIMPL;
3936 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3938 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3940 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3942 return set_doc_event(This, EVENTID_CHANGE, &v);
3945 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3947 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3949 TRACE("(%p)->(%p)\n", This, p);
3951 return get_doc_event(This, EVENTID_CHANGE, p);
3954 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3956 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3958 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3960 return set_doc_event(This, EVENTID_DRAG, &v);
3963 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3965 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3967 TRACE("(%p)->(%p)\n", This, p);
3969 return get_doc_event(This, EVENTID_DRAG, p);
3972 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3974 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3975 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3976 return E_NOTIMPL;
3979 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3981 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3982 FIXME("(%p)->(%p)\n", This, p);
3983 return E_NOTIMPL;
3986 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3988 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3989 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3990 return E_NOTIMPL;
3993 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3995 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
3996 FIXME("(%p)->(%p)\n", This, p);
3997 return E_NOTIMPL;
4000 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
4002 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4003 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4004 return E_NOTIMPL;
4007 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
4009 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4010 FIXME("(%p)->(%p)\n", This, p);
4011 return E_NOTIMPL;
4014 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
4016 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4017 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4018 return E_NOTIMPL;
4021 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
4023 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4024 FIXME("(%p)->(%p)\n", This, p);
4025 return E_NOTIMPL;
4028 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
4030 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4031 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4032 return E_NOTIMPL;
4035 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
4037 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4038 FIXME("(%p)->(%p)\n", This, p);
4039 return E_NOTIMPL;
4042 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
4044 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4045 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4046 return E_NOTIMPL;
4049 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
4051 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4052 FIXME("(%p)->(%p)\n", This, p);
4053 return E_NOTIMPL;
4056 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
4058 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4059 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4060 return E_NOTIMPL;
4063 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
4065 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4066 FIXME("(%p)->(%p)\n", This, p);
4067 return E_NOTIMPL;
4070 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
4072 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4073 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4074 return E_NOTIMPL;
4077 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
4079 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4080 FIXME("(%p)->(%p)\n", This, p);
4081 return E_NOTIMPL;
4084 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
4086 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4088 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4090 return set_doc_event(This, EVENTID_ERROR, &v);
4093 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
4095 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4097 TRACE("(%p)->(%p)\n", This, p);
4099 return get_doc_event(This, EVENTID_ERROR, p);
4102 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
4104 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4106 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4108 return set_doc_event(This, EVENTID_FOCUS, &v);
4111 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
4113 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4115 TRACE("(%p)->(%p)\n", This, p);
4117 return get_doc_event(This, EVENTID_FOCUS, p);
4120 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
4122 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4124 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4126 return set_doc_event(This, EVENTID_INPUT, &v);
4129 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
4131 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4133 TRACE("(%p)->(%p)\n", This, p);
4135 return get_doc_event(This, EVENTID_INPUT, p);
4138 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
4140 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4142 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4144 return set_doc_event(This, EVENTID_LOAD, &v);
4147 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
4149 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4151 TRACE("(%p)->(%p)\n", This, p);
4153 return get_doc_event(This, EVENTID_LOAD, p);
4156 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
4158 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4159 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4160 return E_NOTIMPL;
4163 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
4165 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4166 FIXME("(%p)->(%p)\n", This, p);
4167 return E_NOTIMPL;
4170 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
4172 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4173 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4174 return E_NOTIMPL;
4177 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
4179 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4180 FIXME("(%p)->(%p)\n", This, p);
4181 return E_NOTIMPL;
4184 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
4186 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4187 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4188 return E_NOTIMPL;
4191 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
4193 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4194 FIXME("(%p)->(%p)\n", This, p);
4195 return E_NOTIMPL;
4198 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
4200 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4201 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4202 return E_NOTIMPL;
4205 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
4207 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4208 FIXME("(%p)->(%p)\n", This, p);
4209 return E_NOTIMPL;
4212 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
4214 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4215 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4216 return E_NOTIMPL;
4219 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
4221 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4222 FIXME("(%p)->(%p)\n", This, p);
4223 return E_NOTIMPL;
4226 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
4228 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4229 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4230 return E_NOTIMPL;
4233 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
4235 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4236 FIXME("(%p)->(%p)\n", This, p);
4237 return E_NOTIMPL;
4240 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
4242 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4243 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4244 return E_NOTIMPL;
4247 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
4249 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4250 FIXME("(%p)->(%p)\n", This, p);
4251 return E_NOTIMPL;
4254 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
4256 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4257 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4258 return E_NOTIMPL;
4261 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
4263 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4264 FIXME("(%p)->(%p)\n", This, p);
4265 return E_NOTIMPL;
4268 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
4270 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4271 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4272 return E_NOTIMPL;
4275 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
4277 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4278 FIXME("(%p)->(%p)\n", This, p);
4279 return E_NOTIMPL;
4282 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
4284 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4286 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4288 return set_doc_event(This, EVENTID_SCROLL, &v);
4291 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
4293 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4295 TRACE("(%p)->(%p)\n", This, p);
4297 return get_doc_event(This, EVENTID_SCROLL, p);
4300 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
4302 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4303 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4304 return E_NOTIMPL;
4307 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
4309 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4310 FIXME("(%p)->(%p)\n", This, p);
4311 return E_NOTIMPL;
4314 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
4316 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4317 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4318 return E_NOTIMPL;
4321 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
4323 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4324 FIXME("(%p)->(%p)\n", This, p);
4325 return E_NOTIMPL;
4328 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
4330 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4331 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4332 return E_NOTIMPL;
4335 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
4337 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4338 FIXME("(%p)->(%p)\n", This, p);
4339 return E_NOTIMPL;
4342 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
4344 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4345 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4346 return E_NOTIMPL;
4349 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
4351 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4352 FIXME("(%p)->(%p)\n", This, p);
4353 return E_NOTIMPL;
4356 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
4358 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4360 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4362 return set_doc_event(This, EVENTID_SUBMIT, &v);
4365 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
4367 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4369 TRACE("(%p)->(%p)\n", This, p);
4371 return get_doc_event(This, EVENTID_SUBMIT, p);
4374 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
4376 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4377 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4378 return E_NOTIMPL;
4381 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
4383 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4384 FIXME("(%p)->(%p)\n", This, p);
4385 return E_NOTIMPL;
4388 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
4390 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4391 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4392 return E_NOTIMPL;
4395 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
4397 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4398 FIXME("(%p)->(%p)\n", This, p);
4399 return E_NOTIMPL;
4402 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
4404 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4405 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4406 return E_NOTIMPL;
4409 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4411 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4412 FIXME("(%p)->(%p)\n", This, p);
4413 return E_NOTIMPL;
4416 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4418 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4419 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4420 return E_NOTIMPL;
4423 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4425 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4426 FIXME("(%p)->(%p)\n", This, p);
4427 return E_NOTIMPL;
4430 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4432 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4433 FIXME("(%p)\n", This);
4434 return E_NOTIMPL;
4437 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4438 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4440 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4441 nsIDOMNode *nsnode = NULL;
4442 HTMLDOMNode *node;
4443 nsresult nsres;
4444 HRESULT hres;
4446 TRACE("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4448 if(!This->dom_document) {
4449 WARN("NULL dom_document\n");
4450 return E_UNEXPECTED;
4453 if(!(node = unsafe_impl_from_IHTMLDOMNode(pNodeSource))) {
4454 ERR("not our node\n");
4455 return E_FAIL;
4458 nsres = nsIDOMDocument_ImportNode(This->dom_document, node->nsnode, !!fDeep, 1, &nsnode);
4459 if(NS_FAILED(nsres)) {
4460 ERR("ImportNode failed: %08lx\n", nsres);
4461 return map_nsresult(nsres);
4464 if(!nsnode) {
4465 *ppNodeDest = NULL;
4466 return S_OK;
4469 hres = get_node(nsnode, TRUE, &node);
4470 nsIDOMNode_Release(nsnode);
4471 if(FAILED(hres))
4472 return hres;
4474 *ppNodeDest = &node->IHTMLDOMNode3_iface;
4475 return hres;
4478 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4480 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4482 TRACE("(%p)->(%p)\n", This, p);
4484 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4487 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4489 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4490 FIXME("(%p)->(%p)\n", This, v);
4491 return E_NOTIMPL;
4494 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4496 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4498 TRACE("(%p)->(%p)\n", This, p);
4500 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4503 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4505 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface);
4506 nsIDOMHTMLHeadElement *nshead;
4507 nsIDOMElement *nselem;
4508 HTMLElement *elem;
4509 nsresult nsres;
4510 HRESULT hres;
4512 TRACE("(%p)->(%p)\n", This, p);
4514 if(!This->dom_document) {
4515 FIXME("No document\n");
4516 return E_FAIL;
4519 if(!This->html_document) {
4520 FIXME("Not implemented for XML document\n");
4521 return E_NOTIMPL;
4524 nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &nshead);
4525 assert(nsres == NS_OK);
4527 if(!nshead) {
4528 *p = NULL;
4529 return S_OK;
4532 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4533 nsIDOMHTMLHeadElement_Release(nshead);
4534 assert(nsres == NS_OK);
4536 hres = get_element(nselem, &elem);
4537 nsIDOMElement_Release(nselem);
4538 if(FAILED(hres))
4539 return hres;
4541 *p = &elem->IHTMLElement_iface;
4542 return S_OK;
4545 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4546 HTMLDocument7_QueryInterface,
4547 HTMLDocument7_AddRef,
4548 HTMLDocument7_Release,
4549 HTMLDocument7_GetTypeInfoCount,
4550 HTMLDocument7_GetTypeInfo,
4551 HTMLDocument7_GetIDsOfNames,
4552 HTMLDocument7_Invoke,
4553 HTMLDocument7_get_defaultView,
4554 HTMLDocument7_createCDATASection,
4555 HTMLDocument7_getSelection,
4556 HTMLDocument7_getElementsByTagNameNS,
4557 HTMLDocument7_createElementNS,
4558 HTMLDocument7_createAttributeNS,
4559 HTMLDocument7_put_onmsthumbnailclick,
4560 HTMLDocument7_get_onmsthumbnailclick,
4561 HTMLDocument7_get_characterSet,
4562 HTMLDocument7_createElement,
4563 HTMLDocument7_createAttribute,
4564 HTMLDocument7_getElementsByClassName,
4565 HTMLDocument7_createProcessingInstruction,
4566 HTMLDocument7_adoptNode,
4567 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4568 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4569 HTMLDocument7_get_all,
4570 HTMLDocument7_get_inputEncoding,
4571 HTMLDocument7_get_xmlEncoding,
4572 HTMLDocument7_put_xmlStandalone,
4573 HTMLDocument7_get_xmlStandalone,
4574 HTMLDocument7_put_xmlVersion,
4575 HTMLDocument7_get_xmlVersion,
4576 HTMLDocument7_hasAttributes,
4577 HTMLDocument7_put_onabort,
4578 HTMLDocument7_get_onabort,
4579 HTMLDocument7_put_onblur,
4580 HTMLDocument7_get_onblur,
4581 HTMLDocument7_put_oncanplay,
4582 HTMLDocument7_get_oncanplay,
4583 HTMLDocument7_put_oncanplaythrough,
4584 HTMLDocument7_get_oncanplaythrough,
4585 HTMLDocument7_put_onchange,
4586 HTMLDocument7_get_onchange,
4587 HTMLDocument7_put_ondrag,
4588 HTMLDocument7_get_ondrag,
4589 HTMLDocument7_put_ondragend,
4590 HTMLDocument7_get_ondragend,
4591 HTMLDocument7_put_ondragenter,
4592 HTMLDocument7_get_ondragenter,
4593 HTMLDocument7_put_ondragleave,
4594 HTMLDocument7_get_ondragleave,
4595 HTMLDocument7_put_ondragover,
4596 HTMLDocument7_get_ondragover,
4597 HTMLDocument7_put_ondrop,
4598 HTMLDocument7_get_ondrop,
4599 HTMLDocument7_put_ondurationchange,
4600 HTMLDocument7_get_ondurationchange,
4601 HTMLDocument7_put_onemptied,
4602 HTMLDocument7_get_onemptied,
4603 HTMLDocument7_put_onended,
4604 HTMLDocument7_get_onended,
4605 HTMLDocument7_put_onerror,
4606 HTMLDocument7_get_onerror,
4607 HTMLDocument7_put_onfocus,
4608 HTMLDocument7_get_onfocus,
4609 HTMLDocument7_put_oninput,
4610 HTMLDocument7_get_oninput,
4611 HTMLDocument7_put_onload,
4612 HTMLDocument7_get_onload,
4613 HTMLDocument7_put_onloadeddata,
4614 HTMLDocument7_get_onloadeddata,
4615 HTMLDocument7_put_onloadedmetadata,
4616 HTMLDocument7_get_onloadedmetadata,
4617 HTMLDocument7_put_onloadstart,
4618 HTMLDocument7_get_onloadstart,
4619 HTMLDocument7_put_onpause,
4620 HTMLDocument7_get_onpause,
4621 HTMLDocument7_put_onplay,
4622 HTMLDocument7_get_onplay,
4623 HTMLDocument7_put_onplaying,
4624 HTMLDocument7_get_onplaying,
4625 HTMLDocument7_put_onprogress,
4626 HTMLDocument7_get_onprogress,
4627 HTMLDocument7_put_onratechange,
4628 HTMLDocument7_get_onratechange,
4629 HTMLDocument7_put_onreset,
4630 HTMLDocument7_get_onreset,
4631 HTMLDocument7_put_onscroll,
4632 HTMLDocument7_get_onscroll,
4633 HTMLDocument7_put_onseekend,
4634 HTMLDocument7_get_onseekend,
4635 HTMLDocument7_put_onseeking,
4636 HTMLDocument7_get_onseeking,
4637 HTMLDocument7_put_onselect,
4638 HTMLDocument7_get_onselect,
4639 HTMLDocument7_put_onstalled,
4640 HTMLDocument7_get_onstalled,
4641 HTMLDocument7_put_onsubmit,
4642 HTMLDocument7_get_onsubmit,
4643 HTMLDocument7_put_onsuspend,
4644 HTMLDocument7_get_onsuspend,
4645 HTMLDocument7_put_ontimeupdate,
4646 HTMLDocument7_get_ontimeupdate,
4647 HTMLDocument7_put_onvolumechange,
4648 HTMLDocument7_get_onvolumechange,
4649 HTMLDocument7_put_onwaiting,
4650 HTMLDocument7_get_onwaiting,
4651 HTMLDocument7_normalize,
4652 HTMLDocument7_importNode,
4653 HTMLDocument7_get_parentWindow,
4654 HTMLDocument7_put_body,
4655 HTMLDocument7_get_body,
4656 HTMLDocument7_get_head
4659 static inline HTMLDocumentNode *impl_from_IDocumentSelector(IDocumentSelector *iface)
4661 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentSelector_iface);
4664 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4666 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4667 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4670 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4672 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4673 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4676 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4678 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4679 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4682 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4684 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4685 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4688 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4689 LCID lcid, ITypeInfo **ppTInfo)
4691 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4692 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4695 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4696 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4698 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4699 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4700 rgDispId);
4703 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4704 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4706 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4707 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4708 pDispParams, pVarResult, pExcepInfo, puArgErr);
4711 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4713 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4714 nsIDOMElement *nselem;
4715 HTMLElement *elem;
4716 nsAString nsstr;
4717 nsresult nsres;
4718 HRESULT hres;
4720 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4722 nsAString_InitDepend(&nsstr, v);
4723 nsres = nsIDOMDocument_QuerySelector(This->dom_document, &nsstr, &nselem);
4724 nsAString_Finish(&nsstr);
4725 if(NS_FAILED(nsres)) {
4726 WARN("QuerySelector failed: %08lx\n", nsres);
4727 return map_nsresult(nsres);
4730 if(!nselem) {
4731 *pel = NULL;
4732 return S_OK;
4735 hres = get_element(nselem, &elem);
4736 nsIDOMElement_Release(nselem);
4737 if(FAILED(hres))
4738 return hres;
4740 *pel = &elem->IHTMLElement_iface;
4741 return S_OK;
4744 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4746 HTMLDocumentNode *This = impl_from_IDocumentSelector(iface);
4747 nsIDOMNodeList *node_list;
4748 nsAString nsstr;
4749 nsresult nsres;
4750 HRESULT hres;
4752 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4754 nsAString_InitDepend(&nsstr, v);
4755 nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &nsstr, &node_list);
4756 nsAString_Finish(&nsstr);
4757 if(NS_FAILED(nsres)) {
4758 WARN("QuerySelectorAll failed: %08lx\n", nsres);
4759 return map_nsresult(nsres);
4762 hres = create_child_collection(node_list, dispex_compat_mode(&This->node.event_target.dispex), pel);
4763 nsIDOMNodeList_Release(node_list);
4764 return hres;
4767 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4768 DocumentSelector_QueryInterface,
4769 DocumentSelector_AddRef,
4770 DocumentSelector_Release,
4771 DocumentSelector_GetTypeInfoCount,
4772 DocumentSelector_GetTypeInfo,
4773 DocumentSelector_GetIDsOfNames,
4774 DocumentSelector_Invoke,
4775 DocumentSelector_querySelector,
4776 DocumentSelector_querySelectorAll
4779 static inline HTMLDocumentNode *impl_from_IDocumentEvent(IDocumentEvent *iface)
4781 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentEvent_iface);
4784 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4786 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4787 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4790 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4792 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4793 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4796 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4798 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4799 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4802 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4804 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4805 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4808 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4809 LCID lcid, ITypeInfo **ppTInfo)
4811 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4812 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4815 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4816 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4818 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4819 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4820 rgDispId);
4823 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4824 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4826 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4827 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4828 pDispParams, pVarResult, pExcepInfo, puArgErr);
4831 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4833 HTMLDocumentNode *This = impl_from_IDocumentEvent(iface);
4835 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4837 return create_document_event_str(This, eventType, p);
4840 static const IDocumentEventVtbl DocumentEventVtbl = {
4841 DocumentEvent_QueryInterface,
4842 DocumentEvent_AddRef,
4843 DocumentEvent_Release,
4844 DocumentEvent_GetTypeInfoCount,
4845 DocumentEvent_GetTypeInfo,
4846 DocumentEvent_GetIDsOfNames,
4847 DocumentEvent_Invoke,
4848 DocumentEvent_createEvent
4851 static void HTMLDocumentNode_on_advise(IUnknown *iface, cp_static_data_t *cp)
4853 HTMLDocumentNode *This = CONTAINING_RECORD((IHTMLDocument2*)iface, HTMLDocumentNode, IHTMLDocument2_iface);
4855 if(This->outer_window)
4856 update_doc_cp_events(This, cp);
4859 static inline HTMLDocumentNode *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4861 return CONTAINING_RECORD(iface, HTMLDocumentNode, ISupportErrorInfo_iface);
4864 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4866 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4867 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
4870 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4872 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4873 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
4876 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4878 HTMLDocumentNode *This = impl_from_ISupportErrorInfo(iface);
4879 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
4882 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4884 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4885 return S_FALSE;
4888 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4889 SupportErrorInfo_QueryInterface,
4890 SupportErrorInfo_AddRef,
4891 SupportErrorInfo_Release,
4892 SupportErrorInfo_InterfaceSupportsErrorInfo
4895 static inline HTMLDocumentNode *impl_from_IDispatchEx(IDispatchEx *iface)
4897 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDispatchEx_iface);
4900 static HRESULT has_elem_name(nsIDOMHTMLDocument *html_document, const WCHAR *name)
4902 static const WCHAR fmt[] = L":-moz-any(applet,embed,form,iframe,img,object)[name=\"%s\"]";
4903 WCHAR buf[128], *selector = buf;
4904 nsAString selector_str;
4905 nsIDOMElement *nselem;
4906 nsresult nsres;
4907 size_t len;
4909 len = wcslen(name) + ARRAY_SIZE(fmt) - 2 /* %s */;
4910 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4911 return E_OUTOFMEMORY;
4912 swprintf(selector, len, fmt, name);
4914 nsAString_InitDepend(&selector_str, selector);
4915 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4916 nsAString_Finish(&selector_str);
4917 if(selector != buf)
4918 free(selector);
4919 if(NS_FAILED(nsres))
4920 return map_nsresult(nsres);
4922 if(!nselem)
4923 return DISP_E_UNKNOWNNAME;
4924 nsIDOMElement_Release(nselem);
4925 return S_OK;
4928 static HRESULT get_elem_by_name_or_id(nsIDOMHTMLDocument *html_document, const WCHAR *name, nsIDOMElement **ret)
4930 static const WCHAR fmt[] = L":-moz-any(embed,form,iframe,img):-moz-any([name=\"%s\"],[id=\"%s\"][name]),"
4931 L":-moz-any(applet,object):-moz-any([name=\"%s\"],[id=\"%s\"])";
4932 WCHAR buf[384], *selector = buf;
4933 nsAString selector_str;
4934 nsIDOMElement *nselem;
4935 nsresult nsres;
4936 size_t len;
4938 len = wcslen(name) * 4 + ARRAY_SIZE(fmt) - 8 /* %s */;
4939 if(len > ARRAY_SIZE(buf) && !(selector = malloc(len * sizeof(WCHAR))))
4940 return E_OUTOFMEMORY;
4941 swprintf(selector, len, fmt, name, name, name, name);
4943 nsAString_InitDepend(&selector_str, selector);
4944 nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem);
4945 nsAString_Finish(&selector_str);
4946 if(selector != buf)
4947 free(selector);
4948 if(NS_FAILED(nsres))
4949 return map_nsresult(nsres);
4951 if(ret) {
4952 *ret = nselem;
4953 return S_OK;
4956 if(nselem) {
4957 nsIDOMElement_Release(nselem);
4958 return S_OK;
4960 return DISP_E_UNKNOWNNAME;
4963 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, const WCHAR *name, DISPID *dispid)
4965 unsigned i;
4967 for(i=0; i < This->elem_vars_cnt; i++) {
4968 if(!wcscmp(name, This->elem_vars[i])) {
4969 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4970 return S_OK;
4974 if(This->elem_vars_cnt == This->elem_vars_size) {
4975 WCHAR **new_vars;
4977 if(This->elem_vars_size) {
4978 new_vars = realloc(This->elem_vars, This->elem_vars_size * 2 * sizeof(WCHAR*));
4979 if(!new_vars)
4980 return E_OUTOFMEMORY;
4981 This->elem_vars_size *= 2;
4982 }else {
4983 new_vars = malloc(16 * sizeof(WCHAR*));
4984 if(!new_vars)
4985 return E_OUTOFMEMORY;
4986 This->elem_vars_size = 16;
4989 This->elem_vars = new_vars;
4992 This->elem_vars[This->elem_vars_cnt] = wcsdup(name);
4993 if(!This->elem_vars[This->elem_vars_cnt])
4994 return E_OUTOFMEMORY;
4996 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4997 return S_OK;
5000 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
5002 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5004 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5007 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
5009 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5011 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5014 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
5016 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5018 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5021 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
5023 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5025 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5028 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
5029 LCID lcid, ITypeInfo **ppTInfo)
5031 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5033 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5036 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
5037 LPOLESTR *rgszNames, UINT cNames,
5038 LCID lcid, DISPID *rgDispId)
5040 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5042 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
5045 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
5046 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5047 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5049 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5051 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
5052 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5054 return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags, pDispParams,
5055 pVarResult, pExcepInfo, NULL);
5058 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
5060 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5061 HRESULT hres;
5063 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex & ~fdexNameEnsure, pid);
5064 if(hres != DISP_E_UNKNOWNNAME)
5065 return hres;
5067 if(This->html_document) {
5068 hres = get_elem_by_name_or_id(This->html_document, bstrName, NULL);
5069 if(SUCCEEDED(hres))
5070 hres = dispid_from_elem_name(This, bstrName, pid);
5073 if(hres == DISP_E_UNKNOWNNAME && (grfdex & fdexNameEnsure))
5074 hres = dispex_get_dynid(&This->node.event_target.dispex, bstrName, FALSE, pid);
5075 return hres;
5078 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
5079 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
5081 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5083 if(This->window) {
5084 switch(id) {
5085 case DISPID_READYSTATE:
5086 TRACE("DISPID_READYSTATE\n");
5088 if(!(wFlags & DISPATCH_PROPERTYGET))
5089 return E_INVALIDARG;
5091 V_VT(pvarRes) = VT_I4;
5092 V_I4(pvarRes) = This->window->base.outer_window->readystate;
5093 return S_OK;
5094 default:
5095 break;
5099 return IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
5102 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
5104 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5106 return IDispatchEx_DeleteMemberByName(&This->node.event_target.dispex.IDispatchEx_iface, bstrName, grfdex);
5109 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
5111 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5113 return IDispatchEx_DeleteMemberByDispID(&This->node.event_target.dispex.IDispatchEx_iface, id);
5116 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
5118 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5120 return IDispatchEx_GetMemberProperties(&This->node.event_target.dispex.IDispatchEx_iface, id, grfdexFetch, pgrfdex);
5123 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
5125 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5127 return IDispatchEx_GetMemberName(&This->node.event_target.dispex.IDispatchEx_iface, id, pbstrName);
5130 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
5132 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5134 return IDispatchEx_GetNextDispID(&This->node.event_target.dispex.IDispatchEx_iface, grfdex, id, pid);
5137 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
5139 HTMLDocumentNode *This = impl_from_IDispatchEx(iface);
5141 return IDispatchEx_GetNameSpaceParent(&This->node.event_target.dispex.IDispatchEx_iface, ppunk);
5144 static const IDispatchExVtbl DocDispatchExVtbl = {
5145 DocDispatchEx_QueryInterface,
5146 DocDispatchEx_AddRef,
5147 DocDispatchEx_Release,
5148 DocDispatchEx_GetTypeInfoCount,
5149 DocDispatchEx_GetTypeInfo,
5150 DocDispatchEx_GetIDsOfNames,
5151 DocDispatchEx_Invoke,
5152 DocDispatchEx_GetDispID,
5153 DocDispatchEx_InvokeEx,
5154 DocDispatchEx_DeleteMemberByName,
5155 DocDispatchEx_DeleteMemberByDispID,
5156 DocDispatchEx_GetMemberProperties,
5157 DocDispatchEx_GetMemberName,
5158 DocDispatchEx_GetNextDispID,
5159 DocDispatchEx_GetNameSpaceParent
5162 static inline HTMLDocumentNode *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
5164 return CONTAINING_RECORD(iface, HTMLDocumentNode, IProvideMultipleClassInfo_iface);
5167 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
5168 REFIID riid, void **ppv)
5170 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5171 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5174 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
5176 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5177 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5180 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
5182 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5183 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5186 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
5188 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5189 TRACE("(%p)->(%p)\n", This, ppTI);
5190 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
5193 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
5195 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5196 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
5197 return E_NOTIMPL;
5200 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
5202 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5203 FIXME("(%p)->(%p)\n", This, pcti);
5204 *pcti = 1;
5205 return S_OK;
5208 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
5209 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
5211 HTMLDocumentNode *This = impl_from_IProvideMultipleClassInfo(iface);
5212 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
5213 return E_NOTIMPL;
5216 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
5217 ProvideClassInfo_QueryInterface,
5218 ProvideClassInfo_AddRef,
5219 ProvideClassInfo_Release,
5220 ProvideClassInfo_GetClassInfo,
5221 ProvideClassInfo2_GetGUID,
5222 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
5223 ProvideMultipleClassInfo_GetInfoOfIndex
5226 /**********************************************************
5227 * IMarkupServices implementation
5229 static inline HTMLDocumentNode *impl_from_IMarkupServices(IMarkupServices *iface)
5231 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupServices_iface);
5234 static HRESULT WINAPI MarkupServices_QueryInterface(IMarkupServices *iface, REFIID riid, void **ppvObject)
5236 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5237 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5240 static ULONG WINAPI MarkupServices_AddRef(IMarkupServices *iface)
5242 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5243 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5246 static ULONG WINAPI MarkupServices_Release(IMarkupServices *iface)
5248 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5249 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5252 static HRESULT WINAPI MarkupServices_CreateMarkupPointer(IMarkupServices *iface, IMarkupPointer **ppPointer)
5254 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5256 TRACE("(%p)->(%p)\n", This, ppPointer);
5258 return create_markup_pointer(ppPointer);
5261 static HRESULT WINAPI MarkupServices_CreateMarkupContainer(IMarkupServices *iface, IMarkupContainer **ppMarkupContainer)
5263 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5264 FIXME("(%p)->(%p)\n", This, ppMarkupContainer);
5265 return E_NOTIMPL;
5268 static HRESULT WINAPI MarkupServices_CreateElement(IMarkupServices *iface,
5269 ELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement)
5271 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5272 FIXME("(%p)->(%d,%s,%p)\n", This, tagID, debugstr_w(pchAttributes), ppElement);
5273 return E_NOTIMPL;
5276 static HRESULT WINAPI MarkupServices_CloneElement(IMarkupServices *iface,
5277 IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone)
5279 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5280 FIXME("(%p)->(%p,%p)\n", This, pElemCloneThis, ppElementTheClone);
5281 return E_NOTIMPL;
5284 static HRESULT WINAPI MarkupServices_InsertElement(IMarkupServices *iface,
5285 IHTMLElement *pElementInsert, IMarkupPointer *pPointerStart,
5286 IMarkupPointer *pPointerFinish)
5288 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5289 FIXME("(%p)->(%p,%p,%p)\n", This, pElementInsert, pPointerStart, pPointerFinish);
5290 return E_NOTIMPL;
5293 static HRESULT WINAPI MarkupServices_RemoveElement(IMarkupServices *iface, IHTMLElement *pElementRemove)
5295 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5296 FIXME("(%p)->(%p)\n", This, pElementRemove);
5297 return E_NOTIMPL;
5300 static HRESULT WINAPI MarkupServices_Remove(IMarkupServices *iface,
5301 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5303 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5304 FIXME("(%p)->(%p,%p)\n", This, pPointerStart, pPointerFinish);
5305 return E_NOTIMPL;
5308 static HRESULT WINAPI MarkupServices_Copy(IMarkupServices *iface,
5309 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5310 IMarkupPointer *pPointerTarget)
5312 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5313 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5314 return E_NOTIMPL;
5317 static HRESULT WINAPI MarkupServices_Move(IMarkupServices *iface,
5318 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
5319 IMarkupPointer *pPointerTarget)
5321 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5322 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
5323 return E_NOTIMPL;
5326 static HRESULT WINAPI MarkupServices_InsertText(IMarkupServices *iface,
5327 OLECHAR *pchText, LONG cch, IMarkupPointer *pPointerTarget)
5329 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5330 FIXME("(%p)->(%s,%lx,%p)\n", This, debugstr_w(pchText), cch, pPointerTarget);
5331 return E_NOTIMPL;
5334 static HRESULT WINAPI MarkupServices_ParseString(IMarkupServices *iface,
5335 OLECHAR *pchHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5336 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5338 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5339 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(pchHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5340 return E_NOTIMPL;
5343 static HRESULT WINAPI MarkupServices_ParseGlobal(IMarkupServices *iface,
5344 HGLOBAL hglobalHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
5345 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5347 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5348 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(hglobalHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
5349 return E_NOTIMPL;
5352 static HRESULT WINAPI MarkupServices_IsScopedElement(IMarkupServices *iface,
5353 IHTMLElement *pElement, BOOL *pfScoped)
5355 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5356 FIXME("(%p)->(%p,%p)\n", This, pElement, pfScoped);
5357 return E_NOTIMPL;
5360 static HRESULT WINAPI MarkupServices_GetElementTagId(IMarkupServices *iface,
5361 IHTMLElement *pElement, ELEMENT_TAG_ID *ptagId)
5363 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5364 FIXME("(%p)->(%p,%p)\n", This, pElement, ptagId);
5365 return E_NOTIMPL;
5368 static HRESULT WINAPI MarkupServices_GetTagIDForName(IMarkupServices *iface,
5369 BSTR bstrName, ELEMENT_TAG_ID *ptagId)
5371 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5372 FIXME("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), ptagId);
5373 return E_NOTIMPL;
5376 static HRESULT WINAPI MarkupServices_GetNameForTagID(IMarkupServices *iface,
5377 ELEMENT_TAG_ID tagId, BSTR *pbstrName)
5379 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5380 FIXME("(%p)->(%d,%p)\n", This, tagId, pbstrName);
5381 return E_NOTIMPL;
5384 static HRESULT WINAPI MarkupServices_MovePointersToRange(IMarkupServices *iface,
5385 IHTMLTxtRange *pIRange, IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
5387 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5388 FIXME("(%p)->(%p,%p,%p)\n", This, pIRange, pPointerStart, pPointerFinish);
5389 return E_NOTIMPL;
5392 static HRESULT WINAPI MarkupServices_MoveRangeToPointers(IMarkupServices *iface,
5393 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish, IHTMLTxtRange *pIRange)
5395 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5396 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerStart, pPointerFinish, pIRange);
5397 return E_NOTIMPL;
5400 static HRESULT WINAPI MarkupServices_BeginUndoUnit(IMarkupServices *iface, OLECHAR *pchTitle)
5402 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5403 FIXME("(%p)->(%s)\n", This, debugstr_w(pchTitle));
5404 return E_NOTIMPL;
5407 static HRESULT WINAPI MarkupServices_EndUndoUnit(IMarkupServices *iface)
5409 HTMLDocumentNode *This = impl_from_IMarkupServices(iface);
5410 FIXME("(%p)\n", This);
5411 return E_NOTIMPL;
5414 static const IMarkupServicesVtbl MarkupServicesVtbl = {
5415 MarkupServices_QueryInterface,
5416 MarkupServices_AddRef,
5417 MarkupServices_Release,
5418 MarkupServices_CreateMarkupPointer,
5419 MarkupServices_CreateMarkupContainer,
5420 MarkupServices_CreateElement,
5421 MarkupServices_CloneElement,
5422 MarkupServices_InsertElement,
5423 MarkupServices_RemoveElement,
5424 MarkupServices_Remove,
5425 MarkupServices_Copy,
5426 MarkupServices_Move,
5427 MarkupServices_InsertText,
5428 MarkupServices_ParseString,
5429 MarkupServices_ParseGlobal,
5430 MarkupServices_IsScopedElement,
5431 MarkupServices_GetElementTagId,
5432 MarkupServices_GetTagIDForName,
5433 MarkupServices_GetNameForTagID,
5434 MarkupServices_MovePointersToRange,
5435 MarkupServices_MoveRangeToPointers,
5436 MarkupServices_BeginUndoUnit,
5437 MarkupServices_EndUndoUnit
5440 /**********************************************************
5441 * IMarkupContainer implementation
5443 static inline HTMLDocumentNode *impl_from_IMarkupContainer(IMarkupContainer *iface)
5445 return CONTAINING_RECORD(iface, HTMLDocumentNode, IMarkupContainer_iface);
5448 static HRESULT WINAPI MarkupContainer_QueryInterface(IMarkupContainer *iface, REFIID riid, void **ppvObject)
5450 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5451 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5454 static ULONG WINAPI MarkupContainer_AddRef(IMarkupContainer *iface)
5456 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5457 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5460 static ULONG WINAPI MarkupContainer_Release(IMarkupContainer *iface)
5462 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5463 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5466 static HRESULT WINAPI MarkupContainer_OwningDoc(IMarkupContainer *iface, IHTMLDocument2 **ppDoc)
5468 HTMLDocumentNode *This = impl_from_IMarkupContainer(iface);
5469 FIXME("(%p)->(%p)\n", This, ppDoc);
5470 return E_NOTIMPL;
5473 static const IMarkupContainerVtbl MarkupContainerVtbl = {
5474 MarkupContainer_QueryInterface,
5475 MarkupContainer_AddRef,
5476 MarkupContainer_Release,
5477 MarkupContainer_OwningDoc
5480 /**********************************************************
5481 * IDisplayServices implementation
5483 static inline HTMLDocumentNode *impl_from_IDisplayServices(IDisplayServices *iface)
5485 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDisplayServices_iface);
5488 static HRESULT WINAPI DisplayServices_QueryInterface(IDisplayServices *iface, REFIID riid, void **ppvObject)
5490 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5491 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppvObject);
5494 static ULONG WINAPI DisplayServices_AddRef(IDisplayServices *iface)
5496 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5497 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5500 static ULONG WINAPI DisplayServices_Release(IDisplayServices *iface)
5502 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5503 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5506 static HRESULT WINAPI DisplayServices_CreateDisplayPointer(IDisplayServices *iface, IDisplayPointer **ppDispPointer)
5508 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5509 FIXME("(%p)->(%p)\n", This, ppDispPointer);
5510 return E_NOTIMPL;
5513 static HRESULT WINAPI DisplayServices_TransformRect(IDisplayServices *iface,
5514 RECT *pRect, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5516 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5517 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_rect(pRect), eSource, eDestination, pIElement);
5518 return E_NOTIMPL;
5521 static HRESULT WINAPI DisplayServices_TransformPoint(IDisplayServices *iface,
5522 POINT *pPoint, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5524 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5525 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_point(pPoint), eSource, eDestination, pIElement);
5526 return E_NOTIMPL;
5529 static HRESULT WINAPI DisplayServices_GetCaret(IDisplayServices *iface, IHTMLCaret **ppCaret)
5531 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5532 FIXME("(%p)->(%p)\n", This, ppCaret);
5533 return E_NOTIMPL;
5536 static HRESULT WINAPI DisplayServices_GetComputedStyle(IDisplayServices *iface,
5537 IMarkupPointer *pPointer, IHTMLComputedStyle **ppComputedStyle)
5539 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5540 FIXME("(%p)->(%p,%p)\n", This, pPointer, ppComputedStyle);
5541 return E_NOTIMPL;
5544 static HRESULT WINAPI DisplayServices_ScrollRectIntoView(IDisplayServices *iface,
5545 IHTMLElement *pIElement, RECT rect)
5547 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5548 FIXME("(%p)->(%p,%s)\n", This, pIElement, wine_dbgstr_rect(&rect));
5549 return E_NOTIMPL;
5552 static HRESULT WINAPI DisplayServices_HasFlowLayout(IDisplayServices *iface,
5553 IHTMLElement *pIElement, BOOL *pfHasFlowLayout)
5555 HTMLDocumentNode *This = impl_from_IDisplayServices(iface);
5556 FIXME("(%p)->(%p,%p)\n", This, pIElement, pfHasFlowLayout);
5557 return E_NOTIMPL;
5560 static const IDisplayServicesVtbl DisplayServicesVtbl = {
5561 DisplayServices_QueryInterface,
5562 DisplayServices_AddRef,
5563 DisplayServices_Release,
5564 DisplayServices_CreateDisplayPointer,
5565 DisplayServices_TransformRect,
5566 DisplayServices_TransformPoint,
5567 DisplayServices_GetCaret,
5568 DisplayServices_GetComputedStyle,
5569 DisplayServices_ScrollRectIntoView,
5570 DisplayServices_HasFlowLayout
5573 /**********************************************************
5574 * IDocumentRange implementation
5576 static inline HTMLDocumentNode *impl_from_IDocumentRange(IDocumentRange *iface)
5578 return CONTAINING_RECORD(iface, HTMLDocumentNode, IDocumentRange_iface);
5581 static HRESULT WINAPI DocumentRange_QueryInterface(IDocumentRange *iface, REFIID riid, void **ppv)
5583 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5585 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
5588 static ULONG WINAPI DocumentRange_AddRef(IDocumentRange *iface)
5590 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5592 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
5595 static ULONG WINAPI DocumentRange_Release(IDocumentRange *iface)
5597 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5599 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
5602 static HRESULT WINAPI DocumentRange_GetTypeInfoCount(IDocumentRange *iface, UINT *pctinfo)
5604 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5606 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
5609 static HRESULT WINAPI DocumentRange_GetTypeInfo(IDocumentRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5611 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5613 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5616 static HRESULT WINAPI DocumentRange_GetIDsOfNames(IDocumentRange *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5617 LCID lcid, DISPID *rgDispId)
5619 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5621 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
5622 rgDispId);
5625 static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
5626 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5628 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5630 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5631 pDispParams, pVarResult, pExcepInfo, puArgErr);
5634 static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
5636 HTMLDocumentNode *This = impl_from_IDocumentRange(iface);
5637 nsIDOMRange *nsrange;
5638 HRESULT hres;
5640 TRACE("(%p)->(%p)\n", This, p);
5642 if(!This->dom_document) {
5643 WARN("NULL dom_document\n");
5644 return E_UNEXPECTED;
5647 if(NS_FAILED(nsIDOMDocument_CreateRange(This->dom_document, &nsrange)))
5648 return E_FAIL;
5650 hres = create_dom_range(nsrange, dispex_compat_mode(&This->node.event_target.dispex), p);
5651 nsIDOMRange_Release(nsrange);
5652 return hres;
5655 static const IDocumentRangeVtbl DocumentRangeVtbl = {
5656 DocumentRange_QueryInterface,
5657 DocumentRange_AddRef,
5658 DocumentRange_Release,
5659 DocumentRange_GetTypeInfoCount,
5660 DocumentRange_GetTypeInfo,
5661 DocumentRange_GetIDsOfNames,
5662 DocumentRange_Invoke,
5663 DocumentRange_createRange
5666 static cp_static_data_t HTMLDocumentNodeEvents_data = { HTMLDocumentEvents_tid, HTMLDocumentNode_on_advise };
5667 static cp_static_data_t HTMLDocumentNodeEvents2_data = { HTMLDocumentEvents2_tid, HTMLDocumentNode_on_advise, TRUE };
5669 static const cpc_entry_t HTMLDocumentNode_cpc[] = {
5670 {&IID_IDispatch, &HTMLDocumentNodeEvents_data},
5671 {&IID_IPropertyNotifySink},
5672 {&DIID_HTMLDocumentEvents, &HTMLDocumentNodeEvents_data},
5673 {&DIID_HTMLDocumentEvents2, &HTMLDocumentNodeEvents2_data},
5674 {NULL}
5677 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5679 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
5682 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5684 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5686 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5688 if(IsEqualGUID(&IID_IUnknown, riid))
5689 *ppv = &This->IHTMLDocument2_iface;
5690 else if(IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDispatchEx, riid))
5691 *ppv = &This->IDispatchEx_iface;
5692 else if(IsEqualGUID(&IID_IHTMLDocument, riid) || IsEqualGUID(&IID_IHTMLDocument2, riid))
5693 *ppv = &This->IHTMLDocument2_iface;
5694 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
5695 *ppv = &This->IHTMLDocument3_iface;
5696 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
5697 *ppv = &This->IHTMLDocument4_iface;
5698 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
5699 *ppv = &This->IHTMLDocument5_iface;
5700 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
5701 *ppv = &This->IHTMLDocument6_iface;
5702 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
5703 *ppv = &This->IHTMLDocument7_iface;
5704 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
5705 *ppv = &This->IDocumentSelector_iface;
5706 else if(IsEqualGUID(&IID_IDocumentEvent, riid))
5707 *ppv = &This->IDocumentEvent_iface;
5708 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
5709 *ppv = &This->IHTMLDocument2_iface;
5710 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
5711 *ppv = &This->ISupportErrorInfo_iface;
5712 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
5713 *ppv = &This->IProvideMultipleClassInfo_iface;
5714 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
5715 *ppv = &This->IProvideMultipleClassInfo_iface;
5716 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
5717 *ppv = &This->IProvideMultipleClassInfo_iface;
5718 else if(IsEqualGUID(&IID_IMarkupServices, riid))
5719 *ppv = &This->IMarkupServices_iface;
5720 else if(IsEqualGUID(&IID_IMarkupContainer, riid))
5721 *ppv = &This->IMarkupContainer_iface;
5722 else if(IsEqualGUID(&IID_IDisplayServices, riid))
5723 *ppv = &This->IDisplayServices_iface;
5724 else if(IsEqualGUID(&IID_IDocumentRange, riid))
5725 *ppv = &This->IDocumentRange_iface;
5726 else if(IsEqualGUID(&IID_IPersist, riid))
5727 *ppv = &This->IPersistFile_iface;
5728 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
5729 *ppv = &This->IPersistMoniker_iface;
5730 else if(IsEqualGUID(&IID_IPersistFile, riid))
5731 *ppv = &This->IPersistFile_iface;
5732 else if(IsEqualGUID(&IID_IMonikerProp, riid))
5733 *ppv = &This->IMonikerProp_iface;
5734 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
5735 *ppv = &This->IPersistStreamInit_iface;
5736 else if(IsEqualGUID(&IID_IPersistHistory, riid))
5737 *ppv = &This->IPersistHistory_iface;
5738 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
5739 *ppv = &This->IHlinkTarget_iface;
5740 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
5741 *ppv = &This->IOleCommandTarget_iface;
5742 else if(IsEqualGUID(&IID_IOleObject, riid))
5743 *ppv = &This->IOleObject_iface;
5744 else if(IsEqualGUID(&IID_IOleDocument, riid))
5745 *ppv = &This->IOleDocument_iface;
5746 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
5747 *ppv = &This->IOleInPlaceActiveObject_iface;
5748 else if(IsEqualGUID(&IID_IOleWindow, riid))
5749 *ppv = &This->IOleInPlaceActiveObject_iface;
5750 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
5751 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5752 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
5753 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5754 else if(IsEqualGUID(&IID_IOleControl, riid))
5755 *ppv = &This->IOleControl_iface;
5756 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
5757 *ppv = &This->IObjectWithSite_iface;
5758 else if(IsEqualGUID(&IID_IOleContainer, riid))
5759 *ppv = &This->IOleContainer_iface;
5760 else if(IsEqualGUID(&IID_IObjectSafety, riid))
5761 *ppv = &This->IObjectSafety_iface;
5762 else if(IsEqualGUID(&IID_IServiceProvider, riid))
5763 *ppv = &This->IServiceProvider_iface;
5764 else if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
5765 *ppv = &This->IInternetHostSecurityManager_iface;
5766 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
5767 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5768 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
5769 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
5770 *ppv = NULL;
5771 return E_NOINTERFACE;
5772 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
5773 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
5774 *ppv = NULL;
5775 return E_NOINTERFACE;
5776 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
5777 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
5778 *ppv = NULL;
5779 return E_NOINTERFACE;
5780 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
5781 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
5782 *ppv = NULL;
5783 return E_NOINTERFACE;
5784 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
5785 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
5786 *ppv = NULL;
5787 return E_NOINTERFACE;
5788 }else {
5789 return HTMLDOMNode_QI(&This->node, riid, ppv);
5792 IUnknown_AddRef((IUnknown*)*ppv);
5793 return S_OK;
5796 void detach_document_node(HTMLDocumentNode *doc)
5798 unsigned i;
5800 while(!list_empty(&doc->plugin_hosts))
5801 detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
5803 if(doc->dom_implementation)
5804 detach_dom_implementation(doc->dom_implementation);
5806 unlink_ref(&doc->dom_implementation);
5807 unlink_ref(&doc->namespaces);
5808 detach_events(doc);
5809 detach_selection(doc);
5810 detach_ranges(doc);
5812 for(i=0; i < doc->elem_vars_cnt; i++)
5813 free(doc->elem_vars[i]);
5814 free(doc->elem_vars);
5815 doc->elem_vars_cnt = doc->elem_vars_size = 0;
5816 doc->elem_vars = NULL;
5818 unlink_ref(&doc->catmgr);
5819 if(doc->browser) {
5820 list_remove(&doc->browser_entry);
5821 doc->browser = NULL;
5825 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
5827 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5829 TRACE("(%p)\n", This);
5831 free(This->event_vector);
5832 ConnectionPointContainer_Destroy(&This->cp_container);
5835 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5837 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5838 FIXME("%p\n", This);
5839 return E_NOTIMPL;
5842 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
5844 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5846 if(This->dom_document) {
5847 release_document_mutation(This);
5848 detach_document_node(This);
5849 This->dom_document = NULL;
5850 This->html_document = NULL;
5851 This->window = NULL;
5855 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
5856 .clsid = &CLSID_HTMLDocument,
5857 .qi = HTMLDocumentNode_QI,
5858 .destructor = HTMLDocumentNode_destructor,
5859 .cpc_entries = HTMLDocumentNode_cpc,
5860 .clone = HTMLDocumentNode_clone,
5861 .unlink = HTMLDocumentNode_unlink
5864 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5866 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5867 HTMLDocumentNode *new_node;
5868 HRESULT hres;
5870 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
5871 if(FAILED(hres))
5872 return hres;
5874 *ret = &new_node->node;
5875 return S_OK;
5878 static void HTMLDocumentFragment_unlink(HTMLDOMNode *iface)
5880 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5882 if(This->window) {
5883 detach_document_node(This);
5885 /* document fragments own reference to inner window */
5886 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
5887 This->window = NULL;
5891 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
5893 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
5896 static HRESULT HTMLDocumentNode_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
5898 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5899 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
5901 if(!This->dom_document || idx >= This->elem_vars_cnt)
5902 return DISP_E_MEMBERNOTFOUND;
5904 return (*name = SysAllocString(This->elem_vars[idx])) ? S_OK : E_OUTOFMEMORY;
5907 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5908 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5910 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5911 nsIDOMElement *nselem;
5912 HTMLDOMNode *node;
5913 unsigned i;
5914 HRESULT hres;
5916 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET))
5917 return MSHTML_E_INVALID_PROPERTY;
5919 i = id - MSHTML_DISPID_CUSTOM_MIN;
5921 if(!This->html_document || i >= This->elem_vars_cnt)
5922 return DISP_E_MEMBERNOTFOUND;
5924 hres = get_elem_by_name_or_id(This->html_document, This->elem_vars[i], &nselem);
5925 if(FAILED(hres))
5926 return hres;
5927 if(!nselem)
5928 return DISP_E_MEMBERNOTFOUND;
5930 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
5931 nsIDOMElement_Release(nselem);
5932 if(FAILED(hres))
5933 return hres;
5935 V_VT(res) = VT_DISPATCH;
5936 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5937 return S_OK;
5940 static HRESULT HTMLDocumentNode_next_dispid(DispatchEx *dispex, DISPID id, DISPID *pid)
5942 DWORD idx = (id == DISPID_STARTENUM) ? 0 : id - MSHTML_DISPID_CUSTOM_MIN + 1;
5943 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5944 nsIDOMNodeList *node_list;
5945 const PRUnichar *name;
5946 nsIDOMElement *nselem;
5947 nsIDOMNode *nsnode;
5948 nsAString nsstr;
5949 nsresult nsres;
5950 HRESULT hres;
5951 UINT32 i;
5953 if(!This->html_document)
5954 return S_FALSE;
5956 while(idx < This->elem_vars_cnt) {
5957 hres = has_elem_name(This->html_document, This->elem_vars[idx]);
5958 if(SUCCEEDED(hres)) {
5959 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
5960 return S_OK;
5962 if(hres != DISP_E_UNKNOWNNAME)
5963 return hres;
5964 idx++;
5967 /* Populate possibly missing DISPIDs */
5968 nsAString_InitDepend(&nsstr, L":-moz-any(applet,embed,form,iframe,img,object)[name]");
5969 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->html_document, &nsstr, &node_list);
5970 nsAString_Finish(&nsstr);
5971 if(NS_FAILED(nsres))
5972 return map_nsresult(nsres);
5974 for(i = 0, hres = S_OK; SUCCEEDED(hres); i++) {
5975 nsres = nsIDOMNodeList_Item(node_list, i, &nsnode);
5976 if(NS_FAILED(nsres)) {
5977 hres = map_nsresult(nsres);
5978 break;
5980 if(!nsnode)
5981 break;
5983 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
5984 nsIDOMNode_Release(nsnode);
5985 if(nsres != S_OK)
5986 continue;
5988 nsres = get_elem_attr_value(nselem, L"name", &nsstr, &name);
5989 nsIDOMElement_Release(nselem);
5990 if(NS_FAILED(nsres))
5991 hres = map_nsresult(nsres);
5992 else {
5993 hres = dispid_from_elem_name(This, name, &id);
5994 nsAString_Finish(&nsstr);
5997 nsIDOMNodeList_Release(node_list);
5998 if(FAILED(hres))
5999 return hres;
6001 if(idx >= This->elem_vars_cnt)
6002 return S_FALSE;
6004 *pid = idx + MSHTML_DISPID_CUSTOM_MIN;
6005 return S_OK;
6008 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
6010 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6012 TRACE("(%p) returning %u\n", This, This->document_mode);
6014 return lock_document_mode(This);
6017 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
6019 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6020 return (nsISupports*)This->node.nsnode;
6023 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
6025 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6026 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
6029 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
6031 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6032 if(!This->window)
6033 return NULL;
6034 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
6035 return &This->window->event_target;
6038 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
6040 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6041 ConnectionPointContainer *container = This->doc_obj
6042 ? &This->doc_obj->cp_container : &This->cp_container;
6043 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
6044 return container;
6047 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
6049 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6050 return default_set_current_event(This->window, event);
6053 static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp, VARIANT *res,
6054 EXCEPINFO *ei, IServiceProvider *caller)
6056 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
6058 if(!(flags & DISPATCH_PROPERTYPUT) || !This->outer_window)
6059 return S_FALSE;
6061 return IDispatchEx_InvokeEx(&This->outer_window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
6062 0, flags, dp, res, ei, caller);
6065 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
6067 .destructor = HTMLDOMNode_destructor,
6068 .traverse = HTMLDOMNode_traverse,
6069 .unlink = HTMLDOMNode_unlink,
6070 .get_name = HTMLDocumentNode_get_name,
6071 .invoke = HTMLDocumentNode_invoke,
6072 .next_dispid = HTMLDocumentNode_next_dispid,
6073 .get_compat_mode = HTMLDocumentNode_get_compat_mode,
6075 .get_gecko_target = HTMLDocumentNode_get_gecko_target,
6076 .bind_event = HTMLDocumentNode_bind_event,
6077 .get_parent_event_target = HTMLDocumentNode_get_parent_event_target,
6078 .get_cp_container = HTMLDocumentNode_get_cp_container,
6079 .set_current_event = HTMLDocumentNode_set_current_event
6082 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
6083 .clsid = &CLSID_HTMLDocument,
6084 .qi = HTMLDocumentNode_QI,
6085 .destructor = HTMLDocumentNode_destructor,
6086 .cpc_entries = HTMLDocumentNode_cpc,
6087 .clone = HTMLDocumentFragment_clone,
6088 .unlink = HTMLDocumentFragment_unlink
6091 static const tid_t HTMLDocumentNode_iface_tids[] = {
6092 IHTMLDOMNode_tid,
6093 IHTMLDOMNode2_tid,
6094 IHTMLDocument4_tid,
6095 IHTMLDocument5_tid,
6096 IDocumentSelector_tid,
6100 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
6102 static const dispex_hook_t document2_hooks[] = {
6103 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6104 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6105 {DISPID_UNKNOWN}
6107 static const dispex_hook_t document2_ie11_hooks[] = {
6108 {DISPID_IHTMLDOCUMENT2_URL, NULL, L"URL"},
6109 {DISPID_IHTMLDOCUMENT2_LOCATION, HTMLDocumentNode_location_hook},
6110 {DISPID_IHTMLDOCUMENT2_CREATESTYLESHEET, NULL},
6111 {DISPID_IHTMLDOCUMENT2_FILESIZE, NULL},
6112 {DISPID_IHTMLDOCUMENT2_SELECTION, NULL},
6113 {DISPID_UNKNOWN}
6115 static const dispex_hook_t document3_ie11_hooks[] = {
6116 {DISPID_IHTMLDOCUMENT3_ATTACHEVENT, NULL},
6117 {DISPID_IHTMLDOCUMENT3_DETACHEVENT, NULL},
6118 {DISPID_UNKNOWN}
6120 static const dispex_hook_t document6_ie9_hooks[] = {
6121 {DISPID_IHTMLDOCUMENT6_ONSTORAGE},
6122 {DISPID_UNKNOWN}
6125 HTMLDOMNode_init_dispex_info(info, mode);
6127 if(mode >= COMPAT_MODE_IE9) {
6128 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
6129 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
6132 /* Depending on compatibility version, we add interfaces in different order
6133 * so that the right getElementById implementation is used. */
6134 if(mode < COMPAT_MODE_IE8) {
6135 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
6136 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
6137 }else {
6138 dispex_info_add_interface(info, IHTMLDocument6_tid, mode >= COMPAT_MODE_IE9 ? document6_ie9_hooks : NULL);
6139 dispex_info_add_interface(info, IHTMLDocument3_tid, mode >= COMPAT_MODE_IE11 ? document3_ie11_hooks : NULL);
6141 dispex_info_add_interface(info, IHTMLDocument2_tid, mode >= COMPAT_MODE_IE11 ? document2_ie11_hooks : document2_hooks);
6144 static dispex_static_data_t HTMLDocumentNode_dispex = {
6145 "HTMLDocument",
6146 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
6147 DispHTMLDocument_tid,
6148 HTMLDocumentNode_iface_tids,
6149 HTMLDocumentNode_init_dispex_info
6152 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
6154 HTMLDocumentNode *doc;
6156 doc = calloc(1, sizeof(HTMLDocumentNode));
6157 if(!doc)
6158 return NULL;
6160 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
6161 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
6162 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
6163 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
6164 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
6165 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
6166 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
6167 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
6168 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
6169 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
6170 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
6171 doc->IMarkupServices_iface.lpVtbl = &MarkupServicesVtbl;
6172 doc->IMarkupContainer_iface.lpVtbl = &MarkupContainerVtbl;
6173 doc->IDisplayServices_iface.lpVtbl = &DisplayServicesVtbl;
6174 doc->IDocumentRange_iface.lpVtbl = &DocumentRangeVtbl;
6176 doc->doc_obj = doc_obj;
6177 doc->outer_window = window ? window->base.outer_window : NULL;
6178 doc->window = window;
6180 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocumentNode_cpc);
6181 HTMLDocumentNode_Persist_Init(doc);
6182 HTMLDocumentNode_Service_Init(doc);
6183 HTMLDocumentNode_OleCmd_Init(doc);
6184 HTMLDocumentNode_OleObj_Init(doc);
6185 HTMLDocumentNode_SecMgr_Init(doc);
6187 list_init(&doc->selection_list);
6188 list_init(&doc->range_list);
6189 list_init(&doc->plugin_hosts);
6191 return doc;
6194 HRESULT create_document_node(nsIDOMDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
6195 compat_mode_t parent_mode, HTMLDocumentNode **ret)
6197 HTMLDocumentObj *doc_obj = browser->doc;
6198 HTMLDocumentNode *doc;
6200 doc = alloc_doc_node(doc_obj, window);
6201 if(!doc)
6202 return E_OUTOFMEMORY;
6204 if(parent_mode >= COMPAT_MODE_IE9) {
6205 TRACE("using parent mode %u\n", parent_mode);
6206 doc->document_mode = parent_mode;
6207 lock_document_mode(doc);
6210 if(!doc_obj->window || (window && is_main_content_window(window->base.outer_window)))
6211 doc->cp_container.forward_container = &doc_obj->cp_container;
6213 /* Share reference with HTMLDOMNode */
6214 if(NS_SUCCEEDED(nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&doc->html_document))) {
6215 doc->dom_document = (nsIDOMDocument*)doc->html_document;
6216 nsIDOMHTMLDocument_Release(doc->html_document);
6217 }else {
6218 doc->dom_document = nsdoc;
6219 doc->html_document = NULL;
6222 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)doc->dom_document, &HTMLDocumentNode_dispex);
6224 init_document_mutation(doc);
6225 doc_init_events(doc);
6227 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
6229 list_add_head(&browser->document_nodes, &doc->browser_entry);
6230 doc->browser = browser;
6232 if(browser->usermode == EDITMODE && doc->html_document) {
6233 nsAString mode_str;
6234 nsresult nsres;
6236 nsAString_InitDepend(&mode_str, L"on");
6237 nsres = nsIDOMHTMLDocument_SetDesignMode(doc->html_document, &mode_str);
6238 nsAString_Finish(&mode_str);
6239 if(NS_FAILED(nsres))
6240 ERR("SetDesignMode failed: %08lx\n", nsres);
6243 *ret = doc;
6244 return S_OK;
6247 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
6249 HTMLDocumentNode *doc_frag;
6251 doc_frag = alloc_doc_node(doc_node->doc_obj, doc_node->window);
6252 if(!doc_frag)
6253 return E_OUTOFMEMORY;
6255 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
6257 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
6258 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
6259 doc_frag->document_mode = lock_document_mode(doc_node);
6261 *ret = doc_frag;
6262 return S_OK;
6265 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
6267 HTMLDOMNode *node;
6268 HRESULT hres;
6270 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
6271 if(FAILED(hres))
6272 return hres;
6274 if(!node) {
6275 ERR("document not initialized\n");
6276 return E_FAIL;
6279 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
6280 *ret = impl_from_HTMLDOMNode(node);
6281 return S_OK;