Title: [122414] trunk
Revision
122414
Author
[email protected]
Date
2012-07-11 21:08:40 -0700 (Wed, 11 Jul 2012)

Log Message

Do not save state of stateless form controls
https://bugs.webkit.org/show_bug.cgi?id=90964

Reviewed by Hajime Morita.

Source/WebCore:

By Bug 89409, we started to store unmodified form control
state. However we don't need to make such state for the following
types.
- password
- submit
- reset
- button
- keygen

Test: fast/forms/state-restore-skip-stateless.html

* html/BaseButtonInputType.cpp:
(WebCore::BaseButtonInputType::shouldSaveAndRestoreFormControlState):
Added. Disable saving state for submit, reset, and button types.
* html/BaseButtonInputType.h:
(BaseButtonInputType): Add shouldSaveAndRestoreFormControlState.
* html/HTMLFormControlElementWithState.h:
(HTMLFormControlElementWithState): Make shouldSaveAndRestoreFormControlState virtual.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::shouldSaveAndRestoreFormControlState):
Added. Checks InputType::shouldSaveAndRestoreFormControlState first.
* html/HTMLInputElement.h:
(HTMLInputElement): Override shouldSaveAndRestoreFormControlState.
* html/HTMLKeygenElement.cpp:
(WebCore::HTMLKeygenElement::shouldSaveAndRestoreFormControlState)
Added. Disable saving state for <keygen>.:
* html/HTMLKeygenElement.h: Override shouldSaveAndRestoreFormControlState.
* html/InputType.cpp:
(WebCore::InputType::shouldSaveAndRestoreFormControlState):
Added. Enable saving state for all types by default.
* html/InputType.h:
(InputType): Add shouldSaveAndRestoreFormControlState.
* html/PasswordInputType.cpp:
(WebCore::PasswordInputType::shouldSaveAndRestoreFormControlState):
Added. Disabled saving state.
(WebCore::PasswordInputType::saveFormControlState):
Because shouldSaveAndRestoreFormControlState() returns false,
saveFormControlState should be never called.
* html/PasswordInputType.h:
(PasswordInputType): Override shouldSaveAndRestoreFormControlState.

LayoutTests:

* fast/forms/resources/state-restore-skip-stateless-dump.html: Added.
* fast/forms/state-restore-skip-stateless-expected.txt: Added.
* fast/forms/state-restore-skip-stateless.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (122413 => 122414)


--- trunk/LayoutTests/ChangeLog	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/LayoutTests/ChangeLog	2012-07-12 04:08:40 UTC (rev 122414)
@@ -1,3 +1,14 @@
+2012-07-11  Kent Tamura  <[email protected]>
+
+        Do not save state of stateless form controls
+        https://bugs.webkit.org/show_bug.cgi?id=90964
+
+        Reviewed by Hajime Morita.
+
+        * fast/forms/resources/state-restore-skip-stateless-dump.html: Added.
+        * fast/forms/state-restore-skip-stateless-expected.txt: Added.
+        * fast/forms/state-restore-skip-stateless.html: Added.
+
 2012-07-11  Dan Bernstein  <[email protected]>
 
         When a table row height grows because of pagination, not all cells’ heights are adjusted

Added: trunk/LayoutTests/fast/forms/resources/state-restore-skip-stateless-dump.html (0 => 122414)


--- trunk/LayoutTests/fast/forms/resources/state-restore-skip-stateless-dump.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/resources/state-restore-skip-stateless-dump.html	2012-07-12 04:08:40 UTC (rev 122414)
@@ -0,0 +1,19 @@
+<script src=""
+<script>
+if (window.internals) {
+    buffer = 'Form state vector:';
+    var states = internals.formControlStateOfPreviousHistoryItem();
+    for (var i = 1; i < states.length; ++i) {
+        if (i % 4 == 1) {
+            console.log(buffer);
+            buffer = '';
+        }
+        buffer += states[i] + ', ';
+    }
+    console.log(buffer);
+    console.log('');
+}
+jsTestIsAsync = true;
+finishJSTest();
+</script>
+<script src=""

Added: trunk/LayoutTests/fast/forms/state-restore-skip-stateless-expected.txt (0 => 122414)


