mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +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",
|
"Contain",
|
||||||
"RestyleHint",
|
"RestyleHint",
|
||||||
"TouchAction",
|
"TouchAction",
|
||||||
|
"WillChangeBits",
|
||||||
"TextDecorationLine",
|
"TextDecorationLine",
|
||||||
]
|
]
|
||||||
item_types = ["enums", "structs", "typedefs"]
|
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) {
|
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::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 {
|
match v {
|
||||||
T::AnimateableFeatures { features, bits } => {
|
WillChange::AnimateableFeatures { features, bits } => {
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_ClearWillChange(&mut self.gecko, features.len());
|
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 {
|
unsafe {
|
||||||
Gecko_ClearWillChange(&mut self.gecko, 0);
|
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;
|
self.gecko.mWillChangeBitField = other.gecko.mWillChangeBitField;
|
||||||
unsafe {
|
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 {
|
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::CustomIdent;
|
||||||
use crate::values::specified::box_::WillChangeBits;
|
use crate::values::specified::box_::WillChange;
|
||||||
|
|
||||||
if self.gecko.mWillChange.len() == 0 {
|
if self.gecko.mWillChange.len() == 0 {
|
||||||
return T::Auto
|
return WillChange::Auto
|
||||||
}
|
}
|
||||||
|
|
||||||
let custom_idents: Vec<CustomIdent> = self.gecko.mWillChange.iter().map(|gecko_atom| {
|
let custom_idents: Vec<CustomIdent> = self.gecko.mWillChange.iter().map(|gecko_atom| {
|
||||||
unsafe {
|
unsafe {
|
||||||
CustomIdent(Atom::from_raw(gecko_atom.mRawPtr as *mut nsAtom))
|
CustomIdent(Atom::from_raw(gecko_atom.mRawPtr))
|
||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
T::AnimateableFeatures {
|
WillChange::AnimateableFeatures {
|
||||||
features: custom_idents.into_boxed_slice(),
|
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! {
|
bitflags! {
|
||||||
/// The change bits that we care about.
|
/// The change bits that we care about.
|
||||||
///
|
|
||||||
/// These need to be in sync with NS_STYLE_WILL_CHANGE_*.
|
|
||||||
#[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue)]
|
#[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct WillChangeBits: u8 {
|
pub struct WillChangeBits: u8 {
|
||||||
/// Whether the stacking context will change.
|
/// Whether the stacking context will change.
|
||||||
const STACKING_CONTEXT = 1 << 0;
|
const STACKING_CONTEXT = 1 << 0;
|
||||||
|
@ -616,7 +615,7 @@ impl Parse for WillChange {
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
) -> Result<WillChange, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
if input
|
if input
|
||||||
.try(|input| input.expect_ident_matching("auto"))
|
.try(|input| input.expect_ident_matching("auto"))
|
||||||
.is_ok()
|
.is_ok()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue