Bug 195173

Summary: [css-values-3] calc() with out-of-range value must be clamped within range allowed
Product: WebKit Reporter: Gérard Talbot (no longer involved) <browserbugs2>
Component: CSSAssignee: Joonghun Park <jh718.park>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: jh718.park, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar, W3CTest
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
URL: http://w3c-test.org/css/css-values/calc-numbers.html

Description Gérard Talbot (no longer involved) 2019-02-28 11:01:17 PST
CSS4 Values and Units, section 9.1.4. Range Checking
https://www.w3.org/TR/css-values-4/#calc-range
states

"
Parse-time range-checking of values is not performed within math functions, and therefore out-of-range values do not cause the declaration to become invalid. However, the value resulting from an expression must be clamped to the range allowed in the target context. Clamping is performed on computed values to the extent possible, and also on used values if computation was unable to sufficiently simplify the expression to allow range-checking.
"


Test
----

testing tab-size: calc(2 * -4) in
http://w3c-test.org/css/css-values/calc-numbers.html


Expected result
- - - - - - - -
 
document.defaultView.getComputedStyle(elemTarget)["tab-size"] == "0"


Test result
- - - - - -

https://wpt.fyi/results/css/css-values/calc-numbers.html?label=master

{ but got "12345" }

This seems to suggest that Safari 76 preview treats the declaration as invalid instead of performing clamping on computed value.


Epiphany Technological Preview 3.31.90-45-ga15d70306 using WebKitGTK 2.23.3 also fails that test in the same manner.
Comment 1 Gérard Talbot (no longer involved) 2019-02-28 11:04:08 PST
Also in CSS3:

https://www.w3.org/TR/css-values-3/#calc-range

gives

Since widths smaller than 0px are not allowed, these three declarations are equivalent:

width: calc(5px - 10px);
width: calc(-5px);
width: 0px;
Comment 2 Radar WebKit Bug Importer 2019-03-01 20:56:46 PST
<rdar://problem/48532264>
Comment 3 Joonghun Park 2021-09-29 08:33:45 PDT

*** This bug has been marked as a duplicate of bug 204737 ***