style: Omit center positions in conic/radial gradient serialization.

Differential Revision: https://phabricator.services.mozilla.com/D67461
This commit is contained in:
Tim Nguyen 2020-03-27 22:52:32 +00:00 committed by Emilio Cobos Álvarez
parent 414edb5a4a
commit d17b3cc202
4 changed files with 77 additions and 12 deletions

View file

@ -31,6 +31,17 @@ pub struct GenericPosition<H, V> {
pub vertical: V,
}
impl<H, V> PositionComponent for Position<H, V>
where
H: PositionComponent,
V: PositionComponent,
{
#[inline]
fn is_center(&self) -> bool {
self.horizontal.is_center() && self.vertical.is_center()
}
}
pub use self::GenericPosition as Position;
impl<H, V> Position<H, V> {
@ -43,6 +54,13 @@ impl<H, V> Position<H, V> {
}
}
/// Implements a method that checks if the position is centered.
pub trait PositionComponent {
/// Returns if the position component is 50% or center.
/// For pixel lengths, it always returns false.
fn is_center(&self) -> bool;
}
/// A generic type for representing an `Auto | <position>`.
/// This is used by <offset-anchor> for now.
/// https://drafts.fxtf.org/motion-1/#offset-anchor-property