Title: [131656] trunk/Source
Revision
131656
Author
[email protected]
Date
2012-10-17 15:17:49 -0700 (Wed, 17 Oct 2012)

Log Message

Creating a String from an NSString should check for all 8 bit strings
https://bugs.webkit.org/show_bug.cgi?id=99392

Reviewed by Geoffrey Garen.

Source/WebCore:

Use CFStringGetBytes() to try to get Latin1 data to create an 8 bit string.

No functional change, change covered by existing tests.

* platform/text/mac/StringMac.mm:
(WTF::String::String):

Source/WTF:

Exported the LChar* version of create().

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::create):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (131655 => 131656)


--- trunk/Source/WTF/ChangeLog	2012-10-17 22:16:12 UTC (rev 131655)
+++ trunk/Source/WTF/ChangeLog	2012-10-17 22:17:49 UTC (rev 131656)
@@ -1,5 +1,17 @@
 2012-10-17  Michael Saboff  <[email protected]>
 
+        Creating a String from an NSString should check for all 8 bit strings
+        https://bugs.webkit.org/show_bug.cgi?id=99392
+
+        Reviewed by Geoffrey Garen.
+
+        Exported the LChar* version of create().
+
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringImpl::create):
+
+2012-10-17  Michael Saboff  <[email protected]>
+
         StringImpl::findIgnoringCase() and reverseFindIgnoringCase() don't optimally handle a mix of 8 and 16 bit strings
         https://bugs.webkit.org/show_bug.cgi?id=99224
 

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (131655 => 131656)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2012-10-17 22:16:12 UTC (rev 131655)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2012-10-17 22:17:49 UTC (rev 131656)
@@ -351,7 +351,7 @@
     WTF_EXPORT_STRING_API ~StringImpl();
 
     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> create(const UChar*, unsigned length);
-    static PassRefPtr<StringImpl> create(const LChar*, unsigned length);
+    WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> create(const LChar*, unsigned length);
     ALWAYS_INLINE static PassRefPtr<StringImpl> create(const char* s, unsigned length) { return create(reinterpret_cast<const LChar*>(s), length); }
     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> create(const LChar*);
     ALWAYS_INLINE static PassRefPtr<StringImpl> create(const char* s) { return create(reinterpret_cast<const LChar*>(s)); }

Modified: trunk/Source/WebCore/ChangeLog (131655 => 131656)


--- trunk/Source/WebCore/ChangeLog	2012-10-17 22:16:12 UTC (rev 131655)
+++ trunk/Source/WebCore/ChangeLog	2012-10-17 22:17:49 UTC (rev 131656)
@@ -1,3 +1,17 @@
+2012-10-17  Michael Saboff  <[email protected]>
+
+        Creating a String from an NSString should check for all 8 bit strings
+        https://bugs.webkit.org/show_bug.cgi?id=99392
+
+        Reviewed by Geoffrey Garen.
+
+        Use CFStringGetBytes() to try to get Latin1 data to create an 8 bit string.
+
+        No functional change, change covered by existing tests.
+
+        * platform/text/mac/StringMac.mm:
+        (WTF::String::String):
+
 2012-10-17  Raphael Kubo da Costa  <[email protected]>
 
         [EFL] Remove redundant OpenGL library addition from the build system.

Modified: trunk/Source/WebCore/platform/text/mac/StringMac.mm (131655 => 131656)


--- trunk/Source/WebCore/platform/text/mac/StringMac.mm	2012-10-17 22:16:12 UTC (rev 131655)
+++ trunk/Source/WebCore/platform/text/mac/StringMac.mm	2012-10-17 22:17:49 UTC (rev 131656)
@@ -34,9 +34,17 @@
     if (size == 0)
         m_impl = StringImpl::empty();
     else {
-        Vector<UChar, 1024> buffer(size);
-        CFStringGetCharacters(reinterpret_cast<CFStringRef>(str), CFRangeMake(0, size), buffer.data());
-        m_impl = StringImpl::create(buffer.data(), size);
+        Vector<LChar, 1024> lcharBuffer(size);
+        CFIndex usedBufLen;
+        CFIndex convertedsize = CFStringGetBytes(reinterpret_cast<CFStringRef>(str), CFRangeMake(0, size), kCFStringEncodingISOLatin1, 0, false, lcharBuffer.data(), size, &usedBufLen);
+        if ((convertedsize == size) && (usedBufLen == size)) {
+            m_impl = StringImpl::create(lcharBuffer.data(), size);
+            return;
+        }
+
+        Vector<UChar, 1024> ucharBuffer(size);
+        CFStringGetCharacters(reinterpret_cast<CFStringRef>(str), CFRangeMake(0, size), ucharBuffer.data());
+        m_impl = StringImpl::create(ucharBuffer.data(), size);
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to