[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

weinig at apple.com weinig at apple.com
Wed Dec 22 14:03:08 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a6371c5f8d0de69318af819b34488286d56b1040
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 1 22:00:00 2010 +0000

    Add additional WKString API
    https://bugs.webkit.org/show_bug.cgi?id=46958
    
    Reviewed by Kenneth Rohde Christiansen.
    
    WebKit2:
    
    API Test: WebKit2/WKString
    
    * Shared/API/c/WKString.cpp:
    (WKStringCreateWithUTF8CString):
    (WKStringGetMaximumUTF8CStringSize):
    (WKStringGetUTF8CString):
    (WKStringIsEqual):
    (WKStringIsEqualToUTF8CString):
    * Shared/API/c/WKString.h:
    * Shared/WebString.h:
    (WebKit::WebString::createFromUTF8String):
    (WebKit::WebString::maximumUTF8CStringSize):
    (WebKit::WebString::getUTF8CString):
    (WebKit::WebString::equal):
    (WebKit::WebString::equalToUTF8String):
    
    WebKitTools:
    
    Add basic WKStringRef tests.
    
    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    * TestWebKitAPI/Tests/WebKit2/WKString.cpp: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68930 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 20c5112..73ff052 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,26 @@
+2010-10-01  Sam Weinig  <sam at webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add additional WKString API
+        https://bugs.webkit.org/show_bug.cgi?id=46958
+
+        API Test: WebKit2/WKString
+
+        * Shared/API/c/WKString.cpp:
+        (WKStringCreateWithUTF8CString):
+        (WKStringGetMaximumUTF8CStringSize):
+        (WKStringGetUTF8CString):
+        (WKStringIsEqual):
+        (WKStringIsEqualToUTF8CString):
+        * Shared/API/c/WKString.h:
+        * Shared/WebString.h:
+        (WebKit::WebString::createFromUTF8String):
+        (WebKit::WebString::maximumUTF8CStringSize):
+        (WebKit::WebString::getUTF8CString):
+        (WebKit::WebString::equal):
+        (WebKit::WebString::equalToUTF8String):
+
 2010-10-01  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/WebKit2/Shared/API/c/WKString.cpp b/WebKit2/Shared/API/c/WKString.cpp
index 3ec9c8a..eafed3c 100644
--- a/WebKit2/Shared/API/c/WKString.cpp
+++ b/WebKit2/Shared/API/c/WKString.cpp
@@ -34,17 +34,33 @@ WKTypeID WKStringGetTypeID()
     return toRef(WebString::APIType);
 }
 
+WKStringRef WKStringCreateWithUTF8CString(const char* string)
+{
+    RefPtr<WebString> webString = WebString::createFromUTF8String(string);
+    return toRef(webString.release().leakRef());
+}
+
 bool WKStringIsEmpty(WKStringRef stringRef)
 {
     return toWK(stringRef)->isEmpty();
 }
 
-bool WKStringIsEqual(WKStringRef firstString, WKStringRef secondString)
+size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef)
+{
+    return toWK(stringRef)->maximumUTF8CStringSize();
+}
+
+size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize)
+{
+    return toWK(stringRef)->getUTF8CString(buffer, bufferSize);
+}
+
+bool WKStringIsEqual(WKStringRef aRef, WKStringRef bRef)
+{
+    return toWK(aRef)->equal(toWK(bRef));
+}
+
+bool WKStringIsEqualToUTF8CString(WKStringRef aRef, const char* b)
 {
-    if (firstString == secondString)
-        return true;
-    if (!firstString || !secondString)
-        return false;
-        
-    return toWK(firstString)->string() == toWK(secondString)->string();
+    return toWK(aRef)->equalToUTF8String(b);
 }
diff --git a/WebKit2/Shared/API/c/WKString.h b/WebKit2/Shared/API/c/WKString.h
index 1945045..e79839e 100644
--- a/WebKit2/Shared/API/c/WKString.h
+++ b/WebKit2/Shared/API/c/WKString.h
@@ -38,8 +38,15 @@ extern "C" {
 
 WK_EXPORT WKTypeID WKStringGetTypeID();
 
+WK_EXPORT WKStringRef WKStringCreateWithUTF8CString(const char* string);
+
 WK_EXPORT bool WKStringIsEmpty(WKStringRef string);
-WK_EXPORT bool WKStringIsEqual(WKStringRef firstString, WKStringRef secondString);
+
+WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string);
+WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize);
+
+WK_EXPORT bool WKStringIsEqual(WKStringRef a, WKStringRef b);
+WK_EXPORT bool WKStringIsEqualToUTF8CString(WKStringRef a, const char* b);
 
 #ifdef __cplusplus
 }
diff --git a/WebKit2/Shared/WebString.h b/WebKit2/Shared/WebString.h
index 53a374a..aa36a6d 100644
--- a/WebKit2/Shared/WebString.h
+++ b/WebKit2/Shared/WebString.h
@@ -29,6 +29,7 @@
 #include "APIObject.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/text/WTFString.h>
+#include <wtf/unicode/UTF8.h>
 
 namespace WebKit {
 
@@ -43,9 +44,31 @@ public:
         return adoptRef(new WebString(string));
     }
 
