Skip to content

Instantly share code, notes, and snippets.

@BorisChiou
Created October 17, 2018 18:04
Show Gist options
  • Save BorisChiou/c15171320e24efefb04efedb4de9bbf4 to your computer and use it in GitHub Desktop.
Save BorisChiou/c15171320e24efefb04efedb4de9bbf4 to your computer and use it in GitHub Desktop.
Diff file for generic enum
diff --git a/servo/components/style/cbindgen.toml b/servo/components/style/cbindgen.toml
index 8bcba69c0570..3bb5a75c2307 100644
--- a/servo/components/style/cbindgen.toml
+++ b/servo/components/style/cbindgen.toml
@@ -43,12 +43,13 @@ include = [
"StyleComputedFontStyleDescriptor",
"StyleComputedFontWeightRange",
"StyleDisplay",
"StyleDisplayMode",
"StyleFillRule",
"StyleFontDisplay",
"StyleFontFaceSourceListComponent",
"StyleFontLanguageOverride",
+ "StyleGenericTimingFunction",
"StylePathCommand",
"StyleUnicodeRange",
]
item_types = ["enums", "structs", "typedefs"]
diff --git a/servo/components/style/values/generics/transform.rs b/servo/components/style/values/generics/transform.rs
index d398b40c3f10..0a69e589c34d 100644
--- a/servo/components/style/values/generics/transform.rs
+++ b/servo/components/style/values/generics/transform.rs
@@ -111,41 +111,68 @@ pub enum TimingFunction<Integer, Number> {
#[css(comma, function)]
#[value_info(other_values = "step-start,step-end")]
Steps(Integer, #[css(skip_if = "is_end")] StepPosition),
/// `frames(<integer>)`
#[css(comma, function)]
Frames(Integer),
}
+/// A generic representation of above.
+#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)]
+#[value_info(ty = "TIMING_FUNCTION")]
+#[repr(u8, C)]
+pub enum GenericTimingFunction<Integer, Number> {
+ /// `linear | ease | ease-in | ease-out | ease-in-out`
+ Keyword(TimingKeyword),
+ /// `cubic-bezier(<number>, <number>, <number>, <number>)`
+ #[allow(missing_docs)]
+ #[css(comma, function)]
+ CubicBezier {
+ x1: Number,
+ y1: Number,
+ x2: Number,
+ y2: Number,
+ },
+ /// `step-start | step-end | steps(<integer>, [ start | end ]?)`
+ #[css(comma, function)]
+ #[value_info(other_values = "step-start,step-end")]
+ Steps(Integer, #[css(skip_if = "is_end")] StepPosition),
+ /// `frames(<integer>)`
+ #[css(comma, function)]
+ Frames(Integer),
+}
+
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(
Clone,
Copy,
Debug,
Eq,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
)]
+#[repr(u8)]
pub enum TimingKeyword {
Linear,
Ease,
EaseIn,
EaseOut,
EaseInOut,
}
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
+#[repr(u8)]
pub enum StepPosition {
Start,
End,
}
#[inline]
fn is_end(position: &StepPosition) -> bool {
*position == StepPosition::End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment