Commit c7506e08 authored by weinig@apple.com's avatar weinig@apple.com

Patch for https://bugs.webkit.org/show_bug.cgi?id=41971

Add really basic BackForwardList support.

Reviewed by Anders Carlsson.

* Shared/CoreIPCSupport/WebPageMessageKinds.h:
(WebPageMessage::):
Add new message kind.

* Shared/CoreIPCSupport/WebPageProxyMessageKinds.h:
(WebPageProxyMessage::):
Add new message kinds. Remove DidChangeCanGoBack and DidChangeCanGoForward.

* UIProcess/API/C/WKPage.cpp:
(WKPageGoToBackForwardListItem):
* UIProcess/API/C/WKPage.h:
Add function to initiate a navigation to a BackForward item.  The
BackForward list will be updated to use this as the current item
asynchronously. 

* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::WebBackForwardList):
(WebKit::WebBackForwardList::addItem): Added.
(WebKit::WebBackForwardList::goToItem): Added.
(WebKit::WebBackForwardList::itemAtIndex): Added.
(WebKit::WebBackForwardList::backListCount): Changed to return int matching WebCore.
(WebKit::WebBackForwardList::forwardListCount): Ditto.
(WebKit::WebBackForwardList::backListWithLimit): Add cast to int.
(WebKit::WebBackForwardList::forwardListWithLimit): Ditto.
(WebKit::WebBackForwardList::backListAsImmutableArrayWithLimit): Ditto.
(WebKit::WebBackForwardList::forwardListAsImmutableArrayWithLimit): Ditto.
* UIProcess/WebBackForwardList.h:

* UIProcess/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::WebBackForwardListItem):
* UIProcess/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::create):
(WebKit::WebBackForwardListItem::itemID):
Added itemID.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::canGoForward):
(WebKit::WebPageProxy::canGoBack):
(WebKit::WebPageProxy::goToBackForwardItem):
(WebKit::WebPageProxy::didReceiveMessage):
(WebKit::WebPageProxy::didReceiveSyncMessage):
(WebKit::WebPageProxy::addItemToBackForwardList):
(WebKit::WebPageProxy::goToItemInBackForwardList):
(WebKit::WebPageProxy::processDidExit):
* UIProcess/WebPageProxy.h:
- Removed m_canGoBack and m_canGoForward booleans and instead use the BackForwardList.
- Forward goToBackForwardItem to the WebProcess.
- Respond to messages from the WebBackForwardListProxy in the WebProcess,
  forwarding to the WebBackForwardList.

* WebProcess/WebCoreSupport/WebBackForwardControllerClient.cpp:
(WebKit::WebBackForwardControllerClient::createBackForwardList):
Start using a WebBackForwardListProxy instead of a BackForwardListImpl.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidAddBackForwardItem):
(WebKit::WebFrameLoaderClient::dispatchDidRemoveBackForwardItem):
(WebKit::WebFrameLoaderClient::dispatchDidChangeBackForwardIndex):
Remove calls backForwardListDidChange() now that we communicate much more
information than just this state.

* WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::idToHistoryItemMap):
(WebKit::historyItemToIDMap):
(WebKit::generateHistoryItemID):
(WebKit::getIDForHistoryItem):
(WebKit::WebBackForwardListProxy::itemForID):
Add leaking cached maps of HistoryItems to IDs, the life time of these
objects will be improved in a subsequent patch.

(WebKit::WebBackForwardListProxy::WebBackForwardListProxy):
(WebKit::WebBackForwardListProxy::addItem):
(WebKit::WebBackForwardListProxy::goBack):
(WebKit::WebBackForwardListProxy::goForward):
(WebKit::WebBackForwardListProxy::goToItem):
(WebKit::WebBackForwardListProxy::backItem):
(WebKit::WebBackForwardListProxy::currentItem):
(WebKit::WebBackForwardListProxy::forwardItem):
(WebKit::WebBackForwardListProxy::itemAtIndex):
(WebKit::WebBackForwardListProxy::backListWithLimit):
(WebKit::WebBackForwardListProxy::forwardListWithLimit):
(WebKit::WebBackForwardListProxy::capacity):
(WebKit::WebBackForwardListProxy::setCapacity):
(WebKit::WebBackForwardListProxy::enabled):
(WebKit::WebBackForwardListProxy::setEnabled):
(WebKit::WebBackForwardListProxy::backListCount):
(WebKit::WebBackForwardListProxy::forwardListCount):
(WebKit::WebBackForwardListProxy::containsItem):
(WebKit::WebBackForwardListProxy::close):
(WebKit::WebBackForwardListProxy::closed):
(WebKit::WebBackForwardListProxy::removeItem):
(WebKit::WebBackForwardListProxy::entries):
(WebKit::WebBackForwardListProxy::pushStateItem):
* WebProcess/WebPage/WebBackForwardListProxy.h:
Forward functions to the UIProcess.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::goToBackForwardItem):
(WebKit::WebPage::didReceiveMessage):
* WebProcess/WebPage/WebPage.h:
Respond to GoToBackForwardItem message.

* mac/WebKit2.exp: Add new API function.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@62996 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7534a485
2010-07-09 Sam Weinig <sam@webkit.org>
Reviewed by Anders Carlsson.
Patch for https://bugs.webkit.org/show_bug.cgi?id=41971
Add really basic BackForwardList support.
* Shared/CoreIPCSupport/WebPageMessageKinds.h:
(WebPageMessage::):
Add new message kind.
* Shared/CoreIPCSupport/WebPageProxyMessageKinds.h:
(WebPageProxyMessage::):
Add new message kinds. Remove DidChangeCanGoBack and DidChangeCanGoForward.
* UIProcess/API/C/WKPage.cpp:
(WKPageGoToBackForwardListItem):
* UIProcess/API/C/WKPage.h:
Add function to initiate a navigation to a BackForward item. The
BackForward list will be updated to use this as the current item
asynchronously.
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::WebBackForwardList):
(WebKit::WebBackForwardList::addItem): Added.
(WebKit::WebBackForwardList::goToItem): Added.
(WebKit::WebBackForwardList::itemAtIndex): Added.
(WebKit::WebBackForwardList::backListCount): Changed to return int matching WebCore.
(WebKit::WebBackForwardList::forwardListCount): Ditto.
(WebKit::WebBackForwardList::backListWithLimit): Add cast to int.
(WebKit::WebBackForwardList::forwardListWithLimit): Ditto.
(WebKit::WebBackForwardList::backListAsImmutableArrayWithLimit): Ditto.
(WebKit::WebBackForwardList::forwardListAsImmutableArrayWithLimit): Ditto.
* UIProcess/WebBackForwardList.h:
* UIProcess/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::WebBackForwardListItem):
* UIProcess/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::create):
(WebKit::WebBackForwardListItem::itemID):
Added itemID.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::canGoForward):
(WebKit::WebPageProxy::canGoBack):
(WebKit::WebPageProxy::goToBackForwardItem):
(WebKit::WebPageProxy::didReceiveMessage):
(WebKit::WebPageProxy::didReceiveSyncMessage):
(WebKit::WebPageProxy::addItemToBackForwardList):
(WebKit::WebPageProxy::goToItemInBackForwardList):
(WebKit::WebPageProxy::processDidExit):
* UIProcess/WebPageProxy.h:
- Removed m_canGoBack and m_canGoForward booleans and instead use the BackForwardList.
- Forward goToBackForwardItem to the WebProcess.
- Respond to messages from the WebBackForwardListProxy in the WebProcess,
forwarding to the WebBackForwardList.
* WebProcess/WebCoreSupport/WebBackForwardControllerClient.cpp:
(WebKit::WebBackForwardControllerClient::createBackForwardList):
Start using a WebBackForwardListProxy instead of a BackForwardListImpl.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidAddBackForwardItem):
(WebKit::WebFrameLoaderClient::dispatchDidRemoveBackForwardItem):
(WebKit::WebFrameLoaderClient::dispatchDidChangeBackForwardIndex):
Remove calls backForwardListDidChange() now that we communicate much more
information than just this state.
* WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::idToHistoryItemMap):
(WebKit::historyItemToIDMap):
(WebKit::generateHistoryItemID):
(WebKit::getIDForHistoryItem):
(WebKit::WebBackForwardListProxy::itemForID):
Add leaking cached maps of HistoryItems to IDs, the life time of these
objects will be improved in a subsequent patch.
(WebKit::WebBackForwardListProxy::WebBackForwardListProxy):
(WebKit::WebBackForwardListProxy::addItem):
(WebKit::WebBackForwardListProxy::goBack):
(WebKit::WebBackForwardListProxy::goForward):
(WebKit::WebBackForwardListProxy::goToItem):
(WebKit::WebBackForwardListProxy::backItem):
(WebKit::WebBackForwardListProxy::currentItem):
(WebKit::WebBackForwardListProxy::forwardItem):
(WebKit::WebBackForwardListProxy::itemAtIndex):
(WebKit::WebBackForwardListProxy::backListWithLimit):
(WebKit::WebBackForwardListProxy::forwardListWithLimit):
(WebKit::WebBackForwardListProxy::capacity):
(WebKit::WebBackForwardListProxy::setCapacity):
(WebKit::WebBackForwardListProxy::enabled):
(WebKit::WebBackForwardListProxy::setEnabled):
(WebKit::WebBackForwardListProxy::backListCount):
(WebKit::WebBackForwardListProxy::forwardListCount):
(WebKit::WebBackForwardListProxy::containsItem):
(WebKit::WebBackForwardListProxy::close):
(WebKit::WebBackForwardListProxy::closed):
(WebKit::WebBackForwardListProxy::removeItem):
(WebKit::WebBackForwardListProxy::entries):
(WebKit::WebBackForwardListProxy::pushStateItem):
* WebProcess/WebPage/WebBackForwardListProxy.h:
Forward functions to the UIProcess.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::goToBackForwardItem):
(WebKit::WebPage::didReceiveMessage):
* WebProcess/WebPage/WebPage.h:
Respond to GoToBackForwardItem message.
* mac/WebKit2.exp: Add new API function.
2010-07-09 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
......
......@@ -38,6 +38,7 @@ enum Kind {
GetRenderTreeExternalRepresentation,
GoBack,
GoForward,
GoToBackForwardItem,
KeyEvent,
LoadURL,
MouseEvent,
......
......@@ -41,8 +41,6 @@ enum Kind {
DecidePolicyForMIMEType,
DecidePolicyForNavigationAction,
DecidePolicyForNewWindowAction,
DidChangeCanGoBack,
DidChangeCanGoForward,
DidChangeProgress,
DidCommitLoadForFrame,
DidCreateMainFrame,
......@@ -67,6 +65,13 @@ enum Kind {
DidUpdateHistoryTitle,
SetToolTip,
TakeFocus,
BackForwardAddItem,
BackForwardGoToItem,
BackForwardCurrentItem,
BackForwardItemAtIndex,
BackForwardBackListCount,
BackForwardForwardListCount,
};
}
......
......@@ -96,6 +96,11 @@ bool WKPageCanGoBack(WKPageRef pageRef)
return toWK(pageRef)->canGoBack();
}
void WKPageGoToBackForwardListItem(WKPageRef pageRef, WKBackForwardListItemRef itemRef)
{
toWK(pageRef)->goToBackForwardItem(toWK(itemRef));
}
WKBackForwardListRef WKPageGetBackForwardList(WKPageRef pageRef)
{
return toRef(toWK(pageRef)->backForwardList());
......
......@@ -145,6 +145,7 @@ WK_EXPORT void WKPageGoForward(WKPageRef page);
WK_EXPORT bool WKPageCanGoForward(WKPageRef page);
WK_EXPORT void WKPageGoBack(WKPageRef page);
WK_EXPORT bool WKPageCanGoBack(WKPageRef page);
WK_EXPORT void WKPageGoToBackForwardListItem(WKPageRef page, WKBackForwardListItemRef item);
WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page);
WK_EXPORT WKStringRef WKPageGetTitle(WKPageRef page);
......
......@@ -27,11 +27,15 @@
namespace WebKit {
static const unsigned DefaultCapacity = 100;
static const unsigned NoCurrentItemIndex = UINT_MAX;
WebBackForwardList::WebBackForwardList(WebPageProxy* page)
: m_page(page)
, m_current(NoCurrentItemIndex)
, m_capacity(DefaultCapacity)
, m_closed(true)
, m_enabled(true)
{
}
......@@ -39,6 +43,46 @@ WebBackForwardList::~WebBackForwardList()
{
}
void WebBackForwardList::addItem(WebBackForwardListItem* newItem)
{
if (m_capacity == 0 || !m_enabled)
return;
// Toss anything in the forward list
if (m_current != NoCurrentItemIndex) {
unsigned targetSize = m_current + 1;
while (m_entries.size() > targetSize) {
RefPtr<WebBackForwardListItem> item = m_entries.last();
m_entries.removeLast();
}
}
// Toss the first item if the list is getting too big, as long as we're not using it
// (or even if we are, if we only want 1 entry).
if (m_entries.size() == m_capacity && (m_current != 0 || m_capacity == 1)) {
RefPtr<WebBackForwardListItem> item = m_entries[0];
m_entries.remove(0);
m_current--;
}
m_entries.insert(m_current + 1, newItem);
m_current++;
}
void WebBackForwardList::goToItem(WebBackForwardListItem* item)
{
if (!m_entries.size() || !item)
return;
unsigned index = 0;
for (; index < m_entries.size(); ++index) {
if (m_entries[index] == item)
break;
}
if (index < m_entries.size())
m_current = index;
}
WebBackForwardListItem* WebBackForwardList::currentItem()
{
if (m_current != NoCurrentItemIndex)
......@@ -60,20 +104,32 @@ WebBackForwardListItem* WebBackForwardList::forwardItem()
return 0;
}
unsigned WebBackForwardList::backListCount()
WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index)
{
// Do range checks without doing math on index to avoid overflow.
if (index < -static_cast<int>(m_current))
return 0;
if (index > forwardListCount())
return 0;
return m_entries[index + m_current].get();
}
int WebBackForwardList::backListCount()
{
return m_current == NoCurrentItemIndex ? 0 : m_current;
}
unsigned WebBackForwardList::forwardListCount()
int WebBackForwardList::forwardListCount()
{
return m_current == NoCurrentItemIndex ? 0 : m_entries.size() - (m_current + 1);
return m_current == NoCurrentItemIndex ? 0 : static_cast<int>(m_entries.size()) - (m_current + 1);
}
BackForwardListItemVector WebBackForwardList::backListWithLimit(unsigned limit)
{
BackForwardListItemVector list;
unsigned size = std::min(backListCount(), limit);
unsigned size = std::min(backListCount(), static_cast<int>(limit));
if (!size)
return list;
......@@ -87,7 +143,7 @@ BackForwardListItemVector WebBackForwardList::backListWithLimit(unsigned limit)
BackForwardListItemVector WebBackForwardList::forwardListWithLimit(unsigned limit)
{
BackForwardListItemVector list;
unsigned size = std::min(forwardListCount(), limit);
unsigned size = std::min(forwardListCount(), static_cast<int>(limit));
if (!size)
return list;
......@@ -113,7 +169,7 @@ static void webBackForwardListItemDeref(const void* item)
PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit(unsigned limit)
{
unsigned size = std::min(backListCount(), limit);
unsigned size = std::min(backListCount(), static_cast<int>(limit));
if (!size)
return ImmutableArray::create();
......@@ -133,7 +189,7 @@ PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit
PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLimit(unsigned limit)
{
unsigned size = std::min(forwardListCount(), limit);
unsigned size = std::min(forwardListCount(), static_cast<int>(limit));
if (!size)
return ImmutableArray::create();
......
......@@ -53,12 +53,16 @@ public:
}
~WebBackForwardList();
void addItem(WebBackForwardListItem*);
void goToItem(WebBackForwardListItem*);
WebBackForwardListItem* currentItem();
WebBackForwardListItem* backItem();
WebBackForwardListItem* forwardItem();
WebBackForwardListItem* itemAtIndex(int);
unsigned backListCount();
unsigned forwardListCount();
int backListCount();
int forwardListCount();
BackForwardListItemVector backListWithLimit(unsigned limit);
BackForwardListItemVector forwardListWithLimit(unsigned limit);
......@@ -72,6 +76,9 @@ private:
WebPageProxy* m_page;
BackForwardListItemVector m_entries;
unsigned m_current;
unsigned m_capacity;
bool m_closed;
bool m_enabled;
};
} // namespace WebKit
......
......@@ -29,10 +29,11 @@ using namespace WebCore;
namespace WebKit {
WebBackForwardListItem::WebBackForwardListItem(const String& originalURL, const String& url, const String& title)
WebBackForwardListItem::WebBackForwardListItem(const String& originalURL, const String& url, const String& title, uint64_t itemID)
: m_originalURL(originalURL)
, m_url(url)
, m_title(title)
, m_itemID(itemID)
{
}
......
......@@ -36,22 +36,25 @@ class WebPageProxy;
class WebBackForwardListItem : public RefCounted<WebBackForwardListItem> {
public:
static PassRefPtr<WebBackForwardListItem> create(const WebCore::String& originalURL, const WebCore::String& url, const WebCore::String& title)
static PassRefPtr<WebBackForwardListItem> create(const WebCore::String& originalURL, const WebCore::String& url, const WebCore::String& title, uint64_t itemID)
{
return adoptRef(new WebBackForwardListItem(originalURL, url, title));
return adoptRef(new WebBackForwardListItem(originalURL, url, title, itemID));
}
~WebBackForwardListItem();
uint64_t itemID() const { return m_itemID; }
const WebCore::String& originalURL() const { return m_originalURL; }
const WebCore::String& url() const { return m_url; }
const WebCore::String& title() const { return m_title; }
private:
WebBackForwardListItem(const WebCore::String& originalURL, const WebCore::String& url, const WebCore::String& title);
WebBackForwardListItem(const WebCore::String& originalURL, const WebCore::String& url, const WebCore::String& title, uint64_t itemID);
WebCore::String m_originalURL;
WebCore::String m_url;
WebCore::String m_title;
uint64_t m_itemID;
};
} // namespace WebKit
......
......@@ -29,6 +29,7 @@
#include "MessageID.h"
#include "PageClient.h"
#include "WebBackForwardList.h"
#include "WebBackForwardListItem.h"
#include "WebContext.h"
#include "WebCoreArgumentCoders.h"
#include "WebEvent.h"
......@@ -66,8 +67,6 @@ WebPageProxy::WebPageProxy(WebPageNamespace* pageNamespace, uint64_t pageID)
, m_pageNamespace(pageNamespace)
, m_mainFrame(0)
, m_estimatedProgress(0.0)
, m_canGoBack(false)
, m_canGoForward(false)
, m_backForwardList(WebBackForwardList::create(this))
, m_valid(true)
, m_closed(false)
......@@ -183,9 +182,6 @@ void WebPageProxy::close()
renderTreeExternalRepresentationCallbacks[i]->invalidate();
m_renderTreeExternalRepresentationCallbacks.clear();
m_canGoForward = false;
m_canGoBack = false;
m_estimatedProgress = 0.0;
m_loaderClient.initialize(0);
......@@ -237,6 +233,11 @@ void WebPageProxy::goForward()
process()->send(WebPageMessage::GoForward, m_pageID, CoreIPC::In());
}
bool WebPageProxy::canGoForward() const
{
return m_backForwardList->forwardItem();
}
void WebPageProxy::goBack()
{
if (!isValid())
......@@ -244,6 +245,18 @@ void WebPageProxy::goBack()
process()->send(WebPageMessage::GoBack, m_pageID, CoreIPC::In());
}
bool WebPageProxy::canGoBack() const
{
return m_backForwardList->backItem();
}
void WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
{
if (!isValid())
return;
process()->send(WebPageMessage::GoToBackForwardItem, m_pageID, CoreIPC::In(item->itemID()));
}
void WebPageProxy::setFocused(bool isFocused)
{
if (!isValid())
......@@ -453,20 +466,6 @@ void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::M
takeFocus(direction);
break;
}
case WebPageProxyMessage::DidChangeCanGoBack: {
bool canGoBack;
if (!arguments.decode(canGoBack))
return;
m_canGoBack = canGoBack;
break;
}
case WebPageProxyMessage::DidChangeCanGoForward: {
bool canGoForward;
if (!arguments.decode(canGoForward))
return;
m_canGoForward = canGoForward;
break;
}
case WebPageProxyMessage::DecidePolicyForNavigationAction: {
uint64_t frameID;
uint32_t navigationType;
......@@ -563,6 +562,16 @@ void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::M
didUpdateHistoryTitle(webFrame(frameID), title, url);
break;
}
case WebPageProxyMessage::BackForwardAddItem: {
uint64_t itemID;
String originalURLString;
String urlString;
String title;
if (!arguments.decode(CoreIPC::Out(itemID, originalURLString, urlString, title)))
return;
addItemToBackForwardList(itemID, originalURLString, urlString, title);
break;
}
default:
ASSERT_NOT_REACHED();
break;
......@@ -593,6 +602,34 @@ void WebPageProxy::didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageI
runJavaScriptAlert(webFrame(frameID), alertText);
break;
}
case WebPageProxyMessage::BackForwardCurrentItem: {
WebBackForwardListItem* currentItem = m_backForwardList->currentItem();
uint64_t currentItemID = currentItem ? currentItem->itemID() : 0;
reply.encode(CoreIPC::In(currentItemID));
break;
}
case WebPageProxyMessage::BackForwardItemAtIndex: {
int itemIndex;
if (!arguments.decode(CoreIPC::Out(itemIndex)))
return;
WebBackForwardListItem* item = m_backForwardList->itemAtIndex(itemIndex);
uint64_t itemID = item ? item->itemID() : 0;
reply.encode(CoreIPC::In(itemID));
break;
}
case WebPageProxyMessage::BackForwardBackListCount: {
int backListCount = m_backForwardList->backListCount();
reply.encode(CoreIPC::In(backListCount));
break;
}
case WebPageProxyMessage::BackForwardForwardListCount: {
int forwardListCount = m_backForwardList->forwardListCount();
reply.encode(CoreIPC::In(forwardListCount));
break;
}
default:
ASSERT_NOT_REACHED();
break;
......@@ -759,6 +796,27 @@ void WebPageProxy::didUpdateHistoryTitle(WebFrameProxy* frame, const String& tit
m_historyClient.didUpdateHistoryTitle(this, title, url, frame);
}
// BackForwardList
void WebPageProxy::addItemToBackForwardList(uint64_t itemID, const String& originalURLString, const String& urlString, const String& title)
{
std::pair<HashMap<uint64_t, RefPtr<WebBackForwardListItem> >::iterator, bool> result = m_backForwardListItemMap.add(itemID, 0);
if (result.second)
result.first->second = WebBackForwardListItem::create(originalURLString, urlString, title, itemID);
ASSERT(result.first->second->originalURL() == originalURLString);
ASSERT(result.first->second->url() == urlString);
ASSERT(result.first->second->title() == title);
m_backForwardList->addItem(result.first->second.get());
}
void WebPageProxy::goToItemInBackForwardList(uint64_t itemID)
{
WebBackForwardListItem* item = m_backForwardListItemMap.get(itemID).get();
m_backForwardList->goToItem(item);
}
// Other
void WebPageProxy::takeFocus(bool direction)
......@@ -854,9 +912,6 @@ void WebPageProxy::processDidExit()
renderTreeExternalRepresentationCallbacks[i]->invalidate();
m_renderTreeExternalRepresentationCallbacks.clear();
m_canGoForward = false;
m_canGoBack = false;
m_estimatedProgress = 0.0;
m_pageClient->processDidExit();
......
......@@ -61,6 +61,7 @@ namespace WebKit {
class DrawingAreaProxy;
class PageClient;
class WebBackForwardList;
class WebBackForwardListItem;
class WebKeyboardEvent;
class WebMouseEvent;
class WebPageNamespace;
......@@ -105,9 +106,11 @@ public:
void reload(bool reloadFromOrigin);
void goForward();
bool canGoForward() const { return m_canGoForward; }
bool canGoForward() const;
void goBack();
bool canGoBack() const { return m_canGoBack; }
bool canGoBack() const;
void goToBackForwardItem(WebBackForwardListItem*);
void setFocused(bool isFocused);
void setActive(bool active);
......@@ -181,6 +184,9 @@ private:
void didPerformServerRedirect(WebFrameProxy*, const WebCore::String& sourceURLString, const WebCore::String& destinationURLString);
void didUpdateHistoryTitle(WebFrameProxy*, const WebCore::String& title, const WebCore::String& url);
void addItemToBackForwardList(uint64_t itemID, const WebCore::String& originalURLString, const WebCore::String& urlString, const WebCore::String& title);
void goToItemInBackForwardList(uint64_t itemID);
void takeFocus(bool direction);
void setToolTip(const WebCore::String&);
......@@ -215,6 +221,7 @@ private:
bool m_canGoBack;
bool m_canGoForward;
RefPtr<WebBackForwardList> m_backForwardList;
HashMap<uint64_t, RefPtr<WebBackForwardListItem> > m_backForwardListItemMap;
WebCore::String m_toolTip;
......
......@@ -26,7 +26,7 @@
#include "WebBackForwardControllerClient.h"
#include "WebPage.h"
#include <WebCore/BackForwardListImpl.h>
#include "WebBackForwardListProxy.h"
using namespace WebCore;
......@@ -37,9 +37,9 @@ void WebBackForwardControllerClient::backForwardControllerDestroyed()
delete this;
}
PassRefPtr<BackForwardList> WebBackForwardControllerClient::createBackForwardList(Page* page)
PassRefPtr<BackForwardList> WebBackForwardControllerClient::createBackForwardList(Page*)
{
return BackForwardListImpl::create(page);
return WebBackForwardListProxy::create(m_page);
}
} // namespace WebKit
......@@ -575,20 +575,17 @@ bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem*) const
void WebFrameLoaderClient::dispatchDidAddBackForwardItem(HistoryItem*) const
{
if (WebPage* webPage = m_frame->page())
webPage->backForwardListDidChange();
notImplemented();
}
void WebFrameLoaderClient::dispatchDidRemoveBackForwardItem(HistoryItem*) const
{
if (WebPage* webPage = m_frame->page())
webPage->backForwardListDidChange();
notImplemented();
}
void WebFrameLoaderClient::dispatchDidChangeBackForwardIndex() const
{
if (WebPage* webPage = m_frame->page())
webPage->backForwardListDidChange();
notImplemented();
}
void WebFrameLoaderClient::didDisplayInsecureContent()
......
......@@ -25,14 +25,70 @@
#include "WebBackForwardListProxy.h"
#include "WebCoreArgumentCoders.h"
#include "WebPage.h"
#include "WebPageProxyMessageKinds.h"
#include "WebProcess.h"
#include <WebCore/HistoryItem.h>
#include <wtf/HashMap.h>
using namespace WebCore;
namespace WebKit {
static const unsigned DefaultCapacity = 100;