4 <style type="text/css">
11 background-color: green;
14 #canvas-padding { padding: 5px; }
15 #canvas-border { border: 5px solid; }
16 #canvas-image { background-image: url("../resources/simple_image.png"); }
17 #canvas-transparent-background { background-color: rgba(0, 255, 0, 0.5); }
18 #canvas-opaque { border: 5px solid; }
21 if (window.testRunner)
22 testRunner.dumpAsText();
24 function drawCanvas(canvasID, hasAlpha) {
25 var canvas = document.getElementById(canvasID);
26 var context = canvas.getContext("2d", {alpha: hasAlpha});
27 context.clearRect(0, 0, canvas.width, canvas.height);
31 // Simple background can be direct-composited with content-layer.
32 // The container GraphicsLayer does not paint anything.
33 // The content layer should be treated as opaque because the
34 // background color is opaque.
35 drawCanvas('canvas-simple', true);
37 // Padding makes the background-box bigger than content-box.
38 // The container GraphicsLayer needs to paint background.
39 drawCanvas('canvas-padding', true);
41 // Content layer cannot direct-composite any kind of box decoration.
42 // The container GraphicsLayer needs to paint box decorations.
43 drawCanvas('canvas-border', true);
45 // Content layer cannot direct-composite background image.
46 // The container GraphicsLayer needs to paint background image.
47 drawCanvas('canvas-image', true);
49 // Simple background can be direct-composited with content-layer.
50 // The container GraphicsLayer does not paint anything.
51 // The content layer should not be treated as opaque because the
52 // background color is not opaque.
53 drawCanvas('canvas-transparent-background', true);
55 // Background cannot be direct-composited because of box decoration.
56 // However contents of the canvas are opaque so the background does
57 // not need to be painted.
58 drawCanvas('canvas-opaque', false);
60 if (window.testRunner && window.internals)
61 document.getElementById('layer-tree').innerText = window.internals.layerTreeAsText(document);
63 window.addEventListener('load', doTest, false);
68 <div class="container">
69 <canvas id="canvas-simple" width="50" height="50"></canvas>
71 <div class="container">
72 <canvas id="canvas-transparent-background" width="50" height="50"></canvas>
74 <div class="container">
75 <canvas id="canvas-padding" width="50" height="50"></canvas>
77 <div class="container">
78 <canvas id="canvas-border" width="50" height="50"></canvas>
80 <div class="container">
81 <canvas id="canvas-image" width="50" height="50"></canvas>
83 <div class="container">
84 <canvas id="canvas-opaque" width="50" height="50"></canvas>
86 <pre id="layer-tree"></pre>