mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Merge the two scrollbar color properties into scrollbar-color.
Differential Revision: https://phabricator.services.mozilla.com/D6115
This commit is contained in:
parent
5c66290142
commit
0bcffa7094
5 changed files with 94 additions and 16 deletions
|
@ -20,3 +20,6 @@ pub type Cursor = generics::Cursor<CursorImage>;
|
|||
|
||||
/// A computed value for item of `image cursors`.
|
||||
pub type CursorImage = generics::CursorImage<ComputedImageUrl, Number>;
|
||||
|
||||
/// A computed value for `scrollbar-color` property.
|
||||
pub type ScrollbarColor = generics::ScrollbarColor<Color>;
|
||||
|
|
|
@ -67,3 +67,27 @@ impl<ImageUrl: ToCss, Number: ToCss> ToCss for CursorImage<ImageUrl, Number> {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// A generic value for `scrollbar-color` property.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum ScrollbarColor<Color> {
|
||||
/// `auto`
|
||||
Auto,
|
||||
/// `<color>{2}`
|
||||
Colors {
|
||||
/// First `<color>`, for color of the scrollbar thumb.
|
||||
thumb: Color,
|
||||
/// Second `<color>`, for color of the scrollbar track.
|
||||
track: Color,
|
||||
}
|
||||
}
|
||||
|
||||
impl<Color> Default for ScrollbarColor<Color> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ScrollbarColor::Auto
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,3 +122,21 @@ impl From<MozForceBrokenImageIcon> for u8 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A specified value for `scrollbar-color` property
|
||||
pub type ScrollbarColor = generics::ScrollbarColor<Color>;
|
||||
|
||||
impl Parse for ScrollbarColor {
|
||||
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::ScrollbarColor::Auto);
|
||||
}
|
||||
Ok(generics::ScrollbarColor::Colors {
|
||||
thumb: Color::parse(context, input)?,
|
||||
track: Color::parse(context, input)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue