mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Omit center positions in conic/radial gradient serialization.
Differential Revision: https://phabricator.services.mozilla.com/D67461
This commit is contained in:
parent
414edb5a4a
commit
d17b3cc202
4 changed files with 77 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue