Bug 1646811 - servo: Gate layout 2020 flex implementation behind a pref.
authorSimon Sapin <simon.sapin@exyr.org>
Thu, 18 Jun 2020 18:11:39 +0000
changeset 536360 d7a1aeb69518a871f120d0d7e728df9be528e30c
parent 536359 40dae06d5e4dc28c1cc66b7980cbc7b0437a0b3b
child 536361 1743d20e0d029ea47bb57884c678afae4c15b953
push id119420
push userealvarez@mozilla.com
push dateThu, 18 Jun 2020 18:18:12 +0000
treeherderautoland@206011a5cc20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1646811
milestone79.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 1646811 - servo: Gate layout 2020 flex implementation behind a pref. Differential Revision: https://phabricator.services.mozilla.com/D80231
servo/components/style/values/specified/box.rs
--- a/servo/components/style/values/specified/box.rs
+++ b/servo/components/style/values/specified/box.rs
@@ -29,16 +29,27 @@ fn moz_display_values_enabled(context: &
 }
 
 #[cfg(feature = "gecko")]
 fn moz_box_display_values_enabled(context: &ParserContext) -> bool {
     context.in_ua_or_chrome_sheet() ||
         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 element’s display type, which consists of
 /// the two basic qualities of how an element generates boxes
 /// <https://drafts.csswg.org/css-display/#propdef-display>
 #[allow(missing_docs)]
 #[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, MallocSizeOf, PartialEq, ToCss, ToShmem)]
 #[repr(u8)]
 pub enum DisplayOutside {
     None = 0,
@@ -58,17 +69,16 @@ pub enum DisplayOutside {
 #[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, MallocSizeOf, PartialEq, ToCss, ToShmem)]
 #[repr(u8)]
 pub enum DisplayInside {
     None = 0,
     #[cfg(any(feature = "servo-layout-2020", feature = "gecko"))]
     Contents,
     Flow,
     FlowRoot,
-    #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
     Flex,
     #[cfg(feature = "gecko")]
     Grid,
     #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
     Table,
     #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
     TableRowGroup,
     #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
@@ -141,19 +151,17 @@ impl Display {
     pub const None: Self = Self::new(DisplayOutside::None, DisplayInside::None);
     #[cfg(any(feature = "servo-layout-2020", feature = "gecko"))]
     pub const Contents: Self = Self::new(DisplayOutside::None, DisplayInside::Contents);
     pub const Inline: Self = Self::new(DisplayOutside::Inline, DisplayInside::Flow);
     pub const InlineBlock: Self = Self::new(DisplayOutside::Inline, DisplayInside::FlowRoot);
     pub const Block: Self = Self::new(DisplayOutside::Block, DisplayInside::Flow);
     #[cfg(feature = "gecko")]
     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);
-    #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
     pub const InlineFlex: Self = Self::new(DisplayOutside::Inline, DisplayInside::Flex);
     #[cfg(feature = "gecko")]
     pub const Grid: Self = Self::new(DisplayOutside::Block, DisplayInside::Grid);
     #[cfg(feature = "gecko")]
     pub const InlineGrid: Self = Self::new(DisplayOutside::Inline, DisplayInside::Grid);
     #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
     pub const Table: Self = Self::new(DisplayOutside::Block, DisplayInside::Table);
     #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
@@ -312,30 +320,29 @@ impl Display {
         Display::Inline
     }
 
     /// <https://drafts.csswg.org/css2/visuren.html#x13>
     #[cfg(feature = "servo")]
     #[inline]
     pub fn is_atomic_inline_level(&self) -> bool {
         match *self {
-            Display::InlineBlock => true,
+            Display::InlineBlock | Display::InlineFlex => true,
             #[cfg(any(feature = "servo-layout-2013"))]
-            Display::InlineFlex | Display::InlineTable => true,
+            Display::InlineTable => true,
             _ => false,
         }
     }
 
     /// Returns whether this `display` value is the display of a flex or
     /// grid container.
     ///
     /// This is used to implement various style fixups.
     pub fn is_item_container(&self) -> bool {
         match self.inside() {
-            #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
             DisplayInside::Flex => true,
             #[cfg(feature = "gecko")]
             DisplayInside::Grid => true,
             _ => false,
         }
     }
 
     /// Returns whether an element with this display type is a line
@@ -427,22 +434,19 @@ impl ToCss for Display {
             Display::WebkitInlineBox => dest.write_str("-webkit-inline-box"),
             #[cfg(feature = "gecko")]
             Display::MozInlineBox => dest.write_str("-moz-inline-box"),
             #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
             Display::TableCaption => dest.write_str("table-caption"),
             _ => match (outside, inside) {
                 #[cfg(feature = "gecko")]
                 (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"))]
-                (DisplayOutside::Inline, DisplayInside::Flex) |
-                (DisplayOutside::Inline, DisplayInside::Table) => {
-                    dest.write_str("inline-")?;
-                    inside.to_css(dest)
-                },
+                (DisplayOutside::Inline, DisplayInside::Table) => dest.write_str("inline-table"),
                 #[cfg(feature = "gecko")]
                 (DisplayOutside::Block, DisplayInside::Ruby) => dest.write_str("block ruby"),
                 (_, inside) => {
                     if self.is_list_item() {
                         if outside != DisplayOutside::Block {
                             outside.to_css(dest)?;
                             dest.write_str(" ")?;
                         }
@@ -462,22 +466,21 @@ impl ToCss for Display {
 
 /// <display-inside> = flow | flow-root | table | flex | grid | ruby
 /// https://drafts.csswg.org/css-display/#typedef-display-inside
 fn parse_display_inside<'i, 't>(
     input: &mut Parser<'i, 't>,
 ) -> Result<DisplayInside, ParseError<'i>> {
     Ok(try_match_ident_ignore_ascii_case! { input,
         "flow" => DisplayInside::Flow,
+        "flex" if flexbox_enabled() => DisplayInside::Flex,
         #[cfg(any(feature = "servo-layout-2020", feature = "gecko"))]
         "flow-root" => DisplayInside::FlowRoot,
         #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
         "table" => DisplayInside::Table,
-        #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
-        "flex" => DisplayInside::Flex,
         #[cfg(feature = "gecko")]
         "grid" => DisplayInside::Grid,
         #[cfg(feature = "gecko")]
         "ruby" => DisplayInside::Ruby,
     })
 }
 
 /// <display-outside> = block | inline | run-in
@@ -570,20 +573,18 @@ impl Parse for Display {
         // Now parse the single-keyword `display` values.
         Ok(try_match_ident_ignore_ascii_case! { input,
             "none" => Display::None,
             #[cfg(any(feature = "servo-layout-2020", feature = "gecko"))]
             "contents" => Display::Contents,
             "inline-block" => Display::InlineBlock,
             #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
             "inline-table" => Display::InlineTable,
-            #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
-            "-webkit-flex" => Display::Flex,
-            #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
-            "inline-flex" | "-webkit-inline-flex" => Display::InlineFlex,
+            "-webkit-flex" if flexbox_enabled() => Display::Flex,
+            "inline-flex" | "-webkit-inline-flex" if flexbox_enabled() => Display::InlineFlex,
             #[cfg(feature = "gecko")]
             "inline-grid" => Display::InlineGrid,
             #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
             "table-caption" => Display::TableCaption,
             #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
             "table-row-group" => Display::TableRowGroup,
             #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
             "table-header-group" => Display::TableHeaderGroup,