mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Auto merge of #19966 - emilio:bye-gecko-size, r=nox
style: Get rid of gecko_size_type. It's a hack, should die. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19966) <!-- Reviewable:end -->
This commit is contained in:
commit
dc446198a7
10 changed files with 211 additions and 192 deletions
|
@ -18,8 +18,8 @@ use style_traits::{ParseError, StyleParseErrorKind};
|
|||
use style_traits::values::specified::AllowedNumericType;
|
||||
use stylesheets::CssRuleType;
|
||||
use super::{AllowQuirks, Number, ToComputedValue, Percentage};
|
||||
use values::{Auto, CSSFloat, Either, ExtremumLength, None_, Normal};
|
||||
use values::computed::{self, CSSPixelLength, Context};
|
||||
use values::{Auto, CSSFloat, Either, None_, Normal};
|
||||
use values::computed::{self, CSSPixelLength, Context, ExtremumLength};
|
||||
use values::generics::NonNegative;
|
||||
use values::specified::NonNegativeNumber;
|
||||
use values::specified::calc::CalcNode;
|
||||
|
@ -933,6 +933,7 @@ impl LengthOrPercentageOrAuto {
|
|||
}
|
||||
|
||||
/// Returns a value representing `0%`.
|
||||
#[inline]
|
||||
pub fn zero_percent() -> Self {
|
||||
LengthOrPercentageOrAuto::Percentage(computed::Percentage::zero())
|
||||
}
|
||||
|
@ -1125,15 +1126,45 @@ impl Parse for MozLength {
|
|||
}
|
||||
|
||||
impl MozLength {
|
||||
/// Parses, without quirks, and disallowing ExtremumLength values.
|
||||
///
|
||||
/// Used for logical props in the block direction.
|
||||
pub fn parse_disallow_keyword<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let length = LengthOrPercentageOrAuto::parse_non_negative(context, input)?;
|
||||
Ok(MozLength::LengthOrPercentageOrAuto(length))
|
||||
}
|
||||
|
||||
/// Parses, with quirks.
|
||||
pub fn parse_quirky<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
input.try(ExtremumLength::parse).map(MozLength::ExtremumLength)
|
||||
.or_else(|_| input.try(|i| LengthOrPercentageOrAuto::parse_non_negative_quirky(context, i, allow_quirks))
|
||||
.map(MozLength::LengthOrPercentageOrAuto))
|
||||
if let Ok(l) = input.try(ExtremumLength::parse) {
|
||||
return Ok(MozLength::ExtremumLength(l));
|
||||
}
|
||||
|
||||
let length = LengthOrPercentageOrAuto::parse_non_negative_quirky(
|
||||
context,
|
||||
input,
|
||||
allow_quirks,
|
||||
)?;
|
||||
Ok(MozLength::LengthOrPercentageOrAuto(length))
|
||||
}
|
||||
|
||||
/// Returns `auto`.
|
||||
#[inline]
|
||||
pub fn auto() -> Self {
|
||||
MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::auto())
|
||||
}
|
||||
|
||||
/// Returns `0%`.
|
||||
#[inline]
|
||||
pub fn zero_percent() -> Self {
|
||||
MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::zero_percent())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1152,14 +1183,32 @@ impl Parse for MaxLength {
|
|||
}
|
||||
|
||||
impl MaxLength {
|
||||
/// Parses, without quirks, and disallowing ExtremumLength values.
|
||||
///
|
||||
/// Used for logical props in the block direction.
|
||||
pub fn parse_disallow_keyword<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let length = LengthOrPercentageOrNone::parse_non_negative(context, input)?;
|
||||
Ok(MaxLength::LengthOrPercentageOrNone(length))
|
||||
}
|
||||
|
||||
/// Parses, with quirks.
|
||||
pub fn parse_quirky<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
input.try(ExtremumLength::parse).map(MaxLength::ExtremumLength)
|
||||
.or_else(|_| input.try(|i| LengthOrPercentageOrNone::parse_non_negative_quirky(context, i, allow_quirks))
|
||||
.map(MaxLength::LengthOrPercentageOrNone))
|
||||
if let Ok(l) = input.try(ExtremumLength::parse) {
|
||||
return Ok(MaxLength::ExtremumLength(l));
|
||||
}
|
||||
|
||||
let length = LengthOrPercentageOrNone::parse_non_negative_quirky(
|
||||
context,
|
||||
input,
|
||||
allow_quirks,
|
||||
)?;
|
||||
Ok(MaxLength::LengthOrPercentageOrNone(length))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue