servo_constellation/screenshot_readiness_request.rs
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use rustc_hash::FxHashMap;
6use servo_base::Epoch;
7use servo_base::id::PipelineId;
8
9/// When a [`ScreenshotReadinessRequest`] is received from the renderer, the
10/// [`crate::Constellation`] goes through a variety of states to process them. This data structure
11/// represents those states.
12#[derive(Clone, Copy, Default, PartialEq)]
13pub(crate) enum ScreenshotRequestState {
14 /// The [`crate::Constellation`] has received the [`ScreenshotReadinessRequest`], but has not
15 /// yet forwarded it to the `Pipeline`'s of the request's WebView. This is likely because there
16 /// are still pending navigation changes in the [`crate::Constellation`]. Once those changes are
17 /// resolved the request will be forwarded to the `Pipeline`s.
18 #[default]
19 Pending,
20 /// The [`crate::Constellation`] has forwarded the [`ScreenshotReadinessRequest`] to the
21 /// `Pipeline`s of the corresponding `WebView`. The `Pipeline`s are waiting for a variety of
22 /// things to happen in order to report what the appropriate display list epoch is for the
23 /// screenshot. Once they all report back, the [`crate::Constellation`] considers that the
24 /// request is handled, and the renderer is responsible for waiting to take the screenshot.
25 WaitingOnScript,
26}
27
28pub(crate) struct ScreenshotReadinessRequest {
29 pub state: ScreenshotRequestState,
30 pub pipeline_states: FxHashMap<PipelineId, Option<Epoch>>,
31}