2006-08-31 Anders Carlsson <acarlsson@apple.com>
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Aug 2006 22:26:36 +0000 (22:26 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Aug 2006 22:26:36 +0000 (22:26 +0000)
        Reviewed by Tim H, Hyatt.

        * WebCore.xcodeproj/project.pbxproj:
        Add KURLCFNet.cpp

        * platform/KURL.h:
        Get rid of include, add KURL constructor that takes a CFURLRef.

        * platform/PlatformString.h:
        * platform/StringImpl.h:
        Get rid of include.

        * platform/cf/KURLCFNet.cpp:
        (WebCore::KURL::KURL):
        Add constructor.

        * platform/cf/ResourceLoaderCFNet.cpp:
        Fix includes.

        * platform/cf/StringCF.cpp:
        (WebCore::String::createCFString):
        Move this here from PlatformString.h

        * platform/cf/StringImplCF.cpp:
        (WebCore::StringImpl::createCFString):
        Fix cast.

        * platform/mac/KURLMac.mm:
        Move createCFURL() to KURLCFNet.cpp

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

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/platform/KURL.h
WebCore/platform/PlatformString.h
WebCore/platform/StringImpl.h
WebCore/platform/cf/KURLCFNet.cpp
WebCore/platform/cf/ResourceLoaderCFNet.cpp
WebCore/platform/cf/StringCF.cpp
WebCore/platform/cf/StringImplCF.cpp
WebCore/platform/mac/KURLMac.mm

index 1591130cf97b9bb1f2055a8941d000a99e0f8bb8..faccce86f9ff2a262c2d3ad4a2759451cc4cc79a 100644 (file)
@@ -1,3 +1,35 @@
+2006-08-31  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Tim H, Hyatt.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Add KURLCFNet.cpp
+        
+        * platform/KURL.h:
+        Get rid of include, add KURL constructor that takes a CFURLRef.
+        
+        * platform/PlatformString.h:
+        * platform/StringImpl.h:
+        Get rid of include.
+        
+        * platform/cf/KURLCFNet.cpp:
+        (WebCore::KURL::KURL):
+        Add constructor.
+        
+        * platform/cf/ResourceLoaderCFNet.cpp:
+        Fix includes.
+        
+        * platform/cf/StringCF.cpp:
+        (WebCore::String::createCFString):
+        Move this here from PlatformString.h
+        
+        * platform/cf/StringImplCF.cpp:
+        (WebCore::StringImpl::createCFString):
+        Fix cast.
+        
+        * platform/mac/KURLMac.mm:
+        Move createCFURL() to KURLCFNet.cpp
+
 2006-08-31 Dave Hyatt <hyatt@apple.com>
 
         Make ScrollBar.cpp suitable for compiling on Windows by removing the #import.
index 6f3f4a6c16a8170f303cba127b7ba6071c9bd4db..e0b8a729653e575daaecd61021ab2508631b42a0 100644 (file)
@@ -94,6 +94,7 @@
                1A85B2B70A1B2AC700D8C87C /* JSHTMLDivElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A85B2B50A1B2AC700D8C87C /* JSHTMLDivElement.h */; };
                1A98955C0AA78149005EF5EF /* CString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A98955A0AA78149005EF5EF /* CString.cpp */; };
                1A98955D0AA78149005EF5EF /* CString.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A98955B0AA78149005EF5EF /* CString.h */; };
+               1A98956B0AA78F80005EF5EF /* KURLCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A98956A0AA78F80005EF5EF /* KURLCFNet.cpp */; };
                1A9EF4570A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9EF4560A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp */; };
                1AB7FC680A8B92EC00D9D37B /* XPathEvaluator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AB7FC470A8B92EC00D9D37B /* XPathEvaluator.cpp */; };
                1AB7FC690A8B92EC00D9D37B /* XPathEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB7FC480A8B92EC00D9D37B /* XPathEvaluator.h */; };
                1A85B2B50A1B2AC700D8C87C /* JSHTMLDivElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLDivElement.h; sourceTree = "<group>"; };
                1A98955A0AA78149005EF5EF /* CString.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CString.cpp; sourceTree = "<group>"; };
                1A98955B0AA78149005EF5EF /* CString.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CString.h; sourceTree = "<group>"; };
+               1A98956A0AA78F80005EF5EF /* KURLCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = KURLCFNet.cpp; sourceTree = "<group>"; };
                1A9EF4560A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCanvasRenderingContext2DCustom.cpp; sourceTree = "<group>"; };
                1AB7FC470A8B92EC00D9D37B /* XPathEvaluator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = XPathEvaluator.cpp; sourceTree = "<group>"; };
                1AB7FC480A8B92EC00D9D37B /* XPathEvaluator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = XPathEvaluator.h; sourceTree = "<group>"; };
                1AE42F670AA4B8CB00C8612D /* cf */ = {
                        isa = PBXGroup;
                        children = (
+                               1A98956A0AA78F80005EF5EF /* KURLCFNet.cpp */,
                                1AE42F680AA4B8CB00C8612D /* StringCF.cpp */,
                                1AE42F690AA4B8CB00C8612D /* StringImplCF.cpp */,
                        );
                                85183B490AA6926100F19FA3 /* DOMHTMLPreElement.mm in Sources */,
                                85183B4B0AA6926100F19FA3 /* DOMHTMLQuoteElement.mm in Sources */,
                                1A98955C0AA78149005EF5EF /* CString.cpp in Sources */,
+                               1A98956B0AA78F80005EF5EF /* KURLCFNet.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index a65b1df5fb14650917b7f02182c7f04da99c5884..f664970505fa8e94942a3a3d9cc8245b7bab2cf8 100644 (file)
@@ -29,8 +29,8 @@
 #include <wtf/Platform.h>
 #include "TextEncoding.h"
 
-#if USE(CFNETWORK)
-#include <CoreFoundation/CFURL.h>
+#if PLATFORM(CF)
+typedef const struct __CFURL * CFURLRef;
 #endif
 
 #if PLATFORM(MAC)
@@ -60,7 +60,9 @@ public:
 #if PLATFORM(MAC)
     KURL(NSURL*);
 #endif
-    
+#if PLATFORM(CF)
+    KURL(CFURLRef);
+#endif
     bool isEmpty() const { return urlString.isEmpty(); } 
     bool isMalformed() const { return !m_isValid; }
     bool isValid() const { return m_isValid; }
index 408f7de95eb57729d43ecac78ec28197319625d1..78e023c62c788dbef7b4a0f6391380633636f44d 100644 (file)
@@ -30,7 +30,7 @@
 #include "StringImpl.h"
 
 #if PLATFORM(CF)
-#include <CoreFoundation/CoreFoundation.h>
+typedef const struct __CFString * CFStringRef;
 #endif
 
 #if PLATFORM(QT)
@@ -138,7 +138,7 @@ public:
 
 #if PLATFORM(CF)
     String(CFStringRef);
-    CFStringRef createCFString() const { return m_impl ? m_impl->createCFString() : CFSTR(""); }
+    CFStringRef createCFString() const;
 #endif
 
 #ifdef __OBJC__
index 4ba382799d2ac5374f69571d66fbbdc592ba29dc..1d949bd0b112eebed1d641b85e09d050193361f2 100644 (file)
@@ -33,7 +33,7 @@
 #include <limits.h>
 
 #if PLATFORM(CF)
-#include <CoreFoundation/CoreFoundation.h>
+typedef const struct __CFString * CFStringRef;
 #endif
 
 #ifdef __OBJC__
index f6612be34c8b42fa360e5b31eb303f75000714ba..0ac275ab3c0866f7788ec4b3b7c10505fd860d0c 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
+#include "config.h"
 #include "KURL.h"
+
+#include <wtf/Vector.h>
+#include <CoreFoundation/CFURL.h>
+
 using namespace std;
 
 namespace WebCore {
 
-#if PLATFORM(CF)
+KURL::KURL(CFURLRef url)
+{
+    if (url) {
+        CFIndex bytesLength = CFURLGetBytes(url, 0, 0);
+        Vector<char, 2048> buffer(bytesLength + 6); // 6 for "file:", 1 for NUL terminator
+        char* bytes = &buffer[5];
+        CFURLGetBytes(url, (UInt8*)bytes, bytesLength);
+        bytes[bytesLength] = '\0';
+        if (bytes[0] == '/') {
+            buffer[0] = 'f';
+            buffer[1] = 'i';
+            buffer[2] = 'l';
+            buffer[3] = 'e';
+            buffer[4] = ':';
+            parse(buffer, 0);
+        } else
+            parse(bytes, 0);
+    } else
+        parse("", 0);
+}
+
 CFURLRef KURL::createCFURL() const
 {
     const UInt8 *bytes = (const UInt8 *)urlString.latin1();
@@ -41,6 +66,5 @@ CFURLRef KURL::createCFURL() const
         result = CFURLCreateAbsoluteURLWithBytes(0, bytes, urlString.length(), kCFStringEncodingISOLatin1, 0, true);
     return result;
 }
-#endif
 
 }
index d90775d764221cc94b42bfe3d4aaa86d634020d9..02795967db75328a0779a5d44ffa1a6705575853 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#include <wtf/platform.h>
+#include "config.h"
+
 #if USE(CFNETWORK)
 
-#include "config.h"
 #include "ResourceLoader.h"
 #include "ResourceLoaderInternal.h"
 #include "DocLoader.h"
index e87d79c18ac8a38c82518f0efa245cbfdd6845c4..57b3fcde8fa86749c030dec0b667f32ba4cbe942 100644 (file)
@@ -21,6 +21,8 @@
 #include "config.h"
 #include "PlatformString.h"
 
+#include <CoreFoundation/CoreFoundation.h>
+
 namespace WebCore {
 
 String::String(CFStringRef str)
@@ -33,9 +35,17 @@ String::String(CFStringRef str)
         m_impl = StringImpl::empty();
     else {
         Vector<UChar, 1024> buffer(size);
-        CFStringGetCharacters(str, CFRangeMake(0, size), buffer.data());
+        CFStringGetCharacters(str, CFRangeMake(0, size), (UniChar*)buffer.data());
         m_impl = new StringImpl(buffer.data(), size);
     }
 }
 
+CFStringRef String::createCFString() const
+{
+    if (!m_impl)
+        return CFSTR("");
+
+    return m_impl->createCFString();
+}
+
 }
index d46eb36b720f60e8a4a550b8919cd7f0dae4ab35..849c50f84a519473acf2a18603cf0eaa63dc52fe 100644 (file)
 #include "config.h"
 #include "StringImpl.h"
 
+#include <CoreFoundation/CoreFoundation.h>
+
 namespace WebCore {
 
 CFStringRef StringImpl::createCFString() const
 {
-    return CFStringCreateWithCharacters(NULL, m_data, m_length);
+    return CFStringCreateWithCharacters(NULL, (const UniChar*)m_data, m_length);
 }
 
 }
index d526d4f9b3891168d06272cf958660cb2c6e736e..744d807177a03615d9638ef31d4b552b0ab64dd3 100644 (file)
@@ -53,21 +53,6 @@ KURL::KURL(NSURL *url)
         parse("", 0);
 }
 
-#if PLATFORM(CF)
-CFURLRef KURL::createCFURL() const
-{
-    const UInt8 *bytes = (const UInt8 *)urlString.latin1();
-    // NOTE: We use UTF-8 here since this encoding is used when computing strings when returning URL components
-    // (e.g calls to NSURL -path). However, this function is not tolerant of illegal UTF-8 sequences, which
-    // could either be a malformed string or bytes in a different encoding, like Shift-JIS, so we fall back
-    // onto using ISO Latin-1 in those cases.
-    CFURLRef result = CFURLCreateAbsoluteURLWithBytes(0, bytes, urlString.length(), kCFStringEncodingUTF8, 0, true);
-    if (!result)
-        result = CFURLCreateAbsoluteURLWithBytes(0, bytes, urlString.length(), kCFStringEncodingISOLatin1, 0, true);
-    return result;
-}
-#endif
-
 NSURL *KURL::getNSURL() const
 {
     return HardAutorelease(createCFURL());