Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<style>
body { margin: 0; }
.grid { display: grid; width: 276px; margin-bottom: 4px; overflow: hidden; }
.grid > img { grid-area: 1 / -1; place-self: stretch; min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; object-fit: cover; }
</style>
<!-- An image with an automatic height takes its height from its width through its aspect ratio, but that height still
behaves as auto for its minimum contribution, which its min-height then gives. So with min-height: 0, the row grows
only into the grid container's height, and max-height: 100% then limits the image to that row. -->
<div class="grid" style="aspect-ratio: 4 / 3"><img id="aspect-ratio-grid" style="" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='300'/%3E"></div>
<div class="grid" style="height: 207px"><img id="fixed-height-grid" style="" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='300'/%3E"></div>
<div class="grid" style="height: 207px"><img id="fixed-height-grid-start-aligned" style="place-self: start" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='300'/%3E"></div>
<div class="grid" style="height: 207px"><img id="fixed-height-grid-half-max-height" style="max-height: 50%" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='300'/%3E"></div>
<div class="grid" style="height: 207px"><img id="fixed-height-grid-fixed-max-height" style="max-height: 150px" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='300'/%3E"></div>
<div class="grid" style="height: 207px; grid-template-rows: auto auto"><img id="fixed-height-grid-two-rows" style="grid-area: auto" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='300'/%3E"><div style="height: 20px"></div></div>
<script>
function run(report) {
for (const element of document.querySelectorAll("[id]:not(#out)")) {
const rect = element.getBoundingClientRect();
report(`${element.id}: ${rect.width}x${rect.height}, rows ${getComputedStyle(element.parentElement).gridTemplateRows}`);
}
}
</script>
<script>
if (window.asyncTest)
asyncTest(done => addEventListener("load", () => { run(println); done(); }));
else
addEventListener("load", () => { run(line => console.log(line)); window.engineCompareDone = true; });
</script>