Changeset 142863 in webkit


Ignore:
Timestamp:
Feb 14, 2013 2:23:17 AM (11 years ago)
Author:
eric@webkit.org
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):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r142810 r142863  
     12013-02-14  Eric Seidel  <eric@webkit.org>
     2
     3        REGRESSION(r142712): attribute values show up as "(null)" instead of null with the threaded parser
     4        https://bugs.webkit.org/show_bug.cgi?id=109784
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        When I changed many callsites to use the (existing) String(Vector) constructor
     9        I inadvertantly made those callsites convert empty vectors to null strings
     10        instead of empty strings (like String(UChar,size_t) does).
     11
     12        This is due to an oddity/bug in our Vector implementation where data()
     13        will be 0 if the Vector is empty, but only if it doesn't have inline capacity.
     14        https://bugs.webkit.org/show_bug.cgi?id=109792
     15
     16        This changes String(Vector) to exactly match the behavior of String(vector.data(), vector.size()).
     17
     18        This regression was easily detectable with the threaded parser, because we use String
     19        instead of AtomicString in our CompactToken (used to send the Token data
     20        between threads). The main-thread parser path uses AtomicHTMLToken which
     21        uses AtomicString(Vector) and does not have this bug.
     22
     23        * wtf/text/WTFString.h:
     24        (String):
     25        (WTF::String::String):
     26
    1272013-02-13  Zan Dobersek  <zdobersek@igalia.com>
    228
  • trunk/Source/WTF/wtf/text/WTFString.h

    r142689 r142863  
    111111    // Construct a string by copying the contents of a vector.  To avoid
    112112    // copying, consider using String::adopt instead.
     113    // CAUTION: Vectors with size 0 will return empty strings if they have inlineCapacity
     114    // and null strings if they don't. This is due to https://bugs.webkit.org/show_bug.cgi?id=109792
     115    // and is done to match String(UChar*, size_t) behavior.
    113116    template<size_t inlineCapacity>
    114117    explicit String(const Vector<UChar, inlineCapacity>&);
     
    536539template<size_t inlineCapacity>
    537540String::String(const Vector<UChar, inlineCapacity>& vector)
    538     : m_impl(vector.size() ? StringImpl::create(vector.data(), vector.size()) : 0)
     541    : m_impl(vector.data() ? StringImpl::create(vector.data(), vector.size()) : 0)
    539542{
    540543}
Note: See TracChangeset for help on using the changeset viewer.