Skip to content

Commit

Permalink
Auto-generate parsing/serialization code for grid-auto-{rows,columns}
Browse files Browse the repository at this point in the history
  • Loading branch information
wafflespeanut committed Feb 20, 2017
1 parent 7099743 commit 048f1f3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
10 changes: 10 additions & 0 deletions components/style/properties/longhand/position.mako.rs
Expand Up @@ -272,4 +272,14 @@ ${helpers.predefined_type("object-position",
products="gecko",
boxed=True)}
% endfor

// NOTE: According to the spec, this should handle multiple values of `<track-size>`,
// but gecko supports only a single value
${helpers.predefined_type("grid-auto-%ss" % kind,
"TrackSize",
"Default::default()",
animatable=False,
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-%ss" % kind,
products="gecko",
boxed=True)}
% endfor
7 changes: 7 additions & 0 deletions components/style/values/computed/mod.rs
Expand Up @@ -11,6 +11,7 @@ use properties::ComputedValues;
use std::fmt;
use style_traits::ToCss;
use super::{CSSFloat, RGBA, specified};
use super::specified::grid::{TrackBreadth as GenericTrackBreadth, TrackSize as GenericTrackSize};

pub use cssparser::Color as CSSColor;
pub use self::image::{AngleOrCorner, EndingShape as GradientShape, Gradient, GradientKind, Image};
Expand Down Expand Up @@ -326,6 +327,12 @@ impl ToCss for ClipRect {
/// rect(...) | auto
pub type ClipRectOrAuto = Either<ClipRect, Auto>;

#[allow(missing_docs)]
pub type TrackBreadth = GenericTrackBreadth<LengthOrPercentage>;

#[allow(missing_docs)]
pub type TrackSize = GenericTrackSize<LengthOrPercentage>;

impl ClipRectOrAuto {
/// Return an auto (default for clip-rect and image-region) value
pub fn auto() -> Self {
Expand Down
9 changes: 8 additions & 1 deletion components/style/values/specified/mod.rs
Expand Up @@ -10,6 +10,7 @@ use app_units::Au;
use cssparser::{self, Parser, Token};
use euclid::size::Size2D;
use parser::{ParserContext, Parse};
use self::grid::{TrackBreadth as GenericTrackBreadth, TrackSize as GenericTrackSize};
use self::url::SpecifiedUrl;
use std::ascii::AsciiExt;
use std::f32::consts::PI;
Expand All @@ -22,7 +23,7 @@ use super::computed::Shadow as ComputedShadow;

#[cfg(feature = "gecko")]
pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
pub use self::grid::{GridLine, TrackBreadth, TrackKeyword, TrackSize};
pub use self::grid::{GridLine, TrackKeyword};
pub use self::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
pub use self::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
pub use self::image::{SizeKeyword, VerticalDirection};
Expand Down Expand Up @@ -554,6 +555,12 @@ impl ToCss for Opacity {
#[allow(missing_docs)]
pub type UrlOrNone = Either<SpecifiedUrl, None_>;

#[allow(missing_docs)]
pub type TrackBreadth = GenericTrackBreadth<LengthOrPercentage>;

#[allow(missing_docs)]
pub type TrackSize = GenericTrackSize<LengthOrPercentage>;

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

0 comments on commit 048f1f3

Please sign in to comment.