зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1681691 - Create a NonNegativePercentage type in values:specified. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D109285
This commit is contained in:
Родитель
835997ddf8
Коммит
4545c4a746
|
@ -71,7 +71,7 @@ pub use self::list::Quotes;
|
||||||
pub use self::motion::{OffsetPath, OffsetRotate};
|
pub use self::motion::{OffsetPath, OffsetRotate};
|
||||||
pub use self::outline::OutlineStyle;
|
pub use self::outline::OutlineStyle;
|
||||||
pub use self::page::{Orientation, PageSize, PaperSize};
|
pub use self::page::{Orientation, PageSize, PaperSize};
|
||||||
pub use self::percentage::Percentage;
|
pub use self::percentage::{Percentage, NonNegativePercentage};
|
||||||
pub use self::position::AspectRatio;
|
pub use self::position::AspectRatio;
|
||||||
pub use self::position::{
|
pub use self::position::{
|
||||||
GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto,
|
GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto,
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
use crate::parser::{Parse, ParserContext};
|
use crate::parser::{Parse, ParserContext};
|
||||||
use crate::values::computed::percentage::Percentage as ComputedPercentage;
|
use crate::values::computed::percentage::Percentage as ComputedPercentage;
|
||||||
use crate::values::computed::{Context, ToComputedValue};
|
use crate::values::computed::{Context, ToComputedValue};
|
||||||
|
use crate::values::generics::NonNegative;
|
||||||
use crate::values::specified::calc::CalcNode;
|
use crate::values::specified::calc::CalcNode;
|
||||||
use crate::values::specified::Number;
|
use crate::values::specified::Number;
|
||||||
use crate::values::{serialize_percentage, CSSFloat};
|
use crate::values::{serialize_percentage, CSSFloat};
|
||||||
|
@ -172,3 +173,16 @@ impl ToComputedValue for Percentage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SpecifiedValueInfo for Percentage {}
|
impl SpecifiedValueInfo for Percentage {}
|
||||||
|
|
||||||
|
/// A wrapper of Percentage, whose value must be >= 0.
|
||||||
|
pub type NonNegativePercentage = NonNegative<Percentage>;
|
||||||
|
|
||||||
|
impl Parse for NonNegativePercentage {
|
||||||
|
#[inline]
|
||||||
|
fn parse<'i, 't>(
|
||||||
|
context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
Ok(NonNegative(Percentage::parse_non_negative(context, input)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче