aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/layout
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-10-05 19:47:39 +0200
committerMartin Robinson <mrobinson@igalia.com>2023-11-03 15:38:18 +0000
commitf4d3af296c05260dfbb3deea4f8fa400cb6887d3 (patch)
tree169db2cc68e01a755b30500dd525f1a2ec2da861 /components/shared/layout
parent863529d9622c68f0a9535225237eb5e5c5b8c757 (diff)
downloadservo-f4d3af296c05260dfbb3deea4f8fa400cb6887d3.tar.gz
servo-f4d3af296c05260dfbb3deea4f8fa400cb6887d3.zip
Move `*_traits` and other shared types to `shared`
This is the start of the organization of types that are in their own crates in order to break dependency cycles between other crates. The idea here is that putting these packages into their own directory is the first step toward cleaning them up. They have grown organically and it is difficult to explain to new folks where to put new shared types. Many of these crates contain more than traits or don't contain traits at all. Notably, `script_traits` isn't touched because it is vendored from Gecko. Eventually this will move to `third_party`.
Diffstat (limited to 'components/shared/layout')
-rw-r--r--components/shared/layout/Cargo.toml23
-rw-r--r--components/shared/layout/lib.rs53
2 files changed, 76 insertions, 0 deletions
diff --git a/components/shared/layout/Cargo.toml b/components/shared/layout/Cargo.toml
new file mode 100644
index 00000000000..c81ed04454c
--- /dev/null
+++ b/components/shared/layout/Cargo.toml
@@ -0,0 +1,23 @@
+[package]
+name = "layout_traits"
+version = "0.0.1"
+authors = ["The Servo Project Developers"]
+license = "MPL-2.0"
+edition = "2018"
+publish = false
+
+[lib]
+name = "layout_traits"
+path = "lib.rs"
+
+[dependencies]
+crossbeam-channel = { workspace = true }
+gfx = { path = "../../gfx" }
+ipc-channel = { workspace = true }
+metrics = { path = "../../metrics" }
+msg = { workspace = true }
+net_traits = { workspace = true }
+profile_traits = { workspace = true }
+script_traits = { workspace = true }
+servo_url = { path = "../../url" }
+webrender_api = { workspace = true }
diff --git a/components/shared/layout/lib.rs b/components/shared/layout/lib.rs
new file mode 100644
index 00000000000..1e1783e489f
--- /dev/null
+++ b/components/shared/layout/lib.rs
@@ -0,0 +1,53 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+#![deny(unsafe_code)]
+
+// This module contains traits in layout used generically
+// in the rest of Servo.
+// The traits are here instead of in layout so
+// that these modules won't have to depend on layout.
+
+use std::sync::atomic::AtomicBool;
+use std::sync::Arc;
+
+use crossbeam_channel::{Receiver, Sender};
+use gfx::font_cache_thread::FontCacheThread;
+use ipc_channel::ipc::{IpcReceiver, IpcSender};
+use metrics::PaintTimeMetrics;
+use msg::constellation_msg::{
+ BackgroundHangMonitorRegister, PipelineId, TopLevelBrowsingContextId,
+};
+use net_traits::image_cache::ImageCache;
+use profile_traits::{mem, time};
+use script_traits::{
+ ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg, WebrenderIpcSender,
+ WindowSizeData,
+};
+use servo_url::ServoUrl;
+
+// A static method creating a layout thread
+// Here to remove the compositor -> layout dependency
+pub trait LayoutThreadFactory {
+ type Message;
+ fn create(
+ id: PipelineId,
+ top_level_browsing_context_id: TopLevelBrowsingContextId,
+ url: ServoUrl,
+ is_iframe: bool,
+ chan: (Sender<Self::Message>, Receiver<Self::Message>),
+ pipeline_port: IpcReceiver<LayoutControlMsg>,
+ background_hang_monitor: Box<dyn BackgroundHangMonitorRegister>,
+ constellation_chan: IpcSender<ConstellationMsg>,
+ script_chan: IpcSender<ConstellationControlMsg>,
+ image_cache: Arc<dyn ImageCache>,
+ font_cache_thread: FontCacheThread,
+ time_profiler_chan: time::ProfilerChan,
+ mem_profiler_chan: mem::ProfilerChan,
+ webrender_api_sender: WebrenderIpcSender,
+ paint_time_metrics: PaintTimeMetrics,
+ busy: Arc<AtomicBool>,
+ window_size: WindowSizeData,
+ );
+}