<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.box {
position: relative;
display: inline-block;
margin: 30px;
width: 200px;
height: 200px;
will-change: transform;
}
.main {
border: 40px solid gray;
background-color: red;
line-height: 0;
outline: 20px solid transparent; /* Makes compositing layers larger */
}
.child {
position: absolute;
width: 150px;
height: 150px;
padding: 20px;
will-change: transform;
}
.negative {
z-index: -1;
top: 0;
left: 0;
height: 10px;
width: 10px;
}
img {
display: inline-block;
background-color: green;
height: 100px;
width: 100px;
}
@-webkit-keyframes fade {
from { background-color: green; }
to { background-color: orange; }
}
.embiggener {
position: absolute;
height: 10px;
width: 10px;
top: -50px;
left: -50px;
background-color: blue;
}
#layer-tree {
opacity: 0; /* hide from pixel test */
}
</style>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script type="text/javascript" charset="utf-8">
function repaint()
{
var imagesToRepaint = document.querySelectorAll('.repainted');
for (var i = 0; i < imagesToRepaint.length; ++i) {
var currImage = imagesToRepaint[i];
currImage.style.backgroundColor = 'orange';
}
}
window.addEventListener('load', function() {
runAfterLayoutAndPaint(repaint, true);
}, false);
</script>
</head>
<body>
<!-- Both boxes should look the same. You should see no red. -->
<div class="main box">
<img><img><img class="repainted"><img>
<div class="negative child"></div>
</div>
<div class="main box" style="overflow: hidden;">
<img><img><img class="repainted"><img>
<div class="negative child"></div>
</div>
<pre id="layer-tree"></pre>
</body>
</html>