Repository: servo/servo
File: components/paint/webview_renderer.rs (Rust)

Code before:
        // Do not remove pipeline details until both the Constellation and Script have
        // finished processing the pipeline shutdown. This prevents any followup messges
        // from re-adding the pipeline details and creating a zombie.
        if !pipeline.get().exited.is_all() {
            return;
        }

        pipeline.remove_entry();
    }

    pub(crate) fn set_frame_tree(&mut self, frame_tree: &SendableFrameTree) {
        let pipeline_id = frame_tree.pipeline.id;
        let old_pipeline_id = self.root_pipeline_id.replace(pipeline_id);

        if old_pipeline_id != self.root_pipeline_id {
            debug!(
                "Updating webview ({:?}) from pipeline {:?} to {:?}",
                3, old_pipeline_id, self.root_pipeline_id
            );
        }

        self.set_frame_tree_on_pipeline_details(frame_tree, None);
    }

    // FIXME: For now, we are sending the whole scroll offsets, but ideally we should consider the one that is
    //        actually scrolled. This is quite tricky due to the possibility of race.
    pub(crate) fn send_scroll_positions_to_layout_for_pipeline(
        &self,
        pipeline_id: PipelineId,
        scrolled_node: ExternalScrollId,
    ) {
        let Some(details) = self.pipelines.get(&pipeline_id) else {
            return;
        };

        let offsets = details.scroll_tree.scroll_offsets();

        // This might be true if we have not received a display list from the layout
        // associated with this pipeline yet. In that case, the layout is not ready to
        // receive scroll offsets anyway, so just save time and prevent other issues by
        // not sending them.
        if offsets.is_empty() {
            return;
        }

        let _ = self.embedder_to_constellation_sender.send(
            EmbedderToConstellationMessage::SetScrollStates(
                pipeline_id,
                ScrollStatesUpdate {
                    scrolled_node,
                    offsets,

Review comment (refactor):
Please remove this FIXME. I think we also need to take into account sticky positioning.

```suggestion
```

Code after:
        // Do not remove pipeline details until both the Constellation and Script have
        // finished processing the pipeline shutdown. This prevents any followup messges
        // from re-adding the pipeline details and creating a zombie.
        if !pipeline.get().exited.is_all() {
            return;
        }

        pipeline.remove_entry();
    }

    pub(crate) fn set_frame_tree(&mut self, frame_tree: &SendableFrameTree) {
        let pipeline_id = frame_tree.pipeline.id;
        let old_pipeline_id = self.root_pipeline_id.replace(pipeline_id);

        if old_pipeline_id != self.root_pipeline_id {
            debug!(
                "Updating webview ({:?}) from pipeline {:?} to {:?}",
                3, old_pipeline_id, self.root_pipeline_id
            );
        }

        self.set_frame_tree_on_pipeline_details(frame_tree, None);
    }

    pub(crate) fn send_scroll_positions_to_layout_for_pipeline(
        &self,
        pipeline_id: PipelineId,
        scrolled_node: ExternalScrollId,
    ) {
        let Some(details) = self.pipelines.get(&pipeline_id) else {
            return;
        };

        let offsets = details.scroll_tree.scroll_offsets();

        // This might be true if we have not received a display list from the layout
        // associated with this pipeline yet. In that case, the layout is not ready to
        // receive scroll offsets anyway, so just save time and prevent other issues by
        // not sending them.
        if offsets.is_empty() {
            return;
        }

        let _ = self.embedder_to_constellation_sender.send(
            EmbedderToConstellationMessage::SetScrollStates(
                pipeline_id,
                ScrollStateUpdate {
                    scrolled_node,
                    offsets,
                },
            ),