[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

darin at apple.com darin at apple.com
Fri Jan 21 15:01:17 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 30fcbfca99c3e505aba6785a3492b73f4f35dc67
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 6 07:12:19 2011 +0000

    2011-01-05  Darin Adler  <darin at 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.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75144 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 0ed4262..6c576ca 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,59 @@
+2011-01-05  Darin Adler  <darin at 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 at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebKit2/UIProcess/WebBackForwardList.cpp b/WebKit2/UIProcess/WebBackForwardList.cpp
index f90300c..b351418 100644
--- a/WebKit2/UIProcess/WebBackForwardList.cpp
+++ b/WebKit2/UIProcess/WebBackForwardList.cpp
@@ -45,16 +45,28 @@ WebBackForwardList::~WebBackForwardList()
 {
 }
 
+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();
         }
     }
@@ -62,12 +74,10 @@ void WebBackForwardList::addItem(WebBackForwardListItem* newItem)
     // 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);
@@ -173,12 +183,21 @@ PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLi
 
 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;
 
diff --git a/WebKit2/UIProcess/WebBackForwardList.h b/WebKit2/UIProcess/WebBackForwardList.h
index 0e4a33c..f51ab26 100644
--- a/WebKit2/UIProcess/WebBackForwardList.h
+++ b/WebKit2/UIProcess/WebBackForwardList.h
@@ -55,6 +55,7 @@ public:
     {
         return adoptRef(new WebBackForwardList(page));
     }
+    void pageClosed();
 
     virtual ~WebBackForwardList();
 
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index cd08af1..3be40d8 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -242,6 +242,8 @@ void WebPageProxy::close()
 
     m_isClosed = true;
 
+    m_backForwardList->pageClosed();
+
     process()->disconnectFramesFromPage(this);
     m_mainFrame = 0;
 
@@ -2117,6 +2119,7 @@ WebPageCreationParameters WebPageProxy::creationParameters(const IntSize& size)
 }
 
 #if USE(ACCELERATED_COMPOSITING)
+
 void WebPageProxy::didEnterAcceleratedCompositing()
 {
     m_pageClient->pageDidEnterAcceleratedCompositing();
@@ -2126,6 +2129,7 @@ void WebPageProxy::didLeaveAcceleratedCompositing()
 {
     m_pageClient->pageDidLeaveAcceleratedCompositing();
 }
+
 #endif // USE(ACCELERATED_COMPOSITING)
 
 void WebPageProxy::backForwardClear()
@@ -2175,4 +2179,9 @@ void WebPageProxy::setComplexTextInputEnabled(uint64_t pluginComplexTextInputIde
 }
 #endif
 
+void WebPageProxy::backForwardRemovedItem(uint64_t itemID)
+{
+    process()->send(Messages::WebPage::DidRemoveBackForwardItem(itemID), m_pageID);
+}
+
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/WebPageProxy.h b/WebKit2/UIProcess/WebPageProxy.h
index 47ef409..3e0a406 100644
--- a/WebKit2/UIProcess/WebPageProxy.h
+++ b/WebKit2/UIProcess/WebPageProxy.h
@@ -253,6 +253,8 @@ public:
 
     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*);
 
diff --git a/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp b/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
index f56be00..ab357a9 100644
--- a/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
+++ b/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
@@ -70,40 +70,22 @@ static uint64_t generateHistoryItemID()
     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)
@@ -111,6 +93,15 @@ 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)
 {
@@ -119,11 +110,21 @@ WebBackForwardListProxy::WebBackForwardListProxy(WebPage* 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));
 }
 
@@ -132,8 +133,7 @@ void WebBackForwardListProxy::goToItem(HistoryItem* item)
     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)
@@ -148,8 +148,7 @@ 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()
diff --git a/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h b/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h
index 7cd90fe..b96c761 100644
--- a/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h
+++ b/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h
@@ -38,6 +38,7 @@ public:
     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();
 
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index 938dddd..c9cebcf 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -1518,6 +1518,11 @@ void WebPage::setCustomTextEncodingName(const String& encoding)
     m_page->mainFrame()->loader()->reloadWithOverrideEncoding(encoding);
 }
 
+void WebPage::didRemoveBackForwardItem(uint64_t itemID)
+{
+    WebBackForwardListProxy::removeItem(itemID);
+}
+
 #if PLATFORM(MAC)
 
 bool WebPage::isSpeaking()
diff --git a/WebKit2/WebProcess/WebPage/WebPage.h b/WebKit2/WebProcess/WebPage/WebPage.h
index 1c05840..82d9ba3 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/WebKit2/WebProcess/WebPage/WebPage.h
@@ -339,6 +339,8 @@ private:
 
     void restoreSession(const SessionState&);
 
+    void didRemoveBackForwardItem(uint64_t);
+
     void setDrawsBackground(bool);
     void setDrawsTransparentBackground(bool);
 
diff --git a/WebKit2/WebProcess/WebPage/WebPage.messages.in b/WebKit2/WebProcess/WebPage/WebPage.messages.in
index cf65d69..d781ae1 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.messages.in
+++ b/WebKit2/WebProcess/WebPage/WebPage.messages.in
@@ -49,6 +49,8 @@ messages -> WebPage {
     
     RestoreSession(WebKit::SessionState state)
 
+    DidRemoveBackForwardItem(uint64_t backForwardItemID)
+
     DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID)
 
     # Callbacks.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list