mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Derive ToCss for TransitionProperty
This commit is contained in:
parent
83a2312867
commit
13c40f4fb8
2 changed files with 23 additions and 17 deletions
|
@ -26,10 +26,9 @@ use properties::{LonghandId, ShorthandId};
|
|||
use servo_arc::Arc;
|
||||
use smallvec::SmallVec;
|
||||
use std::{cmp, ptr};
|
||||
use std::fmt::{self, Write};
|
||||
use std::mem::{self, ManuallyDrop};
|
||||
#[cfg(feature = "gecko")] use hash::FnvHashMap;
|
||||
use style_traits::{CssWriter, ParseError, ToCss};
|
||||
use style_traits::ParseError;
|
||||
use super::ComputedValues;
|
||||
use values::{CSSFloat, CustomIdent, Either};
|
||||
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
|
||||
|
@ -79,7 +78,7 @@ pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool {
|
|||
/// a shorthand with at least one transitionable longhand component, or an unsupported property.
|
||||
// NB: This needs to be here because it needs all the longhands generated
|
||||
// beforehand.
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)]
|
||||
pub enum TransitionProperty {
|
||||
/// A shorthand.
|
||||
Shorthand(ShorthandId),
|
||||
|
@ -90,19 +89,6 @@ pub enum TransitionProperty {
|
|||
Unsupported(CustomIdent),
|
||||
}
|
||||
|
||||
impl ToCss for TransitionProperty {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
TransitionProperty::Shorthand(ref id) => dest.write_str(id.name()),
|
||||
TransitionProperty::Longhand(ref id) => dest.write_str(id.name()),
|
||||
TransitionProperty::Unsupported(ref id) => id.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trivial_to_computed_value!(TransitionProperty);
|
||||
|
||||
impl TransitionProperty {
|
||||
|
|
|
@ -800,6 +800,16 @@ pub enum LonghandId {
|
|||
% endfor
|
||||
}
|
||||
|
||||
impl ToCss for LonghandId {
|
||||
#[inline]
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
dest.write_str(self.name())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for LonghandId {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str(self.name())
|
||||
|
@ -1130,7 +1140,7 @@ where
|
|||
}
|
||||
|
||||
/// An identifier for a given shorthand property.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
|
||||
pub enum ShorthandId {
|
||||
% for property in data.shorthands:
|
||||
/// ${property.name}
|
||||
|
@ -1138,6 +1148,16 @@ pub enum ShorthandId {
|
|||
% endfor
|
||||
}
|
||||
|
||||
impl ToCss for ShorthandId {
|
||||
#[inline]
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
dest.write_str(self.name())
|
||||
}
|
||||
}
|
||||
|
||||
impl ShorthandId {
|
||||
/// Get the name for this shorthand property.
|
||||
pub fn name(&self) -> &'static str {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue