Bug 216906

Summary: CSS angle unit conversions should consistently use the same associativity
Product: WebKit Reporter: Keith Miller <keith_miller>
Component: New BugsAssignee: Keith Miller <keith_miller>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, eric.carlson, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, jer.noble, macpherson, menard, mjs, philipj, sergio, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Keith Miller
Reported 2020-09-23 16:21:49 PDT
CSS angle unit conversions should consistently use the same associativity
Attachments
Patch (12.38 KB, patch)
2020-09-23 16:38 PDT, Keith Miller
no flags
Patch (25.97 KB, patch)
2020-09-23 18:55 PDT, Keith Miller
no flags
Patch (21.78 KB, patch)
2020-09-24 09:52 PDT, Keith Miller
no flags
Patch (30.64 KB, patch)
2020-09-24 11:10 PDT, Keith Miller
no flags
Patch for landing (30.78 KB, patch)
2020-09-24 14:57 PDT, Keith Miller
no flags
Keith Miller
Comment 1 2020-09-23 16:38:09 PDT
Keith Miller
Comment 2 2020-09-23 16:39:43 PDT
I'm not 100% sure the image passes are real. If they fail on the bots I'll change them to [ PASS ImageOnlyFailure ] instead.
Maciej Stachowiak
Comment 3 2020-09-23 17:02:02 PDT
Comment on attachment 409516 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=409516&action=review > Source/WebCore/ChangeLog:21 > + This patch changes the WTF functions to operate on a single > + scale factor when converting to/from the canonical > + unit. Conversions between non-canonical units first convert to the > + canonical unit (degree). Also, > + conversionToCanonicalUnitsScaleFactor now gets the scale factor > + from the WTF functions for consistency. Ideally the ChangeLog should explain why this matter. > Source/WTF/wtf/MathExtras.h:103 > +// We compute the scale factor first because it allows us to extract scale factors via these functions. This is important because FP is not associative. e.g. the explanation in this comment would be good in the ChangeLog. > Source/WTF/wtf/MathExtras.h:104 > +inline double deg2rad(double d) { return d * (piDouble / 180.0); } How about extracting the conversion factors into named constants? That would make the comment unnecessary here (there would't be weird parens to explain) and it would avoid the need to call these functions with a 1.0 parameter to generate conversion factors, which seems more awkward than just using conversion factor constants. > Source/WTF/wtf/MathExtras.h:121 > +inline float rad2grad(float r) { return deg2grad(rad2deg(r)); } > +inline float grad2rad(float g) { return deg2rad(grad2deg(g)); } I guess this is right for CSS, but is it right for all uses of these math functions? > Source/WebCore/css/CSSPrimitiveValue.cpp:761 > + factor = grad2deg(1.0); As mentioned above, it would be even nicer if this referenced a named constant instead of calling the conversion function with a 1.0 parameter.
Keith Miller
Comment 4 2020-09-23 17:18:31 PDT
Comment on attachment 409516 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=409516&action=review >> Source/WebCore/ChangeLog:21 >> + from the WTF functions for consistency. > > Ideally the ChangeLog should explain why this matter. Sure. >> Source/WTF/wtf/MathExtras.h:103 >> +// We compute the scale factor first because it allows us to extract scale factors via these functions. This is important because FP is not associative. > > e.g. the explanation in this comment would be good in the ChangeLog. Copied. >> Source/WTF/wtf/MathExtras.h:104 >> +inline double deg2rad(double d) { return d * (piDouble / 180.0); } > > How about extracting the conversion factors into named constants? That would make the comment unnecessary here (there would't be weird parens to explain) and it would avoid the need to call these functions with a 1.0 parameter to generate conversion factors, which seems more awkward than just using conversion factor constants. Fair enough. Done. >> Source/WTF/wtf/MathExtras.h:121 >> +inline float grad2rad(float g) { return deg2rad(grad2deg(g)); } > > I guess this is right for CSS, but is it right for all uses of these math functions? The only place using these is in SVG. And changing this does appear to cause a test to pass. >> Source/WebCore/css/CSSPrimitiveValue.cpp:761 >> + factor = grad2deg(1.0); > > As mentioned above, it would be even nicer if this referenced a named constant instead of calling the conversion function with a 1.0 parameter. Sure.
Keith Miller
Comment 5 2020-09-23 18:55:27 PDT
Keith Miller
Comment 6 2020-09-24 09:52:03 PDT
Keith Miller
Comment 7 2020-09-24 11:10:38 PDT
Keith Miller
Comment 8 2020-09-24 11:30:14 PDT
Comment on attachment 409516 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=409516&action=review >>> Source/WTF/wtf/MathExtras.h:121 >>> +inline float grad2rad(float g) { return deg2rad(grad2deg(g)); } >> >> I guess this is right for CSS, but is it right for all uses of these math functions? > > The only place using these is in SVG. And changing this does appear to cause a test to pass. I lied, that appears to have been a flakey pass... :/
Maciej Stachowiak
Comment 9 2020-09-24 13:10:37 PDT
Comment on attachment 409602 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=409602&action=review r=me > LayoutTests/imported/w3c/ChangeLog:13 > + * web-platform-tests/css/css-values/minmax-angle-computed-expected.txt: > + * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-panner-connections-expected.txt: > + * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-panner-expected.txt: > + * web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/panner-automation-basic-expected.txt: You may want to explain that these are either progressions or irrelevant changes. Does one of these tests cover what you are actually fixing? I assume the minmax-angle-computed-expected one?
Keith Miller
Comment 10 2020-09-24 13:14:48 PDT
Comment on attachment 409602 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=409602&action=review >> LayoutTests/imported/w3c/ChangeLog:13 >> + * web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/panner-automation-basic-expected.txt: > > You may want to explain that these are either progressions or irrelevant changes. > > Does one of these tests cover what you are actually fixing? I assume the minmax-angle-computed-expected one? Yeah, the minmax-angle-computed test covers this edge case. Will add that comment, I'll also clarify that the other tests are simply changes to the rounding error of the panner computation.
Keith Miller
Comment 11 2020-09-24 14:57:03 PDT
Created attachment 409623 [details] Patch for landing
EWS
Comment 12 2020-09-24 15:40:12 PDT
Committed r267551: <https://trac.webkit.org/changeset/267551> All reviewed patches have been landed. Closing bug and clearing flags on attachment 409623 [details].
Radar WebKit Bug Importer
Comment 13 2020-09-24 15:41:20 PDT
Note You need to log in before you can comment on or make changes to this bug.