You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Internal representations of math functions are eagerly simplified to the extent possible, using standard algebraic simplifications (distributing multiplication over sums, combining similar units, etc.).
So, the case like calc(2 * (10px - 1rem)) becomes calc(20px - 2rem).
It's not clear to me if we should do the same for when we have functions inside the brackets, like: calc(2 * (min(10px, 10%) + max(1rem, 1%)) should become calc(2 * min(10px, 10%) + 2 * max(1rem, 1%))?
Currently, no browser does calc(2 * min(10px, 10%) + 2 * max(1rem, 1%)) and just leaves the expression as it is.
So, my question is, should we distribute multiplication over sums in case when the parts are math functions?
The text was updated successfully, but these errors were encountered:
danielsakhapov
changed the title
[css-values] Distributing multiplication over sums clarification
[css-values-4] Distributing multiplication over sums clarification
Oct 5, 2023
The spec doesn't do that distribution, currently, because doing so wouldn't meaningfully simplify the expression.
The current rule means that Product(Numeric, Sum(Numeric, Numeric, Numeric)) can be simplified to Sum(Numeric, Numeric, Numeric), which is a noticeable simplification; we remove one level of nesting.
But if there are math functions, like Product(Numeric, Sum(MathFn, MathFn, MathFn)), distributing the multiplication would leave you with Sum(Product(Numeric, MathFn), Product(Numeric, MathFn), Product(Numeric, MathFn)) - it's no simpler, it just inverts the order of the nested functions.
The spec says that
So, the case like
calc(2 * (10px - 1rem))
becomescalc(20px - 2rem)
.It's not clear to me if we should do the same for when we have functions inside the brackets, like:
calc(2 * (min(10px, 10%) + max(1rem, 1%))
should becomecalc(2 * min(10px, 10%) + 2 * max(1rem, 1%))
?Currently, no browser does
calc(2 * min(10px, 10%) + 2 * max(1rem, 1%))
and just leaves the expression as it is.So, my question is, should we distribute multiplication over sums in case when the parts are math functions?
@tabatkins @fantasai
The text was updated successfully, but these errors were encountered: