-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3003] Allow mathematical expressions in image sizes #3084
Conversation
Thank you! We'll also need to update https://html.spec.whatwg.org/#parsing-a-sizes-attribute. (I wonder how that algorithm works, when is the value computed? It seems that with And we'll need additional test coverage over at https://github.com/w3c/web-platform-tests. |
@annevk Ah, you're right, I missed that reference to |
Thank you! I hope @zcorpan or @tabatkins can help out with the parsing question. I don't really know how this is supposed to work unfortunately. |
The entry points to parsing which is invoked from https://html.spec.whatwg.org/multipage/images.html#select-an-image-source which is invoked from The
https://html.spec.whatwg.org/multipage/images.html#source-size-2 ("the same as in Media Queries" means that font-relative units use initial values, so However, a mathematical function could evaluate differently each time |
source
Outdated
@@ -26775,7 +26777,7 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...</pre> | |||
<dfn><source-size-value></dfn> = <span><length></span></pre> | |||
|
|||
<p>A <span><source-size-value></span> must not be negative, and must not use CSS functions | |||
other than the <span>'calc()'</span> function.</p> | |||
other than the mathematical functions <span>'calc()'</span>, <span>'min()'</span>, and <span>'max()'</span>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to cross-reference "mathematical functions" and not limit to these 3 -- if CSS adds more mathematical functions, they should work here as well.
other than the <span>mathematical functions</span> (such as <span>'calc()'</span>,
<span>'min()'</span>, and <span>'max()'</span>).</p>
source
Outdated
@@ -27929,7 +27931,7 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...</pre> | |||
is a valid non-negative <span><source-size-value></span>, | |||
let <var>size</var> be its value | |||
and remove the <span>component value</span> from <var>unparsed size</var>. | |||
Any CSS function other than the <span>'calc()'</span> function is invalid. | |||
Any CSS function other than the mathematical functions <span>'calc()'</span>, <span>'min()'</span>, and <span>'max()'</span> is invalid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just cross-reference mathematical functions here without listing what they are.
The relevant test is /html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute.html |
Mathematical functions should probably not have single quotes around it? |
@annevk indeed. |
source
Outdated
@@ -3700,7 +3700,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute | |||
<li>The <dfn data-x-href="https://drafts.csswg.org/css-values/#in">'in'</dfn> unit</li> | |||
<li>The <dfn data-x-href="https://drafts.csswg.org/css-values/#px">'px'</dfn> unit</li> | |||
<li>The <dfn data-x-href="https://drafts.csswg.org/css-values/#funcdef-attr">'attr()'</dfn> function</li> | |||
<li>The <dfn data-x-href="https://drafts.csswg.org/css-values/#funcdef-calc">'calc()'</dfn> function</li> | |||
<li>The <dfn data-x-href="https://drafts.csswg.org/css-values/#calc-notation">'mathematical functions'</dfn></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should call this "math functions" and link to https://drafts.csswg.org/css-values/#math-functions.
Thanks @sideshowbarker... ugh, so many dumb mistakes on my part: |
@zcorpan I had a question about the W3C test, should I open an issue there instead? |
@musgravejw up to you. You should feel free to ask questions here about tests as well. Note that per https://whatwg.org/working-mode#changes we'll wait for the tests before merging. |
Test suite is throwing an exception for me, I have opened an issue in the web-platform-tests repo, and will update as soon as I can get it resolved. |
Hi @musgravejw, Mind if I try working on the tests? |
@gloverdonovan Not at all, that would be really helpful actually. Sorry I didn't mean to leave this hanging, I have been meaning to wrap it up as soon as I had some bandwidth. Thank you. |
How's it going @gloverdonovan ? |
Honestly forgot about this issue. I don't think I can dedicate the time to figure out how to write the tests. If anyone else can do it that'd be great. |
Modify attribute parsing
I rebased this PR (because I couldn't build without linting errors in the current state) and fixed the CSSWG link (the link seems to be singular and not plural). For right now, seems like the next step is to have @musgravejw sign the participant agreement (https://participate.whatwg.org/agreement) as an individual. I'll take a look at some tests for this. |
I've added web-platform-tests/wpt#10167 which should suffice for testing this change. |
Great, thanks all! So the one thing still lacking is browser bugs. https://github.com/whatwg/meta/blob/master/MAINTAINERS.md#handling-pull-requests has links for each browser's bug database if someone would like to take that on. Please paste the resulting bugs URLs here. |
I've filed https://crbug.com/825895 for Chromium, @musgravejw how do you feel about taking some of the others? That Chromium issue should be a good template to follow :) |
Thanks again all, the change is now official! 🎂 If anyone is interested in more, #3093 might be a nice follow-up to fix. |
…<img sizes="">, a=testonly Automatic update from web-platform-testsAdd tests for mathematical functions in <img sizes=""> Tests for whatwg/html#3084. wpt-commits: cc9648dde51ca42dfa40d1ff05c017dd3966929f wpt-pr: 10167 wpt-commits: cc9648dde51ca42dfa40d1ff05c017dd3966929f wpt-pr: 10167
…<img sizes="">, a=testonly Automatic update from web-platform-testsAdd tests for mathematical functions in <img sizes=""> Tests for whatwg/html#3084. wpt-commits: cc9648dde51ca42dfa40d1ff05c017dd3966929f wpt-pr: 10167 wpt-commits: cc9648dde51ca42dfa40d1ff05c017dd3966929f wpt-pr: 10167 UltraBlame original commit: 38df35b53e6b8c3fb67629a873c98401edb1492f
…<img sizes="">, a=testonly Automatic update from web-platform-testsAdd tests for mathematical functions in <img sizes=""> Tests for whatwg/html#3084. wpt-commits: cc9648dde51ca42dfa40d1ff05c017dd3966929f wpt-pr: 10167 wpt-commits: cc9648dde51ca42dfa40d1ff05c017dd3966929f wpt-pr: 10167 UltraBlame original commit: 38df35b53e6b8c3fb67629a873c98401edb1492f
…<img sizes="">, a=testonly Automatic update from web-platform-testsAdd tests for mathematical functions in <img sizes=""> Tests for whatwg/html#3084. wpt-commits: cc9648dde51ca42dfa40d1ff05c017dd3966929f wpt-pr: 10167 wpt-commits: cc9648dde51ca42dfa40d1ff05c017dd3966929f wpt-pr: 10167 UltraBlame original commit: 38df35b53e6b8c3fb67629a873c98401edb1492f
This PR attempts to clarify that mathematical functions "min()" and "max()" can also be used as a valid arguments for source-size-value in Image size attributes.
#3003
https://drafts.csswg.org/css-values/#math-functions
/images.html ( diff )
/infrastructure.html ( diff )