Bug 1574148 - Fix Servo build and unify display representation.
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 15 Aug 2019 13:31:44 +0000
changeset 488232 289698fdd8ce1d2ab7f25c2e536bd7f553646e9a
parent 488231 0fffa7c38535239a5b51cee44096e246de446856
child 488233 5128445df0de7cd28f6bf0f603b90e4af186dc68
push id113904
push userncsoregi@mozilla.com
push dateThu, 15 Aug 2019 19:41:00 +0000
treeherdermozilla-inbound@b283a7ef186c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1574148
milestone70.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 1574148 - Fix Servo build and unify display representation. Differential Revision: https://phabricator.services.mozilla.com/D42130
servo/components/style/lib.rs
servo/components/style/properties/shorthands/text.mako.rs
servo/components/style/style_adjuster.rs
servo/components/style/values/specified/box.rs
--- a/servo/components/style/lib.rs
+++ b/servo/components/style/lib.rs
@@ -86,16 +86,17 @@ pub extern crate servo_arc;
 #[macro_use]
 extern crate servo_atoms;
 #[cfg(feature = "servo")]
 extern crate servo_config;
 #[cfg(feature = "servo")]
 extern crate servo_url;
 extern crate smallbitvec;
 extern crate smallvec;
+#[cfg(feature = "gecko")]
 extern crate static_prefs;
 #[cfg(feature = "servo")]
 extern crate string_cache;
 #[macro_use]
 extern crate style_derive;
 extern crate style_traits;
 #[cfg(feature = "gecko")]
 extern crate thin_slice;
--- a/servo/components/style/properties/shorthands/text.mako.rs
+++ b/servo/components/style/properties/shorthands/text.mako.rs
@@ -18,24 +18,24 @@
     % endif
     use crate::properties::longhands::text_decoration_line;
 
     pub fn parse_value<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
     ) -> Result<Longhands, ParseError<'i>> {
         % if engine == "gecko":
+            let text_decoration_thickness_enabled =
+                PropertyId::Longhand(LonghandId::TextDecorationThickness).enabled_for_all_content();
+
             let (mut line, mut style, mut color, mut thickness, mut any) = (None, None, None, None, false);
         % else:
             let (mut line, mut any) = (None, false);
         % endif
 
-        let text_decoration_thickness_enabled =
-            PropertyId::Longhand(LonghandId::TextDecorationThickness).enabled_for_all_content();
-
         loop {
             macro_rules! parse_component {
                 ($value:ident, $module:ident) => (
                     if $value.is_none() {
                         if let Ok(value) = input.try(|input| $module::parse(context, input)) {
                             $value = Some(value);
                             any = true;
                             continue;
--- a/servo/components/style/style_adjuster.rs
+++ b/servo/components/style/style_adjuster.rs
@@ -7,17 +7,16 @@
 
 use crate::dom::TElement;
 use crate::properties::computed_value_flags::ComputedValueFlags;
 use crate::properties::longhands::display::computed_value::T as Display;
 use crate::properties::longhands::float::computed_value::T as Float;
 use crate::properties::longhands::overflow_x::computed_value::T as Overflow;
 use crate::properties::longhands::position::computed_value::T as Position;
 use crate::properties::{self, ComputedValues, StyleBuilder};
-#[cfg(feature = "gecko")]
 use crate::values::specified::box_::DisplayInside;
 use app_units::Au;
 
 /// A struct that implements all the adjustment methods.
 ///
 /// NOTE(emilio): If new adjustments are introduced that depend on reset
 /// properties of the parent, you may need tweaking the
 /// `ChildCascadeRequirement` code in `matching.rs`.
@@ -201,17 +200,16 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
             let parent_display = layout_parent_style.get_box().clone_display();
             blockify_if!(parent_display.is_item_container());
         }
 
         let is_item_or_root = blockify;
 
         blockify_if!(self.style.floated());
         blockify_if!(self.style.out_of_flow_positioned());
-        #[cfg(feature = "gecko")]
         blockify_if!(
             self.style.pseudo.map_or(false, |p| p.is_marker()) &&
                 self.style.get_parent_list().clone_list_style_position() ==
                     ListStylePosition::Outside &&
                 layout_parent_style.get_box().clone_display().inside() != DisplayInside::Inline
         );
 
         if !blockify {
--- a/servo/components/style/values/specified/box.rs
+++ b/servo/components/style/values/specified/box.rs
@@ -29,82 +29,88 @@ 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")
 }
 
-#[cfg(feature = "servo-layout-2013")]
-fn parse_unimplemented_in_servo_2020(_context: &ParserContext) -> bool {
-    true
-}
-
-#[cfg(feature = "servo-layout-2020")]
-fn parse_unimplemented_in_servo_2020(_context: &ParserContext) -> bool {
-    servo_config::prefs::pref_map()
-        .get("layout.2020.unimplemented")
-        .as_bool()
-        .unwrap_or(false)
-}
-
 /// 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)]
-#[cfg(feature = "gecko")]
 #[repr(u8)]
 pub enum DisplayOutside {
     None = 0,
     Inline,
     Block,
     TableCaption,
     InternalTable,
+    #[cfg(feature = "gecko")]
     InternalRuby,
+    #[cfg(feature = "gecko")]
     XUL,
 }
 
 #[allow(missing_docs)]
 #[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, MallocSizeOf, PartialEq, ToCss, ToShmem)]
-#[cfg(feature = "gecko")]
 #[repr(u8)]
 pub enum DisplayInside {
     None = 0,
+    #[cfg(feature = "gecko")]
     Contents,
     Block,
     FlowRoot,
     Inline,
     Flex,
+    #[cfg(feature = "gecko")]
     Grid,
     Table,
     TableRowGroup,
     TableColumn,
     TableColumnGroup,
     TableHeaderGroup,
     TableFooterGroup,
     TableRow,
     TableCell,
+    #[cfg(feature = "gecko")]
     Ruby,
+    #[cfg(feature = "gecko")]
     RubyBase,
+    #[cfg(feature = "gecko")]
     RubyBaseContainer,
+    #[cfg(feature = "gecko")]
     RubyText,
+    #[cfg(feature = "gecko")]
     RubyTextContainer,
+    #[cfg(feature = "gecko")]
     WebkitBox,
+    #[cfg(feature = "gecko")]
     MozBox,
+    #[cfg(feature = "gecko")]
     MozInlineBox,
+    #[cfg(feature = "gecko")]
     MozGrid,
+    #[cfg(feature = "gecko")]
     MozInlineGrid,
+    #[cfg(feature = "gecko")]
     MozGridGroup,
+    #[cfg(feature = "gecko")]
     MozGridLine,
+    #[cfg(feature = "gecko")]
     MozStack,
+    #[cfg(feature = "gecko")]
     MozInlineStack,
+    #[cfg(feature = "gecko")]
     MozDeck,
+    #[cfg(feature = "gecko")]
     MozGroupbox,
+    #[cfg(feature = "gecko")]
     MozPopup,
     Flow, // only used for parsing, not computed value
 }
 
 #[allow(missing_docs)]
 #[derive(
     Clone,
     Copy,
@@ -113,49 +119,52 @@ pub enum DisplayInside {
     FromPrimitive,
     Hash,
     MallocSizeOf,
     PartialEq,
     ToComputedValue,
     ToResolvedValue,
     ToShmem,
 )]
-#[cfg(feature = "gecko")]
 #[repr(transparent)]
 pub struct Display(u16);
 
 /// Gecko-only impl block for Display (shared stuff later in this file):
 #[allow(missing_docs)]
 #[allow(non_upper_case_globals)]
-#[cfg(feature = "gecko")]
 impl Display {
     // Our u16 bits are used as follows:    LOOOOOOOIIIIIIII
     const LIST_ITEM_BIT: u16 = 0x8000; //^
     const DISPLAY_OUTSIDE_BITS: u16 = 7; // ^^^^^^^
     const DISPLAY_INSIDE_BITS: u16 = 8; //        ^^^^^^^^
 
     /// https://drafts.csswg.org/css-display/#the-display-properties
     pub const None: Self = Self::new(DisplayOutside::None, DisplayInside::None);
+    #[cfg(feature = "gecko")]
     pub const Contents: Self = Self::new(DisplayOutside::None, DisplayInside::Contents);
     pub const Inline: Self = Self::new(DisplayOutside::Inline, DisplayInside::Inline);
     pub const InlineBlock: Self = Self::new(DisplayOutside::Inline, DisplayInside::FlowRoot);
     pub const Block: Self = Self::new(DisplayOutside::Block, DisplayInside::Block);
+    #[cfg(feature = "gecko")]
     pub const FlowRoot: Self = Self::new(DisplayOutside::Block, DisplayInside::FlowRoot);
     pub const Flex: Self = Self::new(DisplayOutside::Block, DisplayInside::Flex);
     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);
     pub const Table: Self = Self::new(DisplayOutside::Block, DisplayInside::Table);
     pub const InlineTable: Self = Self::new(DisplayOutside::Inline, DisplayInside::Table);
     pub const TableCaption: Self = Self::new(DisplayOutside::TableCaption, DisplayInside::Block);
+    #[cfg(feature = "gecko")]
     pub const Ruby: Self = Self::new(DisplayOutside::Inline, DisplayInside::Ruby);
+    #[cfg(feature = "gecko")]
     pub const WebkitBox: Self = Self::new(DisplayOutside::Block, DisplayInside::WebkitBox);
+    #[cfg(feature = "gecko")]
     pub const WebkitInlineBox: Self = Self::new(DisplayOutside::Inline, DisplayInside::WebkitBox);
-    pub const ListItem: Self = Self::new_list_item(DisplayOutside::Block, DisplayInside::Block);
-
     /// Internal table boxes.
     pub const TableRowGroup: Self =
         Self::new(DisplayOutside::InternalTable, DisplayInside::TableRowGroup);
     pub const TableHeaderGroup: Self = Self::new(
         DisplayOutside::InternalTable,
         DisplayInside::TableHeaderGroup,
     );
     pub const TableFooterGroup: Self = Self::new(
@@ -164,58 +173,67 @@ impl Display {
     );
     pub const TableColumn: Self =
         Self::new(DisplayOutside::InternalTable, DisplayInside::TableColumn);
     pub const TableColumnGroup: Self = Self::new(
         DisplayOutside::InternalTable,
         DisplayInside::TableColumnGroup,
     );
     pub const TableRow: Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableRow);
+
     pub const TableCell: Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableCell);
 
     /// Internal ruby boxes.
+    #[cfg(feature = "gecko")]
     pub const RubyBase: Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyBase);
+    #[cfg(feature = "gecko")]
     pub const RubyBaseContainer: Self = Self::new(
         DisplayOutside::InternalRuby,
         DisplayInside::RubyBaseContainer,
     );
+    #[cfg(feature = "gecko")]
     pub const RubyText: Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyText);
