style: Rename CaretColor to ColorOrAuto for reusing.

Bug: 1460456
Reviewed-by: heycam
MozReview-Commit-ID: LD6PlNI60GC
This commit is contained in:
Xidorn Quan 2018-05-10 09:56:10 +10:00 committed by Emilio Cobos Álvarez
parent 4e6b100c7e
commit 1b236bf620
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 19 additions and 45 deletions

View file

@ -78,7 +78,7 @@ pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle, TextOve
pub use self::time::Time;
pub use self::transform::{Rotate, Scale, TimingFunction, Transform, TransformOperation};
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
pub use self::ui::{CaretColor, Cursor, MozForceBrokenImageIcon};
pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon};
#[cfg(feature = "gecko")]
pub use self::ui::CursorImage;

View file

@ -4,6 +4,7 @@
//! Computed values for UI properties
use values::{Auto, Either};
use values::computed::Number;
use values::computed::color::Color;
use values::computed::url::ComputedImageUrl;
@ -11,8 +12,8 @@ use values::generics::ui as generics;
pub use values::specified::ui::MozForceBrokenImageIcon;
/// A computed value for the `caret-color` property.
pub type CaretColor = generics::CaretColor<Color>;
/// auto | <color>
pub type ColorOrAuto = Either<Color, Auto>;
/// A computed value for the `cursor` property.
pub type Cursor = generics::Cursor<CursorImage>;

View file

@ -8,17 +8,6 @@ use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};
use style_traits::cursor::CursorKind;
/// A generic value for the `caret-color` property.
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf,
PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero,
ToComputedValue, ToCss)]
pub enum CaretColor<Color> {
/// An explicit color.
Color(Color),
/// The keyword `auto`.
Auto,
}
/// A generic value for the `cursor` property.
///
/// https://drafts.csswg.org/css-ui/#cursor

View file

@ -75,7 +75,7 @@ pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpa
pub use self::time::Time;
pub use self::transform::{Rotate, Scale, TimingFunction, Transform};
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
pub use self::ui::{CaretColor, Cursor, MozForceBrokenImageIcon};
pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon};
#[cfg(feature = "gecko")]
pub use self::ui::CursorImage;
pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent;

View file

@ -9,25 +9,14 @@ use parser::{Parse, ParserContext};
use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use style_traits::cursor::CursorKind;
use values::{Auto, Either};
use values::generics::ui as generics;
use values::specified::Number;
use values::specified::color::Color;
use values::specified::url::SpecifiedImageUrl;
/// A specified value for the `caret-color` property.
pub type CaretColor = generics::CaretColor<Color>;
impl Parse for CaretColor {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
return Ok(generics::CaretColor::Auto);
}
Ok(generics::CaretColor::Color(Color::parse(context, input)?))
}
}
/// auto | <color>
pub type ColorOrAuto = Either<Color, Auto>;
/// A specified value for the `cursor` property.
pub type Cursor = generics::Cursor<CursorImage>;