mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Rename LayerImage to ImageLayer and make it a type alias
This commit is contained in:
parent
fa5b46b6ee
commit
73f77e0a53
12 changed files with 47 additions and 101 deletions
|
@ -15,6 +15,7 @@ use servo_url::ServoUrl;
|
|||
use std::f32::consts::PI;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::{Either, None_};
|
||||
use values::generics::image::{Circle, CompatMode, Ellipse, ColorStop as GenericColorStop};
|
||||
use values::generics::image::{EndingShape as GenericEndingShape, Gradient as GenericGradient};
|
||||
use values::generics::image::{GradientItem as GenericGradientItem, GradientKind as GenericGradientKind};
|
||||
|
@ -24,6 +25,9 @@ use values::specified::{Angle, CSSColor, Length, LengthOrPercentage, NumberOrPer
|
|||
use values::specified::position::{Position, X, Y};
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
/// A specified image layer.
|
||||
pub type ImageLayer = Either<None_, Image>;
|
||||
|
||||
/// Specified values for an image according to CSS-IMAGES.
|
||||
/// https://drafts.csswg.org/css-images/#image-values
|
||||
pub type Image = GenericImage<Gradient, ImageRect>;
|
||||
|
@ -424,51 +428,3 @@ impl Parse for ColorStop {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Specified values for none | <image> | <mask-source>.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct LayerImage(pub Option<Image>);
|
||||
no_viewport_percentage!(LayerImage);
|
||||
|
||||
impl ToCss for LayerImage {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
LayerImage(Some(ref image)) => image.to_css(dest),
|
||||
LayerImage(None) => dest.write_str("none"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use super::computed::{ToComputedValue, Context};
|
||||
impl ToComputedValue for LayerImage {
|
||||
type ComputedValue = super::computed::LayerImage;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
match *self {
|
||||
LayerImage(None) => super::computed::LayerImage(None),
|
||||
LayerImage(Some(ref image)) =>
|
||||
super::computed::LayerImage(Some(image.to_computed_value(context))),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||
match *computed {
|
||||
super::computed::LayerImage(None) => LayerImage(None),
|
||||
super::computed::LayerImage(Some(ref image)) =>
|
||||
LayerImage(Some(ToComputedValue::from_computed_value(image))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for LayerImage {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
Ok(LayerImage(None))
|
||||
} else {
|
||||
Ok(LayerImage(Some(try!(Image::parse(context, input)))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue