style: Use rust types for vertical-align.

The previous commit removed the dependence on the discriminant value, so we
don't need to keep discriminants different from text-align anymore.

Differential Revision: https://phabricator.services.mozilla.com/D29361
This commit is contained in:
Emilio Cobos Álvarez 2019-05-01 13:08:34 +00:00
parent 8123007717
commit c990c9623d
5 changed files with 43 additions and 102 deletions

View file

@ -6,6 +6,37 @@
use crate::values::animated::ToAnimatedZero;
#[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
FromPrimitive,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(u8)]
#[allow(missing_docs)]
pub enum VerticalAlignKeyword {
Baseline,
Sub,
Super,
Top,
TextTop,
Middle,
Bottom,
TextBottom,
#[cfg(feature = "gecko")]
MozMiddleWithBaseline,
}
/// A generic value for the `vertical-align` property.
#[derive(
Animate,
@ -21,35 +52,21 @@ use crate::values::animated::ToAnimatedZero;
ToResolvedValue,
ToShmem,
)]
pub enum VerticalAlign<LengthPercentage> {
/// `baseline`
Baseline,
/// `sub`
Sub,
/// `super`
Super,
/// `top`
Top,
/// `text-top`
TextTop,
/// `middle`
Middle,
/// `bottom`
Bottom,
/// `text-bottom`
TextBottom,
/// `-moz-middle-with-baseline`
#[cfg(feature = "gecko")]
MozMiddleWithBaseline,
#[repr(C, u8)]
pub enum GenericVerticalAlign<LengthPercentage> {
/// One of the vertical-align keywords.
Keyword(VerticalAlignKeyword),
/// `<length-percentage>`
Length(LengthPercentage),
}
pub use self::GenericVerticalAlign as VerticalAlign;
impl<L> VerticalAlign<L> {
/// Returns `baseline`.
#[inline]
pub fn baseline() -> Self {
VerticalAlign::Baseline
VerticalAlign::Keyword(VerticalAlignKeyword::Baseline)
}
}