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
This commit is contained in:
Emilio Cobos Álvarez 2018-05-24 17:49:24 +02:00
parent 6b19318cc8
commit 01f805af9f
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -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();