Repository: servo/servo
File: ports/servoshell/desktop/headed_window.rs (Rust)

Code before:
                                    state: servo::CompositionState::Update,
                                    data: text,
                                },
                            )));
                        },
                        Ime::Commit(text) => {
                            webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
                                servo::CompositionEvent {
                                    state: servo::CompositionState::End,
                                    data: text,
                                },
                            )));
                        },
                        Ime::Disabled => {
                            webview.notify_input_event(InputEvent::Ime(ImeEvent::Dismissed));
                        },
                    },
                    _ => {},
                }
            }
        }
    }

    pub(crate) fn handle_winit_app_event(&self, _window: &ServoShellWindow, app_event: AppEvent) {
        if let AppEvent::Accessibility(ref event) = app_event {
            // TODO: handle a11y events on behalf of servo here

            if self
                .gui
                .borrow_mut()
                .handle_accesskit_event(&event.window_event)
            {
                self.winit_window.request_redraw();
            }
        }
    }
}

impl PlatformWindow for HeadedWindow {
    fn as_headed_window(&self) -> Option<&Self> {
        Some(self)
    }

    fn screen_geometry(&self) -> ScreenGeometry {
        let hidpi_factor = self.hidpi_scale_factor();
        let toolbar_size = Size2D::new(0.0, (self.toolbar_height() * self.hidpi_scale_factor()).0);
        let screen_size = self.screen_size.to_f32() * hidpi_factor;

        // FIXME: In reality, this should subtract screen space used by the system interface
        // elements, but it is difficult to get this value with `winit` currently. See:
        // See https://github.com/rust-windowing/winit/issues/2494

Review comment (suggestion):
Could this read something like the below?

```suggestion
            // TODO(#41930): Forward accesskit_winit::WindowEvent events to Servo where appropriate
```

Code after:
                                    data: text,
                                },
                            )));
                        },
                        Ime::Commit(text) => {
                            webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
                                servo::CompositionEvent {
                                    state: servo::CompositionState::End,
                                    data: text,
                                },
                            )));
                        },
                        Ime::Disabled => {
                            webview.notify_input_event(InputEvent::Ime(ImeEvent::Dismissed));
                        },
                    },
                    _ => {},
                }
            }
        }
    }

    pub(crate) fn handle_winit_app_event(&self, _window: &ServoShellWindow, app_event: AppEvent) {
        if let AppEvent::Accessibility(ref event) = app_event {
            // TODO(#41930): Forward accesskit_winit::WindowEvent events to Servo where appropriate

            if self
                .gui
                .borrow_mut()
                .handle_accesskit_event(&event.window_event)
            {
                self.winit_window.request_redraw();
            }
        }
    }
}

impl PlatformWindow for HeadedWindow {
    fn as_headed_window(&self) -> Option<&Self> {
        Some(self)
    }

    fn screen_geometry(&self) -> ScreenGeometry {
        let hidpi_factor = self.hidpi_scale_factor();
        let toolbar_size = Size2D::new(0.0, (self.toolbar_height() * self.hidpi_scale_factor()).0);
        let screen_size = self.screen_size.to_f32() * hidpi_factor;

        // FIXME: In reality, this should subtract screen space used by the system interface
        // elements, but it is difficult to get this value with `winit` currently. See:
        // See https://github.com/rust-windowing/winit/issues/2494
        let available_screen_size = screen_size - toolbar_size;