Bug 1510785 - Add way to disable XBL in servo. r=emilio
authorBrendan Dahl <bdahl@mozilla.com>
Tue, 08 Oct 2019 23:52:26 +0000
changeset 496867 02740878ddd6f229f43599c5458ed4285f2019f1
parent 496866 4a104e817b352defa9b4aa5df5dc7eb400cd2b87
child 496868 5a2309893b3af80114b786af714032b082290ff1
push id36669
push usershindli@mozilla.com
push dateWed, 09 Oct 2019 09:58:06 +0000
treeherdermozilla-central@be9a6289486a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1510785
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
servo/components/style/Cargo.toml
servo/components/style/gecko/wrapper.rs
servo/ports/geckolib/Cargo.toml
toolkit/content/xul.css
toolkit/library/gtest/rust/Cargo.toml
toolkit/library/rust/Cargo.toml
toolkit/library/rust/gkrust-features.mozbuild
toolkit/library/rust/shared/Cargo.toml
--- a/servo/components/style/Cargo.toml
+++ b/servo/components/style/Cargo.toml
@@ -20,16 +20,17 @@ gecko = ["nsstring", "style_traits/gecko
 servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever",
          "cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union",
          "servo_url", "string_cache", "crossbeam-channel", "to_shmem/servo", "servo_arc/servo"]
 servo-layout-2013 = []
 servo-layout-2020 = []
 gecko_debug = []
 gecko_refcount_logging = []
 gecko_profiler = []
+moz_xbl = []
 
 [dependencies]
 app_units = "0.7"
 arrayvec = "0.4.6"
 atomic_refcell = "0.1"
 bitflags = "1.0"
 byteorder = "1.0"
 cssparser = "0.25"
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -49,18 +49,22 @@ use crate::gecko_bindings::structs::Effe
 use crate::gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT;
 use crate::gecko_bindings::structs::ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO;
 use crate::gecko_bindings::structs::ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO;
 use crate::gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT;
 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;
 use crate::invalidation::element::restyle_hints::RestyleHint;
 use crate::media_queries::Device;
 use crate::properties::animated_properties::{AnimationValue, AnimationValueMap};
 use crate::properties::{ComputedValues, LonghandId};
 use crate::properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
@@ -524,19 +528,21 @@ impl<'a> Iterator for GeckoChildrenItera
                     .as_ref()
                     .map(GeckoNode)
             },
         }
     }
 }
 
 /// 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<Self> {
         unsafe { self.0.mNextBinding.mRawPtr.as_ref().map(GeckoXBLBinding) }
     }
 
     #[inline]
     fn anon_content(&self) -> *const nsIContent {
@@ -551,16 +557,33 @@ impl<'lb> GeckoXBLBinding<'lb> {
             if !binding.anon_content().is_null() {
                 return Some(binding);
             }
             binding = binding.base_binding()?;
         }
     }
 }
 
+/// 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<Self> {
+        None
+    }
+}
+
 /// A simple wrapper over a non-null Gecko `Element` pointer.
 #[derive(Clone, Copy)]
 pub struct GeckoElement<'le>(pub &'le RawGeckoElement);
 
 impl<'le> fmt::Debug for GeckoElement<'le> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         use nsstring::nsCString;
 
@@ -676,31 +699,39 @@ impl<'le> GeckoElement<'le> {
         self.dom_slots().and_then(|s| unsafe {
             // For the bit usage, see nsContentSlots::GetExtendedSlots.
             let e_slots = s._base.mExtendedSlots &
                 !structs::nsIContent_nsContentSlots_sNonOwningExtendedSlotsFlag;
             (e_slots as *const structs::FragmentOrElement_nsExtendedDOMSlots).as_ref()
         })
     }
 
+    #[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<GeckoXBLBinding<'le>> {
         if !self.may_be_in_binding_manager() {
             return None;
         }
 
         let slots = self.extended_slots()?;
         unsafe { slots.mXBLBinding.mRawPtr.as_ref().map(GeckoXBLBinding) }
     }
 
+    #[cfg(not(feature = "moz_xbl"))]
+    #[inline]
+    fn xbl_binding(&self) -> Option<GeckoXBLBinding<'le>> {
+        None
+    }
+
     #[inline]
     fn xbl_binding_with_content(&self) -> Option<GeckoXBLBinding<'le>> {
         self.xbl_binding().and_then(|b| b.binding_with_content())
     }
 
     #[inline]
     fn has_xbl_binding_with_content(&self) -> bool {
         !self.xbl_binding_with_content().is_none()
--- a/servo/ports/geckolib/Cargo.toml
+++ b/servo/ports/geckolib/Cargo.toml
@@ -7,16 +7,17 @@ license = "MPL-2.0"
 [lib]
 name = "geckoservo"
 path = "lib.rs"
 
 [features]
 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"
 cssparser = "0.25"
 cstr = "0.1.2"
 libc = "0.2"
 log = {version = "0.4", features = ["release_max_level_info"]}
 malloc_size_of = {path = "../../components/malloc_size_of"}
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -625,8 +625,12 @@ tabmodalprompt {
   [ordinal="4"] { -moz-box-ordinal-group: 4; }
   [ordinal="5"] { -moz-box-ordinal-group: 5; }
   [ordinal="6"] { -moz-box-ordinal-group: 6; }
   [ordinal="7"] { -moz-box-ordinal-group: 7; }
   [ordinal="8"] { -moz-box-ordinal-group: 8; }
   [ordinal="9"] { -moz-box-ordinal-group: 9; }
   [ordinal="1000"] { -moz-box-ordinal-group: 1000; }
 }
+
+%ifndef MOZ_XBL
+* { -moz-binding: none !important }
+%endif
--- a/toolkit/library/gtest/rust/Cargo.toml
+++ b/toolkit/library/gtest/rust/Cargo.toml
@@ -22,16 +22,17 @@ cranelift_arm64 = ["gkrust-shared/cranel
 cranelift_none = ["gkrust-shared/cranelift_none"]
 gecko_profiler = ["gkrust-shared/gecko_profiler"]
 gecko_profiler_parse_elf = ["gkrust-shared/gecko_profiler_parse_elf"]
 bitsdownload = ["gkrust-shared/bitsdownload"]
 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" }
 mp4parse-gtest = { path = "../../../../dom/media/gtest" }
 nsstring-gtest = { path = "../../../../xpcom/rust/gtest/nsstring" }
 xpcom-gtest = { path = "../../../../xpcom/rust/gtest/xpcom" }
 gkrust-shared = { path = "../../rust/shared" }
 gecko-fuzz-targets = { path = "../../../../tools/fuzzing/rust", optional = true }
--- a/toolkit/library/rust/Cargo.toml
+++ b/toolkit/library/rust/Cargo.toml
@@ -23,16 +23,17 @@ cranelift_arm64 = ["gkrust-shared/cranel
 cranelift_none = ["gkrust-shared/cranelift_none"]
 gecko_profiler = ["gkrust-shared/gecko_profiler"]
 gecko_profiler_parse_elf = ["gkrust-shared/gecko_profiler_parse_elf"]
 bitsdownload = ["gkrust-shared/bitsdownload"]
 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" }
 mozilla-central-workspace-hack = { path = "../../../build/workspace-hack" }
 
 [dev-dependencies]
 stylo_tests = { path = "../../../servo/ports/geckolib/tests/" }
 
--- a/toolkit/library/rust/gkrust-features.mozbuild
+++ b/toolkit/library/rust/gkrust-features.mozbuild
@@ -20,16 +20,19 @@ if CONFIG['MOZ_PULSEAUDIO']:
     gkrust_features += ['cubeb_pulse_rust']
 
 if CONFIG['MOZ_AUDIOUNIT_RUST']:
     gkrust_features += ['cubeb_coreaudio_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'):
     gkrust_features += ['cubeb-remoting']
 
 if CONFIG['MOZ_MEMORY']:
     gkrust_features += ['moz_memory']
 
--- a/toolkit/library/rust/shared/Cargo.toml
+++ b/toolkit/library/rust/shared/Cargo.toml
@@ -64,16 +64,17 @@ cranelift_arm32 = ["jsrust_shared/cranel
 cranelift_arm64 = ["jsrust_shared/cranelift_arm64"]
 cranelift_none = ["jsrust_shared/cranelift_none"]
 gecko_profiler = ["profiler_helper", "geckoservo/gecko_profiler"]
 gecko_profiler_parse_elf = ["profiler_helper/parse_elf"]
 new_xulstore = ["xulstore"]
 new_cert_storage = ["cert_storage"]
 fuzzing_interfaces = []
 webrtc = ["mdns_service"]
+moz_xbl = ["geckoservo/moz_xbl"]
 
 [lib]
 path = "lib.rs"
 test = false
 doctest = false
 bench = false
 doc = false
 plugin = false