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

Don't wrap min/max() in calc() in CSS value serialization

Bug: 825895
Change-Id: I98e3327a82352a90db9a74b1adc4b62ffd54c4ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1758834Reviewed-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@{#688263}
parent f83cf95a
......@@ -76,6 +76,10 @@ class CORE_EXPORT CSSMathExpressionNode
virtual bool IsBinaryOperation() const { return false; }
virtual bool IsVariadicOperation() const { return false; }
bool IsMathFunction() const {
return !IsNumericLiteral() && !IsBinaryOperation();
}
virtual bool IsZero() const = 0;
// Resolves the expression into one value *without doing any type conversion*.
......
......@@ -97,7 +97,13 @@ static String BuildCSSText(const String& expression) {
}
String CSSMathFunctionValue::CustomCSSText() const {
return BuildCSSText(expression_->CustomCSSText());
const String& expression_text = expression_->CustomCSSText();
if (expression_->IsMathFunction()) {
// If |expression_| is already a math function (e.g., min/max), we don't
// need to wrap it in |calc()|.
return expression_text;
}
return BuildCSSText(expression_text);
}
bool CSSMathFunctionValue::Equals(const CSSMathFunctionValue& other) const {
......
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#angles">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#calc-type-checking">
<link rel="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/parsing-testcommon.js"></script>
<script>
function test_valid_angle(value, expected) {
test_valid_value('transform', `rotate(${value})`, `rotate(${expected})`);
}
test_valid_angle('min(1deg)', 'min(1deg)');
test_valid_angle('min(1rad)', 'min(1rad)');
test_valid_angle('min(1turn)', 'min(1turn)');
test_valid_angle('min(1grad)', 'min(1grad)');
test_valid_angle('max(1deg)', 'max(1deg)');
test_valid_angle('max(1rad)', 'max(1rad)');
test_valid_angle('max(1turn)', 'max(1turn)');
test_valid_angle('max(1grad)', 'max(1grad)');
// 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