From 263e3a8327f544990c7ba7edb8cd34994c908049 Mon Sep 17 00:00:00 2001 From: Steve Lamerton Date: Sun, 31 Jul 2011 15:37:55 +0000 Subject: [PATCH] Rework the GTK WebKit backend history to remove the need for the map between wxWebHistoryItems and WebKitWebHistoryItems. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/webhistoryitem_webkit.h | 5 ++++ include/wx/gtk/webview_webkit.h | 33 +------------------------- src/gtk/webview_webkit.cpp | 23 ++++++++++-------- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/include/wx/gtk/webhistoryitem_webkit.h b/include/wx/gtk/webhistoryitem_webkit.h index 13fe309a86..e82bcae5ef 100644 --- a/include/wx/gtk/webhistoryitem_webkit.h +++ b/include/wx/gtk/webhistoryitem_webkit.h @@ -14,6 +14,8 @@ #if wxUSE_WEBVIEW_WEBKIT +#include "webkit/webkit.h" + class WXDLLIMPEXP_WEB wxWebHistoryItem { public: @@ -22,8 +24,11 @@ public: wxString GetUrl() { return m_url; } wxString GetTitle() { return m_title; } + friend class wxWebViewWebKit; + private: wxString m_url, m_title; + WebKitWebHistoryItem* m_histItem; }; #endif // wxUSE_WEBVIEW_WEBKIT diff --git a/include/wx/gtk/webview_webkit.h b/include/wx/gtk/webview_webkit.h index 1775b704f8..d7d4feaa22 100644 --- a/include/wx/gtk/webview_webkit.h +++ b/include/wx/gtk/webview_webkit.h @@ -18,36 +18,6 @@ #include "wx/sharedptr.h" #include "wx/webview.h" -//A set of hash function so we can map wxWebHistoryItems to WebKitWebHistoryItems -class SharedPtrHash -{ -public: - SharedPtrHash() { } - - unsigned long operator()( const wxSharedPtr & item ) const - { - - return wxPointerHash()(item.get()); - } - SharedPtrHash& operator=(const SharedPtrHash&) { return *this; } -}; - -class SharedPtrEqual -{ -public: - SharedPtrEqual() { } - bool operator()( const wxSharedPtr & a, - const wxSharedPtr & b ) const - { - return wxPointerEqual()(a.get(), b.get()); - } - - SharedPtrEqual& operator=(const SharedPtrEqual&) { return *this; } -}; - -WX_DECLARE_HASH_MAP(wxSharedPtr, WebKitWebHistoryItem*, - SharedPtrHash, SharedPtrEqual, HistoryItemHash); - //----------------------------------------------------------------------------- // wxWebViewWebKit //----------------------------------------------------------------------------- @@ -152,7 +122,7 @@ public: virtual void RunScript(const wxString& javascript); //Virtual Filesystem Support - virtual void RegisterHandler(wxWebHandler* handler); + virtual void RegisterHandler(wxWebHandler* handler) {}; /** FIXME: hack to work around signals being received too early */ bool m_ready; @@ -177,7 +147,6 @@ private: GtkWidget *web_view; gint m_historyLimit; - HistoryItemHash m_historyMap; // FIXME: try to get DECLARE_DYNAMIC_CLASS macros & stuff right //DECLARE_DYNAMIC_CLASS(wxWebViewWebKit) diff --git a/src/gtk/webview_webkit.cpp b/src/gtk/webview_webkit.cpp index c1493d21e6..fcdd060b2e 100644 --- a/src/gtk/webview_webkit.cpp +++ b/src/gtk/webview_webkit.cpp @@ -469,11 +469,12 @@ wxVector > wxWebViewWebKit::GetBackwardHistory() for(int i = g_list_length(list) - 1; i >= 0 ; i--) { WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i); - wxSharedPtr item(new wxWebHistoryItem( - webkit_web_history_item_get_uri(gtkitem), - webkit_web_history_item_get_title(gtkitem))); + wxWebHistoryItem* wxitem = new wxWebHistoryItem( + webkit_web_history_item_get_uri(gtkitem), + webkit_web_history_item_get_title(gtkitem)); + wxitem->m_histItem = gtkitem; + wxSharedPtr item(wxitem); backhist.push_back(item); - m_historyMap[item] = gtkitem; } return backhist; } @@ -488,23 +489,25 @@ wxVector > wxWebViewWebKit::GetForwardHistory() for(guint i = 0; i < g_list_length(list); i++) { WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i); - wxSharedPtr item(new wxWebHistoryItem( - webkit_web_history_item_get_uri(gtkitem), - webkit_web_history_item_get_title(gtkitem))); + wxWebHistoryItem* wxitem = new wxWebHistoryItem( + webkit_web_history_item_get_uri(gtkitem), + webkit_web_history_item_get_title(gtkitem)); + wxitem->m_histItem = gtkitem; + wxSharedPtr item(wxitem); forwardhist.push_back(item); - m_historyMap[item] = gtkitem; } return forwardhist; } void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr item) { - WebKitWebHistoryItem* gtkitem = m_historyMap[item]; + WebKitWebHistoryItem* gtkitem = item->m_histItem; if(gtkitem) { WebKitWebBackForwardList* history; history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view)); - webkit_web_back_forward_list_go_to_item(history, gtkitem); + webkit_web_back_forward_list_go_to_item(WEBKIT_WEB_BACK_FORWARD_LIST(history), + WEBKIT_WEB_HISTORY_ITEM(gtkitem)); } } -- 2.47.2