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

Code before:
    fn show_permission_dialog(&self, webview_id: WebViewId, permission_request: PermissionRequest) {
        self.add_dialog(
            webview_id,
            Dialog::new_permission_request_dialog(permission_request),
        );
    }

    fn show_http_authentication_dialog(
        &self,
        webview_id: WebViewId,
        authentication_request: AuthenticationRequest,
    ) {
        self.add_dialog(
            webview_id,
            Dialog::new_authentication_dialog(authentication_request),
        );
    }

    fn dismiss_embedder_controls_for_webview(&self, webview_id: WebViewId) {
        self.dialogs.borrow_mut().remove(&webview_id);
    }

    fn show_console_message(&self, level: servo::ConsoleLogLevel, message: &str) {
        println!("{}", message);
        log::log!(level.into(), "{}", message);
    }
}

fn winit_phase_to_touch_event_type(phase: TouchPhase) -> TouchEventType {
    match phase {
        TouchPhase::Started => TouchEventType::Down,
        TouchPhase::Moved => TouchEventType::Move,
        TouchPhase::Ended => TouchEventType::Up,
        TouchPhase::Cancelled => TouchEventType::Cancel,
    }
}

#[cfg(any(target_os = "linux", target_os = "windows"))]
fn load_icon(icon_bytes: &[u8]) -> Icon {
    let (icon_rgba, icon_width, icon_height) = {
        use image::{GenericImageView, Pixel};
        let image = image::load_from_memory(icon_bytes).expect("Failed to load icon");
        let (width, height) = image.dimensions();
        let mut rgba = Vec::with_capacity((width * height) as usize * 4);
        for (_, _, pixel) in image.pixels() {
            rgba.extend_from_slice(&pixel.to_rgba().0);
        }
        (rgba, width, height)
    };
    Icon::from_rgba(icon_rgba, icon_width, icon_height).expect("Failed to load icon")
}

Review comment (suggestion):
```suggestion
        println!("{message}");
        log::log!(level.into(), "{}", message);
    }
```

Code after:
    fn show_permission_dialog(&self, webview_id: WebViewId, permission_request: PermissionRequest) {
        self.add_dialog(
            webview_id,
            Dialog::new_permission_request_dialog(permission_request),
        );
    }

    fn show_http_authentication_dialog(
        &self,
        webview_id: WebViewId,
        authentication_request: AuthenticationRequest,
    ) {
        self.add_dialog(
            webview_id,
            Dialog::new_authentication_dialog(authentication_request),
        );
    }

    fn dismiss_embedder_controls_for_webview(&self, webview_id: WebViewId) {
        self.dialogs.borrow_mut().remove(&webview_id);
    }

    fn show_console_message(&self, level: servo::ConsoleLogLevel, message: &str) {
        println!("{message}");
        log::log!(level.into(), "{message}");
    }
}

fn winit_phase_to_touch_event_type(phase: TouchPhase) -> TouchEventType {
    match phase {
        TouchPhase::Started => TouchEventType::Down,
        TouchPhase::Moved => TouchEventType::Move,
        TouchPhase::Ended => TouchEventType::Up,
        TouchPhase::Cancelled => TouchEventType::Cancel,
    }
}

#[cfg(any(target_os = "linux", target_os = "windows"))]
fn load_icon(icon_bytes: &[u8]) -> Icon {
    let (icon_rgba, icon_width, icon_height) = {
        use image::{GenericImageView, Pixel};
        let image = image::load_from_memory(icon_bytes).expect("Failed to load icon");
        let (width, height) = image.dimensions();
        let mut rgba = Vec::with_capacity((width * height) as usize * 4);
        for (_, _, pixel) in image.pixels() {
            rgba.extend_from_slice(&pixel.to_rgba().0);
        }
        (rgba, width, height)
    };
    Icon::from_rgba(icon_rgba, icon_width, icon_height).expect("Failed to load icon")
}