From 0c68471b5eaf8a9eb2fabe761dc919712ecf32ce Mon Sep 17 00:00:00 2001 From: Ravi Shankar Date: Wed, 22 Mar 2017 11:10:11 +0530 Subject: [PATCH] Auto-generate code for grid-template-{rows,columns} --- components/style/properties/longhand/position.mako.rs | 11 +++++++++++ components/style/values/computed/mod.rs | 8 ++++++++ components/style/values/specified/mod.rs | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 370a538e893c..83de256d6af6 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -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 | | `, but gecko seems to support + // `subgrid ?` 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" diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 02a71c6b313c..7101192be1a1 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -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; @@ -595,6 +596,13 @@ pub type TrackBreadth = GenericTrackBreadth; /// The computed value of a grid `` pub type TrackSize = GenericTrackSize; +/// The computed value of a grid `` +/// (could also be `` or ``) +pub type TrackList = GenericTrackList; + +/// ` | none` +pub type TrackListOrNone = Either; + impl ClipRectOrAuto { /// Return an auto (default for clip-rect and image-region) value pub fn auto() -> Self { diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 8726cb15334b..3fb46c473b93 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -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; @@ -942,6 +943,13 @@ pub type TrackBreadth = GenericTrackBreadth; /// The specified value of a grid `` pub type TrackSize = GenericTrackSize; +/// The specified value of a grid `` +/// (could also be `` or ``) +pub type TrackList = GenericTrackList; + +/// ` | none` +pub type TrackListOrNone = Either; + #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[allow(missing_docs)]