Skip to content
Permalink
Browse files

style: Add way to disable XBL in servo.

Adds a feature "moz_xbl" that when disabled causes the XBL code in servo to
be stubbed out.

Differential Revision: https://phabricator.services.mozilla.com/D45614
  • Loading branch information...
brendandahl authored and emilio committed Oct 9, 2019
1 parent f6b5870 commit 112a68723edd613651e27fec494194f725ee334a
Showing with 33 additions and 1 deletion.
  1. +1 −0 components/style/Cargo.toml
  2. +32 −1 components/style/gecko/wrapper.rs
@@ -25,6 +25,7 @@ servo-layout-2020 = []
gecko_debug = []
gecko_refcount_logging = []
gecko_profiler = []
moz_xbl = []

[dependencies]
app_units = "0.7"
@@ -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())

0 comments on commit 112a687

Please sign in to comment.
You can’t perform that action at this time.