mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Stylo - support image-orientation property
First, we need to make Servo's image-orientation parser to be agreed with Gecko's. Numbers without any AngleUnit, including unitless 0 angle, should be invalid for image-orientation. However, rotate() and skew() for transform properties accept unitless 0 angle. In order to make all these properties work properly, I fixed Angle::parse() to match Gecko. For the existing users of Angle::parse(), I create Angle::parse_with_unitless() and use it as an alternative for them. Once https://github.com/w3c/csswg-drafts/issues/1162 is resolved, we shall be able to use an unified version of Angle::parse() then. The parser of image-orientation is also fixed to report parsing errors on empty string. Then, with the newly added binding functions support in Gecko side, we shall reuse the same methods from Gecko to pass the computed value from Servo to Gecko. Gecko bug: Bug 1341758
This commit is contained in:
parent
b5a003246e
commit
5332d4b265
5 changed files with 66 additions and 21 deletions
|
@ -83,7 +83,7 @@ ${helpers.single_keyword("image-rendering",
|
|||
|
||||
// Image Orientation
|
||||
<%helpers:longhand name="image-orientation"
|
||||
products="None"
|
||||
products="gecko"
|
||||
animation_type="none"
|
||||
spec="https://drafts.csswg.org/css-images/#propdef-image-orientation, \
|
||||
/// additional values in https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation">
|
||||
|
@ -199,21 +199,23 @@ ${helpers.single_keyword("image-rendering",
|
|||
}
|
||||
}
|
||||
|
||||
// from-image | <angle> | [<angle>? flip]
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("from-image")).is_ok() {
|
||||
// Handle from-image
|
||||
Ok(SpecifiedValue { angle: None, flipped: false })
|
||||
} else if input.try(|input| input.expect_ident_matching("flip")).is_ok() {
|
||||
// Handle flip
|
||||
Ok(SpecifiedValue { angle: Some(Angle::zero()), flipped: true })
|
||||
} else {
|
||||
// Handle <angle> | <angle>? flip
|
||||
// Handle <angle> | <angle> flip
|
||||
let angle = input.try(|input| Angle::parse(context, input)).ok();
|
||||
let flipped = input.try(|input| input.expect_ident_matching("flip")).is_ok();
|
||||
let explicit_angle = if angle.is_none() && !flipped {
|
||||
Some(Angle::zero())
|
||||
} else {
|
||||
angle
|
||||
};
|
||||
if angle.is_none() {
|
||||
return Err(());
|
||||
}
|
||||
|
||||
Ok(SpecifiedValue { angle: explicit_angle, flipped: flipped })
|
||||
let flipped = input.try(|input| input.expect_ident_matching("flip")).is_ok();
|
||||
Ok(SpecifiedValue { angle: angle, flipped: flipped })
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue