From 01f805af9f8421ddae7d67520799747cad686cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 24 May 2018 17:49:24 +0200 Subject: [PATCH] style: Make the general setup for computed style bits nicer. This patch: * Makes StyleStructID an enum class, and moves it to the mozilla namespaces. * Introduces StyleStructConstants with some constants scattered through the codebase. * Makes the computed style bits an enum class, and splits mPseudoType and mBits into their own members, since we were using a uint64_t when we have only a couple flags and CSSPseudoElementType is a byte. We statically assert that the number of style structs is less or equal to 32. * Makes mPseudoTag, mPseudoType and mBits const, since we don't want them to be mutated from C++, and we still need a few more refactorings (mostly getting rid of FinishStyle) to avoid mutating ComputedStyle instead. Bug: 1464060 Reviewed-by: xidorn MozReview-Commit-ID: 7qsTtASGcYB --- components/style/properties/gecko.mako.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 4d14405318e..baa1ed015ee 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -41,7 +41,6 @@ use gecko_bindings::structs; use gecko_bindings::structs::nsCSSPropertyID; use gecko_bindings::structs::mozilla::CSSPseudoElementType; use gecko_bindings::structs::mozilla::CSSPseudoElementType_InheritingAnonBox; -use gecko_bindings::structs::root::NS_STYLE_CONTEXT_TYPE_SHIFT; use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut}; use gecko_bindings::sugar::refptr::RefPtr; use gecko::values::convert_nscolor_to_rgba; @@ -137,12 +136,12 @@ impl ComputedValues { PseudoElement::from_atom(&atom) } + #[inline] fn get_pseudo_type(&self) -> CSSPseudoElementType { - let bits = (self.0).mBits; - let our_type = bits >> NS_STYLE_CONTEXT_TYPE_SHIFT; - unsafe { transmute(our_type as u8) } + self.0.mPseudoType } + #[inline] pub fn is_anon_box(&self) -> bool { let our_type = self.get_pseudo_type(); return our_type == CSSPseudoElementType_InheritingAnonBox || @@ -2985,7 +2984,6 @@ fn static_assert() { I::IntoIter: ExactSizeIterator + Clone { use properties::longhands::animation_${ident}::single_value::computed_value::T as Keyword; - use gecko_bindings::structs; let v = v.into_iter();