Changeset 121207 in webkit


Ignore:
Timestamp:
Jun 25, 2012 6:20:05 PM (12 years ago)
Author:
tkent@chromium.org
Message:

Unreviewed, rolling out r121145.
http://trac.webkit.org/changeset/121145
https://bugs.webkit.org/show_bug.cgi?id=89847

Had an objection for the change.

Source/WebCore:

  • html/FormController.cpp:

(WebCore):
(WebCore::FormControlState::serializeTo):
(WebCore::FormControlState::deserialize):
(WebCore::formStateSignature):
(WebCore::FormController::formElementsState):
(WebCore::FormController::setStateForNewFormElements):

  • html/FormController.h:

(FormControlState):

  • html/shadow/CalendarPickerElement.cpp:

(WebCore::addJavaScriptString):

Source/WTF:

  • wtf/text/StringBuilder.h:

LayoutTests:

  • fast/forms/state-restore-broken-state-expected.txt:
  • fast/forms/state-restore-various-values-expected.txt: Removed.
  • fast/forms/state-restore-various-values.html: Removed.
Location:
trunk
Files:
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r121203 r121207  
     12012-06-25  Kent Tamura  <tkent@chromium.org>
     2
     3        Unreviewed, rolling out r121145.
     4        http://trac.webkit.org/changeset/121145
     5        https://bugs.webkit.org/show_bug.cgi?id=89847
     6
     7        Had an objection for the change.
     8
     9        * fast/forms/state-restore-broken-state-expected.txt:
     10        * fast/forms/state-restore-various-values-expected.txt: Removed.
     11        * fast/forms/state-restore-various-values.html: Removed.
     12
    1132012-06-25  Anders Carlsson  <andersca@apple.com>
    214
  • trunk/LayoutTests/fast/forms/state-restore-broken-state-expected.txt

    r121145 r121207  
    1 CONSOLE MESSAGE: line 5: Generated state: [name1,text,,modified]
     1CONSOLE MESSAGE: line 5: Generated state: [name1,text,1,modified]
    22The value was modified in the first load of state-restore-broken-state-1.html, but it should not be restored because the state-restore-broken-state-2.html breaks the state.
    33
  • trunk/Source/WTF/ChangeLog

    r121196 r121207  
     12012-06-25  Kent Tamura  <tkent@chromium.org>
     2
     3        Unreviewed, rolling out r121145.
     4        http://trac.webkit.org/changeset/121145
     5        https://bugs.webkit.org/show_bug.cgi?id=89847
     6
     7        Had an objection for the change.
     8
     9        * wtf/text/StringBuilder.h:
     10
    1112012-06-25  Yong Li  <yoli@rim.com>
    212
  • trunk/Source/WTF/wtf/text/StringBuilder.h

    r121145 r121207  
    131131    }
    132132
    133     void appendEscaped(const String& string, UChar escape, UChar special)
    134     {
    135         if (string.isEmpty())
    136             return;
    137         unsigned requiredSize = length() + string.length();
    138         if (capacity() < requiredSize)
    139             reserveCapacity(requiredSize);
    140         for (unsigned i = 0; i < string.length(); ++i) {
    141             UChar ch = string[i];
    142             if (ch == escape || ch == special)
    143                 append(escape);
    144             append(ch);
    145         }
    146     }
    147 
    148133    String toString()
    149134    {
  • trunk/Source/WebCore/ChangeLog

    r121206 r121207  
     12012-06-25  Kent Tamura  <tkent@chromium.org>
     2
     3        Unreviewed, rolling out r121145.
     4        http://trac.webkit.org/changeset/121145
     5        https://bugs.webkit.org/show_bug.cgi?id=89847
     6
     7        Had an objection for the change.
     8
     9        * html/FormController.cpp:
     10        (WebCore):
     11        (WebCore::FormControlState::serializeTo):
     12        (WebCore::FormControlState::deserialize):
     13        (WebCore::formStateSignature):
     14        (WebCore::FormController::formElementsState):
     15        (WebCore::FormController::setStateForNewFormElements):
     16        * html/FormController.h:
     17        (FormControlState):
     18        * html/shadow/CalendarPickerElement.cpp:
     19        (WebCore::addJavaScriptString):
     20
    1212012-06-25  Jay Civelli  <jcivelli@chromium.org>
    222
  • trunk/Source/WebCore/html/FormController.cpp

    r121145 r121207  
    2323
    2424#include "HTMLFormControlElementWithState.h"
    25 #include <wtf/text/StringBuilder.h>
    2625
    2726namespace WebCore {
     
    3231
    3332// Serilized form of FormControlState:
     33//  (',' means strings around it are separated in stateVector.)
    3434//
    3535// SerializedControlState ::= SkipState | RestoreState
    36 // SkipState ::= ''
    37 // RestoreState ::= (',' EscapedValue )+
    38 // EscapedValue ::= ('\\' | '\,' | [^\,])+
    39 
    40 String FormControlState::serialize() const
     36// SkipState ::= '0'
     37// RestoreState ::= UnsignedNumber, ControlValue+
     38// UnsignedNumber ::= [0-9]+
     39// ControlValue ::= arbitrary string
     40//
     41// RestoreState has a sequence of ControlValues. The length of the
     42// sequence is represented by UnsignedNumber.
     43
     44void FormControlState::serializeTo(Vector<String>& stateVector) const
    4145{
    4246    ASSERT(!isFailure());
    43     if (!m_values.size())
    44         return emptyString();
    45 
    46     size_t enoughSize = 0;
     47    stateVector.append(String::number(m_values.size()));
    4748    for (size_t i = 0; i < m_values.size(); ++i)
    48         enoughSize += 1 + m_values[i].length() * 2;
    49     StringBuilder builder;
    50     builder.reserveCapacity(enoughSize);
    51     for (size_t i = 0; i < m_values.size(); ++i) {
    52         builder.append(',');
    53         builder.appendEscaped(m_values[i], '\\', ',');
    54     }
    55     return builder.toString();
    56 }
    57 
    58 FormControlState FormControlState::deserialize(const String& escaped)
    59 {
    60     if (!escaped.length())
     49        stateVector.append(m_values[i].isNull() ? emptyString() : m_values[i]);
     50}
     51
     52FormControlState FormControlState::deserialize(const Vector<String>& stateVector, size_t& index)
     53{
     54    if (index >= stateVector.size())
     55        return FormControlState(TypeFailure);
     56    size_t valueSize = stateVector[index++].toUInt();
     57    if (!valueSize)
    6158        return FormControlState();
    62     if (escaped[0] != ',')
     59    if (index + valueSize > stateVector.size())
    6360        return FormControlState(TypeFailure);
    64 
    65     size_t valueSize = 1;
    66     for (unsigned i = 1; i < escaped.length(); ++i) {
    67         if (escaped[i] == '\\') {
    68             if (++i >= escaped.length())
    69                 return FormControlState(TypeFailure);
    70         } else if (escaped[i] == ',')
    71             valueSize++;
    72     }
    73 
    7461    FormControlState state;
    7562    state.m_values.reserveCapacity(valueSize);
    76     StringBuilder builder;
    77     for (unsigned i = 1; i < escaped.length(); ++i) {
    78         if (escaped[i] == '\\') {
    79             if (++i >= escaped.length())
    80                 return FormControlState(TypeFailure);
    81             builder.append(escaped[i]);
    82         } else if (escaped[i] == ',') {
    83             state.append(builder.toString());
    84             builder.clear();
    85         } else
    86             builder.append(escaped[i]);
    87     }
    88     state.append(builder.toString());
     63    for (size_t i = 0; i < valueSize; ++i)
     64        state.append(stateVector[index++]);
    8965    return state;
    9066}
     
    10682    // attribute value of a form control. The following string literal should
    10783    // contain some characters which are rarely used for name attribute values.
    108     DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% WebKit serialized form state version 4 \n\r=&"));
     84    DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% WebKit serialized form state version 3 \n\r=&"));
    10985    return signature;
    11086}
     
    11389{
    11490    Vector<String> stateVector;
    115     stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 3 + 1);
     91    stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 4 + 1);
    11692    stateVector.append(formStateSignature());
    11793    typedef FormElementListHashSet::const_iterator Iterator;
     
    12399        stateVector.append(elementWithState->name().string());
    124100        stateVector.append(elementWithState->formControlType().string());
    125         stateVector.append(elementWithState->saveFormControlState().serialize());
     101        elementWithState->saveFormControlState().serializeTo(stateVector);
    126102    }
    127103    return stateVector;
     
    138114    m_formElementsWithState.clear();
    139115
    140     if (stateVector.size() < 1 || stateVector[0] != formStateSignature())
     116    size_t i = 0;
     117    if (stateVector.size() < 1 || stateVector[i++] != formStateSignature())
    141118        return;
    142     if ((stateVector.size() - 1) % 3)
    143         return;
    144 
    145     for (size_t i = 1; i < stateVector.size(); i += 3) {
    146         AtomicString name = stateVector[i];
    147         AtomicString type = stateVector[i + 1];
    148         FormControlState state = FormControlState::deserialize(stateVector[i + 2]);
     119
     120    while (i + 2 < stateVector.size()) {
     121        AtomicString name = stateVector[i++];
     122        AtomicString type = stateVector[i++];
     123        FormControlState state = FormControlState::deserialize(stateVector, i);
    149124        if (type.isEmpty() || type.impl()->find(isNotFormControlTypeCharacter) != notFound || state.isFailure())
    150125            break;
     
    160135        }
    161136    }
     137    if (i != stateVector.size())
     138        m_stateForNewFormElements.clear();
    162139}
    163140
  • trunk/Source/WebCore/html/FormController.h

    r121145 r121207  
    7979    FormControlState() : m_type(TypeSkip) { }
    8080    explicit FormControlState(const String& value) : m_type(TypeRestore) { m_values.append(value); }
    81     static FormControlState deserialize(const String&);
     81    static FormControlState deserialize(const Vector<String>& stateVector, size_t& index);
    8282    FormControlState(const FormControlState& another) : m_type(another.m_type), m_values(another.m_values) { }
    8383    FormControlState& operator=(const FormControlState&);
     
    8787    const String& operator[](size_t i) const { return m_values[i]; }
    8888    void append(const String&);
    89     String serialize() const;
     89    void serializeTo(Vector<String>& stateVector) const;
    9090
    9191private:
  • trunk/Source/WebCore/html/shadow/CalendarPickerElement.cpp

    r121145 r121207  
    152152    addLiteral("\"", writer);
    153153    StringBuilder builder;
    154     builder.appendEscaped(str, '\\', '"');
     154    builder.reserveCapacity(str.length());
     155    for (unsigned i = 0; i < str.length(); ++i) {
     156        if (str[i] == '\\' || str[i] == '"')
     157            builder.append('\\');
     158        builder.append(str[i]);
     159    }
    155160    addString(builder.toString(), writer);
    156161    addLiteral("\"", writer);
Note: See TracChangeset for help on using the changeset viewer.