style: Fix indentation of the media query code.

Bug: 1396057
Reviewed-by: Manishearth
MozReview-Commit-ID: BtdGHbQAzeS
This commit is contained in:
Emilio Cobos Álvarez 2017-11-10 16:09:19 +01:00
parent bc58e18761
commit a09f5208d4
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -439,7 +439,8 @@ impl MediaExpressionValue {
} }
fn find_feature<F>(mut f: F) -> Option<&'static nsMediaFeature> fn find_feature<F>(mut f: F) -> Option<&'static nsMediaFeature>
where F: FnMut(&'static nsMediaFeature) -> bool, where
F: FnMut(&'static nsMediaFeature) -> bool,
{ {
unsafe { unsafe {
let mut features = structs::nsMediaFeatures_features.as_ptr(); let mut features = structs::nsMediaFeatures_features.as_ptr();
@ -453,10 +454,12 @@ fn find_feature<F>(mut f: F) -> Option<&'static nsMediaFeature>
None None
} }
unsafe fn find_in_table<F>(mut current_entry: *const nsCSSProps_KTableEntry, unsafe fn find_in_table<F>(
mut f: F) mut current_entry: *const nsCSSProps_KTableEntry,
-> Option<(nsCSSKeyword, i16)> mut f: F,
where F: FnMut(nsCSSKeyword, i16) -> bool ) -> Option<(nsCSSKeyword, i16)>
where
F: FnMut(nsCSSKeyword, i16) -> bool
{ {
loop { loop {
let value = (*current_entry).mValue; let value = (*current_entry).mValue;
@ -474,66 +477,69 @@ unsafe fn find_in_table<F>(mut current_entry: *const nsCSSProps_KTableEntry,
} }
} }
fn parse_feature_value<'i, 't>(feature: &nsMediaFeature, fn parse_feature_value<'i, 't>(
feature_value_type: nsMediaFeature_ValueType, feature: &nsMediaFeature,
context: &ParserContext, feature_value_type: nsMediaFeature_ValueType,
input: &mut Parser<'i, 't>) context: &ParserContext,
-> Result<MediaExpressionValue, ParseError<'i>> { input: &mut Parser<'i, 't>,
) -> Result<MediaExpressionValue, ParseError<'i>> {
let value = match feature_value_type { let value = match feature_value_type {
nsMediaFeature_ValueType::eLength => { nsMediaFeature_ValueType::eLength => {
let length = Length::parse_non_negative(context, input)?; let length = Length::parse_non_negative(context, input)?;
// FIXME(canaltinova): See bug 1396057. Gecko doesn't support calc // FIXME(canaltinova): See bug 1396057. Gecko doesn't support calc
// inside media queries. This check is for temporarily remove it // inside media queries. This check is for temporarily remove it
// for parity with gecko. We should remove this check when we want // for parity with gecko. We should remove this check when we want
// to support it. // to support it.
if let Length::Calc(_) = length { if let Length::Calc(_) = length {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
} }
MediaExpressionValue::Length(length) MediaExpressionValue::Length(length)
}, },
nsMediaFeature_ValueType::eInteger => { nsMediaFeature_ValueType::eInteger => {
// FIXME(emilio): We should use `Integer::parse` to handle `calc` // FIXME(emilio): We should use `Integer::parse` to handle `calc`
// properly in integer expressions. Note that calc is still not // properly in integer expressions. Note that calc is still not
// supported in media queries per FIXME above. // supported in media queries per FIXME above.
let i = input.expect_integer()?; let i = input.expect_integer()?;
if i < 0 { if i < 0 {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
} }
MediaExpressionValue::Integer(i as u32) MediaExpressionValue::Integer(i as u32)
} }
nsMediaFeature_ValueType::eBoolInteger => { nsMediaFeature_ValueType::eBoolInteger => {
let i = input.expect_integer()?; let i = input.expect_integer()?;
if i < 0 || i > 1 { if i < 0 || i > 1 {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
} }
MediaExpressionValue::BoolInteger(i == 1) MediaExpressionValue::BoolInteger(i == 1)
} }
nsMediaFeature_ValueType::eFloat => { nsMediaFeature_ValueType::eFloat => {
MediaExpressionValue::Float(input.expect_number()?) MediaExpressionValue::Float(input.expect_number()?)
} }
nsMediaFeature_ValueType::eIntRatio => { nsMediaFeature_ValueType::eIntRatio => {
let a = input.expect_integer()?; let a = input.expect_integer()?;
if a <= 0 { if a <= 0 {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
} }
input.expect_delim('/')?; input.expect_delim('/')?;
let b = input.expect_integer()?; let b = input.expect_integer()?;
if b <= 0 { if b <= 0 {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
} }
MediaExpressionValue::IntRatio(a as u32, b as u32) MediaExpressionValue::IntRatio(a as u32, b as u32)
} }
nsMediaFeature_ValueType::eResolution => { nsMediaFeature_ValueType::eResolution => {
MediaExpressionValue::Resolution(Resolution::parse(input)?) MediaExpressionValue::Resolution(Resolution::parse(input)?)
} }
nsMediaFeature_ValueType::eEnumerated => { nsMediaFeature_ValueType::eEnumerated => {
let location = input.current_source_location(); let location = input.current_source_location();
let keyword = input.expect_ident()?; let keyword = input.expect_ident()?;
let keyword = unsafe { let keyword = unsafe {
bindings::Gecko_LookupCSSKeyword(keyword.as_bytes().as_ptr(), bindings::Gecko_LookupCSSKeyword(
keyword.len() as u32) keyword.as_bytes().as_ptr(),
keyword.len() as u32,
)
}; };
let first_table_entry: *const nsCSSProps_KTableEntry = unsafe { let first_table_entry: *const nsCSSProps_KTableEntry = unsafe {
@ -557,14 +563,12 @@ fn parse_feature_value<'i, 't>(feature: &nsMediaFeature,
impl Expression { impl Expression {
/// Trivially construct a new expression. /// Trivially construct a new expression.
fn new(feature: &'static nsMediaFeature, fn new(
value: Option<MediaExpressionValue>, feature: &'static nsMediaFeature,
range: nsMediaExpression_Range) -> Self { value: Option<MediaExpressionValue>,
Expression { range: nsMediaExpression_Range,
feature: feature, ) -> Self {
value: value, Self { feature, value, range }
range: range,
}
} }
/// Parse a media expression of the form: /// Parse a media expression of the form: