mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
style: Part 2: Retire the support for 3-valued syntax for position.
According to this resolved spec issue: https://github.com/w3c/csswg-drafts/issues/2140, we retire the 3-valued <position> on 1. `object-position` 2. `perspective-origin`, 3. `mask-position` 4. `circle()` and `ellipse()` , but still keep the support for `background-position`. Besides, I simply run this python script to generate the .ini file: ``` s = sys.argv[1] + ".ini" with open(s, "w") as f: f.write('[{}]\n'.format(sys.argv[1])) f.write(' expected: FAIL\n') f.write(' bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1559276\n') ``` Differential Revision: https://phabricator.services.mozilla.com/D37126
This commit is contained in:
parent
6cf87d23f8
commit
145acbf876
2 changed files with 29 additions and 6 deletions
|
@ -15,7 +15,7 @@
|
|||
use crate::properties::longhands::background_clip;
|
||||
use crate::properties::longhands::background_clip::single_value::computed_value::T as Clip;
|
||||
use crate::properties::longhands::background_origin::single_value::computed_value::T as Origin;
|
||||
use crate::values::specified::{Color, Position, PositionComponent};
|
||||
use crate::values::specified::{AllowQuirks, Color, Position, PositionComponent};
|
||||
use crate::parser::Parse;
|
||||
|
||||
// FIXME(emilio): Should be the same type!
|
||||
|
@ -64,7 +64,9 @@
|
|||
}
|
||||
}
|
||||
if position.is_none() {
|
||||
if let Ok(value) = input.try(|input| Position::parse(context, input)) {
|
||||
if let Ok(value) = input.try(|input| {
|
||||
Position::parse_three_value_quirky(context, input, AllowQuirks::No)
|
||||
}) {
|
||||
position = Some(value);
|
||||
|
||||
// Parse background size, if applicable.
|
||||
|
@ -211,7 +213,7 @@
|
|||
let mut any = false;
|
||||
|
||||
input.parse_comma_separated(|input| {
|
||||
let value = Position::parse_quirky(context, input, AllowQuirks::Yes)?;
|
||||
let value = Position::parse_three_value_quirky(context, input, AllowQuirks::Yes)?;
|
||||
position_x.push(value.horizontal);
|
||||
position_y.push(value.vertical);
|
||||
any = true;
|
||||
|
|
|
@ -94,13 +94,17 @@ impl Parse for Position {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Self::parse_quirky(context, input, AllowQuirks::No)
|
||||
let position = Self::parse_three_value_quirky(context, input, AllowQuirks::No)?;
|
||||
if position.is_three_value_syntax() {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
Ok(position)
|
||||
}
|
||||
}
|
||||
|
||||
impl Position {
|
||||
/// Parses a `<position>`, with quirks.
|
||||
pub fn parse_quirky<'i, 't>(
|
||||
/// Parses a `<bg-position>`, with quirks.
|
||||
pub fn parse_three_value_quirky<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
|
@ -183,6 +187,12 @@ impl Position {
|
|||
pub fn center() -> Self {
|
||||
Self::new(PositionComponent::Center, PositionComponent::Center)
|
||||
}
|
||||
|
||||
/// Returns true if this uses a 3 value syntax.
|
||||
#[inline]
|
||||
fn is_three_value_syntax(&self) -> bool {
|
||||
self.horizontal.component_count() != self.vertical.component_count()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for Position {
|
||||
|
@ -252,6 +262,17 @@ impl<S> PositionComponent<S> {
|
|||
pub fn zero() -> Self {
|
||||
PositionComponent::Length(LengthPercentage::Percentage(Percentage::zero()))
|
||||
}
|
||||
|
||||
/// Returns the count of this component.
|
||||
fn component_count(&self) -> usize {
|
||||
match *self {
|
||||
PositionComponent::Length(..) |
|
||||
PositionComponent::Center => 1,
|
||||
PositionComponent::Side(_, ref lp) => {
|
||||
if lp.is_some() { 2 } else { 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Side> ToComputedValue for PositionComponent<S> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue