Auto merge of #15465 - austinprete:caret-color, r=Wafflespeanut

Implement parsing/serialization for caret-color

<!-- Please describe your changes on the following line: -->
This pull request implements parsing and serialization for the caret-color CSS property, per issue #15309 .

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15309

<!-- Either: -->
- [X] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15465)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-03-05 23:53:26 -08:00 committed by GitHub
commit 511b82eea3
5 changed files with 57 additions and 2 deletions

View file

@ -29,11 +29,12 @@ use std::fmt;
use style_traits::ToCss;
use super::ComputedValues;
use values::CSSFloat;
use values::Either;
use values::{Auto, Either};
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
use values::computed::{BorderRadiusSize, ClipRect, LengthOrNone};
use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
use values::computed::{MaxLength, MinLength};
use values::computed::ColorOrAuto;
use values::computed::position::{HorizontalPosition, Position, VerticalPosition};
use values::computed::ToComputedValue;
use values::specified::Angle as SpecifiedAngle;
@ -1796,3 +1797,21 @@ impl Interpolate for TransformList {
}
}
/// https://drafts.csswg.org/css-transitions-1/#animtype-color
impl Interpolate for ColorOrAuto {
#[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) {
(Either::First(ref this), Either::First(ref other)) => {
this.interpolate(&other, progress).map(Either::First)
},
(Either::Second(Auto), Either::Second(Auto)) => {
Ok(Either::Second(Auto))
},
_ => {
let interpolated = if progress < 0.5 { *self } else { *other };
Ok(interpolated)
}
}
}
}

View file

@ -30,3 +30,10 @@ ${helpers.single_keyword("-moz-window-dragging", "default drag no-drag", product
gecko_enum_prefix="StyleWindowDragging",
animatable=False,
spec="None (Nonstandard Firefox-only property)")}
${helpers.predefined_type("caret-color",
"ColorOrAuto",
"Either::Second(Auto)",
spec="https://drafts.csswg.org/css-ui/#caret-color",
animatable="True",
products="none")}

View file

@ -363,3 +363,6 @@ impl ClipRectOrAuto {
}
}
}
/// <color> | auto
pub type ColorOrAuto = Either<CSSColor, Auto>;

View file

@ -998,3 +998,6 @@ impl Parse for ClipRect {
/// rect(...) | auto
pub type ClipRectOrAuto = Either<ClipRect, Auto>;
/// <color> | auto
pub type ColorOrAuto = Either<CSSColor, Auto>;