Title: [121207] trunk
Revision
121207
Author
[email protected]
Date
2012-06-25 18:20:05 -0700 (Mon, 25 Jun 2012)

Log 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.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (121206 => 121207)


--- trunk/LayoutTests/ChangeLog	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/LayoutTests/ChangeLog	2012-06-26 01:20:05 UTC (rev 121207)
@@ -1,3 +1,15 @@
+2012-06-25  Kent Tamura  <[email protected]>
+
+        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.
+
+        * 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.
+
 2012-06-25  Anders Carlsson  <[email protected]>
 
         [Lion WK2] fast/loader/reload-zero-byte-plugin.html hits assert

Modified: trunk/LayoutTests/fast/forms/state-restore-broken-state-expected.txt (121206 => 121207)


--- trunk/LayoutTests/fast/forms/state-restore-broken-state-expected.txt	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/LayoutTests/fast/forms/state-restore-broken-state-expected.txt	2012-06-26 01:20:05 UTC (rev 121207)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 5: Generated state: [name1,text,,modified]
+CONSOLE MESSAGE: line 5: Generated state: [name1,text,1,modified]
 The 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.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Deleted: trunk/LayoutTests/fast/forms/state-restore-various-values-expected.txt (121206 => 121207)


--- trunk/LayoutTests/fast/forms/state-restore-various-values-expected.txt	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/LayoutTests/fast/forms/state-restore-various-values-expected.txt	2012-06-26 01:20:05 UTC (rev 121207)
@@ -1,17 +0,0 @@
-Test if special characters are correctly restored.
-
-PASS $("opt-01").selected is true
-PASS $("opt-02").selected is true
-PASS $("opt-03").selected is true
-PASS $("opt-04").selected is true
-PASS $("opt-05").selected is true
-PASS $("opt-06").selected is true
-PASS $("opt-07").selected is true
-PASS $("opt-08").selected is true
-PASS $("opt-09").selected is true
-PASS $("opt-10").selected is true
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
-

Deleted: trunk/LayoutTests/fast/forms/state-restore-various-values.html (121206 => 121207)


--- trunk/LayoutTests/fast/forms/state-restore-various-values.html	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/LayoutTests/fast/forms/state-restore-various-values.html	2012-06-26 01:20:05 UTC (rev 121207)
@@ -1,70 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src=""
-<script src=""
-</head>
-<body>
-<p>Test if special characters are correctly restored.</p>
-<div id="console"></div>
-
-<input id="emptyOnFirstVisit">
-<div id="parent">
-<form action="" id=form1>
-<select id="select1" multiple>
-  <option id="opt-01"></option>
-  <option id="opt-02">,</option>
-  <option id="opt-03">\</option>
-  <option id="opt-04">,a,</option>
-  <option id="opt-05">,\,</option>
-  <option id="opt-06">,\\,</option>
-  <option id="opt-07">\a\</option>
-  <option id="opt-08">\n\</option>
-  <option id="opt-09">\,,\</option>
-  <option id="opt-10">&amp;&#0;&#x0d;&#x0a;,</option>
-</select>
-</form>
-</div>
-
-<script>
-// Note that this test depends on the fact that select options are stored by
-// value strings, not indexes.
-
-jsTestIsAsync = true;
-
-function runTest()
-{
-    var state = document.getElementById('emptyOnFirstVisit');
-    if (!state.value) {
-        // First visit.
-        setTimeout(function() {
-            state.value = 'visited';
-            var options = $('select1').options;
-            for (var i = 0; i < options.length; ++i)
-                options[i].selected = true;
-            $('form1').submit();
-        }, 0);
-    } else {
-        // Went back to this page again, and form state should be restored.
-        shouldBeTrue('$("opt-01").selected');
-        shouldBeTrue('$("opt-02").selected');
-        shouldBeTrue('$("opt-03").selected');
-        shouldBeTrue('$("opt-04").selected');
-        shouldBeTrue('$("opt-05").selected');
-        shouldBeTrue('$("opt-06").selected');
-        shouldBeTrue('$("opt-07").selected');
-        shouldBeTrue('$("opt-08").selected');
-        shouldBeTrue('$("opt-09").selected');
-        shouldBeTrue('$("opt-10").selected');
-    
-        $('parent').innerHTML = '';
-        setTimeout(function() {
-            finishJSTest();
-        }, 0);
-    }
-}
-
-runTest();
-</script>
-<script src=""
-</body>

Modified: trunk/Source/WTF/ChangeLog (121206 => 121207)


--- trunk/Source/WTF/ChangeLog	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/Source/WTF/ChangeLog	2012-06-26 01:20:05 UTC (rev 121207)
@@ -1,3 +1,13 @@
+2012-06-25  Kent Tamura  <[email protected]>
+
+        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.
+
+        * wtf/text/StringBuilder.h:
+
 2012-06-25  Yong Li  <[email protected]>
 
         [BlackBerry] Add JSC statistics into about:memory

Modified: trunk/Source/WTF/wtf/text/StringBuilder.h (121206 => 121207)


--- trunk/Source/WTF/wtf/text/StringBuilder.h	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/Source/WTF/wtf/text/StringBuilder.h	2012-06-26 01:20:05 UTC (rev 121207)
@@ -130,21 +130,6 @@
         append(static_cast<LChar>(c));
     }
 
-    void appendEscaped(const String& string, UChar escape, UChar special)
-    {
-        if (string.isEmpty())
-            return;
-        unsigned requiredSize = length() + string.length();
-        if (capacity() < requiredSize)
-            reserveCapacity(requiredSize);
-        for (unsigned i = 0; i < string.length(); ++i) {
-            UChar ch = string[i];
-            if (ch == escape || ch == special)
-                append(escape);
-            append(ch);
-        }
-    }
-
     String toString()
     {
         shrinkToFit();

Modified: trunk/Source/WebCore/ChangeLog (121206 => 121207)


--- trunk/Source/WebCore/ChangeLog	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/Source/WebCore/ChangeLog	2012-06-26 01:20:05 UTC (rev 121207)
@@ -1,3 +1,23 @@
+2012-06-25  Kent Tamura  <[email protected]>
+
+        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.
+
+        * 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):
+
 2012-06-25  Jay Civelli  <[email protected]>
 
         Fix progress load reporting for MHTML documents.

Modified: trunk/Source/WebCore/html/FormController.cpp (121206 => 121207)


--- trunk/Source/WebCore/html/FormController.cpp	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/Source/WebCore/html/FormController.cpp	2012-06-26 01:20:05 UTC (rev 121207)
@@ -22,7 +22,6 @@
 #include "FormController.h"
 
 #include "HTMLFormControlElementWithState.h"
-#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -31,61 +30,38 @@
 // ----------------------------------------------------------------------------
 
 // Serilized form of FormControlState:
+//  (',' means strings around it are separated in stateVector.)
 //
 // SerializedControlState ::= SkipState | RestoreState
-// SkipState ::= ''
-// RestoreState ::= (',' EscapedValue )+
-// EscapedValue ::= ('\\' | '\,' | [^\,])+
+// SkipState ::= '0'
+// RestoreState ::= UnsignedNumber, ControlValue+
+// UnsignedNumber ::= [0-9]+
+// ControlValue ::= arbitrary string
+//
+// RestoreState has a sequence of ControlValues. The length of the
+// sequence is represented by UnsignedNumber.
 
-String FormControlState::serialize() const
+void FormControlState::serializeTo(Vector<String>& stateVector) const
 {
     ASSERT(!isFailure());
-    if (!m_values.size())
-        return emptyString();
-
-    size_t enoughSize = 0;
+    stateVector.append(String::number(m_values.size()));
     for (size_t i = 0; i < m_values.size(); ++i)
-        enoughSize += 1 + m_values[i].length() * 2;
-    StringBuilder builder;
-    builder.reserveCapacity(enoughSize);
-    for (size_t i = 0; i < m_values.size(); ++i) {
-        builder.append(',');
-        builder.appendEscaped(m_values[i], '\\', ',');
-    }
-    return builder.toString();
+        stateVector.append(m_values[i].isNull() ? emptyString() : m_values[i]);
 }
 
-FormControlState FormControlState::deserialize(const String& escaped)
+FormControlState FormControlState::deserialize(const Vector<String>& stateVector, size_t& index)
 {
-    if (!escaped.length())
+    if (index >= stateVector.size())
+        return FormControlState(TypeFailure);
+    size_t valueSize = stateVector[index++].toUInt();
+    if (!valueSize)
         return FormControlState();
-    if (escaped[0] != ',')
+    if (index + valueSize > stateVector.size())
         return FormControlState(TypeFailure);
-
-    size_t valueSize = 1;
-    for (unsigned i = 1; i < escaped.length(); ++i) {
-        if (escaped[i] == '\\') {
-            if (++i >= escaped.length())
-                return FormControlState(TypeFailure);
-        } else if (escaped[i] == ',')
-            valueSize++;
-    }
-
     FormControlState state;
     state.m_values.reserveCapacity(valueSize);
-    StringBuilder builder;
-    for (unsigned i = 1; i < escaped.length(); ++i) {
-        if (escaped[i] == '\\') {
-            if (++i >= escaped.length())
-                return FormControlState(TypeFailure);
-            builder.append(escaped[i]);
-        } else if (escaped[i] == ',') {
-            state.append(builder.toString());
-            builder.clear();
-        } else
-            builder.append(escaped[i]);
-    }
-    state.append(builder.toString());
+    for (size_t i = 0; i < valueSize; ++i)
+        state.append(stateVector[index++]);
     return state;
 }
 
