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
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
35 #define NO_SHLWAPI_REG
38 #include "wine/debug.h"
40 #include "mshtml_private.h"
41 #include "htmlevent.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
47 /* Undocumented notification, see tests */
48 #define CMDID_EXPLORER_UPDATEHISTORY 38
55 } download_proc_task_t;
57 static BOOL use_gecko_script(HTMLWindow *window)
62 hres = IInternetSecurityManager_MapUrlToZone(window->secmgr, window->url, &zone, 0);
64 WARN("Could not map %s to zone: %08x\n", debugstr_w(window->url), hres);
68 TRACE("zone %d\n", zone);
69 return zone == URLZONE_UNTRUSTED;
72 static void notify_travellog_update(HTMLDocumentObj *doc)
74 IOleCommandTarget *cmdtrg;
77 if(!doc->is_webbrowser)
80 /* Don't notify if we were in about: page */
81 if(doc->basedoc.window->uri) {
84 hres = IUri_GetScheme(doc->basedoc.window->uri, &scheme);
85 if(SUCCEEDED(hres) && scheme == URL_SCHEME_ABOUT)
89 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
96 IOleCommandTarget_Exec(cmdtrg, &CGID_Explorer, CMDID_EXPLORER_UPDATEHISTORY, 0, &vin, NULL);
97 IOleCommandTarget_Release(cmdtrg);
101 void set_current_uri(HTMLWindow *window, IUri *uri)
104 IUri_Release(window->uri);
108 SysFreeString(window->url);
117 IUri_GetDisplayUri(uri, &window->url);
120 void set_current_mon(HTMLWindow *This, IMoniker *mon)
122 IUriContainer *uri_container;
128 notify_travellog_update(This->doc_obj);
129 IMoniker_Release(This->mon);
136 IMoniker_AddRef(mon);
139 hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
140 if(SUCCEEDED(hres)) {
141 hres = IUriContainer_GetIUri(uri_container, &uri);
142 IUriContainer_Release(uri_container);
144 WARN("GetIUri failed: %08x\n", hres);
152 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
153 if(SUCCEEDED(hres)) {
154 hres = CreateUri(url, 0, 0, &uri);
156 WARN("CrateUri failed: %08x\n", hres);
157 set_current_uri(This, NULL);
158 This->url = SysAllocString(url);
164 WARN("GetDisplayName failed: %08x\n", hres);
168 set_current_uri(This, uri);
171 set_script_mode(This, use_gecko_script(This) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT);
174 HRESULT create_relative_uri(HTMLWindow *window, const WCHAR *rel_uri, IUri **uri)
177 ? CoInternetCombineUrlEx(window->uri, rel_uri, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, uri, 0)
178 : CreateUri(rel_uri, 0, 0, uri);
181 void set_download_state(HTMLDocumentObj *doc, int state)
184 IOleCommandTarget *olecmd;
187 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
188 if(SUCCEEDED(hres)) {
194 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE,
195 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
196 IOleCommandTarget_Release(olecmd);
200 doc->download_state = state;
203 static void set_progress_proc(task_t *_task)
205 docobj_task_t *task = (docobj_task_t*)_task;
206 IOleCommandTarget *olecmd = NULL;
207 HTMLDocumentObj *doc = task->doc;
210 TRACE("(%p)\n", doc);
213 IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
216 VARIANT progress_max, progress;
218 V_VT(&progress_max) = VT_I4;
219 V_I4(&progress_max) = 0; /* FIXME */
220 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSMAX, OLECMDEXECOPT_DONTPROMPTUSER,
221 &progress_max, NULL);
223 V_VT(&progress) = VT_I4;
224 V_I4(&progress) = 0; /* FIXME */
225 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSPOS, OLECMDEXECOPT_DONTPROMPTUSER,
227 IOleCommandTarget_Release(olecmd);
230 if(doc->usermode == EDITMODE && doc->hostui) {
231 DOCHOSTUIINFO hostinfo;
233 memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
234 hostinfo.cbSize = sizeof(DOCHOSTUIINFO);
235 hres = IDocHostUIHandler_GetHostInfo(doc->hostui, &hostinfo);
237 /* FIXME: use hostinfo */
238 TRACE("hostinfo = {%u %08x %08x %s %s}\n",
239 hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick,
240 debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS));
244 static void set_downloading_proc(task_t *_task)
246 download_proc_task_t *task = (download_proc_task_t*)_task;
247 HTMLDocumentObj *doc = task->doc;
250 TRACE("(%p)\n", doc);
252 set_statustext(doc, IDS_STATUS_DOWNLOADINGFROM, task->url);
254 if(task->set_download)
255 set_download_state(doc, 1);
261 IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1);
264 IDropTarget *drop_target = NULL;
266 hres = IDocHostUIHandler_GetDropTarget(doc->hostui, NULL /* FIXME */, &drop_target);
267 if(SUCCEEDED(hres) && drop_target) {
268 FIXME("Use IDropTarget\n");
269 IDropTarget_Release(drop_target);
274 static void set_downloading_task_destr(task_t *_task)
276 download_proc_task_t *task = (download_proc_task_t*)_task;
278 CoTaskMemFree(task->url);
282 void prepare_for_binding(HTMLDocument *This, IMoniker *mon, BOOL navigated_binding)
286 if(This->doc_obj->client) {
287 VARIANT silent, offline;
289 hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent);
290 if(SUCCEEDED(hres)) {
291 if(V_VT(&silent) != VT_BOOL)
292 WARN("silent = %s\n", debugstr_variant(&silent));
293 else if(V_BOOL(&silent))
294 FIXME("silent == true\n");
297 hres = get_client_disp_property(This->doc_obj->client,
298 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
299 if(SUCCEEDED(hres)) {
300 if(V_VT(&offline) != VT_BOOL)
301 WARN("offline = %s\n", debugstr_variant(&offline));
302 else if(V_BOOL(&offline))
303 FIXME("offline == true\n");
307 if(This->window->mon) {
308 update_doc(This, UPDATE_TITLE|UPDATE_UI);
310 update_doc(This, UPDATE_TITLE);
311 set_current_mon(This->window, mon);
314 if(This->doc_obj->client) {
315 IOleCommandTarget *cmdtrg = NULL;
317 hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget,
319 if(SUCCEEDED(hres)) {
322 if(!navigated_binding) {
325 IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL);
327 V_VT(&var) = VT_UNKNOWN;
328 V_UNKNOWN(&var) = (IUnknown*)&This->window->IHTMLWindow2_iface;
329 V_VT(&out) = VT_EMPTY;
330 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 63, 0, &var, &out);
335 IOleCommandTarget_Release(cmdtrg);
340 HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download)
342 download_proc_task_t *download_task;
343 nsChannelBSC *bscallback;
348 hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url);
350 WARN("GetDiaplayName failed: %08x\n", hres);
354 TRACE("got url: %s\n", debugstr_w(url));
356 set_ready_state(This->window, READYSTATE_LOADING);
358 hres = create_doc_uri(This->window, url, &nsuri);
359 if(SUCCEEDED(hres)) {
361 bscallback = async_bsc;
363 hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback);
366 if(SUCCEEDED(hres)) {
367 remove_target_tasks(This->task_magic);
368 abort_document_bindings(This->doc_node);
370 hres = load_nsuri(This->window, nsuri, bscallback, 0/*LOAD_INITIAL_DOCUMENT_URI*/);
371 nsISupports_Release((nsISupports*)nsuri); /* FIXME */
373 set_window_bscallback(This->window, bscallback);
374 if(bscallback != async_bsc)
375 IUnknown_Release((IUnknown*)bscallback);
383 HTMLDocument_LockContainer(This->doc_obj, TRUE);
385 if(This->doc_obj->frame) {
388 task = heap_alloc(sizeof(docobj_task_t));
389 task->doc = This->doc_obj;
390 push_task(&task->header, set_progress_proc, NULL, This->doc_obj->basedoc.task_magic);
393 download_task = heap_alloc(sizeof(download_proc_task_t));
394 download_task->doc = This->doc_obj;
395 download_task->set_download = set_download;
396 download_task->url = url;
397 push_task(&download_task->header, set_downloading_proc, set_downloading_task_destr, This->doc_obj->basedoc.task_magic);
402 void set_ready_state(HTMLWindow *window, READYSTATE readystate)
404 window->readystate = readystate;
406 if(window->doc_obj && window->doc_obj->basedoc.window == window)
407 call_property_onchanged(&window->doc_obj->basedoc.cp_propnotif, DISPID_READYSTATE);
409 fire_event(window->doc, EVENTID_READYSTATECHANGE, FALSE, window->doc->node.nsnode, NULL);
411 if(window->frame_element)
412 fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE,
413 TRUE, window->frame_element->element.node.nsnode, NULL);
416 static HRESULT get_doc_string(HTMLDocumentNode *This, char **str)
425 WARN("NULL nsdoc\n");
429 nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNode, (void**)&nsnode);
430 if(NS_FAILED(nsres)) {
431 ERR("Could not get nsIDOMNode failed: %08x\n", nsres);
435 nsAString_Init(&nsstr, NULL);
436 hres = nsnode_to_nsstring(nsnode, &nsstr);
437 nsIDOMNode_Release(nsnode);
439 nsAString_Finish(&nsstr);
443 nsAString_GetData(&nsstr, &strw);
444 TRACE("%s\n", debugstr_w(strw));
446 *str = heap_strdupWtoA(strw);
448 nsAString_Finish(&nsstr);
451 return E_OUTOFMEMORY;
456 /**********************************************************
457 * IPersistMoniker implementation
460 static inline HTMLDocument *impl_from_IPersistMoniker(IPersistMoniker *iface)
462 return CONTAINING_RECORD(iface, HTMLDocument, IPersistMoniker_iface);
465 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
467 HTMLDocument *This = impl_from_IPersistMoniker(iface);
468 return htmldoc_query_interface(This, riid, ppv);
471 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
473 HTMLDocument *This = impl_from_IPersistMoniker(iface);
474 return htmldoc_addref(This);
477 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
479 HTMLDocument *This = impl_from_IPersistMoniker(iface);
480 return htmldoc_release(This);
483 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
485 HTMLDocument *This = impl_from_IPersistMoniker(iface);
486 return IPersist_GetClassID(&This->IPersistFile_iface, pClassID);
489 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
491 HTMLDocument *This = impl_from_IPersistMoniker(iface);
493 TRACE("(%p)\n", This);
495 return IPersistStreamInit_IsDirty(&This->IPersistStreamInit_iface);
498 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
499 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
501 HTMLDocument *This = impl_from_IPersistMoniker(iface);
504 TRACE("(%p)->(%x %p %p %08x)\n", This, fFullyAvailable, pimkName, pibc, grfMode);
507 IUnknown *unk = NULL;
511 * "__PrecreatedObject"
512 * "BIND_CONTEXT_PARAM"
513 * "__HTMLLOADOPTIONS"
516 * "_ITransData_Object_"
520 IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk);
522 IOleClientSite *client = NULL;
524 hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client);
525 if(SUCCEEDED(hres)) {
526 TRACE("Got client site %p\n", client);
527 IOleObject_SetClientSite(&This->IOleObject_iface, client);
528 IOleClientSite_Release(client);
531 IUnknown_Release(unk);
535 prepare_for_binding(This, pimkName, FALSE);
536 hres = set_moniker(This, pimkName, pibc, NULL, TRUE);
540 return start_binding(This->window, NULL, (BSCallback*)This->window->bscallback, pibc);
543 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName,
544 LPBC pbc, BOOL fRemember)
546 HTMLDocument *This = impl_from_IPersistMoniker(iface);
547 FIXME("(%p)->(%p %p %x)\n", This, pimkName, pbc, fRemember);
551 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
553 HTMLDocument *This = impl_from_IPersistMoniker(iface);
554 FIXME("(%p)->(%p %p)\n", This, pimkName, pibc);
558 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **ppimkName)
560 HTMLDocument *This = impl_from_IPersistMoniker(iface);
562 TRACE("(%p)->(%p)\n", This, ppimkName);
564 if(!This->window || !This->window->mon)
567 IMoniker_AddRef(This->window->mon);
568 *ppimkName = This->window->mon;
572 static const IPersistMonikerVtbl PersistMonikerVtbl = {
573 PersistMoniker_QueryInterface,
574 PersistMoniker_AddRef,
575 PersistMoniker_Release,
576 PersistMoniker_GetClassID,
577 PersistMoniker_IsDirty,
580 PersistMoniker_SaveCompleted,
581 PersistMoniker_GetCurMoniker
584 /**********************************************************
585 * IMonikerProp implementation
588 static inline HTMLDocument *impl_from_IMonikerProp(IMonikerProp *iface)
590 return CONTAINING_RECORD(iface, HTMLDocument, IMonikerProp_iface);
593 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
595 HTMLDocument *This = impl_from_IMonikerProp(iface);
596 return htmldoc_query_interface(This, riid, ppv);
599 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
601 HTMLDocument *This = impl_from_IMonikerProp(iface);
602 return htmldoc_addref(This);
605 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
607 HTMLDocument *This = impl_from_IMonikerProp(iface);
608 return htmldoc_release(This);
611 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
613 HTMLDocument *This = impl_from_IMonikerProp(iface);
615 TRACE("(%p)->(%d %s)\n", This, mkp, debugstr_w(val));
619 heap_free(This->doc_obj->mime);
620 This->doc_obj->mime = heap_strdupW(val);
627 FIXME("mkp %d\n", mkp);
634 static const IMonikerPropVtbl MonikerPropVtbl = {
635 MonikerProp_QueryInterface,
638 MonikerProp_PutProperty
641 /**********************************************************
642 * IPersistFile implementation
645 static inline HTMLDocument *impl_from_IPersistFile(IPersistFile *iface)
647 return CONTAINING_RECORD(iface, HTMLDocument, IPersistFile_iface);
650 static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *iface, REFIID riid, void **ppv)
652 HTMLDocument *This = impl_from_IPersistFile(iface);
653 return htmldoc_query_interface(This, riid, ppv);
656 static ULONG WINAPI PersistFile_AddRef(IPersistFile *iface)
658 HTMLDocument *This = impl_from_IPersistFile(iface);
659 return htmldoc_addref(This);
662 static ULONG WINAPI PersistFile_Release(IPersistFile *iface)
664 HTMLDocument *This = impl_from_IPersistFile(iface);
665 return htmldoc_release(This);
668 static HRESULT WINAPI PersistFile_GetClassID(IPersistFile *iface, CLSID *pClassID)
670 HTMLDocument *This = impl_from_IPersistFile(iface);
672 TRACE("(%p)->(%p)\n", This, pClassID);
677 *pClassID = CLSID_HTMLDocument;
681 static HRESULT WINAPI PersistFile_IsDirty(IPersistFile *iface)
683 HTMLDocument *This = impl_from_IPersistFile(iface);
685 TRACE("(%p)\n", This);
687 return IPersistStreamInit_IsDirty(&This->IPersistStreamInit_iface);
690 static HRESULT WINAPI PersistFile_Load(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode)
692 HTMLDocument *This = impl_from_IPersistFile(iface);
693 FIXME("(%p)->(%s %08x)\n", This, debugstr_w(pszFileName), dwMode);
697 static HRESULT WINAPI PersistFile_Save(IPersistFile *iface, LPCOLESTR pszFileName, BOOL fRemember)
699 HTMLDocument *This = impl_from_IPersistFile(iface);
705 TRACE("(%p)->(%s %x)\n", This, debugstr_w(pszFileName), fRemember);
707 file = CreateFileW(pszFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
708 FILE_ATTRIBUTE_NORMAL, NULL);
709 if(file == INVALID_HANDLE_VALUE) {
710 WARN("Could not create file: %u\n", GetLastError());
714 hres = get_doc_string(This->doc_node, &str);
716 WriteFile(file, str, strlen(str), &written, NULL);
722 static HRESULT WINAPI PersistFile_SaveCompleted(IPersistFile *iface, LPCOLESTR pszFileName)
724 HTMLDocument *This = impl_from_IPersistFile(iface);
725 FIXME("(%p)->(%s)\n", This, debugstr_w(pszFileName));
729 static HRESULT WINAPI PersistFile_GetCurFile(IPersistFile *iface, LPOLESTR *pszFileName)
731 HTMLDocument *This = impl_from_IPersistFile(iface);
732 FIXME("(%p)->(%p)\n", This, pszFileName);
736 static const IPersistFileVtbl PersistFileVtbl = {
737 PersistFile_QueryInterface,
740 PersistFile_GetClassID,
744 PersistFile_SaveCompleted,
745 PersistFile_GetCurFile
748 static inline HTMLDocument *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
750 return CONTAINING_RECORD(iface, HTMLDocument, IPersistStreamInit_iface);
753 static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface,
754 REFIID riid, void **ppv)
756 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
757 return htmldoc_query_interface(This, riid, ppv);
760 static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
762 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
763 return htmldoc_addref(This);
766 static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
768 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
769 return htmldoc_release(This);
772 static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *pClassID)
774 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
775 return IPersist_GetClassID(&This->IPersistFile_iface, pClassID);
778 static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
780 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
782 TRACE("(%p)\n", This);
784 if(This->doc_obj->usermode == EDITMODE)
785 return editor_is_dirty(This);
790 static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM pStm)
792 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
796 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
798 TRACE("(%p)->(%p)\n", This, pStm);
800 hres = CreateURLMoniker(NULL, about_blankW, &mon);
802 WARN("CreateURLMoniker failed: %08x\n", hres);
806 prepare_for_binding(This, mon, FALSE);
807 hres = set_moniker(This, mon, NULL, NULL, TRUE);
808 IMoniker_Release(mon);
812 return channelbsc_load_stream(This->window->bscallback, pStm);
815 static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStm,
818 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
823 TRACE("(%p)->(%p %x)\n", This, pStm, fClearDirty);
825 hres = get_doc_string(This->doc_node, &str);
829 hres = IStream_Write(pStm, str, strlen(str), &written);
831 FIXME("Write failed: %08x\n", hres);
836 set_dirty(This, VARIANT_FALSE);
841 static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
842 ULARGE_INTEGER *pcbSize)
844 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
845 FIXME("(%p)->(%p)\n", This, pcbSize);
849 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
851 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
855 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
857 TRACE("(%p)\n", This);
859 hres = CreateURLMoniker(NULL, about_blankW, &mon);
861 WARN("CreateURLMoniker failed: %08x\n", hres);
865 prepare_for_binding(This, mon, FALSE);
866 hres = set_moniker(This, mon, NULL, NULL, FALSE);
867 IMoniker_Release(mon);
871 return channelbsc_load_stream(This->window->bscallback, NULL);
874 static const IPersistStreamInitVtbl PersistStreamInitVtbl = {
875 PersistStreamInit_QueryInterface,
876 PersistStreamInit_AddRef,
877 PersistStreamInit_Release,
878 PersistStreamInit_GetClassID,
879 PersistStreamInit_IsDirty,
880 PersistStreamInit_Load,
881 PersistStreamInit_Save,
882 PersistStreamInit_GetSizeMax,
883 PersistStreamInit_InitNew
886 /**********************************************************
887 * IPersistHistory implementation
890 static inline HTMLDocument *impl_from_IPersistHistory(IPersistHistory *iface)
892 return CONTAINING_RECORD(iface, HTMLDocument, IPersistHistory_iface);
895 static HRESULT WINAPI PersistHistory_QueryInterface(IPersistHistory *iface, REFIID riid, void **ppv)
897 HTMLDocument *This = impl_from_IPersistHistory(iface);
898 return htmldoc_query_interface(This, riid, ppv);
901 static ULONG WINAPI PersistHistory_AddRef(IPersistHistory *iface)
903 HTMLDocument *This = impl_from_IPersistHistory(iface);
904 return htmldoc_addref(This);
907 static ULONG WINAPI PersistHistory_Release(IPersistHistory *iface)
909 HTMLDocument *This = impl_from_IPersistHistory(iface);
910 return htmldoc_release(This);
913 static HRESULT WINAPI PersistHistory_GetClassID(IPersistHistory *iface, CLSID *pClassID)
915 HTMLDocument *This = impl_from_IPersistHistory(iface);
916 return IPersist_GetClassID(&This->IPersistFile_iface, pClassID);
919 static HRESULT WINAPI PersistHistory_LoadHistory(IPersistHistory *iface, IStream *pStream, IBindCtx *pbc)
921 HTMLDocument *This = impl_from_IPersistHistory(iface);
922 FIXME("(%p)->(%p %p)\n", This, pStream, pbc);
926 static HRESULT WINAPI PersistHistory_SaveHistory(IPersistHistory *iface, IStream *pStream)
928 HTMLDocument *This = impl_from_IPersistHistory(iface);
929 FIXME("(%p)->(%p)\n", This, pStream);
933 static HRESULT WINAPI PersistHistory_SetPositionCookie(IPersistHistory *iface, DWORD dwPositioncookie)
935 HTMLDocument *This = impl_from_IPersistHistory(iface);
936 FIXME("(%p)->(%x)\n", This, dwPositioncookie);
940 static HRESULT WINAPI PersistHistory_GetPositionCookie(IPersistHistory *iface, DWORD *pdwPositioncookie)
942 HTMLDocument *This = impl_from_IPersistHistory(iface);
943 FIXME("(%p)->(%p)\n", This, pdwPositioncookie);
947 static const IPersistHistoryVtbl PersistHistoryVtbl = {
948 PersistHistory_QueryInterface,
949 PersistHistory_AddRef,
950 PersistHistory_Release,
951 PersistHistory_GetClassID,
952 PersistHistory_LoadHistory,
953 PersistHistory_SaveHistory,
954 PersistHistory_SetPositionCookie,
955 PersistHistory_GetPositionCookie
958 void HTMLDocument_Persist_Init(HTMLDocument *This)
960 This->IPersistMoniker_iface.lpVtbl = &PersistMonikerVtbl;
961 This->IPersistFile_iface.lpVtbl = &PersistFileVtbl;
962 This->IMonikerProp_iface.lpVtbl = &MonikerPropVtbl;
963 This->IPersistStreamInit_iface.lpVtbl = &PersistStreamInitVtbl;
964 This->IPersistHistory_iface.lpVtbl = &PersistHistoryVtbl;