mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Rename LengthParsingMode to ParsingMode and LengthParsingMode::SVG to PasingMode::AllowUnitlessLength.
We need another flag that represents allow-negative-number for SMIL, so this enum will also comprise the another parsing mode that allows negative number.
This commit is contained in:
parent
b80d4acef4
commit
fcc50ea421
23 changed files with 85 additions and 85 deletions
|
@ -12,19 +12,19 @@ use stylesheets::{CssRuleType, Origin, UrlExtraData};
|
|||
|
||||
/// The mode to use when parsing lengths.
|
||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
||||
pub enum LengthParsingMode {
|
||||
pub enum ParsingMode {
|
||||
/// In CSS, lengths must have units, except for zero values, where the unit can be omitted.
|
||||
/// https://www.w3.org/TR/css3-values/#lengths
|
||||
Default,
|
||||
/// 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
|
||||
SVG,
|
||||
AllowUnitlessLength,
|
||||
}
|
||||
|
||||
impl LengthParsingMode {
|
||||
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 == LengthParsingMode::SVG
|
||||
*self == ParsingMode::AllowUnitlessLength
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,8 @@ pub struct ParserContext<'a> {
|
|||
pub rule_type: Option<CssRuleType>,
|
||||
/// Line number offsets for inline stylesheets
|
||||
pub line_number_offset: u64,
|
||||
/// The mode to use when parsing lengths.
|
||||
pub length_parsing_mode: LengthParsingMode,
|
||||
/// The mode to use when parsing.
|
||||
pub parsing_mode: ParsingMode,
|
||||
/// The quirks mode of this stylesheet.
|
||||
pub quirks_mode: QuirksMode,
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl<'a> ParserContext<'a> {
|
|||
url_data: &'a UrlExtraData,
|
||||
error_reporter: &'a ParseErrorReporter,
|
||||
rule_type: Option<CssRuleType>,
|
||||
length_parsing_mode: LengthParsingMode,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: QuirksMode)
|
||||
-> ParserContext<'a> {
|
||||
ParserContext {
|
||||
|
@ -62,7 +62,7 @@ impl<'a> ParserContext<'a> {
|
|||
error_reporter: error_reporter,
|
||||
rule_type: rule_type,
|
||||
line_number_offset: 0u64,
|
||||
length_parsing_mode: length_parsing_mode,
|
||||
parsing_mode: parsing_mode,
|
||||
quirks_mode: quirks_mode,
|
||||
}
|
||||
}
|
||||
|
@ -71,10 +71,10 @@ impl<'a> ParserContext<'a> {
|
|||
pub fn new_for_cssom(url_data: &'a UrlExtraData,
|
||||
error_reporter: &'a ParseErrorReporter,
|
||||
rule_type: Option<CssRuleType>,
|
||||
length_parsing_mode: LengthParsingMode,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: QuirksMode)
|
||||
-> ParserContext<'a> {
|
||||
Self::new(Origin::Author, url_data, error_reporter, rule_type, length_parsing_mode, quirks_mode)
|
||||
Self::new(Origin::Author, url_data, error_reporter, rule_type, parsing_mode, quirks_mode)
|
||||
}
|
||||
|
||||
/// Create a parser context based on a previous context, but with a modified rule type.
|
||||
|
@ -87,7 +87,7 @@ impl<'a> ParserContext<'a> {
|
|||
error_reporter: context.error_reporter,
|
||||
rule_type: rule_type,
|
||||
line_number_offset: context.line_number_offset,
|
||||
length_parsing_mode: context.length_parsing_mode,
|
||||
parsing_mode: context.parsing_mode,
|
||||
quirks_mode: context.quirks_mode,
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ impl<'a> ParserContext<'a> {
|
|||
url_data: &'a UrlExtraData,
|
||||
error_reporter: &'a ParseErrorReporter,
|
||||
line_number_offset: u64,
|
||||
length_parsing_mode: LengthParsingMode,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: QuirksMode)
|
||||
-> ParserContext<'a> {
|
||||
ParserContext {
|
||||
|
@ -106,7 +106,7 @@ impl<'a> ParserContext<'a> {
|
|||
error_reporter: error_reporter,
|
||||
rule_type: None,
|
||||
line_number_offset: line_number_offset,
|
||||
length_parsing_mode: length_parsing_mode,
|
||||
parsing_mode: parsing_mode,
|
||||
quirks_mode: quirks_mode,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue