Repository: versotile-org/verso
File: src/window.rs (Rust)

Code before:
        let surface = compositor
            .rendering_context
            .create_surface(&window)
            .unwrap();
        let panel = if with_panel {
            Some(Self::create_control_panel(&window))
        } else {
            None
        };
        let mut window = Self {
            window,
            surface,
            panel,
            webview: None,
            mouse_position: Cell::new(PhysicalPosition::default()),
            modifiers_state: Cell::new(ModifiersState::default()),
        };
        compositor.swap_current_window(&mut window);
        window
    }

    /// Create the control panel
    fn create_control_panel(window: &winit::window::Window) -> WebView {
        let size = window.inner_size();
        let size = Size2D::new(size.width as i32, size.height as i32);
        WebView::new_panel(DeviceIntRect::from_size(size))
    }

    /// Get the content area size for the webview to draw on
    pub fn get_content_rect(&self, mut size: DeviceIntRect) -> DeviceIntRect {
        if self.panel.is_some() {
            size.min.y = size.max.y.min(100);
            size.min.x += 10;
            size.max.y -= 10;
            size.max.x -= 10;
        }
        size
    }

    /// Send the constellation message to start Panel UI
    pub fn init_panel_webview(
        &mut self,
        resource_dir: &Path,
        constellation_sender: &Sender<ConstellationMsg>,
    ) {
        if let Some(panel) = &self.panel {
            let panel_id = panel.webview_id;
            let path = resource_dir.join("panel.html");
            let url = ServoUrl::from_file_path(path.to_str().unwrap()).unwrap();
            send_to_constellation(
                constellation_sender,

Review comment (suggestion):
This doesn't quite work in the second window, `PipelineNamespace::install(PipelineNamespaceId(0))` will panic, I'm not sure what does `PipelineNamespace` do

Code after:
        let surface = compositor
            .rendering_context
            .create_surface(&window)
            .unwrap();

        let mut window = Self {
            window,
            surface,
            panel: None,
            webview: None,
            mouse_position: Cell::new(PhysicalPosition::default()),
            modifiers_state: Cell::new(ModifiersState::default()),
        };
        compositor.swap_current_window(&mut window);
        window
    }

    /// Get the content area size for the webview to draw on
    pub fn get_content_size(&self, mut size: DeviceIntRect) -> DeviceIntRect {
        if self.panel.is_some() {
            size.min.y = size.max.y.min(100);
            size.min.x += 10;
            size.max.y -= 10;
            size.max.x -= 10;
        }
        size
    }

    /// Send the constellation message to start Panel UI
    pub fn create_panel(&mut self, constellation_sender: &Sender<ConstellationMsg>) {
        let size = self.window.inner_size();
        let size = Size2D::new(size.width as i32, size.height as i32);
        let panel_id = WebViewId::new();
        self.panel = Some(WebView::new(panel_id, DeviceIntRect::from_size(size)));

        let url = ServoUrl::parse("verso://panel.html").unwrap();
        send_to_constellation(
            constellation_sender,
            ConstellationMsg::NewWebView(url, panel_id),
        );
    }

    /// Handle Winit window event and return a boolean to indicate if the compositor should repaint immediately.
    pub fn handle_winit_window_event(
        &mut self,
        sender: &Sender<ConstellationMsg>,
        compositor: &mut IOCompositor,
        event: &winit::event::WindowEvent,
    ) -> bool {
        match event {
            WindowEvent::RedrawRequested => {