WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
278852
CSS rounding functions behaves differently in Safari than other browsers
https://bugs.webkit.org/show_bug.cgi?id=278852
Summary
CSS rounding functions behaves differently in Safari than other browsers
Kira
Reported
2024-08-29 03:27:39 PDT
Created
attachment 472343
[details]
Screenshot comparing different behavior in Chrome and Safari Expected behavior: CSS functions round(), rem(), mod() take css variables and calculate values dynamically. Actual behavior: Calculation fails, value is not applied to the CSS property. Example:
https://codepen.io/chipa014/pen/vYqarRP
Expected behavior: Pink div is translated to the right (Screenshot upper half, Chrome). Actual behavior: Pink div is not translated, staying in the corner (Screenshot lower half, Safari).
Attachments
Screenshot comparing different behavior in Chrome and Safari
(409.65 KB, image/png)
2024-08-29 03:27 PDT
,
Kira
no flags
Details
rendering in safari, firefox, chrome
(382.97 KB, image/png)
2024-09-03 22:32 PDT
,
Karl Dubost
no flags
Details
testcase
(1.15 KB, text/html)
2024-09-04 15:11 PDT
,
Karl Dubost
no flags
Details
rendering in safari, firefox, chrome for testcase
(296.12 KB, image/png)
2024-09-04 15:12 PDT
,
Karl Dubost
no flags
Details
testcase with more cases
(2.68 KB, text/html)
2024-09-04 16:38 PDT
,
Karl Dubost
no flags
Details
rendering in safari, firefox, chrome for testcase with more cases
(283.94 KB, image/png)
2024-09-04 16:39 PDT
,
Karl Dubost
no flags
Details
WebKit ToT Screeenshot
(206.42 KB, image/png)
2024-09-04 16:55 PDT
,
Ahmad Saleem
no flags
Details
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Karl Dubost
Comment 1
2024-09-03 22:32:27 PDT
Created
attachment 472437
[details]
rendering in safari, firefox, chrome Is that fixed? Tested on Safari Technology Preview 202 20620.1.4.8 Firefox Nightly 131.0a1 13124.8.29 Google Chrome Canary 130.0.6696.0 6696.0
Karl Dubost
Comment 2
2024-09-03 22:33:19 PDT
@Kira on which versions of Safari did you test?
Kira
Comment 3
2024-09-04 08:25:15 PDT
(In reply to Karl Dubost from
comment #2
)
> @Kira on which versions of Safari did you test?
I managed to track it down to this: round() function takes optional third argument. In Safari it is not optional, therefore resulting in such behavior. Adding the third argument resolves the issue, but whether no default value is intended behavior or not beats me.
Kira
Comment 4
2024-09-04 08:27:07 PDT
For preservation reasons I've reverted my codepen to non-working state, leaving the solution commented.
Karl Dubost
Comment 5
2024-09-04 15:11:13 PDT
Created
attachment 472452
[details]
testcase The codepen is with the working case.
https://codepen.io/chipa014/pen/vYqarRP
Let's create a local testcase where the behavior is different. :) aka translate: calc(100px * round(var(--offset) / 2));
Karl Dubost
Comment 6
2024-09-04 15:12:20 PDT
Created
attachment 472453
[details]
rendering in safari, firefox, chrome for testcase We can see the difference now.
Karl Dubost
Comment 7
2024-09-04 15:13:26 PDT
Tested in Safari Technology Preview 202 20620.1.4.8 Firefox Nightly 132.0a1 13224.9.4 Google Chrome Canary 130.0.6698.0 6698.0
Karl Dubost
Comment 8
2024-09-04 16:17:25 PDT
For reference The current specification
https://drafts.csswg.org/css-values/#funcdef-round
The round(<rounding-strategy>?, A, B?) function contains an optional rounding strategy, and two calculations A and B, and returns the value of A, rounded according to the rounding strategy, to the nearest integer multiple of B either above or below A. The argument calculations can resolve to any <number>, <dimension>, or <percentage>, but must have a consistent type or else the function is invalid; the result’s type will be the consistent type. one thing I want to rap around my head is what value do you expect from round(var(--offset) / 2)) Maybe we should reason with something different than 1 or 0.
Karl Dubost
Comment 9
2024-09-04 16:38:05 PDT
Created
attachment 472454
[details]
testcase with more cases OK this is not related to variables. :) This is related to the way rounding is done.
Karl Dubost
Comment 10
2024-09-04 16:39:28 PDT
Created
attachment 472455
[details]
rendering in safari, firefox, chrome for testcase with more cases Here you can see it's independent of the variable. I will retitle the bug, maybe there is even already a bug for this.
Radar WebKit Bug Importer
Comment 11
2024-09-04 16:40:05 PDT
<
rdar://problem/135307851
>
Karl Dubost
Comment 12
2024-09-04 16:50:03 PDT
This is
https://wpt.fyi/results/css/css-values/round-function.html?label=master&label=experimental&aligned&q=round%20safari%3Afail
Ahmad Saleem
Comment 13
2024-09-04 16:55:53 PDT
Created
attachment 472456
[details]
WebKit ToT Screeenshot
Ahmad Saleem
Comment 14
2024-09-04 16:57:03 PDT
(In reply to Karl Dubost from
comment #12
)
> This is >
https://wpt.fyi/results/css/css-values/round-function
. > html?label=master&label=experimental&aligned&q=round%20safari%3Afail
WebKit ToT passes all of these tests as well.
Karl Dubost
Comment 15
2024-09-04 17:05:02 PDT
OK Good news. Thanks Ahmad. This was fixed by
https://github.com/WebKit/WebKit/commit/e6902e0483c51982df75abe81235860eae084e35
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug