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
This commit is contained in:
Brendan Dahl 2019-10-08 23:52:26 +00:00
parent c68cd30ef2
commit ac5283b5c0
8 changed files with 44 additions and 1 deletions

View File

@ -25,6 +25,7 @@ servo-layout-2020 = []
gecko_debug = []
gecko_refcount_logging = []
gecko_profiler = []
moz_xbl = []
[dependencies]
app_units = "0.7"

View File

@ -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<Self> {
@ -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<Self> {
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<GeckoXBLBinding<'le>> {
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<GeckoXBLBinding<'le>> {
None
}
#[inline]
fn xbl_binding_with_content(&self) -> Option<GeckoXBLBinding<'le>> {
self.xbl_binding().and_then(|b| b.binding_with_content())

View File

@ -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"

View File

@ -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

View File

@ -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" }

View File

@ -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" }

View File

@ -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'):

View File

@ -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"