/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Generic types for CSS values related to borders.
usecrate::derives::*; usecrate::values::generics::rect::Rect; usecrate::values::generics::size::Size2D; usecrate::Zero; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss};
/// A generic value for a single side of a `border-image-width` property. #[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
ToTyped,
)] #[repr(C, u8)] pubenum GenericBorderImageSideWidth<LP, N> { /// `<number>` /// /// NOTE: Numbers need to be before length-percentagess, in order to parse /// them first, since `0` should be a number, not the `0px` length.
Number(N), /// `<length-or-percentage>`
LengthPercentage(LP), /// `auto`
Auto,
}
pubuseself::GenericBorderImageSideWidth as BorderImageSideWidth;
/// A generic value for the `border-image-slice` property. #[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] #[repr(C)] pubstruct GenericBorderImageSlice<NumberOrPercentage> { /// The offsets. #[css(field_bound)] pub offsets: Rect<NumberOrPercentage>, /// Whether to fill the middle part. #[animation(constant)] #[css(represents_keyword)] pub fill: bool,
}
pubuseself::GenericBorderImageSlice as BorderImageSlice;
/// A generic value for the `border-*-radius` longhand properties. #[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
Deserialize,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
Serialize,
ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
ToTyped,
)] #[repr(C)] #[typed(todo_derive_fields)] pubstruct GenericBorderCornerRadius<L>( #[css(field_bound)] #[shmem(field_bound)] pub Size2D<L>,
);
pubuseself::GenericBorderCornerRadius as BorderCornerRadius;
/// A generic value for `border-radius` and `inset()`. /// /// <https://drafts.csswg.org/css-backgrounds-3/#border-radius> #[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
Deserialize,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
Serialize,
ToAnimatedValue,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] #[repr(C)] pubstruct GenericBorderRadius<LengthPercentage> { /// The top left radius. #[shmem(field_bound)] pub top_left: GenericBorderCornerRadius<LengthPercentage>, /// The top right radius. pub top_right: GenericBorderCornerRadius<LengthPercentage>, /// The bottom right radius. pub bottom_right: GenericBorderCornerRadius<LengthPercentage>, /// The bottom left radius. pub bottom_left: GenericBorderCornerRadius<LengthPercentage>,
}
impl<L> ToCss for BorderRadius<L> where
L: PartialEq + ToCss,
{ fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where
W: Write,
{ let BorderRadius {
top_left: BorderCornerRadius(ref tl),
top_right: BorderCornerRadius(ref tr),
bottom_right: BorderCornerRadius(ref br),
bottom_left: BorderCornerRadius(ref bl),
} = *self;
let widths = Rect::new(&tl.width, &tr.width, &br.width, &bl.width); let heights = Rect::new(&tl.height, &tr.height, &br.height, &bl.height);
Self::serialize_rects(widths, heights, dest)
}
}
/// A generic value for the four corners of `corner-shape`. /// /// This mirrors the per-corner layout of `BorderRadius` so it can be used as /// the underlying storage for the four `corner-*-*-shape` longhands and their /// shorthand `corner-shape`. /// /// <https://drafts.csswg.org/css-borders-4/#corner-shaping> #[derive(Clone)] #[repr(C)] pubstruct GenericCornerShapeRect<S> { /// The top-left corner shape. pub top_left: S, /// The top-right corner shape. pub top_right: S, /// The bottom-right corner shape. pub bottom_right: S, /// The bottom-left corner shape. pub bottom_left: S,
}
pubuseself::GenericCornerShapeRect as CornerShapeRect;
impl<S: Clone> CornerShapeRect<S> { /// Construct from a single value applied to all four corners. #[inline] pubfn all(s: S) -> Self { Self {
top_left: s.clone(),
top_right: s.clone(),
bottom_right: s.clone(),
bottom_left: s,
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.