2020: add and call Fragment::build_display_list

This commit is contained in:
Simon Sapin 2019-10-07 16:37:53 +02:00
parent e38cc1a549
commit 4e8eeda976
3 changed files with 42 additions and 12 deletions

View file

@ -6,7 +6,7 @@ use crate::dom_traversal::{Contents, NodeExt};
use crate::flow::construct::ContainsFloats;
use crate::flow::float::FloatBox;
use crate::flow::{BlockContainer, BlockFormattingContext, BlockLevelBox};
use crate::fragments::Fragment;
use crate::fragments::{Fragment, IsContentful};
use crate::geom;
use crate::geom::flow_relative::Vec2;
use crate::positioned::AbsolutelyPositionedBox;
@ -21,6 +21,7 @@ use style::context::SharedStyleContext;
use style::properties::ComputedValues;
use style::values::computed::{Length, LengthOrAuto};
use style_traits::CSSPixel;
use webrender_api::DisplayListBuilder;
pub struct BoxTreeRoot(BlockFormattingContext);
pub struct FragmentTreeRoot(Vec<Fragment>);
@ -129,3 +130,13 @@ impl BoxTreeRoot {
FragmentTreeRoot(flow_children.fragments)
}
}
impl FragmentTreeRoot {
pub fn build_display_list(&self, builder: &mut DisplayListBuilder) -> IsContentful {
let mut is_contentful = IsContentful(false);
for fragment in &self.0 {
fragment.build_display_list(builder, &mut is_contentful)
}
is_contentful
}
}

View file

@ -9,6 +9,7 @@ use servo_arc::Arc;
use style::properties::ComputedValues;
use style::values::computed::Length;
use style::Zero;
use webrender_api::DisplayListBuilder;
pub(crate) enum Fragment {
Box(BoxFragment),
@ -123,3 +124,18 @@ impl CollapsedMargin {
self.max_positive + self.min_negative
}
}
/// 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 Fragment {
pub(crate) fn build_display_list(
&self,
builder: &mut DisplayListBuilder,
is_contentful: &mut IsContentful,
) {
}
}