⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176576 in webkit


Ignore:
Timestamp:
Nov 29, 2014, 2:11:08 PM (12 years ago)
Author:
andersca@apple.com
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.

Location:
trunk/Source/WebKit/mac
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/mac/ChangeLog

    r176575 r176576  
     12014-11-29  Anders Carlsson  <andersca@apple.com>
     2
     3        Populate visited links
     4        https://bugs.webkit.org/show_bug.cgi?id=139101
     5
     6        Reviewed by Sam Weinig.
     7
     8        * History/WebHistory.mm:
     9        (-[WebHistoryPrivate addVisitedLinksToVisitedLinkStore:]):
     10        Helper function that adds all visited link to the given store.
     11
     12        (-[WebHistory _addVisitedLinksToVisitedLinkStore:]):
     13        Call the private method.
     14
     15        * History/WebHistoryInternal.h:
     16        * WebCoreSupport/WebVisitedLinkStore.h:
     17        Add new members.
     18
     19        * WebCoreSupport/WebVisitedLinkStore.mm:
     20        (WebVisitedLinkStore::addVisitedLink):
     21        Get the characters from the URL string and hash them, then call addVisitedLinkHash.
     22
     23        (WebVisitedLinkStore::populateVisitedLinksIfNeeded):
     24        Implement this. First try the delegate, then try the shared history.
     25
     26        (WebVisitedLinkStore::addVisitedLinkHash):
     27        Factor code that adds the link to the hash table into a separate function.
     28
     29        * WebView/WebView.mm:
     30        (-[WebView addVisitedLinks:]):
     31        Add the visited links to the store.
     32
    1332014-11-29  Anders Carlsson  <andersca@apple.com>
    234
  • trunk/Source/WebKit/mac/History/WebHistory.mm

    r176575 r176576  
    712712}
    713713
     714- (void)addVisitedLinksToVisitedLinkStore:(WebVisitedLinkStore&)visitedLinkStore
     715{
     716    for (NSString *urlString in _entriesByURL)
     717        visitedLinkStore.addVisitedLink(urlString);
     718}
     719
    714720@end
    715721
     
    946952}
    947953
     954- (void)_addVisitedLinksToVisitedLinkStore:(WebVisitedLinkStore &)visitedLinkStore
     955{
     956    [_historyPrivate addVisitedLinksToVisitedLinkStore:visitedLinkStore];
     957}
    948958@end
    949959
  • trunk/Source/WebKit/mac/History/WebHistoryInternal.h

    r170368 r176576  
    2929#import "WebHistoryPrivate.h"
    3030
     31class WebVisitedLinkStore;
     32
    3133namespace WebCore {
    3234    class PageGroup;
     
    3638- (void)_visitedURL:(NSURL *)URL withTitle:(NSString *)title method:(NSString *)method wasFailure:(BOOL)wasFailure;
    3739- (void)_addVisitedLinksToPageGroup:(WebCore::PageGroup&)group;
     40- (void)_addVisitedLinksToVisitedLinkStore:(WebVisitedLinkStore&)visitedLinkStore;
    3841@end
  • trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.h

    r176575 r176576  
    3939    static void removeAllVisitedLinks();
    4040
     41    void addVisitedLink(NSString *urlString);
     42
    4143private:
    4244    WebVisitedLinkStore();
     
    4648
    4749    void populateVisitedLinksIfNeeded(WebCore::Page&);
     50    void addVisitedLinkHash(WebCore::LinkHash);
    4851    void removeVisitedLinkHashes();
    4952
  • trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.mm

    r176575 r176576  
    2626#import "WebVisitedLinkStore.h"
    2727
     28#import "WebDelegateImplementationCaching.h"
     29#import "WebFrameInternal.h"
     30#import "WebHistoryInternal.h"
     31#import "WebViewInternal.h"
     32#import <WebCore/BlockExceptions.h>
    2833#import <WebCore/PageCache.h>
    2934#import <wtf/NeverDestroyed.h>
     
    7378}
    7479
     80void WebVisitedLinkStore::addVisitedLink(NSString *urlString)
     81{
     82    if (!s_shouldTrackVisitedLinks)
     83        return;
     84
     85    size_t length = urlString.length;
     86
     87    if (const UChar* characters = CFStringGetCharactersPtr((__bridge CFStringRef)urlString)) {
     88        addVisitedLinkHash(visitedLinkHash(characters, length));
     89        return;
     90    }
     91
     92    Vector<UChar, 512> buffer(length);
     93    [urlString getCharacters:buffer.data()];
     94
     95    addVisitedLinkHash(visitedLinkHash(buffer.data(), length));
     96}
     97
    7598bool WebVisitedLinkStore::isLinkVisited(Page& page, LinkHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
    7699{
     
    80103void WebVisitedLinkStore::addVisitedLink(Page& sourcePage, LinkHash linkHash)
    81104{
     105    if (!s_shouldTrackVisitedLinks)
     106        return;
     107
     108    addVisitedLinkHash(linkHash);
     109}
     110
     111void WebVisitedLinkStore::populateVisitedLinksIfNeeded(Page& page)
     112{
     113    if (m_visitedLinksPopulated)
     114        return;
     115
     116    m_visitedLinksPopulated = true;
     117
     118    WebView *webView = kit(&page);
     119    ASSERT(webView);
     120
     121    if (webView.historyDelegate) {
     122        WebHistoryDelegateImplementationCache* implementations = WebViewGetHistoryDelegateImplementations(webView);
     123
     124        if (implementations->populateVisitedLinksFunc)
     125            CallHistoryDelegate(implementations->populateVisitedLinksFunc, webView, @selector(populateVisitedLinksForWebView:));
     126
     127        return;
     128    }
     129
     130    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     131    [[WebHistory optionalSharedHistory] _addVisitedLinksToVisitedLinkStore:*this];
     132    END_BLOCK_OBJC_EXCEPTIONS;
     133}
     134
     135void WebVisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
     136{
    82137    ASSERT(s_shouldTrackVisitedLinks);
    83138
     
    86141    invalidateStylesForLink(linkHash);
    87142    pageCache()->markPagesForVistedLinkStyleRecalc();
    88 }
    89 
    90 void WebVisitedLinkStore::populateVisitedLinksIfNeeded(Page&)
    91 {
    92     if (m_visitedLinksPopulated)
    93         return;
    94 
    95     m_visitedLinksPopulated = true;
    96 
    97     // FIXME: Populate visited links.
    98143}
    99144
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r176544 r176576  
    107107#import "WebUserMediaClient.h"
    108108#import "WebViewGroup.h"
     109#import "WebVisitedLinkStore.h"
    109110#import <CoreFoundation/CFSet.h>
    110111#import <Foundation/NSURLConnection.h>
     
    69946995- (void)addVisitedLinks:(NSArray *)visitedLinks
    69956996{
     6997    WebVisitedLinkStore& visitedLinkStore = _private->group->visitedLinkStore();
     6998    for (NSString *urlString in visitedLinks)
     6999        visitedLinkStore.addVisitedLink(urlString);
     7000
    69967001    PageGroup& group = core(self)->group();
    6997    
     7002
    69987003    NSEnumerator *enumerator = [visitedLinks objectEnumerator];
    69997004    while (NSString *url = [enumerator nextObject]) {
Note: See TracChangeset for help on using the changeset viewer.