--- trunk/LayoutTests/fast/forms/state-restore-skip-stateless-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/state-restore-skip-stateless-expected.txt	2012-07-12 04:08:40 UTC (rev 122414)
@@ -0,0 +1,23 @@
+CONSOLE MESSAGE: line 44: Test if state of stateless form control types are not saved.
+CONSOLE MESSAGE: line 8: Form state vector:
+CONSOLE MESSAGE: line 8: name02, hidden, No owner, 0, 
+CONSOLE MESSAGE: line 8: name03, text, No owner, 0, 
+CONSOLE MESSAGE: line 8: name04, tel, No owner, 0, 
+CONSOLE MESSAGE: line 8: name05, url, No owner, 0, 
+CONSOLE MESSAGE: line 8: name06, email, No owner, 0, 
+CONSOLE MESSAGE: line 8: name07, text, No owner, 0, 
+CONSOLE MESSAGE: line 8: name14, number, No owner, 0, 
+CONSOLE MESSAGE: line 8: name15, range, No owner, 1, 
+CONSOLE MESSAGE: line 8: 50, name17, checkbox, No owner, 
+CONSOLE MESSAGE: line 8: 1, off, name18, radio, 
+CONSOLE MESSAGE: line 8: No owner, 1, off, name19, 
+CONSOLE MESSAGE: line 8: file, No owner, 0, name26, 
+CONSOLE MESSAGE: line 8: select-one, No owner, 0, name27, 
+CONSOLE MESSAGE: line 8: select-multiple, No owner, 0, name28, 
+CONSOLE MESSAGE: line 8: textarea, No owner, 0, , 
+CONSOLE MESSAGE: line 13: select-one, No owner, 1, 2048 (High Grade), 
+CONSOLE MESSAGE: line 14: 
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/state-restore-skip-stateless.html (0 => 122414)


--- trunk/LayoutTests/fast/forms/state-restore-skip-stateless.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/state-restore-skip-stateless.html	2012-07-12 04:08:40 UTC (rev 122414)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<div id="console"></div>
+
+<fieldset name=name01></fieldset>
+<input name=name02 type=hidden>
+<input name=name03 type=text>
+<input name=name04 type=tel>
+<input name=name05 type=url>
+<input name=name06 type=email>
+<input name=name07 type=pasword>
+<!-- Don't test optional types.
+<input name=name08 type=datetime>
+<input name=name09 type=date>
+<input name=name10 type=month>
+<input name=name11 type=week>
+<input name=name12 type=time>
+<input name=name13 type=datetime-local>
+-->
+<input name=name14 type=number>
+<input name=name15 type=range>
+<!-- <input name=name16 type=color> -->
+<input name=name17 type=checkbox>
+<input name=name18 type=radio>
+<input name=name19 type=file>
+<input name=name20 type=submit>
+<input name=name21 type=reset>
+<input name=name22 type=button>
+<button name=name23 type=submit></button>
+<button name=name24 type=reset></button>
+<button name=name25 type=button></button>
+<select name=name26 ></select>
+<select name=name27 multiple></select>
+<textarea name=name28></textarea>
+<keygen name=name29>
+<output name=name30></output>
+
+<script>
+console.log('Test if state of stateless form control types are not saved.');
+jsTestIsAsync = true;
+
+window._onload_ = function() {
+    setTimeout(function() {
+        location.href = '';
+    }, 0);
+};
+</script>
+<script src=""
+</body>

Modified: trunk/Source/WebCore/ChangeLog (122413 => 122414)


