From b7e05b4a9d5cc65cf5a68f9fab111d42932cd711 Mon Sep 17 00:00:00 2001 From: Daosheng Mu Date: Thu, 28 Apr 2016 07:03:45 +0800 Subject: [PATCH 1/2] Avoid drawing while canvases without contexts. --- components/layout/display_list_builder.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index fb2847e9d77..de76e2b20cc 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -13,7 +13,7 @@ use app_units::{Au, AU_PER_PX}; use azure::azure_hl::Color; use block::{BlockFlow, BlockStackingContextType}; -use canvas_traits::{CanvasMsg, CanvasPixelData, CanvasData, FromLayoutMsg}; +use canvas_traits::{CanvasMsg, CanvasData, FromLayoutMsg}; use context::LayoutContext; use euclid::num::Zero; use euclid::{Matrix4D, Point2D, Point3D, Rect, SideOffsets2D, Size2D}; @@ -34,7 +34,7 @@ use gfx::paint_thread::THREAD_TINT_COLORS; use gfx::text::glyph::CharIndex; use gfx_traits::{color, ScrollPolicy}; use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT}; -use ipc_channel::ipc::{self, IpcSharedMemory}; +use ipc_channel::ipc::{self}; use list_item::ListItemFlow; use model::{self, MaybeAuto, ToGfxMatrix}; use net_traits::image::base::PixelFormat; @@ -1259,13 +1259,7 @@ impl FragmentDisplayListBuilding for Fragment { FromLayoutMsg::SendData(sender))).unwrap(); receiver.recv().unwrap() }, - None => CanvasData::Pixels(CanvasPixelData { - image_data: IpcSharedMemory::from_byte(0xFFu8, - (computed_width * - computed_height * 4) - as usize), - image_key: None, - }), + None => return, }; let base = state.create_base_display_item( From f97e6ab9caa702a550a75aadecfd44a6d3de7622 Mon Sep 17 00:00:00 2001 From: Daosheng Mu Date: Thu, 28 Apr 2016 07:04:34 +0800 Subject: [PATCH 2/2] Add test for canvases without contexts. --- tests/wpt/mozilla/meta/MANIFEST.json | 24 +++++++++++++++++++ .../tests/css/canvas_without_context_a.html | 15 ++++++++++++ .../tests/css/canvas_without_context_ref.html | 14 +++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/wpt/mozilla/tests/css/canvas_without_context_a.html create mode 100644 tests/wpt/mozilla/tests/css/canvas_without_context_ref.html diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 4285757014f..b57efe99a79 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -1212,6 +1212,18 @@ "url": "/_mozilla/css/canvas_radial_gradient_a.html" } ], + "css/canvas_without_context_a.html": [ + { + "path": "css/canvas_without_context_a.html", + "references": [ + [ + "/_mozilla/css/canvas_without_context_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/canvas_without_context_a.html" + } + ], "css/case-insensitive-font-family.html": [ { "path": "css/case-insensitive-font-family.html", @@ -7940,6 +7952,18 @@ "url": "/_mozilla/css/canvas_radial_gradient_a.html" } ], + "css/canvas_without_context_a.html": [ + { + "path": "css/canvas_without_context_a.html", + "references": [ + [ + "/_mozilla/css/canvas_without_context_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/canvas_without_context_a.html" + } + ], "css/case-insensitive-font-family.html": [ { "path": "css/case-insensitive-font-family.html", diff --git a/tests/wpt/mozilla/tests/css/canvas_without_context_a.html b/tests/wpt/mozilla/tests/css/canvas_without_context_a.html new file mode 100644 index 00000000000..b7398f8d59c --- /dev/null +++ b/tests/wpt/mozilla/tests/css/canvas_without_context_a.html @@ -0,0 +1,15 @@ + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/css/canvas_without_context_ref.html b/tests/wpt/mozilla/tests/css/canvas_without_context_ref.html new file mode 100644 index 00000000000..ae0c9c8c8e0 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/canvas_without_context_ref.html @@ -0,0 +1,14 @@ + + + + + +
+ +