Bug 1578921 [wpt PR 18858] - Do not simplify calc(0px + 0%) into 0px, 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 https://github.com/w3c/csswg-drafts/issues/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 <xiaochengh@chromium.org>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693437}

--

wpt-commits: c92eaa98a3e95a47ab21dcdb974f5d1a79e354bb
wpt-pr: 18858
This commit is contained in:
Xiaocheng Hu 2019-09-05 14:52:11 +00:00 коммит произвёл James Graham
Родитель a16c5b8e46
Коммит 521f8c3673
1 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -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>