aboutsummaryrefslogtreecommitdiffstats
path: root/components/servo/lib.rs
diff options
context:
space:
mode:
authorJonathan Schwender <55576758+jschwe@users.noreply.github.com>2024-07-11 15:24:52 +0200
committerGitHub <noreply@github.com>2024-07-11 13:24:52 +0000
commit496ce717c5343984e0f3da00d223604eff03893c (patch)
treeaa07cd532c82f057335f0368f73ff0c310942f2c /components/servo/lib.rs
parent4907e896560dd68bfcd9318b4493de10d7ceee19 (diff)
downloadservo-496ce717c5343984e0f3da00d223604eff03893c.tar.gz
servo-496ce717c5343984e0f3da00d223604eff03893c.zip
Move legacy layout behind a feature flag (#32759)
* Move legacy layout behind a feature flag For now the new feature flag would still be enabled by default, but disabling the `layout_2013` feature, gives the following binary size improvements for servoshell on Linux: - in debug mode from 1278MB -> 1201 MB - in release mode from 144MB -> 140MB - in production mode from 108MB -> 106MB Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com> * Update components/servo/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> --------- Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com> Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/servo/lib.rs')
-rw-r--r--components/servo/lib.rs38
1 files changed, 24 insertions, 14 deletions
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,