Bug 1540093 - Unship line-height: -moz-block-height. r=mats
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 29 Mar 2019 11:11:27 +0000
changeset 466744 46ad671b9fafbabad163c8e6b7d7bc752d142f1b
parent 466743 7077ebbd4677cabc478006b26dbf7cc6ac9bd0dc
child 466745 d133d99184f14bef374ddaea9e5db2c894450340
push id35780
push useropoprus@mozilla.com
push dateFri, 29 Mar 2019 21:53:01 +0000
treeherdermozilla-central@414f37afbe07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1540093
milestone68.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 1540093 - Unship line-height: -moz-block-height. r=mats They're only used in forms.css, and only for some anonymous content, which are not content-accessible in the first place. The only place where this could be exposed is calling getComputedStyle(input, "::placeholder"), so I think this should be pretty safe, but I've added a pref just in case. While at it, also derive the Parse implementation. Less code is better. Differential Revision: https://phabricator.services.mozilla.com/D25118
layout/style/test/property_database.js
layout/style/test/test_non_content_accessible_values.html
modules/libpref/init/StaticPrefList.h
servo/components/style/values/generics/text.rs
servo/components/style/values/specified/text.rs
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -3987,22 +3987,22 @@ var gCSSProperties = {
     applies_to_first_letter: true,
     applies_to_first_line: true,
     applies_to_placeholder: true,
     /*
      * Inheritance tests require consistent font size, since
      * getComputedStyle (which uses the CSS2 computed value, or
      * CSS2.1 used value) doesn't match what the CSS2.1 computed
      * value is.  And they even require consistent font metrics for
-     * computation of 'normal'.   -moz-block-height requires height
-     * on a block.
+     * computation of 'normal'.
      */
     prerequisites: { "font-size": "19px", "font-size-adjust": "none", "font-family": "serif", "font-weight": "normal", "font-style": "normal", "height": "18px", "display": "block", "writing-mode": "initial" },
+
     initial_values: [ "normal" ],
-    other_values: [ "1.0", "1", "1em", "47px", "-moz-block-height", "calc(2px)", "calc(50%)", "calc(3*25px)", "calc(25px*3)", "calc(3*25px + 50%)", "calc(1 + 2*3/4)" ],
+    other_values: [ "1.0", "1", "1em", "47px", "calc(2px)", "calc(50%)", "calc(3*25px)", "calc(25px*3)", "calc(3*25px + 50%)", "calc(1 + 2*3/4)" ],
     invalid_values: [ "calc(1 + 2px)", "calc(100% + 0.1)" ]
   },
   "list-style": {
     domProp: "listStyle",
     inherited: true,
     type: CSS_TYPE_TRUE_SHORTHAND,
     subproperties: [ "list-style-type", "list-style-position", "list-style-image" ],
     initial_values: [ "outside", "disc", "disc outside", "outside disc", "disc none", "none disc", "none disc outside", "none outside disc", "disc none outside", "disc outside none", "outside none disc", "outside disc none" ],
--- a/layout/style/test/test_non_content_accessible_values.html
+++ b/layout/style/test/test_non_content_accessible_values.html
@@ -108,16 +108,19 @@ const NON_CONTENT_ACCESSIBLE_VALUES = {
     "-moz-mac-vibrancy-dark",
     "-moz-mac-vibrancy-light",
     "-moz-mac-vibrant-titlebar-dark",
     "-moz-mac-vibrant-titlebar-light",
   ],
   "-moz-user-select": [
     "-moz-text",
   ],
+  "line-height": [
+    "-moz-block-height",
+  ],
 };
 
 if (!SpecialPowers.getBoolPref("layout.css.xul-box-display-values.content.enabled")) {
   NON_CONTENT_ACCESSIBLE_VALUES.display.push("-moz-box", "-moz-inline-box");
 }
 
 const sheet = document.getElementById("sheet");
 const div = document.querySelector("div");
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -982,16 +982,23 @@ VARCACHE_PREF(
 
 // Is support for CSS "grid-template-{columns,rows}: subgrid X" enabled?
 VARCACHE_PREF(
   "layout.css.grid-template-subgrid-value.enabled",
    layout_css_grid_template_subgrid_value_enabled,
   bool, false
 )
 
+// Pref to control whether line-height: -moz-block-height is exposed to content.
+VARCACHE_PREF(
+  "layout.css.line-height-moz-block-height.content.enabled",
+   layout_css_line_height_moz_block_height_content_enabled,
+  bool, false
+)
+
 // Is support for variation fonts enabled?
 VARCACHE_PREF(
   "layout.css.font-variations.enabled",
    layout_css_font_variations_enabled,
   RelaxedAtomicBool, true
 )
 
 // Are we emulating -moz-{inline}-box layout using CSS flexbox?
--- a/servo/components/style/values/generics/text.rs
+++ b/servo/components/style/values/generics/text.rs
@@ -56,35 +56,45 @@ impl<Value> Spacing<Value> {
     {
         if input.try(|i| i.expect_ident_matching("normal")).is_ok() {
             return Ok(Spacing::Normal);
         }
         parse(context, input).map(Spacing::Value)
     }
 }
 
+#[cfg(feature = "gecko")]
+fn line_height_moz_block_height_enabled(context: &ParserContext) -> bool {
+    use crate::gecko_bindings::structs;
+    context.in_ua_sheet() || unsafe {
+        structs::StaticPrefs_sVarCache_layout_css_line_height_moz_block_height_content_enabled
+    }
+}
+
 /// A generic value for the `line-height` property.
 #[derive(
     Animate,
     Clone,
     ComputeSquaredDistance,
     Copy,
     Debug,
     MallocSizeOf,
     PartialEq,
     SpecifiedValueInfo,
     ToAnimatedValue,
     ToCss,
+    Parse,
 )]
 #[repr(C, u8)]
 pub enum GenericLineHeight<N, L> {
     /// `normal`
     Normal,
     /// `-moz-block-height`
     #[cfg(feature = "gecko")]
+    #[parse(condition = "line_height_moz_block_height_enabled")]
     MozBlockHeight,
     /// `<number>`
     Number(N),
     /// `<length-percentage>`
     Length(L),
 }
 
 pub use self::GenericLineHeight as LineHeight;