--- trunk/Source/WebCore/ChangeLog	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/ChangeLog	2012-07-12 04:08:40 UTC (rev 122414)
@@ -1,3 +1,51 @@
+2012-07-11  Kent Tamura  <[email protected]>
+
+        Do not save state of stateless form controls
+        https://bugs.webkit.org/show_bug.cgi?id=90964
+
+        Reviewed by Hajime Morita.
+
+        By Bug 89409, we started to store unmodified form control
+        state. However we don't need to make such state for the following
+        types.
+        - password
+        - submit
+        - reset
+        - button
+        - keygen
+
+        Test: fast/forms/state-restore-skip-stateless.html
+
+        * html/BaseButtonInputType.cpp:
+        (WebCore::BaseButtonInputType::shouldSaveAndRestoreFormControlState):
+        Added. Disable saving state for submit, reset, and button types.
+        * html/BaseButtonInputType.h:
+        (BaseButtonInputType): Add shouldSaveAndRestoreFormControlState.
+        * html/HTMLFormControlElementWithState.h:
+        (HTMLFormControlElementWithState): Make shouldSaveAndRestoreFormControlState virtual.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::shouldSaveAndRestoreFormControlState):
+        Added. Checks InputType::shouldSaveAndRestoreFormControlState first.
+        * html/HTMLInputElement.h:
+        (HTMLInputElement): Override shouldSaveAndRestoreFormControlState.
+        * html/HTMLKeygenElement.cpp:
+        (WebCore::HTMLKeygenElement::shouldSaveAndRestoreFormControlState)
+        Added. Disable saving state for <keygen>.:
+        * html/HTMLKeygenElement.h: Override shouldSaveAndRestoreFormControlState.
+        * html/InputType.cpp:
+        (WebCore::InputType::shouldSaveAndRestoreFormControlState):
+        Added. Enable saving state for all types by default.
+        * html/InputType.h:
+        (InputType): Add shouldSaveAndRestoreFormControlState.
+        * html/PasswordInputType.cpp:
+        (WebCore::PasswordInputType::shouldSaveAndRestoreFormControlState):
+        Added. Disabled saving state.
+        (WebCore::PasswordInputType::saveFormControlState):
+        Because shouldSaveAndRestoreFormControlState() returns false,
+        saveFormControlState should be never called.
+        * html/PasswordInputType.h:
+        (PasswordInputType): Override shouldSaveAndRestoreFormControlState.
+
 2012-07-11  No'am Rosenthal  <[email protected]>
 
         Compilation error with GLES2 when using gl2ext.h from ANGLE.

Modified: trunk/Source/WebCore/html/BaseButtonInputType.cpp (122413 => 122414)


--- trunk/Source/WebCore/html/BaseButtonInputType.cpp	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/BaseButtonInputType.cpp	2012-07-12 04:08:40 UTC (rev 122414)
@@ -41,6 +41,11 @@
 
 using namespace HTMLNames;
 
+bool BaseButtonInputType::shouldSaveAndRestoreFormControlState() const
+{
+    return false;
+}
+
 bool BaseButtonInputType::appendFormData(FormDataList&, bool) const
 {
     // Buttons except overridden types are never successful.

Modified: trunk/Source/WebCore/html/BaseButtonInputType.h (122413 => 122414)


--- trunk/Source/WebCore/html/BaseButtonInputType.h	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/BaseButtonInputType.h	2012-07-12 04:08:40 UTC (rev 122414)
@@ -41,6 +41,7 @@
     BaseButtonInputType(HTMLInputElement* element) : BaseClickableWithKeyInputType(element) { }
 
 private:
+    virtual bool shouldSaveAndRestoreFormControlState() const OVERRIDE;
     virtual bool appendFormData(FormDataList&, bool) const OVERRIDE;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE;
     virtual bool storesValueSeparateFromAttribute() OVERRIDE;

Modified: trunk/Source/WebCore/html/HTMLFormControlElementWithState.h (122413 => 122414)


--- trunk/Source/WebCore/html/HTMLFormControlElementWithState.h	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/HTMLFormControlElementWithState.h	2012-07-12 04:08:40 UTC (rev 122414)
@@ -36,7 +36,7 @@
 
     virtual bool canContainRangeEndPoint() const { return false; }
 
-    bool shouldSaveAndRestoreFormControlState() const;
+    virtual bool shouldSaveAndRestoreFormControlState() const;
     virtual FormControlState saveFormControlState() const;
     // The specified FormControlState must have at least one string value.
     virtual void restoreFormControlState(const FormControlState&) { }

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (122413 => 122414)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-07-12 04:08:40 UTC (rev 122414)
@@ -526,6 +526,13 @@
     return m_inputType->formControlType();
 }
 
