Bug 1356941 - Use IntermediateColor for caret-color. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 24 Apr 2017 15:03:43 +0900
changeset 566923 036771108dd59f04f4ef886c715077bcd08fe160
parent 566922 d89c7c44fc50d9aefc5d33f67e432ba7fa6d7886
child 566924 d091d501be41dd3ff93c290e07f5e4462b798c3b
push id55379
push userhikezoe@mozilla.com
push dateMon, 24 Apr 2017 06:04:15 +0000
reviewersbirtles
bugs1356941
milestone55.0a1
Bug 1356941 - Use IntermediateColor for caret-color. r?birtles MozReview-Commit-ID: ERFaMfLL9tE
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/properties/longhand/pointing.mako.rs
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/web-animations/animation-model/animation-types/property-list.js
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -399,25 +399,27 @@ impl AnimationValue {
     pub fn uncompute(&self) -> PropertyDeclaration {
         use properties::longhands;
         match *self {
             % for prop in data.longhands:
                 % if prop.animatable:
                     AnimationValue::${prop.camel_case}(ref from) => {
                         PropertyDeclaration::${prop.camel_case}(
                             % if prop.boxed:
-                                Box::new(longhands::${prop.ident}::SpecifiedValue::from_computed_value(from)))
-                            % else:
+                            Box::new(
+                            % endif
                                 longhands::${prop.ident}::SpecifiedValue::from_computed_value(
                                 % if prop.is_animatable_with_computed_value:
                                     from
                                 % else:
                                     &from.into()
                                 % endif
                                 ))
+                            % if prop.boxed:
+                            )
                             % endif
                     }
                 % endif
             % endfor
         }
     }
 
     /// Construct an AnimationValue from a property declaration
@@ -2178,16 +2180,53 @@ impl Interpolate for IntermediateRGBA {
             let blue = try!((self.blue * self.alpha)
                              .interpolate(&(other.blue * other.alpha), progress))
                              * 1. / alpha;
             Ok(IntermediateRGBA::new(red, green, blue, alpha))
         }
     }
 }
 
+impl<'a> From<<&'a Either<CSSParserColor, Auto>> for Either<IntermediateColor, Auto> {
+    fn from(from: &Either<CSSParserColor, Auto>) -> Either<IntermediateColor, Auto> {
+        match *from {
+            Either::First(ref from) =>
+                match *from {
+                    CSSParserColor::RGBA(ref color) =>
+                        Either::First(IntermediateColor::IntermediateRGBA(
+                            IntermediateRGBA::new(color.red_f32(),
+                                                  color.green_f32(),
+                                                  color.blue_f32(),
+                                                  color.alpha_f32()))),
+                    CSSParserColor::CurrentColor =>
+                        Either::First(IntermediateColor::CurrentColor),
+                },
+            Either::Second(Auto) => Either::Second(Auto),
+        }
+    }
+}
+
+impl<'a> From<<&'a Either<IntermediateColor, Auto>> for Either<CSSParserColor, Auto> {
+    fn from(from: &Either<IntermediateColor, Auto>) -> Either<CSSParserColor, Auto> {
+        match *from {
+            Either::First(ref from) =>
+                match *from {
+                    IntermediateColor::IntermediateRGBA(ref color) =>
+                        Either::First(CSSParserColor::RGBA(RGBA::from_floats(color.red,
+                                                                             color.green,
+                                                                             color.blue,
+                                                                             color.alpha))),
+                    IntermediateColor::CurrentColor =>
+                        Either::First(CSSParserColor::CurrentColor),
+                },
+            Either::Second(Auto) => Either::Second(Auto),
+        }
+    }
+}
+
 
 /// We support ComputeDistance for an API in gecko to test the transition per property.
 impl ComputeDistance for AnimationValue {
     fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
         match (self, other) {
             % for prop in data.longhands:
                 % if prop.animatable:
                     % if prop.animation_value_type != "discrete":
--- a/servo/components/style/properties/longhand/pointing.mako.rs
+++ b/servo/components/style/properties/longhand/pointing.mako.rs
@@ -172,11 +172,11 @@
                          gecko_inexhaustive=True,
                          animation_value_type="none",
                          spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-user-focus)")}
 
 ${helpers.predefined_type("caret-color",
                           "ColorOrAuto",
                           "Either::Second(Auto)",
                           spec="https://drafts.csswg.org/css-ui/#caret-color",
-                          animation_value_type="ComputedValue",
+                          animation_value_type="Either<IntermediateColor, Auto>",
                           boxed=True,
                           products="gecko")}
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -211689,17 +211689,17 @@
    "eee8ff07b3ec5e83e5f18305f5bc00eb72468443",
    "testharness"
   ],
   "web-animations/animation-model/animation-types/interpolation-per-property.html": [
    "55100f7d505bc8cbc966ced0d1337ed78534a553",
    "testharness"
   ],
   "web-animations/animation-model/animation-types/property-list.js": [
-   "4fa529fe470abb7a6fb4582d0174f1696b141f87",
+   "0d7f75b05e66da256fe4d2ecb17332ec7abccfd2",
    "support"
   ],
   "web-animations/animation-model/animation-types/property-types.js": [
    "7b79c51f6dc5c33aae127406509770159815c290",
    "support"
   ],
   "web-animations/animation-model/animation-types/spacing-keyframes-filters.html": [
    "bd771a8a18245560221d92ea3495f81918c09848",
--- a/testing/web-platform/tests/web-animations/animation-model/animation-types/property-list.js
+++ b/testing/web-platform/tests/web-animations/animation-model/animation-types/property-list.js
@@ -313,16 +313,20 @@ var gCSSProperties = {
     ]
   },
   'caption-side': {
     // https://drafts.csswg.org/css-tables/#propdef-caption-side
     types: [
       { type: 'discrete', options: [ [ 'top', 'bottom' ] ] }
     ]
   },
+  'caret-color': {
+    // https://drafts.csswg.org/css-ui/#propdef-caret-color
+    types: [ 'color' ]
+  },
   'clear': {
     // https://drafts.csswg.org/css-page-floats/#propdef-clear
     types: [
       { type: 'discrete', options: [ [ 'left', 'right' ] ] }
     ]
   },
   'clip': {
     // https://drafts.fxtf.org/css-masking-1/#propdef-clip