[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:44:56 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7cd2cf0da8aa45fb77fce34c7295b28a983b5161
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 5 18:58:24 2010 +0000

    Add VisitedLinkTable class
    https://bugs.webkit.org/show_bug.cgi?id=43566
    
    Reviewed by Sam Weinig.
    
    * Shared/VisitedLinkTable.cpp: Added.
    (WebKit::VisitedLinkTable::VisitedLinkTable):
    (WebKit::VisitedLinkTable::~VisitedLinkTable):
    Add out of line constructors so we won't have to include SharedMemory.h in the
    VisitedLinkTable.h header.
    
    (WebKit::isPowerOf2):
    Add helper function.
    
    (WebKit::VisitedLinkTable::setSharedMemory):
    Set the new shared memory and update the table size and hash.
    
    (WebKit::doubleHash):
    Add helper function from the WTF HashTable.
    
    (WebKit::VisitedLinkTable::addLinkHash):
    Add a link hash to the table.
    
    (WebKit::VisitedLinkTable::isLinkVisited):
    See if there is an entry for the given link hash.
    
    * Shared/VisitedLinkTable.h: Added.
    (WebKit::VisitedLinkTable::sharedMemory):
    * WebKit2.xcodeproj/project.pbxproj:
    * win/WebKit2.vcproj:
    Add VisitedLinkTable.cpp and VisitedLinkTable.h
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64768 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 2a58a58..c3c4c3b 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,37 @@
+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
+
+        * Shared/VisitedLinkTable.cpp: Added.
+        (WebKit::VisitedLinkTable::VisitedLinkTable):
+        (WebKit::VisitedLinkTable::~VisitedLinkTable):
+        Add out of line constructors so we won't have to include SharedMemory.h in the 
+        VisitedLinkTable.h header.
+
+        (WebKit::isPowerOf2):
+        Add helper function.
+
+        (WebKit::VisitedLinkTable::setSharedMemory):
+        Set the new shared memory and update the table size and hash.
+
+        (WebKit::doubleHash):
+        Add helper function from the WTF HashTable.
+
+        (WebKit::VisitedLinkTable::addLinkHash):
+        Add a link hash to the table.
+
+        (WebKit::VisitedLinkTable::isLinkVisited):
+        See if there is an entry for the given link hash.
+
+        * Shared/VisitedLinkTable.h: Added.
+        (WebKit::VisitedLinkTable::sharedMemory):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+        Add VisitedLinkTable.cpp and VisitedLinkTable.h
+
 2010-08-04  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Adam Roben.
diff --git a/WebKit2/Shared/VisitedLinkTable.cpp b/WebKit2/Shared/VisitedLinkTable.cpp
new file mode 100644
index 0000000..746ec3e
--- /dev/null
+++ b/WebKit2/Shared/VisitedLinkTable.cpp
@@ -0,0 +1,136 @@
+/*
+ * 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 "VisitedLinkTable.h"
+
+#include "SharedMemory.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+VisitedLinkTable::VisitedLinkTable()
+    : m_tableSize(0)
+    , m_table(0)
+{
+}
+
+VisitedLinkTable::~VisitedLinkTable()
+{
+}
+
+static inline bool isPowerOf2(unsigned v)
+{
+    // Taken from http://www.cs.utk.edu/~vose/c-stuff/bithacks.html
+    
+    return !(v & (v - 1)) && v;
+}
+
+void VisitedLinkTable::setSharedMemory(PassRefPtr<SharedMemory> sharedMemory)
+{
+    m_sharedMemory = sharedMemory;
+    
+    ASSERT(m_sharedMemory);
+    ASSERT(!(m_sharedMemory->size() % sizeof(LinkHash)));
+
+    m_table = static_cast<LinkHash*>(m_sharedMemory->data());
+    m_tableSize = m_sharedMemory->size() / sizeof(LinkHash);
+    ASSERT(isPowerOf2(m_tableSize));
+    
+    m_tableSizeMask = m_tableSize - 1;
+}
+
+static inline unsigned doubleHash(unsigned key)
+{
+    key = ~key + (key >> 23);
+    key ^= (key << 12);
+    key ^= (key >> 7);
+    key ^= (key << 2);
+    key ^= (key >> 20);
+    return key;
+}
+    
+bool VisitedLinkTable::addLinkHash(LinkHash linkHash)
+{
+    ASSERT(m_sharedMemory);
+
+    int k = 0;
+    LinkHash* table = m_table;
+    int sizeMask = m_tableSizeMask;
+    unsigned h = static_cast<unsigned>(linkHash);
+    int i = h & sizeMask;
+  
+    LinkHash* entry;
+    while (1) {
+        entry = table + i;
+
+        // Check if this bucket is empty.
+        if (!*entry)
+            break;
+
+        // Check if the same link hash is in the table already.
+        if (*entry == linkHash)
+            return false;
+
+        if (!k)
+            k = 1 | doubleHash(h);
+        i = (i + k) & sizeMask;
+    }
+
+    *entry = linkHash;
+    return true;
+}
+
+bool VisitedLinkTable::isLinkVisited(LinkHash linkHash) const
+{
+    if (!m_sharedMemory)
+        return false;
+
+    int k = 0;
+    LinkHash* table = m_table;
+    int sizeMask = m_tableSizeMask;
+    unsigned h = static_cast<unsigned>(linkHash);
+    int i = h & sizeMask;
+    
+    LinkHash* entry;
+    while (1) {
+        entry = table + i;
+
+        // Check if we've reached the end of the table.
+        if (!*entry)
+            break;
+        
+        if (*entry == linkHash)
+            return true;
+        
+        if (!k)
+            k = 1 | doubleHash(h);
+        i = (i + k) & sizeMask;
+    }
+
+    return false;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/Shared/VisitedLinkTable.h b/WebKit2/Shared/VisitedLinkTable.h
new file mode 100644
index 0000000..c7274c3
--- /dev/null
+++ b/WebKit2/Shared/VisitedLinkTable.h
@@ -0,0 +1,61 @@
+/*
+ * 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 VisitedLinkTable_h
+#define VisitedLinkTable_h
+
+#include <WebCore/LinkHash.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class SharedMemory;
+
+class VisitedLinkTable {
+public:
+    VisitedLinkTable();
+    ~VisitedLinkTable();
+
+    void setSharedMemory(PassRefPtr<SharedMemory>);
+
+    // This should only be called from the UI process.
+    bool addLinkHash(WebCore::LinkHash);
+
+    bool isLinkVisited(WebCore::LinkHash) const;
+
+    SharedMemory* sharedMemory() const { return m_sharedMemory.get(); }
+
+private:
+    RefPtr<SharedMemory> m_sharedMemory;
+
+    unsigned m_tableSize;
+    unsigned m_tableSizeMask;
+    WebCore::LinkHash* m_table;
+};
+
+}
+
+#endif // VisitedLinkTable_h
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index dcca43f..0bd706c 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -32,6 +32,8 @@
 		0F52667411DD4A490006D33C /* WebProcessProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F52667311DD4A490006D33C /* WebProcessProxyMac.mm */; };
 		0FB659231208B4DB0044816C /* DrawingAreaBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB659221208B4DB0044816C /* DrawingAreaBase.h */; };
 		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 */; };
 		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 */; };
@@ -340,6 +342,8 @@
 		0FB659221208B4DB0044816C /* DrawingAreaBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingAreaBase.h; sourceTree = "<group>"; };
 		0FB659A51208B9EE0044816C /* DrawingAreaBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DrawingAreaBase.cpp; sourceTree = "<group>"; };
 		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>"; };
 		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>"; };
@@ -797,6 +801,8 @@
 				BC64696D11DBE603006455B0 /* ImmutableArray.cpp */,
 				BC64696E11DBE603006455B0 /* ImmutableArray.h */,
 				BCC57161115ADB42001CCAF9 /* NotImplemented.h */,
+				1A0F29C9120B37160053D1B9 /* VisitedLinkTable.cpp */,
+				1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */,
 				BC1DD7B1114DC396005ADAF3 /* WebCoreArgumentCoders.h */,
 				51578B821209ECEF00A37C4A /* WebData.h */,
 				516A4A5B120A2CCD00C05B7F /* WebError.h */,
@@ -1382,6 +1388,7 @@
 				516A4A59120A1AB500C05B7F /* WKError.h in Headers */,
 				516A4A5D120A2CCD00C05B7F /* WebError.h in Headers */,
 				1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */,
+				1A0F29CC120B37160053D1B9 /* VisitedLinkTable.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1590,6 +1597,7 @@
 				C0E3AA7B1209E83500A49D01 /* Module.cpp in Sources */,
 				516A4A5A120A1AB500C05B7F /* WKError.cpp in Sources */,
 				1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */,
+				1A0F29CB120B37160053D1B9 /* VisitedLinkTable.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index 524ecd6..e0d293c 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -417,6 +417,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\Shared\VisitedLinkTable.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Shared\VisitedLinkTable.h"
+				>
+			</File>
+			<File
 				RelativePath="..\Shared\WebCoreTypeArgumentMarshalling.h"
 				>
 			</File>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list