mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Move ParsingMode into style_traits.
This commit is contained in:
parent
849bdc958c
commit
8bfed4cb3c
23 changed files with 73 additions and 62 deletions
|
@ -14,6 +14,7 @@
|
|||
#![cfg_attr(feature = "servo", feature(plugin))]
|
||||
|
||||
extern crate app_units;
|
||||
#[macro_use] extern crate bitflags;
|
||||
#[macro_use] extern crate cssparser;
|
||||
extern crate euclid;
|
||||
#[cfg(feature = "servo")] extern crate heapsize;
|
||||
|
@ -140,3 +141,32 @@ impl<'a> From<PropertyDeclarationParseError> for ParseError<'a> {
|
|||
cssparser::ParseError::Custom(SelectorParseError::Custom(StyleParseError::PropertyDeclaration(this)))
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
/// The mode to use when parsing values.
|
||||
pub flags ParsingMode: u8 {
|
||||
/// In CSS, lengths must have units, except for zero values, where the unit can be omitted.
|
||||
/// https://www.w3.org/TR/css3-values/#lengths
|
||||
const PARSING_MODE_DEFAULT = 0x00,
|
||||
/// In SVG, a coordinate or length value without a unit identifier (e.g., "25") is assumed
|
||||
/// to be in user units (px).
|
||||
/// https://www.w3.org/TR/SVG/coords.html#Units
|
||||
const PARSING_MODE_ALLOW_UNITLESS_LENGTH = 0x01,
|
||||
/// In SVG, out-of-range values are not treated as an error in parsing.
|
||||
/// https://www.w3.org/TR/SVG/implnote.html#RangeClamping
|
||||
const PARSING_MODE_ALLOW_ALL_NUMERIC_VALUES = 0x02,
|
||||
}
|
||||
}
|
||||
|
||||
impl ParsingMode {
|
||||
/// Whether the parsing mode allows unitless lengths for non-zero values to be intpreted as px.
|
||||
pub fn allows_unitless_lengths(&self) -> bool {
|
||||
self.intersects(PARSING_MODE_ALLOW_UNITLESS_LENGTH)
|
||||
}
|
||||
|
||||
/// Whether the parsing mode allows all numeric values.
|
||||
pub fn allows_all_numeric_values(&self) -> bool {
|
||||
self.intersects(PARSING_MODE_ALLOW_ALL_NUMERIC_VALUES)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue