mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
style: Rename CaretColor to ColorOrAuto for reusing.
Bug: 1460456 Reviewed-by: heycam MozReview-Commit-ID: LD6PlNI60GC
This commit is contained in:
parent
4e6b100c7e
commit
1b236bf620
7 changed files with 19 additions and 45 deletions
|
@ -6,8 +6,9 @@
|
||||||
|
|
||||||
use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
|
use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
|
||||||
use gecko_bindings::structs::{nscolor, StyleComplexColor};
|
use gecko_bindings::structs::{nscolor, StyleComplexColor};
|
||||||
|
use values::{Auto, Either};
|
||||||
use values::computed::Color as ComputedColor;
|
use values::computed::Color as ComputedColor;
|
||||||
use values::generics::ui::CaretColor;
|
use values::computed::ui::ColorOrAuto;
|
||||||
|
|
||||||
impl From<nscolor> for StyleComplexColor {
|
impl From<nscolor> for StyleComplexColor {
|
||||||
fn from(other: nscolor) -> Self {
|
fn from(other: nscolor) -> Self {
|
||||||
|
@ -59,27 +60,21 @@ impl From<StyleComplexColor> for ComputedColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Color> From<CaretColor<Color>> for StyleComplexColor
|
impl From<ColorOrAuto> for StyleComplexColor {
|
||||||
where
|
fn from(other: ColorOrAuto) -> Self {
|
||||||
Color: Into<StyleComplexColor>,
|
|
||||||
{
|
|
||||||
fn from(other: CaretColor<Color>) -> Self {
|
|
||||||
match other {
|
match other {
|
||||||
CaretColor::Color(color) => color.into(),
|
Either::First(color) => color.into(),
|
||||||
CaretColor::Auto => StyleComplexColor::auto(),
|
Either::Second(_) => StyleComplexColor::auto(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Color> From<StyleComplexColor> for CaretColor<Color>
|
impl From<StyleComplexColor> for ColorOrAuto {
|
||||||
where
|
|
||||||
StyleComplexColor: Into<Color>,
|
|
||||||
{
|
|
||||||
fn from(other: StyleComplexColor) -> Self {
|
fn from(other: StyleComplexColor) -> Self {
|
||||||
if !other.mIsAuto {
|
if !other.mIsAuto {
|
||||||
CaretColor::Color(other.into())
|
Either::First(other.into())
|
||||||
} else {
|
} else {
|
||||||
CaretColor::Auto
|
Either::Second(Auto)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,8 @@ ${helpers.single_keyword("-moz-user-focus",
|
||||||
|
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
"caret-color",
|
"caret-color",
|
||||||
"CaretColor",
|
"ColorOrAuto",
|
||||||
"generics::ui::CaretColor::Auto",
|
"Either::Second(Auto)",
|
||||||
spec="https://drafts.csswg.org/css-ui/#caret-color",
|
spec="https://drafts.csswg.org/css-ui/#caret-color",
|
||||||
animation_value_type="AnimatedCaretColor",
|
animation_value_type="AnimatedCaretColor",
|
||||||
ignored_when_colors_disabled=True,
|
ignored_when_colors_disabled=True,
|
||||||
|
|
|
@ -78,7 +78,7 @@ pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle, TextOve
|
||||||
pub use self::time::Time;
|
pub use self::time::Time;
|
||||||
pub use self::transform::{Rotate, Scale, TimingFunction, Transform, TransformOperation};
|
pub use self::transform::{Rotate, Scale, TimingFunction, Transform, TransformOperation};
|
||||||
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
||||||
pub use self::ui::{CaretColor, Cursor, MozForceBrokenImageIcon};
|
pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use self::ui::CursorImage;
|
pub use self::ui::CursorImage;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
//! Computed values for UI properties
|
//! Computed values for UI properties
|
||||||
|
|
||||||
|
use values::{Auto, Either};
|
||||||
use values::computed::Number;
|
use values::computed::Number;
|
||||||
use values::computed::color::Color;
|
use values::computed::color::Color;
|
||||||
use values::computed::url::ComputedImageUrl;
|
use values::computed::url::ComputedImageUrl;
|
||||||
|
@ -11,8 +12,8 @@ use values::generics::ui as generics;
|
||||||
|
|
||||||
pub use values::specified::ui::MozForceBrokenImageIcon;
|
pub use values::specified::ui::MozForceBrokenImageIcon;
|
||||||
|
|
||||||
/// A computed value for the `caret-color` property.
|
/// auto | <color>
|
||||||
pub type CaretColor = generics::CaretColor<Color>;
|
pub type ColorOrAuto = Either<Color, Auto>;
|
||||||
|
|
||||||
/// A computed value for the `cursor` property.
|
/// A computed value for the `cursor` property.
|
||||||
pub type Cursor = generics::Cursor<CursorImage>;
|
pub type Cursor = generics::Cursor<CursorImage>;
|
||||||
|
|
|
@ -8,17 +8,6 @@ use std::fmt::{self, Write};
|
||||||
use style_traits::{CssWriter, ToCss};
|
use style_traits::{CssWriter, ToCss};
|
||||||
use style_traits::cursor::CursorKind;
|
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.
|
/// A generic value for the `cursor` property.
|
||||||
///
|
///
|
||||||
/// https://drafts.csswg.org/css-ui/#cursor
|
/// https://drafts.csswg.org/css-ui/#cursor
|
||||||
|
|
|
@ -75,7 +75,7 @@ pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpa
|
||||||
pub use self::time::Time;
|
pub use self::time::Time;
|
||||||
pub use self::transform::{Rotate, Scale, TimingFunction, Transform};
|
pub use self::transform::{Rotate, Scale, TimingFunction, Transform};
|
||||||
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
||||||
pub use self::ui::{CaretColor, Cursor, MozForceBrokenImageIcon};
|
pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use self::ui::CursorImage;
|
pub use self::ui::CursorImage;
|
||||||
pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent;
|
pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent;
|
||||||
|
|
|
@ -9,25 +9,14 @@ use parser::{Parse, ParserContext};
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||||
use style_traits::cursor::CursorKind;
|
use style_traits::cursor::CursorKind;
|
||||||
|
use values::{Auto, Either};
|
||||||
use values::generics::ui as generics;
|
use values::generics::ui as generics;
|
||||||
use values::specified::Number;
|
use values::specified::Number;
|
||||||
use values::specified::color::Color;
|
use values::specified::color::Color;
|
||||||
use values::specified::url::SpecifiedImageUrl;
|
use values::specified::url::SpecifiedImageUrl;
|
||||||
|
|
||||||
/// A specified value for the `caret-color` property.
|
/// auto | <color>
|
||||||
pub type CaretColor = generics::CaretColor<Color>;
|
pub type ColorOrAuto = Either<Color, Auto>;
|
||||||
|
|
||||||
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)?))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A specified value for the `cursor` property.
|
/// A specified value for the `cursor` property.
|
||||||
pub type Cursor = generics::Cursor<CursorImage>;
|
pub type Cursor = generics::Cursor<CursorImage>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue