mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Use generics for the vertical-align property
This commit is contained in:
parent
19cbea23a8
commit
542a9337a4
13 changed files with 202 additions and 178 deletions
49
components/style/values/generics/box.rs
Normal file
49
components/style/values/generics/box.rs
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Generic types for box properties.
|
||||
|
||||
use values::animated::ToAnimatedZero;
|
||||
|
||||
/// A generic value for the `vertical-align` property.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
pub enum VerticalAlign<LengthOrPercentage> {
|
||||
/// `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,
|
||||
/// `<length-percentage>`
|
||||
Length(LengthOrPercentage),
|
||||
}
|
||||
|
||||
impl<L> VerticalAlign<L> {
|
||||
/// Returns `baseline`.
|
||||
#[inline]
|
||||
pub fn baseline() -> Self {
|
||||
VerticalAlign::Baseline
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> ToAnimatedZero for VerticalAlign<L> {
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||
Err(())
|
||||
}
|
||||
}
|
|
@ -15,6 +15,8 @@ use super::CustomIdent;
|
|||
pub mod background;
|
||||
pub mod basic_shape;
|
||||
pub mod border;
|
||||
#[path = "box.rs"]
|
||||
pub mod box_;
|
||||
pub mod effects;
|
||||
pub mod flex;
|
||||
#[cfg(feature = "gecko")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue