Add String version of visitedLinkHash() to properly handle 8-bit URL Strings.
authormsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2012 23:21:40 +0000 (23:21 +0000)
committermsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2012 23:21:40 +0000 (23:21 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@131955 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/loader/HistoryController.cpp
Source/WebCore/page/PageGroup.cpp
Source/WebCore/platform/LinkHash.cpp
Source/WebCore/platform/LinkHash.h
Source/WebCore/platform/chromium/LinkHashChromium.cpp
Source/WebKit2/UIProcess/WebContext.cpp

index 5d4a84d..1efc5cc 100644 (file)
@@ -1,5 +1,31 @@
 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
         https://bugs.webkit.org/show_bug.cgi?id=99794
 
index bf3a96b..2b97d45 100644 (file)
@@ -400,6 +400,7 @@ __ZN7WebCore15reportExceptionEPN3JSC9ExecStateENS0_7JSValueE
 __ZN7WebCore15setDOMExceptionEPN3JSC9ExecStateEi
 __ZN7WebCore15toDOMStringListEPN3JSC9ExecStateENS0_7JSValueE
 __ZN7WebCore15visitedLinkHashEPKtj
+__ZN7WebCore15visitedLinkHashERKN3WTF6StringE
 __ZN7WebCore16AbstractDatabase14setIsAvailableEb
 __ZN7WebCore16ApplicationCache18diskUsageForOriginEPNS_14SecurityOriginE
 __ZN7WebCore16ApplicationCache20deleteCacheForOriginEPNS_14SecurityOriginE
index 8551a52..fb6d0e3 100644 (file)
@@ -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
index 314ed14..77928ce 100644 (file)
@@ -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)
index 3615e0e..a0ea795 100644 (file)
@@ -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);
index dc494d2..78eaa3a 100644 (file)
@@ -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
index b051bf4..3dc07ab 100644 (file)
@@ -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
index 1cbe345..51e179b 100644 (file)
@@ -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);
 }