Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1055)

Unified Diff: Source/core/html/HTMLFormControlElement.cpp

Issue 460343004: Fix update of validity cache value, so that it reflects the correct state of any FormControlElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WIP2 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLFormControlElement.cpp
diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp
index bee7cdaa70ffabd5b984f581391aee2bfc2db3fe..edffe97e1e1d6656710e7e665a5b68bd0ac680e0 100644
--- a/Source/core/html/HTMLFormControlElement.cpp
+++ b/Source/core/html/HTMLFormControlElement.cpp
@@ -58,6 +58,7 @@ HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc
, m_willValidateInitialized(false)
, m_willValidate(true)
, m_isValid(true)
+ , m_validIsDirty(false)
tkent 2014/09/03 02:16:35 Initial value should be |true| conceptually.
spartha 2014/09/03 07:58:40 Done.
, m_wasChangedSinceLastFormControlChangeEvent(false)
, m_wasFocusedByMouse(false)
{
@@ -483,20 +484,21 @@ bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<F
bool HTMLFormControlElement::isValidFormControlElement()
{
- // If the following assertion fails, setNeedsValidityCheck() is not called
- // correctly when something which changes validity is updated.
- ASSERT(m_isValid == valid());
+ if (m_validIsDirty) {
+ if (willValidate())
tkent 2014/09/03 02:16:35 Do we need this check? When !willValidate(), m_is
spartha 2014/09/03 07:58:40 Done.
+ m_isValid = valid();
+ m_validIsDirty = false;
+ }
return m_isValid;
}
void HTMLFormControlElement::setNeedsValidityCheck()
{
- bool newIsValid = valid();
- if (willValidate() && newIsValid != m_isValid) {
+ if (!m_validIsDirty && willValidate()) {
// Update style for pseudo classes such as :valid :invalid.
setNeedsStyleRecalc(SubtreeStyleChange);
+ m_validIsDirty = true;
}
- m_isValid = newIsValid;
// Updates only if this control already has a validation message.
if (isValidationMessageVisible()) {

Powered by Google App Engine
This is Rietveld 408576698