+    #[cfg(feature = "gecko")]
     pub const RubyTextContainer: Self = Self::new(
         DisplayOutside::InternalRuby,
         DisplayInside::RubyTextContainer,
     );
 
     /// XUL boxes.
+    #[cfg(feature = "gecko")]
     pub const MozBox: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozBox);
+    #[cfg(feature = "gecko")]
     pub const MozInlineBox: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozInlineBox);
+    #[cfg(feature = "gecko")]
     pub const MozGrid: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozGrid);
+    #[cfg(feature = "gecko")]
     pub const MozInlineGrid: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozInlineGrid);
+    #[cfg(feature = "gecko")]
     pub const MozGridGroup: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozGridGroup);
+    #[cfg(feature = "gecko")]
     pub const MozGridLine: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozGridLine);
+    #[cfg(feature = "gecko")]
     pub const MozStack: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozStack);
+    #[cfg(feature = "gecko")]
     pub const MozInlineStack: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozInlineStack);
+    #[cfg(feature = "gecko")]
     pub const MozDeck: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozDeck);
+    #[cfg(feature = "gecko")]
     pub const MozGroupbox: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozGroupbox);
+    #[cfg(feature = "gecko")]
     pub const MozPopup: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozPopup);
 
     /// Make a raw display value from <display-outside> and <display-inside> values.
     #[inline]
     const fn new(outside: DisplayOutside, inside: DisplayInside) -> Self {
         let o: u16 = ((outside as u8) as u16) << Self::DISPLAY_INSIDE_BITS;
         let i: u16 = (inside as u8) as u16;
         Self(o | i)
     }
 
