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.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121519
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-06-28 Kent Tamura <tkent@chromium.org>
+
+ 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 <bashi@chromium.org>
[Chromium] unreviewed test expectations update after r121510.
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"
+2012-06-28 Kent Tamura <tkent@chromium.org>
+
+ 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 <morrita@google.com>
[Refactoring] NodeRenderingContext ctor could be built on top of the ComposedShadowTreeWalker
, m_isAutofilled(false)
, m_stateRestored(false)
, m_parsingInProgress(createdByParser)
+ , m_valueAttributeWasUpdatedAfterParsing(false)
, m_wasModifiedByUser(false)
, m_canReceiveDroppedFiles(false)
, m_inputType(InputType::createText(this))
}
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
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); }
#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;
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)