WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
229786
Implement abs,sign calc functions
https://bugs.webkit.org/show_bug.cgi?id=229786
Summary
Implement abs,sign calc functions
Nikos Mouchtaris
Reported
2021-09-01 17:57:47 PDT
Implement abs,sign calc functions
Attachments
Patch
(13.55 KB, patch)
2021-09-01 17:58 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Patch
(30.94 KB, patch)
2021-09-14 14:06 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Patch
(31.11 KB, patch)
2021-09-15 17:19 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Patch
(31.15 KB, patch)
2021-09-17 18:31 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Patch
(58.41 KB, patch)
2021-09-20 14:50 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Patch
(45.62 KB, patch)
2021-09-21 14:35 PDT
,
Nikos Mouchtaris
simon.fraser
: review+
Details
Formatted Diff
Diff
abs/sign functions
(45.35 KB, patch)
2021-09-23 17:57 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
abs/sign functions
(42.81 KB, patch)
2021-09-24 11:10 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Nikos Mouchtaris
Comment 1
2021-09-01 17:58:06 PDT
Created
attachment 437098
[details]
Patch
Jon Lee
Comment 2
2021-09-07 13:49:04 PDT
rdar://82268535
Nikos Mouchtaris
Comment 3
2021-09-14 14:06:51 PDT
Created
attachment 438167
[details]
Patch
EWS Watchlist
Comment 4
2021-09-14 14:07:52 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see
https://trac.webkit.org/wiki/WPTExportProcess
Nikos Mouchtaris
Comment 5
2021-09-15 17:19:37 PDT
Created
attachment 438306
[details]
Patch
Nikos Mouchtaris
Comment 6
2021-09-17 18:31:57 PDT
Created
attachment 438540
[details]
Patch
Simon Fraser (smfr)
Comment 7
2021-09-17 19:20:01 PDT
Comment on
attachment 438540
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=438540&action=review
> Source/WebCore/ChangeLog:14 > + Added support for calc functions sign and abs. Involved adding new css keywords and handling > + for parsing calc expression and computing the resulting value. Spec for these functions: > +
https://drafts.csswg.org/css-values-4/#sign-funcs
.
This paragraph should go above the Tests line.
> Source/WebCore/css/calc/CSSCalcExpressionNodeParser.cpp:198 > // TODO: clamp, sin, cos, tan, asin, acos, atan, atan2, pow, sqrt, hypot
This list is no longer correct.
> Source/WebCore/css/calc/CSSCalcOperationNode.cpp:466 > + if (calcOperator() == CalcOperator::Sign) > + combinedUnitType = CSSUnitType::CSS_NUMBER;
The spec says "The abs(A) function contains one calculation A, and returns the absolute value of A, as the same type as the input" so I'm not sure this is right.
> Source/WebCore/css/calc/CSSCalcOperationNode.cpp:1108 > + if (children.size() != 1) > + return std::numeric_limits<double>::quiet_NaN(); > + if (children[0] > 0) > + return 1; > + if (children[0] < 0) > + return -1; > + return children[0];
Does this work for -0?
> Source/WebCore/platform/calc/CalcExpressionOperation.cpp:117 > + if (m_children.size() != 1) > + return std::numeric_limits<double>::quiet_NaN(); > + if (m_children[0]->evaluate(maxValue) > 0) > + return 1; > + if (m_children[0]->evaluate(maxValue) < 0) > + return -1; > + return m_children[0]->evaluate(maxValue);
Same question about -0
> LayoutTests/imported/w3c/web-platform-tests/css/css-values/signs-abs-computed.html:15 > +test_math_used('sign(-1)', '-1', {type:'number', approx:0.1});
Test with -0
> LayoutTests/imported/w3c/web-platform-tests/css/css-values/signs-abs-computed.html:31 > +test_math_used('calc(sign(0))', '0', {type:'number', approx:0.1});
Need to also test with inputs that are lengths, angles etc to test the "as the same type as the input" part.
Nikos Mouchtaris
Comment 8
2021-09-20 14:50:40 PDT
Created
attachment 438733
[details]
Patch
Nikos Mouchtaris
Comment 9
2021-09-21 14:35:32 PDT
Created
attachment 438860
[details]
Patch
Nikos Mouchtaris
Comment 10
2021-09-23 17:57:47 PDT
Created
attachment 439112
[details]
abs/sign functions
Nikos Mouchtaris
Comment 11
2021-09-24 11:10:14 PDT
Created
attachment 439169
[details]
abs/sign functions
EWS
Comment 12
2021-09-24 15:35:09 PDT
Committed
r283063
(
242121@main
): <
https://commits.webkit.org/242121@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 439169
[details]
.
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