mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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
|
@ -10,7 +10,7 @@ use dom::bindings::str::DOMString;
|
|||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::{LengthParsingMode, ParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext};
|
||||
use style::stylesheets::CssRuleType;
|
||||
use style::supports::{Declaration, parse_condition_or_declaration};
|
||||
|
||||
|
@ -32,7 +32,7 @@ impl CSS {
|
|||
let decl = Declaration { prop: property.into(), val: value.into() };
|
||||
let url = win.Document().url();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
decl.eval(&context)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ impl CSS {
|
|||
if let Ok(cond) = cond {
|
||||
let url = win.Document().url();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
cond.eval(&context)
|
||||
} else {
|
||||
|
|
|
@ -16,7 +16,7 @@ use dom::medialist::MediaList;
|
|||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use style::media_queries::parse_media_query_list;
|
||||
use style::parser::{LengthParsingMode, ParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext};
|
||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
||||
use style::stylearc::Arc;
|
||||
use style::stylesheets::{CssRuleType, MediaRule};
|
||||
|
@ -75,7 +75,7 @@ impl CSSMediaRule {
|
|||
let url = win.get_url();
|
||||
let quirks_mode = win.Document().quirks_mode();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
quirks_mode);
|
||||
let new_medialist = parse_media_query_list(&context, &mut input);
|
||||
let mut guard = self.cssconditionrule.shared_lock().write();
|
||||
|
|
|
@ -17,7 +17,7 @@ use dom_struct::dom_struct;
|
|||
use servo_url::ServoUrl;
|
||||
use std::ascii::AsciiExt;
|
||||
use style::attr::AttrValue;
|
||||
use style::parser::LengthParsingMode;
|
||||
use style::parser::ParsingMode;
|
||||
use style::properties::{Importance, PropertyDeclarationBlock, PropertyId, LonghandId, ShorthandId};
|
||||
use style::properties::{parse_one_declaration, parse_style_attribute};
|
||||
use style::selector_parser::PseudoElement;
|
||||
|
@ -260,7 +260,7 @@ impl CSSStyleDeclaration {
|
|||
let result =
|
||||
parse_one_declaration(id, &value, &self.owner.base_url(),
|
||||
window.css_error_reporter(),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
quirks_mode);
|
||||
|
||||
// Step 7
|
||||
|
|
|
@ -13,7 +13,7 @@ use dom::cssrule::SpecificCSSRule;
|
|||
use dom::cssstylesheet::CSSStyleSheet;
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use style::parser::{LengthParsingMode, ParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext};
|
||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
||||
use style::stylearc::Arc;
|
||||
use style::stylesheets::{CssRuleType, SupportsRule};
|
||||
|
@ -63,7 +63,7 @@ impl CSSSupportsRule {
|
|||
let url = win.Document().url();
|
||||
let quirks_mode = win.Document().quirks_mode();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
quirks_mode);
|
||||
let enabled = cond.eval(&context);
|
||||
let mut guard = self.cssconditionrule.shared_lock().write();
|
||||
|
|
|
@ -32,7 +32,7 @@ use std::cell::Cell;
|
|||
use std::default::Default;
|
||||
use style::attr::AttrValue;
|
||||
use style::media_queries::parse_media_query_list;
|
||||
use style::parser::{LengthParsingMode, ParserContext as CssParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext as CssParserContext};
|
||||
use style::str::HTML_SPACE_CHARACTERS;
|
||||
use style::stylearc::Arc;
|
||||
use style::stylesheets::{CssRuleType, Stylesheet};
|
||||
|
@ -282,7 +282,7 @@ impl HTMLLinkElement {
|
|||
let win = document.window();
|
||||
let doc_url = document.url();
|
||||
let context = CssParserContext::new_for_cssom(&doc_url, win.css_error_reporter(), Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
document.quirks_mode());
|
||||
let media = parse_media_query_list(&context, &mut css_parser);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ use net_traits::ReferrerPolicy;
|
|||
use script_layout_interface::message::Msg;
|
||||
use std::cell::Cell;
|
||||
use style::media_queries::parse_media_query_list;
|
||||
use style::parser::{LengthParsingMode, ParserContext as CssParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext as CssParserContext};
|
||||
use style::stylearc::Arc;
|
||||
use style::stylesheets::{CssRuleType, Stylesheet, Origin};
|
||||
use stylesheet_loader::{StylesheetLoader, StylesheetOwner};
|
||||
|
@ -88,7 +88,7 @@ impl HTMLStyleElement {
|
|||
let context = CssParserContext::new_for_cssom(&url,
|
||||
win.css_error_reporter(),
|
||||
Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
doc.quirks_mode());
|
||||
let shared_lock = node.owner_doc().style_shared_lock().clone();
|
||||
let mq = Arc::new(shared_lock.wrap(
|
||||
|
|
|
@ -14,7 +14,7 @@ use dom::window::Window;
|
|||
use dom_struct::dom_struct;
|
||||
use style::media_queries::{MediaQuery, parse_media_query_list};
|
||||
use style::media_queries::MediaList as StyleMediaList;
|
||||
use style::parser::{LengthParsingMode, ParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext};
|
||||
use style::shared_lock::{SharedRwLock, Locked};
|
||||
use style::stylearc::Arc;
|
||||
use style::stylesheets::CssRuleType;
|
||||
|
@ -77,7 +77,7 @@ impl MediaListMethods for MediaList {
|
|||
let url = win.get_url();
|
||||
let quirks_mode = win.Document().quirks_mode();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
quirks_mode);
|
||||
*media_queries = parse_media_query_list(&context, &mut parser);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ impl MediaListMethods for MediaList {
|
|||
let url = win.get_url();
|
||||
let quirks_mode = win.Document().quirks_mode();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
quirks_mode);
|
||||
let m = MediaQuery::parse(&context, &mut parser);
|
||||
// Step 2
|
||||
|
@ -141,7 +141,7 @@ impl MediaListMethods for MediaList {
|
|||
let url = win.get_url();
|
||||
let quirks_mode = win.Document().quirks_mode();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
quirks_mode);
|
||||
let m = MediaQuery::parse(&context, &mut parser);
|
||||
// Step 2
|
||||
|
|
|
@ -104,7 +104,7 @@ use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
|
|||
use style::context::ReflowGoal;
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::media_queries;
|
||||
use style::parser::{LengthParsingMode, ParserContext as CssParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext as CssParserContext};
|
||||
use style::properties::PropertyId;
|
||||
use style::properties::longhands::overflow_x;
|
||||
use style::selector_parser::PseudoElement;
|
||||
|
@ -978,7 +978,7 @@ impl WindowMethods for Window {
|
|||
let url = self.get_url();
|
||||
let quirks_mode = self.Document().quirks_mode();
|
||||
let context = CssParserContext::new_for_cssom(&url, self.css_error_reporter(), Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
quirks_mode);
|
||||
let media_query_list = media_queries::parse_media_query_list(&context, &mut parser);
|
||||
let document = self.Document();
|
||||
|
|
|
@ -488,7 +488,7 @@ mod bindings {
|
|||
"mozilla::DefaultDelete",
|
||||
"mozilla::Side",
|
||||
"mozilla::binding_danger::AssertAndSuppressCleanupPolicy",
|
||||
"mozilla::LengthParsingMode",
|
||||
"mozilla::ParsingMode",
|
||||
"mozilla::InheritTarget",
|
||||
];
|
||||
let opaque_types = [
|
||||
|
@ -751,7 +751,7 @@ mod bindings {
|
|||
"ServoStyleSheet",
|
||||
"EffectCompositor_CascadeLevel",
|
||||
"UpdateAnimationsTasks",
|
||||
"LengthParsingMode",
|
||||
"ParsingMode",
|
||||
"InheritTarget",
|
||||
"URLMatchingFunction",
|
||||
];
|
||||
|
|
|
@ -192,7 +192,7 @@ use gecko_bindings::structs::Loader;
|
|||
use gecko_bindings::structs::ServoStyleSheet;
|
||||
use gecko_bindings::structs::EffectCompositor_CascadeLevel;
|
||||
use gecko_bindings::structs::UpdateAnimationsTasks;
|
||||
use gecko_bindings::structs::LengthParsingMode;
|
||||
use gecko_bindings::structs::ParsingMode;
|
||||
use gecko_bindings::structs::InheritTarget;
|
||||
use gecko_bindings::structs::URLMatchingFunction;
|
||||
pub type nsTArrayBorrowed_uintptr_t<'a> = &'a mut ::gecko_bindings::structs::nsTArray<usize>;
|
||||
|
@ -2034,8 +2034,8 @@ extern "C" {
|
|||
value: *const nsACString,
|
||||
is_important: bool,
|
||||
data: *mut RawGeckoURLExtraData,
|
||||
length_parsing_mode:
|
||||
LengthParsingMode) -> bool;
|
||||
parsing_mode:
|
||||
ParsingMode) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DeclarationBlock_SetPropertyById(declarations:
|
||||
|
@ -2045,8 +2045,8 @@ extern "C" {
|
|||
is_important: bool,
|
||||
data:
|
||||
*mut RawGeckoURLExtraData,
|
||||
length_parsing_mode:
|
||||
LengthParsingMode)
|
||||
parsing_mode:
|
||||
ParsingMode)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
|
|
|
@ -6355,7 +6355,7 @@ pub mod root {
|
|||
pub type UpdateAnimationsTasks = u8;
|
||||
#[repr(i32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum LengthParsingMode { Default = 0, SVG = 1, }
|
||||
pub enum ParsingMode { Default = 0, SVG = 1, }
|
||||
#[repr(i32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum InheritTarget {
|
||||
|
|
|
@ -6218,7 +6218,7 @@ pub mod root {
|
|||
pub type UpdateAnimationsTasks = u8;
|
||||
#[repr(i32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum LengthParsingMode { Default = 0, SVG = 1, }
|
||||
pub enum ParsingMode { Default = 0, SVG = 1, }
|
||||
#[repr(i32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum InheritTarget {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, RuleListParser};
|
||||
use cssparser::{DeclarationListParser, DeclarationParser, parse_one_rule};
|
||||
use error_reporting::NullReporter;
|
||||
use parser::{LengthParsingMode, ParserContext, log_css_error};
|
||||
use parser::{ParsingMode, ParserContext, log_css_error};
|
||||
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, PropertyId};
|
||||
use properties::{PropertyDeclarationId, LonghandId, ParsedDeclaration};
|
||||
use properties::LonghandIdSet;
|
||||
|
@ -131,7 +131,7 @@ impl Keyframe {
|
|||
&parent_stylesheet.url_data,
|
||||
&error_reporter,
|
||||
Some(CssRuleType::Keyframe),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
parent_stylesheet.quirks_mode);
|
||||
let mut input = Parser::new(css);
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use context::QuirksMode;
|
|||
use cssparser::{DeclarationListParser, parse_important};
|
||||
use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter};
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use parser::{LengthParsingMode, ParserContext, log_css_error};
|
||||
use parser::{ParsingMode, ParserContext, log_css_error};
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||
|
@ -649,7 +649,7 @@ pub fn parse_style_attribute(input: &str,
|
|||
url_data,
|
||||
error_reporter,
|
||||
Some(CssRuleType::Style),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
quirks_mode);
|
||||
parse_property_declaration_list(&context, &mut Parser::new(input))
|
||||
}
|
||||
|
@ -663,14 +663,14 @@ pub fn parse_one_declaration(id: PropertyId,
|
|||
input: &str,
|
||||
url_data: &UrlExtraData,
|
||||
error_reporter: &ParseErrorReporter,
|
||||
length_parsing_mode: LengthParsingMode,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: QuirksMode)
|
||||
-> Result<ParsedDeclaration, ()> {
|
||||
let context = ParserContext::new(Origin::Author,
|
||||
url_data,
|
||||
error_reporter,
|
||||
Some(CssRuleType::Style),
|
||||
length_parsing_mode,
|
||||
parsing_mode,
|
||||
quirks_mode);
|
||||
Parser::new(input).parse_entirely(|parser| {
|
||||
ParsedDeclaration::parse(id, &context, parser)
|
||||
|
|
|
@ -29,7 +29,7 @@ use font_metrics::FontMetricsProvider;
|
|||
#[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
|
||||
use logical_geometry::WritingMode;
|
||||
use media_queries::Device;
|
||||
use parser::{LengthParsingMode, Parse, ParserContext};
|
||||
use parser::{ParsingMode, Parse, ParserContext};
|
||||
use properties::animated_properties::TransitionProperty;
|
||||
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
|
||||
use shared_lock::StylesheetGuards;
|
||||
|
@ -387,7 +387,7 @@ impl PropertyDeclarationIdSet {
|
|||
url_data,
|
||||
error_reporter,
|
||||
None,
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
quirks_mode);
|
||||
Parser::new(&css).parse_entirely(|input| {
|
||||
match from_shorthand {
|
||||
|
|
|
@ -26,7 +26,7 @@ use gecko_bindings::sugar::refptr::RefPtr;
|
|||
use keyframes::{Keyframe, parse_keyframe_list};
|
||||
use media_queries::{Device, MediaList, parse_media_query_list};
|
||||
use parking_lot::RwLock;
|
||||
use parser::{LengthParsingMode, Parse, ParserContext, log_css_error};
|
||||
use parser::{ParsingMode, Parse, ParserContext, log_css_error};
|
||||
use properties::{PropertyDeclarationBlock, parse_property_declaration_list};
|
||||
use selector_parser::{SelectorImpl, SelectorParser};
|
||||
use selectors::parser::SelectorList;
|
||||
|
@ -442,7 +442,7 @@ impl CssRule {
|
|||
&parent_stylesheet.url_data,
|
||||
&error_reporter,
|
||||
None,
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
parent_stylesheet.quirks_mode);
|
||||
let mut input = Parser::new(css);
|
||||
|
||||
|
@ -744,7 +744,7 @@ impl Stylesheet {
|
|||
shared_lock: shared_lock,
|
||||
loader: stylesheet_loader,
|
||||
context: ParserContext::new_with_line_number_offset(origin, url_data, error_reporter,
|
||||
line_number_offset, LengthParsingMode::Default,
|
||||
line_number_offset, ParsingMode::Default,
|
||||
quirks_mode),
|
||||
state: Cell::new(State::Start),
|
||||
};
|
||||
|
|
|
@ -630,7 +630,7 @@ impl Length {
|
|||
Token::Dimension(ref value, ref unit) if num_context.is_ok(value.value) =>
|
||||
Length::parse_dimension(context, value.value, unit),
|
||||
Token::Number(ref value) if num_context.is_ok(value.value) => {
|
||||
if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() &&
|
||||
if value.value != 0. && !context.parsing_mode.allows_unitless_lengths() &&
|
||||
!allow_quirks.allowed(context.quirks_mode) {
|
||||
return Err(())
|
||||
}
|
||||
|
@ -972,7 +972,7 @@ impl LengthOrPercentageOrAuto {
|
|||
Token::Percentage(ref value) if num_context.is_ok(value.unit_value) =>
|
||||
Ok(LengthOrPercentageOrAuto::Percentage(Percentage(value.unit_value))),
|
||||
Token::Number(ref value) if num_context.is_ok(value.value) => {
|
||||
if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() &&
|
||||
if value.value != 0. && !context.parsing_mode.allows_unitless_lengths() &&
|
||||
!allow_quirks.allowed(context.quirks_mode) {
|
||||
return Err(())
|
||||
}
|
||||
|
@ -1080,7 +1080,7 @@ impl LengthOrPercentageOrNone {
|
|||
Token::Percentage(ref value) if num_context.is_ok(value.unit_value) =>
|
||||
Ok(LengthOrPercentageOrNone::Percentage(Percentage(value.unit_value))),
|
||||
Token::Number(value) if num_context.is_ok(value.value) => {
|
||||
if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() &&
|
||||
if value.value != 0. && !context.parsing_mode.allows_unitless_lengths() &&
|
||||
!allow_quirks.allowed(context.quirks_mode) {
|
||||
return Err(())
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ use style::gecko_properties::{self, style_structs};
|
|||
use style::keyframes::KeyframesStepValue;
|
||||
use style::media_queries::{MediaList, parse_media_query_list};
|
||||
use style::parallel;
|
||||
use style::parser::{LengthParsingMode, ParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext};
|
||||
use style::properties::{CascadeFlags, ComputedValues, Importance, ParsedDeclaration, StyleBuilder};
|
||||
use style::properties::{LonghandIdSet, PropertyDeclarationBlock, PropertyId};
|
||||
use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
||||
|
@ -1133,30 +1133,30 @@ pub extern "C" fn Servo_StyleSet_Drop(data: RawServoStyleSetOwned) {
|
|||
fn parse_property(property_id: PropertyId,
|
||||
value: *const nsACString,
|
||||
data: *mut URLExtraData,
|
||||
length_parsing_mode: structs::LengthParsingMode) -> Result<ParsedDeclaration, ()> {
|
||||
parsing_mode: structs::ParsingMode) -> Result<ParsedDeclaration, ()> {
|
||||
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
|
||||
let url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
||||
let length_parsing_mode = match length_parsing_mode {
|
||||
structs::LengthParsingMode::Default => LengthParsingMode::Default,
|
||||
structs::LengthParsingMode::SVG => LengthParsingMode::SVG,
|
||||
let parsing_mode = match parsing_mode {
|
||||
structs::ParsingMode::Default => ParsingMode::Default,
|
||||
structs::ParsingMode::AllowUnitlessLength => ParsingMode::AllowUnitlessLength,
|
||||
};
|
||||
|
||||
parse_one_declaration(property_id,
|
||||
value,
|
||||
url_data,
|
||||
&RustLogReporter,
|
||||
length_parsing_mode,
|
||||
parsing_mode,
|
||||
QuirksMode::NoQuirks)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ParseProperty(property: nsCSSPropertyID, value: *const nsACString,
|
||||
data: *mut URLExtraData,
|
||||
length_parsing_mode: structs::LengthParsingMode)
|
||||
parsing_mode: structs::ParsingMode)
|
||||
-> RawServoDeclarationBlockStrong {
|
||||
let id = get_property_id_from_nscsspropertyid!(property,
|
||||
RawServoDeclarationBlockStrong::null());
|
||||
match parse_property(id, value, data, length_parsing_mode) {
|
||||
match parse_property(id, value, data, parsing_mode) {
|
||||
Ok(parsed) => {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let mut block = PropertyDeclarationBlock::new();
|
||||
|
@ -1180,7 +1180,7 @@ pub extern "C" fn Servo_ParseEasing(easing: *const nsAString,
|
|||
url_data,
|
||||
&reporter,
|
||||
Some(CssRuleType::Style),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
let easing = unsafe { (*easing).to_string() };
|
||||
match transition_timing_function::single_value::parse(&context, &mut Parser::new(&easing)) {
|
||||
|
@ -1314,8 +1314,8 @@ pub extern "C" fn Servo_DeclarationBlock_GetPropertyIsImportant(declarations: Ra
|
|||
|
||||
fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId,
|
||||
value: *const nsACString, is_important: bool, data: *mut URLExtraData,
|
||||
length_parsing_mode: structs::LengthParsingMode) -> bool {
|
||||
match parse_property(property_id, value, data, length_parsing_mode) {
|
||||
parsing_mode: structs::ParsingMode) -> bool {
|
||||
match parse_property(property_id, value, data, parsing_mode) {
|
||||
Ok(parsed) => {
|
||||
let importance = if is_important { Importance::Important } else { Importance::Normal };
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
|
@ -1330,18 +1330,18 @@ fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: Pro
|
|||
pub extern "C" fn Servo_DeclarationBlock_SetProperty(declarations: RawServoDeclarationBlockBorrowed,
|
||||
property: *const nsACString, value: *const nsACString,
|
||||
is_important: bool, data: *mut URLExtraData,
|
||||
length_parsing_mode: structs::LengthParsingMode) -> bool {
|
||||
parsing_mode: structs::ParsingMode) -> bool {
|
||||
set_property(declarations, get_property_id_from_property!(property, false),
|
||||
value, is_important, data, length_parsing_mode)
|
||||
value, is_important, data, parsing_mode)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DeclarationBlock_SetPropertyById(declarations: RawServoDeclarationBlockBorrowed,
|
||||
property: nsCSSPropertyID, value: *const nsACString,
|
||||
is_important: bool, data: *mut URLExtraData,
|
||||
length_parsing_mode: structs::LengthParsingMode) -> bool {
|
||||
parsing_mode: structs::ParsingMode) -> bool {
|
||||
set_property(declarations, get_property_id_from_nscsspropertyid!(property, false),
|
||||
value, is_important, data, length_parsing_mode)
|
||||
value, is_important, data, parsing_mode)
|
||||
}
|
||||
|
||||
fn remove_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId) {
|
||||
|
@ -1410,7 +1410,7 @@ pub extern "C" fn Servo_MediaList_SetText(list: RawServoMediaListBorrowed, text:
|
|||
let url_data = unsafe { dummy_url_data() };
|
||||
let reporter = RustLogReporter;
|
||||
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
write_locked_arc(list, |list: &mut MediaList| {
|
||||
*list = parse_media_query_list(&context, &mut parser);
|
||||
|
@ -1442,7 +1442,7 @@ pub extern "C" fn Servo_MediaList_AppendMedium(list: RawServoMediaListBorrowed,
|
|||
let url_data = unsafe { dummy_url_data() };
|
||||
let reporter = RustLogReporter;
|
||||
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
write_locked_arc(list, |list: &mut MediaList| {
|
||||
list.append_medium(&context, new_medium);
|
||||
|
@ -1456,7 +1456,7 @@ pub extern "C" fn Servo_MediaList_DeleteMedium(list: RawServoMediaListBorrowed,
|
|||
let url_data = unsafe { dummy_url_data() };
|
||||
let reporter = RustLogReporter;
|
||||
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
write_locked_arc(list, |list: &mut MediaList| list.delete_medium(&context, old_medium))
|
||||
}
|
||||
|
@ -1810,7 +1810,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetBackgroundImage(declarations:
|
|||
let string = unsafe { (*value).to_string() };
|
||||
let error_reporter = RustLogReporter;
|
||||
let context = ParserContext::new(Origin::Author, url_data, &error_reporter,
|
||||
Some(CssRuleType::Style), LengthParsingMode::Default,
|
||||
Some(CssRuleType::Style), ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
if let Ok(url) = SpecifiedUrl::parse_from_string(string.into(), &context) {
|
||||
let decl = PropertyDeclaration::BackgroundImage(BackgroundImage(
|
||||
|
@ -1842,7 +1842,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(declarat
|
|||
pub extern "C" fn Servo_CSSSupports2(property: *const nsACString, value: *const nsACString) -> bool {
|
||||
let id = get_property_id_from_property!(property, false);
|
||||
|
||||
parse_property(id, value, unsafe { DUMMY_URL_DATA }, structs::LengthParsingMode::Default).is_ok()
|
||||
parse_property(id, value, unsafe { DUMMY_URL_DATA }, structs::ParsingMode::Default).is_ok()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -1854,7 +1854,7 @@ pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool {
|
|||
let url_data = unsafe { dummy_url_data() };
|
||||
let reporter = RustLogReporter;
|
||||
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Style),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
cond.eval(&context)
|
||||
} else {
|
||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::Parser;
|
|||
use media_queries::CSSErrorReporterTest;
|
||||
use parsing::parse;
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::{LengthParsingMode, Parse, ParserContext};
|
||||
use style::parser::{ParsingMode, Parse, ParserContext};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
use style::values::Either;
|
||||
use style::values::specified::{LengthOrPercentageOrNumber, Number};
|
||||
|
@ -35,7 +35,7 @@ fn test_length_literals() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_length_parsing_modes() {
|
||||
fn test_parsing_modes() {
|
||||
// In default length mode, non-zero lengths must have a unit.
|
||||
assert!(parse(Length::parse, "1").is_err());
|
||||
|
||||
|
@ -43,7 +43,7 @@ fn test_length_parsing_modes() {
|
|||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter,
|
||||
Some(CssRuleType::Style), LengthParsingMode::SVG,
|
||||
Some(CssRuleType::Style), ParsingMode::AllowUnitlessLength,
|
||||
QuirksMode::NoQuirks);
|
||||
let mut parser = Parser::new("1");
|
||||
let result = Length::parse(&context, &mut parser);
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
use cssparser::Parser;
|
||||
use media_queries::CSSErrorReporterTest;
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::{LengthParsingMode, ParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
|
||||
fn parse<T, F: Fn(&ParserContext, &mut Parser) -> Result<T, ()>>(f: F, s: &str) -> Result<T, ()> {
|
||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
let mut parser = Parser::new(s);
|
||||
f(&context, &mut parser)
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
use cssparser::Parser;
|
||||
use media_queries::CSSErrorReporterTest;
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::{LengthParsingMode, ParserContext};
|
||||
use style::parser::{ParsingMode, ParserContext};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
|
||||
fn parse<T, F: Fn(&ParserContext, &mut Parser) -> Result<T, ()>>(f: F, s: &str) -> Result<T, ()> {
|
||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
let mut parser = Parser::new(s);
|
||||
f(&context, &mut parser)
|
||||
|
|
|
@ -9,7 +9,7 @@ use servo_config::prefs::{PREFS, PrefValue};
|
|||
use servo_url::ServoUrl;
|
||||
use style::context::QuirksMode;
|
||||
use style::media_queries::{Device, MediaList, MediaType};
|
||||
use style::parser::{LengthParsingMode, Parse, ParserContext};
|
||||
use style::parser::{ParsingMode, Parse, ParserContext};
|
||||
use style::shared_lock::SharedRwLock;
|
||||
use style::stylearc::Arc;
|
||||
use style::stylesheets::{CssRuleType, Stylesheet, Origin};
|
||||
|
@ -295,7 +295,7 @@ fn constrain_viewport() {
|
|||
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Viewport),
|
||||
LengthParsingMode::Default,
|
||||
ParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
|
||||
macro_rules! from_css {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue