diff --git a/components/selectors/builder.rs b/components/selectors/builder.rs index cddaf7195a1..41b83b0c40e 100644 --- a/components/selectors/builder.rs +++ b/components/selectors/builder.rs @@ -110,10 +110,7 @@ impl SelectorBuilder { if parsed_part { flags |= SelectorFlags::HAS_PART; } - self.build_with_specificity_and_flags(SpecificityAndFlags { - specificity, - flags, - }) + self.build_with_specificity_and_flags(SpecificityAndFlags { specificity, flags }) } /// Builds with an explicit SpecificityAndFlags. This is separated from build() so @@ -208,9 +205,9 @@ bitflags! { pub struct SpecificityAndFlags { /// There are two free bits here, since we use ten bits for each specificity /// kind (id, class, element). - pub (crate) specificity: u32, + pub(crate) specificity: u32, /// There's padding after this field due to the size of the flags. - pub (crate) flags: SelectorFlags, + pub(crate) flags: SelectorFlags, } impl SpecificityAndFlags { diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index d76defe8131..982dff793a8 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -751,7 +751,11 @@ impl Selector { /// Creates a Selector from a vec of Components, specified in parse order. Used in tests. #[allow(unused)] - pub (crate) fn from_vec(vec: Vec>, specificity: u32, flags: SelectorFlags) -> Self { + pub(crate) fn from_vec( + vec: Vec>, + specificity: u32, + flags: SelectorFlags, + ) -> Self { let mut builder = SelectorBuilder::default(); for component in vec.into_iter() { if let Some(combinator) = component.as_combinator() { @@ -760,10 +764,7 @@ impl Selector { builder.push_simple_selector(component); } } - let spec = SpecificityAndFlags { - specificity, - flags, - }; + let spec = SpecificityAndFlags { specificity, flags }; Selector(builder.build_with_specificity_and_flags(spec)) } diff --git a/components/style/dom.rs b/components/style/dom.rs index 0e68e55c47f..7d56cc543e7 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -349,7 +349,7 @@ pub trait TShadowRoot: Sized + Copy + Clone + PartialEq { /// Get the list of shadow parts for this shadow root. fn parts<'a>(&self) -> &[::ConcreteElement] where - Self: 'a + Self: 'a, { &[] } @@ -534,7 +534,7 @@ pub trait TElement: /// Internal iterator for the part names of this element. fn each_part(&self, _callback: F) where - F: FnMut(&Atom) + F: FnMut(&Atom), { } diff --git a/components/style/gecko/conversions.rs b/components/style/gecko/conversions.rs index 4ce44136279..bf1b93422f0 100644 --- a/components/style/gecko/conversions.rs +++ b/components/style/gecko/conversions.rs @@ -99,7 +99,7 @@ impl nsStyleImage { fn set_gradient(&mut self, gradient: Box) { unsafe { - bindings::Gecko_SetGradientImageValue(self, Box::into_raw(gradient)); + bindings::Gecko_SetGradientImageValue(self, Box::into_raw(gradient)); } } @@ -142,8 +142,7 @@ impl nsStyleImage { } }, nsStyleImageType::eStyleImageType_Gradient => { - let gradient: &Gradient = - &**self.__bindgen_anon_1.mGradient.as_ref(); + let gradient: &Gradient = &**self.__bindgen_anon_1.mGradient.as_ref(); Some(GenericImage::Gradient(Box::new(gradient.clone()))) }, nsStyleImageType::eStyleImageType_Element => { diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index 659200c3786..fc27e1a8610 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -354,9 +354,8 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> { #[inline] fn parse_part(&self) -> bool { - self.chrome_rules_enabled() || unsafe { - structs::StaticPrefs_sVarCache_layout_css_shadow_parts_enabled - } + self.chrome_rules_enabled() || + unsafe { structs::StaticPrefs_sVarCache_layout_css_shadow_parts_enabled } } fn parse_non_ts_pseudo_class( diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index ba2951f6f25..39e3678eebc 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -189,7 +189,7 @@ impl<'lr> TShadowRoot for GeckoShadowRoot<'lr> { #[inline] fn parts<'a>(&self) -> &[::ConcreteElement] where - Self: 'a + Self: 'a, { let slice: &[*const RawGeckoElement] = &*self.0.mParts; @@ -1350,7 +1350,8 @@ impl<'le> TElement for GeckoElement<'le> { #[inline] fn has_part_attr(&self) -> bool { - self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasPart) + self.as_node() + .get_bool_flag(nsINode_BooleanFlag::ElementHasPart) } // FIXME(emilio): we should probably just return a reference to the Atom. diff --git a/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs index 414c81ee52b..2889c3e7b9d 100644 --- a/components/style/invalidation/element/invalidator.rs +++ b/components/style/invalidation/element/invalidator.rs @@ -78,7 +78,8 @@ pub struct DescendantInvalidationLists<'a> { impl<'a> DescendantInvalidationLists<'a> { fn is_empty(&self) -> bool { - self.dom_descendants.is_empty() && self.slotted_descendants.is_empty() && + self.dom_descendants.is_empty() && + self.slotted_descendants.is_empty() && self.parts.is_empty() } } @@ -179,9 +180,7 @@ impl<'a> Invalidation<'a> { Combinator::Child | Combinator::Descendant | Combinator::PseudoElement => { InvalidationKind::Descendant(DescendantInvalidationKind::Dom) }, - Combinator::Part => { - InvalidationKind::Descendant(DescendantInvalidationKind::Part) - }, + Combinator::Part => InvalidationKind::Descendant(DescendantInvalidationKind::Part), Combinator::SlotAssignment => { InvalidationKind::Descendant(DescendantInvalidationKind::Slotted) }, @@ -506,7 +505,6 @@ where any } - fn invalidate_slotted_elements(&mut self, invalidations: &[Invalidation<'b>]) -> bool { if invalidations.is_empty() { return false; diff --git a/components/style/media_queries/media_feature_expression.rs b/components/style/media_queries/media_feature_expression.rs index ada30c4e895..5b5c4f4fad7 100644 --- a/components/style/media_queries/media_feature_expression.rs +++ b/components/style/media_queries/media_feature_expression.rs @@ -298,8 +298,7 @@ impl MediaFeatureExpression { #[cfg(feature = "gecko")] { - if starts_with_ignore_ascii_case(feature_name, "-webkit-") - { + if starts_with_ignore_ascii_case(feature_name, "-webkit-") { feature_name = &feature_name[8..]; requirements.insert(ParsingRequirements::WEBKIT_PREFIX); if unsafe { diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 8113c402581..13496104a04 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -165,9 +165,11 @@ def parse_property_aliases(alias_list): result.append((name, pref)) return result + def to_phys(name, logical, physical): return name.replace(logical, physical).replace("inset-", "") + class Longhand(object): def __init__(self, style_struct, name, spec=None, animation_value_type=None, keyword=None, predefined_type=None, servo_pref=None, gecko_pref=None, @@ -247,7 +249,7 @@ class Longhand(object): def all_physical_mapped_properties(self): assert self.logical candidates = [s for s in LOGICAL_SIDES + LOGICAL_SIZES + LOGICAL_CORNERS - if s in self.name] + [s for s in LOGICAL_AXES if self.name.endswith(s)] + if s in self.name] + [s for s in LOGICAL_AXES if self.name.endswith(s)] assert(len(candidates) == 1) logical_side = candidates[0] diff --git a/components/style/rule_collector.rs b/components/style/rule_collector.rs index dcd39c2b36c..f536b80b5c5 100644 --- a/components/style/rule_collector.rs +++ b/components/style/rule_collector.rs @@ -332,17 +332,14 @@ where let host = shadow.host(); let containing_shadow = host.containing_shadow(); let part_rules = match containing_shadow { - Some(shadow) => { - shadow - .style_data() - .and_then(|data| data.part_rules(self.pseudo_element)) - }, - None => { - self.stylist - .cascade_data() - .borrow_for_origin(Origin::Author) - .part_rules(self.pseudo_element) - } + Some(shadow) => shadow + .style_data() + .and_then(|data| data.part_rules(self.pseudo_element)), + None => self + .stylist + .cascade_data() + .borrow_for_origin(Origin::Author) + .part_rules(self.pseudo_element), }; // TODO(emilio): SameTreeAuthorNormal is a bit of a lie here, we may diff --git a/components/style/selector_map.rs b/components/style/selector_map.rs index a1ef9d0c273..52b939e0219 100644 --- a/components/style/selector_map.rs +++ b/components/style/selector_map.rs @@ -258,7 +258,7 @@ impl SelectorMap { } /// Adds rules in `rules` that match `element` to the `matching_rules` list. - pub (crate) fn get_matching_rules( + pub(crate) fn get_matching_rules( element: E, rules: &[Rule], matching_rules: &mut ApplicableDeclarationList, diff --git a/components/style/values/computed/image.rs b/components/style/values/computed/image.rs index 3012eece0e7..67b432d5ffd 100644 --- a/components/style/values/computed/image.rs +++ b/components/style/values/computed/image.rs @@ -66,10 +66,10 @@ impl generic::LineDirection for LineDirection { LineDirection::Angle(angle) => angle.radians() == PI, LineDirection::Vertical(VerticalPositionKeyword::Bottom) => { compat_mode == GradientCompatMode::Modern - } + }, LineDirection::Vertical(VerticalPositionKeyword::Top) => { compat_mode != GradientCompatMode::Modern - } + }, _ => false, } } diff --git a/components/style/values/generics/image.rs b/components/style/values/generics/image.rs index 3f126a6e20d..c739820ae03 100644 --- a/components/style/values/generics/image.rs +++ b/components/style/values/generics/image.rs @@ -15,7 +15,16 @@ use style_traits::{CssWriter, ToCss}; /// An | (for background-image, for example). #[derive( - Clone, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub enum GenericImageLayer { /// The `none` value. diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs index f4f4cf9afce..b0133f7a401 100644 --- a/components/style/values/specified/image.rs +++ b/components/style/values/specified/image.rs @@ -11,10 +11,12 @@ use crate::custom_properties::SpecifiedValue; use crate::parser::{Parse, ParserContext}; use crate::stylesheets::CorsMode; use crate::values::generics::image::PaintWorklet; -use crate::values::generics::image::{self as generic, Circle, GradientCompatMode, Ellipse, ShapeExtent}; +use crate::values::generics::image::{ + self as generic, Circle, Ellipse, GradientCompatMode, ShapeExtent, +}; use crate::values::generics::position::Position as GenericPosition; -use crate::values::specified::position::{Position, PositionComponent, Side}; use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPositionKeyword}; +use crate::values::specified::position::{Position, PositionComponent, Side}; use crate::values::specified::url::SpecifiedImageUrl; use crate::values::specified::{Angle, Color, Length, LengthPercentage}; use crate::values::specified::{Number, NumberOrPercentage, Percentage}; @@ -250,7 +252,12 @@ impl Parse for Gradient { return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); } - Ok(Gradient { items, repeating, kind, compat_mode }) + Ok(Gradient { + items, + repeating, + kind, + compat_mode, + }) } } @@ -259,7 +266,9 @@ impl Gradient { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { - use crate::values::specified::position::{HorizontalPositionKeyword as X, VerticalPositionKeyword as Y}; + use crate::values::specified::position::{ + HorizontalPositionKeyword as X, VerticalPositionKeyword as Y, + }; type Point = GenericPosition, Component>; #[derive(Clone, Copy, Parse)] @@ -512,7 +521,9 @@ impl GradientKind { d } else { match *compat_mode { - GradientCompatMode::Modern => LineDirection::Vertical(VerticalPositionKeyword::Bottom), + GradientCompatMode::Modern => { + LineDirection::Vertical(VerticalPositionKeyword::Bottom) + }, _ => LineDirection::Vertical(VerticalPositionKeyword::Top), } }; @@ -563,10 +574,10 @@ impl generic::LineDirection for LineDirection { LineDirection::Angle(ref angle) => angle.degrees() == 180.0, LineDirection::Vertical(VerticalPositionKeyword::Bottom) => { compat_mode == GradientCompatMode::Modern - } + }, LineDirection::Vertical(VerticalPositionKeyword::Top) => { compat_mode != GradientCompatMode::Modern - } + }, _ => false, } } @@ -621,7 +632,9 @@ impl LineDirection { // Fall back to Modern compatibility mode in case there is a `to` keyword. // According to Gecko, `-moz-linear-gradient(to ...)` should serialize like // `linear-gradient(to ...)`. - GradientCompatMode::Moz if to_ident.is_ok() => *compat_mode = GradientCompatMode::Modern, + GradientCompatMode::Moz if to_ident.is_ok() => { + *compat_mode = GradientCompatMode::Modern + }, // There is no `to` keyword in webkit prefixed syntax. If it's consumed, // parsing should throw an error. GradientCompatMode::WebKit if to_ident.is_ok() => { @@ -741,7 +754,9 @@ impl ShapeExtent { compat_mode: GradientCompatMode, ) -> Result> { match Self::parse(input)? { - ShapeExtent::Contain | ShapeExtent::Cover if compat_mode == GradientCompatMode::Modern => { + ShapeExtent::Contain | ShapeExtent::Cover + if compat_mode == GradientCompatMode::Modern => + { Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) }, ShapeExtent::Contain => Ok(ShapeExtent::ClosestSide), diff --git a/components/style/values/specified/position.rs b/components/style/values/specified/position.rs index aeffd418d27..85516790c4f 100644 --- a/components/style/values/specified/position.rs +++ b/components/style/values/specified/position.rs @@ -7,15 +7,15 @@ //! //! [position]: https://drafts.csswg.org/css-backgrounds-3/#position -use crate::Atom; -use crate::selector_map::PrecomputedHashMap; use crate::parser::{Parse, ParserContext}; +use crate::selector_map::PrecomputedHashMap; use crate::str::HTML_SPACE_CHARACTERS; use crate::values::computed::LengthPercentage as ComputedLengthPercentage; use crate::values::computed::{Context, Percentage, ToComputedValue}; use crate::values::generics::position::Position as GenericPosition; use crate::values::generics::position::ZIndex as GenericZIndex; use crate::values::specified::{AllowQuirks, Integer, LengthPercentage}; +use crate::Atom; use crate::Zero; use cssparser::Parser; use selectors::parser::SelectorParseErrorKind; @@ -579,7 +579,9 @@ impl Parse for TemplateAreas { input: &mut Parser<'i, 't>, ) -> Result> { let mut strings = vec![]; - while let Ok(string) = input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) { + while let Ok(string) = + input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) + { strings.push(string); } diff --git a/components/style/values/specified/transform.rs b/components/style/values/specified/transform.rs index d52aa69cd24..9d33fd4188f 100644 --- a/components/style/values/specified/transform.rs +++ b/components/style/values/specified/transform.rs @@ -9,7 +9,9 @@ use crate::values::computed::{Context, LengthPercentage as ComputedLengthPercent use crate::values::computed::{Percentage as ComputedPercentage, ToComputedValue}; use crate::values::generics::transform as generic; use crate::values::generics::transform::{Matrix, Matrix3D}; -use crate::values::specified::position::{Side, HorizontalPositionKeyword, VerticalPositionKeyword}; +use crate::values::specified::position::{ + HorizontalPositionKeyword, Side, VerticalPositionKeyword, +}; use crate::values::specified::{self, Angle, Integer, Length, LengthPercentage, Number}; use crate::Zero; use cssparser::Parser;