mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Make the will-change bitfield use cbindgen.
Differential Revision: https://phabricator.services.mozilla.com/D23414
This commit is contained in:
parent
6e2643c636
commit
01e0f37861
4 changed files with 14 additions and 33 deletions
|
@ -106,6 +106,7 @@ include = [
|
|||
"Contain",
|
||||
"RestyleHint",
|
||||
"TouchAction",
|
||||
"WillChangeBits",
|
||||
"TextDecorationLine",
|
||||
]
|
||||
item_types = ["enums", "structs", "typedefs"]
|
||||
|
|
|
@ -102,20 +102,3 @@ macro_rules! define_keyword_type {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
macro_rules! impl_bitflags_conversions {
|
||||
($name:ident) => {
|
||||
impl From<u8> 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()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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<CustomIdent> = 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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<WillChange, ParseError<'i>> {
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input
|
||||
.try(|input| input.expect_ident_matching("auto"))
|
||||
.is_ok()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue