summaryrefslogtreecommitdiffstats
path: root/servo/components/style/values/generics/box.rs
diff options
context:
space:
mode:
Diffstat (limited to 'servo/components/style/values/generics/box.rs')
-rw-r--r--servo/components/style/values/generics/box.rs132
1 files changed, 132 insertions, 0 deletions
diff --git a/servo/components/style/values/generics/box.rs b/servo/components/style/values/generics/box.rs
new file mode 100644
index 0000000000..5d6e8e2503
--- /dev/null
+++ b/servo/components/style/values/generics/box.rs
@@ -0,0 +1,132 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+//! Generic types for box properties.
+
+use crate::values::animated::ToAnimatedZero;
+
+#[derive(
+ Animate,
+ Clone,
+ ComputeSquaredDistance,
+ Copy,
+ Debug,
+ FromPrimitive,
+ MallocSizeOf,
+ Parse,
+ PartialEq,
+ SpecifiedValueInfo,
+ ToComputedValue,
+ ToCss,
+ ToResolvedValue,
+ ToShmem,
+)]
+#[repr(u8)]
+#[allow(missing_docs)]
+pub enum VerticalAlignKeyword {
+ Baseline,
+ Sub,
+ Super,
+ Top,
+ TextTop,
+ Middle,
+ Bottom,
+ TextBottom,
+ #[cfg(feature = "gecko")]
+ MozMiddleWithBaseline,
+}
+
+/// A generic value for the `vertical-align` property.
+#[derive(
+ Animate,
+ Clone,
+ ComputeSquaredDistance,
+ Copy,
+ Debug,
+ MallocSizeOf,
+ PartialEq,
+ SpecifiedValueInfo,
+ ToComputedValue,
+ ToCss,
+ ToResolvedValue,
+ ToShmem,
+)]
+#[repr(C, u8)]
+pub enum GenericVerticalAlign<LengthPercentage> {
+ /// One of the vertical-align keywords.
+ Keyword(VerticalAlignKeyword),
+ /// `<length-percentage>`
+ Length(LengthPercentage),
+}
+
+pub use self::GenericVerticalAlign as VerticalAlign;
+
+impl<L> VerticalAlign<L> {
+ /// Returns `baseline`.
+ #[inline]
+ pub fn baseline() -> Self {
+ VerticalAlign::Keyword(VerticalAlignKeyword::Baseline)
+ }
+}
+
+impl<L> ToAnimatedZero for VerticalAlign<L> {
+ fn to_animated_zero(&self) -> Result<Self, ()> {
+ Err(())
+ }
+}
+
+/// https://drafts.csswg.org/css-animations/#animation-iteration-count
+#[derive(
+ Clone,
+ Debug,
+ MallocSizeOf,
+ PartialEq,
+ SpecifiedValueInfo,
+ ToComputedValue,
+ ToCss,
+ ToResolvedValue,
+ ToShmem,
+)]
+pub enum AnimationIterationCount<Number> {
+ /// A `<number>` value.
+ Number(Number),
+ /// The `infinite` keyword.
+ Infinite,
+}
+
+/// A generic value for the `perspective` property.
+#[derive(
+ Animate,
+ Clone,
+ ComputeSquaredDistance,
+ Copy,
+ Debug,
+ MallocSizeOf,
+ Parse,
+ PartialEq,
+ SpecifiedValueInfo,
+ ToAnimatedValue,
+ ToAnimatedZero,
+ ToComputedValue,
+ ToCss,
+ ToResolvedValue,
+ ToShmem,
+)]
+#[repr(C, u8)]
+pub enum GenericPerspective<NonNegativeLength> {
+ /// A non-negative length.
+ Length(NonNegativeLength),
+ /// The keyword `none`.
+ None,
+}
+
+pub use self::GenericPerspective as Perspective;
+
+impl<L> Perspective<L> {
+ /// Returns `none`.
+ #[inline]
+ pub fn none() -> Self {
+ Perspective::None
+ }
+}