RESOLVED FIXED239019
calc(): Serialize top level min/max/hypot as calc()
https://bugs.webkit.org/show_bug.cgi?id=239019
Summary calc(): Serialize top level min/max/hypot as calc()
Nikos Mouchtaris
Reported 2022-04-08 16:14:17 PDT
calc(): Serialize top level min/max/hypot as calc()
Attachments
Patch (29.89 KB, patch)
2022-04-08 16:19 PDT, Nikos Mouchtaris
no flags
Patch (40.83 KB, patch)
2022-04-11 14:50 PDT, Nikos Mouchtaris
no flags
Patch (41.82 KB, patch)
2022-04-14 13:05 PDT, Nikos Mouchtaris
no flags
Patch (42.75 KB, patch)
2022-04-14 14:03 PDT, Nikos Mouchtaris
darin: review+
Patch (42.22 KB, patch)
2022-04-14 14:16 PDT, Nikos Mouchtaris
no flags
Nikos Mouchtaris
Comment 1 2022-04-08 16:19:11 PDT
Darin Adler
Comment 2 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
Nikos Mouchtaris
Comment 3 2022-04-11 14:50:49 PDT
Nikos Mouchtaris
Comment 4 2022-04-14 13:05:54 PDT
Darin Adler
Comment 5 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; }
Darin Adler
Comment 6 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.
Nikos Mouchtaris
Comment 7 2022-04-14 14:03:19 PDT
Nikos Mouchtaris
Comment 8 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.
Nikos Mouchtaris
Comment 9 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.
Darin Adler
Comment 10 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.
Nikos Mouchtaris
Comment 11 2022-04-14 14:16:12 PDT
Nikos Mouchtaris
Comment 12 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.
EWS
Comment 13 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].
Radar WebKit Bug Importer
Comment 14 2022-04-14 16:34:14 PDT
Nikos Mouchtaris
Comment 15 2022-04-19 16:05:24 PDT
*** Bug 230365 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.