aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/script_layout
diff options
context:
space:
mode:
Diffstat (limited to 'components/shared/script_layout')
-rw-r--r--components/shared/script_layout/Cargo.toml3
-rw-r--r--components/shared/script_layout/lib.rs35
-rw-r--r--components/shared/script_layout/wrapper_traits.rs6
3 files changed, 28 insertions, 16 deletions
diff --git a/components/shared/script_layout/Cargo.toml b/components/shared/script_layout/Cargo.toml
index 06690192f73..167606f7247 100644
--- a/components/shared/script_layout/Cargo.toml
+++ b/components/shared/script_layout/Cargo.toml
@@ -15,7 +15,6 @@ path = "lib.rs"
base = { workspace = true }
app_units = { workspace = true }
atomic_refcell = { workspace = true }
-canvas_traits = { workspace = true }
compositing_traits = { workspace = true }
constellation_traits = { workspace = true }
embedder_traits = { workspace = true }
@@ -29,7 +28,6 @@ ipc-channel = { workspace = true }
libc = { workspace = true }
malloc_size_of = { workspace = true }
malloc_size_of_derive = { workspace = true }
-metrics = { path = "../../metrics" }
net_traits = { workspace = true }
pixels = { path = "../../pixels" }
profile_traits = { workspace = true }
@@ -40,5 +38,4 @@ serde = { workspace = true }
servo_arc = { workspace = true }
servo_url = { path = "../../url" }
stylo = { workspace = true }
-stylo_traits = { workspace = true }
webrender_api = { workspace = true }
diff --git a/components/shared/script_layout/lib.rs b/components/shared/script_layout/lib.rs
index 96670e60084..e82ee16e24b 100644
--- a/components/shared/script_layout/lib.rs
+++ b/components/shared/script_layout/lib.rs
@@ -20,7 +20,7 @@ use base::Epoch;
use base::id::{BrowsingContextId, PipelineId, WebViewId};
use compositing_traits::CrossProcessCompositorApi;
use constellation_traits::{LoadData, ScrollState};
-use embedder_traits::{UntrustedNodeAddress, ViewportDetails};
+use embedder_traits::{Theme, UntrustedNodeAddress, ViewportDetails};
use euclid::default::{Point2D, Rect};
use fnv::FnvHashMap;
use fonts::{FontContext, SystemFontServiceProxy};
@@ -30,7 +30,7 @@ use libc::c_void;
use malloc_size_of::{MallocSizeOf as MallocSizeOfTrait, MallocSizeOfOps};
use malloc_size_of_derive::MallocSizeOf;
use net_traits::image_cache::{ImageCache, PendingImageId};
-use pixels::Image;
+use pixels::RasterImage;
use profile_traits::mem::Report;
use profile_traits::time;
use script_traits::{InitialScriptState, Painter, ScriptThreadMessage};
@@ -46,10 +46,10 @@ use style::invalidation::element::restyle_hints::RestyleHint;
use style::media_queries::Device;
use style::properties::PropertyId;
use style::properties::style_structs::Font;
-use style::queries::values::PrefersColorScheme;
use style::selector_parser::{PseudoElement, RestyleDamage, Snapshot};
use style::stylesheets::Stylesheet;
use webrender_api::ImageKey;
+use webrender_api::units::DeviceIntSize;
pub trait GenericLayoutDataTrait: Any + MallocSizeOfTrait {
fn as_any(&self) -> &dyn Any;
@@ -154,6 +154,16 @@ pub struct PendingImage {
pub origin: ImmutableOrigin,
}
+/// A data structure to tarck vector image that are fully loaded (i.e has a parsed SVG
+/// tree) but not yet rasterized to the size needed by layout. The rasterization is
+/// happening in the image cache.
+#[derive(Debug)]
+pub struct PendingRasterizationImage {
+ pub node: UntrustedNodeAddress,
+ pub id: PendingImageId,
+ pub size: DeviceIntSize,
+}
+
#[derive(Clone, Copy, Debug)]
pub struct MediaFrame {
pub image_key: webrender_api::ImageKey,
@@ -182,6 +192,7 @@ pub struct LayoutConfig {
pub time_profiler_chan: time::ProfilerChan,
pub compositor_api: CrossProcessCompositorApi,
pub viewport_details: ViewportDetails,
+ pub theme: Theme,
}
pub trait LayoutFactory: Send + Sync {
@@ -392,6 +403,8 @@ pub type IFrameSizes = FnvHashMap<BrowsingContextId, IFrameSize>;
pub struct ReflowResult {
/// The list of images that were encountered that are in progress.
pub pending_images: Vec<PendingImage>,
+ /// The list of vector images that were encountered that still need to be rasterized.
+ pub pending_rasterization_images: Vec<PendingRasterizationImage>,
/// The list of iframes in this layout and their sizes, used in order
/// to communicate them with the Constellation and also the `Window`
/// element of their content pages.
@@ -428,7 +441,7 @@ pub struct ReflowRequest {
/// The set of image animations.
pub node_to_image_animation_map: FxHashMap<OpaqueNode, ImageAnimationState>,
/// The theme for the window
- pub theme: PrefersColorScheme,
+ pub theme: Theme,
/// The node highlighted by the devtools, if any
pub highlighted_dom_node: Option<OpaqueNode>,
}
@@ -507,13 +520,13 @@ pub fn node_id_from_scroll_id(id: usize) -> Option<usize> {
#[derive(Clone, Debug, MallocSizeOf)]
pub struct ImageAnimationState {
#[ignore_malloc_size_of = "Arc is hard"]
- pub image: Arc<Image>,
+ pub image: Arc<RasterImage>,
pub active_frame: usize,
last_update_time: f64,
}
impl ImageAnimationState {
- pub fn new(image: Arc<Image>, last_update_time: f64) -> Self {
+ pub fn new(image: Arc<RasterImage>, last_update_time: f64) -> Self {
Self {
image,
active_frame: 0,
@@ -579,7 +592,7 @@ mod test {
use std::time::Duration;
use ipc_channel::ipc::IpcSharedMemory;
- use pixels::{CorsStatus, Image, ImageFrame, PixelFormat};
+ use pixels::{CorsStatus, ImageFrame, ImageMetadata, PixelFormat, RasterImage};
use crate::ImageAnimationState;
@@ -593,9 +606,11 @@ mod test {
})
.take(10)
.collect();
- let image = Image {
- width: 100,
- height: 100,
+ let image = RasterImage {
+ metadata: ImageMetadata {
+ width: 100,
+ height: 100,
+ },
format: PixelFormat::BGRA8,
id: None,
bytes: IpcSharedMemory::from_byte(1, 1),
diff --git a/components/shared/script_layout/wrapper_traits.rs b/components/shared/script_layout/wrapper_traits.rs
index 6c4de339c1b..f726ee9b19d 100644
--- a/components/shared/script_layout/wrapper_traits.rs
+++ b/components/shared/script_layout/wrapper_traits.rs
@@ -6,13 +6,13 @@
use std::borrow::Cow;
use std::fmt::Debug;
-use std::sync::Arc as StdArc;
use atomic_refcell::AtomicRef;
use base::id::{BrowsingContextId, PipelineId};
use fonts_traits::ByteIndex;
use html5ever::{LocalName, Namespace};
-use pixels::{Image, ImageMetadata};
+use net_traits::image_cache::Image;
+use pixels::ImageMetadata;
use range::Range;
use servo_arc::Arc;
use servo_url::ServoUrl;
@@ -222,7 +222,7 @@ pub trait ThreadSafeLayoutNode<'dom>: Clone + Copy + Debug + NodeInfo + PartialE
fn image_density(&self) -> Option<f64>;
/// If this is an image element, returns its image data. Otherwise, returns `None`.
- fn image_data(&self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)>;
+ fn image_data(&self) -> Option<(Option<Image>, Option<ImageMetadata>)>;
fn canvas_data(&self) -> Option<HTMLCanvasData>;