-
Notifications
You must be signed in to change notification settings - Fork 715
[css-values] Quirky lengths and math expressions #4874
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
Comments
cc @smfr too :) |
Also, note that I really think that Firefox's behavior is more desirable for the "regular length in quirks mode case". I think the "svg-originated property" case is a bit more debatable, but I still think it's better. |
Huge +1 on this. Quirks mode was designed for backwards compatibility for features that pre-dated 1998. It was never intended to propagate into anything new. All new features should be standards mode only. |
We already have agreement that inside a calc expression, numbers are always treated as numbers, not lengths. So a The question is, if the final evaluated result is a number (
For SVG 2, we have two rules for this:
|
I think what Firefox implements is basically this, but with |
My understanding of this is a little different. For non-quirks mode:
This describes the behaviour of Firefox, Webkit etc. for attributes like width, x, r etc. If quirks mode allows length properties to be parsed without units in CSS, then I think that really needs to apply to all length properties - regardless of which specification they're defined in. So What this means for "calc" I don't know. Personally I completely agree with @plinss on this, it should be invalid. You can't evolve quirks mode to keep up with changes in the specification. But, if the decision is made that Additional point, very specific to SVG2. This states all presentation attributes are parsed using the grammar and types defined in CSS, modified so that wherever |
Firefox has the correct behavior. Quirky lengths aren't any different from unitless zeros - inside a calc(), they're a "number", and the type-checking rules don't allow numbers to be added to non-numbers, etc. Both Blink and WebKit are wrong, and wrong in bizarre and clearly incorrect ways. Amelia is right that properties which are defined with an explicit |
Again, for SVG there are two different sets of behavior: properties like I agree that it makes sense to harmonize the second case with other quirky CSS parsing. We can change the SVG spec to link to wherever in CSS that's defined, and just say that SVG presentation attributes use quirky parsing. But That seems to be how it works in Chromium: numbers and calc resulting in numbers are both fine in the stroke properties, regardless of attributes or style declarations. Firefox is inconsistent with the spec by only allowing literal numbers. But again, they support it in both style properties and attributes. Test case Meanwhile, for |
My error, I'd missed that
Unfortunately each of these is also defined in css-fill-stroke-3 as taking a |
This is strictly not about quirkiness in Blink, it is about incorrectly allowing calc expressions which mix percentages and numbers, lengths and numbers, and all three of lengths, percentages and numbers. I have a CL up for review in Blink (which still accepts calc() for <number> which should be per spec): https://chromium-review.googlesource.com/c/chromium/src/+/2134251/ |
We allowed calc expressions combining numbers and lengths, numbers and percentages, and even a combination of numbers, percentages, and lengths. None of those are allowed per the CSS Values and Units spec, and it made it possible to combine user units, lengths, and percentages into the same calc() for certain SVG CSS properties and attributes. See also: w3c/csswg-drafts#4874 This improves SVG interop with Firefox. Firefox does not support calc() for numbers, though. Bug: 1061714 Change-Id: I9e5c492122242e51064310a40e28a233530e357c
We allowed calc expressions combining numbers and lengths, numbers and percentages, and even a combination of numbers, percentages, and lengths. None of those are allowed per the CSS Values and Units spec, and it made it possible to combine user units, lengths, and percentages into the same calc() for certain SVG CSS properties and attributes. See also: w3c/csswg-drafts#4874 This improves SVG interop with Firefox. Firefox does not support calc() for numbers, though. Bug: 1061714 Change-Id: I9e5c492122242e51064310a40e28a233530e357c
We allowed calc expressions combining numbers and lengths, numbers and percentages, and even a combination of numbers, percentages, and lengths. None of those are allowed per the CSS Values and Units spec, and it made it possible to combine user units, lengths, and percentages into the same calc() for certain SVG CSS properties and attributes. See also: w3c/csswg-drafts#4874 This improves SVG interop with Firefox. Firefox does not support calc() for numbers, though. Bug: 1061714 Change-Id: I9e5c492122242e51064310a40e28a233530e357c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134251 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/master@{#756226}
We allowed calc expressions combining numbers and lengths, numbers and percentages, and even a combination of numbers, percentages, and lengths. None of those are allowed per the CSS Values and Units spec, and it made it possible to combine user units, lengths, and percentages into the same calc() for certain SVG CSS properties and attributes. See also: w3c/csswg-drafts#4874 This improves SVG interop with Firefox. Firefox does not support calc() for numbers, though. Bug: 1061714 Change-Id: I9e5c492122242e51064310a40e28a233530e357c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134251 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/master@{#756226}
We allowed calc expressions combining numbers and lengths, numbers and percentages, and even a combination of numbers, percentages, and lengths. None of those are allowed per the CSS Values and Units spec, and it made it possible to combine user units, lengths, and percentages into the same calc() for certain SVG CSS properties and attributes. See also: w3c/csswg-drafts#4874 This improves SVG interop with Firefox. Firefox does not support calc() for numbers, though. Bug: 1061714 Change-Id: I9e5c492122242e51064310a40e28a233530e357c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134251 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/master@{#756226}
…ec., a=testonly Automatic update from web-platform-tests Only allow calc() combinations as per spec. We allowed calc expressions combining numbers and lengths, numbers and percentages, and even a combination of numbers, percentages, and lengths. None of those are allowed per the CSS Values and Units spec, and it made it possible to combine user units, lengths, and percentages into the same calc() for certain SVG CSS properties and attributes. See also: w3c/csswg-drafts#4874 This improves SVG interop with Firefox. Firefox does not support calc() for numbers, though. Bug: 1061714 Change-Id: I9e5c492122242e51064310a40e28a233530e357c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134251 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/master@{#756226} -- wpt-commits: 2e5ea4313ba76d4d0c66c4798ed25a288ddee254 wpt-pr: 22677
…ec., a=testonly Automatic update from web-platform-tests Only allow calc() combinations as per spec. We allowed calc expressions combining numbers and lengths, numbers and percentages, and even a combination of numbers, percentages, and lengths. None of those are allowed per the CSS Values and Units spec, and it made it possible to combine user units, lengths, and percentages into the same calc() for certain SVG CSS properties and attributes. See also: w3c/csswg-drafts#4874 This improves SVG interop with Firefox. Firefox does not support calc() for numbers, though. Bug: 1061714 Change-Id: I9e5c492122242e51064310a40e28a233530e357c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134251 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/master@{#756226} -- wpt-commits: 2e5ea4313ba76d4d0c66c4798ed25a288ddee254 wpt-pr: 22677
The CSS Working Group just discussed
The full IRC log of that discussion<dael> Topic: [css-values] Quirky lengths and math expressions<dael> github: https://github.com//issues/4874 <dael> emilio: This is when should SVG and quirks accept numbers and when shouldn't <dael> emilio: I think quirks mode shouldn't accept calc but SVG is more debatable. <dael> emilio: Haven't checked issue today so don't know if there's new comments there <dael> astearns: One comment from rune where he links to change list for review on Blink <dael> dbaron: I what emilio is asking is the quirks mode rules that you can omit pixels not apply iside of calc <dael> TabAtkins: That's what I feel should be happening <dael> TabAtkins: Effect of quirks mode is these prop are defined to take number as final value and it's interp as pixel. Has no effect on calc b/c doesn't allow 1 + 3px. If your calc ends up as a number it works out. <dael> TabAtkins: That's what some of the SVG properties do explicitly. If we define quirks as same thing it's a nice consistant system <dael> emilio: Seems to be Peter said he didn't want it to work. A number inside quirks not to work. I'm ambivelent. <dael> florian: Logic is quirks was meant to be limited. This is logical extension, yes, but quirks was meant to be as limited as possible. <dael> AmeliaBR: One complication is as we moved to typedOM and exposing the true computed value not just resolved value things could get a lot messier if we need to keep track of numbers instead of lengths <dael> emilio: I don't think any engine will struggle. Final number interp as a length <dael> emilio: I don't know but I suspect fancy calc rules would require keep track but no one impl. You need math there. Calc that resolves to number you can get final at parse. <dael> TabAtkins: NOt true with the later stuff <dael> TabAtkins: Re-reading comments. Looks like you suggest quirks accepts number token as the value. So write a literal number but not any expression. No calc, attr, etc <dael> TabAtkins: That's fine with me. Would like consistent with SVG but since they didn't originally accept calc I suspect could change <dael> AmeliaBR: SVG presentation attributes where they accept values allowed in regular CSS> Could define presentation attributes are quirky <dael> TabAtkins: Or jsut number token in grammar. Yeah <dael> emilio: sgtm. Happy they're consistent <dael> astearns: Prop: In quirks mode properties don't accept calc <dael> TabAtkins: IN quirks mode properties that need to be quirky will spec to take a number token and interp as pixels <dael> AmeliaBR: Spec when fixup happens? How it effect serialization/computing? <dael> TabAtkins: Don't know today <dael> emilio: I think all serialize pixels. <dael> AmeliaBR: I believet hat's true <dael> emilio: Almost sure webkit and FF do that <dael> astearns: I don't expect the resoltution effects serialization <dael> TabAtkins: I could. Have to say when converts to length <dael> plinss: Should be parse time. Quirks should be as limited as possible and was designed to be phased out. Minimal impact and just at parse time. <dael> TabAtkins: Fine with me <fantasai> +1 to plinss <dael> astearns: Prop: In quirks mode properties that are quirky will be able to take a number token which is interpreted as pixels <dael> emilio: And so should SVG <TabAtkins> Confirmed that Blink converts number to px at parse time. <dael> TabAtkins: Different serialization rules, but otherwise yes <dbaron> and the point is that "can take a number token" doesn't apply any quirks *inside* of calc() <dael> AmeliaBR: Not sure how much we need. attribute value will get attribute. CSS serialization can sync <dael> emilio: We return pixels in specified side <dael> astearns: All one thing to resolve on? Or are there 3 bits to resolve separately? <TabAtkins> proposed resolution: Properties that accept "quirky lengths" are defined as having `<number-token>` in their grammar, which is converted at parse-time to a px length. SVG follows along for its presentation attributes. <dael> emilio: I think...browsers do not agree on quirky SVG so at least 2 resolutions <dael> astearns: Prop: Properties that accept quirky lengths accept number token which is converted at parse to pixels <dael> RESOLVED: Properties that accept quirky lengths accept number token which is converted at parse to pixels <dael> astearns: Second: This resolution does not apply to any quirks inside of calc <fantasai> +1 <fantasai> make it clear <dael> emilio: I think that's implied. <dael> astearns: I'd like to specifically resolve to make it clear <dael> TabAtkins: sure <dael> RESOLVED: This resolution does not apply to any quirks inside of calc <dael> astearns: Browser incompat and presentation attributes following along. Can we resolve? <dael> emilio: I've never heard of any compat issues <dael> AmeliaBR: Don't expect issue on compat, but I have to open a separate issue on SVG so we can resolve CSS endorces this and we can add details on SVG <dael> astearns: Prop: encourage SVG to follow this approach <dael> RESOLVED: encourage SVG to follow this approach |
…n parsing, but functions resolving to numbers might be okay due to quirks. #4874
According to [this resolution](w3c/csswg-drafts#4874), Firefox and Safari now need the `stroke-dasharray` values to use units, so adding pixels. Unfortunatelly, css variables don't work in animation `keyframes` on Safari so don't have any other choice than make all the calculation in scss instead. The `total-length` will have to be calculated separately and set staticaly.
…ec., a=testonly Automatic update from web-platform-tests Only allow calc() combinations as per spec. We allowed calc expressions combining numbers and lengths, numbers and percentages, and even a combination of numbers, percentages, and lengths. None of those are allowed per the CSS Values and Units spec, and it made it possible to combine user units, lengths, and percentages into the same calc() for certain SVG CSS properties and attributes. See also: w3c/csswg-drafts#4874 This improves SVG interop with Firefox. Firefox does not support calc() for numbers, though. Bug: 1061714 Change-Id: I9e5c492122242e51064310a40e28a233530e357c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134251 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/master@{#756226} -- wpt-commits: 2e5ea4313ba76d4d0c66c4798ed25a288ddee254 wpt-pr: 22677
Quirks mode allows to specify lengths without units, so do some SVG properties like
stroke-width
. However, when you mix this with calc() units, stuff gets complex very fast (calc()
becomes ambiguous) and the results across browsers become a bit bizarre.Trivial example (link):
All browsers agree on the computed value of
#b
, being4px
as expected. For#a
, we get:1px
) because the expression doesn't parse (Firefox doesn't propagate this quirk intocalc()
).0px
.2px
.I think having the ambiguity of whether a
<number>
should be treated something is a<length>
or not inside math expressions is not worth it and it's only going to get more complex as we add more math functions. Thus I'd like to standardize on Firefox's behavior, if other people agree.Otherwise we could try to parse / resolve
calc()
both as a<number>
and a<length-percentage>
, I guess, which would allow for the previous example, but would disallow stuff likecalc(4 * 100% + 4)
or such...Relevant links:
cc @tabatkins @lilles @andruud
The text was updated successfully, but these errors were encountered: