Title: [176578] trunk/Source/WebKit/win
Revision
176578
Author
[email protected]
Date
2014-11-29 14:23:36 -0800 (Sat, 29 Nov 2014)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebKit/win/ChangeLog (176577 => 176578)


--- trunk/Source/WebKit/win/ChangeLog	2014-11-29 22:17:07 UTC (rev 176577)
+++ trunk/Source/WebKit/win/ChangeLog	2014-11-29 22:23:36 UTC (rev 176578)
@@ -1,3 +1,49 @@
+2014-11-29  Anders Carlsson  <[email protected]>
+
+        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.
+
 2014-11-27  Anders Carlsson  <[email protected]>
 
         Add a stubbed out WebVisitedLinkStore class on Windows

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.cpp (176577 => 176578)


--- trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.cpp	2014-11-29 22:17:07 UTC (rev 176577)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.cpp	2014-11-29 22:23:36 UTC (rev 176578)
@@ -26,8 +26,15 @@
 #include "config.h"
 #include "WebVisitedLinkStore.h"
 
+#include "WebHistory.h"
+#include "WebView.h"
+#include <WebCore/PageCache.h>
 #include <wtf/NeverDestroyed.h>
 
+using namespace WebCore;
+
+static bool s_shouldTrackVisitedLinks;
+
 WebVisitedLinkStore& WebVisitedLinkStore::shared()
 {
     static NeverDestroyed<WebVisitedLinkStore> visitedLinkStore;
@@ -36,6 +43,7 @@
 }
 
 WebVisitedLinkStore::WebVisitedLinkStore()
+    : m_visitedLinksPopulated(false)
 {
 }
 
@@ -43,13 +51,81 @@
 {
 }
 
-bool WebVisitedLinkStore::isLinkVisited(WebCore::Page&, WebCore::LinkHash, const WebCore::URL& baseURL, const AtomicString& attributeURL)
+void WebVisitedLinkStore::setShouldTrackVisitedLinks(bool shouldTrackVisitedLinks)
 {
-    // FIXME: Implement.
-    return false;
+    if (s_shouldTrackVisitedLinks == shouldTrackVisitedLinks)
+        return;
+
+    s_shouldTrackVisitedLinks = shouldTrackVisitedLinks;
+    if (!s_shouldTrackVisitedLinks)
+        removeAllVisitedLinks();
 }
 
-void WebVisitedLinkStore::addVisitedLink(WebCore::Page&, WebCore::LinkHash)
+void WebVisitedLinkStore::removeAllVisitedLinks()
 {
-    // FIXME: Implement.
+    shared().removeVisitedLinkHashes();
+    pageCache()->markPagesForVistedLinkStyleRecalc();
 }
+
+void WebVisitedLinkStore::addVisitedLink(const String& urlString)
+{
+    addVisitedLinkHash(visitedLinkHash(urlString));
+}
+
+bool WebVisitedLinkStore::isLinkVisited(Page& page, LinkHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
+{
+    populateVisitedLinksIfNeeded(page);
+
+    return m_visitedLinkHashes.contains(linkHash);
+}
+
+void WebVisitedLinkStore::addVisitedLink(Page&, LinkHash linkHash)
+{
+    if (!s_shouldTrackVisitedLinks)
+        return;
+
+    addVisitedLinkHash(linkHash);
+}
+
+void WebVisitedLinkStore::populateVisitedLinksIfNeeded(Page& sourcePage)
+{
+    if (m_visitedLinksPopulated)
+        return;
+
+    m_visitedLinksPopulated = true;
+
+    WebView* webView = kit(&sourcePage);
+    if (!webView)
+        return;
+
+    COMPtr<IWebHistoryDelegate> historyDelegate;
+    webView->historyDelegate(&historyDelegate);
+    if (historyDelegate) {
+        historyDelegate->populateVisitedLinksForWebView(webView);
+        return;
+    }
+
+    WebHistory* history = WebHistory::sharedHistory();
+    if (!history)
+        return;
+    history->addVisitedLinksToVisitedLinkStore(*this);
+}
+
+void WebVisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
+{
+    ASSERT(s_shouldTrackVisitedLinks);
+    m_visitedLinkHashes.add(linkHash);
+
+    invalidateStylesForLink(linkHash);
+    pageCache()->markPagesForVistedLinkStyleRecalc();
+}
+
+void WebVisitedLinkStore::removeVisitedLinkHashes()
+{
+    m_visitedLinksPopulated = false;
+    if (m_visitedLinkHashes.isEmpty())
+        return;
+    m_visitedLinkHashes.clear();
+
+    invalidateStylesForAllLinks();
+}

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.h (176577 => 176578)


--- trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.h	2014-11-29 22:17:07 UTC (rev 176577)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.h	2014-11-29 22:23:36 UTC (rev 176578)
@@ -26,6 +26,7 @@
 #ifndef WebVisitedLinkStore_h
 #define WebVisitedLinkStore_h
 
+#include <WebCore/LinkHash.h>
 #include <WebCore/VisitedLinkStore.h>
 #include <wtf/PassRef.h>
 
@@ -35,9 +36,21 @@
     WebVisitedLinkStore();
     virtual ~WebVisitedLinkStore();
 
+    static void setShouldTrackVisitedLinks(bool);
+    static void removeAllVisitedLinks();
+
+    void addVisitedLink(const String& urlString);
+
 private:
     virtual bool isLinkVisited(WebCore::Page&, WebCore::LinkHash, const WebCore::URL& baseURL, const AtomicString& attributeURL) override;
     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;
+    bool m_visitedLinksPopulated;
 };
 
 #endif // WebVisitedLinkStore_h

