mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
stylo: -moz-image-region shouldn't parse unitless lengths in quirks mode
This commit is contained in:
parent
dab2df3565
commit
85fb3efd76
2 changed files with 32 additions and 10 deletions
|
@ -83,6 +83,7 @@ ${helpers.predefined_type("clip",
|
|||
"computed::ClipRectOrAuto::auto()",
|
||||
animation_value_type="ComputedValue",
|
||||
boxed="True",
|
||||
allow_quirks=True,
|
||||
spec="https://drafts.fxtf.org/css-masking/#clip-property")}
|
||||
|
||||
// FIXME: This prop should be animatable
|
||||
|
|
|
@ -1219,13 +1219,22 @@ impl ToComputedValue for ClipRect {
|
|||
|
||||
impl Parse for ClipRect {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
use values::specified::{AllowQuirks, Length};
|
||||
Self::parse_quirky(context, input, AllowQuirks::No)
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_argument(context: &ParserContext, input: &mut Parser) -> Result<Option<Length>, ()> {
|
||||
impl ClipRect {
|
||||
/// Parses a rect(<top>, <left>, <bottom>, <right>), allowing quirks.
|
||||
pub fn parse_quirky(context: &ParserContext, input: &mut Parser,
|
||||
allow_quirks: AllowQuirks) -> Result<Self, ()> {
|
||||
use values::specified::Length;
|
||||
|
||||
fn parse_argument(context: &ParserContext, input: &mut Parser,
|
||||
allow_quirks: AllowQuirks) -> Result<Option<Length>, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
|
||||
Ok(None)
|
||||
} else {
|
||||
Length::parse_quirky(context, input, AllowQuirks::Yes).map(Some)
|
||||
Length::parse_quirky(context, input, allow_quirks).map(Some)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1234,21 +1243,21 @@ impl Parse for ClipRect {
|
|||
}
|
||||
|
||||
input.parse_nested_block(|input| {
|
||||
let top = try!(parse_argument(context, input));
|
||||
let top = try!(parse_argument(context, input, allow_quirks));
|
||||
let right;
|
||||
let bottom;
|
||||
let left;
|
||||
|
||||
if input.try(|input| input.expect_comma()).is_ok() {
|
||||
right = try!(parse_argument(context, input));
|
||||
right = try!(parse_argument(context, input, allow_quirks));
|
||||
try!(input.expect_comma());
|
||||
bottom = try!(parse_argument(context, input));
|
||||
bottom = try!(parse_argument(context, input, allow_quirks));
|
||||
try!(input.expect_comma());
|
||||
left = try!(parse_argument(context, input));
|
||||
left = try!(parse_argument(context, input, allow_quirks));
|
||||
} else {
|
||||
right = try!(parse_argument(context, input));
|
||||
bottom = try!(parse_argument(context, input));
|
||||
left = try!(parse_argument(context, input));
|
||||
right = try!(parse_argument(context, input, allow_quirks));
|
||||
bottom = try!(parse_argument(context, input, allow_quirks));
|
||||
left = try!(parse_argument(context, input, allow_quirks));
|
||||
}
|
||||
Ok(ClipRect {
|
||||
top: top,
|
||||
|
@ -1263,6 +1272,18 @@ impl Parse for ClipRect {
|
|||
/// rect(...) | auto
|
||||
pub type ClipRectOrAuto = Either<ClipRect, Auto>;
|
||||
|
||||
impl ClipRectOrAuto {
|
||||
/// Parses a ClipRect or Auto, allowing quirks.
|
||||
pub fn parse_quirky(context: &ParserContext, input: &mut Parser,
|
||||
allow_quirks: AllowQuirks) -> Result<Self, ()> {
|
||||
if let Ok(v) = input.try(|i| ClipRect::parse_quirky(context, i, allow_quirks)) {
|
||||
Ok(Either::First(v))
|
||||
} else {
|
||||
Auto::parse(context, input).map(Either::Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <color> | auto
|
||||
pub type ColorOrAuto = Either<CSSColor, Auto>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue