Commit 6af05ad4 authored by brettw@chromium.org's avatar brettw@chromium.org

Reviewed by Darin Adler.

Make the page group use the proper link hashing functions rather than
calling the string hash functions directly. Add Chromium-specfic ifdefs
in the visited link computation functions to allow integration.

* page/PageGroup.cpp:
(WebCore::PageGroup::isLinkVisited):
(WebCore::PageGroup::addVisitedLink):
* platform/LinkHash.cpp:
(WebCore::visitedLinkHash):
* platform/LinkHash.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@39060 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e625a40e
2008-12-04 Brett Wilson <brettw@chromium.org>
Reviewed by Darin Adler.
Make the page group use the proper link hashing functions rather than
calling the string hash functions directly. Add Chromium-specfic ifdefs
in the visited link computation functions to allow integration.
* page/PageGroup.cpp:
(WebCore::PageGroup::isLinkVisited):
(WebCore::PageGroup::addVisitedLink):
* platform/LinkHash.cpp:
(WebCore::visitedLinkHash):
* platform/LinkHash.h:
2008-12-05 Chris Marrin <cmarrin@apple.com>
Reviewed by Dave Hyatt.
......@@ -36,6 +36,10 @@
#include "StorageArea.h"
#endif
#if PLATFORM(CHROMIUM)
#include "ChromiumBridge.h"
#endif
namespace WebCore {
static unsigned getUniqueIdentifier()
......@@ -119,21 +123,27 @@ void PageGroup::removePage(Page* page)
bool PageGroup::isLinkVisited(LinkHash visitedLinkHash)
{
#if PLATFORM(CHROMIUM)
// Use Chromium's built-in visited link database.
return ChromiumBridge::isLinkVisited(visitedLinkHash);
#else
if (!m_visitedLinksPopulated) {
m_visitedLinksPopulated = true;
ASSERT(!m_pages.isEmpty());
(*m_pages.begin())->chrome()->client()->populateVisitedLinks();
}
return m_visitedLinkHashes.contains(visitedLinkHash);
#endif
}
inline void PageGroup::addVisitedLink(LinkHash stringHash)
inline void PageGroup::addVisitedLink(LinkHash hash)
{
ASSERT(shouldTrackVisitedLinks);
LinkHash visitedLinkHash = LinkHashHash::avoidDeletedValue(stringHash);
if (!m_visitedLinkHashes.add(visitedLinkHash).second)
#if !PLATFORM(CHROMIUM)
if (!m_visitedLinkHashes.add(hash).second)
return;
Page::visitedStateChanged(this, visitedLinkHash);
#endif
Page::visitedStateChanged(this, hash);
}
void PageGroup::addVisitedLink(const KURL& url)
......@@ -141,14 +151,14 @@ void PageGroup::addVisitedLink(const KURL& url)
if (!shouldTrackVisitedLinks)
return;
ASSERT(!url.isEmpty());
addVisitedLink(url.string().impl()->hash());
addVisitedLink(visitedLinkHash(url.string().characters(), url.string().length()));
}
void PageGroup::addVisitedLink(const UChar* characters, size_t length)
{
if (!shouldTrackVisitedLinks)
return;
addVisitedLink(StringImpl::computeHash(characters, length));
addVisitedLink(visitedLinkHash(characters, length));
}
void PageGroup::removeVisitedLinks()
......
......@@ -27,6 +27,7 @@
#include "LinkHash.h"
#include "PlatformString.h"
#include "StringHash.h"
#include "StringImpl.h"
namespace WebCore {
......@@ -146,6 +147,11 @@ static inline bool needsTrailingSlash(const UChar* characters, unsigned length)
return pos == length;
}
LinkHash visitedLinkHash(const UChar* url, unsigned length)
{
return AlreadyHashed::avoidDeletedValue(StringImpl::computeHash(url, length));
}
LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL)
{
const UChar* characters = attributeURL.characters();
......@@ -167,7 +173,7 @@ LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL)
bool hasColonSlashSlash = containsColonSlashSlash(characters, length);
if (hasColonSlashSlash && !needsTrailingSlash(characters, length))
return AlreadyHashed::avoidDeletedValue(attributeURL.string().impl()->hash());
return visitedLinkHash(attributeURL.characters(), attributeURL.length());
Vector<UChar, 512> buffer;
......@@ -176,7 +182,7 @@ LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL)
// end of the path, *before* the query or anchor.
buffer.append(characters, length);
buffer.append('/');
return AlreadyHashed::avoidDeletedValue(StringImpl::computeHash(buffer.data(), buffer.size()));
return visitedLinkHash(buffer.data(), buffer.size());
}
switch (characters[0]) {
......@@ -198,7 +204,7 @@ LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL)
buffer.append('/');
}
return AlreadyHashed::avoidDeletedValue(StringImpl::computeHash(buffer.data(), buffer.size()));
return visitedLinkHash(buffer.data(), buffer.size());
}
} // namespace WebCore
......@@ -53,6 +53,9 @@ struct LinkHashHash {
}
};
// Returns the has of the string that will be used for visited link coloring.
LinkHash visitedLinkHash(const UChar* url, unsigned length);
// Resolves the potentially relative URL "attributeURL" relative to the given
// base URL, and returns the hash of the string that will be used for visited
// link coloring. It will return the special value of 0 if attributeURL does not
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment