Bug 1559796 - Should not serialize default radius of circle r=emilio

Should not serialize default shape-outside circle() function radius.

The ToCss impl of Circle and Ellipse turn out to be identical in specified and computed value, thus move them to generics.

Differential Revision: https://phabricator.services.mozilla.com/D35183

--HG--
extra : moz-landing-system : lando
This commit is contained in:
violet 2019-06-18 11:54:41 +00:00
Родитель 7d8c86a22d
Коммит f8f8760a7f
11 изменённых файлов: 84 добавлений и 1068 удалений

Просмотреть файл

@ -852,7 +852,7 @@ const basicShapesTests = [
{ start: "circle(500px)", end: "circle(farthest-side)",
expected: ["circle", ["farthest-side at 50% 50%"]]},
{ start: "circle(500px)", end: "circle(closest-side)",
expected: ["circle", ["closest-side at 50% 50%"]]},
expected: ["circle", ["at 50% 50%"]]},
{ start: "ellipse()", end: "ellipse(50px 50px)",
expected: ["ellipse", ["50px 50px at 50% 50%"]] },
{ start: "ellipse(closest-side closest-side)", end: "ellipse(500px 500px)",

Просмотреть файл

@ -10,8 +10,6 @@
use crate::values::computed::url::ComputedUrl;
use crate::values::computed::{Image, LengthPercentage, NonNegativeLengthPercentage};
use crate::values::generics::basic_shape as generic;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};
/// A computed alias for FillRule.
pub use crate::values::generics::basic_shape::FillRule;
@ -42,34 +40,3 @@ pub type Ellipse =
/// The computed value of `ShapeRadius`
pub type ShapeRadius = generic::GenericShapeRadius<NonNegativeLengthPercentage>;
impl ToCss for Circle {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
dest.write_str("circle(")?;
self.radius.to_css(dest)?;
dest.write_str(" at ")?;
self.position.to_css(dest)?;
dest.write_str(")")
}
}
impl ToCss for Ellipse {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
dest.write_str("ellipse(")?;
if (self.semiaxis_x, self.semiaxis_y) != Default::default() {
self.semiaxis_x.to_css(dest)?;
dest.write_str(" ")?;
self.semiaxis_y.to_css(dest)?;
dest.write_str(" ")?;
}
dest.write_str("at ")?;
self.position.to_css(dest)?;
dest.write_str(")")
}
}

Просмотреть файл

@ -378,6 +378,48 @@ where
}
}
impl<H, V, NonNegativeLengthPercentage> ToCss for Circle<H, V, NonNegativeLengthPercentage>
where
GenericPosition<H, V>: ToCss,
NonNegativeLengthPercentage: ToCss + PartialEq,
{
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
dest.write_str("circle(")?;
if self.radius != Default::default() {
self.radius.to_css(dest)?;
dest.write_str(" ")?;
}
dest.write_str("at ")?;
self.position.to_css(dest)?;
dest.write_str(")")
}
}
impl<H, V, NonNegativeLengthPercentage> ToCss for Ellipse<H, V, NonNegativeLengthPercentage>
where
GenericPosition<H, V>: ToCss,
NonNegativeLengthPercentage: ToCss + PartialEq,
{
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
dest.write_str("ellipse(")?;
if self.semiaxis_x != Default::default() || self.semiaxis_y != Default::default() {
self.semiaxis_x.to_css(dest)?;
dest.write_str(" ")?;
self.semiaxis_y.to_css(dest)?;
dest.write_str(" ")?;
}
dest.write_str("at ")?;
self.position.to_css(dest)?;
dest.write_str(")")
}
}
impl<L> Default for ShapeRadius<L> {
#[inline]
fn default() -> Self {

Просмотреть файл

@ -20,8 +20,7 @@ use crate::values::specified::SVGPathData;
use crate::values::specified::{LengthPercentage, NonNegativeLengthPercentage};
use crate::Zero;
use cssparser::Parser;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use style_traits::{ParseError, StyleParseErrorKind};
/// A specified alias for FillRule.
pub use crate::values::generics::basic_shape::FillRule;
@ -239,23 +238,6 @@ impl Circle {
}
}
impl ToCss for Circle {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
dest.write_str("circle(")?;
if generic::ShapeRadius::ClosestSide != self.radius {
self.radius.to_css(dest)?;
dest.write_str(" ")?;
}
dest.write_str("at ")?;
self.position.to_css(dest)?;
dest.write_str(")")
}
}
impl Parse for Ellipse {
fn parse<'i, 't>(
context: &ParserContext,
@ -293,25 +275,6 @@ impl Ellipse {
}
}
impl ToCss for Ellipse {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
dest.write_str("ellipse(")?;
if self.semiaxis_x != ShapeRadius::default() || self.semiaxis_y != ShapeRadius::default() {
self.semiaxis_x.to_css(dest)?;
dest.write_str(" ")?;
self.semiaxis_y.to_css(dest)?;
dest.write_str(" ")?;
}
dest.write_str("at ")?;
self.position.to_css(dest)?;
dest.write_str(")")
}
}
impl Parse for ShapeRadius {
fn parse<'i, 't>(
context: &ParserContext,

Просмотреть файл

@ -1,4 +0,0 @@
[shape-outside-computed.html]
[Property shape-outside value 'circle(at 10% 20%)' computes to 'circle(at 10% 20%)']
expected: FAIL

Просмотреть файл

@ -1,10 +1,4 @@
[shape-outside-circle-000.html]
[No arguments - computed]
expected: FAIL
[Position argument only - computed]
expected: FAIL
[No arguments - inline]
expected: FAIL

Просмотреть файл

@ -1,10 +1,4 @@
[shape-outside-circle-001.html]
[circle() - computed]
expected: FAIL
[circle(closest-side) - computed]
expected: FAIL
[circle() - inline]
expected: FAIL

Просмотреть файл

@ -1,187 +1,19 @@
[shape-outside-circle-002.html]
[circle(at 50%) serializes as circle(at 50% 50%) - computed]
expected: FAIL
[circle(at 50px) serializes as circle(at 50px 50%) - computed]
expected: FAIL
[circle(at 50% 50%) serializes as circle(at 50% 50%) - computed]
expected: FAIL
[circle(at 50% 50px) serializes as circle(at 50% 50px) - computed]
expected: FAIL
[circle(at 50px 50%) serializes as circle(at 50px 50%) - computed]
expected: FAIL
[circle(at 50px 50px) serializes as circle(at 50px 50px) - computed]
expected: FAIL
[circle(at left) serializes as circle(at 0% 50%) - computed]
expected: FAIL
[circle(at top) serializes as circle(at 50% 0%) - computed]
expected: FAIL
[circle(at right) serializes as circle(at 100% 50%) - computed]
expected: FAIL
[circle(at bottom) serializes as circle(at 50% 100%) - computed]
expected: FAIL
[circle(at center) serializes as circle(at 50% 50%) - computed]
expected: FAIL
[circle(at left top) serializes as circle(at 0% 0%) - computed]
expected: FAIL
[circle(at left bottom) serializes as circle(at 0% 100%) - computed]
expected: FAIL
[circle(at left center) serializes as circle(at 0% 50%) - computed]
expected: FAIL
[circle(at top left) serializes as circle(at 0% 0%) - computed]
expected: FAIL
[circle(at top right) serializes as circle(at 100% 0%) - computed]
expected: FAIL
[circle(at top center) serializes as circle(at 50% 0%) - computed]
expected: FAIL
[circle(at right top) serializes as circle(at 100% 0%) - computed]
expected: FAIL
[circle(at right bottom) serializes as circle(at 100% 100%) - computed]
expected: FAIL
[circle(at right center) serializes as circle(at 100% 50%) - computed]
expected: FAIL
[circle(at bottom left) serializes as circle(at 0% 100%) - computed]
expected: FAIL
[circle(at bottom right) serializes as circle(at 100% 100%) - computed]
expected: FAIL
[circle(at bottom center) serializes as circle(at 50% 100%) - computed]
expected: FAIL
[circle(at center top) serializes as circle(at 50% 0%) - computed]
expected: FAIL
[circle(at center left) serializes as circle(at 0% 50%) - computed]
expected: FAIL
[circle(at center right) serializes as circle(at 100% 50%) - computed]
expected: FAIL
[circle(at center bottom) serializes as circle(at 50% 100%) - computed]
expected: FAIL
[circle(at center center) serializes as circle(at 50% 50%) - computed]
expected: FAIL
[circle(at left 50%) serializes as circle(at 0% 50%) - computed]
expected: FAIL
[circle(at left 50px) serializes as circle(at 0% 50px) - computed]
expected: FAIL
[circle(at 50% top) serializes as circle(at 50% 0%) - computed]
expected: FAIL
[circle(at 50px top) serializes as circle(at 50px 0%) - computed]
expected: FAIL
[circle(at right 80%) serializes as circle(at 100% 80%) - computed]
expected: FAIL
[circle(at right 80px) serializes as circle(at 100% 80px) - computed]
expected: FAIL
[circle(at 70% bottom) serializes as circle(at 70% 100%) - computed]
expected: FAIL
[circle(at 70px bottom) serializes as circle(at 70px 100%) - computed]
expected: FAIL
[circle(at center 60%) serializes as circle(at 50% 60%) - computed]
expected: FAIL
[circle(at center 60px) serializes as circle(at 50% 60px) - computed]
expected: FAIL
[circle(at 60% center) serializes as circle(at 60% 50%) - computed]
expected: FAIL
[circle(at 60px center) serializes as circle(at 60px 50%) - computed]
expected: FAIL
[circle(at center top 50%) serializes as circle(at 50% 50%) - computed]
expected: FAIL
[circle(at center top 50px) serializes as circle(at 50% 50px) - computed]
expected: FAIL
[circle(at center left 50%) serializes as circle(at 50% 50%) - computed]
expected: FAIL
[circle(at center left 50px) serializes as circle(at 50px 50%) - computed]
expected: FAIL
[circle(at center right 70%) serializes as circle(at 30% 50%) - computed]
expected: FAIL
[circle(at center right 70px) serializes as circle(at right 70px top 50%) - computed]
expected: FAIL
[circle(at center bottom 70%) serializes as circle(at 50% 30%) - computed]
expected: FAIL
[circle(at center bottom 70px) serializes as circle(at left 50% bottom 70px) - computed]
expected: FAIL
[circle(at left top 50%) serializes as circle(at 0% 50%) - computed]
expected: FAIL
[circle(at left top 50px) serializes as circle(at 0% 50px) - computed]
expected: FAIL
[circle(at left bottom 70%) serializes as circle(at 0% 30%) - computed]
expected: FAIL
[circle(at left bottom 70px) serializes as circle(at left 0% bottom 70px) - computed]
expected: FAIL
[circle(at top left 50%) serializes as circle(at 50% 0%) - computed]
expected: FAIL
[circle(at top left 50px) serializes as circle(at 50px 0%) - computed]
expected: FAIL
[circle(at top right 70%) serializes as circle(at 30% 0%) - computed]
expected: FAIL
[circle(at top right 70px) serializes as circle(at right 70px top 0%) - computed]
expected: FAIL
[circle(at bottom left 50%) serializes as circle(at 50% 100%) - computed]
expected: FAIL
[circle(at bottom left 50px) serializes as circle(at 50px 100%) - computed]
expected: FAIL
[circle(at bottom right 70%) serializes as circle(at 30% 100%) - computed]
expected: FAIL
[circle(at bottom right 70px) serializes as circle(at right 70px top 100%) - computed]
expected: FAIL
[circle(at right bottom 70%) serializes as circle(at 100% 30%) - computed]
expected: FAIL
[circle(at right bottom 70px) serializes as circle(at left 100% bottom 70px) - computed]
expected: FAIL
@ -263,63 +95,18 @@
[circle(at right 80px top) serializes as circle(at right 80px top 0%) - computed]
expected: FAIL
[circle(at left 50% top 50%) serializes as circle(at 50% 50%) - computed]
expected: FAIL
[circle(at left 50% top 50px) serializes as circle(at 50% 50px) - computed]
expected: FAIL
[circle(at left 50% bottom 70%) serializes as circle(at 50% 30%) - computed]
expected: FAIL
[circle(at left 50% bottom 70px) serializes as circle(at left 50% bottom 70px) - computed]
expected: FAIL
[circle(at left 50px top 50%) serializes as circle(at 50px 50%) - computed]
expected: FAIL
[circle(at left 50px top 50px) serializes as circle(at 50px 50px) - computed]
expected: FAIL
[circle(at left 50px bottom 70%) serializes as circle(at 50px 30%) - computed]
expected: FAIL
[circle(at left 50px bottom 70px) serializes as circle(at left 50px bottom 70px) - computed]
expected: FAIL
[circle(at top 50% left 50%) serializes as circle(at 50% 50%) - computed]
expected: FAIL
[circle(at top 50% left 50px) serializes as circle(at 50px 50%) - computed]
expected: FAIL
[circle(at top 50% right 80%) serializes as circle(at 20% 50%) - computed]
expected: FAIL
[circle(at top 50% right 80px) serializes as circle(at right 80px top 50%) - computed]
expected: FAIL
[circle(at top 50px left 50%) serializes as circle(at 50% 50px) - computed]
expected: FAIL
[circle(at top 50px left 50px) serializes as circle(at 50px 50px) - computed]
expected: FAIL
[circle(at top 50px right 80%) serializes as circle(at 20% 50px) - computed]
expected: FAIL
[circle(at top 50px right 80px) serializes as circle(at right 80px top 50px) - computed]
expected: FAIL
[circle(at bottom 70% left 50%) serializes as circle(at 50% 30%) - computed]
expected: FAIL
[circle(at bottom 70% left 50px) serializes as circle(at 50px 30%) - computed]
expected: FAIL
[circle(at bottom 70% right 80%) serializes as circle(at 20% 30%) - computed]
expected: FAIL
[circle(at bottom 70% right 80px) serializes as circle(at right 80px top 30%) - computed]
expected: FAIL
@ -335,15 +122,6 @@
[circle(at bottom 70px right 80px) serializes as circle(at right 80px bottom 70px) - computed]
expected: FAIL
[circle(at right 80% top 50%) serializes as circle(at 20% 50%) - computed]
expected: FAIL
[circle(at right 80% top 50px) serializes as circle(at 20% 50px) - computed]
expected: FAIL
[circle(at right 80% bottom 70%) serializes as circle(at 20% 30%) - computed]
expected: FAIL
[circle(at right 80% bottom 70px) serializes as circle(at left 20% bottom 70px) - computed]
expected: FAIL

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,61 +1,4 @@
[shape-outside-circle-009.html]
[circle(at +50px) - computed]
expected: FAIL
[circle(at -50px) - computed]
expected: FAIL
[circle(at +50%) - computed]
expected: FAIL
[circle(at -50%) - computed]
expected: FAIL
[circle(at left +50px) - computed]
expected: FAIL
[circle(at left +50%) - computed]
expected: FAIL
[circle(at right -50px) - computed]
expected: FAIL
[circle(at right -50%) - computed]
expected: FAIL
[circle(at +50px top) - computed]
expected: FAIL
[circle(at +50% top) - computed]
expected: FAIL
[circle(at -50px bottom) - computed]
expected: FAIL
[circle(at -50% bottom) - computed]
expected: FAIL
[circle(at +50px +50px) - computed]
expected: FAIL
[circle(at +50% +50%) - computed]
expected: FAIL
[circle(at -50px -50px) - computed]
expected: FAIL
[circle(at +50px -50px) - computed]
expected: FAIL
[circle(at -50px +50px) - computed]
expected: FAIL
[circle(at +50% -50%) - computed]
expected: FAIL
[circle(at -50% +50%) - computed]
expected: FAIL
[circle(at +50px) - inline]
expected: FAIL

Просмотреть файл

@ -2,27 +2,6 @@
[circle(at calc((12.5%*6 + 10in) / 4)) - inline style]
expected: FAIL
[circle(at calc(10in)) - computed style]
expected: FAIL
[circle(at calc(10in + 20px)) - computed style]
expected: FAIL
[circle(at calc(30%)) - computed style]
expected: FAIL
[circle(at calc(100%/4)) - computed style]
expected: FAIL
[circle(at calc(25%*3)) - computed style]
expected: FAIL
[circle(at calc(25%*3 - 10in)) - computed style]
expected: FAIL
[circle(at calc((12.5%*6 + 10in) / 4)) - computed style]
expected: FAIL
[circle(at calc(10in)) - inline style]
expected: FAIL