Reviewed by Geoff Garen.
Back/Forward entries in WebKit2 leak
https://bugs.webkit.org/show_bug.cgi?id=51983
Besides fixing the leak, this also fixes a problem where
all history items were sent over to the UI process, but
we wanted to send only back/forward items.
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::pageClosed): Added.
Tells the web process about all the back/forward
items being removed.
(WebKit::WebBackForwardList::addItem): Ditto.
Also removed a redundant call to didChangeBackForwardList.
(WebKit::WebBackForwardList::clear): Ditto.
* UIProcess/WebBackForwardList.h: Added pageClosed.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close): Added a call to pageClosed.
(WebKit::WebPageProxy::backForwardRemovedItem): Added.
Sends a message to the web page in the web process.
* UIProcess/WebPageProxy.h: Added backForwardRemovedItem.
* WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::updateBackForwardItem): Added an itemID argument,
since callers will now be getting it and we don't want to
get it twice. Removed the code to generate an ID. Also
removed some local variables to make the code a little
tighter and clearer.
(WebKit::WK2NotifyHistoryItemChanged): Only call
updateBackForwardItem for items that already have IDs.
We don't want to send cross-process messages for every
history item; just the ones that are top level back/forward
items.
(WebKit::WebBackForwardListProxy::removeItem):
Added. For use when the UI process tells us to remove it.
(WebKit::WebBackForwardListProxy::addItem): Added code to
assign an ID and put this item into the maps. This is called
exactly once on each back/forward item.
* WebProcess/WebPage/WebBackForwardListProxy.h: Added
removeItem.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didRemoveBackForwardItem): Added.
* WebProcess/WebPage/WebPage.h: Added didRemoveBackForwardItem.
* WebProcess/WebPage/WebPage.messages.in: Added
DidRemoveBackForwardItem message.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75144
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-01-05 Darin Adler <darin@apple.com>
+
+ Reviewed by Geoff Garen.
+
+ Back/Forward entries in WebKit2 leak
+ https://bugs.webkit.org/show_bug.cgi?id=51983
+
+ Besides fixing the leak, this also fixes a problem where
+ all history items were sent over to the UI process, but
+ we wanted to send only back/forward items.
+
+ * UIProcess/WebBackForwardList.cpp:
+ (WebKit::WebBackForwardList::pageClosed): Added.
+ Tells the web process about all the back/forward
+ items being removed.
+ (WebKit::WebBackForwardList::addItem): Ditto.
+ Also removed a redundant call to didChangeBackForwardList.
+ (WebKit::WebBackForwardList::clear): Ditto.
+
+ * UIProcess/WebBackForwardList.h: Added pageClosed.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::close): Added a call to pageClosed.
+ (WebKit::WebPageProxy::backForwardRemovedItem): Added.
+ Sends a message to the web page in the web process.
+
+ * UIProcess/WebPageProxy.h: Added backForwardRemovedItem.
+
+ * WebProcess/WebPage/WebBackForwardListProxy.cpp:
+ (WebKit::updateBackForwardItem): Added an itemID argument,
+ since callers will now be getting it and we don't want to
+ get it twice. Removed the code to generate an ID. Also
+ removed some local variables to make the code a little
+ tighter and clearer.
+ (WebKit::WK2NotifyHistoryItemChanged): Only call
+ updateBackForwardItem for items that already have IDs.
+ We don't want to send cross-process messages for every
+ history item; just the ones that are top level back/forward
+ items.
+ (WebKit::WebBackForwardListProxy::removeItem):
+ Added. For use when the UI process tells us to remove it.
+ (WebKit::WebBackForwardListProxy::addItem): Added code to
+ assign an ID and put this item into the maps. This is called
+ exactly once on each back/forward item.
+
+ * WebProcess/WebPage/WebBackForwardListProxy.h: Added
+ removeItem.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::didRemoveBackForwardItem): Added.
+
+ * WebProcess/WebPage/WebPage.h: Added didRemoveBackForwardItem.
+
+ * WebProcess/WebPage/WebPage.messages.in: Added
+ DidRemoveBackForwardItem message.
+
2011-01-05 Steve Falkenburg <sfalken@apple.com>
Reviewed by Darin Adler.
{
}
+void WebBackForwardList::pageClosed()
+{
+ if (m_page) {
+ size_t size = m_entries.size();
+ for (size_t i = 0; i < size; ++i)
+ m_page->backForwardRemovedItem(m_entries[i]->itemID());
+ }
+
+ m_page = 0;
+}
+
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();
+ if (m_page)
+ m_page->backForwardRemovedItem(m_entries.last()->itemID());
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];
+ if (m_page)
+ m_page->backForwardRemovedItem(m_entries[0]->itemID());
m_entries.remove(0);
m_current--;
-
- if (m_page)
- m_page->didChangeBackForwardList();
}
m_entries.insert(m_current + 1, newItem);
void WebBackForwardList::clear()
{
- if (m_entries.size() <= 1)
+ size_t size = m_entries.size();
+ if (size <= 1)
return;
- RefPtr<WebBackForwardListItem> item = currentItem();
- m_entries.resize(1);
- m_entries[0] = item.release();
+ RefPtr<WebBackForwardListItem> currentItem = this->currentItem();
+
+ if (m_page) {
+ for (size_t i = 0; i < size; ++i) {
+ if (m_entries[i] != currentItem)
+ m_page->backForwardRemovedItem(m_entries[i]->itemID());
+ }
+ }
+
+ m_entries.shrink(1);
+ m_entries[0] = currentItem.release();
m_current = 0;
{
return adoptRef(new WebBackForwardList(page));
}
+ void pageClosed();
virtual ~WebBackForwardList();
m_isClosed = true;
+ m_backForwardList->pageClosed();
+
process()->disconnectFramesFromPage(this);
m_mainFrame = 0;
}
#if USE(ACCELERATED_COMPOSITING)
+
void WebPageProxy::didEnterAcceleratedCompositing()
{
m_pageClient->pageDidEnterAcceleratedCompositing();
{
m_pageClient->pageDidLeaveAcceleratedCompositing();
}
+
#endif // USE(ACCELERATED_COMPOSITING)
void WebPageProxy::backForwardClear()
}
#endif
+void WebPageProxy::backForwardRemovedItem(uint64_t itemID)
+{
+ process()->send(Messages::WebPage::DidRemoveBackForwardItem(itemID), m_pageID);
+}
+
} // namespace WebKit
void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy*, uint64_t listenerID);
+ void backForwardRemovedItem(uint64_t itemID);
+
void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
return uniqueHistoryItemID;
}
-static uint64_t getIDForHistoryItem(HistoryItem* item)
+static void updateBackForwardItem(uint64_t itemID, HistoryItem* item)
{
- uint64_t itemID = 0;
-
- std::pair<HistoryItemToIDMap::iterator, bool> result = historyItemToIDMap().add(item, 0);
- if (result.second) {
- itemID = generateHistoryItemID();
- result.first->second = itemID;
- idToHistoryItemMap().set(itemID, item);
- } else
- itemID = result.first->second;
-
- ASSERT(itemID);
- return itemID;
-}
-
-static void updateBackForwardItem(HistoryItem* item)
-{
- uint64_t itemID = getIDForHistoryItem(item);
- const String& originalURLString = item->originalURLString();
- const String& urlString = item->urlString();
- const String& title = item->title();
-
- // FIXME: We only want to do this work for top level back/forward items.
- // The best way to do that is probably to arrange for this entire function to only be called by top leve back/forward items.
EncoderAdapter encoder;
item->encodeBackForwardTree(encoder);
- WebProcess::shared().connection()->send(Messages::WebProcessProxy::AddBackForwardItem(itemID, originalURLString, urlString, title, encoder.data()), 0);
+ WebProcess::shared().connection()->send(Messages::WebProcessProxy::AddBackForwardItem(itemID,
+ item->originalURLString(), item->urlString(), item->title(), encoder.data()), 0);
}
static void WK2NotifyHistoryItemChanged(HistoryItem* item)
{
- updateBackForwardItem(item);
+ uint64_t itemID = historyItemToIDMap().get(item);
+ if (!itemID)
+ return;
+
+ updateBackForwardItem(itemID, item);
}
HistoryItem* WebBackForwardListProxy::itemForID(uint64_t itemID)
return idToHistoryItemMap().get(itemID).get();
}
+void WebBackForwardListProxy::removeBackForwardItem(uint64_t itemID)
+{
+ IDToHistoryItemMap::iterator it = idToHistoryItemMap().find(itemID);
+ if (it == idToHistoryItemMap().end())
+ return;
+ historyItemToIDMap().remove(it->second);
+ idToHistoryItemMap().remove(it);
+}
+
WebBackForwardListProxy::WebBackForwardListProxy(WebPage* page)
: m_page(page)
{
void WebBackForwardListProxy::addItem(PassRefPtr<HistoryItem> prpItem)
{
+ RefPtr<HistoryItem> item = prpItem;
+
+ ASSERT(!historyItemToIDMap().contains(item));
+
if (!m_page)
return;
- RefPtr<HistoryItem> item = prpItem;
- uint64_t itemID = historyItemToIDMap().get(item);
+ uint64_t itemID = generateHistoryItemID();
+
+ ASSERT(!idToHistoryItemMap().contains(itemID));
+
+ historyItemToIDMap().set(item, itemID);
+ idToHistoryItemMap().set(itemID, item);
+
+ updateBackForwardItem(itemID, item.get());
m_page->send(Messages::WebPageProxy::BackForwardAddItem(itemID));
}
if (!m_page)
return;
- uint64_t itemID = historyItemToIDMap().get(item);
- m_page->send(Messages::WebPageProxy::BackForwardGoToItem(itemID));
+ m_page->send(Messages::WebPageProxy::BackForwardGoToItem(historyItemToIDMap().get(item)));
}
HistoryItem* WebBackForwardListProxy::itemAtIndex(int itemIndex)
if (!itemID)
return 0;
- RefPtr<HistoryItem> item = idToHistoryItemMap().get(itemID);
- return item.get();
+ return idToHistoryItemMap().get(itemID).get();
}
int WebBackForwardListProxy::backListCount()
static PassRefPtr<WebBackForwardListProxy> create(WebPage* page) { return adoptRef(new WebBackForwardListProxy(page)); }
static WebCore::HistoryItem* itemForID(uint64_t);
+ static void removeItem(uint64_t itemID);
void clear();
m_page->mainFrame()->loader()->reloadWithOverrideEncoding(encoding);
}
+void WebPage::didRemoveBackForwardItem(uint64_t itemID)
+{
+ WebBackForwardListProxy::removeItem(itemID);
+}
+
#if PLATFORM(MAC)
bool WebPage::isSpeaking()
void restoreSession(const SessionState&);
+ void didRemoveBackForwardItem(uint64_t);
+
void setDrawsBackground(bool);
void setDrawsTransparentBackground(bool);
RestoreSession(WebKit::SessionState state)
+ DidRemoveBackForwardItem(uint64_t backForwardItemID)
+
DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID)
# Callbacks.