Repository: servo/servo
File: components/script/script_thread.rs (Rust)

Code before:
        &self,
        webview_id: WebViewId,
        pipeline_id: PipelineId,
        event: ConstellationInputEvent,
    ) {
        let Some(document) = self.documents.borrow().find_document(pipeline_id) else {
            warn!("Input event sent to closed pipeline {pipeline_id}.");
            let _ = self
                .senders
                .pipeline_to_embedder_sender
                .send(EmbedderMsg::InputEventHandled(
                    webview_id,
                    event.event.id,
                    Default::default(),
                ));
            return;
        };
        document.event_handler().note_pending_input_event(event);
    }

    fn set_accessibility_active(&self, active: bool) {
        if !(pref!(accessibility_enabled)) {
            return;
        }

        self.accessibility_active.replace(active);
        for (_, document) in self.documents.borrow().iter() {
            let window = document.window();
            let layout = window.layout();
            layout.set_accessibility_active(active);
        }
    }

    /// Handle a "navigate an iframe" message from the constellation.
    fn handle_navigate_iframe(
        &self,
        parent_pipeline_id: PipelineId,
        browsing_context_id: BrowsingContextId,
        load_data: LoadData,
        history_handling: NavigationHistoryBehavior,
        can_gc: CanGc,
    ) {
        let iframe = self
            .documents
            .borrow()
            .find_iframe(parent_pipeline_id, browsing_context_id);
        if let Some(iframe) = iframe {
            iframe.navigate_or_reload_child_browsing_context(load_data, history_handling, can_gc);
        }
    }


Review comment (suggestion):
We try to be a bit defensive about this in other places, so maybe good here too:

```suggestion
        let old_value = self.accessibility_active.replace(active);
        if old_value == active {
            return;
        }
```

Code after:
        &self,
        webview_id: WebViewId,
        pipeline_id: PipelineId,
        event: ConstellationInputEvent,
    ) {
        let Some(document) = self.documents.borrow().find_document(pipeline_id) else {
            warn!("Input event sent to closed pipeline {pipeline_id}.");
            let _ = self
                .senders
                .pipeline_to_embedder_sender
                .send(EmbedderMsg::InputEventHandled(
                    webview_id,
                    event.event.id,
                    Default::default(),
                ));
            return;
        };
        document.event_handler().note_pending_input_event(event);
    }

    fn set_accessibility_active(&self, active: bool) {
        if !(pref!(accessibility_enabled)) {
            return;
        }

        let old_value = self.accessibility_active.replace(active);
        if active == old_value {
            return;
        }

        for (_, document) in self.documents.borrow().iter() {
            document.window().layout().set_accessibility_active(active);
        }
    }

    /// Handle a "navigate an iframe" message from the constellation.
    fn handle_navigate_iframe(
        &self,
        parent_pipeline_id: PipelineId,
        browsing_context_id: BrowsingContextId,
        load_data: LoadData,
        history_handling: NavigationHistoryBehavior,
        can_gc: CanGc,
    ) {
        let iframe = self
            .documents
            .borrow()
            .find_iframe(parent_pipeline_id, browsing_context_id);
        if let Some(iframe) = iframe {
            iframe.navigate_or_reload_child_browsing_context(load_data, history_handling, can_gc);
        }