Commit 0e17e1d9 authored by haozhe's avatar haozhe Committed by Commit Bot

Port calc interpolation to wpt

Both Chrome and Firefox passed

Bug: 900581
Change-Id: I7a8e4b3b7f2d040df128cd614e95b8a247d99e71
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1937907Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Commit-Queue: Hao Sheng <haozhes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719355}
parent 1785f13d
<!DOCTYPE html>
<meta charset="UTF-8">
<title>calc interpolation</title>
<link rel="help" href="https://drafts.csswg.org/css-values-3/#calc-notation">
<meta name="assert" content="calc supports animation by computed value">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<style>
.container {
position: relative;
......@@ -21,68 +29,68 @@
background-color: green;
}
</style>
<body>
<template id="target-template">
<div class="container">
<div class="target"></div>
</div>
</template>
<script src="resources/interpolation-test.js"></script>
<script>
assertInterpolation({
test_interpolation({
property: 'left',
from: 'calc(50% - 25px)',
to: 'calc(100% - 10px)'
}, [
{at: -0.25, is: '-10px'},
{at: 0, is: '0px'},
{at: 0.25, is: '10px'},
{at: 0.5, is: '20px'},
{at: 0.75, is: '30px'},
{at: 1, is: '40px'},
{at: 1.25, is: '50px'}
{at: -0.25, expect: '-10px'},
{at: 0, expect: '0px'},
{at: 0.25, expect: '10px'},
{at: 0.5, expect: '20px'},
{at: 0.75, expect: '30px'},
{at: 1, expect: '40px'},
{at: 1.25, expect: '50px'}
]);
assertInterpolation({
test_interpolation({
property: 'text-indent',
from: 'calc(50% - 25px)',
to: 'calc(100% - 10px)'
}, [
{at: -0.25, is: 'calc(((50% - 25px) * 1.25) + ((100% - 10px) * -0.25))'},
{at: 0, is: 'calc(50% - 25px)'},
{at: 0.25, is: 'calc(((50% - 25px) * 0.75) + ((100% - 10px) * 0.25))'},
{at: 0.5, is: 'calc(((50% - 25px) * 0.5) + ((100% - 10px) * 0.5))'},
{at: 0.75, is: 'calc(((50% - 25px) * 0.25) + ((100% - 10px) * 0.75))'},
{at: 1, is: 'calc(100% - 10px)'},
{at: 1.25, is: 'calc(((50% - 25px) * -0.25) + ((100% - 10px) * 1.25))'}
{at: -0.25, expect: 'calc(((50% - 25px) * 1.25) + ((100% - 10px) * -0.25))'},
{at: 0, expect: 'calc(50% - 25px)'},
{at: 0.25, expect: 'calc(((50% - 25px) * 0.75) + ((100% - 10px) * 0.25))'},
{at: 0.5, expect: 'calc(((50% - 25px) * 0.5) + ((100% - 10px) * 0.5))'},
{at: 0.75, expect: 'calc(((50% - 25px) * 0.25) + ((100% - 10px) * 0.75))'},
{at: 1, expect: 'calc(100% - 10px)'},
{at: 1.25, expect: 'calc(((50% - 25px) * -0.25) + ((100% - 10px) * 1.25))'}
]);
assertInterpolation({
test_interpolation({
property: 'text-indent',
from: '0em',
to: '100px'
}, [
{at: -0.25, is: '-25px'},
{at: 0, is: '0em'},
{at: 0.25, is: '25px'},
{at: 0.5, is: '50px'},
{at: 0.75, is: '75px'},
{at: 1, is: '100px'},
{at: 1.25, is: '125px'}
{at: -0.25, expect: '-25px'},
{at: 0, expect: '0em'},
{at: 0.25, expect: '25px'},
{at: 0.5, expect: '50px'},
{at: 0.75, expect: '75px'},
{at: 1, expect: '100px'},
{at: 1.25, expect: '125px'}
]);
assertInterpolation({
test_interpolation({
property: 'text-indent',
from: '0%',
to: '100px'
}, [
{at: -0.25, is: 'calc(0% + -25px)'},
{at: 0, is: '0%'},
{at: 0.25, is: 'calc(0% + 25px)'},
{at: 0.5, is: 'calc(0% + 50px)'},
{at: 0.75, is: 'calc(0% + 75px)'},
{at: 1, is: '100px'},
{at: 1.25, is: 'calc(0% + 125px)'}
{at: -0.25, expect: 'calc(0% + -25px)'},
{at: 0, expect: '0%'},
{at: 0.25, expect: 'calc(0% + 25px)'},
{at: 0.5, expect: 'calc(0% + 50px)'},
{at: 0.75, expect: 'calc(0% + 75px)'},
{at: 1, expect: 'calc(0% + 100px)'},
{at: 1.25, expect: 'calc(0% + 125px)'}
]);
</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