wined3d: Remove fbo_entry->d3d_depth_stencil.
[wine.git] / dlls / mshtml / htmldoc.c
blob784a578b2ed88ec1b9bb86b0e1f82a35e999e0e8
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 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
799 return E_NOTIMPL;
802 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
804 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
805 HRESULT hres;
807 TRACE("(%p)->(%p)\n", This, p);
809 if(!This->window || !This->window->uri) {
810 FIXME("No current URI\n");
811 return E_FAIL;
814 hres = IUri_GetHost(This->window->uri, p);
815 return FAILED(hres) ? hres : S_OK;
818 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
820 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
821 BOOL bret;
823 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
825 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
826 if(!bret) {
827 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
828 return HRESULT_FROM_WIN32(GetLastError());
831 return S_OK;
834 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
836 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
837 DWORD size;
838 BOOL bret;
840 TRACE("(%p)->(%p)\n", This, p);
842 size = 0;
843 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
844 if(!bret) {
845 switch(GetLastError()) {
846 case ERROR_INSUFFICIENT_BUFFER:
847 break;
848 case ERROR_NO_MORE_ITEMS:
849 *p = NULL;
850 return S_OK;
851 default:
852 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
853 return HRESULT_FROM_WIN32(GetLastError());
857 if(!size) {
858 *p = NULL;
859 return S_OK;
862 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
863 if(!*p)
864 return E_OUTOFMEMORY;
866 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
867 if(!bret) {
868 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
869 return E_FAIL;
872 return S_OK;
875 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
877 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
878 FIXME("(%p)->(%x)\n", This, v);
879 return E_NOTIMPL;
882 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
884 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
885 FIXME("(%p)->(%p)\n", This, p);
886 return E_NOTIMPL;
889 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
891 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
892 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
893 return E_NOTIMPL;
896 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
898 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
899 nsAString charset_str;
900 nsresult nsres;
902 TRACE("(%p)->(%p)\n", This, p);
904 if(!This->doc_node->nsdoc) {
905 FIXME("NULL nsdoc\n");
906 return E_FAIL;
909 nsAString_Init(&charset_str, NULL);
910 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
911 return return_nsstr(nsres, &charset_str, p);
914 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
916 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
917 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
918 return E_NOTIMPL;
921 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
923 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
925 TRACE("(%p)->(%p)\n", This, p);
927 *p = charset_string_from_cp(GetACP());
928 return *p ? S_OK : E_OUTOFMEMORY;
931 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
933 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
934 FIXME("(%p)->(%p)\n", This, p);
935 return E_NOTIMPL;
938 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
940 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
941 FIXME("(%p)->(%p)\n", This, p);
942 return E_NOTIMPL;
945 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
947 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
948 FIXME("(%p)->(%p)\n", This, p);
949 return E_NOTIMPL;
952 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
954 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
955 FIXME("(%p)->(%p)\n", This, p);
956 return E_NOTIMPL;
959 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
961 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
962 FIXME("(%p)->(%p)\n", This, p);
963 return E_NOTIMPL;
966 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
968 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
969 FIXME("(%p)->(%p)\n", This, p);
970 return E_NOTIMPL;
973 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
975 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
976 FIXME("(%p)->(%p)\n", This, p);
977 return E_NOTIMPL;
980 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
982 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
983 FIXME("(%p)->(%p)\n", This, p);
984 return E_NOTIMPL;
987 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
989 VARIANT *var, tmp;
990 JSContext *jsctx;
991 nsAString nsstr;
992 ULONG i, argc;
993 nsresult nsres;
994 HRESULT hres;
996 if(!This->doc_node->nsdoc) {
997 WARN("NULL nsdoc\n");
998 return E_UNEXPECTED;
1001 if (!psarray)
1002 return S_OK;
1004 if(psarray->cDims != 1) {
1005 FIXME("cDims=%d\n", psarray->cDims);
1006 return E_INVALIDARG;
1009 hres = SafeArrayAccessData(psarray, (void**)&var);
1010 if(FAILED(hres)) {
1011 WARN("SafeArrayAccessData failed: %08x\n", hres);
1012 return hres;
1015 V_VT(&tmp) = VT_EMPTY;
1017 jsctx = get_context_from_document(This->doc_node->nsdoc);
1018 argc = psarray->rgsabound[0].cElements;
1019 for(i=0; i < argc; i++) {
1020 if(V_VT(var+i) == VT_BSTR) {
1021 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1022 }else {
1023 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1024 if(FAILED(hres)) {
1025 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1026 break;
1028 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1031 if(!ln || i != argc-1)
1032 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1033 else
1034 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1035 nsAString_Finish(&nsstr);
1036 if(V_VT(var+i) != VT_BSTR)
1037 VariantClear(&tmp);
1038 if(NS_FAILED(nsres)) {
1039 ERR("Write failed: %08x\n", nsres);
1040 hres = E_FAIL;
1041 break;
1045 SafeArrayUnaccessData(psarray);
1047 return hres;
1050 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1052 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1054 TRACE("(%p)->(%p)\n", iface, psarray);
1056 return document_write(This, psarray, FALSE);
1059 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1061 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1063 TRACE("(%p)->(%p)\n", This, psarray);
1065 return document_write(This, psarray, TRUE);
1068 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1069 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1071 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1072 nsISupports *tmp;
1073 nsresult nsres;
1075 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
1077 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1078 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1080 if(!This->doc_node->nsdoc) {
1081 ERR("!nsdoc\n");
1082 return E_NOTIMPL;
1085 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
1086 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1087 FIXME("unsupported args\n");
1089 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1090 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1091 if(NS_FAILED(nsres)) {
1092 ERR("Open failed: %08x\n", nsres);
1093 return E_FAIL;
1096 if(tmp)
1097 nsISupports_Release(tmp);
1099 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1100 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1101 return S_OK;
1104 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1106 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1107 nsresult nsres;
1109 TRACE("(%p)\n", This);
1111 if(!This->doc_node->nsdoc) {
1112 ERR("!nsdoc\n");
1113 return E_NOTIMPL;
1116 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1117 if(NS_FAILED(nsres)) {
1118 ERR("Close failed: %08x\n", nsres);
1119 return E_FAIL;
1122 return S_OK;
1125 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1127 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1128 nsresult nsres;
1130 TRACE("(%p)\n", This);
1132 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1133 if(NS_FAILED(nsres)) {
1134 ERR("Clear failed: %08x\n", nsres);
1135 return E_FAIL;
1138 return S_OK;
1141 static const WCHAR copyW[] =
1142 {'c','o','p','y',0};
1143 static const WCHAR cutW[] =
1144 {'c','u','t',0};
1145 static const WCHAR fontnameW[] =
1146 {'f','o','n','t','n','a','m','e',0};
1147 static const WCHAR fontsizeW[] =
1148 {'f','o','n','t','s','i','z','e',0};
1149 static const WCHAR indentW[] =
1150 {'i','n','d','e','n','t',0};
1151 static const WCHAR insertorderedlistW[] =
1152 {'i','n','s','e','r','t','o','r','d','e','r','e','d','l','i','s','t',0};
1153 static const WCHAR insertunorderedlistW[] =
1154 {'i','n','s','e','r','t','u','n','o','r','d','e','r','e','d','l','i','s','t',0};
1155 static const WCHAR outdentW[] =
1156 {'o','u','t','d','e','n','t',0};
1157 static const WCHAR pasteW[] =
1158 {'p','a','s','t','e',0};
1159 static const WCHAR respectvisibilityindesignW[] =
1160 {'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};
1162 static const struct {
1163 const WCHAR *name;
1164 OLECMDID id;
1165 }command_names[] = {
1166 {copyW, IDM_COPY},
1167 {cutW, IDM_CUT},
1168 {fontnameW, IDM_FONTNAME},
1169 {fontsizeW, IDM_FONTSIZE},
1170 {indentW, IDM_INDENT},
1171 {insertorderedlistW, IDM_ORDERLIST},
1172 {insertunorderedlistW, IDM_UNORDERLIST},
1173 {outdentW, IDM_OUTDENT},
1174 {pasteW, IDM_PASTE},
1175 {respectvisibilityindesignW, IDM_RESPECTVISIBILITY_INDESIGN}
1178 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1180 int i;
1182 for(i = 0; i < sizeof(command_names)/sizeof(*command_names); i++) {
1183 if(!strcmpiW(command_names[i].name, str)) {
1184 *cmdid = command_names[i].id;
1185 return TRUE;
1189 FIXME("Unknown command %s\n", debugstr_w(str));
1190 return FALSE;
1193 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1194 VARIANT_BOOL *pfRet)
1196 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1197 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1198 return E_NOTIMPL;
1201 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1202 VARIANT_BOOL *pfRet)
1204 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1205 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1206 return E_NOTIMPL;
1209 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1210 VARIANT_BOOL *pfRet)
1212 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1213 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1214 return E_NOTIMPL;
1217 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1218 VARIANT_BOOL *pfRet)
1220 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1221 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1222 return E_NOTIMPL;
1225 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1226 BSTR *pfRet)
1228 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1229 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1230 return E_NOTIMPL;
1233 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1234 VARIANT *pfRet)
1236 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1237 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1238 return E_NOTIMPL;
1241 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1242 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1244 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1245 OLECMDID cmdid;
1246 VARIANT ret;
1247 HRESULT hres;
1249 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1251 if(!cmdid_from_string(cmdID, &cmdid))
1252 return OLECMDERR_E_NOTSUPPORTED;
1254 V_VT(&ret) = VT_EMPTY;
1255 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1256 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1257 if(FAILED(hres))
1258 return hres;
1260 if(V_VT(&ret) != VT_EMPTY) {
1261 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1262 VariantClear(&ret);
1265 *pfRet = VARIANT_TRUE;
1266 return S_OK;
1269 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1270 VARIANT_BOOL *pfRet)
1272 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1273 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1274 return E_NOTIMPL;
1277 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1278 IHTMLElement **newElem)
1280 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1281 HTMLElement *elem;
1282 HRESULT hres;
1284 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1286 hres = create_element(This->doc_node, eTag, &elem);
1287 if(FAILED(hres))
1288 return hres;
1290 *newElem = &elem->IHTMLElement_iface;
1291 return S_OK;
1294 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1296 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1297 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1298 return E_NOTIMPL;
1301 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1303 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1304 FIXME("(%p)->(%p)\n", This, p);
1305 return E_NOTIMPL;
1308 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1310 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1312 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1314 return set_doc_event(This, EVENTID_CLICK, &v);
1317 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1319 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1321 TRACE("(%p)->(%p)\n", This, p);
1323 return get_doc_event(This, EVENTID_CLICK, p);
1326 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1328 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1330 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1332 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1335 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1337 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1339 TRACE("(%p)->(%p)\n", This, p);
1341 return get_doc_event(This, EVENTID_DBLCLICK, p);
1344 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1346 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1348 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1350 return set_doc_event(This, EVENTID_KEYUP, &v);
1353 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1355 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1357 TRACE("(%p)->(%p)\n", This, p);
1359 return get_doc_event(This, EVENTID_KEYUP, p);
1362 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1364 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1366 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1368 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1371 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1373 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1375 TRACE("(%p)->(%p)\n", This, p);
1377 return get_doc_event(This, EVENTID_KEYDOWN, p);
1380 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1382 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1384 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1386 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1389 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1391 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1393 TRACE("(%p)->(%p)\n", This, p);
1395 return get_doc_event(This, EVENTID_KEYPRESS, p);
1398 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1400 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1402 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1404 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1407 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1409 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1411 TRACE("(%p)->(%p)\n", This, p);
1413 return get_doc_event(This, EVENTID_MOUSEUP, p);
1416 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1418 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1420 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1422 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1425 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1427 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1429 TRACE("(%p)->(%p)\n", This, p);
1431 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1434 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1436 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1438 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1440 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1443 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1445 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1447 TRACE("(%p)->(%p)\n", This, p);
1449 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1452 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1454 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1456 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1458 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1461 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1463 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1465 TRACE("(%p)->(%p)\n", This, p);
1467 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1470 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1472 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1474 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1476 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1479 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1481 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1483 TRACE("(%p)->(%p)\n", This, p);
1485 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1488 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1490 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1492 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1494 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1497 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1499 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1501 TRACE("(%p)->(%p)\n", This, p);
1503 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1506 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1508 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1509 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1510 return E_NOTIMPL;
1513 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1515 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1516 FIXME("(%p)->(%p)\n", This, p);
1517 return E_NOTIMPL;
1520 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1522 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1523 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1524 return E_NOTIMPL;
1527 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1529 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1530 FIXME("(%p)->(%p)\n", This, p);
1531 return E_NOTIMPL;
1534 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1536 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1537 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1538 return E_NOTIMPL;
1541 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1543 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1544 FIXME("(%p)->(%p)\n", This, p);
1545 return E_NOTIMPL;
1548 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1550 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1552 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1554 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1557 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1559 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1561 TRACE("(%p)->(%p)\n", This, p);
1563 return get_doc_event(This, EVENTID_DRAGSTART, p);
1566 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1568 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1570 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1572 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1575 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1577 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1579 TRACE("(%p)->(%p)\n", This, p);
1581 return get_doc_event(This, EVENTID_SELECTSTART, p);
1584 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1585 IHTMLElement **elementHit)
1587 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1588 nsIDOMElement *nselem;
1589 HTMLDOMNode *node;
1590 nsresult nsres;
1591 HRESULT hres;
1593 TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1595 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1596 if(NS_FAILED(nsres)) {
1597 ERR("ElementFromPoint failed: %08x\n", nsres);
1598 return E_FAIL;
1601 if(!nselem) {
1602 *elementHit = NULL;
1603 return S_OK;
1606 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
1607 nsIDOMElement_Release(nselem);
1608 if(FAILED(hres))
1609 return hres;
1611 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)elementHit);
1612 node_release(node);
1613 return hres;
1616 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1618 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1620 TRACE("(%p)->(%p)\n", This, p);
1622 *p = &This->window->base.IHTMLWindow2_iface;
1623 IHTMLWindow2_AddRef(*p);
1624 return S_OK;
1627 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1628 IHTMLStyleSheetsCollection **p)
1630 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1631 nsIDOMStyleSheetList *nsstylelist;
1632 nsresult nsres;
1634 TRACE("(%p)->(%p)\n", This, p);
1636 *p = NULL;
1638 if(!This->doc_node->nsdoc) {
1639 WARN("NULL nsdoc\n");
1640 return E_UNEXPECTED;
1643 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1644 if(NS_FAILED(nsres)) {
1645 ERR("GetStyleSheets failed: %08x\n", nsres);
1646 return E_FAIL;
1649 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1650 nsIDOMStyleSheetList_Release(nsstylelist);
1652 return S_OK;
1655 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1657 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1658 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1659 return E_NOTIMPL;
1662 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1664 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1665 FIXME("(%p)->(%p)\n", This, p);
1666 return E_NOTIMPL;
1669 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1671 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1672 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1673 return E_NOTIMPL;
1676 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1678 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1679 FIXME("(%p)->(%p)\n", This, p);
1680 return E_NOTIMPL;
1683 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1685 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1687 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1689 TRACE("(%p)->(%p)\n", This, String);
1691 if(!String)
1692 return E_INVALIDARG;
1694 *String = SysAllocString(objectW);
1695 return *String ? S_OK : E_OUTOFMEMORY;
1699 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1700 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1702 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1703 nsIDOMHTMLHeadElement *head_elem;
1704 IHTMLStyleElement *style_elem;
1705 HTMLElement *elem;
1706 nsresult nsres;
1707 HRESULT hres;
1709 static const WCHAR styleW[] = {'s','t','y','l','e',0};
1711 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1713 if(!This->doc_node->nsdoc) {
1714 FIXME("not a real doc object\n");
1715 return E_NOTIMPL;
1718 if(lIndex != -1)
1719 FIXME("Unsupported lIndex %d\n", lIndex);
1721 if(bstrHref && *bstrHref) {
1722 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
1723 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1724 return S_OK;
1727 hres = create_element(This->doc_node, styleW, &elem);
1728 if(FAILED(hres))
1729 return hres;
1731 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
1732 if(NS_SUCCEEDED(nsres)) {
1733 nsIDOMNode *head_node, *tmp_node;
1735 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
1736 nsIDOMHTMLHeadElement_Release(head_elem);
1737 assert(nsres == NS_OK);
1739 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
1740 nsIDOMNode_Release(head_node);
1741 if(NS_SUCCEEDED(nsres) && tmp_node)
1742 nsIDOMNode_Release(tmp_node);
1744 if(NS_FAILED(nsres)) {
1745 IHTMLElement_Release(&elem->IHTMLElement_iface);
1746 return E_FAIL;
1749 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
1750 assert(hres == S_OK);
1751 IHTMLElement_Release(&elem->IHTMLElement_iface);
1753 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
1754 IHTMLStyleElement_Release(style_elem);
1755 return hres;
1758 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1759 HTMLDocument_QueryInterface,
1760 HTMLDocument_AddRef,
1761 HTMLDocument_Release,
1762 HTMLDocument_GetTypeInfoCount,
1763 HTMLDocument_GetTypeInfo,
1764 HTMLDocument_GetIDsOfNames,
1765 HTMLDocument_Invoke,
1766 HTMLDocument_get_Script,
1767 HTMLDocument_get_all,
1768 HTMLDocument_get_body,
1769 HTMLDocument_get_activeElement,
1770 HTMLDocument_get_images,
1771 HTMLDocument_get_applets,
1772 HTMLDocument_get_links,
1773 HTMLDocument_get_forms,
1774 HTMLDocument_get_anchors,
1775 HTMLDocument_put_title,
1776 HTMLDocument_get_title,
1777 HTMLDocument_get_scripts,
1778 HTMLDocument_put_designMode,
1779 HTMLDocument_get_designMode,
1780 HTMLDocument_get_selection,
1781 HTMLDocument_get_readyState,
1782 HTMLDocument_get_frames,
1783 HTMLDocument_get_embeds,
1784 HTMLDocument_get_plugins,
1785 HTMLDocument_put_alinkColor,
1786 HTMLDocument_get_alinkColor,
1787 HTMLDocument_put_bgColor,
1788 HTMLDocument_get_bgColor,
1789 HTMLDocument_put_fgColor,
1790 HTMLDocument_get_fgColor,
1791 HTMLDocument_put_linkColor,
1792 HTMLDocument_get_linkColor,
1793 HTMLDocument_put_vlinkColor,
1794 HTMLDocument_get_vlinkColor,
1795 HTMLDocument_get_referrer,
1796 HTMLDocument_get_location,
1797 HTMLDocument_get_lastModified,
1798 HTMLDocument_put_URL,
1799 HTMLDocument_get_URL,
1800 HTMLDocument_put_domain,
1801 HTMLDocument_get_domain,
1802 HTMLDocument_put_cookie,
1803 HTMLDocument_get_cookie,
1804 HTMLDocument_put_expando,
1805 HTMLDocument_get_expando,
1806 HTMLDocument_put_charset,
1807 HTMLDocument_get_charset,
1808 HTMLDocument_put_defaultCharset,
1809 HTMLDocument_get_defaultCharset,
1810 HTMLDocument_get_mimeType,
1811 HTMLDocument_get_fileSize,
1812 HTMLDocument_get_fileCreatedDate,
1813 HTMLDocument_get_fileModifiedDate,
1814 HTMLDocument_get_fileUpdatedDate,
1815 HTMLDocument_get_security,
1816 HTMLDocument_get_protocol,
1817 HTMLDocument_get_nameProp,
1818 HTMLDocument_write,
1819 HTMLDocument_writeln,
1820 HTMLDocument_open,
1821 HTMLDocument_close,
1822 HTMLDocument_clear,
1823 HTMLDocument_queryCommandSupported,
1824 HTMLDocument_queryCommandEnabled,
1825 HTMLDocument_queryCommandState,
1826 HTMLDocument_queryCommandIndeterm,
1827 HTMLDocument_queryCommandText,
1828 HTMLDocument_queryCommandValue,
1829 HTMLDocument_execCommand,
1830 HTMLDocument_execCommandShowHelp,
1831 HTMLDocument_createElement,
1832 HTMLDocument_put_onhelp,
1833 HTMLDocument_get_onhelp,
1834 HTMLDocument_put_onclick,
1835 HTMLDocument_get_onclick,
1836 HTMLDocument_put_ondblclick,
1837 HTMLDocument_get_ondblclick,
1838 HTMLDocument_put_onkeyup,
1839 HTMLDocument_get_onkeyup,
1840 HTMLDocument_put_onkeydown,
1841 HTMLDocument_get_onkeydown,
1842 HTMLDocument_put_onkeypress,
1843 HTMLDocument_get_onkeypress,
1844 HTMLDocument_put_onmouseup,
1845 HTMLDocument_get_onmouseup,
1846 HTMLDocument_put_onmousedown,
1847 HTMLDocument_get_onmousedown,
1848 HTMLDocument_put_onmousemove,
1849 HTMLDocument_get_onmousemove,
1850 HTMLDocument_put_onmouseout,
1851 HTMLDocument_get_onmouseout,
1852 HTMLDocument_put_onmouseover,
1853 HTMLDocument_get_onmouseover,
1854 HTMLDocument_put_onreadystatechange,
1855 HTMLDocument_get_onreadystatechange,
1856 HTMLDocument_put_onafterupdate,
1857 HTMLDocument_get_onafterupdate,
1858 HTMLDocument_put_onrowexit,
1859 HTMLDocument_get_onrowexit,
1860 HTMLDocument_put_onrowenter,
1861 HTMLDocument_get_onrowenter,
1862 HTMLDocument_put_ondragstart,
1863 HTMLDocument_get_ondragstart,
1864 HTMLDocument_put_onselectstart,
1865 HTMLDocument_get_onselectstart,
1866 HTMLDocument_elementFromPoint,
1867 HTMLDocument_get_parentWindow,
1868 HTMLDocument_get_styleSheets,
1869 HTMLDocument_put_onbeforeupdate,
1870 HTMLDocument_get_onbeforeupdate,
1871 HTMLDocument_put_onerrorupdate,
1872 HTMLDocument_get_onerrorupdate,
1873 HTMLDocument_toString,
1874 HTMLDocument_createStyleSheet
1877 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
1879 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
1882 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
1883 REFIID riid, void **ppv)
1885 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1886 return htmldoc_query_interface(This, riid, ppv);
1889 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
1891 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1892 return htmldoc_addref(This);
1895 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
1897 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1898 return htmldoc_release(This);
1901 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
1903 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1904 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1907 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
1908 LCID lcid, ITypeInfo **ppTInfo)
1910 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1911 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1914 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
1915 LPOLESTR *rgszNames, UINT cNames,
1916 LCID lcid, DISPID *rgDispId)
1918 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1919 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1920 rgDispId);
1923 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
1924 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1925 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1927 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1928 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1929 pDispParams, pVarResult, pExcepInfo, puArgErr);
1932 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
1934 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1935 FIXME("(%p)\n", This);
1936 return E_NOTIMPL;
1939 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
1941 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1943 WARN("(%p)->(%x)\n", This, fForce);
1945 /* Doing nothing here should be fine for us. */
1946 return S_OK;
1949 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
1950 IHTMLDOMNode **newTextNode)
1952 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1953 nsIDOMText *nstext;
1954 HTMLDOMNode *node;
1955 nsAString text_str;
1956 nsresult nsres;
1957 HRESULT hres;
1959 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
1961 if(!This->doc_node->nsdoc) {
1962 WARN("NULL nsdoc\n");
1963 return E_UNEXPECTED;
1966 nsAString_InitDepend(&text_str, text);
1967 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
1968 nsAString_Finish(&text_str);
1969 if(NS_FAILED(nsres)) {
1970 ERR("CreateTextNode failed: %08x\n", nsres);
1971 return E_FAIL;
1974 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
1975 nsIDOMText_Release(nstext);
1976 if(FAILED(hres))
1977 return hres;
1979 *newTextNode = &node->IHTMLDOMNode_iface;
1980 return S_OK;
1983 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
1985 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1986 nsIDOMElement *nselem = NULL;
1987 HTMLDOMNode *node;
1988 nsresult nsres;
1989 HRESULT hres;
1991 TRACE("(%p)->(%p)\n", This, p);
1993 if(This->window->readystate == READYSTATE_UNINITIALIZED) {
1994 *p = NULL;
1995 return S_OK;
1998 if(!This->doc_node->nsdoc) {
1999 WARN("NULL nsdoc\n");
2000 return E_UNEXPECTED;
2003 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
2004 if(NS_FAILED(nsres)) {
2005 ERR("GetDocumentElement failed: %08x\n", nsres);
2006 return E_FAIL;
2009 if(!nselem) {
2010 *p = NULL;
2011 return S_OK;
2014 hres = get_node(This->doc_node, (nsIDOMNode *)nselem, TRUE, &node);
2015 nsIDOMElement_Release(nselem);
2016 if(FAILED(hres))
2017 return hres;
2019 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
2020 node_release(node);
2021 return hres;
2024 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2026 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2028 TRACE("(%p)->(%p)\n", This, p);
2030 return elem_unique_id(++This->doc_node->unique_id, p);
2033 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2034 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2036 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2038 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2040 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2043 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2044 IDispatch *pDisp)
2046 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2048 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2050 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2053 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2055 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2056 FIXME("(%p)->()\n", This);
2057 return E_NOTIMPL;
2060 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2062 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2063 FIXME("(%p)->(%p)\n", This, p);
2064 return E_NOTIMPL;
2067 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2069 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2070 FIXME("(%p)->()\n", This);
2071 return E_NOTIMPL;
2074 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2076 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2077 FIXME("(%p)->(%p)\n", This, p);
2078 return E_NOTIMPL;
2081 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2083 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2084 FIXME("(%p)->()\n", This);
2085 return E_NOTIMPL;
2088 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2090 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2091 FIXME("(%p)->(%p)\n", This, p);
2092 return E_NOTIMPL;
2095 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2097 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2098 FIXME("(%p)->()\n", This);
2099 return E_NOTIMPL;
2102 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2104 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2105 FIXME("(%p)->(%p)\n", This, p);
2106 return E_NOTIMPL;
2109 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2111 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2112 FIXME("(%p)->()\n", This);
2113 return E_NOTIMPL;
2116 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2118 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2119 FIXME("(%p)->(%p)\n", This, p);
2120 return E_NOTIMPL;
2123 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2125 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2126 FIXME("(%p)->()\n", This);
2127 return E_NOTIMPL;
2130 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2132 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2133 FIXME("(%p)->(%p)\n", This, p);
2134 return E_NOTIMPL;
2137 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2139 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2140 FIXME("(%p)->()\n", This);
2141 return E_NOTIMPL;
2144 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2146 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2147 FIXME("(%p)->(%p)\n", This, p);
2148 return E_NOTIMPL;
2151 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2153 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2154 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2155 return E_NOTIMPL;
2158 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2160 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2161 FIXME("(%p)->(%p)\n", This, p);
2162 return E_NOTIMPL;
2165 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2167 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2169 TRACE("(%p)->()\n", This);
2171 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2174 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2176 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2178 TRACE("(%p)->(%p)\n", This, p);
2180 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2183 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2185 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2186 FIXME("(%p)->()\n", This);
2187 return E_NOTIMPL;
2190 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2192 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2193 FIXME("(%p)->(%p)\n", This, p);
2194 return E_NOTIMPL;
2197 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2198 IHTMLDocument2 **ppNewDoc)
2200 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2201 nsIDOMDocumentFragment *doc_frag;
2202 HTMLDocumentNode *docnode;
2203 nsresult nsres;
2204 HRESULT hres;
2206 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2208 if(!This->doc_node->nsdoc) {
2209 FIXME("NULL nsdoc\n");
2210 return E_NOTIMPL;
2213 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2214 if(NS_FAILED(nsres)) {
2215 ERR("CreateDocumentFragment failed: %08x\n", nsres);
2216 return E_FAIL;
2219 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2220 nsIDOMDocumentFragment_Release(doc_frag);
2221 if(FAILED(hres))
2222 return hres;
2224 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2225 return S_OK;
2228 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2229 IHTMLDocument2 **p)
2231 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2232 FIXME("(%p)->(%p)\n", This, p);
2233 return E_NOTIMPL;
2236 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2237 VARIANT_BOOL v)
2239 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2240 FIXME("(%p)->(%x)\n", This, v);
2241 return E_NOTIMPL;
2244 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2245 VARIANT_BOOL *p)
2247 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2248 FIXME("(%p)->(%p)\n", This, p);
2249 return E_NOTIMPL;
2252 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2254 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2255 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2256 return E_NOTIMPL;
2259 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2261 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2262 FIXME("(%p)->(%p)\n", This, p);
2263 return E_NOTIMPL;
2266 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2268 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2270 TRACE("(%p)->(%p)\n", This, p);
2272 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2275 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2276 VARIANT_BOOL v)
2278 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2279 FIXME("(%p)->()\n", This);
2280 return E_NOTIMPL;
2283 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2284 VARIANT_BOOL *p)
2286 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2287 FIXME("(%p)->(%p)\n", This, p);
2288 return E_NOTIMPL;
2291 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2293 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2294 FIXME("(%p)->()\n", This);
2295 return E_NOTIMPL;
2298 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2300 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2301 FIXME("(%p)->(%p)\n", This, p);
2302 return E_NOTIMPL;
2305 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2306 IHTMLElementCollection **ppelColl)
2308 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2309 nsIDOMNodeList *node_list;
2310 nsAString selector_str;
2311 WCHAR *selector;
2312 nsresult nsres;
2314 static const WCHAR formatW[] = {'*','[','i','d','=','%','s',']',',','*','[','n','a','m','e','=','%','s',']',0};
2316 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2318 if(!This->doc_node || !This->doc_node->nsdoc) {
2319 /* We should probably return an empty collection. */
2320 FIXME("No nsdoc\n");
2321 return E_NOTIMPL;
2324 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2325 if(!selector)
2326 return E_OUTOFMEMORY;
2327 sprintfW(selector, formatW, v, v);
2330 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2331 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2332 * types and search should be case insensitive. Those are currently not supported properly.
2334 nsAString_InitDepend(&selector_str, selector);
2335 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2336 nsAString_Finish(&selector_str);
2337 heap_free(selector);
2338 if(NS_FAILED(nsres)) {
2339 ERR("QuerySelectorAll failed: %08x\n", nsres);
2340 return E_FAIL;
2343 *ppelColl = create_collection_from_nodelist(This->doc_node, node_list);
2344 nsIDOMNodeList_Release(node_list);
2345 return S_OK;
2349 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2350 IHTMLElement **pel)
2352 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2353 HTMLElement *elem;
2354 HRESULT hres;
2356 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2358 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2359 if(FAILED(hres) || !elem) {
2360 *pel = NULL;
2361 return hres;
2364 *pel = &elem->IHTMLElement_iface;
2365 return S_OK;
2369 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2370 IHTMLElementCollection **pelColl)
2372 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2373 nsIDOMNodeList *nslist;
2374 nsAString id_str;
2375 nsresult nsres;
2377 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2379 if(This->doc_node->nsdoc) {
2380 nsAString_InitDepend(&id_str, v);
2381 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2382 nsAString_Finish(&id_str);
2383 if(FAILED(nsres)) {
2384 ERR("GetElementByName failed: %08x\n", nsres);
2385 return E_FAIL;
2387 }else {
2388 nsIDOMDocumentFragment *docfrag;
2389 nsAString nsstr;
2391 if(v) {
2392 const WCHAR *ptr;
2393 for(ptr=v; *ptr; ptr++) {
2394 if(!isalnumW(*ptr)) {
2395 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2396 return E_NOTIMPL;
2401 nsres = nsIDOMNode_QueryInterface(This->doc_node->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2402 if(NS_FAILED(nsres)) {
2403 ERR("Could not get nsIDOMDocumentFragment iface: %08x\n", nsres);
2404 return E_UNEXPECTED;
2407 nsAString_InitDepend(&nsstr, v);
2408 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2409 nsAString_Finish(&nsstr);
2410 nsIDOMDocumentFragment_Release(docfrag);
2411 if(NS_FAILED(nsres)) {
2412 ERR("QuerySelectorAll failed: %08x\n", nsres);
2413 return E_FAIL;
2418 *pelColl = create_collection_from_nodelist(This->doc_node, nslist);
2419 nsIDOMNodeList_Release(nslist);
2421 return S_OK;
2424 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2425 HTMLDocument3_QueryInterface,
2426 HTMLDocument3_AddRef,
2427 HTMLDocument3_Release,
2428 HTMLDocument3_GetTypeInfoCount,
2429 HTMLDocument3_GetTypeInfo,
2430 HTMLDocument3_GetIDsOfNames,
2431 HTMLDocument3_Invoke,
2432 HTMLDocument3_releaseCapture,
2433 HTMLDocument3_recalc,
2434 HTMLDocument3_createTextNode,
2435 HTMLDocument3_get_documentElement,
2436 HTMLDocument3_get_uniqueID,
2437 HTMLDocument3_attachEvent,
2438 HTMLDocument3_detachEvent,
2439 HTMLDocument3_put_onrowsdelete,
2440 HTMLDocument3_get_onrowsdelete,
2441 HTMLDocument3_put_onrowsinserted,
2442 HTMLDocument3_get_onrowsinserted,
2443 HTMLDocument3_put_oncellchange,
2444 HTMLDocument3_get_oncellchange,
2445 HTMLDocument3_put_ondatasetchanged,
2446 HTMLDocument3_get_ondatasetchanged,
2447 HTMLDocument3_put_ondataavailable,
2448 HTMLDocument3_get_ondataavailable,
2449 HTMLDocument3_put_ondatasetcomplete,
2450 HTMLDocument3_get_ondatasetcomplete,
2451 HTMLDocument3_put_onpropertychange,
2452 HTMLDocument3_get_onpropertychange,
2453 HTMLDocument3_put_dir,
2454 HTMLDocument3_get_dir,
2455 HTMLDocument3_put_oncontextmenu,
2456 HTMLDocument3_get_oncontextmenu,
2457 HTMLDocument3_put_onstop,
2458 HTMLDocument3_get_onstop,
2459 HTMLDocument3_createDocumentFragment,
2460 HTMLDocument3_get_parentDocument,
2461 HTMLDocument3_put_enableDownload,
2462 HTMLDocument3_get_enableDownload,
2463 HTMLDocument3_put_baseUrl,
2464 HTMLDocument3_get_baseUrl,
2465 HTMLDocument3_get_childNodes,
2466 HTMLDocument3_put_inheritStyleSheets,
2467 HTMLDocument3_get_inheritStyleSheets,
2468 HTMLDocument3_put_onbeforeeditfocus,
2469 HTMLDocument3_get_onbeforeeditfocus,
2470 HTMLDocument3_getElementsByName,
2471 HTMLDocument3_getElementById,
2472 HTMLDocument3_getElementsByTagName
2475 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2477 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2480 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2481 REFIID riid, void **ppv)
2483 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2484 return htmldoc_query_interface(This, riid, ppv);
2487 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2489 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2490 return htmldoc_addref(This);
2493 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2495 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2496 return htmldoc_release(This);
2499 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2501 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2502 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2505 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2506 LCID lcid, ITypeInfo **ppTInfo)
2508 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2509 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2512 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2513 LPOLESTR *rgszNames, UINT cNames,
2514 LCID lcid, DISPID *rgDispId)
2516 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2517 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2518 rgDispId);
2521 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2522 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2523 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2525 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2526 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2527 pDispParams, pVarResult, pExcepInfo, puArgErr);
2530 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2532 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2533 nsIDOMHTMLElement *nsbody;
2534 nsresult nsres;
2536 TRACE("(%p)->()\n", This);
2538 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2539 if(NS_FAILED(nsres) || !nsbody) {
2540 ERR("GetBody failed: %08x\n", nsres);
2541 return E_FAIL;
2544 nsres = nsIDOMHTMLElement_Focus(nsbody);
2545 nsIDOMHTMLElement_Release(nsbody);
2546 if(NS_FAILED(nsres)) {
2547 ERR("Focus failed: %08x\n", nsres);
2548 return E_FAIL;
2551 return S_OK;
2554 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2556 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2557 cpp_bool has_focus;
2558 nsresult nsres;
2560 TRACE("(%p)->(%p)\n", This, pfFocus);
2562 if(!This->doc_node->nsdoc) {
2563 FIXME("Unimplemented for fragments.\n");
2564 return E_NOTIMPL;
2567 nsres = nsIDOMHTMLDocument_HasFocus(This->doc_node->nsdoc, &has_focus);
2568 assert(nsres == NS_OK);
2570 *pfFocus = has_focus ? VARIANT_TRUE : VARIANT_FALSE;
2571 return S_OK;
2574 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2576 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2577 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2578 return E_NOTIMPL;
2581 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2583 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2584 FIXME("(%p)->(%p)\n", This, p);
2585 return E_NOTIMPL;
2588 static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
2590 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2591 FIXME("(%p)->(%p)\n", This, p);
2592 return E_NOTIMPL;
2595 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2596 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2598 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2599 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2600 return E_NOTIMPL;
2603 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2605 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2606 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2607 return E_NOTIMPL;
2610 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2612 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2613 FIXME("(%p)->(%p)\n", This, p);
2614 return E_NOTIMPL;
2617 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2618 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2620 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2622 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2624 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2625 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2626 return E_NOTIMPL;
2629 return create_event_obj(ppEventObj);
2632 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2633 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2635 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2637 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2639 return dispatch_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2642 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2643 IHTMLRenderStyle **ppIHTMLRenderStyle)
2645 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2646 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2647 return E_NOTIMPL;
2650 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2652 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2653 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2654 return E_NOTIMPL;
2657 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2659 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2660 FIXME("(%p)->(%p)\n", This, p);
2661 return E_NOTIMPL;
2664 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2666 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2667 FIXME("(%p)->(%p)\n", This, p);
2668 return E_NOTIMPL;
2671 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2672 HTMLDocument4_QueryInterface,
2673 HTMLDocument4_AddRef,
2674 HTMLDocument4_Release,
2675 HTMLDocument4_GetTypeInfoCount,
2676 HTMLDocument4_GetTypeInfo,
2677 HTMLDocument4_GetIDsOfNames,
2678 HTMLDocument4_Invoke,
2679 HTMLDocument4_focus,
2680 HTMLDocument4_hasFocus,
2681 HTMLDocument4_put_onselectionchange,
2682 HTMLDocument4_get_onselectionchange,
2683 HTMLDocument4_get_namespace,
2684 HTMLDocument4_createDocumentFromUrl,
2685 HTMLDocument4_put_media,
2686 HTMLDocument4_get_media,
2687 HTMLDocument4_createEventObject,
2688 HTMLDocument4_fireEvent,
2689 HTMLDocument4_createRenderStyle,
2690 HTMLDocument4_put_oncontrolselect,
2691 HTMLDocument4_get_oncontrolselect,
2692 HTMLDocument4_get_URLEncoded
2695 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2697 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2700 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2701 REFIID riid, void **ppv)
2703 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2704 return htmldoc_query_interface(This, riid, ppv);
2707 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2709 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2710 return htmldoc_addref(This);
2713 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2715 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2716 return htmldoc_release(This);
2719 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2721 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2722 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2725 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2726 LCID lcid, ITypeInfo **ppTInfo)
2728 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2729 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2732 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2733 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2735 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2736 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2737 rgDispId);
2740 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2741 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2742 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2744 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2745 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2746 pDispParams, pVarResult, pExcepInfo, puArgErr);
2749 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2751 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2752 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2753 return E_NOTIMPL;
2756 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2758 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2759 FIXME("(%p)->(%p)\n", This, p);
2760 return E_NOTIMPL;
2763 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2765 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2766 FIXME("(%p)->(%p)\n", This, p);
2767 return E_NOTIMPL;
2770 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2772 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2773 HTMLDocumentNode *doc_node = This->doc_node;
2775 TRACE("(%p)->(%p)\n", This, p);
2777 if(!doc_node->dom_implementation) {
2778 HRESULT hres;
2780 hres = create_dom_implementation(&doc_node->dom_implementation);
2781 if(FAILED(hres))
2782 return hres;
2785 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2786 *p = doc_node->dom_implementation;
2787 return S_OK;
2790 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2791 IHTMLDOMAttribute **ppattribute)
2793 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2794 HTMLDOMAttribute *attr;
2795 HRESULT hres;
2797 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2799 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
2800 if(FAILED(hres))
2801 return hres;
2803 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2804 return S_OK;
2807 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2808 IHTMLDOMNode **ppRetNode)
2810 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2811 nsIDOMComment *nscomment;
2812 HTMLElement *elem;
2813 nsAString str;
2814 nsresult nsres;
2815 HRESULT hres;
2817 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2819 if(!This->doc_node->nsdoc) {
2820 WARN("NULL nsdoc\n");
2821 return E_UNEXPECTED;
2824 nsAString_InitDepend(&str, bstrdata);
2825 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2826 nsAString_Finish(&str);
2827 if(NS_FAILED(nsres)) {
2828 ERR("CreateTextNode failed: %08x\n", nsres);
2829 return E_FAIL;
2832 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2833 nsIDOMComment_Release(nscomment);
2834 if(FAILED(hres))
2835 return hres;
2837 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2838 return S_OK;
2841 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2843 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2844 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2845 return E_NOTIMPL;
2848 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2850 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2851 FIXME("(%p)->(%p)\n", This, p);
2852 return E_NOTIMPL;
2855 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2857 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2858 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2859 return E_NOTIMPL;
2862 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2864 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2865 FIXME("(%p)->(%p)\n", This, p);
2866 return E_NOTIMPL;
2869 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2871 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2872 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2873 return E_NOTIMPL;
2876 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2878 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2879 FIXME("(%p)->(%p)\n", This, p);
2880 return E_NOTIMPL;
2883 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2885 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2886 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2887 return E_NOTIMPL;
2890 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2892 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2893 FIXME("(%p)->(%p)\n", This, p);
2894 return E_NOTIMPL;
2897 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2899 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2900 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2901 return E_NOTIMPL;
2904 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2906 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2907 FIXME("(%p)->(%p)\n", This, p);
2908 return E_NOTIMPL;
2911 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2913 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2914 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2915 return E_NOTIMPL;
2918 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2920 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2921 FIXME("(%p)->(%p)\n", This, p);
2922 return E_NOTIMPL;
2925 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2927 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2928 nsAString mode_str;
2929 nsresult nsres;
2931 TRACE("(%p)->(%p)\n", This, p);
2933 if(!This->doc_node->nsdoc) {
2934 WARN("NULL nsdoc\n");
2935 return E_UNEXPECTED;
2938 nsAString_Init(&mode_str, NULL);
2939 nsres = nsIDOMHTMLDocument_GetCompatMode(This->doc_node->nsdoc, &mode_str);
2940 return return_nsstr(nsres, &mode_str, p);
2943 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
2944 HTMLDocument5_QueryInterface,
2945 HTMLDocument5_AddRef,
2946 HTMLDocument5_Release,
2947 HTMLDocument5_GetTypeInfoCount,
2948 HTMLDocument5_GetTypeInfo,
2949 HTMLDocument5_GetIDsOfNames,
2950 HTMLDocument5_Invoke,
2951 HTMLDocument5_put_onmousewheel,
2952 HTMLDocument5_get_onmousewheel,
2953 HTMLDocument5_get_doctype,
2954 HTMLDocument5_get_implementation,
2955 HTMLDocument5_createAttribute,
2956 HTMLDocument5_createComment,
2957 HTMLDocument5_put_onfocusin,
2958 HTMLDocument5_get_onfocusin,
2959 HTMLDocument5_put_onfocusout,
2960 HTMLDocument5_get_onfocusout,
2961 HTMLDocument5_put_onactivate,
2962 HTMLDocument5_get_onactivate,
2963 HTMLDocument5_put_ondeactivate,
2964 HTMLDocument5_get_ondeactivate,
2965 HTMLDocument5_put_onbeforeactivate,
2966 HTMLDocument5_get_onbeforeactivate,
2967 HTMLDocument5_put_onbeforedeactivate,
2968 HTMLDocument5_get_onbeforedeactivate,
2969 HTMLDocument5_get_compatMode
2972 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
2974 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
2977 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
2978 REFIID riid, void **ppv)
2980 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2981 return htmldoc_query_interface(This, riid, ppv);
2984 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
2986 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2987 return htmldoc_addref(This);
2990 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
2992 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2993 return htmldoc_release(This);
2996 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
2998 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2999 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3002 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
3003 LCID lcid, ITypeInfo **ppTInfo)
3005 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3006 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3009 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
3010 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3012 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3013 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3014 rgDispId);
3017 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
3018 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3019 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3021 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3022 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3023 pDispParams, pVarResult, pExcepInfo, puArgErr);
3026 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3027 IHTMLDocumentCompatibleInfoCollection **p)
3029 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3030 FIXME("(%p)->(%p)\n", This, p);
3031 return E_NOTIMPL;
3034 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface,
3035 VARIANT *p)
3037 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3038 FIXME("(%p)->(%p)\n", This, p);
3039 return E_NOTIMPL;
3042 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3043 VARIANT *p)
3045 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3046 FIXME("(%p)->(%p)\n", This, p);
3047 return E_NOTIMPL;
3050 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3052 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3053 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3054 return E_NOTIMPL;
3057 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3058 VARIANT *p)
3060 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3061 FIXME("(%p)->(%p)\n", This, p);
3062 return E_NOTIMPL;
3065 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3067 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3068 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3069 return E_NOTIMPL;
3072 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3073 BSTR bstrId, IHTMLElement2 **p)
3075 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3076 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3077 return E_NOTIMPL;
3080 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3082 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3083 FIXME("(%p)->()\n", This);
3084 return E_NOTIMPL;
3087 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3088 HTMLDocument6_QueryInterface,
3089 HTMLDocument6_AddRef,
3090 HTMLDocument6_Release,
3091 HTMLDocument6_GetTypeInfoCount,
3092 HTMLDocument6_GetTypeInfo,
3093 HTMLDocument6_GetIDsOfNames,
3094 HTMLDocument6_Invoke,
3095 HTMLDocument6_get_compatible,
3096 HTMLDocument6_get_documentMode,
3097 HTMLDocument6_put_onstorage,
3098 HTMLDocument6_get_onstorage,
3099 HTMLDocument6_put_onstoragecommit,
3100 HTMLDocument6_get_onstoragecommit,
3101 HTMLDocument6_getElementById,
3102 HTMLDocument6_updateSettings
3105 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3107 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3110 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3112 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3113 return htmldoc_query_interface(This, riid, ppv);
3116 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3118 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3119 return htmldoc_addref(This);
3122 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3124 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3125 return htmldoc_release(This);
3128 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3130 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3131 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3134 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3135 LCID lcid, ITypeInfo **ppTInfo)
3137 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3138 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3141 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3142 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3144 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3145 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3146 rgDispId);
3149 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3150 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3151 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3153 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3154 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3155 pDispParams, pVarResult, pExcepInfo, puArgErr);
3158 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3160 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3161 FIXME("(%p)->(%p)\n", This, p);
3162 return E_NOTIMPL;
3165 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3167 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3168 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3169 return E_NOTIMPL;
3172 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3174 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3175 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3176 return E_NOTIMPL;
3179 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3180 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3182 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3183 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3184 return E_NOTIMPL;
3187 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3189 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3190 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3191 return E_NOTIMPL;
3194 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3195 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3197 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3198 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3199 return E_NOTIMPL;
3202 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3204 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3205 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3206 return E_NOTIMPL;
3209 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3211 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3212 FIXME("(%p)->(%p)\n", This, p);
3213 return E_NOTIMPL;
3216 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3218 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3219 FIXME("(%p)->(%p)\n", This, p);
3220 return E_NOTIMPL;
3223 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3225 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3226 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3227 return E_NOTIMPL;
3230 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3232 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3233 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3234 return E_NOTIMPL;
3237 static HRESULT WINAPI HTMLDocument7_getElementByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3239 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3240 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3241 return E_NOTIMPL;
3244 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3245 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3247 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3248 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3249 return E_NOTIMPL;
3252 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3254 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3255 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3256 return E_NOTIMPL;
3259 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3261 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3262 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3263 return E_NOTIMPL;
3266 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3268 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3269 FIXME("(%p)->(%p)\n", This, p);
3270 return E_NOTIMPL;
3273 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3275 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3276 FIXME("(%p)->(%p)\n", This, p);
3277 return E_NOTIMPL;
3280 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3282 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3283 FIXME("(%p)->(%p)\n", This, p);
3284 return E_NOTIMPL;
3287 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3289 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3290 FIXME("(%p)->(%p)\n", This, p);
3291 return E_NOTIMPL;
3294 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3296 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3297 FIXME("(%p)->(%x)\n", This, v);
3298 return E_NOTIMPL;
3301 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3303 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3304 FIXME("(%p)->(%p)\n", This, p);
3305 return E_NOTIMPL;
3308 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3310 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3311 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3312 return E_NOTIMPL;
3315 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3317 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3318 FIXME("(%p)->(%p)\n", This, p);
3319 return E_NOTIMPL;
3322 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3324 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3325 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3326 return E_NOTIMPL;
3329 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3331 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3332 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3333 return E_NOTIMPL;
3336 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3338 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3339 FIXME("(%p)->(%p)\n", This, p);
3340 return E_NOTIMPL;
3343 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3345 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3346 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3347 return E_NOTIMPL;
3350 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3352 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3353 FIXME("(%p)->(%p)\n", This, p);
3354 return E_NOTIMPL;
3357 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3359 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3360 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3361 return E_NOTIMPL;
3364 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3366 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3367 FIXME("(%p)->(%p)\n", This, p);
3368 return E_NOTIMPL;
3371 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3373 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3374 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3375 return E_NOTIMPL;
3378 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3380 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3381 FIXME("(%p)->(%p)\n", This, p);
3382 return E_NOTIMPL;
3385 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3387 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3388 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3389 return E_NOTIMPL;
3392 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3394 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3395 FIXME("(%p)->(%p)\n", This, p);
3396 return E_NOTIMPL;
3399 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3401 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3402 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3403 return E_NOTIMPL;
3406 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3408 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3409 FIXME("(%p)->(%p)\n", This, p);
3410 return E_NOTIMPL;
3413 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3415 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3416 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3417 return E_NOTIMPL;
3420 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3422 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3423 FIXME("(%p)->(%p)\n", This, p);
3424 return E_NOTIMPL;
3427 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3429 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3430 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3431 return E_NOTIMPL;
3434 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3436 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3437 FIXME("(%p)->(%p)\n", This, p);
3438 return E_NOTIMPL;
3441 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3443 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3444 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3445 return E_NOTIMPL;
3448 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3450 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3451 FIXME("(%p)->(%p)\n", This, p);
3452 return E_NOTIMPL;
3455 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3457 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3458 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3459 return E_NOTIMPL;
3462 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3464 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3465 FIXME("(%p)->(%p)\n", This, p);
3466 return E_NOTIMPL;
3469 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3471 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3472 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3473 return E_NOTIMPL;
3476 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3478 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3479 FIXME("(%p)->(%p)\n", This, p);
3480 return E_NOTIMPL;
3483 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3485 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3486 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3487 return E_NOTIMPL;
3490 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
3492 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3493 FIXME("(%p)->(%p)\n", This, p);
3494 return E_NOTIMPL;
3497 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
3499 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3500 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3501 return E_NOTIMPL;
3504 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
3506 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3507 FIXME("(%p)->(%p)\n", This, p);
3508 return E_NOTIMPL;
3511 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
3513 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3514 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3515 return E_NOTIMPL;
3518 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
3520 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3521 FIXME("(%p)->(%p)\n", This, p);
3522 return E_NOTIMPL;
3525 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
3527 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3528 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3529 return E_NOTIMPL;
3532 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
3534 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3535 FIXME("(%p)->(%p)\n", This, p);
3536 return E_NOTIMPL;
3539 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
3541 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3542 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3543 return E_NOTIMPL;
3546 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
3548 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3549 FIXME("(%p)->(%p)\n", This, p);
3550 return E_NOTIMPL;
3553 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
3555 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3556 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3557 return E_NOTIMPL;
3560 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
3562 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3563 FIXME("(%p)->(%p)\n", This, p);
3564 return E_NOTIMPL;
3567 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
3569 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3570 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3571 return E_NOTIMPL;
3574 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
3576 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3577 FIXME("(%p)->(%p)\n", This, p);
3578 return E_NOTIMPL;
3581 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
3583 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3584 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3585 return E_NOTIMPL;
3588 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
3590 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3591 FIXME("(%p)->(%p)\n", This, p);
3592 return E_NOTIMPL;
3595 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
3597 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3598 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3599 return E_NOTIMPL;
3602 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
3604 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3605 FIXME("(%p)->(%p)\n", This, p);
3606 return E_NOTIMPL;
3609 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
3611 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3612 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3613 return E_NOTIMPL;
3616 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
3618 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3619 FIXME("(%p)->(%p)\n", This, p);
3620 return E_NOTIMPL;
3623 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
3625 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3626 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3627 return E_NOTIMPL;
3630 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
3632 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3633 FIXME("(%p)->(%p)\n", This, p);
3634 return E_NOTIMPL;
3637 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
3639 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3640 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3641 return E_NOTIMPL;
3644 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
3646 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3647 FIXME("(%p)->(%p)\n", This, p);
3648 return E_NOTIMPL;
3651 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
3653 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3654 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3655 return E_NOTIMPL;
3658 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
3660 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3661 FIXME("(%p)->(%p)\n", This, p);
3662 return E_NOTIMPL;
3665 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
3667 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3668 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3669 return E_NOTIMPL;
3672 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
3674 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3675 FIXME("(%p)->(%p)\n", This, p);
3676 return E_NOTIMPL;
3679 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
3681 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3682 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3683 return E_NOTIMPL;
3686 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
3688 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3689 FIXME("(%p)->(%p)\n", This, p);
3690 return E_NOTIMPL;
3693 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
3695 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3696 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3697 return E_NOTIMPL;
3700 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
3702 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3703 FIXME("(%p)->(%p)\n", This, p);
3704 return E_NOTIMPL;
3707 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
3709 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3710 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3711 return E_NOTIMPL;
3714 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
3716 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3717 FIXME("(%p)->(%p)\n", This, p);
3718 return E_NOTIMPL;
3721 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
3723 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3724 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3725 return E_NOTIMPL;
3728 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
3730 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3731 FIXME("(%p)->(%p)\n", This, p);
3732 return E_NOTIMPL;
3735 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
3737 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3738 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3739 return E_NOTIMPL;
3742 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
3744 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3745 FIXME("(%p)->(%p)\n", This, p);
3746 return E_NOTIMPL;
3749 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
3751 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3752 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3753 return E_NOTIMPL;
3756 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
3758 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3759 FIXME("(%p)->(%p)\n", This, p);
3760 return E_NOTIMPL;
3763 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
3765 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3766 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3767 return E_NOTIMPL;
3770 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
3772 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3773 FIXME("(%p)->(%p)\n", This, p);
3774 return E_NOTIMPL;
3777 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
3779 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3780 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3781 return E_NOTIMPL;
3784 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
3786 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3787 FIXME("(%p)->(%p)\n", This, p);
3788 return E_NOTIMPL;
3791 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
3793 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3794 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3795 return E_NOTIMPL;
3798 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
3800 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3801 FIXME("(%p)->(%p)\n", This, p);
3802 return E_NOTIMPL;
3805 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
3807 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3808 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3809 return E_NOTIMPL;
3812 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
3814 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3815 FIXME("(%p)->(%p)\n", This, p);
3816 return E_NOTIMPL;
3819 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
3821 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3822 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3823 return E_NOTIMPL;
3826 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
3828 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3829 FIXME("(%p)->(%p)\n", This, p);
3830 return E_NOTIMPL;
3833 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
3835 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3836 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3837 return E_NOTIMPL;
3840 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
3842 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3843 FIXME("(%p)->(%p)\n", This, p);
3844 return E_NOTIMPL;
3847 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
3849 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3850 FIXME("(%p)\n", This);
3851 return E_NOTIMPL;
3854 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
3855 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
3857 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3858 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
3859 return E_NOTIMPL;
3862 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **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_body(IHTMLDocument7 *iface, IHTMLElement *v)
3871 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3872 FIXME("(%p)->(%p)\n", This, v);
3873 return E_NOTIMPL;
3876 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
3878 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3879 FIXME("(%p)->(%p)\n", This, p);
3880 return E_NOTIMPL;
3883 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
3885 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3886 FIXME("(%p)->(%p)\n", This, p);
3887 return E_NOTIMPL;
3890 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
3891 HTMLDocument7_QueryInterface,
3892 HTMLDocument7_AddRef,
3893 HTMLDocument7_Release,
3894 HTMLDocument7_GetTypeInfoCount,
3895 HTMLDocument7_GetTypeInfo,
3896 HTMLDocument7_GetIDsOfNames,
3897 HTMLDocument7_Invoke,
3898 HTMLDocument7_get_defaultView,
3899 HTMLDocument7_createCDATASection,
3900 HTMLDocument7_getSelection,
3901 HTMLDocument7_getElementsByTagNameNS,
3902 HTMLDocument7_createElementNS,
3903 HTMLDocument7_createAttributeNS,
3904 HTMLDocument7_put_onmsthumbnailclick,
3905 HTMLDocument7_get_onmsthumbnailclick,
3906 HTMLDocument7_get_characterSet,
3907 HTMLDocument7_createElement,
3908 HTMLDocument7_createAttribute,
3909 HTMLDocument7_getElementByClassName,
3910 HTMLDocument7_createProcessingInstruction,
3911 HTMLDocument7_adoptNode,
3912 HTMLDocument7_put_onmssitemodejumplistitemremoved,
3913 HTMLDocument7_get_onmssitemodejumplistitemremoved,
3914 HTMLDocument7_get_all,
3915 HTMLDocument7_get_inputEncoding,
3916 HTMLDocument7_get_xmlEncoding,
3917 HTMLDocument7_put_xmlStandalone,
3918 HTMLDocument7_get_xmlStandalone,
3919 HTMLDocument7_put_xmlVersion,
3920 HTMLDocument7_get_xmlVersion,
3921 HTMLDocument7_hasAttributes,
3922 HTMLDocument7_put_onabort,
3923 HTMLDocument7_get_onabort,
3924 HTMLDocument7_put_onblur,
3925 HTMLDocument7_get_onblur,
3926 HTMLDocument7_put_oncanplay,
3927 HTMLDocument7_get_oncanplay,
3928 HTMLDocument7_put_oncanplaythrough,
3929 HTMLDocument7_get_oncanplaythrough,
3930 HTMLDocument7_put_onchange,
3931 HTMLDocument7_get_onchange,
3932 HTMLDocument7_put_ondrag,
3933 HTMLDocument7_get_ondrag,
3934 HTMLDocument7_put_ondragend,
3935 HTMLDocument7_get_ondragend,
3936 HTMLDocument7_put_ondragenter,
3937 HTMLDocument7_get_ondragenter,
3938 HTMLDocument7_put_ondragleave,
3939 HTMLDocument7_get_ondragleave,
3940 HTMLDocument7_put_ondragover,
3941 HTMLDocument7_get_ondragover,
3942 HTMLDocument7_put_ondrop,
3943 HTMLDocument7_get_ondrop,
3944 HTMLDocument7_put_ondurationchange,
3945 HTMLDocument7_get_ondurationchange,
3946 HTMLDocument7_put_onemptied,
3947 HTMLDocument7_get_onemptied,
3948 HTMLDocument7_put_onended,
3949 HTMLDocument7_get_onended,
3950 HTMLDocument7_put_onerror,
3951 HTMLDocument7_get_onerror,
3952 HTMLDocument7_put_onfocus,
3953 HTMLDocument7_get_onfocus,
3954 HTMLDocument7_put_oninput,
3955 HTMLDocument7_get_oninput,
3956 HTMLDocument7_put_onload,
3957 HTMLDocument7_get_onload,
3958 HTMLDocument7_put_onloadeddata,
3959 HTMLDocument7_get_onloadeddata,
3960 HTMLDocument7_put_onloadedmetadata,
3961 HTMLDocument7_get_onloadedmetadata,
3962 HTMLDocument7_put_onloadstart,
3963 HTMLDocument7_get_onloadstart,
3964 HTMLDocument7_put_onpause,
3965 HTMLDocument7_get_onpause,
3966 HTMLDocument7_put_onplay,
3967 HTMLDocument7_get_onplay,
3968 HTMLDocument7_put_onplaying,
3969 HTMLDocument7_get_onplaying,
3970 HTMLDocument7_put_onprogress,
3971 HTMLDocument7_get_onprogress,
3972 HTMLDocument7_put_onratechange,
3973 HTMLDocument7_get_onratechange,
3974 HTMLDocument7_put_onreset,
3975 HTMLDocument7_get_onreset,
3976 HTMLDocument7_put_onscroll,
3977 HTMLDocument7_get_onscroll,
3978 HTMLDocument7_put_onseekend,
3979 HTMLDocument7_get_onseekend,
3980 HTMLDocument7_put_onseeking,
3981 HTMLDocument7_get_onseeking,
3982 HTMLDocument7_put_onselect,
3983 HTMLDocument7_get_onselect,
3984 HTMLDocument7_put_onstalled,
3985 HTMLDocument7_get_onstalled,
3986 HTMLDocument7_put_onsubmit,
3987 HTMLDocument7_get_onsubmit,
3988 HTMLDocument7_put_onsuspend,
3989 HTMLDocument7_get_onsuspend,
3990 HTMLDocument7_put_ontimeupdate,
3991 HTMLDocument7_get_ontimeupdate,
3992 HTMLDocument7_put_onvolumechange,
3993 HTMLDocument7_get_onvolumechange,
3994 HTMLDocument7_put_onwaiting,
3995 HTMLDocument7_get_onwaiting,
3996 HTMLDocument7_normalize,
3997 HTMLDocument7_importNode,
3998 HTMLDocument7_get_parentWindow,
3999 HTMLDocument7_put_body,
4000 HTMLDocument7_get_body,
4001 HTMLDocument7_get_head
4004 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4006 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4008 if(This->window)
4009 update_doc_cp_events(This->doc_node, cp);
4012 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4014 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4017 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4019 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4020 return htmldoc_query_interface(This, riid, ppv);
4023 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4025 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4026 return htmldoc_addref(This);
4029 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4031 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4032 return htmldoc_release(This);
4035 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4037 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4038 return S_FALSE;
4041 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4042 SupportErrorInfo_QueryInterface,
4043 SupportErrorInfo_AddRef,
4044 SupportErrorInfo_Release,
4045 SupportErrorInfo_InterfaceSupportsErrorInfo
4048 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4050 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4053 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4055 nsIDOMNodeList *node_list;
4056 nsAString name_str;
4057 UINT32 len;
4058 unsigned i;
4059 nsresult nsres;
4061 if(!This->nsdoc)
4062 return DISP_E_UNKNOWNNAME;
4064 nsAString_InitDepend(&name_str, name);
4065 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4066 nsAString_Finish(&name_str);
4067 if(NS_FAILED(nsres))
4068 return E_FAIL;
4070 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4071 nsIDOMNodeList_Release(node_list);
4072 if(NS_FAILED(nsres))
4073 return E_FAIL;
4075 if(!len)
4076 return DISP_E_UNKNOWNNAME;
4078 for(i=0; i < This->elem_vars_cnt; i++) {
4079 if(!strcmpW(name, This->elem_vars[i])) {
4080 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4081 return S_OK;
4085 if(This->elem_vars_cnt == This->elem_vars_size) {
4086 WCHAR **new_vars;
4088 if(This->elem_vars_size) {
4089 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4090 if(!new_vars)
4091 return E_OUTOFMEMORY;
4092 This->elem_vars_size *= 2;
4093 }else {
4094 new_vars = heap_alloc(16*sizeof(WCHAR*));
4095 if(!new_vars)
4096 return E_OUTOFMEMORY;
4097 This->elem_vars_size = 16;
4100 This->elem_vars = new_vars;
4103 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4104 if(!This->elem_vars[This->elem_vars_cnt])
4105 return E_OUTOFMEMORY;
4107 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4108 return S_OK;
4111 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4113 HTMLDocument *This = impl_from_IDispatchEx(iface);
4115 return htmldoc_query_interface(This, riid, ppv);
4118 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4120 HTMLDocument *This = impl_from_IDispatchEx(iface);
4122 return htmldoc_addref(This);
4125 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4127 HTMLDocument *This = impl_from_IDispatchEx(iface);
4129 return htmldoc_release(This);
4132 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4134 HTMLDocument *This = impl_from_IDispatchEx(iface);
4136 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4139 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4140 LCID lcid, ITypeInfo **ppTInfo)
4142 HTMLDocument *This = impl_from_IDispatchEx(iface);
4144 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4147 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4148 LPOLESTR *rgszNames, UINT cNames,
4149 LCID lcid, DISPID *rgDispId)
4151 HTMLDocument *This = impl_from_IDispatchEx(iface);
4153 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4156 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4157 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4158 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4160 HTMLDocument *This = impl_from_IDispatchEx(iface);
4162 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4163 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4165 switch(dispIdMember) {
4166 case DISPID_READYSTATE:
4167 TRACE("DISPID_READYSTATE\n");
4169 if(!(wFlags & DISPATCH_PROPERTYGET))
4170 return E_INVALIDARG;
4172 V_VT(pVarResult) = VT_I4;
4173 V_I4(pVarResult) = This->window->readystate;
4174 return S_OK;
4177 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
4178 pVarResult, pExcepInfo, puArgErr);
4181 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4183 HTMLDocument *This = impl_from_IDispatchEx(iface);
4184 HRESULT hres;
4186 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4187 if(hres != DISP_E_UNKNOWNNAME)
4188 return hres;
4190 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4193 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4194 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4196 HTMLDocument *This = impl_from_IDispatchEx(iface);
4198 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
4199 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
4200 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4203 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4206 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4208 HTMLDocument *This = impl_from_IDispatchEx(iface);
4210 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4213 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4215 HTMLDocument *This = impl_from_IDispatchEx(iface);
4217 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4220 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4222 HTMLDocument *This = impl_from_IDispatchEx(iface);
4224 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4227 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4229 HTMLDocument *This = impl_from_IDispatchEx(iface);
4231 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4234 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4236 HTMLDocument *This = impl_from_IDispatchEx(iface);
4238 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
4241 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
4243 HTMLDocument *This = impl_from_IDispatchEx(iface);
4245 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
4248 static const IDispatchExVtbl DocDispatchExVtbl = {
4249 DocDispatchEx_QueryInterface,
4250 DocDispatchEx_AddRef,
4251 DocDispatchEx_Release,
4252 DocDispatchEx_GetTypeInfoCount,
4253 DocDispatchEx_GetTypeInfo,
4254 DocDispatchEx_GetIDsOfNames,
4255 DocDispatchEx_Invoke,
4256 DocDispatchEx_GetDispID,
4257 DocDispatchEx_InvokeEx,
4258 DocDispatchEx_DeleteMemberByName,
4259 DocDispatchEx_DeleteMemberByDispID,
4260 DocDispatchEx_GetMemberProperties,
4261 DocDispatchEx_GetMemberName,
4262 DocDispatchEx_GetNextDispID,
4263 DocDispatchEx_GetNameSpaceParent
4266 static inline HTMLDocument *impl_from_IProvideClassInfo(IProvideClassInfo *iface)
4268 return CONTAINING_RECORD(iface, HTMLDocument, IProvideClassInfo_iface);
4271 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideClassInfo *iface,
4272 REFIID riid, void **ppv)
4274 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4275 return htmldoc_query_interface(This, riid, ppv);
4278 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideClassInfo *iface)
4280 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4281 return htmldoc_addref(This);
4284 static ULONG WINAPI ProvideClassInfo_Release(IProvideClassInfo *iface)
4286 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4287 return htmldoc_release(This);
4290 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideClassInfo* iface,
4291 ITypeInfo **ppTI)
4293 HTMLDocument *This = impl_from_IProvideClassInfo(iface);
4294 TRACE("(%p)->(%p)\n", This, ppTI);
4295 return get_htmldoc_classinfo(ppTI);
4298 static const IProvideClassInfoVtbl ProvideClassInfoVtbl = {
4299 ProvideClassInfo_QueryInterface,
4300 ProvideClassInfo_AddRef,
4301 ProvideClassInfo_Release,
4302 ProvideClassInfo_GetClassInfo
4305 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
4307 *ppv = NULL;
4309 if(IsEqualGUID(&IID_IUnknown, riid))
4310 *ppv = &This->IHTMLDocument2_iface;
4311 else if(IsEqualGUID(&IID_IDispatch, riid))
4312 *ppv = &This->IDispatchEx_iface;
4313 else if(IsEqualGUID(&IID_IDispatchEx, riid))
4314 *ppv = &This->IDispatchEx_iface;
4315 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
4316 *ppv = &This->IHTMLDocument2_iface;
4317 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
4318 *ppv = &This->IHTMLDocument2_iface;
4319 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
4320 *ppv = &This->IHTMLDocument3_iface;
4321 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
4322 *ppv = &This->IHTMLDocument4_iface;
4323 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
4324 *ppv = &This->IHTMLDocument5_iface;
4325 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
4326 *ppv = &This->IHTMLDocument6_iface;
4327 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
4328 *ppv = &This->IHTMLDocument7_iface;
4329 else if(IsEqualGUID(&IID_IPersist, riid))
4330 *ppv = &This->IPersistFile_iface;
4331 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
4332 *ppv = &This->IPersistMoniker_iface;
4333 else if(IsEqualGUID(&IID_IPersistFile, riid))
4334 *ppv = &This->IPersistFile_iface;
4335 else if(IsEqualGUID(&IID_IMonikerProp, riid))
4336 *ppv = &This->IMonikerProp_iface;
4337 else if(IsEqualGUID(&IID_IOleObject, riid))
4338 *ppv = &This->IOleObject_iface;
4339 else if(IsEqualGUID(&IID_IOleDocument, riid))
4340 *ppv = &This->IOleDocument_iface;
4341 else if(IsEqualGUID(&IID_IOleDocumentView, riid))
4342 *ppv = &This->IOleDocumentView_iface;
4343 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
4344 *ppv = &This->IOleInPlaceActiveObject_iface;
4345 else if(IsEqualGUID(&IID_IViewObject, riid))
4346 *ppv = &This->IViewObjectEx_iface;
4347 else if(IsEqualGUID(&IID_IViewObject2, riid))
4348 *ppv = &This->IViewObjectEx_iface;
4349 else if(IsEqualGUID(&IID_IViewObjectEx, riid))
4350 *ppv = &This->IViewObjectEx_iface;
4351 else if(IsEqualGUID(&IID_IOleWindow, riid))
4352 *ppv = &This->IOleInPlaceActiveObject_iface;
4353 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
4354 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4355 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
4356 *ppv = &This->IOleInPlaceObjectWindowless_iface;
4357 else if(IsEqualGUID(&IID_IServiceProvider, riid))
4358 *ppv = &This->IServiceProvider_iface;
4359 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
4360 *ppv = &This->IOleCommandTarget_iface;
4361 else if(IsEqualGUID(&IID_IOleControl, riid))
4362 *ppv = &This->IOleControl_iface;
4363 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
4364 *ppv = &This->IHlinkTarget_iface;
4365 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
4366 *ppv = &This->cp_container.IConnectionPointContainer_iface;
4367 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
4368 *ppv = &This->IPersistStreamInit_iface;
4369 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
4370 *ppv = &This->IHTMLDocument2_iface;
4371 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
4372 *ppv = &This->ISupportErrorInfo_iface;
4373 else if(IsEqualGUID(&IID_IPersistHistory, riid))
4374 *ppv = &This->IPersistHistory_iface;
4375 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
4376 *ppv = &This->IObjectWithSite_iface;
4377 else if(IsEqualGUID(&IID_IOleContainer, riid))
4378 *ppv = &This->IOleContainer_iface;
4379 else if(IsEqualGUID(&IID_IObjectSafety, riid))
4380 *ppv = &This->IObjectSafety_iface;
4381 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
4382 *ppv = &This->IProvideClassInfo_iface;
4383 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
4384 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
4385 *ppv = NULL;
4386 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
4387 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
4388 *ppv = NULL;
4389 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
4390 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
4391 *ppv = NULL;
4392 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
4393 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
4394 *ppv = NULL;
4395 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
4396 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
4397 *ppv = NULL;
4398 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
4399 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
4400 *ppv = NULL;
4401 }else {
4402 return FALSE;
4405 if(*ppv)
4406 IUnknown_AddRef((IUnknown*)*ppv);
4407 return TRUE;
4410 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
4412 static const cpc_entry_t HTMLDocument_cpc[] = {
4413 {&IID_IDispatch, &HTMLDocumentEvents_data},
4414 {&IID_IPropertyNotifySink},
4415 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
4416 {&DIID_HTMLDocumentEvents2},
4417 {NULL}
4420 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
4422 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
4423 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
4424 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
4425 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
4426 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
4427 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
4428 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
4429 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
4430 doc->IProvideClassInfo_iface.lpVtbl = &ProvideClassInfoVtbl;
4432 doc->unk_impl = unk_impl;
4433 doc->dispex = dispex;
4434 doc->task_magic = get_task_target_magic();
4436 HTMLDocument_Persist_Init(doc);
4437 HTMLDocument_OleCmd_Init(doc);
4438 HTMLDocument_OleObj_Init(doc);
4439 HTMLDocument_View_Init(doc);
4440 HTMLDocument_Window_Init(doc);
4441 HTMLDocument_Service_Init(doc);
4442 HTMLDocument_Hlink_Init(doc);
4444 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
4447 static void destroy_htmldoc(HTMLDocument *This)
4449 remove_target_tasks(This->task_magic);
4451 ConnectionPointContainer_Destroy(&This->cp_container);
4454 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
4456 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
4459 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
4461 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4463 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4465 if(htmldoc_qi(&This->basedoc, riid, ppv))
4466 return *ppv ? S_OK : E_NOINTERFACE;
4468 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
4469 *ppv = &This->IInternetHostSecurityManager_iface;
4470 else
4471 return HTMLDOMNode_QI(&This->node, riid, ppv);
4473 IUnknown_AddRef((IUnknown*)*ppv);
4474 return S_OK;
4477 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
4479 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4480 unsigned i;
4482 for(i=0; i < This->elem_vars_cnt; i++)
4483 heap_free(This->elem_vars[i]);
4484 heap_free(This->elem_vars);
4486 detach_events(This);
4487 if(This->body_event_target)
4488 release_event_target(This->body_event_target);
4489 if(This->catmgr)
4490 ICatInformation_Release(This->catmgr);
4492 detach_selection(This);
4493 detach_ranges(This);
4495 while(!list_empty(&This->plugin_hosts))
4496 detach_plugin_host(LIST_ENTRY(list_head(&This->plugin_hosts), PluginHost, entry));
4498 if(!This->nsdoc && This->window) {
4499 /* document fragments own reference to inner window */
4500 IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
4501 This->window = NULL;
4504 heap_free(This->event_vector);
4505 destroy_htmldoc(&This->basedoc);
4508 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4510 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4511 FIXME("%p\n", This);
4512 return E_NOTIMPL;
4515 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
4517 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4519 if(This->nsdoc)
4520 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
4523 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
4525 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4527 if(This->nsdoc) {
4528 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
4530 release_document_mutation(This);
4531 This->nsdoc = NULL;
4532 nsIDOMHTMLDocument_Release(nsdoc);
4533 This->window = NULL;
4537 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
4538 HTMLDocumentNode_QI,
4539 HTMLDocumentNode_destructor,
4540 HTMLDocument_cpc,
4541 HTMLDocumentNode_clone,
4542 NULL,
4543 NULL,
4544 NULL,
4545 NULL,
4546 NULL,
4547 NULL,
4548 NULL,
4549 NULL,
4550 NULL,
4551 NULL,
4552 NULL,
4553 HTMLDocumentNode_traverse,
4554 HTMLDocumentNode_unlink
4557 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4559 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
4560 HTMLDocumentNode *new_node;
4561 HRESULT hres;
4563 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
4564 if(FAILED(hres))
4565 return hres;
4567 *ret = &new_node->node;
4568 return S_OK;
4571 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
4573 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
4576 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4577 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4579 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4580 nsIDOMNodeList *node_list;
4581 nsAString name_str;
4582 nsIDOMNode *nsnode;
4583 HTMLDOMNode *node;
4584 unsigned i;
4585 nsresult nsres;
4586 HRESULT hres;
4588 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
4589 FIXME("unsupported flags %x\n", flags);
4590 return E_NOTIMPL;
4593 i = id - MSHTML_DISPID_CUSTOM_MIN;
4595 if(!This->nsdoc || i >= This->elem_vars_cnt)
4596 return DISP_E_UNKNOWNNAME;
4598 nsAString_InitDepend(&name_str, This->elem_vars[i]);
4599 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4600 nsAString_Finish(&name_str);
4601 if(NS_FAILED(nsres))
4602 return E_FAIL;
4604 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
4605 nsIDOMNodeList_Release(node_list);
4606 if(NS_FAILED(nsres) || !nsnode)
4607 return DISP_E_UNKNOWNNAME;
4609 hres = get_node(This, nsnode, TRUE, &node);
4610 if(FAILED(hres))
4611 return hres;
4613 V_VT(res) = VT_DISPATCH;
4614 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
4615 return S_OK;
4618 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, int eid)
4620 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
4621 ensure_doc_nsevent_handler(This, eid);
4624 static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl = {
4625 NULL,
4626 NULL,
4627 HTMLDocumentNode_invoke,
4628 NULL,
4629 NULL,
4630 HTMLDocumentNode_bind_event
4633 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
4634 HTMLDocumentNode_QI,
4635 HTMLDocumentNode_destructor,
4636 HTMLDocument_cpc,
4637 HTMLDocumentFragment_clone
4640 static const tid_t HTMLDocumentNode_iface_tids[] = {
4641 IHTMLDOMNode_tid,
4642 IHTMLDOMNode2_tid,
4643 IHTMLDocument2_tid,
4644 IHTMLDocument3_tid,
4645 IHTMLDocument4_tid,
4646 IHTMLDocument5_tid,
4650 static dispex_static_data_t HTMLDocumentNode_dispex = {
4651 &HTMLDocumentNode_dispex_vtbl,
4652 DispHTMLDocument_tid,
4653 NULL,
4654 HTMLDocumentNode_iface_tids
4657 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
4659 HTMLDocumentNode *doc;
4661 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
4662 if(!doc)
4663 return NULL;
4665 doc->ref = 1;
4666 doc->basedoc.doc_node = doc;
4667 doc->basedoc.doc_obj = doc_obj;
4668 doc->basedoc.window = window->base.outer_window;
4669 doc->window = window;
4671 init_dispex(&doc->node.event_target.dispex, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4672 &HTMLDocumentNode_dispex);
4673 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
4674 &doc->node.event_target.dispex.IDispatchEx_iface);
4675 HTMLDocumentNode_SecMgr_Init(doc);
4677 list_init(&doc->selection_list);
4678 list_init(&doc->range_list);
4679 list_init(&doc->plugin_hosts);
4681 return doc;
4684 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLInnerWindow *window, HTMLDocumentNode **ret)
4686 HTMLDocumentNode *doc;
4688 doc = alloc_doc_node(doc_obj, window);
4689 if(!doc)
4690 return E_OUTOFMEMORY;
4692 if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
4693 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
4695 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
4697 nsIDOMHTMLDocument_AddRef(nsdoc);
4698 doc->nsdoc = nsdoc;
4700 init_document_mutation(doc);
4701 doc_init_events(doc);
4703 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
4704 doc->node.cp_container = &doc->basedoc.cp_container;
4706 *ret = doc;
4707 return S_OK;
4710 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
4712 HTMLDocumentNode *doc_frag;
4714 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
4715 if(!doc_frag)
4716 return E_OUTOFMEMORY;
4718 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
4720 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
4721 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
4722 doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
4724 *ret = doc_frag;
4725 return S_OK;
4728 /**********************************************************
4729 * ICustomDoc implementation
4732 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
4734 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
4737 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
4739 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4741 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4743 if(htmldoc_qi(&This->basedoc, riid, ppv))
4744 return *ppv ? S_OK : E_NOINTERFACE;
4746 if(IsEqualGUID(&IID_ICustomDoc, riid)) {
4747 *ppv = &This->ICustomDoc_iface;
4748 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
4749 *ppv = &This->ITargetContainer_iface;
4750 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4751 return *ppv ? S_OK : E_NOINTERFACE;
4752 }else {
4753 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
4754 *ppv = NULL;
4755 return E_NOINTERFACE;
4758 IUnknown_AddRef((IUnknown*)*ppv);
4759 return S_OK;
4762 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
4764 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4765 ULONG ref = InterlockedIncrement(&This->ref);
4767 TRACE("(%p) ref = %u\n", This, ref);
4769 return ref;
4772 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
4774 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4775 ULONG ref = InterlockedDecrement(&This->ref);
4777 TRACE("(%p) ref = %u\n", This, ref);
4779 if(!ref) {
4780 nsIDOMWindowUtils *window_utils = NULL;
4782 if(This->basedoc.window && This->basedoc.window->nswindow)
4783 get_nsinterface((nsISupports*)This->basedoc.window->nswindow, &IID_nsIDOMWindowUtils, (void**)&window_utils);
4785 if(This->basedoc.doc_node) {
4786 This->basedoc.doc_node->basedoc.doc_obj = NULL;
4787 htmldoc_release(&This->basedoc.doc_node->basedoc);
4789 if(This->basedoc.window) {
4790 This->basedoc.window->doc_obj = NULL;
4791 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
4793 if(This->basedoc.advise_holder)
4794 IOleAdviseHolder_Release(This->basedoc.advise_holder);
4796 if(This->view_sink)
4797 IAdviseSink_Release(This->view_sink);
4798 if(This->client)
4799 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
4800 if(This->hostui)
4801 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
4802 if(This->in_place_active)
4803 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
4804 if(This->ipsite)
4805 IOleDocumentView_SetInPlaceSite(&This->basedoc.IOleDocumentView_iface, NULL);
4806 if(This->undomgr)
4807 IOleUndoManager_Release(This->undomgr);
4808 if(This->editsvcs)
4809 IHTMLEditServices_Release(This->editsvcs);
4810 if(This->tooltips_hwnd)
4811 DestroyWindow(This->tooltips_hwnd);
4813 if(This->hwnd)
4814 DestroyWindow(This->hwnd);
4815 heap_free(This->mime);
4817 destroy_htmldoc(&This->basedoc);
4818 release_dispex(&This->dispex);
4820 if(This->nscontainer)
4821 NSContainer_Release(This->nscontainer);
4822 heap_free(This);
4824 /* Force cycle collection */
4825 if(window_utils) {
4826 nsIDOMWindowUtils_CycleCollect(window_utils, NULL, 0);
4827 nsIDOMWindowUtils_Release(window_utils);
4831 return ref;
4834 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
4836 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
4837 IOleCommandTarget *cmdtrg;
4838 HRESULT hres;
4840 TRACE("(%p)->(%p)\n", This, pUIHandler);
4842 if(This->custom_hostui && This->hostui == pUIHandler)
4843 return S_OK;
4845 This->custom_hostui = TRUE;
4847 if(This->hostui)
4848 IDocHostUIHandler_Release(This->hostui);
4849 if(pUIHandler)
4850 IDocHostUIHandler_AddRef(pUIHandler);
4851 This->hostui = pUIHandler;
4852 if(!pUIHandler)
4853 return S_OK;
4855 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
4856 if(SUCCEEDED(hres)) {
4857 FIXME("custom UI handler supports IOleCommandTarget\n");
4858 IOleCommandTarget_Release(cmdtrg);
4861 return S_OK;
4864 static const ICustomDocVtbl CustomDocVtbl = {
4865 CustomDoc_QueryInterface,
4866 CustomDoc_AddRef,
4867 CustomDoc_Release,
4868 CustomDoc_SetUIHandler
4871 static const tid_t HTMLDocumentObj_iface_tids[] = {
4872 IHTMLDocument2_tid,
4873 IHTMLDocument3_tid,
4874 IHTMLDocument4_tid,
4875 IHTMLDocument5_tid,
4878 static dispex_static_data_t HTMLDocumentObj_dispex = {
4879 NULL,
4880 DispHTMLDocument_tid,
4881 NULL,
4882 HTMLDocumentObj_iface_tids
4885 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
4887 HTMLDocumentObj *doc;
4888 nsIDOMWindow *nswindow = NULL;
4889 nsresult nsres;
4890 HRESULT hres;
4892 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_mshtml_guid(riid), ppvObject);
4894 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
4895 if(!doc)
4896 return E_OUTOFMEMORY;
4898 init_dispex(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex);
4899 init_doc(&doc->basedoc, (IUnknown*)&doc->ICustomDoc_iface, &doc->dispex.IDispatchEx_iface);
4900 TargetContainer_Init(doc);
4902 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
4903 doc->ref = 1;
4904 doc->basedoc.doc_obj = doc;
4906 doc->usermode = UNKNOWN_USERMODE;
4908 init_binding_ui(doc);
4910 hres = create_nscontainer(doc, &doc->nscontainer);
4911 if(FAILED(hres)) {
4912 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
4913 htmldoc_release(&doc->basedoc);
4914 return hres;
4917 hres = htmldoc_query_interface(&doc->basedoc, riid, ppvObject);
4918 htmldoc_release(&doc->basedoc);
4919 if(FAILED(hres))
4920 return hres;
4922 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
4923 if(NS_FAILED(nsres))
4924 ERR("GetContentDOMWindow failed: %08x\n", nsres);
4926 hres = HTMLOuterWindow_Create(doc, nswindow, NULL /* FIXME */, &doc->basedoc.window);
4927 if(nswindow)
4928 nsIDOMWindow_Release(nswindow);
4929 if(FAILED(hres)) {
4930 htmldoc_release(&doc->basedoc);
4931 return hres;
4934 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
4935 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
4936 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
4939 get_thread_hwnd();
4941 return S_OK;