mirror of
https://github.com/servo/servo.git
synced 2025-10-16 16:29:18 +01:00
87 lines
2.1 KiB
HTML
87 lines
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<html class="reftest-wait">
|
|
<link rel="help" href="https://drafts.css-houdini.org/css-paint-api/">
|
|
<link rel="match" href="two-element-custom-property-animation-ref.html">
|
|
<style>
|
|
#footainer {
|
|
width: 200px;
|
|
height: 200px;
|
|
}
|
|
.fooanimate {
|
|
background-image: paint(foo);
|
|
animation: expand 5s;
|
|
}
|
|
#bartainer {
|
|
width: 200px;
|
|
height: 200px;
|
|
}
|
|
.baranimate {
|
|
background-image: paint(bar);
|
|
animation: colorChange 5s;
|
|
}
|
|
@keyframes expand {
|
|
0% { --foo: 0; }
|
|
0.01% { --foo: 100; }
|
|
99% { --foo: 100; }
|
|
100% { --foo: 200; }
|
|
}
|
|
@keyframes colorChange {
|
|
0% { --bar: rgb(255, 0, 0); }
|
|
0.01% { --bar: rgb(128, 128, 0); }
|
|
99% { --bar: rgb(128, 128, 0); }
|
|
100% { --bar: rgb(0, 255, 0); }
|
|
}
|
|
</style>
|
|
<script src="/common/reftest-wait.js"></script>
|
|
<script src="/common/worklet-reftest.js"></script>
|
|
<body>
|
|
<div id="footainer"></div>
|
|
<div id="bartainer"></div>
|
|
|
|
<script id="code" type="text/worklet">
|
|
registerPaint('foo', class {
|
|
static get inputProperties() { return ['--foo']; }
|
|
paint(ctx, geom, properties) {
|
|
let fooValue = parseFloat(properties.get('--foo').toString());
|
|
ctx.fillStyle = 'green';
|
|
ctx.fillRect(0, 0, fooValue, fooValue);
|
|
}
|
|
});
|
|
|
|
registerPaint('bar', class {
|
|
static get inputProperties() { return ['--bar']; }
|
|
paint(ctx, geom, properties) {
|
|
ctx.fillStyle = properties.get('--bar').toString();
|
|
ctx.fillRect(0, 0, 200, 200);
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
CSS.registerProperty({
|
|
name: '--foo',
|
|
syntax: '<number>',
|
|
initialValue: '0',
|
|
inherits: false
|
|
});
|
|
CSS.registerProperty({
|
|
name: '--bar',
|
|
syntax: '<color>',
|
|
initialValue: 'rgb(0, 0, 0)',
|
|
inherits: false
|
|
});
|
|
</script>
|
|
|
|
<script>
|
|
var code = document.getElementById('code').textContent;
|
|
var blob = new Blob([code], {type: 'text/javascript'});
|
|
CSS.paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
|
|
document.getElementById('footainer').classList.add('fooanimate');
|
|
document.getElementById('bartainer').classList.add('baranimate');
|
|
requestAnimationFrame(function() {
|
|
takeScreenshot();
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|