diff --git a/components/style/gecko/media_features.rs b/components/style/gecko/media_features.rs index 90ee3867ea1..37d667896cc 100644 --- a/components/style/gecko/media_features.rs +++ b/components/style/gecko/media_features.rs @@ -107,7 +107,12 @@ fn eval_aspect_ratio( query_value: Option, range_or_operator: Option, ) -> bool { - eval_aspect_ratio_for(device, query_value, range_or_operator, Device::au_viewport_size) + eval_aspect_ratio_for( + device, + query_value, + range_or_operator, + Device::au_viewport_size, + ) } /// https://drafts.csswg.org/mediaqueries-4/#device-aspect-ratio @@ -244,7 +249,8 @@ fn eval_monochrome( range_or_operator: Option, ) -> bool { // For color devices we should return 0. - let depth = unsafe { bindings::Gecko_MediaFeatures_GetMonochromeBitsPerPixel(device.document()) }; + let depth = + unsafe { bindings::Gecko_MediaFeatures_GetMonochromeBitsPerPixel(device.document()) }; RangeOrOperator::evaluate(range_or_operator, query_value, depth) } diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 08425f22059..a116121a258 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -4,12 +4,12 @@ //! Gecko's media-query device and expression representation. +use crate::context::QuirksMode; use crate::custom_properties::CssEnvironment; use crate::gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor}; use crate::gecko_bindings::bindings; use crate::gecko_bindings::structs; use crate::media_queries::MediaType; -use crate::context::QuirksMode; use crate::properties::ComputedValues; use crate::string_cache::Atom; use crate::values::computed::Length; @@ -20,8 +20,8 @@ use cssparser::RGBA; use euclid::default::Size2D; use euclid::{Scale, SideOffsets2D}; use servo_arc::Arc; -use std::{cmp, fmt}; use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; +use std::{cmp, fmt}; use style_traits::viewport::ViewportConstraints; use style_traits::{CSSPixel, DevicePixel}; @@ -275,7 +275,7 @@ impl Device { }; if pc.mIsRootPaginatedDocument() != 0 { - return self.page_size_minus_default_margin(pc) + return self.page_size_minus_default_margin(pc); } let size = &pc.mSizeForViewportUnits; diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index 4e552e439e9..a9083581234 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -184,12 +184,13 @@ impl NonTSPseudoClass { /// revalidation. pub fn needs_cache_revalidation(&self) -> bool { self.state_flag().is_empty() && - !matches!(*self, - // :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(_) | + !matches!( + *self, + // :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 diff --git a/components/style/gecko/snapshot_helpers.rs b/components/style/gecko/snapshot_helpers.rs index 8d99f84a958..3cb325bb6b1 100644 --- a/components/style/gecko/snapshot_helpers.rs +++ b/components/style/gecko/snapshot_helpers.rs @@ -52,7 +52,7 @@ unsafe fn get_class_or_part_from_attr(attr: &structs::nsAttrValue) -> Class { .mAtomArray .as_ref(); let array = array as *const structs::nsTArray>; - return Class::More(&**array) + return Class::More(&**array); } debug_assert_eq!(base_type, structs::nsAttrValue_ValueBaseType_eStringBase); Class::None diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index 00f4ed8266b..8cf4aa51c0a 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -109,7 +109,11 @@ impl CssUrlData { /// Returns true if this URL looks like a fragment. /// See https://drafts.csswg.org/css-values/#local-urls pub fn is_fragment(&self) -> bool { - self.as_str().as_bytes().iter().next().map_or(false, |b| *b == b'#') + self.as_str() + .as_bytes() + .iter() + .next() + .map_or(false, |b| *b == b'#') } /// Return the unresolved url as string, or the empty string if it's @@ -291,9 +295,7 @@ impl SpecifiedImageUrl { cors_mode: CorsMode, ) -> Result> { Ok(SpecifiedImageUrl(SpecifiedUrl::parse_with_cors_mode( - context, - input, - cors_mode, + context, input, cors_mode, )?)) } } diff --git a/components/style/parser.rs b/components/style/parser.rs index f306e2f3838..837b9740024 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -188,7 +188,7 @@ where impl Parse for Box where - T: Parse + T: Parse, { fn parse<'i, 't>( context: &ParserContext, diff --git a/components/style/selector_parser.rs b/components/style/selector_parser.rs index 52675abf45a..e3841c15482 100644 --- a/components/style/selector_parser.rs +++ b/components/style/selector_parser.rs @@ -75,7 +75,8 @@ impl<'a> SelectorParser<'a> { /// Whether we're parsing selectors in a stylesheet that has chrome /// privilege. pub fn chrome_rules_enabled(&self) -> bool { - self.url_data.map_or(false, |d| d.chrome_rules_enabled()) || self.stylesheet_origin == Origin::User + self.url_data.map_or(false, |d| d.chrome_rules_enabled()) || + self.stylesheet_origin == Origin::User } } diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs index cc0c4a21d72..13599c6630a 100644 --- a/components/style/style_adjuster.rs +++ b/components/style/style_adjuster.rs @@ -169,14 +169,14 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { /// NOTE: If this or the pointer-events tweak is removed, then /// minimal-xul.css and the scrollbar style caching need to be tweaked. fn adjust_for_inert(&mut self) { + use crate::values::specified::ui::CursorKind; + use crate::values::specified::ui::UserSelect; use properties::longhands::_moz_inert::computed_value::T as Inert; use properties::longhands::_moz_user_focus::computed_value::T as UserFocus; use properties::longhands::_moz_user_input::computed_value::T as UserInput; use properties::longhands::_moz_user_modify::computed_value::T as UserModify; - use properties::longhands::pointer_events::computed_value::T as PointerEvents; use properties::longhands::cursor::computed_value::T as Cursor; - use crate::values::specified::ui::CursorKind; - use crate::values::specified::ui::UserSelect; + use properties::longhands::pointer_events::computed_value::T as PointerEvents; let needs_update = { let ui = self.style.get_inherited_ui(); diff --git a/components/style/style_resolver.rs b/components/style/style_resolver.rs index 70ac1b3b4d3..7c28e001403 100644 --- a/components/style/style_resolver.rs +++ b/components/style/style_resolver.rs @@ -139,13 +139,17 @@ fn eager_pseudo_is_definitely_not_generated( return false; } - if !style.flags.intersects(ComputedValueFlags::DISPLAY_DEPENDS_ON_INHERITED_STYLE) && + if !style + .flags + .intersects(ComputedValueFlags::DISPLAY_DEPENDS_ON_INHERITED_STYLE) && style.get_box().clone_display() == Display::None { return true; } - if !style.flags.intersects(ComputedValueFlags::CONTENT_DEPENDS_ON_INHERITED_STYLE) && + if !style + .flags + .intersects(ComputedValueFlags::CONTENT_DEPENDS_ON_INHERITED_STYLE) && style.ineffective_content_property() { return true; diff --git a/components/style/stylesheet_set.rs b/components/style/stylesheet_set.rs index fe743025419..9e858a4566c 100644 --- a/components/style/stylesheet_set.rs +++ b/components/style/stylesheet_set.rs @@ -5,11 +5,13 @@ //! A centralized set of stylesheets for a document. use crate::dom::TElement; -use crate::invalidation::stylesheets::{StylesheetInvalidationSet, RuleChangeKind}; +use crate::invalidation::stylesheets::{RuleChangeKind, StylesheetInvalidationSet}; use crate::media_queries::Device; use crate::selector_parser::SnapshotMap; use crate::shared_lock::SharedRwLockReadGuard; -use crate::stylesheets::{CssRule, Origin, OriginSet, OriginSetIterator, PerOrigin, StylesheetInDocument}; +use crate::stylesheets::{ + CssRule, Origin, OriginSet, OriginSetIterator, PerOrigin, StylesheetInDocument, +}; use std::{mem, slice}; /// Entry for a StylesheetSet. @@ -465,9 +467,9 @@ macro_rules! sheet_set_methods { // Insertion / Removals need to rebuild both the cascade and // invalidation data. For generic changes this is conservative, // could be optimized on a per-case basis. - RuleChangeKind::Generic | - RuleChangeKind::Insertion | - RuleChangeKind::Removal => DataValidity::FullyInvalid, + RuleChangeKind::Generic | RuleChangeKind::Insertion | RuleChangeKind::Removal => { + DataValidity::FullyInvalid + }, // TODO(emilio): This, in theory, doesn't need to invalidate // style data, if the rule we're modifying is actually in the // CascadeData already. @@ -536,9 +538,9 @@ where /// Returns whether the given set has changed from the last flush. pub fn has_changed(&self) -> bool { !self.invalidations.is_empty() || - self.collections - .iter_origins() - .any(|(collection, _)| collection.dirty) + self.collections + .iter_origins() + .any(|(collection, _)| collection.dirty) } /// Flush the current set, unmarking it as dirty, and returns a diff --git a/components/style/stylesheets/document_rule.rs b/components/style/stylesheets/document_rule.rs index 736dddb502e..c4e70855801 100644 --- a/components/style/stylesheets/document_rule.rs +++ b/components/style/stylesheets/document_rule.rs @@ -206,8 +206,12 @@ impl DocumentMatchingFunction { DocumentMatchingFunction::MediaDocument(_) => { GeckoDocumentMatchingFunction::MediaDocument }, - DocumentMatchingFunction::PlainTextDocument(..) => GeckoDocumentMatchingFunction::PlainTextDocument, - DocumentMatchingFunction::UnobservableDocument(..) => GeckoDocumentMatchingFunction::UnobservableDocument, + DocumentMatchingFunction::PlainTextDocument(..) => { + GeckoDocumentMatchingFunction::PlainTextDocument + }, + DocumentMatchingFunction::UnobservableDocument(..) => { + GeckoDocumentMatchingFunction::UnobservableDocument + }, }; let pattern = nsCStr::from(match *self { diff --git a/components/style/stylesheets/font_feature_values_rule.rs b/components/style/stylesheets/font_feature_values_rule.rs index 8417497acba..98eef923f7e 100644 --- a/components/style/stylesheets/font_feature_values_rule.rs +++ b/components/style/stylesheets/font_feature_values_rule.rs @@ -20,7 +20,7 @@ use crate::values::serialize_atom_identifier; use crate::Atom; use cssparser::{AtRuleParser, AtRuleType, BasicParseErrorKind, CowRcStr}; use cssparser::{DeclarationListParser, DeclarationParser, Parser}; -use cssparser::{QualifiedRuleParser, RuleListParser, SourceLocation, ParserState, Token}; +use cssparser::{ParserState, QualifiedRuleParser, RuleListParser, SourceLocation, Token}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; diff --git a/components/style/stylesheets/keyframes_rule.rs b/components/style/stylesheets/keyframes_rule.rs index a35d3d2d623..ad53ac6d667 100644 --- a/components/style/stylesheets/keyframes_rule.rs +++ b/components/style/stylesheets/keyframes_rule.rs @@ -17,7 +17,9 @@ use crate::str::CssStringWriter; use crate::stylesheets::rule_parser::VendorPrefix; use crate::stylesheets::{CssRuleType, StylesheetContents}; use crate::values::{serialize_percentage, KeyframesName}; -use cssparser::{parse_one_rule, DeclarationListParser, DeclarationParser, ParserState, SourceLocation, Token}; +use cssparser::{ + parse_one_rule, DeclarationListParser, DeclarationParser, ParserState, SourceLocation, Token, +}; use cssparser::{AtRuleParser, CowRcStr, Parser, ParserInput, QualifiedRuleParser, RuleListParser}; use servo_arc::Arc; use std::fmt::{self, Write}; diff --git a/components/style/stylesheets/mod.rs b/components/style/stylesheets/mod.rs index 724a54ff127..fd9be56b5b5 100644 --- a/components/style/stylesheets/mod.rs +++ b/components/style/stylesheets/mod.rs @@ -57,7 +57,9 @@ pub use self::page_rule::PageRule; pub use self::rule_list::{CssRules, CssRulesHelpers}; pub use self::rule_parser::{InsertRuleContext, State, TopLevelRuleParser}; pub use self::rules_iterator::{AllRules, EffectiveRules}; -pub use self::rules_iterator::{NestedRuleIterationCondition, EffectiveRulesIterator, RulesIterator}; +pub use self::rules_iterator::{ + EffectiveRulesIterator, NestedRuleIterationCondition, RulesIterator, +}; pub use self::style_rule::StyleRule; pub use self::stylesheet::{AllowImportRules, SanitizationData, SanitizationKind}; pub use self::stylesheet::{DocumentStyleSheet, Namespaces, Stylesheet}; diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index 4150f9936f1..df4a2c0631c 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -27,7 +27,7 @@ use crate::values::computed::font::FamilyName; use crate::values::{CssUrl, CustomIdent, KeyframesName}; use crate::{Namespace, Prefix}; use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser}; -use cssparser::{BasicParseError, BasicParseErrorKind, CowRcStr, SourcePosition, ParserState}; +use cssparser::{BasicParseError, BasicParseErrorKind, CowRcStr, ParserState, SourcePosition}; use selectors::SelectorList; use servo_arc::Arc; use style_traits::{ParseError, StyleParseErrorKind}; @@ -482,7 +482,12 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { ); Ok(CssRule::FontFeatureValues(Arc::new(self.shared_lock.wrap( - FontFeatureValuesRule::parse(&context, input, family_names, start.source_location()), + FontFeatureValuesRule::parse( + &context, + input, + family_names, + start.source_location(), + ), )))) }, AtRuleBlockPrelude::CounterStyle(name) => { @@ -492,9 +497,12 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { self.namespaces, ); - Ok(CssRule::CounterStyle(Arc::new(self.shared_lock.wrap( - parse_counter_style_body(name, &context, input, start.source_location())?.into(), - )))) + Ok(CssRule::CounterStyle(Arc::new( + self.shared_lock.wrap( + parse_counter_style_body(name, &context, input, start.source_location())? + .into(), + ), + ))) }, AtRuleBlockPrelude::Media(media_queries) => { Ok(CssRule::Media(Arc::new(self.shared_lock.wrap(MediaRule { diff --git a/components/style/stylesheets/rules_iterator.rs b/components/style/stylesheets/rules_iterator.rs index ad3aa97590d..cc52a9550be 100644 --- a/components/style/stylesheets/rules_iterator.rs +++ b/components/style/stylesheets/rules_iterator.rs @@ -130,7 +130,13 @@ where }; let mut effective = true; - let children = children_of_rule::(rule, self.device, self.quirks_mode, self.guard, &mut effective); + let children = children_of_rule::( + rule, + self.device, + self.quirks_mode, + self.guard, + &mut effective, + ); if !effective { continue; } @@ -197,7 +203,7 @@ impl EffectiveRules { ) -> bool { match *rule { CssRule::Import(ref import_rule) => { - let import_rule = import_rule.read_with(guard); + let import_rule = import_rule.read_with(guard); Self::process_import(guard, device, quirks_mode, import_rule) }, CssRule::Document(ref doc_rule) => { diff --git a/components/style/stylesheets/stylesheet.rs b/components/style/stylesheets/stylesheet.rs index 8a9fd7db7cd..41c80c3cc66 100644 --- a/components/style/stylesheets/stylesheet.rs +++ b/components/style/stylesheets/stylesheet.rs @@ -243,7 +243,12 @@ pub trait StylesheetInDocument: ::std::fmt::Debug { where C: NestedRuleIterationCondition, { - RulesIterator::new(device, self.quirks_mode(guard), guard, self.rules(guard).iter()) + RulesIterator::new( + device, + self.quirks_mode(guard), + guard, + self.rules(guard).iter(), + ) } /// Returns whether the style-sheet applies for the current device. diff --git a/components/style/stylesheets/viewport_rule.rs b/components/style/stylesheets/viewport_rule.rs index b4edeadd4bc..a62b7a5bbf1 100644 --- a/components/style/stylesheets/viewport_rule.rs +++ b/components/style/stylesheets/viewport_rule.rs @@ -16,8 +16,8 @@ use crate::properties::StyleBuilder; use crate::rule_cache::RuleCacheConditions; use crate::shared_lock::{SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard}; use crate::str::CssStringWriter; -use crate::stylesheets::{Origin, StylesheetInDocument}; use crate::stylesheets::cascading_at_rule::DescriptorDeclaration; +use crate::stylesheets::{Origin, StylesheetInDocument}; use crate::values::computed::{Context, ToComputedValue}; use crate::values::generics::length::LengthPercentageOrAuto; use crate::values::generics::NonNegative; diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index 6dbdcf497de..22f5e306976 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -11,9 +11,9 @@ use crate::values::generics::box_::Perspective as GenericPerspective; use crate::values::generics::box_::VerticalAlign as GenericVerticalAlign; use crate::values::specified::box_ as specified; +pub use crate::values::specified::box_::Clear as SpecifiedClear; pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin}; -pub use crate::values::specified::box_::{Clear as SpecifiedClear}; -pub use crate::values::specified::box_::{Float as SpecifiedFloat, Contain, Display, Overflow}; +pub use crate::values::specified::box_::{Contain, Display, Float as SpecifiedFloat, Overflow}; pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox, OverscrollBehavior}; pub use crate::values::specified::box_::{ ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType, diff --git a/components/style/values/computed/font.rs b/components/style/values/computed/font.rs index e0d6f689c31..df6a8ed667e 100644 --- a/components/style/values/computed/font.rs +++ b/components/style/values/computed/font.rs @@ -35,9 +35,9 @@ use style_traits::{CssWriter, ParseError, ToCss}; use to_shmem::{self, SharedMemoryBuilder, ToShmem}; pub use crate::values::computed::Length as MozScriptMinSize; -pub use crate::values::specified::Integer as SpecifiedInteger; pub use crate::values::specified::font::{FontSynthesis, MozScriptSizeMultiplier}; pub use crate::values::specified::font::{XLang, XTextZoom}; +pub use crate::values::specified::Integer as SpecifiedInteger; /// A value for the font-weight property per: /// diff --git a/components/style/values/computed/image.rs b/components/style/values/computed/image.rs index 307b7fa0c2f..5e123a07abb 100644 --- a/components/style/values/computed/image.rs +++ b/components/style/values/computed/image.rs @@ -7,15 +7,15 @@ //! //! [image]: https://drafts.csswg.org/css-images/#image-values -use crate::values::computed::position::Position; use crate::values::computed::percentage::Percentage; +use crate::values::computed::position::Position; use crate::values::computed::url::ComputedImageUrl; #[cfg(feature = "gecko")] use crate::values::computed::NumberOrPercentage; use crate::values::computed::{Angle, Color, Context}; use crate::values::computed::{ AngleOrPercentage, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage, - ToComputedValue, Resolution, + Resolution, ToComputedValue, }; use crate::values::generics::image::{self as generic, GradientCompatMode}; use crate::values::specified::image as specified; @@ -26,7 +26,8 @@ use style_traits::{CssWriter, ToCss}; /// Computed values for an image according to CSS-IMAGES. /// -pub type Image = generic::GenericImage; +pub type Image = + generic::GenericImage; /// Computed values for a CSS gradient. /// @@ -116,7 +117,6 @@ impl ToComputedValue for specified::ImageSet { } } - /// Computed values for `-moz-image-rect(...)`. #[cfg(feature = "gecko")] pub type MozImageRect = generic::GenericMozImageRect; diff --git a/components/style/values/computed/length_percentage.rs b/components/style/values/computed/length_percentage.rs index 22fd9b5f8c3..098b1abfafc 100644 --- a/components/style/values/computed/length_percentage.rs +++ b/components/style/values/computed/length_percentage.rs @@ -265,9 +265,9 @@ impl LengthPercentage { CalcLengthPercentageLeaf::Length(l) => { Self::new_length(Length::new(clamping_mode.clamp(l.px())).normalized()) }, - CalcLengthPercentageLeaf::Percentage(p) => { - Self::new_percent(Percentage(clamping_mode.clamp(crate::values::normalize(p.0)))) - }, + CalcLengthPercentageLeaf::Percentage(p) => Self::new_percent(Percentage( + clamping_mode.clamp(crate::values::normalize(p.0)), + )), } }, _ => Self::new_calc_unchecked(Box::new(CalcLengthPercentage { diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 38ed9cbb90a..a07c51fe210 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -71,7 +71,7 @@ pub use self::list::MozListReversed; pub use self::list::Quotes; pub use self::motion::{OffsetPath, OffsetRotate}; pub use self::outline::OutlineStyle; -pub use self::page::{Orientation, PaperSize, PageSize}; +pub use self::page::{Orientation, PageSize, PaperSize}; pub use self::percentage::{NonNegativePercentage, Percentage}; pub use self::position::AspectRatio; pub use self::position::{ diff --git a/components/style/values/generics/image.rs b/components/style/values/generics/image.rs index b4301cd1b29..bb875b9f32e 100644 --- a/components/style/values/generics/image.rs +++ b/components/style/values/generics/image.rs @@ -59,10 +59,10 @@ pub enum GenericImage pub use self::GenericImage as Image; /// -#[css(comma, function = "cross-fade")] #[derive( Clone, Debug, MallocSizeOf, PartialEq, ToResolvedValue, ToShmem, ToCss, ToComputedValue, )] +#[css(comma, function = "cross-fade")] #[repr(C)] pub struct GenericCrossFade { /// All of the image percent pairings passed as arguments to @@ -74,14 +74,7 @@ pub struct GenericCrossFade { /// A ` | none` value. Represents optional percentage values /// assosicated with cross-fade images. #[derive( - Clone, - Debug, - MallocSizeOf, - PartialEq, - ToComputedValue, - ToResolvedValue, - ToShmem, - ToCss, + Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem, ToCss, )] #[repr(C, u8)] pub enum PercentOrNone { @@ -94,14 +87,7 @@ pub enum PercentOrNone { /// An optional percent and a cross fade image. #[derive( - Clone, - Debug, - MallocSizeOf, - PartialEq, - ToComputedValue, - ToResolvedValue, - ToShmem, - ToCss, + Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem, ToCss, )] #[repr(C)] pub struct GenericCrossFadeElement { @@ -115,15 +101,7 @@ pub struct GenericCrossFadeElement { /// An image or a color. `cross-fade` takes either when blending /// images together. #[derive( - Clone, - Debug, - MallocSizeOf, - PartialEq, - ToComputedValue, - ToResolvedValue, - ToShmem, - ToCss, - Parse, + Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem, ToCss, )] #[repr(C, u8)] pub enum GenericCrossFadeImage { @@ -139,10 +117,8 @@ pub use self::GenericCrossFadeElement as CrossFadeElement; pub use self::GenericCrossFadeImage as CrossFadeImage; /// https://drafts.csswg.org/css-images-4/#image-set-notation +#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToResolvedValue, ToShmem, ToCss)] #[css(comma, function = "image-set")] -#[derive( - Clone, Debug, MallocSizeOf, PartialEq, ToResolvedValue, ToShmem, ToCss, -)] #[repr(C)] pub struct GenericImageSet { /// The index of the selected candidate. Zero for specified values. diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index 21104fd44d3..141e1d056b2 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -496,9 +496,7 @@ where let t = t.to_pixel_length(reference_height)? as f64; Transform3D::translation(0., t, 0.) }, - TranslateZ(ref z) => { - Transform3D::translation(0., 0., z.to_pixel_length(None)? as f64) - }, + TranslateZ(ref z) => Transform3D::translation(0., 0., z.to_pixel_length(None)? as f64), Skew(theta_x, theta_y) => Transform3D::skew( euclid::Angle::radians(theta_x.radians64()), euclid::Angle::radians(theta_y.radians64()), diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs index 93b00b27751..5f45d81d83d 100644 --- a/components/style/values/specified/font.rs +++ b/components/style/values/specified/font.rs @@ -2325,14 +2325,18 @@ impl Parse for MathDepth { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { - if input.try_parse(|i| i.expect_ident_matching("auto-add")).is_ok() { + if input + .try_parse(|i| i.expect_ident_matching("auto-add")) + .is_ok() + { return Ok(MathDepth::AutoAdd); } if let Ok(math_depth_value) = input.try_parse(|input| Integer::parse(context, input)) { return Ok(MathDepth::Absolute(math_depth_value)); } input.expect_function_matching("add")?; - let math_depth_delta_value = input.parse_nested_block(|input| Integer::parse(context, input))?; + let math_depth_delta_value = + input.parse_nested_block(|input| Integer::parse(context, input))?; Ok(MathDepth::Add(math_depth_delta_value)) } } diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs index 2fa8d0bb1ee..51bacdf2ce5 100644 --- a/components/style/values/specified/image.rs +++ b/components/style/values/specified/image.rs @@ -21,7 +21,7 @@ use crate::values::specified::position::{Position, PositionComponent, Side}; use crate::values::specified::url::SpecifiedImageUrl; use crate::values::specified::{ Angle, AngleOrPercentage, Color, Length, LengthPercentage, NonNegativeLength, - NonNegativeLengthPercentage, Resolution + NonNegativeLengthPercentage, Resolution, }; use crate::values::specified::{Number, NumberOrPercentage, Percentage}; use crate::Atom; @@ -36,7 +36,8 @@ use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss}; /// Specified values for an image according to CSS-IMAGES. /// -pub type Image = generic::Image; +pub type Image = + generic::Image; /// Specified values for a CSS gradient. /// @@ -194,7 +195,9 @@ impl Image { if allow_none && input.try_parse(|i| i.expect_ident_matching("none")).is_ok() { return Ok(generic::Image::None); } - if let Ok(url) = input.try_parse(|input| SpecifiedImageUrl::parse_with_cors_mode(context, input, cors_mode)) { + if let Ok(url) = input + .try_parse(|input| SpecifiedImageUrl::parse_with_cors_mode(context, input, cors_mode)) + { return Ok(generic::Image::Url(url)); } if let Ok(gradient) = input.try_parse(|i| Gradient::parse(context, i)) { @@ -218,7 +221,9 @@ impl Image { } #[cfg(feature = "gecko")] { - if let Ok(image_rect) = input.try_parse(|input| MozImageRect::parse(context, input, cors_mode)) { + if let Ok(image_rect) = + input.try_parse(|input| MozImageRect::parse(context, input, cors_mode)) + { return Ok(generic::Image::Rect(Box::new(image_rect))); } Ok(generic::Image::Element(Image::parse_element(input)?)) @@ -254,7 +259,12 @@ impl Image { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { - Self::parse_with_cors_mode(context, input, CorsMode::Anonymous, /* allow_none = */ true) + Self::parse_with_cors_mode( + context, + input, + CorsMode::Anonymous, + /* allow_none = */ true, + ) } } @@ -299,8 +309,10 @@ impl CrossFadeImage { input: &mut Parser<'i, 't>, cors_mode: CorsMode, ) -> Result> { - if let Ok(image) = input.try_parse(|input| Image::parse_with_cors_mode(context, input, cors_mode, /* allow_none = */ false)) { - return Ok(Self::Image(image)) + if let Ok(image) = input.try_parse(|input| { + Image::parse_with_cors_mode(context, input, cors_mode, /* allow_none = */ false) + }) { + return Ok(Self::Image(image)); } Ok(Self::Color(Color::parse(context, input)?)) } @@ -334,7 +346,7 @@ impl ImageSet { })?; Ok(Self { selected_index: 0, - items: items.into() + items: items.into(), }) } } @@ -346,14 +358,19 @@ impl ImageSetItem { cors_mode: CorsMode, ) -> Result> { let image = match input.try_parse(|i| i.expect_url_or_string()) { - Ok(url) => Image::Url(SpecifiedImageUrl::parse_from_string(url.as_ref().into(), context, cors_mode)), - Err(..) => Image::parse_with_cors_mode(context, input, cors_mode, /* allow_none = */ false)?, + Ok(url) => Image::Url(SpecifiedImageUrl::parse_from_string( + url.as_ref().into(), + context, + cors_mode, + )), + Err(..) => Image::parse_with_cors_mode( + context, input, cors_mode, /* allow_none = */ false, + )?, }; - let resolution = input.try_parse(|input| Resolution::parse(context, input)).unwrap_or(Resolution::X(1.0)); - Ok(Self { - image, - resolution, - }) + let resolution = input + .try_parse(|input| Resolution::parse(context, input)) + .unwrap_or(Resolution::X(1.0)); + Ok(Self { image, resolution }) } } diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index d60c5d87f1f..d91f9b8195f 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -70,7 +70,7 @@ pub use self::list::MozListReversed; pub use self::list::Quotes; pub use self::motion::{OffsetPath, OffsetRotate}; pub use self::outline::OutlineStyle; -pub use self::page::{Orientation, PaperSize, PageSize}; +pub use self::page::{Orientation, PageSize, PaperSize}; pub use self::percentage::Percentage; pub use self::position::AspectRatio; pub use self::position::{ @@ -122,8 +122,8 @@ pub mod length; pub mod list; pub mod motion; pub mod outline; -pub mod percentage; pub mod page; +pub mod percentage; pub mod position; pub mod ratio; pub mod rect;