mirror of
https://github.com/servo/servo.git
synced 2025-08-15 02:15:33 +01:00
Auto merge of #16373 - jryans:at-page-viewport-units, r=emilio
Stylo: Disable viewport units for @page Reviewed by @emilio in [bug 1353191](https://bugzilla.mozilla.org/show_bug.cgi?id=1353191). --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16373) <!-- Reviewable:end -->
This commit is contained in:
commit
5f6c27bb94
63 changed files with 472 additions and 360 deletions
|
@ -612,8 +612,8 @@ pub fn parse_style_attribute(input: &str,
|
|||
url_data: &UrlExtraData,
|
||||
error_reporter: &ParseErrorReporter)
|
||||
-> PropertyDeclarationBlock {
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter);
|
||||
parse_property_declaration_list(&context, &mut Parser::new(input), CssRuleType::Style)
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style));
|
||||
parse_property_declaration_list(&context, &mut Parser::new(input))
|
||||
}
|
||||
|
||||
/// Parse a given property declaration. Can result in multiple
|
||||
|
@ -626,9 +626,9 @@ pub fn parse_one_declaration(id: PropertyId,
|
|||
url_data: &UrlExtraData,
|
||||
error_reporter: &ParseErrorReporter)
|
||||
-> Result<ParsedDeclaration, ()> {
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter);
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style));
|
||||
Parser::new(input).parse_entirely(|parser| {
|
||||
ParsedDeclaration::parse(id, &context, parser, false, CssRuleType::Style)
|
||||
ParsedDeclaration::parse(id, &context, parser)
|
||||
.map_err(|_| ())
|
||||
})
|
||||
}
|
||||
|
@ -636,7 +636,6 @@ pub fn parse_one_declaration(id: PropertyId,
|
|||
/// A struct to parse property declarations.
|
||||
struct PropertyDeclarationParser<'a, 'b: 'a> {
|
||||
context: &'a ParserContext<'b>,
|
||||
rule_type: CssRuleType,
|
||||
}
|
||||
|
||||
|
||||
|
@ -654,7 +653,7 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> {
|
|||
-> Result<(ParsedDeclaration, Importance), ()> {
|
||||
let id = try!(PropertyId::parse(name.into()));
|
||||
let parsed = input.parse_until_before(Delimiter::Bang, |input| {
|
||||
ParsedDeclaration::parse(id, self.context, input, false, self.rule_type)
|
||||
ParsedDeclaration::parse(id, self.context, input)
|
||||
.map_err(|_| ())
|
||||
})?;
|
||||
let importance = match input.try(parse_important) {
|
||||
|
@ -673,13 +672,11 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> {
|
|||
/// Parse a list of property declarations and return a property declaration
|
||||
/// block.
|
||||
pub fn parse_property_declaration_list(context: &ParserContext,
|
||||
input: &mut Parser,
|
||||
rule_type: CssRuleType)
|
||||
input: &mut Parser)
|
||||
-> PropertyDeclarationBlock {
|
||||
let mut block = PropertyDeclarationBlock::new();
|
||||
let parser = PropertyDeclarationParser {
|
||||
context: context,
|
||||
rule_type: rule_type,
|
||||
};
|
||||
let mut iter = DeclarationListParser::new(input, parser);
|
||||
while let Some(declaration) = iter.next() {
|
||||
|
|
|
@ -482,7 +482,7 @@ ${helpers.single_keyword("background-origin",
|
|||
})
|
||||
}
|
||||
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
if input.try(|input| input.expect_ident_matching("cover")).is_ok() {
|
||||
return Ok(SpecifiedValue::Cover);
|
||||
}
|
||||
|
@ -492,12 +492,12 @@ ${helpers.single_keyword("background-origin",
|
|||
}
|
||||
|
||||
let width =
|
||||
try!(specified::LengthOrPercentageOrAuto::parse_non_negative(input));
|
||||
try!(specified::LengthOrPercentageOrAuto::parse_non_negative(context, input));
|
||||
|
||||
let height = if input.is_exhausted() {
|
||||
specified::LengthOrPercentageOrAuto::Auto
|
||||
} else {
|
||||
try!(specified::LengthOrPercentageOrAuto::parse_non_negative(input))
|
||||
try!(specified::LengthOrPercentageOrAuto::parse_non_negative(context, input))
|
||||
};
|
||||
|
||||
Ok(SpecifiedValue::Explicit(ExplicitSize {
|
||||
|
|
|
@ -525,16 +525,16 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box",
|
|||
}
|
||||
|
||||
impl Parse for SingleSpecifiedValue {
|
||||
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
|
||||
return Ok(SingleSpecifiedValue::Auto);
|
||||
}
|
||||
|
||||
if let Ok(len) = input.try(|input| LengthOrPercentage::parse_non_negative(input)) {
|
||||
if let Ok(len) = input.try(|input| LengthOrPercentage::parse_non_negative(context, input)) {
|
||||
return Ok(SingleSpecifiedValue::LengthOrPercentage(len));
|
||||
}
|
||||
|
||||
let num = try!(Number::parse_non_negative(input));
|
||||
let num = try!(Number::parse_non_negative(context, input));
|
||||
Ok(SingleSpecifiedValue::Number(num))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -558,20 +558,20 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
}
|
||||
|
||||
impl Parse for SpecifiedValue {
|
||||
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
|
||||
fn parse(context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
|
||||
if let Ok(function_name) = input.try(|input| input.expect_function()) {
|
||||
return match_ignore_ascii_case! { &function_name,
|
||||
"cubic-bezier" => {
|
||||
let (mut p1x, mut p1y, mut p2x, mut p2y) =
|
||||
(Number::new(0.0), Number::new(0.0), Number::new(0.0), Number::new(0.0));
|
||||
try!(input.parse_nested_block(|input| {
|
||||
p1x = try!(specified::parse_number(input));
|
||||
p1x = try!(specified::parse_number(context, input));
|
||||
try!(input.expect_comma());
|
||||
p1y = try!(specified::parse_number(input));
|
||||
p1y = try!(specified::parse_number(context, input));
|
||||
try!(input.expect_comma());
|
||||
p2x = try!(specified::parse_number(input));
|
||||
p2x = try!(specified::parse_number(context, input));
|
||||
try!(input.expect_comma());
|
||||
p2y = try!(specified::parse_number(input));
|
||||
p2y = try!(specified::parse_number(context, input));
|
||||
Ok(())
|
||||
}));
|
||||
if p1x.value < 0.0 || p1x.value > 1.0 ||
|
||||
|
@ -585,7 +585,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
"steps" => {
|
||||
let (mut step_count, mut start_end) = (specified::Integer::new(0), StartEnd::End);
|
||||
try!(input.parse_nested_block(|input| {
|
||||
step_count = try!(specified::parse_integer(input));
|
||||
step_count = try!(specified::parse_integer(context, input));
|
||||
if step_count.value() < 1 {
|
||||
return Err(())
|
||||
}
|
||||
|
@ -1057,12 +1057,12 @@ ${helpers.single_keyword("animation-fill-mode",
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
Ok(SpecifiedValue::None)
|
||||
} else if input.try(|input| input.expect_function_matching("repeat")).is_ok() {
|
||||
input.parse_nested_block(|input| {
|
||||
LengthOrPercentage::parse_non_negative(input).map(SpecifiedValue::Repeat)
|
||||
LengthOrPercentage::parse_non_negative(context, input).map(SpecifiedValue::Repeat)
|
||||
})
|
||||
} else {
|
||||
Err(())
|
||||
|
@ -1349,7 +1349,7 @@ ${helpers.predefined_type("scroll-snap-coordinate",
|
|||
"matrix" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let values = try!(input.parse_comma_separated(|input| {
|
||||
specified::parse_number(input)
|
||||
specified::parse_number(context, input)
|
||||
}));
|
||||
if values.len() != 6 {
|
||||
return Err(())
|
||||
|
@ -1367,7 +1367,7 @@ ${helpers.predefined_type("scroll-snap-coordinate",
|
|||
},
|
||||
"matrix3d" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let values = try!(input.parse_comma_separated(specified::parse_number));
|
||||
let values = try!(input.parse_comma_separated(|i| specified::parse_number(context, i)));
|
||||
if values.len() != 16 {
|
||||
return Err(())
|
||||
}
|
||||
|
@ -1426,9 +1426,9 @@ ${helpers.predefined_type("scroll-snap-coordinate",
|
|||
},
|
||||
"scale" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let sx = try!(specified::parse_number(input));
|
||||
let sx = try!(specified::parse_number(context, input));
|
||||
if input.try(|input| input.expect_comma()).is_ok() {
|
||||
let sy = try!(specified::parse_number(input));
|
||||
let sy = try!(specified::parse_number(context, input));
|
||||
result.push(SpecifiedOperation::Scale(sx, Some(sy)));
|
||||
} else {
|
||||
result.push(SpecifiedOperation::Scale(sx, None));
|
||||
|
@ -1438,32 +1438,32 @@ ${helpers.predefined_type("scroll-snap-coordinate",
|
|||
},
|
||||
"scalex" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let sx = try!(specified::parse_number(input));
|
||||
let sx = try!(specified::parse_number(context, input));
|
||||
result.push(SpecifiedOperation::ScaleX(sx));
|
||||
Ok(())
|
||||
}))
|
||||
},
|
||||
"scaley" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let sy = try!(specified::parse_number(input));
|
||||
let sy = try!(specified::parse_number(context, input));
|
||||
result.push(SpecifiedOperation::ScaleY(sy));
|
||||
Ok(())
|
||||
}))
|
||||
},
|
||||
"scalez" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let sz = try!(specified::parse_number(input));
|
||||
let sz = try!(specified::parse_number(context, input));
|
||||
result.push(SpecifiedOperation::ScaleZ(sz));
|
||||
Ok(())
|
||||
}))
|
||||
},
|
||||
"scale3d" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let sx = try!(specified::parse_number(input));
|
||||
let sx = try!(specified::parse_number(context, input));
|
||||
try!(input.expect_comma());
|
||||
let sy = try!(specified::parse_number(input));
|
||||
let sy = try!(specified::parse_number(context, input));
|
||||
try!(input.expect_comma());
|
||||
let sz = try!(specified::parse_number(input));
|
||||
let sz = try!(specified::parse_number(context, input));
|
||||
result.push(SpecifiedOperation::Scale3D(sx, sy, sz));
|
||||
Ok(())
|
||||
}))
|
||||
|
@ -1498,11 +1498,11 @@ ${helpers.predefined_type("scroll-snap-coordinate",
|
|||
},
|
||||
"rotate3d" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let ax = try!(specified::parse_number(input));
|
||||
let ax = try!(specified::parse_number(context, input));
|
||||
try!(input.expect_comma());
|
||||
let ay = try!(specified::parse_number(input));
|
||||
let ay = try!(specified::parse_number(context, input));
|
||||
try!(input.expect_comma());
|
||||
let az = try!(specified::parse_number(input));
|
||||
let az = try!(specified::parse_number(context, input));
|
||||
try!(input.expect_comma());
|
||||
let theta = try!(specified::Angle::parse_with_unitless(context,input));
|
||||
// TODO(gw): Check the axis can be normalized!!
|
||||
|
@ -1538,7 +1538,7 @@ ${helpers.predefined_type("scroll-snap-coordinate",
|
|||
},
|
||||
"perspective" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let d = try!(specified::Length::parse_non_negative(input));
|
||||
let d = try!(specified::Length::parse_non_negative(context, input));
|
||||
result.push(SpecifiedOperation::Perspective(d));
|
||||
Ok(())
|
||||
}))
|
||||
|
|
|
@ -330,11 +330,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
parse_common(1, input)
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
parse_common(context, 1, input)
|
||||
}
|
||||
|
||||
pub fn parse_common(default_value: i32, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
pub fn parse_common(context: &ParserContext, default_value: i32, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(SpecifiedValue(Vec::new()))
|
||||
}
|
||||
|
@ -349,8 +349,8 @@
|
|||
if content::counter_name_is_illegal(&counter_name) {
|
||||
return Err(())
|
||||
}
|
||||
let counter_delta =
|
||||
input.try(|input| specified::parse_integer(input)).unwrap_or(specified::Integer::new(default_value));
|
||||
let counter_delta = input.try(|input| specified::parse_integer(context, input))
|
||||
.unwrap_or(specified::Integer::new(default_value));
|
||||
counters.push((counter_name, counter_delta))
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@
|
|||
pub use super::counter_increment::{SpecifiedValue, computed_value, get_initial_value};
|
||||
use super::counter_increment::parse_common;
|
||||
|
||||
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
parse_common(0, input)
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
parse_common(context, 0, input)
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
|
@ -339,7 +339,7 @@ ${helpers.predefined_type("clip",
|
|||
if let Ok(function_name) = input.try(|input| input.expect_function()) {
|
||||
filters.push(try!(input.parse_nested_block(|input| {
|
||||
match_ignore_ascii_case! { &function_name,
|
||||
"blur" => specified::Length::parse_non_negative(input).map(SpecifiedFilter::Blur),
|
||||
"blur" => specified::Length::parse_non_negative(context, input).map(SpecifiedFilter::Blur),
|
||||
"brightness" => parse_factor(input).map(SpecifiedFilter::Brightness),
|
||||
"contrast" => parse_factor(input).map(SpecifiedFilter::Contrast),
|
||||
"grayscale" => parse_factor(input).map(SpecifiedFilter::Grayscale),
|
||||
|
|
|
@ -681,8 +681,8 @@ ${helpers.single_keyword("font-variant-caps",
|
|||
}
|
||||
}
|
||||
/// <length> | <percentage> | <absolute-size> | <relative-size>
|
||||
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if let Ok(lop) = input.try(specified::LengthOrPercentage::parse_non_negative) {
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if let Ok(lop) = input.try(|i| specified::LengthOrPercentage::parse_non_negative(context, i)) {
|
||||
return Ok(SpecifiedValue::Length(lop))
|
||||
}
|
||||
|
||||
|
@ -788,14 +788,14 @@ ${helpers.single_keyword("font-variant-caps",
|
|||
}
|
||||
|
||||
/// none | <number>
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
use values::specified::Number;
|
||||
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(SpecifiedValue::None);
|
||||
}
|
||||
|
||||
Ok(SpecifiedValue::Number(try!(Number::parse_non_negative(input))))
|
||||
Ok(SpecifiedValue::Number(try!(Number::parse_non_negative(context, input))))
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
|
|
|
@ -71,7 +71,6 @@ ${helpers.predefined_type(
|
|||
"parse_numbers_are_pixels_non_negative",
|
||||
products="gecko",
|
||||
animation_type="normal",
|
||||
needs_context=False,
|
||||
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeWidth")}
|
||||
|
||||
${helpers.single_keyword("stroke-linecap", "butt round square",
|
||||
|
@ -84,7 +83,6 @@ ${helpers.single_keyword("stroke-linejoin", "miter round bevel",
|
|||
|
||||
${helpers.predefined_type("stroke-miterlimit", "Number", "4.0",
|
||||
"parse_at_least_one", products="gecko",
|
||||
needs_context=False,
|
||||
animation_type="none",
|
||||
spec="https://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty")}
|
||||
|
||||
|
@ -108,7 +106,6 @@ ${helpers.predefined_type(
|
|||
"parse_numbers_are_pixels",
|
||||
products="gecko",
|
||||
animation_type="normal",
|
||||
needs_context=False,
|
||||
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing")}
|
||||
|
||||
// Section 14 - Clipping, Masking and Compositing
|
||||
|
|
|
@ -114,14 +114,14 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
let mut first = None;
|
||||
let mut second = None;
|
||||
match specified::Length::parse_non_negative(input) {
|
||||
match specified::Length::parse_non_negative(context, input) {
|
||||
Err(()) => (),
|
||||
Ok(length) => {
|
||||
first = Some(length);
|
||||
if let Ok(len) = input.try(|input| specified::Length::parse_non_negative(input)) {
|
||||
if let Ok(len) = input.try(|input| specified::Length::parse_non_negative(context, input)) {
|
||||
second = Some(len);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,18 +45,18 @@
|
|||
}
|
||||
}
|
||||
/// normal | <number> | <length> | <percentage>
|
||||
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
use cssparser::Token;
|
||||
use std::ascii::AsciiExt;
|
||||
|
||||
// We try to parse as a Number first because, for 'line-height', we want
|
||||
// "0" to be parsed as a plain Number rather than a Length (0px); this
|
||||
// matches the behaviour of all major browsers
|
||||
if let Ok(number) = input.try(specified::Number::parse_non_negative) {
|
||||
if let Ok(number) = input.try(|i| specified::Number::parse_non_negative(context, i)) {
|
||||
return Ok(SpecifiedValue::Number(number))
|
||||
}
|
||||
|
||||
if let Ok(lop) = input.try(specified::LengthOrPercentage::parse_non_negative) {
|
||||
if let Ok(lop) = input.try(|i| specified::LengthOrPercentage::parse_non_negative(context, i)) {
|
||||
return Ok(SpecifiedValue::LengthOrPercentage(lop))
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ ${helpers.predefined_type("outline-color", "CSSColor", "computed::CSSColor::Curr
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
specified::parse_border_width(input).map(SpecifiedValue)
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
specified::parse_border_width(context, input).map(SpecifiedValue)
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
"computed::LengthOrPercentage::Length(Au(0))",
|
||||
"parse_non_negative",
|
||||
alias=maybe_moz_logical_alias(product, side, "-moz-padding-%s"),
|
||||
needs_context=False,
|
||||
animation_type="normal",
|
||||
logical = side[1],
|
||||
spec = spec)}
|
||||
|
|
|
@ -95,14 +95,12 @@ ${helpers.predefined_type("flex-grow", "Number",
|
|||
"0.0", "parse_non_negative",
|
||||
spec="https://drafts.csswg.org/css-flexbox/#flex-grow-property",
|
||||
extra_prefixes="webkit",
|
||||
needs_context=False,
|
||||
animation_type="normal")}
|
||||
|
||||
${helpers.predefined_type("flex-shrink", "Number",
|
||||
"1.0", "parse_non_negative",
|
||||
spec="https://drafts.csswg.org/css-flexbox/#flex-shrink-property",
|
||||
extra_prefixes="webkit",
|
||||
needs_context=False,
|
||||
animation_type="normal")}
|
||||
|
||||
// https://drafts.csswg.org/css-align/#align-self-property
|
||||
|
@ -142,7 +140,6 @@ ${helpers.predefined_type("flex-basis",
|
|||
"computed::LengthOrPercentageOrAuto::Auto" if product == "gecko" else
|
||||
"computed::LengthOrPercentageOrAutoOrContent::Auto",
|
||||
"parse_non_negative",
|
||||
needs_context=False,
|
||||
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property",
|
||||
extra_prefixes="webkit",
|
||||
animation_type="normal" if product == "gecko" else "none")}
|
||||
|
@ -158,7 +155,6 @@ ${helpers.predefined_type("flex-basis",
|
|||
"LengthOrPercentageOrAuto",
|
||||
"computed::LengthOrPercentageOrAuto::Auto",
|
||||
"parse_non_negative",
|
||||
needs_context=False,
|
||||
spec=spec % size,
|
||||
animation_type="normal", logical = logical)}
|
||||
% if product == "gecko":
|
||||
|
@ -255,14 +251,12 @@ ${helpers.predefined_type("flex-basis",
|
|||
"LengthOrPercentage",
|
||||
"computed::LengthOrPercentage::Length(Au(0))",
|
||||
"parse_non_negative",
|
||||
needs_context=False,
|
||||
spec=spec % ("min-%s" % size),
|
||||
animation_type="normal", logical = logical)}
|
||||
${helpers.predefined_type("max-%s" % size,
|
||||
"LengthOrPercentageOrNone",
|
||||
"computed::LengthOrPercentageOrNone::None",
|
||||
"parse_non_negative",
|
||||
needs_context=False,
|
||||
spec=spec % ("min-%s" % size),
|
||||
animation_type="normal", logical = logical)}
|
||||
% endif
|
||||
|
|
|
@ -288,7 +288,7 @@ ${helpers.predefined_type(
|
|||
return Ok(SpecifiedValue::Normal);
|
||||
}
|
||||
|
||||
let size = try!(Number::parse_at_least_one(input));
|
||||
let size = try!(Number::parse_at_least_one(context, input));
|
||||
|
||||
match input.try(|input| Integer::parse(context, input)) {
|
||||
Ok(number) => {
|
||||
|
|
|
@ -25,7 +25,6 @@ ${helpers.single_keyword("-moz-box-direction", "normal reverse",
|
|||
|
||||
${helpers.predefined_type("-moz-box-flex", "Number", "0.0", "parse_non_negative",
|
||||
products="gecko", gecko_ffi_name="mBoxFlex",
|
||||
needs_context=False,
|
||||
animation_type="none",
|
||||
alias="-webkit-box-flex",
|
||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/box-flex)")}
|
||||
|
@ -52,7 +51,6 @@ ${helpers.single_keyword("-moz-stack-sizing", "stretch-to-fit ignore",
|
|||
|
||||
${helpers.predefined_type("-moz-box-ordinal-group", "Integer", "0",
|
||||
parse_method="parse_non_negative",
|
||||
needs_context=False,
|
||||
products="gecko",
|
||||
alias="-webkit-box-ordinal-group",
|
||||
gecko_ffi_name="mBoxOrdinal",
|
||||
|
|
|
@ -330,7 +330,7 @@ impl PropertyDeclarationIdSet {
|
|||
//
|
||||
// FIXME(pcwalton): Cloning the error reporter is slow! But so are custom
|
||||
// properties, so whatever...
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter);
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter, None);
|
||||
Parser::new(&css).parse_entirely(|input| {
|
||||
match from_shorthand {
|
||||
None => {
|
||||
|
@ -976,9 +976,9 @@ impl ParsedDeclaration {
|
|||
/// This will not actually parse Importance values, and will always set things
|
||||
/// to Importance::Normal. Parsing Importance values is the job of PropertyDeclarationParser,
|
||||
/// we only set them here so that we don't have to reallocate
|
||||
pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser,
|
||||
in_keyframe_block: bool, rule_type: CssRuleType)
|
||||
pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser)
|
||||
-> Result<ParsedDeclaration, PropertyDeclarationParseError> {
|
||||
let rule_type = context.rule_type();
|
||||
debug_assert!(rule_type == CssRuleType::Keyframe ||
|
||||
rule_type == CssRuleType::Page ||
|
||||
rule_type == CssRuleType::Style,
|
||||
|
@ -999,7 +999,7 @@ impl ParsedDeclaration {
|
|||
LonghandId::${property.camel_case} => {
|
||||
% if not property.derived_from:
|
||||
% if not property.allowed_in_keyframe_block:
|
||||
if in_keyframe_block {
|
||||
if rule_type == CssRuleType::Keyframe {
|
||||
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
|
||||
}
|
||||
% endif
|
||||
|
@ -1032,7 +1032,7 @@ impl ParsedDeclaration {
|
|||
% for shorthand in data.shorthands:
|
||||
ShorthandId::${shorthand.camel_case} => {
|
||||
% if not shorthand.allowed_in_keyframe_block:
|
||||
if in_keyframe_block {
|
||||
if rule_type == CssRuleType::Keyframe {
|
||||
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
|
||||
}
|
||||
% endif
|
||||
|
|
|
@ -50,10 +50,10 @@
|
|||
spec="https://drafts.csswg.org/css-flexbox/#flex-property">
|
||||
use values::specified::Number;
|
||||
|
||||
fn parse_flexibility(input: &mut Parser)
|
||||
fn parse_flexibility(context: &ParserContext, input: &mut Parser)
|
||||
-> Result<(Number, Option<Number>),()> {
|
||||
let grow = try!(Number::parse_non_negative(input));
|
||||
let shrink = input.try(Number::parse_non_negative).ok();
|
||||
let grow = try!(Number::parse_non_negative(context, input));
|
||||
let shrink = input.try(|i| Number::parse_non_negative(context, i)).ok();
|
||||
Ok((grow, shrink))
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@
|
|||
}
|
||||
loop {
|
||||
if grow.is_none() {
|
||||
if let Ok((flex_grow, flex_shrink)) = input.try(parse_flexibility) {
|
||||
if let Ok((flex_grow, flex_shrink)) = input.try(|i| parse_flexibility(context, i)) {
|
||||
grow = Some(flex_grow);
|
||||
shrink = flex_shrink;
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue