mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
style: Should not serialize default radius of circle.
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
This commit is contained in:
parent
c7c1fed95c
commit
e1e82dbe5f
3 changed files with 43 additions and 71 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue