style: Use enums for text-align / text-align-last.

This also fixes some backwards logic in nsBlockFrame::ReflowDirtyLines, and adds
some static assertions to nsGenericHTMLElement that almost cause a very subtle
bug.

Depends on D63792

Differential Revision: https://phabricator.services.mozilla.com/D63793
This commit is contained in:
Emilio Cobos Álvarez 2020-02-24 13:32:57 +00:00
parent 37c382a74b
commit 7af9a087aa
8 changed files with 47 additions and 61 deletions

View file

@ -85,6 +85,7 @@ pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight, TextAl
pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak};
pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing};
pub use self::text::{TextDecorationLength, TextDecorationSkipInk, TextTransform};
pub use self::text::TextAlignLast;
pub use self::time::Time;
pub use self::transform::{Rotate, Scale, Transform};
pub use self::transform::{TransformOrigin, TransformStyle, Translate};

View file

@ -517,6 +517,35 @@ impl ToCss for TextTransformOther {
}
}
/// Specified and computed value of text-align-last.
#[derive(
Clone,
Copy,
Debug,
Eq,
FromPrimitive,
Hash,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[allow(missing_docs)]
#[repr(u8)]
pub enum TextAlignLast {
Auto,
Start,
End,
Left,
Right,
Center,
Justify,
}
/// Specified value of text-align keyword value.
#[derive(
Clone,
@ -535,14 +564,18 @@ impl ToCss for TextTransformOther {
ToShmem,
)]
#[allow(missing_docs)]
#[repr(u8)]
pub enum TextAlignKeyword {
Start,
End,
Left,
Right,
Center,
#[cfg(any(feature = "gecko", feature = "servo-layout-2013"))]
Justify,
#[css(skip)]
#[cfg(feature = "gecko")]
Char,
End,
#[cfg(feature = "gecko")]
MozCenter,
#[cfg(feature = "gecko")]
@ -555,9 +588,6 @@ pub enum TextAlignKeyword {
ServoLeft,
#[cfg(feature = "servo-layout-2013")]
ServoRight,
#[css(skip)]
#[cfg(feature = "gecko")]
Char,
}
/// Specified value of text-align property.
@ -579,14 +609,6 @@ pub enum TextAlign {
MozCenterOrInherit,
}
impl TextAlign {
/// Convert an enumerated value coming from Gecko to a `TextAlign`.
#[cfg(feature = "gecko")]
pub fn from_gecko_keyword(kw: u32) -> Self {
TextAlign::Keyword(TextAlignKeyword::from_gecko_keyword(kw))
}
}
impl ToComputedValue for TextAlign {
type ComputedValue = TextAlignKeyword;