+bool HTMLInputElement::shouldSaveAndRestoreFormControlState() const
+{
+    if (!m_inputType->shouldSaveAndRestoreFormControlState())
+        return false;
+    return HTMLTextFormControlElement::shouldSaveAndRestoreFormControlState();
+}
+
 FormControlState HTMLInputElement::saveFormControlState() const
 {
     return m_inputType->saveFormControlState();

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (122413 => 122414)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2012-07-12 04:08:40 UTC (rev 122414)
@@ -296,6 +296,7 @@
 
     virtual const AtomicString& formControlType() const;
 
+    virtual bool shouldSaveAndRestoreFormControlState() const OVERRIDE;
     virtual FormControlState saveFormControlState() const OVERRIDE;
     virtual void restoreFormControlState(const FormControlState&) OVERRIDE;
 

Modified: trunk/Source/WebCore/html/HTMLKeygenElement.cpp (122413 => 122414)


--- trunk/Source/WebCore/html/HTMLKeygenElement.cpp	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/HTMLKeygenElement.cpp	2012-07-12 04:08:40 UTC (rev 122414)
@@ -129,6 +129,11 @@
     static_cast<HTMLFormControlElement*>(shadowSelect())->reset();
 }
 
+bool HTMLKeygenElement::shouldSaveAndRestoreFormControlState() const
+{
+    return false;
+}
+
 HTMLSelectElement* HTMLKeygenElement::shadowSelect() const
 {
     ShadowRoot* root = this->shadow()->oldestShadowRoot();

Modified: trunk/Source/WebCore/html/HTMLKeygenElement.h (122413 => 122414)


--- trunk/Source/WebCore/html/HTMLKeygenElement.h	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/HTMLKeygenElement.h	2012-07-12 04:08:40 UTC (rev 122414)
@@ -51,6 +51,7 @@
     virtual bool supportLabels() const OVERRIDE { return true; }
 
     virtual void reset();
+    virtual bool shouldSaveAndRestoreFormControlState() const OVERRIDE;
 
     HTMLSelectElement* shadowSelect() const;
 };

Modified: trunk/Source/WebCore/html/InputType.cpp (122413 => 122414)


--- trunk/Source/WebCore/html/InputType.cpp	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/InputType.cpp	2012-07-12 04:08:40 UTC (rev 122414)
@@ -169,6 +169,11 @@
     return false;
 }
 
+bool InputType::shouldSaveAndRestoreFormControlState() const
+{
+    return true;
+}
+
 FormControlState InputType::saveFormControlState() const
 {
     String currentValue = element()->value();

Modified: trunk/Source/WebCore/html/InputType.h (122413 => 122414)


--- trunk/Source/WebCore/html/InputType.h	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/InputType.h	2012-07-12 04:08:40 UTC (rev 122414)
@@ -128,6 +128,7 @@
 
     // Form value functions
 
+    virtual bool shouldSaveAndRestoreFormControlState() const;
     virtual FormControlState saveFormControlState() const;
     virtual void restoreFormControlState(const FormControlState&);
     virtual bool isFormDataAppendable() const;

Modified: trunk/Source/WebCore/html/PasswordInputType.cpp (122413 => 122414)


--- trunk/Source/WebCore/html/PasswordInputType.cpp	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/PasswordInputType.cpp	2012-07-12 04:08:40 UTC (rev 122414)
@@ -49,9 +49,15 @@
     return InputTypeNames::password();
 }
 
+bool PasswordInputType::shouldSaveAndRestoreFormControlState() const
+{
+    return false;
+}
+
 FormControlState PasswordInputType::saveFormControlState() const
 {
     // Should never save/restore password fields.
+    ASSERT_NOT_REACHED();
     return FormControlState();
 }
 

Modified: trunk/Source/WebCore/html/PasswordInputType.h (122413 => 122414)


--- trunk/Source/WebCore/html/PasswordInputType.h	2012-07-12 03:54:08 UTC (rev 122413)
+++ trunk/Source/WebCore/html/PasswordInputType.h	2012-07-12 04:08:40 UTC (rev 122414)
@@ -42,6 +42,7 @@
 private:
     PasswordInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
     virtual const AtomicString& formControlType() const OVERRIDE;
+    virtual bool shouldSaveAndRestoreFormControlState() const OVERRIDE;
     virtual FormControlState saveFormControlState() const OVERRIDE;
     virtual void restoreFormControlState(const FormControlState&) OVERRIDE;
     virtual bool shouldUseInputMethod() const OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to