mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Have TextAlign derive ToCss and unship char value from it.
Bug: 1434130 Reviewed-by: emilio MozReview-Commit-ID: CXDnyqzjQkq
This commit is contained in:
parent
43bb6364f6
commit
5437c96402
1 changed files with 8 additions and 17 deletions
|
@ -355,13 +355,17 @@ impl Parse for TextDecorationLine {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! define_text_align_keyword {
|
macro_rules! define_text_align_keyword {
|
||||||
($($name: ident => $discriminant: expr,)+) => {
|
($(
|
||||||
|
$(#[$($meta:tt)+])*
|
||||||
|
$name: ident => $discriminant: expr,
|
||||||
|
)+) => {
|
||||||
/// Specified value of text-align keyword value.
|
/// Specified value of text-align keyword value.
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq,
|
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq,
|
||||||
SpecifiedValueInfo, ToComputedValue, ToCss)]
|
SpecifiedValueInfo, ToComputedValue, ToCss)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum TextAlignKeyword {
|
pub enum TextAlignKeyword {
|
||||||
$(
|
$(
|
||||||
|
$(#[$($meta)+])*
|
||||||
$name = $discriminant,
|
$name = $discriminant,
|
||||||
)+
|
)+
|
||||||
}
|
}
|
||||||
|
@ -392,6 +396,7 @@ define_text_align_keyword! {
|
||||||
MozCenter => 6,
|
MozCenter => 6,
|
||||||
MozLeft => 7,
|
MozLeft => 7,
|
||||||
MozRight => 8,
|
MozRight => 8,
|
||||||
|
#[css(skip)]
|
||||||
Char => 10,
|
Char => 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +423,7 @@ impl TextAlignKeyword {
|
||||||
|
|
||||||
/// Specified value of text-align property.
|
/// Specified value of text-align property.
|
||||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, SpecifiedValueInfo)]
|
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, SpecifiedValueInfo, ToCss)]
|
||||||
pub enum TextAlign {
|
pub enum TextAlign {
|
||||||
/// Keyword value of text-align property.
|
/// Keyword value of text-align property.
|
||||||
Keyword(TextAlignKeyword),
|
Keyword(TextAlignKeyword),
|
||||||
|
@ -430,6 +435,7 @@ pub enum TextAlign {
|
||||||
/// only set directly on the elements and it has a different handling
|
/// only set directly on the elements and it has a different handling
|
||||||
/// unlike other values.
|
/// unlike other values.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
#[css(skip)]
|
||||||
MozCenterOrInherit,
|
MozCenterOrInherit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,21 +460,6 @@ impl Parse for TextAlign {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToCss for TextAlign {
|
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
||||||
where
|
|
||||||
W: Write,
|
|
||||||
{
|
|
||||||
match *self {
|
|
||||||
TextAlign::Keyword(key) => key.to_css(dest),
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
TextAlign::MatchParent => dest.write_str("match-parent"),
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
TextAlign::MozCenterOrInherit => Ok(()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TextAlign {
|
impl TextAlign {
|
||||||
/// Convert an enumerated value coming from Gecko to a `TextAlign`.
|
/// Convert an enumerated value coming from Gecko to a `TextAlign`.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue