From 8929087d8365d2e57dc446f25ee18ac4139c4e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 25 Dec 2018 23:09:29 +0000 Subject: [PATCH] style: Update the Rust target version for bindgen. This brings us alignas support and also associated constants for bitfield enums. Differential Revision: https://phabricator.services.mozilla.com/D15334 --- components/style/build_gecko.rs | 4 +- .../gecko/pseudo_element_definition.mako.rs | 4 +- components/style/gecko/restyle_damage.rs | 2 +- components/style/gecko/wrapper.rs | 7 +--- .../gecko_bindings/sugar/origin_flags.rs | 9 ++--- .../invalidation/element/restyle_hints.rs | 37 ++++++++----------- components/style/properties/gecko.mako.rs | 3 +- 7 files changed, 26 insertions(+), 40 deletions(-) diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 9b627a4a82e..734d09569f5 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -139,7 +139,9 @@ mod bindings { // Disable rust unions, because we replace some types inside of // them. - let mut builder = Builder::default().rust_target(RustTarget::Stable_1_0); + let mut builder = Builder::default() + .rust_target(RustTarget::Stable_1_25) + .disable_untagged_union(); let rustfmt_path = env::var_os("RUSTFMT") // This can be replaced with diff --git a/components/style/gecko/pseudo_element_definition.mako.rs b/components/style/gecko/pseudo_element_definition.mako.rs index aaa3d7c8c99..613bbd281ee 100644 --- a/components/style/gecko/pseudo_element_definition.mako.rs +++ b/components/style/gecko/pseudo_element_definition.mako.rs @@ -156,8 +156,6 @@ impl PseudoElement { /// Construct a `CSSPseudoElementType` from a pseudo-element #[inline] fn pseudo_type(&self) -> CSSPseudoElementType { - use crate::gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox; - match *self { % for pseudo in PSEUDOS: % if not pseudo.is_anon_box(): @@ -165,7 +163,7 @@ impl PseudoElement { % elif pseudo.is_tree_pseudo_element(): PseudoElement::${pseudo.capitalized_pseudo()}(..) => CSSPseudoElementType::XULTree, % elif pseudo.is_inheriting_anon_box(): - PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType_InheritingAnonBox, + PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType::InheritingAnonBox, % else: PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType::NonInheritingAnonBox, % endif diff --git a/components/style/gecko/restyle_damage.rs b/components/style/gecko/restyle_damage.rs index b2b14b413e3..9c9d07b7112 100644 --- a/components/style/gecko/restyle_damage.rs +++ b/components/style/gecko/restyle_damage.rs @@ -83,7 +83,7 @@ impl GeckoRestyleDamage { /// Gets restyle damage to reconstruct the entire frame, subsuming all /// other damage. pub fn reconstruct() -> Self { - GeckoRestyleDamage(structs::nsChangeHint_nsChangeHint_ReconstructFrame) + GeckoRestyleDamage(structs::nsChangeHint::nsChangeHint_ReconstructFrame) } } diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 0768e9e26af..1340a005d74 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1501,9 +1501,6 @@ impl<'le> TElement for GeckoElement<'le> { /// Process various tasks that are a result of animation-only restyle. fn process_post_animation(&self, tasks: PostAnimationTasks) { - use crate::gecko_bindings::structs::nsChangeHint_nsChangeHint_Empty; - use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree; - debug_assert!(!tasks.is_empty(), "Should be involved a task"); // If display style was changed from none to other, we need to resolve @@ -1519,8 +1516,8 @@ impl<'le> TElement for GeckoElement<'le> { ); unsafe { self.note_explicit_hints( - nsRestyleHint_eRestyle_Subtree, - nsChangeHint_nsChangeHint_Empty, + nsRestyleHint::eRestyle_Subtree, + nsChangeHint::nsChangeHint_Empty, ); } } diff --git a/components/style/gecko_bindings/sugar/origin_flags.rs b/components/style/gecko_bindings/sugar/origin_flags.rs index b7250b53930..409b145f1e9 100644 --- a/components/style/gecko_bindings/sugar/origin_flags.rs +++ b/components/style/gecko_bindings/sugar/origin_flags.rs @@ -5,17 +5,14 @@ //! Helper to iterate over `OriginFlags` bits. use crate::gecko_bindings::structs::OriginFlags; -use crate::gecko_bindings::structs::OriginFlags_Author; -use crate::gecko_bindings::structs::OriginFlags_User; -use crate::gecko_bindings::structs::OriginFlags_UserAgent; use crate::stylesheets::OriginSet; /// Checks that the values for OriginFlags are the ones we expect. pub fn assert_flags_match() { use crate::stylesheets::origin::*; - debug_assert_eq!(OriginFlags_UserAgent.0, OriginSet::ORIGIN_USER_AGENT.bits()); - debug_assert_eq!(OriginFlags_Author.0, OriginSet::ORIGIN_AUTHOR.bits()); - debug_assert_eq!(OriginFlags_User.0, OriginSet::ORIGIN_USER.bits()); + debug_assert_eq!(OriginFlags::UserAgent.0, OriginSet::ORIGIN_USER_AGENT.bits()); + debug_assert_eq!(OriginFlags::Author.0, OriginSet::ORIGIN_AUTHOR.bits()); + debug_assert_eq!(OriginFlags::User.0, OriginSet::ORIGIN_USER.bits()); } impl From for OriginSet { diff --git a/components/style/invalidation/element/restyle_hints.rs b/components/style/invalidation/element/restyle_hints.rs index 1d8a7f5bd14..2cb8e222e46 100644 --- a/components/style/invalidation/element/restyle_hints.rs +++ b/components/style/invalidation/element/restyle_hints.rs @@ -193,38 +193,31 @@ impl Default for RestyleHint { #[cfg(feature = "gecko")] impl From for RestyleHint { fn from(mut raw: nsRestyleHint) -> Self { - use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Force as eRestyle_Force; - use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_ForceDescendants as eRestyle_ForceDescendants; - use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_LaterSiblings as eRestyle_LaterSiblings; - use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Self as eRestyle_Self; - use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_SomeDescendants as eRestyle_SomeDescendants; - use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree as eRestyle_Subtree; - let mut hint = RestyleHint::empty(); debug_assert!( - raw.0 & eRestyle_LaterSiblings.0 == 0, + raw.0 & nsRestyleHint::eRestyle_LaterSiblings.0 == 0, "Handle later siblings manually if necessary plz." ); - if (raw.0 & (eRestyle_Self.0 | eRestyle_Subtree.0)) != 0 { - raw.0 &= !eRestyle_Self.0; + if (raw.0 & (nsRestyleHint::eRestyle_Self.0 | nsRestyleHint::eRestyle_Subtree.0)) != 0 { + raw.0 &= !nsRestyleHint::eRestyle_Self.0; hint.insert(RestyleHint::RESTYLE_SELF); } - if (raw.0 & (eRestyle_Subtree.0 | eRestyle_SomeDescendants.0)) != 0 { - raw.0 &= !eRestyle_Subtree.0; - raw.0 &= !eRestyle_SomeDescendants.0; + if (raw.0 & (nsRestyleHint::eRestyle_Subtree.0 | nsRestyleHint::eRestyle_SomeDescendants.0)) != 0 { + raw.0 &= !nsRestyleHint::eRestyle_Subtree.0; + raw.0 &= !nsRestyleHint::eRestyle_SomeDescendants.0; hint.insert(RestyleHint::RESTYLE_DESCENDANTS); } - if (raw.0 & (eRestyle_ForceDescendants.0 | eRestyle_Force.0)) != 0 { - raw.0 &= !eRestyle_Force.0; + if (raw.0 & (nsRestyleHint::eRestyle_ForceDescendants.0 | nsRestyleHint::eRestyle_Force.0)) != 0 { + raw.0 &= !nsRestyleHint::eRestyle_Force.0; hint.insert(RestyleHint::RECASCADE_SELF); } - if (raw.0 & eRestyle_ForceDescendants.0) != 0 { - raw.0 &= !eRestyle_ForceDescendants.0; + if (raw.0 & nsRestyleHint::eRestyle_ForceDescendants.0) != 0 { + raw.0 &= !nsRestyleHint::eRestyle_ForceDescendants.0; hint.insert(RestyleHint::RECASCADE_DESCENDANTS); } @@ -248,7 +241,7 @@ pub fn assert_restyle_hints_match() { if cfg!(debug_assertions) { let mut replacements = RestyleHint::replacements(); $( - assert_eq!(structs::$a.0 as usize, $b.bits() as usize, stringify!($b)); + assert_eq!(structs::nsRestyleHint::$a.0 as usize, $b.bits() as usize, stringify!($b)); replacements.remove($b); )* assert_eq!(replacements, RestyleHint::empty(), @@ -259,9 +252,9 @@ pub fn assert_restyle_hints_match() { } check_restyle_hints! { - nsRestyleHint_eRestyle_CSSTransitions => RestyleHint::RESTYLE_CSS_TRANSITIONS, - nsRestyleHint_eRestyle_CSSAnimations => RestyleHint::RESTYLE_CSS_ANIMATIONS, - nsRestyleHint_eRestyle_StyleAttribute => RestyleHint::RESTYLE_STYLE_ATTRIBUTE, - nsRestyleHint_eRestyle_StyleAttribute_Animations => RestyleHint::RESTYLE_SMIL, + eRestyle_CSSTransitions => RestyleHint::RESTYLE_CSS_TRANSITIONS, + eRestyle_CSSAnimations => RestyleHint::RESTYLE_CSS_ANIMATIONS, + eRestyle_StyleAttribute => RestyleHint::RESTYLE_STYLE_ATTRIBUTE, + eRestyle_StyleAttribute_Animations => RestyleHint::RESTYLE_SMIL, } } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 218f150e670..d969f14f54a 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -39,7 +39,6 @@ use crate::gecko_bindings::bindings::RawGeckoPresContextBorrowed; use crate::gecko_bindings::structs; use crate::gecko_bindings::structs::nsCSSPropertyID; use crate::gecko_bindings::structs::mozilla::CSSPseudoElementType; -use crate::gecko_bindings::structs::mozilla::CSSPseudoElementType_InheritingAnonBox; use crate::gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut}; use crate::gecko_bindings::sugar::refptr::RefPtr; use crate::gecko::values::convert_nscolor_to_rgba; @@ -138,7 +137,7 @@ impl ComputedValues { #[inline] pub fn is_anon_box(&self) -> bool { let our_type = self.get_pseudo_type(); - return our_type == CSSPseudoElementType_InheritingAnonBox || + return our_type == CSSPseudoElementType::InheritingAnonBox || our_type == CSSPseudoElementType::NonInheritingAnonBox; }