Skip to content
Permalink
Browse files

Use the is_contentful field of DisplayListBuilder

  • Loading branch information
SimonSapin committed Jan 9, 2020
1 parent 062c187 commit 53fc6143dcbbdb2f8669e7260083e8ad7482218e
@@ -21,6 +21,11 @@ type HitInfo = Option<ItemTag>;
pub struct DisplayListBuilder {
current_space_and_clip: wr::SpaceAndClipInfo,
pub wr: wr::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 is_contentful: bool,
}

@@ -56,32 +61,25 @@ impl 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 Fragment {
pub(crate) fn build_display_list(
&self,
builder: &mut DisplayListBuilder,
is_contentful: &mut IsContentful,
containing_block: &Rect<Length>,
) {
match self {
Fragment::Box(b) => b.build_display_list(builder, is_contentful, containing_block),
Fragment::Box(b) => b.build_display_list(builder, containing_block),
Fragment::Anonymous(a) => {
let rect = a
.rect
.to_physical(a.mode, containing_block)
.translate(&containing_block.top_left);
for child in &a.children {
child.build_display_list(builder, is_contentful, &rect)
child.build_display_list(builder, &rect)
}
},
Fragment::Text(t) => {
is_contentful.0 = true;
builder.is_contentful = true;
let rect = t
.rect
.to_physical(t.parent_style.writing_mode, containing_block)
@@ -101,7 +99,7 @@ impl Fragment {
},
Fragment::Image(i) => {
use style::computed_values::image_rendering::T as ImageRendering;
is_contentful.0 = true;
builder.is_contentful = true;
let rect = i
.rect
.to_physical(i.style.writing_mode, containing_block)
@@ -129,7 +127,6 @@ impl BoxFragment {
fn build_display_list(
&self,
builder: &mut DisplayListBuilder,
is_contentful: &mut IsContentful,
containing_block: &Rect<Length>,
) {
let border_rect = self
@@ -147,7 +144,7 @@ impl BoxFragment {
.to_physical(self.style.writing_mode, containing_block)
.translate(&containing_block.top_left);
for child in &self.children {
child.build_display_list(builder, is_contentful, &content_rect)
child.build_display_list(builder, &content_rect)
}
}

@@ -3,7 +3,6 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::context::LayoutContext;
use crate::display_list::IsContentful;
use crate::dom_traversal::{Contents, NodeExt};
use crate::flow::construct::ContainsFloats;
use crate::flow::float::FloatBox;
@@ -140,7 +139,7 @@ impl FragmentTreeRoot {
&self,
builder: &mut crate::display_list::DisplayListBuilder,
viewport_size: webrender_api::units::LayoutSize,
) -> IsContentful {
) {
let containing_block = geom::physical::Rect {
top_left: geom::physical::Vec2 {
x: Length::zero(),
@@ -151,10 +150,8 @@ impl FragmentTreeRoot {
y: Length::new(viewport_size.height),
},
};
let mut is_contentful = IsContentful(false);
for fragment in &self.0 {
fragment.build_display_list(builder, &mut is_contentful, &containing_block)
fragment.build_display_list(builder, &containing_block)
}
is_contentful
}
}
@@ -1290,7 +1290,7 @@ impl LayoutThread {
self.viewport_size.height.to_f32_px(),
));
let mut display_list = DisplayListBuilder::new(self.id.to_webrender(), viewport_size);
let is_contentful = fragment_tree.build_display_list(&mut display_list, viewport_size);
fragment_tree.build_display_list(&mut display_list, viewport_size);

debug!("Layout done!");

@@ -1302,7 +1302,7 @@ impl LayoutThread {
// sending the display list to WebRender in order to set time related
// Progressive Web Metrics.
self.paint_time_metrics
.maybe_observe_paint_time(self, epoch, is_contentful.0);
.maybe_observe_paint_time(self, epoch, display_list.is_contentful);

self.webrender_api.send_display_list(
self.webrender_document,

0 comments on commit 53fc614

Please sign in to comment.
You can’t perform that action at this time.