Repository: servo/servo
File: components/constellation/constellation.rs (Rust)

Code before:
            self.update_active_keybord_modifiers(event);
        }

        // The constellation tracks the state of pressed mouse buttons and keyboard
        // modifiers and updates the event here to reflect the current state.
        let pressed_mouse_buttons = self.pressed_mouse_buttons;
        let active_keyboard_modifiers = self.active_keyboard_modifiers;

        let event_id = event.id;
        let Some(webview) = self.webviews.get_mut(&webview_id) else {
            warn!("Got input event for unknown WebViewId: {webview_id:?}");
            self.embedder_proxy.send(EmbedderMsg::InputEventHandled(
                webview_id,
                event_id,
                Default::default(),
            ));
            return;
        };

        let event = ConstellationInputEvent {
            hit_test_result,
            pressed_mouse_buttons,
            active_keyboard_modifiers,
            event,
        };

        if !webview.forward_input_event(event, &self.pipelines, &self.browsing_contexts) {
            self.embedder_proxy.send(EmbedderMsg::InputEventHandled(
                webview_id,
                event_id,
                Default::default(),
            ));
        }
    }

    #[servo_tracing::instrument(skip_all)]
    fn handle_new_top_level_browsing_context(
        &mut self,
        url: ServoUrl,
        NewWebViewDetails {
            webview_id,
            viewport_details,
            user_content_manager_id,
        }: NewWebViewDetails,
    ) {
        let pipeline_id = PipelineId::new();
        let browsing_context_id = BrowsingContextId::from(webview_id);
        let load_data = LoadData::new_for_new_unrelated_webview(url);
        let is_private = false;
        let throttled = false;


Review comment (suggestion):
@mrobinson said:

> Is the idea that this will be enabled or disabled per-WebView in the future? If so, the external-facing API should likely be on `WebView` in the API. If not (and I think that's a perfectly fine decision), then this code should probably iterate though each `EventLoop` by iterating through `Constellation::event_loops()` here.
>
> If you take the second approach, then in `ScriptThread` (there is one of these per-`EventLoop`), iterate through all `Document`s and enable / disable accessibility for every Layout.

Code after:
            NamedKey::SymbolLock => Modifiers::SYMBOL_LOCK,
            NamedKey::Hyper => Modifiers::HYPER,
            // The web doesn't make a distinction between these keys (there is only
            // "meta") so map "super" to "meta".
            NamedKey::Super => Modifiers::META,
            _ => return,
        };
        match event.event.state {
            KeyState::Down => self.active_keyboard_modifiers.insert(modified_modifier),
            KeyState::Up => self.active_keyboard_modifiers.remove(modified_modifier),
        }
    }

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

        self.accessibility_active = active;
        for event_loop in self.event_loops() {
            let _ = event_loop.send(ScriptThreadMessage::SetAccessibilityActive(active));
        }
    }

    fn forward_input_event(
        &mut self,
        webview_id: WebViewId,
        event: InputEventAndId,
        hit_test_result: Option<PaintHitTestResult>,
    ) {
        if let InputEvent::MouseButton(event) = &event.event {
            self.update_pressed_mouse_buttons(event);
        }

        if let InputEvent::Keyboard(event) = &event.event {
            self.update_active_keybord_modifiers(event);
        }

        // The constellation tracks the state of pressed mouse buttons and keyboard
        // modifiers and updates the event here to reflect the current state.
        let pressed_mouse_buttons = self.pressed_mouse_buttons;
        let active_keyboard_modifiers = self.active_keyboard_modifiers;

        let event_id = event.id;
        let Some(webview) = self.webviews.get_mut(&webview_id) else {
            warn!("Got input event for unknown WebViewId: {webview_id:?}");
            self.embedder_proxy.send(EmbedderMsg::InputEventHandled(
                webview_id,