From 280402b2a1ce47d9a2ee4b5c76ebb974c90c34cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 21 Feb 2020 00:46:50 +0000 Subject: [PATCH] style: Fix C++ side of values. Differential Revision: https://phabricator.services.mozilla.com/D63398 --- .../style/values/computed/length_percentage.rs | 1 + components/style/values/generics/calc.rs | 12 ++++++------ components/style/values/specified/calc.rs | 7 +++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/style/values/computed/length_percentage.rs b/components/style/values/computed/length_percentage.rs index b70117f3b18..4e2e6e5695f 100644 --- a/components/style/values/computed/length_percentage.rs +++ b/components/style/values/computed/length_percentage.rs @@ -552,6 +552,7 @@ impl<'de> Deserialize<'de> for LengthPercentage { /// The leaves of a `` calc expression. #[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize, ToAnimatedZero, ToCss, ToResolvedValue)] #[allow(missing_docs)] +#[repr(u8)] pub enum CalcLengthPercentageLeaf { Length(Length), Percentage(Percentage), diff --git a/components/style/values/generics/calc.rs b/components/style/values/generics/calc.rs index 6a920ddcd78..833864aebf2 100644 --- a/components/style/values/generics/calc.rs +++ b/components/style/values/generics/calc.rs @@ -54,9 +54,9 @@ pub enum GenericCalcNode { Leaf(L), /// A sum node, representing `a + b + c` where a, b, and c are the /// arguments. - Sum(Box<[GenericCalcNode]>), + Sum(crate::OwnedSlice>), /// A `min` or `max` function. - MinMax(Box<[GenericCalcNode]>, MinMaxOp), + MinMax(crate::OwnedSlice>, MinMaxOp), /// A `clamp()` function. Clamp { /// The minimum value. @@ -131,7 +131,7 @@ impl CalcNode { fn map_children( children: &[CalcNode], map: &mut F, - ) -> Box<[CalcNode]> + ) -> crate::OwnedSlice> where L: CalcNodeLeaf, O: CalcNodeLeaf, @@ -209,7 +209,7 @@ impl CalcNode { pub fn simplify_and_sort_children(&mut self) { macro_rules! replace_self_with { ($slot:expr) => {{ - let dummy = Self::MinMax(Box::new([]), MinMaxOp::Max); + let dummy = Self::MinMax(Default::default(), MinMaxOp::Max); let result = mem::replace($slot, dummy); mem::replace(self, result); }}; @@ -315,7 +315,7 @@ impl CalcNode { return replace_self_with!(&mut children_slot[0]); } - let mut children = mem::replace(children_slot, Box::new([])).into_vec(); + let mut children = mem::replace(children_slot, Default::default()).into_vec(); if !sums_to_merge.is_empty() { children.reserve(extra_kids - sums_to_merge.len()); @@ -347,7 +347,7 @@ impl CalcNode { replace_self_with!(&mut children[0]); } else { // Else put our simplified children back. - mem::replace(children_slot, children.into_boxed_slice()); + mem::replace(children_slot, children.into_boxed_slice().into()); } }, Self::Leaf(ref mut l) => { diff --git a/components/style/values/specified/calc.rs b/components/style/values/specified/calc.rs index 9d0d407fbf4..9f5817a7703 100644 --- a/components/style/values/specified/calc.rs +++ b/components/style/values/specified/calc.rs @@ -397,8 +397,7 @@ impl CalcNode { let arguments = input .parse_comma_separated(|input| { Self::parse_argument(context, input, expected_unit) - })? - .into_boxed_slice(); + })?; let op = match function { MathFunction::Min => MinMaxOp::Min, @@ -406,7 +405,7 @@ impl CalcNode { _ => unreachable!(), }; - Ok(Self::MinMax(arguments, op)) + Ok(Self::MinMax(arguments.into(), op)) }, } }) @@ -452,7 +451,7 @@ impl CalcNode { Ok(if sum.len() == 1 { sum.drain(..).next().unwrap() } else { - Self::Sum(sum.into_boxed_slice()) + Self::Sum(sum.into_boxed_slice().into()) }) }