Jacek Caban : ieframe: Use IPersistHistory for history navigation, if possible.

Alexandre Julliard julliard at winehq.org
Tue Apr 2 13:38:37 CDT 2013


Module: wine
Branch: master
Commit: 0f5badf44fb476feff7f320e0a993e79c118db9e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0f5badf44fb476feff7f320e0a993e79c118db9e

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Apr  2 17:39:45 2013 +0200

ieframe: Use IPersistHistory for history navigation, if possible.

---

 dlls/ieframe/dochost.c  |   28 ++++++++++++++++++++++++++++
 dlls/ieframe/ieframe.h  |    1 +
 dlls/ieframe/navigate.c |   45 +++++++++++++++++++++++++++++++--------------
 3 files changed, 60 insertions(+), 14 deletions(-)

diff --git a/dlls/ieframe/dochost.c b/dlls/ieframe/dochost.c
index e1a897a..f95c4bd 100644
--- a/dlls/ieframe/dochost.c
+++ b/dlls/ieframe/dochost.c
@@ -20,6 +20,7 @@
 
 #include "exdispid.h"
 #include "mshtml.h"
+#include "perhist.h"
 #include "initguid.h"
 
 #include "wine/debug.h"
@@ -335,9 +336,33 @@ static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
 
 static void free_travellog_entry(travellog_entry_t *entry)
 {
+    if(entry->stream)
+        IStream_Release(entry->stream);
     heap_free(entry->url);
 }
 
+static IStream *get_travellog_stream(DocHost *This)
+{
+    IPersistHistory *persist_history;
+    IStream *stream;
+    HRESULT hres;
+
+    hres = IUnknown_QueryInterface(This->document, &IID_IPersistHistory, (void**)&persist_history);
+    if(FAILED(hres))
+        return NULL;
+
+    hres = CreateStreamOnHGlobal(NULL, TRUE, &stream);
+    if(SUCCEEDED(hres))
+        hres = IPersistHistory_SaveHistory(persist_history, stream);
+    IPersistHistory_Release(persist_history);
+    if(FAILED(hres)) {
+        IStream_Release(stream);
+        return NULL;
+    }
+
+    return stream;
+}
+
 static void update_travellog(DocHost *This)
 {
     travellog_entry_t *new_entry;
@@ -368,9 +393,12 @@ static void update_travellog(DocHost *This)
     new_entry = This->travellog.log + This->travellog.position;
 
     new_entry->url = heap_strdupW(This->url);
+    TRACE("Adding %s at %d\n", debugstr_w(This->url), This->travellog.position);
     if(!new_entry->url)
         return;
 
+    new_entry->stream = get_travellog_stream(This);
+
     if(This->travellog.loading_pos == -1) {
         This->travellog.position++;
     }else {
diff --git a/dlls/ieframe/ieframe.h b/dlls/ieframe/ieframe.h
index 2508ef2..4140e05 100644
--- a/dlls/ieframe/ieframe.h
+++ b/dlls/ieframe/ieframe.h
@@ -96,6 +96,7 @@ typedef struct {
 
 typedef struct {
     WCHAR *url;
+    IStream *stream;
 } travellog_entry_t;
 
 typedef struct _IDocHostContainerVtbl
diff --git a/dlls/ieframe/navigate.c b/dlls/ieframe/navigate.c
index b6e277c..703e32c 100644
--- a/dlls/ieframe/navigate.c
+++ b/dlls/ieframe/navigate.c
@@ -27,6 +27,7 @@
 #include "shlwapi.h"
 #include "wininet.h"
 #include "mshtml.h"
+#include "perhist.h"
 #include "resource.h"
 
 #include "wine/debug.h"
@@ -1058,30 +1059,46 @@ HRESULT go_home(DocHost *This)
     return navigate_url(This, wszPageName, NULL, NULL, NULL, NULL);
 }
 
-HRESULT go_back(DocHost *This)
+static HRESULT navigate_history(DocHost *This, unsigned travellog_pos)
 {
-    WCHAR *url;
+    IPersistHistory *persist_history;
+    travellog_entry_t *entry;
+    LARGE_INTEGER li;
     HRESULT hres;
 
-    if(!This->travellog.position) {
-        WARN("No history available\n");
-        return E_FAIL;
+    if(!This->doc_navigate) {
+        FIXME("unsupported doc_navigate FALSE\n");
+        return E_NOTIMPL;
     }
 
-    This->travellog.loading_pos = This->travellog.position-1;
-    url = This->travellog.log[This->travellog.loading_pos].url;
+    This->travellog.loading_pos = travellog_pos;
+    entry = This->travellog.log + This->travellog.loading_pos;
 
-    if(This->doc_navigate) {
-        hres = async_doc_navigate(This, url, NULL, NULL, 0, FALSE);
-    }else {
-        FIXME("unsupported doc_navigate FALSE\n");
-        hres = E_NOTIMPL;
-    }
+    if(!entry->stream)
+        return async_doc_navigate(This, entry->url, NULL, NULL, 0, FALSE);
+
+    hres = IUnknown_QueryInterface(This->document, &IID_IPersistHistory, (void**)&persist_history);
+    if(FAILED(hres))
+        return hres;
+
+    li.QuadPart = 0;
+    IStream_Seek(entry->stream, li, STREAM_SEEK_SET, NULL);
 
-    heap_free(url);
+    hres = IPersistHistory_LoadHistory(persist_history, entry->stream, NULL);
+    IPersistHistory_Release(persist_history);
     return hres;
 }
 
+HRESULT go_back(DocHost *This)
+{
+    if(!This->travellog.position) {
+        WARN("No history available\n");
+        return E_FAIL;
+    }
+
+    return navigate_history(This, This->travellog.position-1);
+}
+
 HRESULT get_location_url(DocHost *This, BSTR *ret)
 {
     FIXME("semi-stub\n");




More information about the wine-cvs mailing list