mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +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 {
|
||||
($($name: ident => $discriminant: expr,)+) => {
|
||||
($(
|
||||
$(#[$($meta:tt)+])*
|
||||
$name: ident => $discriminant: expr,
|
||||
)+) => {
|
||||
/// Specified value of text-align keyword value.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq,
|
||||
SpecifiedValueInfo, ToComputedValue, ToCss)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum TextAlignKeyword {
|
||||
$(
|
||||
$(#[$($meta)+])*
|
||||
$name = $discriminant,
|
||||
)+
|
||||
}
|
||||
|
@ -392,6 +396,7 @@ define_text_align_keyword! {
|
|||
MozCenter => 6,
|
||||
MozLeft => 7,
|
||||
MozRight => 8,
|
||||
#[css(skip)]
|
||||
Char => 10,
|
||||
}
|
||||
|
||||
|
@ -418,7 +423,7 @@ impl TextAlignKeyword {
|
|||
|
||||
/// Specified value of text-align property.
|
||||
#[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 {
|
||||
/// Keyword value of text-align property.
|
||||
Keyword(TextAlignKeyword),
|
||||
|
@ -430,6 +435,7 @@ pub enum TextAlign {
|
|||
/// only set directly on the elements and it has a different handling
|
||||
/// unlike other values.
|
||||
#[cfg(feature = "gecko")]
|
||||
#[css(skip)]
|
||||
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 {
|
||||
/// Convert an enumerated value coming from Gecko to a `TextAlign`.
|
||||
#[cfg(feature = "gecko")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue