mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +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
41
components/style/values/specified/box.rs
Normal file
41
components/style/values/specified/box.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* 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/. */
|
||||
|
||||
//! Specified types for box properties.
|
||||
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use style_traits::ParseError;
|
||||
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
|
||||
use values::specified::AllowQuirks;
|
||||
use values::specified::length::LengthOrPercentage;
|
||||
|
||||
/// A specified value for the `vertical-align` property.
|
||||
pub type VerticalAlign = GenericVerticalAlign<LengthOrPercentage>;
|
||||
|
||||
impl Parse for VerticalAlign {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(lop) = input.try(|i| LengthOrPercentage::parse_quirky(context, i, AllowQuirks::Yes)) {
|
||||
return Ok(GenericVerticalAlign::Length(lop));
|
||||
}
|
||||
|
||||
try_match_ident_ignore_ascii_case! { input.expect_ident()?,
|
||||
"baseline" => Ok(GenericVerticalAlign::Baseline),
|
||||
"sub" => Ok(GenericVerticalAlign::Sub),
|
||||
"super" => Ok(GenericVerticalAlign::Super),
|
||||
"top" => Ok(GenericVerticalAlign::Top),
|
||||
"text-top" => Ok(GenericVerticalAlign::TextTop),
|
||||
"middle" => Ok(GenericVerticalAlign::Middle),
|
||||
"bottom" => Ok(GenericVerticalAlign::Bottom),
|
||||
"text-bottom" => Ok(GenericVerticalAlign::TextBottom),
|
||||
#[cfg(feature = "gecko")]
|
||||
"-moz-middle-with-baseline" => {
|
||||
Ok(GenericVerticalAlign::MozMiddleWithBaseline)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, Justify
|
|||
pub use self::background::BackgroundSize;
|
||||
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||
pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth};
|
||||
pub use self::box_::VerticalAlign;
|
||||
pub use self::color::{Color, RGBAColor};
|
||||
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
pub use self::flex::FlexBasis;
|
||||
|
@ -60,6 +61,8 @@ pub mod angle;
|
|||
pub mod background;
|
||||
pub mod basic_shape;
|
||||
pub mod border;
|
||||
#[path = "box.rs"]
|
||||
pub mod box_;
|
||||
pub mod calc;
|
||||
pub mod color;
|
||||
pub mod effects;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue