mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
Rename MinLength to MozLength.
So that we can reuse this for non-min-prefixed properties (e.g. width).
This commit is contained in:
parent
95bda2dff9
commit
57c27e5d35
8 changed files with 59 additions and 58 deletions
|
@ -606,56 +606,56 @@ pub type LengthOrNumber = Either<Length, Number>;
|
|||
/// Either a computed `<length>` or the `normal` keyword.
|
||||
pub type LengthOrNormal = Either<Length, Normal>;
|
||||
|
||||
/// A value suitable for a `min-width` or `min-height` property.
|
||||
/// A value suitable for a `min-width`, `min-height`, `width` or `height` property.
|
||||
/// See specified/values/length.rs for more details.
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[allow(missing_docs)]
|
||||
pub enum MinLength {
|
||||
pub enum MozLength {
|
||||
LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
|
||||
ExtremumLength(ExtremumLength),
|
||||
}
|
||||
|
||||
impl MinLength {
|
||||
impl MozLength {
|
||||
/// Returns the `auto` value.
|
||||
pub fn auto() -> Self {
|
||||
MinLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto)
|
||||
MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for specified::MinLength {
|
||||
type ComputedValue = MinLength;
|
||||
impl ToComputedValue for specified::MozLength {
|
||||
type ComputedValue = MozLength;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> MinLength {
|
||||
fn to_computed_value(&self, context: &Context) -> MozLength {
|
||||
match *self {
|
||||
specified::MinLength::LengthOrPercentageOrAuto(ref lopoa) => {
|
||||
MinLength::LengthOrPercentageOrAuto(lopoa.to_computed_value(context))
|
||||
specified::MozLength::LengthOrPercentageOrAuto(ref lopoa) => {
|
||||
MozLength::LengthOrPercentageOrAuto(lopoa.to_computed_value(context))
|
||||
}
|
||||
specified::MinLength::ExtremumLength(ref ext) => {
|
||||
MinLength::ExtremumLength(ext.clone())
|
||||
specified::MozLength::ExtremumLength(ref ext) => {
|
||||
MozLength::ExtremumLength(ext.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &MinLength) -> Self {
|
||||
fn from_computed_value(computed: &MozLength) -> Self {
|
||||
match *computed {
|
||||
MinLength::LengthOrPercentageOrAuto(ref lopoa) =>
|
||||
specified::MinLength::LengthOrPercentageOrAuto(
|
||||
MozLength::LengthOrPercentageOrAuto(ref lopoa) =>
|
||||
specified::MozLength::LengthOrPercentageOrAuto(
|
||||
specified::LengthOrPercentageOrAuto::from_computed_value(&lopoa)),
|
||||
MinLength::ExtremumLength(ref ext) =>
|
||||
specified::MinLength::ExtremumLength(ext.clone()),
|
||||
MozLength::ExtremumLength(ref ext) =>
|
||||
specified::MozLength::ExtremumLength(ext.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for MinLength {
|
||||
impl ToCss for MozLength {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
MinLength::LengthOrPercentageOrAuto(lopoa) =>
|
||||
MozLength::LengthOrPercentageOrAuto(lopoa) =>
|
||||
lopoa.to_css(dest),
|
||||
MinLength::ExtremumLength(ext) =>
|
||||
MozLength::ExtremumLength(ext) =>
|
||||
ext.to_css(dest),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ pub use super::specified::{BorderStyle, GridLine, Percentage, UrlOrNone};
|
|||
pub use super::specified::url::SpecifiedUrl;
|
||||
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
pub use self::length::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone, LengthOrNone};
|
||||
pub use self::length::{MaxLength, MinLength};
|
||||
pub use self::length::{MaxLength, MozLength};
|
||||
pub use self::position::Position;
|
||||
|
||||
pub mod basic_shape;
|
||||
|
|
|
@ -1176,41 +1176,41 @@ impl LengthOrNumber {
|
|||
}
|
||||
|
||||
/// A value suitable for a `min-width` or `min-height` property.
|
||||
/// Unlike `max-width` or `max-height` properties, a MinLength can be
|
||||
/// Unlike `max-width` or `max-height` properties, a MozLength can be
|
||||
/// `auto`, and cannot be `none`.
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[allow(missing_docs)]
|
||||
pub enum MinLength {
|
||||
pub enum MozLength {
|
||||
LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
|
||||
ExtremumLength(ExtremumLength),
|
||||
}
|
||||
|
||||
impl ToCss for MinLength {
|
||||
impl ToCss for MozLength {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
MinLength::LengthOrPercentageOrAuto(ref lopoa) =>
|
||||
MozLength::LengthOrPercentageOrAuto(ref lopoa) =>
|
||||
lopoa.to_css(dest),
|
||||
MinLength::ExtremumLength(ref ext) =>
|
||||
MozLength::ExtremumLength(ref ext) =>
|
||||
ext.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for MinLength {
|
||||
impl Parse for MozLength {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
MinLength::parse_quirky(context, input, AllowQuirks::No)
|
||||
MozLength::parse_quirky(context, input, AllowQuirks::No)
|
||||
}
|
||||
}
|
||||
|
||||
impl MinLength {
|
||||
impl MozLength {
|
||||
/// Parses, with quirks.
|
||||
pub fn parse_quirky(context: &ParserContext,
|
||||
input: &mut Parser,
|
||||
allow_quirks: AllowQuirks) -> Result<Self, ()> {
|
||||
input.try(ExtremumLength::parse).map(MinLength::ExtremumLength)
|
||||
input.try(ExtremumLength::parse).map(MozLength::ExtremumLength)
|
||||
.or_else(|()| input.try(|i| LengthOrPercentageOrAuto::parse_non_negative_quirky(context, i, allow_quirks))
|
||||
.map(MinLength::LengthOrPercentageOrAuto))
|
||||
.map(MozLength::LengthOrPercentageOrAuto))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ pub use self::length::AbsoluteLength;
|
|||
pub use self::length::{FontRelativeLength, ViewportPercentageLength, CharacterWidth, Length, CalcLengthOrPercentage};
|
||||
pub use self::length::{Percentage, LengthOrNone, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
pub use self::length::{LengthOrPercentageOrNone, LengthOrPercentageOrAutoOrContent, NoCalcLength};
|
||||
pub use self::length::{MaxLength, MinLength};
|
||||
pub use self::length::{MaxLength, MozLength};
|
||||
pub use self::position::{Position, PositionComponent};
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue