mirror of
https://github.com/servo/servo.git
synced 2025-07-30 10:40:27 +01:00
61 lines
1.8 KiB
Rust
61 lines
1.8 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/. */
|
|
|
|
//! Common [values][values] used in CSS.
|
|
//!
|
|
//! [values]: https://drafts.csswg.org/css-values/
|
|
|
|
pub use cssparser::RGBA;
|
|
|
|
macro_rules! define_numbered_css_keyword_enum {
|
|
($name: ident: $( $css: expr => $variant: ident = $value: expr ),+,) => {
|
|
define_numbered_css_keyword_enum!($name: $( $css => $variant = $value ),+);
|
|
};
|
|
($name: ident: $( $css: expr => $variant: ident = $value: expr ),+) => {
|
|
#[allow(non_camel_case_types)]
|
|
#[derive(Clone, Eq, PartialEq, PartialOrd, Ord, Copy, RustcEncodable, Debug)]
|
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
|
pub enum $name {
|
|
$( $variant = $value ),+
|
|
}
|
|
|
|
impl $name {
|
|
pub fn parse(input: &mut ::cssparser::Parser) -> Result<$name, ()> {
|
|
match_ignore_ascii_case! { try!(input.expect_ident()),
|
|
$( $css => Ok($name::$variant), )+
|
|
_ => Err(())
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ToCss for $name {
|
|
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result
|
|
where W: ::std::fmt::Write {
|
|
match *self {
|
|
$( $name::$variant => dest.write_str($css) ),+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pub mod computed;
|
|
pub mod specified;
|
|
|
|
pub type CSSFloat = f32;
|
|
|
|
pub const FONT_MEDIUM_PX: i32 = 16;
|
|
|
|
pub trait HasViewportPercentage {
|
|
fn has_viewport_percentage(&self) -> bool;
|
|
}
|
|
|
|
pub trait NoViewportPercentage {}
|
|
|
|
impl<T> HasViewportPercentage for T where T: NoViewportPercentage {
|
|
fn has_viewport_percentage(&self) -> bool {
|
|
false
|
|
}
|
|
}
|
|
|