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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-03-29 11:11:27 +00:00
Родитель 3514c8548d
Коммит 859ca6ad05
5 изменённых файлов: 23 добавлений и 30 удалений

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

@ -3992,12 +3992,12 @@ var gCSSProperties = {
* getComputedStyle (which uses the CSS2 computed value, or * getComputedStyle (which uses the CSS2 computed value, or
* CSS2.1 used value) doesn't match what the CSS2.1 computed * CSS2.1 used value) doesn't match what the CSS2.1 computed
* value is. And they even require consistent font metrics for * value is. And they even require consistent font metrics for
* computation of 'normal'. -moz-block-height requires height * computation of 'normal'.
* on a block.
*/ */
prerequisites: { "font-size": "19px", "font-size-adjust": "none", "font-family": "serif", "font-weight": "normal", "font-style": "normal", "height": "18px", "display": "block", "writing-mode": "initial" }, 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" ], 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)" ] invalid_values: [ "calc(1 + 2px)", "calc(100% + 0.1)" ]
}, },
"list-style": { "list-style": {

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

@ -113,6 +113,9 @@ const NON_CONTENT_ACCESSIBLE_VALUES = {
"-moz-user-select": [ "-moz-user-select": [
"-moz-text", "-moz-text",
], ],
"line-height": [
"-moz-block-height",
],
}; };
if (!SpecialPowers.getBoolPref("layout.css.xul-box-display-values.content.enabled")) { if (!SpecialPowers.getBoolPref("layout.css.xul-box-display-values.content.enabled")) {

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

@ -987,6 +987,13 @@ VARCACHE_PREF(
bool, false 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? // Is support for variation fonts enabled?
VARCACHE_PREF( VARCACHE_PREF(
"layout.css.font-variations.enabled", "layout.css.font-variations.enabled",

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

@ -61,6 +61,14 @@ impl<Value> 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. /// A generic value for the `line-height` property.
#[derive( #[derive(
Animate, Animate,
@ -73,6 +81,7 @@ impl<Value> Spacing<Value> {
SpecifiedValueInfo, SpecifiedValueInfo,
ToAnimatedValue, ToAnimatedValue,
ToCss, ToCss,
Parse,
)] )]
#[repr(C, u8)] #[repr(C, u8)]
pub enum GenericLineHeight<N, L> { pub enum GenericLineHeight<N, L> {
@ -80,6 +89,7 @@ pub enum GenericLineHeight<N, L> {
Normal, Normal,
/// `-moz-block-height` /// `-moz-block-height`
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
#[parse(condition = "line_height_moz_block_height_enabled")]
MozBlockHeight, MozBlockHeight,
/// `<number>` /// `<number>`
Number(N), Number(N),

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

@ -73,33 +73,6 @@ impl Parse for WordSpacing {
} }
} }
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 { impl ToComputedValue for LineHeight {
type ComputedValue = ComputedLineHeight; type ComputedValue = ComputedLineHeight;