Repository: servo/servo
File: ports/servoshell/egl/app.rs (Rust)

Code before:
        }
    }

    pub fn set_throttled(&self, throttled: bool) {
        if let Some(webview) = self.active_or_newest_webview() {
            webview.set_throttled(throttled);
            self.spin_event_loop();
        }
    }

    pub fn ime_dismissed(&self) {
        if let Some(webview) = self.active_or_newest_webview() {
            webview.notify_input_event(InputEvent::Ime(ImeEvent::Dismissed));
            self.spin_event_loop();
        }
    }

    // TODO: Instead of letting the embedder drive the refresh-driver, we should move the vsync
    // notification directly into the VsyncRefreshDriver.
    pub fn notify_vsync(&self) {
        self.refresh_driver.notify_vsync();
        self.spin_event_loop();
    }

    pub fn pause_painting(&self) {
        if let Err(e) = self
            .window_rendering_context
            .borrow()
            .as_ref()
            .expect("")
            .take_window()
        {
            warn!("Unbinding native surface from context failed ({:?})", e);
        }
        self.spin_event_loop();
    }

    pub fn resume_painting(
        &self,
        window_handle: RawWindowHandle,
        viewport_rect: Rect<i32, DevicePixel>,
    ) {
        let window_handle = unsafe { WindowHandle::borrow_raw(window_handle) };
        let size = viewport_rect.size.to_u32();
        if let Err(error) = self
            .window_rendering_context
            .borrow_mut()
            .as_mut()
            .expect("resume_painting called but platform window does not exist")
            .set_window(window_handle, PhysicalSize::new(size.width, size.height))
        {

Review comment (suggestion):
```suggestion
        if let Err(error) = self
```

Code after:
    pub fn ime_dismissed(&self) {
        if let Some(webview) = self.active_or_newest_webview() {
            webview.notify_input_event(InputEvent::Ime(ImeEvent::Dismissed));
            self.spin_event_loop();
        }
    }

    // TODO: Instead of letting the embedder drive the RefreshDriver we should move the vsync
    // notification directly into the VsyncRefreshDriver.
    pub fn notify_vsync(&self) {
        let platform_window = self.window().platform_window();
        let embedded_platform_window = platform_window
            .as_headed_window()
            .expect("No headed window");
        embedded_platform_window.refresh_driver.notify_vsync();
        self.spin_event_loop();
    }

    pub fn pause_painting(&self) {
        let platform_window = self.window().platform_window();
        let embedded_platform_window = platform_window
            .as_headed_window()
            .expect("No headed window");
        if let Err(error) = embedded_platform_window.rendering_context.take_window() {
            warn!("Unbinding native surface from context failed ({error:?})");
        }
        self.spin_event_loop();
    }

    pub fn resume_painting(
        &self,
        window_handle: RawWindowHandle,
        viewport_rect: Rect<i32, DevicePixel>,
    ) {
        let window_handle = unsafe { WindowHandle::borrow_raw(window_handle) };
        let size = viewport_rect.size.to_u32();
        let platform_window = self.window().platform_window();
        let embedded_platform_window = platform_window
            .as_headed_window()
            .expect("No headed window");
        if let Err(error) = embedded_platform_window
            .rendering_context
            .set_window(window_handle, PhysicalSize::new(size.width, size.height))
        {
            warn!("Binding native surface to context failed ({error:?})");
        }
        self.spin_event_loop();
    }
}

#[cfg(feature = "webxr")]