diff --git a/Cargo.lock b/Cargo.lock index 58fa1df1a34b..185f28e14a4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1378,7 +1378,7 @@ dependencies = [ name = "dom" version = "0.1.0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.999.999", ] [[package]] @@ -4622,7 +4622,7 @@ dependencies = [ name = "selectors" version = "0.22.0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.999.999", "cssparser", "derive_more", "fxhash", @@ -4981,7 +4981,7 @@ dependencies = [ "arrayvec", "atomic_refcell", "bindgen 0.64.0", - "bitflags 1.3.2", + "bitflags 2.999.999", "byteorder", "cssparser", "derive_more", @@ -5047,7 +5047,7 @@ name = "style_traits" version = "0.0.1" dependencies = [ "app_units", - "bitflags 1.3.2", + "bitflags 2.999.999", "cssparser", "euclid", "lazy_static", diff --git a/dom/base/rust/Cargo.toml b/dom/base/rust/Cargo.toml index efc42a2df573..38828c3f0f8e 100644 --- a/dom/base/rust/Cargo.toml +++ b/dom/base/rust/Cargo.toml @@ -11,4 +11,4 @@ license = "MPL-2.0" path = "lib.rs" [dependencies] -bitflags = "1.0" +bitflags = "2" diff --git a/dom/base/rust/lib.rs b/dom/base/rust/lib.rs index e40ea585f906..388c1320df51 100644 --- a/dom/base/rust/lib.rs +++ b/dom/base/rust/lib.rs @@ -9,6 +9,7 @@ use bitflags::bitflags; bitflags! { /// Event-based element states. #[repr(C)] + #[derive(Clone, Copy, Eq, PartialEq)] pub struct ElementState: u64 { /// The mouse is down on this element. /// @@ -181,6 +182,7 @@ bitflags! { bitflags! { /// Event-based document states. #[repr(C)] + #[derive(Clone, Copy, Eq, PartialEq)] pub struct DocumentState: u64 { /// Window activation status const WINDOW_INACTIVE = 1 << 0; diff --git a/servo/components/selectors/Cargo.toml b/servo/components/selectors/Cargo.toml index 1c87025b8920..ee78103cd4e7 100644 --- a/servo/components/selectors/Cargo.toml +++ b/servo/components/selectors/Cargo.toml @@ -18,7 +18,7 @@ path = "lib.rs" bench = [] [dependencies] -bitflags = "1.0" +bitflags = "2" matches = "0.1" cssparser = "0.31" derive_more = { version = "0.99", default-features = false, features = ["add", "add_assign"] } diff --git a/servo/components/selectors/builder.rs b/servo/components/selectors/builder.rs index 410984619b18..d2bbf2c0c947 100644 --- a/servo/components/selectors/builder.rs +++ b/servo/components/selectors/builder.rs @@ -178,7 +178,7 @@ fn split_from_end(s: &[T], at: usize) -> (&[T], &[T]) { bitflags! { /// Flags that indicate at which point of parsing a selector are we. - #[derive(Default, ToShmem)] + #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, ToShmem)] pub (crate) struct SelectorFlags : u8 { const HAS_PSEUDO = 1 << 0; const HAS_SLOTTED = 1 << 1; diff --git a/servo/components/selectors/matching.rs b/servo/components/selectors/matching.rs index 5d44a5208862..707b88bd2f35 100644 --- a/servo/components/selectors/matching.rs +++ b/servo/components/selectors/matching.rs @@ -28,6 +28,7 @@ pub static RECOMMENDED_SELECTOR_BLOOM_FILTER_SIZE: usize = 4096; bitflags! { /// Set of flags that are set on either the element or its parent (depending /// on the flag) if the element could potentially match a selector. + #[derive(Clone, Copy)] pub struct ElementSelectorFlags: usize { /// When a child is added or removed from the parent, all the children /// must be restyled, because they may match :nth-last-child, diff --git a/servo/components/selectors/parser.rs b/servo/components/selectors/parser.rs index 4c1281c2cef1..c2a1bfeae57e 100644 --- a/servo/components/selectors/parser.rs +++ b/servo/components/selectors/parser.rs @@ -78,6 +78,7 @@ fn to_ascii_lowercase(s: &str) -> Cow { bitflags! { /// Flags that indicate at which point of parsing a selector are we. + #[derive(Copy, Clone)] struct SelectorParsingState: u8 { /// Whether we should avoid adding default namespaces to selectors that /// aren't type or universal selectors. @@ -1506,6 +1507,7 @@ pub struct RelativeSelector { bitflags! { /// Composition of combinators in a given selector, not traversing selectors of pseudoclasses. + #[derive(Clone, Debug, Eq, PartialEq)] struct CombinatorComposition: u8 { const DESCENDANTS = 1 << 0; const SIBLINGS = 1 << 1; @@ -1518,10 +1520,10 @@ impl CombinatorComposition { for combinator in CombinatorIter::new(inner_selector.iter_skip_relative_selector_anchor()) { match combinator { Combinator::Descendant | Combinator::Child => { - result.insert(CombinatorComposition::DESCENDANTS); + result.insert(Self::DESCENDANTS); }, Combinator::NextSibling | Combinator::LaterSibling => { - result.insert(CombinatorComposition::SIBLINGS); + result.insert(Self::SIBLINGS); }, Combinator::Part | Combinator::PseudoElement | Combinator::SlotAssignment => { continue diff --git a/servo/components/selectors/visitor.rs b/servo/components/selectors/visitor.rs index 785c12813a6b..69d66630e5b1 100644 --- a/servo/components/selectors/visitor.rs +++ b/servo/components/selectors/visitor.rs @@ -62,7 +62,7 @@ pub trait SelectorVisitor: Sized { bitflags! { /// The kinds of components the visitor is visiting the selector list of, if any - #[derive(Default)] + #[derive(Clone, Copy, Default)] pub struct SelectorListKind: u8 { /// The visitor is inside :not(..) const NEGATION = 1 << 0; diff --git a/servo/components/style/Cargo.toml b/servo/components/style/Cargo.toml index cb91e00c31e5..30ad42f6c460 100644 --- a/servo/components/style/Cargo.toml +++ b/servo/components/style/Cargo.toml @@ -30,7 +30,7 @@ gecko_refcount_logging = [] app_units = "0.7" arrayvec = "0.7" atomic_refcell = "0.1" -bitflags = "1.0" +bitflags = "2" byteorder = "1.0" cssparser = "0.31" derive_more = { version = "0.99", default-features = false, features = ["add", "add_assign", "deref", "from"] } diff --git a/servo/components/style/color/mod.rs b/servo/components/style/color/mod.rs index f5a36aba2e88..f8ceee9703d2 100644 --- a/servo/components/style/color/mod.rs +++ b/servo/components/style/color/mod.rs @@ -128,7 +128,7 @@ impl ColorSpace { bitflags! { /// Flags used when serializing colors. - #[derive(Default, MallocSizeOf, ToShmem)] + #[derive(Clone, Copy, Default, MallocSizeOf, PartialEq, ToShmem)] #[repr(C)] pub struct ColorFlags : u8 { /// If set, serializes sRGB colors into `color(srgb ...)` instead of diff --git a/servo/components/style/font_face.rs b/servo/components/style/font_face.rs index 1f624e5d2a9b..ffa40cd74a54 100644 --- a/servo/components/style/font_face.rs +++ b/servo/components/style/font_face.rs @@ -97,7 +97,7 @@ pub enum FontFaceSourceFormatKeyword { bitflags! { /// Flags for the @font-face tech() function, indicating font technologies /// required by the resource. - #[derive(ToShmem)] + #[derive(Clone, Copy, Debug, Eq, PartialEq, ToShmem)] #[repr(C)] pub struct FontFaceSourceTechFlags: u16 { /// Font requires OpenType feature support. diff --git a/servo/components/style/gecko/selector_parser.rs b/servo/components/style/gecko/selector_parser.rs index 9be8bf6623d3..6bf527b141a6 100644 --- a/servo/components/style/gecko/selector_parser.rs +++ b/servo/components/style/gecko/selector_parser.rs @@ -26,6 +26,7 @@ pub use crate::gecko::snapshot::SnapshotMap; bitflags! { // See NonTSPseudoClass::is_enabled_in() + #[derive(Copy, Clone)] struct NonTSPseudoClassFlag: u8 { const PSEUDO_CLASS_ENABLED_IN_UA_SHEETS = 1 << 0; const PSEUDO_CLASS_ENABLED_IN_CHROME = 1 << 1; diff --git a/servo/components/style/gecko/snapshot.rs b/servo/components/style/gecko/snapshot.rs index 84756406ed81..cb5f2dea676d 100644 --- a/servo/components/style/gecko/snapshot.rs +++ b/servo/components/style/gecko/snapshot.rs @@ -170,7 +170,7 @@ impl ElementSnapshot for GeckoElementSnapshot { fn state(&self) -> Option { if self.has_any(Flags::State) { - Some(ElementState::from_bits_truncate(self.mState)) + Some(ElementState::from_bits_retain(self.mState)) } else { None } diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs index eb3ab03c73c7..b33f230d275f 100644 --- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -719,7 +719,7 @@ impl<'le> GeckoElement<'le> { #[inline] fn document_state(&self) -> DocumentState { - DocumentState::from_bits_truncate(self.as_node().owner_doc().0.mDocumentState.bits) + DocumentState::from_bits_retain(self.as_node().owner_doc().0.mDocumentState.bits) } #[inline] @@ -1183,7 +1183,7 @@ impl<'le> TElement for GeckoElement<'le> { #[inline] fn state(&self) -> ElementState { - ElementState::from_bits_truncate(self.state_internal()) + ElementState::from_bits_retain(self.state_internal()) } #[inline] diff --git a/servo/components/style/gecko_bindings/sugar/origin_flags.rs b/servo/components/style/gecko_bindings/sugar/origin_flags.rs index e0f0981c5d80..b27060405a43 100644 --- a/servo/components/style/gecko_bindings/sugar/origin_flags.rs +++ b/servo/components/style/gecko_bindings/sugar/origin_flags.rs @@ -20,7 +20,7 @@ pub fn assert_flags_match() { impl From for OriginSet { fn from(flags: OriginFlags) -> Self { - Self::from_bits_truncate(flags.0) + Self::from_bits_retain(flags.0) } } diff --git a/servo/components/style/invalidation/element/restyle_hints.rs b/servo/components/style/invalidation/element/restyle_hints.rs index 6020e429ec65..ccce71b7de35 100644 --- a/servo/components/style/invalidation/element/restyle_hints.rs +++ b/servo/components/style/invalidation/element/restyle_hints.rs @@ -9,6 +9,7 @@ use crate::traversal_flags::TraversalFlags; bitflags! { /// The kind of restyle we need to do for a given element. #[repr(C)] + #[derive(Clone, Copy, Debug)] pub struct RestyleHint: u16 { /// Do a selector match of the element. const RESTYLE_SELF = 1 << 0; diff --git a/servo/components/style/logical_geometry.rs b/servo/components/style/logical_geometry.rs index d475e9bdfc41..b8a7927dbb02 100644 --- a/servo/components/style/logical_geometry.rs +++ b/servo/components/style/logical_geometry.rs @@ -25,7 +25,7 @@ pub enum InlineBaseDirection { // TODO: improve the readability of the WritingMode serialization, refer to the Debug:fmt() bitflags!( - #[cfg_attr(feature = "servo", derive(MallocSizeOf, Serialize))] + #[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq, Serialize)] #[repr(C)] pub struct WritingMode: u8 { /// A vertical writing mode; writing-mode is vertical-rl, @@ -170,7 +170,7 @@ impl WritingMode { /// Returns the `horizontal-tb` value. pub fn horizontal_tb() -> Self { - Self::from_bits_truncate(0) + Self::empty() } #[inline] @@ -418,7 +418,7 @@ impl DebugWritingMode { #[inline] fn new(mode: WritingMode) -> DebugWritingMode { - DebugWritingMode { mode: mode } + DebugWritingMode { mode } } } diff --git a/servo/components/style/properties/computed_value_flags.rs b/servo/components/style/properties/computed_value_flags.rs index d84311de0844..5fbe8f3a95e4 100644 --- a/servo/components/style/properties/computed_value_flags.rs +++ b/servo/components/style/properties/computed_value_flags.rs @@ -12,6 +12,7 @@ bitflags! { /// If we ever want to add some flags that shouldn't inherit for them, /// we might want to add a function to handle this. #[repr(C)] + #[derive(Clone, Copy, Eq, PartialEq)] pub struct ComputedValueFlags: u32 { /// Whether the style or any of the ancestors has a text-decoration-line /// property that should get propagated to descendants. diff --git a/servo/components/style/properties/longhands/position.mako.rs b/servo/components/style/properties/longhands/position.mako.rs index 251767c71bc3..4c974ef9dccf 100644 --- a/servo/components/style/properties/longhands/position.mako.rs +++ b/servo/components/style/properties/longhands/position.mako.rs @@ -36,24 +36,6 @@ )} % endfor -#[cfg(feature = "gecko")] -macro_rules! impl_align_conversions { - ($name: path) => { - impl From for $name { - fn from(bits: u8) -> $name { - $name(crate::values::specified::align::AlignFlags::from_bits(bits) - .expect("bits contain valid flag")) - } - } - - impl From<$name> for u8 { - fn from(v: $name) -> u8 { - v.0.bits() - } - } - }; -} - ${helpers.predefined_type( "z-index", "ZIndex", @@ -184,9 +166,6 @@ ${helpers.single_keyword( servo_restyle_damage="reflow", )} - #[cfg(feature = "gecko")] - impl_align_conversions!(crate::values::specified::align::AlignItems); - ${helpers.predefined_type( "justify-items", "JustifyItems", @@ -195,9 +174,6 @@ ${helpers.single_keyword( spec="https://drafts.csswg.org/css-align/#propdef-justify-items", animation_value_type="discrete", )} - - #[cfg(feature = "gecko")] - impl_align_conversions!(crate::values::specified::align::JustifyItems); % endif // Flex item properties @@ -258,9 +234,6 @@ ${helpers.predefined_type( spec="https://drafts.csswg.org/css-align/#justify-self-property", animation_value_type="discrete", )} - - #[cfg(feature = "gecko")] - impl_align_conversions!(crate::values::specified::align::SelfAlignment); % endif // https://drafts.csswg.org/css-flexbox/#propdef-order diff --git a/servo/components/style/properties/properties.mako.rs b/servo/components/style/properties/properties.mako.rs index c4414364fc2b..c580fdbc9174 100644 --- a/servo/components/style/properties/properties.mako.rs +++ b/servo/components/style/properties/properties.mako.rs @@ -1198,6 +1198,7 @@ impl CSSWideKeyword { bitflags! { /// A set of flags for properties. + #[derive(Clone, Copy)] pub struct PropertyFlags: u16 { /// This longhand property applies to ::first-letter. const APPLIES_TO_FIRST_LETTER = 1 << 1; @@ -1427,7 +1428,7 @@ impl LonghandId { 0, % endfor ]; - PropertyFlags::from_bits_truncate(FLAGS[self as usize]) + PropertyFlags::from_bits_retain(FLAGS[self as usize]) } /// Returns true if the property is one that is ignored when document @@ -1602,7 +1603,7 @@ impl ShorthandId { 0, % endfor ]; - PropertyFlags::from_bits_truncate(FLAGS[self as usize]) + PropertyFlags::from_bits_retain(FLAGS[self as usize]) } /// Returns whether this property is a legacy shorthand. diff --git a/servo/components/style/queries/feature.rs b/servo/components/style/queries/feature.rs index 0a85d7a245fb..977634c27a90 100644 --- a/servo/components/style/queries/feature.rs +++ b/servo/components/style/queries/feature.rs @@ -104,7 +104,7 @@ macro_rules! keyword_evaluator { bitflags! { /// Different flags or toggles that change how a expression is parsed or /// evaluated. - #[derive(ToShmem)] + #[derive(Clone, Copy, ToShmem)] pub struct FeatureFlags : u8 { /// The feature should only be parsed in chrome and ua sheets. const CHROME_AND_UA_ONLY = 1 << 0; diff --git a/servo/components/style/selector_map.rs b/servo/components/style/selector_map.rs index 9f774b75b73d..ed56cb41e566 100644 --- a/servo/components/style/selector_map.rs +++ b/servo/components/style/selector_map.rs @@ -40,7 +40,7 @@ impl Default for PrecomputedHasher { /// /// We can avoid selector-matching those global rules for all elements without /// these pseudo-class states. -const RARE_PSEUDO_CLASS_STATES: ElementState = ElementState::from_bits_truncate( +const RARE_PSEUDO_CLASS_STATES: ElementState = ElementState::from_bits_retain( ElementState::FULLSCREEN.bits() | ElementState::VISITED_OR_UNVISITED.bits() | ElementState::URLTARGET.bits() | diff --git a/servo/components/style/stylesheets/origin.rs b/servo/components/style/stylesheets/origin.rs index 27ad3fa184a4..6f8f97b66102 100644 --- a/servo/components/style/stylesheets/origin.rs +++ b/servo/components/style/stylesheets/origin.rs @@ -58,7 +58,7 @@ impl Origin { bitflags! { /// A set of origins. This is equivalent to Gecko's OriginFlags. - #[derive(MallocSizeOf)] + #[derive(Clone, Copy, PartialEq, MallocSizeOf)] pub struct OriginSet: u8 { /// const ORIGIN_USER_AGENT = Origin::UserAgent as u8; @@ -85,7 +85,7 @@ impl OriginSet { impl From for OriginSet { fn from(origin: Origin) -> Self { - Self::from_bits_truncate(origin as u8) + Self::from_bits_retain(origin as u8) } } diff --git a/servo/components/style/thread_state.rs b/servo/components/style/thread_state.rs index 2a39feef4871..3dc5541e00bd 100644 --- a/servo/components/style/thread_state.rs +++ b/servo/components/style/thread_state.rs @@ -9,8 +9,9 @@ use std::cell::RefCell; -bitflags! { +bitflags ! { /// A thread state flag, used for multiple assertions. + #[derive(Clone, Copy, Eq, PartialEq)] pub struct ThreadState: u32 { /// Whether we're in a script thread. const SCRIPT = 0x01; diff --git a/servo/components/style/traversal_flags.rs b/servo/components/style/traversal_flags.rs index 0987230ed026..4bb8e1374a95 100644 --- a/servo/components/style/traversal_flags.rs +++ b/servo/components/style/traversal_flags.rs @@ -10,6 +10,7 @@ bitflags! { /// Flags that control the traversal process. + #[derive(Clone, Copy, Eq, PartialEq)] pub struct TraversalFlags: u32 { /// Traverse only elements for animation restyles. const AnimationOnly = 1 << 0; diff --git a/servo/components/style/values/specified/align.rs b/servo/components/style/values/specified/align.rs index ebb6f6383402..f0d36fe01e43 100644 --- a/servo/components/style/values/specified/align.rs +++ b/servo/components/style/values/specified/align.rs @@ -13,7 +13,7 @@ use style_traits::{CssWriter, KeywordsCollectFn, ParseError, SpecifiedValueInfo, bitflags! { /// Constants shared by multiple CSS Box Alignment properties - #[derive(MallocSizeOf, ToComputedValue, ToResolvedValue, ToShmem)] + #[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] #[repr(C)] pub struct AlignFlags: u8 { // Enumeration stored in the lower 5 bits: diff --git a/servo/components/style/values/specified/box.rs b/servo/components/style/values/specified/box.rs index 3decb2582bdc..7c6daf8eebf8 100644 --- a/servo/components/style/values/specified/box.rs +++ b/servo/components/style/values/specified/box.rs @@ -1001,7 +1001,7 @@ impl WillChange { bitflags! { /// The change bits that we care about. - #[derive(Default, MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] + #[derive(Clone, Copy, Default, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] #[repr(C)] pub struct WillChangeBits: u16 { /// Whether a property which can create a stacking context **on any @@ -1112,7 +1112,7 @@ impl Parse for WillChange { bitflags! { /// Values for the `touch-action` property. - #[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, Parse)] + #[derive(Clone, Copy, Eq, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] #[css(bitflags(single = "none,auto,manipulation", mixed = "pan-x,pan-y,pinch-zoom"))] #[repr(C)] pub struct TouchAction: u8 { @@ -1140,7 +1140,7 @@ impl TouchAction { } bitflags! { - #[derive(MallocSizeOf, Parse, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] + #[derive(Clone, Copy, Eq, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] #[css(bitflags(single = "none,strict,content", mixed="size,layout,style,paint,inline-size", overlapping_bits))] #[repr(C)] /// Constants for contain: https://drafts.csswg.org/css-contain/#contain-property @@ -1882,7 +1882,7 @@ impl Overflow { } bitflags! { - #[derive(MallocSizeOf, SpecifiedValueInfo, ToCss, ToComputedValue, ToResolvedValue, ToShmem, Parse)] + #[derive(Clone, Copy, Eq, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] #[repr(C)] #[css(bitflags(single = "auto", mixed = "stable,both-edges", validate_mixed="Self::has_stable"))] /// Values for scrollbar-gutter: diff --git a/servo/components/style/values/specified/calc.rs b/servo/components/style/values/specified/calc.rs index dc5b83597a29..7351a61069a0 100644 --- a/servo/components/style/values/specified/calc.rs +++ b/servo/components/style/values/specified/calc.rs @@ -119,6 +119,7 @@ bitflags! { /// This is used as a hint for the parser to fast-reject invalid /// expressions. Numbers are always allowed because they multiply other /// units. + #[derive(Clone, Copy)] struct CalcUnits: u8 { const LENGTH = 1 << 0; const PERCENTAGE = 1 << 1; diff --git a/servo/components/style/values/specified/color.rs b/servo/components/style/values/specified/color.rs index 57e0cf203985..94568b7d9273 100644 --- a/servo/components/style/values/specified/color.rs +++ b/servo/components/style/values/specified/color.rs @@ -1011,7 +1011,7 @@ impl Parse for CaretColor { bitflags! { /// Various flags to represent the color-scheme property in an efficient /// way. - #[derive(Default, MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] + #[derive(Clone, Copy, Default, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] #[repr(C)] #[value_info(other_values = "light,dark,only")] pub struct ColorSchemeFlags: u8 { diff --git a/servo/components/style/values/specified/font.rs b/servo/components/style/values/specified/font.rs index 4a5eed5296f8..47dc2c5ae335 100644 --- a/servo/components/style/values/specified/font.rs +++ b/servo/components/style/values/specified/font.rs @@ -983,7 +983,7 @@ impl Parse for FontSize { } bitflags! { - #[cfg_attr(feature = "servo", derive(MallocSizeOf))] + #[derive(Clone, Copy)] /// Flags of variant alternates in bit struct VariantAlternatesParsingFlags: u8 { /// None of variant alternates enabled @@ -1208,7 +1208,7 @@ macro_rules! impl_variant_east_asian { )+ } => { bitflags! { - #[derive(MallocSizeOf, ToComputedValue, ToResolvedValue, ToShmem)] + #[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] /// Vairants for east asian variant pub struct FontVariantEastAsian: u16 { /// None of the features @@ -1379,7 +1379,7 @@ macro_rules! impl_variant_ligatures { )+ } => { bitflags! { - #[derive(MallocSizeOf, ToComputedValue, ToResolvedValue, ToShmem)] + #[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] /// Variants of ligatures pub struct FontVariantLigatures: u16 { /// Specifies that common default features are enabled @@ -1557,8 +1557,8 @@ macro_rules! impl_variant_numeric { )+ } => { bitflags! { - #[derive(MallocSizeOf, ToComputedValue, ToResolvedValue, ToShmem)] - /// Vairants of numeric values + #[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] + /// Variants of numeric values pub struct FontVariantNumeric: u8 { /// None of other variants are enabled. const NORMAL = 0; diff --git a/servo/components/style/values/specified/image.rs b/servo/components/style/values/specified/image.rs index 72be1fed4610..9a6707066ed3 100644 --- a/servo/components/style/values/specified/image.rs +++ b/servo/components/style/values/specified/image.rs @@ -166,6 +166,7 @@ pub type MozImageRect = generic::GenericMozImageRect(&self, dest: &mut CssWriter) -> fmt::Result - where - W: Write, - { - let mut writer = SequenceWriter::new(dest, " "); - let mut any = false; - macro_rules! maybe_write { - ($ident:ident => $str:expr) => { - if self.contains(TextTransformOther::$ident) { - writer.raw_item($str)?; - any = true; - } - }; - } - - maybe_write!(FULL_WIDTH => "full-width"); - maybe_write!(FULL_SIZE_KANA => "full-size-kana"); - - debug_assert!(any || self.is_empty()); - - Ok(()) - } -} - /// Specified and computed value of text-align-last. #[derive( Clone, @@ -773,7 +748,7 @@ impl Parse for TextEmphasisStyle { } bitflags! { - #[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, Parse, ToCss)] + #[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq, Parse, Serialize, SpecifiedValueInfo, ToCss, ToComputedValue, ToResolvedValue, ToShmem)] #[repr(C)] #[css(bitflags(mixed="over,under,left,right", validate_mixed="Self::validate_and_simplify"))] /// Values for text-emphasis-position: @@ -985,7 +960,7 @@ impl TextDecorationLength { } bitflags! { - #[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] + #[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] #[value_info(other_values = "auto,from-font,under,left,right")] #[repr(C)] /// Specified keyword values for the text-underline-position property. diff --git a/servo/components/style_traits/Cargo.toml b/servo/components/style_traits/Cargo.toml index a4b6755362dd..fd50a5a0aaca 100644 --- a/servo/components/style_traits/Cargo.toml +++ b/servo/components/style_traits/Cargo.toml @@ -15,7 +15,7 @@ gecko = [] [dependencies] app_units = "0.7" -bitflags = "1.0" +bitflags = "2" cssparser = "0.31" euclid = "0.22" lazy_static = "1" diff --git a/servo/components/style_traits/lib.rs b/servo/components/style_traits/lib.rs index 2f69f46873c6..054b74b6b81a 100644 --- a/servo/components/style_traits/lib.rs +++ b/servo/components/style_traits/lib.rs @@ -245,6 +245,7 @@ pub enum PropertySyntaxParseError { bitflags! { /// The mode to use when parsing values. + #[derive(Clone, Copy, Eq, PartialEq)] pub struct ParsingMode: u8 { /// In CSS; lengths must have units, except for zero values, where the unit can be omitted. /// diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index 9dd2cc4087af..cfcb2b9adaf1 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -295,7 +295,7 @@ pub extern "C" fn Servo_TraverseSubtree( snapshots: *const ServoElementSnapshotTable, raw_flags: ServoTraversalFlags, ) -> bool { - let traversal_flags = TraversalFlags::from_bits_truncate(raw_flags); + let traversal_flags = TraversalFlags::from_bits_retain(raw_flags); debug_assert!(!snapshots.is_null()); let element = GeckoElement(root); @@ -4374,7 +4374,7 @@ fn parse_property_into( reporter: Option<&dyn ParseErrorReporter>, ) -> Result<(), ()> { let value = unsafe { value.as_str_unchecked() }; - let parsing_mode = ParsingMode::from_bits_truncate(parsing_mode); + let parsing_mode = ParsingMode::from_bits_retain(parsing_mode); if let Some(non_custom) = property_id.non_custom_id() { if !non_custom.allowed_in_rule(rule_type.into()) { @@ -5194,7 +5194,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue( Clear => get_from_computed::(value), VerticalAlign => VerticalAlign::Keyword(VerticalAlignKeyword::from_u32(value).unwrap()), TextAlign => get_from_computed::(value), - TextEmphasisPosition => TextEmphasisPosition::from_bits_truncate(value as u8), + TextEmphasisPosition => TextEmphasisPosition::from_bits_retain(value as u8), FontSize => { // We rely on Gecko passing in font-size values (0...7) here. longhands::font_size::SpecifiedValue::from_html_size(value as u8) @@ -6754,7 +6754,7 @@ pub extern "C" fn Servo_StyleSet_HasStateDependency( ) -> bool { let element = GeckoElement(element); - let state = ElementState::from_bits_truncate(state); + let state = ElementState::from_bits_retain(state); let data = raw_data.borrow(); data.stylist @@ -6769,7 +6769,7 @@ pub extern "C" fn Servo_StyleSet_HasNthOfStateDependency( ) -> bool { let element = GeckoElement(element); - let state = ElementState::from_bits_truncate(state); + let state = ElementState::from_bits_retain(state); let data = raw_data.borrow(); data.stylist @@ -6781,7 +6781,7 @@ pub extern "C" fn Servo_StyleSet_HasDocumentStateDependency( raw_data: &PerDocumentStyleData, state: u64, ) -> bool { - let state = DocumentState::from_bits_truncate(state); + let state = DocumentState::from_bits_retain(state); let data = raw_data.borrow(); data.stylist.has_document_state_dependency(state) @@ -7360,7 +7360,7 @@ pub unsafe extern "C" fn Servo_InvalidateStyleForDocStateChanges( let root = GeckoElement(root); let mut processor = DocumentStateInvalidationProcessor::new( iter, - DocumentState::from_bits_truncate(states_changed), + DocumentState::from_bits_retain(states_changed), &mut nth_index_cache, root.as_node().owner_doc().quirks_mode(), );