--- a/servo/components/style/values/specified/text.rs
+++ b/servo/components/style/values/specified/text.rs
@@ -68,43 +68,16 @@ impl Parse for WordSpacing {
         input: &mut Parser<'i, 't>,
     ) -> Result<Self, ParseError<'i>> {
         Spacing::parse_with(context, input, |c, i| {
             LengthPercentage::parse_quirky(c, i, AllowQuirks::Yes)
         })
     }
 }
 
-impl Parse for LineHeight {
-    fn parse<'i, 't>(
-        context: &ParserContext,
-        input: &mut Parser<'i, 't>,
-    ) -> Result<Self, ParseError<'i>> {
-        if let Ok(number) = input.try(|i| NonNegativeNumber::parse(context, i)) {
-            return Ok(GenericLineHeight::Number(number));
-        }
-        if let Ok(nlp) = input.try(|i| NonNegativeLengthPercentage::parse(context, i)) {
-            return Ok(GenericLineHeight::Length(nlp));
-        }
-        let location = input.current_source_location();
-        let ident = input.expect_ident()?;
-        match ident {
-            ref ident if ident.eq_ignore_ascii_case("normal") => Ok(GenericLineHeight::Normal),
-            #[cfg(feature = "gecko")]
-            ref ident if ident.eq_ignore_ascii_case("-moz-block-height") => {
-                Ok(GenericLineHeight::MozBlockHeight)
-            },
-            ident => {
-                Err(location
-                    .new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())))
-            },
-        }
-    }
-}
-
 impl ToComputedValue for LineHeight {
     type ComputedValue = ComputedLineHeight;
 
     #[inline]
     fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
         use crate::values::computed::Length as ComputedLength;
         use crate::values::specified::length::FontBaseSize;
         match *self {