-    /// Make a list-item display value from <display-outside> and <display-inside>.
-    #[inline]
-    const fn new_list_item(outside: DisplayOutside, inside: DisplayInside) -> Self {
-        let v = Self::new(outside, inside);
-        Self(v.0 | Self::LIST_ITEM_BIT)
-    }
-
     /// Make a display enum value from <display-outside> and <display-inside> values.
     /// We store `flow` as a synthetic `block` or `inline` inside-value to simplify
     /// our layout code.
     #[inline]
     fn from3(outside: DisplayOutside, inside: DisplayInside, list_item: bool) -> Self {
         let inside = match inside {
             DisplayInside::Flow => match outside {
                 DisplayOutside::Inline => DisplayInside::Inline,
@@ -248,135 +266,67 @@ impl Display {
     /// Returns whether this `display` value is some kind of list-item.
     #[inline]
     pub const fn is_list_item(&self) -> bool {
         (self.0 & Self::LIST_ITEM_BIT) != 0
     }
 
     /// Returns whether this `display` value is a ruby level container.
     pub fn is_ruby_level_container(&self) -> bool {
-        matches!(
-            *self,
-            Display::RubyBaseContainer | Display::RubyTextContainer
-        )
+        match *self {
+            #[cfg(feature = "gecko")]
+            Display::RubyBaseContainer | Display::RubyTextContainer => true,
+            _ => false,
+        }
     }
 
     /// Returns whether this `display` value is one of the types for ruby.
     pub fn is_ruby_type(&self) -> bool {
-        matches!(
-            self.inside(),
+        match self.inside() {
+            #[cfg(feature = "gecko")]
             DisplayInside::Ruby |
-                DisplayInside::RubyBase |
-                DisplayInside::RubyText |
-                DisplayInside::RubyBaseContainer |
-                DisplayInside::RubyTextContainer
-        )
+            DisplayInside::RubyBase |
+            DisplayInside::RubyText |
+            DisplayInside::RubyBaseContainer |
+            DisplayInside::RubyTextContainer => true,
+            _ => false,
+        }
     }
 }
 
-/// Servo version of Display only contains single-keyword values, and isn't
-/// using outside/inside values at all.
-#[allow(missing_docs)]
-#[derive(
-    Clone,
-    Copy,
-    Debug,
-    Deserialize,
-    Eq,
-    FromPrimitive,
-    Hash,
-    MallocSizeOf,
-    Parse,
-    PartialEq,
-    Serialize,
-    SpecifiedValueInfo,
-    ToComputedValue,
-    ToCss,
-    ToResolvedValue,
-    ToShmem,
-)]
-#[cfg(not(feature = "gecko"))]
-#[repr(u8)]
-pub enum Display {
-    None = 0,
-    Block,
-    Inline,
-    #[parse(condition = "parse_unimplemented_in_servo_2020")]
-    InlineBlock,
-    #[cfg(feature = "servo-layout-2013")]
-    ListItem,
-    #[cfg(feature = "servo-layout-2013")]
-    Table,
-    #[cfg(feature = "servo-layout-2013")]
-    InlineTable,
-    #[cfg(feature = "servo-layout-2013")]
-    TableRowGroup,
-    #[cfg(feature = "servo-layout-2013")]
-    TableColumn,
-    #[cfg(feature = "servo-layout-2013")]
-    TableColumnGroup,
-    #[cfg(feature = "servo-layout-2013")]
-    TableHeaderGroup,
-    #[cfg(feature = "servo-layout-2013")]
-    TableFooterGroup,
-    #[cfg(feature = "servo-layout-2013")]
-    TableRow,
-    #[cfg(feature = "servo-layout-2013")]
-    TableCell,
-    #[cfg(feature = "servo-layout-2013")]
-    TableCaption,
-    #[cfg(feature = "servo-layout-2013")]
-    #[parse(aliases = "-webkit-flex")]
-    Flex,
-    #[cfg(feature = "servo-layout-2013")]
-    #[parse(aliases = "-webkit-inline-flex")]
-    InlineFlex,
-}
-
 /// Shared Display impl for both Gecko and Servo.
-#[allow(missing_docs)]
 #[allow(non_upper_case_globals)]
 impl Display {
     /// The initial display value.
     #[inline]
     pub fn inline() -> Self {
         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,
-            #[cfg(feature = "servo-layout-2013")]
             Display::InlineFlex | 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 {
-        #[cfg(feature = "gecko")]
-        {
-            match self.inside() {
-                DisplayInside::Flex | DisplayInside::Grid => true,
-                _ => false,
-            }
-        }
-        #[cfg(not(feature = "gecko"))]
-        {
-            match *self {
-                #[cfg(feature = "servo-layout-2013")]
-                Display::Flex | Display::InlineFlex => true,
-                _ => false,
-            }
+        match self.inside() {
+            DisplayInside::Flex => true,
+            #[cfg(feature = "gecko")]
+            DisplayInside::Grid => true,
+            _ => false,
         }
     }
 
     /// Returns whether an element with this display type is a line
     /// participant, which means it may lay its children on the same
     /// line as itself.
     pub fn is_line_participant(&self) -> bool {
         match *self {
@@ -389,61 +339,47 @@ impl Display {
 
     /// Convert this display into an equivalent block display.
     ///
     /// Also used for :root style adjustments.
     pub fn equivalent_block_display(&self, _is_root_element: bool) -> Self {
         #[cfg(feature = "gecko")]
         {
             // Special handling for `contents` and `list-item`s on the root element.
-            if _is_root_element && (*self == Display::Contents || self.is_list_item()) {
+            if _is_root_element && (self.is_contents() || self.is_list_item()) {
                 return Display::Block;
             }
-            match self.outside() {
-                DisplayOutside::Inline => {
-                    let inside = match self.inside() {
-                        DisplayInside::Inline | DisplayInside::FlowRoot => DisplayInside::Block,
-                        inside => inside,
-                    };
-                    Display::from3(DisplayOutside::Block, inside, self.is_list_item())
-                },
-                DisplayOutside::Block | DisplayOutside::None => *self,
-                _ => Display::Block,
-            }
         }
-        #[cfg(not(feature = "gecko"))]
-        match *self {
-            // Values that have a corresponding block-outside version.
-            #[cfg(feature = "servo-layout-2013")]
-            Display::InlineTable => Display::Table,
-            #[cfg(feature = "servo-layout-2013")]
-            Display::InlineFlex => Display::Flex,
 
-            // These are not changed by blockification.
-            Display::None | Display::Block => *self,
-            #[cfg(feature = "servo-layout-2013")]
-            Display::Flex | Display::ListItem | Display::Table => *self,
-
-            // Everything else becomes block.
+        match self.outside() {
+            DisplayOutside::Inline => {
+                let inside = match self.inside() {
+                    DisplayInside::Inline | DisplayInside::FlowRoot => DisplayInside::Block,
+                    inside => inside,
+                };
+                Display::from3(DisplayOutside::Block, inside, self.is_list_item())
+            },
+            DisplayOutside::Block | DisplayOutside::None => *self,
             _ => Display::Block,
         }
     }
 
     /// Convert this display into an equivalent inline-outside display.
     /// https://drafts.csswg.org/css-display/#inlinify
     #[cfg(feature = "gecko")]
     pub fn inlinify(&self) -> Self {
         match self.outside() {
             DisplayOutside::Block => {
                 let inside = match self.inside() {
                     DisplayInside::Block => DisplayInside::FlowRoot,
                     inside => inside,
                 };
                 Display::from3(DisplayOutside::Inline, inside, self.is_list_item())
             },
+            #[cfg(feature = "gecko")]
             DisplayOutside::XUL => match self.inside() {
                 DisplayInside::MozBox => Display::MozInlineBox,
                 DisplayInside::MozStack => Display::MozInlineStack,
                 _ => *self,
             },
             _ => *self,
         }
     }
@@ -460,17 +396,16 @@ impl Display {
 
     /// Returns true if the value is `None`
     #[inline]
     pub fn is_none(&self) -> bool {
         *self == Display::None
     }
 }
 
-#[cfg(feature = "gecko")]
 impl ToCss for Display {
     fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
     where
         W: fmt::Write,
     {
         debug_assert_ne!(
             self.inside(),
             DisplayInside::Flow,
@@ -479,29 +414,34 @@ impl ToCss for Display {
         let outside = self.outside();
         let inside = match self.inside() {
             DisplayInside::Block | DisplayInside::Inline => DisplayInside::Flow,
             inside => inside,
         };
         match *self {
             Display::Block | Display::Inline => outside.to_css(dest),
             Display::InlineBlock => dest.write_str("inline-block"),
+            #[cfg(feature = "gecko")]
             Display::WebkitInlineBox => dest.write_str("-webkit-inline-box"),
+            #[cfg(feature = "gecko")]
             Display::MozInlineBox => dest.write_str("-moz-inline-box"),
+            #[cfg(feature = "gecko")]
             Display::MozInlineGrid => dest.write_str("-moz-inline-grid"),
+            #[cfg(feature = "gecko")]
             Display::MozInlineStack => dest.write_str("-moz-inline-stack"),
             Display::TableCaption => dest.write_str("table-caption"),
-            Display::ListItem => dest.write_str("list-item"),
             _ => match (outside, inside) {
+                #[cfg(feature = "gecko")]
+                (DisplayOutside::Inline, DisplayInside::Grid) => dest.write_str("inline-grid"),
                 (DisplayOutside::Inline, DisplayInside::Flex) |
-                (DisplayOutside::Inline, DisplayInside::Grid) |
                 (DisplayOutside::Inline, DisplayInside::Table) => {
                     dest.write_str("inline-")?;
                     inside.to_css(dest)
                 },
+                #[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(" ")?;
                         }
                         if inside != DisplayInside::Flow {
@@ -515,73 +455,74 @@ impl ToCss for Display {
                 },
             },
         }
     }
 }
 
 /// <display-inside> = flow | flow-root | table | flex | grid | ruby
 /// https://drafts.csswg.org/css-display/#typedef-display-inside
-#[cfg(feature = "gecko")]
 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,
+        #[cfg(feature = "gecko")]
         "flow-root" => DisplayInside::FlowRoot,
         "table" => DisplayInside::Table,
         "flex" => DisplayInside::Flex,
+        #[cfg(feature = "gecko")]
         "grid" => DisplayInside::Grid,
+        #[cfg(feature = "gecko")]
         "ruby" => DisplayInside::Ruby,
     })
 }
 
 /// <display-outside> = block | inline | run-in
 /// https://drafts.csswg.org/css-display/#typedef-display-outside
-#[cfg(feature = "gecko")]
 fn parse_display_outside<'i, 't>(
     input: &mut Parser<'i, 't>,
 ) -> Result<DisplayOutside, ParseError<'i>> {
     Ok(try_match_ident_ignore_ascii_case! { input,
         "block" => DisplayOutside::Block,
         "inline" => DisplayOutside::Inline,
         // FIXME(bug 2056): not supported in layout yet:
         //"run-in" => DisplayOutside::RunIn,
     })
 }
 
 /// (flow | flow-root)?
-#[cfg(feature = "gecko")]
 fn parse_display_inside_for_list_item<'i, 't>(
     input: &mut Parser<'i, 't>,
 ) -> Result<DisplayInside, ParseError<'i>> {
     Ok(try_match_ident_ignore_ascii_case! { input,
         "flow" => DisplayInside::Flow,
+        #[cfg(feature = "gecko")]
         "flow-root" => DisplayInside::FlowRoot,
     })
 }
 /// Test a <display-inside> Result for same values as above.
-#[cfg(feature = "gecko")]
 fn is_valid_inside_for_list_item<'i>(inside: &Result<DisplayInside, ParseError<'i>>) -> bool {
-    matches!(
-        inside,
-        Ok(DisplayInside::Flow) | Ok(DisplayInside::FlowRoot)
-    )
+    match inside {
+        Ok(DisplayInside::Flow) => true,
+        #[cfg(feature = "gecko")]
+        Ok(DisplayInside::FlowRoot) => true,
+        _ => false,
+    }
 }
 
 /// Parse `list-item`.
-#[cfg(feature = "gecko")]
 fn parse_list_item<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(), ParseError<'i>> {
     Ok(try_match_ident_ignore_ascii_case! { input,
         "list-item" => (),
     })
 }
 
-#[cfg(feature = "gecko")]
 impl Parse for Display {
+    #[allow(unused)] // `context` isn't used for servo-2020 for now
     fn parse<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
     ) -> Result<Display, ParseError<'i>> {
         // Parse all combinations of <display-inside/outside>? and `list-item`? first.
         let mut got_list_item = input.try(parse_list_item).is_ok();
         let mut inside = if got_list_item {
             input.try(parse_display_inside_for_list_item)
@@ -610,62 +551,80 @@ impl Parse for Display {
             }
         }
         if got_list_item || inside.is_ok() || outside.is_ok() {
             let inside = inside.unwrap_or(DisplayInside::Flow);
             let outside = outside.unwrap_or(match inside {
                 // "If <display-outside> is omitted, the element’s outside display type
                 // defaults to block — except for ruby, which defaults to inline."
                 // https://drafts.csswg.org/css-display/#inside-model
+                #[cfg(feature = "gecko")]
                 DisplayInside::Ruby => DisplayOutside::Inline,
                 _ => DisplayOutside::Block,
             });
             return Ok(Display::from3(outside, inside, got_list_item));
         }
 
         // Now parse the single-keyword `display` values.
         Ok(try_match_ident_ignore_ascii_case! { input,
             "none" => Display::None,
+            #[cfg(feature = "gecko")]
             "contents" => Display::Contents,
             "inline-block" => Display::InlineBlock,
             "inline-table" => Display::InlineTable,
-            "inline-flex" => Display::InlineFlex,
             "-webkit-flex" => Display::Flex,
-            "-webkit-inline-flex" => Display::InlineFlex,
+            "inline-flex" | "-webkit-inline-flex" => Display::InlineFlex,
+            #[cfg(feature = "gecko")]
             "inline-grid" => Display::InlineGrid,
             "table-caption" => Display::TableCaption,
             "table-row-group" => Display::TableRowGroup,
             "table-header-group" => Display::TableHeaderGroup,
             "table-footer-group" => Display::TableFooterGroup,
             "table-column" => Display::TableColumn,
             "table-column-group" => Display::TableColumnGroup,
             "table-row" => Display::TableRow,
             "table-cell" => Display::TableCell,
+            #[cfg(feature = "gecko")]
             "ruby-base" => Display::RubyBase,
+            #[cfg(feature = "gecko")]
             "ruby-base-container" => Display::RubyBaseContainer,
+            #[cfg(feature = "gecko")]
             "ruby-text" => Display::RubyText,
+            #[cfg(feature = "gecko")]
             "ruby-text-container" => Display::RubyTextContainer,
+            #[cfg(feature = "gecko")]
             "-webkit-box" => Display::WebkitBox,
+            #[cfg(feature = "gecko")]
             "-webkit-inline-box" => Display::WebkitInlineBox,
+            #[cfg(feature = "gecko")]
             "-moz-box" if moz_box_display_values_enabled(context) => Display::MozBox,
+            #[cfg(feature = "gecko")]
             "-moz-inline-box" if moz_box_display_values_enabled(context) => Display::MozInlineBox,
+            #[cfg(feature = "gecko")]
             "-moz-grid" if moz_display_values_enabled(context) => Display::MozGrid,
+            #[cfg(feature = "gecko")]
             "-moz-inline-grid" if moz_display_values_enabled(context) => Display::MozInlineGrid,
+            #[cfg(feature = "gecko")]
             "-moz-grid-group" if moz_display_values_enabled(context) => Display::MozGridGroup,
+            #[cfg(feature = "gecko")]
             "-moz-grid-line" if moz_display_values_enabled(context) => Display::MozGridLine,
+            #[cfg(feature = "gecko")]
             "-moz-stack" if moz_display_values_enabled(context) => Display::MozStack,
+            #[cfg(feature = "gecko")]
             "-moz-inline-stack" if moz_display_values_enabled(context) => Display::MozInlineStack,
+            #[cfg(feature = "gecko")]
             "-moz-deck" if moz_display_values_enabled(context) => Display::MozDeck,
+            #[cfg(feature = "gecko")]
             "-moz-groupbox" if moz_display_values_enabled(context) => Display::MozGroupbox,
+            #[cfg(feature = "gecko")]
             "-moz-popup" if moz_display_values_enabled(context) => Display::MozPopup,
         })
     }
 }
 
-#[cfg(feature = "gecko")]
 impl SpecifiedValueInfo for Display {
     fn collect_completion_keywords(f: KeywordsCollectFn) {
         f(&[
             "block",
             "contents",
             "flex",
             "flow-root",
             "grid",