- Revision
- 176576
- Author
- [email protected]
- Date
- 2014-11-29 14:11:08 -0800 (Sat, 29 Nov 2014)
Log Message
Populate visited links
https://bugs.webkit.org/show_bug.cgi?id=139101
Reviewed by Sam Weinig.
* History/WebHistory.mm:
(-[WebHistoryPrivate addVisitedLinksToVisitedLinkStore:]):
Helper function that adds all visited link to the given store.
(-[WebHistory _addVisitedLinksToVisitedLinkStore:]):
Call the private method.
* History/WebHistoryInternal.h:
* WebCoreSupport/WebVisitedLinkStore.h:
Add new members.
* WebCoreSupport/WebVisitedLinkStore.mm:
(WebVisitedLinkStore::addVisitedLink):
Get the characters from the URL string and hash them, then call addVisitedLinkHash.
(WebVisitedLinkStore::populateVisitedLinksIfNeeded):
Implement this. First try the delegate, then try the shared history.
(WebVisitedLinkStore::addVisitedLinkHash):
Factor code that adds the link to the hash table into a separate function.
* WebView/WebView.mm:
(-[WebView addVisitedLinks:]):
Add the visited links to the store.
Modified Paths
Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (176575 => 176576)
--- trunk/Source/WebKit/mac/ChangeLog 2014-11-29 21:49:40 UTC (rev 176575)
+++ trunk/Source/WebKit/mac/ChangeLog 2014-11-29 22:11:08 UTC (rev 176576)
@@ -1,5 +1,37 @@
2014-11-29 Anders Carlsson <[email protected]>
+ Populate visited links
+ https://bugs.webkit.org/show_bug.cgi?id=139101
+
+ Reviewed by Sam Weinig.
+
+ * History/WebHistory.mm:
+ (-[WebHistoryPrivate addVisitedLinksToVisitedLinkStore:]):
+ Helper function that adds all visited link to the given store.
+
+ (-[WebHistory _addVisitedLinksToVisitedLinkStore:]):
+ Call the private method.
+
+ * History/WebHistoryInternal.h:
+ * WebCoreSupport/WebVisitedLinkStore.h:
+ Add new members.
+
+ * WebCoreSupport/WebVisitedLinkStore.mm:
+ (WebVisitedLinkStore::addVisitedLink):
+ Get the characters from the URL string and hash them, then call addVisitedLinkHash.
+
+ (WebVisitedLinkStore::populateVisitedLinksIfNeeded):
+ Implement this. First try the delegate, then try the shared history.
+
+ (WebVisitedLinkStore::addVisitedLinkHash):
+ Factor code that adds the link to the hash table into a separate function.
+
+ * WebView/WebView.mm:
+ (-[WebView addVisitedLinks:]):
+ Add the visited links to the store.
+
+2014-11-29 Anders Carlsson <[email protected]>
+
More work on the legacy WebKit visited link store
https://bugs.webkit.org/show_bug.cgi?id=139100
Modified: trunk/Source/WebKit/mac/History/WebHistory.mm (176575 => 176576)
--- trunk/Source/WebKit/mac/History/WebHistory.mm 2014-11-29 21:49:40 UTC (rev 176575)
+++ trunk/Source/WebKit/mac/History/WebHistory.mm 2014-11-29 22:11:08 UTC (rev 176576)
@@ -711,6 +711,12 @@
}
}
+- (void)addVisitedLinksToVisitedLinkStore:(WebVisitedLinkStore&)visitedLinkStore
+{
+ for (NSString *urlString in _entriesByURL)
+ visitedLinkStore.addVisitedLink(urlString);
+}
+
@end
@implementation WebHistory
@@ -945,6 +951,10 @@
[_historyPrivate addVisitedLinksToPageGroup:group];
}
+- (void)_addVisitedLinksToVisitedLinkStore:(WebVisitedLinkStore &)visitedLinkStore
+{
+ [_historyPrivate addVisitedLinksToVisitedLinkStore:visitedLinkStore];
+}
@end
WebHistoryWriter::WebHistoryWriter(DateToEntriesMap* entriesByDate)
Modified: trunk/Source/WebKit/mac/History/WebHistoryInternal.h (176575 => 176576)
--- trunk/Source/WebKit/mac/History/WebHistoryInternal.h 2014-11-29 21:49:40 UTC (rev 176575)
+++ trunk/Source/WebKit/mac/History/WebHistoryInternal.h 2014-11-29 22:11:08 UTC (rev 176576)
@@ -28,6 +28,8 @@
#import "WebHistoryPrivate.h"
+class WebVisitedLinkStore;
+
namespace WebCore {
class PageGroup;
}
@@ -35,4 +37,5 @@
@interface WebHistory (WebInternal)
- (void)_visitedURL:(NSURL *)URL withTitle:(NSString *)title method:(NSString *)method wasFailure:(BOOL)wasFailure;
- (void)_addVisitedLinksToPageGroup:(WebCore::PageGroup&)group;
+- (void)_addVisitedLinksToVisitedLinkStore:(WebVisitedLinkStore&)visitedLinkStore;
@end
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.h (176575 => 176576)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.h 2014-11-29 21:49:40 UTC (rev 176575)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.h 2014-11-29 22:11:08 UTC (rev 176576)
@@ -38,6 +38,8 @@
static void setShouldTrackVisitedLinks(bool);
static void removeAllVisitedLinks();
+ void addVisitedLink(NSString *urlString);
+
private:
WebVisitedLinkStore();
@@ -45,6 +47,7 @@
virtual void addVisitedLink(WebCore::Page&, WebCore::LinkHash) override;
void populateVisitedLinksIfNeeded(WebCore::Page&);
+ void addVisitedLinkHash(WebCore::LinkHash);
void removeVisitedLinkHashes();
HashSet<WebCore::LinkHash, WebCore::LinkHashHash> m_visitedLinkHashes;
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.mm (176575 => 176576)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.mm 2014-11-29 21:49:40 UTC (rev 176575)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.mm 2014-11-29 22:11:08 UTC (rev 176576)
@@ -25,6 +25,11 @@
#import "WebVisitedLinkStore.h"
+#import "WebDelegateImplementationCaching.h"
+#import "WebFrameInternal.h"
+#import "WebHistoryInternal.h"
+#import "WebViewInternal.h"
+#import <WebCore/BlockExceptions.h>
#import <WebCore/PageCache.h>
#import <wtf/NeverDestroyed.h>
@@ -72,6 +77,24 @@
pageCache()->markPagesForVistedLinkStyleRecalc();
}
+void WebVisitedLinkStore::addVisitedLink(NSString *urlString)
+{
+ if (!s_shouldTrackVisitedLinks)
+ return;
+
+ size_t length = urlString.length;
+
+ if (const UChar* characters = CFStringGetCharactersPtr((__bridge CFStringRef)urlString)) {
+ addVisitedLinkHash(visitedLinkHash(characters, length));
+ return;
+ }
+
+ Vector<UChar, 512> buffer(length);
+ [urlString getCharacters:buffer.data()];
+
+ addVisitedLinkHash(visitedLinkHash(buffer.data(), length));
+}
+
bool WebVisitedLinkStore::isLinkVisited(Page& page, LinkHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
{
return m_visitedLinkHashes.contains(linkHash);
@@ -79,24 +102,46 @@
void WebVisitedLinkStore::addVisitedLink(Page& sourcePage, LinkHash linkHash)
{
- ASSERT(s_shouldTrackVisitedLinks);
+ if (!s_shouldTrackVisitedLinks)
+ return;
- m_visitedLinkHashes.add(linkHash);
-
- invalidateStylesForLink(linkHash);
- pageCache()->markPagesForVistedLinkStyleRecalc();
+ addVisitedLinkHash(linkHash);
}
-void WebVisitedLinkStore::populateVisitedLinksIfNeeded(Page&)
+void WebVisitedLinkStore::populateVisitedLinksIfNeeded(Page& page)
{
if (m_visitedLinksPopulated)
return;
m_visitedLinksPopulated = true;
- // FIXME: Populate visited links.
+ WebView *webView = kit(&page);
+ ASSERT(webView);
+
+ if (webView.historyDelegate) {
+ WebHistoryDelegateImplementationCache* implementations = WebViewGetHistoryDelegateImplementations(webView);
+
+ if (implementations->populateVisitedLinksFunc)
+ CallHistoryDelegate(implementations->populateVisitedLinksFunc, webView, @selector(populateVisitedLinksForWebView:));
+
+ return;
+ }
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ [[WebHistory optionalSharedHistory] _addVisitedLinksToVisitedLinkStore:*this];
+ END_BLOCK_OBJC_EXCEPTIONS;
}
+void WebVisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
+{
+ ASSERT(s_shouldTrackVisitedLinks);
+
+ m_visitedLinkHashes.add(linkHash);
+
+ invalidateStylesForLink(linkHash);
+ pageCache()->markPagesForVistedLinkStyleRecalc();
+}
+
void WebVisitedLinkStore::removeVisitedLinkHashes()
{
m_visitedLinksPopulated = false;
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (176575 => 176576)
--- trunk/Source/WebKit/mac/WebView/WebView.mm 2014-11-29 21:49:40 UTC (rev 176575)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm 2014-11-29 22:11:08 UTC (rev 176576)
@@ -106,6 +106,7 @@
#import "WebUIDelegatePrivate.h"
#import "WebUserMediaClient.h"
#import "WebViewGroup.h"
+#import "WebVisitedLinkStore.h"
#import <CoreFoundation/CFSet.h>
#import <Foundation/NSURLConnection.h>
#import <_javascript_Core/APICast.h>
@@ -6993,8 +6994,12 @@
- (void)addVisitedLinks:(NSArray *)visitedLinks
{
+ WebVisitedLinkStore& visitedLinkStore = _private->group->visitedLinkStore();
+ for (NSString *urlString in visitedLinks)
+ visitedLinkStore.addVisitedLink(urlString);
+
PageGroup& group = core(self)->group();
-
+
NSEnumerator *enumerator = [visitedLinks objectEnumerator];
while (NSString *url = "" nextObject]) {
size_t length = [url length];