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

Code before:

    fn add_webview(&self, webview: WebView) {
        let webview_id = webview.id();
        self.webview_collection_mut().add(webview);
        let total = self.webview_collection().len();
        info!("Added webview with ID: {webview_id:?}, total webviews: {total}");
    }

    fn focused_webview(&self) -> Option<WebView> {
        self.webview_collection().focused().cloned()
    }

    #[allow(dead_code)]
    fn newest_webview(&self) -> Option<WebView> {
        self.webview_collection().newest().cloned()
    }

    /// Gets the "active" webview: the focused webview if there is one,
    /// otherwise the most recently created webview.
    #[allow(dead_code)]
    fn active_webview(&self) -> Option<WebView> {
        self.webview_collection().active().cloned()
    }

    /// Gets the "active" webview, panicking if there is none.
    /// This is a convenience method for platforms that assume there's always an active webview.
    #[allow(dead_code)]
    fn active_webview_or_panic(&self) -> WebView {
        self.active_webview()
            .expect("Should always have an active WebView")
    }

    fn set_pending_traversal(
        &self,
        traversal_id: TraversalId,
        sender: GenericSender<WebDriverLoadStatus>,
    ) {
        self.base()
            .webdriver_senders
            .borrow_mut()
            .pending_traversals
            .insert(traversal_id, sender);
    }

    fn set_load_status_sender(
        &self,
        webview_id: WebViewId,
        sender: GenericSender<WebDriverLoadStatus>,
    ) {
        self.base()
            .webdriver_senders

Review comment (suggestion):
```suggestion
    /// Gets the "active" [`WebView`], panicking if there is none.
    /// This is a convenience method for platforms that assume there's always an active [`WebView`].
```

Code after:
    fn newest_webview(&self) -> Option<WebView> {
        self.webview_collection().newest().cloned()
    }

    /// Gets the "active" [`WebView`]: the focused [`WebView`] if there is one,
    /// otherwise the most recently created [`WebView`].
    #[allow(dead_code)]
    fn active_webview(&self) -> Option<WebView> {
        self.webview_collection().active().cloned()
    }

    /// Gets the "active" [`WebView`], panicking if there is none.
    /// This is a convenience method for platforms that assume there's always an active [`WebView`].
    #[allow(dead_code)]
    fn active_webview_or_panic(&self) -> WebView {
        self.active_webview()
            .expect("Should always have an active WebView")
    }

    fn set_pending_traversal(
        &self,
        traversal_id: TraversalId,
        sender: GenericSender<WebDriverLoadStatus>,
    ) {
        self.base()
            .webdriver_senders
            .borrow_mut()
            .pending_traversals
            .insert(traversal_id, sender);
    }

    fn set_load_status_sender(
        &self,
        webview_id: WebViewId,
        sender: GenericSender<WebDriverLoadStatus>,
    ) {
        self.base()
            .webdriver_senders
            .borrow_mut()
            .load_status_senders
            .insert(webview_id, sender);
    }

    fn remove_load_status_sender(&self, webview_id: WebViewId) {
        self.base()
            .webdriver_senders
            .borrow_mut()
            .load_status_senders
            .remove(&webview_id);
    }