Commit 88843393 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Do not simplify calculation across math functions

The existing code is too aggressive in simplifying calc() expressions
that, math functions (min/max etc) can be simplified away when they
can be directly resolved. This doesn't match the spec (*), and is fixed
in this patch.

(*) https://drafts.csswg.org/css-values-4/#math-function-simplify-a-calculation

Bug: 825895
Change-Id: Id5796299da50e40b09bc38bf0271c8f5cd7897de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1825325Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700132}
parent 9490becd
......@@ -385,6 +385,9 @@ CSSMathExpressionNode* CSSMathExpressionBinaryOperation::CreateSimplified(
const CSSMathExpressionNode* left_side,
const CSSMathExpressionNode* right_side,
CSSMathOperator op) {
if (left_side->IsMathFunction() || right_side->IsMathFunction())
return Create(left_side, right_side, op);
CalculationCategory left_category = left_side->Category();
CalculationCategory right_category = right_side->Category();
DCHECK_NE(left_category, kCalcOther);
......
......@@ -20,6 +20,9 @@ test_valid_angle('max(1rad)', 'max(1rad)');
test_valid_angle('max(1turn)', 'max(1turn)');
test_valid_angle('max(1grad)', 'max(1grad)');
test_valid_angle('calc(min(1deg) + min(2deg))', 'calc(min(1deg) + min(2deg))');
test_valid_angle('calc(max(1deg) + max(2deg))', 'calc(max(1deg) + max(2deg))');
// TODO(crbug.com/978682): Complete this test suite
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment