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

Support clamp() in CSSNumericValue.parse()

This patch supports parsing 'clamp(MIN, VAL, MAX)' into a
CSSNumericValue via the parse() method.

This was missed in the previous implementation of clamp(), and should be
the last missing piece of the implementation.

Bug: 825895
Change-Id: I6da8113d62b1416dc6d3521b58134932b257ca62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832147
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701536}
parent e379550e
...@@ -253,8 +253,8 @@ CSSNumericValue* CSSNumericValue::parse(const String& css_text, ...@@ -253,8 +253,8 @@ CSSNumericValue* CSSNumericValue::parse(const String& css_text,
range.Peek().FunctionId() == CSSValueID::kWebkitCalc || range.Peek().FunctionId() == CSSValueID::kWebkitCalc ||
(RuntimeEnabledFeatures::CSSComparisonFunctionsEnabled() && (RuntimeEnabledFeatures::CSSComparisonFunctionsEnabled() &&
(range.Peek().FunctionId() == CSSValueID::kMin || (range.Peek().FunctionId() == CSSValueID::kMin ||
range.Peek().FunctionId() == CSSValueID::kMax))) { range.Peek().FunctionId() == CSSValueID::kMax ||
// TODO(crbug.com/825895): Support clamp() after min()/max() are done. range.Peek().FunctionId() == CSSValueID::kClamp))) {
CSSMathExpressionNode* expression = CSSMathExpressionNode* expression =
CSSMathExpressionNode::ParseCalc(range); CSSMathExpressionNode::ParseCalc(range);
if (expression) if (expression)
......
...@@ -37,4 +37,9 @@ test(() => { ...@@ -37,4 +37,9 @@ test(() => {
assert_style_value_equals(expected, CSSNumericValue.parse('max(10px, 10%)')); assert_style_value_equals(expected, CSSNumericValue.parse('max(10px, 10%)'));
}, 'Parsing max() is successful'); }, 'Parsing max() is successful');
test(() => {
const expected = new CSSMathMax(CSS.px(10), new CSSMathMin(CSS.percent(10), CSS.px(20)));
assert_style_value_equals(expected, CSSNumericValue.parse('clamp(10px, 10%, 20px)'));
}, 'Parsing clamp() is successful');
</script> </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