WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 229507
Implement sin, cos, tan, e and pi for calc
https://bugs.webkit.org/show_bug.cgi?id=229507
Summary
Implement sin, cos, tan, e and pi for calc
Nikos Mouchtaris
Reported
2021-08-25 11:43:49 PDT
Implement calc math functions
Attachments
Patch
(12.82 KB, patch)
2021-08-25 11:46 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Patch
(15.99 KB, patch)
2021-08-25 17:38 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Patch
(26.49 KB, patch)
2021-08-27 14:18 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Patch
(35.11 KB, patch)
2021-08-31 16:47 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Patch
(35.14 KB, patch)
2021-08-31 16:49 PDT
,
Nikos Mouchtaris
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Nikos Mouchtaris
Comment 1
2021-08-25 11:46:40 PDT
Created
attachment 436406
[details]
Patch
Nikos Mouchtaris
Comment 2
2021-08-25 17:38:08 PDT
Created
attachment 436448
[details]
Patch
Darin Adler
Comment 3
2021-08-26 19:26:51 PDT
Comment on
attachment 436448
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=436448&action=review
> Source/WebCore/css/calc/CSSCalcOperationNode.cpp:-682 > -#if ASSERT_ENABLED > - for (auto& child : m_children) > - ASSERT(child->category() == CalculationCategory::Number); > -#endif
What’s the rationale for removing this assertion? Change log doesn’t say.
> Source/WebCore/platform/calc/CalcExpressionOperation.cpp:31 > -#include <wtf/text/TextStream.h> > +#include "math.h" > > +#include <wtf/text/TextStream.h>
This isn’t correct WebKit style. The includes should been a single paragraph, not two separate ones. No blank line between them. But blank line after them before "namespace". Also, this should be <math.h> or <cmath>, not "math.h". I think we should prefer <cmath>.
> Source/WebCore/platform/calc/CalcExpressionOperation.cpp:95 > + double sinValue = sin(m_children[0]->evaluate(maxValue)); > + return sinValue;
No reason for a local variable here. return std::sin(m_children[0]->evaluate(maxValue));
Nikos Mouchtaris
Comment 4
2021-08-27 14:18:52 PDT
Created
attachment 436674
[details]
Patch
Tim Horton
Comment 5
2021-08-27 14:46:41 PDT
Comment on
attachment 436674
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=436674&action=review
> Source/WebCore/css/calc/CSSCalcExpressionNodeParser.cpp:98 > +static const CSSCalcSymbolTable getConstantTable()
style nit: no `get` because it doesn't have out args (which is the only case where we use the `get` prefix in webkit)
> Source/WebCore/css/calc/CSSCalcExpressionNodeParser.cpp:100 > + return { {CSSValuePi, CSSUnitType::CSS_NUMBER, piDouble}, {CSSValueE, CSSUnitType::CSS_NUMBER, std::exp(1.0)} };
style nit: spaces inside braces
> Source/WebCore/css/calc/CSSCalcOperationNode.cpp:632 > - if (calcOperationNode.children().size() == 1 && depth) > + if (calcOperationNode.children().size() == 1 && !depth)
I wonder if you want to fix this separately with a separate test? Or maybe you said it was previously not observable?
Nikos Mouchtaris
Comment 6
2021-08-27 14:52:33 PDT
Yeah it was not previously observable without the introduction of the one child node functions so I think its fine to fix here.
Myles C. Maxfield
Comment 7
2021-08-27 15:00:18 PDT
Comment on
attachment 436674
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=436674&action=review
> LayoutTests/ChangeLog:12 > + * css3/calc/simple-trig-functions.html: Added.
No tests that test failing parses? like atan(3px)? No tests that test things like tan(pi/2) for infinity?
> LayoutTests/css3/calc/simple-trig-functions.html:71 > + element.innerHTML += " => PASS";
This should be using js-test.js instead.
> LayoutTests/css3/calc/trig-functions-with-constants.html:53 > + element.innerHTML += " => PASS";
Ditto.
Myles C. Maxfield
Comment 8
2021-08-27 15:01:29 PDT
Comment on
attachment 436674
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=436674&action=review
>> LayoutTests/ChangeLog:12 >> + * css3/calc/simple-trig-functions.html: Added. > > No tests that test failing parses? like atan(3px)? > > No tests that test things like tan(pi/2) for infinity?
How about testing animations?
Myles C. Maxfield
Comment 9
2021-08-27 15:02:56 PDT
Comment on
attachment 436674
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=436674&action=review
>> LayoutTests/css3/calc/trig-functions-with-constants.html:53 >> + element.innerHTML += " => PASS"; > > Ditto.
You'll also want to test the CSSOM itself, and getComputedStyle()
Myles C. Maxfield
Comment 10
2021-08-27 16:42:09 PDT
Comment on
attachment 436674
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=436674&action=review
> Source/WebCore/ChangeLog:3 > + Implement calc math functions
Which ones?
Nikos Mouchtaris
Comment 11
2021-08-31 16:47:00 PDT
Created
attachment 436966
[details]
Patch
Nikos Mouchtaris
Comment 12
2021-08-31 16:49:23 PDT
Created
attachment 436967
[details]
Patch
Radar WebKit Bug Importer
Comment 13
2021-09-01 11:44:22 PDT
<
rdar://problem/82638816
>
Jon Lee
Comment 14
2021-09-01 12:26:04 PDT
Comment on
attachment 436967
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=436967&action=review
> LayoutTests/css3/calc/trig-functions-with-constants.html:45 > + testValue('calc(sin(tan(pi/4)*pi/2) * 100px)', '100');
same test case repeated 3 times?
Simon Fraser (smfr)
Comment 15
2021-09-07 21:01:45 PDT
Comment on
attachment 436967
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=436967&action=review
Are there WPT for these trig functions? Can we contribute some?
> Source/WebCore/css/calc/CSSCalcOperationNode.cpp:366 > + return adoptRef(new CSSCalcOperationNode(CalculationCategory::Number, op, WTFMove(values)));
Normally we avoid calling bare 'new' and instead give classes a static create() function. But I see you're following existing code here.
> LayoutTests/css3/calc/trig-functions-with-constants.html:31 > + testValue('calc(sin(30deg + 1.0471967rad ) * 100px)', '100');
Do you test lack of units - tan(0.3) ?
EWS
Comment 16
2021-09-08 12:05:14 PDT
Committed
r282162
(
241454@main
): <
https://commits.webkit.org/241454@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 436967
[details]
.
Simon Fraser (smfr)
Comment 17
2022-06-21 18:05:14 PDT
***
Bug 203311
has been marked as a duplicate of this bug. ***
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