WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
156558
:in-range & :out-of-range CSS pseudo-classes shouldn't match inputs without range limitations
https://bugs.webkit.org/show_bug.cgi?id=156558
Summary
:in-range & :out-of-range CSS pseudo-classes shouldn't match inputs without r...
Chris Rebert
Reported
2016-04-13 15:09:39 PDT
Created
attachment 276361
[details]
Testcase demonstrating the bug Steps to reproduce the problem: 1. Open the attached testcase in WebKit Nightly on OS X or in iOS 9.3 Safari. 2. Observe the background-colors and borders of the <input>s What is the expected behavior? The inputs should have neither a red border nor a red background-color, because they don't have range limitations (
https://html.spec.whatwg.org/multipage/forms.html#have-range-limitations
), because they have neither `min` nor `max` attributes and the HTML spec doesn't define a default minimum or maximum for any of these input types. Therefore, these inputs should fail the 2nd of the 3 conditions required to match :in-range or :out-of-range . Per
https://html.spec.whatwg.org/multipage/scripting.html#selector-in-range
> The :in-range pseudo-class must match all elements that are [...], have range limitations, and [...]
What went wrong? The inputs have red borders and/or red backgrounds, indicating that they matched the :in-range or :out-of-range pseudo-classes despite not having range limitations.
Attachments
Testcase demonstrating the bug
(674 bytes, text/html)
2016-04-13 15:09 PDT
,
Chris Rebert
no flags
Details
Screenshot of testcase on iOS
(55.02 KB, image/png)
2016-04-13 15:14 PDT
,
Chris Rebert
no flags
Details
Patch
(44.09 KB, patch)
2016-06-15 17:12 PDT
,
Benjamin Poulain
no flags
Details
Formatted Diff
Diff
Patch
(45.10 KB, patch)
2016-06-15 19:01 PDT
,
Benjamin Poulain
no flags
Details
Formatted Diff
Diff
Patch for landing
(45.39 KB, patch)
2016-06-16 15:25 PDT
,
Benjamin Poulain
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Chris Rebert
Comment 1
2016-04-13 15:14:00 PDT
Created
attachment 276362
[details]
Screenshot of testcase on iOS
Benjamin Poulain
Comment 2
2016-06-15 17:12:32 PDT
Created
attachment 281406
[details]
Patch
Benjamin Poulain
Comment 3
2016-06-15 19:01:49 PDT
Created
attachment 281423
[details]
Patch
Simon Fraser (smfr)
Comment 4
2016-06-16 14:21:57 PDT
Comment on
attachment 281423
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=281423&action=review
> Source/WebCore/html/InputType.cpp:343 > + return false;
Shouldn't this return true? If the input has no range limitations, aren't you aways in-range?
> Source/WebCore/html/NumberInputType.cpp:170 > + const AtomicString& minAttribute = element.fastGetAttribute(minAttr); > + Decimal minimumFromAttribute = parseToNumberOrNaN(minAttribute); > + if (minimumFromAttribute.isFinite()) { > + hasRangeLimitations = true; > + minimum = minimumFromAttribute; > + }
I think this could go into a separate function or lambda and be shared.
> Source/WebCore/html/StepRange.h:74 > + StepRange(const Decimal& stepBase, bool hasRangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription&);
Please make an enum for hasRangeLimitations. The call sites are unreadable with this change.
Benjamin Poulain
Comment 5
2016-06-16 14:34:33 PDT
(In reply to
comment #4
)
> View in context: >
https://bugs.webkit.org/attachment.cgi?id=281423&action=review
> > > Source/WebCore/html/InputType.cpp:343 > > + return false; > > Shouldn't this return true? If the input has no range limitations, aren't > you aways in-range?
The way the spec defines it, you are only in range if there is a valid range to begin with. In this case, since you have no range or and invalid range, you are not in-range.
Benjamin Poulain
Comment 6
2016-06-16 15:25:50 PDT
Created
attachment 281480
[details]
Patch for landing
WebKit Commit Bot
Comment 7
2016-06-16 15:47:03 PDT
Comment on
attachment 281480
[details]
Patch for landing Clearing flags on attachment: 281480 Committed
r202143
: <
http://trac.webkit.org/changeset/202143
>
WebKit Commit Bot
Comment 8
2016-06-16 15:47:07 PDT
All reviewed patches have been landed. Closing bug.
Chris Rebert
Comment 9
2016-06-16 16:05:31 PDT
Wonderful! I look forward to the next Tech Preview release so that I can update
http://caniuse.com/#feat=css-in-out-of-range
to reflect this fix.
Benjamin Poulain
Comment 10
2016-06-16 16:12:11 PDT
(In reply to
comment #9
)
> Wonderful! I look forward to the next Tech Preview release so that I can > update
http://caniuse.com/#feat=css-in-out-of-range
to reflect this fix.
Your bug report was really high quality. Thanks a lot for taking the time to write a test case and highlight the relevant spec.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug