2011-02-05 Adam Barth <abarth@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 20:21:58 +0000 (20:21 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 20:21:58 +0000 (20:21 +0000)
        Reviewed by Eric Seidel.

        Introduce URLString to represent a canonicalized URL represented by a string
        https://bugs.webkit.org/show_bug.cgi?id=53847

        Instead of using String all over the codebase to represent a URL,
        instead we should have a type to represent a canonicalized URL in the
        form of a string.  This patch introduces that type.

        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.xcodeproj/project.pbxproj:
        * platform/KURL.cpp:
        (WebCore::KURL::KURL):
        * platform/KURL.h:
        (WebCore::KURL::urlString):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77748 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/KURL.cpp
Source/WebCore/platform/KURL.h
Source/WebCore/platform/URLString.h [new file with mode: 0644]

index eac42da473a3f60910ef20c0606170ad13cd2bce..cfeb9c4e03eb9642c45e2d6dbbd73bb27b621847 100644 (file)
@@ -1,3 +1,22 @@
+2011-02-05  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Introduce URLString to represent a canonicalized URL represented by a string
+        https://bugs.webkit.org/show_bug.cgi?id=53847
+
+        Instead of using String all over the codebase to represent a URL,
+        instead we should have a type to represent a canonicalized URL in the
+        form of a string.  This patch introduces that type.
+
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/KURL.cpp:
+        (WebCore::KURL::KURL):
+        * platform/KURL.h:
+        (WebCore::KURL::urlString):
+
 2011-02-05  Robert Hogan  <robert@webkit.org>
 
         Reviewed by Antonio Gomes.
index a0c59db69960ae3d9f70819f7d62de70373af4ac..75a50cd60c89e111d5cf82dc23196c02e85c66f9 100644 (file)
@@ -2669,6 +2669,7 @@ webcore_sources += \
        Source/WebCore/platform/Timer.cpp \
        Source/WebCore/platform/Timer.h \
        Source/WebCore/platform/TreeShared.h \
+       Source/WebCore/platform/URLString.h \
        Source/WebCore/platform/UUID.cpp \
        Source/WebCore/platform/UUID.h \
        Source/WebCore/platform/Widget.cpp \
index 65cb8f7b8815d4e54e5061a99f5b6e6efb17e322..376a7e97eaf6cea330a404d568b20227875af191 100644 (file)
             'platform/Timer.cpp',
             'platform/Timer.h',
             'platform/TreeShared.h',
+            'platform/URLString.h',
             'platform/UUID.cpp',
             'platform/UUID.h',
             'platform/Widget.cpp',
index c4528a92aa7126ff1eff6752992a1f4ac16776bc..8a8d97f8dd0cd5b0c056c7149c47fbaf7e3ba4b8 100644 (file)
                97059978107D975200A50A7C /* PolicyCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059974107D975200A50A7C /* PolicyCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97059979107D975200A50A7C /* PolicyChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059975107D975200A50A7C /* PolicyChecker.cpp */; };
                9705997A107D975200A50A7C /* PolicyChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059976107D975200A50A7C /* PolicyChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               971491DA12FD65E8001BFEB1 /* URLString.h in Headers */ = {isa = PBXBuildFile; fileRef = 971491D912FD65E8001BFEB1 /* URLString.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97205AAF123928CA00B17380 /* FTPDirectoryDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97205AAD123928CA00B17380 /* FTPDirectoryDocument.cpp */; };
                97205AB0123928CA00B17380 /* FTPDirectoryDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 97205AAE123928CA00B17380 /* FTPDirectoryDocument.h */; };
                97205AB51239291000B17380 /* ImageDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97205AB11239291000B17380 /* ImageDocument.cpp */; };
                97059974107D975200A50A7C /* PolicyCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyCallback.h; sourceTree = "<group>"; };
                97059975107D975200A50A7C /* PolicyChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyChecker.cpp; sourceTree = "<group>"; };
                97059976107D975200A50A7C /* PolicyChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyChecker.h; sourceTree = "<group>"; };
+               971491D912FD65E8001BFEB1 /* URLString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLString.h; sourceTree = "<group>"; };
                97205AAD123928CA00B17380 /* FTPDirectoryDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FTPDirectoryDocument.cpp; sourceTree = "<group>"; };
                97205AAE123928CA00B17380 /* FTPDirectoryDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FTPDirectoryDocument.h; sourceTree = "<group>"; };
                97205AB11239291000B17380 /* ImageDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDocument.cpp; sourceTree = "<group>"; };
                                93309EA1099EB78C0056E581 /* Timer.cpp */,
                                9305B24C098F1B6B00C28855 /* Timer.h */,
                                1419D2C40CEA6F6100FF507A /* TreeShared.h */,
+                               971491D912FD65E8001BFEB1 /* URLString.h */,
                                2E3BBF051162DA1100B9409A /* UUID.cpp */,
                                2E3BBF061162DA1100B9409A /* UUID.h */,
                                515788C01207852C00A37C4A /* VisitedLinkStrategy.h */,
                                14947FFE12F80CD200A0F631 /* DocumentOrderedMap.h in Headers */,
                                97C471DC12F925BD0086354B /* ContentSecurityPolicy.h in Headers */,
                                A7FE819C12FA677700850C1E /* ProgressBarValueElement.h in Headers */,
+                               971491DA12FD65E8001BFEB1 /* URLString.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 3ed666894a6a531d76a3c4f24c525bac294da844..200d538b2d50cabb1decea80ae75b75f4e3ff758 100644 (file)
@@ -322,6 +322,12 @@ KURL::KURL(ParsedURLStringTag, const String& url)
     ASSERT(url == m_string);
 }
 
+KURL::KURL(ParsedURLStringTag, const URLString& url)
+{
+    parse(url.string());
+    ASSERT(url.string() == m_string);
+}
+
 KURL::KURL(const KURL& base, const String& relative)
 {
     init(base, relative, UTF8Encoding());
index cbf0d8b83247af7269221d5f45d71b89e50222f2..521e7ca3b895ba1c4a048109894fecbfa4121670 100644 (file)
@@ -27,6 +27,7 @@
 #define KURL_h
 
 #include "PlatformString.h"
+#include "URLString.h"
 #include <wtf/HashMap.h>
 
 #if PLATFORM(CF)
@@ -74,6 +75,7 @@ public:
     // It is usually best to avoid repeatedly parsing a string, unless memory saving outweigh the possible slow-downs.
     KURL(ParsedURLStringTag, const char*);
     KURL(ParsedURLStringTag, const String&);
+    KURL(ParsedURLStringTag, const URLString&);
 
     // Resolves the relative URL with the given base URL. If provided, the
     // TextEncoding is used to encode non-ASCII characers. The base URL can be
@@ -117,11 +119,13 @@ public:
     bool canSetHostOrPort() const { return isHierarchical(); }
 
     bool canSetPathname() const { return isHierarchical(); }
-    
+
 #if USE(GOOGLEURL)
     const String& string() const { return m_url.string(); }
+    URLString urlString() const { return URLString(m_url.string()); }
 #else
     const String& string() const { return m_string; }
+    URLString urlString() const { return URLString(m_string); }
 #endif
 
     String protocol() const;
diff --git a/Source/WebCore/platform/URLString.h b/Source/WebCore/platform/URLString.h
new file mode 100644 (file)
index 0000000..78e4b33
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 Google, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef URLString_h
+#define URLString_h
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class KURL;
+
+class URLString {
+public:
+    const String& string() const { return m_string; }
+
+private:
+    friend class KURL;
+
+    explicit URLString(const String& string)
+        : m_string(string)
+    {
+    }
+    
+    String m_string;
+};
+
+}
+
+#endif