Title: [121519] trunk
- Revision
- 121519
- Author
- [email protected]
- Date
- 2012-06-28 23:12:22 -0700 (Thu, 28 Jun 2012)
Log Message
REGRESSION(r106388): Form hidden element values being restored
incorrectly for dynamically generated content
https://bugs.webkit.org/show_bug.cgi?id=88685
Reviewed by Hajime Morita.
Source/WebCore:
We should not save value attribute updated during parsing.
Test: fast/forms/state-restore-to-non-edited-controls.html
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::HTMLInputElement):
Initialize m_valueAttributeWasUpdatedAfterParsing.
(WebCore::HTMLInputElement::parseAttribute):
Set true to m_valueAttributeWasUpdatedAfterParsing if value
attribute is updated and it's not in parsing.
* html/HTMLInputElement.h:
(WebCore::HTMLInputElement::valueAttributeWasUpdatedAfterParsing):
Added for HiddenInputType.
* html/HiddenInputType.cpp:
(WebCore::HiddenInputType::saveFormControlState):
Save the value only if valueAttributeWasUpdatedAfterParsing() is true.
LayoutTests:
* fast/forms/state-restore-to-non-edited-controls-expected.txt:
A failing test is fixed.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (121518 => 121519)
--- trunk/LayoutTests/ChangeLog 2012-06-29 06:00:56 UTC (rev 121518)
+++ trunk/LayoutTests/ChangeLog 2012-06-29 06:12:22 UTC (rev 121519)
@@ -1,3 +1,14 @@
+2012-06-28 Kent Tamura <[email protected]>
+
+ REGRESSION(r106388): Form hidden element values being restored
+ incorrectly for dynamically generated content
+ https://bugs.webkit.org/show_bug.cgi?id=88685
+
+ Reviewed by Hajime Morita.
+
+ * fast/forms/state-restore-to-non-edited-controls-expected.txt:
+ A failing test is fixed.
+
2012-06-28 Kenichi Ishibashi <[email protected]>
[Chromium] unreviewed test expectations update after r121510.
Modified: trunk/LayoutTests/fast/forms/state-restore-to-non-edited-controls-expected.txt (121518 => 121519)
--- trunk/LayoutTests/fast/forms/state-restore-to-non-edited-controls-expected.txt 2012-06-29 06:00:56 UTC (rev 121518)
+++ trunk/LayoutTests/fast/forms/state-restore-to-non-edited-controls-expected.txt 2012-06-29 06:12:22 UTC (rev 121519)
@@ -1,7 +1,7 @@
Test to NOT save state for non-edited controls
PASS document.getElementById("button").value is "2"
-FAIL document.getElementById("hidden").value should be 2. Was 1.
+PASS document.getElementById("hidden").value is "2"
PASS document.getElementById("image").value is "2"
PASS document.getElementById("reset").value is "2"
PASS document.getElementById("submit1").value is "2"
Modified: trunk/Source/WebCore/ChangeLog (121518 => 121519)
--- trunk/Source/WebCore/ChangeLog 2012-06-29 06:00:56 UTC (rev 121518)
+++ trunk/Source/WebCore/ChangeLog 2012-06-29 06:12:22 UTC (rev 121519)
@@ -1,3 +1,28 @@
+2012-06-28 Kent Tamura <[email protected]>
+
+ REGRESSION(r106388): Form hidden element values being restored
+ incorrectly for dynamically generated content
+ https://bugs.webkit.org/show_bug.cgi?id=88685
+
+ Reviewed by Hajime Morita.
+
+ We should not save value attribute updated during parsing.
+
+ Test: fast/forms/state-restore-to-non-edited-controls.html
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::HTMLInputElement):
+ Initialize m_valueAttributeWasUpdatedAfterParsing.
+ (WebCore::HTMLInputElement::parseAttribute):
+ Set true to m_valueAttributeWasUpdatedAfterParsing if value
+ attribute is updated and it's not in parsing.
+ * html/HTMLInputElement.h:
+ (WebCore::HTMLInputElement::valueAttributeWasUpdatedAfterParsing):
+ Added for HiddenInputType.
+ * html/HiddenInputType.cpp:
+ (WebCore::HiddenInputType::saveFormControlState):
+ Save the value only if valueAttributeWasUpdatedAfterParsing() is true.
+
2012-06-28 MORITA Hajime <[email protected]>
[Refactoring] NodeRenderingContext ctor could be built on top of the ComposedShadowTreeWalker
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (121518 => 121519)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-06-29 06:00:56 UTC (rev 121518)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-06-29 06:12:22 UTC (rev 121519)
@@ -95,6 +95,7 @@
, m_isAutofilled(false)
, m_stateRestored(false)
, m_parsingInProgress(createdByParser)
+ , m_valueAttributeWasUpdatedAfterParsing(false)
, m_wasModifiedByUser(false)
, m_canReceiveDroppedFiles(false)
, m_inputType(InputType::createText(this))
@@ -594,6 +595,7 @@
}
setFormControlValueMatchesRenderer(false);
setNeedsValidityCheck();
+ m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress;
} else if (attribute.name() == checkedAttr) {
// Another radio button in the same group might be checked by state
// restore. We shouldn't call setChecked() even if this has the checked
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (121518 => 121519)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2012-06-29 06:00:56 UTC (rev 121518)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2012-06-29 06:12:22 UTC (rev 121519)
@@ -238,11 +238,12 @@
HTMLInputElement* checkedRadioButtonForGroup() const;
bool isInRequiredRadioButtonGroup() const;
+ // Functions for InputType classes.
void setValueInternal(const String&, TextFieldEventBehavior);
-
bool isTextFormControlFocusable() const;
bool isTextFormControlKeyboardFocusable(KeyboardEvent*) const;
bool isTextFormControlMouseFocusable() const;
+ bool valueAttributeWasUpdatedAfterParsing() const { return m_valueAttributeWasUpdatedAfterParsing; }
void cacheSelectionInResponseToSetValue(int caretOffset) { cacheSelection(caretOffset, caretOffset, SelectionHasNoDirection); }
@@ -386,6 +387,7 @@
#endif
bool m_stateRestored : 1;
bool m_parsingInProgress : 1;
+ bool m_valueAttributeWasUpdatedAfterParsing : 1;
bool m_wasModifiedByUser : 1;
bool m_canReceiveDroppedFiles : 1;
OwnPtr<InputType> m_inputType;
Modified: trunk/Source/WebCore/html/HiddenInputType.cpp (121518 => 121519)
--- trunk/Source/WebCore/html/HiddenInputType.cpp 2012-06-29 06:00:56 UTC (rev 121518)
+++ trunk/Source/WebCore/html/HiddenInputType.cpp 2012-06-29 06:12:22 UTC (rev 121519)
@@ -54,8 +54,11 @@
FormControlState HiddenInputType::saveFormControlState() const
{
- // FIXME: We should not always save the value. http://webkit.org/b/88685
- return FormControlState(element()->value());
+ // valueAttributeWasUpdatedAfterParsing() never be true for form
+ // controls create by createElement() or cloneNode(). It's ok for
+ // now because we restore values only to form controls created by
+ // parsing.
+ return element()->valueAttributeWasUpdatedAfterParsing() ? FormControlState(element()->value()) : FormControlState();
}
void HiddenInputType::restoreFormControlState(const FormControlState& state)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes