Split some logic out of VisitedLinkStore and make it reusable
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Sep 2017 21:14:09 +0000 (21:14 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Sep 2017 21:14:09 +0000 (21:14 +0000)
commitf986010b31bd60b6e54497ac48f96bdd0428a84e
treeeaf31479a8b8f2a4e765c518db81047f7a399e2a
parent0c24dc40c3decdb251cfc72522f824f68fa97652
Split some logic out of VisitedLinkStore and make it reusable
https://bugs.webkit.org/show_bug.cgi?id=177575

Reviewed by Alex Christensen.

Source/WebCore:

Rename LinkHash to SharedStringHash to make it more reusable.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/StyleResolver.cpp:
* dom/VisitedLinkState.cpp:
(WebCore::linkHashForElement):
(WebCore::VisitedLinkState::invalidateStyleForLink):
(WebCore::VisitedLinkState::determineLinkStateSlowCase):
* dom/VisitedLinkState.h:
* html/HTMLAnchorElement.h:
(WebCore::HTMLAnchorElement::visitedLinkHash const):
* loader/EmptyClients.cpp:
* loader/HistoryController.cpp:
(WebCore::addVisitedLink):
* page/Page.cpp:
(WebCore::Page::invalidateStylesForLink):
* page/Page.h:
* page/VisitedLinkStore.cpp:
(WebCore::VisitedLinkStore::invalidateStylesForLink):
* page/VisitedLinkStore.h:
* platform/SharedStringHash.cpp: Renamed from Source/WebCore/platform/LinkHash.cpp.
(WebCore::needsTrailingSlash):
(WebCore::computeSharedStringHashInline):
(WebCore::computeSharedStringHash):
* platform/SharedStringHash.h: Renamed from Source/WebCore/platform/LinkHash.h.
(WebCore::SharedStringHashHash::hash):
(WebCore::SharedStringHashHash::equal):
(WebCore::SharedStringHashHash::avoidDeletedValue):

Source/WebKit:

Split some logic out of VisitedLinkStore and make it reusable for other purposes than
visited links and from other processes than the UIProcess.

The plan is to reuse the new SharedStringHashStore for Service Worker registration
on StorageProcess side and querying on WebContent process side.

* CMakeLists.txt:
* Shared/SharedStringHashStore.cpp: Added.
(WebKit::nextPowerOf2):
(WebKit::tableSizeForKeyCount):
(WebKit::SharedStringHashStore::SharedStringHashStore):
(WebKit::SharedStringHashStore::createSharedMemoryHandle):
(WebKit::SharedStringHashStore::add):
(WebKit::SharedStringHashStore::clear):
(WebKit::SharedStringHashStore::resizeTable):
(WebKit::SharedStringHashStore::pendingSharedStringHashesTimerFired):
* Shared/SharedStringHashStore.h: Copied from Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.h.
(WebKit::SharedStringHashStore::Client::~Client):
(WebKit::SharedStringHashStore::isEmpty const):
* Shared/SharedStringHashTable.cpp: Renamed from Source/WebKit/Shared/VisitedLinkTable.cpp.
(WebKit::SharedStringHashTable::SharedStringHashTable):
(WebKit::SharedStringHashTable::~SharedStringHashTable):
(WebKit::SharedStringHashTable::setSharedMemory):
(WebKit::SharedStringHashTable::add):
(WebKit::SharedStringHashTable::contains const):
(WebKit::SharedStringHashTable::clear):
* Shared/SharedStringHashTable.h: Renamed from Source/WebKit/Shared/VisitedLinkTable.h.
* UIProcess/API/C/WKContext.cpp:
(WKContextAddVisitedLink):
* UIProcess/API/Cocoa/_WKVisitedLinkStore.mm:
(-[_WKVisitedLinkStore addVisitedLinkWithURL:]):
* UIProcess/VisitedLinkStore.cpp:
(WebKit::VisitedLinkStore::VisitedLinkStore):
(WebKit::VisitedLinkStore::addProcess):
(WebKit::VisitedLinkStore::addVisitedLinkHash):
(WebKit::VisitedLinkStore::removeAll):
(WebKit::VisitedLinkStore::addVisitedLinkHashFromPage):
(WebKit::VisitedLinkStore::sendStoreHandleToProcess):
(WebKit::VisitedLinkStore::didInvalidateSharedMemory):
(WebKit::VisitedLinkStore::didAddSharedStringHashes):
* UIProcess/VisitedLinkStore.h:
* UIProcess/WebProcessPool.cpp:
* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessProxy.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebPage/VisitedLinkTableController.cpp:
(WebKit::VisitedLinkTableController::isLinkVisited):
(WebKit::VisitedLinkTableController::addVisitedLink):
(WebKit::VisitedLinkTableController::visitedLinkStateChanged):
* WebProcess/WebPage/VisitedLinkTableController.h:
* WebProcess/WebPage/VisitedLinkTableController.messages.in:

Source/WebKitLegacy/mac:

* WebCoreSupport/WebVisitedLinkStore.h:
* WebCoreSupport/WebVisitedLinkStore.mm:
(WebVisitedLinkStore::addVisitedLink):
(WebVisitedLinkStore::removeVisitedLink):
(WebVisitedLinkStore::isLinkVisited):
(WebVisitedLinkStore::addVisitedLinkHash):

Source/WebKitLegacy/win:

* WebCoreSupport/WebVisitedLinkStore.cpp:
(WebVisitedLinkStore::addVisitedLink):
(WebVisitedLinkStore::isLinkVisited):
(WebVisitedLinkStore::addVisitedLinkHash):
* WebCoreSupport/WebVisitedLinkStore.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
38 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/dom/VisitedLinkState.cpp
Source/WebCore/dom/VisitedLinkState.h
Source/WebCore/html/HTMLAnchorElement.h
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/HistoryController.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/VisitedLinkStore.cpp
Source/WebCore/page/VisitedLinkStore.h
Source/WebCore/platform/SharedStringHash.cpp [moved from Source/WebCore/platform/LinkHash.cpp with 83% similarity]
Source/WebCore/platform/SharedStringHash.h [moved from Source/WebCore/platform/LinkHash.h with 75% similarity]
Source/WebKit/CMakeLists.txt
Source/WebKit/ChangeLog
Source/WebKit/Shared/SharedStringHashStore.cpp [new file with mode: 0644]
Source/WebKit/Shared/SharedStringHashStore.h [new file with mode: 0644]
Source/WebKit/Shared/SharedStringHashTable.cpp [moved from Source/WebKit/Shared/VisitedLinkTable.cpp with 74% similarity]
Source/WebKit/Shared/SharedStringHashTable.h [moved from Source/WebKit/Shared/VisitedLinkTable.h with 76% similarity]
Source/WebKit/UIProcess/API/C/WKContext.cpp
Source/WebKit/UIProcess/API/Cocoa/_WKVisitedLinkStore.mm
Source/WebKit/UIProcess/VisitedLinkStore.cpp
Source/WebKit/UIProcess/VisitedLinkStore.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebProcessProxy.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.cpp
Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.h
Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.messages.in
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebVisitedLinkStore.h
Source/WebKitLegacy/mac/WebCoreSupport/WebVisitedLinkStore.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebVisitedLinkStore.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebVisitedLinkStore.h