mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Make text-shadow and box-shadow use SimpleShadow
This commit is contained in:
parent
65ff4a399c
commit
201d7e79e7
14 changed files with 414 additions and 434 deletions
|
@ -4,9 +4,23 @@
|
|||
|
||||
//! Generic types for CSS values related to effects.
|
||||
|
||||
use std::fmt;
|
||||
use style_traits::values::{SequenceWriter, ToCss};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
/// A generic value for a single `box-shadow`.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
|
||||
pub struct BoxShadow<Color, SizeLength, ShapeLength> {
|
||||
/// The base shadow.
|
||||
pub base: SimpleShadow<Color, SizeLength, ShapeLength>,
|
||||
/// The spread radius.
|
||||
pub spread: ShapeLength,
|
||||
/// Whether this is an inset box shadow.
|
||||
pub inset: bool,
|
||||
}
|
||||
|
||||
/// A generic value for a single `filter`.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
|
||||
|
@ -62,3 +76,25 @@ pub struct SimpleShadow<Color, SizeLength, ShapeLength> {
|
|||
/// Blur radius.
|
||||
pub blur: ShapeLength,
|
||||
}
|
||||
|
||||
impl<Color, SizeLength, ShapeLength> ToCss for BoxShadow<Color, SizeLength, ShapeLength>
|
||||
where
|
||||
Color: ToCss,
|
||||
SizeLength: ToCss,
|
||||
ShapeLength: ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
{
|
||||
let mut writer = SequenceWriter::new(&mut *dest, " ");
|
||||
writer.item(&self.base)?;
|
||||
writer.item(&self.spread)?;
|
||||
}
|
||||
if self.inset {
|
||||
dest.write_str(" inset")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue