Skip to content
Permalink
Browse files

style: Part 2: Retire the support for 3-valued syntax for position.

According to this resolved spec issue:
w3c/csswg-drafts#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
  • Loading branch information...
BorisChiou authored and emilio committed Jul 10, 2019
1 parent 6cf87d2 commit 145acbf8767398ff8895195294a88b22981c5e46
@@ -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> {

0 comments on commit 145acbf

Please sign in to comment.
You can’t perform that action at this time.