Commit bf34b594 authored by msaboff@apple.com's avatar msaboff@apple.com

Add String version of visitedLinkHash() to properly handle 8-bit URL Strings.

https://bugs.webkit.org/show_bug.cgi?id=99735

Reviewed by Filip Pizlo.

Added String version of visitedLinkHash().  Made speculative addition of visitedLinkHash()
to chromium platform version of LinkHashChromium.cpp.
Changed calls in the form of visitedLinkHash(string.characters(), string.length()) to use the
new form.

No changes to functionality, so no new tests.

* WebCore.exp.in:
* loader/HistoryController.cpp:
(WebCore::addVisitedLink):
* page/PageGroup.cpp:
(WebCore::PageGroup::addVisitedLink):
* platform/LinkHash.cpp:
(WebCore::visitedLinkHashInline):
(WebCore::visitedLinkHash):
* platform/LinkHash.h:
* platform/chromium/LinkHashChromium.cpp:
(WebCore::visitedLinkHash):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b5fdcb6a
2012-10-19 Michael Saboff <msaboff@apple.com>
Add String version of visitedLinkHash() to properly handle 8-bit URL Strings.
https://bugs.webkit.org/show_bug.cgi?id=99735
Reviewed by Filip Pizlo.
Added String version of visitedLinkHash(). Made speculative addition of visitedLinkHash()
to chromium platform version of LinkHashChromium.cpp.
Changed calls in the form of visitedLinkHash(string.characters(), string.length()) to use the
new form.
No changes to functionality, so no new tests.
* WebCore.exp.in:
* loader/HistoryController.cpp:
(WebCore::addVisitedLink):
* page/PageGroup.cpp:
(WebCore::PageGroup::addVisitedLink):
* platform/LinkHash.cpp:
(WebCore::visitedLinkHashInline):
(WebCore::visitedLinkHash):
* platform/LinkHash.h:
* platform/chromium/LinkHashChromium.cpp:
(WebCore::visitedLinkHash):
2012-10-19 Michael Saboff <msaboff@apple.com>
String(CFStringRef) should try to converting to an 8 bit string before converting to 16 bit string
......
......@@ -400,6 +400,7 @@ __ZN7WebCore15reportExceptionEPN3JSC9ExecStateENS0_7JSValueE
__ZN7WebCore15setDOMExceptionEPN3JSC9ExecStateEi
__ZN7WebCore15toDOMStringListEPN3JSC9ExecStateENS0_7JSValueE
__ZN7WebCore15visitedLinkHashEPKtj
__ZN7WebCore15visitedLinkHashERKN3WTF6StringE
__ZN7WebCore16AbstractDatabase14setIsAvailableEb
__ZN7WebCore16ApplicationCache18diskUsageForOriginEPNS_14SecurityOriginE
__ZN7WebCore16ApplicationCache20deleteCacheForOriginEPNS_14SecurityOriginE
......
......@@ -60,7 +60,7 @@ namespace WebCore {
static inline void addVisitedLink(Page* page, const KURL& url)
{
#if USE(PLATFORM_STRATEGIES)
platformStrategies()->visitedLinkStrategy()->addVisitedLink(page, visitedLinkHash(url.string().characters(), url.string().length()));
platformStrategies()->visitedLinkStrategy()->addVisitedLink(page, visitedLinkHash(url.string()));
#else
page->group().addVisitedLink(url);
#endif
......
......@@ -210,7 +210,7 @@ void PageGroup::addVisitedLink(const KURL& url)
if (!shouldTrackVisitedLinks)
return;
ASSERT(!url.isEmpty());
addVisitedLink(visitedLinkHash(url.string().characters(), url.string().length()));
addVisitedLink(visitedLinkHash(url.string()));
}
void PageGroup::addVisitedLink(const UChar* characters, size_t length)
......
......@@ -194,11 +194,21 @@ static inline bool needsTrailingSlash(const UChar* characters, unsigned length)
return pos == length;
}
static ALWAYS_INLINE LinkHash visitedLinkHashInline(const UChar* url, unsigned length)
template <typename CharacterType>
static ALWAYS_INLINE LinkHash visitedLinkHashInline(const CharacterType* url, unsigned length)
{
return AlreadyHashed::avoidDeletedValue(StringHasher::computeHash(url, length));
}
LinkHash visitedLinkHash(const String& url)
{
unsigned length = url.length();
if (length && url.is8Bit())
return visitedLinkHashInline(url.characters8(), length);
return visitedLinkHashInline(url.characters(), length);
}
LinkHash visitedLinkHash(const UChar* url, unsigned length)
{
return visitedLinkHashInline(url, length);
......
......@@ -53,7 +53,8 @@ struct LinkHashHash {
}
};
// Returns the has of the string that will be used for visited link coloring.
// Returns the hash of the string that will be used for visited link coloring.
LinkHash visitedLinkHash(const String& url);
LinkHash visitedLinkHash(const UChar* url, unsigned length);
// Resolves the potentially relative URL "attributeURL" relative to the given
......
......@@ -51,6 +51,11 @@ LinkHash visitedLinkHash(const UChar* url, unsigned length)
return WebKit::Platform::current()->visitedLinkHash(buffer.data(), buffer.length());
}
LinkHash visitedLinkHash(const String& url)
{
return (url.characters(), url.length());
}
LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL)
{
// Resolve the relative URL using googleurl and pass the absolute URL up to
......
......@@ -749,7 +749,7 @@ void WebContext::addVisitedLink(const String& visitedURL)
if (visitedURL.isEmpty())
return;
LinkHash linkHash = visitedLinkHash(visitedURL.characters(), visitedURL.length());
LinkHash linkHash = visitedLinkHash(visitedURL);
addVisitedLinkHash(linkHash);
}
......
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