2 * Copyright 2005 Jacek Caban
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
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
35 #include "htmlevent.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
41 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppvObject)
43 HTMLDocument *This = HTMLDOC_THIS(iface);
46 if(IsEqualGUID(&IID_IUnknown, riid)) {
47 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppvObject);
48 *ppvObject = HTMLDOC(This);
49 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
50 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppvObject);
51 *ppvObject = DISPATCHEX(This);
52 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
53 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppvObject);
54 *ppvObject = DISPATCHEX(This);
55 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
56 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppvObject);
57 *ppvObject = HTMLDOC(This);
58 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
59 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppvObject);
60 *ppvObject = HTMLDOC(This);
61 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
62 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppvObject);
63 *ppvObject = HTMLDOC3(This);
64 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
65 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppvObject);
66 *ppvObject = HTMLDOC4(This);
67 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
68 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppvObject);
69 *ppvObject = HTMLDOC5(This);
70 }else if(IsEqualGUID(&IID_IPersist, riid)) {
71 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppvObject);
72 *ppvObject = PERSIST(This);
73 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
74 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppvObject);
75 *ppvObject = PERSISTMON(This);
76 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
77 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppvObject);
78 *ppvObject = PERSISTFILE(This);
79 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
80 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppvObject);
81 *ppvObject = MONPROP(This);
82 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
83 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppvObject);
84 *ppvObject = OLEOBJ(This);
85 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
86 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppvObject);
87 *ppvObject = OLEDOC(This);
88 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
89 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppvObject);
90 *ppvObject = DOCVIEW(This);
91 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
92 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppvObject);
93 *ppvObject = ACTOBJ(This);
94 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
95 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppvObject);
96 *ppvObject = VIEWOBJ(This);
97 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
98 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppvObject);
99 *ppvObject = VIEWOBJ2(This);
100 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
101 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppvObject);
102 *ppvObject = OLEWIN(This);
103 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
104 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppvObject);
105 *ppvObject = INPLACEOBJ(This);
106 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
107 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppvObject);
108 *ppvObject = INPLACEWIN(This);
109 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
110 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppvObject);
111 *ppvObject = SERVPROV(This);
112 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
113 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppvObject);
114 *ppvObject = CMDTARGET(This);
115 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
116 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppvObject);
117 *ppvObject = CONTROL(This);
118 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
119 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppvObject);
120 *ppvObject = HLNKTARGET(This);
121 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
122 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppvObject);
123 *ppvObject = CONPTCONT(&This->cp_container);
124 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
125 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppvObject);
126 *ppvObject = PERSTRINIT(This);
127 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
128 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppvObject);
129 *ppvObject = CUSTOMDOC(This);
130 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
131 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppvObject);
132 *ppvObject = HTMLDOC(This);
133 }else if(IsEqualGUID(&IID_ISupportErrorInfo, riid)) {
134 TRACE("(%p)->(IID_ISupportErrorInfo %p)\n", This, ppvObject);
135 *ppvObject = SUPPERRINFO(This);
136 }else if(IsEqualGUID(&IID_IPersistHistory, riid)) {
137 TRACE("(%p)->(IID_IPersistHistory %p)\n", This, ppvObject);
138 *ppvObject = PERSISTHIST(This);
139 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
140 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppvObject);
141 return E_NOINTERFACE;
142 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
143 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppvObject);
144 return E_NOINTERFACE;
145 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
146 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppvObject);
147 return E_NOINTERFACE;
148 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
149 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppvObject);
150 return E_NOINTERFACE;
151 }else if(dispex_query_interface(&This->dispex, riid, ppvObject)) {
152 return *ppvObject ? S_OK : E_NOINTERFACE;
156 IHTMLDocument2_AddRef(iface);
160 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppvObject);
161 return E_NOINTERFACE;
164 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
166 HTMLDocument *This = HTMLDOC_THIS(iface);
167 ULONG ref = InterlockedIncrement(&This->ref);
168 TRACE("(%p) ref = %u\n", This, ref);
172 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
174 HTMLDocument *This = HTMLDOC_THIS(iface);
175 ULONG ref = InterlockedDecrement(&This->ref);
177 TRACE("(%p) ref = %u\n", This, ref);
180 remove_doc_tasks(This);
181 release_script_hosts(This);
184 IOleObject_SetClientSite(OLEOBJ(This), NULL);
185 if(This->in_place_active)
186 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
188 IOleDocumentView_SetInPlaceSite(DOCVIEW(This), NULL);
190 IOleUndoManager_Release(This->undomgr);
192 set_document_bscallback(This, NULL);
193 set_current_mon(This, NULL);
195 if(This->tooltips_hwnd)
196 DestroyWindow(This->tooltips_hwnd);
198 DestroyWindow(This->hwnd);
200 if(This->option_factory) {
201 This->option_factory->doc = NULL;
202 IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
206 This->location->doc = NULL;
209 IHTMLWindow2_Release(HTMLWINDOW2(This->window));
211 if(This->event_target)
212 release_event_target(This->event_target);
214 heap_free(This->mime);
215 detach_selection(This);
218 release_dispex(&This->dispex);
220 ConnectionPointContainer_Destroy(&This->cp_container);
223 remove_mutation_observer(This->nscontainer, This->nsdoc);
224 nsIDOMHTMLDocument_Release(This->nsdoc);
226 if(This->nscontainer)
227 NSContainer_Release(This->nscontainer);
235 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
237 HTMLDocument *This = HTMLDOC_THIS(iface);
239 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
242 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
243 LCID lcid, ITypeInfo **ppTInfo)
245 HTMLDocument *This = HTMLDOC_THIS(iface);
247 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
250 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
251 LPOLESTR *rgszNames, UINT cNames,
252 LCID lcid, DISPID *rgDispId)
254 HTMLDocument *This = HTMLDOC_THIS(iface);
256 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
259 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
260 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
261 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
263 HTMLDocument *This = HTMLDOC_THIS(iface);
265 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
266 pVarResult, pExcepInfo, puArgErr);
269 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
271 HTMLDocument *This = HTMLDOC_THIS(iface);
273 TRACE("(%p)->(%p)\n", This, p);
275 *p = (IDispatch*)HTMLWINDOW2(This->window);
276 IDispatch_AddRef(*p);
280 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
282 HTMLDocument *This = HTMLDOC_THIS(iface);
283 nsIDOMElement *nselem = NULL;
286 TRACE("(%p)->(%p)\n", This, p);
289 WARN("NULL nsdoc\n");
293 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
294 if(NS_FAILED(nsres)) {
295 ERR("GetDocumentElement failed: %08x\n", nsres);
300 *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE), TRUE);
301 nsIDOMElement_Release(nselem);
309 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
311 HTMLDocument *This = HTMLDOC_THIS(iface);
312 nsIDOMHTMLElement *nsbody = NULL;
316 TRACE("(%p)->(%p)\n", This, p);
319 WARN("NULL nsdoc\n");
323 nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody);
324 if(NS_FAILED(nsres)) {
325 TRACE("Could not get body: %08x\n", nsres);
330 node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
331 nsIDOMHTMLElement_Release(nsbody);
333 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
338 TRACE("*p = %p\n", *p);
342 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
344 HTMLDocument *This = HTMLDOC_THIS(iface);
345 FIXME("(%p)->(%p)\n", This, p);
349 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
351 HTMLDocument *This = HTMLDOC_THIS(iface);
352 nsIDOMHTMLCollection *nscoll = NULL;
355 TRACE("(%p)->(%p)\n", This, p);
363 WARN("NULL nsdoc\n");
367 nsres = nsIDOMHTMLDocument_GetImages(This->nsdoc, &nscoll);
368 if(NS_FAILED(nsres)) {
369 ERR("GetImages failed: %08x\n", nsres);
374 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
375 nsIDOMElement_Release(nscoll);
381 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
383 HTMLDocument *This = HTMLDOC_THIS(iface);
384 nsIDOMHTMLCollection *nscoll = NULL;
387 TRACE("(%p)->(%p)\n", This, p);
395 WARN("NULL nsdoc\n");
399 nsres = nsIDOMHTMLDocument_GetApplets(This->nsdoc, &nscoll);
400 if(NS_FAILED(nsres)) {
401 ERR("GetApplets failed: %08x\n", nsres);
406 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
407 nsIDOMElement_Release(nscoll);
413 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
415 HTMLDocument *This = HTMLDOC_THIS(iface);
416 nsIDOMHTMLCollection *nscoll = NULL;
419 TRACE("(%p)->(%p)\n", This, p);
427 WARN("NULL nsdoc\n");
431 nsres = nsIDOMHTMLDocument_GetLinks(This->nsdoc, &nscoll);
432 if(NS_FAILED(nsres)) {
433 ERR("GetLinks failed: %08x\n", nsres);
438 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
439 nsIDOMElement_Release(nscoll);
445 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
447 HTMLDocument *This = HTMLDOC_THIS(iface);
448 nsIDOMHTMLCollection *nscoll = NULL;
451 TRACE("(%p)->(%p)\n", This, p);
459 WARN("NULL nsdoc\n");
463 nsres = nsIDOMHTMLDocument_GetForms(This->nsdoc, &nscoll);
464 if(NS_FAILED(nsres)) {
465 ERR("GetForms failed: %08x\n", nsres);
470 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
471 nsIDOMElement_Release(nscoll);
477 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
479 HTMLDocument *This = HTMLDOC_THIS(iface);
480 nsIDOMHTMLCollection *nscoll = NULL;
483 TRACE("(%p)->(%p)\n", This, p);
491 WARN("NULL nsdoc\n");
495 nsres = nsIDOMHTMLDocument_GetAnchors(This->nsdoc, &nscoll);
496 if(NS_FAILED(nsres)) {
497 ERR("GetAnchors failed: %08x\n", nsres);
502 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
503 nsIDOMElement_Release(nscoll);
509 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
511 HTMLDocument *This = HTMLDOC_THIS(iface);
515 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
518 WARN("NULL nsdoc\n");
522 nsAString_Init(&nsstr, v);
523 nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr);
524 nsAString_Finish(&nsstr);
526 ERR("SetTitle failed: %08x\n", nsres);
531 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
533 HTMLDocument *This = HTMLDOC_THIS(iface);
534 const PRUnichar *ret;
538 TRACE("(%p)->(%p)\n", This, p);
541 WARN("NULL nsdoc\n");
546 nsAString_Init(&nsstr, NULL);
547 nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
548 if (NS_SUCCEEDED(nsres)) {
549 nsAString_GetData(&nsstr, &ret);
550 *p = SysAllocString(ret);
552 nsAString_Finish(&nsstr);
554 if(NS_FAILED(nsres)) {
555 ERR("GetTitle failed: %08x\n", nsres);
562 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
564 HTMLDocument *This = HTMLDOC_THIS(iface);
565 FIXME("(%p)->(%p)\n", This, p);
569 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
571 HTMLDocument *This = HTMLDOC_THIS(iface);
572 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
576 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
578 HTMLDocument *This = HTMLDOC_THIS(iface);
579 static WCHAR szOff[] = {'O','f','f',0};
580 FIXME("(%p)->(%p) always returning Off\n", This, p);
585 *p = SysAllocString(szOff);
590 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
592 HTMLDocument *This = HTMLDOC_THIS(iface);
593 nsISelection *nsselection = NULL;
595 TRACE("(%p)->(%p)\n", This, p);
597 if(This->nscontainer) {
598 nsIDOMWindow *dom_window = NULL;
600 nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
602 nsIDOMWindow_GetSelection(dom_window, &nsselection);
603 nsIDOMWindow_Release(dom_window);
607 *p = HTMLSelectionObject_Create(This, nsselection);
611 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
613 HTMLDocument *This = HTMLDOC_THIS(iface);
615 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
616 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
617 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
618 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
619 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
621 static const LPCWSTR readystate_str[] = {
629 TRACE("(%p)->(%p)\n", iface, p);
634 *p = SysAllocString(readystate_str[This->readystate]);
638 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
640 HTMLDocument *This = HTMLDOC_THIS(iface);
641 FIXME("(%p)->(%p)\n", This, p);
645 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
647 HTMLDocument *This = HTMLDOC_THIS(iface);
648 FIXME("(%p)->(%p)\n", This, p);
652 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
654 HTMLDocument *This = HTMLDOC_THIS(iface);
655 FIXME("(%p)->(%p)\n", This, p);
659 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
661 HTMLDocument *This = HTMLDOC_THIS(iface);
662 FIXME("(%p)\n", This);
666 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
668 HTMLDocument *This = HTMLDOC_THIS(iface);
669 FIXME("(%p)->(%p)\n", This, p);
673 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
675 HTMLDocument *This = HTMLDOC_THIS(iface);
676 FIXME("(%p)\n", This);
680 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
682 HTMLDocument *This = HTMLDOC_THIS(iface);
683 FIXME("(%p)->(%p)\n", This, p);
687 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
689 HTMLDocument *This = HTMLDOC_THIS(iface);
690 FIXME("(%p)\n", This);
694 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
696 HTMLDocument *This = HTMLDOC_THIS(iface);
697 FIXME("(%p)->(%p)\n", This, p);
701 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
703 HTMLDocument *This = HTMLDOC_THIS(iface);
704 FIXME("(%p)->()\n", This);
708 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
710 HTMLDocument *This = HTMLDOC_THIS(iface);
711 FIXME("(%p)->(%p)\n", This, p);
715 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
717 HTMLDocument *This = HTMLDOC_THIS(iface);
718 FIXME("(%p)\n", This);
722 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
724 HTMLDocument *This = HTMLDOC_THIS(iface);
725 FIXME("(%p)->(%p)\n", This, p);
729 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
731 HTMLDocument *This = HTMLDOC_THIS(iface);
732 FIXME("(%p)->(%p)\n", This, p);
736 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
738 HTMLDocument *This = HTMLDOC_THIS(iface);
740 TRACE("(%p)->(%p)\n", This, p);
743 IHTMLLocation_AddRef(HTMLLOCATION(This->location));
745 This->location = HTMLLocation_Create(This);
747 *p = HTMLLOCATION(This->location);
751 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
753 HTMLDocument *This = HTMLDOC_THIS(iface);
754 FIXME("(%p)->(%p)\n", This, p);
758 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
760 HTMLDocument *This = HTMLDOC_THIS(iface);
761 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
765 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
767 HTMLDocument *This = HTMLDOC_THIS(iface);
769 static const WCHAR about_blank_url[] =
770 {'a','b','o','u','t',':','b','l','a','n','k',0};
772 TRACE("(%p)->(%p)\n", iface, p);
774 *p = SysAllocString(This->url ? This->url : about_blank_url);
778 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
780 HTMLDocument *This = HTMLDOC_THIS(iface);
781 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
785 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
787 HTMLDocument *This = HTMLDOC_THIS(iface);
788 FIXME("(%p)->(%p)\n", This, p);
792 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
794 HTMLDocument *This = HTMLDOC_THIS(iface);
795 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
799 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
801 HTMLDocument *This = HTMLDOC_THIS(iface);
802 FIXME("(%p)->(%p)\n", This, p);
806 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
808 HTMLDocument *This = HTMLDOC_THIS(iface);
809 FIXME("(%p)->(%x)\n", This, v);
813 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
815 HTMLDocument *This = HTMLDOC_THIS(iface);
816 FIXME("(%p)->(%p)\n", This, p);
820 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
822 HTMLDocument *This = HTMLDOC_THIS(iface);
823 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
827 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
829 HTMLDocument *This = HTMLDOC_THIS(iface);
830 FIXME("(%p)->(%p)\n", This, p);
834 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
836 HTMLDocument *This = HTMLDOC_THIS(iface);
837 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
841 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
843 HTMLDocument *This = HTMLDOC_THIS(iface);
844 FIXME("(%p)->(%p)\n", This, p);
848 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
850 HTMLDocument *This = HTMLDOC_THIS(iface);
851 FIXME("(%p)->(%p)\n", This, p);
855 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
857 HTMLDocument *This = HTMLDOC_THIS(iface);
858 FIXME("(%p)->(%p)\n", This, p);
862 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
864 HTMLDocument *This = HTMLDOC_THIS(iface);
865 FIXME("(%p)->(%p)\n", This, p);
869 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
871 HTMLDocument *This = HTMLDOC_THIS(iface);
872 FIXME("(%p)->(%p)\n", This, p);
876 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
878 HTMLDocument *This = HTMLDOC_THIS(iface);
879 FIXME("(%p)->(%p)\n", This, p);
883 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
885 HTMLDocument *This = HTMLDOC_THIS(iface);
886 FIXME("(%p)->(%p)\n", This, p);
890 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
892 HTMLDocument *This = HTMLDOC_THIS(iface);
893 FIXME("(%p)->(%p)\n", This, p);
897 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
899 HTMLDocument *This = HTMLDOC_THIS(iface);
900 FIXME("(%p)->(%p)\n", This, p);
904 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
913 WARN("NULL nsdoc\n");
917 if(psarray->cDims != 1) {
918 FIXME("cDims=%d\n", psarray->cDims);
922 hres = SafeArrayAccessData(psarray, (void**)&var);
924 WARN("SafeArrayAccessData failed: %08x\n", hres);
928 nsAString_Init(&nsstr, NULL);
930 argc = psarray->rgsabound[0].cElements;
931 for(i=0; i < argc; i++) {
932 if(V_VT(var+i) == VT_BSTR) {
933 nsAString_SetData(&nsstr, V_BSTR(var+i));
934 if(!ln || i != argc-1)
935 nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
937 nsres = nsIDOMHTMLDocument_Writeln(This->nsdoc, &nsstr);
939 ERR("Write failed: %08x\n", nsres);
941 FIXME("vt=%d\n", V_VT(var+i));
945 nsAString_Finish(&nsstr);
946 SafeArrayUnaccessData(psarray);
951 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
953 HTMLDocument *This = HTMLDOC_THIS(iface);
955 TRACE("(%p)->(%p)\n", iface, psarray);
957 return document_write(This, psarray, FALSE);
960 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
962 HTMLDocument *This = HTMLDOC_THIS(iface);
964 TRACE("(%p)->(%p)\n", This, psarray);
966 return document_write(This, psarray, TRUE);
969 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
970 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
972 HTMLDocument *This = HTMLDOC_THIS(iface);
975 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
977 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
978 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
985 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
986 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
987 FIXME("unsupported args\n");
989 nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
990 if(NS_FAILED(nsres)) {
991 ERR("Open failed: %08x\n", nsres);
995 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
996 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
1000 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1002 HTMLDocument *This = HTMLDOC_THIS(iface);
1005 TRACE("(%p)\n", This);
1012 nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
1013 if(NS_FAILED(nsres)) {
1014 ERR("Close failed: %08x\n", nsres);
1021 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1023 HTMLDocument *This = HTMLDOC_THIS(iface);
1024 FIXME("(%p)\n", This);
1028 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1029 VARIANT_BOOL *pfRet)
1031 HTMLDocument *This = HTMLDOC_THIS(iface);
1032 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1036 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1037 VARIANT_BOOL *pfRet)
1039 HTMLDocument *This = HTMLDOC_THIS(iface);
1040 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1044 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1045 VARIANT_BOOL *pfRet)
1047 HTMLDocument *This = HTMLDOC_THIS(iface);
1048 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1052 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1053 VARIANT_BOOL *pfRet)
1055 HTMLDocument *This = HTMLDOC_THIS(iface);
1056 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1060 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1063 HTMLDocument *This = HTMLDOC_THIS(iface);
1064 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1068 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1071 HTMLDocument *This = HTMLDOC_THIS(iface);
1072 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1076 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1077 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1079 HTMLDocument *This = HTMLDOC_THIS(iface);
1080 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
1084 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1085 VARIANT_BOOL *pfRet)
1087 HTMLDocument *This = HTMLDOC_THIS(iface);
1088 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1092 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1093 IHTMLElement **newElem)
1095 HTMLDocument *This = HTMLDOC_THIS(iface);
1096 nsIDOMElement *nselem;
1101 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1104 WARN("NULL nsdoc\n");
1105 return E_UNEXPECTED;
1108 nsAString_Init(&tag_str, eTag);
1109 nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
1110 nsAString_Finish(&tag_str);
1111 if(NS_FAILED(nsres)) {
1112 ERR("CreateElement failed: %08x\n", nsres);
1116 elem = HTMLElement_Create(This, (nsIDOMNode*)nselem, TRUE);
1117 nsIDOMElement_Release(nselem);
1119 *newElem = HTMLELEM(elem);
1120 IHTMLElement_AddRef(HTMLELEM(elem));
1124 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1126 HTMLDocument *This = HTMLDOC_THIS(iface);
1127 FIXME("(%p)\n", This);
1131 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1133 HTMLDocument *This = HTMLDOC_THIS(iface);
1134 FIXME("(%p)->(%p)\n", This, p);
1138 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1140 HTMLDocument *This = HTMLDOC_THIS(iface);
1141 FIXME("(%p)\n", This);
1145 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1147 HTMLDocument *This = HTMLDOC_THIS(iface);
1148 FIXME("(%p)->(%p)\n", This, p);
1152 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1154 HTMLDocument *This = HTMLDOC_THIS(iface);
1155 FIXME("(%p)\n", This);
1159 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1161 HTMLDocument *This = HTMLDOC_THIS(iface);
1162 FIXME("(%p)->(%p)\n", This, p);
1166 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1168 HTMLDocument *This = HTMLDOC_THIS(iface);
1170 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1172 return set_doc_event(This, EVENTID_KEYUP, &v);
1175 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1177 HTMLDocument *This = HTMLDOC_THIS(iface);
1179 TRACE("(%p)->(%p)\n", This, p);
1181 return get_doc_event(This, EVENTID_KEYUP, p);
1184 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1186 HTMLDocument *This = HTMLDOC_THIS(iface);
1188 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1190 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1193 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1195 HTMLDocument *This = HTMLDOC_THIS(iface);
1197 TRACE("(%p)->(%p)\n", This, p);
1199 return get_doc_event(This, EVENTID_KEYDOWN, p);
1202 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1204 HTMLDocument *This = HTMLDOC_THIS(iface);
1205 FIXME("(%p)\n", This);
1209 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1211 HTMLDocument *This = HTMLDOC_THIS(iface);
1212 FIXME("(%p)->(%p)\n", This, p);
1216 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1218 HTMLDocument *This = HTMLDOC_THIS(iface);
1219 FIXME("(%p)\n", This);
1223 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1225 HTMLDocument *This = HTMLDOC_THIS(iface);
1226 FIXME("(%p)->(%p)\n", This, p);
1230 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1232 HTMLDocument *This = HTMLDOC_THIS(iface);
1233 FIXME("(%p)\n", This);
1237 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1239 HTMLDocument *This = HTMLDOC_THIS(iface);
1240 FIXME("(%p)->(%p)\n", This, p);
1244 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1246 HTMLDocument *This = HTMLDOC_THIS(iface);
1247 FIXME("(%p)\n", This);
1251 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1253 HTMLDocument *This = HTMLDOC_THIS(iface);
1254 FIXME("(%p)->(%p)\n", This, p);
1258 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1260 HTMLDocument *This = HTMLDOC_THIS(iface);
1261 FIXME("(%p)\n", This);
1265 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1267 HTMLDocument *This = HTMLDOC_THIS(iface);
1268 FIXME("(%p)->(%p)\n", This, p);
1272 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1274 HTMLDocument *This = HTMLDOC_THIS(iface);
1276 TRACE("(%p)\n", This);
1278 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1281 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1283 HTMLDocument *This = HTMLDOC_THIS(iface);
1285 TRACE("(%p)->(%p)\n", This, p);
1287 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1290 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1292 HTMLDocument *This = HTMLDOC_THIS(iface);
1293 FIXME("(%p)\n", This);
1297 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1299 HTMLDocument *This = HTMLDOC_THIS(iface);
1300 FIXME("(%p)->(%p)\n", This, p);
1304 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1306 HTMLDocument *This = HTMLDOC_THIS(iface);
1307 FIXME("(%p)\n", This);
1311 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1313 HTMLDocument *This = HTMLDOC_THIS(iface);
1314 FIXME("(%p)->(%p)\n", This, p);
1318 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1320 HTMLDocument *This = HTMLDOC_THIS(iface);
1321 FIXME("(%p)\n", This);
1325 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1327 HTMLDocument *This = HTMLDOC_THIS(iface);
1328 FIXME("(%p)->(%p)\n", This, p);
1332 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1334 HTMLDocument *This = HTMLDOC_THIS(iface);
1335 FIXME("(%p)\n", This);
1339 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1341 HTMLDocument *This = HTMLDOC_THIS(iface);
1342 FIXME("(%p)->(%p)\n", This, p);
1346 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1348 HTMLDocument *This = HTMLDOC_THIS(iface);
1350 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1352 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1355 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1357 HTMLDocument *This = HTMLDOC_THIS(iface);
1359 TRACE("(%p)->(%p)\n", This, p);
1361 return get_doc_event(This, EVENTID_DRAGSTART, p);
1364 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1366 HTMLDocument *This = HTMLDOC_THIS(iface);
1368 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1370 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1373 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1375 HTMLDocument *This = HTMLDOC_THIS(iface);
1377 TRACE("(%p)->(%p)\n", This, p);
1379 return get_doc_event(This, EVENTID_SELECTSTART, p);
1382 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1383 IHTMLElement **elementHit)
1385 HTMLDocument *This = HTMLDOC_THIS(iface);
1386 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1390 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1392 HTMLDocument *This = HTMLDOC_THIS(iface);
1394 TRACE("(%p)->(%p)\n", This, p);
1396 *p = HTMLWINDOW2(This->window);
1397 IHTMLWindow2_AddRef(*p);
1401 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1402 IHTMLStyleSheetsCollection **p)
1404 HTMLDocument *This = HTMLDOC_THIS(iface);
1405 nsIDOMStyleSheetList *nsstylelist;
1406 nsIDOMDocumentStyle *nsdocstyle;
1409 TRACE("(%p)->(%p)\n", This, p);
1414 WARN("NULL nsdoc\n");
1415 return E_UNEXPECTED;
1418 nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1419 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1420 nsIDOMDocumentStyle_Release(nsdocstyle);
1421 if(NS_FAILED(nsres)) {
1422 ERR("GetStyleSheets failed: %08x\n", nsres);
1426 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1427 nsIDOMDocumentStyle_Release(nsstylelist);
1432 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1434 HTMLDocument *This = HTMLDOC_THIS(iface);
1435 FIXME("(%p)\n", This);
1439 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1441 HTMLDocument *This = HTMLDOC_THIS(iface);
1442 FIXME("(%p)->(%p)\n", This, p);
1446 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1448 HTMLDocument *This = HTMLDOC_THIS(iface);
1449 FIXME("(%p)\n", This);
1453 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1455 HTMLDocument *This = HTMLDOC_THIS(iface);
1456 FIXME("(%p)->(%p)\n", This, p);
1460 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1462 HTMLDocument *This = HTMLDOC_THIS(iface);
1463 FIXME("(%p)->(%p)\n", This, String);
1467 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1468 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1470 HTMLDocument *This = HTMLDOC_THIS(iface);
1472 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1474 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1478 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1479 HTMLDocument_QueryInterface,
1480 HTMLDocument_AddRef,
1481 HTMLDocument_Release,
1482 HTMLDocument_GetTypeInfoCount,
1483 HTMLDocument_GetTypeInfo,
1484 HTMLDocument_GetIDsOfNames,
1485 HTMLDocument_Invoke,
1486 HTMLDocument_get_Script,
1487 HTMLDocument_get_all,
1488 HTMLDocument_get_body,
1489 HTMLDocument_get_activeElement,
1490 HTMLDocument_get_images,
1491 HTMLDocument_get_applets,
1492 HTMLDocument_get_links,
1493 HTMLDocument_get_forms,
1494 HTMLDocument_get_anchors,
1495 HTMLDocument_put_title,
1496 HTMLDocument_get_title,
1497 HTMLDocument_get_scripts,
1498 HTMLDocument_put_designMode,
1499 HTMLDocument_get_designMode,
1500 HTMLDocument_get_selection,
1501 HTMLDocument_get_readyState,
1502 HTMLDocument_get_frames,
1503 HTMLDocument_get_embeds,
1504 HTMLDocument_get_plugins,
1505 HTMLDocument_put_alinkColor,
1506 HTMLDocument_get_alinkColor,
1507 HTMLDocument_put_bgColor,
1508 HTMLDocument_get_bgColor,
1509 HTMLDocument_put_fgColor,
1510 HTMLDocument_get_fgColor,
1511 HTMLDocument_put_linkColor,
1512 HTMLDocument_get_linkColor,
1513 HTMLDocument_put_vlinkColor,
1514 HTMLDocument_get_vlinkColor,
1515 HTMLDocument_get_referrer,
1516 HTMLDocument_get_location,
1517 HTMLDocument_get_lastModified,
1518 HTMLDocument_put_URL,
1519 HTMLDocument_get_URL,
1520 HTMLDocument_put_domain,
1521 HTMLDocument_get_domain,
1522 HTMLDocument_put_cookie,
1523 HTMLDocument_get_cookie,
1524 HTMLDocument_put_expando,
1525 HTMLDocument_get_expando,
1526 HTMLDocument_put_charset,
1527 HTMLDocument_get_charset,
1528 HTMLDocument_put_defaultCharset,
1529 HTMLDocument_get_defaultCharset,
1530 HTMLDocument_get_mimeType,
1531 HTMLDocument_get_fileSize,
1532 HTMLDocument_get_fileCreatedDate,
1533 HTMLDocument_get_fileModifiedDate,
1534 HTMLDocument_get_fileUpdatedDate,
1535 HTMLDocument_get_security,
1536 HTMLDocument_get_protocol,
1537 HTMLDocument_get_nameProp,
1539 HTMLDocument_writeln,
1543 HTMLDocument_queryCommandSupported,
1544 HTMLDocument_queryCommandEnabled,
1545 HTMLDocument_queryCommandState,
1546 HTMLDocument_queryCommandIndeterm,
1547 HTMLDocument_queryCommandText,
1548 HTMLDocument_queryCommandValue,
1549 HTMLDocument_execCommand,
1550 HTMLDocument_execCommandShowHelp,
1551 HTMLDocument_createElement,
1552 HTMLDocument_put_onhelp,
1553 HTMLDocument_get_onhelp,
1554 HTMLDocument_put_onclick,
1555 HTMLDocument_get_onclick,
1556 HTMLDocument_put_ondblclick,
1557 HTMLDocument_get_ondblclick,
1558 HTMLDocument_put_onkeyup,
1559 HTMLDocument_get_onkeyup,
1560 HTMLDocument_put_onkeydown,
1561 HTMLDocument_get_onkeydown,
1562 HTMLDocument_put_onkeypress,
1563 HTMLDocument_get_onkeypress,
1564 HTMLDocument_put_onmouseup,
1565 HTMLDocument_get_onmouseup,
1566 HTMLDocument_put_onmousedown,
1567 HTMLDocument_get_onmousedown,
1568 HTMLDocument_put_onmousemove,
1569 HTMLDocument_get_onmousemove,
1570 HTMLDocument_put_onmouseout,
1571 HTMLDocument_get_onmouseout,
1572 HTMLDocument_put_onmouseover,
1573 HTMLDocument_get_onmouseover,
1574 HTMLDocument_put_onreadystatechange,
1575 HTMLDocument_get_onreadystatechange,
1576 HTMLDocument_put_onafterupdate,
1577 HTMLDocument_get_onafterupdate,
1578 HTMLDocument_put_onrowexit,
1579 HTMLDocument_get_onrowexit,
1580 HTMLDocument_put_onrowenter,
1581 HTMLDocument_get_onrowenter,
1582 HTMLDocument_put_ondragstart,
1583 HTMLDocument_get_ondragstart,
1584 HTMLDocument_put_onselectstart,
1585 HTMLDocument_get_onselectstart,
1586 HTMLDocument_elementFromPoint,
1587 HTMLDocument_get_parentWindow,
1588 HTMLDocument_get_styleSheets,
1589 HTMLDocument_put_onbeforeupdate,
1590 HTMLDocument_get_onbeforeupdate,
1591 HTMLDocument_put_onerrorupdate,
1592 HTMLDocument_get_onerrorupdate,
1593 HTMLDocument_toString,
1594 HTMLDocument_createStyleSheet
1597 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1599 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1601 HTMLDocument *This = SUPPINFO_THIS(iface);
1602 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1605 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1607 HTMLDocument *This = SUPPINFO_THIS(iface);
1608 return IHTMLDocument_AddRef(HTMLDOC(This));
1611 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1613 HTMLDocument *This = SUPPINFO_THIS(iface);
1614 return IHTMLDocument_Release(HTMLDOC(This));
1617 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1619 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1623 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1624 SupportErrorInfo_QueryInterface,
1625 SupportErrorInfo_AddRef,
1626 SupportErrorInfo_Release,
1627 SupportErrorInfo_InterfaceSupportsErrorInfo
1630 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1632 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1634 HTMLDocument *This = DISPEX_THIS(iface);
1636 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1639 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1641 HTMLDocument *This = DISPEX_THIS(iface);
1643 return IHTMLDocument2_AddRef(HTMLDOC(This));
1646 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1648 HTMLDocument *This = DISPEX_THIS(iface);
1650 return IHTMLDocument2_Release(HTMLDOC(This));
1653 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1655 HTMLDocument *This = DISPEX_THIS(iface);
1657 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1660 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1661 LCID lcid, ITypeInfo **ppTInfo)
1663 HTMLDocument *This = DISPEX_THIS(iface);
1665 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1668 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1669 LPOLESTR *rgszNames, UINT cNames,
1670 LCID lcid, DISPID *rgDispId)
1672 HTMLDocument *This = DISPEX_THIS(iface);
1674 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1677 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1678 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1679 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1681 HTMLDocument *This = DISPEX_THIS(iface);
1683 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1684 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1686 switch(dispIdMember) {
1687 case DISPID_READYSTATE:
1688 TRACE("DISPID_READYSTATE\n");
1690 if(!(wFlags & DISPATCH_PROPERTYGET))
1691 return E_INVALIDARG;
1693 V_VT(pVarResult) = VT_I4;
1694 V_I4(pVarResult) = This->readystate;
1698 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1699 pVarResult, pExcepInfo, puArgErr);
1702 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1704 HTMLDocument *This = DISPEX_THIS(iface);
1706 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1709 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1710 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1712 HTMLDocument *This = DISPEX_THIS(iface);
1714 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1717 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1719 HTMLDocument *This = DISPEX_THIS(iface);
1721 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1724 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1726 HTMLDocument *This = DISPEX_THIS(iface);
1728 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1731 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1733 HTMLDocument *This = DISPEX_THIS(iface);
1735 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1738 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1740 HTMLDocument *This = DISPEX_THIS(iface);
1742 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1745 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1747 HTMLDocument *This = DISPEX_THIS(iface);
1749 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1752 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1754 HTMLDocument *This = DISPEX_THIS(iface);
1756 return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1761 static const IDispatchExVtbl DocDispatchExVtbl = {
1762 DocDispatchEx_QueryInterface,
1763 DocDispatchEx_AddRef,
1764 DocDispatchEx_Release,
1765 DocDispatchEx_GetTypeInfoCount,
1766 DocDispatchEx_GetTypeInfo,
1767 DocDispatchEx_GetIDsOfNames,
1768 DocDispatchEx_Invoke,
1769 DocDispatchEx_GetDispID,
1770 DocDispatchEx_InvokeEx,
1771 DocDispatchEx_DeleteMemberByName,
1772 DocDispatchEx_DeleteMemberByDispID,
1773 DocDispatchEx_GetMemberProperties,
1774 DocDispatchEx_GetMemberName,
1775 DocDispatchEx_GetNextDispID,
1776 DocDispatchEx_GetNameSpaceParent
1779 static const tid_t HTMLDocument_iface_tids[] = {
1786 static dispex_static_data_t HTMLDocument_dispex = {
1788 DispHTMLDocument_tid,
1790 HTMLDocument_iface_tids
1793 static HRESULT alloc_doc(HTMLDocument **ret)
1797 doc = heap_alloc_zero(sizeof(HTMLDocument));
1798 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1799 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1800 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1802 doc->readystate = READYSTATE_UNINITIALIZED;
1803 doc->scriptmode = SCRIPTMODE_GECKO;
1805 list_init(&doc->bindings);
1806 list_init(&doc->script_hosts);
1807 list_init(&doc->selection_list);
1808 list_init(&doc->range_list);
1810 HTMLDocument_HTMLDocument3_Init(doc);
1811 HTMLDocument_HTMLDocument5_Init(doc);
1812 HTMLDocument_Persist_Init(doc);
1813 HTMLDocument_OleCmd_Init(doc);
1814 HTMLDocument_OleObj_Init(doc);
1815 HTMLDocument_View_Init(doc);
1816 HTMLDocument_Window_Init(doc);
1817 HTMLDocument_Service_Init(doc);
1818 HTMLDocument_Hlink_Init(doc);
1820 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1821 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
1822 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
1823 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
1825 init_dispex(&doc->dispex, (IUnknown*)HTMLDOC(doc), &HTMLDocument_dispex);
1831 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocument **ret)
1836 hres = alloc_doc(&doc);
1840 nsIDOMHTMLDocument_AddRef(nsdoc);
1843 hres = HTMLWindow_Create(doc, NULL, &doc->window);
1845 IHTMLDocument_Release(HTMLDOC(doc));
1853 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1856 nsIDOMWindow *nswindow = NULL;
1859 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1861 hres = alloc_doc(&doc);
1865 hres = IHTMLDocument_QueryInterface(HTMLDOC(doc), riid, ppvObject);
1866 IHTMLDocument_Release(HTMLDOC(doc));
1870 doc->nscontainer = NSContainer_Create(doc, NULL);
1871 update_nsdocument(doc);
1873 if(doc->nscontainer) {
1876 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
1877 if(NS_FAILED(nsres))
1878 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1881 hres = HTMLWindow_Create(doc, nswindow, &doc->window);
1883 nsIDOMWindow_Release(nswindow);
1885 IHTMLDocument_Release(HTMLDOC(doc));