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

Code before:
    }

    /// Go back in history.
    pub fn go_back(&self) {
        self.window()
            .queue_user_interface_command(UserInterfaceCommand::Back);
        self.spin_event_loop();
    }

    /// Go forward in history.
    pub fn go_forward(&self) {
        self.window()
            .queue_user_interface_command(UserInterfaceCommand::Forward);
        self.spin_event_loop();
    }

    /// Let Servo know that the window has been resized.
    pub fn resize(&self, viewport_rect: Rect<i32, DevicePixel>) {
        if let Some(webview) = self.active_or_newest_webview() {
            info!("Setting viewport to {viewport_rect:?}");
            let size = viewport_rect.size;
            webview.resize(PhysicalSize::new(size.width as u32, size.height as u32));
        }
        let window = self.window().platform_window();
        let ohos_window = window.as_headed_window().expect("No headed window");
        *ohos_window.viewport_rect.borrow_mut() = viewport_rect;

        self.spin_event_loop();
    }

    /// Scroll.
    /// x/y are scroll coordinates.
    /// dx/dy are scroll deltas.
    pub fn scroll(&self, dx: f32, dy: f32, x: f32, y: f32) {
        if let Some(webview) = self.active_or_newest_webview() {
            let scroll = Scroll::Delta(DeviceVector2D::new(dx, dy).into());
            let point = DevicePoint::new(x, y).into();
            webview.notify_scroll_event(scroll, point);
            self.spin_event_loop();
        }
    }

    /// Touch event: press down
    pub fn touch_down(&self, x: f32, y: f32, pointer_id: i32) {
        if let Some(webview) = self.active_or_newest_webview() {
            webview.notify_input_event(InputEvent::Touch(TouchEvent::new(
                TouchEventType::Down,
                TouchId(pointer_id),
                DevicePoint::new(x, y).into(),
            )));
            self.spin_event_loop();

Review comment (suggestion):
```suggestion
        let embedded_platform_window = window.as_headed_window().expect("No headed window");
        *embedded_platform_window.viewport_rect.borrow_mut() = viewport_rect;
```

Code after:
    pub fn go_forward(&self) {
        self.window()
            .queue_user_interface_command(UserInterfaceCommand::Forward);
        self.spin_event_loop();
    }

    /// Let Servo know that the window has been resized.
    pub fn resize(&self, viewport_rect: Rect<i32, DevicePixel>) {
        if let Some(webview) = self.active_or_newest_webview() {
            info!("Setting viewport to {viewport_rect:?}");
            let size = viewport_rect.size;
            webview.resize(PhysicalSize::new(size.width as u32, size.height as u32));
        }
        let window = self.window().platform_window();
        let embedded_platform_window = window.as_headed_window().expect("No headed window");
        *embedded_platform_window.viewport_rect.borrow_mut() = viewport_rect;

        self.spin_event_loop();
    }

    /// Scroll.
    /// x/y are scroll coordinates.
    /// dx/dy are scroll deltas.
    pub fn scroll(&self, dx: f32, dy: f32, x: f32, y: f32) {
        if let Some(webview) = self.active_or_newest_webview() {
            let scroll = Scroll::Delta(DeviceVector2D::new(dx, dy).into());
            let point = DevicePoint::new(x, y).into();
            webview.notify_scroll_event(scroll, point);
            self.spin_event_loop();
        }
    }

    /// Touch event: press down
    pub fn touch_down(&self, x: f32, y: f32, pointer_id: i32) {
        if let Some(webview) = self.active_or_newest_webview() {
            webview.notify_input_event(InputEvent::Touch(TouchEvent::new(
                TouchEventType::Down,
                TouchId(pointer_id),
                DevicePoint::new(x, y).into(),
            )));
            self.spin_event_loop();
        }
    }

    /// Touch event: move touching finger
    pub fn touch_move(&self, x: f32, y: f32, pointer_id: i32) {
        if let Some(webview) = self.active_or_newest_webview() {
            webview.notify_input_event(InputEvent::Touch(TouchEvent::new(
                TouchEventType::Move,
                TouchId(pointer_id),
                DevicePoint::new(x, y).into(),