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 "htmlscript.h"
42 #include "htmlevent.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
48 /* Undocumented notification, see tests */
49 #define CMDID_EXPLORER_UPDATEHISTORY 38
56 } download_proc_task_t;
58 static BOOL use_gecko_script(HTMLOuterWindow *window)
63 hres = IInternetSecurityManager_MapUrlToZone(window->secmgr, window->url, &zone, 0);
65 WARN("Could not map %s to zone: %08x\n", debugstr_w(window->url), hres);
69 TRACE("zone %d\n", zone);
70 return zone == URLZONE_UNTRUSTED;
73 static void notify_travellog_update(HTMLDocumentObj *doc)
75 IOleCommandTarget *cmdtrg;
78 if(!doc->is_webbrowser)
81 /* Don't notify if we were in about: page */
82 if(doc->basedoc.window->uri) {
85 hres = IUri_GetScheme(doc->basedoc.window->uri, &scheme);
86 if(SUCCEEDED(hres) && scheme == URL_SCHEME_ABOUT)
90 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
97 IOleCommandTarget_Exec(cmdtrg, &CGID_Explorer, CMDID_EXPLORER_UPDATEHISTORY, 0, &vin, NULL);
98 IOleCommandTarget_Release(cmdtrg);
102 void set_current_uri(HTMLOuterWindow *window, IUri *uri)
105 IUri_Release(window->uri);
109 SysFreeString(window->url);
118 IUri_GetDisplayUri(uri, &window->url);
121 void set_current_mon(HTMLOuterWindow *This, IMoniker *mon)
123 IUriContainer *uri_container;
129 notify_travellog_update(This->doc_obj);
130 IMoniker_Release(This->mon);
137 IMoniker_AddRef(mon);
140 hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
141 if(SUCCEEDED(hres)) {
142 hres = IUriContainer_GetIUri(uri_container, &uri);
143 IUriContainer_Release(uri_container);
145 WARN("GetIUri failed: %08x\n", hres);
153 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
154 if(SUCCEEDED(hres)) {
155 hres = CreateUri(url, 0, 0, &uri);
157 WARN("CrateUri failed: %08x\n", hres);
158 set_current_uri(This, NULL);
159 This->url = SysAllocString(url);
165 WARN("GetDisplayName failed: %08x\n", hres);
169 set_current_uri(This, uri);
172 set_script_mode(This, use_gecko_script(This) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT);
175 HRESULT create_relative_uri(HTMLOuterWindow *window, const WCHAR *rel_uri, IUri **uri)
178 ? CoInternetCombineUrlEx(window->uri, rel_uri, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, uri, 0)
179 : CreateUri(rel_uri, 0, 0, uri);
182 void set_download_state(HTMLDocumentObj *doc, int state)
185 IOleCommandTarget *olecmd;
188 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
189 if(SUCCEEDED(hres)) {
195 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE,
196 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
197 IOleCommandTarget_Release(olecmd);
201 doc->download_state = state;
204 static void set_progress_proc(task_t *_task)
206 docobj_task_t *task = (docobj_task_t*)_task;
207 IOleCommandTarget *olecmd = NULL;
208 HTMLDocumentObj *doc = task->doc;
211 TRACE("(%p)\n", doc);
214 IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
217 VARIANT progress_max, progress;
219 V_VT(&progress_max) = VT_I4;
220 V_I4(&progress_max) = 0; /* FIXME */
221 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSMAX, OLECMDEXECOPT_DONTPROMPTUSER,
222 &progress_max, NULL);
224 V_VT(&progress) = VT_I4;
225 V_I4(&progress) = 0; /* FIXME */
226 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSPOS, OLECMDEXECOPT_DONTPROMPTUSER,
228 IOleCommandTarget_Release(olecmd);
231 if(doc->usermode == EDITMODE && doc->hostui) {
232 DOCHOSTUIINFO hostinfo;
234 memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
235 hostinfo.cbSize = sizeof(DOCHOSTUIINFO);
236 hres = IDocHostUIHandler_GetHostInfo(doc->hostui, &hostinfo);
238 /* FIXME: use hostinfo */
239 TRACE("hostinfo = {%u %08x %08x %s %s}\n",
240 hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick,
241 debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS));
245 static void set_downloading_proc(task_t *_task)
247 download_proc_task_t *task = (download_proc_task_t*)_task;
248 HTMLDocumentObj *doc = task->doc;
251 TRACE("(%p)\n", doc);
253 set_statustext(doc, IDS_STATUS_DOWNLOADINGFROM, task->url);
255 if(task->set_download)
256 set_download_state(doc, 1);
262 IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1);
265 IDropTarget *drop_target = NULL;
267 hres = IDocHostUIHandler_GetDropTarget(doc->hostui, NULL /* FIXME */, &drop_target);
268 if(SUCCEEDED(hres) && drop_target) {
269 FIXME("Use IDropTarget\n");
270 IDropTarget_Release(drop_target);
275 static void set_downloading_task_destr(task_t *_task)
277 download_proc_task_t *task = (download_proc_task_t*)_task;
279 CoTaskMemFree(task->url);
283 void prepare_for_binding(HTMLDocument *This, IMoniker *mon, BOOL navigated_binding)
287 if(This->doc_obj->client) {
288 VARIANT silent, offline;
290 hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent);
291 if(SUCCEEDED(hres)) {
292 if(V_VT(&silent) != VT_BOOL)
293 WARN("silent = %s\n", debugstr_variant(&silent));
294 else if(V_BOOL(&silent))
295 FIXME("silent == true\n");
298 hres = get_client_disp_property(This->doc_obj->client,
299 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
300 if(SUCCEEDED(hres)) {
301 if(V_VT(&offline) != VT_BOOL)
302 WARN("offline = %s\n", debugstr_variant(&offline));
303 else if(V_BOOL(&offline))
304 FIXME("offline == true\n");
308 if(This->window->mon) {
309 update_doc(This, UPDATE_TITLE|UPDATE_UI);
311 update_doc(This, UPDATE_TITLE);
312 set_current_mon(This->window, mon);
315 if(This->doc_obj->client) {
316 IOleCommandTarget *cmdtrg = NULL;
318 hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget,
320 if(SUCCEEDED(hres)) {
323 if(!navigated_binding) {
326 IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL);
328 V_VT(&var) = VT_UNKNOWN;
329 V_UNKNOWN(&var) = (IUnknown*)&This->window->base.IHTMLWindow2_iface;
330 V_VT(&out) = VT_EMPTY;
331 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 63, 0, &var, &out);
336 IOleCommandTarget_Release(cmdtrg);
341 HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download)
343 download_proc_task_t *download_task;
344 nsChannelBSC *bscallback;
349 hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url);
351 WARN("GetDiaplayName failed: %08x\n", hres);
355 TRACE("got url: %s\n", debugstr_w(url));
357 set_ready_state(This->window, READYSTATE_LOADING);
359 hres = create_doc_uri(This->window, url, &nsuri);
360 if(SUCCEEDED(hres)) {
362 bscallback = async_bsc;
364 hres = create_channelbsc(mon, NULL, NULL, 0, TRUE, &bscallback);
367 if(SUCCEEDED(hres)) {
368 remove_target_tasks(This->task_magic);
369 abort_window_bindings(This->window->base.inner_window);
371 hres = load_nsuri(This->window, nsuri, bscallback, 0/*LOAD_INITIAL_DOCUMENT_URI*/);
372 nsISupports_Release((nsISupports*)nsuri); /* FIXME */
374 hres = create_pending_window(This->window, bscallback);
375 if(bscallback != async_bsc)
376 IBindStatusCallback_Release(&bscallback->bsc.IBindStatusCallback_iface);
384 HTMLDocument_LockContainer(This->doc_obj, TRUE);
386 if(This->doc_obj->frame) {
389 task = heap_alloc(sizeof(docobj_task_t));
390 task->doc = This->doc_obj;
391 hres = push_task(&task->header, set_progress_proc, NULL, This->doc_obj->basedoc.task_magic);
398 download_task = heap_alloc(sizeof(download_proc_task_t));
399 download_task->doc = This->doc_obj;
400 download_task->set_download = set_download;
401 download_task->url = url;
402 return push_task(&download_task->header, set_downloading_proc, set_downloading_task_destr, This->doc_obj->basedoc.task_magic);
405 void set_ready_state(HTMLOuterWindow *window, READYSTATE readystate)
407 window->readystate = readystate;
409 if(window->doc_obj && window->doc_obj->basedoc.window == window)
410 call_property_onchanged(&window->doc_obj->basedoc.cp_propnotif, DISPID_READYSTATE);
412 fire_event(window->base.inner_window->doc, EVENTID_READYSTATECHANGE, FALSE,
413 window->base.inner_window->doc->node.nsnode, NULL, NULL);
415 if(window->frame_element)
416 fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE,
417 TRUE, window->frame_element->element.node.nsnode, NULL, NULL);
420 static HRESULT get_doc_string(HTMLDocumentNode *This, char **str)
429 WARN("NULL nsdoc\n");
433 nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNode, (void**)&nsnode);
434 if(NS_FAILED(nsres)) {
435 ERR("Could not get nsIDOMNode failed: %08x\n", nsres);
439 nsAString_Init(&nsstr, NULL);
440 hres = nsnode_to_nsstring(nsnode, &nsstr);
441 nsIDOMNode_Release(nsnode);
443 nsAString_Finish(&nsstr);
447 nsAString_GetData(&nsstr, &strw);
448 TRACE("%s\n", debugstr_w(strw));
450 *str = heap_strdupWtoA(strw);
452 nsAString_Finish(&nsstr);
455 return E_OUTOFMEMORY;
460 /**********************************************************
461 * IPersistMoniker implementation
464 static inline HTMLDocument *impl_from_IPersistMoniker(IPersistMoniker *iface)
466 return CONTAINING_RECORD(iface, HTMLDocument, IPersistMoniker_iface);
469 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
471 HTMLDocument *This = impl_from_IPersistMoniker(iface);
472 return htmldoc_query_interface(This, riid, ppv);
475 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
477 HTMLDocument *This = impl_from_IPersistMoniker(iface);
478 return htmldoc_addref(This);
481 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
483 HTMLDocument *This = impl_from_IPersistMoniker(iface);
484 return htmldoc_release(This);
487 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
489 HTMLDocument *This = impl_from_IPersistMoniker(iface);
490 return IPersistFile_GetClassID(&This->IPersistFile_iface, pClassID);
493 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
495 HTMLDocument *This = impl_from_IPersistMoniker(iface);
497 TRACE("(%p)\n", This);
499 return IPersistStreamInit_IsDirty(&This->IPersistStreamInit_iface);
502 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
503 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
505 HTMLDocument *This = impl_from_IPersistMoniker(iface);
508 TRACE("(%p)->(%x %p %p %08x)\n", This, fFullyAvailable, pimkName, pibc, grfMode);
511 IUnknown *unk = NULL;
515 * "__PrecreatedObject"
516 * "BIND_CONTEXT_PARAM"
517 * "__HTMLLOADOPTIONS"
520 * "_ITransData_Object_"
524 hres = IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk);
525 if(SUCCEEDED(hres) && unk) {
526 IOleClientSite *client = NULL;
528 hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client);
529 if(SUCCEEDED(hres)) {
530 TRACE("Got client site %p\n", client);
531 IOleObject_SetClientSite(&This->IOleObject_iface, client);
532 IOleClientSite_Release(client);
535 IUnknown_Release(unk);
539 prepare_for_binding(This, pimkName, FALSE);
540 call_docview_84(This->doc_obj);
541 hres = set_moniker(This, pimkName, pibc, NULL, TRUE);
545 return start_binding(This->window->pending_window, (BSCallback*)This->window->pending_window->bscallback, pibc);
548 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName,
549 LPBC pbc, BOOL fRemember)
551 HTMLDocument *This = impl_from_IPersistMoniker(iface);
552 FIXME("(%p)->(%p %p %x)\n", This, pimkName, pbc, fRemember);
556 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
558 HTMLDocument *This = impl_from_IPersistMoniker(iface);
559 FIXME("(%p)->(%p %p)\n", This, pimkName, pibc);
563 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **ppimkName)
565 HTMLDocument *This = impl_from_IPersistMoniker(iface);
567 TRACE("(%p)->(%p)\n", This, ppimkName);
569 if(!This->window || !This->window->mon)
572 IMoniker_AddRef(This->window->mon);
573 *ppimkName = This->window->mon;
577 static const IPersistMonikerVtbl PersistMonikerVtbl = {
578 PersistMoniker_QueryInterface,
579 PersistMoniker_AddRef,
580 PersistMoniker_Release,
581 PersistMoniker_GetClassID,
582 PersistMoniker_IsDirty,
585 PersistMoniker_SaveCompleted,
586 PersistMoniker_GetCurMoniker
589 /**********************************************************
590 * IMonikerProp implementation
593 static inline HTMLDocument *impl_from_IMonikerProp(IMonikerProp *iface)
595 return CONTAINING_RECORD(iface, HTMLDocument, IMonikerProp_iface);
598 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
600 HTMLDocument *This = impl_from_IMonikerProp(iface);
601 return htmldoc_query_interface(This, riid, ppv);
604 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
606 HTMLDocument *This = impl_from_IMonikerProp(iface);
607 return htmldoc_addref(This);
610 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
612 HTMLDocument *This = impl_from_IMonikerProp(iface);
613 return htmldoc_release(This);
616 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
618 HTMLDocument *This = impl_from_IMonikerProp(iface);
620 TRACE("(%p)->(%d %s)\n", This, mkp, debugstr_w(val));
624 heap_free(This->doc_obj->mime);
625 This->doc_obj->mime = heap_strdupW(val);
632 FIXME("mkp %d\n", mkp);
639 static const IMonikerPropVtbl MonikerPropVtbl = {
640 MonikerProp_QueryInterface,
643 MonikerProp_PutProperty
646 /**********************************************************
647 * IPersistFile implementation
650 static inline HTMLDocument *impl_from_IPersistFile(IPersistFile *iface)
652 return CONTAINING_RECORD(iface, HTMLDocument, IPersistFile_iface);
655 static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *iface, REFIID riid, void **ppv)
657 HTMLDocument *This = impl_from_IPersistFile(iface);
658 return htmldoc_query_interface(This, riid, ppv);
661 static ULONG WINAPI PersistFile_AddRef(IPersistFile *iface)
663 HTMLDocument *This = impl_from_IPersistFile(iface);
664 return htmldoc_addref(This);
667 static ULONG WINAPI PersistFile_Release(IPersistFile *iface)
669 HTMLDocument *This = impl_from_IPersistFile(iface);
670 return htmldoc_release(This);
673 static HRESULT WINAPI PersistFile_GetClassID(IPersistFile *iface, CLSID *pClassID)
675 HTMLDocument *This = impl_from_IPersistFile(iface);
677 TRACE("(%p)->(%p)\n", This, pClassID);
682 *pClassID = CLSID_HTMLDocument;
686 static HRESULT WINAPI PersistFile_IsDirty(IPersistFile *iface)
688 HTMLDocument *This = impl_from_IPersistFile(iface);
690 TRACE("(%p)\n", This);
692 return IPersistStreamInit_IsDirty(&This->IPersistStreamInit_iface);
695 static HRESULT WINAPI PersistFile_Load(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode)
697 HTMLDocument *This = impl_from_IPersistFile(iface);
698 FIXME("(%p)->(%s %08x)\n", This, debugstr_w(pszFileName), dwMode);
702 static HRESULT WINAPI PersistFile_Save(IPersistFile *iface, LPCOLESTR pszFileName, BOOL fRemember)
704 HTMLDocument *This = impl_from_IPersistFile(iface);
710 TRACE("(%p)->(%s %x)\n", This, debugstr_w(pszFileName), fRemember);
712 file = CreateFileW(pszFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
713 FILE_ATTRIBUTE_NORMAL, NULL);
714 if(file == INVALID_HANDLE_VALUE) {
715 WARN("Could not create file: %u\n", GetLastError());
719 hres = get_doc_string(This->doc_node, &str);
721 WriteFile(file, str, strlen(str), &written, NULL);
727 static HRESULT WINAPI PersistFile_SaveCompleted(IPersistFile *iface, LPCOLESTR pszFileName)
729 HTMLDocument *This = impl_from_IPersistFile(iface);
730 FIXME("(%p)->(%s)\n", This, debugstr_w(pszFileName));
734 static HRESULT WINAPI PersistFile_GetCurFile(IPersistFile *iface, LPOLESTR *pszFileName)
736 HTMLDocument *This = impl_from_IPersistFile(iface);
737 FIXME("(%p)->(%p)\n", This, pszFileName);
741 static const IPersistFileVtbl PersistFileVtbl = {
742 PersistFile_QueryInterface,
745 PersistFile_GetClassID,
749 PersistFile_SaveCompleted,
750 PersistFile_GetCurFile
753 static inline HTMLDocument *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
755 return CONTAINING_RECORD(iface, HTMLDocument, IPersistStreamInit_iface);
758 static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface,
759 REFIID riid, void **ppv)
761 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
762 return htmldoc_query_interface(This, riid, ppv);
765 static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
767 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
768 return htmldoc_addref(This);
771 static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
773 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
774 return htmldoc_release(This);
777 static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *pClassID)
779 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
780 return IPersistFile_GetClassID(&This->IPersistFile_iface, pClassID);
783 static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
785 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
787 TRACE("(%p)\n", This);
789 if(This->doc_obj->usermode == EDITMODE)
790 return editor_is_dirty(This);
795 static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM pStm)
797 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
801 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
803 TRACE("(%p)->(%p)\n", This, pStm);
805 hres = CreateURLMoniker(NULL, about_blankW, &mon);
807 WARN("CreateURLMoniker failed: %08x\n", hres);
811 prepare_for_binding(This, mon, FALSE);
812 hres = set_moniker(This, mon, NULL, NULL, TRUE);
813 IMoniker_Release(mon);
817 return channelbsc_load_stream(This->window->pending_window, pStm);
820 static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStm,
823 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
828 TRACE("(%p)->(%p %x)\n", This, pStm, fClearDirty);
830 hres = get_doc_string(This->doc_node, &str);
834 hres = IStream_Write(pStm, str, strlen(str), &written);
836 FIXME("Write failed: %08x\n", hres);
841 set_dirty(This, VARIANT_FALSE);
846 static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
847 ULARGE_INTEGER *pcbSize)
849 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
850 FIXME("(%p)->(%p)\n", This, pcbSize);
854 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
856 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
860 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
862 TRACE("(%p)\n", This);
864 hres = CreateURLMoniker(NULL, about_blankW, &mon);
866 WARN("CreateURLMoniker failed: %08x\n", hres);
870 prepare_for_binding(This, mon, FALSE);
871 hres = set_moniker(This, mon, NULL, NULL, FALSE);
872 IMoniker_Release(mon);
876 return channelbsc_load_stream(This->window->pending_window, NULL);
879 static const IPersistStreamInitVtbl PersistStreamInitVtbl = {
880 PersistStreamInit_QueryInterface,
881 PersistStreamInit_AddRef,
882 PersistStreamInit_Release,
883 PersistStreamInit_GetClassID,
884 PersistStreamInit_IsDirty,
885 PersistStreamInit_Load,
886 PersistStreamInit_Save,
887 PersistStreamInit_GetSizeMax,
888 PersistStreamInit_InitNew
891 /**********************************************************
892 * IPersistHistory implementation
895 static inline HTMLDocument *impl_from_IPersistHistory(IPersistHistory *iface)
897 return CONTAINING_RECORD(iface, HTMLDocument, IPersistHistory_iface);
900 static HRESULT WINAPI PersistHistory_QueryInterface(IPersistHistory *iface, REFIID riid, void **ppv)
902 HTMLDocument *This = impl_from_IPersistHistory(iface);
903 return htmldoc_query_interface(This, riid, ppv);
906 static ULONG WINAPI PersistHistory_AddRef(IPersistHistory *iface)
908 HTMLDocument *This = impl_from_IPersistHistory(iface);
909 return htmldoc_addref(This);
912 static ULONG WINAPI PersistHistory_Release(IPersistHistory *iface)
914 HTMLDocument *This = impl_from_IPersistHistory(iface);
915 return htmldoc_release(This);
918 static HRESULT WINAPI PersistHistory_GetClassID(IPersistHistory *iface, CLSID *pClassID)
920 HTMLDocument *This = impl_from_IPersistHistory(iface);
921 return IPersistFile_GetClassID(&This->IPersistFile_iface, pClassID);
924 static HRESULT WINAPI PersistHistory_LoadHistory(IPersistHistory *iface, IStream *pStream, IBindCtx *pbc)
926 HTMLDocument *This = impl_from_IPersistHistory(iface);
927 FIXME("(%p)->(%p %p)\n", This, pStream, pbc);
931 static HRESULT WINAPI PersistHistory_SaveHistory(IPersistHistory *iface, IStream *pStream)
933 HTMLDocument *This = impl_from_IPersistHistory(iface);
934 FIXME("(%p)->(%p)\n", This, pStream);
938 static HRESULT WINAPI PersistHistory_SetPositionCookie(IPersistHistory *iface, DWORD dwPositioncookie)
940 HTMLDocument *This = impl_from_IPersistHistory(iface);
941 FIXME("(%p)->(%x)\n", This, dwPositioncookie);
945 static HRESULT WINAPI PersistHistory_GetPositionCookie(IPersistHistory *iface, DWORD *pdwPositioncookie)
947 HTMLDocument *This = impl_from_IPersistHistory(iface);
948 FIXME("(%p)->(%p)\n", This, pdwPositioncookie);
952 static const IPersistHistoryVtbl PersistHistoryVtbl = {
953 PersistHistory_QueryInterface,
954 PersistHistory_AddRef,
955 PersistHistory_Release,
956 PersistHistory_GetClassID,
957 PersistHistory_LoadHistory,
958 PersistHistory_SaveHistory,
959 PersistHistory_SetPositionCookie,
960 PersistHistory_GetPositionCookie
963 void HTMLDocument_Persist_Init(HTMLDocument *This)
965 This->IPersistMoniker_iface.lpVtbl = &PersistMonikerVtbl;
966 This->IPersistFile_iface.lpVtbl = &PersistFileVtbl;
967 This->IMonikerProp_iface.lpVtbl = &MonikerPropVtbl;
968 This->IPersistStreamInit_iface.lpVtbl = &PersistStreamInitVtbl;
969 This->IPersistHistory_iface.lpVtbl = &PersistHistoryVtbl;