Skip to content

Commit

Permalink
Auto merge of #10727 - jdm:canvas_panic, r=pcwalton
Browse files Browse the repository at this point in the history
Use DOM width/height for canvas display list item.

Fixes #10705.

r? @glennw

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10727)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Apr 22, 2016
2 parents dff217c + 1623114 commit 0e0e902
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 14 deletions.
12 changes: 9 additions & 3 deletions components/layout/display_list_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,9 @@ impl FragmentDisplayListBuilding for Fragment {
let height = canvas_fragment_info.replaced_image_fragment_info
.computed_block_size.map_or(0, |h| h.to_px() as usize);
if width > 0 && height > 0 {
let computed_width = canvas_fragment_info.canvas_inline_size().to_px();
let computed_height = canvas_fragment_info.canvas_block_size().to_px();

let layer_id = self.layer_id();
let canvas_data = match canvas_fragment_info.ipc_renderer {
Some(ref ipc_renderer) => {
Expand All @@ -1230,7 +1233,10 @@ impl FragmentDisplayListBuilding for Fragment {
receiver.recv().unwrap()
},
None => CanvasData::Pixels(CanvasPixelData {
image_data: IpcSharedMemory::from_byte(0xFFu8, width * height * 4),
image_data: IpcSharedMemory::from_byte(0xFFu8,
(computed_width *
computed_height * 4)
as usize),
image_key: None,
}),
};
Expand All @@ -1245,8 +1251,8 @@ impl FragmentDisplayListBuilding for Fragment {
clip),
image_data: Some(Arc::new(canvas_data.image_data)),
webrender_image: WebRenderImageInfo {
width: width as u32,
height: height as u32,
width: computed_width as u32,
height: computed_height as u32,
format: PixelFormat::RGBA8,
key: canvas_data.image_key,
},
Expand Down
32 changes: 30 additions & 2 deletions tests/wpt/metadata/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -35214,8 +35214,36 @@
"local_changes": {
"deleted": [],
"deleted_reftests": {},
"items": {},
"reftest_nodes": {}
"items": {
"reftest": {
"html/rendering/replaced-elements/embedded-content-rendering-rules/canvas_scale.html": [
{
"path": "html/rendering/replaced-elements/embedded-content-rendering-rules/canvas_scale.html",
"references": [
[
"/html/rendering/replaced-elements/embedded-content-rendering-rules/canvas_scale_ref.html",
"=="
]
],
"url": "/html/rendering/replaced-elements/embedded-content-rendering-rules/canvas_scale.html"
}
]
}
},
"reftest_nodes": {
"html/rendering/replaced-elements/embedded-content-rendering-rules/canvas_scale.html": [
{
"path": "html/rendering/replaced-elements/embedded-content-rendering-rules/canvas_scale.html",
"references": [
[
"/html/rendering/replaced-elements/embedded-content-rendering-rules/canvas_scale_ref.html",
"=="
]
],
"url": "/html/rendering/replaced-elements/embedded-content-rendering-rules/canvas_scale.html"
}
]
}
},
"reftest_nodes": {
"2dcontext/building-paths/canvas_complexshapes_arcto_001.htm": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[read-pixels-test.html]
type: testharness
expected: CRASH
expected: TIMEOUT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[state-uneffected-after-compositing.html]
type: testharness
expected: CRASH
expected: TIMEOUT
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
expected: FAIL

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[texture-size-cube-maps.html]
type: testharness
expected: CRASH
expected: TIMEOUT
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[texture-size-limit.html]
type: testharness
expected:
if os == "linux": CRASH
if not debug and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64) and (backend == "cpu"): CRASH
expected: TIMEOUT
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
expected: FAIL

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[texture-size.html]
type: testharness
expected:
if os == "linux": CRASH
if not debug and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64) and (backend == "cpu"): CRASH
expected: TIMEOUT
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
expected: FAIL

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<meta charset="utf-8">
<title>Verify that canvases are scaled up to their computed size</title>
<link rel="match" href="canvas_scale_ref.html">
<style>
canvas {
width: 20px;
height: 20px;
}
div {
line-height: 0;
}
</style>
<div><canvas width="16" height="16" data-color="#FF00FF"></canvas><canvas width="16" height="16" data-color="#00FF00"></canvas></div>
<div><canvas width="16" height="16" data-color="#0000FF"></canvas><canvas width="16" height="16" data-color="#FF00FF"></canvas></div>
<script>
var canvases = document.getElementsByTagName('canvas');
for (var i = 0; i < canvases.length; i++) {
var ctx = canvases[i].getContext('2d');
ctx.fillStyle = canvases[i].getAttribute('data-color');
ctx.fillRect(0, 0, 16, 16);
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<meta charset="utf-8">
<style>
span {
display: inline-block;
width: 20px;
height: 20px;
}
div {
line-height: 0;
}
</style>
<div><span style="background-color: #FF00FF"></span><span style="background-color: #00FF00"></span></div>
<div><span style="background-color: #0000FF"></span><span style="background-color: #FF00FF"></span></div>

0 comments on commit 0e0e902

Please sign in to comment.