Skip to content

Commit

Permalink
Add CSSMathExpressionNumericLiteral canonical units eager simplification
Browse files Browse the repository at this point in the history
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 <[email protected]>
Commit-Queue: Traian Captan <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1121473}
  • Loading branch information
tcaptan-cr authored and cookiecrook committed Apr 8, 2023
1 parent 98f5983 commit cb7ed25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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`);
Expand Down

0 comments on commit cb7ed25

Please sign in to comment.