Repository: servo/servo
File: components/script/dom/window.rs (Rust)

Code before:
    }
}

/// An id used to cancel navigations; for now only used for planned form navigations.
/// Loosely based on <https://html.spec.whatwg.org/multipage/#ongoing-navigation>.
#[derive(Clone, Copy, Debug, Default, JSTraceable, MallocSizeOf, PartialEq)]
pub(crate) struct OngoingNavigation(u32);

type PendingImageRasterizationKey = (PendingImageId, DeviceIntSize);

/// Ancillary data of pending image request that was initiated by layout during a reflow.
/// This data is used to faciliate invalidating layout when the image data becomes available
/// at some point in the future.
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
#[derive(JSTraceable, MallocSizeOf)]
struct PendingLayoutImageAncillaryData {
    node: Dom<Node>,
    #[no_trace]
    destination: LayoutImageDestination,
}

#[dom_struct]
pub(crate) struct Window {
    globalscope: GlobalScope,

    /// A weak handle to script thread
    #[ignore_malloc_size_of = "Weak does not need to be accounted"]
    #[no_trace]
    weak_script_thread: Weak<ScriptThread>,

    /// The webview that contains this [`Window`].
    ///
    /// This may not be the top-level [`Window`], in the case of frames.
    #[no_trace]
    webview_id: WebViewId,
    script_chan: Sender<MainThreadScriptMsg>,
    #[no_trace]
    #[ignore_malloc_size_of = "TODO: Add MallocSizeOf support to layout"]
    layout: RefCell<Box<dyn Layout>>,
    navigator: MutNullableDom<Navigator>,
    #[ignore_malloc_size_of = "ImageCache"]
    #[no_trace]
    image_cache: Arc<dyn ImageCache>,
    #[no_trace]
    image_cache_sender: Sender<ImageCacheResponseMessage>,
    window_proxy: MutNullableDom<WindowProxy>,
    document: MutNullableDom<Document>,
    location: MutNullableDom<Location>,
    history: MutNullableDom<History>,
    indexeddb: MutNullableDom<IDBFactory>,
    custom_element_registry: MutNullableDom<CustomElementRegistry>,

Review comment (suggestion):
I think the expanded rustdoc is useful here:


```suggestion
    /// A `Weak` reference to this [`ScriptThread`] used to give to child [`Window`]s so
    /// they can more easily call methods on the [`ScriptThread`] without constantly having
    /// to pass it everywhere.
```

Code after:
    }
}

/// An id used to cancel navigations; for now only used for planned form navigations.
/// Loosely based on <https://html.spec.whatwg.org/multipage/#ongoing-navigation>.
#[derive(Clone, Copy, Debug, Default, JSTraceable, MallocSizeOf, PartialEq)]
pub(crate) struct OngoingNavigation(u32);

type PendingImageRasterizationKey = (PendingImageId, DeviceIntSize);

/// Ancillary data of pending image request that was initiated by layout during a reflow.
/// This data is used to faciliate invalidating layout when the image data becomes available
/// at some point in the future.
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
#[derive(JSTraceable, MallocSizeOf)]
struct PendingLayoutImageAncillaryData {
    node: Dom<Node>,
    #[no_trace]
    destination: LayoutImageDestination,
}

#[dom_struct]
pub(crate) struct Window {
    globalscope: GlobalScope,

    /// A `Weak` reference to this [`ScriptThread`] used to give to child [`Window`]s so
    /// they can more easily call methods on the [`ScriptThread`] without constantly having
    /// to pass it everywhere.
    #[ignore_malloc_size_of = "Weak does not need to be accounted"]
    #[no_trace]
    weak_script_thread: Weak<ScriptThread>,

    /// The webview that contains this [`Window`].
    ///
    /// This may not be the top-level [`Window`], in the case of frames.
    #[no_trace]
    webview_id: WebViewId,
    script_chan: Sender<MainThreadScriptMsg>,
    #[no_trace]
    #[ignore_malloc_size_of = "TODO: Add MallocSizeOf support to layout"]
    layout: RefCell<Box<dyn Layout>>,
    navigator: MutNullableDom<Navigator>,
    #[ignore_malloc_size_of = "ImageCache"]
    #[no_trace]
    image_cache: Arc<dyn ImageCache>,
    #[no_trace]
    image_cache_sender: Sender<ImageCacheResponseMessage>,
    window_proxy: MutNullableDom<WindowProxy>,
    document: MutNullableDom<Document>,
    location: MutNullableDom<Location>,
    history: MutNullableDom<History>,