Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html class="reftest-wait">
<title>drawElementImage with inline drawable</title>
<link rel="help" href="https://github.com/WICG/html-in-canvas">
<link rel="match" href="inline-drawable-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<script src="/common/reftest-wait.js"></script>
<script src="/html/canvas/resources/wait-for-canvas-paint.js"></script>
<style>
#canvas {
background: #ccc;
}
#child {
width: 200px;
height: 200px;
background: lightgreen;
}
span {
font: 25px/1 Ahem;
}
#inlinea {
color: blue;
}
#inlineb {
color: green;
}
#inlinec {
color: purple;
}
</style>
<canvas id="canvas" width="300" height="200" layoutsubtree>
<div id="child" drawable>
<span id="inlinea">X</span>
<span id="inlineb" drawable>X</span>
<span id="inlinec">X</span>
</div>
</canvas>
<script>
onload = async () => {
await waitForCanvasPaint(canvas);
// Draw the 200x200 lightgreen #child at the origin. This should not
// include the drawable #inlineb, but should include #inlinea and #inlinec.
canvas.getContext('2d').drawElementImage(child, 0, 0);
// Draw the #inlineb at 225,25.
canvas.getContext('2d').drawElementImage(inlineb, 225, 25);
takeScreenshot();
};
</script>
</html>