+    static PassRefPtr<WebString> createFromUTF8String(const char* string)
+    {
+        return adoptRef(new WebString(String::fromUTF8(string)));
+    }
+
     bool isNull() const { return m_string.isNull(); }
     bool isEmpty() const { return m_string.isEmpty(); }
 
+    size_t maximumUTF8CStringSize() const { return m_string.length() * 3 + 1; }
+    size_t getUTF8CString(char* buffer, size_t bufferSize)
+    {
+        if (!bufferSize)
+            return 0;
+        char* p = buffer;
+        const UChar* d = m_string.characters();
+        WTF::Unicode::ConversionResult result = WTF::Unicode::convertUTF16ToUTF8(&d, d + m_string.length(), &p, p + bufferSize - 1, /* strict */ true);
+        *p++ = '\0';
+        if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted)
+            return 0;
+        return p - buffer;
+    }
+
+    bool equal(WebString* other) { return m_string == other->m_string; }
+    bool equalToUTF8String(const char* other) { return m_string == String::fromUTF8(other); }
+
     const String& string() const { return m_string; }
 
 private:
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 8327a3b..8f7ae04 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -1963,7 +1963,6 @@
 			isa = PBXProject;
 			buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "WebKit2" */;
 			compatibilityVersion = "Xcode 3.1";
-			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				English,
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 136caa8..d902c8b 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,17 @@
 2010-10-01  Sam Weinig  <sam at webkit.org>
 
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add additional WKString API
+        https://bugs.webkit.org/show_bug.cgi?id=46958
+
+        Add basic WKStringRef tests.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/WKString.cpp: Added.
+
+2010-10-01  Sam Weinig  <sam at webkit.org>
+
         Reviewed by Dan Bernstein.
 
         Add makefile for TestWebKitAPI and call it from the base makefile.
diff --git a/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
index 2c5de14..0a38bf6 100644
--- a/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
+++ b/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
@@ -15,6 +15,7 @@
 		BC90964E1255620C00083756 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC90964D1255620C00083756 /* JavaScriptCore.framework */; };
 		BC90977A125571AB00083756 /* PageLoadBasic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC909779125571AB00083756 /* PageLoadBasic.cpp */; };
 		BC909784125571CF00083756 /* basic-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = BC909778125571AB00083756 /* basic-1.html */; };
+		BC90995E12567BC100083756 /* WKString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC90995D12567BC100083756 /* WKString.cpp */; };
 		BCA61DB511700EFD00460D1E /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCA61DB411700EFD00460D1E /* WebKit2.framework */; };
 		BCB9E9F111235BDE00A137E0 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCB9E9F011235BDE00A137E0 /* Cocoa.framework */; };
 /* End PBXBuildFile section */
@@ -58,6 +59,7 @@
 		BC90964D1255620C00083756 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = ../../WebKitBuild/Debug/JavaScriptCore.framework; sourceTree = SOURCE_ROOT; };
 		BC909778125571AB00083756 /* basic-1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "basic-1.html"; sourceTree = "<group>"; };
 		BC909779125571AB00083756 /* PageLoadBasic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageLoadBasic.cpp; sourceTree = "<group>"; };
+		BC90995D12567BC100083756 /* WKString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKString.cpp; sourceTree = "<group>"; };
 		BCA61DB411700EFD00460D1E /* WebKit2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		BCB9E7C711234E3A00A137E0 /* TestsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestsController.h; sourceTree = "<group>"; };
 		BCB9E7FA112359A300A137E0 /* Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test.h; sourceTree = "<group>"; };
@@ -137,6 +139,7 @@
 			children = (
 				BC90977B125571AE00083756 /* Resources */,
 				BC909779125571AB00083756 /* PageLoadBasic.cpp */,
+				BC90995D12567BC100083756 /* WKString.cpp */,
 			);
 			path = WebKit2;
 			sourceTree = "<group>";
@@ -226,6 +229,7 @@
 				BC90955D125548AA00083756 /* PlatformWebViewMac.mm in Sources */,
 				BC90964C125561BF00083756 /* VectorBasic.cpp in Sources */,
 				BC90977A125571AB00083756 /* PageLoadBasic.cpp in Sources */,
+				BC90995E12567BC100083756 /* WKString.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKString.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKString.cpp
new file mode 100644
index 0000000..2b69989
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/Tests/WebKit2/WKString.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Apple 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 APPLE INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#include "Test.h"
+
+#include <WebKit2/WKString.h>
+
+namespace TestWebKitAPI {
+
+TEST(WKString)
+{
+    WKStringRef string = WKStringCreateWithUTF8CString("hello");
+    TEST_ASSERT(!WKStringIsEmpty(string));
+    TEST_ASSERT(WKStringIsEqual(string, string));
+    TEST_ASSERT(WKStringIsEqualToUTF8CString(string, "hello"));
+    TEST_ASSERT(WKStringGetMaximumUTF8CStringSize(string) == 16);
+
+    size_t maxSize = WKStringGetMaximumUTF8CStringSize(string);
+    char* buffer = (char*)malloc(maxSize);
+    
+    size_t actualSize = WKStringGetUTF8CString(string, buffer, maxSize);
+    TEST_ASSERT(actualSize == 6);
+    TEST_ASSERT(strcmp(buffer, "hello") == 0);
+
+    free(buffer);
+}
+
+} // namespace TestWebKitAPI

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list