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
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
34 #include "htmlevent.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
40 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppvObject)
42 HTMLDocument *This = HTMLDOC_THIS(iface);
45 if(IsEqualGUID(&IID_IUnknown, riid)) {
46 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppvObject);
47 *ppvObject = HTMLDOC(This);
48 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
49 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppvObject);
50 *ppvObject = DISPATCHEX(This);
51 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
52 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppvObject);
53 *ppvObject = DISPATCHEX(This);
54 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
55 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppvObject);
56 *ppvObject = HTMLDOC(This);
57 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
58 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppvObject);
59 *ppvObject = HTMLDOC(This);
60 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
61 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppvObject);
62 *ppvObject = HTMLDOC3(This);
63 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
64 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppvObject);
65 *ppvObject = HTMLDOC4(This);
66 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
67 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppvObject);
68 *ppvObject = HTMLDOC5(This);
69 }else if(IsEqualGUID(&IID_IPersist, riid)) {
70 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppvObject);
71 *ppvObject = PERSIST(This);
72 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
73 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppvObject);
74 *ppvObject = PERSISTMON(This);
75 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
76 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppvObject);
77 *ppvObject = PERSISTFILE(This);
78 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
79 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppvObject);
80 *ppvObject = MONPROP(This);
81 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
82 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppvObject);
83 *ppvObject = OLEOBJ(This);
84 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
85 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppvObject);
86 *ppvObject = OLEDOC(This);
87 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
88 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppvObject);
89 *ppvObject = DOCVIEW(This);
90 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
91 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppvObject);
92 *ppvObject = ACTOBJ(This);
93 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
94 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppvObject);
95 *ppvObject = VIEWOBJ(This);
96 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
97 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppvObject);
98 *ppvObject = VIEWOBJ2(This);
99 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
100 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppvObject);
101 *ppvObject = OLEWIN(This);
102 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
103 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppvObject);
104 *ppvObject = INPLACEOBJ(This);
105 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
106 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppvObject);
107 *ppvObject = INPLACEWIN(This);
108 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
109 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppvObject);
110 *ppvObject = SERVPROV(This);
111 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
112 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppvObject);
113 *ppvObject = CMDTARGET(This);
114 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
115 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppvObject);
116 *ppvObject = CONTROL(This);
117 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
118 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppvObject);
119 *ppvObject = HLNKTARGET(This);
120 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
121 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppvObject);
122 *ppvObject = CONPTCONT(&This->cp_container);
123 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
124 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppvObject);
125 *ppvObject = PERSTRINIT(This);
126 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
127 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppvObject);
128 *ppvObject = CUSTOMDOC(This);
129 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
130 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppvObject);
131 *ppvObject = HTMLDOC(This);
132 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
133 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppvObject);
134 return E_NOINTERFACE;
135 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
136 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppvObject);
137 return E_NOINTERFACE;
138 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
139 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppvObject);
140 return E_NOINTERFACE;
141 }else if(dispex_query_interface(&This->dispex, riid, ppvObject)) {
142 return *ppvObject ? S_OK : E_NOINTERFACE;
146 IHTMLDocument2_AddRef(iface);
150 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppvObject);
151 return E_NOINTERFACE;
154 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
156 HTMLDocument *This = HTMLDOC_THIS(iface);
157 ULONG ref = InterlockedIncrement(&This->ref);
158 TRACE("(%p) ref = %u\n", This, ref);
162 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
164 HTMLDocument *This = HTMLDOC_THIS(iface);
165 ULONG ref = InterlockedDecrement(&This->ref);
167 TRACE("(%p) ref = %u\n", This, ref);
170 remove_doc_tasks(This);
171 release_script_hosts(This);
174 IOleObject_SetClientSite(OLEOBJ(This), NULL);
175 if(This->in_place_active)
176 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
178 IOleDocumentView_SetInPlaceSite(DOCVIEW(This), NULL);
180 IOleUndoManager_Release(This->undomgr);
182 set_document_bscallback(This, NULL);
183 set_current_mon(This, NULL);
185 if(This->tooltips_hwnd)
186 DestroyWindow(This->tooltips_hwnd);
188 DestroyWindow(This->hwnd);
190 if(This->option_factory) {
191 This->option_factory->doc = NULL;
192 IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
196 This->location->doc = NULL;
199 IHTMLWindow2_Release(HTMLWINDOW2(This->window));
201 if(This->event_target)
202 release_event_target(This->event_target);
204 heap_free(This->mime);
205 detach_selection(This);
209 ConnectionPointContainer_Destroy(&This->cp_container);
212 nsIDOMHTMLDocument_Release(This->nsdoc);
213 if(This->nscontainer)
214 NSContainer_Release(This->nscontainer);
224 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
226 HTMLDocument *This = HTMLDOC_THIS(iface);
228 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
231 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
232 LCID lcid, ITypeInfo **ppTInfo)
234 HTMLDocument *This = HTMLDOC_THIS(iface);
236 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
239 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
240 LPOLESTR *rgszNames, UINT cNames,
241 LCID lcid, DISPID *rgDispId)
243 HTMLDocument *This = HTMLDOC_THIS(iface);
245 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
248 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
249 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
250 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
252 HTMLDocument *This = HTMLDOC_THIS(iface);
254 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
255 pVarResult, pExcepInfo, puArgErr);
258 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
260 HTMLDocument *This = HTMLDOC_THIS(iface);
262 TRACE("(%p)->(%p)\n", This, p);
264 *p = (IDispatch*)HTMLWINDOW2(This->window);
265 IDispatch_AddRef(*p);
269 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
271 HTMLDocument *This = HTMLDOC_THIS(iface);
272 nsIDOMElement *nselem = NULL;
275 TRACE("(%p)->(%p)\n", This, p);
278 WARN("NULL nsdoc\n");
282 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
283 if(NS_FAILED(nsres)) {
284 ERR("GetDocumentElement failed: %08x\n", nsres);
289 *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE), TRUE);
290 nsIDOMElement_Release(nselem);
298 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
300 HTMLDocument *This = HTMLDOC_THIS(iface);
301 nsIDOMHTMLElement *nsbody = NULL;
305 TRACE("(%p)->(%p)\n", This, p);
308 WARN("NULL nsdoc\n");
312 nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody);
313 if(NS_FAILED(nsres)) {
314 TRACE("Could not get body: %08x\n", nsres);
319 node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
320 nsIDOMHTMLElement_Release(nsbody);
322 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
327 TRACE("*p = %p\n", *p);
331 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
333 HTMLDocument *This = HTMLDOC_THIS(iface);
334 FIXME("(%p)->(%p)\n", This, p);
338 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
340 HTMLDocument *This = HTMLDOC_THIS(iface);
341 nsIDOMHTMLCollection *nscoll = NULL;
344 TRACE("(%p)->(%p)\n", This, p);
352 WARN("NULL nsdoc\n");
356 nsres = nsIDOMHTMLDocument_GetImages(This->nsdoc, &nscoll);
357 if(NS_FAILED(nsres)) {
358 ERR("GetImages failed: %08x\n", nsres);
363 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
364 nsIDOMElement_Release(nscoll);
370 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
372 HTMLDocument *This = HTMLDOC_THIS(iface);
373 nsIDOMHTMLCollection *nscoll = NULL;
376 TRACE("(%p)->(%p)\n", This, p);
384 WARN("NULL nsdoc\n");
388 nsres = nsIDOMHTMLDocument_GetApplets(This->nsdoc, &nscoll);
389 if(NS_FAILED(nsres)) {
390 ERR("GetApplets failed: %08x\n", nsres);
395 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
396 nsIDOMElement_Release(nscoll);
402 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
404 HTMLDocument *This = HTMLDOC_THIS(iface);
405 nsIDOMHTMLCollection *nscoll = NULL;
408 TRACE("(%p)->(%p)\n", This, p);
416 WARN("NULL nsdoc\n");
420 nsres = nsIDOMHTMLDocument_GetLinks(This->nsdoc, &nscoll);
421 if(NS_FAILED(nsres)) {
422 ERR("GetLinks failed: %08x\n", nsres);
427 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
428 nsIDOMElement_Release(nscoll);
434 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
436 HTMLDocument *This = HTMLDOC_THIS(iface);
437 nsIDOMHTMLCollection *nscoll = NULL;
440 TRACE("(%p)->(%p)\n", This, p);
448 WARN("NULL nsdoc\n");
452 nsres = nsIDOMHTMLDocument_GetForms(This->nsdoc, &nscoll);
453 if(NS_FAILED(nsres)) {
454 ERR("GetForms failed: %08x\n", nsres);
459 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
460 nsIDOMElement_Release(nscoll);
466 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
468 HTMLDocument *This = HTMLDOC_THIS(iface);
469 FIXME("(%p)->(%p)\n", This, p);
473 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
475 HTMLDocument *This = HTMLDOC_THIS(iface);
479 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
482 WARN("NULL nsdoc\n");
486 nsAString_Init(&nsstr, v);
487 nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr);
488 nsAString_Finish(&nsstr);
490 ERR("SetTitle failed: %08x\n", nsres);
495 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
497 HTMLDocument *This = HTMLDOC_THIS(iface);
498 const PRUnichar *ret;
502 TRACE("(%p)->(%p)\n", This, p);
505 WARN("NULL nsdoc\n");
510 nsAString_Init(&nsstr, NULL);
511 nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
512 if (NS_SUCCEEDED(nsres)) {
513 nsAString_GetData(&nsstr, &ret);
514 *p = SysAllocString(ret);
516 nsAString_Finish(&nsstr);
518 if(NS_FAILED(nsres)) {
519 ERR("GetTitle failed: %08x\n", nsres);
526 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
528 HTMLDocument *This = HTMLDOC_THIS(iface);
529 FIXME("(%p)->(%p)\n", This, p);
533 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
535 HTMLDocument *This = HTMLDOC_THIS(iface);
536 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
540 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
542 HTMLDocument *This = HTMLDOC_THIS(iface);
543 static WCHAR szOff[] = {'O','f','f',0};
544 FIXME("(%p)->(%p) always returning Off\n", This, p);
549 *p = SysAllocString(szOff);
554 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
556 HTMLDocument *This = HTMLDOC_THIS(iface);
557 nsISelection *nsselection = NULL;
559 TRACE("(%p)->(%p)\n", This, p);
561 if(This->nscontainer) {
562 nsIDOMWindow *dom_window = NULL;
564 nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
566 nsIDOMWindow_GetSelection(dom_window, &nsselection);
567 nsIDOMWindow_Release(dom_window);
571 *p = HTMLSelectionObject_Create(This, nsselection);
575 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
577 HTMLDocument *This = HTMLDOC_THIS(iface);
579 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
580 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
581 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
582 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
583 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
585 static const LPCWSTR readystate_str[] = {
593 TRACE("(%p)->(%p)\n", iface, p);
598 *p = SysAllocString(readystate_str[This->readystate]);
602 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
604 HTMLDocument *This = HTMLDOC_THIS(iface);
605 FIXME("(%p)->(%p)\n", This, p);
609 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
611 HTMLDocument *This = HTMLDOC_THIS(iface);
612 FIXME("(%p)->(%p)\n", This, p);
616 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
618 HTMLDocument *This = HTMLDOC_THIS(iface);
619 FIXME("(%p)->(%p)\n", This, p);
623 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
625 HTMLDocument *This = HTMLDOC_THIS(iface);
626 FIXME("(%p)\n", This);
630 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
632 HTMLDocument *This = HTMLDOC_THIS(iface);
633 FIXME("(%p)->(%p)\n", This, p);
637 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
639 HTMLDocument *This = HTMLDOC_THIS(iface);
640 FIXME("(%p)\n", This);
644 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
646 HTMLDocument *This = HTMLDOC_THIS(iface);
647 FIXME("(%p)->(%p)\n", This, p);
651 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
653 HTMLDocument *This = HTMLDOC_THIS(iface);
654 FIXME("(%p)\n", This);
658 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
660 HTMLDocument *This = HTMLDOC_THIS(iface);
661 FIXME("(%p)->(%p)\n", This, p);
665 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
667 HTMLDocument *This = HTMLDOC_THIS(iface);
668 FIXME("(%p)->()\n", This);
672 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
674 HTMLDocument *This = HTMLDOC_THIS(iface);
675 FIXME("(%p)->(%p)\n", This, p);
679 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
681 HTMLDocument *This = HTMLDOC_THIS(iface);
682 FIXME("(%p)\n", This);
686 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
688 HTMLDocument *This = HTMLDOC_THIS(iface);
689 FIXME("(%p)->(%p)\n", This, p);
693 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
695 HTMLDocument *This = HTMLDOC_THIS(iface);
696 FIXME("(%p)->(%p)\n", This, p);
700 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
702 HTMLDocument *This = HTMLDOC_THIS(iface);
704 TRACE("(%p)->(%p)\n", This, p);
707 IHTMLLocation_AddRef(HTMLLOCATION(This->location));
709 This->location = HTMLLocation_Create(This);
711 *p = HTMLLOCATION(This->location);
715 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
717 HTMLDocument *This = HTMLDOC_THIS(iface);
718 FIXME("(%p)->(%p)\n", This, p);
722 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
724 HTMLDocument *This = HTMLDOC_THIS(iface);
725 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
729 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
731 HTMLDocument *This = HTMLDOC_THIS(iface);
733 static const WCHAR about_blank_url[] =
734 {'a','b','o','u','t',':','b','l','a','n','k',0};
736 TRACE("(%p)->(%p)\n", iface, p);
738 *p = SysAllocString(This->url ? This->url : about_blank_url);
742 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
744 HTMLDocument *This = HTMLDOC_THIS(iface);
745 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
749 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
751 HTMLDocument *This = HTMLDOC_THIS(iface);
752 FIXME("(%p)->(%p)\n", This, p);
756 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
758 HTMLDocument *This = HTMLDOC_THIS(iface);
759 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
763 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
765 HTMLDocument *This = HTMLDOC_THIS(iface);
766 FIXME("(%p)->(%p)\n", This, p);
770 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
772 HTMLDocument *This = HTMLDOC_THIS(iface);
773 FIXME("(%p)->(%x)\n", This, v);
777 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
779 HTMLDocument *This = HTMLDOC_THIS(iface);
780 FIXME("(%p)->(%p)\n", This, p);
784 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
786 HTMLDocument *This = HTMLDOC_THIS(iface);
787 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
791 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
793 HTMLDocument *This = HTMLDOC_THIS(iface);
794 FIXME("(%p)->(%p)\n", This, p);
798 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
800 HTMLDocument *This = HTMLDOC_THIS(iface);
801 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
805 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
807 HTMLDocument *This = HTMLDOC_THIS(iface);
808 FIXME("(%p)->(%p)\n", This, p);
812 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
814 HTMLDocument *This = HTMLDOC_THIS(iface);
815 FIXME("(%p)->(%p)\n", This, p);
819 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
821 HTMLDocument *This = HTMLDOC_THIS(iface);
822 FIXME("(%p)->(%p)\n", This, p);
826 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
828 HTMLDocument *This = HTMLDOC_THIS(iface);
829 FIXME("(%p)->(%p)\n", This, p);
833 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
835 HTMLDocument *This = HTMLDOC_THIS(iface);
836 FIXME("(%p)->(%p)\n", This, p);
840 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
842 HTMLDocument *This = HTMLDOC_THIS(iface);
843 FIXME("(%p)->(%p)\n", This, p);
847 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
849 HTMLDocument *This = HTMLDOC_THIS(iface);
850 FIXME("(%p)->(%p)\n", This, p);
854 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
856 HTMLDocument *This = HTMLDOC_THIS(iface);
857 FIXME("(%p)->(%p)\n", This, p);
861 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
863 HTMLDocument *This = HTMLDOC_THIS(iface);
864 FIXME("(%p)->(%p)\n", This, p);
868 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
870 HTMLDocument *This = HTMLDOC_THIS(iface);
877 TRACE("(%p)->(%p)\n", iface, psarray);
880 WARN("NULL nsdoc\n");
884 if(psarray->cDims != 1) {
885 FIXME("cDims=%d\n", psarray->cDims);
889 hres = SafeArrayAccessData(psarray, (void**)&var);
891 WARN("SafeArrayAccessData failed: %08x\n", hres);
895 nsAString_Init(&nsstr, NULL);
897 for(i=0; i < psarray->rgsabound[0].cElements; i++) {
898 if(V_VT(var+i) == VT_BSTR) {
899 nsAString_SetData(&nsstr, V_BSTR(var+i));
900 nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
902 ERR("Write failed: %08x\n", nsres);
904 FIXME("vt=%d\n", V_VT(var+i));
908 nsAString_Finish(&nsstr);
909 SafeArrayUnaccessData(psarray);
914 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
916 HTMLDocument *This = HTMLDOC_THIS(iface);
917 FIXME("(%p)->(%p)\n", This, psarray);
921 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
922 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
924 HTMLDocument *This = HTMLDOC_THIS(iface);
927 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
929 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
930 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
937 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
938 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
939 FIXME("unsupported args\n");
941 nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
942 if(NS_FAILED(nsres)) {
943 ERR("Open failed: %08x\n", nsres);
947 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
948 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
952 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
954 HTMLDocument *This = HTMLDOC_THIS(iface);
957 TRACE("(%p)\n", This);
964 nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
965 if(NS_FAILED(nsres)) {
966 ERR("Close failed: %08x\n", nsres);
973 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
975 HTMLDocument *This = HTMLDOC_THIS(iface);
976 FIXME("(%p)\n", This);
980 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
983 HTMLDocument *This = HTMLDOC_THIS(iface);
984 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
988 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
991 HTMLDocument *This = HTMLDOC_THIS(iface);
992 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
996 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
999 HTMLDocument *This = HTMLDOC_THIS(iface);
1000 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1004 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1005 VARIANT_BOOL *pfRet)
1007 HTMLDocument *This = HTMLDOC_THIS(iface);
1008 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1012 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1015 HTMLDocument *This = HTMLDOC_THIS(iface);
1016 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1020 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1023 HTMLDocument *This = HTMLDOC_THIS(iface);
1024 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1028 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1029 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1031 HTMLDocument *This = HTMLDOC_THIS(iface);
1032 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
1036 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(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_createElement(IHTMLDocument2 *iface, BSTR eTag,
1045 IHTMLElement **newElem)
1047 HTMLDocument *This = HTMLDOC_THIS(iface);
1048 nsIDOMElement *nselem;
1053 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1056 WARN("NULL nsdoc\n");
1057 return E_UNEXPECTED;
1060 nsAString_Init(&tag_str, eTag);
1061 nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
1062 nsAString_Finish(&tag_str);
1063 if(NS_FAILED(nsres)) {
1064 ERR("CreateElement failed: %08x\n", nsres);
1068 elem = HTMLElement_Create(This, (nsIDOMNode*)nselem, TRUE);
1069 nsIDOMElement_Release(nselem);
1071 *newElem = HTMLELEM(elem);
1072 IHTMLElement_AddRef(HTMLELEM(elem));
1076 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1078 HTMLDocument *This = HTMLDOC_THIS(iface);
1079 FIXME("(%p)\n", This);
1083 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1085 HTMLDocument *This = HTMLDOC_THIS(iface);
1086 FIXME("(%p)->(%p)\n", This, p);
1090 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1092 HTMLDocument *This = HTMLDOC_THIS(iface);
1093 FIXME("(%p)\n", This);
1097 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1099 HTMLDocument *This = HTMLDOC_THIS(iface);
1100 FIXME("(%p)->(%p)\n", This, p);
1104 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1106 HTMLDocument *This = HTMLDOC_THIS(iface);
1107 FIXME("(%p)\n", This);
1111 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1113 HTMLDocument *This = HTMLDOC_THIS(iface);
1114 FIXME("(%p)->(%p)\n", This, p);
1118 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1120 HTMLDocument *This = HTMLDOC_THIS(iface);
1122 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1124 return set_doc_event(This, EVENTID_KEYUP, &v);
1127 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1129 HTMLDocument *This = HTMLDOC_THIS(iface);
1131 TRACE("(%p)->(%p)\n", This, p);
1133 return get_doc_event(This, EVENTID_KEYUP, p);
1136 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1138 HTMLDocument *This = HTMLDOC_THIS(iface);
1140 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1142 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1145 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1147 HTMLDocument *This = HTMLDOC_THIS(iface);
1149 TRACE("(%p)->(%p)\n", This, p);
1151 return get_doc_event(This, EVENTID_KEYDOWN, p);
1154 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1156 HTMLDocument *This = HTMLDOC_THIS(iface);
1157 FIXME("(%p)\n", This);
1161 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1163 HTMLDocument *This = HTMLDOC_THIS(iface);
1164 FIXME("(%p)->(%p)\n", This, p);
1168 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1170 HTMLDocument *This = HTMLDOC_THIS(iface);
1171 FIXME("(%p)\n", This);
1175 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1177 HTMLDocument *This = HTMLDOC_THIS(iface);
1178 FIXME("(%p)->(%p)\n", This, p);
1182 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1184 HTMLDocument *This = HTMLDOC_THIS(iface);
1185 FIXME("(%p)\n", This);
1189 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1191 HTMLDocument *This = HTMLDOC_THIS(iface);
1192 FIXME("(%p)->(%p)\n", This, p);
1196 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1198 HTMLDocument *This = HTMLDOC_THIS(iface);
1199 FIXME("(%p)\n", This);
1203 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1205 HTMLDocument *This = HTMLDOC_THIS(iface);
1206 FIXME("(%p)->(%p)\n", This, p);
1210 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1212 HTMLDocument *This = HTMLDOC_THIS(iface);
1213 FIXME("(%p)\n", This);
1217 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1219 HTMLDocument *This = HTMLDOC_THIS(iface);
1220 FIXME("(%p)->(%p)\n", This, p);
1224 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1226 HTMLDocument *This = HTMLDOC_THIS(iface);
1228 TRACE("(%p)\n", This);
1230 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1233 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1235 HTMLDocument *This = HTMLDOC_THIS(iface);
1237 TRACE("(%p)->(%p)\n", This, p);
1239 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1242 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1244 HTMLDocument *This = HTMLDOC_THIS(iface);
1245 FIXME("(%p)\n", This);
1249 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1251 HTMLDocument *This = HTMLDOC_THIS(iface);
1252 FIXME("(%p)->(%p)\n", This, p);
1256 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1258 HTMLDocument *This = HTMLDOC_THIS(iface);
1259 FIXME("(%p)\n", This);
1263 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1265 HTMLDocument *This = HTMLDOC_THIS(iface);
1266 FIXME("(%p)->(%p)\n", This, p);
1270 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1272 HTMLDocument *This = HTMLDOC_THIS(iface);
1273 FIXME("(%p)\n", This);
1277 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1279 HTMLDocument *This = HTMLDOC_THIS(iface);
1280 FIXME("(%p)->(%p)\n", This, p);
1284 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1286 HTMLDocument *This = HTMLDOC_THIS(iface);
1287 FIXME("(%p)\n", This);
1291 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1293 HTMLDocument *This = HTMLDOC_THIS(iface);
1294 FIXME("(%p)->(%p)\n", This, p);
1298 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1300 HTMLDocument *This = HTMLDOC_THIS(iface);
1302 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1304 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1307 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1309 HTMLDocument *This = HTMLDOC_THIS(iface);
1311 TRACE("(%p)->(%p)\n", This, p);
1313 return get_doc_event(This, EVENTID_DRAGSTART, p);
1316 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1318 HTMLDocument *This = HTMLDOC_THIS(iface);
1320 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1322 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1325 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1327 HTMLDocument *This = HTMLDOC_THIS(iface);
1329 TRACE("(%p)->(%p)\n", This, p);
1331 return get_doc_event(This, EVENTID_SELECTSTART, p);
1334 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, long x, long y,
1335 IHTMLElement **elementHit)
1337 HTMLDocument *This = HTMLDOC_THIS(iface);
1338 FIXME("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1342 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1344 HTMLDocument *This = HTMLDOC_THIS(iface);
1346 TRACE("(%p)->(%p)\n", This, p);
1348 *p = HTMLWINDOW2(This->window);
1349 IHTMLWindow2_AddRef(*p);
1353 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1354 IHTMLStyleSheetsCollection **p)
1356 HTMLDocument *This = HTMLDOC_THIS(iface);
1357 nsIDOMStyleSheetList *nsstylelist;
1358 nsIDOMDocumentStyle *nsdocstyle;
1361 TRACE("(%p)->(%p)\n", This, p);
1366 WARN("NULL nsdoc\n");
1367 return E_UNEXPECTED;
1370 nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1371 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1372 nsIDOMDocumentStyle_Release(nsdocstyle);
1373 if(NS_FAILED(nsres)) {
1374 ERR("GetStyleSheets failed: %08x\n", nsres);
1378 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1379 nsIDOMDocumentStyle_Release(nsstylelist);
1384 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1386 HTMLDocument *This = HTMLDOC_THIS(iface);
1387 FIXME("(%p)\n", This);
1391 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1393 HTMLDocument *This = HTMLDOC_THIS(iface);
1394 FIXME("(%p)->(%p)\n", This, p);
1398 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1400 HTMLDocument *This = HTMLDOC_THIS(iface);
1401 FIXME("(%p)\n", This);
1405 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1407 HTMLDocument *This = HTMLDOC_THIS(iface);
1408 FIXME("(%p)->(%p)\n", This, p);
1412 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1414 HTMLDocument *This = HTMLDOC_THIS(iface);
1415 FIXME("(%p)->(%p)\n", This, String);
1419 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1420 long lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1422 HTMLDocument *This = HTMLDOC_THIS(iface);
1424 FIXME("(%p)->(%s %ld %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1426 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1430 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1431 HTMLDocument_QueryInterface,
1432 HTMLDocument_AddRef,
1433 HTMLDocument_Release,
1434 HTMLDocument_GetTypeInfoCount,
1435 HTMLDocument_GetTypeInfo,
1436 HTMLDocument_GetIDsOfNames,
1437 HTMLDocument_Invoke,
1438 HTMLDocument_get_Script,
1439 HTMLDocument_get_all,
1440 HTMLDocument_get_body,
1441 HTMLDocument_get_activeElement,
1442 HTMLDocument_get_images,
1443 HTMLDocument_get_applets,
1444 HTMLDocument_get_links,
1445 HTMLDocument_get_forms,
1446 HTMLDocument_get_anchors,
1447 HTMLDocument_put_title,
1448 HTMLDocument_get_title,
1449 HTMLDocument_get_scripts,
1450 HTMLDocument_put_designMode,
1451 HTMLDocument_get_designMode,
1452 HTMLDocument_get_selection,
1453 HTMLDocument_get_readyState,
1454 HTMLDocument_get_frames,
1455 HTMLDocument_get_embeds,
1456 HTMLDocument_get_plugins,
1457 HTMLDocument_put_alinkColor,
1458 HTMLDocument_get_alinkColor,
1459 HTMLDocument_put_bgColor,
1460 HTMLDocument_get_bgColor,
1461 HTMLDocument_put_fgColor,
1462 HTMLDocument_get_fgColor,
1463 HTMLDocument_put_linkColor,
1464 HTMLDocument_get_linkColor,
1465 HTMLDocument_put_vlinkColor,
1466 HTMLDocument_get_vlinkColor,
1467 HTMLDocument_get_referrer,
1468 HTMLDocument_get_location,
1469 HTMLDocument_get_lastModified,
1470 HTMLDocument_put_URL,
1471 HTMLDocument_get_URL,
1472 HTMLDocument_put_domain,
1473 HTMLDocument_get_domain,
1474 HTMLDocument_put_cookie,
1475 HTMLDocument_get_cookie,
1476 HTMLDocument_put_expando,
1477 HTMLDocument_get_expando,
1478 HTMLDocument_put_charset,
1479 HTMLDocument_get_charset,
1480 HTMLDocument_put_defaultCharset,
1481 HTMLDocument_get_defaultCharset,
1482 HTMLDocument_get_mimeType,
1483 HTMLDocument_get_fileSize,
1484 HTMLDocument_get_fileCreatedDate,
1485 HTMLDocument_get_fileModifiedDate,
1486 HTMLDocument_get_fileUpdatedDate,
1487 HTMLDocument_get_security,
1488 HTMLDocument_get_protocol,
1489 HTMLDocument_get_nameProp,
1491 HTMLDocument_writeln,
1495 HTMLDocument_queryCommandSupported,
1496 HTMLDocument_queryCommandEnabled,
1497 HTMLDocument_queryCommandState,
1498 HTMLDocument_queryCommandIndeterm,
1499 HTMLDocument_queryCommandText,
1500 HTMLDocument_queryCommandValue,
1501 HTMLDocument_execCommand,
1502 HTMLDocument_execCommandShowHelp,
1503 HTMLDocument_createElement,
1504 HTMLDocument_put_onhelp,
1505 HTMLDocument_get_onhelp,
1506 HTMLDocument_put_onclick,
1507 HTMLDocument_get_onclick,
1508 HTMLDocument_put_ondblclick,
1509 HTMLDocument_get_ondblclick,
1510 HTMLDocument_put_onkeyup,
1511 HTMLDocument_get_onkeyup,
1512 HTMLDocument_put_onkeydown,
1513 HTMLDocument_get_onkeydown,
1514 HTMLDocument_put_onkeypress,
1515 HTMLDocument_get_onkeypress,
1516 HTMLDocument_put_onmouseup,
1517 HTMLDocument_get_onmouseup,
1518 HTMLDocument_put_onmousedown,
1519 HTMLDocument_get_onmousedown,
1520 HTMLDocument_put_onmousemove,
1521 HTMLDocument_get_onmousemove,
1522 HTMLDocument_put_onmouseout,
1523 HTMLDocument_get_onmouseout,
1524 HTMLDocument_put_onmouseover,
1525 HTMLDocument_get_onmouseover,
1526 HTMLDocument_put_onreadystatechange,
1527 HTMLDocument_get_onreadystatechange,
1528 HTMLDocument_put_onafterupdate,
1529 HTMLDocument_get_onafterupdate,
1530 HTMLDocument_put_onrowexit,
1531 HTMLDocument_get_onrowexit,
1532 HTMLDocument_put_onrowenter,
1533 HTMLDocument_get_onrowenter,
1534 HTMLDocument_put_ondragstart,
1535 HTMLDocument_get_ondragstart,
1536 HTMLDocument_put_onselectstart,
1537 HTMLDocument_get_onselectstart,
1538 HTMLDocument_elementFromPoint,
1539 HTMLDocument_get_parentWindow,
1540 HTMLDocument_get_styleSheets,
1541 HTMLDocument_put_onbeforeupdate,
1542 HTMLDocument_get_onbeforeupdate,
1543 HTMLDocument_put_onerrorupdate,
1544 HTMLDocument_get_onerrorupdate,
1545 HTMLDocument_toString,
1546 HTMLDocument_createStyleSheet
1549 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1551 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1553 HTMLDocument *This = DISPEX_THIS(iface);
1555 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1558 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1560 HTMLDocument *This = DISPEX_THIS(iface);
1562 return IHTMLDocument2_AddRef(HTMLDOC(This));
1565 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1567 HTMLDocument *This = DISPEX_THIS(iface);
1569 return IHTMLDocument2_Release(HTMLDOC(This));
1572 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1574 HTMLDocument *This = DISPEX_THIS(iface);
1576 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1579 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1580 LCID lcid, ITypeInfo **ppTInfo)
1582 HTMLDocument *This = DISPEX_THIS(iface);
1584 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1587 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1588 LPOLESTR *rgszNames, UINT cNames,
1589 LCID lcid, DISPID *rgDispId)
1591 HTMLDocument *This = DISPEX_THIS(iface);
1593 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1596 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1597 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1598 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1600 HTMLDocument *This = DISPEX_THIS(iface);
1602 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1603 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1605 switch(dispIdMember) {
1606 case DISPID_READYSTATE:
1607 TRACE("DISPID_READYSTATE\n");
1609 if(!(wFlags & DISPATCH_PROPERTYGET))
1610 return E_INVALIDARG;
1612 V_VT(pVarResult) = VT_I4;
1613 V_I4(pVarResult) = This->readystate;
1617 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1618 pVarResult, pExcepInfo, puArgErr);
1621 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1623 HTMLDocument *This = DISPEX_THIS(iface);
1625 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1628 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1629 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1631 HTMLDocument *This = DISPEX_THIS(iface);
1633 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1636 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1638 HTMLDocument *This = DISPEX_THIS(iface);
1640 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1643 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1645 HTMLDocument *This = DISPEX_THIS(iface);
1647 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1650 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1652 HTMLDocument *This = DISPEX_THIS(iface);
1654 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1657 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1659 HTMLDocument *This = DISPEX_THIS(iface);
1661 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1664 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1666 HTMLDocument *This = DISPEX_THIS(iface);
1668 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1671 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1673 HTMLDocument *This = DISPEX_THIS(iface);
1675 return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1680 static const IDispatchExVtbl DocDispatchExVtbl = {
1681 DocDispatchEx_QueryInterface,
1682 DocDispatchEx_AddRef,
1683 DocDispatchEx_Release,
1684 DocDispatchEx_GetTypeInfoCount,
1685 DocDispatchEx_GetTypeInfo,
1686 DocDispatchEx_GetIDsOfNames,
1687 DocDispatchEx_Invoke,
1688 DocDispatchEx_GetDispID,
1689 DocDispatchEx_InvokeEx,
1690 DocDispatchEx_DeleteMemberByName,
1691 DocDispatchEx_DeleteMemberByDispID,
1692 DocDispatchEx_GetMemberProperties,
1693 DocDispatchEx_GetMemberName,
1694 DocDispatchEx_GetNextDispID,
1695 DocDispatchEx_GetNameSpaceParent
1698 static const tid_t HTMLDocument_iface_tids[] = {
1705 static dispex_static_data_t HTMLDocument_dispex = {
1707 DispHTMLDocument_tid,
1709 HTMLDocument_iface_tids
1712 static HRESULT alloc_doc(HTMLDocument **ret)
1716 doc = heap_alloc_zero(sizeof(HTMLDocument));
1717 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1718 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1720 doc->readystate = READYSTATE_UNINITIALIZED;
1721 doc->scriptmode = SCRIPTMODE_GECKO;
1723 list_init(&doc->bindings);
1724 list_init(&doc->script_hosts);
1725 list_init(&doc->selection_list);
1726 list_init(&doc->range_list);
1728 HTMLDocument_HTMLDocument3_Init(doc);
1729 HTMLDocument_HTMLDocument5_Init(doc);
1730 HTMLDocument_Persist_Init(doc);
1731 HTMLDocument_OleCmd_Init(doc);
1732 HTMLDocument_OleObj_Init(doc);
1733 HTMLDocument_View_Init(doc);
1734 HTMLDocument_Window_Init(doc);
1735 HTMLDocument_Service_Init(doc);
1736 HTMLDocument_Hlink_Init(doc);
1738 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1739 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
1740 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
1741 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
1743 init_dispex(&doc->dispex, (IUnknown*)HTMLDOC(doc), &HTMLDocument_dispex);
1749 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocument **ret)
1754 hres = alloc_doc(&doc);
1758 nsIDOMHTMLDocument_AddRef(nsdoc);
1761 hres = HTMLWindow_Create(doc, NULL, &doc->window);
1763 IHTMLDocument_Release(HTMLDOC(doc));
1771 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1774 nsIDOMWindow *nswindow = NULL;
1777 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1779 hres = alloc_doc(&doc);
1783 hres = IHTMLDocument_QueryInterface(HTMLDOC(doc), riid, ppvObject);
1784 IHTMLDocument_Release(HTMLDOC(doc));
1790 doc->nscontainer = NSContainer_Create(doc, NULL);
1791 update_nsdocument(doc);
1793 if(doc->nscontainer) {
1796 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
1797 if(NS_FAILED(nsres))
1798 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1801 hres = HTMLWindow_Create(doc, nswindow, &doc->window);
1803 nsIDOMWindow_Release(nswindow);
1805 IHTMLDocument_Release(HTMLDOC(doc));