mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Document style_traits and deny missing docs on it.
This commit is contained in:
parent
40a6a1f971
commit
82b6825a86
4 changed files with 37 additions and 7 deletions
|
@ -2,6 +2,8 @@
|
|||
* 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/. */
|
||||
|
||||
//! Helper types and traits for the handling of CSS values.
|
||||
|
||||
use app_units::Au;
|
||||
use std::fmt;
|
||||
|
||||
|
@ -78,13 +80,14 @@ macro_rules! __define_css_keyword_enum__add_optional_traits {
|
|||
#[macro_export]
|
||||
macro_rules! __define_css_keyword_enum__actual {
|
||||
($name: ident [ $( $derived_trait: ident),* ] [ $( $css: expr => $variant: ident ),+ ]) => {
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_camel_case_types, missing_docs)]
|
||||
#[derive(Clone, Eq, PartialEq, Copy, Hash, RustcEncodable, Debug $(, $derived_trait )* )]
|
||||
pub enum $name {
|
||||
$( $variant ),+
|
||||
}
|
||||
|
||||
impl $name {
|
||||
/// Parse this property from a CSS input stream.
|
||||
pub fn parse(input: &mut ::cssparser::Parser) -> Result<$name, ()> {
|
||||
match_ignore_ascii_case! { try!(input.expect_ident()),
|
||||
$( $css => Ok($name::$variant), )+
|
||||
|
@ -105,18 +108,23 @@ macro_rules! __define_css_keyword_enum__actual {
|
|||
}
|
||||
}
|
||||
|
||||
/// Helper types for the handling of specified values.
|
||||
pub mod specified {
|
||||
use app_units::Au;
|
||||
|
||||
/// Whether to allow negative values or not.
|
||||
#[repr(u8)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum AllowedNumericType {
|
||||
/// Allow all kind of numeric values.
|
||||
All,
|
||||
/// Allow only non-negative values.
|
||||
NonNegative
|
||||
}
|
||||
|
||||
impl AllowedNumericType {
|
||||
/// Whether value is valid for this allowed numeric type.
|
||||
#[inline]
|
||||
pub fn is_ok(&self, value: f32) -> bool {
|
||||
match *self {
|
||||
|
@ -125,6 +133,7 @@ pub mod specified {
|
|||
}
|
||||
}
|
||||
|
||||
/// Clamp the value following the rules of this numeric type.
|
||||
#[inline]
|
||||
pub fn clamp(&self, val: Au) -> Au {
|
||||
use std::cmp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue