aboutsummaryrefslogtreecommitdiffstats
path: root/components/servo
diff options
context:
space:
mode:
Diffstat (limited to 'components/servo')
-rw-r--r--components/servo/Cargo.toml4
-rw-r--r--components/servo/lib.rs38
2 files changed, 27 insertions, 15 deletions
diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml
index 3335a1dd84f..4d6781d05ae 100644
--- a/components/servo/Cargo.toml
+++ b/components/servo/Cargo.toml
@@ -16,6 +16,7 @@ debugmozjs = ["script/debugmozjs"]
googlevr = ["webxr/googlevr"]
jitspew = ["script/jitspew"]
js_backtrace = ["script/js_backtrace"]
+layout_2013 = ["dep:layout_thread_2013"]
max_log_level = ["log/release_max_level_info"]
media-gstreamer = ["servo-media-gstreamer", "gstreamer"]
multiview = ["compositing/multiview", "constellation/multiview"]
@@ -39,6 +40,7 @@ bluetooth = { path = "../bluetooth" }
bluetooth_traits = { workspace = true }
canvas = { path = "../canvas", default-features = false }
canvas_traits = { workspace = true }
+cfg-if = { workspace = true }
compositing = { path = "../compositing" }
compositing_traits = { workspace = true }
constellation = { path = "../constellation" }
@@ -54,7 +56,7 @@ gleam = { workspace = true }
gstreamer = { workspace = true, optional = true }
ipc-channel = { workspace = true }
keyboard-types = { workspace = true }
-layout_thread_2013 = { path = "../layout_thread" }
+layout_thread_2013 = { path = "../layout_thread", optional = true }
layout_thread_2020 = { path = "../layout_thread_2020" }
log = { workspace = true }
media = { path = "../media" }
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index f130e99160b..1d1ef2bb988 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -67,6 +67,8 @@ use fonts::FontCacheThread;
use gaol::sandbox::{ChildSandbox, ChildSandboxMethods};
pub use gleam::gl;
use ipc_channel::ipc::{self, IpcSender};
+#[cfg(feature = "layout_2013")]
+pub use layout_thread_2013;
use log::{error, trace, warn, Log, Metadata, Record};
use media::{GLPlayerThreads, GlApi, NativeDisplay, WindowGLContext};
use net::resource_thread::new_resource_threads;
@@ -98,10 +100,9 @@ use webrender_traits::{
pub use {
background_hang_monitor, base, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing,
constellation, devtools, devtools_traits, embedder_traits, euclid, fonts, ipc_channel,
- keyboard_types, layout_thread_2013, layout_thread_2020, media, net, net_traits, profile,
- profile_traits, script, script_layout_interface, script_traits, servo_config as config,
- servo_config, servo_geometry, servo_url as url, servo_url, style, style_traits, webgpu,
- webrender_api, webrender_traits,
+ keyboard_types, layout_thread_2020, media, net, net_traits, profile, profile_traits, script,
+ script_layout_interface, script_traits, servo_config as config, servo_config, servo_geometry,
+ servo_url as url, servo_url, style, style_traits, webgpu, webrender_api, webrender_traits,
};
#[cfg(feature = "webdriver")]
@@ -968,6 +969,22 @@ fn create_compositor_channel(
)
}
+fn get_layout_factory(legacy_layout: bool) -> Arc<dyn LayoutFactory> {
+ cfg_if::cfg_if! {
+ if #[cfg(feature = "layout_2013")] {
+ if legacy_layout {
+ return Arc::new(layout_thread_2013::LayoutFactoryImpl());
+ }
+ } else {
+ if legacy_layout {
+ warn!("Runtime option `legacy_layout` was enabled, but the `layout_2013` \
+ feature was not enabled at compile time. Falling back to layout 2020! ");
+ }
+ }
+ }
+ Arc::new(layout_thread_2020::LayoutFactoryImpl())
+}
+
fn create_constellation(
user_agent: Cow<'static, str>,
config_dir: Option<PathBuf>,
@@ -1034,11 +1051,7 @@ fn create_constellation(
wgpu_image_map,
};
- let layout_factory: Arc<dyn LayoutFactory> = if opts::get().legacy_layout {
- Arc::new(layout_thread_2013::LayoutFactoryImpl())
- } else {
- Arc::new(layout_thread_2020::LayoutFactoryImpl())
- };
+ let layout_factory: Arc<dyn LayoutFactory> = get_layout_factory(opts::get().legacy_layout);
Constellation::<
script::script_thread::ScriptThread,
@@ -1213,11 +1226,8 @@ pub fn run_content_process(token: String) {
set_logger(content.script_to_constellation_chan().clone());
let background_hang_monitor_register = content.register_with_background_hang_monitor();
- let layout_factory: Arc<dyn LayoutFactory> = if opts::get().legacy_layout {
- Arc::new(layout_thread_2013::LayoutFactoryImpl())
- } else {
- Arc::new(layout_thread_2020::LayoutFactoryImpl())
- };
+ let layout_factory: Arc<dyn LayoutFactory> =
+ get_layout_factory(opts::get().legacy_layout);
content.start_all::<script::script_thread::ScriptThread>(
true,