dwmapi: Clear DWM_TIMING_INFO structure before returning.
[wine.git] / dlls / mshtml / htmldoc.c
blob3a742a86a1b4049861eec91f84fa94e9f6967df7
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "wininet.h"
28 #include "ole2.h"
29 #include "perhist.h"
30 #include "mshtmdid.h"
31 #include "mshtmcid.h"
33 #include "wine/debug.h"
35 #include "mshtml_private.h"
36 #include "htmlevent.h"
37 #include "pluginhost.h"
38 #include "binding.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
42 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret);
44 HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement **ret)
46 nsIDOMNodeList *nsnode_list;
47 nsIDOMElement *nselem;
48 nsIDOMNode *nsnode;
49 nsAString id_str;
50 nsresult nsres;
51 HRESULT hres;
53 if(!doc->nsdoc) {
54 WARN("NULL nsdoc\n");
55 return E_UNEXPECTED;
58 nsAString_InitDepend(&id_str, id);
59 /* get element by id attribute */
60 nsres = nsIDOMHTMLDocument_GetElementById(doc->nsdoc, &id_str, &nselem);
61 if(FAILED(nsres)) {
62 ERR("GetElementById failed: %08lx\n", nsres);
63 nsAString_Finish(&id_str);
64 return E_FAIL;
67 /* get first element by name attribute */
68 nsres = nsIDOMHTMLDocument_GetElementsByName(doc->nsdoc, &id_str, &nsnode_list);
69 nsAString_Finish(&id_str);
70 if(FAILED(nsres)) {
71 ERR("getElementsByName failed: %08lx\n", nsres);
72 if(nselem)
73 nsIDOMElement_Release(nselem);
74 return E_FAIL;
77 nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode);
78 nsIDOMNodeList_Release(nsnode_list);
79 assert(nsres == NS_OK);
81 if(nsnode && nselem) {
82 UINT16 pos;
84 nsres = nsIDOMNode_CompareDocumentPosition(nsnode, (nsIDOMNode*)nselem, &pos);
85 if(NS_FAILED(nsres)) {
86 FIXME("CompareDocumentPosition failed: 0x%08lx\n", nsres);
87 nsIDOMNode_Release(nsnode);
88 nsIDOMElement_Release(nselem);
89 return E_FAIL;
92 TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
93 if(!(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS))) {
94 nsIDOMElement_Release(nselem);
95 nselem = NULL;
99 if(nsnode) {
100 if(!nselem) {
101 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
102 assert(nsres == NS_OK);
104 nsIDOMNode_Release(nsnode);
107 if(!nselem) {
108 *ret = NULL;
109 return S_OK;
112 hres = get_element(nselem, ret);
113 nsIDOMElement_Release(nselem);
114 return hres;
117 UINT get_document_charset(HTMLDocumentNode *doc)
119 nsAString charset_str;
120 UINT ret = 0;
121 nsresult nsres;
123 if(doc->charset)
124 return doc->charset;
126 nsAString_Init(&charset_str, NULL);
127 nsres = nsIDOMHTMLDocument_GetCharacterSet(doc->nsdoc, &charset_str);
128 if(NS_SUCCEEDED(nsres)) {
129 const PRUnichar *charset;
131 nsAString_GetData(&charset_str, &charset);
133 if(*charset) {
134 BSTR str = SysAllocString(charset);
135 ret = cp_from_charset_string(str);
136 SysFreeString(str);
138 }else {
139 ERR("GetCharset failed: %08lx\n", nsres);
141 nsAString_Finish(&charset_str);
143 if(!ret)
144 return CP_UTF8;
146 return doc->charset = ret;
149 static inline HTMLDocument *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
151 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument2_iface);
154 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
156 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
158 return htmldoc_query_interface(This, riid, ppv);
161 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
163 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
165 return htmldoc_addref(This);
168 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
170 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
172 return htmldoc_release(This);
175 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
177 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
179 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
182 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
183 LCID lcid, ITypeInfo **ppTInfo)
185 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
187 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
190 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
191 LPOLESTR *rgszNames, UINT cNames,
192 LCID lcid, DISPID *rgDispId)
194 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
196 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
197 rgDispId);
200 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
201 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
202 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
204 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
206 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
207 pDispParams, pVarResult, pExcepInfo, puArgErr);
210 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
212 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
213 HRESULT hres;
215 TRACE("(%p)->(%p)\n", This, p);
217 hres = IHTMLDocument7_get_parentWindow(&This->IHTMLDocument7_iface, (IHTMLWindow2**)p);
218 return hres == S_OK && !*p ? E_PENDING : hres;
221 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
223 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
224 nsIDOMElement *nselem = NULL;
225 HTMLDOMNode *node;
226 nsresult nsres;
227 HRESULT hres;
229 TRACE("(%p)->(%p)\n", This, p);
231 if(!This->doc_node->nsdoc) {
232 WARN("NULL nsdoc\n");
233 return E_UNEXPECTED;
236 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
237 if(NS_FAILED(nsres)) {
238 ERR("GetDocumentElement failed: %08lx\n", nsres);
239 return E_FAIL;
242 if(!nselem) {
243 *p = NULL;
244 return S_OK;
247 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
248 nsIDOMElement_Release(nselem);
249 if(FAILED(hres))
250 return hres;
252 *p = create_all_collection(node, TRUE);
253 node_release(node);
254 return hres;
257 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
259 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
260 nsIDOMHTMLElement *nsbody = NULL;
261 HTMLElement *element;
262 HRESULT hres;
264 TRACE("(%p)->(%p)\n", This, p);
266 if(This->doc_node->nsdoc) {
267 nsresult nsres;
269 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
270 if(NS_FAILED(nsres)) {
271 TRACE("Could not get body: %08lx\n", nsres);
272 return E_UNEXPECTED;
276 if(!nsbody) {
277 *p = NULL;
278 return S_OK;
281 hres = get_element((nsIDOMElement*)nsbody, &element);
282 nsIDOMHTMLElement_Release(nsbody);
283 if(FAILED(hres))
284 return hres;
286 *p = &element->IHTMLElement_iface;
287 return S_OK;
290 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
292 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
293 nsIDOMElement *nselem;
294 HTMLElement *elem;
295 nsresult nsres;
296 HRESULT hres;
298 TRACE("(%p)->(%p)\n", This, p);
300 if(!This->doc_node->nsdoc) {
301 *p = NULL;
302 return S_OK;
306 * NOTE: Gecko may return an active element even if the document is not visible.
307 * IE returns NULL in this case.
309 nsres = nsIDOMHTMLDocument_GetActiveElement(This->doc_node->nsdoc, &nselem);
310 if(NS_FAILED(nsres)) {
311 ERR("GetActiveElement failed: %08lx\n", nsres);
312 return E_FAIL;
315 if(!nselem) {
316 *p = NULL;
317 return S_OK;
320 hres = get_element(nselem, &elem);
321 nsIDOMElement_Release(nselem);
322 if(FAILED(hres))
323 return hres;
325 *p = &elem->IHTMLElement_iface;
326 return S_OK;
329 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
331 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
332 nsIDOMHTMLCollection *nscoll = NULL;
333 nsresult nsres;
335 TRACE("(%p)->(%p)\n", This, p);
337 if(!p)
338 return E_INVALIDARG;
340 *p = NULL;
342 if(!This->doc_node->nsdoc) {
343 WARN("NULL nsdoc\n");
344 return E_UNEXPECTED;
347 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
348 if(NS_FAILED(nsres)) {
349 ERR("GetImages failed: %08lx\n", nsres);
350 return E_FAIL;
353 if(nscoll) {
354 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
355 nsIDOMHTMLCollection_Release(nscoll);
358 return S_OK;
361 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
363 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
364 nsIDOMHTMLCollection *nscoll = NULL;
365 nsresult nsres;
367 TRACE("(%p)->(%p)\n", This, p);
369 if(!p)
370 return E_INVALIDARG;
372 *p = NULL;
374 if(!This->doc_node->nsdoc) {
375 WARN("NULL nsdoc\n");
376 return E_UNEXPECTED;
379 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
380 if(NS_FAILED(nsres)) {
381 ERR("GetApplets failed: %08lx\n", nsres);
382 return E_FAIL;
385 if(nscoll) {
386 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
387 nsIDOMHTMLCollection_Release(nscoll);
390 return S_OK;
393 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
395 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
396 nsIDOMHTMLCollection *nscoll = NULL;
397 nsresult nsres;
399 TRACE("(%p)->(%p)\n", This, p);
401 if(!p)
402 return E_INVALIDARG;
404 *p = NULL;
406 if(!This->doc_node->nsdoc) {
407 WARN("NULL nsdoc\n");
408 return E_UNEXPECTED;
411 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
412 if(NS_FAILED(nsres)) {
413 ERR("GetLinks failed: %08lx\n", nsres);
414 return E_FAIL;
417 if(nscoll) {
418 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
419 nsIDOMHTMLCollection_Release(nscoll);
422 return S_OK;
425 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
427 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
428 nsIDOMHTMLCollection *nscoll = NULL;
429 nsresult nsres;
431 TRACE("(%p)->(%p)\n", This, p);
433 if(!p)
434 return E_INVALIDARG;
436 *p = NULL;
438 if(!This->doc_node->nsdoc) {
439 WARN("NULL nsdoc\n");
440 return E_UNEXPECTED;
443 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
444 if(NS_FAILED(nsres)) {
445 ERR("GetForms failed: %08lx\n", nsres);
446 return E_FAIL;
449 if(nscoll) {
450 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
451 nsIDOMHTMLCollection_Release(nscoll);
454 return S_OK;
457 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
459 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
460 nsIDOMHTMLCollection *nscoll = NULL;
461 nsresult nsres;
463 TRACE("(%p)->(%p)\n", This, p);
465 if(!p)
466 return E_INVALIDARG;
468 *p = NULL;
470 if(!This->doc_node->nsdoc) {
471 WARN("NULL nsdoc\n");
472 return E_UNEXPECTED;
475 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
476 if(NS_FAILED(nsres)) {
477 ERR("GetAnchors failed: %08lx\n", nsres);
478 return E_FAIL;
481 if(nscoll) {
482 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
483 nsIDOMHTMLCollection_Release(nscoll);
486 return S_OK;
489 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
491 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
492 nsAString nsstr;
493 nsresult nsres;
495 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
497 if(!This->doc_node->nsdoc) {
498 WARN("NULL nsdoc\n");
499 return E_UNEXPECTED;
502 nsAString_InitDepend(&nsstr, v);
503 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
504 nsAString_Finish(&nsstr);
505 if(NS_FAILED(nsres))
506 ERR("SetTitle failed: %08lx\n", nsres);
508 return S_OK;
511 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
513 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
514 const PRUnichar *ret;
515 nsAString nsstr;
516 nsresult nsres;
518 TRACE("(%p)->(%p)\n", This, p);
520 if(!This->doc_node->nsdoc) {
521 WARN("NULL nsdoc\n");
522 return E_UNEXPECTED;
526 nsAString_Init(&nsstr, NULL);
527 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
528 if (NS_SUCCEEDED(nsres)) {
529 nsAString_GetData(&nsstr, &ret);
530 *p = SysAllocString(ret);
532 nsAString_Finish(&nsstr);
534 if(NS_FAILED(nsres)) {
535 ERR("GetTitle failed: %08lx\n", nsres);
536 return E_FAIL;
539 return S_OK;
542 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
544 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
545 nsIDOMHTMLCollection *nscoll = NULL;
546 nsresult nsres;
548 TRACE("(%p)->(%p)\n", This, p);
550 if(!p)
551 return E_INVALIDARG;
553 *p = NULL;
555 if(!This->doc_node->nsdoc) {
556 WARN("NULL nsdoc\n");
557 return E_UNEXPECTED;
560 nsres = nsIDOMHTMLDocument_GetScripts(This->doc_node->nsdoc, &nscoll);
561 if(NS_FAILED(nsres)) {
562 ERR("GetImages failed: %08lx\n", nsres);
563 return E_FAIL;
566 if(nscoll) {
567 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
568 nsIDOMHTMLCollection_Release(nscoll);
571 return S_OK;
574 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
576 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
577 HRESULT hres;
579 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
581 if(wcsicmp(v, L"on")) {
582 FIXME("Unsupported arg %s\n", debugstr_w(v));
583 return E_NOTIMPL;
586 hres = setup_edit_mode(This->doc_obj);
587 if(FAILED(hres))
588 return hres;
590 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
591 return S_OK;
594 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
596 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
597 FIXME("(%p)->(%p) always returning Off\n", This, p);
599 if(!p)
600 return E_INVALIDARG;
602 *p = SysAllocString(L"Off");
604 return S_OK;
607 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
609 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
610 nsISelection *nsselection;
611 nsresult nsres;
613 TRACE("(%p)->(%p)\n", This, p);
615 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
616 if(NS_FAILED(nsres)) {
617 ERR("GetSelection failed: %08lx\n", nsres);
618 return E_FAIL;
621 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
624 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
626 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
629 TRACE("(%p)->(%p)\n", iface, p);
631 if(!p)
632 return E_POINTER;
634 return get_readystate_string(This->window->readystate, p);
637 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
639 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
641 TRACE("(%p)->(%p)\n", This, p);
643 return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p);
646 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
648 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
649 FIXME("(%p)->(%p)\n", This, p);
650 return E_NOTIMPL;
653 static HRESULT WINAPI HTMLDocument_get_plugins(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_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
662 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
663 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
664 return E_NOTIMPL;
667 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
669 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
670 FIXME("(%p)->(%p)\n", This, p);
671 return E_NOTIMPL;
674 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
676 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
677 IHTMLElement *element = NULL;
678 IHTMLBodyElement *body;
679 HRESULT hr;
681 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
683 hr = IHTMLDocument2_get_body(iface, &element);
684 if (FAILED(hr))
686 ERR("Failed to get body (0x%08lx)\n", hr);
687 return hr;
690 if(!element)
692 FIXME("Empty body element.\n");
693 return hr;
696 hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body);
697 if (SUCCEEDED(hr))
699 hr = IHTMLBodyElement_put_bgColor(body, v);
700 IHTMLBodyElement_Release(body);
702 IHTMLElement_Release(element);
704 return hr;
707 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
709 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
710 nsAString nsstr;
711 nsresult nsres;
712 HRESULT hres;
714 TRACE("(%p)->(%p)\n", This, p);
716 if(!This->doc_node->nsdoc) {
717 WARN("NULL nsdoc\n");
718 return E_UNEXPECTED;
721 nsAString_Init(&nsstr, NULL);
722 nsres = nsIDOMHTMLDocument_GetBgColor(This->doc_node->nsdoc, &nsstr);
723 hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p);
724 if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) {
725 TRACE("default #ffffff\n");
726 if(!(V_BSTR(p) = SysAllocString(L"#ffffff")))
727 hres = E_OUTOFMEMORY;
729 return hres;
732 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
734 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
735 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
736 return E_NOTIMPL;
739 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
741 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
742 FIXME("(%p)->(%p)\n", This, p);
743 return E_NOTIMPL;
746 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
748 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
749 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
750 return E_NOTIMPL;
753 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
755 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
756 FIXME("(%p)->(%p)\n", This, p);
757 return E_NOTIMPL;
760 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
762 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
763 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
764 return E_NOTIMPL;
767 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
769 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
770 FIXME("(%p)->(%p)\n", This, p);
771 return E_NOTIMPL;
774 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
776 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
778 FIXME("(%p)->(%p)\n", This, p);
780 *p = NULL;
781 return S_OK;
784 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
786 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface)->doc_node;
788 TRACE("(%p)->(%p)\n", This, p);
790 if(!This->nsdoc || !This->window) {
791 WARN("NULL window\n");
792 return E_UNEXPECTED;
795 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
798 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
800 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
801 FIXME("(%p)->(%p)\n", This, p);
802 return E_NOTIMPL;
805 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
807 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
809 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
811 if(!This->window) {
812 FIXME("No window available\n");
813 return E_FAIL;
816 return navigate_url(This->window, v, This->window->uri, BINDING_NAVIGATED);
819 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
821 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
823 TRACE("(%p)->(%p)\n", iface, p);
825 *p = SysAllocString(This->window->url ? This->window->url : L"about:blank");
826 return *p ? S_OK : E_OUTOFMEMORY;
829 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
831 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
832 nsAString nsstr;
833 nsresult nsres;
835 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
837 nsAString_InitDepend(&nsstr, v);
838 nsres = nsIDOMHTMLDocument_SetDomain(This->doc_node->nsdoc, &nsstr);
839 nsAString_Finish(&nsstr);
840 if(NS_FAILED(nsres)) {
841 ERR("SetDomain failed: %08lx\n", nsres);
842 return E_INVALIDARG;
845 return S_OK;
848 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
850 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
851 nsAString nsstr;
852 nsresult nsres;
854 TRACE("(%p)->(%p)\n", This, p);
856 nsAString_Init(&nsstr, NULL);
857 nsres = nsIDOMHTMLDocument_GetDomain(This->doc_node->nsdoc, &nsstr);
858 if(NS_SUCCEEDED(nsres) && This->window && This->window->uri) {
859 const PRUnichar *str;
860 HRESULT hres;
862 nsAString_GetData(&nsstr, &str);
863 if(!*str) {
864 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
865 nsAString_Finish(&nsstr);
866 hres = IUri_GetHost(This->window->uri, p);
867 return FAILED(hres) ? hres : S_OK;
871 return return_nsstr(nsres, &nsstr, p);
874 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
876 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
877 BOOL bret;
879 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
881 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
882 if(!bret) {
883 FIXME("InternetSetCookieExW failed: %lu\n", GetLastError());
884 return HRESULT_FROM_WIN32(GetLastError());
887 return S_OK;
890 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
892 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
893 DWORD size;
894 BOOL bret;
896 TRACE("(%p)->(%p)\n", This, p);
898 size = 0;
899 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
900 if(!bret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
901 WARN("InternetGetCookieExW failed: %lu\n", GetLastError());
902 *p = NULL;
903 return S_OK;
906 if(!size) {
907 *p = NULL;
908 return S_OK;
911 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
912 if(!*p)
913 return E_OUTOFMEMORY;
915 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
916 if(!bret) {
917 ERR("InternetGetCookieExW failed: %lu\n", GetLastError());
918 return E_FAIL;
921 return S_OK;
924 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
926 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
927 FIXME("(%p)->(%x)\n", This, v);
928 return E_NOTIMPL;
931 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
933 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
934 FIXME("(%p)->(%p)\n", This, p);
935 return E_NOTIMPL;
938 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
940 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
941 FIXME("(%p)->(%s) returning S_OK\n", This, debugstr_w(v));
942 return S_OK;
945 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
947 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
949 TRACE("(%p)->(%p)\n", This, p);
951 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
954 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
956 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
957 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
958 return E_NOTIMPL;
961 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
963 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
965 TRACE("(%p)->(%p)\n", This, p);
967 *p = charset_string_from_cp(GetACP());
968 return *p ? S_OK : E_OUTOFMEMORY;
971 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
973 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
974 FIXME("(%p)->(%p)\n", This, p);
975 return E_NOTIMPL;
978 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
980 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
981 FIXME("(%p)->(%p)\n", This, p);
982 return E_NOTIMPL;
985 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
987 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
988 FIXME("(%p)->(%p)\n", This, p);
989 return E_NOTIMPL;
992 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
994 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
995 FIXME("(%p)->(%p)\n", This, p);
996 return E_NOTIMPL;
999 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
1001 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1002 FIXME("(%p)->(%p)\n", This, p);
1003 return E_NOTIMPL;
1006 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
1008 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1009 FIXME("(%p)->(%p)\n", This, p);
1010 return E_NOTIMPL;
1013 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
1015 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1016 FIXME("(%p)->(%p)\n", This, p);
1017 return E_NOTIMPL;
1020 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1022 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1023 FIXME("(%p)->(%p)\n", This, p);
1024 return E_NOTIMPL;
1027 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
1029 VARIANT *var, tmp;
1030 JSContext *jsctx;
1031 nsAString nsstr;
1032 ULONG i, argc;
1033 nsresult nsres;
1034 HRESULT hres;
1036 if(!This->doc_node->nsdoc) {
1037 WARN("NULL nsdoc\n");
1038 return E_UNEXPECTED;
1041 if (!psarray)
1042 return S_OK;
1044 if(psarray->cDims != 1) {
1045 FIXME("cDims=%d\n", psarray->cDims);
1046 return E_INVALIDARG;
1049 hres = SafeArrayAccessData(psarray, (void**)&var);
1050 if(FAILED(hres)) {
1051 WARN("SafeArrayAccessData failed: %08lx\n", hres);
1052 return hres;
1055 V_VT(&tmp) = VT_EMPTY;
1057 jsctx = get_context_from_document(This->doc_node->nsdoc);
1058 argc = psarray->rgsabound[0].cElements;
1059 for(i=0; i < argc; i++) {
1060 if(V_VT(var+i) == VT_BSTR) {
1061 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1062 }else {
1063 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1064 if(FAILED(hres)) {
1065 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1066 break;
1068 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1071 if(!ln || i != argc-1)
1072 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1073 else
1074 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1075 nsAString_Finish(&nsstr);
1076 if(V_VT(var+i) != VT_BSTR)
1077 VariantClear(&tmp);
1078 if(NS_FAILED(nsres)) {
1079 ERR("Write failed: %08lx\n", nsres);
1080 hres = E_FAIL;
1081 break;
1085 SafeArrayUnaccessData(psarray);
1087 return hres;
1090 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1092 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1094 TRACE("(%p)->(%p)\n", iface, psarray);
1096 return document_write(This, psarray, FALSE);
1099 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1101 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1103 TRACE("(%p)->(%p)\n", This, psarray);
1105 return document_write(This, psarray, TRUE);
1108 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1109 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1111 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1112 nsISupports *tmp;
1113 nsresult nsres;
1115 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1116 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1118 if(!This->doc_node->nsdoc) {
1119 ERR("!nsdoc\n");
1120 return E_NOTIMPL;
1123 if(!url || wcscmp(url, L"text/html") || V_VT(&name) != VT_ERROR
1124 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1125 FIXME("unsupported args\n");
1127 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1128 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1129 if(NS_FAILED(nsres)) {
1130 ERR("Open failed: %08lx\n", nsres);
1131 return E_FAIL;
1134 if(tmp)
1135 nsISupports_Release(tmp);
1137 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1138 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1139 return S_OK;
1142 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1144 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1145 nsresult nsres;
1147 TRACE("(%p)\n", This);
1149 if(!This->doc_node->nsdoc) {
1150 ERR("!nsdoc\n");
1151 return E_NOTIMPL;
1154 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1155 if(NS_FAILED(nsres)) {
1156 ERR("Close failed: %08lx\n", nsres);
1157 return E_FAIL;
1160 return S_OK;
1163 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1165 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1166 nsresult nsres;
1168 TRACE("(%p)\n", This);
1170 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1171 if(NS_FAILED(nsres)) {
1172 ERR("Clear failed: %08lx\n", nsres);
1173 return E_FAIL;
1176 return S_OK;
1179 static const struct {
1180 const WCHAR *name;
1181 OLECMDID id;
1182 }command_names[] = {
1183 {L"copy", IDM_COPY},
1184 {L"cut", IDM_CUT},
1185 {L"fontname", IDM_FONTNAME},
1186 {L"fontsize", IDM_FONTSIZE},
1187 {L"indent", IDM_INDENT},
1188 {L"insertorderedlist", IDM_ORDERLIST},
1189 {L"insertunorderedlist", IDM_UNORDERLIST},
1190 {L"outdent", IDM_OUTDENT},
1191 {L"paste", IDM_PASTE},
1192 {L"respectvisibilityindesign", IDM_RESPECTVISIBILITY_INDESIGN}
1195 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1197 int i;
1199 for(i = 0; i < ARRAY_SIZE(command_names); i++) {
1200 if(!wcsicmp(command_names[i].name, str)) {
1201 *cmdid = command_names[i].id;
1202 return TRUE;
1206 FIXME("Unknown command %s\n", debugstr_w(str));
1207 return FALSE;
1210 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1211 VARIANT_BOOL *pfRet)
1213 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1214 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1215 return E_NOTIMPL;
1218 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1219 VARIANT_BOOL *pfRet)
1221 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1222 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1223 return E_NOTIMPL;
1226 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1227 VARIANT_BOOL *pfRet)
1229 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1230 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1231 return E_NOTIMPL;
1234 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1235 VARIANT_BOOL *pfRet)
1237 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1238 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1239 return E_NOTIMPL;
1242 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1243 BSTR *pfRet)
1245 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1246 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1247 return E_NOTIMPL;
1250 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1251 VARIANT *pfRet)
1253 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1254 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1255 return E_NOTIMPL;
1258 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1259 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1261 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1262 OLECMDID cmdid;
1263 VARIANT ret;
1264 HRESULT hres;
1266 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1268 if(!cmdid_from_string(cmdID, &cmdid))
1269 return OLECMDERR_E_NOTSUPPORTED;
1271 V_VT(&ret) = VT_EMPTY;
1272 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1273 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1274 if(FAILED(hres))
1275 return hres;
1277 if(V_VT(&ret) != VT_EMPTY) {
1278 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1279 VariantClear(&ret);
1282 *pfRet = VARIANT_TRUE;
1283 return S_OK;
1286 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1287 VARIANT_BOOL *pfRet)
1289 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1290 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1291 return E_NOTIMPL;
1294 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1295 IHTMLElement **newElem)
1297 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1298 HTMLElement *elem;
1299 HRESULT hres;
1301 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1303 hres = create_element(This->doc_node, eTag, &elem);
1304 if(FAILED(hres))
1305 return hres;
1307 *newElem = &elem->IHTMLElement_iface;
1308 return S_OK;
1311 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1313 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1314 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1315 return E_NOTIMPL;
1318 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1320 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1321 FIXME("(%p)->(%p)\n", This, p);
1322 return E_NOTIMPL;
1325 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1327 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1329 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1331 return set_doc_event(This, EVENTID_CLICK, &v);
1334 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1336 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1338 TRACE("(%p)->(%p)\n", This, p);
1340 return get_doc_event(This, EVENTID_CLICK, p);
1343 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1345 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1347 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1349 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1352 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1354 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1356 TRACE("(%p)->(%p)\n", This, p);
1358 return get_doc_event(This, EVENTID_DBLCLICK, p);
1361 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1363 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1365 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1367 return set_doc_event(This, EVENTID_KEYUP, &v);
1370 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1372 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1374 TRACE("(%p)->(%p)\n", This, p);
1376 return get_doc_event(This, EVENTID_KEYUP, p);
1379 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1381 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1383 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1385 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1388 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1390 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1392 TRACE("(%p)->(%p)\n", This, p);
1394 return get_doc_event(This, EVENTID_KEYDOWN, p);
1397 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1399 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1401 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1403 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1406 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1408 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1410 TRACE("(%p)->(%p)\n", This, p);
1412 return get_doc_event(This, EVENTID_KEYPRESS, p);
1415 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1417 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1419 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1421 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1424 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1426 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1428 TRACE("(%p)->(%p)\n", This, p);
1430 return get_doc_event(This, EVENTID_MOUSEUP, p);
1433 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1435 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1437 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1439 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1442 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1444 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1446 TRACE("(%p)->(%p)\n", This, p);
1448 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1451 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1453 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1455 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1457 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1460 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1462 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1464 TRACE("(%p)->(%p)\n", This, p);
1466 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1469 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1471 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1473 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1475 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1478 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1480 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1482 TRACE("(%p)->(%p)\n", This, p);
1484 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1487 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1489 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1491 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1493 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1496 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1498 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1500 TRACE("(%p)->(%p)\n", This, p);
1502 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1505 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1507 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1509 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1511 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1514 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1516 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1518 TRACE("(%p)->(%p)\n", This, p);
1520 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1523 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1525 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1526 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1527 return E_NOTIMPL;
1530 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1532 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1533 FIXME("(%p)->(%p)\n", This, p);
1534 return E_NOTIMPL;
1537 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1539 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1540 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1541 return E_NOTIMPL;
1544 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1546 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1547 FIXME("(%p)->(%p)\n", This, p);
1548 return E_NOTIMPL;
1551 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1553 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1554 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1555 return E_NOTIMPL;
1558 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1560 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1561 FIXME("(%p)->(%p)\n", This, p);
1562 return E_NOTIMPL;
1565 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1567 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1569 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1571 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1574 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1576 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1578 TRACE("(%p)->(%p)\n", This, p);
1580 return get_doc_event(This, EVENTID_DRAGSTART, p);
1583 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1585 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1587 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1589 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1592 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1594 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1596 TRACE("(%p)->(%p)\n", This, p);
1598 return get_doc_event(This, EVENTID_SELECTSTART, p);
1601 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1602 IHTMLElement **elementHit)
1604 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1605 nsIDOMElement *nselem;
1606 HTMLElement *element;
1607 nsresult nsres;
1608 HRESULT hres;
1610 TRACE("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1612 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1613 if(NS_FAILED(nsres)) {
1614 ERR("ElementFromPoint failed: %08lx\n", nsres);
1615 return E_FAIL;
1618 if(!nselem) {
1619 *elementHit = NULL;
1620 return S_OK;
1623 hres = get_element(nselem, &element);
1624 nsIDOMElement_Release(nselem);
1625 if(FAILED(hres))
1626 return hres;
1628 *elementHit = &element->IHTMLElement_iface;
1629 return S_OK;
1632 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1634 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1635 HRESULT hres;
1637 TRACE("(%p)->(%p)\n", This, p);
1639 hres = IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
1640 return hres == S_OK && !*p ? E_FAIL : hres;
1643 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1644 IHTMLStyleSheetsCollection **p)
1646 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1647 nsIDOMStyleSheetList *nsstylelist;
1648 nsresult nsres;
1649 HRESULT hres;
1651 TRACE("(%p)->(%p)\n", This, p);
1653 *p = NULL;
1655 if(!This->doc_node->nsdoc) {
1656 WARN("NULL nsdoc\n");
1657 return E_UNEXPECTED;
1660 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1661 if(NS_FAILED(nsres)) {
1662 ERR("GetStyleSheets failed: %08lx\n", nsres);
1663 return map_nsresult(nsres);
1666 hres = create_style_sheet_collection(nsstylelist,
1667 dispex_compat_mode(&This->doc_node->node.event_target.dispex), p);
1668 nsIDOMStyleSheetList_Release(nsstylelist);
1669 return hres;
1672 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1674 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1675 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1676 return E_NOTIMPL;
1679 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1681 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1682 FIXME("(%p)->(%p)\n", This, p);
1683 return E_NOTIMPL;
1686 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1688 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1689 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1690 return E_NOTIMPL;
1693 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1695 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1696 FIXME("(%p)->(%p)\n", This, p);
1697 return E_NOTIMPL;
1700 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1702 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1704 TRACE("(%p)->(%p)\n", This, String);
1706 return dispex_to_string(&This->doc_node->node.event_target.dispex, String);
1709 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1710 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1712 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1713 nsIDOMHTMLHeadElement *head_elem;
1714 IHTMLStyleElement *style_elem;
1715 HTMLElement *elem;
1716 nsresult nsres;
1717 HRESULT hres;
1719 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1721 if(!This->doc_node->nsdoc) {
1722 FIXME("not a real doc object\n");
1723 return E_NOTIMPL;
1726 if(lIndex != -1)
1727 FIXME("Unsupported lIndex %ld\n", lIndex);
1729 if(bstrHref && *bstrHref) {
1730 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
1731 return create_style_sheet(NULL, dispex_compat_mode(&This->doc_node->node.event_target.dispex),
1732 ppnewStyleSheet);
1735 hres = create_element(This->doc_node, L"style", &elem);
1736 if(FAILED(hres))
1737 return hres;
1739 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
1740 if(NS_SUCCEEDED(nsres)) {
1741 nsIDOMNode *head_node, *tmp_node;
1743 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
1744 nsIDOMHTMLHeadElement_Release(head_elem);
1745 assert(nsres == NS_OK);
1747 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
1748 nsIDOMNode_Release(head_node);
1749 if(NS_SUCCEEDED(nsres) && tmp_node)
1750 nsIDOMNode_Release(tmp_node);
1752 if(NS_FAILED(nsres)) {
1753 IHTMLElement_Release(&elem->IHTMLElement_iface);
1754 return E_FAIL;
1757 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
1758 assert(hres == S_OK);
1759 IHTMLElement_Release(&elem->IHTMLElement_iface);
1761 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
1762 IHTMLStyleElement_Release(style_elem);
1763 return hres;
1766 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1767 HTMLDocument_QueryInterface,
1768 HTMLDocument_AddRef,
1769 HTMLDocument_Release,
1770 HTMLDocument_GetTypeInfoCount,
1771 HTMLDocument_GetTypeInfo,
1772 HTMLDocument_GetIDsOfNames,
1773 HTMLDocument_Invoke,
1774 HTMLDocument_get_Script,
1775 HTMLDocument_get_all,
1776 HTMLDocument_get_body,
1777 HTMLDocument_get_activeElement,
1778 HTMLDocument_get_images,
1779 HTMLDocument_get_applets,
1780 HTMLDocument_get_links,
1781 HTMLDocument_get_forms,
1782 HTMLDocument_get_anchors,
1783 HTMLDocument_put_title,
1784 HTMLDocument_get_title,
1785 HTMLDocument_get_scripts,
1786 HTMLDocument_put_designMode,
1787 HTMLDocument_get_designMode,
1788 HTMLDocument_get_selection,
1789 HTMLDocument_get_readyState,
1790 HTMLDocument_get_frames,
1791 HTMLDocument_get_embeds,
1792 HTMLDocument_get_plugins,
1793 HTMLDocument_put_alinkColor,
1794 HTMLDocument_get_alinkColor,
1795 HTMLDocument_put_bgColor,
1796 HTMLDocument_get_bgColor,
1797 HTMLDocument_put_fgColor,
1798 HTMLDocument_get_fgColor,
1799 HTMLDocument_put_linkColor,
1800 HTMLDocument_get_linkColor,
1801 HTMLDocument_put_vlinkColor,
1802 HTMLDocument_get_vlinkColor,
1803 HTMLDocument_get_referrer,
1804 HTMLDocument_get_location,
1805 HTMLDocument_get_lastModified,
1806 HTMLDocument_put_URL,
1807 HTMLDocument_get_URL,
1808 HTMLDocument_put_domain,
1809 HTMLDocument_get_domain,
1810 HTMLDocument_put_cookie,
1811 HTMLDocument_get_cookie,
1812 HTMLDocument_put_expando,
1813 HTMLDocument_get_expando,
1814 HTMLDocument_put_charset,
1815 HTMLDocument_get_charset,
1816 HTMLDocument_put_defaultCharset,
1817 HTMLDocument_get_defaultCharset,
1818 HTMLDocument_get_mimeType,
1819 HTMLDocument_get_fileSize,
1820 HTMLDocument_get_fileCreatedDate,
1821 HTMLDocument_get_fileModifiedDate,
1822 HTMLDocument_get_fileUpdatedDate,
1823 HTMLDocument_get_security,
1824 HTMLDocument_get_protocol,
1825 HTMLDocument_get_nameProp,
1826 HTMLDocument_write,
1827 HTMLDocument_writeln,
1828 HTMLDocument_open,
1829 HTMLDocument_close,
1830 HTMLDocument_clear,
1831 HTMLDocument_queryCommandSupported,
1832 HTMLDocument_queryCommandEnabled,
1833 HTMLDocument_queryCommandState,
1834 HTMLDocument_queryCommandIndeterm,
1835 HTMLDocument_queryCommandText,
1836 HTMLDocument_queryCommandValue,
1837 HTMLDocument_execCommand,
1838 HTMLDocument_execCommandShowHelp,
1839 HTMLDocument_createElement,
1840 HTMLDocument_put_onhelp,
1841 HTMLDocument_get_onhelp,
1842 HTMLDocument_put_onclick,
1843 HTMLDocument_get_onclick,
1844 HTMLDocument_put_ondblclick,
1845 HTMLDocument_get_ondblclick,
1846 HTMLDocument_put_onkeyup,
1847 HTMLDocument_get_onkeyup,
1848 HTMLDocument_put_onkeydown,
1849 HTMLDocument_get_onkeydown,
1850 HTMLDocument_put_onkeypress,
1851 HTMLDocument_get_onkeypress,
1852 HTMLDocument_put_onmouseup,
1853 HTMLDocument_get_onmouseup,
1854 HTMLDocument_put_onmousedown,
1855 HTMLDocument_get_onmousedown,
1856 HTMLDocument_put_onmousemove,
1857 HTMLDocument_get_onmousemove,
1858 HTMLDocument_put_onmouseout,
1859 HTMLDocument_get_onmouseout,
1860 HTMLDocument_put_onmouseover,
1861 HTMLDocument_get_onmouseover,
1862 HTMLDocument_put_onreadystatechange,
1863 HTMLDocument_get_onreadystatechange,
1864 HTMLDocument_put_onafterupdate,
1865 HTMLDocument_get_onafterupdate,
1866 HTMLDocument_put_onrowexit,
1867 HTMLDocument_get_onrowexit,
1868 HTMLDocument_put_onrowenter,
1869 HTMLDocument_get_onrowenter,
1870 HTMLDocument_put_ondragstart,
1871 HTMLDocument_get_ondragstart,
1872 HTMLDocument_put_onselectstart,
1873 HTMLDocument_get_onselectstart,
1874 HTMLDocument_elementFromPoint,
1875 HTMLDocument_get_parentWindow,
1876 HTMLDocument_get_styleSheets,
1877 HTMLDocument_put_onbeforeupdate,
1878 HTMLDocument_get_onbeforeupdate,
1879 HTMLDocument_put_onerrorupdate,
1880 HTMLDocument_get_onerrorupdate,
1881 HTMLDocument_toString,
1882 HTMLDocument_createStyleSheet
1885 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
1887 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
1890 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
1891 REFIID riid, void **ppv)
1893 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1894 return htmldoc_query_interface(This, riid, ppv);
1897 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
1899 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1900 return htmldoc_addref(This);
1903 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
1905 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1906 return htmldoc_release(This);
1909 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
1911 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1912 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1915 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
1916 LCID lcid, ITypeInfo **ppTInfo)
1918 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1919 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1922 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
1923 LPOLESTR *rgszNames, UINT cNames,
1924 LCID lcid, DISPID *rgDispId)
1926 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1927 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1928 rgDispId);
1931 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
1932 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1933 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1935 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1936 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1937 pDispParams, pVarResult, pExcepInfo, puArgErr);
1940 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
1942 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1943 FIXME("(%p)\n", This);
1944 return E_NOTIMPL;
1947 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
1949 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1951 WARN("(%p)->(%x)\n", This, fForce);
1953 /* Doing nothing here should be fine for us. */
1954 return S_OK;
1957 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
1958 IHTMLDOMNode **newTextNode)
1960 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1961 nsIDOMText *nstext;
1962 HTMLDOMNode *node;
1963 nsAString text_str;
1964 nsresult nsres;
1965 HRESULT hres;
1967 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
1969 if(!This->doc_node->nsdoc) {
1970 WARN("NULL nsdoc\n");
1971 return E_UNEXPECTED;
1974 nsAString_InitDepend(&text_str, text);
1975 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
1976 nsAString_Finish(&text_str);
1977 if(NS_FAILED(nsres)) {
1978 ERR("CreateTextNode failed: %08lx\n", nsres);
1979 return E_FAIL;
1982 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
1983 nsIDOMText_Release(nstext);
1984 if(FAILED(hres))
1985 return hres;
1987 *newTextNode = &node->IHTMLDOMNode_iface;
1988 return S_OK;
1991 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
1993 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1994 nsIDOMElement *nselem = NULL;
1995 HTMLElement *element;
1996 nsresult nsres;
1997 HRESULT hres;
1999 TRACE("(%p)->(%p)\n", This, p);
2001 if(This->window->readystate == READYSTATE_UNINITIALIZED) {
2002 *p = NULL;
2003 return S_OK;
2006 if(!This->doc_node->nsdoc) {
2007 WARN("NULL nsdoc\n");
2008 return E_UNEXPECTED;
2011 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
2012 if(NS_FAILED(nsres)) {
2013 ERR("GetDocumentElement failed: %08lx\n", nsres);
2014 return E_FAIL;
2017 if(!nselem) {
2018 *p = NULL;
2019 return S_OK;
2022 hres = get_element(nselem, &element);
2023 nsIDOMElement_Release(nselem);
2024 if(FAILED(hres))
2025 return hres;
2027 *p = &element->IHTMLElement_iface;
2028 return hres;
2031 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2033 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2035 TRACE("(%p)->(%p)\n", This, p);
2037 return elem_unique_id(++This->doc_node->unique_id, p);
2040 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2041 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2043 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2045 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2047 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2050 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2051 IDispatch *pDisp)
2053 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2055 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2057 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2060 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2062 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2063 FIXME("(%p)->()\n", This);
2064 return E_NOTIMPL;
2067 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2069 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2070 FIXME("(%p)->(%p)\n", This, p);
2071 return E_NOTIMPL;
2074 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2076 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2077 FIXME("(%p)->()\n", This);
2078 return E_NOTIMPL;
2081 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2083 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2084 FIXME("(%p)->(%p)\n", This, p);
2085 return E_NOTIMPL;
2088 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2090 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2091 FIXME("(%p)->()\n", This);
2092 return E_NOTIMPL;
2095 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2097 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2098 FIXME("(%p)->(%p)\n", This, p);
2099 return E_NOTIMPL;
2102 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2104 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2105 FIXME("(%p)->()\n", This);
2106 return E_NOTIMPL;
2109 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2111 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2112 FIXME("(%p)->(%p)\n", This, p);
2113 return E_NOTIMPL;
2116 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2118 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2119 FIXME("(%p)->()\n", This);
2120 return E_NOTIMPL;
2123 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2125 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2126 FIXME("(%p)->(%p)\n", This, p);
2127 return E_NOTIMPL;
2130 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2132 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2133 FIXME("(%p)->()\n", This);
2134 return E_NOTIMPL;
2137 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2139 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2140 FIXME("(%p)->(%p)\n", This, p);
2141 return E_NOTIMPL;
2144 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2146 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2147 FIXME("(%p)->()\n", This);
2148 return E_NOTIMPL;
2151 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2153 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2154 FIXME("(%p)->(%p)\n", This, p);
2155 return E_NOTIMPL;
2158 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2160 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2161 nsAString dir_str;
2162 nsresult nsres;
2164 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2166 if(!This->doc_node->nsdoc) {
2167 FIXME("NULL nsdoc\n");
2168 return E_UNEXPECTED;
2171 nsAString_InitDepend(&dir_str, v);
2172 nsres = nsIDOMHTMLDocument_SetDir(This->doc_node->nsdoc, &dir_str);
2173 nsAString_Finish(&dir_str);
2174 if(NS_FAILED(nsres)) {
2175 ERR("SetDir failed: %08lx\n", nsres);
2176 return E_FAIL;
2179 return S_OK;
2182 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2184 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2185 nsAString dir_str;
2186 nsresult nsres;
2188 TRACE("(%p)->(%p)\n", This, p);
2190 if(!This->doc_node->nsdoc) {
2191 FIXME("NULL nsdoc\n");
2192 return E_UNEXPECTED;
2195 nsAString_Init(&dir_str, NULL);
2196 nsres = nsIDOMHTMLDocument_GetDir(This->doc_node->nsdoc, &dir_str);
2197 return return_nsstr(nsres, &dir_str, p);
2200 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2202 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2204 TRACE("(%p)->()\n", This);
2206 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2209 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2211 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2213 TRACE("(%p)->(%p)\n", This, p);
2215 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2218 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2220 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2221 FIXME("(%p)->()\n", This);
2222 return E_NOTIMPL;
2225 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2227 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2228 FIXME("(%p)->(%p)\n", This, p);
2229 return E_NOTIMPL;
2232 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2233 IHTMLDocument2 **ppNewDoc)
2235 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2236 nsIDOMDocumentFragment *doc_frag;
2237 HTMLDocumentNode *docnode;
2238 nsresult nsres;
2239 HRESULT hres;
2241 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2243 if(!This->doc_node->nsdoc) {
2244 FIXME("NULL nsdoc\n");
2245 return E_NOTIMPL;
2248 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2249 if(NS_FAILED(nsres)) {
2250 ERR("CreateDocumentFragment failed: %08lx\n", nsres);
2251 return E_FAIL;
2254 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2255 nsIDOMDocumentFragment_Release(doc_frag);
2256 if(FAILED(hres))
2257 return hres;
2259 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2260 return S_OK;
2263 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2264 IHTMLDocument2 **p)
2266 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2267 FIXME("(%p)->(%p)\n", This, p);
2268 return E_NOTIMPL;
2271 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2272 VARIANT_BOOL v)
2274 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2275 FIXME("(%p)->(%x)\n", This, v);
2276 return E_NOTIMPL;
2279 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2280 VARIANT_BOOL *p)
2282 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2283 FIXME("(%p)->(%p)\n", This, p);
2284 return E_NOTIMPL;
2287 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2289 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2290 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2291 return E_NOTIMPL;
2294 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2296 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2297 FIXME("(%p)->(%p)\n", This, p);
2298 return E_NOTIMPL;
2301 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2303 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2305 TRACE("(%p)->(%p)\n", This, p);
2307 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2310 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2311 VARIANT_BOOL v)
2313 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2314 FIXME("(%p)->()\n", This);
2315 return E_NOTIMPL;
2318 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2319 VARIANT_BOOL *p)
2321 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2322 FIXME("(%p)->(%p)\n", This, p);
2323 return E_NOTIMPL;
2326 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2328 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2329 FIXME("(%p)->()\n", This);
2330 return E_NOTIMPL;
2333 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2335 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2336 FIXME("(%p)->(%p)\n", This, p);
2337 return E_NOTIMPL;
2340 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2341 IHTMLElementCollection **ppelColl)
2343 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2344 nsIDOMNodeList *node_list;
2345 nsAString selector_str;
2346 WCHAR *selector;
2347 nsresult nsres;
2348 static const WCHAR formatW[] = L"*[id=%s],*[name=%s]";
2350 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2352 if(!This->doc_node || !This->doc_node->nsdoc) {
2353 /* We should probably return an empty collection. */
2354 FIXME("No nsdoc\n");
2355 return E_NOTIMPL;
2358 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2359 if(!selector)
2360 return E_OUTOFMEMORY;
2361 swprintf(selector, 2*SysStringLen(v) + ARRAY_SIZE(formatW), formatW, v, v);
2364 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2365 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2366 * types and search should be case insensitive. Those are currently not supported properly.
2368 nsAString_InitDepend(&selector_str, selector);
2369 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2370 nsAString_Finish(&selector_str);
2371 heap_free(selector);
2372 if(NS_FAILED(nsres)) {
2373 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2374 return E_FAIL;
2377 *ppelColl = create_collection_from_nodelist(node_list, This->doc_node->document_mode);
2378 nsIDOMNodeList_Release(node_list);
2379 return S_OK;
2383 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2384 IHTMLElement **pel)
2386 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2387 HTMLElement *elem;
2388 HRESULT hres;
2390 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2392 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2393 if(FAILED(hres) || !elem) {
2394 *pel = NULL;
2395 return hres;
2398 *pel = &elem->IHTMLElement_iface;
2399 return S_OK;
2403 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2404 IHTMLElementCollection **pelColl)
2406 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2407 nsIDOMNodeList *nslist;
2408 nsAString id_str;
2409 nsresult nsres;
2411 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2413 if(This->doc_node->nsdoc) {
2414 nsAString_InitDepend(&id_str, v);
2415 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2416 nsAString_Finish(&id_str);
2417 if(FAILED(nsres)) {
2418 ERR("GetElementByName failed: %08lx\n", nsres);
2419 return E_FAIL;
2421 }else {
2422 nsIDOMDocumentFragment *docfrag;
2423 nsAString nsstr;
2425 if(v) {
2426 const WCHAR *ptr;
2427 for(ptr=v; *ptr; ptr++) {
2428 if(!iswalnum(*ptr)) {
2429 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2430 return E_NOTIMPL;
2435 nsres = nsIDOMNode_QueryInterface(This->doc_node->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2436 if(NS_FAILED(nsres)) {
2437 ERR("Could not get nsIDOMDocumentFragment iface: %08lx\n", nsres);
2438 return E_UNEXPECTED;
2441 nsAString_InitDepend(&nsstr, v);
2442 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2443 nsAString_Finish(&nsstr);
2444 nsIDOMDocumentFragment_Release(docfrag);
2445 if(NS_FAILED(nsres)) {
2446 ERR("QuerySelectorAll failed: %08lx\n", nsres);
2447 return E_FAIL;
2452 *pelColl = create_collection_from_nodelist(nslist, This->doc_node->document_mode);
2453 nsIDOMNodeList_Release(nslist);
2455 return S_OK;
2458 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2459 HTMLDocument3_QueryInterface,
2460 HTMLDocument3_AddRef,
2461 HTMLDocument3_Release,
2462 HTMLDocument3_GetTypeInfoCount,
2463 HTMLDocument3_GetTypeInfo,
2464 HTMLDocument3_GetIDsOfNames,
2465 HTMLDocument3_Invoke,
2466 HTMLDocument3_releaseCapture,
2467 HTMLDocument3_recalc,
2468 HTMLDocument3_createTextNode,
2469 HTMLDocument3_get_documentElement,
2470 HTMLDocument3_get_uniqueID,
2471 HTMLDocument3_attachEvent,
2472 HTMLDocument3_detachEvent,
2473 HTMLDocument3_put_onrowsdelete,
2474 HTMLDocument3_get_onrowsdelete,
2475 HTMLDocument3_put_onrowsinserted,
2476 HTMLDocument3_get_onrowsinserted,
2477 HTMLDocument3_put_oncellchange,
2478 HTMLDocument3_get_oncellchange,
2479 HTMLDocument3_put_ondatasetchanged,
2480 HTMLDocument3_get_ondatasetchanged,
2481 HTMLDocument3_put_ondataavailable,
2482 HTMLDocument3_get_ondataavailable,
2483 HTMLDocument3_put_ondatasetcomplete,
2484 HTMLDocument3_get_ondatasetcomplete,
2485 HTMLDocument3_put_onpropertychange,
2486 HTMLDocument3_get_onpropertychange,
2487 HTMLDocument3_put_dir,
2488 HTMLDocument3_get_dir,
2489 HTMLDocument3_put_oncontextmenu,
2490 HTMLDocument3_get_oncontextmenu,
2491 HTMLDocument3_put_onstop,
2492 HTMLDocument3_get_onstop,
2493 HTMLDocument3_createDocumentFragment,
2494 HTMLDocument3_get_parentDocument,
2495 HTMLDocument3_put_enableDownload,
2496 HTMLDocument3_get_enableDownload,
2497 HTMLDocument3_put_baseUrl,
2498 HTMLDocument3_get_baseUrl,
2499 HTMLDocument3_get_childNodes,
2500 HTMLDocument3_put_inheritStyleSheets,
2501 HTMLDocument3_get_inheritStyleSheets,
2502 HTMLDocument3_put_onbeforeeditfocus,
2503 HTMLDocument3_get_onbeforeeditfocus,
2504 HTMLDocument3_getElementsByName,
2505 HTMLDocument3_getElementById,
2506 HTMLDocument3_getElementsByTagName
2509 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2511 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2514 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2515 REFIID riid, void **ppv)
2517 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2518 return htmldoc_query_interface(This, riid, ppv);
2521 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2523 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2524 return htmldoc_addref(This);
2527 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2529 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2530 return htmldoc_release(This);
2533 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2535 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2536 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2539 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2540 LCID lcid, ITypeInfo **ppTInfo)
2542 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2543 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2546 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2547 LPOLESTR *rgszNames, UINT cNames,
2548 LCID lcid, DISPID *rgDispId)
2550 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2551 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2552 rgDispId);
2555 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2556 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2557 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2559 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2560 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2561 pDispParams, pVarResult, pExcepInfo, puArgErr);
2564 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2566 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2567 nsIDOMHTMLElement *nsbody;
2568 nsresult nsres;
2570 TRACE("(%p)->()\n", This);
2572 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2573 if(NS_FAILED(nsres) || !nsbody) {
2574 ERR("GetBody failed: %08lx\n", nsres);
2575 return E_FAIL;
2578 nsres = nsIDOMHTMLElement_Focus(nsbody);
2579 nsIDOMHTMLElement_Release(nsbody);
2580 if(NS_FAILED(nsres)) {
2581 ERR("Focus failed: %08lx\n", nsres);
2582 return E_FAIL;
2585 return S_OK;
2588 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2590 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2591 cpp_bool has_focus;
2592 nsresult nsres;
2594 TRACE("(%p)->(%p)\n", This, pfFocus);
2596 if(!This->doc_node->nsdoc) {
2597 FIXME("Unimplemented for fragments.\n");
2598 return E_NOTIMPL;
2601 nsres = nsIDOMHTMLDocument_HasFocus(This->doc_node->nsdoc, &has_focus);
2602 assert(nsres == NS_OK);
2604 *pfFocus = variant_bool(has_focus);
2605 return S_OK;
2608 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2610 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2612 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2614 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2617 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2619 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2621 TRACE("(%p)->(%p)\n", This, p);
2623 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2626 static HRESULT WINAPI HTMLDocument4_get_namespaces(IHTMLDocument4 *iface, IDispatch **p)
2628 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2630 TRACE("(%p)->(%p)\n", This, p);
2632 if(!This->doc_node->namespaces) {
2633 HRESULT hres;
2635 hres = create_namespace_collection(dispex_compat_mode(&This->doc_node->node.event_target.dispex),
2636 &This->doc_node->namespaces);
2637 if(FAILED(hres))
2638 return hres;
2641 IHTMLNamespaceCollection_AddRef(This->doc_node->namespaces);
2642 *p = (IDispatch*)This->doc_node->namespaces;
2643 return S_OK;
2646 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2647 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2649 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2650 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2651 return E_NOTIMPL;
2654 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2656 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2657 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2658 return E_NOTIMPL;
2661 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2663 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2664 FIXME("(%p)->(%p)\n", This, p);
2665 return E_NOTIMPL;
2668 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2669 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2671 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2673 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2675 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2676 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2677 return E_NOTIMPL;
2680 return create_event_obj(dispex_compat_mode(&This->doc_node->node.event_target.dispex), ppEventObj);
2683 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2684 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2686 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2688 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2690 return fire_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2693 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2694 IHTMLRenderStyle **ppIHTMLRenderStyle)
2696 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2697 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2698 return E_NOTIMPL;
2701 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2703 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2704 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2705 return E_NOTIMPL;
2708 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2710 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2711 FIXME("(%p)->(%p)\n", This, p);
2712 return E_NOTIMPL;
2715 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2717 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2718 FIXME("(%p)->(%p)\n", This, p);
2719 return E_NOTIMPL;
2722 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2723 HTMLDocument4_QueryInterface,
2724 HTMLDocument4_AddRef,
2725 HTMLDocument4_Release,
2726 HTMLDocument4_GetTypeInfoCount,
2727 HTMLDocument4_GetTypeInfo,
2728 HTMLDocument4_GetIDsOfNames,
2729 HTMLDocument4_Invoke,
2730 HTMLDocument4_focus,
2731 HTMLDocument4_hasFocus,
2732 HTMLDocument4_put_onselectionchange,
2733 HTMLDocument4_get_onselectionchange,
2734 HTMLDocument4_get_namespaces,
2735 HTMLDocument4_createDocumentFromUrl,
2736 HTMLDocument4_put_media,
2737 HTMLDocument4_get_media,
2738 HTMLDocument4_createEventObject,
2739 HTMLDocument4_fireEvent,
2740 HTMLDocument4_createRenderStyle,
2741 HTMLDocument4_put_oncontrolselect,
2742 HTMLDocument4_get_oncontrolselect,
2743 HTMLDocument4_get_URLEncoded
2746 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2748 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2751 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2752 REFIID riid, void **ppv)
2754 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2755 return htmldoc_query_interface(This, riid, ppv);
2758 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2760 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2761 return htmldoc_addref(This);
2764 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2766 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2767 return htmldoc_release(This);
2770 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2772 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2773 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2776 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2777 LCID lcid, ITypeInfo **ppTInfo)
2779 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2780 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2783 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2784 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2786 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2787 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2788 rgDispId);
2791 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2792 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2793 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2795 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2796 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2797 pDispParams, pVarResult, pExcepInfo, puArgErr);
2800 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2802 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2804 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2806 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
2809 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2811 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2813 TRACE("(%p)->(%p)\n", This, p);
2815 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
2818 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2820 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2821 FIXME("(%p)->(%p)\n", This, p);
2822 return E_NOTIMPL;
2825 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2827 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2828 HTMLDocumentNode *doc_node = This->doc_node;
2830 TRACE("(%p)->(%p)\n", This, p);
2832 if(!doc_node->dom_implementation) {
2833 HRESULT hres;
2835 hres = create_dom_implementation(doc_node, &doc_node->dom_implementation);
2836 if(FAILED(hres))
2837 return hres;
2840 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2841 *p = doc_node->dom_implementation;
2842 return S_OK;
2845 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2846 IHTMLDOMAttribute **ppattribute)
2848 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2849 HTMLDOMAttribute *attr;
2850 HRESULT hres;
2852 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2854 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, dispex_compat_mode(&This->doc_node->node.event_target.dispex), &attr);
2855 if(FAILED(hres))
2856 return hres;
2858 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2859 return S_OK;
2862 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2863 IHTMLDOMNode **ppRetNode)
2865 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2866 nsIDOMComment *nscomment;
2867 HTMLElement *elem;
2868 nsAString str;
2869 nsresult nsres;
2870 HRESULT hres;
2872 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2874 if(!This->doc_node->nsdoc) {
2875 WARN("NULL nsdoc\n");
2876 return E_UNEXPECTED;
2879 nsAString_InitDepend(&str, bstrdata);
2880 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2881 nsAString_Finish(&str);
2882 if(NS_FAILED(nsres)) {
2883 ERR("CreateTextNode failed: %08lx\n", nsres);
2884 return E_FAIL;
2887 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2888 nsIDOMComment_Release(nscomment);
2889 if(FAILED(hres))
2890 return hres;
2892 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2893 return S_OK;
2896 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2898 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2900 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2902 return set_doc_event(This, EVENTID_FOCUSIN, &v);
2905 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2907 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2909 TRACE("(%p)->(%p)\n", This, p);
2911 return get_doc_event(This, EVENTID_FOCUSIN, p);
2914 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2916 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2918 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2920 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
2923 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2925 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2927 TRACE("(%p)->(%p)\n", This, p);
2929 return get_doc_event(This, EVENTID_FOCUSOUT, p);
2932 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2934 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2935 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2936 return E_NOTIMPL;
2939 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2941 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2942 FIXME("(%p)->(%p)\n", This, p);
2943 return E_NOTIMPL;
2946 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2948 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2949 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2950 return E_NOTIMPL;
2953 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2955 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2956 FIXME("(%p)->(%p)\n", This, p);
2957 return E_NOTIMPL;
2960 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2962 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2963 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2964 return E_NOTIMPL;
2967 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2969 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2970 FIXME("(%p)->(%p)\n", This, p);
2971 return E_NOTIMPL;
2974 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2976 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2977 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2978 return E_NOTIMPL;
2981 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2983 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2984 FIXME("(%p)->(%p)\n", This, p);
2985 return E_NOTIMPL;
2988 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2990 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2992 TRACE("(%p)->(%p)\n", This, p);
2994 *p = SysAllocString(This->doc_node->document_mode <= COMPAT_MODE_IE5 ? L"BackCompat" : L"CSS1Compat");
2995 return *p ? S_OK : E_OUTOFMEMORY;
2998 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
2999 HTMLDocument5_QueryInterface,
3000 HTMLDocument5_AddRef,
3001 HTMLDocument5_Release,
3002 HTMLDocument5_GetTypeInfoCount,
3003 HTMLDocument5_GetTypeInfo,
3004 HTMLDocument5_GetIDsOfNames,
3005 HTMLDocument5_Invoke,
3006 HTMLDocument5_put_onmousewheel,
3007 HTMLDocument5_get_onmousewheel,
3008 HTMLDocument5_get_doctype,
3009 HTMLDocument5_get_implementation,
3010 HTMLDocument5_createAttribute,
3011 HTMLDocument5_createComment,
3012 HTMLDocument5_put_onfocusin,
3013 HTMLDocument5_get_onfocusin,
3014 HTMLDocument5_put_onfocusout,
3015 HTMLDocument5_get_onfocusout,
3016 HTMLDocument5_put_onactivate,
3017 HTMLDocument5_get_onactivate,
3018 HTMLDocument5_put_ondeactivate,
3019 HTMLDocument5_get_ondeactivate,
3020 HTMLDocument5_put_onbeforeactivate,
3021 HTMLDocument5_get_onbeforeactivate,
3022 HTMLDocument5_put_onbeforedeactivate,
3023 HTMLDocument5_get_onbeforedeactivate,
3024 HTMLDocument5_get_compatMode
3027 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3029 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
3032 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
3033 REFIID riid, void **ppv)
3035 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3036 return htmldoc_query_interface(This, riid, ppv);
3039 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3041 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3042 return htmldoc_addref(This);
3045 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3047 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3048 return htmldoc_release(This);
3051 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3053 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3054 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3057 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
3058 LCID lcid, ITypeInfo **ppTInfo)
3060 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3061 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3064 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
3065 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3067 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3068 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3069 rgDispId);
3072 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
3073 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3074 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3076 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3077 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3078 pDispParams, pVarResult, pExcepInfo, puArgErr);
3081 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3082 IHTMLDocumentCompatibleInfoCollection **p)
3084 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3085 FIXME("(%p)->(%p)\n", This, p);
3086 return E_NOTIMPL;
3089 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3091 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3093 TRACE("(%p)->(%p)\n", This, p);
3095 if(!This->doc_node) {
3096 FIXME("NULL doc_node\n");
3097 return E_UNEXPECTED;
3100 V_VT(p) = VT_R4;
3101 V_R4(p) = compat_mode_info[This->doc_node->document_mode].document_mode;
3102 return S_OK;
3105 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3106 VARIANT *p)
3108 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3109 FIXME("(%p)->(%p)\n", This, p);
3110 return E_NOTIMPL;
3113 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3115 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3116 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3117 return E_NOTIMPL;
3120 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3121 VARIANT *p)
3123 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3124 FIXME("(%p)->(%p)\n", This, p);
3125 return E_NOTIMPL;
3128 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3130 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3131 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3132 return E_NOTIMPL;
3135 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3136 BSTR bstrId, IHTMLElement2 **p)
3138 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3139 nsIDOMElement *nselem;
3140 HTMLElement *elem;
3141 nsAString nsstr;
3142 nsresult nsres;
3143 HRESULT hres;
3145 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3148 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3149 * not search for name attributes, so we may simply let Gecko do the right thing.
3152 if(!This->doc_node->nsdoc) {
3153 FIXME("Not a document\n");
3154 return E_FAIL;
3157 nsAString_InitDepend(&nsstr, bstrId);
3158 nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &nsstr, &nselem);
3159 nsAString_Finish(&nsstr);
3160 if(NS_FAILED(nsres)) {
3161 ERR("GetElementById failed: %08lx\n", nsres);
3162 return E_FAIL;
3165 if(!nselem) {
3166 *p = NULL;
3167 return S_OK;
3170 hres = get_element(nselem, &elem);
3171 nsIDOMElement_Release(nselem);
3172 if(FAILED(hres))
3173 return hres;
3175 *p = &elem->IHTMLElement2_iface;
3176 return S_OK;
3179 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3181 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3182 FIXME("(%p)->()\n", This);
3183 return E_NOTIMPL;
3186 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3187 HTMLDocument6_QueryInterface,
3188 HTMLDocument6_AddRef,
3189 HTMLDocument6_Release,
3190 HTMLDocument6_GetTypeInfoCount,
3191 HTMLDocument6_GetTypeInfo,
3192 HTMLDocument6_GetIDsOfNames,
3193 HTMLDocument6_Invoke,
3194 HTMLDocument6_get_compatible,
3195 HTMLDocument6_get_documentMode,
3196 HTMLDocument6_put_onstorage,
3197 HTMLDocument6_get_onstorage,
3198 HTMLDocument6_put_onstoragecommit,
3199 HTMLDocument6_get_onstoragecommit,
3200 HTMLDocument6_getElementById,
3201 HTMLDocument6_updateSettings
3204 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3206 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3209 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3211 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3212 return htmldoc_query_interface(This, riid, ppv);
3215 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3217 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3218 return htmldoc_addref(This);
3221 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3223 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3224 return htmldoc_release(This);
3227 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3229 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3230 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3233 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3234 LCID lcid, ITypeInfo **ppTInfo)
3236 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3237 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3240 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3241 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3243 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3244 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3245 rgDispId);
3248 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3249 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3250 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3252 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3253 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3254 pDispParams, pVarResult, pExcepInfo, puArgErr);
3257 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3259 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface)->doc_node;
3261 TRACE("(%p)->(%p)\n", This, p);
3263 if(This->window && This->window->base.outer_window) {
3264 *p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
3265 IHTMLWindow2_AddRef(*p);
3266 }else {
3267 *p = NULL;
3269 return S_OK;
3272 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3274 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3275 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3276 return E_NOTIMPL;
3279 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3281 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3282 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3283 return E_NOTIMPL;
3286 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3287 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3289 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3290 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3291 return E_NOTIMPL;
3294 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3296 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3297 nsIDOMElement *dom_element;
3298 HTMLElement *element;
3299 nsAString ns, tag;
3300 nsresult nsres;
3301 HRESULT hres;
3303 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3305 if(!This->doc_node->nsdoc) {
3306 FIXME("NULL nsdoc\n");
3307 return E_FAIL;
3310 if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
3311 FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
3313 nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
3314 nsAString_InitDepend(&tag, bstrTag);
3315 nsres = nsIDOMHTMLDocument_CreateElementNS(This->doc_node->nsdoc, &ns, &tag, &dom_element);
3316 nsAString_Finish(&ns);
3317 nsAString_Finish(&tag);
3318 if(NS_FAILED(nsres)) {
3319 WARN("CreateElementNS failed: %08lx\n", nsres);
3320 return map_nsresult(nsres);
3323 hres = HTMLElement_Create(This->doc_node, (nsIDOMNode*)dom_element, FALSE, &element);
3324 nsIDOMElement_Release(dom_element);
3325 if(FAILED(hres))
3326 return hres;
3328 *newElem = &element->IHTMLElement_iface;
3329 return S_OK;
3332 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3333 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3335 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3336 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3337 return E_NOTIMPL;
3340 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3342 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3343 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3344 return E_NOTIMPL;
3347 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3349 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3351 TRACE("(%p)->(%p)\n", This, p);
3353 return get_doc_event(This, EVENTID_MSTHUMBNAILCLICK, p);
3356 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3358 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3359 nsAString charset_str;
3360 nsresult nsres;
3362 TRACE("(%p)->(%p)\n", This, p);
3364 if(!This->doc_node->nsdoc) {
3365 FIXME("NULL nsdoc\n");
3366 return E_FAIL;
3369 nsAString_Init(&charset_str, NULL);
3370 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
3371 return return_nsstr(nsres, &charset_str, p);
3374 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3376 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3378 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3380 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3383 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3385 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3387 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3389 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3392 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3394 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3395 nsIDOMNodeList *nslist;
3396 nsAString nsstr;
3397 nsresult nsres;
3399 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3401 if(!This->doc_node->nsdoc) {
3402 FIXME("NULL nsdoc not supported\n");
3403 return E_NOTIMPL;
3406 nsAString_InitDepend(&nsstr, v);
3407 nsres = nsIDOMHTMLDocument_GetElementsByClassName(This->doc_node->nsdoc, &nsstr, &nslist);
3408 nsAString_Finish(&nsstr);
3409 if(FAILED(nsres)) {
3410 ERR("GetElementByClassName failed: %08lx\n", nsres);
3411 return E_FAIL;
3415 *pel = create_collection_from_nodelist(nslist, This->doc_node->document_mode);
3416 nsIDOMNodeList_Release(nslist);
3417 return S_OK;
3420 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3421 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3423 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3424 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3425 return E_NOTIMPL;
3428 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3430 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3431 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3432 return E_NOTIMPL;
3435 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3437 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3438 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3439 return E_NOTIMPL;
3442 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3444 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3445 FIXME("(%p)->(%p)\n", This, p);
3446 return E_NOTIMPL;
3449 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3451 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3453 TRACE("(%p)->(%p)\n", This, p);
3455 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3458 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3460 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3461 FIXME("(%p)->(%p)\n", This, p);
3462 return E_NOTIMPL;
3465 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3467 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3468 FIXME("(%p)->(%p)\n", This, p);
3469 return E_NOTIMPL;
3472 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3474 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3475 FIXME("(%p)->(%x)\n", This, v);
3476 return E_NOTIMPL;
3479 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3481 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3482 FIXME("(%p)->(%p)\n", This, p);
3483 return E_NOTIMPL;
3486 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3488 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3489 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3490 return E_NOTIMPL;
3493 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3495 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3496 FIXME("(%p)->(%p)\n", This, p);
3497 return E_NOTIMPL;
3500 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3502 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3503 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3504 return E_NOTIMPL;
3507 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3509 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3511 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3513 return set_doc_event(This, EVENTID_ABORT, &v);
3516 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3518 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3520 TRACE("(%p)->(%p)\n", This, p);
3522 return get_doc_event(This, EVENTID_ABORT, p);
3525 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3527 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3529 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3531 return set_doc_event(This, EVENTID_BLUR, &v);
3534 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3536 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3538 TRACE("(%p)->(%p)\n", This, p);
3540 return get_doc_event(This, EVENTID_BLUR, p);
3543 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3545 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3546 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3547 return E_NOTIMPL;
3550 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3552 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3553 FIXME("(%p)->(%p)\n", This, p);
3554 return E_NOTIMPL;
3557 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3559 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3560 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3561 return E_NOTIMPL;
3564 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3566 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3567 FIXME("(%p)->(%p)\n", This, p);
3568 return E_NOTIMPL;
3571 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3573 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3575 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3577 return set_doc_event(This, EVENTID_CHANGE, &v);
3580 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3582 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3584 TRACE("(%p)->(%p)\n", This, p);
3586 return get_doc_event(This, EVENTID_CHANGE, p);
3589 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3591 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3593 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3595 return set_doc_event(This, EVENTID_DRAG, &v);
3598 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3600 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3602 TRACE("(%p)->(%p)\n", This, p);
3604 return get_doc_event(This, EVENTID_DRAG, p);
3607 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3609 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3610 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3611 return E_NOTIMPL;
3614 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3616 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3617 FIXME("(%p)->(%p)\n", This, p);
3618 return E_NOTIMPL;
3621 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3623 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3624 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3625 return E_NOTIMPL;
3628 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3630 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3631 FIXME("(%p)->(%p)\n", This, p);
3632 return E_NOTIMPL;
3635 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3637 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3638 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3639 return E_NOTIMPL;
3642 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3644 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3645 FIXME("(%p)->(%p)\n", This, p);
3646 return E_NOTIMPL;
3649 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3651 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3652 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3653 return E_NOTIMPL;
3656 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3658 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3659 FIXME("(%p)->(%p)\n", This, p);
3660 return E_NOTIMPL;
3663 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3665 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3666 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3667 return E_NOTIMPL;
3670 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3672 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3673 FIXME("(%p)->(%p)\n", This, p);
3674 return E_NOTIMPL;
3677 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3679 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3680 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3681 return E_NOTIMPL;
3684 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
3686 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3687 FIXME("(%p)->(%p)\n", This, p);
3688 return E_NOTIMPL;
3691 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
3693 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3694 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3695 return E_NOTIMPL;
3698 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
3700 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3701 FIXME("(%p)->(%p)\n", This, p);
3702 return E_NOTIMPL;
3705 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
3707 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3708 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3709 return E_NOTIMPL;
3712 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
3714 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3715 FIXME("(%p)->(%p)\n", This, p);
3716 return E_NOTIMPL;
3719 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
3721 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3723 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3725 return set_doc_event(This, EVENTID_ERROR, &v);
3728 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
3730 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3732 TRACE("(%p)->(%p)\n", This, p);
3734 return get_doc_event(This, EVENTID_ERROR, p);
3737 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
3739 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3741 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3743 return set_doc_event(This, EVENTID_FOCUS, &v);
3746 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
3748 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3750 TRACE("(%p)->(%p)\n", This, p);
3752 return get_doc_event(This, EVENTID_FOCUS, p);
3755 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
3757 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3759 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3761 return set_doc_event(This, EVENTID_INPUT, &v);
3764 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
3766 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3768 TRACE("(%p)->(%p)\n", This, p);
3770 return get_doc_event(This, EVENTID_INPUT, p);
3773 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
3775 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3777 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3779 return set_doc_event(This, EVENTID_LOAD, &v);
3782 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
3784 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3786 TRACE("(%p)->(%p)\n", This, p);
3788 return get_doc_event(This, EVENTID_LOAD, p);
3791 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(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_onloadeddata(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_onloadedmetadata(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_onloadedmetadata(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_onloadstart(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_onloadstart(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_onpause(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_onpause(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_put_onplay(IHTMLDocument7 *iface, VARIANT v)
3849 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3850 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3851 return E_NOTIMPL;
3854 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
3856 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3857 FIXME("(%p)->(%p)\n", This, p);
3858 return E_NOTIMPL;
3861 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
3863 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3864 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3865 return E_NOTIMPL;
3868 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
3870 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3871 FIXME("(%p)->(%p)\n", This, p);
3872 return E_NOTIMPL;
3875 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
3877 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3878 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3879 return E_NOTIMPL;
3882 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
3884 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3885 FIXME("(%p)->(%p)\n", This, p);
3886 return E_NOTIMPL;
3889 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
3891 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3892 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3893 return E_NOTIMPL;
3896 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
3898 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3899 FIXME("(%p)->(%p)\n", This, p);
3900 return E_NOTIMPL;
3903 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
3905 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3906 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3907 return E_NOTIMPL;
3910 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
3912 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3913 FIXME("(%p)->(%p)\n", This, p);
3914 return E_NOTIMPL;
3917 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
3919 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3921 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3923 return set_doc_event(This, EVENTID_SCROLL, &v);
3926 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
3928 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3930 TRACE("(%p)->(%p)\n", This, p);
3932 return get_doc_event(This, EVENTID_SCROLL, p);
3935 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
3937 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3938 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3939 return E_NOTIMPL;
3942 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
3944 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3945 FIXME("(%p)->(%p)\n", This, p);
3946 return E_NOTIMPL;
3949 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
3951 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3952 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3953 return E_NOTIMPL;
3956 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
3958 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3959 FIXME("(%p)->(%p)\n", This, p);
3960 return E_NOTIMPL;
3963 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
3965 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3966 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3967 return E_NOTIMPL;
3970 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
3972 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3973 FIXME("(%p)->(%p)\n", This, p);
3974 return E_NOTIMPL;
3977 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
3979 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3980 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3981 return E_NOTIMPL;
3984 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
3986 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3987 FIXME("(%p)->(%p)\n", This, p);
3988 return E_NOTIMPL;
3991 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
3993 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3995 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3997 return set_doc_event(This, EVENTID_SUBMIT, &v);
4000 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
4002 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4004 TRACE("(%p)->(%p)\n", This, p);
4006 return get_doc_event(This, EVENTID_SUBMIT, p);
4009 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
4011 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4012 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4013 return E_NOTIMPL;
4016 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
4018 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4019 FIXME("(%p)->(%p)\n", This, p);
4020 return E_NOTIMPL;
4023 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
4025 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4026 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4027 return E_NOTIMPL;
4030 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
4032 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4033 FIXME("(%p)->(%p)\n", This, p);
4034 return E_NOTIMPL;
4037 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
4039 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4040 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4041 return E_NOTIMPL;
4044 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4046 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4047 FIXME("(%p)->(%p)\n", This, p);
4048 return E_NOTIMPL;
4051 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4053 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4054 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4055 return E_NOTIMPL;
4058 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4060 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4061 FIXME("(%p)->(%p)\n", This, p);
4062 return E_NOTIMPL;
4065 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4067 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4068 FIXME("(%p)\n", This);
4069 return E_NOTIMPL;
4072 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4073 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4075 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4076 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4077 return E_NOTIMPL;
4080 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4082 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4084 TRACE("(%p)->(%p)\n", This, p);
4086 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4089 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4091 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4092 FIXME("(%p)->(%p)\n", This, v);
4093 return E_NOTIMPL;
4096 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4098 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4100 TRACE("(%p)->(%p)\n", This, p);
4102 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4105 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4107 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4108 nsIDOMHTMLHeadElement *nshead;
4109 nsIDOMElement *nselem;
4110 HTMLElement *elem;
4111 nsresult nsres;
4112 HRESULT hres;
4114 TRACE("(%p)->(%p)\n", This, p);
4116 if(!This->doc_node->nsdoc) {
4117 FIXME("No document\n");
4118 return E_FAIL;
4121 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &nshead);
4122 assert(nsres == NS_OK);
4124 if(!nshead) {
4125 *p = NULL;
4126 return S_OK;
4129 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4130 nsIDOMHTMLHeadElement_Release(nshead);
4131 assert(nsres == NS_OK);
4133 hres = get_element(nselem, &elem);
4134 nsIDOMElement_Release(nselem);
4135 if(FAILED(hres))
4136 return hres;
4138 *p = &elem->IHTMLElement_iface;
4139 return S_OK;
4142 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4143 HTMLDocument7_QueryInterface,
4144 HTMLDocument7_AddRef,
4145 HTMLDocument7_Release,
4146 HTMLDocument7_GetTypeInfoCount,
4147 HTMLDocument7_GetTypeInfo,
4148 HTMLDocument7_GetIDsOfNames,
4149 HTMLDocument7_Invoke,
4150 HTMLDocument7_get_defaultView,
4151 HTMLDocument7_createCDATASection,
4152 HTMLDocument7_getSelection,
4153 HTMLDocument7_getElementsByTagNameNS,
4154 HTMLDocument7_createElementNS,
4155 HTMLDocument7_createAttributeNS,
4156 HTMLDocument7_put_onmsthumbnailclick,
4157 HTMLDocument7_get_onmsthumbnailclick,
4158 HTMLDocument7_get_characterSet,
4159 HTMLDocument7_createElement,
4160 HTMLDocument7_createAttribute,
4161 HTMLDocument7_getElementsByClassName,
4162 HTMLDocument7_createProcessingInstruction,
4163 HTMLDocument7_adoptNode,
4164 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4165 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4166 HTMLDocument7_get_all,
4167 HTMLDocument7_get_inputEncoding,
4168 HTMLDocument7_get_xmlEncoding,
4169 HTMLDocument7_put_xmlStandalone,
4170 HTMLDocument7_get_xmlStandalone,
4171 HTMLDocument7_put_xmlVersion,
4172 HTMLDocument7_get_xmlVersion,
4173 HTMLDocument7_hasAttributes,
4174 HTMLDocument7_put_onabort,
4175 HTMLDocument7_get_onabort,
4176 HTMLDocument7_put_onblur,
4177 HTMLDocument7_get_onblur,
4178 HTMLDocument7_put_oncanplay,
4179 HTMLDocument7_get_oncanplay,
4180 HTMLDocument7_put_oncanplaythrough,
4181 HTMLDocument7_get_oncanplaythrough,
4182 HTMLDocument7_put_onchange,
4183 HTMLDocument7_get_onchange,
4184 HTMLDocument7_put_ondrag,
4185 HTMLDocument7_get_ondrag,
4186 HTMLDocument7_put_ondragend,
4187 HTMLDocument7_get_ondragend,
4188 HTMLDocument7_put_ondragenter,
4189 HTMLDocument7_get_ondragenter,
4190 HTMLDocument7_put_ondragleave,
4191 HTMLDocument7_get_ondragleave,
4192 HTMLDocument7_put_ondragover,
4193 HTMLDocument7_get_ondragover,
4194 HTMLDocument7_put_ondrop,
4195 HTMLDocument7_get_ondrop,
4196 HTMLDocument7_put_ondurationchange,
4197 HTMLDocument7_get_ondurationchange,
4198 HTMLDocument7_put_onemptied,
4199 HTMLDocument7_get_onemptied,
4200 HTMLDocument7_put_onended,
4201 HTMLDocument7_get_onended,
4202 HTMLDocument7_put_onerror,
4203 HTMLDocument7_get_onerror,
4204 HTMLDocument7_put_onfocus,
4205 HTMLDocument7_get_onfocus,
4206 HTMLDocument7_put_oninput,
4207 HTMLDocument7_get_oninput,
4208 HTMLDocument7_put_onload,
4209 HTMLDocument7_get_onload,
4210 HTMLDocument7_put_onloadeddata,
4211 HTMLDocument7_get_onloadeddata,
4212 HTMLDocument7_put_onloadedmetadata,
4213 HTMLDocument7_get_onloadedmetadata,
4214 HTMLDocument7_put_onloadstart,
4215 HTMLDocument7_get_onloadstart,
4216 HTMLDocument7_put_onpause,
4217 HTMLDocument7_get_onpause,
4218 HTMLDocument7_put_onplay,
4219 HTMLDocument7_get_onplay,
4220 HTMLDocument7_put_onplaying,
4221 HTMLDocument7_get_onplaying,
4222 HTMLDocument7_put_onprogress,
4223 HTMLDocument7_get_onprogress,
4224 HTMLDocument7_put_onratechange,
4225 HTMLDocument7_get_onratechange,
4226 HTMLDocument7_put_onreset,
4227 HTMLDocument7_get_onreset,
4228 HTMLDocument7_put_onscroll,
4229 HTMLDocument7_get_onscroll,
4230 HTMLDocument7_put_onseekend,
4231 HTMLDocument7_get_onseekend,
4232 HTMLDocument7_put_onseeking,
4233 HTMLDocument7_get_onseeking,
4234 HTMLDocument7_put_onselect,
4235 HTMLDocument7_get_onselect,
4236 HTMLDocument7_put_onstalled,
4237 HTMLDocument7_get_onstalled,
4238 HTMLDocument7_put_onsubmit,
4239 HTMLDocument7_get_onsubmit,
4240 HTMLDocument7_put_onsuspend,
4241 HTMLDocument7_get_onsuspend,
4242 HTMLDocument7_put_ontimeupdate,
4243 HTMLDocument7_get_ontimeupdate,
4244 HTMLDocument7_put_onvolumechange,
4245 HTMLDocument7_get_onvolumechange,
4246 HTMLDocument7_put_onwaiting,
4247 HTMLDocument7_get_onwaiting,
4248 HTMLDocument7_normalize,
4249 HTMLDocument7_importNode,
4250 HTMLDocument7_get_parentWindow,
4251 HTMLDocument7_put_body,
4252 HTMLDocument7_get_body,
4253 HTMLDocument7_get_head
4256 static inline HTMLDocument *impl_from_IDocumentSelector(IDocumentSelector *iface)
4258 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentSelector_iface);
4261 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4263 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4264 return htmldoc_query_interface(This, riid, ppv);
4267 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4269 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4270 return htmldoc_addref(This);
4273 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4275 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4276 return htmldoc_release(This);
4279 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4281 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4282 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4285 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4286 LCID lcid, ITypeInfo **ppTInfo)
4288 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4289 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4292 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4293 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4295 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4296 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4297 rgDispId);
4300 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4301 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4303 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4304 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4305 pDispParams, pVarResult, pExcepInfo, puArgErr);
4308 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4310 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4311 nsIDOMElement *nselem;
4312 HTMLElement *elem;
4313 nsAString nsstr;
4314 nsresult nsres;
4315 HRESULT hres;
4317 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4319 nsAString_InitDepend(&nsstr, v);
4320 nsres = nsIDOMHTMLDocument_QuerySelector(This->doc_node->nsdoc, &nsstr, &nselem);
4321 nsAString_Finish(&nsstr);
4322 if(NS_FAILED(nsres)) {
4323 ERR("QuerySelector failed: %08lx\n", nsres);
4324 return E_FAIL;
4327 if(!nselem) {
4328 *pel = NULL;
4329 return S_OK;
4332 hres = get_element(nselem, &elem);
4333 nsIDOMElement_Release(nselem);
4334 if(FAILED(hres))
4335 return hres;
4337 *pel = &elem->IHTMLElement_iface;
4338 return S_OK;
4341 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4343 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4344 nsIDOMNodeList *node_list;
4345 nsAString nsstr;
4346 HRESULT hres;
4348 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4350 nsAString_InitDepend(&nsstr, v);
4351 hres = map_nsresult(nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &nsstr, &node_list));
4352 nsAString_Finish(&nsstr);
4353 if(FAILED(hres)) {
4354 ERR("QuerySelectorAll failed: %08lx\n", hres);
4355 return hres;
4358 hres = create_child_collection(node_list, dispex_compat_mode(&This->doc_node->node.event_target.dispex), pel);
4359 nsIDOMNodeList_Release(node_list);
4360 return hres;
4363 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4364 DocumentSelector_QueryInterface,
4365 DocumentSelector_AddRef,
4366 DocumentSelector_Release,
4367 DocumentSelector_GetTypeInfoCount,
4368 DocumentSelector_GetTypeInfo,
4369 DocumentSelector_GetIDsOfNames,
4370 DocumentSelector_Invoke,
4371 DocumentSelector_querySelector,
4372 DocumentSelector_querySelectorAll
4375 static inline HTMLDocument *impl_from_IDocumentEvent(IDocumentEvent *iface)
4377 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentEvent_iface);
4380 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4382 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4383 return htmldoc_query_interface(This, riid, ppv);
4386 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4388 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4389 return htmldoc_addref(This);
4392 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4394 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4395 return htmldoc_release(This);
4398 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4400 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4401 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4404 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4405 LCID lcid, ITypeInfo **ppTInfo)
4407 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4408 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4411 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4412 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4414 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4415 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4416 rgDispId);
4419 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4420 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4422 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4423 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4424 pDispParams, pVarResult, pExcepInfo, puArgErr);
4427 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4429 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4431 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4433 return create_document_event_str(This->doc_node, eventType, p);
4436 static const IDocumentEventVtbl DocumentEventVtbl = {
4437 DocumentEvent_QueryInterface,
4438 DocumentEvent_AddRef,
4439 DocumentEvent_Release,
4440 DocumentEvent_GetTypeInfoCount,
4441 DocumentEvent_GetTypeInfo,
4442 DocumentEvent_GetIDsOfNames,
4443 DocumentEvent_Invoke,
4444 DocumentEvent_createEvent
4447 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4449 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4451 if(This->window)
4452 update_doc_cp_events(This->doc_node, cp);
4455 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4457 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4460 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4462 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4463 return htmldoc_query_interface(This, riid, ppv);
4466 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4468 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4469 return htmldoc_addref(This);
4472 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4474 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4475 return htmldoc_release(This);
4478 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4480 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4481 return S_FALSE;
4484 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4485 SupportErrorInfo_QueryInterface,
4486 SupportErrorInfo_AddRef,
4487 SupportErrorInfo_Release,
4488 SupportErrorInfo_InterfaceSupportsErrorInfo
4491 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4493 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4496 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4498 nsIDOMNodeList *node_list;
4499 nsAString name_str;
4500 UINT32 len;
4501 unsigned i;
4502 nsresult nsres;
4504 if(!This->nsdoc)
4505 return DISP_E_UNKNOWNNAME;
4507 nsAString_InitDepend(&name_str, name);
4508 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4509 nsAString_Finish(&name_str);
4510 if(NS_FAILED(nsres))
4511 return E_FAIL;
4513 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4514 nsIDOMNodeList_Release(node_list);
4515 if(NS_FAILED(nsres))
4516 return E_FAIL;
4518 if(!len)
4519 return DISP_E_UNKNOWNNAME;
4521 for(i=0; i < This->elem_vars_cnt; i++) {
4522 if(!wcscmp(name, This->elem_vars[i])) {
4523 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4524 return S_OK;
4528 if(This->elem_vars_cnt == This->elem_vars_size) {
4529 WCHAR **new_vars;
4531 if(This->elem_vars_size) {
4532 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4533 if(!new_vars)
4534 return E_OUTOFMEMORY;
4535 This->elem_vars_size *= 2;
4536 }else {
4537 new_vars = heap_alloc(16*sizeof(WCHAR*));
4538 if(!new_vars)
4539 return E_OUTOFMEMORY;
4540 This->elem_vars_size = 16;
4543 This->elem_vars = new_vars;
4546 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4547 if(!This->elem_vars[This->elem_vars_cnt])
4548 return E_OUTOFMEMORY;
4550 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4551 return S_OK;
4554 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4556 HTMLDocument *This = impl_from_IDispatchEx(iface);
4558 return htmldoc_query_interface(This, riid, ppv);
4561 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4563 HTMLDocument *This = impl_from_IDispatchEx(iface);
4565 return htmldoc_addref(This);
4568 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4570 HTMLDocument *This = impl_from_IDispatchEx(iface);
4572 return htmldoc_release(This);
4575 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4577 HTMLDocument *This = impl_from_IDispatchEx(iface);
4579 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4582 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4583 LCID lcid, ITypeInfo **ppTInfo)
4585 HTMLDocument *This = impl_from_IDispatchEx(iface);
4587 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4590 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4591 LPOLESTR *rgszNames, UINT cNames,
4592 LCID lcid, DISPID *rgDispId)
4594 HTMLDocument *This = impl_from_IDispatchEx(iface);
4596 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4599 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4600 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4601 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4603 HTMLDocument *This = impl_from_IDispatchEx(iface);
4605 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4606 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4608 switch(dispIdMember) {
4609 case DISPID_READYSTATE:
4610 TRACE("DISPID_READYSTATE\n");
4612 if(!(wFlags & DISPATCH_PROPERTYGET))
4613 return E_INVALIDARG;
4615 V_VT(pVarResult) = VT_I4;
4616 V_I4(pVarResult) = This->window->readystate;
4617 return S_OK;
4620 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
4621 pVarResult, pExcepInfo, puArgErr);
4624 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4626 HTMLDocument *This = impl_from_IDispatchEx(iface);
4627 HRESULT hres;
4629 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4630 if(hres != DISP_E_UNKNOWNNAME)
4631 return hres;
4633 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4636 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4637 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4639 HTMLDocument *This = impl_from_IDispatchEx(iface);
4641 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
4642 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
4643 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4646 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4649 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4651 HTMLDocument *This = impl_from_IDispatchEx(iface);
4653 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4656 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4658 HTMLDocument *This = impl_from_IDispatchEx(iface);
4660 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4663 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4665 HTMLDocument *This = impl_from_IDispatchEx(iface);
4667 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4670 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4672 HTMLDocument *This = impl_from_IDispatchEx(iface);
4674 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4677 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4679 HTMLDocument *This = impl_from_IDispatchEx(iface);
4681 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
4684 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
4686 HTMLDocument *This = impl_from_IDispatchEx(iface);
4688 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
4691 static const IDispatchExVtbl DocDispatchExVtbl = {
4692 DocDispatchEx_QueryInterface,
4693 DocDispatchEx_AddRef,
4694 DocDispatchEx_Release,
4695 DocDispatchEx_GetTypeInfoCount,
4696 DocDispatchEx_GetTypeInfo,
4697 DocDispatchEx_GetIDsOfNames,
4698 DocDispatchEx_Invoke,
4699 DocDispatchEx_GetDispID,
4700 DocDispatchEx_InvokeEx,
4701 DocDispatchEx_DeleteMemberByName,
4702 DocDispatchEx_DeleteMemberByDispID,
4703 DocDispatchEx_GetMemberProperties,
4704 DocDispatchEx_GetMemberName,
4705 DocDispatchEx_GetNextDispID,
4706 DocDispatchEx_GetNameSpaceParent
4709 static inline HTMLDocument *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
4711 return CONTAINING_RECORD(iface, HTMLDocument, IProvideMultipleClassInfo_iface);
4714 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
4715 REFIID riid, void **ppv)
4717 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4718 return htmldoc_query_interface(This, riid, ppv);
4721 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
4723 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4724 return htmldoc_addref(This);
4727 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
4729 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4730 return htmldoc_release(This);
4733 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
4735 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4736 TRACE("(%p)->(%p)\n", This, ppTI);
4737 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
4740 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
4742 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4743 FIXME("(%p)->(%lu %p)\n", This, dwGuidKind, pGUID);
4744 return E_NOTIMPL;
4747 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
4749 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4750 FIXME("(%p)->(%p)\n", This, pcti);
4751 *pcti = 1;
4752 return S_OK;
4755 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
4756 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
4758 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4759 FIXME("(%p)->(%lu %lx %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
4760 return E_NOTIMPL;
4763 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
4764 ProvideClassInfo_QueryInterface,
4765 ProvideClassInfo_AddRef,
4766 ProvideClassInfo_Release,
4767 ProvideClassInfo_GetClassInfo,
4768 ProvideClassInfo2_GetGUID,
4769 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
4770 ProvideMultipleClassInfo_GetInfoOfIndex
4773 /**********************************************************
4774 * IMarkupServices implementation
4776 static inline HTMLDocument *impl_from_IMarkupServices(IMarkupServices *iface)
4778 return CONTAINING_RECORD(iface, HTMLDocument, IMarkupServices_iface);
4781 static HRESULT WINAPI MarkupServices_QueryInterface(IMarkupServices *iface, REFIID riid, void **ppvObject)
4783 HTMLDocument *This = impl_from_IMarkupServices(iface);
4784 return htmldoc_query_interface(This, riid, ppvObject);
4787 static ULONG WINAPI MarkupServices_AddRef(IMarkupServices *iface)
4789 HTMLDocument *This = impl_from_IMarkupServices(iface);
4790 return htmldoc_addref(This);
4793 static ULONG WINAPI MarkupServices_Release(IMarkupServices *iface)
4795 HTMLDocument *This = impl_from_IMarkupServices(iface);
4796 return htmldoc_release(This);
4799 static HRESULT WINAPI MarkupServices_CreateMarkupPointer(IMarkupServices *iface, IMarkupPointer **ppPointer)
4801 HTMLDocument *This = impl_from_IMarkupServices(iface);
4803 TRACE("(%p)->(%p)\n", This, ppPointer);
4805 return create_markup_pointer(ppPointer);
4808 static HRESULT WINAPI MarkupServices_CreateMarkupContainer(IMarkupServices *iface, IMarkupContainer **ppMarkupContainer)
4810 HTMLDocument *This = impl_from_IMarkupServices(iface);
4811 FIXME("(%p)->(%p)\n", This, ppMarkupContainer);
4812 return E_NOTIMPL;
4815 static HRESULT WINAPI MarkupServices_CreateElement(IMarkupServices *iface,
4816 ELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement)
4818 HTMLDocument *This = impl_from_IMarkupServices(iface);
4819 FIXME("(%p)->(%d,%s,%p)\n", This, tagID, debugstr_w(pchAttributes), ppElement);
4820 return E_NOTIMPL;
4823 static HRESULT WINAPI MarkupServices_CloneElement(IMarkupServices *iface,
4824 IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone)
4826 HTMLDocument *This = impl_from_IMarkupServices(iface);
4827 FIXME("(%p)->(%p,%p)\n", This, pElemCloneThis, ppElementTheClone);
4828 return E_NOTIMPL;
4831 static HRESULT WINAPI MarkupServices_InsertElement(IMarkupServices *iface,
4832 IHTMLElement *pElementInsert, IMarkupPointer *pPointerStart,
4833 IMarkupPointer *pPointerFinish)
4835 HTMLDocument *This = impl_from_IMarkupServices(iface);
4836 FIXME("(%p)->(%p,%p,%p)\n", This, pElementInsert, pPointerStart, pPointerFinish);
4837 return E_NOTIMPL;
4840 static HRESULT WINAPI MarkupServices_RemoveElement(IMarkupServices *iface, IHTMLElement *pElementRemove)
4842 HTMLDocument *This = impl_from_IMarkupServices(iface);
4843 FIXME("(%p)->(%p)\n", This, pElementRemove);
4844 return E_NOTIMPL;
4847 static HRESULT WINAPI MarkupServices_Remove(IMarkupServices *iface,
4848 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
4850 HTMLDocument *This = impl_from_IMarkupServices(iface);
4851 FIXME("(%p)->(%p,%p)\n", This, pPointerStart, pPointerFinish);
4852 return E_NOTIMPL;
4855 static HRESULT WINAPI MarkupServices_Copy(IMarkupServices *iface,
4856 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
4857 IMarkupPointer *pPointerTarget)
4859 HTMLDocument *This = impl_from_IMarkupServices(iface);
4860 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
4861 return E_NOTIMPL;
4864 static HRESULT WINAPI MarkupServices_Move(IMarkupServices *iface,
4865 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
4866 IMarkupPointer *pPointerTarget)
4868 HTMLDocument *This = impl_from_IMarkupServices(iface);
4869 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
4870 return E_NOTIMPL;
4873 static HRESULT WINAPI MarkupServices_InsertText(IMarkupServices *iface,
4874 OLECHAR *pchText, LONG cch, IMarkupPointer *pPointerTarget)
4876 HTMLDocument *This = impl_from_IMarkupServices(iface);
4877 FIXME("(%p)->(%s,%lx,%p)\n", This, debugstr_w(pchText), cch, pPointerTarget);
4878 return E_NOTIMPL;
4881 static HRESULT WINAPI MarkupServices_ParseString(IMarkupServices *iface,
4882 OLECHAR *pchHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
4883 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
4885 HTMLDocument *This = impl_from_IMarkupServices(iface);
4886 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(pchHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
4887 return E_NOTIMPL;
4890 static HRESULT WINAPI MarkupServices_ParseGlobal(IMarkupServices *iface,
4891 HGLOBAL hglobalHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
4892 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
4894 HTMLDocument *This = impl_from_IMarkupServices(iface);
4895 FIXME("(%p)->(%s,%lx,%p,%p,%p)\n", This, debugstr_w(hglobalHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
4896 return E_NOTIMPL;
4899 static HRESULT WINAPI MarkupServices_IsScopedElement(IMarkupServices *iface,
4900 IHTMLElement *pElement, BOOL *pfScoped)
4902 HTMLDocument *This = impl_from_IMarkupServices(iface);
4903 FIXME("(%p)->(%p,%p)\n", This, pElement, pfScoped);
4904 return E_NOTIMPL;
4907 static HRESULT WINAPI MarkupServices_GetElementTagId(IMarkupServices *iface,
4908 IHTMLElement *pElement, ELEMENT_TAG_ID *ptagId)
4910 HTMLDocument *This = impl_from_IMarkupServices(iface);
4911 FIXME("(%p)->(%p,%p)\n", This, pElement, ptagId);
4912 return E_NOTIMPL;
4915 static HRESULT WINAPI MarkupServices_GetTagIDForName(IMarkupServices *iface,
4916 BSTR bstrName, ELEMENT_TAG_ID *ptagId)
4918 HTMLDocument *This = impl_from_IMarkupServices(iface);
4919 FIXME("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), ptagId);
4920 return E_NOTIMPL;
4923 static HRESULT WINAPI MarkupServices_GetNameForTagID(IMarkupServices *iface,
4924 ELEMENT_TAG_ID tagId, BSTR *pbstrName)
4926 HTMLDocument *This = impl_from_IMarkupServices(iface);
4927 FIXME("(%p)->(%d,%p)\n", This, tagId, pbstrName);
4928 return E_NOTIMPL;
4931 static HRESULT WINAPI MarkupServices_MovePointersToRange(IMarkupServices *iface,
4932 IHTMLTxtRange *pIRange, IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
4934 HTMLDocument *This = impl_from_IMarkupServices(iface);
4935 FIXME("(%p)->(%p,%p,%p)\n", This, pIRange, pPointerStart, pPointerFinish);
4936 return E_NOTIMPL;
4939 static HRESULT WINAPI MarkupServices_MoveRangeToPointers(IMarkupServices *iface,
4940 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish, IHTMLTxtRange *pIRange)
4942 HTMLDocument *This = impl_from_IMarkupServices(iface);
4943 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerStart, pPointerFinish, pIRange);
4944 return E_NOTIMPL;
4947 static HRESULT WINAPI MarkupServices_BeginUndoUnit(IMarkupServices *iface, OLECHAR *pchTitle)
4949 HTMLDocument *This = impl_from_IMarkupServices(iface);
4950 FIXME("(%p)->(%s)\n", This, debugstr_w(pchTitle));
4951 return E_NOTIMPL;
4954 static HRESULT WINAPI MarkupServices_EndUndoUnit(IMarkupServices *iface)
4956 HTMLDocument *This = impl_from_IMarkupServices(iface);
4957 FIXME("(%p)\n", This);
4958 return E_NOTIMPL;
4961 static const IMarkupServicesVtbl MarkupServicesVtbl = {
4962 MarkupServices_QueryInterface,
4963 MarkupServices_AddRef,
4964 MarkupServices_Release,
4965 MarkupServices_CreateMarkupPointer,
4966 MarkupServices_CreateMarkupContainer,
4967 MarkupServices_CreateElement,
4968 MarkupServices_CloneElement,
4969 MarkupServices_InsertElement,
4970 MarkupServices_RemoveElement,
4971 MarkupServices_Remove,
4972 MarkupServices_Copy,
4973 MarkupServices_Move,
4974 MarkupServices_InsertText,
4975 MarkupServices_ParseString,
4976 MarkupServices_ParseGlobal,
4977 MarkupServices_IsScopedElement,
4978 MarkupServices_GetElementTagId,
4979 MarkupServices_GetTagIDForName,
4980 MarkupServices_GetNameForTagID,
4981 MarkupServices_MovePointersToRange,
4982 MarkupServices_MoveRangeToPointers,
4983 MarkupServices_BeginUndoUnit,
4984 MarkupServices_EndUndoUnit
4987 /**********************************************************
4988 * IMarkupContainer implementation
4990 static inline HTMLDocument *impl_from_IMarkupContainer(IMarkupContainer *iface)
4992 return CONTAINING_RECORD(iface, HTMLDocument, IMarkupContainer_iface);
4995 static HRESULT WINAPI MarkupContainer_QueryInterface(IMarkupContainer *iface, REFIID riid, void **ppvObject)
4997 HTMLDocument *This = impl_from_IMarkupContainer(iface);
4998 return htmldoc_query_interface(This, riid, ppvObject);
5001 static ULONG WINAPI MarkupContainer_AddRef(IMarkupContainer *iface)
5003 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5004 return htmldoc_addref(This);
5007 static ULONG WINAPI MarkupContainer_Release(IMarkupContainer *iface)
5009 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5010 return htmldoc_release(This);
5013 static HRESULT WINAPI MarkupContainer_OwningDoc(IMarkupContainer *iface, IHTMLDocument2 **ppDoc)
5015 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5016 FIXME("(%p)->(%p)\n", This, ppDoc);
5017 return E_NOTIMPL;
5020 static const IMarkupContainerVtbl MarkupContainerVtbl = {
5021 MarkupContainer_QueryInterface,
5022 MarkupContainer_AddRef,
5023 MarkupContainer_Release,
5024 MarkupContainer_OwningDoc
5027 /**********************************************************
5028 * IDisplayServices implementation
5030 static inline HTMLDocument *impl_from_IDisplayServices(IDisplayServices *iface)
5032 return CONTAINING_RECORD(iface, HTMLDocument, IDisplayServices_iface);
5035 static HRESULT WINAPI DisplayServices_QueryInterface(IDisplayServices *iface, REFIID riid, void **ppvObject)
5037 HTMLDocument *This = impl_from_IDisplayServices(iface);
5038 return htmldoc_query_interface(This, riid, ppvObject);
5041 static ULONG WINAPI DisplayServices_AddRef(IDisplayServices *iface)
5043 HTMLDocument *This = impl_from_IDisplayServices(iface);
5044 return htmldoc_addref(This);
5047 static ULONG WINAPI DisplayServices_Release(IDisplayServices *iface)
5049 HTMLDocument *This = impl_from_IDisplayServices(iface);
5050 return htmldoc_release(This);
5053 static HRESULT WINAPI DisplayServices_CreateDisplayPointer(IDisplayServices *iface, IDisplayPointer **ppDispPointer)
5055 HTMLDocument *This = impl_from_IDisplayServices(iface);
5056 FIXME("(%p)->(%p)\n", This, ppDispPointer);
5057 return E_NOTIMPL;
5060 static HRESULT WINAPI DisplayServices_TransformRect(IDisplayServices *iface,
5061 RECT *pRect, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5063 HTMLDocument *This = impl_from_IDisplayServices(iface);
5064 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_rect(pRect), eSource, eDestination, pIElement);
5065 return E_NOTIMPL;
5068 static HRESULT WINAPI DisplayServices_TransformPoint(IDisplayServices *iface,
5069 POINT *pPoint, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5071 HTMLDocument *This = impl_from_IDisplayServices(iface);
5072 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_point(pPoint), eSource, eDestination, pIElement);
5073 return E_NOTIMPL;
5076 static HRESULT WINAPI DisplayServices_GetCaret(IDisplayServices *iface, IHTMLCaret **ppCaret)
5078 HTMLDocument *This = impl_from_IDisplayServices(iface);
5079 FIXME("(%p)->(%p)\n", This, ppCaret);
5080 return E_NOTIMPL;
5083 static HRESULT WINAPI DisplayServices_GetComputedStyle(IDisplayServices *iface,
5084 IMarkupPointer *pPointer, IHTMLComputedStyle **ppComputedStyle)
5086 HTMLDocument *This = impl_from_IDisplayServices(iface);
5087 FIXME("(%p)->(%p,%p)\n", This, pPointer, ppComputedStyle);
5088 return E_NOTIMPL;
5091 static HRESULT WINAPI DisplayServices_ScrollRectIntoView(IDisplayServices *iface,
5092 IHTMLElement *pIElement, RECT rect)
5094 HTMLDocument *This = impl_from_IDisplayServices(iface);
5095 FIXME("(%p)->(%p,%s)\n", This, pIElement, wine_dbgstr_rect(&rect));
5096 return E_NOTIMPL;
5099 static HRESULT WINAPI DisplayServices_HasFlowLayout(IDisplayServices *iface,
5100 IHTMLElement *pIElement, BOOL *pfHasFlowLayout)
5102 HTMLDocument *This = impl_from_IDisplayServices(iface);
5103 FIXME("(%p)->(%p,%p)\n", This, pIElement, pfHasFlowLayout);
5104 return E_NOTIMPL;
5107 static const IDisplayServicesVtbl DisplayServicesVtbl = {
5108 DisplayServices_QueryInterface,
5109 DisplayServices_AddRef,
5110 DisplayServices_Release,
5111 DisplayServices_CreateDisplayPointer,
5112 DisplayServices_TransformRect,
5113 DisplayServices_TransformPoint,
5114 DisplayServices_GetCaret,
5115 DisplayServices_GetComputedStyle,
5116 DisplayServices_ScrollRectIntoView,
5117 DisplayServices_HasFlowLayout
5120 /**********************************************************
5121 * IDocumentRange implementation
5123 static inline HTMLDocument *impl_from_IDocumentRange(IDocumentRange *iface)
5125 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentRange_iface);
5128 static HRESULT WINAPI DocumentRange_QueryInterface(IDocumentRange *iface, REFIID riid, void **ppv)
5130 HTMLDocument *This = impl_from_IDocumentRange(iface);
5132 return htmldoc_query_interface(This, riid, ppv);
5135 static ULONG WINAPI DocumentRange_AddRef(IDocumentRange *iface)
5137 HTMLDocument *This = impl_from_IDocumentRange(iface);
5139 return htmldoc_addref(This);
5142 static ULONG WINAPI DocumentRange_Release(IDocumentRange *iface)
5144 HTMLDocument *This = impl_from_IDocumentRange(iface);
5146 return htmldoc_release(This);
5149 static HRESULT WINAPI DocumentRange_GetTypeInfoCount(IDocumentRange *iface, UINT *pctinfo)
5151 HTMLDocument *This = impl_from_IDocumentRange(iface);
5153 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
5156 static HRESULT WINAPI DocumentRange_GetTypeInfo(IDocumentRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5158 HTMLDocument *This = impl_from_IDocumentRange(iface);
5160 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5163 static HRESULT WINAPI DocumentRange_GetIDsOfNames(IDocumentRange *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5164 LCID lcid, DISPID *rgDispId)
5166 HTMLDocument *This = impl_from_IDocumentRange(iface);
5168 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
5169 rgDispId);
5172 static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
5173 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5175 HTMLDocument *This = impl_from_IDocumentRange(iface);
5177 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5178 pDispParams, pVarResult, pExcepInfo, puArgErr);
5181 static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
5183 HTMLDocument *This = impl_from_IDocumentRange(iface);
5184 nsIDOMRange *nsrange;
5185 HRESULT hres;
5187 TRACE("(%p)->(%p)\n", This, p);
5189 if(!This->doc_node->nsdoc) {
5190 WARN("NULL nsdoc\n");
5191 return E_UNEXPECTED;
5194 if(NS_FAILED(nsIDOMHTMLDocument_CreateRange(This->doc_node->nsdoc, &nsrange)))
5195 return E_FAIL;
5197 hres = create_dom_range(nsrange, dispex_compat_mode(&This->doc_node->node.event_target.dispex), p);
5198 nsIDOMRange_Release(nsrange);
5199 return hres;
5202 static const IDocumentRangeVtbl DocumentRangeVtbl = {
5203 DocumentRange_QueryInterface,
5204 DocumentRange_AddRef,
5205 DocumentRange_Release,
5206 DocumentRange_GetTypeInfoCount,
5207 DocumentRange_GetTypeInfo,
5208 DocumentRange_GetIDsOfNames,
5209 DocumentRange_Invoke,
5210 DocumentRange_createRange,
5213 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
5215 *ppv = NULL;
5217 if(IsEqualGUID(&IID_IUnknown, riid))
5218 *ppv = &This->IHTMLDocument2_iface;
5219 else if(IsEqualGUID(&IID_IDispatch, riid))
5220 *ppv = &This->IDispatchEx_iface;
5221 else if(IsEqualGUID(&IID_IDispatchEx, riid))
5222 *ppv = &This->IDispatchEx_iface;
5223 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
5224 *ppv = &This->IHTMLDocument2_iface;
5225 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
5226 *ppv = &This->IHTMLDocument2_iface;
5227 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
5228 *ppv = &This->IHTMLDocument3_iface;
5229 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
5230 *ppv = &This->IHTMLDocument4_iface;
5231 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
5232 *ppv = &This->IHTMLDocument5_iface;
5233 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
5234 *ppv = &This->IHTMLDocument6_iface;
5235 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
5236 *ppv = &This->IHTMLDocument7_iface;
5237 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
5238 *ppv = &This->IDocumentSelector_iface;
5239 else if(IsEqualGUID(&IID_IDocumentEvent, riid))
5240 *ppv = &This->IDocumentEvent_iface;
5241 else if(IsEqualGUID(&IID_IPersist, riid))
5242 *ppv = &This->IPersistFile_iface;
5243 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
5244 *ppv = &This->IPersistMoniker_iface;
5245 else if(IsEqualGUID(&IID_IPersistFile, riid))
5246 *ppv = &This->IPersistFile_iface;
5247 else if(IsEqualGUID(&IID_IMonikerProp, riid))
5248 *ppv = &This->IMonikerProp_iface;
5249 else if(IsEqualGUID(&IID_IOleObject, riid))
5250 *ppv = &This->IOleObject_iface;
5251 else if(IsEqualGUID(&IID_IOleDocument, riid))
5252 *ppv = &This->IOleDocument_iface;
5253 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
5254 *ppv = &This->IOleInPlaceActiveObject_iface;
5255 else if(IsEqualGUID(&IID_IOleWindow, riid))
5256 *ppv = &This->IOleInPlaceActiveObject_iface;
5257 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
5258 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5259 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
5260 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5261 else if(IsEqualGUID(&IID_IServiceProvider, riid))
5262 *ppv = &This->IServiceProvider_iface;
5263 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
5264 *ppv = &This->IOleCommandTarget_iface;
5265 else if(IsEqualGUID(&IID_IOleControl, riid))
5266 *ppv = &This->IOleControl_iface;
5267 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
5268 *ppv = &This->IHlinkTarget_iface;
5269 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
5270 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5271 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
5272 *ppv = &This->IPersistStreamInit_iface;
5273 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
5274 *ppv = &This->IHTMLDocument2_iface;
5275 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
5276 *ppv = &This->ISupportErrorInfo_iface;
5277 else if(IsEqualGUID(&IID_IPersistHistory, riid))
5278 *ppv = &This->IPersistHistory_iface;
5279 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
5280 *ppv = &This->IObjectWithSite_iface;
5281 else if(IsEqualGUID(&IID_IOleContainer, riid))
5282 *ppv = &This->IOleContainer_iface;
5283 else if(IsEqualGUID(&IID_IObjectSafety, riid))
5284 *ppv = &This->IObjectSafety_iface;
5285 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
5286 *ppv = &This->IProvideMultipleClassInfo_iface;
5287 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
5288 *ppv = &This->IProvideMultipleClassInfo_iface;
5289 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
5290 *ppv = &This->IProvideMultipleClassInfo_iface;
5291 else if(IsEqualGUID(&IID_IMarkupServices, riid))
5292 *ppv = &This->IMarkupServices_iface;
5293 else if(IsEqualGUID(&IID_IMarkupContainer, riid))
5294 *ppv = &This->IMarkupContainer_iface;
5295 else if(IsEqualGUID(&IID_IDisplayServices, riid))
5296 *ppv = &This->IDisplayServices_iface;
5297 else if(IsEqualGUID(&IID_IDocumentRange, riid))
5298 *ppv = &This->IDocumentRange_iface;
5299 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
5300 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
5301 *ppv = NULL;
5302 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
5303 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
5304 *ppv = NULL;
5305 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
5306 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
5307 *ppv = NULL;
5308 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
5309 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
5310 *ppv = NULL;
5311 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
5312 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
5313 *ppv = NULL;
5314 }else {
5315 return FALSE;
5318 if(*ppv)
5319 IUnknown_AddRef((IUnknown*)*ppv);
5320 return TRUE;
5323 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
5324 static cp_static_data_t HTMLDocumentEvents2_data = { HTMLDocumentEvents2_tid, HTMLDocument_on_advise, TRUE };
5326 static const cpc_entry_t HTMLDocument_cpc[] = {
5327 {&IID_IDispatch, &HTMLDocumentEvents_data},
5328 {&IID_IPropertyNotifySink},
5329 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
5330 {&DIID_HTMLDocumentEvents2, &HTMLDocumentEvents2_data},
5331 {NULL}
5334 static void init_doc(HTMLDocument *doc, IUnknown *outer, IDispatchEx *dispex)
5336 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
5337 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
5338 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
5339 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
5340 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
5341 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
5342 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
5343 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
5344 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
5345 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
5346 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
5347 doc->IMarkupServices_iface.lpVtbl = &MarkupServicesVtbl;
5348 doc->IMarkupContainer_iface.lpVtbl = &MarkupContainerVtbl;
5349 doc->IDisplayServices_iface.lpVtbl = &DisplayServicesVtbl;
5350 doc->IDocumentRange_iface.lpVtbl = &DocumentRangeVtbl;
5352 doc->outer_unk = outer;
5353 doc->dispex = dispex;
5355 HTMLDocument_Persist_Init(doc);
5356 HTMLDocument_OleCmd_Init(doc);
5357 HTMLDocument_OleObj_Init(doc);
5358 HTMLDocument_Service_Init(doc);
5360 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
5363 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5365 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
5368 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5370 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5372 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5374 if(htmldoc_qi(&This->basedoc, riid, ppv))
5375 return *ppv ? S_OK : E_NOINTERFACE;
5377 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
5378 *ppv = &This->IInternetHostSecurityManager_iface;
5379 else
5380 return HTMLDOMNode_QI(&This->node, riid, ppv);
5382 IUnknown_AddRef((IUnknown*)*ppv);
5383 return S_OK;
5386 void detach_document_node(HTMLDocumentNode *doc)
5388 unsigned i;
5390 while(!list_empty(&doc->plugin_hosts))
5391 detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
5393 if(doc->dom_implementation) {
5394 detach_dom_implementation(doc->dom_implementation);
5395 IHTMLDOMImplementation_Release(doc->dom_implementation);
5396 doc->dom_implementation = NULL;
5399 if(doc->namespaces) {
5400 IHTMLNamespaceCollection_Release(doc->namespaces);
5401 doc->namespaces = NULL;
5404 detach_events(doc);
5405 detach_selection(doc);
5406 detach_ranges(doc);
5408 for(i=0; i < doc->elem_vars_cnt; i++)
5409 heap_free(doc->elem_vars[i]);
5410 heap_free(doc->elem_vars);
5411 doc->elem_vars_cnt = doc->elem_vars_size = 0;
5412 doc->elem_vars = NULL;
5414 if(doc->catmgr) {
5415 ICatInformation_Release(doc->catmgr);
5416 doc->catmgr = NULL;
5419 if(!doc->nsdoc && doc->window) {
5420 /* document fragments own reference to inner window */
5421 IHTMLWindow2_Release(&doc->window->base.IHTMLWindow2_iface);
5422 doc->window = NULL;
5425 if(doc->browser) {
5426 list_remove(&doc->browser_entry);
5427 doc->browser = NULL;
5431 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
5433 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5435 TRACE("(%p)\n", This);
5437 heap_free(This->event_vector);
5438 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
5441 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5443 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5444 FIXME("%p\n", This);
5445 return E_NOTIMPL;
5448 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
5450 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5452 if(This->nsdoc)
5453 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
5456 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
5458 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5460 if(This->nsdoc) {
5461 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
5463 release_document_mutation(This);
5464 detach_document_node(This);
5465 This->nsdoc = NULL;
5466 nsIDOMHTMLDocument_Release(nsdoc);
5467 This->window = NULL;
5471 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
5472 &CLSID_HTMLDocument,
5473 HTMLDocumentNode_QI,
5474 HTMLDocumentNode_destructor,
5475 HTMLDocument_cpc,
5476 HTMLDocumentNode_clone,
5477 NULL,
5478 NULL,
5479 NULL,
5480 NULL,
5481 NULL,
5482 NULL,
5483 NULL,
5484 NULL,
5485 NULL,
5486 NULL,
5487 HTMLDocumentNode_traverse,
5488 HTMLDocumentNode_unlink
5491 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5493 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5494 HTMLDocumentNode *new_node;
5495 HRESULT hres;
5497 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
5498 if(FAILED(hres))
5499 return hres;
5501 *ret = &new_node->node;
5502 return S_OK;
5505 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
5507 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
5510 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5511 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5513 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5514 nsIDOMNodeList *node_list;
5515 nsAString name_str;
5516 nsIDOMNode *nsnode;
5517 HTMLDOMNode *node;
5518 unsigned i;
5519 nsresult nsres;
5520 HRESULT hres;
5522 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
5523 FIXME("unsupported flags %x\n", flags);
5524 return E_NOTIMPL;
5527 i = id - MSHTML_DISPID_CUSTOM_MIN;
5529 if(!This->nsdoc || i >= This->elem_vars_cnt)
5530 return DISP_E_UNKNOWNNAME;
5532 nsAString_InitDepend(&name_str, This->elem_vars[i]);
5533 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
5534 nsAString_Finish(&name_str);
5535 if(NS_FAILED(nsres))
5536 return E_FAIL;
5538 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
5539 nsIDOMNodeList_Release(node_list);
5540 if(NS_FAILED(nsres) || !nsnode)
5541 return DISP_E_UNKNOWNNAME;
5543 hres = get_node(nsnode, TRUE, &node);
5544 if(FAILED(hres))
5545 return hres;
5547 V_VT(res) = VT_DISPATCH;
5548 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5549 return S_OK;
5552 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
5554 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5556 TRACE("(%p) returning %u\n", This, This->document_mode);
5558 return lock_document_mode(This);
5561 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
5563 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5564 return (nsISupports*)This->node.nsnode;
5567 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
5569 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5570 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
5573 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
5575 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5576 if(!This->window)
5577 return NULL;
5578 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
5579 return &This->window->event_target;
5582 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
5584 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5585 ConnectionPointContainer *container = This->basedoc.doc_obj
5586 ? &This->basedoc.doc_obj->basedoc.cp_container : &This->basedoc.cp_container;
5587 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
5588 return container;
5591 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
5593 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5594 return default_set_current_event(This->window, event);
5597 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
5599 NULL,
5600 NULL,
5601 HTMLDocumentNode_invoke,
5602 HTMLDocumentNode_get_compat_mode,
5603 NULL
5605 HTMLDocumentNode_get_gecko_target,
5606 HTMLDocumentNode_bind_event,
5607 HTMLDocumentNode_get_parent_event_target,
5608 NULL,
5609 HTMLDocumentNode_get_cp_container,
5610 HTMLDocumentNode_set_current_event
5613 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
5614 &CLSID_HTMLDocument,
5615 HTMLDocumentNode_QI,
5616 HTMLDocumentNode_destructor,
5617 HTMLDocument_cpc,
5618 HTMLDocumentFragment_clone
5621 static const tid_t HTMLDocumentNode_iface_tids[] = {
5622 IHTMLDOMNode_tid,
5623 IHTMLDOMNode2_tid,
5624 IHTMLDocument2_tid,
5625 IHTMLDocument4_tid,
5626 IHTMLDocument5_tid,
5627 IDocumentSelector_tid,
5631 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
5633 HTMLDOMNode_init_dispex_info(info, mode);
5635 if(mode >= COMPAT_MODE_IE9) {
5636 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
5637 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
5640 /* Depending on compatibility version, we add interfaces in different order
5641 * so that the right getElementById implementation is used. */
5642 if(mode < COMPAT_MODE_IE8) {
5643 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5644 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5645 }else {
5646 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5647 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5651 static dispex_static_data_t HTMLDocumentNode_dispex = {
5652 L"HTMLDocument",
5653 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
5654 DispHTMLDocument_tid,
5655 HTMLDocumentNode_iface_tids,
5656 HTMLDocumentNode_init_dispex_info
5659 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
5661 HTMLDocumentNode *doc;
5663 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
5664 if(!doc)
5665 return NULL;
5667 doc->ref = 1;
5668 doc->basedoc.doc_node = doc;
5669 doc->basedoc.doc_obj = doc_obj;
5670 doc->basedoc.window = window ? window->base.outer_window : NULL;
5671 doc->window = window;
5673 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
5674 &doc->node.event_target.dispex.IDispatchEx_iface);
5675 HTMLDocumentNode_SecMgr_Init(doc);
5677 list_init(&doc->selection_list);
5678 list_init(&doc->range_list);
5679 list_init(&doc->plugin_hosts);
5681 return doc;
5684 HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
5685 compat_mode_t parent_mode, HTMLDocumentNode **ret)
5687 HTMLDocumentObj *doc_obj = browser->doc;
5688 HTMLDocumentNode *doc;
5690 doc = alloc_doc_node(doc_obj, window);
5691 if(!doc)
5692 return E_OUTOFMEMORY;
5694 if(parent_mode >= COMPAT_MODE_IE9) {
5695 TRACE("using parent mode %u\n", parent_mode);
5696 doc->document_mode = parent_mode;
5697 lock_document_mode(doc);
5700 if(!doc_obj->basedoc.window || (window && is_main_content_window(window->base.outer_window)))
5701 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
5703 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc, &HTMLDocumentNode_dispex);
5705 nsIDOMHTMLDocument_AddRef(nsdoc);
5706 doc->nsdoc = nsdoc;
5708 init_document_mutation(doc);
5709 doc_init_events(doc);
5711 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
5713 list_add_head(&browser->document_nodes, &doc->browser_entry);
5714 doc->browser = browser;
5716 if(browser->usermode == EDITMODE) {
5717 nsAString mode_str;
5718 nsresult nsres;
5720 nsAString_InitDepend(&mode_str, L"on");
5721 nsres = nsIDOMHTMLDocument_SetDesignMode(doc->nsdoc, &mode_str);
5722 nsAString_Finish(&mode_str);
5723 if(NS_FAILED(nsres))
5724 ERR("SetDesignMode failed: %08lx\n", nsres);
5727 *ret = doc;
5728 return S_OK;
5731 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
5733 HTMLDocumentNode *doc_frag;
5735 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
5736 if(!doc_frag)
5737 return E_OUTOFMEMORY;
5739 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
5741 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
5742 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
5743 doc_frag->document_mode = lock_document_mode(doc_node);
5745 *ret = doc_frag;
5746 return S_OK;
5749 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
5751 HTMLDOMNode *node;
5752 HRESULT hres;
5754 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
5755 if(FAILED(hres))
5756 return hres;
5758 if(!node) {
5759 ERR("document not initialized\n");
5760 return E_FAIL;
5763 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
5764 *ret = impl_from_HTMLDOMNode(node);
5765 return S_OK;
5768 static inline HTMLDocumentObj *impl_from_IUnknown(IUnknown *iface)
5770 return CONTAINING_RECORD(iface, HTMLDocumentObj, IUnknown_inner);
5773 static HRESULT WINAPI HTMLDocumentObj_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
5775 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5777 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5779 if(IsEqualGUID(&IID_IUnknown, riid)) {
5780 *ppv = &This->IUnknown_inner;
5781 }else if(htmldoc_qi(&This->basedoc, riid, ppv)) {
5782 return *ppv ? S_OK : E_NOINTERFACE;
5783 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
5784 *ppv = &This->ICustomDoc_iface;
5785 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
5786 *ppv = &This->IOleDocumentView_iface;
5787 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
5788 *ppv = &This->IViewObjectEx_iface;
5789 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
5790 *ppv = &This->IViewObjectEx_iface;
5791 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
5792 *ppv = &This->IViewObjectEx_iface;
5793 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
5794 *ppv = &This->ITargetContainer_iface;
5795 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5796 return *ppv ? S_OK : E_NOINTERFACE;
5797 }else {
5798 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
5799 *ppv = NULL;
5800 return E_NOINTERFACE;
5803 IUnknown_AddRef((IUnknown*)*ppv);
5804 return S_OK;
5807 static ULONG WINAPI HTMLDocumentObj_AddRef(IUnknown *iface)
5809 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5810 ULONG ref = InterlockedIncrement(&This->ref);
5812 TRACE("(%p) ref = %lu\n", This, ref);
5814 return ref;
5817 static ULONG WINAPI HTMLDocumentObj_Release(IUnknown *iface)
5819 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5820 ULONG ref = InterlockedDecrement(&This->ref);
5822 TRACE("(%p) ref = %lu\n", This, ref);
5824 if(!ref) {
5825 if(This->basedoc.doc_node) {
5826 This->basedoc.doc_node->basedoc.doc_obj = NULL;
5827 htmldoc_release(&This->basedoc.doc_node->basedoc);
5829 if(This->basedoc.window)
5830 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
5831 if(This->advise_holder)
5832 IOleAdviseHolder_Release(This->advise_holder);
5834 if(This->view_sink)
5835 IAdviseSink_Release(This->view_sink);
5836 if(This->client)
5837 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
5838 if(This->hostui)
5839 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
5840 if(This->in_place_active)
5841 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
5842 if(This->ipsite)
5843 IOleDocumentView_SetInPlaceSite(&This->IOleDocumentView_iface, NULL);
5844 if(This->undomgr)
5845 IOleUndoManager_Release(This->undomgr);
5846 if(This->editsvcs)
5847 IHTMLEditServices_Release(This->editsvcs);
5848 if(This->tooltips_hwnd)
5849 DestroyWindow(This->tooltips_hwnd);
5851 if(This->hwnd)
5852 DestroyWindow(This->hwnd);
5853 heap_free(This->mime);
5855 remove_target_tasks(This->task_magic);
5856 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
5857 release_dispex(&This->dispex);
5859 if(This->nscontainer)
5860 detach_gecko_browser(This->nscontainer);
5861 heap_free(This);
5864 return ref;
5867 static const IUnknownVtbl HTMLDocumentObjVtbl = {
5868 HTMLDocumentObj_QueryInterface,
5869 HTMLDocumentObj_AddRef,
5870 HTMLDocumentObj_Release
5873 /**********************************************************
5874 * ICustomDoc implementation
5877 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
5879 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
5882 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
5884 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5886 return htmldoc_query_interface(&This->basedoc, riid, ppv);
5889 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
5891 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5893 return htmldoc_addref(&This->basedoc);
5896 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
5898 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5900 return htmldoc_release(&This->basedoc);
5903 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
5905 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5906 IOleCommandTarget *cmdtrg;
5907 HRESULT hres;
5909 TRACE("(%p)->(%p)\n", This, pUIHandler);
5911 if(This->custom_hostui && This->hostui == pUIHandler)
5912 return S_OK;
5914 This->custom_hostui = TRUE;
5916 if(This->hostui)
5917 IDocHostUIHandler_Release(This->hostui);
5918 if(pUIHandler)
5919 IDocHostUIHandler_AddRef(pUIHandler);
5920 This->hostui = pUIHandler;
5921 if(!pUIHandler)
5922 return S_OK;
5924 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
5925 if(SUCCEEDED(hres)) {
5926 FIXME("custom UI handler supports IOleCommandTarget\n");
5927 IOleCommandTarget_Release(cmdtrg);
5930 return S_OK;
5933 static const ICustomDocVtbl CustomDocVtbl = {
5934 CustomDoc_QueryInterface,
5935 CustomDoc_AddRef,
5936 CustomDoc_Release,
5937 CustomDoc_SetUIHandler
5940 static const tid_t HTMLDocumentObj_iface_tids[] = {
5941 IHTMLDocument2_tid,
5942 IHTMLDocument3_tid,
5943 IHTMLDocument4_tid,
5944 IHTMLDocument5_tid,
5947 static dispex_static_data_t HTMLDocumentObj_dispex = {
5948 L"HTMLDocumentObj",
5949 NULL,
5950 DispHTMLDocument_tid,
5951 HTMLDocumentObj_iface_tids
5954 static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID riid, void **ppv)
5956 HTMLDocumentObj *doc;
5957 HRESULT hres;
5959 if(outer && !IsEqualGUID(&IID_IUnknown, riid)) {
5960 *ppv = NULL;
5961 return E_INVALIDARG;
5964 /* ensure that security manager is initialized */
5965 if(!get_security_manager())
5966 return E_OUTOFMEMORY;
5968 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
5969 if(!doc)
5970 return E_OUTOFMEMORY;
5972 doc->ref = 1;
5973 doc->IUnknown_inner.lpVtbl = &HTMLDocumentObjVtbl;
5974 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
5976 doc->basedoc.doc_obj = doc;
5978 init_dispatch(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex, COMPAT_MODE_QUIRKS);
5979 init_doc(&doc->basedoc, outer ? outer : &doc->IUnknown_inner, &doc->dispex.IDispatchEx_iface);
5980 TargetContainer_Init(doc);
5981 doc->is_mhtml = is_mhtml;
5983 doc->task_magic = get_task_target_magic();
5985 HTMLDocument_View_Init(doc);
5987 hres = create_gecko_browser(doc, &doc->nscontainer);
5988 if(FAILED(hres)) {
5989 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
5990 htmldoc_release(&doc->basedoc);
5991 return hres;
5994 if(IsEqualGUID(&IID_IUnknown, riid)) {
5995 *ppv = &doc->IUnknown_inner;
5996 }else {
5997 hres = htmldoc_query_interface(&doc->basedoc, riid, ppv);
5998 htmldoc_release(&doc->basedoc);
5999 if(FAILED(hres))
6000 return hres;
6003 doc->basedoc.window = doc->nscontainer->content_window;
6004 IHTMLWindow2_AddRef(&doc->basedoc.window->base.IHTMLWindow2_iface);
6006 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
6007 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
6008 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
6011 get_thread_hwnd();
6013 return S_OK;
6016 HRESULT HTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
6018 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
6019 return create_document_object(FALSE, outer, riid, ppv);
6022 HRESULT MHTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
6024 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
6025 return create_document_object(TRUE, outer, riid, ppv);