Repository: servo/servo
File: components/compositing/largest_contentful_paint_calculator.rs (Rust)

Code before:
        if self.disabled_lcp_for_webviews.contains(&webview_id) {
            return false;
        }
        self.lcp_containers
            .entry(pipeline_id)
            .or_default()
            .lcp_candidates
            .push(candidate);
        true
    }

    pub fn remove_lcp_candidates_for_pipeline(&mut self, pipeline_id: PipelineId) {
        self.lcp_containers.remove(&pipeline_id);
    }

    pub fn calculate_largest_contentful_paint(
        &mut self,
        paint_time: CrossProcessInstant,
        pipeline_id: PipelineId,
    ) -> Option<LargestContentfulPaint> {
        self.lcp_containers
            .get_mut(&pipeline_id)
            .and_then(|container| container.calculate_largest_contentful_paint(paint_time))
    }

    pub fn add_to_disabled_lcp_webviews(&mut self, webview_id: WebViewId) {
        self.disabled_lcp_for_webviews.insert(webview_id);
    }

    pub fn clear(&mut self) {
        self.lcp_containers.clear();
        self.disabled_lcp_for_webviews.clear();
    }
}

/// Holds the LCP candidates and the latest LCP for a specific pipeline.
#[derive(Default)]
struct LargestContentfulPaintsContainer {
    /// List of candidates for Largest Contentful Paint in this pipeline.
    lcp_candidates: Vec<LCPCandidate>,
    /// The most recent Largest Contentful Paint, if any.
    latest_lcp: Option<LargestContentfulPaint>,
}

impl LargestContentfulPaintsContainer {
    fn calculate_largest_contentful_paint(
        &mut self,
        paint_time: CrossProcessInstant,
    ) -> Option<LargestContentfulPaint> {
        if self.lcp_candidates.is_empty() {
            return self.latest_lcp;

Review comment (suggestion):
```suggestion
    pub(crate) fn add_to_disabled_lcp_webviews(&mut self, webview_id: WebViewId) {
```

Code after:
        if self.disabled_lcp_for_webviews.contains(&webview_id) {
            return false;
        }
        self.lcp_containers
            .entry(pipeline_id)
            .or_default()
            .lcp_candidates
            .push(candidate);
        true
    }

    pub(crate) fn remove_lcp_candidates_for_pipeline(&mut self, pipeline_id: PipelineId) {
        self.lcp_containers.remove(&pipeline_id);
    }

    pub(crate) fn calculate_largest_contentful_paint(
        &mut self,
        paint_time: CrossProcessInstant,
        pipeline_id: PipelineId,
    ) -> Option<LargestContentfulPaint> {
        self.lcp_containers
            .get_mut(&pipeline_id)
            .and_then(|container| container.calculate_largest_contentful_paint(paint_time))
    }

    pub(crate) fn add_to_disabled_lcp_webviews(&mut self, webview_id: WebViewId) {
        self.disabled_lcp_for_webviews.insert(webview_id);
    }

    pub(crate) fn clear(&mut self) {
        self.lcp_containers.clear();
        self.disabled_lcp_for_webviews.clear();
    }
}

/// Holds the LCP candidates and the latest LCP for a specific pipeline.
#[derive(Default)]
struct LargestContentfulPaintsContainer {
    /// List of candidates for Largest Contentful Paint in this pipeline.
    lcp_candidates: Vec<LCPCandidate>,
    /// The most recent Largest Contentful Paint, if any.
    latest_lcp: Option<LargestContentfulPaint>,
}

impl LargestContentfulPaintsContainer {
    fn calculate_largest_contentful_paint(
        &mut self,
        paint_time: CrossProcessInstant,
    ) -> Option<LargestContentfulPaint> {
        if self.lcp_candidates.is_empty() {
            return self.latest_lcp;