Bug 1374233 - Part 5: Apply restrictions to column-{*} properties. draft
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 22 Jun 2017 16:43:34 +0800
changeset 599429 92e43dfd7e9b6dcc82a7f3adc8f7c213a19b5e26
parent 599428 ad59c2f1f2a7478ca7b5543240709d3f877de974
child 599430 0879451298bb4f931891c049fcdc071707243c28
push id65518
push userbmo:boris.chiou@gmail.com
push dateFri, 23 Jun 2017 04:39:24 +0000
bugs1374233
milestone56.0a1
Bug 1374233 - Part 5: Apply restrictions to column-{*} properties. For column-* properties, we need to implement Restrictable for LengthOrAuto, LengthOrNormal, and IntegerOrAuto. MozReview-Commit-ID: B4PWeR4sKDH
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/properties/longhand/column.mako.rs
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -35,16 +35,18 @@ use std::cmp;
 use style_traits::ParseError;
 use super::ComputedValues;
 use values::{Auto, CSSFloat, CustomIdent, Either};
 use values::animated::effects::{Filter as AnimatedFilter, FilterList as AnimatedFilterList};
 use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
 use values::computed::{BorderCornerRadius, ClipRect};
 use values::computed::{CalcLengthOrPercentage, Color, Context, ComputedValueAsSpecified};
 use values::computed::{LengthOrPercentage, MaxLength, MozLength, Shadow, ToComputedValue};
+use values::computed::IntegerOrAuto;
+use values::computed::length::{LengthOrAuto, LengthOrNormal};
 use values::computed::LengthOrNumber;
 use values::generics::{SVGPaint, SVGPaintKind};
 use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
 use values::generics::effects::Filter;
 use values::generics::position as generic_position;
 use values::specified::length::Percentage;
 
 
@@ -3478,8 +3480,38 @@ impl Restrictable for LengthOrNumber {
     #[inline]
     fn restrict_value(self, restriction_type: Restrictions) -> Self {
         match self {
             Either::First(length) => Either::First(length.restrict_value(restriction_type)),
             Either::Second(number) => Either::Second(number.restrict_value(restriction_type))
         }
     }
 }
+
+impl Restrictable for LengthOrAuto {
+    #[inline]
+    fn restrict_value(self, restriction_type: Restrictions) -> Self {
+        match self {
+            Either::First(length) => Either::First(length.restrict_value(restriction_type)),
+            _ => self
+        }
+    }
+}
+
+impl Restrictable for LengthOrNormal {
+    #[inline]
+    fn restrict_value(self, restriction_type: Restrictions) -> Self {
+        match self {
+            Either::First(length) => Either::First(length.restrict_value(restriction_type)),
+            _ => self
+        }
+    }
+}
+
+impl Restrictable for IntegerOrAuto {
+    #[inline]
+    fn restrict_value(self, restriction_type: Restrictions) -> Self {
+        match self {
+            Either::First(integer) => Either::First(integer.restrict_value(restriction_type)),
+            _ => self
+        }
+    }
+}
--- a/servo/components/style/properties/longhand/column.mako.rs
+++ b/servo/components/style/properties/longhand/column.mako.rs
@@ -8,51 +8,55 @@
 
 ${helpers.predefined_type("column-width",
                           "length::LengthOrAuto",
                           "Either::Second(Auto)",
                           initial_specified_value="Either::Second(Auto)",
                           parse_method="parse_non_negative_length",
                           extra_prefixes="moz",
                           animation_value_type="ComputedValue",
+                          restriction_type="Restrictions::NonNegative",
                           experimental=True,
                           spec="https://drafts.csswg.org/css-multicol/#propdef-column-width")}
 
 
 ${helpers.predefined_type("column-count",
                           "IntegerOrAuto",
                           "Either::Second(Auto)",
                           parse_method="parse_positive",
                           initial_specified_value="Either::Second(Auto)",
                           experimental="True",
                           animation_value_type="ComputedValue",
+                          restriction_type="Restrictions::AtLeastOne",
                           extra_prefixes="moz",
                           spec="https://drafts.csswg.org/css-multicol/#propdef-column-count")}
 
 ${helpers.predefined_type("column-gap",
                           "length::LengthOrNormal",
                           "Either::Second(Normal)",
                           parse_method='parse_non_negative_length',
                           extra_prefixes="moz",
                           experimental=True,
                           animation_value_type="ComputedValue",
+                          restriction_type="Restrictions::NonNegative",
                           spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap")}
 
 ${helpers.single_keyword("column-fill", "balance auto", extra_prefixes="moz",
                          products="gecko", animation_value_type="discrete",
                          spec="https://drafts.csswg.org/css-multicol/#propdef-column-fill")}
 
 ${helpers.predefined_type("column-rule-width",
                           "BorderSideWidth",
                           "Au::from_px(3)",
                           initial_specified_value="specified::BorderSideWidth::Medium",
                           computed_type="::app_units::Au",
                           products="gecko",
                           spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width",
                           animation_value_type="ComputedValue",
+                          restriction_type="Restrictions::NonNegative",
                           extra_prefixes="moz")}
 
 // https://drafts.csswg.org/css-multicol-1/#crc
 ${helpers.predefined_type("column-rule-color", "Color",
                           "computed_value::T::currentcolor()",
                           initial_specified_value="specified::Color::currentcolor()",
                           products="gecko", animation_value_type="IntermediateColor", extra_prefixes="moz",
                           need_clone=True, ignored_when_colors_disabled=True,