/* 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; impl Parse for VerticalAlign { fn parse<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { 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) }, } } }