mirror of
https://github.com/servo/servo.git
synced 2025-10-12 14:30:25 +01:00
41 lines
1.6 KiB
Rust
41 lines
1.6 KiB
Rust
/* 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)
|
|
},
|
|
}
|
|
}
|
|
}
|