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

Changeset 176578 in webkit


Ignore:
Timestamp:
Nov 29, 2014, 2:23:36 PM (12 years ago)
Author:
andersca@apple.com
Message:

Stub out more of WebVisitedLinkStore on Windows
https://bugs.webkit.org/show_bug.cgi?id=139098

Reviewed by Sam Weinig.

  • WebCoreSupport/WebVisitedLinkStore.cpp:

(WebVisitedLinkStore::WebVisitedLinkStore):
Initialize m_visitedLinksPopulated to false.

(WebVisitedLinkStore::setShouldTrackVisitedLinks):
Update s_shouldTrackVisitedLinks and remove all visited links if needed.

(WebVisitedLinkStore::removeAllVisitedLinks):
Remove all hashes from our shared link store.

(WebVisitedLinkStore::addVisitedLink):
Compute the visited link hash and add it to the store.

(WebVisitedLinkStore::isLinkVisited):
Populate visited links and then look up the hash in our hash map.

(WebVisitedLinkStore::populateVisitedLinksIfNeeded):
Call out to the history delegate or populate visited links from shared history.

(WebVisitedLinkStore::addVisitedLinkHash):
Add the hash if we're tracking hashes.

(WebVisitedLinkStore::removeVisitedLinkHashes):
Clear the map.

  • WebCoreSupport/WebVisitedLinkStore.h:

Add members.

  • WebHistory.cpp:

(WebHistory::addVisitedLinksToVisitedLinkStore):
New function that adds visited links from the history to a given store.

  • WebHistory.h:

Add new member.

  • WebView.cpp:

(WebView::addVisitedLinks):
Add links to the visited link store as well.

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

Legend:

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

    r176573 r176578  
     12014-11-29  Anders Carlsson  <andersca@apple.com>
     2
     3        Stub out more of WebVisitedLinkStore on Windows
     4        https://bugs.webkit.org/show_bug.cgi?id=139098
     5
     6        Reviewed by Sam Weinig.
     7
     8        * WebCoreSupport/WebVisitedLinkStore.cpp:
     9        (WebVisitedLinkStore::WebVisitedLinkStore):
     10        Initialize m_visitedLinksPopulated to false.
     11
     12        (WebVisitedLinkStore::setShouldTrackVisitedLinks):
     13        Update s_shouldTrackVisitedLinks and remove all visited links if needed.
     14
     15        (WebVisitedLinkStore::removeAllVisitedLinks):
     16        Remove all hashes from our shared link store.
     17
     18        (WebVisitedLinkStore::addVisitedLink):
     19        Compute the visited link hash and add it to the store.
     20
     21        (WebVisitedLinkStore::isLinkVisited):
     22        Populate visited links and then look up the hash in our hash map.
     23
     24        (WebVisitedLinkStore::populateVisitedLinksIfNeeded):
     25        Call out to the history delegate or populate visited links from shared history.
     26
     27        (WebVisitedLinkStore::addVisitedLinkHash):
     28        Add the hash if we're tracking hashes.
     29
     30        (WebVisitedLinkStore::removeVisitedLinkHashes):
     31        Clear the map.
     32
     33        * WebCoreSupport/WebVisitedLinkStore.h:
     34        Add members.
     35
     36        * WebHistory.cpp:
     37        (WebHistory::addVisitedLinksToVisitedLinkStore):
     38        New function that adds visited links from the history to a given store.
     39
     40        * WebHistory.h:
     41        Add new member.
     42
     43        * WebView.cpp:
     44        (WebView::addVisitedLinks):
     45        Add links to the visited link store as well.
     46
    1472014-11-27  Anders Carlsson  <andersca@apple.com>
    248
  • trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.cpp

    r176573 r176578  
    2727#include "WebVisitedLinkStore.h"
    2828
     29#include "WebHistory.h"
     30#include "WebView.h"
     31#include <WebCore/PageCache.h>
    2932#include <wtf/NeverDestroyed.h>
     33
     34using namespace WebCore;
     35
     36static bool s_shouldTrackVisitedLinks;
    3037
    3138WebVisitedLinkStore& WebVisitedLinkStore::shared()
     
    3744
    3845WebVisitedLinkStore::WebVisitedLinkStore()
     46    : m_visitedLinksPopulated(false)
    3947{
    4048}
     
    4452}
    4553
    46 bool WebVisitedLinkStore::isLinkVisited(WebCore::Page&, WebCore::LinkHash, const WebCore::URL& baseURL, const AtomicString& attributeURL)
     54void WebVisitedLinkStore::setShouldTrackVisitedLinks(bool shouldTrackVisitedLinks)
    4755{
    48     // FIXME: Implement.
    49     return false;
     56    if (s_shouldTrackVisitedLinks == shouldTrackVisitedLinks)
     57        return;
     58
     59    s_shouldTrackVisitedLinks = shouldTrackVisitedLinks;
     60    if (!s_shouldTrackVisitedLinks)
     61        removeAllVisitedLinks();
    5062}
    5163
    52 void WebVisitedLinkStore::addVisitedLink(WebCore::Page&, WebCore::LinkHash)
     64void WebVisitedLinkStore::removeAllVisitedLinks()
    5365{
    54     // FIXME: Implement.
     66    shared().removeVisitedLinkHashes();
     67    pageCache()->markPagesForVistedLinkStyleRecalc();
    5568}
     69
     70void WebVisitedLinkStore::addVisitedLink(const String& urlString)
     71{
     72    addVisitedLinkHash(visitedLinkHash(urlString));
     73}
     74
     75bool WebVisitedLinkStore::isLinkVisited(Page& page, LinkHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
     76{
     77    populateVisitedLinksIfNeeded(page);
     78
     79    return m_visitedLinkHashes.contains(linkHash);
     80}
     81
     82void WebVisitedLinkStore::addVisitedLink(Page&, LinkHash linkHash)
     83{
     84    if (!s_shouldTrackVisitedLinks)
     85        return;
     86
     87    addVisitedLinkHash(linkHash);
     88}
     89
     90void WebVisitedLinkStore::populateVisitedLinksIfNeeded(Page& sourcePage)
     91{
     92    if (m_visitedLinksPopulated)
     93        return;
     94
     95    m_visitedLinksPopulated = true;
     96
     97    WebView* webView = kit(&sourcePage);
     98    if (!webView)
     99        return;
     100
     101    COMPtr<IWebHistoryDelegate> historyDelegate;
     102    webView->historyDelegate(&historyDelegate);
     103    if (historyDelegate) {
     104        historyDelegate->populateVisitedLinksForWebView(webView);
     105        return;
     106    }
     107
     108    WebHistory* history = WebHistory::sharedHistory();
     109    if (!history)
     110        return;
     111    history->addVisitedLinksToVisitedLinkStore(*this);
     112}
     113
     114void WebVisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
     115{
     116    ASSERT(s_shouldTrackVisitedLinks);
     117    m_visitedLinkHashes.add(linkHash);
     118
     119    invalidateStylesForLink(linkHash);
     120    pageCache()->markPagesForVistedLinkStyleRecalc();
     121}
     122
     123void WebVisitedLinkStore::removeVisitedLinkHashes()
     124{
     125    m_visitedLinksPopulated = false;
     126    if (m_visitedLinkHashes.isEmpty())
     127        return;
     128    m_visitedLinkHashes.clear();
     129
     130    invalidateStylesForAllLinks();
     131}
  • trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.h

    r176573 r176578  
    2727#define WebVisitedLinkStore_h
    2828
     29#include <WebCore/LinkHash.h>
    2930#include <WebCore/VisitedLinkStore.h>
    3031#include <wtf/PassRef.h>
     
    3637    virtual ~WebVisitedLinkStore();
    3738
     39    static void setShouldTrackVisitedLinks(bool);
     40    static void removeAllVisitedLinks();
     41
     42    void addVisitedLink(const String& urlString);
     43
    3844private:
    3945    virtual bool isLinkVisited(WebCore::Page&, WebCore::LinkHash, const WebCore::URL& baseURL, const AtomicString& attributeURL) override;
    4046    virtual void addVisitedLink(WebCore::Page&, WebCore::LinkHash) override;
     47
     48    void populateVisitedLinksIfNeeded(WebCore::Page&);
     49    void addVisitedLinkHash(WebCore::LinkHash);
     50    void removeVisitedLinkHashes();
     51
     52    HashSet<WebCore::LinkHash, WebCore::LinkHashHash> m_visitedLinkHashes;
     53    bool m_visitedLinksPopulated;
    4154};
    4255
  • trunk/Source/WebKit/win/WebHistory.cpp

    r174470 r176578  
    3535#include "WebNotificationCenter.h"
    3636#include "WebPreferences.h"
     37#include "WebVisitedLinkStore.h"
    3738#include <WebCore/BString.h>
    3839#include <WebCore/HistoryItem.h>
     
    579580}
    580581
     582WebHistory::addVisitedLinksToVisitedLinkStore(WebVisitedLinkStore& visitedLinkStore)
     583{
     584    for (auto& url : m_entriesByURL.keys())
     585        group.addVisitedLinkHash(visitedLinkHash(url));
     586}
     587
    581588void WebHistory::addVisitedLinksToPageGroup(PageGroup& group)
    582589{
  • trunk/Source/WebKit/win/WebHistory.h

    r165676 r176578  
    4040
    4141class WebPreferences;
     42class WebVisitedLinkStore;
    4243
    4344class WebHistory : public IWebHistory, public IWebHistoryPrivate {
     
    112113    void visitedURL(const WebCore::URL&, const WTF::String& title, const WTF::String& httpMethod, bool wasFailure, bool increaseVisitCount);
    113114    void addVisitedLinksToPageGroup(WebCore::PageGroup&);
     115    void addVisitedLinksToVisitedLinkStore(WebVisitedLinkStore&);
    114116
    115117    COMPtr<IWebHistoryItem> itemForURLString(const WTF::String&) const;
  • trunk/Source/WebKit/win/WebView.cpp

    r176523 r176578  
    6666#include "WebPreferences.h"
    6767#include "WebScriptWorld.h"
     68#include "WebVisitedLinkStore.h"
    6869#include "resource.h"
    6970#include <JavaScriptCore/APICast.h>
     
    64336434HRESULT WebView::addVisitedLinks(BSTR* visitedURLs, unsigned visitedURLCount)
    64346435{
     6436    auto& visitedLinkStore = WebVisitedLinkStore::shared();
    64356437    PageGroup& group = core(this)->group();
    64366438   
     
    64396441        unsigned length = SysStringLen(url);
    64406442        group.addVisitedLink(url, length);
     6443
     6444        visitedLinkStore.addVisitedLink(String(url, length));
    64416445    }
    64426446
Note: See TracChangeset for help on using the changeset viewer.