Title: [142863] trunk/Source/WTF
Revision
142863
Author
e...@webkit.org
Date
2013-02-14 02:23:17 -0800 (Thu, 14 Feb 2013)

Log Message

REGRESSION(r142712): attribute values show up as "(null)" instead of null with the threaded parser
https://bugs.webkit.org/show_bug.cgi?id=109784

Reviewed by Benjamin Poulain.

When I changed many callsites to use the (existing) String(Vector) constructor
I inadvertantly made those callsites convert empty vectors to null strings
instead of empty strings (like String(UChar,size_t) does).

This is due to an oddity/bug in our Vector implementation where data()
will be 0 if the Vector is empty, but only if it doesn't have inline capacity.
https://bugs.webkit.org/show_bug.cgi?id=109792

This changes String(Vector) to exactly match the behavior of String(vector.data(), vector.size()).

This regression was easily detectable with the threaded parser, because we use String
instead of AtomicString in our CompactToken (used to send the Token data
between threads). The main-thread parser path uses AtomicHTMLToken which
uses AtomicString(Vector) and does not have this bug.

* wtf/text/WTFString.h:
(String):
(WTF::String::String):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (142862 => 142863)


--- trunk/Source/WTF/ChangeLog	2013-02-14 10:22:21 UTC (rev 142862)
+++ trunk/Source/WTF/ChangeLog	2013-02-14 10:23:17 UTC (rev 142863)
@@ -1,3 +1,29 @@
+2013-02-14  Eric Seidel  <e...@webkit.org>
+
+        REGRESSION(r142712): attribute values show up as "(null)" instead of null with the threaded parser
+        https://bugs.webkit.org/show_bug.cgi?id=109784
+
+        Reviewed by Benjamin Poulain.
+
+        When I changed many callsites to use the (existing) String(Vector) constructor
+        I inadvertantly made those callsites convert empty vectors to null strings
+        instead of empty strings (like String(UChar,size_t) does).
+
+        This is due to an oddity/bug in our Vector implementation where data()
+        will be 0 if the Vector is empty, but only if it doesn't have inline capacity.
+        https://bugs.webkit.org/show_bug.cgi?id=109792
+
+        This changes String(Vector) to exactly match the behavior of String(vector.data(), vector.size()).
+
+        This regression was easily detectable with the threaded parser, because we use String
+        instead of AtomicString in our CompactToken (used to send the Token data
+        between threads). The main-thread parser path uses AtomicHTMLToken which
+        uses AtomicString(Vector) and does not have this bug.
+
+        * wtf/text/WTFString.h:
+        (String):
+        (WTF::String::String):
+
 2013-02-13  Zan Dobersek  <zdober...@igalia.com>
 
         The 'global isinf/isnan' compiler quirk required when using clang with libstdc++

Modified: trunk/Source/WTF/wtf/text/WTFString.h (142862 => 142863)


--- trunk/Source/WTF/wtf/text/WTFString.h	2013-02-14 10:22:21 UTC (rev 142862)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2013-02-14 10:23:17 UTC (rev 142863)
@@ -110,6 +110,9 @@
 
     // Construct a string by copying the contents of a vector.  To avoid
     // copying, consider using String::adopt instead.
+    // CAUTION: Vectors with size 0 will return empty strings if they have inlineCapacity
+    // and null strings if they don't. This is due to https://bugs.webkit.org/show_bug.cgi?id=109792
+    // and is done to match String(UChar*, size_t) behavior.
     template<size_t inlineCapacity>
     explicit String(const Vector<UChar, inlineCapacity>&);
 
@@ -535,7 +538,7 @@
 
 template<size_t inlineCapacity>
 String::String(const Vector<UChar, inlineCapacity>& vector)
-    : m_impl(vector.size() ? StringImpl::create(vector.data(), vector.size()) : 0)
+    : m_impl(vector.data() ? StringImpl::create(vector.data(), vector.size()) : 0)
 {
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to