Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 02cc0941250b2e56725a417c2a1bf8a7fc4e533e
      
https://github.com/WebKit/WebKit/commit/02cc0941250b2e56725a417c2a1bf8a7fc4e533e
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-10-13 (Tue, 13 Oct 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/typed-arithmetic-negated-product-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/typed-arithmetic-negated-product.html
    M Source/WebCore/css/calc/CSSCalcTree+Simplification.cpp

  Log Message:
  -----------
  calc() negation of a typed-arithmetic product flips the sign of every factor
https://bugs.webkit.org/show_bug.cgi?id=327205
rdar://189779826

Reviewed by Sam Weinig.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

When a Negate node's child is a Product whose children are all numeric,
simplify(Negate&) negated every child of the product. That is only
correct when the product has an odd number of factors, since
-(a * b) = (-a) * b, not (-a) * (-b). With typed arithmetic, a product
such as `2px * 3px` (type length^2) cannot be resolved on its own and so
survives simplification. Subtracting it then produced the wrong sign:
`calc((0px * 0px - 2px * 3px) / 1px)` resolved to 6px instead of -6px.

Negate only the first factor of the product instead.

Test: 
imported/w3c/web-platform-tests/css/css-values/typed-arithmetic-negated-product.html

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/typed-arithmetic-negated-product-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/typed-arithmetic-negated-product.html:
 Added.
* Source/WebCore/css/calc/CSSCalcTree+Simplification.cpp:
(WebCore::CSSCalc::simplify):

Canonical link: https://commits.webkit.org/323577@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to