From f362f6f93bc79de6ba32995cdd96382dc5bc311f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Thu, 2 Feb 2017 04:42:44 +0300 Subject: [PATCH] Fix the panic when transform is non-invertible --- components/gfx/display_list/mod.rs | 9 ++++++- tests/wpt/mozilla/meta/MANIFEST.json | 10 +++++++ .../mozilla/non-invertible-transform.html | 26 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/tests/mozilla/non-invertible-transform.html diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index ec3173cb847..af4b793c6b2 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -182,7 +182,14 @@ impl DisplayList { *client_point } else { let point = *translated_point - stacking_context.bounds.origin; - let inv_transform = stacking_context.transform.inverse().unwrap(); + let inv_transform = match stacking_context.transform.inverse() { + Some(transform) => transform, + None => { + // If a transform function causes the current transformation matrix of an object + // to be non-invertible, the object and its content do not get displayed. + return; + } + }; let frac_point = inv_transform.transform_point(&Point2D::new(point.x.to_f32_px(), point.y.to_f32_px())); Point2D::new(Au::from_f32_px(frac_point.x), Au::from_f32_px(frac_point.y)) diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index c73fdd4a390..c199b547b38 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -13321,6 +13321,12 @@ {} ] ], + "mozilla/non-invertible-transform.html": [ + [ + "/_mozilla/mozilla/non-invertible-transform.html", + {} + ] + ], "mozilla/out-of-order-stylesheet-loads-and-imports.html": [ [ "/_mozilla/mozilla/out-of-order-stylesheet-loads-and-imports.html", @@ -25886,6 +25892,10 @@ "fe965e58fdcb78d08384a9fde74c982e34768745", "testharness" ], + "mozilla/non-invertible-transform.html": [ + "6fa68fe08c9dd5d594e838da51617951193fee19", + "testharness" + ], "mozilla/out-of-order-stylesheet-loads-and-imports.html": [ "462f5b6a1f47e0e40ad407ccd13b3058176d106d", "testharness" diff --git a/tests/wpt/mozilla/tests/mozilla/non-invertible-transform.html b/tests/wpt/mozilla/tests/mozilla/non-invertible-transform.html new file mode 100644 index 00000000000..f03c9c01344 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/non-invertible-transform.html @@ -0,0 +1,26 @@ + + + + + Shouldn't panic when transform is non-invertible + + + + + +
+ + +