aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-04-03 13:57:33 -0400
committerGitHub <noreply@github.com>2020-04-03 13:57:33 -0400
commitf7d3d4a44762b3196c8dcbe58b628b5a23fc7833 (patch)
tree5819a72bd74332222deb651fde69fd5b9a4c3ab0
parent7ba88247baf27eddde07cd6097bd0f2de0171122 (diff)
parent61fb84d6a09b04f7d2de2ebbda3db0d10925561f (diff)
downloadservo-f7d3d4a44762b3196c8dcbe58b628b5a23fc7833.tar.gz
servo-f7d3d4a44762b3196c8dcbe58b628b5a23fc7833.zip
Auto merge of #26065 - dralley:fix-motionmark, r=cbrewster,SimonSapin
Don't send empty canvases to WebRender If any dimension of a canvas is 0, don't try to display it as it causes problems inside webrender. Minimal test case available here: https://github.com/servo/servo/issues/21411#issuecomment-605226547 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
-rw-r--r--components/layout/display_list/builder.rs6
-rw-r--r--components/layout_2020/display_list/mod.rs1
-rw-r--r--components/layout_2020/replaced.rs7
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json7
-rw-r--r--tests/wpt/mozilla/tests/mozilla/zero_size_canvas_crash.html13
5 files changed, 34 insertions, 0 deletions
diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs
index 56748d55d2b..17f946f7187 100644
--- a/components/layout/display_list/builder.rs
+++ b/components/layout/display_list/builder.rs
@@ -1875,6 +1875,12 @@ impl Fragment {
}
},
SpecificFragmentInfo::Canvas(ref canvas_fragment_info) => {
+ if canvas_fragment_info.dom_width == Au(0) ||
+ canvas_fragment_info.dom_height == Au(0)
+ {
+ return;
+ }
+
let image_key = match canvas_fragment_info.source {
CanvasFragmentSource::WebGL(image_key) => image_key,
CanvasFragmentSource::Image(ref ipc_renderer) => match *ipc_renderer {
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs
index 46c31934831..dccee5ea71a 100644
--- a/components/layout_2020/display_list/mod.rs
+++ b/components/layout_2020/display_list/mod.rs
@@ -87,6 +87,7 @@ impl Fragment {
.rect
.to_physical(i.style.writing_mode, containing_block)
.translate(containing_block.origin.to_vector());
+
let common = builder.common_properties(rect.clone().to_webrender());
builder.wr.push_image(
&common,
diff --git a/components/layout_2020/replaced.rs b/components/layout_2020/replaced.rs
index 334ff44a665..f3501ce0e71 100644
--- a/components/layout_2020/replaced.rs
+++ b/components/layout_2020/replaced.rs
@@ -102,6 +102,7 @@ impl ReplacedContent {
let width = (intrinsic_size_in_dots.width as CSSFloat) / dppx;
let height = (intrinsic_size_in_dots.height as CSSFloat) / dppx;
+
return Some(Self {
kind,
intrinsic: IntrinsicSizes {
@@ -201,6 +202,12 @@ impl ReplacedContent {
.into_iter()
.collect(),
ReplacedContentKind::Canvas(canvas_info) => {
+ if self.intrinsic.width == Some(Length::zero()) ||
+ self.intrinsic.height == Some(Length::zero())
+ {
+ return vec![];
+ }
+
let image_key = match canvas_info.source {
CanvasSource::WebGL(image_key) => image_key,
CanvasSource::Image(ref ipc_renderer) => match *ipc_renderer {
diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json
index 65282571142..770fb31f3a8 100644
--- a/tests/wpt/mozilla/meta/MANIFEST.json
+++ b/tests/wpt/mozilla/meta/MANIFEST.json
@@ -14591,6 +14591,13 @@
null,
{}
]
+ ],
+ "zero_size_canvas_crash.html": [
+ "45eb9b559e8d6105baca5ab4d336de520d33b36b",
+ [
+ null,
+ {}
+ ]
]
},
"webxr": {
diff --git a/tests/wpt/mozilla/tests/mozilla/zero_size_canvas_crash.html b/tests/wpt/mozilla/tests/mozilla/zero_size_canvas_crash.html
new file mode 100644
index 00000000000..45eb9b559e8
--- /dev/null
+++ b/tests/wpt/mozilla/tests/mozilla/zero_size_canvas_crash.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>Test for #21411: Panic when putting a zero-sized canvas on the display list.</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<canvas id="myCanvas" width="0" height="0" style="width:10px; height:10px;"></canvas>
+<script>
+ test(function () {
+ var c = document.getElementById("myCanvas");
+ var ctx = c.getContext("2d");
+ ctx.clearRect(0, 0, c.width, c.height);
+ }, "Doesn't crash when the page has a canvas with a zero-dimension");
+</script>