Bug 239019 - calc(): Serialize top level min/max/hypot as calc()
Summary: calc(): Serialize top level min/max/hypot as calc()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nikos Mouchtaris
URL:
Keywords: InRadar
: 230365 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-04-08 16:14 PDT by Nikos Mouchtaris
Modified: 2022-04-19 16:05 PDT (History)
8 users (show)

See Also:


Attachments
Patch (29.89 KB, patch)
2022-04-08 16:19 PDT, Nikos Mouchtaris
no flags Details | Formatted Diff | Diff
Patch (40.83 KB, patch)
2022-04-11 14:50 PDT, Nikos Mouchtaris
no flags Details | Formatted Diff | Diff
Patch (41.82 KB, patch)
2022-04-14 13:05 PDT, Nikos Mouchtaris
no flags Details | Formatted Diff | Diff
Patch (42.75 KB, patch)
2022-04-14 14:03 PDT, Nikos Mouchtaris
darin: review+
Details | Formatted Diff | Diff
Patch (42.22 KB, patch)
2022-04-14 14:16 PDT, Nikos Mouchtaris
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikos Mouchtaris 2022-04-08 16:14:17 PDT
calc(): Serialize top level min/max/hypot as calc()
Comment 1 Nikos Mouchtaris 2022-04-08 16:19:11 PDT
Created attachment 457124 [details]
Patch
Comment 2 Darin Adler 2022-04-11 14:31:26 PDT
Comment on attachment 457124 [details]
Patch

fast/css/calc-parsing.html is failing and some other two; we should review once we have a patch with all tests passing
Comment 3 Nikos Mouchtaris 2022-04-11 14:50:49 PDT
Created attachment 457289 [details]
Patch
Comment 4 Nikos Mouchtaris 2022-04-14 13:05:54 PDT
Created attachment 457645 [details]
Patch
Comment 5 Darin Adler 2022-04-14 13:50:24 PDT
Comment on attachment 457645 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=457645&action=review

> Source/WebCore/css/calc/CSSCalcOperationNode.h:75
> +    void makeTopLevelCalc() { m_operator = CalcOperator::Add; }

Needs a comment explaining why the way to make something a top-level call is to set the operator to add, since that's not obvious from the name. I might move the body out of the class to the bottom of the header just to make room for the comment.

    void makeTopLevelCalc();

...

inline void CSSCalcOperationNode::makeTopLevelCalc()
{
    // Top level calc nodes where we need not preserve the function are changed into add nodes because that’s the best way to make them serialize as "calc(xxx)" and also evaluate them efficiently.
    <<<or whatever the comment should say>>>
    m_operator = CaclOperator::Add;
}
Comment 6 Darin Adler 2022-04-14 13:51:14 PDT
Comment on attachment 457645 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=457645&action=review

>> Source/WebCore/css/calc/CSSCalcOperationNode.h:75
>> +    void makeTopLevelCalc() { m_operator = CalcOperator::Add; }
> 
> Needs a comment explaining why the way to make something a top-level call is to set the operator to add, since that's not obvious from the name. I might move the body out of the class to the bottom of the header just to make room for the comment.
> 
>     void makeTopLevelCalc();
> 
> ...
> 
> inline void CSSCalcOperationNode::makeTopLevelCalc()
> {
>     // Top level calc nodes where we need not preserve the function are changed into add nodes because that’s the best way to make them serialize as "calc(xxx)" and also evaluate them efficiently.
>     <<<or whatever the comment should say>>>
>     m_operator = CaclOperator::Add;
> }

Also, these can be private rather than public, I think. And the inline function bodies could be in the .cpp file rather than in the .h file if they are only used there.
Comment 7 Nikos Mouchtaris 2022-04-14 14:03:19 PDT
Created attachment 457646 [details]
Patch
Comment 8 Nikos Mouchtaris 2022-04-14 14:04:13 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 457645 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=457645&action=review
> 
> > Source/WebCore/css/calc/CSSCalcOperationNode.h:75
> > +    void makeTopLevelCalc() { m_operator = CalcOperator::Add; }
> 
> Needs a comment explaining why the way to make something a top-level call is
> to set the operator to add, since that's not obvious from the name. I might
> move the body out of the class to the bottom of the header just to make room
> for the comment.
> 
>     void makeTopLevelCalc();
> 
> ...
> 
> inline void CSSCalcOperationNode::makeTopLevelCalc()
> {
>     // Top level calc nodes where we need not preserve the function are
> changed into add nodes because that’s the best way to make them serialize as
> "calc(xxx)" and also evaluate them efficiently.
>     <<<or whatever the comment should say>>>
>     m_operator = CaclOperator::Add;
> }

Fixed.
Comment 9 Nikos Mouchtaris 2022-04-14 14:04:24 PDT
(In reply to Darin Adler from comment #6)
> Comment on attachment 457645 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=457645&action=review
> 
> >> Source/WebCore/css/calc/CSSCalcOperationNode.h:75
> >> +    void makeTopLevelCalc() { m_operator = CalcOperator::Add; }
> > 
> > Needs a comment explaining why the way to make something a top-level call is to set the operator to add, since that's not obvious from the name. I might move the body out of the class to the bottom of the header just to make room for the comment.
> > 
> >     void makeTopLevelCalc();
> > 
> > ...
> > 
> > inline void CSSCalcOperationNode::makeTopLevelCalc()
> > {
> >     // Top level calc nodes where we need not preserve the function are changed into add nodes because that’s the best way to make them serialize as "calc(xxx)" and also evaluate them efficiently.
> >     <<<or whatever the comment should say>>>
> >     m_operator = CaclOperator::Add;
> > }
> 
> Also, these can be private rather than public, I think. And the inline
> function bodies could be in the .cpp file rather than in the .h file if they
> are only used there.

Fixed.
Comment 10 Darin Adler 2022-04-14 14:04:53 PDT
Comment on attachment 457646 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=457646&action=review

> Source/WebCore/css/calc/CSSCalcOperationNode.h:74
> +    bool shouldNotPreserveFunction() const { return isMinOrMaxNode() || isHypotNode(); }

I think this can also be private.
Comment 11 Nikos Mouchtaris 2022-04-14 14:16:12 PDT
Created attachment 457647 [details]
Patch
Comment 12 Nikos Mouchtaris 2022-04-14 14:17:02 PDT
(In reply to Darin Adler from comment #10)
> Comment on attachment 457646 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=457646&action=review
> 
> > Source/WebCore/css/calc/CSSCalcOperationNode.h:74
> > +    bool shouldNotPreserveFunction() const { return isMinOrMaxNode() || isHypotNode(); }
> 
> I think this can also be private.

Fixed.
Comment 13 EWS 2022-04-14 16:33:52 PDT
Committed r292893 (249663@main): <https://commits.webkit.org/249663@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 457647 [details].
Comment 14 Radar WebKit Bug Importer 2022-04-14 16:34:14 PDT
<rdar://problem/91784817>
Comment 15 Nikos Mouchtaris 2022-04-19 16:05:24 PDT
*** Bug 230365 has been marked as a duplicate of this bug. ***