Skip to content

Commit

Permalink
Implement CSS comparison functions min/max
Browse files Browse the repository at this point in the history
This patch implements the CSSComparison functions min/max following
spec: https://drafts.csswg.org/css-values-4/#comp-func

1. New CSSMathOperator types and a new CSSMathExpressionNode subclass
   are added, so that CSSMathFunctionValue can represent an expression
   that involves min() and max()

2. Parser support for min() and max() are added

3. Conversions between CSSMathFunctionValue and CalculationValue are
   augmented to support comparisons

A minimal test suite is also added to verify reachability of the newly
added code.

The following will be finished by future patches:
- Bridging comparison functions with CSS typed OM objects
- Supporting comparison functions in the 'sizes' attribute
- Adding a comprehensive wpt test suite for comparison functions

Bug: 825895
Change-Id: I5bbf09b62818f733573f6d38837c68e555fcae59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1744799
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687414}
  • Loading branch information
xiaochengh authored and chromium-wpt-export-bot committed Aug 15, 2019
1 parent b73b102 commit 31a271d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions css/css-values/max-length-percent-001.html
@@ -0,0 +1,18 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS values: max() between pixel and percentage values</title>
<link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func">
<link rel="match" href="reference/200-200-green.html">
<link rel="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
<style>
html, body { margin: 0px; padding: 0px; }
#parent { width: 400px; }
#target {
width: max(100px, 25% + 100px, 150px + 10%);
height: 200px;
background: green;
}
</style>
<div id=parent>
<div id=target></div>
</div>
18 changes: 18 additions & 0 deletions css/css-values/min-length-percent-001.html
@@ -0,0 +1,18 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS values: min() between pixel and percentage values</title>
<link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func">
<link rel="match" href="reference/200-200-green.html">
<link rel="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
<style>
html, body { margin: 0px; padding: 0px; }
#parent { width: 400px; }
#target {
width: min(300px, 25% + 100px, 50px + 50%);
height: 200px;
background: green;
}
</style>
<div id=parent>
<div id=target></div>
</div>

0 comments on commit 31a271d

Please sign in to comment.