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

Code before:
        )));
        self.spin_event_loop();
    }

    pub fn media_session_action(&self, action: MediaSessionActionType) {
        if let Some(webview) = self.active_or_newest_webview() {
            webview.notify_media_session_action_event(action);
            self.spin_event_loop();
        }
    }

    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) };

Review comment (suggestion):
```suggestion
    // TODO: Instead of letting the embedder drive the RefreshDriver we should move the vsync
```

Code after:

    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 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))