Bug 28868 - [HTML5][Forms] :valid/:invalid/:optional/:required CSS selectors should be applied lively
Summary: [HTML5][Forms] :valid/:invalid/:optional/:required CSS selectors should be ap...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://www.whatwg.org/specs/web-apps/...
Keywords:
Depends on:
Blocks: HTML5Forms 28649 29071
  Show dependency treegraph
 
Reported: 2009-09-01 02:56 PDT by Kent Tamura
Modified: 2009-10-05 11:23 PDT (History)
5 users (show)

See Also:


Attachments
Proposed patch (22.46 KB, patch)
2009-09-01 03:03 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Proposed patch (rev.2) (22.11 KB, patch)
2009-09-01 03:24 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Proposed patch (rev.3) (21.41 KB, patch)
2009-09-07 20:30 PDT, Kent Tamura
eric: commit-queue-
Details | Formatted Diff | Diff
Proposed patch (rev.4) (23.33 KB, patch)
2009-09-23 16:39 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Proposed patch (rev.5) (23.12 KB, patch)
2009-09-27 21:53 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Proposed patch (rev.6) (21.96 KB, patch)
2009-10-01 06:42 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Proposed patch (rev.7) (22.15 KB, patch)
2009-10-01 17:42 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Tamura 2009-09-01 02:56:13 PDT
:valid, :invalid, :optional and :required CSS selectors should be applied immediately when an element's
  * value,
  * constraints, or
  * willValidate
state is changed.  In the current WebKit, some of them apply selectors immediately and some of them don't.
Comment 1 Kent Tamura 2009-09-01 03:03:51 PDT
Created attachment 38853 [details]
Proposed patch
Comment 2 Kent Tamura 2009-09-01 03:24:28 PDT
Created attachment 38854 [details]
Proposed patch (rev.2)
Comment 3 Eric Seidel (no email) 2009-09-01 07:47:47 PDT
Comment on attachment 38854 [details]
Proposed patch (rev.2)

I probably would have used a function to make the test output more readable:
+PASS document.defaultView.getComputedStyle(el, null).getPropertyValue("background-color") is "rgb(255, 0, 0)"

function backgroundOf(el)
{
    return document.defaultView.getComputedStyle(el, null).getPropertyValue("background-color");
}

PASS backgroundOf(el) is "rgb(255, 0, 0)"

or maybe even:

PASS backgroundOf(el) is "red"

Slightly sad to see custom edited html files instead of just using .js files and the standard TEMPLATE.html, but these are fine. :)

Those comments above are just nits, not requiring any change.  I'd need to stare at the c++ part of this more to make a real review decision...
Comment 4 Kent Tamura 2009-09-07 20:30:36 PDT
Created attachment 39168 [details]
Proposed patch (rev.3)

Follows the Eric's advice.
 - Separate test HTMLs and JavaScript code
 - Visible text changes in the tests
Comment 5 Kent Tamura 2009-09-21 09:28:27 PDT
Note that we don"t need to update the patch rev.3 for the resoruces -> script-tests change because the tests uses not only .js but also .css.
Comment 6 Eric Seidel (no email) 2009-09-23 10:45:27 PDT
Comment on attachment 39168 [details]
Proposed patch (rev.3)

Looks fine to me.  Sad this has been sitting in the queue for 2 weeks w/o comment. :(

50     if (textArea->willValidate())
 51         // Need to sync the value in order to apply :valid/:invalid selectors.
 52         textArea->updateValue();

Needs {} since the comment makes it multi-line.  There are 2 instances of that.

If updateValue() isn't const anymore, why is this const_cast needed?
 297     const_cast<HTMLTextAreaElement*>(this)->updateValue();

I'm not sure I'm the best person to review this change, but the others have been silent.  It looks OK to me and looks non-harmful.  I'll r+ it, but it can't be auto-committed as is, so you'll have to commit this yourself, find someone to commit it, or post a new patch with modifications for the commit-queue.
Comment 7 Kent Tamura 2009-09-23 16:39:55 PDT
Created attachment 40029 [details]
Proposed patch (rev.4)


> Needs {} since the comment makes it multi-line.  There are 2 instances of that.

Fixed 2 instances, and removed {} for single statement at another place.

> If updateValue() isn't const anymore, why is this const_cast needed?
>  297     const_cast<HTMLTextAreaElement*>(this)->updateValue();

In order to nuke "const" of "this".  This method is const and updateValue() is not const.
Comment 8 Kent Tamura 2009-09-27 21:53:22 PDT
Created attachment 40215 [details]
Proposed patch (rev.5)

Resolved a patch conflict with today's WebKit source.
Comment 9 Kent Tamura 2009-10-01 06:42:21 PDT
Created attachment 40439 [details]
Proposed patch (rev.6)

- Resolved a conflict with r48959.
- Added more explanation to ChangeLog.
Comment 10 Kent Tamura 2009-10-01 17:42:52 PDT
Created attachment 40487 [details]
Proposed patch (rev.7)

Oops, ChangeLog in the previous patch was old.
Comment 11 Eric Seidel (no email) 2009-10-05 10:59:34 PDT
Comment on attachment 39168 [details]
Proposed patch (rev.3)

Clearing r+ on this obsolete patch.
Comment 12 Eric Seidel (no email) 2009-10-05 11:00:59 PDT
Comment on attachment 40487 [details]
Proposed patch (rev.7)

Looks OK.
Comment 13 WebKit Commit Bot 2009-10-05 11:23:31 PDT
Comment on attachment 40487 [details]
Proposed patch (rev.7)

Clearing flags on attachment: 40487

Committed r49105: <http://trac.webkit.org/changeset/49105>
Comment 14 WebKit Commit Bot 2009-10-05 11:23:35 PDT
All reviewed patches have been landed.  Closing bug.