diff --git a/components/style/cbindgen.toml b/components/style/cbindgen.toml index 0d2af9f21e7..b5d374d77bf 100644 --- a/components/style/cbindgen.toml +++ b/components/style/cbindgen.toml @@ -106,6 +106,7 @@ include = [ "Contain", "RestyleHint", "TouchAction", + "WillChangeBits", "TextDecorationLine", ] item_types = ["enums", "structs", "typedefs"] diff --git a/components/style/macros.rs b/components/style/macros.rs index 6347e5fa4a0..fb189837181 100644 --- a/components/style/macros.rs +++ b/components/style/macros.rs @@ -102,20 +102,3 @@ macro_rules! define_keyword_type { } }; } - -#[cfg(feature = "gecko")] -macro_rules! impl_bitflags_conversions { - ($name:ident) => { - impl From for $name { - fn from(bits: u8) -> $name { - $name::from_bits(bits).expect("bits contain valid flag") - } - } - - impl From<$name> for u8 { - fn from(v: $name) -> u8 { - v.bits() - } - } - }; -} diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 82c8e96ec2d..331ffb5c34f 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -2940,10 +2940,10 @@ fn static_assert() { pub fn set_will_change(&mut self, v: longhands::will_change::computed_value::T) { use crate::gecko_bindings::bindings::{Gecko_AppendWillChange, Gecko_ClearWillChange}; - use crate::properties::longhands::will_change::computed_value::T; + use crate::values::specified::box_::{WillChangeBits, WillChange}; match v { - T::AnimateableFeatures { features, bits } => { + WillChange::AnimateableFeatures { features, bits } => { unsafe { Gecko_ClearWillChange(&mut self.gecko, features.len()); } @@ -2954,13 +2954,13 @@ fn static_assert() { } } - self.gecko.mWillChangeBitField = bits.bits(); + self.gecko.mWillChangeBitField = bits; }, - T::Auto => { + WillChange::Auto => { unsafe { Gecko_ClearWillChange(&mut self.gecko, 0); } - self.gecko.mWillChangeBitField = 0; + self.gecko.mWillChangeBitField = WillChangeBits::empty(); }, }; } @@ -2970,7 +2970,7 @@ fn static_assert() { self.gecko.mWillChangeBitField = other.gecko.mWillChangeBitField; unsafe { - Gecko_CopyWillChangeFrom(&mut self.gecko, &other.gecko as *const _ as *mut _); + Gecko_CopyWillChangeFrom(&mut self.gecko, &other.gecko); } } @@ -2979,24 +2979,22 @@ fn static_assert() { } pub fn clone_will_change(&self) -> longhands::will_change::computed_value::T { - use crate::properties::longhands::will_change::computed_value::T; - use crate::gecko_bindings::structs::nsAtom; use crate::values::CustomIdent; - use crate::values::specified::box_::WillChangeBits; + use crate::values::specified::box_::WillChange; if self.gecko.mWillChange.len() == 0 { - return T::Auto + return WillChange::Auto } let custom_idents: Vec = self.gecko.mWillChange.iter().map(|gecko_atom| { unsafe { - CustomIdent(Atom::from_raw(gecko_atom.mRawPtr as *mut nsAtom)) + CustomIdent(Atom::from_raw(gecko_atom.mRawPtr)) } }).collect(); - T::AnimateableFeatures { + WillChange::AnimateableFeatures { features: custom_idents.into_boxed_slice(), - bits: WillChangeBits::from_bits_truncate(self.gecko.mWillChangeBitField), + bits: self.gecko.mWillChangeBitField, } } diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index dddf3f9b4af..ab81d4c3450 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -555,9 +555,8 @@ impl WillChange { bitflags! { /// The change bits that we care about. - /// - /// These need to be in sync with NS_STYLE_WILL_CHANGE_*. #[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue)] + #[repr(C)] pub struct WillChangeBits: u8 { /// Whether the stacking context will change. const STACKING_CONTEXT = 1 << 0; @@ -616,7 +615,7 @@ impl Parse for WillChange { fn parse<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, - ) -> Result> { + ) -> Result> { if input .try(|input| input.expect_ident_matching("auto")) .is_ok()