haikuwebkit/LayoutTests/fast/shapes
Antoine Quint e5ddace466 calc() should not contain 0 values other than percentages
https://bugs.webkit.org/show_bug.cgi?id=224611

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Fix expectation of existing WPT tests and make some modifications to existing WPT tests.

* web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt:
* web-platform-tests/css/css-shapes/parsing/shape-outside-computed-expected.txt:
* web-platform-tests/css/css-shapes/parsing/shape-outside-computed.html: Add a new assertion checking
that the computed style for shape-outside may not contain 0px values in calc() values.
* web-platform-tests/css/css-transitions/animations/vertical-align-interpolation-expected.txt:
* web-platform-tests/css/css-transitions/animations/vertical-align-interpolation.html: Use 40% rather than
calc(0px + 40%) as the expected value for the computed style at the 100% keyframe when blending from 40px
to 40%. The test would have passed with calc(0px + 40%) as well, since it would now compute to 40%, but
the test is clearer when the actual computed form is used.
* web-platform-tests/css/css-values/minmax-percentage-serialize-expected.txt:

Source/WebCore:

A calc() value containing a 0px value, such as calc(10% + 0px), was incorrectly serialized
as-is for the computed style, instead of the simplified form containing on the percentage.

For the correct behavior we need to make four changes in css/CSSCalculationValue.cpp:

1. in createCSS(const CalcExpressionNode&, const RenderStyle&), when dealing with a node
that is CalcExpressionNodeType::Length, we return nullptr in the case then node's Length
is a 0 value that's not a percentage,

2. additionally, in createCSS(const Vector<std::unique_ptr<CalcExpressionNode>>&, const RenderStyle&),
we no longer bail when a nullptr value is returned for a child and instead proceed with the
processing of further children, ensuring that a 0px value in, say, a Sum operation is removed
while retaining other non-zero values,

3. back in createCSS(const CalcExpressionNode&, const RenderStyle&), for CalcExpressionNodeType::Operation
nodes, when there is single parameter to a Sum operation we return that parameter rather than
a Sum operation, and do the same for a Negate operation, making sure we return negated node if
it is the second child,

4. finally, in CSSCalcOperationNode::buildCSSText(const CSSCalcExpressionNode&, StringBuilder&)
when we serialize a calculated value, we do not enclose the value in a `calc()` string if the
node is a CSSCalcPrimitiveValueNode.

* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::buildCSSText):
(WebCore::createCSS):

LayoutTests:

Adjust a non-WPT test to not feature a 0px addition.

* fast/shapes/shape-outside-floats/shape-outside-animation-expected.txt:
* fast/shapes/shape-outside-floats/shape-outside-animation.html:


Canonical link: https://commits.webkit.org/236585@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276052 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-15 19:39:30 +00:00
..
parsing calc() serialization doesn't match the spec 2019-12-04 02:22:35 +00:00
resources
shape-outside-floats calc() should not contain 0 values other than percentages 2021-04-15 19:39:30 +00:00
assert-when-rounded-rect-overflows-expected.txt RenderStyle::getRoundedInnerBorderFor should never produce a rect with negative width/height 2021-03-15 21:27:39 +00:00
assert-when-rounded-rect-overflows.html RenderStyle::getRoundedInnerBorderFor should never produce a rect with negative width/height 2021-03-15 21:27:39 +00:00
css-shapes-enabled-expected.txt
css-shapes-enabled.html