Repository: servo/servo
File: components/shared/script/lib.rs (Rust)

Code before:
    /// Preferences were updated in the parent process.
    PreferencesUpdated(Vec<(String, PrefValue)>),
    /// Notify the `ScriptThread` that the Servo renderer is no longer waiting on
    /// asynchronous image uploads for the given `Pipeline`. These are mainly used
    /// by canvas to perform uploads while the display list is being built.
    NoLongerWaitingOnAsychronousImageUpdates(PipelineId),
    /// Forward a keyboard scroll operation from an `<iframe>` to a parent pipeline.
    ForwardKeyboardScroll(PipelineId, KeyboardScroll),
    /// Request readiness for a screenshot from the given pipeline. The pipeline will
    /// respond when it is ready to take the screenshot or will not be able to take it
    /// in the future.
    RequestScreenshotReadiness(WebViewId, PipelineId),
    /// A response to a request to show an embedder user interface control.
    EmbedderControlResponse(EmbedderControlId, EmbedderControlResponse),
    /// Set the `UserContents` for the given `UserContentManagerId`. A `ScriptThread` can host many
    /// `WebView`s which share the same `UserContentManager`. Only documents loaded after
    /// the processing of this message will observe the new `UserContents` of the specified
    /// `UserContentManagerId`.
    SetUserContents(UserContentManagerId, UserContents),
    /// Release all data for the given `UserContentManagerId` from the `ScriptThread`'s
    /// `user_contents_for_manager_id` map.
    DestroyUserContentManager(UserContentManagerId),
    /// Send the embedder an accessibility tree update.
    AccessibilityTreeUpdate(WebViewId, accesskit::TreeUpdate),
    /// Update the pinch zoom details of a pipeline. Each `Window` stores a `VisualViewport` DOM
    /// instances that gets updated according to the changes from the `Compositor``.
    UpdatePinchZoomDetails(PipelineId, PinchZoomDetails),
}

impl fmt::Debug for ScriptThreadMessage {
    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        let variant_string: &'static str = self.into();
        write!(formatter, "ConstellationControlMsg::{variant_string}")
    }
}

/// Used to determine if a script has any pending asynchronous activity.
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum DocumentState {
    /// The document has been loaded and is idle.
    Idle,
    /// The document is either loading or waiting on an event.
    Pending,
}

/// Input events from the embedder that are sent via the `Constellation`` to the `ScriptThread`.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ConstellationInputEvent {
    /// The hit test result of this input event, if any.
    pub hit_test_result: Option<PaintHitTestResult>,
    /// The pressed mouse button state of the constellation when this input

Review comment (suggestion):
```suggestion
    /// instance that gets updated according to the changes from the `Compositor``.
```

Code after:
    /// Preferences were updated in the parent process.
    PreferencesUpdated(Vec<(String, PrefValue)>),
    /// Notify the `ScriptThread` that the Servo renderer is no longer waiting on
    /// asynchronous image uploads for the given `Pipeline`. These are mainly used
    /// by canvas to perform uploads while the display list is being built.
    NoLongerWaitingOnAsychronousImageUpdates(PipelineId),
    /// Forward a keyboard scroll operation from an `<iframe>` to a parent pipeline.
    ForwardKeyboardScroll(PipelineId, KeyboardScroll),
    /// Request readiness for a screenshot from the given pipeline. The pipeline will
    /// respond when it is ready to take the screenshot or will not be able to take it
    /// in the future.
    RequestScreenshotReadiness(WebViewId, PipelineId),
    /// A response to a request to show an embedder user interface control.
    EmbedderControlResponse(EmbedderControlId, EmbedderControlResponse),
    /// Set the `UserContents` for the given `UserContentManagerId`. A `ScriptThread` can host many
    /// `WebView`s which share the same `UserContentManager`. Only documents loaded after
    /// the processing of this message will observe the new `UserContents` of the specified
    /// `UserContentManagerId`.
    SetUserContents(UserContentManagerId, UserContents),
    /// Release all data for the given `UserContentManagerId` from the `ScriptThread`'s
    /// `user_contents_for_manager_id` map.
    DestroyUserContentManager(UserContentManagerId),
    /// Send the embedder an accessibility tree update.
    AccessibilityTreeUpdate(WebViewId, accesskit::TreeUpdate),
    /// Update the pinch zoom details of a pipeline. Each `Window` stores a `VisualViewport` DOM
    /// instance that gets updated according to the changes from the `Compositor``.
    UpdatePinchZoomInfos(PipelineId, PinchZoomInfos),
}

impl fmt::Debug for ScriptThreadMessage {
    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        let variant_string: &'static str = self.into();
        write!(formatter, "ConstellationControlMsg::{variant_string}")
    }
}

/// Used to determine if a script has any pending asynchronous activity.
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum DocumentState {
    /// The document has been loaded and is idle.
    Idle,
    /// The document is either loading or waiting on an event.
    Pending,
}

/// Input events from the embedder that are sent via the `Constellation`` to the `ScriptThread`.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ConstellationInputEvent {
    /// The hit test result of this input event, if any.
    pub hit_test_result: Option<PaintHitTestResult>,
    /// The pressed mouse button state of the constellation when this input