Skip to content

[css-values-4] Agressively simplifying a Sum node can change the sign of 0 #13919

@cdoublev

Description

@cdoublev

#13069 added the simplification of Sum nodes containing an unresolved value and negate nodes.

For example, 1px - (1em + 1px) is simplified to -1em.

But this simplification can change the sign of zero, like in order: sign((-1 * 0px) - (1em - 1em * sibling-count())). If I am not mistaken, with the new simplification requirement, it simplifies to sign(-0px + -1em + (1em * sibling-count()), which resolves to sign(-0px - 1px + 1px) assuming 1em resolves to 1px and sibling-count() to 1. -0px - 1px + 1px results to 0. On the other hand, if it resolves to sign(-0px - 0px), -0px - 0px results to -0px.

0⁻ + 0⁻ or 0⁻ - 0⁺ produces 0⁻. All other additions or subtractions that would produce a zero produce 0⁺.

Note that signed zeros cannot be written in CSS. At least, they are not supposed to.

Also note that ordering calculation terms can have a similar effect.

edit: (1em - 1em) simplifies to 0em because units are the same, so added sibling-count() into play.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions