From 4548f5b4f8c1ced0d44cd1510f2a52543fc94c5a Mon Sep 17 00:00:00 2001 From: Traian Captan Date: Thu, 23 Mar 2023 17:08:13 -0700 Subject: [PATCH] Add CSSMathExpressionNumericLiteral canonical units eager simplification Spec def: "If root is a dimension that is not expressed in its canonical unit, and there is enough information available to convert it to the canonical unit, do so, and return the value." https://w3c.github.io/csswg-drafts/css-values/#calc-simplification However, Numbers should not be eagerly simplified at this time since that would result in converting Integers to Doubles (kNumber, canonical unit for Numbers). R=xiaochengh Bug: 1050968 Change-Id: I79adfbd516be640be51b86e1b33a2693c3b51ed9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4367363 Reviewed-by: Xiaocheng Hu Commit-Queue: Traian Captan Cr-Commit-Position: refs/heads/main@{#1121473} --- .../cssTransformValue.tentative.html | 2 +- .../the-stylepropertymap/properties/resources/testsuite.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/css/css-typed-om/stylevalue-serialization/cssTransformValue.tentative.html b/css/css-typed-om/stylevalue-serialization/cssTransformValue.tentative.html index 856b9314d852b71..c098868f143cb78 100644 --- a/css/css-typed-om/stylevalue-serialization/cssTransformValue.tentative.html +++ b/css/css-typed-om/stylevalue-serialization/cssTransformValue.tentative.html @@ -107,7 +107,7 @@ new CSSMathProduct(CSS.number(3)) ), ]), - cssText: 'translate(calc(1px + 1em), 0px) rotate(calc(90deg + 1turn)) perspective(calc(1px + 1em)) skew(calc(90deg * 2), calc(1turn * 2)) scale3d(calc(1 * 2), calc(1 + 1), calc(3))', + cssText: 'translate(calc(1px + 1em), 0px) rotate(calc(90deg + 360deg)) perspective(calc(1px + 1em)) skew(calc(90deg * 2), calc(360deg * 2)) scale3d(calc(1 * 2), calc(1 + 1), calc(3))', desc: 'CSSTransformValue containing CSSMathValues' }, { diff --git a/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js b/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js index 9708c5c04fc2510..cecd72ad927cfe2 100644 --- a/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js +++ b/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js @@ -148,8 +148,7 @@ const gTestSyntaxExamples = { { description: "a calc time", input: new CSSMathSum(new CSSUnitValue(0, 's'), new CSSUnitValue(0, 'ms')), - // Specified/computed calcs are usually simplified. - // FIXME: Test this properly + specifiedExpected: new CSSMathSum(new CSSUnitValue(0, 's'), new CSSUnitValue(0, 's')), defaultSpecified: (_, result) => assert_is_calc_sum(result), defaultComputed: (_, result) => assert_is_unit('s', result) } @@ -311,7 +310,7 @@ function testPropertyValid(propertyName, examples, specified, computed, descript 'Specified value must be a CSSStyleValue'); if (specified || example.defaultSpecified) { - (specified || example.defaultSpecified)(example.input, specifiedResult); + (specified || example.defaultSpecified)(example.specifiedExpected || example.input, specifiedResult); } else { assert_style_value_equals(specifiedResult, example.input, `Setting ${example.description} and getting its specified value`);