[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 11:45:07 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 9f52ae74e9e9f618deacd97882cf1fc949fff631
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 5 19:54:13 2010 +0000

    Add VisitedLinkProvider class
    https://bugs.webkit.org/show_bug.cgi?id=43570
    
    Reviewed by Sam Weinig.
    
    * Shared/CoreIPCSupport/WebProcessMessageKinds.h:
    (WebProcessMessage::):
    Add SetVisitedLinkTable, VisitedLinkStateChanged and AllVisitedLinkStateChanged.
    
    * UIProcess/VisitedLinkProvider.cpp: Added.
    (WebKit::VisitedLinkProvider::VisitedLinkProvider):
    Initialize table.
    
    (WebKit::VisitedLinkProvider::populateVisitedLinksIfNeeded):
    Ask the context to populate visited links.
    
    (WebKit::VisitedLinkProvider::addVisitedLink):
    Add the link hash to the set of pending visited links and start the timer.
    
    (WebKit::nextPowerOf2):
    Add helper function.
    
    (WebKit::tableSizeForKeyCount):
    Given a key count, returns a table size. The table size is always a power of two, and
    is chosen so that the table is always at least half empty.
    
    (WebKit::VisitedLinkProvider::pendingVisitedLinksTimerFired):
    First, check if we need to resize the hash table and allocate new shared memory for it if that is the case.
    Then, go through the pending link hash vector and insert all the elements in the table. Finally, notify the web
    process about visited links whose state have changed.
    
    * WebProcess/WebProcess.cpp:
    (WebKit::WebProcess::didReceiveMessage):
    Add case statements.
    
    * win/WebKit2.vcproj:
    * WebKit2.xcodeproj/project.pbxproj:
    Add VisitedLinkProvider.cpp and VisitedLinkProvider.h.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64775 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index c3c4c3b..b00e1af 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -2,6 +2,47 @@
 
         Reviewed by Sam Weinig.
 
+        Add VisitedLinkProvider class
+        https://bugs.webkit.org/show_bug.cgi?id=43570
+
+        * Shared/CoreIPCSupport/WebProcessMessageKinds.h:
+        (WebProcessMessage::):
+        Add SetVisitedLinkTable, VisitedLinkStateChanged and AllVisitedLinkStateChanged.
+
+        * UIProcess/VisitedLinkProvider.cpp: Added.
+        (WebKit::VisitedLinkProvider::VisitedLinkProvider):
+        Initialize table.
+
+        (WebKit::VisitedLinkProvider::populateVisitedLinksIfNeeded):
+        Ask the context to populate visited links.
+
+        (WebKit::VisitedLinkProvider::addVisitedLink):
+        Add the link hash to the set of pending visited links and start the timer.
+
+        (WebKit::nextPowerOf2):
+        Add helper function.
+
+        (WebKit::tableSizeForKeyCount):
+        Given a key count, returns a table size. The table size is always a power of two, and
+        is chosen so that the table is always at least half empty.
+
+        (WebKit::VisitedLinkProvider::pendingVisitedLinksTimerFired):
+        First, check if we need to resize the hash table and allocate new shared memory for it if that is the case.
+        Then, go through the pending link hash vector and insert all the elements in the table. Finally, notify the web
+        process about visited links whose state have changed.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::didReceiveMessage):
+        Add case statements.
+
+        * win/WebKit2.vcproj:
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add VisitedLinkProvider.cpp and VisitedLinkProvider.h.
+
+2010-08-05  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
         Add VisitedLinkTable class
         https://bugs.webkit.org/show_bug.cgi?id=43566
 
diff --git a/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h b/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
index 80be98f..c5a725c 100644
--- a/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
+++ b/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
@@ -33,6 +33,11 @@
 namespace WebProcessMessage {
 
 enum Kind {
+    SetVisitedLinkTable,
+    VisitedLinkStateChanged,
+    AllVisitedLinkStateChanged,
+    
+    // FIXME: Remove AddVisitedLink.
     AddVisitedLink,
     LoadInjectedBundle,
     SetApplicationCacheDirectory,
diff --git a/WebKit2/UIProcess/VisitedLinkProvider.cpp b/WebKit2/UIProcess/VisitedLinkProvider.cpp
new file mode 100644
index 0000000..e8a1244
--- /dev/null
+++ b/WebKit2/UIProcess/VisitedLinkProvider.cpp
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "VisitedLinkProvider.h"
+
+#include "SharedMemory.h"
+#include "VisitedLinkTable.h"
+#include "WebContext.h"
+#include "WebProcessMessageKinds.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const int VisitedLinkTableMaxLoad = 2;
+
+VisitedLinkProvider::VisitedLinkProvider(WebContext* context)
+    : m_context(context)
+    , m_visitedLinksPopulated(false)
+    , m_keyCount(0)
+    , m_tableSize(0)
+    , m_pendingVisitedLinksTimer(RunLoop::main(), this, &VisitedLinkProvider::pendingVisitedLinksTimerFired)
+{
+}
+
+void VisitedLinkProvider::populateVisitedLinksIfNeeded()
+{
+    if (m_visitedLinksPopulated)
+        return;
+
+    m_context->populateVisitedLinks();
+
+    m_visitedLinksPopulated = true;
+}
+
+void VisitedLinkProvider::addVisitedLink(LinkHash linkHash)
+{
+    m_pendingVisitedLinks.add(linkHash);
+
+    if (!m_pendingVisitedLinksTimer.isActive())
+        m_pendingVisitedLinksTimer.startOneShot(0);
+}
+
+static unsigned nextPowerOf2(unsigned v)
+{
+    // Taken from http://www.cs.utk.edu/~vose/c-stuff/bithacks.html
+    // Devised by Sean Anderson, Sepember 14, 2001
+    
+    v--;
+    v |= v >> 1;
+    v |= v >> 2;
+    v |= v >> 4;
+    v |= v >> 8;
+    v |= v >> 16;
+    v++;
+    
+    return v;
+}
+
+static unsigned tableSizeForKeyCount(unsigned keyCount)
+{
+    // We want the table to be at least half empty.
+    unsigned tableSize = nextPowerOf2(keyCount * VisitedLinkTableMaxLoad);
+
+    // Ensure that the table size is at least the size of a page.
+    size_t minimumTableSize = SharedMemory::systemPageSize() / sizeof(LinkHash);
+    if (tableSize < minimumTableSize)
+        return minimumTableSize;
+    
+    return tableSize;
+}
+
+void VisitedLinkProvider::pendingVisitedLinksTimerFired()
+{
+    Vector<WebCore::LinkHash> pendingVisitedLinks;
+    copyToVector(m_pendingVisitedLinks, pendingVisitedLinks);
+    m_pendingVisitedLinks.clear();
+
+    unsigned currentTableSize = m_tableSize;
+    unsigned newTableSize = tableSizeForKeyCount(m_keyCount + pendingVisitedLinks.size());
+
+    // Links that were added.
+    Vector<WebCore::LinkHash> addedVisitedLinks;
+
+    if (currentTableSize != newTableSize) {
+        // Create a new table.
+        RefPtr<SharedMemory> newTableMemory = SharedMemory::create(newTableSize * sizeof(LinkHash));
+
+        // We failed to create the shared memory.
+        if (!newTableMemory)
+            return;
+
+        memset(newTableMemory->data(), 0, newTableMemory->size());
+
+        RefPtr<SharedMemory> currentTableMemory = m_table.sharedMemory();
+
+        m_table.setSharedMemory(newTableMemory);
+        m_tableSize = newTableSize;
+
+        if (currentTableMemory) {
+            ASSERT(currentTableMemory->size() == currentTableSize * sizeof(LinkHash));
+
+            // Go through the current hash table and re-add all entries to the new hash table.
+            const LinkHash* currentLinkHashes = static_cast<const LinkHash*>(currentTableMemory->data());
+            for (unsigned i = 0; i < currentTableSize; ++i) {
+                LinkHash linkHash = currentLinkHashes[i];
+                
+                if (!linkHash)
+                    continue;
+
+                // It should always be possible to add the link hash to a new table.
+                if (!m_table.addLinkHash(linkHash))
+                    ASSERT_NOT_REACHED();
+            }
+        }
+    }
+
+    for (size_t i = 0; i < pendingVisitedLinks.size(); ++i) {
+        if (m_table.addLinkHash(pendingVisitedLinks[i]))
+            addedVisitedLinks.append(pendingVisitedLinks[i]);
+    }
+
+    m_keyCount += pendingVisitedLinks.size();
+
+    if (currentTableSize != newTableSize) {
+        // Send the new visited link table.
+        
+        SharedMemory::Handle handle;
+        if (!m_table.sharedMemory()->createHandle(handle, SharedMemory::ReadOnly))
+            return;
+
+        m_context->process()->send(WebProcessMessage::SetVisitedLinkTable, 0, CoreIPC::In(handle));
+    }
+    
+    // We now need to let the web process know that we've added links.
+    if (addedVisitedLinks.size() <= 20) {
+        m_context->process()->send(WebProcessMessage::VisitedLinkStateChanged, 0, CoreIPC::In(addedVisitedLinks));
+        return;
+    }
+    
+    // Just recalculate all the visited links.
+    m_context->process()->send(WebProcessMessage::AllVisitedLinkStateChanged, 0, CoreIPC::In());
+    return;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/VisitedLinkProvider.h b/WebKit2/UIProcess/VisitedLinkProvider.h
new file mode 100644
index 0000000..82d5e50
--- /dev/null
+++ b/WebKit2/UIProcess/VisitedLinkProvider.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef VisitedLinkProvider_h
+#define VisitedLinkProvider_h
+
+#include "RunLoop.h"
+#include "VisitedLinkTable.h"
+#include <WebCore/LinkHash.h>
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+    class String;
+}
+
+namespace WebKit {
+
+class WebContext;
+    
+class VisitedLinkProvider : Noncopyable {
+public:
+    explicit VisitedLinkProvider(WebContext*);
+
+    void populateVisitedLinksIfNeeded();
+    void addVisitedLink(WebCore::LinkHash);
+
+private:
+    void pendingVisitedLinksTimerFired();
+
+    WebContext* m_context;
+    bool m_visitedLinksPopulated;
+
+    unsigned m_keyCount;
+    unsigned m_tableSize;
+    VisitedLinkTable m_table;
+
+    HashSet<WebCore::LinkHash, WebCore::LinkHashHash> m_pendingVisitedLinks;
+    RunLoop::Timer<VisitedLinkProvider> m_pendingVisitedLinksTimer;
+};
+
+} // namespace WebKit
+
+#endif // VisitedLinkProvider_h
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 0bd706c..54b6cb1 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -34,6 +34,8 @@
 		0FB659A61208B9EE0044816C /* DrawingAreaBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB659A51208B9EE0044816C /* DrawingAreaBase.cpp */; };
 		1A0F29CB120B37160053D1B9 /* VisitedLinkTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0F29C9120B37160053D1B9 /* VisitedLinkTable.cpp */; };
 		1A0F29CC120B37160053D1B9 /* VisitedLinkTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */; };
+		1A0F29E3120B44420053D1B9 /* VisitedLinkProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0F29E1120B44420053D1B9 /* VisitedLinkProvider.cpp */; };
+		1A0F29E4120B44420053D1B9 /* VisitedLinkProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0F29E2120B44420053D1B9 /* VisitedLinkProvider.h */; };
 		1A10475A110A5AD500A43ECD /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */; };
 		1A1C4EC810D06099005E67E7 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C79A100E7FC50078DEBC /* WebCore.framework */; };
 		1A1C649B11F4174200553C19 /* WebContextMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A1C648611F415B700553C19 /* WebContextMac.mm */; };
@@ -344,6 +346,8 @@
 		1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
 		1A0F29C9120B37160053D1B9 /* VisitedLinkTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisitedLinkTable.cpp; sourceTree = "<group>"; };
 		1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedLinkTable.h; sourceTree = "<group>"; };
+		1A0F29E1120B44420053D1B9 /* VisitedLinkProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisitedLinkProvider.cpp; sourceTree = "<group>"; };
+		1A0F29E2120B44420053D1B9 /* VisitedLinkProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedLinkProvider.h; sourceTree = "<group>"; };
 		1A1C648611F415B700553C19 /* WebContextMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContextMac.mm; sourceTree = "<group>"; };
 		1A2161AE11F37664008AD0F5 /* NPRuntimeObjectMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPRuntimeObjectMap.h; sourceTree = "<group>"; };
 		1A2161AF11F37664008AD0F5 /* NPRuntimeObjectMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeObjectMap.cpp; sourceTree = "<group>"; };
@@ -949,6 +953,8 @@
 				BC597074116591D000551FCA /* ProcessModel.h */,
 				BC111B08112F5E3C00337BAB /* ResponsivenessTimer.cpp */,
 				1A30066C1110F4F70031937C /* ResponsivenessTimer.h */,
+				1A0F29E1120B44420053D1B9 /* VisitedLinkProvider.cpp */,
+				1A0F29E2120B44420053D1B9 /* VisitedLinkProvider.h */,
 				BC72BA1B11E64907001EB4EA /* WebBackForwardList.cpp */,
 				BC72BA1C11E64907001EB4EA /* WebBackForwardList.h */,
 				BC646BF511DD377B006455B0 /* WebBackForwardListItem.cpp */,
@@ -1389,6 +1395,7 @@
 				516A4A5D120A2CCD00C05B7F /* WebError.h in Headers */,
 				1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */,
 				1A0F29CC120B37160053D1B9 /* VisitedLinkTable.h in Headers */,
+				1A0F29E4120B44420053D1B9 /* VisitedLinkProvider.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1598,6 +1605,7 @@
 				516A4A5A120A1AB500C05B7F /* WKError.cpp in Sources */,
 				1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */,
 				1A0F29CB120B37160053D1B9 /* VisitedLinkTable.cpp in Sources */,
+				1A0F29E3120B44420053D1B9 /* VisitedLinkProvider.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKit2/WebProcess/WebProcess.cpp b/WebKit2/WebProcess/WebProcess.cpp
index 7d48c6a..841f988 100644
--- a/WebKit2/WebProcess/WebProcess.cpp
+++ b/WebKit2/WebProcess/WebProcess.cpp
@@ -177,6 +177,12 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
 {
     if (messageID.is<CoreIPC::MessageClassWebProcess>()) {
         switch (messageID.get<WebProcessMessage::Kind>()) {
+            case WebProcessMessage::SetVisitedLinkTable:
+            case WebProcessMessage::VisitedLinkStateChanged:
+            case WebProcessMessage::AllVisitedLinkStateChanged:
+                // FIXME: Implement.
+                return;
+            
             case WebProcessMessage::AddVisitedLink: {
                 WebCore::LinkHash hash;
                 if (!arguments->decode(CoreIPC::Out(hash)))
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index e0d293c..f19b47b 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -953,6 +953,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\UIProcess\VisitedLinkProvider.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\UIProcess\VisitedLinkProvider.h"
+				>
+			</File>
+			<File
 				RelativePath="..\UIProcess\WebBackForwardList.cpp"
 				>
 			</File>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list