webservices: Add a stub implementation of WS_TYPE_ATTRIBUTE_FIELD_MAPPING in the...
[wine.git] / dlls / mshtml / htmldoc.c
blob8fa3f52e2d444aa72ca33a839d8ddf5705c10f36
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 "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <assert.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "wininet.h"
31 #include "ole2.h"
32 #include "perhist.h"
33 #include "mshtmdid.h"
34 #include "mshtmcid.h"
36 #include "wine/debug.h"
38 #include "mshtml_private.h"
39 #include "htmlevent.h"
40 #include "pluginhost.h"
41 #include "binding.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
45 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret);
47 HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement **ret)
49 nsIDOMNodeList *nsnode_list;
50 nsIDOMElement *nselem;
51 nsIDOMNode *nsnode;
52 nsAString id_str;
53 nsresult nsres;
54 HRESULT hres;
56 if(!doc->nsdoc) {
57 WARN("NULL nsdoc\n");
58 return E_UNEXPECTED;
61 nsAString_InitDepend(&id_str, id);
62 /* get element by id attribute */
63 nsres = nsIDOMHTMLDocument_GetElementById(doc->nsdoc, &id_str, &nselem);
64 if(FAILED(nsres)) {
65 ERR("GetElementById failed: %08x\n", nsres);
66 nsAString_Finish(&id_str);
67 return E_FAIL;
70 /* get first element by name attribute */
71 nsres = nsIDOMHTMLDocument_GetElementsByName(doc->nsdoc, &id_str, &nsnode_list);
72 nsAString_Finish(&id_str);
73 if(FAILED(nsres)) {
74 ERR("getElementsByName failed: %08x\n", nsres);
75 if(nselem)
76 nsIDOMElement_Release(nselem);
77 return E_FAIL;
80 nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode);
81 nsIDOMNodeList_Release(nsnode_list);
82 assert(nsres == NS_OK);
84 if(nsnode && nselem) {
85 UINT16 pos;
87 nsres = nsIDOMNode_CompareDocumentPosition(nsnode, (nsIDOMNode*)nselem, &pos);
88 if(NS_FAILED(nsres)) {
89 FIXME("CompareDocumentPosition failed: 0x%08x\n", nsres);
90 nsIDOMNode_Release(nsnode);
91 nsIDOMElement_Release(nselem);
92 return E_FAIL;
95 TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
96 if(!(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS))) {
97 nsIDOMElement_Release(nselem);
98 nselem = NULL;
102 if(nsnode) {
103 if(!nselem) {
104 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
105 assert(nsres == NS_OK);
107 nsIDOMNode_Release(nsnode);
110 if(!nselem) {
111 *ret = NULL;
112 return S_OK;
115 hres = get_elem(doc, nselem, ret);
116 nsIDOMElement_Release(nselem);
117 return hres;
120 UINT get_document_charset(HTMLDocumentNode *doc)
122 nsAString charset_str;
123 UINT ret = 0;
124 nsresult nsres;
126 if(doc->charset)
127 return doc->charset;
129 nsAString_Init(&charset_str, NULL);
130 nsres = nsIDOMHTMLDocument_GetCharacterSet(doc->nsdoc, &charset_str);
131 if(NS_SUCCEEDED(nsres)) {
132 const PRUnichar *charset;
134 nsAString_GetData(&charset_str, &charset);
136 if(*charset) {
137 BSTR str = SysAllocString(charset);
138 ret = cp_from_charset_string(str);
139 SysFreeString(str);
141 }else {
142 ERR("GetCharset failed: %08x\n", nsres);
144 nsAString_Finish(&charset_str);
146 if(!ret)
147 return CP_UTF8;
149 return doc->charset = ret;
152 static inline HTMLDocument *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
154 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument2_iface);
157 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
159 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
161 return htmldoc_query_interface(This, riid, ppv);
164 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
166 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
168 return htmldoc_addref(This);
171 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
173 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
175 return htmldoc_release(This);
178 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
180 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
182 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
185 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
186 LCID lcid, ITypeInfo **ppTInfo)
188 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
190 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
193 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
194 LPOLESTR *rgszNames, UINT cNames,
195 LCID lcid, DISPID *rgDispId)
197 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
199 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
200 rgDispId);
203 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
204 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
205 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
207 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
209 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
210 pDispParams, pVarResult, pExcepInfo, puArgErr);
213 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
215 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
217 TRACE("(%p)->(%p)\n", This, p);
219 *p = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
220 IDispatch_AddRef(*p);
221 return S_OK;
224 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
226 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
227 nsIDOMElement *nselem = NULL;
228 HTMLDOMNode *node;
229 nsresult nsres;
230 HRESULT hres;
232 TRACE("(%p)->(%p)\n", This, p);
234 if(!This->doc_node->nsdoc) {
235 WARN("NULL nsdoc\n");
236 return E_UNEXPECTED;
239 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
240 if(NS_FAILED(nsres)) {
241 ERR("GetDocumentElement failed: %08x\n", nsres);
242 return E_FAIL;
245 if(!nselem) {
246 *p = NULL;
247 return S_OK;
250 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
251 nsIDOMElement_Release(nselem);
252 if(FAILED(hres))
253 return hres;
255 *p = create_all_collection(node, TRUE);
256 node_release(node);
257 return hres;
260 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
262 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
263 nsIDOMHTMLElement *nsbody = NULL;
264 HTMLDOMNode *node;
265 HRESULT hres;
267 TRACE("(%p)->(%p)\n", This, p);
269 if(This->doc_node->nsdoc) {
270 nsresult nsres;
272 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
273 if(NS_FAILED(nsres)) {
274 TRACE("Could not get body: %08x\n", nsres);
275 return E_UNEXPECTED;
279 if(!nsbody) {
280 *p = NULL;
281 return S_OK;
284 hres = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE, &node);
285 nsIDOMHTMLElement_Release(nsbody);
286 if(FAILED(hres))
287 return hres;
289 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
290 node_release(node);
291 return hres;
294 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
296 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
297 nsIDOMElement *nselem;
298 HTMLElement *elem;
299 nsresult nsres;
300 HRESULT hres;
302 TRACE("(%p)->(%p)\n", This, p);
304 if(!This->doc_node->nsdoc) {
305 *p = NULL;
306 return S_OK;
310 * NOTE: Gecko may return an active element even if the document is not visible.
311 * IE returns NULL in this case.
313 nsres = nsIDOMHTMLDocument_GetActiveElement(This->doc_node->nsdoc, &nselem);
314 if(NS_FAILED(nsres)) {
315 ERR("GetActiveElement failed: %08x\n", nsres);
316 return E_FAIL;
319 if(!nselem) {
320 *p = NULL;
321 return S_OK;
324 hres = get_elem(This->doc_node, nselem, &elem);
325 nsIDOMElement_Release(nselem);
326 if(FAILED(hres))
327 return hres;
329 *p = &elem->IHTMLElement_iface;
330 return S_OK;
333 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
335 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
336 nsIDOMHTMLCollection *nscoll = NULL;
337 nsresult nsres;
339 TRACE("(%p)->(%p)\n", This, p);
341 if(!p)
342 return E_INVALIDARG;
344 *p = NULL;
346 if(!This->doc_node->nsdoc) {
347 WARN("NULL nsdoc\n");
348 return E_UNEXPECTED;
351 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
352 if(NS_FAILED(nsres)) {
353 ERR("GetImages failed: %08x\n", nsres);
354 return E_FAIL;
357 if(nscoll) {
358 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
359 nsIDOMHTMLCollection_Release(nscoll);
362 return S_OK;
365 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
367 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
368 nsIDOMHTMLCollection *nscoll = NULL;
369 nsresult nsres;
371 TRACE("(%p)->(%p)\n", This, p);
373 if(!p)
374 return E_INVALIDARG;
376 *p = NULL;
378 if(!This->doc_node->nsdoc) {
379 WARN("NULL nsdoc\n");
380 return E_UNEXPECTED;
383 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
384 if(NS_FAILED(nsres)) {
385 ERR("GetApplets failed: %08x\n", nsres);
386 return E_FAIL;
389 if(nscoll) {
390 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
391 nsIDOMHTMLCollection_Release(nscoll);
394 return S_OK;
397 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
399 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
400 nsIDOMHTMLCollection *nscoll = NULL;
401 nsresult nsres;
403 TRACE("(%p)->(%p)\n", This, p);
405 if(!p)
406 return E_INVALIDARG;
408 *p = NULL;
410 if(!This->doc_node->nsdoc) {
411 WARN("NULL nsdoc\n");
412 return E_UNEXPECTED;
415 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
416 if(NS_FAILED(nsres)) {
417 ERR("GetLinks failed: %08x\n", nsres);
418 return E_FAIL;
421 if(nscoll) {
422 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
423 nsIDOMHTMLCollection_Release(nscoll);
426 return S_OK;
429 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
431 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
432 nsIDOMHTMLCollection *nscoll = NULL;
433 nsresult nsres;
435 TRACE("(%p)->(%p)\n", This, p);
437 if(!p)
438 return E_INVALIDARG;
440 *p = NULL;
442 if(!This->doc_node->nsdoc) {
443 WARN("NULL nsdoc\n");
444 return E_UNEXPECTED;
447 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
448 if(NS_FAILED(nsres)) {
449 ERR("GetForms failed: %08x\n", nsres);
450 return E_FAIL;
453 if(nscoll) {
454 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
455 nsIDOMHTMLCollection_Release(nscoll);
458 return S_OK;
461 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
463 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
464 nsIDOMHTMLCollection *nscoll = NULL;
465 nsresult nsres;
467 TRACE("(%p)->(%p)\n", This, p);
469 if(!p)
470 return E_INVALIDARG;
472 *p = NULL;
474 if(!This->doc_node->nsdoc) {
475 WARN("NULL nsdoc\n");
476 return E_UNEXPECTED;
479 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
480 if(NS_FAILED(nsres)) {
481 ERR("GetAnchors failed: %08x\n", nsres);
482 return E_FAIL;
485 if(nscoll) {
486 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
487 nsIDOMHTMLCollection_Release(nscoll);
490 return S_OK;
493 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
495 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
496 nsAString nsstr;
497 nsresult nsres;
499 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
501 if(!This->doc_node->nsdoc) {
502 WARN("NULL nsdoc\n");
503 return E_UNEXPECTED;
506 nsAString_InitDepend(&nsstr, v);
507 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
508 nsAString_Finish(&nsstr);
509 if(NS_FAILED(nsres))
510 ERR("SetTitle failed: %08x\n", nsres);
512 return S_OK;
515 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
517 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
518 const PRUnichar *ret;
519 nsAString nsstr;
520 nsresult nsres;
522 TRACE("(%p)->(%p)\n", This, p);
524 if(!This->doc_node->nsdoc) {
525 WARN("NULL nsdoc\n");
526 return E_UNEXPECTED;
530 nsAString_Init(&nsstr, NULL);
531 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
532 if (NS_SUCCEEDED(nsres)) {
533 nsAString_GetData(&nsstr, &ret);
534 *p = SysAllocString(ret);
536 nsAString_Finish(&nsstr);
538 if(NS_FAILED(nsres)) {
539 ERR("GetTitle failed: %08x\n", nsres);
540 return E_FAIL;
543 return S_OK;
546 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
548 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
549 nsIDOMHTMLCollection *nscoll = NULL;
550 nsresult nsres;
552 TRACE("(%p)->(%p)\n", This, p);
554 if(!p)
555 return E_INVALIDARG;
557 *p = NULL;
559 if(!This->doc_node->nsdoc) {
560 WARN("NULL nsdoc\n");
561 return E_UNEXPECTED;
564 nsres = nsIDOMHTMLDocument_GetScripts(This->doc_node->nsdoc, &nscoll);
565 if(NS_FAILED(nsres)) {
566 ERR("GetImages failed: %08x\n", nsres);
567 return E_FAIL;
570 if(nscoll) {
571 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
572 nsIDOMHTMLCollection_Release(nscoll);
575 return S_OK;
578 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
580 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
581 HRESULT hres;
583 static const WCHAR onW[] = {'o','n',0};
585 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
587 if(strcmpiW(v, onW)) {
588 FIXME("Unsupported arg %s\n", debugstr_w(v));
589 return E_NOTIMPL;
592 hres = setup_edit_mode(This->doc_obj);
593 if(FAILED(hres))
594 return hres;
596 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
597 return S_OK;
600 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
602 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
603 static const WCHAR szOff[] = {'O','f','f',0};
604 FIXME("(%p)->(%p) always returning Off\n", This, p);
606 if(!p)
607 return E_INVALIDARG;
609 *p = SysAllocString(szOff);
611 return S_OK;
614 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
616 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
617 nsISelection *nsselection;
618 nsresult nsres;
620 TRACE("(%p)->(%p)\n", This, p);
622 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
623 if(NS_FAILED(nsres)) {
624 ERR("GetSelection failed: %08x\n", nsres);
625 return E_FAIL;
628 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
631 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
633 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
636 TRACE("(%p)->(%p)\n", iface, p);
638 if(!p)
639 return E_POINTER;
641 return get_readystate_string(This->window->readystate, p);
644 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
646 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
648 TRACE("(%p)->(%p)\n", This, p);
650 return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p);
653 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
655 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
656 FIXME("(%p)->(%p)\n", This, p);
657 return E_NOTIMPL;
660 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
662 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
663 FIXME("(%p)->(%p)\n", This, p);
664 return E_NOTIMPL;
667 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
669 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
670 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
671 return E_NOTIMPL;
674 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
676 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
677 FIXME("(%p)->(%p)\n", This, p);
678 return E_NOTIMPL;
681 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
683 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
684 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
685 return E_NOTIMPL;
688 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
690 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
691 FIXME("(%p)->(%p)\n", This, p);
692 return E_NOTIMPL;
695 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
697 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
698 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
699 return E_NOTIMPL;
702 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
704 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
705 FIXME("(%p)->(%p)\n", This, p);
706 return E_NOTIMPL;
709 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
711 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
712 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
713 return E_NOTIMPL;
716 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
718 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
719 FIXME("(%p)->(%p)\n", This, p);
720 return E_NOTIMPL;
723 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
725 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
726 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
727 return E_NOTIMPL;
730 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
732 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
733 FIXME("(%p)->(%p)\n", This, p);
734 return E_NOTIMPL;
737 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
739 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
741 FIXME("(%p)->(%p)\n", This, p);
743 *p = NULL;
744 return S_OK;
747 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
749 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
751 TRACE("(%p)->(%p)\n", This, p);
753 if(!This->doc_node->nsdoc) {
754 WARN("NULL nsdoc\n");
755 return E_UNEXPECTED;
758 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
761 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
763 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
764 FIXME("(%p)->(%p)\n", This, p);
765 return E_NOTIMPL;
768 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
770 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
772 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
774 if(!This->window) {
775 FIXME("No window available\n");
776 return E_FAIL;
779 return navigate_url(This->window, v, This->window->uri, BINDING_NAVIGATED);
782 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
784 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
786 static const WCHAR about_blank_url[] =
787 {'a','b','o','u','t',':','b','l','a','n','k',0};
789 TRACE("(%p)->(%p)\n", iface, p);
791 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
792 return *p ? S_OK : E_OUTOFMEMORY;
795 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
797 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
798 nsAString nsstr;
799 nsresult nsres;
801 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
803 nsAString_InitDepend(&nsstr, v);
804 nsres = nsIDOMHTMLDocument_SetDomain(This->doc_node->nsdoc, &nsstr);
805 nsAString_Finish(&nsstr);
806 if(NS_FAILED(nsres)) {
807 ERR("SetDomain failed: %08x\n", nsres);
808 return E_INVALIDARG;
811 return S_OK;
814 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
816 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
817 nsAString nsstr;
818 nsresult nsres;
820 TRACE("(%p)->(%p)\n", This, p);
822 nsAString_Init(&nsstr, NULL);
823 nsres = nsIDOMHTMLDocument_GetDomain(This->doc_node->nsdoc, &nsstr);
824 if(NS_SUCCEEDED(nsres) && This->window && This->window->uri) {
825 const PRUnichar *str;
826 HRESULT hres;
828 nsAString_GetData(&nsstr, &str);
829 if(!*str) {
830 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
831 nsAString_Finish(&nsstr);
832 hres = IUri_GetHost(This->window->uri, p);
833 return FAILED(hres) ? hres : S_OK;
837 return return_nsstr(nsres, &nsstr, p);
840 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
842 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
843 BOOL bret;
845 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
847 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
848 if(!bret) {
849 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
850 return HRESULT_FROM_WIN32(GetLastError());
853 return S_OK;
856 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
858 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
859 DWORD size;
860 BOOL bret;
862 TRACE("(%p)->(%p)\n", This, p);
864 size = 0;
865 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
866 if(!bret) {
867 switch(GetLastError()) {
868 case ERROR_INSUFFICIENT_BUFFER:
869 break;
870 case ERROR_NO_MORE_ITEMS:
871 *p = NULL;
872 return S_OK;
873 default:
874 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
875 return HRESULT_FROM_WIN32(GetLastError());
879 if(!size) {
880 *p = NULL;
881 return S_OK;
884 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
885 if(!*p)
886 return E_OUTOFMEMORY;
888 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
889 if(!bret) {
890 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
891 return E_FAIL;
894 return S_OK;
897 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
899 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
900 FIXME("(%p)->(%x)\n", This, v);
901 return E_NOTIMPL;
904 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
906 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
907 FIXME("(%p)->(%p)\n", This, p);
908 return E_NOTIMPL;
911 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
913 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
914 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
915 return E_NOTIMPL;
918 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
920 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
921 nsAString charset_str;
922 nsresult nsres;
924 TRACE("(%p)->(%p)\n", This, p);
926 if(!This->doc_node->nsdoc) {
927 FIXME("NULL nsdoc\n");
928 return E_FAIL;
931 nsAString_Init(&charset_str, NULL);
932 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
933 return return_nsstr(nsres, &charset_str, p);
936 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
938 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
939 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
940 return E_NOTIMPL;
943 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
945 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
947 TRACE("(%p)->(%p)\n", This, p);
949 *p = charset_string_from_cp(GetACP());
950 return *p ? S_OK : E_OUTOFMEMORY;
953 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
955 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
956 FIXME("(%p)->(%p)\n", This, p);
957 return E_NOTIMPL;
960 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
962 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
963 FIXME("(%p)->(%p)\n", This, p);
964 return E_NOTIMPL;
967 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
969 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
970 FIXME("(%p)->(%p)\n", This, p);
971 return E_NOTIMPL;
974 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
976 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
977 FIXME("(%p)->(%p)\n", This, p);
978 return E_NOTIMPL;
981 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
983 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
984 FIXME("(%p)->(%p)\n", This, p);
985 return E_NOTIMPL;
988 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
990 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
991 FIXME("(%p)->(%p)\n", This, p);
992 return E_NOTIMPL;
995 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
997 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
998 FIXME("(%p)->(%p)\n", This, p);
999 return E_NOTIMPL;
1002 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1004 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1005 FIXME("(%p)->(%p)\n", This, p);
1006 return E_NOTIMPL;
1009 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
1011 VARIANT *var, tmp;
1012 JSContext *jsctx;
1013 nsAString nsstr;
1014 ULONG i, argc;
1015 nsresult nsres;
1016 HRESULT hres;
1018 if(!This->doc_node->nsdoc) {
1019 WARN("NULL nsdoc\n");
1020 return E_UNEXPECTED;
1023 if (!psarray)
1024 return S_OK;
1026 if(psarray->cDims != 1) {
1027 FIXME("cDims=%d\n", psarray->cDims);
1028 return E_INVALIDARG;
1031 hres = SafeArrayAccessData(psarray, (void**)&var);
1032 if(FAILED(hres)) {
1033 WARN("SafeArrayAccessData failed: %08x\n", hres);
1034 return hres;
1037 V_VT(&tmp) = VT_EMPTY;
1039 jsctx = get_context_from_document(This->doc_node->nsdoc);
1040 argc = psarray->rgsabound[0].cElements;
1041 for(i=0; i < argc; i++) {
1042 if(V_VT(var+i) == VT_BSTR) {
1043 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1044 }else {
1045 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1046 if(FAILED(hres)) {
1047 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1048 break;
1050 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1053 if(!ln || i != argc-1)
1054 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1055 else
1056 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1057 nsAString_Finish(&nsstr);
1058 if(V_VT(var+i) != VT_BSTR)
1059 VariantClear(&tmp);
1060 if(NS_FAILED(nsres)) {
1061 ERR("Write failed: %08x\n", nsres);
1062 hres = E_FAIL;
1063 break;
1067 SafeArrayUnaccessData(psarray);
1069 return hres;
1072 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1074 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1076 TRACE("(%p)->(%p)\n", iface, psarray);
1078 return document_write(This, psarray, FALSE);
1081 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1083 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1085 TRACE("(%p)->(%p)\n", This, psarray);
1087 return document_write(This, psarray, TRUE);
1090 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1091 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1093 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1094 nsISupports *tmp;
1095 nsresult nsres;
1097 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
1099 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1100 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1102 if(!This->doc_node->nsdoc) {
1103 ERR("!nsdoc\n");
1104 return E_NOTIMPL;
1107 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
1108 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1109 FIXME("unsupported args\n");
1111 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1112 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1113 if(NS_FAILED(nsres)) {
1114 ERR("Open failed: %08x\n", nsres);
1115 return E_FAIL;
1118 if(tmp)
1119 nsISupports_Release(tmp);
1121 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1122 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1123 return S_OK;
1126 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1128 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1129 nsresult nsres;
1131 TRACE("(%p)\n", This);
1133 if(!This->doc_node->nsdoc) {
1134 ERR("!nsdoc\n");
1135 return E_NOTIMPL;
1138 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1139 if(NS_FAILED(nsres)) {
1140 ERR("Close failed: %08x\n", nsres);
1141 return E_FAIL;
1144 return S_OK;
1147 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1149 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1150 nsresult nsres;
1152 TRACE("(%p)\n", This);
1154 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1155 if(NS_FAILED(nsres)) {
1156 ERR("Clear failed: %08x\n", nsres);
1157 return E_FAIL;
1160 return S_OK;
1163 static const WCHAR copyW[] =
1164 {'c','o','p','y',0};
1165 static const WCHAR cutW[] =
1166 {'c','u','t',0};
1167 static const WCHAR fontnameW[] =
1168 {'f','o','n','t','n','a','m','e',0};
1169 static const WCHAR fontsizeW[] =
1170 {'f','o','n','t','s','i','z','e',0};
1171 static const WCHAR indentW[] =
1172 {'i','n','d','e','n','t',0};
1173 static const WCHAR insertorderedlistW[] =
1174 {'i','n','s','e','r','t','o','r','d','e','r','e','d','l','i','s','t',0};
1175 static const WCHAR insertunorderedlistW[] =
1176 {'i','n','s','e','r','t','u','n','o','r','d','e','r','e','d','l','i','s','t',0};
1177 static const WCHAR outdentW[] =
1178 {'o','u','t','d','e','n','t',0};
1179 static const WCHAR pasteW[] =
1180 {'p','a','s','t','e',0};
1181 static const WCHAR respectvisibilityindesignW[] =
1182 {'r','e','s','p','e','c','t','v','i','s','i','b','i','l','i','t','y','i','n','d','e','s','i','g','n',0};
1184 static const struct {
1185 const WCHAR *name;
1186 OLECMDID id;
1187 }command_names[] = {
1188 {copyW, IDM_COPY},
1189 {cutW, IDM_CUT},
1190 {fontnameW, IDM_FONTNAME},
1191 {fontsizeW, IDM_FONTSIZE},
1192 {indentW, IDM_INDENT},
1193 {insertorderedlistW, IDM_ORDERLIST},
1194 {insertunorderedlistW, IDM_UNORDERLIST},
1195 {outdentW, IDM_OUTDENT},
1196 {pasteW, IDM_PASTE},
1197 {respectvisibilityindesignW, IDM_RESPECTVISIBILITY_INDESIGN}
1200 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1202 int i;
1204 for(i = 0; i < sizeof(command_names)/sizeof(*command_names); i++) {
1205 if(!strcmpiW(command_names[i].name, str)) {
1206 *cmdid = command_names[i].id;
1207 return TRUE;
1211 FIXME("Unknown command %s\n", debugstr_w(str));
1212 return FALSE;
1215 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1216 VARIANT_BOOL *pfRet)
1218 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1219 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1220 return E_NOTIMPL;
1223 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1224 VARIANT_BOOL *pfRet)
1226 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1227 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1228 return E_NOTIMPL;
1231 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1232 VARIANT_BOOL *pfRet)
1234 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1235 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1236 return E_NOTIMPL;
1239 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1240 VARIANT_BOOL *pfRet)
1242 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1243 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1244 return E_NOTIMPL;
1247 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1248 BSTR *pfRet)
1250 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1251 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1252 return E_NOTIMPL;
1255 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1256 VARIANT *pfRet)
1258 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1259 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1260 return E_NOTIMPL;
1263 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1264 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1266 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1267 OLECMDID cmdid;
1268 VARIANT ret;
1269 HRESULT hres;
1271 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1273 if(!cmdid_from_string(cmdID, &cmdid))
1274 return OLECMDERR_E_NOTSUPPORTED;
1276 V_VT(&ret) = VT_EMPTY;
1277 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1278 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1279 if(FAILED(hres))
1280 return hres;
1282 if(V_VT(&ret) != VT_EMPTY) {
1283 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1284 VariantClear(&ret);
1287 *pfRet = VARIANT_TRUE;
1288 return S_OK;
1291 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1292 VARIANT_BOOL *pfRet)
1294 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1295 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1296 return E_NOTIMPL;
1299 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1300 IHTMLElement **newElem)
1302 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1303 HTMLElement *elem;
1304 HRESULT hres;
1306 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1308 hres = create_element(This->doc_node, eTag, &elem);
1309 if(FAILED(hres))
1310 return hres;
1312 *newElem = &elem->IHTMLElement_iface;
1313 return S_OK;
1316 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1318 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1319 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1320 return E_NOTIMPL;
1323 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1325 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1326 FIXME("(%p)->(%p)\n", This, p);
1327 return E_NOTIMPL;
1330 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1332 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1334 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1336 return set_doc_event(This, EVENTID_CLICK, &v);
1339 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1341 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1343 TRACE("(%p)->(%p)\n", This, p);
1345 return get_doc_event(This, EVENTID_CLICK, p);
1348 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1350 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1352 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1354 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1357 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1359 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1361 TRACE("(%p)->(%p)\n", This, p);
1363 return get_doc_event(This, EVENTID_DBLCLICK, p);
1366 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1368 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1370 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1372 return set_doc_event(This, EVENTID_KEYUP, &v);
1375 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1377 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1379 TRACE("(%p)->(%p)\n", This, p);
1381 return get_doc_event(This, EVENTID_KEYUP, p);
1384 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1386 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1388 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1390 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1393 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1395 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1397 TRACE("(%p)->(%p)\n", This, p);
1399 return get_doc_event(This, EVENTID_KEYDOWN, p);
1402 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1404 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1406 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1408 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1411 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1413 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1415 TRACE("(%p)->(%p)\n", This, p);
1417 return get_doc_event(This, EVENTID_KEYPRESS, p);
1420 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1422 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1424 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1426 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1429 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1431 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1433 TRACE("(%p)->(%p)\n", This, p);
1435 return get_doc_event(This, EVENTID_MOUSEUP, p);
1438 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1440 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1442 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1444 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1447 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1449 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1451 TRACE("(%p)->(%p)\n", This, p);
1453 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1456 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1458 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1460 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1462 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1465 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1467 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1469 TRACE("(%p)->(%p)\n", This, p);
1471 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1474 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1476 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1478 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1480 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1483 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1485 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1487 TRACE("(%p)->(%p)\n", This, p);
1489 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1492 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1494 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1496 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1498 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1501 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1503 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1505 TRACE("(%p)->(%p)\n", This, p);
1507 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1510 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1512 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1514 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1516 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1519 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1521 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1523 TRACE("(%p)->(%p)\n", This, p);
1525 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1528 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1530 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1531 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1532 return E_NOTIMPL;
1535 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1537 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1538 FIXME("(%p)->(%p)\n", This, p);
1539 return E_NOTIMPL;
1542 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1544 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1545 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1546 return E_NOTIMPL;
1549 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1551 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1552 FIXME("(%p)->(%p)\n", This, p);
1553 return E_NOTIMPL;
1556 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1558 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1559 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1560 return E_NOTIMPL;
1563 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1565 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1566 FIXME("(%p)->(%p)\n", This, p);
1567 return E_NOTIMPL;
1570 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1572 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1574 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1576 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1579 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1581 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1583 TRACE("(%p)->(%p)\n", This, p);
1585 return get_doc_event(This, EVENTID_DRAGSTART, p);
1588 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1590 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1592 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1594 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1597 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1599 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1601 TRACE("(%p)->(%p)\n", This, p);
1603 return get_doc_event(This, EVENTID_SELECTSTART, p);
1606 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1607 IHTMLElement **elementHit)
1609 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1610 nsIDOMElement *nselem;
1611 HTMLDOMNode *node;
1612 nsresult nsres;
1613 HRESULT hres;
1615 TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1617 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1618 if(NS_FAILED(nsres)) {
1619 ERR("ElementFromPoint failed: %08x\n", nsres);
1620 return E_FAIL;
1623 if(!nselem) {
1624 *elementHit = NULL;
1625 return S_OK;
1628 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
1629 nsIDOMElement_Release(nselem);
1630 if(FAILED(hres))
1631 return hres;
1633 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)elementHit);
1634 node_release(node);
1635 return hres;
1638 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1640 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1642 TRACE("(%p)->(%p)\n", This, p);
1644 *p = &This->window->base.IHTMLWindow2_iface;
1645 IHTMLWindow2_AddRef(*p);
1646 return S_OK;
1649 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1650 IHTMLStyleSheetsCollection **p)
1652 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1653 nsIDOMStyleSheetList *nsstylelist;
1654 nsresult nsres;
1656 TRACE("(%p)->(%p)\n", This, p);
1658 *p = NULL;
1660 if(!This->doc_node->nsdoc) {
1661 WARN("NULL nsdoc\n");
1662 return E_UNEXPECTED;
1665 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1666 if(NS_FAILED(nsres)) {
1667 ERR("GetStyleSheets failed: %08x\n", nsres);
1668 return E_FAIL;
1671 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1672 nsIDOMStyleSheetList_Release(nsstylelist);
1674 return S_OK;
1677 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1679 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1680 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1681 return E_NOTIMPL;
1684 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1686 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1687 FIXME("(%p)->(%p)\n", This, p);
1688 return E_NOTIMPL;
1691 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1693 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1694 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1695 return E_NOTIMPL;
1698 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1700 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1701 FIXME("(%p)->(%p)\n", This, p);
1702 return E_NOTIMPL;
1705 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1707 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1709 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1711 TRACE("(%p)->(%p)\n", This, String);
1713 if(!String)
1714 return E_INVALIDARG;
1716 *String = SysAllocString(objectW);
1717 return *String ? S_OK : E_OUTOFMEMORY;
1721 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1722 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1724 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1725 nsIDOMHTMLHeadElement *head_elem;
1726 IHTMLStyleElement *style_elem;
1727 HTMLElement *elem;
1728 nsresult nsres;
1729 HRESULT hres;
1731 static const WCHAR styleW[] = {'s','t','y','l','e',0};
1733 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1735 if(!This->doc_node->nsdoc) {
1736 FIXME("not a real doc object\n");
1737 return E_NOTIMPL;
1740 if(lIndex != -1)
1741 FIXME("Unsupported lIndex %d\n", lIndex);
1743 if(bstrHref && *bstrHref) {
1744 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
1745 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1746 return S_OK;
1749 hres = create_element(This->doc_node, styleW, &elem);
1750 if(FAILED(hres))
1751 return hres;
1753 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
1754 if(NS_SUCCEEDED(nsres)) {
1755 nsIDOMNode *head_node, *tmp_node;
1757 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
1758 nsIDOMHTMLHeadElement_Release(head_elem);
1759 assert(nsres == NS_OK);
1761 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
1762 nsIDOMNode_Release(head_node);
1763 if(NS_SUCCEEDED(nsres) && tmp_node)
1764 nsIDOMNode_Release(tmp_node);
1766 if(NS_FAILED(nsres)) {
1767 IHTMLElement_Release(&elem->IHTMLElement_iface);
1768 return E_FAIL;
1771 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
1772 assert(hres == S_OK);
1773 IHTMLElement_Release(&elem->IHTMLElement_iface);
1775 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
1776 IHTMLStyleElement_Release(style_elem);
1777 return hres;
1780 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1781 HTMLDocument_QueryInterface,
1782 HTMLDocument_AddRef,
1783 HTMLDocument_Release,
1784 HTMLDocument_GetTypeInfoCount,
1785 HTMLDocument_GetTypeInfo,
1786 HTMLDocument_GetIDsOfNames,
1787 HTMLDocument_Invoke,
1788 HTMLDocument_get_Script,
1789 HTMLDocument_get_all,
1790 HTMLDocument_get_body,
1791 HTMLDocument_get_activeElement,
1792 HTMLDocument_get_images,
1793 HTMLDocument_get_applets,
1794 HTMLDocument_get_links,
1795 HTMLDocument_get_forms,
1796 HTMLDocument_get_anchors,
1797 HTMLDocument_put_title,
1798 HTMLDocument_get_title,
1799 HTMLDocument_get_scripts,
1800 HTMLDocument_put_designMode,
1801 HTMLDocument_get_designMode,
1802 HTMLDocument_get_selection,
1803 HTMLDocument_get_readyState,
1804 HTMLDocument_get_frames,
1805 HTMLDocument_get_embeds,
1806 HTMLDocument_get_plugins,
1807 HTMLDocument_put_alinkColor,
1808 HTMLDocument_get_alinkColor,
1809 HTMLDocument_put_bgColor,
1810 HTMLDocument_get_bgColor,
1811 HTMLDocument_put_fgColor,
1812 HTMLDocument_get_fgColor,
1813 HTMLDocument_put_linkColor,
1814 HTMLDocument_get_linkColor,
1815 HTMLDocument_put_vlinkColor,
1816 HTMLDocument_get_vlinkColor,
1817 HTMLDocument_get_referrer,
1818 HTMLDocument_get_location,
1819 HTMLDocument_get_lastModified,
1820 HTMLDocument_put_URL,
1821 HTMLDocument_get_URL,
1822 HTMLDocument_put_domain,
1823 HTMLDocument_get_domain,
1824 HTMLDocument_put_cookie,
1825 HTMLDocument_get_cookie,
1826 HTMLDocument_put_expando,
1827 HTMLDocument_get_expando,
1828 HTMLDocument_put_charset,
1829 HTMLDocument_get_charset,
1830 HTMLDocument_put_defaultCharset,
1831 HTMLDocument_get_defaultCharset,
1832 HTMLDocument_get_mimeType,
1833 HTMLDocument_get_fileSize,
1834 HTMLDocument_get_fileCreatedDate,
1835 HTMLDocument_get_fileModifiedDate,
1836 HTMLDocument_get_fileUpdatedDate,
1837 HTMLDocument_get_security,
1838 HTMLDocument_get_protocol,
1839 HTMLDocument_get_nameProp,
1840 HTMLDocument_write,
1841 HTMLDocument_writeln,
1842 HTMLDocument_open,
1843 HTMLDocument_close,
1844 HTMLDocument_clear,
1845 HTMLDocument_queryCommandSupported,
1846 HTMLDocument_queryCommandEnabled,
1847 HTMLDocument_queryCommandState,
1848 HTMLDocument_queryCommandIndeterm,
1849 HTMLDocument_queryCommandText,
1850 HTMLDocument_queryCommandValue,
1851 HTMLDocument_execCommand,
1852 HTMLDocument_execCommandShowHelp,
1853 HTMLDocument_createElement,
1854 HTMLDocument_put_onhelp,
1855 HTMLDocument_get_onhelp,
1856 HTMLDocument_put_onclick,
1857 HTMLDocument_get_onclick,
1858 HTMLDocument_put_ondblclick,
1859 HTMLDocument_get_ondblclick,
1860 HTMLDocument_put_onkeyup,
1861 HTMLDocument_get_onkeyup,
1862 HTMLDocument_put_onkeydown,
1863 HTMLDocument_get_onkeydown,
1864 HTMLDocument_put_onkeypress,
1865 HTMLDocument_get_onkeypress,
1866 HTMLDocument_put_onmouseup,
1867 HTMLDocument_get_onmouseup,
1868 HTMLDocument_put_onmousedown,
1869 HTMLDocument_get_onmousedown,
1870 HTMLDocument_put_onmousemove,
1871 HTMLDocument_get_onmousemove,
1872 HTMLDocument_put_onmouseout,
1873 HTMLDocument_get_onmouseout,
1874 HTMLDocument_put_onmouseover,
1875 HTMLDocument_get_onmouseover,
1876 HTMLDocument_put_onreadystatechange,
1877 HTMLDocument_get_onreadystatechange,
1878 HTMLDocument_put_onafterupdate,
1879 HTMLDocument_get_onafterupdate,
1880 HTMLDocument_put_onrowexit,
1881 HTMLDocument_get_onrowexit,
1882 HTMLDocument_put_onrowenter,
1883 HTMLDocument_get_onrowenter,
1884 HTMLDocument_put_ondragstart,
1885 HTMLDocument_get_ondragstart,
1886 HTMLDocument_put_onselectstart,
1887 HTMLDocument_get_onselectstart,
1888 HTMLDocument_elementFromPoint,
1889 HTMLDocument_get_parentWindow,
1890 HTMLDocument_get_styleSheets,
1891 HTMLDocument_put_onbeforeupdate,
1892 HTMLDocument_get_onbeforeupdate,
1893 HTMLDocument_put_onerrorupdate,
1894 HTMLDocument_get_onerrorupdate,
1895 HTMLDocument_toString,
1896 HTMLDocument_createStyleSheet
1899 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
1901 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
1904 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
1905 REFIID riid, void **ppv)
1907 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1908 return htmldoc_query_interface(This, riid, ppv);
1911 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
1913 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1914 return htmldoc_addref(This);
1917 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
1919 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1920 return htmldoc_release(This);
1923 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
1925 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1926 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1929 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
1930 LCID lcid, ITypeInfo **ppTInfo)
1932 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1933 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1936 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
1937 LPOLESTR *rgszNames, UINT cNames,
1938 LCID lcid, DISPID *rgDispId)
1940 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1941 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1942 rgDispId);
1945 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
1946 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1947 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1949 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1950 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1951 pDispParams, pVarResult, pExcepInfo, puArgErr);
1954 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
1956 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1957 FIXME("(%p)\n", This);
1958 return E_NOTIMPL;
1961 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
1963 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1965 WARN("(%p)->(%x)\n", This, fForce);
1967 /* Doing nothing here should be fine for us. */
1968 return S_OK;
1971 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
1972 IHTMLDOMNode **newTextNode)
1974 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1975 nsIDOMText *nstext;
1976 HTMLDOMNode *node;
1977 nsAString text_str;
1978 nsresult nsres;
1979 HRESULT hres;
1981 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
1983 if(!This->doc_node->nsdoc) {
1984 WARN("NULL nsdoc\n");
1985 return E_UNEXPECTED;
1988 nsAString_InitDepend(&text_str, text);
1989 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
1990 nsAString_Finish(&text_str);
1991 if(NS_FAILED(nsres)) {
1992 ERR("CreateTextNode failed: %08x\n", nsres);
1993 return E_FAIL;
1996 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
1997 nsIDOMText_Release(nstext);
1998 if(FAILED(hres))
1999 return hres;
2001 *newTextNode = &node->IHTMLDOMNode_iface;
2002 return S_OK;
2005 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
2007 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2008 nsIDOMElement *nselem = NULL;
2009 HTMLDOMNode *node;
2010 nsresult nsres;
2011 HRESULT hres;
2013 TRACE("(%p)->(%p)\n", This, p);
2015 if(This->window->readystate == READYSTATE_UNINITIALIZED) {
2016 *p = NULL;
2017 return S_OK;
2020 if(!This->doc_node->nsdoc) {
2021 WARN("NULL nsdoc\n");
2022 return E_UNEXPECTED;
2025 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
2026 if(NS_FAILED(nsres)) {
2027 ERR("GetDocumentElement failed: %08x\n", nsres);
2028 return E_FAIL;
2031 if(!nselem) {
2032 *p = NULL;
2033 return S_OK;
2036 hres = get_node(This->doc_node, (nsIDOMNode *)nselem, TRUE, &node);
2037 nsIDOMElement_Release(nselem);
2038 if(FAILED(hres))
2039 return hres;
2041 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
2042 node_release(node);
2043 return hres;
2046 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2048 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2050 TRACE("(%p)->(%p)\n", This, p);
2052 return elem_unique_id(++This->doc_node->unique_id, p);
2055 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2056 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2058 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2060 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2062 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2065 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2066 IDispatch *pDisp)
2068 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2070 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2072 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2075 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2077 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2078 FIXME("(%p)->()\n", This);
2079 return E_NOTIMPL;
2082 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2084 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2085 FIXME("(%p)->(%p)\n", This, p);
2086 return E_NOTIMPL;
2089 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2091 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2092 FIXME("(%p)->()\n", This);
2093 return E_NOTIMPL;
2096 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2098 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2099 FIXME("(%p)->(%p)\n", This, p);
2100 return E_NOTIMPL;
2103 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2105 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2106 FIXME("(%p)->()\n", This);
2107 return E_NOTIMPL;
2110 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2112 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2113 FIXME("(%p)->(%p)\n", This, p);
2114 return E_NOTIMPL;
2117 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2119 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2120 FIXME("(%p)->()\n", This);
2121 return E_NOTIMPL;
2124 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2126 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2127 FIXME("(%p)->(%p)\n", This, p);
2128 return E_NOTIMPL;
2131 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2133 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2134 FIXME("(%p)->()\n", This);
2135 return E_NOTIMPL;
2138 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2140 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2141 FIXME("(%p)->(%p)\n", This, p);
2142 return E_NOTIMPL;
2145 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2147 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2148 FIXME("(%p)->()\n", This);
2149 return E_NOTIMPL;
2152 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2154 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2155 FIXME("(%p)->(%p)\n", This, p);
2156 return E_NOTIMPL;
2159 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2161 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2162 FIXME("(%p)->()\n", This);
2163 return E_NOTIMPL;
2166 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2168 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2169 FIXME("(%p)->(%p)\n", This, p);
2170 return E_NOTIMPL;
2173 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2175 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2176 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2177 return E_NOTIMPL;
2180 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2182 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2183 FIXME("(%p)->(%p)\n", This, p);
2184 return E_NOTIMPL;
2187 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2189 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2191 TRACE("(%p)->()\n", This);
2193 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2196 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2198 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2200 TRACE("(%p)->(%p)\n", This, p);
2202 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2205 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2207 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2208 FIXME("(%p)->()\n", This);
2209 return E_NOTIMPL;
2212 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2214 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2215 FIXME("(%p)->(%p)\n", This, p);
2216 return E_NOTIMPL;
2219 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2220 IHTMLDocument2 **ppNewDoc)
2222 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2223 nsIDOMDocumentFragment *doc_frag;
2224 HTMLDocumentNode *docnode;
2225 nsresult nsres;
2226 HRESULT hres;
2228 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2230 if(!This->doc_node->nsdoc) {
2231 FIXME("NULL nsdoc\n");
2232 return E_NOTIMPL;
2235 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2236 if(NS_FAILED(nsres)) {
2237 ERR("CreateDocumentFragment failed: %08x\n", nsres);
2238 return E_FAIL;
2241 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2242 nsIDOMDocumentFragment_Release(doc_frag);
2243 if(FAILED(hres))
2244 return hres;
2246 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2247 return S_OK;
2250 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2251 IHTMLDocument2 **p)
2253 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2254 FIXME("(%p)->(%p)\n", This, p);
2255 return E_NOTIMPL;
2258 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2259 VARIANT_BOOL v)
2261 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2262 FIXME("(%p)->(%x)\n", This, v);
2263 return E_NOTIMPL;
2266 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2267 VARIANT_BOOL *p)
2269 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2270 FIXME("(%p)->(%p)\n", This, p);
2271 return E_NOTIMPL;
2274 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2276 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2277 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2278 return E_NOTIMPL;
2281 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2283 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2284 FIXME("(%p)->(%p)\n", This, p);
2285 return E_NOTIMPL;
2288 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2290 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2292 TRACE("(%p)->(%p)\n", This, p);
2294 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2297 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2298 VARIANT_BOOL v)
2300 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2301 FIXME("(%p)->()\n", This);
2302 return E_NOTIMPL;
2305 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2306 VARIANT_BOOL *p)
2308 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2309 FIXME("(%p)->(%p)\n", This, p);
2310 return E_NOTIMPL;
2313 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2315 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2316 FIXME("(%p)->()\n", This);
2317 return E_NOTIMPL;
2320 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2322 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2323 FIXME("(%p)->(%p)\n", This, p);
2324 return E_NOTIMPL;
2327 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2328 IHTMLElementCollection **ppelColl)
2330 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2331 nsIDOMNodeList *node_list;
2332 nsAString selector_str;
2333 WCHAR *selector;
2334 nsresult nsres;
2336 static const WCHAR formatW[] = {'*','[','i','d','=','%','s',']',',','*','[','n','a','m','e','=','%','s',']',0};
2338 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2340 if(!This->doc_node || !This->doc_node->nsdoc) {
2341 /* We should probably return an empty collection. */
2342 FIXME("No nsdoc\n");
2343 return E_NOTIMPL;
2346 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2347 if(!selector)
2348 return E_OUTOFMEMORY;
2349 sprintfW(selector, formatW, v, v);
2352 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2353 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2354 * types and search should be case insensitive. Those are currently not supported properly.
2356 nsAString_InitDepend(&selector_str, selector);
2357 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2358 nsAString_Finish(&selector_str);
2359 heap_free(selector);
2360 if(NS_FAILED(nsres)) {
2361 ERR("QuerySelectorAll failed: %08x\n", nsres);
2362 return E_FAIL;
2365 *ppelColl = create_collection_from_nodelist(This->doc_node, node_list);
2366 nsIDOMNodeList_Release(node_list);
2367 return S_OK;
2371 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2372 IHTMLElement **pel)
2374 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2375 HTMLElement *elem;
2376 HRESULT hres;
2378 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2380 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2381 if(FAILED(hres) || !elem) {
2382 *pel = NULL;
2383 return hres;
2386 *pel = &elem->IHTMLElement_iface;
2387 return S_OK;
2391 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2392 IHTMLElementCollection **pelColl)
2394 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2395 nsIDOMNodeList *nslist;
2396 nsAString id_str;
2397 nsresult nsres;
2399 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2401 if(This->doc_node->nsdoc) {
2402 nsAString_InitDepend(&id_str, v);
2403 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2404 nsAString_Finish(&id_str);
2405 if(FAILED(nsres)) {
2406 ERR("GetElementByName failed: %08x\n", nsres);
2407 return E_FAIL;
2409 }else {
2410 nsIDOMDocumentFragment *docfrag;
2411 nsAString nsstr;
2413 if(v) {
2414 const WCHAR *ptr;
2415 for(ptr=v; *ptr; ptr++) {
2416 if(!isalnumW(*ptr)) {
2417 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2418 return E_NOTIMPL;
2423 nsres = nsIDOMNode_QueryInterface(This->doc_node->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2424 if(NS_FAILED(nsres)) {
2425 ERR("Could not get nsIDOMDocumentFragment iface: %08x\n", nsres);
2426 return E_UNEXPECTED;
2429 nsAString_InitDepend(&nsstr, v);
2430 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2431 nsAString_Finish(&nsstr);
2432 nsIDOMDocumentFragment_Release(docfrag);
2433 if(NS_FAILED(nsres)) {
2434 ERR("QuerySelectorAll failed: %08x\n", nsres);
2435 return E_FAIL;
2440 *pelColl = create_collection_from_nodelist(This->doc_node, nslist);
2441 nsIDOMNodeList_Release(nslist);
2443 return S_OK;
2446 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2447 HTMLDocument3_QueryInterface,
2448 HTMLDocument3_AddRef,
2449 HTMLDocument3_Release,
2450 HTMLDocument3_GetTypeInfoCount,
2451 HTMLDocument3_GetTypeInfo,
2452 HTMLDocument3_GetIDsOfNames,
2453 HTMLDocument3_Invoke,
2454 HTMLDocument3_releaseCapture,
2455 HTMLDocument3_recalc,
2456 HTMLDocument3_createTextNode,
2457 HTMLDocument3_get_documentElement,
2458 HTMLDocument3_get_uniqueID,
2459 HTMLDocument3_attachEvent,
2460 HTMLDocument3_detachEvent,
2461 HTMLDocument3_put_onrowsdelete,
2462 HTMLDocument3_get_onrowsdelete,
2463 HTMLDocument3_put_onrowsinserted,
2464 HTMLDocument3_get_onrowsinserted,
2465 HTMLDocument3_put_oncellchange,
2466 HTMLDocument3_get_oncellchange,
2467 HTMLDocument3_put_ondatasetchanged,
2468 HTMLDocument3_get_ondatasetchanged,
2469 HTMLDocument3_put_ondataavailable,
2470 HTMLDocument3_get_ondataavailable,
2471 HTMLDocument3_put_ondatasetcomplete,
2472 HTMLDocument3_get_ondatasetcomplete,
2473 HTMLDocument3_put_onpropertychange,
2474 HTMLDocument3_get_onpropertychange,
2475 HTMLDocument3_put_dir,
2476 HTMLDocument3_get_dir,
2477 HTMLDocument3_put_oncontextmenu,
2478 HTMLDocument3_get_oncontextmenu,
2479 HTMLDocument3_put_onstop,
2480 HTMLDocument3_get_onstop,
2481 HTMLDocument3_createDocumentFragment,
2482 HTMLDocument3_get_parentDocument,
2483 HTMLDocument3_put_enableDownload,
2484 HTMLDocument3_get_enableDownload,
2485 HTMLDocument3_put_baseUrl,
2486 HTMLDocument3_get_baseUrl,
2487 HTMLDocument3_get_childNodes,
2488 HTMLDocument3_put_inheritStyleSheets,
2489 HTMLDocument3_get_inheritStyleSheets,
2490 HTMLDocument3_put_onbeforeeditfocus,
2491 HTMLDocument3_get_onbeforeeditfocus,
2492 HTMLDocument3_getElementsByName,
2493 HTMLDocument3_getElementById,
2494 HTMLDocument3_getElementsByTagName
2497 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2499 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2502 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2503 REFIID riid, void **ppv)
2505 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2506 return htmldoc_query_interface(This, riid, ppv);
2509 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2511 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2512 return htmldoc_addref(This);
2515 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2517 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2518 return htmldoc_release(This);
2521 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2523 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2524 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2527 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2528 LCID lcid, ITypeInfo **ppTInfo)
2530 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2531 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2534 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2535 LPOLESTR *rgszNames, UINT cNames,
2536 LCID lcid, DISPID *rgDispId)
2538 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2539 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2540 rgDispId);
2543 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2544 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2545 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2547 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2548 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2549 pDispParams, pVarResult, pExcepInfo, puArgErr);
2552 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2554 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2555 nsIDOMHTMLElement *nsbody;
2556 nsresult nsres;
2558 TRACE("(%p)->()\n", This);
2560 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2561 if(NS_FAILED(nsres) || !nsbody) {
2562 ERR("GetBody failed: %08x\n", nsres);
2563 return E_FAIL;
2566 nsres = nsIDOMHTMLElement_Focus(nsbody);
2567 nsIDOMHTMLElement_Release(nsbody);
2568 if(NS_FAILED(nsres)) {
2569 ERR("Focus failed: %08x\n", nsres);
2570 return E_FAIL;
2573 return S_OK;
2576 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2578 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2579 cpp_bool has_focus;
2580 nsresult nsres;
2582 TRACE("(%p)->(%p)\n", This, pfFocus);
2584 if(!This->doc_node->nsdoc) {
2585 FIXME("Unimplemented for fragments.\n");
2586 return E_NOTIMPL;
2589 nsres = nsIDOMHTMLDocument_HasFocus(This->doc_node->nsdoc, &has_focus);
2590 assert(nsres == NS_OK);
2592 *pfFocus = has_focus ? VARIANT_TRUE : VARIANT_FALSE;
2593 return S_OK;
2596 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2598 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2599 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2600 return E_NOTIMPL;
2603 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2605 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2606 FIXME("(%p)->(%p)\n", This, p);
2607 return E_NOTIMPL;
2610 static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
2612 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2613 FIXME("(%p)->(%p)\n", This, p);
2614 return E_NOTIMPL;
2617 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2618 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2620 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2621 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2622 return E_NOTIMPL;
2625 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2627 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2628 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2629 return E_NOTIMPL;
2632 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2634 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2635 FIXME("(%p)->(%p)\n", This, p);
2636 return E_NOTIMPL;
2639 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2640 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2642 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2644 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2646 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2647 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2648 return E_NOTIMPL;
2651 return create_event_obj(ppEventObj);
2654 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2655 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2657 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2659 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2661 return dispatch_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2664 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2665 IHTMLRenderStyle **ppIHTMLRenderStyle)
2667 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2668 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2669 return E_NOTIMPL;
2672 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2674 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2675 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2676 return E_NOTIMPL;
2679 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2681 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2682 FIXME("(%p)->(%p)\n", This, p);
2683 return E_NOTIMPL;
2686 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2688 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2689 FIXME("(%p)->(%p)\n", This, p);
2690 return E_NOTIMPL;
2693 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2694 HTMLDocument4_QueryInterface,
2695 HTMLDocument4_AddRef,
2696 HTMLDocument4_Release,
2697 HTMLDocument4_GetTypeInfoCount,
2698 HTMLDocument4_GetTypeInfo,
2699 HTMLDocument4_GetIDsOfNames,
2700 HTMLDocument4_Invoke,
2701 HTMLDocument4_focus,
2702 HTMLDocument4_hasFocus,
2703 HTMLDocument4_put_onselectionchange,
2704 HTMLDocument4_get_onselectionchange,
2705 HTMLDocument4_get_namespace,
2706 HTMLDocument4_createDocumentFromUrl,
2707 HTMLDocument4_put_media,
2708 HTMLDocument4_get_media,
2709 HTMLDocument4_createEventObject,
2710 HTMLDocument4_fireEvent,
2711 HTMLDocument4_createRenderStyle,
2712 HTMLDocument4_put_oncontrolselect,
2713 HTMLDocument4_get_oncontrolselect,
2714 HTMLDocument4_get_URLEncoded
2717 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2719 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2722 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2723 REFIID riid, void **ppv)
2725 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2726 return htmldoc_query_interface(This, riid, ppv);
2729 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2731 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2732 return htmldoc_addref(This);
2735 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2737 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2738 return htmldoc_release(This);
2741 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2743 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2744 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2747 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2748 LCID lcid, ITypeInfo **ppTInfo)
2750 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2751 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2754 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2755 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2757 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2758 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2759 rgDispId);
2762 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2763 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2764 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2766 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2767 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2768 pDispParams, pVarResult, pExcepInfo, puArgErr);
2771 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2773 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2774 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2775 return E_NOTIMPL;
2778 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2780 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2781 FIXME("(%p)->(%p)\n", This, p);
2782 return E_NOTIMPL;
2785 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2787 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2788 FIXME("(%p)->(%p)\n", This, p);
2789 return E_NOTIMPL;
2792 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2794 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2795 HTMLDocumentNode *doc_node = This->doc_node;
2797 TRACE("(%p)->(%p)\n", This, p);
2799 if(!doc_node->dom_implementation) {
2800 HRESULT hres;
2802 hres = create_dom_implementation(&doc_node->dom_implementation);
2803 if(FAILED(hres))
2804 return hres;
2807 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2808 *p = doc_node->dom_implementation;
2809 return S_OK;
2812 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2813 IHTMLDOMAttribute **ppattribute)
2815 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2816 HTMLDOMAttribute *attr;
2817 HRESULT hres;
2819 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2821 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
2822 if(FAILED(hres))
2823 return hres;
2825 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2826 return S_OK;
2829 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2830 IHTMLDOMNode **ppRetNode)
2832 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2833 nsIDOMComment *nscomment;
2834 HTMLElement *elem;
2835 nsAString str;
2836 nsresult nsres;
2837 HRESULT hres;
2839 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2841 if(!This->doc_node->nsdoc) {
2842 WARN("NULL nsdoc\n");
2843 return E_UNEXPECTED;
2846 nsAString_InitDepend(&str, bstrdata);
2847 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2848 nsAString_Finish(&str);
2849 if(NS_FAILED(nsres)) {
2850 ERR("CreateTextNode failed: %08x\n", nsres);
2851 return E_FAIL;
2854 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2855 nsIDOMComment_Release(nscomment);
2856 if(FAILED(hres))
2857 return hres;
2859 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2860 return S_OK;
2863 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2865 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2866 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2867 return E_NOTIMPL;
2870 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2872 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2873 FIXME("(%p)->(%p)\n", This, p);
2874 return E_NOTIMPL;
2877 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2879 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2880 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2881 return E_NOTIMPL;
2884 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2886 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2887 FIXME("(%p)->(%p)\n", This, p);
2888 return E_NOTIMPL;
2891 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2893 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2894 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2895 return E_NOTIMPL;
2898 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2900 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2901 FIXME("(%p)->(%p)\n", This, p);
2902 return E_NOTIMPL;
2905 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2907 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2908 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2909 return E_NOTIMPL;
2912 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2914 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2915 FIXME("(%p)->(%p)\n", This, p);
2916 return E_NOTIMPL;
2919 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2921 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2922 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2923 return E_NOTIMPL;
2926 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2928 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2929 FIXME("(%p)->(%p)\n", This, p);
2930 return E_NOTIMPL;
2933 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2935 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2936 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2937 return E_NOTIMPL;
2940 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2942 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2943 FIXME("(%p)->(%p)\n", This, p);
2944 return E_NOTIMPL;
2947 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2949 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2951 static const WCHAR BackCompatW[] = {'B','a','c','k','C','o','m','p','a','t',0};
2952 static const WCHAR CSS1CompatW[] = {'C','S','S','1','C','o','m','p','a','t',0};
2954 TRACE("(%p)->(%p)\n", This, p);
2956 *p = SysAllocString(This->doc_node->document_mode == COMPAT_MODE_QUIRKS ? BackCompatW : CSS1CompatW);
2957 return *p ? S_OK : E_OUTOFMEMORY;
2960 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
2961 HTMLDocument5_QueryInterface,
2962 HTMLDocument5_AddRef,
2963 HTMLDocument5_Release,
2964 HTMLDocument5_GetTypeInfoCount,
2965 HTMLDocument5_GetTypeInfo,
2966 HTMLDocument5_GetIDsOfNames,
2967 HTMLDocument5_Invoke,
2968 HTMLDocument5_put_onmousewheel,
2969 HTMLDocument5_get_onmousewheel,
2970 HTMLDocument5_get_doctype,
2971 HTMLDocument5_get_implementation,
2972 HTMLDocument5_createAttribute,
2973 HTMLDocument5_createComment,
2974 HTMLDocument5_put_onfocusin,
2975 HTMLDocument5_get_onfocusin,
2976 HTMLDocument5_put_onfocusout,
2977 HTMLDocument5_get_onfocusout,
2978 HTMLDocument5_put_onactivate,
2979 HTMLDocument5_get_onactivate,
2980 HTMLDocument5_put_ondeactivate,
2981 HTMLDocument5_get_ondeactivate,
2982 HTMLDocument5_put_onbeforeactivate,
2983 HTMLDocument5_get_onbeforeactivate,
2984 HTMLDocument5_put_onbeforedeactivate,
2985 HTMLDocument5_get_onbeforedeactivate,
2986 HTMLDocument5_get_compatMode
2989 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
2991 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
2994 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
2995 REFIID riid, void **ppv)
2997 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2998 return htmldoc_query_interface(This, riid, ppv);
3001 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3003 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3004 return htmldoc_addref(This);
3007 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3009 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3010 return htmldoc_release(This);
3013 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3015 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3016 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3019 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
3020 LCID lcid, ITypeInfo **ppTInfo)
3022 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3023 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3026 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
3027 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3029 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3030 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3031 rgDispId);
3034 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
3035 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3036 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3038 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3039 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3040 pDispParams, pVarResult, pExcepInfo, puArgErr);
3043 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3044 IHTMLDocumentCompatibleInfoCollection **p)
3046 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3047 FIXME("(%p)->(%p)\n", This, p);
3048 return E_NOTIMPL;
3051 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3053 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3055 static const int docmode_values[] = {
3056 5, /* DOCMODE_QUIRKS */
3057 7, /* DOCMODE_IE7 */
3058 8, /* DOCMODE_IE8 */
3059 9, /* DOCMODE_IE8 */
3060 10, /* DOCMODE_IE10 */
3061 11 /* DOCMODE_IE11 */
3064 TRACE("(%p)->(%p)\n", This, p);
3066 if(!This->doc_node) {
3067 FIXME("NULL doc_node\n");
3068 return E_UNEXPECTED;
3071 assert(This->doc_node->document_mode < sizeof(docmode_values)/sizeof(*docmode_values));
3073 V_VT(p) = VT_I4;
3074 V_I4(p) = docmode_values[This->doc_node->document_mode];
3075 return S_OK;
3078 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3079 VARIANT *p)
3081 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3082 FIXME("(%p)->(%p)\n", This, p);
3083 return E_NOTIMPL;
3086 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3088 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3089 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3090 return E_NOTIMPL;
3093 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3094 VARIANT *p)
3096 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3097 FIXME("(%p)->(%p)\n", This, p);
3098 return E_NOTIMPL;
3101 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3103 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3104 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3105 return E_NOTIMPL;
3108 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3109 BSTR bstrId, IHTMLElement2 **p)
3111 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3112 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3113 return E_NOTIMPL;
3116 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3118 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3119 FIXME("(%p)->()\n", This);
3120 return E_NOTIMPL;
3123 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3124 HTMLDocument6_QueryInterface,
3125 HTMLDocument6_AddRef,
3126 HTMLDocument6_Release,
3127 HTMLDocument6_GetTypeInfoCount,
3128 HTMLDocument6_GetTypeInfo,
3129 HTMLDocument6_GetIDsOfNames,
3130 HTMLDocument6_Invoke,
3131 HTMLDocument6_get_compatible,
3132 HTMLDocument6_get_documentMode,
3133 HTMLDocument6_put_onstorage,
3134 HTMLDocument6_get_onstorage,
3135 HTMLDocument6_put_onstoragecommit,
3136 HTMLDocument6_get_onstoragecommit,
3137 HTMLDocument6_getElementById,
3138 HTMLDocument6_updateSettings
3141 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3143 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3146 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3148 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3149 return htmldoc_query_interface(This, riid, ppv);
3152 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3154 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3155 return htmldoc_addref(This);
3158 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3160 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3161 return htmldoc_release(This);
3164 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3166 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3167 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3170 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3171 LCID lcid, ITypeInfo **ppTInfo)
3173 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3174 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3177 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3178 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3180 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3181 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3182 rgDispId);
3185 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3186 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3187 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3189 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3190 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3191 pDispParams, pVarResult, pExcepInfo, puArgErr);
3194 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3196 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3197 FIXME("(%p)->(%p)\n", This, p);
3198 return E_NOTIMPL;
3201 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3203 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3204 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3205 return E_NOTIMPL;
3208 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3210 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3211 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3212 return E_NOTIMPL;
3215 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3216 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3218 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3219 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3220 return E_NOTIMPL;
3223 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3225 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3226 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3227 return E_NOTIMPL;
3230 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3231 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3233 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3234 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3235 return E_NOTIMPL;
3238 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3240 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3241 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3242 return E_NOTIMPL;
3245 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3247 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3248 FIXME("(%p)->(%p)\n", This, p);
3249 return E_NOTIMPL;
3252 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3254 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3255 FIXME("(%p)->(%p)\n", This, p);
3256 return E_NOTIMPL;
3259 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3261 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3262 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3263 return E_NOTIMPL;
3266 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3268 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3269 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3270 return E_NOTIMPL;
3273 static HRESULT WINAPI HTMLDocument7_getElementByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3275 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3276 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3277 return E_NOTIMPL;
3280 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3281 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3283 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3284 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3285 return E_NOTIMPL;
3288 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3290 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3291 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3292 return E_NOTIMPL;
3295 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3297 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3298 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3299 return E_NOTIMPL;
3302 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3304 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3305 FIXME("(%p)->(%p)\n", This, p);
3306 return E_NOTIMPL;
3309 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3311 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3312 FIXME("(%p)->(%p)\n", This, p);
3313 return E_NOTIMPL;
3316 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3318 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3319 FIXME("(%p)->(%p)\n", This, p);
3320 return E_NOTIMPL;
3323 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3325 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3326 FIXME("(%p)->(%p)\n", This, p);
3327 return E_NOTIMPL;
3330 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3332 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3333 FIXME("(%p)->(%x)\n", This, v);
3334 return E_NOTIMPL;
3337 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3339 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3340 FIXME("(%p)->(%p)\n", This, p);
3341 return E_NOTIMPL;
3344 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3346 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3347 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3348 return E_NOTIMPL;
3351 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3353 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3354 FIXME("(%p)->(%p)\n", This, p);
3355 return E_NOTIMPL;
3358 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3360 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3361 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3362 return E_NOTIMPL;
3365 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3367 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3368 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3369 return E_NOTIMPL;
3372 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3374 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3375 FIXME("(%p)->(%p)\n", This, p);
3376 return E_NOTIMPL;
3379 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3381 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3382 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3383 return E_NOTIMPL;
3386 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3388 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3389 FIXME("(%p)->(%p)\n", This, p);
3390 return E_NOTIMPL;
3393 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3395 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3396 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3397 return E_NOTIMPL;
3400 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3402 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3403 FIXME("(%p)->(%p)\n", This, p);
3404 return E_NOTIMPL;
3407 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3409 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3410 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3411 return E_NOTIMPL;
3414 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3416 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3417 FIXME("(%p)->(%p)\n", This, p);
3418 return E_NOTIMPL;
3421 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3423 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3424 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3425 return E_NOTIMPL;
3428 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3430 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3431 FIXME("(%p)->(%p)\n", This, p);
3432 return E_NOTIMPL;
3435 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3437 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3438 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3439 return E_NOTIMPL;
3442 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3444 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3445 FIXME("(%p)->(%p)\n", This, p);
3446 return E_NOTIMPL;
3449 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3451 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3452 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3453 return E_NOTIMPL;
3456 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3458 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3459 FIXME("(%p)->(%p)\n", This, p);
3460 return E_NOTIMPL;
3463 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3465 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3466 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3467 return E_NOTIMPL;
3470 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3472 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3473 FIXME("(%p)->(%p)\n", This, p);
3474 return E_NOTIMPL;
3477 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3479 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3480 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3481 return E_NOTIMPL;
3484 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3486 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3487 FIXME("(%p)->(%p)\n", This, p);
3488 return E_NOTIMPL;
3491 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3493 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3494 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3495 return E_NOTIMPL;
3498 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3500 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3501 FIXME("(%p)->(%p)\n", This, p);
3502 return E_NOTIMPL;
3505 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3507 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3508 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3509 return E_NOTIMPL;
3512 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3514 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3515 FIXME("(%p)->(%p)\n", This, p);
3516 return E_NOTIMPL;
3519 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3521 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3522 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3523 return E_NOTIMPL;
3526 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
3528 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3529 FIXME("(%p)->(%p)\n", This, p);
3530 return E_NOTIMPL;
3533 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
3535 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3536 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3537 return E_NOTIMPL;
3540 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
3542 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3543 FIXME("(%p)->(%p)\n", This, p);
3544 return E_NOTIMPL;
3547 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
3549 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3550 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3551 return E_NOTIMPL;
3554 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
3556 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3557 FIXME("(%p)->(%p)\n", This, p);
3558 return E_NOTIMPL;
3561 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
3563 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3564 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3565 return E_NOTIMPL;
3568 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
3570 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3571 FIXME("(%p)->(%p)\n", This, p);
3572 return E_NOTIMPL;
3575 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
3577 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3578 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3579 return E_NOTIMPL;
3582 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
3584 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3585 FIXME("(%p)->(%p)\n", This, p);
3586 return E_NOTIMPL;
3589 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
3591 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3592 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3593 return E_NOTIMPL;
3596 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
3598 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3599 FIXME("(%p)->(%p)\n", This, p);
3600 return E_NOTIMPL;
3603 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
3605 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3606 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3607 return E_NOTIMPL;
3610 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
3612 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3613 FIXME("(%p)->(%p)\n", This, p);
3614 return E_NOTIMPL;
3617 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
3619 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3620 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3621 return E_NOTIMPL;
3624 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
3626 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3627 FIXME("(%p)->(%p)\n", This, p);
3628 return E_NOTIMPL;
3631 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
3633 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3634 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3635 return E_NOTIMPL;
3638 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
3640 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3641 FIXME("(%p)->(%p)\n", This, p);
3642 return E_NOTIMPL;
3645 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
3647 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3648 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3649 return E_NOTIMPL;
3652 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
3654 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3655 FIXME("(%p)->(%p)\n", This, p);
3656 return E_NOTIMPL;
3659 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
3661 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3662 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3663 return E_NOTIMPL;
3666 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
3668 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3669 FIXME("(%p)->(%p)\n", This, p);
3670 return E_NOTIMPL;
3673 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
3675 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3676 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3677 return E_NOTIMPL;
3680 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
3682 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3683 FIXME("(%p)->(%p)\n", This, p);
3684 return E_NOTIMPL;
3687 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
3689 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3690 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3691 return E_NOTIMPL;
3694 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
3696 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3697 FIXME("(%p)->(%p)\n", This, p);
3698 return E_NOTIMPL;
3701 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
3703 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3704 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3705 return E_NOTIMPL;
3708 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
3710 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3711 FIXME("(%p)->(%p)\n", This, p);
3712 return E_NOTIMPL;
3715 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
3717 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3718 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3719 return E_NOTIMPL;
3722 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
3724 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3725 FIXME("(%p)->(%p)\n", This, p);
3726 return E_NOTIMPL;
3729 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
3731 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3732 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3733 return E_NOTIMPL;
3736 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
3738 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3739 FIXME("(%p)->(%p)\n", This, p);
3740 return E_NOTIMPL;
3743 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
3745 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3746 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3747 return E_NOTIMPL;
3750 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
3752 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3753 FIXME("(%p)->(%p)\n", This, p);
3754 return E_NOTIMPL;
3757 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
3759 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3760 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3761 return E_NOTIMPL;
3764 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
3766 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3767 FIXME("(%p)->(%p)\n", This, p);
3768 return E_NOTIMPL;
3771 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
3773 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3774 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3775 return E_NOTIMPL;
3778 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
3780 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3781 FIXME("(%p)->(%p)\n", This, p);
3782 return E_NOTIMPL;
3785 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
3787 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3788 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3789 return E_NOTIMPL;
3792 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
3794 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3795 FIXME("(%p)->(%p)\n", This, p);
3796 return E_NOTIMPL;
3799 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
3801 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3802 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3803 return E_NOTIMPL;
3806 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
3808 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3809 FIXME("(%p)->(%p)\n", This, p);
3810 return E_NOTIMPL;
3813 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
3815 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3816 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3817 return E_NOTIMPL;
3820 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
3822 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3823 FIXME("(%p)->(%p)\n", This, p);
3824 return E_NOTIMPL;
3827 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
3829 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3830 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3831 return E_NOTIMPL;
3834 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
3836 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3837 FIXME("(%p)->(%p)\n", This, p);
3838 return E_NOTIMPL;
3841 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
3843 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3844 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3845 return E_NOTIMPL;
3848 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
3850 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3851 FIXME("(%p)->(%p)\n", This, p);
3852 return E_NOTIMPL;
3855 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
3857 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3858 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3859 return E_NOTIMPL;
3862 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
3864 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3865 FIXME("(%p)->(%p)\n", This, p);
3866 return E_NOTIMPL;
3869 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
3871 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3872 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3873 return E_NOTIMPL;
3876 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
3878 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3879 FIXME("(%p)->(%p)\n", This, p);
3880 return E_NOTIMPL;
3883 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
3885 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3886 FIXME("(%p)\n", This);
3887 return E_NOTIMPL;
3890 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
3891 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
3893 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3894 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
3895 return E_NOTIMPL;
3898 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3900 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3901 FIXME("(%p)->(%p)\n", This, p);
3902 return E_NOTIMPL;
3905 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
3907 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3908 FIXME("(%p)->(%p)\n", This, v);
3909 return E_NOTIMPL;
3912 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
3914 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3915 FIXME("(%p)->(%p)\n", This, p);
3916 return E_NOTIMPL;
3919 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
3921 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3922 FIXME("(%p)->(%p)\n", This, p);
3923 return E_NOTIMPL;
3926 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
3927 HTMLDocument7_QueryInterface,
3928 HTMLDocument7_AddRef,
3929 HTMLDocument7_Release,
3930 HTMLDocument7_GetTypeInfoCount,
3931 HTMLDocument7_GetTypeInfo,
3932 HTMLDocument7_GetIDsOfNames,
3933 HTMLDocument7_Invoke,
3934 HTMLDocument7_get_defaultView,
3935 HTMLDocument7_createCDATASection,
3936 HTMLDocument7_getSelection,
3937 HTMLDocument7_getElementsByTagNameNS,
3938 HTMLDocument7_createElementNS,
3939 HTMLDocument7_createAttributeNS,
3940 HTMLDocument7_put_onmsthumbnailclick,
3941 HTMLDocument7_get_onmsthumbnailclick,
3942 HTMLDocument7_get_characterSet,
3943 HTMLDocument7_createElement,
3944 HTMLDocument7_createAttribute,
3945 HTMLDocument7_getElementByClassName,
3946 HTMLDocument7_createProcessingInstruction,
3947 HTMLDocument7_adoptNode,
3948 HTMLDocument7_put_onmssitemodejumplistitemremoved,
3949 HTMLDocument7_get_onmssitemodejumplistitemremoved,
3950 HTMLDocument7_get_all,
3951 HTMLDocument7_get_inputEncoding,
3952 HTMLDocument7_get_xmlEncoding,
3953 HTMLDocument7_put_xmlStandalone,
3954 HTMLDocument7_get_xmlStandalone,
3955 HTMLDocument7_put_xmlVersion,
3956 HTMLDocument7_get_xmlVersion,
3957 HTMLDocument7_hasAttributes,
3958 HTMLDocument7_put_onabort,
3959 HTMLDocument7_get_onabort,
3960 HTMLDocument7_put_onblur,
3961 HTMLDocument7_get_onblur,
3962 HTMLDocument7_put_oncanplay,
3963 HTMLDocument7_get_oncanplay,
3964 HTMLDocument7_put_oncanplaythrough,
3965 HTMLDocument7_get_oncanplaythrough,
3966 HTMLDocument7_put_onchange,
3967 HTMLDocument7_get_onchange,
3968 HTMLDocument7_put_ondrag,
3969 HTMLDocument7_get_ondrag,
3970 HTMLDocument7_put_ondragend,
3971 HTMLDocument7_get_ondragend,
3972 HTMLDocument7_put_ondragenter,
3973 HTMLDocument7_get_ondragenter,
3974 HTMLDocument7_put_ondragleave,
3975 HTMLDocument7_get_ondragleave,
3976 HTMLDocument7_put_ondragover,
3977 HTMLDocument7_get_ondragover,
3978 HTMLDocument7_put_ondrop,
3979 HTMLDocument7_get_ondrop,
3980 HTMLDocument7_put_ondurationchange,
3981 HTMLDocument7_get_ondurationchange,
3982 HTMLDocument7_put_onemptied,
3983 HTMLDocument7_get_onemptied,
3984 HTMLDocument7_put_onended,
3985 HTMLDocument7_get_onended,
3986 HTMLDocument7_put_onerror,
3987 HTMLDocument7_get_onerror,
3988 HTMLDocument7_put_onfocus,
3989 HTMLDocument7_get_onfocus,
3990 HTMLDocument7_put_oninput,
3991 HTMLDocument7_get_oninput,
3992 HTMLDocument7_put_onload,
3993 HTMLDocument7_get_onload,
3994 HTMLDocument7_put_onloadeddata,
3995 HTMLDocument7_get_onloadeddata,
3996 HTMLDocument7_put_onloadedmetadata,
3997 HTMLDocument7_get_onloadedmetadata,
3998 HTMLDocument7_put_onloadstart,
3999 HTMLDocument7_get_onloadstart,
4000 HTMLDocument7_put_onpause,
4001 HTMLDocument7_get_onpause,
4002 HTMLDocument7_put_onplay,
4003 HTMLDocument7_get_onplay,
4004 HTMLDocument7_put_onplaying,
4005 HTMLDocument7_get_onplaying,
4006 HTMLDocument7_put_onprogress,
4007 HTMLDocument7_get_onprogress,
4008 HTMLDocument7_put_onratechange,
4009 HTMLDocument7_get_onratechange,
4010 HTMLDocument7_put_onreset,
4011 HTMLDocument7_get_onreset,
4012 HTMLDocument7_put_onscroll,
4013 HTMLDocument7_get_onscroll,
4014 HTMLDocument7_put_onseekend,
4015 HTMLDocument7_get_onseekend,
4016 HTMLDocument7_put_onseeking,
4017 HTMLDocument7_get_onseeking,
4018 HTMLDocument7_put_onselect,
4019 HTMLDocument7_get_onselect,
4020 HTMLDocument7_put_onstalled,
4021 HTMLDocument7_get_onstalled,
4022 HTMLDocument7_put_onsubmit,
4023 HTMLDocument7_get_onsubmit,
4024 HTMLDocument7_put_onsuspend,
4025 HTMLDocument7_get_onsuspend,
4026 HTMLDocument7_put_ontimeupdate,
4027 HTMLDocument7_get_ontimeupdate,
4028 HTMLDocument7_put_onvolumechange,
4029 HTMLDocument7_get_onvolumechange,
4030 HTMLDocument7_put_onwaiting,
4031 HTMLDocument7_get_onwaiting,
4032 HTMLDocument7_normalize,
4033 HTMLDocument7_importNode,
4034 HTMLDocument7_get_parentWindow,
4035 HTMLDocument7_put_body,
4036 HTMLDocument7_get_body,
4037 HTMLDocument7_get_head
4040 static inline HTMLDocument *impl_from_IDocumentSelector(IDocumentSelector *iface)
4042 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentSelector_iface);
4045 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4047 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4048 return htmldoc_query_interface(This, riid, ppv);
4051 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4053 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4054 return htmldoc_addref(This);
4057 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4059 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4060 return htmldoc_release(This);
4063 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4065 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4066 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4069 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4070 LCID lcid, ITypeInfo **ppTInfo)
4072 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4073 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4076 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4077 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4079 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4080 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4081 rgDispId);
4084 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4085 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4087 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4088 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4089 pDispParams, pVarResult, pExcepInfo, puArgErr);
4092 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4094 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4095 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4096 return E_NOTIMPL;
4099 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4101 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4102 nsIDOMNodeList *node_list;
4103 nsAString nsstr;
4104 nsresult nsres;
4106 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4108 nsAString_InitDepend(&nsstr, v);
4109 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &nsstr, &node_list);
4110 nsAString_Finish(&nsstr);
4111 if(NS_FAILED(nsres)) {
4112 ERR("QuerySelectorAll failed: %08x\n", nsres);
4113 return E_FAIL;
4116 *pel = create_child_collection(This->doc_node, node_list);
4117 nsIDOMNodeList_Release(node_list);
4118 return *pel ? S_OK : E_OUTOFMEMORY;
4121 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4122 DocumentSelector_QueryInterface,
4123 DocumentSelector_AddRef,
4124 DocumentSelector_Release,
4125 DocumentSelector_GetTypeInfoCount,
4126 DocumentSelector_GetTypeInfo,
4127 DocumentSelector_GetIDsOfNames,
4128 DocumentSelector_Invoke,
4129 DocumentSelector_querySelector,
4130 DocumentSelector_querySelectorAll
4133 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4135 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4137 if(This->window)
4138 update_doc_cp_events(This->doc_node, cp);
4141 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4143 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4146 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4148 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4149 return htmldoc_query_interface(This, riid, ppv);
4152 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4154 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4155 return htmldoc_addref(This);
4158 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4160 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4161 return htmldoc_release(This);
4164 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4166 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4167 return S_FALSE;
4170 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4171 SupportErrorInfo_QueryInterface,
4172 SupportErrorInfo_AddRef,
4173 SupportErrorInfo_Release,
4174 SupportErrorInfo_InterfaceSupportsErrorInfo
4177 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4179 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4182 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4184 nsIDOMNodeList *node_list;
4185 nsAString name_str;
4186 UINT32 len;
4187 unsigned i;
4188 nsresult nsres;
4190 if(!This->nsdoc)
4191 return DISP_E_UNKNOWNNAME;
4193 nsAString_InitDepend(&name_str, name);
4194 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4195 nsAString_Finish(&name_str);
4196 if(NS_FAILED(nsres))
4197 return E_FAIL;
4199 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4200 nsIDOMNodeList_Release(node_list);
4201 if(NS_FAILED(nsres))
4202 return E_FAIL;
4204 if(!len)
4205 return DISP_E_UNKNOWNNAME;
4207 for(i=0; i < This->elem_vars_cnt; i++) {
4208 if(!strcmpW(name, This->elem_vars[i])) {
4209 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4210 return S_OK;
4214 if(This->elem_vars_cnt == This->elem_vars_size) {
4215 WCHAR **new_vars;
4217 if(This->elem_vars_size) {
4218 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4219 if(!new_vars)
4220 return E_OUTOFMEMORY;
4221 This->elem_vars_size *= 2;
4222 }else {
4223 new_vars = heap_alloc(16*sizeof(WCHAR*));
4224 if(!new_vars)
4225 return E_OUTOFMEMORY;
4226 This->elem_vars_size = 16;
4229 This->elem_vars = new_vars;
4232 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4233 if(!This->elem_vars[This->elem_vars_cnt])
4234 return E_OUTOFMEMORY;
4236 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4237 return S_OK;
4240 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4242 HTMLDocument *This = impl_from_IDispatchEx(iface);
4244 return htmldoc_query_interface(This, riid, ppv);
4247 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4249 HTMLDocument *This = impl_from_IDispatchEx(iface);
4251 return htmldoc_addref(This);
4254 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4256 HTMLDocument *This = impl_from_IDispatchEx(iface);
4258 return htmldoc_release(This);
4261 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4263 HTMLDocument *This = impl_from_IDispatchEx(iface);
4265 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4268 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4269 LCID lcid, ITypeInfo **ppTInfo)
4271 HTMLDocument *This = impl_from_IDispatchEx(iface);
4273 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4276 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4277 LPOLESTR *rgszNames, UINT cNames,
4278 LCID lcid, DISPID *rgDispId)
4280 HTMLDocument *This = impl_from_IDispatchEx(iface);
4282 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4285 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4286 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4287 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4289 HTMLDocument *This = impl_from_IDispatchEx(iface);
4291 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4292 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4294 switch(dispIdMember) {
4295 case DISPID_READYSTATE:
4296 TRACE("DISPID_READYSTATE\n");
4298 if(!(wFlags & DISPATCH_PROPERTYGET))
4299 return E_INVALIDARG;
4301 V_VT(pVarResult) = VT_I4;
4302 V_I4(pVarResult) = This->window->readystate;
4303 return S_OK;
4306 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
4307 pVarResult, pExcepInfo, puArgErr);
4310 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4312 HTMLDocument *This = impl_from_IDispatchEx(iface);
4313 HRESULT hres;
4315 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4316 if(hres != DISP_E_UNKNOWNNAME)
4317 return hres;
4319 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4322 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4323 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4325 HTMLDocument *This = impl_from_IDispatchEx(iface);
4327 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
4328 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
4329 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4332 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4335 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4337 HTMLDocument *This = impl_from_IDispatchEx(iface);
4339 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4342 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4344 HTMLDocument *This = impl_from_IDispatchEx(iface);
4346 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4349 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4351 HTMLDocument *This = impl_from_IDispatchEx(iface);
4353 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4356 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4358 HTMLDocument *This = impl_from_IDispatchEx(iface);
4360 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4363 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4365 HTMLDocument *This = impl_from_IDispatchEx(iface);
4367 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
4370 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
4372 HTMLDocument *This = impl_from_IDispatchEx(iface);
4374 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
4377 static const IDispatchExVtbl DocDispatchExVtbl = {
4378 DocDispatchEx_QueryInterface,
4379 DocDispatchEx_AddRef,
4380 DocDispatchEx_Release,
4381 DocDispatchEx_GetTypeInfoCount,
4382 DocDispatchEx_GetTypeInfo,
4383 DocDispatchEx_GetIDsOfNames,
4384 DocDispatchEx_Invoke,
4385 DocDispatchEx_GetDispID,
4386 DocDispatchEx_InvokeEx,
4387 DocDispatchEx_DeleteMemberByName,
4388 DocDispatchEx_DeleteMemberByDispID,
4389 DocDispatchEx_GetMemberProperties,
4390 DocDispatchEx_GetMemberName,
4391 DocDispatchEx_GetNextDispID,
4392 DocDispatchEx_GetNameSpaceParent
4395 static inline HTMLDocument *impl_from_IProvideClassInfo(IProvideClassInfo *iface)
4397 return CONTAINING_RECORD(iface, HTMLDocument, IProvideClassInfo_iface);
4400 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideClassInfo *iface,
4401 REFIID riid, void **ppv)
4403 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4404 return htmldoc_query_interface(This, riid, ppv);
4407 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideClassInfo *iface)
4409 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4410 return htmldoc_addref(This);
4413 static ULONG WINAPI ProvideClassInfo_Release(IProvideClassInfo *iface)
4415 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4416 return htmldoc_release(This);
4419 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideClassInfo* iface,
4420 ITypeInfo **ppTI)
4422 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4423 TRACE("(%p)->(%p)\n", This, ppTI);
4424 return get_htmldoc_classinfo(ppTI);
4427 static const IProvideClassInfoVtbl ProvideClassInfoVtbl = {
4428 ProvideClassInfo_QueryInterface,
4429 ProvideClassInfo_AddRef,
4430 ProvideClassInfo_Release,
4431 ProvideClassInfo_GetClassInfo
4434 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
4436 *ppv = NULL;
4438 if(IsEqualGUID(&IID_IUnknown, riid))
4439 *ppv = &This->IHTMLDocument2_iface;
4440 else if(IsEqualGUID(&IID_IDispatch, riid))
4441 *ppv = &This->IDispatchEx_iface;
4442 else if(IsEqualGUID(&IID_IDispatchEx, riid))
4443 *ppv = &This->IDispatchEx_iface;
4444 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
4445 *ppv = &This->IHTMLDocument2_iface;
4446 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
4447 *ppv = &This->IHTMLDocument2_iface;
4448 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
4449 *ppv = &This->IHTMLDocument3_iface;
4450 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
4451 *ppv = &This->IHTMLDocument4_iface;
4452 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
4453 *ppv = &This->IHTMLDocument5_iface;
4454 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
4455 *ppv = &This->IHTMLDocument6_iface;
4456 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
4457 *ppv = &This->IHTMLDocument7_iface;
4458 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
4459 *ppv = &This->IDocumentSelector_iface;
4460 else if(IsEqualGUID(&IID_IPersist, riid))
4461 *ppv = &This->IPersistFile_iface;
4462 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
4463 *ppv = &This->IPersistMoniker_iface;
4464 else if(IsEqualGUID(&IID_IPersistFile, riid))
4465 *ppv = &This->IPersistFile_iface;
4466 else if(IsEqualGUID(&IID_IMonikerProp, riid))
4467 *ppv = &This->IMonikerProp_iface;
4468 else if(IsEqualGUID(&IID_IOleObject, riid))
4469 *ppv = &This->IOleObject_iface;
4470 else if(IsEqualGUID(&IID_IOleDocument, riid))
4471 *ppv = &This->IOleDocument_iface;
4472 else if(IsEqualGUID(&IID_IOleDocumentView, riid))
4473 *ppv = &This->IOleDocumentView_iface;
4474 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
4475 *ppv = &This->IOleInPlaceActiveObject_iface;
4476 else if(IsEqualGUID(&IID_IViewObject, riid))
4477 *ppv = &This->IViewObjectEx_iface;
4478 else if(IsEqualGUID(&IID_IViewObject2, riid))
4479 *ppv = &This->IViewObjectEx_iface;
4480 else if(IsEqualGUID(&IID_IViewObjectEx, riid))
4481 *ppv = &This->IViewObjectEx_iface;
4482 else if(IsEqualGUID(&IID_IOleWindow, riid))
4483 *ppv = &This->IOleInPlaceActiveObject_iface;
4484 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
4485 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4486 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
4487 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4488 else if(IsEqualGUID(&IID_IServiceProvider, riid))
4489 *ppv = &This->IServiceProvider_iface;
4490 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
4491 *ppv = &This->IOleCommandTarget_iface;
4492 else if(IsEqualGUID(&IID_IOleControl, riid))
4493 *ppv = &This->IOleControl_iface;
4494 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
4495 *ppv = &This->IHlinkTarget_iface;
4496 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
4497 *ppv = &This->cp_container.IConnectionPointContainer_iface;
4498 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
4499 *ppv = &This->IPersistStreamInit_iface;
4500 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
4501 *ppv = &This->IHTMLDocument2_iface;
4502 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
4503 *ppv = &This->ISupportErrorInfo_iface;
4504 else if(IsEqualGUID(&IID_IPersistHistory, riid))
4505 *ppv = &This->IPersistHistory_iface;
4506 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
4507 *ppv = &This->IObjectWithSite_iface;
4508 else if(IsEqualGUID(&IID_IOleContainer, riid))
4509 *ppv = &This->IOleContainer_iface;
4510 else if(IsEqualGUID(&IID_IObjectSafety, riid))
4511 *ppv = &This->IObjectSafety_iface;
4512 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
4513 *ppv = &This->IProvideClassInfo_iface;
4514 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
4515 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
4516 *ppv = NULL;
4517 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
4518 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
4519 *ppv = NULL;
4520 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
4521 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
4522 *ppv = NULL;
4523 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
4524 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
4525 *ppv = NULL;
4526 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
4527 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
4528 *ppv = NULL;
4529 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
4530 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
4531 *ppv = NULL;
4532 }else {
4533 return FALSE;
4536 if(*ppv)
4537 IUnknown_AddRef((IUnknown*)*ppv);
4538 return TRUE;
4541 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
4543 static const cpc_entry_t HTMLDocument_cpc[] = {
4544 {&IID_IDispatch, &HTMLDocumentEvents_data},
4545 {&IID_IPropertyNotifySink},
4546 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
4547 {&DIID_HTMLDocumentEvents2},
4548 {NULL}
4551 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
4553 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
4554 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
4555 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
4556 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
4557 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
4558 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
4559 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
4560 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
4561 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
4562 doc->IProvideClassInfo_iface.lpVtbl = &ProvideClassInfoVtbl;
4564 doc->unk_impl = unk_impl;
4565 doc->dispex = dispex;
4566 doc->task_magic = get_task_target_magic();
4568 HTMLDocument_Persist_Init(doc);
4569 HTMLDocument_OleCmd_Init(doc);
4570 HTMLDocument_OleObj_Init(doc);
4571 HTMLDocument_View_Init(doc);
4572 HTMLDocument_Window_Init(doc);
4573 HTMLDocument_Service_Init(doc);
4574 HTMLDocument_Hlink_Init(doc);
4576 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
4579 static void destroy_htmldoc(HTMLDocument *This)
4581 remove_target_tasks(This->task_magic);
4583 ConnectionPointContainer_Destroy(&This->cp_container);
4586 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
4588 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
4591 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
4593 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4595 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4597 if(htmldoc_qi(&This->basedoc, riid, ppv))
4598 return *ppv ? S_OK : E_NOINTERFACE;
4600 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
4601 *ppv = &This->IInternetHostSecurityManager_iface;
4602 else
4603 return HTMLDOMNode_QI(&This->node, riid, ppv);
4605 IUnknown_AddRef((IUnknown*)*ppv);
4606 return S_OK;
4609 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
4611 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4612 unsigned i;
4614 for(i=0; i < This->elem_vars_cnt; i++)
4615 heap_free(This->elem_vars[i]);
4616 heap_free(This->elem_vars);
4618 detach_events(This);
4619 if(This->body_event_target)
4620 release_event_target(This->body_event_target);
4621 if(This->catmgr)
4622 ICatInformation_Release(This->catmgr);
4624 detach_selection(This);
4625 detach_ranges(This);
4627 while(!list_empty(&This->plugin_hosts))
4628 detach_plugin_host(LIST_ENTRY(list_head(&This->plugin_hosts), PluginHost, entry));
4630 if(!This->nsdoc && This->window) {
4631 /* document fragments own reference to inner window */
4632 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
4633 This->window = NULL;
4636 heap_free(This->event_vector);
4637 destroy_htmldoc(&This->basedoc);
4640 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4642 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4643 FIXME("%p\n", This);
4644 return E_NOTIMPL;
4647 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
4649 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4651 if(This->nsdoc)
4652 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
4655 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
4657 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4659 if(This->nsdoc) {
4660 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
4662 release_document_mutation(This);
4663 This->nsdoc = NULL;
4664 nsIDOMHTMLDocument_Release(nsdoc);
4665 This->window = NULL;
4669 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
4670 HTMLDocumentNode_QI,
4671 HTMLDocumentNode_destructor,
4672 HTMLDocument_cpc,
4673 HTMLDocumentNode_clone,
4674 NULL,
4675 NULL,
4676 NULL,
4677 NULL,
4678 NULL,
4679 NULL,
4680 NULL,
4681 NULL,
4682 NULL,
4683 NULL,
4684 NULL,
4685 HTMLDocumentNode_traverse,
4686 HTMLDocumentNode_unlink
4689 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4691 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4692 HTMLDocumentNode *new_node;
4693 HRESULT hres;
4695 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
4696 if(FAILED(hres))
4697 return hres;
4699 *ret = &new_node->node;
4700 return S_OK;
4703 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
4705 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
4708 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4709 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4711 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4712 nsIDOMNodeList *node_list;
4713 nsAString name_str;
4714 nsIDOMNode *nsnode;
4715 HTMLDOMNode *node;
4716 unsigned i;
4717 nsresult nsres;
4718 HRESULT hres;
4720 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
4721 FIXME("unsupported flags %x\n", flags);
4722 return E_NOTIMPL;
4725 i = id - MSHTML_DISPID_CUSTOM_MIN;
4727 if(!This->nsdoc || i >= This->elem_vars_cnt)
4728 return DISP_E_UNKNOWNNAME;
4730 nsAString_InitDepend(&name_str, This->elem_vars[i]);
4731 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4732 nsAString_Finish(&name_str);
4733 if(NS_FAILED(nsres))
4734 return E_FAIL;
4736 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
4737 nsIDOMNodeList_Release(node_list);
4738 if(NS_FAILED(nsres) || !nsnode)
4739 return DISP_E_UNKNOWNNAME;
4741 hres = get_node(This, nsnode, TRUE, &node);
4742 if(FAILED(hres))
4743 return hres;
4745 V_VT(res) = VT_DISPATCH;
4746 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
4747 return S_OK;
4750 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, int eid)
4752 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4753 ensure_doc_nsevent_handler(This, eid);
4756 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl = {
4757 NULL,
4758 NULL,
4759 HTMLDocumentNode_invoke,
4760 NULL,
4761 NULL,
4762 HTMLDocumentNode_bind_event
4765 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
4766 HTMLDocumentNode_QI,
4767 HTMLDocumentNode_destructor,
4768 HTMLDocument_cpc,
4769 HTMLDocumentFragment_clone
4772 static const tid_t HTMLDocumentNode_iface_tids[] = {
4773 IHTMLDOMNode_tid,
4774 IHTMLDOMNode2_tid,
4775 IHTMLDocument2_tid,
4776 IHTMLDocument3_tid,
4777 IHTMLDocument4_tid,
4778 IHTMLDocument5_tid,
4779 IHTMLDocument6_tid,
4780 IDocumentSelector_tid,
4784 static dispex_static_data_t HTMLDocumentNode_dispex = {
4785 &HTMLDocumentNode_dispex_vtbl,
4786 DispHTMLDocument_tid,
4787 HTMLDocumentNode_iface_tids
4790 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
4792 HTMLDocumentNode *doc;
4794 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
4795 if(!doc)
4796 return NULL;
4798 doc->ref = 1;
4799 doc->basedoc.doc_node = doc;
4800 doc->basedoc.doc_obj = doc_obj;
4801 doc->basedoc.window = window->base.outer_window;
4802 doc->window = window;
4804 init_dispex(&doc->node.event_target.dispex, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4805 &HTMLDocumentNode_dispex);
4806 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4807 &doc->node.event_target.dispex.IDispatchEx_iface);
4808 HTMLDocumentNode_SecMgr_Init(doc);
4810 list_init(&doc->selection_list);
4811 list_init(&doc->range_list);
4812 list_init(&doc->plugin_hosts);
4814 return doc;
4817 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLInnerWindow *window, HTMLDocumentNode **ret)
4819 HTMLDocumentNode *doc;
4821 doc = alloc_doc_node(doc_obj, window);
4822 if(!doc)
4823 return E_OUTOFMEMORY;
4825 if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
4826 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
4828 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
4830 nsIDOMHTMLDocument_AddRef(nsdoc);
4831 doc->nsdoc = nsdoc;
4833 init_document_mutation(doc);
4834 doc_init_events(doc);
4836 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
4837 doc->node.cp_container = &doc->basedoc.cp_container;
4839 *ret = doc;
4840 return S_OK;
4843 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
4845 HTMLDocumentNode *doc_frag;
4847 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
4848 if(!doc_frag)
4849 return E_OUTOFMEMORY;
4851 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
4853 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
4854 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
4855 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
4857 *ret = doc_frag;
4858 return S_OK;
4861 /**********************************************************
4862 * ICustomDoc implementation
4865 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
4867 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
4870 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
4872 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4874 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4876 if(htmldoc_qi(&This->basedoc, riid, ppv))
4877 return *ppv ? S_OK : E_NOINTERFACE;
4879 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
4880 *ppv = &This->ICustomDoc_iface;
4881 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
4882 *ppv = &This->ITargetContainer_iface;
4883 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4884 return *ppv ? S_OK : E_NOINTERFACE;
4885 }else {
4886 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
4887 *ppv = NULL;
4888 return E_NOINTERFACE;
4891 IUnknown_AddRef((IUnknown*)*ppv);
4892 return S_OK;
4895 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
4897 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4898 ULONG ref = InterlockedIncrement(&This->ref);
4900 TRACE("(%p) ref = %u\n", This, ref);
4902 return ref;
4905 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
4907 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4908 ULONG ref = InterlockedDecrement(&This->ref);
4910 TRACE("(%p) ref = %u\n", This, ref);
4912 if(!ref) {
4913 nsIDOMWindowUtils *window_utils = NULL;
4915 if(This->basedoc.window && This->basedoc.window->nswindow)
4916 get_nsinterface((nsISupports*)This->basedoc.window->nswindow, &IID_nsIDOMWindowUtils, (void**)&window_utils);
4918 if(This->basedoc.doc_node) {
4919 This->basedoc.doc_node->basedoc.doc_obj = NULL;
4920 htmldoc_release(&This->basedoc.doc_node->basedoc);
4922 if(This->basedoc.window) {
4923 This->basedoc.window->doc_obj = NULL;
4924 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
4926 if(This->basedoc.advise_holder)
4927 IOleAdviseHolder_Release(This->basedoc.advise_holder);
4929 if(This->view_sink)
4930 IAdviseSink_Release(This->view_sink);
4931 if(This->client)
4932 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
4933 if(This->hostui)
4934 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
4935 if(This->in_place_active)
4936 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
4937 if(This->ipsite)
4938 IOleDocumentView_SetInPlaceSite(&This->basedoc.IOleDocumentView_iface, NULL);
4939 if(This->undomgr)
4940 IOleUndoManager_Release(This->undomgr);
4941 if(This->editsvcs)
4942 IHTMLEditServices_Release(This->editsvcs);
4943 if(This->tooltips_hwnd)
4944 DestroyWindow(This->tooltips_hwnd);
4946 if(This->hwnd)
4947 DestroyWindow(This->hwnd);
4948 heap_free(This->mime);
4950 destroy_htmldoc(&This->basedoc);
4951 release_dispex(&This->dispex);
4953 if(This->nscontainer)
4954 NSContainer_Release(This->nscontainer);
4955 heap_free(This);
4957 /* Force cycle collection */
4958 if(window_utils) {
4959 nsIDOMWindowUtils_CycleCollect(window_utils, NULL, 0);
4960 nsIDOMWindowUtils_Release(window_utils);
4964 return ref;
4967 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
4969 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4970 IOleCommandTarget *cmdtrg;
4971 HRESULT hres;
4973 TRACE("(%p)->(%p)\n", This, pUIHandler);
4975 if(This->custom_hostui && This->hostui == pUIHandler)
4976 return S_OK;
4978 This->custom_hostui = TRUE;
4980 if(This->hostui)
4981 IDocHostUIHandler_Release(This->hostui);
4982 if(pUIHandler)
4983 IDocHostUIHandler_AddRef(pUIHandler);
4984 This->hostui = pUIHandler;
4985 if(!pUIHandler)
4986 return S_OK;
4988 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
4989 if(SUCCEEDED(hres)) {
4990 FIXME("custom UI handler supports IOleCommandTarget\n");
4991 IOleCommandTarget_Release(cmdtrg);
4994 return S_OK;
4997 static const ICustomDocVtbl CustomDocVtbl = {
4998 CustomDoc_QueryInterface,
4999 CustomDoc_AddRef,
5000 CustomDoc_Release,
5001 CustomDoc_SetUIHandler
5004 static const tid_t HTMLDocumentObj_iface_tids[] = {
5005 IHTMLDocument2_tid,
5006 IHTMLDocument3_tid,
5007 IHTMLDocument4_tid,
5008 IHTMLDocument5_tid,
5011 static dispex_static_data_t HTMLDocumentObj_dispex = {
5012 NULL,
5013 DispHTMLDocument_tid,
5014 HTMLDocumentObj_iface_tids
5017 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
5019 mozIDOMWindowProxy *mozwindow;
5020 HTMLDocumentObj *doc;
5021 nsIDOMWindow *nswindow = NULL;
5022 nsresult nsres;
5023 HRESULT hres;
5025 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_mshtml_guid(riid), ppvObject);
5027 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
5028 if(!doc)
5029 return E_OUTOFMEMORY;
5031 init_dispex(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex);
5032 init_doc(&doc->basedoc, (IUnknown*)&doc->ICustomDoc_iface, &doc->dispex.IDispatchEx_iface);
5033 TargetContainer_Init(doc);
5035 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
5036 doc->ref = 1;
5037 doc->basedoc.doc_obj = doc;
5039 doc->usermode = UNKNOWN_USERMODE;
5041 init_binding_ui(doc);
5043 hres = create_nscontainer(doc, &doc->nscontainer);
5044 if(FAILED(hres)) {
5045 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
5046 htmldoc_release(&doc->basedoc);
5047 return hres;
5050 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
5051 htmldoc_release(&doc->basedoc);
5052 if(FAILED(hres))
5053 return hres;
5055 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &mozwindow);
5056 if(NS_FAILED(nsres))
5057 ERR("GetContentDOMWindow failed: %08x\n", nsres);
5059 nsres = mozIDOMWindowProxy_QueryInterface(mozwindow, &IID_nsIDOMWindow, (void**)&nswindow);
5060 mozIDOMWindowProxy_Release(mozwindow);
5061 assert(nsres == NS_OK);
5063 hres = HTMLOuterWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
5064 if(nswindow)
5065 nsIDOMWindow_Release(nswindow);
5066 if(FAILED(hres)) {
5067 htmldoc_release(&doc->basedoc);
5068 return hres;
5071 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
5072 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
5073 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
5076 get_thread_hwnd();
5078 return S_OK;