-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Mapping to aspect-ratio with zero dimension. #6527
Comments
This is also relevant because some tokens are valid when parsing as non-negative integers but not vice versa, so dimensions aren't always a super-set of what the attribute will parse. |
I'm ambivalent on whether zero should be allowed or not, but we should parse the attributes with the same rules we use for the element (this is relevant for |
So interesting test cases here would be:
Are there any other differences? |
|
I agree that the rules should be the same for the two. But what do you mean with "re-parse"? Whether parsing happens twice is just an implementation issue, right? I'm certainly happy to change the attribute mappings to disallow zero, and to use ParseHTMLNonNegativeInteger for canvas. Or whatever the outcome here is. |
Yeah, true. I generally mean "parsing with different algorithms for different purposes". I don't care about parsing multiple times if the result is the same of course :-)
I don't mind so much about which direction we go in the zero issue, I just noticed it diverged from the spec. But the integer vs. dimension issue I think is worth solving. |
… and <video>. As per https://html.spec.whatwg.org/#attributes-for-embedded-content-and-images: > The width and height attributes map to the aspect-ratio property on > img, canvas, and video elements, and input elements with a type > attribute in the Image Button state. See whatwg/html#6527 for the parsing issue with canvas and zero. For now allow both behaviors in the tests. We also remove the width-and-height-map-to-aspect-ratio pref, as it is true everywhere and has been for a while. Differential Revision: https://phabricator.services.mozilla.com/D109618 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1700640 gecko-commit: 985b66b916980b78328063dfdccdc5e5b71318e5 gecko-reviewers: boris
…t type=image>, and <video>. r=boris As per https://html.spec.whatwg.org/#attributes-for-embedded-content-and-images: > The width and height attributes map to the aspect-ratio property on > img, canvas, and video elements, and input elements with a type > attribute in the Image Button state. See whatwg/html#6527 for the parsing issue with canvas and zero. For now allow both behaviors in the tests. We also remove the width-and-height-map-to-aspect-ratio pref, as it is true everywhere and has been for a while. Differential Revision: https://phabricator.services.mozilla.com/D109618
Okay, so if we want to parse consistently, we'd indeed move to the zero-allowing dimension parser for I can do a PR if that sounds good as I see we already have some tests. |
Yes, I think so. That'd be great. Note that the tests in web-platform-tests/wpt#28229 would need to be adjusted to not have the double expectation, but that's a very simple change. |
Also map <canvas width height> to aspect-ratio consistently with how the attributes are parsed. Tests: web-platform-tests/wpt#28229. Follow-up: #6528. Closes #4961 and closes #6527.
Created #6529. |
… and <video>. As per https://html.spec.whatwg.org/#attributes-for-embedded-content-and-images: > The width and height attributes map to the aspect-ratio property on > img, canvas, and video elements, and input elements with a type > attribute in the Image Button state. See whatwg/html#6527 for the parsing issue with canvas and zero. For now allow both behaviors in the tests. We also remove the width-and-height-map-to-aspect-ratio pref, as it is true everywhere and has been for a while. Differential Revision: https://phabricator.services.mozilla.com/D109618 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1700640 gecko-commit: 985b66b916980b78328063dfdccdc5e5b71318e5 gecko-reviewers: boris
Also map <canvas width height> to aspect-ratio consistently with how the attributes are parsed and clean up some wording. Tests: web-platform-tests/wpt#28229 & web-platform-tests/wpt#28932. Follow-up: #6528. Closes #4961 and closes #6527.
https://html.spec.whatwg.org/#map-to-the-aspect-ratio-property uses https://html.spec.whatwg.org/#rules-for-parsing-non-zero-dimension-values, which means that width=0 or height=0 shouldn't map to aspect-ratio, but that doesn't match Chrome's implementation nor the WPT tests.
Given how this should work in CSS is well defined, and that in #4961 we probably want to use the attributes for
<canvas>
(whose width / height attributes have different parsing rules, https://html.spec.whatwg.org/#rules-for-parsing-non-negative-integers), I suggest the aspect-ratio mapping code should not re-parse the attribute value with different rules.The text was updated successfully, but these errors were encountered: