Skip to content

Commit

Permalink
Auto-generate code for grid-template-{rows,columns}
Browse files Browse the repository at this point in the history
  • Loading branch information
wafflespeanut committed May 18, 2017
1 parent 26540df commit 0c68471
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/style/properties/longhand/position.mako.rs
Expand Up @@ -319,6 +319,17 @@ ${helpers.predefined_type("object-position",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-%ss" % kind,
products="gecko",
boxed=True)}

// NOTE: The spec lists only `none | <track-list> | <auto-track-list>`, but gecko seems to support
// `subgrid <line-name-list>?` in addition to this (probably old spec). We should support it soon.
${helpers.predefined_type("grid-template-%ss" % kind,
"TrackListOrNone",
"Either::Second(None_)",
products="none",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-%ss" % kind,
boxed=True,
animation_value_type="none")}

% endfor

<%helpers:longhand name="grid-auto-flow"
Expand Down
8 changes: 8 additions & 0 deletions components/style/values/computed/mod.rs
Expand Up @@ -19,6 +19,7 @@ use super::{CSSFloat, CSSInteger, RGBA};
use super::generics::BorderRadiusSize as GenericBorderRadiusSize;
use super::specified;
use super::specified::grid::{TrackBreadth as GenericTrackBreadth, TrackSize as GenericTrackSize};
use super::specified::grid::TrackList as GenericTrackList;

pub use app_units::Au;
pub use cssparser::Color as CSSColor;
Expand Down Expand Up @@ -595,6 +596,13 @@ pub type TrackBreadth = GenericTrackBreadth<LengthOrPercentage>;
/// The computed value of a grid `<track-size>`
pub type TrackSize = GenericTrackSize<LengthOrPercentage>;

/// The computed value of a grid `<track-list>`
/// (could also be `<auto-track-list>` or `<explicit-track-list>`)
pub type TrackList = GenericTrackList<TrackSize>;

/// `<track-list> | none`
pub type TrackListOrNone = Either<TrackList, None_>;

impl ClipRectOrAuto {
/// Return an auto (default for clip-rect and image-region) value
pub fn auto() -> Self {
Expand Down
8 changes: 8 additions & 0 deletions components/style/values/specified/mod.rs
Expand Up @@ -13,6 +13,7 @@ use euclid::size::Size2D;
use itoa;
use parser::{ParserContext, Parse};
use self::grid::{TrackBreadth as GenericTrackBreadth, TrackSize as GenericTrackSize};
use self::grid::{TrackList as GenericTrackList, TrackSizeOrRepeat};
use self::url::SpecifiedUrl;
use std::ascii::AsciiExt;
use std::f32;
Expand Down Expand Up @@ -942,6 +943,13 @@ pub type TrackBreadth = GenericTrackBreadth<LengthOrPercentage>;
/// The specified value of a grid `<track-size>`
pub type TrackSize = GenericTrackSize<LengthOrPercentage>;

/// The specified value of a grid `<track-list>`
/// (could also be `<auto-track-list>` or `<explicit-track-list>`)
pub type TrackList = GenericTrackList<TrackSizeOrRepeat>;

/// `<track-list> | none`
pub type TrackListOrNone = Either<TrackList, None_>;

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)]
Expand Down

0 comments on commit 0c68471

Please sign in to comment.