Bug 1646811 - servo: Gate layout 2020 flex implementation behind a pref.

Differential Revision: https://phabricator.services.mozilla.com/D80231
This commit is contained in:
Simon Sapin 2020-06-18 18:11:39 +00:00
Родитель 06852fdbb6
Коммит ce5f91aa47
1 изменённых файлов: 18 добавлений и 17 удалений

Просмотреть файл

@ -34,6 +34,17 @@ fn moz_box_display_values_enabled(context: &ParserContext) -> bool {
static_prefs::pref!("layout.css.xul-box-display-values.content.enabled") static_prefs::pref!("layout.css.xul-box-display-values.content.enabled")
} }
fn flexbox_enabled() -> bool {
if cfg!(feature = "servo-layout-2020") {
servo_config::prefs::pref_map()
.get("layout.flexbox.enabled")
.as_bool()
.unwrap_or(false)
} else {
true
}
}
/// Defines an elements display type, which consists of /// Defines an elements display type, which consists of
/// the two basic qualities of how an element generates boxes /// the two basic qualities of how an element generates boxes
/// <https://drafts.csswg.org/css-display/#propdef-display> /// <https://drafts.csswg.org/css-display/#propdef-display>
@ -63,7 +74,6 @@ pub enum DisplayInside {
Contents, Contents,
Flow, Flow,
FlowRoot, FlowRoot,
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
Flex, Flex,
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
Grid, Grid,
@ -146,9 +156,7 @@ impl Display {
pub const Block: Self = Self::new(DisplayOutside::Block, DisplayInside::Flow); pub const Block: Self = Self::new(DisplayOutside::Block, DisplayInside::Flow);
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub const FlowRoot: Self = Self::new(DisplayOutside::Block, DisplayInside::FlowRoot); pub const FlowRoot: Self = Self::new(DisplayOutside::Block, DisplayInside::FlowRoot);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const Flex: Self = Self::new(DisplayOutside::Block, DisplayInside::Flex); pub const Flex: Self = Self::new(DisplayOutside::Block, DisplayInside::Flex);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const InlineFlex: Self = Self::new(DisplayOutside::Inline, DisplayInside::Flex); pub const InlineFlex: Self = Self::new(DisplayOutside::Inline, DisplayInside::Flex);
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub const Grid: Self = Self::new(DisplayOutside::Block, DisplayInside::Grid); pub const Grid: Self = Self::new(DisplayOutside::Block, DisplayInside::Grid);
@ -317,9 +325,9 @@ impl Display {
#[inline] #[inline]
pub fn is_atomic_inline_level(&self) -> bool { pub fn is_atomic_inline_level(&self) -> bool {
match *self { match *self {
Display::InlineBlock => true, Display::InlineBlock | Display::InlineFlex => true,
#[cfg(any(feature = "servo-layout-2013"))] #[cfg(any(feature = "servo-layout-2013"))]
Display::InlineFlex | Display::InlineTable => true, Display::InlineTable => true,
_ => false, _ => false,
} }
} }
@ -330,7 +338,6 @@ impl Display {
/// This is used to implement various style fixups. /// This is used to implement various style fixups.
pub fn is_item_container(&self) -> bool { pub fn is_item_container(&self) -> bool {
match self.inside() { match self.inside() {
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
DisplayInside::Flex => true, DisplayInside::Flex => true,
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
DisplayInside::Grid => true, DisplayInside::Grid => true,
@ -432,12 +439,9 @@ impl ToCss for Display {
_ => match (outside, inside) { _ => match (outside, inside) {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
(DisplayOutside::Inline, DisplayInside::Grid) => dest.write_str("inline-grid"), (DisplayOutside::Inline, DisplayInside::Grid) => dest.write_str("inline-grid"),
(DisplayOutside::Inline, DisplayInside::Flex) => dest.write_str("inline-flex"),
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))] #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
(DisplayOutside::Inline, DisplayInside::Flex) | (DisplayOutside::Inline, DisplayInside::Table) => dest.write_str("inline-table"),
(DisplayOutside::Inline, DisplayInside::Table) => {
dest.write_str("inline-")?;
inside.to_css(dest)
},
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
(DisplayOutside::Block, DisplayInside::Ruby) => dest.write_str("block ruby"), (DisplayOutside::Block, DisplayInside::Ruby) => dest.write_str("block ruby"),
(_, inside) => { (_, inside) => {
@ -467,12 +471,11 @@ fn parse_display_inside<'i, 't>(
) -> Result<DisplayInside, ParseError<'i>> { ) -> Result<DisplayInside, ParseError<'i>> {
Ok(try_match_ident_ignore_ascii_case! { input, Ok(try_match_ident_ignore_ascii_case! { input,
"flow" => DisplayInside::Flow, "flow" => DisplayInside::Flow,
"flex" if flexbox_enabled() => DisplayInside::Flex,
#[cfg(any(feature = "servo-layout-2020", feature = "gecko"))] #[cfg(any(feature = "servo-layout-2020", feature = "gecko"))]
"flow-root" => DisplayInside::FlowRoot, "flow-root" => DisplayInside::FlowRoot,
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))] #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
"table" => DisplayInside::Table, "table" => DisplayInside::Table,
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
"flex" => DisplayInside::Flex,
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
"grid" => DisplayInside::Grid, "grid" => DisplayInside::Grid,
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
@ -575,10 +578,8 @@ impl Parse for Display {
"inline-block" => Display::InlineBlock, "inline-block" => Display::InlineBlock,
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))] #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
"inline-table" => Display::InlineTable, "inline-table" => Display::InlineTable,
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))] "-webkit-flex" if flexbox_enabled() => Display::Flex,
"-webkit-flex" => Display::Flex, "inline-flex" | "-webkit-inline-flex" if flexbox_enabled() => Display::InlineFlex,
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
"inline-flex" | "-webkit-inline-flex" => Display::InlineFlex,
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
"inline-grid" => Display::InlineGrid, "inline-grid" => Display::InlineGrid,
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))] #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]