Repository: servo/servo
File: components/layout/display_list/mod.rs (Rust)

Code before:
                            builder.wr().push_repeating_image(
                                &layer.common,
                                layer.bounds,
                                layer.tile_size,
                                layer.tile_spacing,
                                style.clone_image_rendering().to_webrender(),
                                wr::AlphaType::PremultipliedAlpha,
                                image_key,
                                wr::ColorF::WHITE,
                            )
                        } else {
                            builder.wr().push_image(
                                &layer.common,
                                layer.bounds,
                                style.clone_image_rendering().to_webrender(),
                                wr::AlphaType::PremultipliedAlpha,
                                image_key,
                                wr::ColorF::WHITE,
                            )
                        }

                        if let Some(lcp_collector) = &mut builder.lcp_candidate_collector {
                            let transform = builder
                                .compositor_info
                                .scroll_tree
                                .cumulative_node_to_root_transform(builder.current_scroll_node_id);
                            let area = transform_au_rectangle(
                                f32_rect_to_au_rect(layer.bounds.to_rect().to_untyped()),
                                transform,
                            );
                            dbg!(area);
                            if let Some(a) = area {
                                dbg!(a.size.width.to_f32_px() * a.size.height.to_f32_px());
                            }
                            // let Some(a) = area {
                            //     dbg!(a);
                            // }
                            // lcp_collector.add_candidate(LCPCandidate {
                            //     id: 0,
                            //     area:0,
                            //     epoch: builder.compositor_info.epoch,
                            // });
                        }
                    }
                },
            }
        }
    }

    fn build_border_side(&mut self, style_color: BorderStyleColor) -> wr::BorderSide {
        wr::BorderSide {

Review comment (suggestion):
This is closer to what I imagined. Thanks!

I think the next steps are:
1. Move the calculation of `area` into `LCPCollector.add_candidate`
2. Also take clipping into account

In the end, this will probably be similar to Blink's [PaintTimingDetector](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/paint/timing/paint_timing_detector.h;l=46;drc=62a9a00176f862e688fa47919ed6f19b59f77b5f)

Code after:
                    if let Some(layer) = layer {
                        if layer.repeat {
                            builder.wr().push_repeating_image(
                                &layer.common,
                                layer.bounds,
                                layer.tile_size,
                                layer.tile_spacing,
                                style.clone_image_rendering().to_webrender(),
                                wr::AlphaType::PremultipliedAlpha,
                                image_key,
                                wr::ColorF::WHITE,
                            )
                        } else {
                            builder.wr().push_image(
                                &layer.common,
                                layer.bounds,
                                style.clone_image_rendering().to_webrender(),
                                wr::AlphaType::PremultipliedAlpha,
                                image_key,
                                wr::ColorF::WHITE,
                            )
                        }

                        let lcp_candidate_id = self
                            .fragment
                            .base
                            .tag
                            .map(|tag| LCPCandidateID(tag.node.id()))
                            .unwrap_or(LCPCandidateID(0));
                        builder.collect_lcp_candidate(
                            LargestContentfulPaintType::BackgroundImage,
                            lcp_candidate_id,
                            layer.common.clip_rect,
                            layer.bounds,
                        );
                    }
                },
            }
        }
    }

    fn build_border_side(&mut self, style_color: BorderStyleColor) -> wr::BorderSide {
        wr::BorderSide {
            color: rgba(style_color.color),
            style: match style_color.style {
                BorderStyle::None => wr::BorderStyle::None,
                BorderStyle::Solid => wr::BorderStyle::Solid,
                BorderStyle::Double => wr::BorderStyle::Double,
                BorderStyle::Dotted => wr::BorderStyle::Dotted,
                BorderStyle::Dashed => wr::BorderStyle::Dashed,
                BorderStyle::Hidden => wr::BorderStyle::Hidden,