mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Implement style system support for Masonry layout.
This implements support for this CSS Masonry layout proposal: https://github.com/w3c/csswg-drafts/issues/4650 I've intentionally left out a shorthand (place-tracks?) for now until we have a draft CSS spec for this. Differential Revision: https://phabricator.services.mozilla.com/D67061
This commit is contained in:
parent
21d48e00cc
commit
6f58c66589
11 changed files with 295 additions and 30 deletions
|
@ -171,16 +171,6 @@ impl ContentDistribution {
|
|||
Self { primary }
|
||||
}
|
||||
|
||||
fn from_bits(bits: u16) -> Self {
|
||||
Self {
|
||||
primary: AlignFlags::from_bits_truncate(bits as u8),
|
||||
}
|
||||
}
|
||||
|
||||
fn as_bits(&self) -> u16 {
|
||||
self.primary.bits() as u16
|
||||
}
|
||||
|
||||
/// Returns whether this value is a <baseline-position>.
|
||||
pub fn is_baseline_position(&self) -> bool {
|
||||
matches!(
|
||||
|
@ -292,6 +282,41 @@ impl SpecifiedValueInfo for AlignContent {
|
|||
}
|
||||
}
|
||||
|
||||
/// Value for the `align-tracks` property.
|
||||
///
|
||||
/// <https://github.com/w3c/csswg-drafts/issues/4650>
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
#[css(comma)]
|
||||
pub struct AlignTracks(
|
||||
#[css(iterable, if_empty = "normal")]
|
||||
pub crate::OwnedSlice<AlignContent>
|
||||
);
|
||||
|
||||
impl Parse for AlignTracks {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let values = input.parse_comma_separated(|input| {
|
||||
AlignContent::parse(context, input)
|
||||
})?;
|
||||
Ok(AlignTracks(values.into()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Value for the `justify-content` property.
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-align/#propdef-justify-content>
|
||||
|
@ -329,18 +354,38 @@ impl SpecifiedValueInfo for JustifyContent {
|
|||
ContentDistribution::list_keywords(f, AxisDirection::Inline);
|
||||
}
|
||||
}
|
||||
/// Value for the `justify-tracks` property.
|
||||
///
|
||||
/// <https://github.com/w3c/csswg-drafts/issues/4650>
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
#[css(comma)]
|
||||
pub struct JustifyTracks(
|
||||
#[css(iterable, if_empty = "normal")]
|
||||
pub crate::OwnedSlice<JustifyContent>
|
||||
);
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl From<u16> for JustifyContent {
|
||||
fn from(bits: u16) -> Self {
|
||||
JustifyContent(ContentDistribution::from_bits(bits))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl From<JustifyContent> for u16 {
|
||||
fn from(v: JustifyContent) -> u16 {
|
||||
v.0.as_bits()
|
||||
impl Parse for JustifyTracks {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let values = input.parse_comma_separated(|input| {
|
||||
JustifyContent::parse(context, input)
|
||||
})?;
|
||||
Ok(JustifyTracks(values.into()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue