Uplift bitfield fix for nsChangeHint

This commit is contained in:
Manish Goregaokar 2016-11-18 14:09:23 -08:00
parent 9fb589dfd2
commit 3d5b26ac26
5 changed files with 219 additions and 104 deletions

View file

@ -188,6 +188,7 @@ COMPILATION_TARGETS = {
"StyleTransition", "StyleTransition",
"UniquePtr", "UniquePtr",
], ],
"bitfield_enum_types": ["nsChangeHint", "nsRestyleHint"],
"opaque_types": [ "opaque_types": [
"atomic___base", "atomic___base",
"nsAString_internal_char_traits", "nsAString_internal_char_traits",
@ -523,6 +524,11 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
flags.append("--whitelist-var") flags.append("--whitelist-var")
flags.append(header) flags.append(header)
if "bitfield_enum_types" in current_target:
for ty in current_target["bitfield_enum_types"]:
flags.append("--bitfield-enum")
flags.append(ty)
if "opaque_types" in current_target: if "opaque_types" in current_target:
for ty in current_target["opaque_types"]: for ty in current_target["opaque_types"]:
flags.append("--opaque-type") flags.append("--opaque-type")

View file

@ -4,6 +4,7 @@
use dom::TRestyleDamage; use dom::TRestyleDamage;
use gecko_bindings::bindings; use gecko_bindings::bindings;
use gecko_bindings::structs;
use gecko_bindings::structs::{nsChangeHint, nsStyleContext}; use gecko_bindings::structs::{nsChangeHint, nsStyleContext};
use gecko_bindings::sugar::ownership::FFIArcHelpers; use gecko_bindings::sugar::ownership::FFIArcHelpers;
use properties::ComputedValues; use properties::ComputedValues;
@ -23,8 +24,7 @@ impl TRestyleDamage for GeckoRestyleDamage {
type PreExistingComputedValues = nsStyleContext; type PreExistingComputedValues = nsStyleContext;
fn empty() -> Self { fn empty() -> Self {
use std::mem; GeckoRestyleDamage(nsChangeHint(0))
GeckoRestyleDamage(unsafe { mem::transmute(0u32) })
} }
fn compute(source: &nsStyleContext, fn compute(source: &nsStyleContext,
@ -38,7 +38,7 @@ impl TRestyleDamage for GeckoRestyleDamage {
} }
fn rebuild_and_reflow() -> Self { fn rebuild_and_reflow() -> Self {
GeckoRestyleDamage(nsChangeHint::nsChangeHint_ReconstructFrame) GeckoRestyleDamage(structs::nsChangeHint_nsChangeHint_ReconstructFrame)
} }
} }
@ -46,8 +46,7 @@ impl BitOr for GeckoRestyleDamage {
type Output = Self; type Output = Self;
fn bitor(self, other: Self) -> Self { fn bitor(self, other: Self) -> Self {
use std::mem; GeckoRestyleDamage(self.0 | other.0)
GeckoRestyleDamage(unsafe { mem::transmute(self.0 as u32 | other.0 as u32) })
} }
} }

View file

@ -3948,7 +3948,36 @@ fn bindgen_test_layout_EventStates() {
impl Clone for EventStates { impl Clone for EventStates {
fn clone(&self) -> Self { *self } fn clone(&self) -> Self { *self }
} }
#[repr(u32)] pub const nsRestyleHint_eRestyle_Self: nsRestyleHint = nsRestyleHint(1);
pub const nsRestyleHint_eRestyle_SomeDescendants: nsRestyleHint =
nsRestyleHint(2);
pub const nsRestyleHint_eRestyle_Subtree: nsRestyleHint = nsRestyleHint(4);
pub const nsRestyleHint_eRestyle_LaterSiblings: nsRestyleHint =
nsRestyleHint(8);
pub const nsRestyleHint_eRestyle_CSSTransitions: nsRestyleHint =
nsRestyleHint(16);
pub const nsRestyleHint_eRestyle_CSSAnimations: nsRestyleHint =
nsRestyleHint(32);
pub const nsRestyleHint_eRestyle_SVGAttrAnimations: nsRestyleHint =
nsRestyleHint(64);
pub const nsRestyleHint_eRestyle_StyleAttribute: nsRestyleHint =
nsRestyleHint(128);
pub const nsRestyleHint_eRestyle_StyleAttribute_Animations: nsRestyleHint =
nsRestyleHint(256);
pub const nsRestyleHint_eRestyle_Force: nsRestyleHint = nsRestyleHint(512);
pub const nsRestyleHint_eRestyle_ForceDescendants: nsRestyleHint =
nsRestyleHint(1024);
pub const nsRestyleHint_eRestyle_AllHintsWithAnimations: nsRestyleHint =
nsRestyleHint(368);
impl ::std::ops::BitOr<nsRestyleHint> for nsRestyleHint {
type
Output
=
Self;
#[inline]
fn bitor(self, other: Self) -> Self { nsRestyleHint(self.0 | other.0) }
}
#[repr(C)]
/** /**
* |nsRestyleHint| is a bitfield for the result of * |nsRestyleHint| is a bitfield for the result of
* |HasStateDependentStyle| and |HasAttributeDependentStyle|. When no * |HasStateDependentStyle| and |HasAttributeDependentStyle|. When no
@ -3968,20 +3997,7 @@ impl Clone for EventStates {
* RestyleManager::RestyleHintToString. * RestyleManager::RestyleHintToString.
*/ */
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum nsRestyleHint { pub struct nsRestyleHint(pub u32);
eRestyle_Self = 1,
eRestyle_SomeDescendants = 2,
eRestyle_Subtree = 4,
eRestyle_LaterSiblings = 8,
eRestyle_CSSTransitions = 16,
eRestyle_CSSAnimations = 32,
eRestyle_SVGAttrAnimations = 64,
eRestyle_StyleAttribute = 128,
eRestyle_StyleAttribute_Animations = 256,
eRestyle_Force = 512,
eRestyle_ForceDescendants = 1024,
eRestyle_AllHintsWithAnimations = 368,
}
/** /**
* Instances of this class represent moments in time, or a special * Instances of this class represent moments in time, or a special
* "null" moment. We do not use the non-monotonic system clock or * "null" moment. We do not use the non-monotonic system clock or
@ -5089,39 +5105,78 @@ fn bindgen_test_layout_RestyleManagerHandle() {
impl Clone for RestyleManagerHandle { impl Clone for RestyleManagerHandle {
fn clone(&self) -> Self { *self } fn clone(&self) -> Self { *self }
} }
#[repr(u32)] pub const nsChangeHint_nsChangeHint_RepaintFrame: nsChangeHint =
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] nsChangeHint(1);
pub enum nsChangeHint { pub const nsChangeHint_nsChangeHint_NeedReflow: nsChangeHint =
nsChangeHint_RepaintFrame = 1, nsChangeHint(2);
nsChangeHint_NeedReflow = 2, pub const nsChangeHint_nsChangeHint_ClearAncestorIntrinsics: nsChangeHint =
nsChangeHint_ClearAncestorIntrinsics = 4, nsChangeHint(4);
nsChangeHint_ClearDescendantIntrinsics = 8, pub const nsChangeHint_nsChangeHint_ClearDescendantIntrinsics: nsChangeHint =
nsChangeHint_NeedDirtyReflow = 16, nsChangeHint(8);
nsChangeHint_SyncFrameView = 32, pub const nsChangeHint_nsChangeHint_NeedDirtyReflow: nsChangeHint =
nsChangeHint_UpdateCursor = 64, nsChangeHint(16);
nsChangeHint_UpdateEffects = 128, pub const nsChangeHint_nsChangeHint_SyncFrameView: nsChangeHint =
nsChangeHint_UpdateOpacityLayer = 256, nsChangeHint(32);
nsChangeHint_UpdateTransformLayer = 512, pub const nsChangeHint_nsChangeHint_UpdateCursor: nsChangeHint =
nsChangeHint_ReconstructFrame = 1024, nsChangeHint(64);
nsChangeHint_UpdateOverflow = 2048, pub const nsChangeHint_nsChangeHint_UpdateEffects: nsChangeHint =
nsChangeHint_UpdateSubtreeOverflow = 4096, nsChangeHint(128);
nsChangeHint_UpdatePostTransformOverflow = 8192, pub const nsChangeHint_nsChangeHint_UpdateOpacityLayer: nsChangeHint =
nsChangeHint_UpdateParentOverflow = 16384, nsChangeHint(256);
nsChangeHint_ChildrenOnlyTransform = 32768, pub const nsChangeHint_nsChangeHint_UpdateTransformLayer: nsChangeHint =
nsChangeHint_RecomputePosition = 65536, nsChangeHint(512);
nsChangeHint_UpdateContainingBlock = 131072, pub const nsChangeHint_nsChangeHint_ReconstructFrame: nsChangeHint =
nsChangeHint_BorderStyleNoneChange = 262144, nsChangeHint(1024);
nsChangeHint_UpdateTextPath = 524288, pub const nsChangeHint_nsChangeHint_UpdateOverflow: nsChangeHint =
nsChangeHint_SchedulePaint = 1048576, nsChangeHint(2048);
nsChangeHint_NeutralChange = 2097152, pub const nsChangeHint_nsChangeHint_UpdateSubtreeOverflow: nsChangeHint =
nsChangeHint_InvalidateRenderingObservers = 4194304, nsChangeHint(4096);
nsChangeHint_ReflowChangesSizeOrPosition = 8388608, pub const nsChangeHint_nsChangeHint_UpdatePostTransformOverflow: nsChangeHint
nsChangeHint_UpdateComputedBSize = 16777216, =
nsChangeHint_UpdateUsesOpacity = 33554432, nsChangeHint(8192);
nsChangeHint_UpdateBackgroundPosition = 67108864, pub const nsChangeHint_nsChangeHint_UpdateParentOverflow: nsChangeHint =
nsChangeHint_AddOrRemoveTransform = 134217728, nsChangeHint(16384);
nsChangeHint_AllHints = 268435455, pub const nsChangeHint_nsChangeHint_ChildrenOnlyTransform: nsChangeHint =
nsChangeHint(32768);
pub const nsChangeHint_nsChangeHint_RecomputePosition: nsChangeHint =
nsChangeHint(65536);
pub const nsChangeHint_nsChangeHint_UpdateContainingBlock: nsChangeHint =
nsChangeHint(131072);
pub const nsChangeHint_nsChangeHint_BorderStyleNoneChange: nsChangeHint =
nsChangeHint(262144);
pub const nsChangeHint_nsChangeHint_UpdateTextPath: nsChangeHint =
nsChangeHint(524288);
pub const nsChangeHint_nsChangeHint_SchedulePaint: nsChangeHint =
nsChangeHint(1048576);
pub const nsChangeHint_nsChangeHint_NeutralChange: nsChangeHint =
nsChangeHint(2097152);
pub const nsChangeHint_nsChangeHint_InvalidateRenderingObservers: nsChangeHint
=
nsChangeHint(4194304);
pub const nsChangeHint_nsChangeHint_ReflowChangesSizeOrPosition: nsChangeHint
=
nsChangeHint(8388608);
pub const nsChangeHint_nsChangeHint_UpdateComputedBSize: nsChangeHint =
nsChangeHint(16777216);
pub const nsChangeHint_nsChangeHint_UpdateUsesOpacity: nsChangeHint =
nsChangeHint(33554432);
pub const nsChangeHint_nsChangeHint_UpdateBackgroundPosition: nsChangeHint =
nsChangeHint(67108864);
pub const nsChangeHint_nsChangeHint_AddOrRemoveTransform: nsChangeHint =
nsChangeHint(134217728);
pub const nsChangeHint_nsChangeHint_AllHints: nsChangeHint =
nsChangeHint(268435455);
impl ::std::ops::BitOr<nsChangeHint> for nsChangeHint {
type
Output
=
Self;
#[inline]
fn bitor(self, other: Self) -> Self { nsChangeHint(self.0 | other.0) }
} }
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct nsChangeHint(pub u32);
pub type nscolor = u32; pub type nscolor = u32;
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

View file

@ -3930,7 +3930,36 @@ fn bindgen_test_layout_EventStates() {
impl Clone for EventStates { impl Clone for EventStates {
fn clone(&self) -> Self { *self } fn clone(&self) -> Self { *self }
} }
#[repr(u32)] pub const nsRestyleHint_eRestyle_Self: nsRestyleHint = nsRestyleHint(1);
pub const nsRestyleHint_eRestyle_SomeDescendants: nsRestyleHint =
nsRestyleHint(2);
pub const nsRestyleHint_eRestyle_Subtree: nsRestyleHint = nsRestyleHint(4);
pub const nsRestyleHint_eRestyle_LaterSiblings: nsRestyleHint =
nsRestyleHint(8);
pub const nsRestyleHint_eRestyle_CSSTransitions: nsRestyleHint =
nsRestyleHint(16);
pub const nsRestyleHint_eRestyle_CSSAnimations: nsRestyleHint =
nsRestyleHint(32);
pub const nsRestyleHint_eRestyle_SVGAttrAnimations: nsRestyleHint =
nsRestyleHint(64);
pub const nsRestyleHint_eRestyle_StyleAttribute: nsRestyleHint =
nsRestyleHint(128);
pub const nsRestyleHint_eRestyle_StyleAttribute_Animations: nsRestyleHint =
nsRestyleHint(256);
pub const nsRestyleHint_eRestyle_Force: nsRestyleHint = nsRestyleHint(512);
pub const nsRestyleHint_eRestyle_ForceDescendants: nsRestyleHint =
nsRestyleHint(1024);
pub const nsRestyleHint_eRestyle_AllHintsWithAnimations: nsRestyleHint =
nsRestyleHint(368);
impl ::std::ops::BitOr<nsRestyleHint> for nsRestyleHint {
type
Output
=
Self;
#[inline]
fn bitor(self, other: Self) -> Self { nsRestyleHint(self.0 | other.0) }
}
#[repr(C)]
/** /**
* |nsRestyleHint| is a bitfield for the result of * |nsRestyleHint| is a bitfield for the result of
* |HasStateDependentStyle| and |HasAttributeDependentStyle|. When no * |HasStateDependentStyle| and |HasAttributeDependentStyle|. When no
@ -3950,20 +3979,7 @@ impl Clone for EventStates {
* RestyleManager::RestyleHintToString. * RestyleManager::RestyleHintToString.
*/ */
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum nsRestyleHint { pub struct nsRestyleHint(pub u32);
eRestyle_Self = 1,
eRestyle_SomeDescendants = 2,
eRestyle_Subtree = 4,
eRestyle_LaterSiblings = 8,
eRestyle_CSSTransitions = 16,
eRestyle_CSSAnimations = 32,
eRestyle_SVGAttrAnimations = 64,
eRestyle_StyleAttribute = 128,
eRestyle_StyleAttribute_Animations = 256,
eRestyle_Force = 512,
eRestyle_ForceDescendants = 1024,
eRestyle_AllHintsWithAnimations = 368,
}
/** /**
* Instances of this class represent moments in time, or a special * Instances of this class represent moments in time, or a special
* "null" moment. We do not use the non-monotonic system clock or * "null" moment. We do not use the non-monotonic system clock or
@ -5068,39 +5084,78 @@ fn bindgen_test_layout_RestyleManagerHandle() {
impl Clone for RestyleManagerHandle { impl Clone for RestyleManagerHandle {
fn clone(&self) -> Self { *self } fn clone(&self) -> Self { *self }
} }
#[repr(u32)] pub const nsChangeHint_nsChangeHint_RepaintFrame: nsChangeHint =
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] nsChangeHint(1);
pub enum nsChangeHint { pub const nsChangeHint_nsChangeHint_NeedReflow: nsChangeHint =
nsChangeHint_RepaintFrame = 1, nsChangeHint(2);
nsChangeHint_NeedReflow = 2, pub const nsChangeHint_nsChangeHint_ClearAncestorIntrinsics: nsChangeHint =
nsChangeHint_ClearAncestorIntrinsics = 4, nsChangeHint(4);
nsChangeHint_ClearDescendantIntrinsics = 8, pub const nsChangeHint_nsChangeHint_ClearDescendantIntrinsics: nsChangeHint =
nsChangeHint_NeedDirtyReflow = 16, nsChangeHint(8);
nsChangeHint_SyncFrameView = 32, pub const nsChangeHint_nsChangeHint_NeedDirtyReflow: nsChangeHint =
nsChangeHint_UpdateCursor = 64, nsChangeHint(16);
nsChangeHint_UpdateEffects = 128, pub const nsChangeHint_nsChangeHint_SyncFrameView: nsChangeHint =
nsChangeHint_UpdateOpacityLayer = 256, nsChangeHint(32);
nsChangeHint_UpdateTransformLayer = 512, pub const nsChangeHint_nsChangeHint_UpdateCursor: nsChangeHint =
nsChangeHint_ReconstructFrame = 1024, nsChangeHint(64);
nsChangeHint_UpdateOverflow = 2048, pub const nsChangeHint_nsChangeHint_UpdateEffects: nsChangeHint =
nsChangeHint_UpdateSubtreeOverflow = 4096, nsChangeHint(128);
nsChangeHint_UpdatePostTransformOverflow = 8192, pub const nsChangeHint_nsChangeHint_UpdateOpacityLayer: nsChangeHint =
nsChangeHint_UpdateParentOverflow = 16384, nsChangeHint(256);
nsChangeHint_ChildrenOnlyTransform = 32768, pub const nsChangeHint_nsChangeHint_UpdateTransformLayer: nsChangeHint =
nsChangeHint_RecomputePosition = 65536, nsChangeHint(512);
nsChangeHint_UpdateContainingBlock = 131072, pub const nsChangeHint_nsChangeHint_ReconstructFrame: nsChangeHint =
nsChangeHint_BorderStyleNoneChange = 262144, nsChangeHint(1024);
nsChangeHint_UpdateTextPath = 524288, pub const nsChangeHint_nsChangeHint_UpdateOverflow: nsChangeHint =
nsChangeHint_SchedulePaint = 1048576, nsChangeHint(2048);
nsChangeHint_NeutralChange = 2097152, pub const nsChangeHint_nsChangeHint_UpdateSubtreeOverflow: nsChangeHint =
nsChangeHint_InvalidateRenderingObservers = 4194304, nsChangeHint(4096);
nsChangeHint_ReflowChangesSizeOrPosition = 8388608, pub const nsChangeHint_nsChangeHint_UpdatePostTransformOverflow: nsChangeHint
nsChangeHint_UpdateComputedBSize = 16777216, =
nsChangeHint_UpdateUsesOpacity = 33554432, nsChangeHint(8192);
nsChangeHint_UpdateBackgroundPosition = 67108864, pub const nsChangeHint_nsChangeHint_UpdateParentOverflow: nsChangeHint =
nsChangeHint_AddOrRemoveTransform = 134217728, nsChangeHint(16384);
nsChangeHint_AllHints = 268435455, pub const nsChangeHint_nsChangeHint_ChildrenOnlyTransform: nsChangeHint =
nsChangeHint(32768);
pub const nsChangeHint_nsChangeHint_RecomputePosition: nsChangeHint =
nsChangeHint(65536);
pub const nsChangeHint_nsChangeHint_UpdateContainingBlock: nsChangeHint =
nsChangeHint(131072);
pub const nsChangeHint_nsChangeHint_BorderStyleNoneChange: nsChangeHint =
nsChangeHint(262144);
pub const nsChangeHint_nsChangeHint_UpdateTextPath: nsChangeHint =
nsChangeHint(524288);
pub const nsChangeHint_nsChangeHint_SchedulePaint: nsChangeHint =
nsChangeHint(1048576);
pub const nsChangeHint_nsChangeHint_NeutralChange: nsChangeHint =
nsChangeHint(2097152);
pub const nsChangeHint_nsChangeHint_InvalidateRenderingObservers: nsChangeHint
=
nsChangeHint(4194304);
pub const nsChangeHint_nsChangeHint_ReflowChangesSizeOrPosition: nsChangeHint
=
nsChangeHint(8388608);
pub const nsChangeHint_nsChangeHint_UpdateComputedBSize: nsChangeHint =
nsChangeHint(16777216);
pub const nsChangeHint_nsChangeHint_UpdateUsesOpacity: nsChangeHint =
nsChangeHint(33554432);
pub const nsChangeHint_nsChangeHint_UpdateBackgroundPosition: nsChangeHint =
nsChangeHint(67108864);
pub const nsChangeHint_nsChangeHint_AddOrRemoveTransform: nsChangeHint =
nsChangeHint(134217728);
pub const nsChangeHint_nsChangeHint_AllHints: nsChangeHint =
nsChangeHint(268435455);
impl ::std::ops::BitOr<nsChangeHint> for nsChangeHint {
type
Output
=
Self;
#[inline]
fn bitor(self, other: Self) -> Self { nsChangeHint(self.0 | other.0) }
} }
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct nsChangeHint(pub u32);
pub type nscolor = u32; pub type nscolor = u32;
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

View file

@ -23,24 +23,24 @@ macro_rules! check_enum_value {
// const-fn and no other way to access the numerical value :-( // const-fn and no other way to access the numerical value :-(
macro_rules! check_enum_value_non_static { macro_rules! check_enum_value_non_static {
($a:expr, $b:expr) => { ($a:expr, $b:expr) => {
assert_eq!($a as usize, $b as usize); assert_eq!($a.0 as usize, $b as usize);
} }
} }
#[test] #[test]
fn assert_restyle_hints_match() { fn assert_restyle_hints_match() {
use style::restyle_hints::*; // For flags use style::restyle_hints::*; // For flags
use style::gecko_bindings::structs::nsRestyleHint; use style::gecko_bindings::structs;
check_enum_value_non_static!(nsRestyleHint::eRestyle_Self, RESTYLE_SELF.bits()); check_enum_value_non_static!(structs::nsRestyleHint_eRestyle_Self, RESTYLE_SELF.bits());
// XXX This for Servo actually means something like an hypothetical // XXX This for Servo actually means something like an hypothetical
// Restyle_AllDescendants (but without running selector matching on the // Restyle_AllDescendants (but without running selector matching on the
// element). ServoRestyleManager interprets it like that, but in practice we // element). ServoRestyleManager interprets it like that, but in practice we
// should align the behavior with Gecko adding a new restyle hint, maybe? // should align the behavior with Gecko adding a new restyle hint, maybe?
// //
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1291786 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1291786
check_enum_value_non_static!(nsRestyleHint::eRestyle_SomeDescendants, RESTYLE_DESCENDANTS.bits()); check_enum_value_non_static!(structs::nsRestyleHint_eRestyle_SomeDescendants, RESTYLE_DESCENDANTS.bits());
check_enum_value_non_static!(nsRestyleHint::eRestyle_LaterSiblings, RESTYLE_LATER_SIBLINGS.bits()); check_enum_value_non_static!(structs::nsRestyleHint_eRestyle_LaterSiblings, RESTYLE_LATER_SIBLINGS.bits());
} }
// Note that we can't call each_pseudo_element, parse_pseudo_element, or // Note that we can't call each_pseudo_element, parse_pseudo_element, or