diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-03-21 15:55:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-21 14:55:00 +0000 |
commit | 54244797688fbeec85baac6fcfc9b71d555bf72c (patch) | |
tree | 5e9914cce8a83a8d8b171da0ead4d6f1cf725ca5 /components/layout_2020 | |
parent | 1f232eb17c031fe18035a17249de99b2af6fa53e (diff) | |
download | servo-54244797688fbeec85baac6fcfc9b71d555bf72c.tar.gz servo-54244797688fbeec85baac6fcfc9b71d555bf72c.zip |
metrics: Simplify `ProgressiveWebMetrics` (#35985)
Simply how `ProgressiveWebMetrics` works:
1. Keep only a single struct instead of one in layout and one script
that both implement the `ProgressiveWebMetrics` trait. Since layout
and script are the same thread these can now just be a single
`ProgressiveWebMetrics` struct stored in script.
2. Have the compositor be responsible for informing the Constellation
(which informs the ScripThread) about paint metrics. This makes
communication flow one way and removes one dependency between the
compositor and script (of two).
3. All units tests are moved into the `metrics` crate itself since there
is only one struct there now.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/layout_2020')
-rw-r--r-- | components/layout_2020/display_list/mod.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs index 696aecefeda..4ba62041099 100644 --- a/components/layout_2020/display_list/mod.rs +++ b/components/layout_2020/display_list/mod.rs @@ -102,6 +102,7 @@ impl DisplayList { pipeline_id: wr::PipelineId, epoch: wr::Epoch, viewport_scroll_sensitivity: AxesScrollSensitivity, + first_reflow: bool, ) -> Self { Self { wr: wr::DisplayListBuilder::new(pipeline_id), @@ -111,6 +112,7 @@ impl DisplayList { pipeline_id, epoch, viewport_scroll_sensitivity, + first_reflow, ), spatial_tree_count: 0, } @@ -161,11 +163,6 @@ pub(crate) struct DisplayListBuilder<'a> { /// The [DisplayList] used to collect display list items and metadata. pub display_list: &'a mut DisplayList, - - /// Contentful paint i.e. whether the display list contains items of type - /// text, image, non-white canvas or SVG). Used by metrics. - /// See <https://w3c.github.io/paint-timing/#first-contentful-paint>. - is_contentful: bool, } impl DisplayList { @@ -175,7 +172,7 @@ impl DisplayList { context: &LayoutContext, fragment_tree: &FragmentTree, root_stacking_context: &StackingContext, - ) -> bool { + ) { #[cfg(feature = "tracing")] let _span = tracing::trace_span!("display_list::build", servo_profiling = true).entered(); let mut builder = DisplayListBuilder { @@ -183,12 +180,10 @@ impl DisplayList { current_reference_frame_scroll_node_id: self.compositor_info.root_reference_frame_id, current_clip_chain_id: ClipChainId::INVALID, element_for_canvas_background: fragment_tree.canvas_background.from_element, - is_contentful: false, context, display_list: self, }; fragment_tree.build_display_list(&mut builder, root_stacking_context); - builder.is_contentful } } @@ -197,6 +192,10 @@ impl DisplayListBuilder<'_> { &mut self.display_list.wr } + fn mark_is_contentful(&mut self) { + self.display_list.compositor_info.is_contentful = true; + } + fn common_properties( &self, clip_rect: units::LayoutRect, @@ -282,7 +281,7 @@ impl Fragment { let image = image.borrow(); match image.style.get_inherited_box().visibility { Visibility::Visible => { - builder.is_contentful = true; + builder.mark_is_contentful(); let image_rendering = image .style @@ -318,7 +317,7 @@ impl Fragment { let iframe = iframe.borrow(); match iframe.style.get_inherited_box().visibility { Visibility::Visible => { - builder.is_contentful = true; + builder.mark_is_contentful(); let rect = iframe.rect.translate(containing_block.origin.to_vector()); let common = builder.common_properties(rect.to_webrender(), &iframe.style); @@ -384,7 +383,7 @@ impl Fragment { // NB: The order of painting text components (CSS Text Decoration Module Level 3) is: // shadows, underline, overline, text, text-emphasis, and then line-through. - builder.is_contentful = true; + builder.mark_is_contentful(); let rect = fragment.rect.translate(containing_block.origin.to_vector()); let mut baseline_origin = rect.origin; |