mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Implement enough of 3d transforms spec to run the CSS FPS demo.
This commit is contained in:
parent
d86c587925
commit
39ddbbb0e1
19 changed files with 894 additions and 145 deletions
|
@ -480,6 +480,45 @@ pub mod specified {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Copy, Debug)]
|
||||
pub enum LengthOrNone {
|
||||
Length(Length),
|
||||
None,
|
||||
}
|
||||
|
||||
impl ToCss for LengthOrNone {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match self {
|
||||
&LengthOrNone::Length(length) => length.to_css(dest),
|
||||
&LengthOrNone::None => dest.write_str("none"),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl LengthOrNone {
|
||||
fn parse_internal(input: &mut Parser, context: &AllowedNumericType)
|
||||
-> Result<LengthOrNone, ()>
|
||||
{
|
||||
match try!(input.next()) {
|
||||
Token::Dimension(ref value, ref unit) if context.is_ok(value.value) =>
|
||||
Length::parse_dimension(value.value, unit).map(LengthOrNone::Length),
|
||||
Token::Number(ref value) if value.value == 0. =>
|
||||
Ok(LengthOrNone::Length(Length::Absolute(Au(0)))),
|
||||
Token::Ident(ref value) if value.eq_ignore_ascii_case("none") =>
|
||||
Ok(LengthOrNone::None),
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
#[inline]
|
||||
pub fn parse(input: &mut Parser) -> Result<LengthOrNone, ()> {
|
||||
LengthOrNone::parse_internal(input, &AllowedNumericType::All)
|
||||
}
|
||||
#[inline]
|
||||
pub fn parse_non_negative(input: &mut Parser) -> Result<LengthOrNone, ()> {
|
||||
LengthOrNone::parse_internal(input, &AllowedNumericType::NonNegative)
|
||||
}
|
||||
}
|
||||
|
||||
/// The sum of a series of lengths and a percentage. This is used in `calc()` and other things
|
||||
/// that effectively work like it (e.g. transforms).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
@ -1069,6 +1108,36 @@ pub mod computed {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Copy)]
|
||||
pub enum LengthOrNone {
|
||||
Length(Au),
|
||||
None,
|
||||
}
|
||||
impl fmt::Debug for LengthOrNone {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
&LengthOrNone::Length(length) => write!(f, "{:?}", length),
|
||||
&LengthOrNone::None => write!(f, "none"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for specified::LengthOrNone {
|
||||
type ComputedValue = LengthOrNone;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> LengthOrNone {
|
||||
match *self {
|
||||
specified::LengthOrNone::Length(value) => {
|
||||
LengthOrNone::Length(value.to_computed_value(context))
|
||||
}
|
||||
specified::LengthOrNone::None => {
|
||||
LengthOrNone::None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The sum of a series of lengths and a percentage. This is used in `calc()` and other things
|
||||
/// that effectively work like it (e.g. transforms).
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue