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);
183 IOleObject_SetClientSite(OLEOBJ(This), NULL);
184 if(This->in_place_active)
185 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
187 IOleDocumentView_SetInPlaceSite(DOCVIEW(This), NULL);
189 IOleUndoManager_Release(This->undomgr);
191 set_document_bscallback(This, NULL);
192 set_current_mon(This, NULL);
194 if(This->tooltips_hwnd)
195 DestroyWindow(This->tooltips_hwnd);
197 DestroyWindow(This->hwnd);
199 if(This->option_factory) {
200 This->option_factory->doc = NULL;
201 IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
205 This->location->doc = NULL;
208 IHTMLWindow2_Release(HTMLWINDOW2(This->window));
210 if(This->event_target)
211 release_event_target(This->event_target);
213 heap_free(This->mime);
214 detach_selection(This);
217 release_dispex(&This->dispex);
219 ConnectionPointContainer_Destroy(&This->cp_container);
222 remove_mutation_observer(This->nscontainer, This->nsdoc);
223 nsIDOMHTMLDocument_Release(This->nsdoc);
225 if(This->nscontainer)
226 NSContainer_Release(This->nscontainer);
234 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
236 HTMLDocument *This = HTMLDOC_THIS(iface);
238 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
241 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
242 LCID lcid, ITypeInfo **ppTInfo)
244 HTMLDocument *This = HTMLDOC_THIS(iface);
246 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
249 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
250 LPOLESTR *rgszNames, UINT cNames,
251 LCID lcid, DISPID *rgDispId)
253 HTMLDocument *This = HTMLDOC_THIS(iface);
255 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
258 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
259 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
260 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
262 HTMLDocument *This = HTMLDOC_THIS(iface);
264 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
265 pVarResult, pExcepInfo, puArgErr);
268 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
270 HTMLDocument *This = HTMLDOC_THIS(iface);
272 TRACE("(%p)->(%p)\n", This, p);
274 *p = (IDispatch*)HTMLWINDOW2(This->window);
275 IDispatch_AddRef(*p);
279 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
281 HTMLDocument *This = HTMLDOC_THIS(iface);
282 nsIDOMElement *nselem = NULL;
285 TRACE("(%p)->(%p)\n", This, p);
288 WARN("NULL nsdoc\n");
292 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
293 if(NS_FAILED(nsres)) {
294 ERR("GetDocumentElement failed: %08x\n", nsres);
299 *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE), TRUE);
300 nsIDOMElement_Release(nselem);
308 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
310 HTMLDocument *This = HTMLDOC_THIS(iface);
311 nsIDOMHTMLElement *nsbody = NULL;
315 TRACE("(%p)->(%p)\n", This, p);
318 WARN("NULL nsdoc\n");
322 nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody);
323 if(NS_FAILED(nsres)) {
324 TRACE("Could not get body: %08x\n", nsres);
329 node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
330 nsIDOMHTMLElement_Release(nsbody);
332 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
337 TRACE("*p = %p\n", *p);
341 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
343 HTMLDocument *This = HTMLDOC_THIS(iface);
344 FIXME("(%p)->(%p)\n", This, p);
348 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
350 HTMLDocument *This = HTMLDOC_THIS(iface);
351 nsIDOMHTMLCollection *nscoll = NULL;
354 TRACE("(%p)->(%p)\n", This, p);
362 WARN("NULL nsdoc\n");
366 nsres = nsIDOMHTMLDocument_GetImages(This->nsdoc, &nscoll);
367 if(NS_FAILED(nsres)) {
368 ERR("GetImages failed: %08x\n", nsres);
373 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
374 nsIDOMElement_Release(nscoll);
380 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
382 HTMLDocument *This = HTMLDOC_THIS(iface);
383 nsIDOMHTMLCollection *nscoll = NULL;
386 TRACE("(%p)->(%p)\n", This, p);
394 WARN("NULL nsdoc\n");
398 nsres = nsIDOMHTMLDocument_GetApplets(This->nsdoc, &nscoll);
399 if(NS_FAILED(nsres)) {
400 ERR("GetApplets failed: %08x\n", nsres);
405 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
406 nsIDOMElement_Release(nscoll);
412 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
414 HTMLDocument *This = HTMLDOC_THIS(iface);
415 nsIDOMHTMLCollection *nscoll = NULL;
418 TRACE("(%p)->(%p)\n", This, p);
426 WARN("NULL nsdoc\n");
430 nsres = nsIDOMHTMLDocument_GetLinks(This->nsdoc, &nscoll);
431 if(NS_FAILED(nsres)) {
432 ERR("GetLinks failed: %08x\n", nsres);
437 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
438 nsIDOMElement_Release(nscoll);
444 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
446 HTMLDocument *This = HTMLDOC_THIS(iface);
447 nsIDOMHTMLCollection *nscoll = NULL;
450 TRACE("(%p)->(%p)\n", This, p);
458 WARN("NULL nsdoc\n");
462 nsres = nsIDOMHTMLDocument_GetForms(This->nsdoc, &nscoll);
463 if(NS_FAILED(nsres)) {
464 ERR("GetForms failed: %08x\n", nsres);
469 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
470 nsIDOMElement_Release(nscoll);
476 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
478 HTMLDocument *This = HTMLDOC_THIS(iface);
479 nsIDOMHTMLCollection *nscoll = NULL;
482 TRACE("(%p)->(%p)\n", This, p);
490 WARN("NULL nsdoc\n");
494 nsres = nsIDOMHTMLDocument_GetAnchors(This->nsdoc, &nscoll);
495 if(NS_FAILED(nsres)) {
496 ERR("GetAnchors failed: %08x\n", nsres);
501 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
502 nsIDOMElement_Release(nscoll);
508 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
510 HTMLDocument *This = HTMLDOC_THIS(iface);
514 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
517 WARN("NULL nsdoc\n");
521 nsAString_Init(&nsstr, v);
522 nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr);
523 nsAString_Finish(&nsstr);
525 ERR("SetTitle failed: %08x\n", nsres);
530 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
532 HTMLDocument *This = HTMLDOC_THIS(iface);
533 const PRUnichar *ret;
537 TRACE("(%p)->(%p)\n", This, p);
540 WARN("NULL nsdoc\n");
545 nsAString_Init(&nsstr, NULL);
546 nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
547 if (NS_SUCCEEDED(nsres)) {
548 nsAString_GetData(&nsstr, &ret);
549 *p = SysAllocString(ret);
551 nsAString_Finish(&nsstr);
553 if(NS_FAILED(nsres)) {
554 ERR("GetTitle failed: %08x\n", nsres);
561 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
563 HTMLDocument *This = HTMLDOC_THIS(iface);
564 FIXME("(%p)->(%p)\n", This, p);
568 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
570 HTMLDocument *This = HTMLDOC_THIS(iface);
571 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
575 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
577 HTMLDocument *This = HTMLDOC_THIS(iface);
578 static WCHAR szOff[] = {'O','f','f',0};
579 FIXME("(%p)->(%p) always returning Off\n", This, p);
584 *p = SysAllocString(szOff);
589 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
591 HTMLDocument *This = HTMLDOC_THIS(iface);
592 nsISelection *nsselection = NULL;
594 TRACE("(%p)->(%p)\n", This, p);
596 if(This->nscontainer) {
597 nsIDOMWindow *dom_window = NULL;
599 nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
601 nsIDOMWindow_GetSelection(dom_window, &nsselection);
602 nsIDOMWindow_Release(dom_window);
606 *p = HTMLSelectionObject_Create(This, nsselection);
610 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
612 HTMLDocument *This = HTMLDOC_THIS(iface);
614 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
615 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
616 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
617 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
618 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
620 static const LPCWSTR readystate_str[] = {
628 TRACE("(%p)->(%p)\n", iface, p);
633 *p = SysAllocString(readystate_str[This->readystate]);
637 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
639 HTMLDocument *This = HTMLDOC_THIS(iface);
640 FIXME("(%p)->(%p)\n", This, p);
644 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
646 HTMLDocument *This = HTMLDOC_THIS(iface);
647 FIXME("(%p)->(%p)\n", This, p);
651 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
653 HTMLDocument *This = HTMLDOC_THIS(iface);
654 FIXME("(%p)->(%p)\n", This, p);
658 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
660 HTMLDocument *This = HTMLDOC_THIS(iface);
661 FIXME("(%p)\n", This);
665 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
667 HTMLDocument *This = HTMLDOC_THIS(iface);
668 FIXME("(%p)->(%p)\n", This, p);
672 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
674 HTMLDocument *This = HTMLDOC_THIS(iface);
675 FIXME("(%p)\n", This);
679 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
681 HTMLDocument *This = HTMLDOC_THIS(iface);
682 FIXME("(%p)->(%p)\n", This, p);
686 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
688 HTMLDocument *This = HTMLDOC_THIS(iface);
689 FIXME("(%p)\n", This);
693 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
695 HTMLDocument *This = HTMLDOC_THIS(iface);
696 FIXME("(%p)->(%p)\n", This, p);
700 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
702 HTMLDocument *This = HTMLDOC_THIS(iface);
703 FIXME("(%p)->()\n", This);
707 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
709 HTMLDocument *This = HTMLDOC_THIS(iface);
710 FIXME("(%p)->(%p)\n", This, p);
714 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
716 HTMLDocument *This = HTMLDOC_THIS(iface);
717 FIXME("(%p)\n", This);
721 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
723 HTMLDocument *This = HTMLDOC_THIS(iface);
724 FIXME("(%p)->(%p)\n", This, p);
728 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
730 HTMLDocument *This = HTMLDOC_THIS(iface);
731 FIXME("(%p)->(%p)\n", This, p);
735 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
737 HTMLDocument *This = HTMLDOC_THIS(iface);
739 TRACE("(%p)->(%p)\n", This, p);
742 IHTMLLocation_AddRef(HTMLLOCATION(This->location));
744 This->location = HTMLLocation_Create(This);
746 *p = HTMLLOCATION(This->location);
750 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
752 HTMLDocument *This = HTMLDOC_THIS(iface);
753 FIXME("(%p)->(%p)\n", This, p);
757 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
759 HTMLDocument *This = HTMLDOC_THIS(iface);
760 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
764 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
766 HTMLDocument *This = HTMLDOC_THIS(iface);
768 static const WCHAR about_blank_url[] =
769 {'a','b','o','u','t',':','b','l','a','n','k',0};
771 TRACE("(%p)->(%p)\n", iface, p);
773 *p = SysAllocString(This->url ? This->url : about_blank_url);
777 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
779 HTMLDocument *This = HTMLDOC_THIS(iface);
780 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
784 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
786 HTMLDocument *This = HTMLDOC_THIS(iface);
787 FIXME("(%p)->(%p)\n", This, p);
791 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
793 HTMLDocument *This = HTMLDOC_THIS(iface);
794 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
798 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
800 HTMLDocument *This = HTMLDOC_THIS(iface);
801 FIXME("(%p)->(%p)\n", This, p);
805 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
807 HTMLDocument *This = HTMLDOC_THIS(iface);
808 FIXME("(%p)->(%x)\n", This, v);
812 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
814 HTMLDocument *This = HTMLDOC_THIS(iface);
815 FIXME("(%p)->(%p)\n", This, p);
819 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
821 HTMLDocument *This = HTMLDOC_THIS(iface);
822 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
826 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
828 HTMLDocument *This = HTMLDOC_THIS(iface);
829 FIXME("(%p)->(%p)\n", This, p);
833 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
835 HTMLDocument *This = HTMLDOC_THIS(iface);
836 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
840 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
842 HTMLDocument *This = HTMLDOC_THIS(iface);
843 FIXME("(%p)->(%p)\n", This, p);
847 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
849 HTMLDocument *This = HTMLDOC_THIS(iface);
850 FIXME("(%p)->(%p)\n", This, p);
854 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
856 HTMLDocument *This = HTMLDOC_THIS(iface);
857 FIXME("(%p)->(%p)\n", This, p);
861 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
863 HTMLDocument *This = HTMLDOC_THIS(iface);
864 FIXME("(%p)->(%p)\n", This, p);
868 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
870 HTMLDocument *This = HTMLDOC_THIS(iface);
871 FIXME("(%p)->(%p)\n", This, p);
875 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
877 HTMLDocument *This = HTMLDOC_THIS(iface);
878 FIXME("(%p)->(%p)\n", This, p);
882 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
884 HTMLDocument *This = HTMLDOC_THIS(iface);
885 FIXME("(%p)->(%p)\n", This, p);
889 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
891 HTMLDocument *This = HTMLDOC_THIS(iface);
892 FIXME("(%p)->(%p)\n", This, p);
896 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
898 HTMLDocument *This = HTMLDOC_THIS(iface);
899 FIXME("(%p)->(%p)\n", This, p);
903 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
912 WARN("NULL nsdoc\n");
916 if(psarray->cDims != 1) {
917 FIXME("cDims=%d\n", psarray->cDims);
921 hres = SafeArrayAccessData(psarray, (void**)&var);
923 WARN("SafeArrayAccessData failed: %08x\n", hres);
927 nsAString_Init(&nsstr, NULL);
929 argc = psarray->rgsabound[0].cElements;
930 for(i=0; i < argc; i++) {
931 if(V_VT(var+i) == VT_BSTR) {
932 nsAString_SetData(&nsstr, V_BSTR(var+i));
933 if(!ln || i != argc-1)
934 nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
936 nsres = nsIDOMHTMLDocument_Writeln(This->nsdoc, &nsstr);
938 ERR("Write failed: %08x\n", nsres);
940 FIXME("vt=%d\n", V_VT(var+i));
944 nsAString_Finish(&nsstr);
945 SafeArrayUnaccessData(psarray);
950 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
952 HTMLDocument *This = HTMLDOC_THIS(iface);
954 TRACE("(%p)->(%p)\n", iface, psarray);
956 return document_write(This, psarray, FALSE);
959 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
961 HTMLDocument *This = HTMLDOC_THIS(iface);
963 TRACE("(%p)->(%p)\n", This, psarray);
965 return document_write(This, psarray, TRUE);
968 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
969 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
971 HTMLDocument *This = HTMLDOC_THIS(iface);
974 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
976 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
977 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
984 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
985 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
986 FIXME("unsupported args\n");
988 nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
989 if(NS_FAILED(nsres)) {
990 ERR("Open failed: %08x\n", nsres);
994 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
995 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
999 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1001 HTMLDocument *This = HTMLDOC_THIS(iface);
1004 TRACE("(%p)\n", This);
1011 nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
1012 if(NS_FAILED(nsres)) {
1013 ERR("Close failed: %08x\n", nsres);
1020 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1022 HTMLDocument *This = HTMLDOC_THIS(iface);
1023 FIXME("(%p)\n", This);
1027 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1028 VARIANT_BOOL *pfRet)
1030 HTMLDocument *This = HTMLDOC_THIS(iface);
1031 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1035 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1036 VARIANT_BOOL *pfRet)
1038 HTMLDocument *This = HTMLDOC_THIS(iface);
1039 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1043 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1044 VARIANT_BOOL *pfRet)
1046 HTMLDocument *This = HTMLDOC_THIS(iface);
1047 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1051 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1052 VARIANT_BOOL *pfRet)
1054 HTMLDocument *This = HTMLDOC_THIS(iface);
1055 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1059 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1062 HTMLDocument *This = HTMLDOC_THIS(iface);
1063 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1067 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1070 HTMLDocument *This = HTMLDOC_THIS(iface);
1071 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1075 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1076 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1078 HTMLDocument *This = HTMLDOC_THIS(iface);
1079 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
1083 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1084 VARIANT_BOOL *pfRet)
1086 HTMLDocument *This = HTMLDOC_THIS(iface);
1087 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1091 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1092 IHTMLElement **newElem)
1094 HTMLDocument *This = HTMLDOC_THIS(iface);
1095 nsIDOMElement *nselem;
1100 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1103 WARN("NULL nsdoc\n");
1104 return E_UNEXPECTED;
1107 nsAString_Init(&tag_str, eTag);
1108 nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
1109 nsAString_Finish(&tag_str);
1110 if(NS_FAILED(nsres)) {
1111 ERR("CreateElement failed: %08x\n", nsres);
1115 elem = HTMLElement_Create(This, (nsIDOMNode*)nselem, TRUE);
1116 nsIDOMElement_Release(nselem);
1118 *newElem = HTMLELEM(elem);
1119 IHTMLElement_AddRef(HTMLELEM(elem));
1123 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1125 HTMLDocument *This = HTMLDOC_THIS(iface);
1126 FIXME("(%p)\n", This);
1130 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1132 HTMLDocument *This = HTMLDOC_THIS(iface);
1133 FIXME("(%p)->(%p)\n", This, p);
1137 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1139 HTMLDocument *This = HTMLDOC_THIS(iface);
1141 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1143 return set_doc_event(This, EVENTID_CLICK, &v);
1146 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1148 HTMLDocument *This = HTMLDOC_THIS(iface);
1150 TRACE("(%p)->(%p)\n", This, p);
1152 return get_doc_event(This, EVENTID_CLICK, p);
1155 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1157 HTMLDocument *This = HTMLDOC_THIS(iface);
1158 FIXME("(%p)\n", This);
1162 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1164 HTMLDocument *This = HTMLDOC_THIS(iface);
1165 FIXME("(%p)->(%p)\n", This, p);
1169 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1171 HTMLDocument *This = HTMLDOC_THIS(iface);
1173 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1175 return set_doc_event(This, EVENTID_KEYUP, &v);
1178 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1180 HTMLDocument *This = HTMLDOC_THIS(iface);
1182 TRACE("(%p)->(%p)\n", This, p);
1184 return get_doc_event(This, EVENTID_KEYUP, p);
1187 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1189 HTMLDocument *This = HTMLDOC_THIS(iface);
1191 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1193 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1196 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1198 HTMLDocument *This = HTMLDOC_THIS(iface);
1200 TRACE("(%p)->(%p)\n", This, p);
1202 return get_doc_event(This, EVENTID_KEYDOWN, p);
1205 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1207 HTMLDocument *This = HTMLDOC_THIS(iface);
1208 FIXME("(%p)\n", This);
1212 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1214 HTMLDocument *This = HTMLDOC_THIS(iface);
1215 FIXME("(%p)->(%p)\n", This, p);
1219 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1221 HTMLDocument *This = HTMLDOC_THIS(iface);
1222 FIXME("(%p)\n", This);
1226 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1228 HTMLDocument *This = HTMLDOC_THIS(iface);
1229 FIXME("(%p)->(%p)\n", This, p);
1233 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1235 HTMLDocument *This = HTMLDOC_THIS(iface);
1236 FIXME("(%p)\n", This);
1240 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1242 HTMLDocument *This = HTMLDOC_THIS(iface);
1243 FIXME("(%p)->(%p)\n", This, p);
1247 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1249 HTMLDocument *This = HTMLDOC_THIS(iface);
1250 FIXME("(%p)\n", This);
1254 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1256 HTMLDocument *This = HTMLDOC_THIS(iface);
1257 FIXME("(%p)->(%p)\n", This, p);
1261 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1263 HTMLDocument *This = HTMLDOC_THIS(iface);
1264 FIXME("(%p)\n", This);
1268 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1270 HTMLDocument *This = HTMLDOC_THIS(iface);
1271 FIXME("(%p)->(%p)\n", This, p);
1275 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1277 HTMLDocument *This = HTMLDOC_THIS(iface);
1279 TRACE("(%p)\n", This);
1281 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1284 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1286 HTMLDocument *This = HTMLDOC_THIS(iface);
1288 TRACE("(%p)->(%p)\n", This, p);
1290 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1293 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1295 HTMLDocument *This = HTMLDOC_THIS(iface);
1296 FIXME("(%p)\n", This);
1300 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1302 HTMLDocument *This = HTMLDOC_THIS(iface);
1303 FIXME("(%p)->(%p)\n", This, p);
1307 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1309 HTMLDocument *This = HTMLDOC_THIS(iface);
1310 FIXME("(%p)\n", This);
1314 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1316 HTMLDocument *This = HTMLDOC_THIS(iface);
1317 FIXME("(%p)->(%p)\n", This, p);
1321 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1323 HTMLDocument *This = HTMLDOC_THIS(iface);
1324 FIXME("(%p)\n", This);
1328 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1330 HTMLDocument *This = HTMLDOC_THIS(iface);
1331 FIXME("(%p)->(%p)\n", This, p);
1335 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1337 HTMLDocument *This = HTMLDOC_THIS(iface);
1338 FIXME("(%p)\n", This);
1342 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1344 HTMLDocument *This = HTMLDOC_THIS(iface);
1345 FIXME("(%p)->(%p)\n", This, p);
1349 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1351 HTMLDocument *This = HTMLDOC_THIS(iface);
1353 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1355 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1358 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1360 HTMLDocument *This = HTMLDOC_THIS(iface);
1362 TRACE("(%p)->(%p)\n", This, p);
1364 return get_doc_event(This, EVENTID_DRAGSTART, p);
1367 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1369 HTMLDocument *This = HTMLDOC_THIS(iface);
1371 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1373 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1376 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1378 HTMLDocument *This = HTMLDOC_THIS(iface);
1380 TRACE("(%p)->(%p)\n", This, p);
1382 return get_doc_event(This, EVENTID_SELECTSTART, p);
1385 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1386 IHTMLElement **elementHit)
1388 HTMLDocument *This = HTMLDOC_THIS(iface);
1389 FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1393 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1395 HTMLDocument *This = HTMLDOC_THIS(iface);
1397 TRACE("(%p)->(%p)\n", This, p);
1399 *p = HTMLWINDOW2(This->window);
1400 IHTMLWindow2_AddRef(*p);
1404 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1405 IHTMLStyleSheetsCollection **p)
1407 HTMLDocument *This = HTMLDOC_THIS(iface);
1408 nsIDOMStyleSheetList *nsstylelist;
1409 nsIDOMDocumentStyle *nsdocstyle;
1412 TRACE("(%p)->(%p)\n", This, p);
1417 WARN("NULL nsdoc\n");
1418 return E_UNEXPECTED;
1421 nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1422 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1423 nsIDOMDocumentStyle_Release(nsdocstyle);
1424 if(NS_FAILED(nsres)) {
1425 ERR("GetStyleSheets failed: %08x\n", nsres);
1429 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1430 nsIDOMDocumentStyle_Release(nsstylelist);
1435 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1437 HTMLDocument *This = HTMLDOC_THIS(iface);
1438 FIXME("(%p)\n", This);
1442 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1444 HTMLDocument *This = HTMLDOC_THIS(iface);
1445 FIXME("(%p)->(%p)\n", This, p);
1449 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1451 HTMLDocument *This = HTMLDOC_THIS(iface);
1452 FIXME("(%p)\n", This);
1456 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1458 HTMLDocument *This = HTMLDOC_THIS(iface);
1459 FIXME("(%p)->(%p)\n", This, p);
1463 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1465 HTMLDocument *This = HTMLDOC_THIS(iface);
1466 FIXME("(%p)->(%p)\n", This, String);
1470 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1471 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1473 HTMLDocument *This = HTMLDOC_THIS(iface);
1475 FIXME("(%p)->(%s %d %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1477 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1481 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1482 HTMLDocument_QueryInterface,
1483 HTMLDocument_AddRef,
1484 HTMLDocument_Release,
1485 HTMLDocument_GetTypeInfoCount,
1486 HTMLDocument_GetTypeInfo,
1487 HTMLDocument_GetIDsOfNames,
1488 HTMLDocument_Invoke,
1489 HTMLDocument_get_Script,
1490 HTMLDocument_get_all,
1491 HTMLDocument_get_body,
1492 HTMLDocument_get_activeElement,
1493 HTMLDocument_get_images,
1494 HTMLDocument_get_applets,
1495 HTMLDocument_get_links,
1496 HTMLDocument_get_forms,
1497 HTMLDocument_get_anchors,
1498 HTMLDocument_put_title,
1499 HTMLDocument_get_title,
1500 HTMLDocument_get_scripts,
1501 HTMLDocument_put_designMode,
1502 HTMLDocument_get_designMode,
1503 HTMLDocument_get_selection,
1504 HTMLDocument_get_readyState,
1505 HTMLDocument_get_frames,
1506 HTMLDocument_get_embeds,
1507 HTMLDocument_get_plugins,
1508 HTMLDocument_put_alinkColor,
1509 HTMLDocument_get_alinkColor,
1510 HTMLDocument_put_bgColor,
1511 HTMLDocument_get_bgColor,
1512 HTMLDocument_put_fgColor,
1513 HTMLDocument_get_fgColor,
1514 HTMLDocument_put_linkColor,
1515 HTMLDocument_get_linkColor,
1516 HTMLDocument_put_vlinkColor,
1517 HTMLDocument_get_vlinkColor,
1518 HTMLDocument_get_referrer,
1519 HTMLDocument_get_location,
1520 HTMLDocument_get_lastModified,
1521 HTMLDocument_put_URL,
1522 HTMLDocument_get_URL,
1523 HTMLDocument_put_domain,
1524 HTMLDocument_get_domain,
1525 HTMLDocument_put_cookie,
1526 HTMLDocument_get_cookie,
1527 HTMLDocument_put_expando,
1528 HTMLDocument_get_expando,
1529 HTMLDocument_put_charset,
1530 HTMLDocument_get_charset,
1531 HTMLDocument_put_defaultCharset,
1532 HTMLDocument_get_defaultCharset,
1533 HTMLDocument_get_mimeType,
1534 HTMLDocument_get_fileSize,
1535 HTMLDocument_get_fileCreatedDate,
1536 HTMLDocument_get_fileModifiedDate,
1537 HTMLDocument_get_fileUpdatedDate,
1538 HTMLDocument_get_security,
1539 HTMLDocument_get_protocol,
1540 HTMLDocument_get_nameProp,
1542 HTMLDocument_writeln,
1546 HTMLDocument_queryCommandSupported,
1547 HTMLDocument_queryCommandEnabled,
1548 HTMLDocument_queryCommandState,
1549 HTMLDocument_queryCommandIndeterm,
1550 HTMLDocument_queryCommandText,
1551 HTMLDocument_queryCommandValue,
1552 HTMLDocument_execCommand,
1553 HTMLDocument_execCommandShowHelp,
1554 HTMLDocument_createElement,
1555 HTMLDocument_put_onhelp,
1556 HTMLDocument_get_onhelp,
1557 HTMLDocument_put_onclick,
1558 HTMLDocument_get_onclick,
1559 HTMLDocument_put_ondblclick,
1560 HTMLDocument_get_ondblclick,
1561 HTMLDocument_put_onkeyup,
1562 HTMLDocument_get_onkeyup,
1563 HTMLDocument_put_onkeydown,
1564 HTMLDocument_get_onkeydown,
1565 HTMLDocument_put_onkeypress,
1566 HTMLDocument_get_onkeypress,
1567 HTMLDocument_put_onmouseup,
1568 HTMLDocument_get_onmouseup,
1569 HTMLDocument_put_onmousedown,
1570 HTMLDocument_get_onmousedown,
1571 HTMLDocument_put_onmousemove,
1572 HTMLDocument_get_onmousemove,
1573 HTMLDocument_put_onmouseout,
1574 HTMLDocument_get_onmouseout,
1575 HTMLDocument_put_onmouseover,
1576 HTMLDocument_get_onmouseover,
1577 HTMLDocument_put_onreadystatechange,
1578 HTMLDocument_get_onreadystatechange,
1579 HTMLDocument_put_onafterupdate,
1580 HTMLDocument_get_onafterupdate,
1581 HTMLDocument_put_onrowexit,
1582 HTMLDocument_get_onrowexit,
1583 HTMLDocument_put_onrowenter,
1584 HTMLDocument_get_onrowenter,
1585 HTMLDocument_put_ondragstart,
1586 HTMLDocument_get_ondragstart,
1587 HTMLDocument_put_onselectstart,
1588 HTMLDocument_get_onselectstart,
1589 HTMLDocument_elementFromPoint,
1590 HTMLDocument_get_parentWindow,
1591 HTMLDocument_get_styleSheets,
1592 HTMLDocument_put_onbeforeupdate,
1593 HTMLDocument_get_onbeforeupdate,
1594 HTMLDocument_put_onerrorupdate,
1595 HTMLDocument_get_onerrorupdate,
1596 HTMLDocument_toString,
1597 HTMLDocument_createStyleSheet
1600 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
1602 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
1604 HTMLDocument *This = SUPPINFO_THIS(iface);
1605 return IHTMLDocument_QueryInterface(HTMLDOC(This), riid, ppv);
1608 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
1610 HTMLDocument *This = SUPPINFO_THIS(iface);
1611 return IHTMLDocument_AddRef(HTMLDOC(This));
1614 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
1616 HTMLDocument *This = SUPPINFO_THIS(iface);
1617 return IHTMLDocument_Release(HTMLDOC(This));
1620 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
1622 FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
1626 static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
1627 SupportErrorInfo_QueryInterface,
1628 SupportErrorInfo_AddRef,
1629 SupportErrorInfo_Release,
1630 SupportErrorInfo_InterfaceSupportsErrorInfo
1633 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1635 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1637 HTMLDocument *This = DISPEX_THIS(iface);
1639 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1642 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1644 HTMLDocument *This = DISPEX_THIS(iface);
1646 return IHTMLDocument2_AddRef(HTMLDOC(This));
1649 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1651 HTMLDocument *This = DISPEX_THIS(iface);
1653 return IHTMLDocument2_Release(HTMLDOC(This));
1656 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1658 HTMLDocument *This = DISPEX_THIS(iface);
1660 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1663 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1664 LCID lcid, ITypeInfo **ppTInfo)
1666 HTMLDocument *This = DISPEX_THIS(iface);
1668 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1671 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1672 LPOLESTR *rgszNames, UINT cNames,
1673 LCID lcid, DISPID *rgDispId)
1675 HTMLDocument *This = DISPEX_THIS(iface);
1677 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1680 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1681 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1682 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1684 HTMLDocument *This = DISPEX_THIS(iface);
1686 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1687 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1689 switch(dispIdMember) {
1690 case DISPID_READYSTATE:
1691 TRACE("DISPID_READYSTATE\n");
1693 if(!(wFlags & DISPATCH_PROPERTYGET))
1694 return E_INVALIDARG;
1696 V_VT(pVarResult) = VT_I4;
1697 V_I4(pVarResult) = This->readystate;
1701 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1702 pVarResult, pExcepInfo, puArgErr);
1705 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1707 HTMLDocument *This = DISPEX_THIS(iface);
1709 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1712 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1713 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1715 HTMLDocument *This = DISPEX_THIS(iface);
1717 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1720 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1722 HTMLDocument *This = DISPEX_THIS(iface);
1724 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1727 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1729 HTMLDocument *This = DISPEX_THIS(iface);
1731 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1734 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1736 HTMLDocument *This = DISPEX_THIS(iface);
1738 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1741 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1743 HTMLDocument *This = DISPEX_THIS(iface);
1745 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1748 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1750 HTMLDocument *This = DISPEX_THIS(iface);
1752 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1755 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1757 HTMLDocument *This = DISPEX_THIS(iface);
1759 return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1764 static const IDispatchExVtbl DocDispatchExVtbl = {
1765 DocDispatchEx_QueryInterface,
1766 DocDispatchEx_AddRef,
1767 DocDispatchEx_Release,
1768 DocDispatchEx_GetTypeInfoCount,
1769 DocDispatchEx_GetTypeInfo,
1770 DocDispatchEx_GetIDsOfNames,
1771 DocDispatchEx_Invoke,
1772 DocDispatchEx_GetDispID,
1773 DocDispatchEx_InvokeEx,
1774 DocDispatchEx_DeleteMemberByName,
1775 DocDispatchEx_DeleteMemberByDispID,
1776 DocDispatchEx_GetMemberProperties,
1777 DocDispatchEx_GetMemberName,
1778 DocDispatchEx_GetNextDispID,
1779 DocDispatchEx_GetNameSpaceParent
1782 static const tid_t HTMLDocument_iface_tids[] = {
1789 static dispex_static_data_t HTMLDocument_dispex = {
1791 DispHTMLDocument_tid,
1793 HTMLDocument_iface_tids
1796 static HRESULT alloc_doc(HTMLDocument **ret)
1800 doc = heap_alloc_zero(sizeof(HTMLDocument));
1801 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1802 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1803 doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
1805 doc->readystate = READYSTATE_UNINITIALIZED;
1807 list_init(&doc->bindings);
1808 list_init(&doc->selection_list);
1809 list_init(&doc->range_list);
1811 HTMLDocument_HTMLDocument3_Init(doc);
1812 HTMLDocument_HTMLDocument5_Init(doc);
1813 HTMLDocument_Persist_Init(doc);
1814 HTMLDocument_OleCmd_Init(doc);
1815 HTMLDocument_OleObj_Init(doc);
1816 HTMLDocument_View_Init(doc);
1817 HTMLDocument_Window_Init(doc);
1818 HTMLDocument_Service_Init(doc);
1819 HTMLDocument_Hlink_Init(doc);
1821 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1822 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
1823 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
1824 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
1826 init_dispex(&doc->dispex, (IUnknown*)HTMLDOC(doc), &HTMLDocument_dispex);
1832 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocument **ret)
1837 hres = alloc_doc(&doc);
1841 nsIDOMHTMLDocument_AddRef(nsdoc);
1844 hres = HTMLWindow_Create(doc, NULL, &doc->window);
1846 IHTMLDocument_Release(HTMLDOC(doc));
1854 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1857 nsIDOMWindow *nswindow = NULL;
1860 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1862 hres = alloc_doc(&doc);
1866 hres = IHTMLDocument_QueryInterface(HTMLDOC(doc), riid, ppvObject);
1867 IHTMLDocument_Release(HTMLDOC(doc));
1871 doc->nscontainer = NSContainer_Create(doc, NULL);
1872 update_nsdocument(doc);
1874 if(doc->nscontainer) {
1877 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
1878 if(NS_FAILED(nsres))
1879 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1882 hres = HTMLWindow_Create(doc, nswindow, &doc->window);
1884 nsIDOMWindow_Release(nswindow);
1886 IHTMLDocument_Release(HTMLDOC(doc));