diff --git a/servo/components/selectors/matching.rs b/servo/components/selectors/matching.rs index 7c509e8e673c..f50dc8ddecf7 100644 --- a/servo/components/selectors/matching.rs +++ b/servo/components/selectors/matching.rs @@ -261,10 +261,11 @@ where let iter = selector.iter_from(selector.len() - from_offset); debug_assert!( iter.clone().next().is_some() || - (from_offset != selector.len() && matches!( - selector.combinator_at_parse_order(from_offset), - Combinator::SlotAssignment | Combinator::PseudoElement - )), + (from_offset != selector.len() && + matches!( + selector.combinator_at_parse_order(from_offset), + Combinator::SlotAssignment | Combinator::PseudoElement + )), "Got the math wrong: {:?} | {:?} | {} {}", selector, selector.iter_raw_match_order().as_slice(), @@ -454,11 +455,9 @@ where context.current_host.is_some(), "Should not be trying to match slotted rules in a non-shadow-tree context" ); - debug_assert!( - element - .assigned_slot() - .map_or(true, |s| s.is_html_slot_element()) - ); + debug_assert!(element + .assigned_slot() + .map_or(true, |s| s.is_html_slot_element())); let scope = context.current_host?; let mut current_slot = element.assigned_slot()?; while current_slot.containing_shadow_host().unwrap().opaque() != scope { @@ -674,9 +673,9 @@ where Component::Combinator(_) => unreachable!(), Component::Slotted(ref selector) => { // are never flattened tree slottables. - !element.is_html_slot_element() && element.assigned_slot().is_some() && context - .shared - .nest(|context| { + !element.is_html_slot_element() && + element.assigned_slot().is_some() && + context.shared.nest(|context| { matches_complex_selector(selector.iter(), element, context, flags_setter) }) }, diff --git a/servo/components/selectors/parser.rs b/servo/components/selectors/parser.rs index 4dda76d32002..fa043b772a97 100644 --- a/servo/components/selectors/parser.rs +++ b/servo/components/selectors/parser.rs @@ -449,9 +449,7 @@ where ref local_name, never_matches, .. - } - if !never_matches => - { + } if !never_matches => { if !visitor.visit_attribute_selector( &NamespaceConstraint::Specific(&namespace_empty_string::()), local_name, @@ -459,7 +457,7 @@ where ) { return false; } - } + }, AttributeOther(ref attr_selector) if !attr_selector.never_matches => { let empty_string; let namespace = match attr_selector.namespace() { @@ -1366,7 +1364,7 @@ where SelectorParseErrorKind::DanglingCombinator } else { SelectorParseErrorKind::EmptySelector - })) + })); }, }; @@ -1634,7 +1632,7 @@ where OptionalQName::None(t) => { return Err(input.new_custom_error( SelectorParseErrorKind::NoQualifiedNameInAttributeSelector(t), - )) + )); }, OptionalQName::Some(_, None) => unreachable!(), OptionalQName::Some(ns, Some(ln)) => { @@ -1691,7 +1689,7 @@ where Ok(t) => { return Err(location.new_custom_error( SelectorParseErrorKind::UnexpectedTokenInAttributeSelector(t.clone()), - )) + )); }, }; @@ -1768,11 +1766,12 @@ impl AttributeFlags { AttributeFlags::CaseSensitive => ParsedCaseSensitivity::ExplicitCaseSensitive, AttributeFlags::AsciiCaseInsensitive => ParsedCaseSensitivity::AsciiCaseInsensitive, AttributeFlags::CaseSensitivityDependsOnName => { - if !have_namespace && include!(concat!( - env!("OUT_DIR"), - "/ascii_case_insensitive_html_attributes.rs" - )) - .contains(local_name) + if !have_namespace && + include!(concat!( + env!("OUT_DIR"), + "/ascii_case_insensitive_html_attributes.rs" + )) + .contains(local_name) { ParsedCaseSensitivity::AsciiCaseInsensitiveIfInHtmlElementInHtmlDocument } else { @@ -1961,7 +1960,7 @@ where &Token::Ident(ref name) => name.clone(), t => { return Err(location - .new_custom_error(SelectorParseErrorKind::NoIdentForPseudo(t.clone()))) + .new_custom_error(SelectorParseErrorKind::NoIdentForPseudo(t.clone()))); }, }; diff --git a/servo/components/style/attr.rs b/servo/components/style/attr.rs index 2e2372be2d71..16173d640571 100644 --- a/servo/components/style/attr.rs +++ b/servo/components/style/attr.rs @@ -6,7 +6,6 @@ //! //! [attr]: https://dom.spec.whatwg.org/#interface-attr -use app_units::Au; use crate::properties::PropertyDeclarationBlock; use crate::shared_lock::Locked; use crate::str::str_join; @@ -14,6 +13,7 @@ use crate::str::{read_exponent, read_fraction, HTML_SPACE_CHARACTERS}; use crate::str::{read_numbers, split_commas, split_html_space_chars}; use crate::values::specified::Length; use crate::{Atom, LocalName, Namespace, Prefix}; +use app_units::Au; use cssparser::{self, Color, RGBA}; use euclid::num::Zero; use num_traits::ToPrimitive; diff --git a/servo/components/style/bloom.rs b/servo/components/style/bloom.rs index 077efa920118..92e6b2a48b42 100644 --- a/servo/components/style/bloom.rs +++ b/servo/components/style/bloom.rs @@ -7,8 +7,8 @@ #![deny(missing_docs)] -use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use crate::dom::{SendElement, TElement}; +use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use owning_ref::OwningHandle; use selectors::bloom::BloomFilter; use servo_arc::Arc; diff --git a/servo/components/style/build_gecko.rs b/servo/components/style/build_gecko.rs index 22a61d1d7e42..734d09569f5f 100644 --- a/servo/components/style/build_gecko.rs +++ b/servo/components/style/build_gecko.rs @@ -515,8 +515,7 @@ mod bindings { "pub type nsTArrayBorrowed_{}<'a> = ", "&'a mut ::gecko_bindings::structs::nsTArray<{}>;" ), - cpp_type, - rust_type + cpp_type, rust_type )) }) .handle_str_items("servo-immutable-borrow-types", |b, ty| b.borrowed_type(ty)) diff --git a/servo/components/style/context.rs b/servo/components/style/context.rs index 42e506777ab3..aca1d24f2eaf 100644 --- a/servo/components/style/context.rs +++ b/servo/components/style/context.rs @@ -4,7 +4,6 @@ //! The context within which style is calculated. -use app_units::Au; #[cfg(feature = "servo")] use crate::animation::Animation; use crate::bloom::StyleBloom; @@ -29,6 +28,7 @@ use crate::thread_state::{self, ThreadState}; use crate::timer::Timer; use crate::traversal::DomTraversal; use crate::traversal_flags::TraversalFlags; +use app_units::Au; #[cfg(feature = "servo")] use crossbeam_channel::Sender; use euclid::Size2D; diff --git a/servo/components/style/custom_properties.rs b/servo/components/style/custom_properties.rs index 130c92b0e9b2..6bc2b331e35a 100644 --- a/servo/components/style/custom_properties.rs +++ b/servo/components/style/custom_properties.rs @@ -434,7 +434,7 @@ fn parse_declaration_value_block<'i, 't>( return Ok(( TokenSerializationType::nothing(), TokenSerializationType::nothing(), - )) + )); }, }; let first_token_type = token.serialization_type(); diff --git a/servo/components/style/dom.rs b/servo/components/style/dom.rs index eee5b9d90ef0..1c64543310c4 100644 --- a/servo/components/style/dom.rs +++ b/servo/components/style/dom.rs @@ -7,7 +7,6 @@ #![allow(unsafe_code)] #![deny(missing_docs)] -use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use crate::applicable_declarations::ApplicableDeclarationBlock; #[cfg(feature = "gecko")] use crate::context::PostAnimationTasks; @@ -23,6 +22,7 @@ use crate::shared_lock::Locked; use crate::stylist::CascadeData; use crate::traversal_flags::TraversalFlags; use crate::{Atom, LocalName, Namespace, WeakAtom}; +use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use selectors::matching::{ElementSelectorFlags, QuirksMode, VisitedHandlingMode}; use selectors::sink::Push; use selectors::Element as SelectorsElement; @@ -42,10 +42,7 @@ use std::ops::Deref; /// data structures. Also, layout code tends to be faster when the DOM is not being accessed, for /// locality reasons. Using `OpaqueNode` enforces this invariant. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -#[cfg_attr( - feature = "servo", - derive(MallocSizeOf, Deserialize, Serialize) -)] +#[cfg_attr(feature = "servo", derive(MallocSizeOf, Deserialize, Serialize))] pub struct OpaqueNode(pub usize); impl OpaqueNode { diff --git a/servo/components/style/font_face.rs b/servo/components/style/font_face.rs index 7b911cbb76c4..38c4bb788338 100644 --- a/servo/components/style/font_face.rs +++ b/servo/components/style/font_face.rs @@ -336,9 +336,10 @@ impl<'a> FontFace<'a> { // We support only opentype fonts and truetype is an alias for // that format. Sources without format hints need to be // downloaded in case we support them. - hints.is_empty() || hints - .iter() - .any(|hint| hint == "truetype" || hint == "opentype" || hint == "woff") + hints.is_empty() || + hints.iter().any(|hint| { + hint == "truetype" || hint == "opentype" || hint == "woff" + }) } else { true } diff --git a/servo/components/style/font_metrics.rs b/servo/components/style/font_metrics.rs index 031faa7c5366..0c37a4446588 100644 --- a/servo/components/style/font_metrics.rs +++ b/servo/components/style/font_metrics.rs @@ -6,12 +6,12 @@ #![deny(missing_docs)] -use app_units::Au; use crate::context::SharedStyleContext; use crate::logical_geometry::WritingMode; use crate::media_queries::Device; use crate::properties::style_structs::Font; use crate::Atom; +use app_units::Au; /// Represents the font metrics that style needs from a font to compute the /// value of certain CSS units like `ex`. diff --git a/servo/components/style/gecko/conversions.rs b/servo/components/style/gecko/conversions.rs index 4dfb989f7d79..e077a9f9666e 100644 --- a/servo/components/style/gecko/conversions.rs +++ b/servo/components/style/gecko/conversions.rs @@ -10,7 +10,6 @@ #![allow(unsafe_code)] -use app_units::Au; use crate::gecko::values::GeckoStyleCoordConvertible; use crate::gecko_bindings::bindings; use crate::gecko_bindings::structs::RawGeckoGfxMatrix4x4; @@ -30,6 +29,7 @@ use crate::values::generics::box_::VerticalAlign; use crate::values::generics::grid::{TrackListValue, TrackSize}; use crate::values::generics::image::{CompatMode, GradientItem, Image as GenericImage}; use crate::values::generics::rect::Rect; +use app_units::Au; use std::f32::consts::PI; impl From for nsStyleCoord_CalcValue { diff --git a/servo/components/style/gecko/data.rs b/servo/components/style/gecko/data.rs index 6ac0d01f9974..af98f116afb5 100644 --- a/servo/components/style/gecko/data.rs +++ b/servo/components/style/gecko/data.rs @@ -4,7 +4,6 @@ //! Data needed to style a Gecko document. -use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use crate::context::QuirksMode; use crate::dom::TElement; use crate::gecko_bindings::bindings::{self, RawServoStyleSet}; @@ -18,6 +17,7 @@ use crate::selector_parser::SnapshotMap; use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards}; use crate::stylesheets::{CssRule, Origin, StylesheetContents, StylesheetInDocument}; use crate::stylist::Stylist; +use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use malloc_size_of::MallocSizeOfOps; use servo_arc::Arc; use std::fmt; diff --git a/servo/components/style/gecko/media_features.rs b/servo/components/style/gecko/media_features.rs index af166e60986c..29f5b61816f6 100644 --- a/servo/components/style/gecko/media_features.rs +++ b/servo/components/style/gecko/media_features.rs @@ -4,7 +4,6 @@ //! Gecko's media feature list and evaluator. -use app_units::Au; use crate::gecko_bindings::bindings; use crate::gecko_bindings::structs; use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements}; @@ -14,6 +13,7 @@ use crate::media_queries::{Device, MediaType}; use crate::values::computed::CSSPixelLength; use crate::values::computed::Resolution; use crate::Atom; +use app_units::Au; use euclid::Size2D; fn viewport_size(device: &Device) -> Size2D { diff --git a/servo/components/style/gecko/media_queries.rs b/servo/components/style/gecko/media_queries.rs index f7ed0fd85b73..851422467ce6 100644 --- a/servo/components/style/gecko/media_queries.rs +++ b/servo/components/style/gecko/media_queries.rs @@ -4,8 +4,6 @@ //! Gecko's media-query device and expression representation. -use app_units::Au; -use app_units::AU_PER_PX; use crate::custom_properties::CssEnvironment; use crate::gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor}; use crate::gecko_bindings::bindings; @@ -16,6 +14,8 @@ use crate::properties::ComputedValues; use crate::string_cache::Atom; use crate::values::computed::font::FontSize; use crate::values::{CustomIdent, KeyframesName}; +use app_units::Au; +use app_units::AU_PER_PX; use cssparser::RGBA; use euclid::Size2D; use euclid::TypedScale; diff --git a/servo/components/style/gecko/selector_parser.rs b/servo/components/style/gecko/selector_parser.rs index 330bf6057a20..b00cb4f909e3 100644 --- a/servo/components/style/gecko/selector_parser.rs +++ b/servo/components/style/gecko/selector_parser.rs @@ -230,33 +230,34 @@ impl NonTSPseudoClass { /// Returns true if the given pseudoclass should trigger style sharing cache /// revalidation. pub fn needs_cache_revalidation(&self) -> bool { - self.state_flag().is_empty() && !matches!(*self, - // :-moz-any is handled by the revalidation visitor walking - // the things inside it; it does not need to cause - // revalidation on its own. - NonTSPseudoClass::MozAny(_) | - // :dir() depends on state only, but doesn't use state_flag - // because its semantics don't quite match. Nevertheless, it - // doesn't need cache revalidation, because we already compare - // states for elements and candidates. - NonTSPseudoClass::Dir(_) | - // :-moz-is-html only depends on the state of the document and - // the namespace of the element; the former is invariant - // across all the elements involved and the latter is already - // checked for by our caching precondtions. - NonTSPseudoClass::MozIsHTML | - // :-moz-placeholder is parsed but never matches. - NonTSPseudoClass::MozPlaceholder | - // :-moz-locale-dir and :-moz-window-inactive depend only on - // the state of the document, which is invariant across all - // the elements involved in a given style cache. - NonTSPseudoClass::MozLocaleDir(_) | - NonTSPseudoClass::MozWindowInactive | - // Similar for the document themes. - NonTSPseudoClass::MozLWTheme | - NonTSPseudoClass::MozLWThemeBrightText | - NonTSPseudoClass::MozLWThemeDarkText - ) + self.state_flag().is_empty() && + !matches!(*self, + // :-moz-any is handled by the revalidation visitor walking + // the things inside it; it does not need to cause + // revalidation on its own. + NonTSPseudoClass::MozAny(_) | + // :dir() depends on state only, but doesn't use state_flag + // because its semantics don't quite match. Nevertheless, it + // doesn't need cache revalidation, because we already compare + // states for elements and candidates. + NonTSPseudoClass::Dir(_) | + // :-moz-is-html only depends on the state of the document and + // the namespace of the element; the former is invariant + // across all the elements involved and the latter is already + // checked for by our caching precondtions. + NonTSPseudoClass::MozIsHTML | + // :-moz-placeholder is parsed but never matches. + NonTSPseudoClass::MozPlaceholder | + // :-moz-locale-dir and :-moz-window-inactive depend only on + // the state of the document, which is invariant across all + // the elements involved in a given style cache. + NonTSPseudoClass::MozLocaleDir(_) | + NonTSPseudoClass::MozWindowInactive | + // Similar for the document themes. + NonTSPseudoClass::MozLWTheme | + NonTSPseudoClass::MozLWThemeBrightText | + NonTSPseudoClass::MozLWThemeDarkText + ) } /// Returns true if the evaluation of the pseudo-class depends on the diff --git a/servo/components/style/gecko/values.rs b/servo/components/style/gecko/values.rs index a9162264baae..b22f68cd05d0 100644 --- a/servo/components/style/gecko/values.rs +++ b/servo/components/style/gecko/values.rs @@ -6,7 +6,6 @@ //! Different kind of helpers to interact with Gecko values. -use app_units::Au; use crate::counter_style::{Symbol, Symbols}; use crate::gecko_bindings::structs::{self, nsStyleCoord, CounterStylePtr}; use crate::gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius}; @@ -27,6 +26,7 @@ use crate::values::generics::length::{MaxLength, MozLength}; use crate::values::generics::{CounterStyleOrNone, NonNegative}; use crate::values::{Auto, Either, None_, Normal}; use crate::Atom; +use app_units::Au; use cssparser::RGBA; use nsstring::{nsACString, nsCStr}; use std::cmp::max; diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs index 5e711cabd5c3..1a9ea0b3ad90 100644 --- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -14,8 +14,6 @@ //! style system it's kind of pointless in the Stylo case, and only Servo forces //! the separation between the style system implementation and everything else. -use app_units::Au; -use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use crate::applicable_declarations::ApplicableDeclarationBlock; use crate::author_styles::AuthorStyles; use crate::context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks}; @@ -72,6 +70,8 @@ use crate::shared_lock::Locked; use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; use crate::stylist::CascadeData; use crate::CaseSensitivityExt; +use app_units::Au; +use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator}; use selectors::attr::{CaseSensitivity, NamespaceConstraint}; use selectors::matching::VisitedHandlingMode; @@ -931,13 +931,14 @@ impl<'le> GeckoElement<'le> { debug_assert_eq!(to.is_some(), from.is_some()); - combined_duration > 0.0f32 && from != to && from - .unwrap() - .animate( - to.as_ref().unwrap(), - Procedure::Interpolate { progress: 0.5 }, - ) - .is_ok() + combined_duration > 0.0f32 && + from != to && + from.unwrap() + .animate( + to.as_ref().unwrap(), + Procedure::Interpolate { progress: 0.5 }, + ) + .is_ok() } } @@ -1241,10 +1242,11 @@ impl<'le> TElement for GeckoElement<'le> { } fn owner_doc_matches_for_testing(&self, device: &Device) -> bool { - self.as_node().owner_doc().0 as *const structs::Document == device - .pres_context() - .mDocument - .mRawPtr + self.as_node().owner_doc().0 as *const structs::Document == + device + .pres_context() + .mDocument + .mRawPtr } fn style_attribute(&self) -> Option>> { @@ -1861,9 +1863,8 @@ impl<'le> TElement for GeckoElement<'le> { .intersects(NonTSPseudoClass::Active.state_flag()); if active { let declarations = unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0) }; - let declarations: Option< - &RawOffsetArc>, - > = declarations.and_then(|s| s.as_arc_opt()); + let declarations: Option<&RawOffsetArc>> = + declarations.and_then(|s| s.as_arc_opt()); if let Some(decl) = declarations { hints.push(ApplicableDeclarationBlock::from_declarations( decl.clone_arc(), @@ -2078,11 +2079,10 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { return false; } - debug_assert!( - self.as_node() - .parent_node() - .map_or(false, |p| p.is_document()) - ); + debug_assert!(self + .as_node() + .parent_node() + .map_or(false, |p| p.is_document())); unsafe { bindings::Gecko_IsRootElement(self.0) } } diff --git a/servo/components/style/gecko_bindings/mod.rs b/servo/components/style/gecko_bindings/mod.rs index 75e045a4bbdd..78fc8e3ae76d 100644 --- a/servo/components/style/gecko_bindings/mod.rs +++ b/servo/components/style/gecko_bindings/mod.rs @@ -4,12 +4,7 @@ //! Gecko's C++ bindings, along with some rust helpers to ease its use. -#[allow( - dead_code, - improper_ctypes, - non_camel_case_types, - missing_docs -)] +#[allow(dead_code, improper_ctypes, non_camel_case_types, missing_docs)] pub mod bindings { include!(concat!(env!("OUT_DIR"), "/gecko/bindings.rs")); } diff --git a/servo/components/style/gecko_bindings/sugar/ns_css_shadow_item.rs b/servo/components/style/gecko_bindings/sugar/ns_css_shadow_item.rs index 4a17093ba077..03d68576deab 100644 --- a/servo/components/style/gecko_bindings/sugar/ns_css_shadow_item.rs +++ b/servo/components/style/gecko_bindings/sugar/ns_css_shadow_item.rs @@ -4,9 +4,9 @@ //! Rust helpers for Gecko's `nsCSSShadowItem`. -use app_units::Au; use crate::gecko_bindings::structs::nsCSSShadowItem; use crate::values::computed::effects::{BoxShadow, SimpleShadow}; +use app_units::Au; impl nsCSSShadowItem { /// Sets this item from the given box shadow. diff --git a/servo/components/style/invalidation/element/element_wrapper.rs b/servo/components/style/invalidation/element/element_wrapper.rs index ca18c6d8e76c..c794eb15c2c2 100644 --- a/servo/components/style/invalidation/element/element_wrapper.rs +++ b/servo/components/style/invalidation/element/element_wrapper.rs @@ -208,10 +208,10 @@ where // Instead, we use the `visited_handling` to determine if they // match. NonTSPseudoClass::Link => { - return self.is_link() && context.visited_handling().matches_unvisited() + return self.is_link() && context.visited_handling().matches_unvisited(); }, NonTSPseudoClass::Visited => { - return self.is_link() && context.visited_handling().matches_visited() + return self.is_link() && context.visited_handling().matches_visited(); }, #[cfg(feature = "gecko")] diff --git a/servo/components/style/logical_geometry.rs b/servo/components/style/logical_geometry.rs index 55ba76a60d57..b6cc9ef5bc67 100644 --- a/servo/components/style/logical_geometry.rs +++ b/servo/components/style/logical_geometry.rs @@ -1221,11 +1221,12 @@ impl + Sub> LogicalRect { pub fn translate(&self, offset: &LogicalPoint) -> LogicalRect { LogicalRect { - start: self.start + LogicalSize { - inline: offset.i, - block: offset.b, - debug_writing_mode: offset.debug_writing_mode, - }, + start: self.start + + LogicalSize { + inline: offset.i, + block: offset.b, + debug_writing_mode: offset.debug_writing_mode, + }, size: self.size, debug_writing_mode: self.debug_writing_mode, } diff --git a/servo/components/style/matching.rs b/servo/components/style/matching.rs index c7c547a3c61e..b1240443dea9 100644 --- a/servo/components/style/matching.rs +++ b/servo/components/style/matching.rs @@ -469,11 +469,9 @@ trait PrivateMatchMethods: TElement { pseudo: Option<&PseudoElement>, ) -> ChildCascadeRequirement { debug!("accumulate_damage_for: {:?}", self); - debug_assert!( - !shared_context - .traversal_flags - .contains(TraversalFlags::Forgetful) - ); + debug_assert!(!shared_context + .traversal_flags + .contains(TraversalFlags::Forgetful)); let difference = self.compute_style_difference(old_values, new_values, pseudo); diff --git a/servo/components/style/media_queries/media_feature.rs b/servo/components/style/media_queries/media_feature.rs index 69808242772c..d5e015b3b072 100644 --- a/servo/components/style/media_queries/media_feature.rs +++ b/servo/components/style/media_queries/media_feature.rs @@ -30,9 +30,10 @@ type MediaFeatureEvaluator = fn( pub type KeywordSerializer = fn(KeywordDiscriminant) -> String; /// Parses a given identifier. -pub type KeywordParser = - for<'a, 'i, 't> fn(context: &'a ParserContext, input: &'a mut Parser<'i, 't>) - -> Result>; +pub type KeywordParser = for<'a, 'i, 't> fn( + context: &'a ParserContext, + input: &'a mut Parser<'i, 't>, +) -> Result>; /// An evaluator for a given media feature. /// diff --git a/servo/components/style/media_queries/media_feature_expression.rs b/servo/components/style/media_queries/media_feature_expression.rs index 5144189778de..ec864510c725 100644 --- a/servo/components/style/media_queries/media_feature_expression.rs +++ b/servo/components/style/media_queries/media_feature_expression.rs @@ -134,10 +134,11 @@ impl RangeOrOperator { match range_or_op { RangeOrOperator::Range(range) => { - cmp == Ordering::Equal || match range { - Range::Min => cmp == Ordering::Greater, - Range::Max => cmp == Ordering::Less, - } + cmp == Ordering::Equal || + match range { + Range::Min => cmp == Ordering::Greater, + Range::Max => cmp == Ordering::Less, + } }, RangeOrOperator::Operator(op) => match op { Operator::Equal => cmp == Ordering::Equal, @@ -344,7 +345,7 @@ impl MediaFeatureExpression { Err(()) => { return Err(location.new_custom_error( StyleParseErrorKind::MediaQueryExpectedFeatureName(ident.clone()), - )) + )); }, } diff --git a/servo/components/style/media_queries/media_list.rs b/servo/components/style/media_queries/media_list.rs index bd4125d53247..0acf4f1bdf9d 100644 --- a/servo/components/style/media_queries/media_list.rs +++ b/servo/components/style/media_queries/media_list.rs @@ -74,21 +74,22 @@ impl MediaList { pub fn evaluate(&self, device: &Device, quirks_mode: QuirksMode) -> bool { // Check if it is an empty media query list or any queries match. // https://drafts.csswg.org/mediaqueries-4/#mq-list - self.media_queries.is_empty() || self.media_queries.iter().any(|mq| { - let media_match = mq.media_type.matches(device.media_type()); + self.media_queries.is_empty() || + self.media_queries.iter().any(|mq| { + let media_match = mq.media_type.matches(device.media_type()); - // Check if the media condition match. - let query_match = media_match && mq - .condition - .as_ref() - .map_or(true, |c| c.matches(device, quirks_mode)); + // Check if the media condition match. + let query_match = media_match && + mq.condition + .as_ref() + .map_or(true, |c| c.matches(device, quirks_mode)); - // Apply the logical NOT qualifier to the result - match mq.qualifier { - Some(Qualifier::Not) => !query_match, - _ => query_match, - } - }) + // Apply the logical NOT qualifier to the result + match mq.qualifier { + Some(Qualifier::Not) => !query_match, + _ => query_match, + } + }) } /// Whether this `MediaList` contains no media queries. diff --git a/servo/components/style/parallel.rs b/servo/components/style/parallel.rs index 1b9f80f5722c..237453084df7 100644 --- a/servo/components/style/parallel.rs +++ b/servo/components/style/parallel.rs @@ -22,11 +22,11 @@ #![deny(missing_docs)] -use arrayvec::ArrayVec; use crate::context::{StyleContext, ThreadLocalStyleContext}; use crate::dom::{OpaqueNode, SendNode, TElement}; use crate::scoped_tls::ScopedTLS; use crate::traversal::{DomTraversal, PerLevelTraversalData}; +use arrayvec::ArrayVec; use itertools::Itertools; use rayon; use smallvec::SmallVec; diff --git a/servo/components/style/servo/media_queries.rs b/servo/components/style/servo/media_queries.rs index d35e8dc3ccd0..b3c99cf875a9 100644 --- a/servo/components/style/servo/media_queries.rs +++ b/servo/components/style/servo/media_queries.rs @@ -4,7 +4,6 @@ //! Servo's media-query device and expression representation. -use app_units::Au; use crate::custom_properties::CssEnvironment; use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements}; use crate::media_queries::media_feature::{Evaluator, MediaFeatureDescription}; @@ -14,6 +13,7 @@ use crate::properties::ComputedValues; use crate::values::computed::font::FontSize; use crate::values::computed::CSSPixelLength; use crate::values::KeyframesName; +use app_units::Au; use cssparser::RGBA; use euclid::{Size2D, TypedScale, TypedSize2D}; use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering}; diff --git a/servo/components/style/servo/selector_parser.rs b/servo/components/style/servo/selector_parser.rs index cd7252280177..9abfe9769197 100644 --- a/servo/components/style/servo/selector_parser.rs +++ b/servo/components/style/servo/selector_parser.rs @@ -457,7 +457,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> { parser: &mut CssParser<'i, 't>, ) -> Result> { use self::NonTSPseudoClass::*; - let pseudo_class = match_ignore_ascii_case!{ &name, + let pseudo_class = match_ignore_ascii_case! { &name, "lang" => { Lang(parser.expect_ident_or_string()?.as_ref().into()) } diff --git a/servo/components/style/shared_lock.rs b/servo/components/style/shared_lock.rs index 57038f627fe3..09bfa1635034 100644 --- a/servo/components/style/shared_lock.rs +++ b/servo/components/style/shared_lock.rs @@ -4,10 +4,10 @@ //! Different objects protected by the same lock -#[cfg(feature = "gecko")] -use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use crate::str::{CssString, CssStringWriter}; use crate::stylesheets::Origin; +#[cfg(feature = "gecko")] +use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; #[cfg(feature = "servo")] use parking_lot::RwLock; use servo_arc::Arc; diff --git a/servo/components/style/sharing/mod.rs b/servo/components/style/sharing/mod.rs index 843fd76e2e66..c7be23572c67 100644 --- a/servo/components/style/sharing/mod.rs +++ b/servo/components/style/sharing/mod.rs @@ -64,7 +64,6 @@ //! selectors are effectively stripped off, so that matching them all against //! elements makes sense. -use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use crate::applicable_declarations::ApplicableDeclarationBlock; use crate::bloom::StyleBloom; use crate::context::{SelectorFlagsMap, SharedStyleContext, StyleContext}; @@ -75,6 +74,7 @@ use crate::rule_tree::StrongRuleNode; use crate::style_resolver::{PrimaryStyle, ResolvedElementStyles}; use crate::stylist::Stylist; use crate::Atom; +use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use owning_ref::OwningHandle; use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode}; use selectors::NthIndexCache; diff --git a/servo/components/style/style_adjuster.rs b/servo/components/style/style_adjuster.rs index ea4e6a43d74a..248d0ad0661b 100644 --- a/servo/components/style/style_adjuster.rs +++ b/servo/components/style/style_adjuster.rs @@ -5,7 +5,6 @@ //! A struct to encapsulate all the style fixups and flags propagations //! a computed style needs in order for it to adhere to the CSS spec. -use app_units::Au; use crate::dom::TElement; use crate::properties::computed_value_flags::ComputedValueFlags; use crate::properties::longhands::display::computed_value::T as Display; @@ -13,6 +12,7 @@ use crate::properties::longhands::float::computed_value::T as Float; use crate::properties::longhands::overflow_x::computed_value::T as Overflow; use crate::properties::longhands::position::computed_value::T as Position; use crate::properties::{self, ComputedValues, StyleBuilder}; +use app_units::Au; /// A struct that implements all the adjustment methods. /// @@ -190,12 +190,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { let is_root = self.style.pseudo.is_none() && element.map_or(false, |e| e.is_root()); blockify_if!(is_root); if !self.skip_item_display_fixup(element) { - blockify_if!( - layout_parent_style - .get_box() - .clone_display() - .is_item_container() - ); + blockify_if!(layout_parent_style + .get_box() + .clone_display() + .is_item_container()); } let is_item_or_root = blockify; @@ -220,11 +218,12 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { pub fn set_bits(&mut self) { let display = self.style.get_box().clone_display(); - if !display.is_contents() && !self - .style - .get_text() - .clone_text_decoration_line() - .is_empty() + if !display.is_contents() && + !self + .style + .get_text() + .clone_text_decoration_line() + .is_empty() { self.style .flags @@ -299,10 +298,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { #[cfg(feature = "gecko")] fn adjust_for_text_in_ruby(&mut self) { let parent_display = self.style.get_parent_box().clone_display(); - if parent_display.is_ruby_type() || self - .style - .get_parent_flags() - .contains(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK) + if parent_display.is_ruby_type() || + self.style + .get_parent_flags() + .contains(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK) { self.style .flags diff --git a/servo/components/style/stylesheets/font_feature_values_rule.rs b/servo/components/style/stylesheets/font_feature_values_rule.rs index d7e7315d7be4..a93ed43d4758 100644 --- a/servo/components/style/stylesheets/font_feature_values_rule.rs +++ b/servo/components/style/stylesheets/font_feature_values_rule.rs @@ -70,11 +70,7 @@ impl Parse for SingleValue { match *input.next()? { Token::Number { int_value: Some(v), .. - } - if v >= 0 => - { - Ok(SingleValue(v as u32)) - }, + } if v >= 0 => Ok(SingleValue(v as u32)), ref t => Err(location.new_unexpected_token_error(t.clone())), } } @@ -103,22 +99,14 @@ impl Parse for PairValues { let first = match *input.next()? { Token::Number { int_value: Some(a), .. - } - if a >= 0 => - { - a as u32 - }, + } if a >= 0 => a as u32, ref t => return Err(location.new_unexpected_token_error(t.clone())), }; let location = input.current_source_location(); match input.next() { Ok(&Token::Number { int_value: Some(b), .. - }) - if b >= 0 => - { - Ok(PairValues(first, Some(b as u32))) - }, + }) if b >= 0 => Ok(PairValues(first, Some(b as u32))), // It can't be anything other than number. Ok(t) => Err(location.new_unexpected_token_error(t.clone())), // It can be just one value. @@ -157,11 +145,9 @@ impl Parse for VectorValues { match input.next() { Ok(&Token::Number { int_value: Some(a), .. - }) - if a >= 0 => - { + }) if a >= 0 => { vec.push(a as u32); - } + }, // It can't be anything other than number. Ok(t) => return Err(location.new_unexpected_token_error(t.clone())), Err(_) => break, diff --git a/servo/components/style/stylesheets/keyframes_rule.rs b/servo/components/style/stylesheets/keyframes_rule.rs index 59f015bf4ae6..662bc9ae4814 100644 --- a/servo/components/style/stylesheets/keyframes_rule.rs +++ b/servo/components/style/stylesheets/keyframes_rule.rs @@ -141,11 +141,7 @@ impl KeyframePercentage { Token::Percentage { unit_value: percentage, .. - } - if percentage >= 0. && percentage <= 1. => - { - Ok(KeyframePercentage::new(percentage)) - }, + } if percentage >= 0. && percentage <= 1. => Ok(KeyframePercentage::new(percentage)), _ => Err(input.new_unexpected_token_error(token)), } } @@ -600,7 +596,7 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for KeyframeDeclarationParser<'a, 'b> { let id = match PropertyId::parse(&name, self.context) { Ok(id) => id, Err(()) => { - return Err(input.new_custom_error(StyleParseErrorKind::UnknownProperty(name))) + return Err(input.new_custom_error(StyleParseErrorKind::UnknownProperty(name))); }, }; diff --git a/servo/components/style/stylesheets/rule_parser.rs b/servo/components/style/stylesheets/rule_parser.rs index a2a062ba1739..44943259b38d 100644 --- a/servo/components/style/stylesheets/rule_parser.rs +++ b/servo/components/style/stylesheets/rule_parser.rs @@ -107,9 +107,10 @@ impl<'b> TopLevelRuleParser<'b> { // If there's anything that isn't a namespace rule (or import rule, but // we checked that already at the beginning), reject with a // StateError. - if new_state == State::Namespaces && ctx.rule_list[ctx.index..] - .iter() - .any(|r| !matches!(*r, CssRule::Namespace(..))) + if new_state == State::Namespaces && + ctx.rule_list[ctx.index..] + .iter() + .any(|r| !matches!(*r, CssRule::Namespace(..))) { self.dom_error = Some(RulesMutateError::InvalidState); return false; diff --git a/servo/components/style/stylesheets/supports_rule.rs b/servo/components/style/stylesheets/supports_rule.rs index e0d23ea0f5d5..45f6f97812dc 100644 --- a/servo/components/style/stylesheets/supports_rule.rs +++ b/servo/components/style/stylesheets/supports_rule.rs @@ -145,7 +145,7 @@ impl SupportsCondition { function: &str, input: &mut Parser<'i, 't>, ) -> Result> { - match_ignore_ascii_case!{ function, + match_ignore_ascii_case! { function, // Although this is an internal syntax, it is not necessary // to check parsing context as far as we accept any // unexpected token as future syntax, and evaluate it to @@ -350,9 +350,8 @@ impl RawSelector { use crate::selector_parser::PseudoElement; use selectors::parser::Component; - let has_any_unknown_webkit_pseudo = selector.has_pseudo_element() && selector - .iter_raw_match_order() - .any(|component| { + let has_any_unknown_webkit_pseudo = selector.has_pseudo_element() && + selector.iter_raw_match_order().any(|component| { matches!( *component, Component::PseudoElement(PseudoElement::UnknownWebkit(..)) diff --git a/servo/components/style/stylesheets/viewport_rule.rs b/servo/components/style/stylesheets/viewport_rule.rs index d7b644114c64..4df576a15ab8 100644 --- a/servo/components/style/stylesheets/viewport_rule.rs +++ b/servo/components/style/stylesheets/viewport_rule.rs @@ -7,7 +7,6 @@ //! [at]: https://drafts.csswg.org/css-device-adapt/#atviewport-rule //! [meta]: https://drafts.csswg.org/css-device-adapt/#viewport-meta -use app_units::Au; use crate::context::QuirksMode; use crate::error_reporting::ContextualParseError; use crate::font_metrics::get_metrics_provider_for_product; @@ -20,6 +19,7 @@ use crate::str::CssStringWriter; use crate::stylesheets::{Origin, StylesheetInDocument}; use crate::values::computed::{Context, ToComputedValue}; use crate::values::specified::{LengthOrPercentageOrAuto, NoCalcLength, ViewportPercentageLength}; +use app_units::Au; use cssparser::CowRcStr; use cssparser::{parse_important, AtRuleParser, DeclarationListParser, DeclarationParser, Parser}; use euclid::TypedSize2D; diff --git a/servo/components/style/stylist.rs b/servo/components/style/stylist.rs index 1d021e6e3e07..3815a8a3da6a 100644 --- a/servo/components/style/stylist.rs +++ b/servo/components/style/stylist.rs @@ -355,10 +355,7 @@ pub struct Stylist { stylesheets: StylistStylesheetSet, /// If true, the quirks-mode stylesheet is applied. - #[cfg_attr( - feature = "servo", - ignore_malloc_size_of = "defined in selectors" - )] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "defined in selectors")] quirks_mode: QuirksMode, /// Selector maps for all of the style sheets in the stylist, after @@ -1572,9 +1569,8 @@ impl<'a> SelectorVisitor for StylistSelectorVisitor<'a> { // Also, note that this call happens before we visit any of the simple // selectors in the next ComplexSelector, so we can use this to skip // looking at them. - self.passed_rightmost_selector = - self.passed_rightmost_selector || - !matches!(combinator, None | Some(Combinator::PseudoElement)); + self.passed_rightmost_selector = self.passed_rightmost_selector || + !matches!(combinator, None | Some(Combinator::PseudoElement)); true } @@ -1591,9 +1587,8 @@ impl<'a> SelectorVisitor for StylistSelectorVisitor<'a> { } fn visit_simple_selector(&mut self, s: &Component) -> bool { - self.needs_revalidation = - self.needs_revalidation || - component_needs_revalidation(s, self.passed_rightmost_selector); + self.needs_revalidation = self.needs_revalidation || + component_needs_revalidation(s, self.passed_rightmost_selector); match *s { Component::NonTSPseudoClass(ref p) => { @@ -2026,10 +2021,10 @@ impl CascadeData { debug!("Found valid keyframes rule: {:?}", *keyframes_rule); // Don't let a prefixed keyframes animation override a non-prefixed one. - let needs_insertion = keyframes_rule.vendor_prefix.is_none() || self - .animations - .get(keyframes_rule.name.as_atom()) - .map_or(true, |rule| rule.vendor_prefix.is_some()); + let needs_insertion = keyframes_rule.vendor_prefix.is_none() || + self.animations + .get(keyframes_rule.name.as_atom()) + .map_or(true, |rule| rule.vendor_prefix.is_some()); if needs_insertion { let animation = KeyframesAnimation::from_keyframes( &keyframes_rule.keyframes, diff --git a/servo/components/style/traversal.rs b/servo/components/style/traversal.rs index 89cbfb834771..f1821900bb4b 100644 --- a/servo/components/style/traversal.rs +++ b/servo/components/style/traversal.rs @@ -208,11 +208,11 @@ pub trait DomTraversal: Sync { // animation-only restyle hint or recascade. if traversal_flags.for_animation_only() { return data.map_or(false, |d| d.has_styles()) && - (el.has_animation_only_dirty_descendants() || data - .as_ref() - .unwrap() - .hint - .has_animation_hint_or_recascade()); + (el.has_animation_only_dirty_descendants() || + data.as_ref() + .unwrap() + .hint + .has_animation_hint_or_recascade()); } // Non-incremental layout visits every node. @@ -516,9 +516,8 @@ pub fn recalc_style_at( !child_cascade_requirement.can_skip_cascade() || is_servo_nonincremental_layout(); - traverse_children = - traverse_children && - !traversal.should_cull_subtree(context, element, &data, is_initial_style); + traverse_children = traverse_children && + !traversal.should_cull_subtree(context, element, &data, is_initial_style); // Examine our children, and enqueue the appropriate ones for traversal. if traverse_children { diff --git a/servo/components/style/values/animated/mod.rs b/servo/components/style/values/animated/mod.rs index 1c96d13accac..bd0a7af1f95b 100644 --- a/servo/components/style/values/animated/mod.rs +++ b/servo/components/style/values/animated/mod.rs @@ -8,7 +8,6 @@ //! computed values and need yet another intermediate representation. This //! module's raison d'ĂȘtre is to ultimately contain all these types. -use app_units::Au; use crate::properties::PropertyId; use crate::values::computed::length::CalcLengthOrPercentage; use crate::values::computed::url::ComputedUrl; @@ -16,6 +15,7 @@ use crate::values::computed::Angle as ComputedAngle; use crate::values::computed::Image; use crate::values::CSSFloat; use crate::values::specified::SVGPathData; +use app_units::Au; use euclid::{Point2D, Size2D}; use smallvec::SmallVec; use std::cmp; diff --git a/servo/components/style/values/computed/border.rs b/servo/components/style/values/computed/border.rs index e9cb3f3fa83f..09dcfbe117ad 100644 --- a/servo/components/style/values/computed/border.rs +++ b/servo/components/style/values/computed/border.rs @@ -4,7 +4,6 @@ //! Computed types for CSS values related to borders. -use app_units::Au; use crate::values::generics::NonNegative; use crate::values::computed::length::{NonNegativeLengthOrPercentage, NonNegativeLength}; use crate::values::computed::{NonNegativeNumber, NonNegativeNumberOrPercentage}; @@ -15,6 +14,7 @@ use crate::values::generics::border::BorderRadius as GenericBorderRadius; use crate::values::generics::border::BorderSpacing as GenericBorderSpacing; use crate::values::generics::rect::Rect; use crate::values::generics::size::Size; +use app_units::Au; pub use crate::values::specified::border::BorderImageRepeat; diff --git a/servo/components/style/values/computed/font.rs b/servo/components/style/values/computed/font.rs index b818bf998c14..765efd9a0d87 100644 --- a/servo/components/style/values/computed/font.rs +++ b/servo/components/style/values/computed/font.rs @@ -4,8 +4,6 @@ //! Computed values for font properties -use app_units::Au; -use byteorder::{BigEndian, ByteOrder}; #[cfg(feature = "gecko")] use crate::gecko_bindings::sugar::refptr::RefPtr; #[cfg(feature = "gecko")] @@ -19,6 +17,8 @@ use crate::values::specified::font::{self as specified, MAX_FONT_WEIGHT, MIN_FON use crate::values::specified::length::{FontBaseSize, NoCalcLength}; use crate::values::CSSFloat; use crate::Atom; +use app_units::Au; +use byteorder::{BigEndian, ByteOrder}; use cssparser::{serialize_identifier, CssStringWriter, Parser}; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; diff --git a/servo/components/style/values/computed/length.rs b/servo/components/style/values/computed/length.rs index 1af28587a391..240b5ceb1ee9 100644 --- a/servo/components/style/values/computed/length.rs +++ b/servo/components/style/values/computed/length.rs @@ -5,7 +5,6 @@ //! `` computed values, and related ones. use super::{Context, Number, Percentage, ToComputedValue}; -use app_units::Au; use crate::values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero}; use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; use crate::values::generics::length::MaxLength as GenericMaxLength; @@ -15,6 +14,7 @@ use crate::values::generics::NonNegative; use crate::values::specified::length::ViewportPercentageLength; use crate::values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength}; use crate::values::{specified, Auto, CSSFloat, Either, IsAuto, Normal}; +use app_units::Au; use ordered_float::NotNan; use std::fmt::{self, Write}; use std::ops::{Add, Neg}; diff --git a/servo/components/style/values/generics/basic_shape.rs b/servo/components/style/values/generics/basic_shape.rs index 6ffb0da69c3f..bfe709ceb4b7 100644 --- a/servo/components/style/values/generics/basic_shape.rs +++ b/servo/components/style/values/generics/basic_shape.rs @@ -291,11 +291,7 @@ where ( &ShapeSource::Shape(ref this, ref this_box), &ShapeSource::Shape(ref other, ref other_box), - ) - if this_box == other_box => - { - this.compute_squared_distance(other) - }, + ) if this_box == other_box => this.compute_squared_distance(other), (&ShapeSource::Path(ref this), &ShapeSource::Path(ref other)) if this.fill == other.fill => { diff --git a/servo/components/style/values/generics/font.rs b/servo/components/style/values/generics/font.rs index 0d5e6b21eee4..ee14e15bfe5e 100644 --- a/servo/components/style/values/generics/font.rs +++ b/servo/components/style/values/generics/font.rs @@ -4,9 +4,9 @@ //! Generic types for font stuff. +use crate::parser::{Parse, ParserContext}; use app_units::Au; use byteorder::{BigEndian, ReadBytesExt}; -use crate::parser::{Parse, ParserContext}; use cssparser::Parser; use num_traits::One; use std::fmt::{self, Write}; diff --git a/servo/components/style/values/generics/text.rs b/servo/components/style/values/generics/text.rs index df0279c71212..090c3c1f687b 100644 --- a/servo/components/style/values/generics/text.rs +++ b/servo/components/style/values/generics/text.rs @@ -4,10 +4,10 @@ //! Generic types for text properties. -use app_units::Au; use crate::parser::ParserContext; use crate::values::animated::{Animate, Procedure, ToAnimatedZero}; use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; +use app_units::Au; use cssparser::Parser; use style_traits::ParseError; diff --git a/servo/components/style/values/generics/transform.rs b/servo/components/style/values/generics/transform.rs index 91af1355a272..158b7456c762 100644 --- a/servo/components/style/values/generics/transform.rs +++ b/servo/components/style/values/generics/transform.rs @@ -4,13 +4,13 @@ //! Generic types for CSS values that are related to transformations. -use app_units::Au; use crate::values::computed::length::Length as ComputedLength; use crate::values::computed::length::LengthOrPercentage as ComputedLengthOrPercentage; use crate::values::specified::angle::Angle as SpecifiedAngle; use crate::values::specified::length::Length as SpecifiedLength; use crate::values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage; use crate::values::{computed, CSSFloat}; +use app_units::Au; use euclid::{self, Rect, Transform3D}; use num_traits::Zero; use std::fmt::{self, Write}; diff --git a/servo/components/style/values/mod.rs b/servo/components/style/values/mod.rs index 8a47220fd6ad..659ff95b1a7b 100644 --- a/servo/components/style/values/mod.rs +++ b/servo/components/style/values/mod.rs @@ -93,10 +93,7 @@ where } /// Convenience void type to disable some properties and values through types. -#[cfg_attr( - feature = "servo", - derive(Deserialize, MallocSizeOf, Serialize) -)] +#[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))] #[derive( Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss, )] diff --git a/servo/components/style/values/specified/angle.rs b/servo/components/style/values/specified/angle.rs index 6e8cd059f35c..35a0944aed56 100644 --- a/servo/components/style/values/specified/angle.rs +++ b/servo/components/style/values/specified/angle.rs @@ -193,7 +193,7 @@ impl Angle { AllowUnitlessZeroAngle::No => Err(()), }, Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => { - return input.parse_nested_block(|i| CalcNode::parse_angle(context, i)) + return input.parse_nested_block(|i| CalcNode::parse_angle(context, i)); }, _ => Err(()), } diff --git a/servo/components/style/values/specified/box.rs b/servo/components/style/values/specified/box.rs index 54030ba71395..c785fb0c0dbb 100644 --- a/servo/components/style/values/specified/box.rs +++ b/servo/components/style/values/specified/box.rs @@ -218,10 +218,7 @@ impl Display { // Special handling for contents and list-item on the root // element for Gecko. #[cfg(feature = "gecko")] - Display::Contents | Display::ListItem if _is_root_element => - { - Display::Block - }, + Display::Contents | Display::ListItem if _is_root_element => Display::Block, // These are not changed by blockification. Display::None | Display::Block | Display::Flex | Display::ListItem | Display::Table => { @@ -747,7 +744,9 @@ impl Parse for Contain { let flag = match flag { Some(flag) if !result.contains(flag) => flag, _ => { - return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name))) + return Err( + input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name)) + ); }, }; result.insert(flag); @@ -826,7 +825,7 @@ impl Parse for TransitionProperty { location, ident, &["none"], - )?)) + )?)); }, }; @@ -1309,7 +1308,7 @@ impl BreakBetween { Ok(v) => v, Err(()) => { return Err(location - .new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone()))) + .new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone()))); }, }; match break_value { diff --git a/servo/components/style/values/specified/calc.rs b/servo/components/style/values/specified/calc.rs index 6abb94b946c7..2fe00ff8799a 100644 --- a/servo/components/style/values/specified/calc.rs +++ b/servo/components/style/values/specified/calc.rs @@ -180,7 +180,7 @@ impl CalcNode { ) => { return NoCalcLength::parse_dimension(context, value, unit) .map(CalcNode::Length) - .map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError)) + .map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError)); }, ( &Token::Dimension { @@ -204,7 +204,7 @@ impl CalcNode { }, (&Token::Percentage { unit_value, .. }, CalcUnit::LengthOrPercentage) | (&Token::Percentage { unit_value, .. }, CalcUnit::Percentage) => { - return Ok(CalcNode::Percentage(unit_value)) + return Ok(CalcNode::Percentage(unit_value)); }, (&Token::ParenthesisBlock, _) => {}, (&Token::Function(ref name), _) if name.eq_ignore_ascii_case("calc") => {}, diff --git a/servo/components/style/values/specified/counters.rs b/servo/components/style/values/specified/counters.rs index b89d7ebafe0d..6ee6575fc94d 100644 --- a/servo/components/style/values/specified/counters.rs +++ b/servo/components/style/values/specified/counters.rs @@ -181,7 +181,7 @@ impl Parse for Content { None => { return Err(input.new_custom_error( StyleParseErrorKind::UnexpectedFunction(name.clone()), - )) + )); }, } }, diff --git a/servo/components/style/values/specified/font.rs b/servo/components/style/values/specified/font.rs index 9cf97e2879c1..e5699742b140 100644 --- a/servo/components/style/values/specified/font.rs +++ b/servo/components/style/values/specified/font.rs @@ -4,8 +4,6 @@ //! Specified values for font properties -use app_units::Au; -use byteorder::{BigEndian, ByteOrder}; #[cfg(feature = "gecko")] use crate::gecko_bindings::bindings; use crate::parser::{Parse, ParserContext}; @@ -22,6 +20,8 @@ use crate::values::specified::{AllowQuirks, Angle, Integer, LengthOrPercentage}; use crate::values::specified::{NoCalcLength, Number, Percentage}; use crate::values::CustomIdent; use crate::Atom; +use app_units::Au; +use byteorder::{BigEndian, ByteOrder}; use cssparser::{Parser, Token}; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; diff --git a/servo/components/style/values/specified/grid.rs b/servo/components/style/values/specified/grid.rs index cd879e26e48f..8fdaf51b2755 100644 --- a/servo/components/style/values/specified/grid.rs +++ b/servo/components/style/values/specified/grid.rs @@ -22,11 +22,7 @@ pub fn parse_flex<'i, 't>(input: &mut Parser<'i, 't>) -> Result - { - Ok(value) - }, + } if unit.eq_ignore_ascii_case("fr") && value.is_sign_positive() => Ok(value), ref t => Err(location.new_unexpected_token_error(t.clone())), } } diff --git a/servo/components/style/values/specified/image.rs b/servo/components/style/values/specified/image.rs index 53d028e5711b..d4ace9789a28 100644 --- a/servo/components/style/values/specified/image.rs +++ b/servo/components/style/values/specified/image.rs @@ -262,7 +262,7 @@ impl Parse for Gradient { let (shape, repeating, mut compat_mode) = match result { Some(result) => result, None => { - return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(func))) + return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(func))); }, }; @@ -792,7 +792,7 @@ impl LineDirection { CompatMode::WebKit if to_ident.is_ok() => { return Err( i.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("to".into())) - ) + ); }, _ => {}, } diff --git a/servo/components/style/values/specified/length.rs b/servo/components/style/values/specified/length.rs index c447a1cfa3e5..dce643a754f2 100644 --- a/servo/components/style/values/specified/length.rs +++ b/servo/components/style/values/specified/length.rs @@ -7,7 +7,6 @@ //! [length]: https://drafts.csswg.org/css-values/#lengths use super::{AllowQuirks, Number, Percentage, ToComputedValue}; -use app_units::Au; use crate::font_metrics::FontMetricsQueryResult; use crate::parser::{Parse, ParserContext}; use crate::values::computed::{self, CSSPixelLength, Context, ExtremumLength}; @@ -17,6 +16,7 @@ use crate::values::generics::transform::IsZeroLength; use crate::values::generics::NonNegative; use crate::values::specified::calc::CalcNode; use crate::values::{Auto, CSSFloat, Either, IsAuto, Normal}; +use app_units::Au; use cssparser::{Parser, Token}; use euclid::Size2D; use std::cmp; @@ -601,12 +601,10 @@ impl Length { match *token { Token::Dimension { value, ref unit, .. - } - if num_context.is_ok(context.parsing_mode, value) => - { + } if num_context.is_ok(context.parsing_mode, value) => { return NoCalcLength::parse_dimension(context, value, unit) .map(Length::NoCalc) - .map_err(|()| location.new_unexpected_token_error(token.clone())) + .map_err(|()| location.new_unexpected_token_error(token.clone())); }, Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => { if value != 0. && @@ -800,20 +798,18 @@ impl LengthOrPercentage { match *token { Token::Dimension { value, ref unit, .. - } - if num_context.is_ok(context.parsing_mode, value) => - { + } if num_context.is_ok(context.parsing_mode, value) => { return NoCalcLength::parse_dimension(context, value, unit) .map(LengthOrPercentage::Length) - .map_err(|()| location.new_unexpected_token_error(token.clone())) + .map_err(|()| location.new_unexpected_token_error(token.clone())); }, Token::Percentage { unit_value, .. } if num_context.is_ok(context.parsing_mode, unit_value) => { return Ok(LengthOrPercentage::Percentage(computed::Percentage( unit_value, - ))) - }, + ))); + } Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => { if value != 0. && !context.parsing_mode.allows_unitless_lengths() && @@ -932,20 +928,18 @@ impl LengthOrPercentageOrAuto { match *token { Token::Dimension { value, ref unit, .. - } - if num_context.is_ok(context.parsing_mode, value) => - { + } if num_context.is_ok(context.parsing_mode, value) => { return NoCalcLength::parse_dimension(context, value, unit) .map(LengthOrPercentageOrAuto::Length) - .map_err(|()| location.new_unexpected_token_error(token.clone())) + .map_err(|()| location.new_unexpected_token_error(token.clone())); }, Token::Percentage { unit_value, .. } if num_context.is_ok(context.parsing_mode, unit_value) => { return Ok(LengthOrPercentageOrAuto::Percentage(computed::Percentage( unit_value, - ))) - }, + ))); + } Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => { if value != 0. && !context.parsing_mode.allows_unitless_lengths() && @@ -958,7 +952,7 @@ impl LengthOrPercentageOrAuto { ))); }, Token::Ident(ref value) if value.eq_ignore_ascii_case("auto") => { - return Ok(LengthOrPercentageOrAuto::Auto) + return Ok(LengthOrPercentageOrAuto::Auto); }, Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {}, _ => return Err(location.new_unexpected_token_error(token.clone())), @@ -1098,20 +1092,18 @@ impl LengthOrPercentageOrNone { match *token { Token::Dimension { value, ref unit, .. - } - if num_context.is_ok(context.parsing_mode, value) => - { + } if num_context.is_ok(context.parsing_mode, value) => { return NoCalcLength::parse_dimension(context, value, unit) .map(LengthOrPercentageOrNone::Length) - .map_err(|()| location.new_unexpected_token_error(token.clone())) + .map_err(|()| location.new_unexpected_token_error(token.clone())); }, Token::Percentage { unit_value, .. } if num_context.is_ok(context.parsing_mode, unit_value) => { return Ok(LengthOrPercentageOrNone::Percentage(computed::Percentage( unit_value, - ))) - }, + ))); + } Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => { if value != 0. && !context.parsing_mode.allows_unitless_lengths() && @@ -1125,7 +1117,7 @@ impl LengthOrPercentageOrNone { }, Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {}, Token::Ident(ref value) if value.eq_ignore_ascii_case("none") => { - return Ok(LengthOrPercentageOrNone::None) + return Ok(LengthOrPercentageOrNone::None); }, _ => return Err(location.new_unexpected_token_error(token.clone())), } diff --git a/servo/components/style/values/specified/mod.rs b/servo/components/style/values/specified/mod.rs index 5d80fc585603..a73252bbeb67 100644 --- a/servo/components/style/values/specified/mod.rs +++ b/servo/components/style/values/specified/mod.rs @@ -138,7 +138,7 @@ fn parse_number_with_clamping_mode<'i, 't>( return Ok(Number { value: value.min(f32::MAX).max(f32::MIN), calc_clamping_mode: None, - }) + }); }, Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {}, ref t => return Err(location.new_unexpected_token_error(t.clone())), @@ -828,7 +828,7 @@ impl Attr { Some(ns) => ns, None => { return Err(location - .new_custom_error(StyleParseErrorKind::UnspecifiedError)) + .new_custom_error(StyleParseErrorKind::UnspecifiedError)); }, }; Some((prefix, ns)) diff --git a/servo/components/style/values/specified/source_size_list.rs b/servo/components/style/values/specified/source_size_list.rs index fd07dc8007fd..b27bc2875a6e 100644 --- a/servo/components/style/values/specified/source_size_list.rs +++ b/servo/components/style/values/specified/source_size_list.rs @@ -4,13 +4,13 @@ //! https://html.spec.whatwg.org/multipage/#source-size-list -use app_units::Au; #[cfg(feature = "gecko")] use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use crate::media_queries::{Device, MediaCondition}; use crate::parser::{Parse, ParserContext}; use crate::values::computed::{self, ToComputedValue}; use crate::values::specified::{Length, NoCalcLength, ViewportPercentageLength}; +use app_units::Au; use cssparser::{Delimiter, Parser, Token}; use selectors::context::QuirksMode; use style_traits::ParseError; @@ -118,7 +118,7 @@ impl SourceSizeList { return Self { source_sizes, value: Some(value), - } + }; }, Ok(SourceSizeOrLength::SourceSize(source_size)) => { source_sizes.push(source_size); diff --git a/servo/components/style/values/specified/text.rs b/servo/components/style/values/specified/text.rs index 4733864f7bdc..3a5663c4bfd1 100644 --- a/servo/components/style/values/specified/text.rs +++ b/servo/components/style/values/specified/text.rs @@ -91,8 +91,7 @@ impl Parse for LineHeight { match ident { ref ident if ident.eq_ignore_ascii_case("normal") => Ok(GenericLineHeight::Normal), #[cfg(feature = "gecko")] - ref ident if ident.eq_ignore_ascii_case("-moz-block-height") => - { + ref ident if ident.eq_ignore_ascii_case("-moz-block-height") => { Ok(GenericLineHeight::MozBlockHeight) }, ident => { diff --git a/servo/components/style/values/specified/time.rs b/servo/components/style/values/specified/time.rs index 22ef8053cca7..740232f5cbc7 100644 --- a/servo/components/style/values/specified/time.rs +++ b/servo/components/style/values/specified/time.rs @@ -92,12 +92,10 @@ impl Time { // ParsingMode::DEFAULT directly. Ok(&Token::Dimension { value, ref unit, .. - }) - if clamping_mode.is_ok(ParsingMode::DEFAULT, value) => - { + }) if clamping_mode.is_ok(ParsingMode::DEFAULT, value) => { return Time::parse_dimension(value, unit, /* from_calc = */ false) .map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError)); - } + }, Ok(&Token::Function(ref name)) if name.eq_ignore_ascii_case("calc") => {}, Ok(t) => return Err(location.new_unexpected_token_error(t.clone())), Err(e) => return Err(e.into()), diff --git a/servo/components/style_derive/cg.rs b/servo/components/style_derive/cg.rs index 7508bad9a8be..b963e326c045 100644 --- a/servo/components/style_derive/cg.rs +++ b/servo/components/style_derive/cg.rs @@ -172,9 +172,7 @@ fn path_to_ident(path: &Path) -> Option<&Ident> { Path { leading_colon: None, ref segments, - } - if segments.len() == 1 => - { + } if segments.len() == 1 => { if segments[0].arguments.is_empty() { Some(&segments[0].ident) } else { diff --git a/servo/components/style_derive/parse.rs b/servo/components/style_derive/parse.rs index 9042b12d9883..9e3ddccc4539 100644 --- a/servo/components/style_derive/parse.rs +++ b/servo/components/style_derive/parse.rs @@ -43,7 +43,7 @@ pub fn derive(input: DeriveInput) -> TokenStream { saw_condition |= parse_attrs.condition.is_some(); let condition = match parse_attrs.condition { Some(ref p) => quote! { if #p(context) }, - None => quote!{}, + None => quote! {}, }; let mut body = quote! { diff --git a/servo/components/style_traits/lib.rs b/servo/components/style_traits/lib.rs index 9984854ea495..09f5997da8ac 100644 --- a/servo/components/style_traits/lib.rs +++ b/servo/components/style_traits/lib.rs @@ -48,10 +48,7 @@ pub enum DevicePixel {} /// Represents a mobile style pinch zoom factor. /// TODO(gw): Once WR supports pinch zoom, use a type directly from webrender_api. #[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr( - feature = "servo", - derive(Deserialize, Serialize, MallocSizeOf) -)] +#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, MallocSizeOf))] pub struct PinchZoomFactor(f32); impl PinchZoomFactor { diff --git a/servo/components/style_traits/viewport.rs b/servo/components/style_traits/viewport.rs index f9fb57526994..f1aa18412e32 100644 --- a/servo/components/style_traits/viewport.rs +++ b/servo/components/style_traits/viewport.rs @@ -28,10 +28,7 @@ define_css_keyword_enum! { /// /// #[derive(Clone, Debug, PartialEq)] -#[cfg_attr( - feature = "servo", - derive(Deserialize, Serialize, MallocSizeOf) -)] +#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, MallocSizeOf))] pub struct ViewportConstraints { /// Width and height: /// * https://drafts.csswg.org/css-device-adapt/#width-desc