Modified: trunk/Source/WebKit/win/WebHistory.cpp (176577 => 176578)


--- trunk/Source/WebKit/win/WebHistory.cpp	2014-11-29 22:17:07 UTC (rev 176577)
+++ trunk/Source/WebKit/win/WebHistory.cpp	2014-11-29 22:23:36 UTC (rev 176578)
@@ -34,6 +34,7 @@
 #include "WebKit.h"
 #include "WebNotificationCenter.h"
 #include "WebPreferences.h"
+#include "WebVisitedLinkStore.h"
 #include <WebCore/BString.h>
 #include <WebCore/HistoryItem.h>
 #include <WebCore/URL.h>
@@ -578,6 +579,12 @@
     return m_entriesByURL.get(urlString);
 }
 
+WebHistory::addVisitedLinksToVisitedLinkStore(WebVisitedLinkStore& visitedLinkStore)
+{
+    for (auto& url : m_entriesByURL.keys())
+        group.addVisitedLinkHash(visitedLinkHash(url)); 
+}
+
 void WebHistory::addVisitedLinksToPageGroup(PageGroup& group)
 {
     for (auto& url : m_entriesByURL.keys())

Modified: trunk/Source/WebKit/win/WebHistory.h (176577 => 176578)


--- trunk/Source/WebKit/win/WebHistory.h	2014-11-29 22:17:07 UTC (rev 176577)
+++ trunk/Source/WebKit/win/WebHistory.h	2014-11-29 22:23:36 UTC (rev 176578)
@@ -39,6 +39,7 @@
 //-----------------------------------------------------------------------------
 
 class WebPreferences;
+class WebVisitedLinkStore;
 
 class WebHistory : public IWebHistory, public IWebHistoryPrivate {
 public:
@@ -111,6 +112,7 @@
     static WebHistory* sharedHistory();
     void visitedURL(const WebCore::URL&, const WTF::String& title, const WTF::String& httpMethod, bool wasFailure, bool increaseVisitCount);
     void addVisitedLinksToPageGroup(WebCore::PageGroup&);
+    void addVisitedLinksToVisitedLinkStore(WebVisitedLinkStore&);
 
     COMPtr<IWebHistoryItem> itemForURLString(const WTF::String&) const;
 

Modified: trunk/Source/WebKit/win/WebView.cpp (176577 => 176578)


--- trunk/Source/WebKit/win/WebView.cpp	2014-11-29 22:17:07 UTC (rev 176577)
+++ trunk/Source/WebKit/win/WebView.cpp	2014-11-29 22:23:36 UTC (rev 176578)
@@ -65,6 +65,7 @@
 #include "WebPlatformStrategies.h"
 #include "WebPreferences.h"
 #include "WebScriptWorld.h"
+#include "WebVisitedLinkStore.h"
 #include "resource.h"
 #include <_javascript_Core/APICast.h>
 #include <_javascript_Core/InitializeThreading.h>
@@ -6432,12 +6433,15 @@
 
 HRESULT WebView::addVisitedLinks(BSTR* visitedURLs, unsigned visitedURLCount)
 {
+    auto& visitedLinkStore = WebVisitedLinkStore::shared();
     PageGroup& group = core(this)->group();
     
     for (unsigned i = 0; i < visitedURLCount; ++i) {
         BSTR url = ""
         unsigned length = SysStringLen(url);
         group.addVisitedLink(url, length);
+
+        visitedLinkStore.addVisitedLink(String(url, length));
     }
 
     return S_OK;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to