@@ -105,14 +81,14 @@
     // In the legacy version of serialized state, the first item was a name
     // attribute value of a form control. The following string literal should
     // contain some characters which are rarely used for name attribute values.
-    DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% WebKit serialized form state version 4 \n\r=&"));
+    DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% WebKit serialized form state version 3 \n\r=&"));
     return signature;
 }
 
 Vector<String> FormController::formElementsState() const
 {
     Vector<String> stateVector;
-    stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 3 + 1);
+    stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 4 + 1);
     stateVector.append(formStateSignature());
     typedef FormElementListHashSet::const_iterator Iterator;
     Iterator end = m_formElementsWithState.end();
@@ -122,7 +98,7 @@
             continue;
         stateVector.append(elementWithState->name().string());
         stateVector.append(elementWithState->formControlType().string());
-        stateVector.append(elementWithState->saveFormControlState().serialize());
+        elementWithState->saveFormControlState().serializeTo(stateVector);
     }
     return stateVector;
 }
@@ -137,15 +113,14 @@
     typedef FormElementStateMap::iterator Iterator;
     m_formElementsWithState.clear();
 
-    if (stateVector.size() < 1 || stateVector[0] != formStateSignature())
+    size_t i = 0;
+    if (stateVector.size() < 1 || stateVector[i++] != formStateSignature())
         return;
-    if ((stateVector.size() - 1) % 3)
-        return;
 
-    for (size_t i = 1; i < stateVector.size(); i += 3) {
-        AtomicString name = stateVector[i];
-        AtomicString type = stateVector[i + 1];
-        FormControlState state = FormControlState::deserialize(stateVector[i + 2]);
+    while (i + 2 < stateVector.size()) {
+        AtomicString name = stateVector[i++];
+        AtomicString type = stateVector[i++];
+        FormControlState state = FormControlState::deserialize(stateVector, i);
         if (type.isEmpty() || type.impl()->find(isNotFormControlTypeCharacter) != notFound || state.isFailure())
             break;
 
@@ -159,6 +134,8 @@
             m_stateForNewFormElements.set(key, stateList);
         }
     }
+    if (i != stateVector.size())
+        m_stateForNewFormElements.clear();
 }
 
 bool FormController::hasStateForNewFormElements() const

Modified: trunk/Source/WebCore/html/FormController.h (121206 => 121207)


--- trunk/Source/WebCore/html/FormController.h	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/Source/WebCore/html/FormController.h	2012-06-26 01:20:05 UTC (rev 121207)
@@ -78,7 +78,7 @@
 public:
     FormControlState() : m_type(TypeSkip) { }
     explicit FormControlState(const String& value) : m_type(TypeRestore) { m_values.append(value); }
-    static FormControlState deserialize(const String&);
+    static FormControlState deserialize(const Vector<String>& stateVector, size_t& index);
     FormControlState(const FormControlState& another) : m_type(another.m_type), m_values(another.m_values) { }
     FormControlState& operator=(const FormControlState&);
 
@@ -86,7 +86,7 @@
     size_t valueSize() const { return m_values.size(); }
     const String& operator[](size_t i) const { return m_values[i]; }
     void append(const String&);
-    String serialize() const;
+    void serializeTo(Vector<String>& stateVector) const;
 
 private:
     enum Type { TypeSkip, TypeRestore, TypeFailure };

Modified: trunk/Source/WebCore/html/shadow/CalendarPickerElement.cpp (121206 => 121207)


--- trunk/Source/WebCore/html/shadow/CalendarPickerElement.cpp	2012-06-26 01:12:06 UTC (rev 121206)
+++ trunk/Source/WebCore/html/shadow/CalendarPickerElement.cpp	2012-06-26 01:20:05 UTC (rev 121207)
@@ -151,7 +151,12 @@
 {
     addLiteral("\"", writer);
     StringBuilder builder;
-    builder.appendEscaped(str, '\\', '"');
+    builder.reserveCapacity(str.length());
+    for (unsigned i = 0; i < str.length(); ++i) {
+        if (str[i] == '\\' || str[i] == '"')
+            builder.append('\\');
+        builder.append(str[i]);
+    }
     addString(builder.toString(), writer);
     addLiteral("\"", writer);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to