mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
style: Support multiple track sizes for grid-auto-{columns|rows}.
Support `<track-size>+` on the implicit track sizing properties, grid-auto-columns and grid-auto-rows. Differential Revision: https://phabricator.services.mozilla.com/D38408
This commit is contained in:
parent
69191d8b8c
commit
29f6db4d16
6 changed files with 76 additions and 22 deletions
|
@ -290,16 +290,17 @@ impl<L> TrackSize<L> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<L> Default for TrackSize<L> {
|
||||
fn default() -> Self {
|
||||
TrackSize::Breadth(TrackBreadth::Auto)
|
||||
impl<L: PartialEq> TrackSize<L> {
|
||||
/// Return true if it is `auto`.
|
||||
#[inline]
|
||||
pub fn is_auto(&self) -> bool {
|
||||
*self == TrackSize::Breadth(TrackBreadth::Auto)
|
||||
}
|
||||
}
|
||||
|
||||
impl<L: PartialEq> TrackSize<L> {
|
||||
/// Returns true if current TrackSize is same as default.
|
||||
pub fn is_default(&self) -> bool {
|
||||
*self == TrackSize::default()
|
||||
impl<L> Default for TrackSize<L> {
|
||||
fn default() -> Self {
|
||||
TrackSize::Breadth(TrackBreadth::Auto)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,6 +335,39 @@ impl<L: ToCss> ToCss for TrackSize<L> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A `<track-size>+`.
|
||||
/// We use the empty slice as `auto`, and always parse `auto` as an empty slice.
|
||||
/// This means it's impossible to have a slice containing only one auto item.
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
Default,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
pub struct GenericImplicitGridTracks<T>(
|
||||
#[css(if_empty = "auto", iterable)] pub crate::OwnedSlice<T>,
|
||||
);
|
||||
|
||||
pub use self::GenericImplicitGridTracks as ImplicitGridTracks;
|
||||
|
||||
impl<T: fmt::Debug + Default + PartialEq> ImplicitGridTracks<T> {
|
||||
/// Returns true if current value is same as its initial value (i.e. auto).
|
||||
pub fn is_initial(&self) -> bool {
|
||||
debug_assert_ne!(
|
||||
*self,
|
||||
ImplicitGridTracks(crate::OwnedSlice::from(vec![Default::default()]))
|
||||
);
|
||||
self.0.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function for serializing identifiers with a prefix and suffix, used
|
||||
/// for serializing <line-names> (in grid).
|
||||
pub fn concat_serialize_idents<W>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue