[Cocoa WebKit2] Add SPI to clear all visited links in a VisitedLinkProvider
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 May 2014 21:23:37 +0000 (21:23 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 May 2014 21:23:37 +0000 (21:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132573

Patch by Sam Weinig <sam@webkit.org> on 2014-05-05
Reviewed by Dan Bernstein.

* Shared/VisitedLinkTable.cpp:
(WebKit::VisitedLinkTable::VisitedLinkTable):
(WebKit::VisitedLinkTable::clear):
* Shared/VisitedLinkTable.h:
Add functions to clear the visited link table.

* UIProcess/API/Cocoa/_WKVisitedLinkProvider.h:
* UIProcess/API/Cocoa/_WKVisitedLinkProvider.mm:
(-[_WKVisitedLinkProvider removeAll]):
Add SPI.

* UIProcess/VisitedLinkProvider.cpp:
(WebKit::VisitedLinkProvider::removeAll):
* UIProcess/VisitedLinkProvider.h:
A remove all resets the provider and notifies all the attached processes.

* WebProcess/WebPage/VisitedLinkTableController.cpp:
(WebKit::VisitedLinkTableController::removeAllVisitedLinks):
* WebProcess/WebPage/VisitedLinkTableController.h:
* WebProcess/WebPage/VisitedLinkTableController.messages.in:
Add message to clear the visited links for a process.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168317 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/VisitedLinkTable.cpp
Source/WebKit2/Shared/VisitedLinkTable.h
Source/WebKit2/UIProcess/API/Cocoa/_WKVisitedLinkProvider.h
Source/WebKit2/UIProcess/API/Cocoa/_WKVisitedLinkProvider.mm
Source/WebKit2/UIProcess/VisitedLinkProvider.cpp
Source/WebKit2/UIProcess/VisitedLinkProvider.h
Source/WebKit2/WebProcess/WebPage/VisitedLinkTableController.cpp
Source/WebKit2/WebProcess/WebPage/VisitedLinkTableController.h
Source/WebKit2/WebProcess/WebPage/VisitedLinkTableController.messages.in

index 771fd1e..1dedce8 100644 (file)
@@ -1,3 +1,32 @@
+2014-05-05  Sam Weinig  <sam@webkit.org>
+
+        [Cocoa WebKit2] Add SPI to clear all visited links in a VisitedLinkProvider
+        https://bugs.webkit.org/show_bug.cgi?id=132573
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/VisitedLinkTable.cpp:
+        (WebKit::VisitedLinkTable::VisitedLinkTable):
+        (WebKit::VisitedLinkTable::clear):
+        * Shared/VisitedLinkTable.h:
+        Add functions to clear the visited link table.
+
+        * UIProcess/API/Cocoa/_WKVisitedLinkProvider.h:
+        * UIProcess/API/Cocoa/_WKVisitedLinkProvider.mm:
+        (-[_WKVisitedLinkProvider removeAll]):
+        Add SPI.
+
+        * UIProcess/VisitedLinkProvider.cpp:
+        (WebKit::VisitedLinkProvider::removeAll):
+        * UIProcess/VisitedLinkProvider.h:
+        A remove all resets the provider and notifies all the attached processes.
+
+        * WebProcess/WebPage/VisitedLinkTableController.cpp:
+        (WebKit::VisitedLinkTableController::removeAllVisitedLinks):
+        * WebProcess/WebPage/VisitedLinkTableController.h:
+        * WebProcess/WebPage/VisitedLinkTableController.messages.in:
+        Add message to clear the visited links for a process.
+
 2014-05-05  Benjamin Poulain  <benjamin@webkit.org>
 
         [iOS][WK2] Special case ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture() for image documents
index 30df619..59fe118 100644 (file)
@@ -34,7 +34,8 @@ namespace WebKit {
 
 VisitedLinkTable::VisitedLinkTable()
     : m_tableSize(0)
-    , m_table(0)
+    , m_tableSizeMask(0)
+    , m_table(nullptr)
 {
 }
 
@@ -136,4 +137,11 @@ bool VisitedLinkTable::isLinkVisited(LinkHash linkHash) const
     return false;
 }
 
+void VisitedLinkTable::clear()
+{
+    m_tableSize = 0;
+    m_tableSizeMask = 0;
+    m_sharedMemory = nullptr;
+}
+
 } // namespace WebKit
index c7274c3..861ce7a 100644 (file)
@@ -47,6 +47,7 @@ public:
     bool isLinkVisited(WebCore::LinkHash) const;
 
     SharedMemory* sharedMemory() const { return m_sharedMemory.get(); }
+    void clear();
 
 private:
     RefPtr<SharedMemory> m_sharedMemory;
index 1667149..7b6a772 100644 (file)
@@ -32,6 +32,7 @@ WK_API_CLASS
 @interface _WKVisitedLinkProvider : NSObject
 
 - (void)addVisitedLinkWithURL:(NSURL *)URL;
+- (void)removeAll;
 
 @end
 
index 18e5cdd..e65c9ac 100644 (file)
     _visitedLinkProvider->addVisitedLinkHash(linkHash);
 }
 
+- (void)removeAll
+{
+    _visitedLinkProvider->removeAll();
+}
+
 @end
 
 #endif
index 338e482..7cb6399 100644 (file)
@@ -89,6 +89,18 @@ void VisitedLinkProvider::removeProcess(WebProcessProxy& process)
         process.removeMessageReceiver(Messages::VisitedLinkProvider::messageReceiverName(), m_identifier);
 }
 
+void VisitedLinkProvider::removeAll()
+{
+    m_pendingVisitedLinksTimer.stop();
+    m_pendingVisitedLinks.clear();
+    m_keyCount = 0;
+    m_tableSize = 0;
+    m_table.clear();
+
+    for (auto& processAndCount : m_processes)
+        processAndCount.key->connection()->send(Messages::VisitedLinkTableController::RemoveAllVisitedLinks(), m_identifier);
+}
+
 void VisitedLinkProvider::addVisitedLinkHash(LinkHash linkHash)
 {
     m_pendingVisitedLinks.add(linkHash);
index b4633ff..d3f3524 100644 (file)
@@ -52,6 +52,7 @@ public:
     void removeProcess(WebProcessProxy&);
 
     void addVisitedLinkHash(WebCore::LinkHash);
+    void removeAll();
 
 private:
     VisitedLinkProvider();
index c44e3a6..8e37462 100644 (file)
@@ -113,4 +113,12 @@ void VisitedLinkTableController::allVisitedLinkStateChanged()
     pageCache()->markPagesForVistedLinkStyleRecalc();
 }
 
+void VisitedLinkTableController::removeAllVisitedLinks()
+{
+    m_visitedLinkTable.clear();
+
+    invalidateStylesForAllLinks();
+    pageCache()->markPagesForVistedLinkStyleRecalc();
+}
+
 } // namespace WebKit
index 45db74f..d659ddb 100644 (file)
@@ -51,6 +51,7 @@ private:
     void setVisitedLinkTable(const SharedMemory::Handle&);
     void visitedLinkStateChanged(const Vector<WebCore::LinkHash>&);
     void allVisitedLinkStateChanged();
+    void removeAllVisitedLinks();
 
     uint64_t m_identifier;
     VisitedLinkTable m_visitedLinkTable;
index e3b3ad1..039dd30 100644 (file)
@@ -24,4 +24,5 @@ messages -> VisitedLinkTableController {
     SetVisitedLinkTable(WebKit::SharedMemory::Handle handle)
     VisitedLinkStateChanged(Vector<WebCore::LinkHash> linkHashes)
     AllVisitedLinkStateChanged()
+    RemoveAllVisitedLinks()
 }