aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/display_list/webrender_helpers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/display_list/webrender_helpers.rs')
-rw-r--r--components/layout/display_list/webrender_helpers.rs53
1 files changed, 34 insertions, 19 deletions
diff --git a/components/layout/display_list/webrender_helpers.rs b/components/layout/display_list/webrender_helpers.rs
index a27979a3189..993e2b38cef 100644
--- a/components/layout/display_list/webrender_helpers.rs
+++ b/components/layout/display_list/webrender_helpers.rs
@@ -17,10 +17,6 @@ use webrender_api::{
RasterSpace, ReferenceFrameKind, SpaceAndClipInfo, SpatialId, StackingContext,
};
-pub trait WebRenderDisplayListConverter {
- fn convert_to_webrender(&mut self, pipeline_id: PipelineId) -> DisplayListBuilder;
-}
-
struct ClipScrollState {
clip_ids: Vec<Option<ClipId>>,
spatial_ids: Vec<Option<SpatialId>>,
@@ -28,17 +24,17 @@ struct ClipScrollState {
active_spatial_id: SpatialId,
}
-trait WebRenderDisplayItemConverter {
- fn convert_to_webrender(
- &mut self,
- clip_scroll_nodes: &[ClipScrollNode],
- state: &mut ClipScrollState,
- builder: &mut DisplayListBuilder,
- );
-}
+/// Contentful paint, for the purpose of
+/// https://w3c.github.io/paint-timing/#first-contentful-paint
+/// (i.e. the display list contains items of type text,
+/// image, non-white canvas or SVG). Used by metrics.
+pub struct IsContentful(pub bool);
-impl WebRenderDisplayListConverter for DisplayList {
- fn convert_to_webrender(&mut self, pipeline_id: PipelineId) -> DisplayListBuilder {
+impl DisplayList {
+ pub fn convert_to_webrender(
+ &mut self,
+ pipeline_id: PipelineId,
+ ) -> (DisplayListBuilder, IsContentful) {
let mut clip_ids = vec![None; self.clip_scroll_nodes.len()];
let mut spatial_ids = vec![None; self.clip_scroll_nodes.len()];
@@ -67,21 +63,24 @@ impl WebRenderDisplayListConverter for DisplayList {
1024 * 1024, // 1 MB of space
);
+ let mut is_contentful = IsContentful(false);
for item in &mut self.list {
- item.convert_to_webrender(&self.clip_scroll_nodes, &mut state, &mut builder);
+ is_contentful.0 |= item
+ .convert_to_webrender(&self.clip_scroll_nodes, &mut state, &mut builder)
+ .0;
}
- builder
+ (builder, is_contentful)
}
}
-impl WebRenderDisplayItemConverter for DisplayItem {
+impl DisplayItem {
fn convert_to_webrender(
&mut self,
clip_scroll_nodes: &[ClipScrollNode],
state: &mut ClipScrollState,
builder: &mut DisplayListBuilder,
- ) {
+ ) -> IsContentful {
// Note: for each time of a display item, if we register one of `clip_ids` or `spatial_ids`,
// we also register the other one as inherited from the current state or the stack.
// This is not an ideal behavior, but it is compatible with the old WebRender model
@@ -109,15 +108,18 @@ impl WebRenderDisplayItemConverter for DisplayItem {
DisplayItem::Rectangle(ref mut item) => {
item.item.common = build_common_item_properties(&item.base, state);
builder.push_item(&WrDisplayItem::Rectangle(item.item));
+ IsContentful(false)
},
DisplayItem::Text(ref mut item) => {
item.item.common = build_common_item_properties(&item.base, state);
builder.push_item(&WrDisplayItem::Text(item.item));
builder.push_iter(item.data.iter());
+ IsContentful(true)
},
DisplayItem::Image(ref mut item) => {
item.item.common = build_common_item_properties(&item.base, state);
builder.push_item(&WrDisplayItem::Image(item.item));
+ IsContentful(true)
},
DisplayItem::Border(ref mut item) => {
item.item.common = build_common_item_properties(&item.base, state);
@@ -125,24 +127,29 @@ impl WebRenderDisplayItemConverter for DisplayItem {
builder.push_stops(item.data.as_ref());
}
builder.push_item(&WrDisplayItem::Border(item.item));
+ IsContentful(false)
},
DisplayItem::Gradient(ref mut item) => {
item.item.common = build_common_item_properties(&item.base, state);
builder.push_stops(item.data.as_ref());
builder.push_item(&WrDisplayItem::Gradient(item.item));
+ IsContentful(false)
},
DisplayItem::RadialGradient(ref mut item) => {
item.item.common = build_common_item_properties(&item.base, state);
builder.push_stops(item.data.as_ref());
builder.push_item(&WrDisplayItem::RadialGradient(item.item));
+ IsContentful(false)
},
DisplayItem::Line(ref mut item) => {
item.item.common = build_common_item_properties(&item.base, state);
builder.push_item(&WrDisplayItem::Line(item.item));
+ IsContentful(false)
},
DisplayItem::BoxShadow(ref mut item) => {
item.item.common = build_common_item_properties(&item.base, state);
builder.push_item(&WrDisplayItem::BoxShadow(item.item));
+ IsContentful(false)
},
DisplayItem::PushTextShadow(ref mut item) => {
let common = build_common_item_properties(&item.base, state);
@@ -154,9 +161,11 @@ impl WebRenderDisplayItemConverter for DisplayItem {
item.shadow,
true,
);
+ IsContentful(false)
},
DisplayItem::PopAllTextShadows(_) => {
builder.push_item(&WrDisplayItem::PopAllShadows);
+ IsContentful(false)
},
DisplayItem::Iframe(ref mut item) => {
let common = build_common_item_properties(&item.base, state);
@@ -170,6 +179,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
item.iframe.to_webrender(),
true,
);
+ IsContentful(false)
},
DisplayItem::PushStackingContext(ref mut item) => {
let stacking_context = &item.stacking_context;
@@ -235,8 +245,12 @@ impl WebRenderDisplayItemConverter for DisplayItem {
};
builder.push_item(&WrDisplayItem::PushStackingContext(wr_item));
+ IsContentful(false)
+ },
+ DisplayItem::PopStackingContext(_) => {
+ builder.pop_stacking_context();
+ IsContentful(false)
},
- DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(),
DisplayItem::DefineClipScrollNode(ref mut item) => {
let node = &clip_scroll_nodes[item.node_index.to_index()];
let item_rect = node.clip.main;
@@ -298,6 +312,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
unreachable!("Found DefineClipScrollNode for Placeholder type node.");
},
};
+ IsContentful(false)
},
}
}