xmllite: Drop superfluous casts to self.
[wine.git] / dlls / mshtml / htmldoc.c
blob344079ba36eec6c51f052abeb97872d2ff2953e2
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>
21 #include <assert.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "wininet.h"
29 #include "ole2.h"
30 #include "perhist.h"
31 #include "mshtmdid.h"
32 #include "mshtmcid.h"
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
37 #include "htmlevent.h"
38 #include "pluginhost.h"
39 #include "binding.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
43 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret);
45 HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement **ret)
47 nsIDOMNodeList *nsnode_list;
48 nsIDOMElement *nselem;
49 nsIDOMNode *nsnode;
50 nsAString id_str;
51 nsresult nsres;
52 HRESULT hres;
54 if(!doc->nsdoc) {
55 WARN("NULL nsdoc\n");
56 return E_UNEXPECTED;
59 nsAString_InitDepend(&id_str, id);
60 /* get element by id attribute */
61 nsres = nsIDOMHTMLDocument_GetElementById(doc->nsdoc, &id_str, &nselem);
62 if(FAILED(nsres)) {
63 ERR("GetElementById failed: %08x\n", nsres);
64 nsAString_Finish(&id_str);
65 return E_FAIL;
68 /* get first element by name attribute */
69 nsres = nsIDOMHTMLDocument_GetElementsByName(doc->nsdoc, &id_str, &nsnode_list);
70 nsAString_Finish(&id_str);
71 if(FAILED(nsres)) {
72 ERR("getElementsByName failed: %08x\n", nsres);
73 if(nselem)
74 nsIDOMElement_Release(nselem);
75 return E_FAIL;
78 nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode);
79 nsIDOMNodeList_Release(nsnode_list);
80 assert(nsres == NS_OK);
82 if(nsnode && nselem) {
83 UINT16 pos;
85 nsres = nsIDOMNode_CompareDocumentPosition(nsnode, (nsIDOMNode*)nselem, &pos);
86 if(NS_FAILED(nsres)) {
87 FIXME("CompareDocumentPosition failed: 0x%08x\n", nsres);
88 nsIDOMNode_Release(nsnode);
89 nsIDOMElement_Release(nselem);
90 return E_FAIL;
93 TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
94 if(!(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS))) {
95 nsIDOMElement_Release(nselem);
96 nselem = NULL;
100 if(nsnode) {
101 if(!nselem) {
102 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
103 assert(nsres == NS_OK);
105 nsIDOMNode_Release(nsnode);
108 if(!nselem) {
109 *ret = NULL;
110 return S_OK;
113 hres = get_element(nselem, ret);
114 nsIDOMElement_Release(nselem);
115 return hres;
118 UINT get_document_charset(HTMLDocumentNode *doc)
120 nsAString charset_str;
121 UINT ret = 0;
122 nsresult nsres;
124 if(doc->charset)
125 return doc->charset;
127 nsAString_Init(&charset_str, NULL);
128 nsres = nsIDOMHTMLDocument_GetCharacterSet(doc->nsdoc, &charset_str);
129 if(NS_SUCCEEDED(nsres)) {
130 const PRUnichar *charset;
132 nsAString_GetData(&charset_str, &charset);
134 if(*charset) {
135 BSTR str = SysAllocString(charset);
136 ret = cp_from_charset_string(str);
137 SysFreeString(str);
139 }else {
140 ERR("GetCharset failed: %08x\n", nsres);
142 nsAString_Finish(&charset_str);
144 if(!ret)
145 return CP_UTF8;
147 return doc->charset = ret;
150 static inline HTMLDocument *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
152 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument2_iface);
155 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
157 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
159 return htmldoc_query_interface(This, riid, ppv);
162 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
164 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
166 return htmldoc_addref(This);
169 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
171 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
173 return htmldoc_release(This);
176 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
178 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
180 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
183 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
184 LCID lcid, ITypeInfo **ppTInfo)
186 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
188 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
191 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
192 LPOLESTR *rgszNames, UINT cNames,
193 LCID lcid, DISPID *rgDispId)
195 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
197 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
198 rgDispId);
201 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
202 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
203 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
205 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
207 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
208 pDispParams, pVarResult, pExcepInfo, puArgErr);
211 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
213 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
214 HRESULT hres;
216 TRACE("(%p)->(%p)\n", This, p);
218 hres = IHTMLDocument7_get_parentWindow(&This->IHTMLDocument7_iface, (IHTMLWindow2**)p);
219 return hres == S_OK && !*p ? E_PENDING : hres;
222 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
224 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
225 nsIDOMElement *nselem = NULL;
226 HTMLDOMNode *node;
227 nsresult nsres;
228 HRESULT hres;
230 TRACE("(%p)->(%p)\n", This, p);
232 if(!This->doc_node->nsdoc) {
233 WARN("NULL nsdoc\n");
234 return E_UNEXPECTED;
237 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
238 if(NS_FAILED(nsres)) {
239 ERR("GetDocumentElement failed: %08x\n", nsres);
240 return E_FAIL;
243 if(!nselem) {
244 *p = NULL;
245 return S_OK;
248 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
249 nsIDOMElement_Release(nselem);
250 if(FAILED(hres))
251 return hres;
253 *p = create_all_collection(node, TRUE);
254 node_release(node);
255 return hres;
258 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
260 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
261 nsIDOMHTMLElement *nsbody = NULL;
262 HTMLElement *element;
263 HRESULT hres;
265 TRACE("(%p)->(%p)\n", This, p);
267 if(This->doc_node->nsdoc) {
268 nsresult nsres;
270 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
271 if(NS_FAILED(nsres)) {
272 TRACE("Could not get body: %08x\n", nsres);
273 return E_UNEXPECTED;
277 if(!nsbody) {
278 *p = NULL;
279 return S_OK;
282 hres = get_element((nsIDOMElement*)nsbody, &element);
283 nsIDOMHTMLElement_Release(nsbody);
284 if(FAILED(hres))
285 return hres;
287 *p = &element->IHTMLElement_iface;
288 return S_OK;
291 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
293 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
294 nsIDOMElement *nselem;
295 HTMLElement *elem;
296 nsresult nsres;
297 HRESULT hres;
299 TRACE("(%p)->(%p)\n", This, p);
301 if(!This->doc_node->nsdoc) {
302 *p = NULL;
303 return S_OK;
307 * NOTE: Gecko may return an active element even if the document is not visible.
308 * IE returns NULL in this case.
310 nsres = nsIDOMHTMLDocument_GetActiveElement(This->doc_node->nsdoc, &nselem);
311 if(NS_FAILED(nsres)) {
312 ERR("GetActiveElement failed: %08x\n", nsres);
313 return E_FAIL;
316 if(!nselem) {
317 *p = NULL;
318 return S_OK;
321 hres = get_element(nselem, &elem);
322 nsIDOMElement_Release(nselem);
323 if(FAILED(hres))
324 return hres;
326 *p = &elem->IHTMLElement_iface;
327 return S_OK;
330 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
332 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
333 nsIDOMHTMLCollection *nscoll = NULL;
334 nsresult nsres;
336 TRACE("(%p)->(%p)\n", This, p);
338 if(!p)
339 return E_INVALIDARG;
341 *p = NULL;
343 if(!This->doc_node->nsdoc) {
344 WARN("NULL nsdoc\n");
345 return E_UNEXPECTED;
348 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
349 if(NS_FAILED(nsres)) {
350 ERR("GetImages failed: %08x\n", nsres);
351 return E_FAIL;
354 if(nscoll) {
355 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
356 nsIDOMHTMLCollection_Release(nscoll);
359 return S_OK;
362 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
364 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
365 nsIDOMHTMLCollection *nscoll = NULL;
366 nsresult nsres;
368 TRACE("(%p)->(%p)\n", This, p);
370 if(!p)
371 return E_INVALIDARG;
373 *p = NULL;
375 if(!This->doc_node->nsdoc) {
376 WARN("NULL nsdoc\n");
377 return E_UNEXPECTED;
380 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
381 if(NS_FAILED(nsres)) {
382 ERR("GetApplets failed: %08x\n", nsres);
383 return E_FAIL;
386 if(nscoll) {
387 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
388 nsIDOMHTMLCollection_Release(nscoll);
391 return S_OK;
394 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
396 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
397 nsIDOMHTMLCollection *nscoll = NULL;
398 nsresult nsres;
400 TRACE("(%p)->(%p)\n", This, p);
402 if(!p)
403 return E_INVALIDARG;
405 *p = NULL;
407 if(!This->doc_node->nsdoc) {
408 WARN("NULL nsdoc\n");
409 return E_UNEXPECTED;
412 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
413 if(NS_FAILED(nsres)) {
414 ERR("GetLinks failed: %08x\n", nsres);
415 return E_FAIL;
418 if(nscoll) {
419 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
420 nsIDOMHTMLCollection_Release(nscoll);
423 return S_OK;
426 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
428 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
429 nsIDOMHTMLCollection *nscoll = NULL;
430 nsresult nsres;
432 TRACE("(%p)->(%p)\n", This, p);
434 if(!p)
435 return E_INVALIDARG;
437 *p = NULL;
439 if(!This->doc_node->nsdoc) {
440 WARN("NULL nsdoc\n");
441 return E_UNEXPECTED;
444 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
445 if(NS_FAILED(nsres)) {
446 ERR("GetForms failed: %08x\n", nsres);
447 return E_FAIL;
450 if(nscoll) {
451 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
452 nsIDOMHTMLCollection_Release(nscoll);
455 return S_OK;
458 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
460 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
461 nsIDOMHTMLCollection *nscoll = NULL;
462 nsresult nsres;
464 TRACE("(%p)->(%p)\n", This, p);
466 if(!p)
467 return E_INVALIDARG;
469 *p = NULL;
471 if(!This->doc_node->nsdoc) {
472 WARN("NULL nsdoc\n");
473 return E_UNEXPECTED;
476 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
477 if(NS_FAILED(nsres)) {
478 ERR("GetAnchors failed: %08x\n", nsres);
479 return E_FAIL;
482 if(nscoll) {
483 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
484 nsIDOMHTMLCollection_Release(nscoll);
487 return S_OK;
490 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
492 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
493 nsAString nsstr;
494 nsresult nsres;
496 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
498 if(!This->doc_node->nsdoc) {
499 WARN("NULL nsdoc\n");
500 return E_UNEXPECTED;
503 nsAString_InitDepend(&nsstr, v);
504 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
505 nsAString_Finish(&nsstr);
506 if(NS_FAILED(nsres))
507 ERR("SetTitle failed: %08x\n", nsres);
509 return S_OK;
512 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
514 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
515 const PRUnichar *ret;
516 nsAString nsstr;
517 nsresult nsres;
519 TRACE("(%p)->(%p)\n", This, p);
521 if(!This->doc_node->nsdoc) {
522 WARN("NULL nsdoc\n");
523 return E_UNEXPECTED;
527 nsAString_Init(&nsstr, NULL);
528 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
529 if (NS_SUCCEEDED(nsres)) {
530 nsAString_GetData(&nsstr, &ret);
531 *p = SysAllocString(ret);
533 nsAString_Finish(&nsstr);
535 if(NS_FAILED(nsres)) {
536 ERR("GetTitle failed: %08x\n", nsres);
537 return E_FAIL;
540 return S_OK;
543 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
545 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
546 nsIDOMHTMLCollection *nscoll = NULL;
547 nsresult nsres;
549 TRACE("(%p)->(%p)\n", This, p);
551 if(!p)
552 return E_INVALIDARG;
554 *p = NULL;
556 if(!This->doc_node->nsdoc) {
557 WARN("NULL nsdoc\n");
558 return E_UNEXPECTED;
561 nsres = nsIDOMHTMLDocument_GetScripts(This->doc_node->nsdoc, &nscoll);
562 if(NS_FAILED(nsres)) {
563 ERR("GetImages failed: %08x\n", nsres);
564 return E_FAIL;
567 if(nscoll) {
568 *p = create_collection_from_htmlcol(nscoll, This->doc_node->document_mode);
569 nsIDOMHTMLCollection_Release(nscoll);
572 return S_OK;
575 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
577 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
578 HRESULT hres;
580 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
582 if(wcsicmp(v, L"on")) {
583 FIXME("Unsupported arg %s\n", debugstr_w(v));
584 return E_NOTIMPL;
587 hres = setup_edit_mode(This->doc_obj);
588 if(FAILED(hres))
589 return hres;
591 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
592 return S_OK;
595 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
597 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
598 FIXME("(%p)->(%p) always returning Off\n", This, p);
600 if(!p)
601 return E_INVALIDARG;
603 *p = SysAllocString(L"Off");
605 return S_OK;
608 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
610 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
611 nsISelection *nsselection;
612 nsresult nsres;
614 TRACE("(%p)->(%p)\n", This, p);
616 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
617 if(NS_FAILED(nsres)) {
618 ERR("GetSelection failed: %08x\n", nsres);
619 return E_FAIL;
622 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
625 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
627 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
630 TRACE("(%p)->(%p)\n", iface, p);
632 if(!p)
633 return E_POINTER;
635 return get_readystate_string(This->window->readystate, p);
638 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
640 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
642 TRACE("(%p)->(%p)\n", This, p);
644 return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p);
647 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
649 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
650 FIXME("(%p)->(%p)\n", This, p);
651 return E_NOTIMPL;
654 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
656 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
657 FIXME("(%p)->(%p)\n", This, p);
658 return E_NOTIMPL;
661 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
663 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
664 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
665 return E_NOTIMPL;
668 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
670 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
671 FIXME("(%p)->(%p)\n", This, p);
672 return E_NOTIMPL;
675 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
677 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
678 IHTMLElement *element = NULL;
679 IHTMLBodyElement *body;
680 HRESULT hr;
682 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
684 hr = IHTMLDocument2_get_body(iface, &element);
685 if (FAILED(hr))
687 ERR("Failed to get body (0x%08x)\n", hr);
688 return hr;
691 if(!element)
693 FIXME("Empty body element.\n");
694 return hr;
697 hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body);
698 if (SUCCEEDED(hr))
700 hr = IHTMLBodyElement_put_bgColor(body, v);
701 IHTMLBodyElement_Release(body);
703 IHTMLElement_Release(element);
705 return hr;
708 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
710 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
711 nsAString nsstr;
712 nsresult nsres;
713 HRESULT hres;
715 TRACE("(%p)->(%p)\n", This, p);
717 if(!This->doc_node->nsdoc) {
718 WARN("NULL nsdoc\n");
719 return E_UNEXPECTED;
722 nsAString_Init(&nsstr, NULL);
723 nsres = nsIDOMHTMLDocument_GetBgColor(This->doc_node->nsdoc, &nsstr);
724 hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p);
725 if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) {
726 TRACE("default #ffffff\n");
727 if(!(V_BSTR(p) = SysAllocString(L"#ffffff")))
728 hres = E_OUTOFMEMORY;
730 return hres;
733 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
735 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
736 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
737 return E_NOTIMPL;
740 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
742 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
743 FIXME("(%p)->(%p)\n", This, p);
744 return E_NOTIMPL;
747 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
749 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
750 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
751 return E_NOTIMPL;
754 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
756 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
757 FIXME("(%p)->(%p)\n", This, p);
758 return E_NOTIMPL;
761 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
763 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
764 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
765 return E_NOTIMPL;
768 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
770 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
771 FIXME("(%p)->(%p)\n", This, p);
772 return E_NOTIMPL;
775 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
777 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
779 FIXME("(%p)->(%p)\n", This, p);
781 *p = NULL;
782 return S_OK;
785 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
787 HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface)->doc_node;
789 TRACE("(%p)->(%p)\n", This, p);
791 if(!This->nsdoc || !This->window) {
792 WARN("NULL window\n");
793 return E_UNEXPECTED;
796 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
799 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
801 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
802 FIXME("(%p)->(%p)\n", This, p);
803 return E_NOTIMPL;
806 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
808 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
810 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
812 if(!This->window) {
813 FIXME("No window available\n");
814 return E_FAIL;
817 return navigate_url(This->window, v, This->window->uri, BINDING_NAVIGATED);
820 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
822 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
824 TRACE("(%p)->(%p)\n", iface, p);
826 *p = SysAllocString(This->window->url ? This->window->url : L"about:blank");
827 return *p ? S_OK : E_OUTOFMEMORY;
830 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
832 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
833 nsAString nsstr;
834 nsresult nsres;
836 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
838 nsAString_InitDepend(&nsstr, v);
839 nsres = nsIDOMHTMLDocument_SetDomain(This->doc_node->nsdoc, &nsstr);
840 nsAString_Finish(&nsstr);
841 if(NS_FAILED(nsres)) {
842 ERR("SetDomain failed: %08x\n", nsres);
843 return E_INVALIDARG;
846 return S_OK;
849 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
851 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
852 nsAString nsstr;
853 nsresult nsres;
855 TRACE("(%p)->(%p)\n", This, p);
857 nsAString_Init(&nsstr, NULL);
858 nsres = nsIDOMHTMLDocument_GetDomain(This->doc_node->nsdoc, &nsstr);
859 if(NS_SUCCEEDED(nsres) && This->window && This->window->uri) {
860 const PRUnichar *str;
861 HRESULT hres;
863 nsAString_GetData(&nsstr, &str);
864 if(!*str) {
865 TRACE("Gecko returned empty string, fallback to loaded URL.\n");
866 nsAString_Finish(&nsstr);
867 hres = IUri_GetHost(This->window->uri, p);
868 return FAILED(hres) ? hres : S_OK;
872 return return_nsstr(nsres, &nsstr, p);
875 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
877 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
878 BOOL bret;
880 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
882 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
883 if(!bret) {
884 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
885 return HRESULT_FROM_WIN32(GetLastError());
888 return S_OK;
891 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
893 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
894 DWORD size;
895 BOOL bret;
897 TRACE("(%p)->(%p)\n", This, p);
899 size = 0;
900 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
901 if(!bret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
902 WARN("InternetGetCookieExW failed: %u\n", GetLastError());
903 *p = NULL;
904 return S_OK;
907 if(!size) {
908 *p = NULL;
909 return S_OK;
912 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
913 if(!*p)
914 return E_OUTOFMEMORY;
916 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
917 if(!bret) {
918 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
919 return E_FAIL;
922 return S_OK;
925 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
927 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
928 FIXME("(%p)->(%x)\n", This, v);
929 return E_NOTIMPL;
932 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
934 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
935 FIXME("(%p)->(%p)\n", This, p);
936 return E_NOTIMPL;
939 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
941 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
942 FIXME("(%p)->(%s) returning S_OK\n", This, debugstr_w(v));
943 return S_OK;
946 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
948 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
950 TRACE("(%p)->(%p)\n", This, p);
952 return IHTMLDocument7_get_characterSet(&This->IHTMLDocument7_iface, p);
955 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
957 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
958 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
959 return E_NOTIMPL;
962 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
964 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
966 TRACE("(%p)->(%p)\n", This, p);
968 *p = charset_string_from_cp(GetACP());
969 return *p ? S_OK : E_OUTOFMEMORY;
972 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
974 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
975 FIXME("(%p)->(%p)\n", This, p);
976 return E_NOTIMPL;
979 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
981 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
982 FIXME("(%p)->(%p)\n", This, p);
983 return E_NOTIMPL;
986 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
988 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
989 FIXME("(%p)->(%p)\n", This, p);
990 return E_NOTIMPL;
993 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
995 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
996 FIXME("(%p)->(%p)\n", This, p);
997 return E_NOTIMPL;
1000 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
1002 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1003 FIXME("(%p)->(%p)\n", This, p);
1004 return E_NOTIMPL;
1007 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
1009 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1010 FIXME("(%p)->(%p)\n", This, p);
1011 return E_NOTIMPL;
1014 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
1016 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1017 FIXME("(%p)->(%p)\n", This, p);
1018 return E_NOTIMPL;
1021 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
1023 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1024 FIXME("(%p)->(%p)\n", This, p);
1025 return E_NOTIMPL;
1028 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
1030 VARIANT *var, tmp;
1031 JSContext *jsctx;
1032 nsAString nsstr;
1033 ULONG i, argc;
1034 nsresult nsres;
1035 HRESULT hres;
1037 if(!This->doc_node->nsdoc) {
1038 WARN("NULL nsdoc\n");
1039 return E_UNEXPECTED;
1042 if (!psarray)
1043 return S_OK;
1045 if(psarray->cDims != 1) {
1046 FIXME("cDims=%d\n", psarray->cDims);
1047 return E_INVALIDARG;
1050 hres = SafeArrayAccessData(psarray, (void**)&var);
1051 if(FAILED(hres)) {
1052 WARN("SafeArrayAccessData failed: %08x\n", hres);
1053 return hres;
1056 V_VT(&tmp) = VT_EMPTY;
1058 jsctx = get_context_from_document(This->doc_node->nsdoc);
1059 argc = psarray->rgsabound[0].cElements;
1060 for(i=0; i < argc; i++) {
1061 if(V_VT(var+i) == VT_BSTR) {
1062 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
1063 }else {
1064 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1065 if(FAILED(hres)) {
1066 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1067 break;
1069 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1072 if(!ln || i != argc-1)
1073 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1074 else
1075 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1076 nsAString_Finish(&nsstr);
1077 if(V_VT(var+i) != VT_BSTR)
1078 VariantClear(&tmp);
1079 if(NS_FAILED(nsres)) {
1080 ERR("Write failed: %08x\n", nsres);
1081 hres = E_FAIL;
1082 break;
1086 SafeArrayUnaccessData(psarray);
1088 return hres;
1091 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1093 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1095 TRACE("(%p)->(%p)\n", iface, psarray);
1097 return document_write(This, psarray, FALSE);
1100 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1102 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1104 TRACE("(%p)->(%p)\n", This, psarray);
1106 return document_write(This, psarray, TRUE);
1109 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1110 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1112 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1113 nsISupports *tmp;
1114 nsresult nsres;
1116 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1117 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1119 if(!This->doc_node->nsdoc) {
1120 ERR("!nsdoc\n");
1121 return E_NOTIMPL;
1124 if(!url || wcscmp(url, L"text/html") || V_VT(&name) != VT_ERROR
1125 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1126 FIXME("unsupported args\n");
1128 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1129 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1130 if(NS_FAILED(nsres)) {
1131 ERR("Open failed: %08x\n", nsres);
1132 return E_FAIL;
1135 if(tmp)
1136 nsISupports_Release(tmp);
1138 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1139 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1140 return S_OK;
1143 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1145 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1146 nsresult nsres;
1148 TRACE("(%p)\n", This);
1150 if(!This->doc_node->nsdoc) {
1151 ERR("!nsdoc\n");
1152 return E_NOTIMPL;
1155 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1156 if(NS_FAILED(nsres)) {
1157 ERR("Close failed: %08x\n", nsres);
1158 return E_FAIL;
1161 return S_OK;
1164 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1166 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1167 nsresult nsres;
1169 TRACE("(%p)\n", This);
1171 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1172 if(NS_FAILED(nsres)) {
1173 ERR("Clear failed: %08x\n", nsres);
1174 return E_FAIL;
1177 return S_OK;
1180 static const struct {
1181 const WCHAR *name;
1182 OLECMDID id;
1183 }command_names[] = {
1184 {L"copy", IDM_COPY},
1185 {L"cut", IDM_CUT},
1186 {L"fontname", IDM_FONTNAME},
1187 {L"fontsize", IDM_FONTSIZE},
1188 {L"indent", IDM_INDENT},
1189 {L"insertorderedlist", IDM_ORDERLIST},
1190 {L"insertunorderedlist", IDM_UNORDERLIST},
1191 {L"outdent", IDM_OUTDENT},
1192 {L"paste", IDM_PASTE},
1193 {L"respectvisibilityindesign", IDM_RESPECTVISIBILITY_INDESIGN}
1196 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1198 int i;
1200 for(i = 0; i < ARRAY_SIZE(command_names); i++) {
1201 if(!wcsicmp(command_names[i].name, str)) {
1202 *cmdid = command_names[i].id;
1203 return TRUE;
1207 FIXME("Unknown command %s\n", debugstr_w(str));
1208 return FALSE;
1211 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1212 VARIANT_BOOL *pfRet)
1214 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1215 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1216 return E_NOTIMPL;
1219 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1220 VARIANT_BOOL *pfRet)
1222 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1223 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1224 return E_NOTIMPL;
1227 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1228 VARIANT_BOOL *pfRet)
1230 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1231 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1232 return E_NOTIMPL;
1235 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1236 VARIANT_BOOL *pfRet)
1238 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1239 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1240 return E_NOTIMPL;
1243 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1244 BSTR *pfRet)
1246 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1247 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1248 return E_NOTIMPL;
1251 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1252 VARIANT *pfRet)
1254 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1255 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1256 return E_NOTIMPL;
1259 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1260 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1262 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1263 OLECMDID cmdid;
1264 VARIANT ret;
1265 HRESULT hres;
1267 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1269 if(!cmdid_from_string(cmdID, &cmdid))
1270 return OLECMDERR_E_NOTSUPPORTED;
1272 V_VT(&ret) = VT_EMPTY;
1273 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1274 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1275 if(FAILED(hres))
1276 return hres;
1278 if(V_VT(&ret) != VT_EMPTY) {
1279 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1280 VariantClear(&ret);
1283 *pfRet = VARIANT_TRUE;
1284 return S_OK;
1287 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1288 VARIANT_BOOL *pfRet)
1290 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1291 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1292 return E_NOTIMPL;
1295 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1296 IHTMLElement **newElem)
1298 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1299 HTMLElement *elem;
1300 HRESULT hres;
1302 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1304 hres = create_element(This->doc_node, eTag, &elem);
1305 if(FAILED(hres))
1306 return hres;
1308 *newElem = &elem->IHTMLElement_iface;
1309 return S_OK;
1312 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1314 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1315 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1316 return E_NOTIMPL;
1319 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1321 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1322 FIXME("(%p)->(%p)\n", This, p);
1323 return E_NOTIMPL;
1326 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1328 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1330 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1332 return set_doc_event(This, EVENTID_CLICK, &v);
1335 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1337 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1339 TRACE("(%p)->(%p)\n", This, p);
1341 return get_doc_event(This, EVENTID_CLICK, p);
1344 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1346 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1348 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1350 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1353 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1355 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1357 TRACE("(%p)->(%p)\n", This, p);
1359 return get_doc_event(This, EVENTID_DBLCLICK, p);
1362 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1364 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1366 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1368 return set_doc_event(This, EVENTID_KEYUP, &v);
1371 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1373 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1375 TRACE("(%p)->(%p)\n", This, p);
1377 return get_doc_event(This, EVENTID_KEYUP, p);
1380 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1382 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1384 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1386 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1389 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1391 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1393 TRACE("(%p)->(%p)\n", This, p);
1395 return get_doc_event(This, EVENTID_KEYDOWN, p);
1398 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1400 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1402 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1404 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1407 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1409 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1411 TRACE("(%p)->(%p)\n", This, p);
1413 return get_doc_event(This, EVENTID_KEYPRESS, p);
1416 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1418 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1420 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1422 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1425 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1427 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1429 TRACE("(%p)->(%p)\n", This, p);
1431 return get_doc_event(This, EVENTID_MOUSEUP, p);
1434 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1436 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1438 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1440 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1443 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1445 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1447 TRACE("(%p)->(%p)\n", This, p);
1449 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1452 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1454 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1456 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1458 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1461 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1463 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1465 TRACE("(%p)->(%p)\n", This, p);
1467 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1470 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1472 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1474 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1476 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1479 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1481 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1483 TRACE("(%p)->(%p)\n", This, p);
1485 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1488 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1490 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1492 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1494 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1497 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1499 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1501 TRACE("(%p)->(%p)\n", This, p);
1503 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1506 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1508 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1510 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1512 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1515 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1517 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1519 TRACE("(%p)->(%p)\n", This, p);
1521 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1524 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1526 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1527 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1528 return E_NOTIMPL;
1531 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1533 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1534 FIXME("(%p)->(%p)\n", This, p);
1535 return E_NOTIMPL;
1538 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1540 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1541 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1542 return E_NOTIMPL;
1545 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1547 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1548 FIXME("(%p)->(%p)\n", This, p);
1549 return E_NOTIMPL;
1552 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1554 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1555 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1556 return E_NOTIMPL;
1559 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1561 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1562 FIXME("(%p)->(%p)\n", This, p);
1563 return E_NOTIMPL;
1566 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1568 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1570 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1572 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1575 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1577 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1579 TRACE("(%p)->(%p)\n", This, p);
1581 return get_doc_event(This, EVENTID_DRAGSTART, p);
1584 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1586 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1588 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1590 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1593 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1595 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1597 TRACE("(%p)->(%p)\n", This, p);
1599 return get_doc_event(This, EVENTID_SELECTSTART, p);
1602 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1603 IHTMLElement **elementHit)
1605 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1606 nsIDOMElement *nselem;
1607 HTMLElement *element;
1608 nsresult nsres;
1609 HRESULT hres;
1611 TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1613 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1614 if(NS_FAILED(nsres)) {
1615 ERR("ElementFromPoint failed: %08x\n", nsres);
1616 return E_FAIL;
1619 if(!nselem) {
1620 *elementHit = NULL;
1621 return S_OK;
1624 hres = get_element(nselem, &element);
1625 nsIDOMElement_Release(nselem);
1626 if(FAILED(hres))
1627 return hres;
1629 *elementHit = &element->IHTMLElement_iface;
1630 return S_OK;
1633 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1635 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1636 HRESULT hres;
1638 TRACE("(%p)->(%p)\n", This, p);
1640 hres = IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
1641 return hres == S_OK && !*p ? E_FAIL : hres;
1644 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1645 IHTMLStyleSheetsCollection **p)
1647 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1648 nsIDOMStyleSheetList *nsstylelist;
1649 nsresult nsres;
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: %08x\n", nsres);
1663 return E_FAIL;
1666 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1667 nsIDOMStyleSheetList_Release(nsstylelist);
1669 return S_OK;
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 if(!String)
1707 return E_INVALIDARG;
1709 *String = SysAllocString(L"[object]");
1710 return *String ? S_OK : E_OUTOFMEMORY;
1714 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1715 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1717 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1718 nsIDOMHTMLHeadElement *head_elem;
1719 IHTMLStyleElement *style_elem;
1720 HTMLElement *elem;
1721 nsresult nsres;
1722 HRESULT hres;
1724 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1726 if(!This->doc_node->nsdoc) {
1727 FIXME("not a real doc object\n");
1728 return E_NOTIMPL;
1731 if(lIndex != -1)
1732 FIXME("Unsupported lIndex %d\n", lIndex);
1734 if(bstrHref && *bstrHref) {
1735 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
1736 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1737 return S_OK;
1740 hres = create_element(This->doc_node, L"style", &elem);
1741 if(FAILED(hres))
1742 return hres;
1744 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
1745 if(NS_SUCCEEDED(nsres)) {
1746 nsIDOMNode *head_node, *tmp_node;
1748 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
1749 nsIDOMHTMLHeadElement_Release(head_elem);
1750 assert(nsres == NS_OK);
1752 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
1753 nsIDOMNode_Release(head_node);
1754 if(NS_SUCCEEDED(nsres) && tmp_node)
1755 nsIDOMNode_Release(tmp_node);
1757 if(NS_FAILED(nsres)) {
1758 IHTMLElement_Release(&elem->IHTMLElement_iface);
1759 return E_FAIL;
1762 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
1763 assert(hres == S_OK);
1764 IHTMLElement_Release(&elem->IHTMLElement_iface);
1766 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
1767 IHTMLStyleElement_Release(style_elem);
1768 return hres;
1771 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1772 HTMLDocument_QueryInterface,
1773 HTMLDocument_AddRef,
1774 HTMLDocument_Release,
1775 HTMLDocument_GetTypeInfoCount,
1776 HTMLDocument_GetTypeInfo,
1777 HTMLDocument_GetIDsOfNames,
1778 HTMLDocument_Invoke,
1779 HTMLDocument_get_Script,
1780 HTMLDocument_get_all,
1781 HTMLDocument_get_body,
1782 HTMLDocument_get_activeElement,
1783 HTMLDocument_get_images,
1784 HTMLDocument_get_applets,
1785 HTMLDocument_get_links,
1786 HTMLDocument_get_forms,
1787 HTMLDocument_get_anchors,
1788 HTMLDocument_put_title,
1789 HTMLDocument_get_title,
1790 HTMLDocument_get_scripts,
1791 HTMLDocument_put_designMode,
1792 HTMLDocument_get_designMode,
1793 HTMLDocument_get_selection,
1794 HTMLDocument_get_readyState,
1795 HTMLDocument_get_frames,
1796 HTMLDocument_get_embeds,
1797 HTMLDocument_get_plugins,
1798 HTMLDocument_put_alinkColor,
1799 HTMLDocument_get_alinkColor,
1800 HTMLDocument_put_bgColor,
1801 HTMLDocument_get_bgColor,
1802 HTMLDocument_put_fgColor,
1803 HTMLDocument_get_fgColor,
1804 HTMLDocument_put_linkColor,
1805 HTMLDocument_get_linkColor,
1806 HTMLDocument_put_vlinkColor,
1807 HTMLDocument_get_vlinkColor,
1808 HTMLDocument_get_referrer,
1809 HTMLDocument_get_location,
1810 HTMLDocument_get_lastModified,
1811 HTMLDocument_put_URL,
1812 HTMLDocument_get_URL,
1813 HTMLDocument_put_domain,
1814 HTMLDocument_get_domain,
1815 HTMLDocument_put_cookie,
1816 HTMLDocument_get_cookie,
1817 HTMLDocument_put_expando,
1818 HTMLDocument_get_expando,
1819 HTMLDocument_put_charset,
1820 HTMLDocument_get_charset,
1821 HTMLDocument_put_defaultCharset,
1822 HTMLDocument_get_defaultCharset,
1823 HTMLDocument_get_mimeType,
1824 HTMLDocument_get_fileSize,
1825 HTMLDocument_get_fileCreatedDate,
1826 HTMLDocument_get_fileModifiedDate,
1827 HTMLDocument_get_fileUpdatedDate,
1828 HTMLDocument_get_security,
1829 HTMLDocument_get_protocol,
1830 HTMLDocument_get_nameProp,
1831 HTMLDocument_write,
1832 HTMLDocument_writeln,
1833 HTMLDocument_open,
1834 HTMLDocument_close,
1835 HTMLDocument_clear,
1836 HTMLDocument_queryCommandSupported,
1837 HTMLDocument_queryCommandEnabled,
1838 HTMLDocument_queryCommandState,
1839 HTMLDocument_queryCommandIndeterm,
1840 HTMLDocument_queryCommandText,
1841 HTMLDocument_queryCommandValue,
1842 HTMLDocument_execCommand,
1843 HTMLDocument_execCommandShowHelp,
1844 HTMLDocument_createElement,
1845 HTMLDocument_put_onhelp,
1846 HTMLDocument_get_onhelp,
1847 HTMLDocument_put_onclick,
1848 HTMLDocument_get_onclick,
1849 HTMLDocument_put_ondblclick,
1850 HTMLDocument_get_ondblclick,
1851 HTMLDocument_put_onkeyup,
1852 HTMLDocument_get_onkeyup,
1853 HTMLDocument_put_onkeydown,
1854 HTMLDocument_get_onkeydown,
1855 HTMLDocument_put_onkeypress,
1856 HTMLDocument_get_onkeypress,
1857 HTMLDocument_put_onmouseup,
1858 HTMLDocument_get_onmouseup,
1859 HTMLDocument_put_onmousedown,
1860 HTMLDocument_get_onmousedown,
1861 HTMLDocument_put_onmousemove,
1862 HTMLDocument_get_onmousemove,
1863 HTMLDocument_put_onmouseout,
1864 HTMLDocument_get_onmouseout,
1865 HTMLDocument_put_onmouseover,
1866 HTMLDocument_get_onmouseover,
1867 HTMLDocument_put_onreadystatechange,
1868 HTMLDocument_get_onreadystatechange,
1869 HTMLDocument_put_onafterupdate,
1870 HTMLDocument_get_onafterupdate,
1871 HTMLDocument_put_onrowexit,
1872 HTMLDocument_get_onrowexit,
1873 HTMLDocument_put_onrowenter,
1874 HTMLDocument_get_onrowenter,
1875 HTMLDocument_put_ondragstart,
1876 HTMLDocument_get_ondragstart,
1877 HTMLDocument_put_onselectstart,
1878 HTMLDocument_get_onselectstart,
1879 HTMLDocument_elementFromPoint,
1880 HTMLDocument_get_parentWindow,
1881 HTMLDocument_get_styleSheets,
1882 HTMLDocument_put_onbeforeupdate,
1883 HTMLDocument_get_onbeforeupdate,
1884 HTMLDocument_put_onerrorupdate,
1885 HTMLDocument_get_onerrorupdate,
1886 HTMLDocument_toString,
1887 HTMLDocument_createStyleSheet
1890 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
1892 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
1895 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
1896 REFIID riid, void **ppv)
1898 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1899 return htmldoc_query_interface(This, riid, ppv);
1902 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
1904 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1905 return htmldoc_addref(This);
1908 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
1910 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1911 return htmldoc_release(This);
1914 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
1916 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1917 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1920 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
1921 LCID lcid, ITypeInfo **ppTInfo)
1923 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1924 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1927 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
1928 LPOLESTR *rgszNames, UINT cNames,
1929 LCID lcid, DISPID *rgDispId)
1931 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1932 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1933 rgDispId);
1936 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
1937 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1938 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1940 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1941 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1942 pDispParams, pVarResult, pExcepInfo, puArgErr);
1945 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
1947 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1948 FIXME("(%p)\n", This);
1949 return E_NOTIMPL;
1952 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
1954 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1956 WARN("(%p)->(%x)\n", This, fForce);
1958 /* Doing nothing here should be fine for us. */
1959 return S_OK;
1962 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
1963 IHTMLDOMNode **newTextNode)
1965 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1966 nsIDOMText *nstext;
1967 HTMLDOMNode *node;
1968 nsAString text_str;
1969 nsresult nsres;
1970 HRESULT hres;
1972 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
1974 if(!This->doc_node->nsdoc) {
1975 WARN("NULL nsdoc\n");
1976 return E_UNEXPECTED;
1979 nsAString_InitDepend(&text_str, text);
1980 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
1981 nsAString_Finish(&text_str);
1982 if(NS_FAILED(nsres)) {
1983 ERR("CreateTextNode failed: %08x\n", nsres);
1984 return E_FAIL;
1987 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
1988 nsIDOMText_Release(nstext);
1989 if(FAILED(hres))
1990 return hres;
1992 *newTextNode = &node->IHTMLDOMNode_iface;
1993 return S_OK;
1996 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
1998 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1999 nsIDOMElement *nselem = NULL;
2000 HTMLElement *element;
2001 nsresult nsres;
2002 HRESULT hres;
2004 TRACE("(%p)->(%p)\n", This, p);
2006 if(This->window->readystate == READYSTATE_UNINITIALIZED) {
2007 *p = NULL;
2008 return S_OK;
2011 if(!This->doc_node->nsdoc) {
2012 WARN("NULL nsdoc\n");
2013 return E_UNEXPECTED;
2016 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
2017 if(NS_FAILED(nsres)) {
2018 ERR("GetDocumentElement failed: %08x\n", nsres);
2019 return E_FAIL;
2022 if(!nselem) {
2023 *p = NULL;
2024 return S_OK;
2027 hres = get_element(nselem, &element);
2028 nsIDOMElement_Release(nselem);
2029 if(FAILED(hres))
2030 return hres;
2032 *p = &element->IHTMLElement_iface;
2033 return hres;
2036 static HRESULT WINAPI HTMLDocument3_get_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2038 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2040 TRACE("(%p)->(%p)\n", This, p);
2042 return elem_unique_id(++This->doc_node->unique_id, p);
2045 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2046 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2048 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2050 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2052 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2055 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2056 IDispatch *pDisp)
2058 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2060 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2062 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2065 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2067 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2068 FIXME("(%p)->()\n", This);
2069 return E_NOTIMPL;
2072 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2074 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2075 FIXME("(%p)->(%p)\n", This, p);
2076 return E_NOTIMPL;
2079 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2081 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2082 FIXME("(%p)->()\n", This);
2083 return E_NOTIMPL;
2086 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2088 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2089 FIXME("(%p)->(%p)\n", This, p);
2090 return E_NOTIMPL;
2093 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2095 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2096 FIXME("(%p)->()\n", This);
2097 return E_NOTIMPL;
2100 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2102 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2103 FIXME("(%p)->(%p)\n", This, p);
2104 return E_NOTIMPL;
2107 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2109 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2110 FIXME("(%p)->()\n", This);
2111 return E_NOTIMPL;
2114 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2116 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2117 FIXME("(%p)->(%p)\n", This, p);
2118 return E_NOTIMPL;
2121 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2123 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2124 FIXME("(%p)->()\n", This);
2125 return E_NOTIMPL;
2128 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2130 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2131 FIXME("(%p)->(%p)\n", This, p);
2132 return E_NOTIMPL;
2135 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2137 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2138 FIXME("(%p)->()\n", This);
2139 return E_NOTIMPL;
2142 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2144 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2145 FIXME("(%p)->(%p)\n", This, p);
2146 return E_NOTIMPL;
2149 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2151 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2152 FIXME("(%p)->()\n", This);
2153 return E_NOTIMPL;
2156 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2158 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2159 FIXME("(%p)->(%p)\n", This, p);
2160 return E_NOTIMPL;
2163 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2165 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2166 nsAString dir_str;
2167 nsresult nsres;
2169 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2171 if(!This->doc_node->nsdoc) {
2172 FIXME("NULL nsdoc\n");
2173 return E_UNEXPECTED;
2176 nsAString_InitDepend(&dir_str, v);
2177 nsres = nsIDOMHTMLDocument_SetDir(This->doc_node->nsdoc, &dir_str);
2178 nsAString_Finish(&dir_str);
2179 if(NS_FAILED(nsres)) {
2180 ERR("SetDir failed: %08x\n", nsres);
2181 return E_FAIL;
2184 return S_OK;
2187 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2189 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2190 nsAString dir_str;
2191 nsresult nsres;
2193 TRACE("(%p)->(%p)\n", This, p);
2195 if(!This->doc_node->nsdoc) {
2196 FIXME("NULL nsdoc\n");
2197 return E_UNEXPECTED;
2200 nsAString_Init(&dir_str, NULL);
2201 nsres = nsIDOMHTMLDocument_GetDir(This->doc_node->nsdoc, &dir_str);
2202 return return_nsstr(nsres, &dir_str, p);
2205 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2207 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2209 TRACE("(%p)->()\n", This);
2211 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2214 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2216 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2218 TRACE("(%p)->(%p)\n", This, p);
2220 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2223 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2225 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2226 FIXME("(%p)->()\n", This);
2227 return E_NOTIMPL;
2230 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2232 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2233 FIXME("(%p)->(%p)\n", This, p);
2234 return E_NOTIMPL;
2237 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2238 IHTMLDocument2 **ppNewDoc)
2240 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2241 nsIDOMDocumentFragment *doc_frag;
2242 HTMLDocumentNode *docnode;
2243 nsresult nsres;
2244 HRESULT hres;
2246 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2248 if(!This->doc_node->nsdoc) {
2249 FIXME("NULL nsdoc\n");
2250 return E_NOTIMPL;
2253 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2254 if(NS_FAILED(nsres)) {
2255 ERR("CreateDocumentFragment failed: %08x\n", nsres);
2256 return E_FAIL;
2259 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2260 nsIDOMDocumentFragment_Release(doc_frag);
2261 if(FAILED(hres))
2262 return hres;
2264 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2265 return S_OK;
2268 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2269 IHTMLDocument2 **p)
2271 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2272 FIXME("(%p)->(%p)\n", This, p);
2273 return E_NOTIMPL;
2276 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2277 VARIANT_BOOL v)
2279 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2280 FIXME("(%p)->(%x)\n", This, v);
2281 return E_NOTIMPL;
2284 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2285 VARIANT_BOOL *p)
2287 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2288 FIXME("(%p)->(%p)\n", This, p);
2289 return E_NOTIMPL;
2292 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2294 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2295 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2296 return E_NOTIMPL;
2299 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2301 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2302 FIXME("(%p)->(%p)\n", This, p);
2303 return E_NOTIMPL;
2306 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2308 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2310 TRACE("(%p)->(%p)\n", This, p);
2312 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2315 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2316 VARIANT_BOOL v)
2318 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2319 FIXME("(%p)->()\n", This);
2320 return E_NOTIMPL;
2323 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2324 VARIANT_BOOL *p)
2326 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2327 FIXME("(%p)->(%p)\n", This, p);
2328 return E_NOTIMPL;
2331 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2333 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2334 FIXME("(%p)->()\n", This);
2335 return E_NOTIMPL;
2338 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2340 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2341 FIXME("(%p)->(%p)\n", This, p);
2342 return E_NOTIMPL;
2345 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2346 IHTMLElementCollection **ppelColl)
2348 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2349 nsIDOMNodeList *node_list;
2350 nsAString selector_str;
2351 WCHAR *selector;
2352 nsresult nsres;
2353 static const WCHAR formatW[] = L"*[id=%s],*[name=%s]";
2355 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2357 if(!This->doc_node || !This->doc_node->nsdoc) {
2358 /* We should probably return an empty collection. */
2359 FIXME("No nsdoc\n");
2360 return E_NOTIMPL;
2363 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2364 if(!selector)
2365 return E_OUTOFMEMORY;
2366 swprintf(selector, 2*SysStringLen(v) + ARRAY_SIZE(formatW), formatW, v, v);
2369 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2370 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2371 * types and search should be case insensitive. Those are currently not supported properly.
2373 nsAString_InitDepend(&selector_str, selector);
2374 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2375 nsAString_Finish(&selector_str);
2376 heap_free(selector);
2377 if(NS_FAILED(nsres)) {
2378 ERR("QuerySelectorAll failed: %08x\n", nsres);
2379 return E_FAIL;
2382 *ppelColl = create_collection_from_nodelist(node_list, This->doc_node->document_mode);
2383 nsIDOMNodeList_Release(node_list);
2384 return S_OK;
2388 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2389 IHTMLElement **pel)
2391 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2392 HTMLElement *elem;
2393 HRESULT hres;
2395 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2397 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2398 if(FAILED(hres) || !elem) {
2399 *pel = NULL;
2400 return hres;
2403 *pel = &elem->IHTMLElement_iface;
2404 return S_OK;
2408 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2409 IHTMLElementCollection **pelColl)
2411 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2412 nsIDOMNodeList *nslist;
2413 nsAString id_str;
2414 nsresult nsres;
2416 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2418 if(This->doc_node->nsdoc) {
2419 nsAString_InitDepend(&id_str, v);
2420 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2421 nsAString_Finish(&id_str);
2422 if(FAILED(nsres)) {
2423 ERR("GetElementByName failed: %08x\n", nsres);
2424 return E_FAIL;
2426 }else {
2427 nsIDOMDocumentFragment *docfrag;
2428 nsAString nsstr;
2430 if(v) {
2431 const WCHAR *ptr;
2432 for(ptr=v; *ptr; ptr++) {
2433 if(!iswalnum(*ptr)) {
2434 FIXME("Unsupported invalid tag %s\n", debugstr_w(v));
2435 return E_NOTIMPL;
2440 nsres = nsIDOMNode_QueryInterface(This->doc_node->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&docfrag);
2441 if(NS_FAILED(nsres)) {
2442 ERR("Could not get nsIDOMDocumentFragment iface: %08x\n", nsres);
2443 return E_UNEXPECTED;
2446 nsAString_InitDepend(&nsstr, v);
2447 nsres = nsIDOMDocumentFragment_QuerySelectorAll(docfrag, &nsstr, &nslist);
2448 nsAString_Finish(&nsstr);
2449 nsIDOMDocumentFragment_Release(docfrag);
2450 if(NS_FAILED(nsres)) {
2451 ERR("QuerySelectorAll failed: %08x\n", nsres);
2452 return E_FAIL;
2457 *pelColl = create_collection_from_nodelist(nslist, This->doc_node->document_mode);
2458 nsIDOMNodeList_Release(nslist);
2460 return S_OK;
2463 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2464 HTMLDocument3_QueryInterface,
2465 HTMLDocument3_AddRef,
2466 HTMLDocument3_Release,
2467 HTMLDocument3_GetTypeInfoCount,
2468 HTMLDocument3_GetTypeInfo,
2469 HTMLDocument3_GetIDsOfNames,
2470 HTMLDocument3_Invoke,
2471 HTMLDocument3_releaseCapture,
2472 HTMLDocument3_recalc,
2473 HTMLDocument3_createTextNode,
2474 HTMLDocument3_get_documentElement,
2475 HTMLDocument3_get_uniqueID,
2476 HTMLDocument3_attachEvent,
2477 HTMLDocument3_detachEvent,
2478 HTMLDocument3_put_onrowsdelete,
2479 HTMLDocument3_get_onrowsdelete,
2480 HTMLDocument3_put_onrowsinserted,
2481 HTMLDocument3_get_onrowsinserted,
2482 HTMLDocument3_put_oncellchange,
2483 HTMLDocument3_get_oncellchange,
2484 HTMLDocument3_put_ondatasetchanged,
2485 HTMLDocument3_get_ondatasetchanged,
2486 HTMLDocument3_put_ondataavailable,
2487 HTMLDocument3_get_ondataavailable,
2488 HTMLDocument3_put_ondatasetcomplete,
2489 HTMLDocument3_get_ondatasetcomplete,
2490 HTMLDocument3_put_onpropertychange,
2491 HTMLDocument3_get_onpropertychange,
2492 HTMLDocument3_put_dir,
2493 HTMLDocument3_get_dir,
2494 HTMLDocument3_put_oncontextmenu,
2495 HTMLDocument3_get_oncontextmenu,
2496 HTMLDocument3_put_onstop,
2497 HTMLDocument3_get_onstop,
2498 HTMLDocument3_createDocumentFragment,
2499 HTMLDocument3_get_parentDocument,
2500 HTMLDocument3_put_enableDownload,
2501 HTMLDocument3_get_enableDownload,
2502 HTMLDocument3_put_baseUrl,
2503 HTMLDocument3_get_baseUrl,
2504 HTMLDocument3_get_childNodes,
2505 HTMLDocument3_put_inheritStyleSheets,
2506 HTMLDocument3_get_inheritStyleSheets,
2507 HTMLDocument3_put_onbeforeeditfocus,
2508 HTMLDocument3_get_onbeforeeditfocus,
2509 HTMLDocument3_getElementsByName,
2510 HTMLDocument3_getElementById,
2511 HTMLDocument3_getElementsByTagName
2514 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2516 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2519 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2520 REFIID riid, void **ppv)
2522 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2523 return htmldoc_query_interface(This, riid, ppv);
2526 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2528 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2529 return htmldoc_addref(This);
2532 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2534 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2535 return htmldoc_release(This);
2538 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2540 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2541 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2544 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2545 LCID lcid, ITypeInfo **ppTInfo)
2547 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2548 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2551 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2552 LPOLESTR *rgszNames, UINT cNames,
2553 LCID lcid, DISPID *rgDispId)
2555 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2556 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2557 rgDispId);
2560 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2561 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2562 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2564 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2565 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2566 pDispParams, pVarResult, pExcepInfo, puArgErr);
2569 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2571 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2572 nsIDOMHTMLElement *nsbody;
2573 nsresult nsres;
2575 TRACE("(%p)->()\n", This);
2577 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2578 if(NS_FAILED(nsres) || !nsbody) {
2579 ERR("GetBody failed: %08x\n", nsres);
2580 return E_FAIL;
2583 nsres = nsIDOMHTMLElement_Focus(nsbody);
2584 nsIDOMHTMLElement_Release(nsbody);
2585 if(NS_FAILED(nsres)) {
2586 ERR("Focus failed: %08x\n", nsres);
2587 return E_FAIL;
2590 return S_OK;
2593 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2595 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2596 cpp_bool has_focus;
2597 nsresult nsres;
2599 TRACE("(%p)->(%p)\n", This, pfFocus);
2601 if(!This->doc_node->nsdoc) {
2602 FIXME("Unimplemented for fragments.\n");
2603 return E_NOTIMPL;
2606 nsres = nsIDOMHTMLDocument_HasFocus(This->doc_node->nsdoc, &has_focus);
2607 assert(nsres == NS_OK);
2609 *pfFocus = variant_bool(has_focus);
2610 return S_OK;
2613 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2615 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2617 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2619 return set_doc_event(This, EVENTID_SELECTIONCHANGE, &v);
2622 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2624 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2626 TRACE("(%p)->(%p)\n", This, p);
2628 return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
2631 static HRESULT WINAPI HTMLDocument4_get_namespaces(IHTMLDocument4 *iface, IDispatch **p)
2633 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2635 TRACE("(%p)->(%p)\n", This, p);
2637 if(!This->doc_node->namespaces) {
2638 HRESULT hres;
2640 hres = create_namespace_collection(&This->doc_node->namespaces);
2641 if(FAILED(hres))
2642 return hres;
2645 IHTMLNamespaceCollection_AddRef(This->doc_node->namespaces);
2646 *p = (IDispatch*)This->doc_node->namespaces;
2647 return S_OK;
2650 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2651 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2653 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2654 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2655 return E_NOTIMPL;
2658 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2660 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2661 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2662 return E_NOTIMPL;
2665 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2667 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2668 FIXME("(%p)->(%p)\n", This, p);
2669 return E_NOTIMPL;
2672 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2673 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2675 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2677 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2679 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2680 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2681 return E_NOTIMPL;
2684 return create_event_obj(ppEventObj);
2687 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2688 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2690 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2692 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2694 return fire_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2697 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2698 IHTMLRenderStyle **ppIHTMLRenderStyle)
2700 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2701 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2702 return E_NOTIMPL;
2705 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2707 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2708 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2709 return E_NOTIMPL;
2712 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2714 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2715 FIXME("(%p)->(%p)\n", This, p);
2716 return E_NOTIMPL;
2719 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2721 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2722 FIXME("(%p)->(%p)\n", This, p);
2723 return E_NOTIMPL;
2726 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2727 HTMLDocument4_QueryInterface,
2728 HTMLDocument4_AddRef,
2729 HTMLDocument4_Release,
2730 HTMLDocument4_GetTypeInfoCount,
2731 HTMLDocument4_GetTypeInfo,
2732 HTMLDocument4_GetIDsOfNames,
2733 HTMLDocument4_Invoke,
2734 HTMLDocument4_focus,
2735 HTMLDocument4_hasFocus,
2736 HTMLDocument4_put_onselectionchange,
2737 HTMLDocument4_get_onselectionchange,
2738 HTMLDocument4_get_namespaces,
2739 HTMLDocument4_createDocumentFromUrl,
2740 HTMLDocument4_put_media,
2741 HTMLDocument4_get_media,
2742 HTMLDocument4_createEventObject,
2743 HTMLDocument4_fireEvent,
2744 HTMLDocument4_createRenderStyle,
2745 HTMLDocument4_put_oncontrolselect,
2746 HTMLDocument4_get_oncontrolselect,
2747 HTMLDocument4_get_URLEncoded
2750 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2752 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2755 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2756 REFIID riid, void **ppv)
2758 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2759 return htmldoc_query_interface(This, riid, ppv);
2762 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2764 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2765 return htmldoc_addref(This);
2768 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2770 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2771 return htmldoc_release(This);
2774 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2776 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2777 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2780 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2781 LCID lcid, ITypeInfo **ppTInfo)
2783 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2784 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2787 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2788 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2790 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2791 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2792 rgDispId);
2795 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2796 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2797 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2799 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2800 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2801 pDispParams, pVarResult, pExcepInfo, puArgErr);
2804 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2806 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2808 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2810 return set_doc_event(This, EVENTID_MOUSEWHEEL, &v);
2813 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2815 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2817 TRACE("(%p)->(%p)\n", This, p);
2819 return get_doc_event(This, EVENTID_MOUSEWHEEL, p);
2822 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2824 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2825 FIXME("(%p)->(%p)\n", This, p);
2826 return E_NOTIMPL;
2829 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2831 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2832 HTMLDocumentNode *doc_node = This->doc_node;
2834 TRACE("(%p)->(%p)\n", This, p);
2836 if(!doc_node->dom_implementation) {
2837 HRESULT hres;
2839 hres = create_dom_implementation(doc_node, &doc_node->dom_implementation);
2840 if(FAILED(hres))
2841 return hres;
2844 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2845 *p = doc_node->dom_implementation;
2846 return S_OK;
2849 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2850 IHTMLDOMAttribute **ppattribute)
2852 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2853 HTMLDOMAttribute *attr;
2854 HRESULT hres;
2856 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2858 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
2859 if(FAILED(hres))
2860 return hres;
2862 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2863 return S_OK;
2866 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2867 IHTMLDOMNode **ppRetNode)
2869 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2870 nsIDOMComment *nscomment;
2871 HTMLElement *elem;
2872 nsAString str;
2873 nsresult nsres;
2874 HRESULT hres;
2876 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2878 if(!This->doc_node->nsdoc) {
2879 WARN("NULL nsdoc\n");
2880 return E_UNEXPECTED;
2883 nsAString_InitDepend(&str, bstrdata);
2884 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2885 nsAString_Finish(&str);
2886 if(NS_FAILED(nsres)) {
2887 ERR("CreateTextNode failed: %08x\n", nsres);
2888 return E_FAIL;
2891 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2892 nsIDOMComment_Release(nscomment);
2893 if(FAILED(hres))
2894 return hres;
2896 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2897 return S_OK;
2900 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2902 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2904 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2906 return set_doc_event(This, EVENTID_FOCUSIN, &v);
2909 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2911 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2913 TRACE("(%p)->(%p)\n", This, p);
2915 return get_doc_event(This, EVENTID_FOCUSIN, p);
2918 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2920 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2922 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2924 return set_doc_event(This, EVENTID_FOCUSOUT, &v);
2927 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2929 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2931 TRACE("(%p)->(%p)\n", This, p);
2933 return get_doc_event(This, EVENTID_FOCUSOUT, p);
2936 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2938 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2939 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2940 return E_NOTIMPL;
2943 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2945 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2946 FIXME("(%p)->(%p)\n", This, p);
2947 return E_NOTIMPL;
2950 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2952 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2953 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2954 return E_NOTIMPL;
2957 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2959 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2960 FIXME("(%p)->(%p)\n", This, p);
2961 return E_NOTIMPL;
2964 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2966 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2967 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2968 return E_NOTIMPL;
2971 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2973 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2974 FIXME("(%p)->(%p)\n", This, p);
2975 return E_NOTIMPL;
2978 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2980 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2981 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2982 return E_NOTIMPL;
2985 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2987 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2988 FIXME("(%p)->(%p)\n", This, p);
2989 return E_NOTIMPL;
2992 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2994 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2996 TRACE("(%p)->(%p)\n", This, p);
2998 *p = SysAllocString(This->doc_node->document_mode <= COMPAT_MODE_IE5 ? L"BackCompat" : L"CSS1Compat");
2999 return *p ? S_OK : E_OUTOFMEMORY;
3002 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
3003 HTMLDocument5_QueryInterface,
3004 HTMLDocument5_AddRef,
3005 HTMLDocument5_Release,
3006 HTMLDocument5_GetTypeInfoCount,
3007 HTMLDocument5_GetTypeInfo,
3008 HTMLDocument5_GetIDsOfNames,
3009 HTMLDocument5_Invoke,
3010 HTMLDocument5_put_onmousewheel,
3011 HTMLDocument5_get_onmousewheel,
3012 HTMLDocument5_get_doctype,
3013 HTMLDocument5_get_implementation,
3014 HTMLDocument5_createAttribute,
3015 HTMLDocument5_createComment,
3016 HTMLDocument5_put_onfocusin,
3017 HTMLDocument5_get_onfocusin,
3018 HTMLDocument5_put_onfocusout,
3019 HTMLDocument5_get_onfocusout,
3020 HTMLDocument5_put_onactivate,
3021 HTMLDocument5_get_onactivate,
3022 HTMLDocument5_put_ondeactivate,
3023 HTMLDocument5_get_ondeactivate,
3024 HTMLDocument5_put_onbeforeactivate,
3025 HTMLDocument5_get_onbeforeactivate,
3026 HTMLDocument5_put_onbeforedeactivate,
3027 HTMLDocument5_get_onbeforedeactivate,
3028 HTMLDocument5_get_compatMode
3031 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
3033 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
3036 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
3037 REFIID riid, void **ppv)
3039 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3040 return htmldoc_query_interface(This, riid, ppv);
3043 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
3045 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3046 return htmldoc_addref(This);
3049 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
3051 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3052 return htmldoc_release(This);
3055 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
3057 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3058 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3061 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
3062 LCID lcid, ITypeInfo **ppTInfo)
3064 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3065 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3068 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
3069 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3071 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3072 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3073 rgDispId);
3076 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
3077 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3078 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3080 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3081 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3082 pDispParams, pVarResult, pExcepInfo, puArgErr);
3085 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
3086 IHTMLDocumentCompatibleInfoCollection **p)
3088 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3089 FIXME("(%p)->(%p)\n", This, p);
3090 return E_NOTIMPL;
3093 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARIANT *p)
3095 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3097 TRACE("(%p)->(%p)\n", This, p);
3099 if(!This->doc_node) {
3100 FIXME("NULL doc_node\n");
3101 return E_UNEXPECTED;
3104 V_VT(p) = VT_R4;
3105 V_R4(p) = compat_mode_info[This->doc_node->document_mode].document_mode;
3106 return S_OK;
3109 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
3110 VARIANT *p)
3112 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3113 FIXME("(%p)->(%p)\n", This, p);
3114 return E_NOTIMPL;
3117 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
3119 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3120 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3121 return E_NOTIMPL;
3124 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
3125 VARIANT *p)
3127 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3128 FIXME("(%p)->(%p)\n", This, p);
3129 return E_NOTIMPL;
3132 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3134 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3135 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3136 return E_NOTIMPL;
3139 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3140 BSTR bstrId, IHTMLElement2 **p)
3142 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3143 nsIDOMElement *nselem;
3144 HTMLElement *elem;
3145 nsAString nsstr;
3146 nsresult nsres;
3147 HRESULT hres;
3149 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3152 * Unlike IHTMLDocument3 implementation, this is standard compliant and does
3153 * not search for name attributes, so we may simply let Gecko do the right thing.
3156 if(!This->doc_node->nsdoc) {
3157 FIXME("Not a document\n");
3158 return E_FAIL;
3161 nsAString_InitDepend(&nsstr, bstrId);
3162 nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &nsstr, &nselem);
3163 nsAString_Finish(&nsstr);
3164 if(NS_FAILED(nsres)) {
3165 ERR("GetElementById failed: %08x\n", nsres);
3166 return E_FAIL;
3169 if(!nselem) {
3170 *p = NULL;
3171 return S_OK;
3174 hres = get_element(nselem, &elem);
3175 nsIDOMElement_Release(nselem);
3176 if(FAILED(hres))
3177 return hres;
3179 *p = &elem->IHTMLElement2_iface;
3180 return S_OK;
3183 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3185 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3186 FIXME("(%p)->()\n", This);
3187 return E_NOTIMPL;
3190 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3191 HTMLDocument6_QueryInterface,
3192 HTMLDocument6_AddRef,
3193 HTMLDocument6_Release,
3194 HTMLDocument6_GetTypeInfoCount,
3195 HTMLDocument6_GetTypeInfo,
3196 HTMLDocument6_GetIDsOfNames,
3197 HTMLDocument6_Invoke,
3198 HTMLDocument6_get_compatible,
3199 HTMLDocument6_get_documentMode,
3200 HTMLDocument6_put_onstorage,
3201 HTMLDocument6_get_onstorage,
3202 HTMLDocument6_put_onstoragecommit,
3203 HTMLDocument6_get_onstoragecommit,
3204 HTMLDocument6_getElementById,
3205 HTMLDocument6_updateSettings
3208 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3210 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3213 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3215 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3216 return htmldoc_query_interface(This, riid, ppv);
3219 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3221 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3222 return htmldoc_addref(This);
3225 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3227 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3228 return htmldoc_release(This);
3231 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3233 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3234 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3237 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3238 LCID lcid, ITypeInfo **ppTInfo)
3240 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3241 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3244 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3245 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3247 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3248 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3249 rgDispId);
3252 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3253 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3254 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3256 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3257 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3258 pDispParams, pVarResult, pExcepInfo, puArgErr);
3261 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3263 HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface)->doc_node;
3265 TRACE("(%p)->(%p)\n", This, p);
3267 if(This->window && This->window->base.outer_window) {
3268 *p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
3269 IHTMLWindow2_AddRef(*p);
3270 }else {
3271 *p = NULL;
3273 return S_OK;
3276 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3278 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3279 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3280 return E_NOTIMPL;
3283 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3285 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3286 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3287 return E_NOTIMPL;
3290 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3291 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3293 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3294 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3295 return E_NOTIMPL;
3298 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3300 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3301 nsIDOMElement *dom_element;
3302 HTMLElement *element;
3303 nsAString ns, tag;
3304 nsresult nsres;
3305 HRESULT hres;
3307 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3309 if(!This->doc_node->nsdoc) {
3310 FIXME("NULL nsdoc\n");
3311 return E_FAIL;
3314 if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
3315 FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
3317 nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
3318 nsAString_InitDepend(&tag, bstrTag);
3319 nsres = nsIDOMHTMLDocument_CreateElementNS(This->doc_node->nsdoc, &ns, &tag, &dom_element);
3320 nsAString_Finish(&ns);
3321 nsAString_Finish(&tag);
3322 if(NS_FAILED(nsres)) {
3323 WARN("CreateElementNS failed: %08x\n", nsres);
3324 return map_nsresult(nsres);
3327 hres = HTMLElement_Create(This->doc_node, (nsIDOMNode*)dom_element, FALSE, &element);
3328 nsIDOMElement_Release(dom_element);
3329 if(FAILED(hres))
3330 return hres;
3332 *newElem = &element->IHTMLElement_iface;
3333 return S_OK;
3336 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3337 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3339 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3340 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3341 return E_NOTIMPL;
3344 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3346 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3347 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3348 return E_NOTIMPL;
3351 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3353 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3355 TRACE("(%p)->(%p)\n", This, p);
3357 return get_doc_event(This, EVENTID_MSTHUMBNAILCLICK, p);
3360 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3362 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3363 nsAString charset_str;
3364 nsresult nsres;
3366 TRACE("(%p)->(%p)\n", This, p);
3368 if(!This->doc_node->nsdoc) {
3369 FIXME("NULL nsdoc\n");
3370 return E_FAIL;
3373 nsAString_Init(&charset_str, NULL);
3374 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
3375 return return_nsstr(nsres, &charset_str, p);
3378 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3380 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3382 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrTag), newElem);
3384 return IHTMLDocument2_createElement(&This->IHTMLDocument2_iface, bstrTag, newElem);
3387 static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3389 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3391 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrAttrName), ppAttribute);
3393 return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
3396 static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
3398 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3399 nsIDOMNodeList *nslist;
3400 nsAString nsstr;
3401 nsresult nsres;
3403 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
3405 if(!This->doc_node->nsdoc) {
3406 FIXME("NULL nsdoc not supported\n");
3407 return E_NOTIMPL;
3410 nsAString_InitDepend(&nsstr, v);
3411 nsres = nsIDOMHTMLDocument_GetElementsByClassName(This->doc_node->nsdoc, &nsstr, &nslist);
3412 nsAString_Finish(&nsstr);
3413 if(FAILED(nsres)) {
3414 ERR("GetElementByClassName failed: %08x\n", nsres);
3415 return E_FAIL;
3419 *pel = create_collection_from_nodelist(nslist, This->doc_node->document_mode);
3420 nsIDOMNodeList_Release(nslist);
3421 return S_OK;
3424 static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
3425 BSTR data, IDOMProcessingInstruction **newProcessingInstruction)
3427 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3428 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), newProcessingInstruction);
3429 return E_NOTIMPL;
3432 static HRESULT WINAPI HTMLDocument7_adoptNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource, IHTMLDOMNode3 **ppNodeDest)
3434 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3435 FIXME("(%p)->(%p %p)\n", This, pNodeSource, ppNodeDest);
3436 return E_NOTIMPL;
3439 static HRESULT WINAPI HTMLDocument7_put_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT v)
3441 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3442 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3443 return E_NOTIMPL;
3446 static HRESULT WINAPI HTMLDocument7_get_onmssitemodejumplistitemremoved(IHTMLDocument7 *iface, VARIANT *p)
3448 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3449 FIXME("(%p)->(%p)\n", This, p);
3450 return E_NOTIMPL;
3453 static HRESULT WINAPI HTMLDocument7_get_all(IHTMLDocument7 *iface, IHTMLElementCollection **p)
3455 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3457 TRACE("(%p)->(%p)\n", This, p);
3459 return IHTMLDocument2_get_all(&This->IHTMLDocument2_iface, p);
3462 static HRESULT WINAPI HTMLDocument7_get_inputEncoding(IHTMLDocument7 *iface, BSTR *p)
3464 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3465 FIXME("(%p)->(%p)\n", This, p);
3466 return E_NOTIMPL;
3469 static HRESULT WINAPI HTMLDocument7_get_xmlEncoding(IHTMLDocument7 *iface, BSTR *p)
3471 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3472 FIXME("(%p)->(%p)\n", This, p);
3473 return E_NOTIMPL;
3476 static HRESULT WINAPI HTMLDocument7_put_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL v)
3478 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3479 FIXME("(%p)->(%x)\n", This, v);
3480 return E_NOTIMPL;
3483 static HRESULT WINAPI HTMLDocument7_get_xmlStandalone(IHTMLDocument7 *iface, VARIANT_BOOL *p)
3485 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3486 FIXME("(%p)->(%p)\n", This, p);
3487 return E_NOTIMPL;
3490 static HRESULT WINAPI HTMLDocument7_put_xmlVersion(IHTMLDocument7 *iface, BSTR v)
3492 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3493 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3494 return E_NOTIMPL;
3497 static HRESULT WINAPI HTMLDocument7_get_xmlVersion(IHTMLDocument7 *iface, BSTR *p)
3499 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3500 FIXME("(%p)->(%p)\n", This, p);
3501 return E_NOTIMPL;
3504 static HRESULT WINAPI HTMLDocument7_hasAttributes(IHTMLDocument7 *iface, VARIANT_BOOL *pfHasAttributes)
3506 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3507 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
3508 return E_NOTIMPL;
3511 static HRESULT WINAPI HTMLDocument7_put_onabort(IHTMLDocument7 *iface, VARIANT v)
3513 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3515 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3517 return set_doc_event(This, EVENTID_ABORT, &v);
3520 static HRESULT WINAPI HTMLDocument7_get_onabort(IHTMLDocument7 *iface, VARIANT *p)
3522 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3524 TRACE("(%p)->(%p)\n", This, p);
3526 return get_doc_event(This, EVENTID_ABORT, p);
3529 static HRESULT WINAPI HTMLDocument7_put_onblur(IHTMLDocument7 *iface, VARIANT v)
3531 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3533 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3535 return set_doc_event(This, EVENTID_BLUR, &v);
3538 static HRESULT WINAPI HTMLDocument7_get_onblur(IHTMLDocument7 *iface, VARIANT *p)
3540 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3542 TRACE("(%p)->(%p)\n", This, p);
3544 return get_doc_event(This, EVENTID_BLUR, p);
3547 static HRESULT WINAPI HTMLDocument7_put_oncanplay(IHTMLDocument7 *iface, VARIANT v)
3549 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3550 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3551 return E_NOTIMPL;
3554 static HRESULT WINAPI HTMLDocument7_get_oncanplay(IHTMLDocument7 *iface, VARIANT *p)
3556 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3557 FIXME("(%p)->(%p)\n", This, p);
3558 return E_NOTIMPL;
3561 static HRESULT WINAPI HTMLDocument7_put_oncanplaythrough(IHTMLDocument7 *iface, VARIANT v)
3563 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3564 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3565 return E_NOTIMPL;
3568 static HRESULT WINAPI HTMLDocument7_get_oncanplaythrough(IHTMLDocument7 *iface, VARIANT *p)
3570 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3571 FIXME("(%p)->(%p)\n", This, p);
3572 return E_NOTIMPL;
3575 static HRESULT WINAPI HTMLDocument7_put_onchange(IHTMLDocument7 *iface, VARIANT v)
3577 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3579 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3581 return set_doc_event(This, EVENTID_CHANGE, &v);
3584 static HRESULT WINAPI HTMLDocument7_get_onchange(IHTMLDocument7 *iface, VARIANT *p)
3586 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3588 TRACE("(%p)->(%p)\n", This, p);
3590 return get_doc_event(This, EVENTID_CHANGE, p);
3593 static HRESULT WINAPI HTMLDocument7_put_ondrag(IHTMLDocument7 *iface, VARIANT v)
3595 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3597 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3599 return set_doc_event(This, EVENTID_DRAG, &v);
3602 static HRESULT WINAPI HTMLDocument7_get_ondrag(IHTMLDocument7 *iface, VARIANT *p)
3604 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3606 TRACE("(%p)->(%p)\n", This, p);
3608 return get_doc_event(This, EVENTID_DRAG, p);
3611 static HRESULT WINAPI HTMLDocument7_put_ondragend(IHTMLDocument7 *iface, VARIANT v)
3613 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3614 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3615 return E_NOTIMPL;
3618 static HRESULT WINAPI HTMLDocument7_get_ondragend(IHTMLDocument7 *iface, VARIANT *p)
3620 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3621 FIXME("(%p)->(%p)\n", This, p);
3622 return E_NOTIMPL;
3625 static HRESULT WINAPI HTMLDocument7_put_ondragenter(IHTMLDocument7 *iface, VARIANT v)
3627 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3628 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3629 return E_NOTIMPL;
3632 static HRESULT WINAPI HTMLDocument7_get_ondragenter(IHTMLDocument7 *iface, VARIANT *p)
3634 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3635 FIXME("(%p)->(%p)\n", This, p);
3636 return E_NOTIMPL;
3639 static HRESULT WINAPI HTMLDocument7_put_ondragleave(IHTMLDocument7 *iface, VARIANT v)
3641 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3642 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3643 return E_NOTIMPL;
3646 static HRESULT WINAPI HTMLDocument7_get_ondragleave(IHTMLDocument7 *iface, VARIANT *p)
3648 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3649 FIXME("(%p)->(%p)\n", This, p);
3650 return E_NOTIMPL;
3653 static HRESULT WINAPI HTMLDocument7_put_ondragover(IHTMLDocument7 *iface, VARIANT v)
3655 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3656 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3657 return E_NOTIMPL;
3660 static HRESULT WINAPI HTMLDocument7_get_ondragover(IHTMLDocument7 *iface, VARIANT *p)
3662 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3663 FIXME("(%p)->(%p)\n", This, p);
3664 return E_NOTIMPL;
3667 static HRESULT WINAPI HTMLDocument7_put_ondrop(IHTMLDocument7 *iface, VARIANT v)
3669 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3670 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3671 return E_NOTIMPL;
3674 static HRESULT WINAPI HTMLDocument7_get_ondrop(IHTMLDocument7 *iface, VARIANT *p)
3676 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3677 FIXME("(%p)->(%p)\n", This, p);
3678 return E_NOTIMPL;
3681 static HRESULT WINAPI HTMLDocument7_put_ondurationchange(IHTMLDocument7 *iface, VARIANT v)
3683 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3684 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3685 return E_NOTIMPL;
3688 static HRESULT WINAPI HTMLDocument7_get_ondurationchange(IHTMLDocument7 *iface, VARIANT *p)
3690 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3691 FIXME("(%p)->(%p)\n", This, p);
3692 return E_NOTIMPL;
3695 static HRESULT WINAPI HTMLDocument7_put_onemptied(IHTMLDocument7 *iface, VARIANT v)
3697 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3698 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3699 return E_NOTIMPL;
3702 static HRESULT WINAPI HTMLDocument7_get_onemptied(IHTMLDocument7 *iface, VARIANT *p)
3704 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3705 FIXME("(%p)->(%p)\n", This, p);
3706 return E_NOTIMPL;
3709 static HRESULT WINAPI HTMLDocument7_put_onended(IHTMLDocument7 *iface, VARIANT v)
3711 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3712 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3713 return E_NOTIMPL;
3716 static HRESULT WINAPI HTMLDocument7_get_onended(IHTMLDocument7 *iface, VARIANT *p)
3718 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3719 FIXME("(%p)->(%p)\n", This, p);
3720 return E_NOTIMPL;
3723 static HRESULT WINAPI HTMLDocument7_put_onerror(IHTMLDocument7 *iface, VARIANT v)
3725 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3727 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3729 return set_doc_event(This, EVENTID_ERROR, &v);
3732 static HRESULT WINAPI HTMLDocument7_get_onerror(IHTMLDocument7 *iface, VARIANT *p)
3734 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3736 TRACE("(%p)->(%p)\n", This, p);
3738 return get_doc_event(This, EVENTID_ERROR, p);
3741 static HRESULT WINAPI HTMLDocument7_put_onfocus(IHTMLDocument7 *iface, VARIANT v)
3743 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3745 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3747 return set_doc_event(This, EVENTID_FOCUS, &v);
3750 static HRESULT WINAPI HTMLDocument7_get_onfocus(IHTMLDocument7 *iface, VARIANT *p)
3752 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3754 TRACE("(%p)->(%p)\n", This, p);
3756 return get_doc_event(This, EVENTID_FOCUS, p);
3759 static HRESULT WINAPI HTMLDocument7_put_oninput(IHTMLDocument7 *iface, VARIANT v)
3761 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3763 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3765 return set_doc_event(This, EVENTID_INPUT, &v);
3768 static HRESULT WINAPI HTMLDocument7_get_oninput(IHTMLDocument7 *iface, VARIANT *p)
3770 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3772 TRACE("(%p)->(%p)\n", This, p);
3774 return get_doc_event(This, EVENTID_INPUT, p);
3777 static HRESULT WINAPI HTMLDocument7_put_onload(IHTMLDocument7 *iface, VARIANT v)
3779 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3781 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3783 return set_doc_event(This, EVENTID_LOAD, &v);
3786 static HRESULT WINAPI HTMLDocument7_get_onload(IHTMLDocument7 *iface, VARIANT *p)
3788 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3790 TRACE("(%p)->(%p)\n", This, p);
3792 return get_doc_event(This, EVENTID_LOAD, p);
3795 static HRESULT WINAPI HTMLDocument7_put_onloadeddata(IHTMLDocument7 *iface, VARIANT v)
3797 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3798 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3799 return E_NOTIMPL;
3802 static HRESULT WINAPI HTMLDocument7_get_onloadeddata(IHTMLDocument7 *iface, VARIANT *p)
3804 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3805 FIXME("(%p)->(%p)\n", This, p);
3806 return E_NOTIMPL;
3809 static HRESULT WINAPI HTMLDocument7_put_onloadedmetadata(IHTMLDocument7 *iface, VARIANT v)
3811 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3812 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3813 return E_NOTIMPL;
3816 static HRESULT WINAPI HTMLDocument7_get_onloadedmetadata(IHTMLDocument7 *iface, VARIANT *p)
3818 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3819 FIXME("(%p)->(%p)\n", This, p);
3820 return E_NOTIMPL;
3823 static HRESULT WINAPI HTMLDocument7_put_onloadstart(IHTMLDocument7 *iface, VARIANT v)
3825 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3826 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3827 return E_NOTIMPL;
3830 static HRESULT WINAPI HTMLDocument7_get_onloadstart(IHTMLDocument7 *iface, VARIANT *p)
3832 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3833 FIXME("(%p)->(%p)\n", This, p);
3834 return E_NOTIMPL;
3837 static HRESULT WINAPI HTMLDocument7_put_onpause(IHTMLDocument7 *iface, VARIANT v)
3839 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3840 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3841 return E_NOTIMPL;
3844 static HRESULT WINAPI HTMLDocument7_get_onpause(IHTMLDocument7 *iface, VARIANT *p)
3846 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3847 FIXME("(%p)->(%p)\n", This, p);
3848 return E_NOTIMPL;
3851 static HRESULT WINAPI HTMLDocument7_put_onplay(IHTMLDocument7 *iface, VARIANT v)
3853 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3854 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3855 return E_NOTIMPL;
3858 static HRESULT WINAPI HTMLDocument7_get_onplay(IHTMLDocument7 *iface, VARIANT *p)
3860 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3861 FIXME("(%p)->(%p)\n", This, p);
3862 return E_NOTIMPL;
3865 static HRESULT WINAPI HTMLDocument7_put_onplaying(IHTMLDocument7 *iface, VARIANT v)
3867 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3868 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3869 return E_NOTIMPL;
3872 static HRESULT WINAPI HTMLDocument7_get_onplaying(IHTMLDocument7 *iface, VARIANT *p)
3874 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3875 FIXME("(%p)->(%p)\n", This, p);
3876 return E_NOTIMPL;
3879 static HRESULT WINAPI HTMLDocument7_put_onprogress(IHTMLDocument7 *iface, VARIANT v)
3881 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3882 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3883 return E_NOTIMPL;
3886 static HRESULT WINAPI HTMLDocument7_get_onprogress(IHTMLDocument7 *iface, VARIANT *p)
3888 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3889 FIXME("(%p)->(%p)\n", This, p);
3890 return E_NOTIMPL;
3893 static HRESULT WINAPI HTMLDocument7_put_onratechange(IHTMLDocument7 *iface, VARIANT v)
3895 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3896 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3897 return E_NOTIMPL;
3900 static HRESULT WINAPI HTMLDocument7_get_onratechange(IHTMLDocument7 *iface, VARIANT *p)
3902 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3903 FIXME("(%p)->(%p)\n", This, p);
3904 return E_NOTIMPL;
3907 static HRESULT WINAPI HTMLDocument7_put_onreset(IHTMLDocument7 *iface, VARIANT v)
3909 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3910 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3911 return E_NOTIMPL;
3914 static HRESULT WINAPI HTMLDocument7_get_onreset(IHTMLDocument7 *iface, VARIANT *p)
3916 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3917 FIXME("(%p)->(%p)\n", This, p);
3918 return E_NOTIMPL;
3921 static HRESULT WINAPI HTMLDocument7_put_onscroll(IHTMLDocument7 *iface, VARIANT v)
3923 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3925 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3927 return set_doc_event(This, EVENTID_SCROLL, &v);
3930 static HRESULT WINAPI HTMLDocument7_get_onscroll(IHTMLDocument7 *iface, VARIANT *p)
3932 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3934 TRACE("(%p)->(%p)\n", This, p);
3936 return get_doc_event(This, EVENTID_SCROLL, p);
3939 static HRESULT WINAPI HTMLDocument7_put_onseekend(IHTMLDocument7 *iface, VARIANT v)
3941 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3942 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3943 return E_NOTIMPL;
3946 static HRESULT WINAPI HTMLDocument7_get_onseekend(IHTMLDocument7 *iface, VARIANT *p)
3948 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3949 FIXME("(%p)->(%p)\n", This, p);
3950 return E_NOTIMPL;
3953 static HRESULT WINAPI HTMLDocument7_put_onseeking(IHTMLDocument7 *iface, VARIANT v)
3955 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3956 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3957 return E_NOTIMPL;
3960 static HRESULT WINAPI HTMLDocument7_get_onseeking(IHTMLDocument7 *iface, VARIANT *p)
3962 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3963 FIXME("(%p)->(%p)\n", This, p);
3964 return E_NOTIMPL;
3967 static HRESULT WINAPI HTMLDocument7_put_onselect(IHTMLDocument7 *iface, VARIANT v)
3969 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3970 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3971 return E_NOTIMPL;
3974 static HRESULT WINAPI HTMLDocument7_get_onselect(IHTMLDocument7 *iface, VARIANT *p)
3976 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3977 FIXME("(%p)->(%p)\n", This, p);
3978 return E_NOTIMPL;
3981 static HRESULT WINAPI HTMLDocument7_put_onstalled(IHTMLDocument7 *iface, VARIANT v)
3983 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3984 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3985 return E_NOTIMPL;
3988 static HRESULT WINAPI HTMLDocument7_get_onstalled(IHTMLDocument7 *iface, VARIANT *p)
3990 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3991 FIXME("(%p)->(%p)\n", This, p);
3992 return E_NOTIMPL;
3995 static HRESULT WINAPI HTMLDocument7_put_onsubmit(IHTMLDocument7 *iface, VARIANT v)
3997 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3999 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4001 return set_doc_event(This, EVENTID_SUBMIT, &v);
4004 static HRESULT WINAPI HTMLDocument7_get_onsubmit(IHTMLDocument7 *iface, VARIANT *p)
4006 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4008 TRACE("(%p)->(%p)\n", This, p);
4010 return get_doc_event(This, EVENTID_SUBMIT, p);
4013 static HRESULT WINAPI HTMLDocument7_put_onsuspend(IHTMLDocument7 *iface, VARIANT v)
4015 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4016 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4017 return E_NOTIMPL;
4020 static HRESULT WINAPI HTMLDocument7_get_onsuspend(IHTMLDocument7 *iface, VARIANT *p)
4022 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4023 FIXME("(%p)->(%p)\n", This, p);
4024 return E_NOTIMPL;
4027 static HRESULT WINAPI HTMLDocument7_put_ontimeupdate(IHTMLDocument7 *iface, VARIANT v)
4029 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4030 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4031 return E_NOTIMPL;
4034 static HRESULT WINAPI HTMLDocument7_get_ontimeupdate(IHTMLDocument7 *iface, VARIANT *p)
4036 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4037 FIXME("(%p)->(%p)\n", This, p);
4038 return E_NOTIMPL;
4041 static HRESULT WINAPI HTMLDocument7_put_onvolumechange(IHTMLDocument7 *iface, VARIANT v)
4043 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4044 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4045 return E_NOTIMPL;
4048 static HRESULT WINAPI HTMLDocument7_get_onvolumechange(IHTMLDocument7 *iface, VARIANT *p)
4050 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4051 FIXME("(%p)->(%p)\n", This, p);
4052 return E_NOTIMPL;
4055 static HRESULT WINAPI HTMLDocument7_put_onwaiting(IHTMLDocument7 *iface, VARIANT v)
4057 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4058 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4059 return E_NOTIMPL;
4062 static HRESULT WINAPI HTMLDocument7_get_onwaiting(IHTMLDocument7 *iface, VARIANT *p)
4064 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4065 FIXME("(%p)->(%p)\n", This, p);
4066 return E_NOTIMPL;
4069 static HRESULT WINAPI HTMLDocument7_normalize(IHTMLDocument7 *iface)
4071 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4072 FIXME("(%p)\n", This);
4073 return E_NOTIMPL;
4076 static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNode *pNodeSource,
4077 VARIANT_BOOL fDeep, IHTMLDOMNode3 **ppNodeDest)
4079 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4080 FIXME("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
4081 return E_NOTIMPL;
4084 static HRESULT WINAPI HTMLDocument7_get_parentWindow(IHTMLDocument7 *iface, IHTMLWindow2 **p)
4086 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4088 TRACE("(%p)->(%p)\n", This, p);
4090 return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
4093 static HRESULT WINAPI HTMLDocument7_put_body(IHTMLDocument7 *iface, IHTMLElement *v)
4095 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4096 FIXME("(%p)->(%p)\n", This, v);
4097 return E_NOTIMPL;
4100 static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement **p)
4102 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4104 TRACE("(%p)->(%p)\n", This, p);
4106 return IHTMLDocument2_get_body(&This->IHTMLDocument2_iface, p);
4109 static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p)
4111 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
4112 nsIDOMHTMLHeadElement *nshead;
4113 nsIDOMElement *nselem;
4114 HTMLElement *elem;
4115 nsresult nsres;
4116 HRESULT hres;
4118 TRACE("(%p)->(%p)\n", This, p);
4120 if(!This->doc_node->nsdoc) {
4121 FIXME("No document\n");
4122 return E_FAIL;
4125 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &nshead);
4126 assert(nsres == NS_OK);
4128 if(!nshead) {
4129 *p = NULL;
4130 return S_OK;
4133 nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem);
4134 nsIDOMHTMLHeadElement_Release(nshead);
4135 assert(nsres == NS_OK);
4137 hres = get_element(nselem, &elem);
4138 nsIDOMElement_Release(nselem);
4139 if(FAILED(hres))
4140 return hres;
4142 *p = &elem->IHTMLElement_iface;
4143 return S_OK;
4146 static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
4147 HTMLDocument7_QueryInterface,
4148 HTMLDocument7_AddRef,
4149 HTMLDocument7_Release,
4150 HTMLDocument7_GetTypeInfoCount,
4151 HTMLDocument7_GetTypeInfo,
4152 HTMLDocument7_GetIDsOfNames,
4153 HTMLDocument7_Invoke,
4154 HTMLDocument7_get_defaultView,
4155 HTMLDocument7_createCDATASection,
4156 HTMLDocument7_getSelection,
4157 HTMLDocument7_getElementsByTagNameNS,
4158 HTMLDocument7_createElementNS,
4159 HTMLDocument7_createAttributeNS,
4160 HTMLDocument7_put_onmsthumbnailclick,
4161 HTMLDocument7_get_onmsthumbnailclick,
4162 HTMLDocument7_get_characterSet,
4163 HTMLDocument7_createElement,
4164 HTMLDocument7_createAttribute,
4165 HTMLDocument7_getElementsByClassName,
4166 HTMLDocument7_createProcessingInstruction,
4167 HTMLDocument7_adoptNode,
4168 HTMLDocument7_put_onmssitemodejumplistitemremoved,
4169 HTMLDocument7_get_onmssitemodejumplistitemremoved,
4170 HTMLDocument7_get_all,
4171 HTMLDocument7_get_inputEncoding,
4172 HTMLDocument7_get_xmlEncoding,
4173 HTMLDocument7_put_xmlStandalone,
4174 HTMLDocument7_get_xmlStandalone,
4175 HTMLDocument7_put_xmlVersion,
4176 HTMLDocument7_get_xmlVersion,
4177 HTMLDocument7_hasAttributes,
4178 HTMLDocument7_put_onabort,
4179 HTMLDocument7_get_onabort,
4180 HTMLDocument7_put_onblur,
4181 HTMLDocument7_get_onblur,
4182 HTMLDocument7_put_oncanplay,
4183 HTMLDocument7_get_oncanplay,
4184 HTMLDocument7_put_oncanplaythrough,
4185 HTMLDocument7_get_oncanplaythrough,
4186 HTMLDocument7_put_onchange,
4187 HTMLDocument7_get_onchange,
4188 HTMLDocument7_put_ondrag,
4189 HTMLDocument7_get_ondrag,
4190 HTMLDocument7_put_ondragend,
4191 HTMLDocument7_get_ondragend,
4192 HTMLDocument7_put_ondragenter,
4193 HTMLDocument7_get_ondragenter,
4194 HTMLDocument7_put_ondragleave,
4195 HTMLDocument7_get_ondragleave,
4196 HTMLDocument7_put_ondragover,
4197 HTMLDocument7_get_ondragover,
4198 HTMLDocument7_put_ondrop,
4199 HTMLDocument7_get_ondrop,
4200 HTMLDocument7_put_ondurationchange,
4201 HTMLDocument7_get_ondurationchange,
4202 HTMLDocument7_put_onemptied,
4203 HTMLDocument7_get_onemptied,
4204 HTMLDocument7_put_onended,
4205 HTMLDocument7_get_onended,
4206 HTMLDocument7_put_onerror,
4207 HTMLDocument7_get_onerror,
4208 HTMLDocument7_put_onfocus,
4209 HTMLDocument7_get_onfocus,
4210 HTMLDocument7_put_oninput,
4211 HTMLDocument7_get_oninput,
4212 HTMLDocument7_put_onload,
4213 HTMLDocument7_get_onload,
4214 HTMLDocument7_put_onloadeddata,
4215 HTMLDocument7_get_onloadeddata,
4216 HTMLDocument7_put_onloadedmetadata,
4217 HTMLDocument7_get_onloadedmetadata,
4218 HTMLDocument7_put_onloadstart,
4219 HTMLDocument7_get_onloadstart,
4220 HTMLDocument7_put_onpause,
4221 HTMLDocument7_get_onpause,
4222 HTMLDocument7_put_onplay,
4223 HTMLDocument7_get_onplay,
4224 HTMLDocument7_put_onplaying,
4225 HTMLDocument7_get_onplaying,
4226 HTMLDocument7_put_onprogress,
4227 HTMLDocument7_get_onprogress,
4228 HTMLDocument7_put_onratechange,
4229 HTMLDocument7_get_onratechange,
4230 HTMLDocument7_put_onreset,
4231 HTMLDocument7_get_onreset,
4232 HTMLDocument7_put_onscroll,
4233 HTMLDocument7_get_onscroll,
4234 HTMLDocument7_put_onseekend,
4235 HTMLDocument7_get_onseekend,
4236 HTMLDocument7_put_onseeking,
4237 HTMLDocument7_get_onseeking,
4238 HTMLDocument7_put_onselect,
4239 HTMLDocument7_get_onselect,
4240 HTMLDocument7_put_onstalled,
4241 HTMLDocument7_get_onstalled,
4242 HTMLDocument7_put_onsubmit,
4243 HTMLDocument7_get_onsubmit,
4244 HTMLDocument7_put_onsuspend,
4245 HTMLDocument7_get_onsuspend,
4246 HTMLDocument7_put_ontimeupdate,
4247 HTMLDocument7_get_ontimeupdate,
4248 HTMLDocument7_put_onvolumechange,
4249 HTMLDocument7_get_onvolumechange,
4250 HTMLDocument7_put_onwaiting,
4251 HTMLDocument7_get_onwaiting,
4252 HTMLDocument7_normalize,
4253 HTMLDocument7_importNode,
4254 HTMLDocument7_get_parentWindow,
4255 HTMLDocument7_put_body,
4256 HTMLDocument7_get_body,
4257 HTMLDocument7_get_head
4260 static inline HTMLDocument *impl_from_IDocumentSelector(IDocumentSelector *iface)
4262 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentSelector_iface);
4265 static HRESULT WINAPI DocumentSelector_QueryInterface(IDocumentSelector *iface, REFIID riid, void **ppv)
4267 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4268 return htmldoc_query_interface(This, riid, ppv);
4271 static ULONG WINAPI DocumentSelector_AddRef(IDocumentSelector *iface)
4273 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4274 return htmldoc_addref(This);
4277 static ULONG WINAPI DocumentSelector_Release(IDocumentSelector *iface)
4279 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4280 return htmldoc_release(This);
4283 static HRESULT WINAPI DocumentSelector_GetTypeInfoCount(IDocumentSelector *iface, UINT *pctinfo)
4285 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4286 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4289 static HRESULT WINAPI DocumentSelector_GetTypeInfo(IDocumentSelector *iface, UINT iTInfo,
4290 LCID lcid, ITypeInfo **ppTInfo)
4292 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4293 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4296 static HRESULT WINAPI DocumentSelector_GetIDsOfNames(IDocumentSelector *iface, REFIID riid,
4297 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4299 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4300 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4301 rgDispId);
4304 static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID dispIdMember, REFIID riid,
4305 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4307 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4308 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4309 pDispParams, pVarResult, pExcepInfo, puArgErr);
4312 static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
4314 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4315 nsIDOMElement *nselem;
4316 HTMLElement *elem;
4317 nsAString nsstr;
4318 nsresult nsres;
4319 HRESULT hres;
4321 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4323 nsAString_InitDepend(&nsstr, v);
4324 nsres = nsIDOMHTMLDocument_QuerySelector(This->doc_node->nsdoc, &nsstr, &nselem);
4325 nsAString_Finish(&nsstr);
4326 if(NS_FAILED(nsres)) {
4327 ERR("QuerySelector failed: %08x\n", nsres);
4328 return E_FAIL;
4331 if(!nselem) {
4332 *pel = NULL;
4333 return S_OK;
4336 hres = get_element(nselem, &elem);
4337 nsIDOMElement_Release(nselem);
4338 if(FAILED(hres))
4339 return hres;
4341 *pel = &elem->IHTMLElement_iface;
4342 return S_OK;
4345 static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4347 HTMLDocument *This = impl_from_IDocumentSelector(iface);
4348 nsIDOMNodeList *node_list;
4349 nsAString nsstr;
4350 nsresult nsres;
4352 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4354 nsAString_InitDepend(&nsstr, v);
4355 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &nsstr, &node_list);
4356 nsAString_Finish(&nsstr);
4357 if(NS_FAILED(nsres)) {
4358 ERR("QuerySelectorAll failed: %08x\n", nsres);
4359 return E_FAIL;
4362 *pel = create_child_collection(node_list);
4363 nsIDOMNodeList_Release(node_list);
4364 return *pel ? S_OK : E_OUTOFMEMORY;
4367 static const IDocumentSelectorVtbl DocumentSelectorVtbl = {
4368 DocumentSelector_QueryInterface,
4369 DocumentSelector_AddRef,
4370 DocumentSelector_Release,
4371 DocumentSelector_GetTypeInfoCount,
4372 DocumentSelector_GetTypeInfo,
4373 DocumentSelector_GetIDsOfNames,
4374 DocumentSelector_Invoke,
4375 DocumentSelector_querySelector,
4376 DocumentSelector_querySelectorAll
4379 static inline HTMLDocument *impl_from_IDocumentEvent(IDocumentEvent *iface)
4381 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentEvent_iface);
4384 static HRESULT WINAPI DocumentEvent_QueryInterface(IDocumentEvent *iface, REFIID riid, void **ppv)
4386 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4387 return htmldoc_query_interface(This, riid, ppv);
4390 static ULONG WINAPI DocumentEvent_AddRef(IDocumentEvent *iface)
4392 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4393 return htmldoc_addref(This);
4396 static ULONG WINAPI DocumentEvent_Release(IDocumentEvent *iface)
4398 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4399 return htmldoc_release(This);
4402 static HRESULT WINAPI DocumentEvent_GetTypeInfoCount(IDocumentEvent *iface, UINT *pctinfo)
4404 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4405 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
4408 static HRESULT WINAPI DocumentEvent_GetTypeInfo(IDocumentEvent *iface, UINT iTInfo,
4409 LCID lcid, ITypeInfo **ppTInfo)
4411 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4412 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4415 static HRESULT WINAPI DocumentEvent_GetIDsOfNames(IDocumentEvent *iface, REFIID riid,
4416 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4418 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4419 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
4420 rgDispId);
4423 static HRESULT WINAPI DocumentEvent_Invoke(IDocumentEvent *iface, DISPID dispIdMember, REFIID riid,
4424 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4426 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4427 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4428 pDispParams, pVarResult, pExcepInfo, puArgErr);
4431 static HRESULT WINAPI DocumentEvent_createEvent(IDocumentEvent *iface, BSTR eventType, IDOMEvent **p)
4433 HTMLDocument *This = impl_from_IDocumentEvent(iface);
4435 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eventType), p);
4437 return create_document_event_str(This->doc_node, eventType, p);
4440 static const IDocumentEventVtbl DocumentEventVtbl = {
4441 DocumentEvent_QueryInterface,
4442 DocumentEvent_AddRef,
4443 DocumentEvent_Release,
4444 DocumentEvent_GetTypeInfoCount,
4445 DocumentEvent_GetTypeInfo,
4446 DocumentEvent_GetIDsOfNames,
4447 DocumentEvent_Invoke,
4448 DocumentEvent_createEvent
4451 static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
4453 HTMLDocument *This = impl_from_IHTMLDocument2((IHTMLDocument2*)iface);
4455 if(This->window)
4456 update_doc_cp_events(This->doc_node, cp);
4459 static inline HTMLDocument *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
4461 return CONTAINING_RECORD(iface, HTMLDocument, ISupportErrorInfo_iface);
4464 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
4466 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4467 return htmldoc_query_interface(This, riid, ppv);
4470 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
4472 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4473 return htmldoc_addref(This);
4476 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
4478 HTMLDocument *This = impl_from_ISupportErrorInfo(iface);
4479 return htmldoc_release(This);
4482 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
4484 FIXME("(%p)->(%s)\n", iface, debugstr_mshtml_guid(riid));
4485 return S_FALSE;
4488 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
4489 SupportErrorInfo_QueryInterface,
4490 SupportErrorInfo_AddRef,
4491 SupportErrorInfo_Release,
4492 SupportErrorInfo_InterfaceSupportsErrorInfo
4495 static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
4497 return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface);
4500 static HRESULT dispid_from_elem_name(HTMLDocumentNode *This, BSTR name, DISPID *dispid)
4502 nsIDOMNodeList *node_list;
4503 nsAString name_str;
4504 UINT32 len;
4505 unsigned i;
4506 nsresult nsres;
4508 if(!This->nsdoc)
4509 return DISP_E_UNKNOWNNAME;
4511 nsAString_InitDepend(&name_str, name);
4512 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
4513 nsAString_Finish(&name_str);
4514 if(NS_FAILED(nsres))
4515 return E_FAIL;
4517 nsres = nsIDOMNodeList_GetLength(node_list, &len);
4518 nsIDOMNodeList_Release(node_list);
4519 if(NS_FAILED(nsres))
4520 return E_FAIL;
4522 if(!len)
4523 return DISP_E_UNKNOWNNAME;
4525 for(i=0; i < This->elem_vars_cnt; i++) {
4526 if(!wcscmp(name, This->elem_vars[i])) {
4527 *dispid = MSHTML_DISPID_CUSTOM_MIN+i;
4528 return S_OK;
4532 if(This->elem_vars_cnt == This->elem_vars_size) {
4533 WCHAR **new_vars;
4535 if(This->elem_vars_size) {
4536 new_vars = heap_realloc(This->elem_vars, This->elem_vars_size*2*sizeof(WCHAR*));
4537 if(!new_vars)
4538 return E_OUTOFMEMORY;
4539 This->elem_vars_size *= 2;
4540 }else {
4541 new_vars = heap_alloc(16*sizeof(WCHAR*));
4542 if(!new_vars)
4543 return E_OUTOFMEMORY;
4544 This->elem_vars_size = 16;
4547 This->elem_vars = new_vars;
4550 This->elem_vars[This->elem_vars_cnt] = heap_strdupW(name);
4551 if(!This->elem_vars[This->elem_vars_cnt])
4552 return E_OUTOFMEMORY;
4554 *dispid = MSHTML_DISPID_CUSTOM_MIN+This->elem_vars_cnt++;
4555 return S_OK;
4558 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
4560 HTMLDocument *This = impl_from_IDispatchEx(iface);
4562 return htmldoc_query_interface(This, riid, ppv);
4565 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
4567 HTMLDocument *This = impl_from_IDispatchEx(iface);
4569 return htmldoc_addref(This);
4572 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
4574 HTMLDocument *This = impl_from_IDispatchEx(iface);
4576 return htmldoc_release(This);
4579 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
4581 HTMLDocument *This = impl_from_IDispatchEx(iface);
4583 return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
4586 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
4587 LCID lcid, ITypeInfo **ppTInfo)
4589 HTMLDocument *This = impl_from_IDispatchEx(iface);
4591 return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
4594 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
4595 LPOLESTR *rgszNames, UINT cNames,
4596 LCID lcid, DISPID *rgDispId)
4598 HTMLDocument *This = impl_from_IDispatchEx(iface);
4600 return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
4603 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
4604 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4605 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4607 HTMLDocument *This = impl_from_IDispatchEx(iface);
4609 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
4610 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4612 switch(dispIdMember) {
4613 case DISPID_READYSTATE:
4614 TRACE("DISPID_READYSTATE\n");
4616 if(!(wFlags & DISPATCH_PROPERTYGET))
4617 return E_INVALIDARG;
4619 V_VT(pVarResult) = VT_I4;
4620 V_I4(pVarResult) = This->window->readystate;
4621 return S_OK;
4624 return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
4625 pVarResult, pExcepInfo, puArgErr);
4628 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
4630 HTMLDocument *This = impl_from_IDispatchEx(iface);
4631 HRESULT hres;
4633 hres = IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
4634 if(hres != DISP_E_UNKNOWNNAME)
4635 return hres;
4637 return dispid_from_elem_name(This->doc_node, bstrName, pid);
4640 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
4641 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
4643 HTMLDocument *This = impl_from_IDispatchEx(iface);
4645 if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
4646 return IDispatchEx_InvokeEx(&This->window->base.IDispatchEx_iface, DISPID_IHTMLWINDOW2_LOCATION,
4647 lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4650 return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
4653 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
4655 HTMLDocument *This = impl_from_IDispatchEx(iface);
4657 return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
4660 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
4662 HTMLDocument *This = impl_from_IDispatchEx(iface);
4664 return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
4667 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
4669 HTMLDocument *This = impl_from_IDispatchEx(iface);
4671 return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
4674 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
4676 HTMLDocument *This = impl_from_IDispatchEx(iface);
4678 return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
4681 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
4683 HTMLDocument *This = impl_from_IDispatchEx(iface);
4685 return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
4688 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
4690 HTMLDocument *This = impl_from_IDispatchEx(iface);
4692 return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
4695 static const IDispatchExVtbl DocDispatchExVtbl = {
4696 DocDispatchEx_QueryInterface,
4697 DocDispatchEx_AddRef,
4698 DocDispatchEx_Release,
4699 DocDispatchEx_GetTypeInfoCount,
4700 DocDispatchEx_GetTypeInfo,
4701 DocDispatchEx_GetIDsOfNames,
4702 DocDispatchEx_Invoke,
4703 DocDispatchEx_GetDispID,
4704 DocDispatchEx_InvokeEx,
4705 DocDispatchEx_DeleteMemberByName,
4706 DocDispatchEx_DeleteMemberByDispID,
4707 DocDispatchEx_GetMemberProperties,
4708 DocDispatchEx_GetMemberName,
4709 DocDispatchEx_GetNextDispID,
4710 DocDispatchEx_GetNameSpaceParent
4713 static inline HTMLDocument *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
4715 return CONTAINING_RECORD(iface, HTMLDocument, IProvideMultipleClassInfo_iface);
4718 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
4719 REFIID riid, void **ppv)
4721 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4722 return htmldoc_query_interface(This, riid, ppv);
4725 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
4727 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4728 return htmldoc_addref(This);
4731 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
4733 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4734 return htmldoc_release(This);
4737 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
4739 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4740 TRACE("(%p)->(%p)\n", This, ppTI);
4741 return get_class_typeinfo(&CLSID_HTMLDocument, ppTI);
4744 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
4746 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4747 FIXME("(%p)->(%u %p)\n", This, dwGuidKind, pGUID);
4748 return E_NOTIMPL;
4751 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
4753 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4754 FIXME("(%p)->(%p)\n", This, pcti);
4755 *pcti = 1;
4756 return S_OK;
4759 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
4760 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
4762 HTMLDocument *This = impl_from_IProvideMultipleClassInfo(iface);
4763 FIXME("(%p)->(%u %x %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
4764 return E_NOTIMPL;
4767 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
4768 ProvideClassInfo_QueryInterface,
4769 ProvideClassInfo_AddRef,
4770 ProvideClassInfo_Release,
4771 ProvideClassInfo_GetClassInfo,
4772 ProvideClassInfo2_GetGUID,
4773 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
4774 ProvideMultipleClassInfo_GetInfoOfIndex
4777 /**********************************************************
4778 * IMarkupServices implementation
4780 static inline HTMLDocument *impl_from_IMarkupServices(IMarkupServices *iface)
4782 return CONTAINING_RECORD(iface, HTMLDocument, IMarkupServices_iface);
4785 static HRESULT WINAPI MarkupServices_QueryInterface(IMarkupServices *iface, REFIID riid, void **ppvObject)
4787 HTMLDocument *This = impl_from_IMarkupServices(iface);
4788 return htmldoc_query_interface(This, riid, ppvObject);
4791 static ULONG WINAPI MarkupServices_AddRef(IMarkupServices *iface)
4793 HTMLDocument *This = impl_from_IMarkupServices(iface);
4794 return htmldoc_addref(This);
4797 static ULONG WINAPI MarkupServices_Release(IMarkupServices *iface)
4799 HTMLDocument *This = impl_from_IMarkupServices(iface);
4800 return htmldoc_release(This);
4803 static HRESULT WINAPI MarkupServices_CreateMarkupPointer(IMarkupServices *iface, IMarkupPointer **ppPointer)
4805 HTMLDocument *This = impl_from_IMarkupServices(iface);
4807 TRACE("(%p)->(%p)\n", This, ppPointer);
4809 return create_markup_pointer(ppPointer);
4812 static HRESULT WINAPI MarkupServices_CreateMarkupContainer(IMarkupServices *iface, IMarkupContainer **ppMarkupContainer)
4814 HTMLDocument *This = impl_from_IMarkupServices(iface);
4815 FIXME("(%p)->(%p)\n", This, ppMarkupContainer);
4816 return E_NOTIMPL;
4819 static HRESULT WINAPI MarkupServices_CreateElement(IMarkupServices *iface,
4820 ELEMENT_TAG_ID tagID, OLECHAR *pchAttributes, IHTMLElement **ppElement)
4822 HTMLDocument *This = impl_from_IMarkupServices(iface);
4823 FIXME("(%p)->(%d,%s,%p)\n", This, tagID, debugstr_w(pchAttributes), ppElement);
4824 return E_NOTIMPL;
4827 static HRESULT WINAPI MarkupServices_CloneElement(IMarkupServices *iface,
4828 IHTMLElement *pElemCloneThis, IHTMLElement **ppElementTheClone)
4830 HTMLDocument *This = impl_from_IMarkupServices(iface);
4831 FIXME("(%p)->(%p,%p)\n", This, pElemCloneThis, ppElementTheClone);
4832 return E_NOTIMPL;
4835 static HRESULT WINAPI MarkupServices_InsertElement(IMarkupServices *iface,
4836 IHTMLElement *pElementInsert, IMarkupPointer *pPointerStart,
4837 IMarkupPointer *pPointerFinish)
4839 HTMLDocument *This = impl_from_IMarkupServices(iface);
4840 FIXME("(%p)->(%p,%p,%p)\n", This, pElementInsert, pPointerStart, pPointerFinish);
4841 return E_NOTIMPL;
4844 static HRESULT WINAPI MarkupServices_RemoveElement(IMarkupServices *iface, IHTMLElement *pElementRemove)
4846 HTMLDocument *This = impl_from_IMarkupServices(iface);
4847 FIXME("(%p)->(%p)\n", This, pElementRemove);
4848 return E_NOTIMPL;
4851 static HRESULT WINAPI MarkupServices_Remove(IMarkupServices *iface,
4852 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
4854 HTMLDocument *This = impl_from_IMarkupServices(iface);
4855 FIXME("(%p)->(%p,%p)\n", This, pPointerStart, pPointerFinish);
4856 return E_NOTIMPL;
4859 static HRESULT WINAPI MarkupServices_Copy(IMarkupServices *iface,
4860 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
4861 IMarkupPointer *pPointerTarget)
4863 HTMLDocument *This = impl_from_IMarkupServices(iface);
4864 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
4865 return E_NOTIMPL;
4868 static HRESULT WINAPI MarkupServices_Move(IMarkupServices *iface,
4869 IMarkupPointer *pPointerSourceStart, IMarkupPointer *pPointerSourceFinish,
4870 IMarkupPointer *pPointerTarget)
4872 HTMLDocument *This = impl_from_IMarkupServices(iface);
4873 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerSourceStart, pPointerSourceFinish, pPointerTarget);
4874 return E_NOTIMPL;
4877 static HRESULT WINAPI MarkupServices_InsertText(IMarkupServices *iface,
4878 OLECHAR *pchText, LONG cch, IMarkupPointer *pPointerTarget)
4880 HTMLDocument *This = impl_from_IMarkupServices(iface);
4881 FIXME("(%p)->(%s,%x,%p)\n", This, debugstr_w(pchText), cch, pPointerTarget);
4882 return E_NOTIMPL;
4885 static HRESULT WINAPI MarkupServices_ParseString(IMarkupServices *iface,
4886 OLECHAR *pchHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
4887 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
4889 HTMLDocument *This = impl_from_IMarkupServices(iface);
4890 FIXME("(%p)->(%s,%x,%p,%p,%p)\n", This, debugstr_w(pchHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
4891 return E_NOTIMPL;
4894 static HRESULT WINAPI MarkupServices_ParseGlobal(IMarkupServices *iface,
4895 HGLOBAL hglobalHTML, DWORD dwFlags, IMarkupContainer **ppContainerResult,
4896 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
4898 HTMLDocument *This = impl_from_IMarkupServices(iface);
4899 FIXME("(%p)->(%s,%x,%p,%p,%p)\n", This, debugstr_w(hglobalHTML), dwFlags, ppContainerResult, pPointerStart, pPointerFinish);
4900 return E_NOTIMPL;
4903 static HRESULT WINAPI MarkupServices_IsScopedElement(IMarkupServices *iface,
4904 IHTMLElement *pElement, BOOL *pfScoped)
4906 HTMLDocument *This = impl_from_IMarkupServices(iface);
4907 FIXME("(%p)->(%p,%p)\n", This, pElement, pfScoped);
4908 return E_NOTIMPL;
4911 static HRESULT WINAPI MarkupServices_GetElementTagId(IMarkupServices *iface,
4912 IHTMLElement *pElement, ELEMENT_TAG_ID *ptagId)
4914 HTMLDocument *This = impl_from_IMarkupServices(iface);
4915 FIXME("(%p)->(%p,%p)\n", This, pElement, ptagId);
4916 return E_NOTIMPL;
4919 static HRESULT WINAPI MarkupServices_GetTagIDForName(IMarkupServices *iface,
4920 BSTR bstrName, ELEMENT_TAG_ID *ptagId)
4922 HTMLDocument *This = impl_from_IMarkupServices(iface);
4923 FIXME("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), ptagId);
4924 return E_NOTIMPL;
4927 static HRESULT WINAPI MarkupServices_GetNameForTagID(IMarkupServices *iface,
4928 ELEMENT_TAG_ID tagId, BSTR *pbstrName)
4930 HTMLDocument *This = impl_from_IMarkupServices(iface);
4931 FIXME("(%p)->(%d,%p)\n", This, tagId, pbstrName);
4932 return E_NOTIMPL;
4935 static HRESULT WINAPI MarkupServices_MovePointersToRange(IMarkupServices *iface,
4936 IHTMLTxtRange *pIRange, IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish)
4938 HTMLDocument *This = impl_from_IMarkupServices(iface);
4939 FIXME("(%p)->(%p,%p,%p)\n", This, pIRange, pPointerStart, pPointerFinish);
4940 return E_NOTIMPL;
4943 static HRESULT WINAPI MarkupServices_MoveRangeToPointers(IMarkupServices *iface,
4944 IMarkupPointer *pPointerStart, IMarkupPointer *pPointerFinish, IHTMLTxtRange *pIRange)
4946 HTMLDocument *This = impl_from_IMarkupServices(iface);
4947 FIXME("(%p)->(%p,%p,%p)\n", This, pPointerStart, pPointerFinish, pIRange);
4948 return E_NOTIMPL;
4951 static HRESULT WINAPI MarkupServices_BeginUndoUnit(IMarkupServices *iface, OLECHAR *pchTitle)
4953 HTMLDocument *This = impl_from_IMarkupServices(iface);
4954 FIXME("(%p)->(%s)\n", This, debugstr_w(pchTitle));
4955 return E_NOTIMPL;
4958 static HRESULT WINAPI MarkupServices_EndUndoUnit(IMarkupServices *iface)
4960 HTMLDocument *This = impl_from_IMarkupServices(iface);
4961 FIXME("(%p)\n", This);
4962 return E_NOTIMPL;
4965 static const IMarkupServicesVtbl MarkupServicesVtbl = {
4966 MarkupServices_QueryInterface,
4967 MarkupServices_AddRef,
4968 MarkupServices_Release,
4969 MarkupServices_CreateMarkupPointer,
4970 MarkupServices_CreateMarkupContainer,
4971 MarkupServices_CreateElement,
4972 MarkupServices_CloneElement,
4973 MarkupServices_InsertElement,
4974 MarkupServices_RemoveElement,
4975 MarkupServices_Remove,
4976 MarkupServices_Copy,
4977 MarkupServices_Move,
4978 MarkupServices_InsertText,
4979 MarkupServices_ParseString,
4980 MarkupServices_ParseGlobal,
4981 MarkupServices_IsScopedElement,
4982 MarkupServices_GetElementTagId,
4983 MarkupServices_GetTagIDForName,
4984 MarkupServices_GetNameForTagID,
4985 MarkupServices_MovePointersToRange,
4986 MarkupServices_MoveRangeToPointers,
4987 MarkupServices_BeginUndoUnit,
4988 MarkupServices_EndUndoUnit
4991 /**********************************************************
4992 * IMarkupContainer implementation
4994 static inline HTMLDocument *impl_from_IMarkupContainer(IMarkupContainer *iface)
4996 return CONTAINING_RECORD(iface, HTMLDocument, IMarkupContainer_iface);
4999 static HRESULT WINAPI MarkupContainer_QueryInterface(IMarkupContainer *iface, REFIID riid, void **ppvObject)
5001 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5002 return htmldoc_query_interface(This, riid, ppvObject);
5005 static ULONG WINAPI MarkupContainer_AddRef(IMarkupContainer *iface)
5007 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5008 return htmldoc_addref(This);
5011 static ULONG WINAPI MarkupContainer_Release(IMarkupContainer *iface)
5013 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5014 return htmldoc_release(This);
5017 static HRESULT WINAPI MarkupContainer_OwningDoc(IMarkupContainer *iface, IHTMLDocument2 **ppDoc)
5019 HTMLDocument *This = impl_from_IMarkupContainer(iface);
5020 FIXME("(%p)->(%p)\n", This, ppDoc);
5021 return E_NOTIMPL;
5024 static const IMarkupContainerVtbl MarkupContainerVtbl = {
5025 MarkupContainer_QueryInterface,
5026 MarkupContainer_AddRef,
5027 MarkupContainer_Release,
5028 MarkupContainer_OwningDoc
5031 /**********************************************************
5032 * IDisplayServices implementation
5034 static inline HTMLDocument *impl_from_IDisplayServices(IDisplayServices *iface)
5036 return CONTAINING_RECORD(iface, HTMLDocument, IDisplayServices_iface);
5039 static HRESULT WINAPI DisplayServices_QueryInterface(IDisplayServices *iface, REFIID riid, void **ppvObject)
5041 HTMLDocument *This = impl_from_IDisplayServices(iface);
5042 return htmldoc_query_interface(This, riid, ppvObject);
5045 static ULONG WINAPI DisplayServices_AddRef(IDisplayServices *iface)
5047 HTMLDocument *This = impl_from_IDisplayServices(iface);
5048 return htmldoc_addref(This);
5051 static ULONG WINAPI DisplayServices_Release(IDisplayServices *iface)
5053 HTMLDocument *This = impl_from_IDisplayServices(iface);
5054 return htmldoc_release(This);
5057 static HRESULT WINAPI DisplayServices_CreateDisplayPointer(IDisplayServices *iface, IDisplayPointer **ppDispPointer)
5059 HTMLDocument *This = impl_from_IDisplayServices(iface);
5060 FIXME("(%p)->(%p)\n", This, ppDispPointer);
5061 return E_NOTIMPL;
5064 static HRESULT WINAPI DisplayServices_TransformRect(IDisplayServices *iface,
5065 RECT *pRect, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5067 HTMLDocument *This = impl_from_IDisplayServices(iface);
5068 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_rect(pRect), eSource, eDestination, pIElement);
5069 return E_NOTIMPL;
5072 static HRESULT WINAPI DisplayServices_TransformPoint(IDisplayServices *iface,
5073 POINT *pPoint, COORD_SYSTEM eSource, COORD_SYSTEM eDestination, IHTMLElement *pIElement)
5075 HTMLDocument *This = impl_from_IDisplayServices(iface);
5076 FIXME("(%p)->(%s,%d,%d,%p)\n", This, wine_dbgstr_point(pPoint), eSource, eDestination, pIElement);
5077 return E_NOTIMPL;
5080 static HRESULT WINAPI DisplayServices_GetCaret(IDisplayServices *iface, IHTMLCaret **ppCaret)
5082 HTMLDocument *This = impl_from_IDisplayServices(iface);
5083 FIXME("(%p)->(%p)\n", This, ppCaret);
5084 return E_NOTIMPL;
5087 static HRESULT WINAPI DisplayServices_GetComputedStyle(IDisplayServices *iface,
5088 IMarkupPointer *pPointer, IHTMLComputedStyle **ppComputedStyle)
5090 HTMLDocument *This = impl_from_IDisplayServices(iface);
5091 FIXME("(%p)->(%p,%p)\n", This, pPointer, ppComputedStyle);
5092 return E_NOTIMPL;
5095 static HRESULT WINAPI DisplayServices_ScrollRectIntoView(IDisplayServices *iface,
5096 IHTMLElement *pIElement, RECT rect)
5098 HTMLDocument *This = impl_from_IDisplayServices(iface);
5099 FIXME("(%p)->(%p,%s)\n", This, pIElement, wine_dbgstr_rect(&rect));
5100 return E_NOTIMPL;
5103 static HRESULT WINAPI DisplayServices_HasFlowLayout(IDisplayServices *iface,
5104 IHTMLElement *pIElement, BOOL *pfHasFlowLayout)
5106 HTMLDocument *This = impl_from_IDisplayServices(iface);
5107 FIXME("(%p)->(%p,%p)\n", This, pIElement, pfHasFlowLayout);
5108 return E_NOTIMPL;
5111 static const IDisplayServicesVtbl DisplayServicesVtbl = {
5112 DisplayServices_QueryInterface,
5113 DisplayServices_AddRef,
5114 DisplayServices_Release,
5115 DisplayServices_CreateDisplayPointer,
5116 DisplayServices_TransformRect,
5117 DisplayServices_TransformPoint,
5118 DisplayServices_GetCaret,
5119 DisplayServices_GetComputedStyle,
5120 DisplayServices_ScrollRectIntoView,
5121 DisplayServices_HasFlowLayout
5124 /**********************************************************
5125 * IDocumentRange implementation
5127 static inline HTMLDocument *impl_from_IDocumentRange(IDocumentRange *iface)
5129 return CONTAINING_RECORD(iface, HTMLDocument, IDocumentRange_iface);
5132 static HRESULT WINAPI DocumentRange_QueryInterface(IDocumentRange *iface, REFIID riid, void **ppv)
5134 HTMLDocument *This = impl_from_IDocumentRange(iface);
5136 return htmldoc_query_interface(This, riid, ppv);
5139 static ULONG WINAPI DocumentRange_AddRef(IDocumentRange *iface)
5141 HTMLDocument *This = impl_from_IDocumentRange(iface);
5143 return htmldoc_addref(This);
5146 static ULONG WINAPI DocumentRange_Release(IDocumentRange *iface)
5148 HTMLDocument *This = impl_from_IDocumentRange(iface);
5150 return htmldoc_release(This);
5153 static HRESULT WINAPI DocumentRange_GetTypeInfoCount(IDocumentRange *iface, UINT *pctinfo)
5155 HTMLDocument *This = impl_from_IDocumentRange(iface);
5157 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
5160 static HRESULT WINAPI DocumentRange_GetTypeInfo(IDocumentRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5162 HTMLDocument *This = impl_from_IDocumentRange(iface);
5164 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5167 static HRESULT WINAPI DocumentRange_GetIDsOfNames(IDocumentRange *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5168 LCID lcid, DISPID *rgDispId)
5170 HTMLDocument *This = impl_from_IDocumentRange(iface);
5172 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
5173 rgDispId);
5176 static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
5177 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5179 HTMLDocument *This = impl_from_IDocumentRange(iface);
5181 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
5182 pDispParams, pVarResult, pExcepInfo, puArgErr);
5185 static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
5187 HTMLDocument *This = impl_from_IDocumentRange(iface);
5188 nsIDOMRange *nsrange;
5189 HRESULT hres;
5191 TRACE("(%p)->(%p)\n", This, p);
5193 if(!This->doc_node->nsdoc) {
5194 WARN("NULL nsdoc\n");
5195 return E_UNEXPECTED;
5198 if(NS_FAILED(nsIDOMHTMLDocument_CreateRange(This->doc_node->nsdoc, &nsrange)))
5199 return E_FAIL;
5201 hres = HTMLDOMRange_Create(nsrange, p);
5202 nsIDOMRange_Release(nsrange);
5203 return hres;
5206 static const IDocumentRangeVtbl DocumentRangeVtbl = {
5207 DocumentRange_QueryInterface,
5208 DocumentRange_AddRef,
5209 DocumentRange_Release,
5210 DocumentRange_GetTypeInfoCount,
5211 DocumentRange_GetTypeInfo,
5212 DocumentRange_GetIDsOfNames,
5213 DocumentRange_Invoke,
5214 DocumentRange_createRange,
5217 static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
5219 *ppv = NULL;
5221 if(IsEqualGUID(&IID_IUnknown, riid))
5222 *ppv = &This->IHTMLDocument2_iface;
5223 else if(IsEqualGUID(&IID_IDispatch, riid))
5224 *ppv = &This->IDispatchEx_iface;
5225 else if(IsEqualGUID(&IID_IDispatchEx, riid))
5226 *ppv = &This->IDispatchEx_iface;
5227 else if(IsEqualGUID(&IID_IHTMLDocument, riid))
5228 *ppv = &This->IHTMLDocument2_iface;
5229 else if(IsEqualGUID(&IID_IHTMLDocument2, riid))
5230 *ppv = &This->IHTMLDocument2_iface;
5231 else if(IsEqualGUID(&IID_IHTMLDocument3, riid))
5232 *ppv = &This->IHTMLDocument3_iface;
5233 else if(IsEqualGUID(&IID_IHTMLDocument4, riid))
5234 *ppv = &This->IHTMLDocument4_iface;
5235 else if(IsEqualGUID(&IID_IHTMLDocument5, riid))
5236 *ppv = &This->IHTMLDocument5_iface;
5237 else if(IsEqualGUID(&IID_IHTMLDocument6, riid))
5238 *ppv = &This->IHTMLDocument6_iface;
5239 else if(IsEqualGUID(&IID_IHTMLDocument7, riid))
5240 *ppv = &This->IHTMLDocument7_iface;
5241 else if(IsEqualGUID(&IID_IDocumentSelector, riid))
5242 *ppv = &This->IDocumentSelector_iface;
5243 else if(IsEqualGUID(&IID_IDocumentEvent, riid))
5244 *ppv = &This->IDocumentEvent_iface;
5245 else if(IsEqualGUID(&IID_IPersist, riid))
5246 *ppv = &This->IPersistFile_iface;
5247 else if(IsEqualGUID(&IID_IPersistMoniker, riid))
5248 *ppv = &This->IPersistMoniker_iface;
5249 else if(IsEqualGUID(&IID_IPersistFile, riid))
5250 *ppv = &This->IPersistFile_iface;
5251 else if(IsEqualGUID(&IID_IMonikerProp, riid))
5252 *ppv = &This->IMonikerProp_iface;
5253 else if(IsEqualGUID(&IID_IOleObject, riid))
5254 *ppv = &This->IOleObject_iface;
5255 else if(IsEqualGUID(&IID_IOleDocument, riid))
5256 *ppv = &This->IOleDocument_iface;
5257 else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid))
5258 *ppv = &This->IOleInPlaceActiveObject_iface;
5259 else if(IsEqualGUID(&IID_IOleWindow, riid))
5260 *ppv = &This->IOleInPlaceActiveObject_iface;
5261 else if(IsEqualGUID(&IID_IOleInPlaceObject, riid))
5262 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5263 else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
5264 *ppv = &This->IOleInPlaceObjectWindowless_iface;
5265 else if(IsEqualGUID(&IID_IServiceProvider, riid))
5266 *ppv = &This->IServiceProvider_iface;
5267 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
5268 *ppv = &This->IOleCommandTarget_iface;
5269 else if(IsEqualGUID(&IID_IOleControl, riid))
5270 *ppv = &This->IOleControl_iface;
5271 else if(IsEqualGUID(&IID_IHlinkTarget, riid))
5272 *ppv = &This->IHlinkTarget_iface;
5273 else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
5274 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5275 else if(IsEqualGUID(&IID_IPersistStreamInit, riid))
5276 *ppv = &This->IPersistStreamInit_iface;
5277 else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
5278 *ppv = &This->IHTMLDocument2_iface;
5279 else if(IsEqualGUID(&IID_ISupportErrorInfo, riid))
5280 *ppv = &This->ISupportErrorInfo_iface;
5281 else if(IsEqualGUID(&IID_IPersistHistory, riid))
5282 *ppv = &This->IPersistHistory_iface;
5283 else if(IsEqualGUID(&IID_IObjectWithSite, riid))
5284 *ppv = &This->IObjectWithSite_iface;
5285 else if(IsEqualGUID(&IID_IOleContainer, riid))
5286 *ppv = &This->IOleContainer_iface;
5287 else if(IsEqualGUID(&IID_IObjectSafety, riid))
5288 *ppv = &This->IObjectSafety_iface;
5289 else if(IsEqualGUID(&IID_IProvideClassInfo, riid))
5290 *ppv = &This->IProvideMultipleClassInfo_iface;
5291 else if(IsEqualGUID(&IID_IProvideClassInfo2, riid))
5292 *ppv = &This->IProvideMultipleClassInfo_iface;
5293 else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid))
5294 *ppv = &This->IProvideMultipleClassInfo_iface;
5295 else if(IsEqualGUID(&IID_IMarkupServices, riid))
5296 *ppv = &This->IMarkupServices_iface;
5297 else if(IsEqualGUID(&IID_IMarkupContainer, riid))
5298 *ppv = &This->IMarkupContainer_iface;
5299 else if(IsEqualGUID(&IID_IDisplayServices, riid))
5300 *ppv = &This->IDisplayServices_iface;
5301 else if(IsEqualGUID(&IID_IDocumentRange, riid))
5302 *ppv = &This->IDocumentRange_iface;
5303 else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
5304 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppv);
5305 *ppv = NULL;
5306 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
5307 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
5308 *ppv = NULL;
5309 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
5310 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppv);
5311 *ppv = NULL;
5312 }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
5313 TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv);
5314 *ppv = NULL;
5315 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
5316 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
5317 *ppv = NULL;
5318 }else {
5319 return FALSE;
5322 if(*ppv)
5323 IUnknown_AddRef((IUnknown*)*ppv);
5324 return TRUE;
5327 static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
5328 static cp_static_data_t HTMLDocumentEvents2_data = { HTMLDocumentEvents2_tid, HTMLDocument_on_advise, TRUE };
5330 static const cpc_entry_t HTMLDocument_cpc[] = {
5331 {&IID_IDispatch, &HTMLDocumentEvents_data},
5332 {&IID_IPropertyNotifySink},
5333 {&DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data},
5334 {&DIID_HTMLDocumentEvents2, &HTMLDocumentEvents2_data},
5335 {NULL}
5338 static void init_doc(HTMLDocument *doc, IUnknown *outer, IDispatchEx *dispex)
5340 doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl;
5341 doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl;
5342 doc->IHTMLDocument4_iface.lpVtbl = &HTMLDocument4Vtbl;
5343 doc->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
5344 doc->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
5345 doc->IHTMLDocument7_iface.lpVtbl = &HTMLDocument7Vtbl;
5346 doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl;
5347 doc->IDocumentSelector_iface.lpVtbl = &DocumentSelectorVtbl;
5348 doc->IDocumentEvent_iface.lpVtbl = &DocumentEventVtbl;
5349 doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
5350 doc->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
5351 doc->IMarkupServices_iface.lpVtbl = &MarkupServicesVtbl;
5352 doc->IMarkupContainer_iface.lpVtbl = &MarkupContainerVtbl;
5353 doc->IDisplayServices_iface.lpVtbl = &DisplayServicesVtbl;
5354 doc->IDocumentRange_iface.lpVtbl = &DocumentRangeVtbl;
5356 doc->outer_unk = outer;
5357 doc->dispex = dispex;
5359 HTMLDocument_Persist_Init(doc);
5360 HTMLDocument_OleCmd_Init(doc);
5361 HTMLDocument_OleObj_Init(doc);
5362 HTMLDocument_Service_Init(doc);
5364 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->IHTMLDocument2_iface, HTMLDocument_cpc);
5367 static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5369 return CONTAINING_RECORD(iface, HTMLDocumentNode, node);
5372 static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5374 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5376 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5378 if(htmldoc_qi(&This->basedoc, riid, ppv))
5379 return *ppv ? S_OK : E_NOINTERFACE;
5381 if(IsEqualGUID(&IID_IInternetHostSecurityManager, riid))
5382 *ppv = &This->IInternetHostSecurityManager_iface;
5383 else
5384 return HTMLDOMNode_QI(&This->node, riid, ppv);
5386 IUnknown_AddRef((IUnknown*)*ppv);
5387 return S_OK;
5390 void detach_document_node(HTMLDocumentNode *doc)
5392 unsigned i;
5394 while(!list_empty(&doc->plugin_hosts))
5395 detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
5397 if(doc->dom_implementation) {
5398 detach_dom_implementation(doc->dom_implementation);
5399 IHTMLDOMImplementation_Release(doc->dom_implementation);
5400 doc->dom_implementation = NULL;
5403 if(doc->namespaces) {
5404 IHTMLNamespaceCollection_Release(doc->namespaces);
5405 doc->namespaces = NULL;
5408 detach_events(doc);
5409 detach_selection(doc);
5410 detach_ranges(doc);
5412 for(i=0; i < doc->elem_vars_cnt; i++)
5413 heap_free(doc->elem_vars[i]);
5414 heap_free(doc->elem_vars);
5415 doc->elem_vars_cnt = doc->elem_vars_size = 0;
5416 doc->elem_vars = NULL;
5418 if(doc->catmgr) {
5419 ICatInformation_Release(doc->catmgr);
5420 doc->catmgr = NULL;
5423 if(!doc->nsdoc && doc->window) {
5424 /* document fragments own reference to inner window */
5425 IHTMLWindow2_Release(&doc->window->base.IHTMLWindow2_iface);
5426 doc->window = NULL;
5429 if(doc->browser) {
5430 list_remove(&doc->browser_entry);
5431 doc->browser = NULL;
5435 static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
5437 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5439 TRACE("(%p)\n", This);
5441 heap_free(This->event_vector);
5442 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
5445 static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5447 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5448 FIXME("%p\n", This);
5449 return E_NOTIMPL;
5452 static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
5454 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5456 if(This->nsdoc)
5457 note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb);
5460 static void HTMLDocumentNode_unlink(HTMLDOMNode *iface)
5462 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5464 if(This->nsdoc) {
5465 nsIDOMHTMLDocument *nsdoc = This->nsdoc;
5467 release_document_mutation(This);
5468 detach_document_node(This);
5469 This->nsdoc = NULL;
5470 nsIDOMHTMLDocument_Release(nsdoc);
5471 This->window = NULL;
5475 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
5476 &CLSID_HTMLDocument,
5477 HTMLDocumentNode_QI,
5478 HTMLDocumentNode_destructor,
5479 HTMLDocument_cpc,
5480 HTMLDocumentNode_clone,
5481 NULL,
5482 NULL,
5483 NULL,
5484 NULL,
5485 NULL,
5486 NULL,
5487 NULL,
5488 NULL,
5489 NULL,
5490 NULL,
5491 HTMLDocumentNode_traverse,
5492 HTMLDocumentNode_unlink
5495 static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5497 HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
5498 HTMLDocumentNode *new_node;
5499 HRESULT hres;
5501 hres = create_document_fragment(nsnode, This->node.doc, &new_node);
5502 if(FAILED(hres))
5503 return hres;
5505 *ret = &new_node->node;
5506 return S_OK;
5509 static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface)
5511 return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex);
5514 static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5515 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5517 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5518 nsIDOMNodeList *node_list;
5519 nsAString name_str;
5520 nsIDOMNode *nsnode;
5521 HTMLDOMNode *node;
5522 unsigned i;
5523 nsresult nsres;
5524 HRESULT hres;
5526 if(flags != DISPATCH_PROPERTYGET && flags != (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) {
5527 FIXME("unsupported flags %x\n", flags);
5528 return E_NOTIMPL;
5531 i = id - MSHTML_DISPID_CUSTOM_MIN;
5533 if(!This->nsdoc || i >= This->elem_vars_cnt)
5534 return DISP_E_UNKNOWNNAME;
5536 nsAString_InitDepend(&name_str, This->elem_vars[i]);
5537 nsres = nsIDOMHTMLDocument_GetElementsByName(This->nsdoc, &name_str, &node_list);
5538 nsAString_Finish(&name_str);
5539 if(NS_FAILED(nsres))
5540 return E_FAIL;
5542 nsres = nsIDOMNodeList_Item(node_list, 0, &nsnode);
5543 nsIDOMNodeList_Release(node_list);
5544 if(NS_FAILED(nsres) || !nsnode)
5545 return DISP_E_UNKNOWNNAME;
5547 hres = get_node(nsnode, TRUE, &node);
5548 if(FAILED(hres))
5549 return hres;
5551 V_VT(res) = VT_DISPATCH;
5552 V_DISPATCH(res) = (IDispatch*)&node->IHTMLDOMNode_iface;
5553 return S_OK;
5556 static compat_mode_t HTMLDocumentNode_get_compat_mode(DispatchEx *dispex)
5558 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5560 TRACE("(%p) returning %u\n", This, This->document_mode);
5562 return lock_document_mode(This);
5565 static nsISupports *HTMLDocumentNode_get_gecko_target(DispatchEx *dispex)
5567 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5568 return (nsISupports*)This->node.nsnode;
5571 static void HTMLDocumentNode_bind_event(DispatchEx *dispex, eventid_t eid)
5573 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5574 ensure_doc_nsevent_handler(This, This->node.nsnode, eid);
5577 static EventTarget *HTMLDocumentNode_get_parent_event_target(DispatchEx *dispex)
5579 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5580 if(!This->window)
5581 return NULL;
5582 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
5583 return &This->window->event_target;
5586 static ConnectionPointContainer *HTMLDocumentNode_get_cp_container(DispatchEx *dispex)
5588 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5589 ConnectionPointContainer *container = This->basedoc.doc_obj
5590 ? &This->basedoc.doc_obj->basedoc.cp_container : &This->basedoc.cp_container;
5591 IConnectionPointContainer_AddRef(&container->IConnectionPointContainer_iface);
5592 return container;
5595 static IHTMLEventObj *HTMLDocumentNode_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
5597 HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
5598 return default_set_current_event(This->window, event);
5601 static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
5603 NULL,
5604 NULL,
5605 HTMLDocumentNode_invoke,
5606 HTMLDocumentNode_get_compat_mode,
5607 NULL
5609 HTMLDocumentNode_get_gecko_target,
5610 HTMLDocumentNode_bind_event,
5611 HTMLDocumentNode_get_parent_event_target,
5612 NULL,
5613 HTMLDocumentNode_get_cp_container,
5614 HTMLDocumentNode_set_current_event
5617 static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
5618 &CLSID_HTMLDocument,
5619 HTMLDocumentNode_QI,
5620 HTMLDocumentNode_destructor,
5621 HTMLDocument_cpc,
5622 HTMLDocumentFragment_clone
5625 static const tid_t HTMLDocumentNode_iface_tids[] = {
5626 IHTMLDOMNode_tid,
5627 IHTMLDOMNode2_tid,
5628 IHTMLDocument2_tid,
5629 IHTMLDocument4_tid,
5630 IHTMLDocument5_tid,
5631 IDocumentSelector_tid,
5635 static void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
5637 HTMLDOMNode_init_dispex_info(info, mode);
5639 if(mode >= COMPAT_MODE_IE9) {
5640 dispex_info_add_interface(info, IHTMLDocument7_tid, NULL);
5641 dispex_info_add_interface(info, IDocumentEvent_tid, NULL);
5644 /* Depending on compatibility version, we add interfaces in different order
5645 * so that the right getElementById implementation is used. */
5646 if(mode < COMPAT_MODE_IE8) {
5647 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5648 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5649 }else {
5650 dispex_info_add_interface(info, IHTMLDocument6_tid, NULL);
5651 dispex_info_add_interface(info, IHTMLDocument3_tid, NULL);
5655 static dispex_static_data_t HTMLDocumentNode_dispex = {
5656 &HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
5657 DispHTMLDocument_tid,
5658 HTMLDocumentNode_iface_tids,
5659 HTMLDocumentNode_init_dispex_info
5662 static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window)
5664 HTMLDocumentNode *doc;
5666 doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
5667 if(!doc)
5668 return NULL;
5670 doc->ref = 1;
5671 doc->basedoc.doc_node = doc;
5672 doc->basedoc.doc_obj = doc_obj;
5673 doc->basedoc.window = window ? window->base.outer_window : NULL;
5674 doc->window = window;
5676 init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
5677 &doc->node.event_target.dispex.IDispatchEx_iface);
5678 HTMLDocumentNode_SecMgr_Init(doc);
5680 list_init(&doc->selection_list);
5681 list_init(&doc->range_list);
5682 list_init(&doc->plugin_hosts);
5684 return doc;
5687 HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
5688 compat_mode_t parent_mode, HTMLDocumentNode **ret)
5690 HTMLDocumentObj *doc_obj = browser->doc;
5691 HTMLDocumentNode *doc;
5693 doc = alloc_doc_node(doc_obj, window);
5694 if(!doc)
5695 return E_OUTOFMEMORY;
5697 if(parent_mode >= COMPAT_MODE_IE9) {
5698 TRACE("using parent mode %u\n", parent_mode);
5699 doc->document_mode = parent_mode;
5700 lock_document_mode(doc);
5703 if(!doc_obj->basedoc.window || (window && is_main_content_window(window->base.outer_window)))
5704 doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
5706 HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc, &HTMLDocumentNode_dispex);
5708 nsIDOMHTMLDocument_AddRef(nsdoc);
5709 doc->nsdoc = nsdoc;
5711 init_document_mutation(doc);
5712 doc_init_events(doc);
5714 doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
5716 list_add_head(&browser->document_nodes, &doc->browser_entry);
5717 doc->browser = browser;
5719 if(browser->usermode == EDITMODE) {
5720 nsAString mode_str;
5721 nsresult nsres;
5723 nsAString_InitDepend(&mode_str, L"on");
5724 nsres = nsIDOMHTMLDocument_SetDesignMode(doc->nsdoc, &mode_str);
5725 nsAString_Finish(&mode_str);
5726 if(NS_FAILED(nsres))
5727 ERR("SetDesignMode failed: %08x\n", nsres);
5730 *ret = doc;
5731 return S_OK;
5734 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret)
5736 HTMLDocumentNode *doc_frag;
5738 doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->window);
5739 if(!doc_frag)
5740 return E_OUTOFMEMORY;
5742 IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
5744 HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
5745 doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
5746 doc_frag->document_mode = lock_document_mode(doc_node);
5748 *ret = doc_frag;
5749 return S_OK;
5752 HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
5754 HTMLDOMNode *node;
5755 HRESULT hres;
5757 hres = get_node((nsIDOMNode*)dom_document, FALSE, &node);
5758 if(FAILED(hres))
5759 return hres;
5761 if(!node) {
5762 ERR("document not initialized\n");
5763 return E_FAIL;
5766 assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
5767 *ret = impl_from_HTMLDOMNode(node);
5768 return S_OK;
5771 static inline HTMLDocumentObj *impl_from_IUnknown(IUnknown *iface)
5773 return CONTAINING_RECORD(iface, HTMLDocumentObj, IUnknown_inner);
5776 static HRESULT WINAPI HTMLDocumentObj_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
5778 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5780 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5782 if(IsEqualGUID(&IID_IUnknown, riid)) {
5783 *ppv = &This->IUnknown_inner;
5784 }else if(htmldoc_qi(&This->basedoc, riid, ppv)) {
5785 return *ppv ? S_OK : E_NOINTERFACE;
5786 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
5787 *ppv = &This->ICustomDoc_iface;
5788 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
5789 *ppv = &This->IOleDocumentView_iface;
5790 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
5791 *ppv = &This->IViewObjectEx_iface;
5792 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
5793 *ppv = &This->IViewObjectEx_iface;
5794 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
5795 *ppv = &This->IViewObjectEx_iface;
5796 }else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
5797 *ppv = &This->ITargetContainer_iface;
5798 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5799 return *ppv ? S_OK : E_NOINTERFACE;
5800 }else {
5801 FIXME("Unimplemented interface %s\n", debugstr_mshtml_guid(riid));
5802 *ppv = NULL;
5803 return E_NOINTERFACE;
5806 IUnknown_AddRef((IUnknown*)*ppv);
5807 return S_OK;
5810 static ULONG WINAPI HTMLDocumentObj_AddRef(IUnknown *iface)
5812 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5813 ULONG ref = InterlockedIncrement(&This->ref);
5815 TRACE("(%p) ref = %u\n", This, ref);
5817 return ref;
5820 static ULONG WINAPI HTMLDocumentObj_Release(IUnknown *iface)
5822 HTMLDocumentObj *This = impl_from_IUnknown(iface);
5823 ULONG ref = InterlockedDecrement(&This->ref);
5825 TRACE("(%p) ref = %u\n", This, ref);
5827 if(!ref) {
5828 if(This->basedoc.doc_node) {
5829 This->basedoc.doc_node->basedoc.doc_obj = NULL;
5830 htmldoc_release(&This->basedoc.doc_node->basedoc);
5832 if(This->basedoc.window)
5833 IHTMLWindow2_Release(&This->basedoc.window->base.IHTMLWindow2_iface);
5834 if(This->advise_holder)
5835 IOleAdviseHolder_Release(This->advise_holder);
5837 if(This->view_sink)
5838 IAdviseSink_Release(This->view_sink);
5839 if(This->client)
5840 IOleObject_SetClientSite(&This->basedoc.IOleObject_iface, NULL);
5841 if(This->hostui)
5842 ICustomDoc_SetUIHandler(&This->ICustomDoc_iface, NULL);
5843 if(This->in_place_active)
5844 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
5845 if(This->ipsite)
5846 IOleDocumentView_SetInPlaceSite(&This->IOleDocumentView_iface, NULL);
5847 if(This->undomgr)
5848 IOleUndoManager_Release(This->undomgr);
5849 if(This->editsvcs)
5850 IHTMLEditServices_Release(This->editsvcs);
5851 if(This->tooltips_hwnd)
5852 DestroyWindow(This->tooltips_hwnd);
5854 if(This->hwnd)
5855 DestroyWindow(This->hwnd);
5856 heap_free(This->mime);
5858 remove_target_tasks(This->task_magic);
5859 ConnectionPointContainer_Destroy(&This->basedoc.cp_container);
5860 release_dispex(&This->dispex);
5862 if(This->nscontainer)
5863 detach_gecko_browser(This->nscontainer);
5864 heap_free(This);
5867 return ref;
5870 static const IUnknownVtbl HTMLDocumentObjVtbl = {
5871 HTMLDocumentObj_QueryInterface,
5872 HTMLDocumentObj_AddRef,
5873 HTMLDocumentObj_Release
5876 /**********************************************************
5877 * ICustomDoc implementation
5880 static inline HTMLDocumentObj *impl_from_ICustomDoc(ICustomDoc *iface)
5882 return CONTAINING_RECORD(iface, HTMLDocumentObj, ICustomDoc_iface);
5885 static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
5887 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5889 return htmldoc_query_interface(&This->basedoc, riid, ppv);
5892 static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
5894 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5896 return htmldoc_addref(&This->basedoc);
5899 static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
5901 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5903 return htmldoc_release(&This->basedoc);
5906 static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
5908 HTMLDocumentObj *This = impl_from_ICustomDoc(iface);
5909 IOleCommandTarget *cmdtrg;
5910 HRESULT hres;
5912 TRACE("(%p)->(%p)\n", This, pUIHandler);
5914 if(This->custom_hostui && This->hostui == pUIHandler)
5915 return S_OK;
5917 This->custom_hostui = TRUE;
5919 if(This->hostui)
5920 IDocHostUIHandler_Release(This->hostui);
5921 if(pUIHandler)
5922 IDocHostUIHandler_AddRef(pUIHandler);
5923 This->hostui = pUIHandler;
5924 if(!pUIHandler)
5925 return S_OK;
5927 hres = IDocHostUIHandler_QueryInterface(pUIHandler, &IID_IOleCommandTarget, (void**)&cmdtrg);
5928 if(SUCCEEDED(hres)) {
5929 FIXME("custom UI handler supports IOleCommandTarget\n");
5930 IOleCommandTarget_Release(cmdtrg);
5933 return S_OK;
5936 static const ICustomDocVtbl CustomDocVtbl = {
5937 CustomDoc_QueryInterface,
5938 CustomDoc_AddRef,
5939 CustomDoc_Release,
5940 CustomDoc_SetUIHandler
5943 static const tid_t HTMLDocumentObj_iface_tids[] = {
5944 IHTMLDocument2_tid,
5945 IHTMLDocument3_tid,
5946 IHTMLDocument4_tid,
5947 IHTMLDocument5_tid,
5950 static dispex_static_data_t HTMLDocumentObj_dispex = {
5951 NULL,
5952 DispHTMLDocument_tid,
5953 HTMLDocumentObj_iface_tids
5956 static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID riid, void **ppv)
5958 HTMLDocumentObj *doc;
5959 HRESULT hres;
5961 if(outer && !IsEqualGUID(&IID_IUnknown, riid)) {
5962 *ppv = NULL;
5963 return E_INVALIDARG;
5966 /* ensure that security manager is initialized */
5967 if(!get_security_manager())
5968 return E_OUTOFMEMORY;
5970 doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
5971 if(!doc)
5972 return E_OUTOFMEMORY;
5974 doc->ref = 1;
5975 doc->IUnknown_inner.lpVtbl = &HTMLDocumentObjVtbl;
5976 doc->ICustomDoc_iface.lpVtbl = &CustomDocVtbl;
5978 doc->basedoc.doc_obj = doc;
5980 init_dispex(&doc->dispex, (IUnknown*)&doc->ICustomDoc_iface, &HTMLDocumentObj_dispex);
5981 init_doc(&doc->basedoc, outer ? outer : &doc->IUnknown_inner, &doc->dispex.IDispatchEx_iface);
5982 TargetContainer_Init(doc);
5983 doc->is_mhtml = is_mhtml;
5985 doc->task_magic = get_task_target_magic();
5987 HTMLDocument_View_Init(doc);
5989 hres = create_gecko_browser(doc, &doc->nscontainer);
5990 if(FAILED(hres)) {
5991 ERR("Failed to init Gecko, returning CLASS_E_CLASSNOTAVAILABLE\n");
5992 htmldoc_release(&doc->basedoc);
5993 return hres;
5996 if(IsEqualGUID(&IID_IUnknown, riid)) {
5997 *ppv = &doc->IUnknown_inner;
5998 }else {
5999 hres = htmldoc_query_interface(&doc->basedoc, riid, ppv);
6000 htmldoc_release(&doc->basedoc);
6001 if(FAILED(hres))
6002 return hres;
6005 doc->basedoc.window = doc->nscontainer->content_window;
6006 IHTMLWindow2_AddRef(&doc->basedoc.window->base.IHTMLWindow2_iface);
6008 if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
6009 doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
6010 htmldoc_addref(&doc->basedoc.doc_node->basedoc);
6013 get_thread_hwnd();
6015 return S_OK;
6018 HRESULT HTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
6020 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
6021 return create_document_object(FALSE, outer, riid, ppv);
6024 HRESULT MHTMLDocument_Create(IUnknown *outer, REFIID riid, void **ppv)
6026 TRACE("(%p %s %p)\n", outer, debugstr_mshtml_guid(riid), ppv);
6027 return create_document_object(TRUE, outer, riid, ppv);