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

Issue 672163002: Fix bug where form/fieldset :valid/:invalid won't be recalculated upon control's willValidate change

Created:
6 years, 2 months ago by Bartek Nowierski
Modified:
6 years, 2 months ago
Reviewers:
tkent, keishi
CC:
blink-reviews, dglazkov+blink, blink-reviews-html_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

Fix a problem where a control's willValidate change wouldn't trigger the containing form's or fieldset's style change. Cache form validity while at it to avoid style recalculation BUG=360466 TEST=Added cases to layout tests that toggle controls disabled and readonly in form and fieldset

Patch Set 1 #

Patch Set 2 : Fix bug where willValidate change won't update form style + optimize form validity check through ca… #

Patch Set 3 : Add missing style refresh on willValidite change #

Patch Set 4 : Add layout tests to catch the problem #

Total comments: 6

Patch Set 5 : Apply keishi's comments + Pull #

Patch Set 6 : Fixes to the logic #

Unified diffs Side-by-side diffs Delta from patch set Stats (+127 lines, -32 lines) Patch
M LayoutTests/fast/forms/fieldset-pseudo-valid-style.html View 1 2 3 2 chunks +16 lines, -1 line 0 comments Download
M LayoutTests/fast/forms/fieldset-pseudo-valid-style-expected.txt View 1 2 3 2 chunks +11 lines, -1 line 0 comments Download
M LayoutTests/fast/forms/form-pseudo-valid-style.html View 1 2 3 4 5 2 chunks +27 lines, -1 line 0 comments Download
M LayoutTests/fast/forms/form-pseudo-valid-style-expected.txt View 1 2 3 4 5 2 chunks +17 lines, -1 line 0 comments Download
M Source/core/html/HTMLFormControlElement.h View 1 2 3 4 5 3 chunks +5 lines, -2 lines 0 comments Download
M Source/core/html/HTMLFormControlElement.cpp View 1 2 3 4 5 5 chunks +16 lines, -16 lines 0 comments Download
M Source/core/html/HTMLFormElement.h View 1 2 3 4 5 2 chunks +5 lines, -1 line 0 comments Download
M Source/core/html/HTMLFormElement.cpp View 1 2 3 4 5 4 chunks +30 lines, -9 lines 0 comments Download

Messages

Total messages: 6 (1 generated)
Bartek Nowierski
6 years, 2 months ago (2014-10-23 10:12:50 UTC) #2
keishi
https://codereview.chromium.org/672163002/diff/60001/Source/core/html/HTMLFormControlElement.cpp File Source/core/html/HTMLFormControlElement.cpp (right): https://codereview.chromium.org/672163002/diff/60001/Source/core/html/HTMLFormControlElement.cpp#newcode417 Source/core/html/HTMLFormControlElement.cpp:417: // call willValidate() again. Is this true? m_willValidateInitialized is ...
6 years, 2 months ago (2014-10-24 10:25:49 UTC) #3
Bartek Nowierski
https://codereview.chromium.org/672163002/diff/60001/Source/core/html/HTMLFormControlElement.cpp File Source/core/html/HTMLFormControlElement.cpp (right): https://codereview.chromium.org/672163002/diff/60001/Source/core/html/HTMLFormControlElement.cpp#newcode417 Source/core/html/HTMLFormControlElement.cpp:417: // call willValidate() again. On 2014/10/24 10:25:49, keishi wrote: ...
6 years, 2 months ago (2014-10-24 10:48:30 UTC) #4
keishi
https://codereview.chromium.org/672163002/diff/60001/Source/core/html/HTMLFormControlElement.cpp File Source/core/html/HTMLFormControlElement.cpp (right): https://codereview.chromium.org/672163002/diff/60001/Source/core/html/HTMLFormControlElement.cpp#newcode417 Source/core/html/HTMLFormControlElement.cpp:417: // call willValidate() again. On 2014/10/24 10:48:30, Bartek Nowierski ...
6 years, 2 months ago (2014-10-24 11:07:17 UTC) #5
Bartek Nowierski
6 years, 2 months ago (2014-10-24 14:47:16 UTC) #6
https://codereview.chromium.org/672163002/diff/60001/Source/core/html/HTMLFor...
File Source/core/html/HTMLFormControlElement.cpp (right):

https://codereview.chromium.org/672163002/diff/60001/Source/core/html/HTMLFor...
Source/core/html/HTMLFormControlElement.cpp:417: // call willValidate() again.
On 2014/10/24 11:07:17, keishi wrote:
> On 2014/10/24 10:48:30, Bartek Nowierski wrote:
> > On 2014/10/24 10:25:49, keishi wrote:
> > > Is this true? m_willValidateInitialized is set to true above and
> > > recalcWillValidate will set m_dataListAncestorState so I don't think this
> > > creates an infinite recursion.
> > 
> > It's a little more complex than that. Calling isValidElement() here will
> trigger
> > the m_isValid==valid() assert, because the above two line will change the
> > validity result.
> > 
> > So what I tried was calling isValidElement two lines above, but that one
does
> > cause infinite recursion as you noted.
> > 
> > One way or the other, the statement that willValidate may be called is true.
> 
> I think using ElementAddition/Removal here when we should be using
> ElementModified is bad.
> 
> The problem seems to be in HTMLFormControlElement::setNeedsValidityCheck.
> formOwnerSetNeedsValidityCheck and fieldSetAncestorsSetNeedsValidityCheck
should
> be called from setNeedsValidityCheck() but it isn't. 
> Inside HTMLFormControlElement::setNeedsValidityCheck,
> formOwnerSetNeedsValidityCheck and fieldSetAncestorsSetNeedsValidityCheck
should
> be moved out of the if statement.

Done.

Powered by Google App Engine
This is Rietveld 408576698