From 474033c39f94709bb98912e7870c807bc495d8d3 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Thu, 10 Mar 2016 14:33:22 -0800 Subject: [PATCH] Simplify the display list slightly Now that WebRender uses an Iframe display item, we do not need the Noop item for the non-WebRender path. We can simply reuse the Iframe display item. Also remove the layer_id member from the LayeredItem struct, as it is unused. --- components/gfx/display_list/mod.rs | 7 ----- components/layout/display_list_builder.rs | 33 +++++++++-------------- components/layout/webrender_helpers.rs | 3 +-- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 516fd5cba60..34c78080f1f 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -744,7 +744,6 @@ pub enum DisplayItem { LineClass(Box), BoxShadowClass(Box), LayeredItemClass(Box), - NoopClass(Box), IframeClass(Box), } @@ -1168,9 +1167,6 @@ pub struct LayeredItem { /// Fields common to all display items. pub item: DisplayItem, - /// The id of the layer this item belongs to. - pub layer_id: LayerId, - /// The id of the layer this item belongs to. pub layer_info: LayerInfo, } @@ -1251,7 +1247,6 @@ impl DisplayItem { DisplayItem::LayeredItemClass(ref item) => item.item.draw_into_context(paint_context), - DisplayItem::NoopClass(_) => { } DisplayItem::IframeClass(..) => {} } } @@ -1280,7 +1275,6 @@ impl DisplayItem { DisplayItem::LineClass(ref line) => &line.base, DisplayItem::BoxShadowClass(ref box_shadow) => &box_shadow.base, DisplayItem::LayeredItemClass(ref layered_item) => layered_item.item.base(), - DisplayItem::NoopClass(ref base_item) => base_item, DisplayItem::IframeClass(ref iframe) => &iframe.base, } } @@ -1364,7 +1358,6 @@ impl fmt::Debug for DisplayItem { DisplayItem::BoxShadowClass(_) => "BoxShadow".to_owned(), DisplayItem::LayeredItemClass(ref layered_item) => format!("LayeredItem({:?})", layered_item.item), - DisplayItem::NoopClass(_) => "Noop".to_owned(), DisplayItem::IframeClass(_) => "Iframe".to_owned(), }, self.bounds(), diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 71411009272..4589848a0f5 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -1141,28 +1141,22 @@ impl FragmentDisplayListBuilding for Fragment { } SpecificFragmentInfo::Iframe(ref fragment_info) => { if !stacking_relative_content_box.is_empty() { + let item = DisplayItem::IframeClass(box IframeDisplayItem { + base: BaseDisplayItem::new( + &stacking_relative_content_box, + DisplayItemMetadata::new(self.node, + &*self.style, + Cursor::DefaultCursor), + clip), + iframe: fragment_info.pipeline_id, + }); + if opts::get().use_webrender { - state.add_display_item(DisplayItem::IframeClass(box IframeDisplayItem { - base: BaseDisplayItem::new( - &stacking_relative_content_box, - DisplayItemMetadata::new(self.node, - &*self.style, - Cursor::DefaultCursor), - clip), - iframe: fragment_info.pipeline_id, - }), DisplayListSection::Content); + state.add_display_item(item, DisplayListSection::Content); } else { - let layer_id = self.layer_id(); state.add_display_item(DisplayItem::LayeredItemClass(box LayeredItem { - item: DisplayItem::NoopClass( - box BaseDisplayItem::new( - &stacking_relative_content_box, - DisplayItemMetadata::new(self.node, - &*self.style, - Cursor::DefaultCursor), - clip)), - layer_id: layer_id, - layer_info: LayerInfo::new(layer_id, + item: item, + layer_info: LayerInfo::new(self.layer_id(), ScrollPolicy::Scrollable, Some(fragment_info.pipeline_id), color::transparent()), @@ -1248,7 +1242,6 @@ impl FragmentDisplayListBuilding for Fragment { } else { state.add_display_item(DisplayItem::LayeredItemClass(box LayeredItem { item: display_item, - layer_id: layer_id, layer_info: LayerInfo::new(layer_id, ScrollPolicy::Scrollable, None, diff --git a/components/layout/webrender_helpers.rs b/components/layout/webrender_helpers.rs index 68a6ea96ee7..37a3913dc7f 100644 --- a/components/layout/webrender_helpers.rs +++ b/components/layout/webrender_helpers.rs @@ -504,8 +504,7 @@ impl WebRenderDisplayItemConverter for DisplayItem { DisplayItem::LineClass(..) => { println!("TODO DisplayItem::LineClass"); } - DisplayItem::LayeredItemClass(..) | - DisplayItem::NoopClass(..) => { + DisplayItem::LayeredItemClass(..) => { panic!("Unexpected in webrender!"); } DisplayItem::BoxShadowClass(ref item) => {