Skip to content

Commit

Permalink
Bug 1578921 [wpt PR 18858] - Do not simplify calc(0px + 0%) into 0px,…
Browse files Browse the repository at this point in the history
… a=testonly

Automatic update from web-platform-tests
Do not simplify calc(0px + 0%) into 0px

Currently, when we create |Length| from calc(), and then create a
CSSPrimitiveValue from that |Length|, we may drop the percentage part
if it's zero.

As discussed at w3c/csswg-drafts#3482, zero
percentages in calcs should be preserved.

Hence, this part ensures that percentage is perserved in calc(0px + 0%)

Note: we may want to preserve 0% in all cases, but that leads to many
test failures, so we leave the investigation to future instead.

This is also preparation for crrev.com/c/1777025, which switches the
implementation of InterpolableLength to a math expression to support
min/max.

Bug: 991672
Change-Id: I386f42a323079cce3d6ee545fa00ef289406e8bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1779721
Commit-Queue: Xiaocheng Hu <xiaochenghchromium.org>
Reviewed-by: Emil A Eklund <eaechromium.org>
Cr-Commit-Position: refs/heads/master{#693437}

--

wpt-commits: c92eaa98a3e95a47ab21dcdb974f5d1a79e354bb
wpt-pr: 18858

UltraBlame original commit: 203d6c8149371b278e332611fe8552e193373368
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent 41dd787 commit b791dd3
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!doctype html>
<link rel="help" href="https://www.w3.org/TR/css-values-4/#calc-computed-value">
<link rel="help" href="https://www.w3.org/TR/CSS2/visudet.html#the-height-property">
<link rel="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
<link rel="match" href="../reference/ref-filled-green-100px-square-only.html">
<title>0% in calc() should be preserved</title>
<script>
CSS.registerProperty({
name: '--custom-height',
syntax: '<length-percentage>',
initialValue: 'calc(0% + 0px)',
inherits: false
});
</script>
<style>
.height-filler {
height: 100px;
}

.test {
width: 100px;
height: var(--custom-height);
background-color: green;
}
</style>
<p>Test passes if there is a filled green square.</p>
<div class="test">
<div class="height-filler">
</div>
</div>

0 comments on commit b791dd3

Please sign in to comment.