mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Move border-image-repeat outside of mako.
This commit is contained in:
parent
b4339ab5c8
commit
50b517d0db
7 changed files with 95 additions and 59 deletions
|
@ -69,6 +69,7 @@ use style::values::computed::effects::SimpleShadow;
|
||||||
use style::values::computed::pointing::Cursor;
|
use style::values::computed::pointing::Cursor;
|
||||||
use style::values::generics::background::BackgroundSize;
|
use style::values::generics::background::BackgroundSize;
|
||||||
use style::values::generics::image::{GradientKind, Image, PaintWorklet};
|
use style::values::generics::image::{GradientKind, Image, PaintWorklet};
|
||||||
|
use style::values::specified::border::RepeatKeyword;
|
||||||
use style_traits::CSSPixel;
|
use style_traits::CSSPixel;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use style_traits::cursor::CursorKind;
|
use style_traits::cursor::CursorKind;
|
||||||
|
|
|
@ -1713,7 +1713,7 @@ fn static_assert() {
|
||||||
%>
|
%>
|
||||||
|
|
||||||
pub fn set_border_image_repeat(&mut self, v: longhands::border_image_repeat::computed_value::T) {
|
pub fn set_border_image_repeat(&mut self, v: longhands::border_image_repeat::computed_value::T) {
|
||||||
use properties::longhands::border_image_repeat::computed_value::RepeatKeyword;
|
use values::specified::border::RepeatKeyword;
|
||||||
use gecko_bindings::structs::StyleBorderImageRepeat;
|
use gecko_bindings::structs::StyleBorderImageRepeat;
|
||||||
|
|
||||||
% for i, side in enumerate(["H", "V"]):
|
% for i, side in enumerate(["H", "V"]):
|
||||||
|
@ -1735,7 +1735,7 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clone_border_image_repeat(&self) -> longhands::border_image_repeat::computed_value::T {
|
pub fn clone_border_image_repeat(&self) -> longhands::border_image_repeat::computed_value::T {
|
||||||
use properties::longhands::border_image_repeat::computed_value::RepeatKeyword;
|
use values::specified::border::RepeatKeyword;
|
||||||
use gecko_bindings::structs::StyleBorderImageRepeat;
|
use gecko_bindings::structs::StyleBorderImageRepeat;
|
||||||
|
|
||||||
% for side in ["H", "V"]:
|
% for side in ["H", "V"]:
|
||||||
|
|
|
@ -101,60 +101,15 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
|
||||||
flags="APPLIES_TO_FIRST_LETTER",
|
flags="APPLIES_TO_FIRST_LETTER",
|
||||||
boxed=True)}
|
boxed=True)}
|
||||||
|
|
||||||
<%helpers:longhand name="border-image-repeat" animation_value_type="discrete"
|
${helpers.predefined_type(
|
||||||
flags="APPLIES_TO_FIRST_LETTER"
|
"border-image-repeat",
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#border-image-repeat">
|
"BorderImageRepeat",
|
||||||
pub mod computed_value {
|
"computed::BorderImageRepeat::stretch()",
|
||||||
pub use super::RepeatKeyword;
|
initial_specified_value="specified::BorderImageRepeat::stretch()",
|
||||||
|
animation_value_type="discrete",
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
spec="https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat",
|
||||||
pub struct T(pub RepeatKeyword, pub RepeatKeyword);
|
flags="APPLIES_TO_FIRST_LETTER",
|
||||||
}
|
)}
|
||||||
|
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
|
||||||
pub struct SpecifiedValue(pub RepeatKeyword,
|
|
||||||
pub Option<RepeatKeyword>);
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
|
|
||||||
pub enum RepeatKeyword {
|
|
||||||
Stretch,
|
|
||||||
Repeat,
|
|
||||||
Round,
|
|
||||||
Space,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
|
||||||
computed_value::T(RepeatKeyword::Stretch, RepeatKeyword::Stretch)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
|
||||||
SpecifiedValue(RepeatKeyword::Stretch, None)
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToComputedValue for SpecifiedValue {
|
|
||||||
type ComputedValue = computed_value::T;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn to_computed_value(&self, _context: &Context) -> computed_value::T {
|
|
||||||
computed_value::T(self.0, self.1.unwrap_or(self.0))
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
fn from_computed_value(computed: &computed_value::T) -> Self {
|
|
||||||
SpecifiedValue(computed.0, Some(computed.1))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
|
||||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
|
||||||
let first = RepeatKeyword::parse(input)?;
|
|
||||||
let second = input.try(RepeatKeyword::parse).ok();
|
|
||||||
|
|
||||||
Ok(SpecifiedValue(first, second))
|
|
||||||
}
|
|
||||||
</%helpers:longhand>
|
|
||||||
|
|
||||||
${helpers.predefined_type("border-image-width", "BorderImageWidth",
|
${helpers.predefined_type("border-image-width", "BorderImageWidth",
|
||||||
initial_value="computed::BorderImageWidth::all(computed::BorderImageSideWidth::one())",
|
initial_value="computed::BorderImageWidth::all(computed::BorderImageSideWidth::one())",
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
//! Computed types for CSS values related to borders.
|
//! Computed types for CSS values related to borders.
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
|
use std::fmt::{self, Write};
|
||||||
|
use style_traits::{ToCss, CssWriter};
|
||||||
use values::animated::ToAnimatedZero;
|
use values::animated::ToAnimatedZero;
|
||||||
use values::computed::{Number, NumberOrPercentage};
|
use values::computed::{Context, Number, NumberOrPercentage, ToComputedValue};
|
||||||
use values::computed::length::{LengthOrPercentage, NonNegativeLength};
|
use values::computed::length::{LengthOrPercentage, NonNegativeLength};
|
||||||
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
|
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
|
||||||
use values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth;
|
use values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth;
|
||||||
|
@ -15,6 +17,7 @@ use values::generics::border::BorderRadius as GenericBorderRadius;
|
||||||
use values::generics::border::BorderSpacing as GenericBorderSpacing;
|
use values::generics::border::BorderSpacing as GenericBorderSpacing;
|
||||||
use values::generics::rect::Rect;
|
use values::generics::rect::Rect;
|
||||||
use values::generics::size::Size;
|
use values::generics::size::Size;
|
||||||
|
use values::specified::border::{BorderImageRepeat as SpecifiedBorderImageRepeat, RepeatKeyword};
|
||||||
|
|
||||||
/// A computed value for the `border-image-width` property.
|
/// A computed value for the `border-image-width` property.
|
||||||
pub type BorderImageWidth = Rect<BorderImageSideWidth>;
|
pub type BorderImageWidth = Rect<BorderImageSideWidth>;
|
||||||
|
@ -81,3 +84,44 @@ impl ToAnimatedZero for BorderCornerRadius {
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The computed value of the `border-image-repeat` property:
|
||||||
|
///
|
||||||
|
/// https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat
|
||||||
|
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
||||||
|
pub struct BorderImageRepeat(pub RepeatKeyword, pub RepeatKeyword);
|
||||||
|
|
||||||
|
impl BorderImageRepeat {
|
||||||
|
/// Returns the `stretch` value.
|
||||||
|
pub fn stretch() -> Self {
|
||||||
|
BorderImageRepeat(RepeatKeyword::Stretch, RepeatKeyword::Stretch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for BorderImageRepeat {
|
||||||
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||||
|
where
|
||||||
|
W: Write,
|
||||||
|
{
|
||||||
|
self.0.to_css(dest)?;
|
||||||
|
if self.0 != self.1 {
|
||||||
|
dest.write_str(" ")?;
|
||||||
|
self.1.to_css(dest)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToComputedValue for SpecifiedBorderImageRepeat {
|
||||||
|
type ComputedValue = BorderImageRepeat;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_computed_value(&self, _: &Context) -> Self::ComputedValue {
|
||||||
|
BorderImageRepeat(self.0, self.1.unwrap_or(self.0))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||||
|
SpecifiedBorderImageRepeat(computed.0, Some(computed.1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub use self::align::{AlignItems, AlignContent, JustifyContent, SelfAlignment, J
|
||||||
pub use self::align::{AlignSelf, JustifySelf};
|
pub use self::align::{AlignSelf, JustifySelf};
|
||||||
pub use self::angle::Angle;
|
pub use self::angle::Angle;
|
||||||
pub use self::background::{BackgroundSize, BackgroundRepeat};
|
pub use self::background::{BackgroundSize, BackgroundRepeat};
|
||||||
pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageSideWidth};
|
pub use self::border::{BorderImageRepeat, BorderImageSlice, BorderImageWidth, BorderImageSideWidth};
|
||||||
pub use self::border::{BorderRadius, BorderCornerRadius, BorderSpacing};
|
pub use self::border::{BorderRadius, BorderCornerRadius, BorderSpacing};
|
||||||
pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVariantAlternates};
|
pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVariantAlternates};
|
||||||
pub use self::font::{FontFamily, FontLanguageOverride, FontVariantSettings, FontVariantEastAsian};
|
pub use self::font::{FontFamily, FontLanguageOverride, FontVariantSettings, FontVariantEastAsian};
|
||||||
|
|
|
@ -171,3 +171,39 @@ impl Parse for BorderSpacing {
|
||||||
}).map(GenericBorderSpacing)
|
}).map(GenericBorderSpacing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A single border-image-repeat keyword.
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
|
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
|
||||||
|
pub enum RepeatKeyword {
|
||||||
|
Stretch,
|
||||||
|
Repeat,
|
||||||
|
Round,
|
||||||
|
Space,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The specified value for the `border-image-repeat` property.
|
||||||
|
///
|
||||||
|
/// https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat
|
||||||
|
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||||
|
pub struct BorderImageRepeat(pub RepeatKeyword, pub Option<RepeatKeyword>);
|
||||||
|
|
||||||
|
impl BorderImageRepeat {
|
||||||
|
/// Returns the `stretch` value.
|
||||||
|
#[inline]
|
||||||
|
pub fn stretch() -> Self {
|
||||||
|
BorderImageRepeat(RepeatKeyword::Stretch, None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Parse for BorderImageRepeat {
|
||||||
|
fn parse<'i, 't>(
|
||||||
|
_context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
let horizontal = RepeatKeyword::parse(input)?;
|
||||||
|
let vertical = input.try(RepeatKeyword::parse).ok();
|
||||||
|
Ok(BorderImageRepeat(horizontal, vertical))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub use self::align::{AlignContent, JustifyContent, AlignItems, ContentDistribut
|
||||||
pub use self::align::{AlignSelf, JustifySelf};
|
pub use self::align::{AlignSelf, JustifySelf};
|
||||||
pub use self::background::{BackgroundRepeat, BackgroundSize};
|
pub use self::background::{BackgroundRepeat, BackgroundSize};
|
||||||
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||||
pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
|
pub use self::border::{BorderImageRepeat, BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
|
||||||
pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVariantAlternates};
|
pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVariantAlternates};
|
||||||
pub use self::font::{FontFamily, FontLanguageOverride, FontVariantSettings, FontVariantEastAsian};
|
pub use self::font::{FontFamily, FontLanguageOverride, FontVariantSettings, FontVariantEastAsian};
|
||||||
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};
|
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue