From ac5283b5c0bdd25770e0f50ce72ea42ada5d8192 Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Tue, 8 Oct 2019 23:52:26 +0000 Subject: [PATCH] Bug 1510785 - Add way to disable XBL in servo. r=emilio Adds a feature "moz_xbl" that when disabled causes the XBL code in servo to be stubbed out. Depends on D45613 Differential Revision: https://phabricator.services.mozilla.com/D45614 --HG-- extra : moz-landing-system : lando --- servo/components/style/Cargo.toml | 1 + servo/components/style/gecko/wrapper.rs | 33 ++++++++++++++++++- servo/ports/geckolib/Cargo.toml | 1 + toolkit/content/xul.css | 4 +++ toolkit/library/gtest/rust/Cargo.toml | 1 + toolkit/library/rust/Cargo.toml | 1 + toolkit/library/rust/gkrust-features.mozbuild | 3 ++ toolkit/library/rust/shared/Cargo.toml | 1 + 8 files changed, 44 insertions(+), 1 deletion(-) diff --git a/servo/components/style/Cargo.toml b/servo/components/style/Cargo.toml index 688c6065c1ff..0ced2201883d 100644 --- a/servo/components/style/Cargo.toml +++ b/servo/components/style/Cargo.toml @@ -25,6 +25,7 @@ servo-layout-2020 = [] gecko_debug = [] gecko_refcount_logging = [] gecko_profiler = [] +moz_xbl = [] [dependencies] app_units = "0.7" diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs index 68c0473bf121..cb2c73bdb3f7 100644 --- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -54,8 +54,12 @@ use crate::gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES; use crate::gecko_bindings::structs::NODE_NEEDS_FRAME; use crate::gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag}; use crate::gecko_bindings::structs::{ - nsINode as RawGeckoNode, nsXBLBinding as RawGeckoXBLBinding, Element as RawGeckoElement, + nsINode as RawGeckoNode, Element as RawGeckoElement, }; +#[cfg(feature = "moz_xbl")] +use crate::gecko_bindings::structs::nsXBLBinding as RawGeckoXBLBinding; +#[cfg(not(feature = "moz_xbl"))] +use values::Impossible; use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI}; use crate::global_style_data::GLOBAL_STYLE_DATA; use crate::hash::FxHashMap; @@ -529,9 +533,11 @@ impl<'a> Iterator for GeckoChildrenIterator<'a> { } /// A Simple wrapper over a non-null Gecko `nsXBLBinding` pointer. +#[cfg(feature = "moz_xbl")] #[derive(Clone, Copy)] pub struct GeckoXBLBinding<'lb>(pub &'lb RawGeckoXBLBinding); +#[cfg(feature = "moz_xbl")] impl<'lb> GeckoXBLBinding<'lb> { #[inline] fn base_binding(&self) -> Option { @@ -556,6 +562,23 @@ impl<'lb> GeckoXBLBinding<'lb> { } } +/// A stub wraper for GeckoXBLBinding. +#[cfg(not(feature = "moz_xbl"))] +pub struct GeckoXBLBinding<'lb>(&'lb Impossible); + +#[cfg(not(feature = "moz_xbl"))] +impl<'lb> GeckoXBLBinding<'lb> { + + #[inline] + fn anon_content(&self) -> *const nsIContent { + match *self.0 {} + } + + fn binding_with_content(&self) -> Option { + None + } +} + /// A simple wrapper over a non-null Gecko `Element` pointer. #[derive(Clone, Copy)] pub struct GeckoElement<'le>(pub &'le RawGeckoElement); @@ -681,11 +704,13 @@ impl<'le> GeckoElement<'le> { }) } + #[cfg(feature = "moz_xbl")] #[inline] fn may_be_in_binding_manager(&self) -> bool { self.flags() & (structs::NODE_MAY_BE_IN_BINDING_MNGR as u32) != 0 } + #[cfg(feature = "moz_xbl")] #[inline] fn xbl_binding(&self) -> Option> { if !self.may_be_in_binding_manager() { @@ -696,6 +721,12 @@ impl<'le> GeckoElement<'le> { unsafe { slots.mXBLBinding.mRawPtr.as_ref().map(GeckoXBLBinding) } } + #[cfg(not(feature = "moz_xbl"))] + #[inline] + fn xbl_binding(&self) -> Option> { + None + } + #[inline] fn xbl_binding_with_content(&self) -> Option> { self.xbl_binding().and_then(|b| b.binding_with_content()) diff --git a/servo/ports/geckolib/Cargo.toml b/servo/ports/geckolib/Cargo.toml index 796b689f84d8..8dfae3d4288d 100644 --- a/servo/ports/geckolib/Cargo.toml +++ b/servo/ports/geckolib/Cargo.toml @@ -12,6 +12,7 @@ path = "lib.rs" gecko_debug = ["style/gecko_debug", "nsstring/gecko_debug"] gecko_profiler = ["style/gecko_profiler"] gecko_refcount_logging = ["style/gecko_refcount_logging", "servo_arc/gecko_refcount_logging"] +moz_xbl = ["style/moz_xbl"] [dependencies] atomic_refcell = "0.1" diff --git a/toolkit/content/xul.css b/toolkit/content/xul.css index 57ce4d241147..5b053d6e5730 100644 --- a/toolkit/content/xul.css +++ b/toolkit/content/xul.css @@ -630,3 +630,7 @@ tabmodalprompt { [ordinal="9"] { -moz-box-ordinal-group: 9; } [ordinal="1000"] { -moz-box-ordinal-group: 1000; } } + +%ifndef MOZ_XBL +* { -moz-binding: none !important } +%endif diff --git a/toolkit/library/gtest/rust/Cargo.toml b/toolkit/library/gtest/rust/Cargo.toml index e461082208c9..cb6c2b2b3fe5 100644 --- a/toolkit/library/gtest/rust/Cargo.toml +++ b/toolkit/library/gtest/rust/Cargo.toml @@ -27,6 +27,7 @@ new_xulstore = ["gkrust-shared/new_xulstore"] new_cert_storage = ["gkrust-shared/new_cert_storage"] fuzzing_interfaces = ["gkrust-shared/fuzzing_interfaces", "gecko-fuzz-targets"] webrtc = ["gkrust-shared/webrtc"] +moz_xbl = ["gkrust-shared/moz_xbl"] [dependencies] bench-collections-gtest = { path = "../../../../xpcom/rust/gtest/bench-collections" } diff --git a/toolkit/library/rust/Cargo.toml b/toolkit/library/rust/Cargo.toml index de8ef2ba40af..7954334452a6 100644 --- a/toolkit/library/rust/Cargo.toml +++ b/toolkit/library/rust/Cargo.toml @@ -28,6 +28,7 @@ new_xulstore = ["gkrust-shared/new_xulstore"] new_cert_storage = ["gkrust-shared/new_cert_storage"] fuzzing_interfaces = ["gkrust-shared/fuzzing_interfaces"] webrtc = ["gkrust-shared/webrtc"] +moz_xbl = ["gkrust-shared/moz_xbl"] [dependencies] gkrust-shared = { path = "shared" } diff --git a/toolkit/library/rust/gkrust-features.mozbuild b/toolkit/library/rust/gkrust-features.mozbuild index 8c6c48e499d5..3d2795232fc7 100644 --- a/toolkit/library/rust/gkrust-features.mozbuild +++ b/toolkit/library/rust/gkrust-features.mozbuild @@ -25,6 +25,9 @@ if CONFIG['MOZ_AUDIOUNIT_RUST']: if CONFIG['MOZ_RUST_SIMD']: gkrust_features += ['simd-accel'] +if CONFIG['MOZ_XBL']: + gkrust_features += ['moz_xbl'] + # This feature is not yet supported on all platforms, and this check needs to # match MOZ_CUBEB_REMOTING in CubebUtils.cpp. if (CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android') or CONFIG['OS_ARCH'] == 'Darwin' or (CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CPU_ARCH'] != 'aarch64'): diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index 3cd2ec14a292..cc3ae4dea8da 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -69,6 +69,7 @@ new_xulstore = ["xulstore"] new_cert_storage = ["cert_storage"] fuzzing_interfaces = [] webrtc = ["mdns_service"] +moz_xbl = ["geckoservo/moz_xbl"] [lib] path = "lib.rs"