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

Code before:
            NamedKey::NumLock => Modifiers::NUM_LOCK,
            NamedKey::ScrollLock => Modifiers::SCROLL_LOCK,
            NamedKey::Shift => Modifiers::SHIFT,
            NamedKey::Symbol => Modifiers::SYMBOL,
            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;
        }

        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(

Review comment (suggestion):
I would add this basic bail out for when the embedder is asking us to constantly enable accessibility. This can avoid some downstream repercussions for a misbehaving embedder.

```suggestion
        if active == self.accessibility_active {
            return;
        }
        
        self.accessibility_active = active;
```

Code after:
            NamedKey::NumLock => Modifiers::NUM_LOCK,
            NamedKey::ScrollLock => Modifiers::SCROLL_LOCK,
            NamedKey::Shift => Modifiers::SHIFT,
            NamedKey::Symbol => Modifiers::SYMBOL,
            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;